Observed since 20 Oct, 21:40 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
Lightweight semantic code search and distillation utility for AI coding agents. It solves the API knowledge gap via real-time local signature extraction and intent analysis without PyTorch. Optimized for token efficiency, it compresses codebase context into compact semantic summaries stored in a local DuckDB vector similarity index.
The API Knowledge Bridge for AI Coding Agents.
Local, fast, and token-efficient semantic search that eliminates LLM hallucinations by providing real-time local context.
Features • Quick Start • Architecture • AI Agent Guide • Contributing
In 2026, AI coding agents are limited by stale training data. They hallucinate library calls because they don't know your specific environment.
pip install agent-coderag
# Install tree-sitter grammars for your languages on-demand
pip install tree-sitter-python tree-sitter-javascript
# Download pre-trained multilingual embedding models (~130MB)
agent-coderag setup
# (Optional) Connect your preferred LLM for semantic distillation
# Using Ollama (Local)
agent-coderag config --url "http://localhost:11434" --provider "ollama" --model "qwen2.5-coder"
# Using OpenAI-compatible API (e.g. Groq, OpenRouter, DeepSeek)
agent-coderag config --url "https://api.deepseek.com" --provider "openai" --key "your-api-key" --model "deepseek-chat"
If you don't configure an LLM provider, agent-coderag works in 100% Offline Mode:
Remote embeddings are not 100% Offline Mode. If you set embedding_base + embedding_model, sync / search / rebuild need the network. Embedder choice is process-global (config.json); after a remote model or dimension change, run agent-coderag rebuild (or delete that --db) for each project index.
agent-coderag config \
--embedding-url "http://localhost:8081/v1" \
--embedding-model "text-embedding-3-small" \
--embedding-key "your-api-key" \
--embedding-provider "openai"
agent-coderag config --clear-embedding
# Index your entire project (respects .gitignore automatically)
agent-coderag sync --all
# Trusted Maven/Gradle projects only: allow dependency resolution
agent-coderag sync --all --allow-build-execution
# Perform a semantic search
agent-coderag search "how does the authentication middleware work?"
Dependency build execution is disabled by default. Maven and Gradle build files
can execute repository-controlled code, so use --allow-build-execution only
after you have reviewed and trust the project.
Verify external library signatures without leaving the CLI:
# Explicit language selection (Recommended for multi-language repos)
agent-coderag api requests --lang python
agent-coderag api lodash --lang typescript
agent-coderag api serde --lang rust
# Built-in auto-detection for common project types (Cargo.toml, package.json, etc.)
agent-coderag api fmt
1.4.0 migration: Storage lifetime and default DB resolution changed. Pin
agent-coderag<1.4until you adapt (see Database & lifetime).
from pathlib import Path
from code_rag import CodeRAG, default_db_path
async def main():
root = Path(".")
print(default_db_path(root)) # resolved path before first sync
# db=None (default): legacy code_rag.db in cwd/root, else root/.coderag.db
async with CodeRAG(root=root) as rag:
await rag.setup()
await rag.sync(index_all=True)
hits = await rag.search("authentication middleware", limit=5)
# Opens the DB only when a provider needs it (e.g. Java JAR cache).
report = await rag.api("pydantic", lang="python")
db=None): resolution order is (1) ./code_rag.db if it exists, (2) else {root}/code_rag.db if it exists, (3) else {root}/.coderag.db (created on first sync/rebuild). Use default_db_path(root) to preview. New projects: prefer .coderag.db (step 3) or set db= explicitly.CodeRAG(db=...) / agent-coderag --db .... Path is a file, not a directory. Relative paths resolve against process cwd, not root..coderag.db.wal) beside the index during writes; locks should not persist after an operation finishes.connect_timeout_seconds=5 (CLI --connect-timeout) waits on file locks, then raises StorageBusyError (ErrorCode.STORAGE_BUSY). Pass 0 for a single attempt.search (and api when storage is needed) opens read-only. A missing index file is an error — use sync/rebuild to create it. An index file that exists but has no embeddings table (e.g. opened/written without a completed vector sync) raises StorageError with ErrorCode.EMBEDDINGS_MISSING — run sync (library: CodeRAG.sync) before search. With --json, success is a hit array; errors are {"status":"error","message":...} and include "code" when the exception carries an ErrorCode.sync stores paths relative to root (src/a.py). The first sync rewrites an older absolute index when the file is still under root or its unit hashes match a file in the tree. Search returns an absolute path under the current root. search --relative-paths, config relative_paths: true, or CodeRAG(relative_paths=True) returns the stored relative path. Until that sync runs, search returns the absolute path stored in the index. Ignore rules use the same project-relative path, so a .worktrees/<name> checkout is indexed when that directory is the root.CodeRAG instance serializes overlapping ops. config() with embedding flags / --clear-embedding closes the process embedder so the next op rebuilds it; distill-only config refreshes Distiller and keeps the embedder.api() without DB: providers that do not need the index (e.g. Python) skip DuckDB entirely; Java uses a short read-only open for JAR cache lookup.CodeRAGError and inspect .code — STORAGE_BUSY, STORAGE_CORRUPT, EMBEDDING_MISMATCH, EMBEDDINGS_MISSING (from code_rag import ErrorCode).| Language | Method | Discovery Source |
|---|---|---|
| Python | 3-Stage Probe | .pyi stubs, static source, or runtime inspect |
| Java | Bytecode Reflection | JARs resolved via Maven or Gradle with explicit --allow-build-execution opt-in |
| Go | Standard Tooling | Native go doc -all integration |
| TypeScript/JS | Declaration Maps | .d.ts files from node_modules or @types |
| Rust | Registry Analysis | Source code from Cargo registry via cargo metadata |
| C# | Assembly Metadata | DLL metadata via dnfile and XML documentation |
agent-coderag creates a semantic map of your codebase using a multi-stage pipeline:
graph LR
Code[Local Codebase] --> Parser[Multi-Language Parser]
Parser --> Delta[Delta-Sync SHA-256]
Delta -- New/Changed --> Distill[LLM Distiller]
Delta -- Unchanged --> Cache[Local Cache]
Distill --> Embed[ONNX Embedder]
Cache --> Embed
Embed --> DuckDB[(DuckDB VSS)]
DuckDB --> Agent[AI Agent Response]
agent-coderag is designed to be the primary tool for your AI agents.
Programmatic Output:
agent-coderag --json search "database init" --limit 1
We maintain a strict quality bar.
# Install development dependencies
make install
# Run full test suite with coverage
make test
# Run linters (Prospector, MyPy, Bandit)
make lint
Contributions make the open source community an amazing place to learn, inspire, and create.
Distributed under the MIT License. See LICENSE for more information.
Built for agents. Driven by humans.
Download counts and popularity will appear here as the collector receives them.
| Version | Published | Direct dependencies | Open version |
|---|---|---|---|
| 1.5.2 | 16 Oct 2026 | 19 |
This describes our collected data; it is not a security assessment.
Observed since 20 Oct, 21:40 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package:7e37d525a76f618f15d1f29f5d10f80c5a11ae73d27a6a4bd6017ddc7a23b7b3