SuperAPIAI Directory

vs-token-safer

github.com · AI coding

Routes code search through language-server indexes (clangd, Roslyn, tsserver, pyright) instead of grep, plus symbol-level edits and git/p4 output compaction.

Open website Alternatives
PricingOpen source开源项目(可免费自部署)
PlatformsLinux

About this tool

vs-token-safer is a token-saving code search layer designed for AI coding agents (especially Claude Code). It sits between the coding agent's small context window and large code repositories, replacing traditional grep search with language server indexes or tree-sitter indexes, thereby greatly reducing the number of tokens entering the model context.

Purpose

When a coding agent needs to find the location of a symbol, call relationships, or answer questions like "how does the authentication flow work", traditional grep pastes a large number of source lines into the conversation, quickly filling up the context. vs-token-safer instead returns a short file:line list, along with a one-line completeness note indicating which precision tier the answer came from.

Main capabilities

  • Multi-language support: TypeScript, JavaScript, and Python work with zero configuration; C# and C++ require installing the corresponding language servers (Roslyn, clangd); over 30 other languages are supported via built-in tree-sitter (36 grammars bundled, 19 of which have tuned declaration extraction).
  • Precision ladder: EXACT (official language server, semantic ground truth), SYNTACTIC (tree-sitter parsing, no toolchain required), FUZZY (concept dictionary mined from the repository's own identifiers and comments, no AI model, no upload), SECTION (Markdown/TOML/YAML/CSS/HTML addressed by heading). Tiers can switch automatically, for example after FUZZY finds the real name it climbs to EXACT to confirm.
  • Symbol-level editing: replace/insert/delete declarations by name, with the index providing ranges, without reading the entire file into context. Preview by default, only writes when apply=true.
  • Document and configuration support: for Markdown, AsciiDoc, reST, TOML, INI, YAML, JSON, and text files, a "symbol" can be treated as a section (heading, [section], or key), reading or replacing a section by name without opening the entire file.
  • Change impact analysis: detect_changes maps a git diff to changed symbols, traverses callers, and gives a LOW/MED/HIGH risk score based on impact scope, call cascade depth, and historically co-changed files.
  • grep rewriting: the hook not only blocks grep, it also rewrites the command in place into an index query, so the search runs as usual and the flow is not interrupted. VTS_REWRITE=0 changes this to blocking instead of rewriting.
  • Discovering omissions: vts discover reads recent sessions and reports which searches bypassed the index and what they cost.
  • Local dashboard: vts serve provides an interactive 3D graph at 127.0.0.1, including the include graph (clangd), call graph (live LSP call hierarchy), and symbol graph (tree-sitter files + import edges, no language server required). The page is fully self-contained, with CSS/JS inlined and Three.js vendored locally, so it renders even offline.
  • Log analysis plugin: gamedev-log-analyzer is installed as a dependency, and can analyze large editor and build logs, outputting file:line to hand off to goto_definition/find_references to open the code.
  • Local model orchestration: the optional vts-local-orchestrator lets a local LLM (Ollama, default gemma4:e4b) drive the same vs-search tools, with Claude receiving only the condensed file:line answers.

Usage

After installing as a Claude Code plugin, restart the session (the vs-search MCP server only starts in a new session). Prerequisites: Node ≥ 18, and language servers—clangd (C/C++) and Roslyn (C#) must be installed manually, while JS/TS and Python are installed automatically. If you only need the log analyzer, you can run /plugin install gamedev-log-analyzer@vs-token-safer.

The MCP server is named vs-search and provides the same tools as the vts CLI. Management/meta operations are done through a single MCP tool vts_admin {op, params}, for example vts_admin {op:"git", params:{argv:["status","-s"]}}. You can also hand the entire lookup to the code-locator subagent, which searches in its own context and returns only file:line table.

The dashboard can be opened via the slash command /vs-token-safer:viz, closed via /vs-token-safer:viz-stop, or used via the CLI.

Use cases

  • Large TypeScript/Python monorepos, C#/.NET solutions, Unreal Engine C++ code trees, etc.
  • AI coding workflows that need to frequently locate symbols, view call relationships, and assess the scope of change impact.
  • Claude Code users who want to reduce token consumption and keep context lean.

Limitations

  • Returns the first N results (there is a cap), not all text occurrences; the truncated tail is mostly comments, includes, or substring noise. When exhaustive results are needed, increase maxResults or switch to grep.
  • clangd indexes asynchronously, so the first search has a one-time warm-up cost; the MCP server warms up at startup (enabled by default when projectPath is set) and caches the client.
  • Cold indexing of large monorepos is the main cost, which can be mitigated by limiting the scope to a subtree or pre-indexing (clangd-indexer).
  • The 3D graph node cap is VTS_VIZ_MAX_NODES (200).
  • Everything runs locally; nothing is uploaded.

Performance data

In a benchmark with 3 languages and 150 files, it uses 87% fewer tokens than grep; on a real Unreal Engine 5 code tree, about 99.3% fewer (about 138x). The mock-LSP evaluation (node eval/run.mjs) goes from about 57,308 to 1,515 tokens, a 97.4% reduction. The tree-sitter layer returns the same file:line as clangd EXACT (line difference 0) on a second real UE5 game module (3,143 files, 133,890 symbols), at about 240 milliseconds vs clangd cold start of about 127 seconds.

Up/Down to navigate · Enter to open · ESC to closeBrowse all tools