Skip to content

Code Intelligence

basemind pre-indexes your codebase using tree-sitter, mapping symbols, calls, and imports across 300+ languages. Structural queries resolve in milliseconds (an outline in about a millisecond, symbol and reference lookups in single-digit milliseconds on a 74k-file monorepo; see Performance) and return paths, line numbers, and signatures — not file bodies — so they cost a fraction of the tokens of reading source.

Precise, scope- and import-aware resolution

Section titled “Precise, scope- and import-aware resolution”

Navigation is scope- and import-aware for JavaScript/TypeScript (via oxc) and for Python and Java — via an in-tree, tree-sitter-0.26 fork of GitHub’s stack-graphs engines (vendored under crates/) executing .tsg name-binding rules, with no per-language LSP server. Every other language still gets fast tree-sitter scope binding.

This resolves each use to the definition it actually binds to: a shadowed local isn’t confused with an import, and code_refs with relation: "definition" lands on the right target — including across files, for Python dotted/relative imports and for JS/TS module resolution (Node resolution plus tsconfig paths aliases via oxc_resolver).

Known limitation this release: Java cross-file resolution of a member call on an imported type (Foo.greet()) is not yet resolved — the imported type itself resolves, the method call on it does not.

Toggle with [code_intel] precise_resolution in basemind.toml (default true). Set it to false to fall back to tree-sitter locals binding for every language.

Each job is its own MCP tool with an exact schema; the CLI commands are under basemind code. Every line and column is 1-based. See the MCP tools reference for all arguments.

Get a file’s structure: every symbol with its kind, signature and 1-based line / end_line, plus the file’s imports.

{
"path": "src/store.rs"
}

Returns a table of contents you can scan in seconds instead of reading a thousand-line file. Feed a span to code_read. Code files only.

Find where a symbol is defined, by name, across all indexed files. Results are ranked: exact name, then prefix, then substring, then (with fuzzy: true) fuzzy subsequence. Matching is case-sensitive. Optionally filter by kind (function, method, struct, enum, class, interface, trait, type, const, module, macro).

{
"name": "parse_config",
"kind": "function"
}

Returns path, line and signature for each match.

Read one symbol’s source body, or an exact line span, instead of the whole file. Pass symbol, or line with end_line; not both. Bodies over 128 KiB are cut and flagged truncated, with omitted_bytes saying how much was left out.

{
"path": "src/store.rs",
"symbol": "open"
}
{
"path": "src/store.rs",
"line": 120,
"end_line": 160
}

One tool answers “what calls X”, “what implements X”, “what imports X” and “which definition does this reference bind to”. relation picks the question (default callers).

Call sites of a name. The identifier is matched exactly, with no scope resolution: Foo::bar() and bar() both match name: "bar", and bar_baz() does not. Pass match: "substring" to match longer names too.

{
"name": "open_store"
}

Callers of one definition. path pins the definition in that file. A hit then has resolved: true when resolution proved the binding, resolved: false when it checked and could not, and no resolved when the hit was not checked; resolution says why when nothing could be checked. A pinned file edited since it was indexed is an error naming index_rescan.

{
"name": "open_store",
"path": "src/store.rs"
}

Types that implement or inherit from a name: Rust impl blocks, Python class inheritance, TypeScript/JavaScript class declarations.

{
"name": "Drawable",
"relation": "implementations"
}

Files importing a module (a heuristic reverse lookup over import statements).

{
"name": "tokio::sync",
"relation": "importers"
}

Go-to-definition: resolve the reference name at path:line to the definition it binds to. column (1-based) is optional and defaults to where name occurs on the line. Intra-file resolution uses tree-sitter locals across 80+ languages; JavaScript/TypeScript, Python and Java additionally get precise, scope- and import-aware resolution, including cross-file. See Precise, scope- and import-aware resolution above.

{
"name": "open_store",
"relation": "definition",
"path": "src/main.rs",
"line": 42
}

Call-site lookups are backed by an indexed call-site table and capped by limit (default 100). From a daemon-backed session (the standard deployment) the scan runs in the daemon against the same index, so total and cursors are complete and identical to what a writer session sees; only when no daemon is reachable does a session fall back to an in-RAM projection capped by [resources] max_map_cache_mb, flagged with a projections_capped notice.

Text search over the contents of indexed code files. pattern is literal text unless regex: true (Rust regex syntax). path is a substring of the repo-relative path; a glob is rejected. Each hit has the path, line, the full line text and the enclosing symbol (name, kind); context: true adds one line before and after.

{
"pattern": "cache_root(",
"path": "src/"
}
{
"pattern": "fn \\w+_call",
"regex": true
}

The scanner keeps a small per-file trigram bloom filter (about 12.8 % of the indexed code bytes). A grep skips every file whose filter proves it cannot contain a literal the pattern requires, so on a 74k-file monorepo the 15 benchmark patterns dropped from several seconds to about 130 ms p50 with identical results (ADR-0012). A file is skipped only when its size and mtime still match the scan, so edited, added or deleted files are still searched. Regex patterns with no required 3-byte literal (.*, (?i)k) sweep every file. Set BASEMIND_GREP_BLOOM=0 to force the full sweep. An existing index gains its filters on the next scan; no wipe is needed.

code_grep covers code only. Prose, data and config files (Markdown, JSON, YAML, TOML, …) live in the document tier: search them with docs_search.

Locate a file by a fuzzy fragment of its name or path, or list indexed files when query is omitted. Filter by language or path_prefix. Covers code and documents (markdown, config, PDFs).

{
"query": "readme"
}

Index health and repo identity: file counts per language, scan and degraded state, the cache directory, and the repository’s branch and HEAD. Call it when a result is unexpectedly empty or says “not indexed”.

  • code_outline a file before you open it. A 1000-line file becomes a 30-line table of contents. Then code_read only the symbol or span you need.
  • code_symbols instead of grep for a definition. Returns indexed symbol names and positions, skipping comment/string noise.
  • code_refs instead of grepping call sites. Indexed call edges, not text matches.
  • code_grep instead of shelling out to ripgrep. It searches the indexed code files and returns capped, structured hits with the enclosing symbol.
  • Do not re-read a file basemind already mapped. If the outline answered the question, stop.
  • index_rescan after you edit code, not a server reconnect. Pass paths: [...] to limit it.

Git intelligence · Code search · Document search