You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
β‘ Mesh: A Modern, Modular and Hackable AI Harness
Developed byFarshid Mossaiby
A modern, modular and hackable AI CLI harness written in Python. Mesh connects to any OpenAI- or Anthropic-compatible model provider and wraps it with a full agentic toolset: file editing, shell access, web search, MCP servers, sub-agent delegation, persistent memory, session save/resume, Markdown logging, automated test-and-repair loops, a comprehensive test suite, and a safety layer that gates risky tool calls β all driven from a single terminal chat loop.
π Key Features
Provider Management via CLI (/providers) β Add, list, test, configure custom headers, or remove model providers directly from the terminal without manual editing of config.json.
Persistent Command History (/history) β Cross-session terminal history persisted on disk in .mesh/history.txt with β / β arrow-key recall and inspection/clearing commands.
Multi-Provider Support with Exponential Backoff & Retry β Talk to OpenAI, Anthropic, Grok, OpenRouter, Ollama, LM Studio, vLLM, DeepSeek, or any OpenAI-compatible REST endpoint, all configured in config.json. Includes customizable exponential backoff with randomized jitter (/config set retry) for resilient API communication.
Concurrent Read-Only Tool Execution β When a model requests multiple tool calls in a turn, contiguous read-only operations (read_file, glob_files, web_search, web_fetch, search_symbols, calculator, git_status, git_diff, memory queries) run in parallel via asyncio.gather(), while mutating actions execute sequentially with strict state safety.
Model Context Protocol Client (/mcps) β Native support for both stdio (subprocesses) and SSE (Server-Sent Events) HTTP transports (mcps.json), allowing seamless integration with local binaries or remote GUI applications (e.g. Blender, databases, web services).
Background Symbol Indexing with Persistent Disk Cache (.mesh/symbols.cache.json) β Polyglot Tree-sitter AST symbol indexing across 11 languages (Python, JS/TS, Rust, Go, C/C++, Java, C#, PHP, Ruby). Caches parsed symbols, line numbers, and docstrings to disk in .mesh/symbols.cache.json with mtime/size validation and runs incremental directory scans asynchronously in a background thread pool without blocking REPL interactions.
Prefix-Cached Context Compaction (/compact) β Compacts older conversation history using in-context prompt evaluation to maximize LLM prompt cache hits (saving up to 90% in token cost and latency), while preserving pinned goals, skills, and active tools.
Accurate Token Accounting with tiktoken β BPE tokenization for OpenAI/Anthropic/OpenRouter models with LRU encoding caching and graceful character-count fallback (CHARS_PER_TOKEN = 4) for precise context threshold triggers and compaction.
IDE Config Auto-Completion & JSON Schema ($schema) β Native Draft 2020-12 JSON Schema generation (config.schema.json and /config schema) provides instant autocomplete, parameter descriptions, and type validation in VS Code, Cursor, JetBrains, and Neovim.
Modular Core Architecture β Clean separation of concerns between InferenceCoordinator (turn loops, streaming, auto-routing, metrics) and ToolOrchestrator (batching, concurrent execution, logging, reflexion).
Disk-Backed Session Save & Resume (/session) β Save full conversation state, goals, todo graph, notes, memory, active mode, metrics, and checkpoints to disk under sessions/<name>.json. Resume anytime with /session load <name>, python main.py --session <name>, or python main.py --resume.
Markdown Session Logging (/log) β Stream clean, structured Markdown transcripts of user prompts, assistant responses, and tool executions to a log file (session.md or custom path) via CLI --log or /log on <path>.
Operating Modes (/mode) β build (full access, default), plan and review (read-only workspace inspection, no writes/shell/delegation/MCP), chat (conversational Q&A, brainstorming, and research with web search, fetch, calculator, advisor, and memory), and yolo (full access, no confirmation prompts for ambiguous-risk actions β high-risk actions are still always blocked).
Safety Guard (/guard) β An LLM-backed risk assessor that reviews tool calls before execution, can run in supervised or autonomous mode, supports per-session tool trust, and always blocks genuinely high-risk actions regardless of mode.
Directory Permissions (/dirs) β A PermissionManager enforces a working-directory allow-list for every file/shell tool. Out-of-bounds access triggers an interactive Allow Once / Always Allow / Deny prompt.
Sub-Agent & Multi-Agent Workflows (/agent) β Spin up focused sub-agents for task delegation (delegate), branching exploration (explore), parallel task squads (squad), multi-model consensus (consensus), and second-opinion advisory review (advisor).
Autonomous Test/Fix Loop (/loop) β Runs a test or build command, and on failure automatically delegates a repair sub-agent to fix the code and retries, up to a configurable number of iterations.
Declarative Skills (/skills) β Package specialized system prompts and tools into reusable skills, loaded from skills.json or custom Python classes (see skills/code_skill.py).
Persistent Memory & Notes β A key-value memory store with semantic search (/memory), a running Markdown notes.md (/note), pinned session goals with completion criteria (/goal), and multi-step task tracking (todo).
Native Tool Suite β File ops (read_file, write_file, edit_file, hash_edit, glob_files), shell execution, key-less web search/fetch, Git tools (git_init, git_status, git_diff, git_commit, git_push, git_branch), a calculator, and an ask_user tool for human-in-the-loop decisions.
Test-Driven Reliability β Automated pytest test suite verifying concurrency partitioning, tool safety, dependency DAGs, file hash drift protection, permission isolation, and session roundtrip persistence.
Rich Terminal UI β Real-time Markdown streaming with syntax highlighting, toggleable Chain-of-Thought display (/debug), and an interactive arrow-key model/menu switcher with context-aware tab completion.
# Start an interactive CLI session
./mesh # Linux / macOS
mesh.bat # Windows# Enable session Markdown logging on launch
python main.py --log session.md
# Resume the most recently saved disk session
python main.py --resume
# Load or create a specific named disk session
python main.py --session my-feature
# Run a script file non-interactively
python main.py path/to/script.txt --non-interactive
π οΈ Slash Commands Reference
Models & Providers
Command
Description
/providers [list|add|remove|test|header] <args>
List, add, remove, test, or configure model providers live from the CLI
/models [discover|add|remove] [<args>]
List, discover, add, or remove configured models
/switch [auto|router|<model_key>]
Switch active model or mode: /switch [auto|router|<model_key>]