Repository navigation
code intel
The design-level companion to the Subagent System README — the runtime and API reference for the spawn pipeline, role tool policy, and the
sessions_*tools — and to the Subagent Design page — the two-axis role model (depth role × functional role). This page documents the code retrieval framework those roles use: the tree-sitter symbol index, ast-grep structural search and rewrite, the LSP precise-retrieval tools, and the embedding-backed semantic code search.
Source of truth: agent/tools/code_intel/**, config/features/agent_side/code_intel.py, config/features/agent_side/code_intel_semantic.py, config/features/agent_side/ast_grep.py, config/features/agent_side/lsp.py, config/path.py, agent/tools/subagent/types/functional_role.py, agent/tools/subagent/spawn/core.py, agent/tools/subagent/spawn/system_prompt.py, and agent/tools/subagent/roles/definitions/librarian/AGENTS.md. Every statement below was verified against that code.
- Overview
- Design Invariants
- Layer 0: Keyword Search (ripgrep)
- Layer 1: Tree-sitter Symbol Index
- Layer 2: ast-grep Structural Search & Rewrite
- Layer 3: LSP Precise Retrieval
- Layer 4: Semantic Code Search
- Role Model & Tool Surface
- Configuration
- Environment Capability Matrix
- Limitations & Failure Modes
- Test Map
- Related Documentation
Code Intel answers code-understanding questions with five retrieval engines, each aimed at a different question shape. Four of them are subagent-only; the keyword layer is the one the main agent shares:
| Layer | Question it answers | Tools | Gate |
|---|---|---|---|
| Keyword search | Where does this literal or regex appear — in contents or in file names? | search_files |
main agent + researcher + librarian
|
| Tree-sitter symbol index | Where is a symbol defined, and what calls it? |
explore, callers, callees, impact, path
|
CODE_INTEL_ROLES (researcher / librarian / executor / general) |
| ast-grep | What code has this structural shape, and how do I rewrite it? |
ast_grep_search, ast_grep_rewrite
|
every subagent |
| LSP | What does the type checker know about this position? |
lsp_goto_definition, lsp_find_references, lsp_workspace_symbol, lsp_call_hierarchy, lsp_rename, lsp_diagnostics, lsp_format, lsp_status
|
CODE_INTEL_ROLES |
| Semantic search | Which code implements this concept? | semantic_code_search |
CODE_INTEL_ROLES |
The engines compose into one workflow: explore locates a symbol and its call paths, ast_grep_search finds structural patterns across languages, the LSP tools resolve definitions and references with type awareness, and semantic_code_search retrieves by concept when no name matches. All four are built and injected at child-agent assembly time.
child agent assembly (spawn/core.py)
base tools → role policy (allow / deny / main_only gate)
├─ role ∈ CODE_INTEL_ROLES? → + explore/callers/callees/impact/path (+ semantic_code_search when enabled)
│ + the eight lsp_* tools
└─ always → + ast_grep_search / ast_grep_rewrite
-
The main agent never sees these tools. No code-intel or LSP builder is registered in
_MAIN_TOOLS_BUILDERS; injection happens only inside_build_child_agent, after the role tool policy. -
The tool faces are role-gated. The tree-sitter suite and all eight LSP tools go to
CODE_INTEL_ROLES(researcher,librarian,executor,general); ast-grep goes to every functional role because it is a core structural capability. The four roles share ONE tool face: the read-only roles are told to keeplsp_rename/lsp_formatin preview, while the write roles may apply them (the defaults stay preview). - Fail-open is the contract. A missing binary, an unparseable file, an unavailable model, a timeout, or a refused request returns a JSON payload with an actionable message; no retrieval failure raises into the child turn.
- Everything is bounded by construction. File counts, per-file bytes, build time, batches, result counts, path counts, pattern size, and opened files all have caps; the LSP manager adds an LRU concurrency limit and idle reaping.
-
Writes are opt-in and containment-checked.
ast_grep_rewritepreviews unlessdry_run=false;lsp_renameandlsp_formatpreview unless called with the apply flag; every write path re-validates traversal and project-root containment before touching disk. -
No new LLM provider. BGE remains the text embedder; code-intel uses the
jina-embeddings-v2-base-codeONNX code embedder and the existing reranker wrapper; the only new storage is the SQLite index. -
Roots resolve per call.
SHERRY_CODE_INTEL_ROOT,SHERRY_SG_ROOT, andSHERRY_LSP_ROOToverride the working root for drills and tests; without them the process cwd and the sharedresolve_project_pathgate apply.
search_files is the cheap layer, and the only retrieval tool the main agent
holds: a regex sweep over file contents (target='content') or over file names
(target='files'). It runs on two engines behind one contract — ripgrep when it
resolves, the pure-Python walk otherwise — and which one ran is invisible to the
caller, because the result envelope, the page cut and the three truncation
markers all come from agent/tools/file_tools/search_scan.py's ScanState.
| Property | How |
|---|---|
| Engine |
agent/tools/pub_base/rg_backend.py runs rg --json streamed line by line, with --sort=path for stable paging |
| Fallback | the walk in agent/tools/file_tools/search_files.py serves a host without rg, a pattern the Rust engine cannot express (lookaround, backreference) and every hard rg failure (exit >= 2) |
| Discovery |
agent/tools/pub_base/rg_resolver.py: SHERRY_RG_PATH → the interpreter's own directory and sys.prefix/bin → ~/.sherry/runtime/ripgrep/<slug> → the code-intel bin cache → PATH → Homebrew, each candidate probed with --version
|
| Dependency |
ripgrep-bin, whose platform wheels cover linux aarch64/x86_64/riscv64, macOS both, Windows both — so uv sync puts rg next to the interpreter, and the resolver checks there before PATH because a server started as ./.venv/bin/python -m server has no venv bin on PATH
|
| Bounds | 5.0 s scan budget and 10 000 matches (TOOLS_TIMEOUTS), a page cut one match past offset+limit, and SKIP_DIR_NAMES plus the configured prune dirs translated into --glob exclusions |
| Off the loop | the async path runs the scan in a worker thread |
Measured on this repository: the same content search over the same scope costs
16.6 s with the walk and 1.2 s with ripgrep (2.0 s with --sort=path).
The number that matters is not the speed-up but the budget: the walk cannot
finish a repository-wide pass inside 5 s, so a search for a pattern that is not
there returned scan_stop_reason: "time_budget" — honest, but incomplete.
ripgrep finishes it.
Three traps the implementation had to learn, each pinned by a test:
-
Globs travel as one argv token (
--glob=!**/x/**). Passed bare they become the search pattern and the paths: rg then scans everything, matches the wrong thing and exits 2 — which the fallback hides. - Include globs precede exclusions. rg resolves overlapping globs last-match-wins, so an include placed after the exclusions re-admits the directories those exclusions pruned.
- stderr is drained on a thread with a cap. We block on stdout; a child that fills its stderr pipe would otherwise stall until the watchdog kills it.
The bounded cleanup this shares with the other spawn sites lives in
agent/tools/pub_base/process_reap.py: SIGTERM → wait → SIGKILL → wait →
abandon the handle with a warning, because a child wedged in uninterruptible I/O
(or holding a pipe open through a grandchild) must not turn a timeout into a hang.
Four modules implement the index: agent/tools/code_intel/extract.py (pure bytes → symbols and call sites), agent/tools/code_intel/indexer.py (SQLite persistence and incremental walking), agent/tools/code_intel/query.py (matching and call-graph queries), and agent/tools/code_intel/tools.py (the LangChain wrappers).
| Grammar | Language keys | Extensions | Symbol nodes |
|---|---|---|---|
| Python | python |
.py |
function_definition, class_definition, call
|
| TypeScript |
typescript, tsx
|
.ts, .tsx, .js, .jsx
|
function_declaration, class_declaration, method_definition, variable_declarator (arrow and function expressions), call_expression
|
| Rust | rust |
.rs |
function_item, struct_item, enum_item, trait_item, impl_item, call_expression, macro_invocation
|
| Go | go |
.go |
function_declaration, method_declaration, type_spec (struct_type and interface_type), call_expression
|
The node names and grammar versions were measured against the pinned packages — tree-sitter 0.26.0, tree-sitter-python 0.25.0, tree-sitter-typescript 0.23.2, tree-sitter-rust 0.24.2, tree-sitter-go 0.25.0 — and parsers are constructed as Parser(Language(capsule)). The javascript alias maps to the typescript grammar and jsx to tsx. Three SQLite tables hold the result: symbols, call_edges, and index_meta. The call graph is resolved in a second pass by priority: same file, then same directory, then any global match, then a fuzzy Levenshtein match at distance ≤ 2.
Incrementality and bounds: every file's mtime and size are compared against index_meta; only changed files are re-parsed, removed files are dropped (including detaching inbound resolved edges), and writes are batched in transactions of 100 files. The walk stops at code_intel_index_max_files (5000) or code_intel_index_timeout_s (60) and reports truncated. Fail-open is per file: a syntax-error file, an oversized file (over 1 MB), an unknown extension, or a read error records an index_meta row and is skipped — a syntax-error file is never partially indexed. Mutating calls are serialized by an instance lock, and the connection uses WAL with a 30 s busy timeout.
Queries refresh the incremental index before they read, so a search after edits does not return stale symbols, and an unchanged tree is a cheap no-op. The five tools are:
| Tool | Input | Output | Bound |
|---|---|---|---|
explore |
fuzzy concept, symbol name, or natural-language intent | matched symbols with source, docstring, immediate callers and callees; a suggestion when nothing matches | 10 symbols, 8000 source chars |
callers |
symbol name | every function or method that calls it, with call-site lines | exact name first, fuzzy fallback |
callees |
symbol name | every call the symbol emits, with the resolved target file and line when known | duplicate call sites collapsed |
impact |
symbol name | transitive callers (blast radius), with depth and the name reached through | depth 3, truncated flag |
path |
two symbol names | shortest directed hop sequence across calls/imports/inherits/mixins, each hop with edge type + confidence | depth 3, truncated flag |
The index is refreshed from the project's shadow-git snapshot instead of a full walk whenever possible:
| Layer | Mechanism | Fallback |
|---|---|---|
| Watermark |
index_meta_summary (one row) stores the last indexed shadow HEAD. A matching HEAD short-circuits with an empty IndexResult. |
first index, no shadow store, or a truncated walk |
| Diff |
diff_between_commits_with_status (READ-ONLY) names A/M/D/R/C files between the watermark and the current HEAD; only those are re-parsed, and deleted/renamed old paths are dropped. |
a capped (500) diff, an empty diff, or a git failure |
| External edits | a 20-file sample from index_meta is stat-compared; any mtime/size difference falls back to the full walk (shadow-git only sees agent writes). |
a stat failure also walks |
| Edge resolve | only unresolved edges from the changed files or naming a changed/removed symbol are resolved. | more than 800 filter parameters use the full resolver |
| Query cache | a per-CodeQuery cache keyed by (shadow HEAD, index generation); an external edit moves the generation even though HEAD is unchanged. Bounded to 256 entries. |
no shadow store disables caching |
The original full walk is unchanged and remains the fallback for every case the
fast path cannot prove. IndexResult.total_* counts are lazy (the five
COUNT(*) scans run only when the property is read), and the schema DDL runs
once per indexer instance. Read connections stay per call: the query cache removes the repeated-query cost, and a shared connection has no lifecycle owner (the agent tool set is rebuilt), so it is deliberately not kept open.
The index is no longer call-only. Three parallel tables sit beside call_edges
(which is never altered): import_edges (module-scope rows use
importer_id = 0), inherit_edges (inherit_type = class / interface /
trait) and mixin_edges (implements, Rust trait impls, Go embedding).
CREATE TABLE IF NOT EXISTS upgrades an older DB in place on first open.
| Language | Imports | Inheritance | Mixins |
|---|---|---|---|
| Python |
import a.b, from a.b import c
|
class bases | — |
| TypeScript | default / named / namespace / side-effect |
extends (class, interface) |
implements |
| Rust | use a::b::{c, d} |
trait supertraits | impl Trait for Type |
| Go | import paths | interface embedding | struct embedding |
Resolution stays name-based and two-pass; the new tables prefer the file's own
language, so a TypeScript Base never resolves to a Python Base. Six query
methods expose them: imports_of, importers_of, inherits_from,
subclasses_of, mixins_of, mixins_in_by. callers and callees now carry
confidence: "EXTRACTED" (resolved) or "INFERRED" (name-only) beside the
unchanged resolved bool.
The sixth tool, path(symbol_a, symbol_b), is a directed bidirectional BFS
across all four edge families — forward from A over outgoing edges, backward
from B over incoming edges — bounded by code_intel_call_graph_max_depth. Each
hop carries edge_type (calls / imports / inherits / mixes_in) and
confidence. impact is unchanged: it remains the one-directional caller blast
radius. god_nodes ranks by total resolved degree; communities runs networkx
Louvain on demand (connected components without networkx) and community_of
looks one symbol up.
The same index feeds
skills/builtin/code_wiki/scripts/core.py::export_wiki_from_index, a
deterministic zero-LLM export (README / architecture / modules / class diagram).
sequences.md stays LLM-generated because runtime flow is not in an AST. A
missing index or an unsupported language returns
{"fallback": true, "reason": ...} so the skill's LLM procedure takes over.
ast-grep treats the search pattern as code rather than regex, so $NAME matches one AST node and $$$NAME matches zero or more nodes. The implementation lives in agent/tools/code_intel/ast_grep/: resolver.py (binary discovery), provisioner.py (verified download), install_hints.py (recovery hints), and runner.py (the two tools). The standalone fallback installers are scripts/install.sh and scripts/install.ps1 under the same directory.
Binary discovery is five-tiered, and every candidate must be a non-empty regular file that passes a short --version probe whose output contains ast-grep:
- Explicit override — the
SHERRY_SG_PATHenvironment variable. - Provisioned runtime —
~/.sherry/runtime/ast-grep/<platform>-<arch>/sg. - Code-intel bin cache —
.codeintel/ast-grep/bin(ast-grepthensg). -
PATHlookup —ast-grepthensg, honoring the WindowsPATHEXT. - Homebrew and Linuxbrew prefixes.
When no tier resolves, the first tool call auto-provisions the pinned 0.43.0 release: the per-platform URL and SHA-256 live in config/features/agent_side/ast_grep.py, the download is bounded by a 60 s timeout, a checksum mismatch is fatal (fail-closed — unverified bytes are never installed), and extraction uses the standard-library zipfile module because the host may not have unzip. The real ast-grep binary is preferred over the sg launcher, which re-execs relative to its own path and cannot run in every sandbox; the extracted binary is written atomically with mode 755. Resolution is cached per process while the file still exists.
Both tools run the sg CLI as a subprocess with a scrubbed environment and a 30 s timeout:
| Tool | Behavior | Safety default |
|---|---|---|
ast_grep_search |
sg run --json=stream with --strictness smart by default; returns compact matches (file, 1-based line, text, meta-variables) |
max 50 matches, 64 paths, 16 KiB pattern |
ast_grep_rewrite |
previews the replacement list; applies in place only with dry_run=false (--update-all) |
dry_run defaults to true
|
Every path is screened before the subprocess runs: without an override the canonical resolve_project_path gate is used, and with SHERRY_SG_ROOT set the same traversal predicate plus containment against that root applies — so an applying rewrite can only ever write inside the project.
The LSP layer is agent/tools/code_intel/lsp/: protocol.py (URIs, 1-based to 0-based positions, result formatting), resolver.py (binary discovery), installer.py (allow-listed auto-install), fallback.py (availability to actionable message), client.py (JSON-RPC over stdio), manager.py (process lifecycle), and tools.py (the eight tools). The tools take line and character as 1-based values and convert to LSP-native 0-based positions internally.
| Tool | Purpose | Default behavior |
|---|---|---|
lsp_goto_definition |
Type-aware jump to a definition | read-only |
lsp_find_references |
All references to a symbol | read-only |
lsp_workspace_symbol |
Fuzzy workspace symbol search | read-only, result count capped |
lsp_call_hierarchy |
Incoming callers or outgoing callees | read-only |
lsp_rename |
Workspace rename | previews a WorkspaceEdit; applies only with dry_run=false
|
lsp_diagnostics |
Errors and warnings for a file | waits for the asynchronous publishDiagnostics notification and reports timed_out
|
lsp_format |
Whole-file or range formatting | previews; applies only with write=true; reports supported=false instead of faking success |
lsp_status |
Honest availability of every configured server | starts nothing |
Discovery mirrors the ast-grep tiers with a marker-gated twist: an explicit absolute path, then repo-local bin directories trusted only when the matching marker file exists beside them (pyproject.toml to .venv/bin, package.json to node_modules/.bin, Cargo.toml to target/debug, go.mod to bin, walking up to the repository root), then the ~/.sherry/runtime/lsp placement, then PATH, then Homebrew. Resolution is cached per (cwd, command, platform).
A language server is a heavy resident subprocess, so the process-level manager bounds it: servers start lazily on the first request for a (language, cwd), at most lsp_max_concurrent_servers (3) live at once with least-recently-used eviction, an idle sweeper reaps servers unused for lsp_idle_shutdown_s (300 s), and shutdown_all runs from an atexit hook — a client never leaves an orphan. Each client frames JSON-RPC with Content-Length, dispatches responses on a reader thread, answers server-to-client requests with an empty result, bounds every wait by a timeout, caps opened files at 32 (closing the oldest), and refuses files over 1 MB.
Availability is a three-state report: available, not_installed (configured but no binary passed discovery — an install hint and the local-install command are returned), or not_configured (language not in lsp_enabled_languages). Every unavailable path returns the tool name, the install hint, and a fallback to explore or terminal (rg/grep). Auto-install is off by default (lsp_auto_install=False); when enabled it executes only the allow-listed command for the requested language, with a 60 s timeout and a scrubbed environment.
Semantic search embeds the Layer 1 symbol table instead of slicing arbitrary line windows, so each vector describes exactly one function, method, or class. agent/tools/code_intel/semantic/chunker.py builds a chunk from a header naming the symbol and its location plus the symbol body (falling back to the stored Layer 1 snippet); agent/tools/code_intel/semantic/indexer.py owns the code_embeddings table; agent/tools/code_intel/semantic/search.py ranks by cosine and optionally reranks.
The index is incremental by construction: it refreshes the symbol index first, drops embeddings whose symbol no longer exists, and embeds only symbols without a vector. Rows are written in batches of 16 (configurable), and a build run embeds at most 1000 chunks, at most 60 per file, each at most 2000 characters. Vectors are packed as array('d') blobs in the code_embeddings table, which also stores the model name and dim; a stored model change or a stored dimension conflict purges the index and rebuilds it in the same call, and a partially embedded index is resumable because already-embedded symbols are skipped. The code-intel semantic layer is optional and code-embedder-only: it uses jina-embeddings-v2-base-code (ONNX, 768d, Apache-2.0) under models/embed_model/code/; BGE remains the text embedder (memory/RAG) and is never used here. semantic_code_search is registered only when CODE_INTEL_SEMANTIC enables a valid profile. It is OFF by default; the Model Config panel's download writes the opt-in marker and enables it (/code-embedder/status, POST /code-embedder/download, DELETE /code-embedder disables).
Search self-heals the index, embeds the query, ranks every stored chunk by pure-Python cosine similarity, keeps a candidate pool of 40, and hands the top candidates to the existing models.build_reranker_model when one is configured. The final page is code_intel_semantic_default_top_k (5) by default, at most 20. Fail-open states are explicit in the payload: no indexed embeddings yields a message to build the index first; an unavailable query model yields a degraded message; an unconfigured reranker silently keeps cosine order with reranked=false; and an index or query dimension mismatch asks for a rebuild instead of scoring nonsense.
CODE_INTEL_ROLES in agent/tools/subagent/types/functional_role.py is the single source of truth for both the tool injection (agent/tools/subagent/spawn/core.py) and the prompt guidance (agent/tools/subagent/spawn/system_prompt.py), so the tool face and its documentation cannot drift apart:
| Functional role | Tree-sitter suite | LSP tools | ast-grep |
|---|---|---|---|
researcher |
yes | yes | yes |
librarian |
yes | yes | yes |
general |
yes | yes | yes |
executor |
yes | yes | yes |
reviewer |
no | no | yes |
The four eligible roles share the same injected tools; the difference is prompt-only. CODE_INTEL_WRITE_ROLES (executor, general) may pass dry_run=false / write=true to apply a rename or formatting edit; researcher / librarian are told never to. Lightweight lookups should be done directly by a write role; a heavy multi-step investigation still belongs in a spawned researcher. The single-hop spawn allow-list is untouched because code-intel tools are local analysis and never spawn a child.
The main agent is outside this table entirely: the builders are never added to _MAIN_TOOLS_BUILDERS, and the isolation tests assert that build_lsp_tools is absent from that list and from the agent.tools namespace. The librarian definition at agent/tools/subagent/roles/definitions/librarian/AGENTS.md documents the intended external-repo workflow — clone with terminal, then index and search with explore and semantic_code_search, and answer with permalinks. search_files is the exception to that gating: it is a main tool (it is in _MAIN_TOOLS_BUILDERS) and researcher / librarian name it in their whitelists, so keyword retrieval is the one search surface the main agent shares with the code-intel roles. The two-axis role model itself (depth role × functional role) is documented in the Subagent Design page, and each role's tool list in the Subagent System README.
| Object | Module | Key knobs (default) |
|---|---|---|
CODE_INTEL |
config/features/agent_side/code_intel.py |
max 5000 files, 1 MB per file, 60 s build budget, batch 100, explore 10 symbols and 8000 chars, call depth 3, fuzzy score 0.3 |
CODE_INTEL_SEMANTIC |
config/features/agent_side/code_intel_semantic.py |
model jina-embeddings-v2-base-code (ONNX, 768d), enabled auto/on/off, top-K 5 (max 20), candidate pool 40, batch 16, 1000 chunks per build, 60 per file, 2000 chars per chunk |
AST_GREP |
config/features/agent_side/ast_grep.py |
pinned 0.43.0, 50 matches, 16 KiB pattern, 30 s run timeout, 64 paths, 60 s provision timeout, 5 s version-probe timeout |
LSP |
config/features/agent_side/lsp.py |
request 10 s, start 15 s, diagnostics 15 s, 3 concurrent servers, 300 s idle shutdown, 50 results, 32 opened files, 1 MB per file, auto-install off |
RIPGREP |
config/features/agent_side/ripgrep.py |
enabled, SHERRY_RG_PATH, runtime dir, 5 s version-probe timeout, 5 s / 5 s reap graces; the scan budget and match cap live in TOOLS_TIMEOUTS
|
CODE_INTEL_ROLES |
agent/tools/subagent/types/functional_role.py |
researcher, librarian, executor, general (CODE_INTEL_WRITE_ROLES = executor, general) |
The index database follows the SESSION's project directory: a spawn indexes into <project_root>/.sherry/codeintel/index.db (agent/tools/code_intel/roots.py::index_db_for_root), so alternating between projects no longer rebuilds one shared index (the stored paths are project-relative and collide across roots). The shared CODE_INTEL_DIR / "index.db" (CODE_INTEL_DIR = APP_HOME / ".codeintel" in config/path.py) stays the fallback for a call with no project root, code_intel_index_db_path pins one explicitly, and SHERRY_CODE_INTEL_DB overrides the path at call time (as does SHERRY_CODE_INTEL_ROOT for the root).
Discovery is not capability: the matrix below is the state measured on the development host on 2026-09-23, and "discovered" means the resolver found a candidate binary — it does not prove the server starts or answers. python is the only language with a real end-to-end smoke; typescript is discovery-only; rust resolves to a rustup shim whose rust-analyzer component is not installed, so a start fails and the tool degrades to the fallback message; the remaining seven languages are not_installed.
| Language | Server command | Discovered on this host | Verification depth |
|---|---|---|---|
python |
basedpyright-langserver --stdio |
yes — repository .venv/bin
|
real smoke: definition, references, diagnostics, rename preview, and status |
typescript |
typescript-language-server --stdio |
yes — PATH
|
discovery only |
rust |
rust-analyzer |
binary yes — toolchain component missing | start degrades to the fallback |
go |
gopls |
no | install hint and fallback |
cpp |
clangd |
no | install hint and fallback |
java |
jdtls |
no | install hint and fallback |
ruby |
ruby-lsp |
no | install hint and fallback |
bash |
bash-language-server start |
no | install hint and fallback |
vue |
vue-language-server --stdio |
no | install hint and fallback |
yaml |
yaml-language-server --stdio |
no | install hint and fallback |
The other three engines on the same host:
| Engine | State | Evidence |
|---|---|---|
| Tree-sitter index | four grammars installed (tree-sitter 0.26.0 family) |
the full code-intel suite passes (299 tests) |
| ast-grep | available from the provisioned runtime tier (ast-grep 0.43.0) |
a basic structural search returns real matches |
| Semantic search |
jina-embeddings-v2-base-code ONNX files present |
the real-embedding smoke returns a relevant symbol for a concept query |
Any machine that lacks these capabilities degrades instead of failing: an unresolved ast-grep triggers the verified auto-provision path, and an unavailable embedding backend makes semantic_code_search return a degraded message pointing back at explore and terminal.
-
The index is caller-triggered and self-healed. There is no background indexer: the first query builds the index, and every query refreshes it incrementally. A large repository pays the build on its first call, bounded by the file and time caps (
truncatedis reported). - File-event auto-sync is not adopted. Semantic search already self-heals the index on every query and the index rebuilds on demand, so a resident file-watcher would add process overhead for a marginal gain.
-
Syntax-error, oversized, and unknown-extension files are skipped, each with an
index_metarow recording the reason; they are never partially indexed. -
Embedding batches reload the model. Each
embed_documentscall loads the backend (the local GGUF loader is invoked per batch), so batching trades load time against peak memory; the per-build and per-file caps keep this bounded. -
An unconfigured reranker only costs ranking quality. Without one, results stay in cosine order and the payload says
reranked=false; with one, a reranker failure also falls back to cosine order. - ast-grep's first use downloads the binary. The provision path is bounded by a 60 s timeout and refuses to install on a checksum mismatch; on an offline or asset-less platform the tool returns install hints instead.
-
LSP servers are heavy. The manager caps them at 2 concurrent, reaps after 300 s idle, and evicts the least-recently-used server; the first request for a language pays the server start, and
lsp_diagnosticsmay returntimed_outwhen a server publishes nothing within its window. -
This host's LSP coverage is partial. Only
pythonandtypescriptare discoverable;rustresolves but cannot start without its toolchain component; the other seven languages need an install. Auto-install is off by default, so a missing server never triggers a package-manager run. -
The keyword layer is budgeted, and its cost tracks the tree.
search_filesstops at 5 s or 10 000 matches and says so; the limits are per call, so the scan budget is a property of the repository (a largelogs/directory counts) rather than of the query. The librarian's tool face isread_file/search_files/terminal/web_searchplus the code-intel suite — external-repo keyword retrieval can use either the structured tool orterminal(rg/grep). -
Writes are two-step by design.
ast_grep_rewrite,lsp_rename, andlsp_formatonly write when explicitly asked to; their previews are the safe default, and applied edits are still containment-checked.
| Area | Tests |
|---|---|
| Symbol index, call graph, and end-to-end queries |
tests/agent/tools/code_intel/test_indexer.py, tests/agent/tools/code_intel/test_query.py, tests/agent/tools/code_intel/test_e2e.py, tests/agent/tools/code_intel/test_integration.py
|
| Shadow fast path, lazy counts, and query cache | tests/agent/tools/code_intel/test_shadow_fast_path.py |
| Index tools and role isolation |
tests/agent/tools/code_intel/test_tools.py, tests/agent/tools/code_intel/test_integration.py
|
| ast-grep discovery, provisioning, and tools |
tests/agent/tools/code_intel/ast_grep/test_resolver.py, tests/agent/tools/code_intel/ast_grep/test_provisioner.py, tests/agent/tools/code_intel/ast_grep/test_runner.py, tests/agent/tools/code_intel/ast_grep/test_install_hints.py, tests/agent/tools/code_intel/ast_grep/test_ast_grep_e2e.py
|
| LSP protocol, resolver, installer, fallback, client, manager, and tools |
tests/agent/tools/code_intel/lsp/test_protocol.py, tests/agent/tools/code_intel/lsp/test_resolver.py, tests/agent/tools/code_intel/lsp/test_installer.py, tests/agent/tools/code_intel/lsp/test_fallback.py, tests/agent/tools/code_intel/lsp/test_client.py, tests/agent/tools/code_intel/lsp/test_manager.py, tests/agent/tools/code_intel/lsp/test_lsp_tools.py, tests/agent/tools/code_intel/lsp/test_lsp_extended.py
|
| LSP role isolation and real smoke |
tests/agent/tools/code_intel/lsp/test_role_isolation.py, tests/agent/tools/code_intel/lsp/test_lsp_smoke.py, tests/agent/tools/code_intel/lsp/test_lsp_e2e.py
|
| Semantic chunking, indexing, search, and smoke |
tests/agent/tools/code_intel/semantic/test_chunker.py, tests/agent/tools/code_intel/semantic/test_indexer.py, tests/agent/tools/code_intel/semantic/test_search.py, tests/agent/tools/code_intel/semantic/test_semantic_e2e.py, tests/agent/tools/code_intel/semantic/test_semantic_smoke.py
|
| Keyword layer: ripgrep vs the walk, discovery, reap |
tests/agent/tools/pub_base/test_rg_resolver.py, tests/agent/tools/pub_base/test_rg_backend.py, tests/agent/tools/pub_base/test_process_reap.py, tests/agent/tools/file_tools/test_search_engines.py, tests/agent/tools/file_tools/test_search_bounds.py
|
| Role wiring and prompt sections |
tests/agent/tools/subagent/types/test_functional_role.py, tests/agent/tools/subagent/roles/test_loader.py, tests/agent/tools/subagent/spawn/test_functional_role_integration.py, tests/agent/tools/subagent/spawn/test_system_prompt_role.py
|
| Page | What it covers |
|---|---|
| Subagent System README | Runtime and API reference: spawn pipeline, registry, and each role's tool list |
| Subagent Design | The two-axis role model (depth role × functional role) and the spawn-privilege guards |
| Context Engine README | The embedding storage and search pattern that the semantic layer reuses |
Generated from the repository's wiki/ tree. Source