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.
Project description
agent-coderag
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
Why agent-coderag?
In 2026, AI coding agents are limited by stale training data. They hallucinate library calls because they don't know your specific environment.
- The Pain: Your agent writes code for Pydantic v1 while you have v2 installed. You waste 5000+ tokens in a "Fail-Fix-Fail" loop.
- The Cure: agent-coderag extracts live API signatures and technical intent from your local environment. It feeds the LLM exactly what it needs to see—no more, no less.
Key Features
- Instant Startup: Built on onnxruntime and Rust-based tokenizers. Zero PyTorch overhead.
- Context Compression: Replace 10,000 lines of raw code with a 200-token semantic summary.
- Universal Tree-Sitter Parser: Supports 25+ languages (Python, JS/TS, Rust, Java, C++, Go, Ruby, etc.) with high precision.
- API Discovery: On-the-fly extraction of public signatures for 6 core ecosystems (Python, Java, Go, TypeScript, Rust, C#) with build-system awareness.
- Local First: All embeddings and data stay on your machine in a high-performance DuckDB VSS index.
Quick Start
Installation
pip install agent-coderag
# Install tree-sitter grammars for your languages on-demand
pip install tree-sitter-python tree-sitter-javascript
Initial Setup
# 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" --key "your-api-key" --model "deepseek-chat"
Offline Mode (No Provider)
If you don't configure an LLM provider, agent-coderag works in 100% Offline Mode:
- Parsing & API Discovery: Still works perfectly using local Tree-Sitter grammars and javap.
- Search: Remains fast and accurate.
- Distillation: Instead of AI-generated summaries, the system uses code signatures and entity names as fallback metadata. No data ever leaves your machine.
First Sync & Search
# Index your entire project (respects .gitignore automatically)
agent-coderag sync --all
# Perform a semantic search
agent-coderag search "how does the authentication middleware work?"
API Discovery
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
Supported Ecosystems (Discovery)
| Language | Method | Discovery Source |
|---|---|---|
| Python | 3-Stage Probe | .pyi stubs, static source, or runtime inspect |
| Java | Bytecode Reflection | JARs resolved via Maven (pom.xml) or Gradle |
| 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 |
How It Works
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]
- Structural Parsing: Identifies classes, methods, and relations (imports).
- Technical Distillation: Generates a concise "intent summary" of each code unit.
- Vectorization: Local ONNX model creates 384-dimensional embeddings.
- VSS Storage: DuckDB enables sub-millisecond similarity search.
Agent-Native Usage
agent-coderag is designed to be the primary tool for your AI agents.
The Protocol:
- Search First: Instead of reading files, the agent runs agent-coderag --json search.
- Verify Signatures: The agent runs agent-coderag api to get real signatures.
- Read Summaries: The agent uses the summary field to decide which files are actually relevant.
Programmatic Output:
agent-coderag --json search "database init" --limit 1
Development & Testing
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
Contributing
Contributions make the open source community an amazing place to learn, inspire, and create.
- Fork the Project
- Create your Feature Branch (git checkout -b feature/AmazingFeature)
- Commit your Changes (git commit -m 'feat: add AmazingFeature')
- Push to the Branch (git push origin feature/AmazingFeature)
- Open a Pull Request
License
Distributed under the MIT License. See LICENSE for more information.
Built for agents. Driven by humans.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file agent_coderag-1.3.0.tar.gz.
File metadata
- Download URL: agent_coderag-1.3.0.tar.gz
- Upload date:
- Size: 47.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
05106a157970a3e7a020b5da35e95ae10a26e7e0452680bfa99b0efe8b26c60f
|
|
| MD5 |
68c9fc8b4efd4296ecb36a54bf105150
|
|
| BLAKE2b-256 |
4a4cdca3fe858c5e9e2ed8cd1405178091360a59d8931500a4579412cd56ff19
|
Provenance
The following attestation bundles were made for agent_coderag-1.3.0.tar.gz:
Publisher:
release.yml on naranor/agent-coderag
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
agent_coderag-1.3.0.tar.gz -
Subject digest:
05106a157970a3e7a020b5da35e95ae10a26e7e0452680bfa99b0efe8b26c60f - Sigstore transparency entry: 1587740554
- Sigstore integration time:
-
Permalink:
naranor/agent-coderag@6d19244679a75c47e567aa14c77ab325321b09ee -
Branch / Tag:
refs/tags/v1.3.0 - Owner: https://github.com/naranor
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@6d19244679a75c47e567aa14c77ab325321b09ee -
Trigger Event:
push
-
Statement type:
File details
Details for the file agent_coderag-1.3.0-py3-none-any.whl.
File metadata
- Download URL: agent_coderag-1.3.0-py3-none-any.whl
- Upload date:
- Size: 43.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c919d87af0244b39b9cb4112d5c9d41cf9473da88badd156644adf66b0a92eab
|
|
| MD5 |
2a79b1776890ed59dab88fad6a0da1ad
|
|
| BLAKE2b-256 |
b1f30fa4678159dd14af17ef48560d24e7341557817a7ae1bf732b7a489e54b5
|
Provenance
The following attestation bundles were made for agent_coderag-1.3.0-py3-none-any.whl:
Publisher:
release.yml on naranor/agent-coderag
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
agent_coderag-1.3.0-py3-none-any.whl -
Subject digest:
c919d87af0244b39b9cb4112d5c9d41cf9473da88badd156644adf66b0a92eab - Sigstore transparency entry: 1587740626
- Sigstore integration time:
-
Permalink:
naranor/agent-coderag@6d19244679a75c47e567aa14c77ab325321b09ee -
Branch / Tag:
refs/tags/v1.3.0 - Owner: https://github.com/naranor
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@6d19244679a75c47e567aa14c77ab325321b09ee -
Trigger Event:
push
-
Statement type: