Skip to main content
Looking for the API? See the Code Index SDK Reference for CodeIndexSDK, CodeIndexConfig, and CodeIndexToolsMixin.
GAIA’s Code Index gives you fast semantic search over a repository without sending source to the cloud. It parses files into symbol-level chunks, embeds them via Lemonade Server on AMD NPU/GPU hardware, and stores them in a local FAISS index for sub-second queries. The index is exposed three ways:
  • CLIgaia-code index ... for build, search, status, clear, and chat.
  • Tool mixinCodeIndexToolsMixin is composed into the built-in CodeAgent and is available to any custom agent that opts in.
  • Python SDKCodeIndexSDK for direct programmatic use.
gh is not required — the index covers source files only.

Overview

AspectDetails
Languages parsedPython (AST), JavaScript, TypeScript, Go, Rust, Java, C, C++
EmbeddingsLocal AMD NPU/GPU via Lemonade Server (nomic-embed-text-v2-moe-GGUF by default)
Vector storeFAISS IndexFlatL2
Cache~/.gaia/code_index/<repo-hash>/ (atomic writes; incremental on file-hash)
PrivacyAll processing local; sensitive files (.env, .pem, .key, …) auto-excluded

Setup

Install the [rag] extras (FAISS + numpy live there):
Start Lemonade Server so embeddings can be generated:
If FAISS or numpy are missing at runtime you’ll see exactly:

CLI usage

Build the index

Common index-level flags (apply to every subcommand):
FlagPurpose
--repo PATHRepository root (default: cwd)
--max-files NCap discovery (default 5000)
--model MLemonade embedding model
--base-url URLLemonade server URL (default http://localhost:13305/api/v1)
--no-lemonade-checkSkip the server reachability check
--use-claude / --use-chatgptCloud LLM for index chat (embeddings still local)
Re-running gaia-code index is incremental: unchanged files (matched by SHA-256) reuse their existing embeddings.
Example queries against a hypothetical service repo:

Inspect and manage

Interactive Q&A

This launches CodeAgent with the CodeIndexToolsMixin already wired in, so the agent can call index_codebase, search_code_index, get_index_status, and clear_code_index autonomously while answering your questions.

Agent integration

CodeAgent ships with the mixin already composed, so gaia-code chat sessions and any CodeAgent instance can call the four code-index tools:
ToolDescription
index_codebaseBuild / refresh the FAISS index
search_code_indexSemantic search over indexed chunks
get_index_statusReport current index state
clear_code_indexRemove the cached index
Custom agents compose CodeIndexToolsMixin directly in their class declaration; it’s also registered in KNOWN_TOOLS["code_index"] (src/gaia/agents/registry.py) for dynamic resolution. For SDK-level composition see the SDK reference.

Example interaction

Cache layout

Both files are written atomically (temp file + rename). The cache is keyed by the resolved repo path. If you switch embedding models the metadata mismatch is detected and search returns empty until you re-index.

Privacy

All processing is local. No source code is sent to external services. Sensitive filenames are skipped automatically: .env, .env.*, .htpasswd, SSH private keys (id_rsa, id_ed25519, …), and any *.pem, *.key, *.pfx, *.p12, *.jks, *.keystore.

Testing

The code-index stack has unit-test coverage in tests/unit/test_code_index*.py64 tests spanning the SDK (cache layout, incremental re-index, atomic writes), the parsers (Python AST + the regex backends for JS/TS/Go/Rust/Java/C/C++), and the CodeIndexToolsMixin tool surface. Run them with:
Retrieval-quality benchmarks (precision/recall against curated queries) are tracked under #868.

Real-world benchmark

Indexing the gaia repo itself against Lemonade Server’s nomic-embed-text-v2-moe-GGUF embedding model:
MetricValue
Source files discovered973
Semantic chunks indexed23,974
Languages parsedPython, JavaScript, TypeScript, Go, Rust, Java, C/C++
Embedding modelnomic-embed-text-v2-moe-GGUF (via Lemonade Server)
Wall-clock (remote, ngrok)~51 min
The 51-minute figure is network-bound (embeddings sent to a remote Lemonade Server over an ngrok tunnel). On a local Ryzen AI setup the embedding step runs on the NPU and is substantially faster. For retrieval-quality metrics see #868.

Roadmap

  • #869 — MCP server wrapper, so external code assistants can drive the index.
  • #870 — Multi-repo indexing in a single namespace.
  • #871 — Verilog / VHDL parsers for hardware-design codebases.