Benzi is code intelligence infrastructure for AI models, and the project is hosted on GitHub (https://github.com/oooscoos/Benzi)。其核心思路是:在回答任何问题之前,先用基于 tree-sitter's compiler parses each file, resolves imports, builds class inheritance chains, traces every identifier to its definition, and generates a precise, queryable index instead of stuffing raw source code directly into the model's context window.
Purpose and positioning Benzi is designed to replace the common grep/glob raw-source approach of AI coding agents, using a structured index to let models resolve symbols, call edges, references, and inheritance relationships in O(1) time. Call flow and data flow converge at each call site, making it easy to trace the source of erroneous values.
Main capabilities
- Compile: tree-sitter parses each file, resolves imports, builds class inheritance, traces identifiers to definitions, and outputs an index rather than text.
- Query: agents read and plan through structured tools, such as profile, get_callers, backflow, trace_path, skim_source, and more than 30 other tools.
- Controlled editing: every write is checked by a real parser, and automatically rolled back if parsing fails; before and after editing, the "blast radius" is checked (changed symbols, callers, holders, related tests).
- Run verification: run focused reproductions and tests under a runtime tracer, confirm changes with real values and real dispatch, and converge fuzzy edges to the targets actually triggered.
- Incremental reindexing: each round only re-parses the parts changed on disk.
- Snapshot rollback: snapshot the index before every write, and reload the snapshot when undoing.
- Six states: resolved, external, candidate, unresolved, observed, unindexed; anything static analysis cannot determine is marked as undetermined rather than guessed.
- Runtime tracer: hook every call in Python and overlay observations back onto the static graph.
- Persistent memory: persistent facts saved per repository, retained after restart.
- Dual engine: code index + HTML/CSS/DOM-JS markup index, supporting cascading resolution and selector specificity, including frontend code embedded in Python strings.
- Model-agnostic: supports Anthropic, OpenAI, or any compatible API; the agent can automatically escalate to a larger model when a task exceeds the current model's capabilities (set via the BENZI_ESCALATE_MODEL environment variable, e.g. deepseek-pro).
Usage Benzi is completely free during the beta and offers three usage modes that share the same login configuration:
- VS Code extension: from Install Benzi from the VS Code Marketplace, click the Benzi icon in the left activity bar to open the settings panel, select a model and paste the API key (an Anthropic key or a non-Anthropic key such as DeepSeek, Groq, or Kimi), enter your email and click Send, enter the one-time verification code received by email, click Save model & keys, then Run Benzi.
- Headless CLI (PyPI): supports Python 3.11–3.14 on Windows, macOS, and Linux. Installation command: pip install benzi, which installs the benzi-login, benzi-headless, and benzi-mcp commands. Log in: benzi-login --login you@example.com; set the model and key: benzi-login --model deepseek and benzi-login --nonanthropic-key YOUR_KEY (or benzi-login --anthropic-key YOUR_KEY); run on a repository: benzi-headless . "fix the failing test in parser.py".
- MCP server: exposes the compiled index as tools to existing agents (Claude Code, Cursor, or any MCP client). Install and log in as above; you can skip model and key setup. Register in Claude Code: claude mcp add --scope user benzi -- benzi-mcp; to pin it to a specific repository: claude mcp add --scope user benzi -- benzi-mcp /path/to/your/repo.
Language support Supports ten languages: Python, JavaScript, TypeScript, Java, C#, C++, C, Go, Rust, and Ruby. Each language is integrated into the same query graph as a tree-sitter grammar plugin. Python has the deepest support and is the only language with a runtime tracer; other languages can reach core graph capabilities, but not all of their constructs are modeled yet. C, C++, Rust, and Ruby have less incremental reindexing optimization; they are usable but not fast enough under large edit loops.
Use cases Suitable for scenarios where an AI coding agent needs to precisely locate, explain, modify, and verify code in large codebases, especially for teams that want to reduce the amount of source code read, lower token costs, and improve editing safety. Also suitable for enhancing the code understanding capabilities of existing agents via MCP.
Limitations
- Free during beta; official pricing information is not yet available.
- Support depth varies across languages; some constructs in non-Python languages are not modeled.
- The MCP approach does not include the Benzi agent's own runtime tracing, controlled editing, blast radius, automatic escalation, persistent memory, rollback, and other features; output quality depends on the agent used.
- Code is compiled and indexed locally and is not uploaded; only code snippets actually read by the agent are sent to the model provider.
- The officially published SWE-bench Verified result is 413 resolved out of 500 instances (82.6%), at a total cost of $9.26, or 1.85 cents per task, with 97.6% of input tokens coming from cache, based on DeepSeek V4.1-Flash.