Introduction
RCE Code is a language-agnostic code indexing, search, and retrieval library — the base layer beneath a context engine. It turns a repository into a queryable index and answers with five fused retrieval modalities, locally and offline by default.
RCE Code does one thing on purpose: retrieval over code. It does not do LLM generation, conversation memory, or agent / MCP orchestration — those belong to the layer above. What it hands that layer is a fast, incremental, content-addressed index plus a single Python facade (CodeEngine) and a rce-code CLI to query it.
The five modalities
Every query path is exposed through one small API, and fused where fusion helps. You can reach for a single modality or let hybrid search combine them.
Lexical
SQLite FTS5 BM25 with identifier sub-token expansion, so getUserById matches “user”.
Grep
Live ripgrep over the working tree, aligned to the indexed corpus.
Semantic
Cosine KNN over chunk embeddings — numpy by default, sqlite-vec optional.
Hybrid
Reciprocal Rank Fusion of lexical, semantic, and symbol results.
Structural
Symbol lookup, definition-aligned AST chunks, and a resolved call graph.
Repo Map
Aider-style relevance-ranked map via personalized PageRank, token-budgeted.
How it works
RCE Code parses with tree-sitter and stores everything in a single SQLite database. Indexing is a pure pipeline — walk the repo, parse, chunk along definition boundaries, extract symbols and references, then resolve the call graph — and it is incremental: files are content-hashed, so re-indexing an unchanged tree is nearly free.
- Definition-aligned chunks. The AST chunker never splits a function mid-body; each top-level definition becomes one chunk, with comments attached.
- Single writer, WAL. Parsing happens in pure workers; the parent process is the sole writer, committing one transaction per file.
- Content-addressed. Chunks, symbols, and embeddings are keyed by content hash, so nothing is recomputed unless the code actually changed.
A first taste
Open or create an index, build it, embed, and run a hybrid query: