Skip to main content
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

FAISS and numpy live under the [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 at gaia.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

State is initialised lazily — calling _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.PathValidator to keep file reads scoped to the configured repo_path, and the index_codebase tool refuses any repo_path that isn’t a sub-path of the agent’s original root.

Roadmap

  • #869 — MCP server wrapper exposing the index to external code assistants.
  • #870 — Multi-repo indexing in a single namespace.
  • #871 — Verilog / VHDL parsers.