Looking for usage docs? See the Code Index guide for CLI walkthroughs and architecture overview.
CodeIndexSDK indexes repository files (no git history, no PRs) using Lemonade Server embeddings and FAISS for vector similarity search. The SDK is exposed to agents via CodeIndexToolsMixin, which is already composed into the built-in CodeAgent.
Installation
[rag] extras. If they’re missing the SDK raises:
CodeIndexConfig
CodeIndexSDK
index_repository() -> IndexResult
Discover source files, parse them, embed via Lemonade, and persist a FAISS index. Re-runs are incremental — unchanged files (matched by SHA-256) reuse their existing embeddings.
search(query, scope="all", top_k=10) -> List[SearchResult]
L2 distance is converted to a similarity score in
[0, 1] via 1 / (1 + dist).
get_status() -> Dict
clear_index()
Removes the FAISS index and metadata for this repo from the cache.
Data types
CodeChunk
SearchResult
IndexResult
Parsers
gaia.code_index.parsers provides language detection and symbol-aware chunking.
Agent integration: CodeIndexToolsMixin
The mixin lives atgaia.agents.tools.code_index_tools.CodeIndexToolsMixin. It exposes four @tool-decorated methods through register_code_index_tools():
CodeAgent already composes this mixin, so gaia-code index chat and any CodeAgent instance get the tools for free.
Composing onto a custom Python agent
_init_code_index_state is optional but recommended so the agent honours the repo path you intended.
CodeIndexToolsMixin is also registered in KNOWN_TOOLS["code_index"] (src/gaia/agents/registry.py) for dynamic composition when scaffolding agents — see the custom-agent guide.
Privacy and safety
- All embeddings are generated locally by Lemonade Server.
- Sensitive filenames are skipped during discovery:
.env,.env.*, SSH private keys,*.pem,*.key,*.pfx,*.p12,*.jks,*.keystore. - The SDK uses
gaia.security.PathValidatorto keep file reads scoped to the configuredrepo_path, and theindex_codebasetool refuses anyrepo_paththat isn’t a sub-path of the agent’s original root.