Looking for usage docs? See the Code Index guide for the flagship-agent skill walkthrough 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 flagship GaiaAgent.
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():
GaiaAgent already composes this mixin, so the flagship agent’s coding skill gets the tools for free — see the Code Index guide.
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.