agent-coderag 1.1.0__tar.gz → 1.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- agent_coderag-1.2.0/PKG-INFO +206 -0
- agent_coderag-1.2.0/README.md +171 -0
- agent_coderag-1.2.0/agent_coderag.egg-info/PKG-INFO +206 -0
- {agent_coderag-1.1.0 → agent_coderag-1.2.0}/agent_coderag.egg-info/SOURCES.txt +11 -1
- {agent_coderag-1.1.0 → agent_coderag-1.2.0}/agent_coderag.egg-info/requires.txt +1 -0
- {agent_coderag-1.1.0 → agent_coderag-1.2.0}/code_rag/core/interfaces.py +9 -1
- {agent_coderag-1.1.0 → agent_coderag-1.2.0}/code_rag/core/manager.py +10 -8
- {agent_coderag-1.1.0 → agent_coderag-1.2.0}/code_rag/core/models.py +7 -6
- {agent_coderag-1.1.0 → agent_coderag-1.2.0}/code_rag/discovery/dependency.py +12 -3
- agent_coderag-1.2.0/code_rag/discovery/java_discovery.py +100 -0
- {agent_coderag-1.1.0 → agent_coderag-1.2.0}/code_rag/entry/cli.py +52 -17
- agent_coderag-1.2.0/code_rag/parsers/ast_index.py +121 -0
- agent_coderag-1.2.0/code_rag/parsers/java_parser.py +144 -0
- agent_coderag-1.2.0/code_rag/parsers/multi_parser.py +39 -0
- agent_coderag-1.2.0/code_rag/storage/duckdb_impl.py +155 -0
- {agent_coderag-1.1.0 → agent_coderag-1.2.0}/pyproject.toml +2 -1
- {agent_coderag-1.1.0 → agent_coderag-1.2.0}/tests/test_ast_parser.py +0 -1
- agent_coderag-1.2.0/tests/test_cli.py +283 -0
- {agent_coderag-1.1.0 → agent_coderag-1.2.0}/tests/test_code_rag_simple.py +2 -5
- {agent_coderag-1.1.0 → agent_coderag-1.2.0}/tests/test_dependency_discovery.py +6 -9
- agent_coderag-1.2.0/tests/test_distiller.py +95 -0
- agent_coderag-1.2.0/tests/test_embedder.py +59 -0
- agent_coderag-1.2.0/tests/test_interfaces.py +83 -0
- agent_coderag-1.2.0/tests/test_java_parser.py +60 -0
- agent_coderag-1.2.0/tests/test_multi_parser.py +30 -0
- agent_coderag-1.2.0/tests/test_parsers.py +42 -0
- agent_coderag-1.1.0/PKG-INFO +0 -188
- agent_coderag-1.1.0/README.md +0 -154
- agent_coderag-1.1.0/agent_coderag.egg-info/PKG-INFO +0 -188
- agent_coderag-1.1.0/code_rag/parsers/ast_index.py +0 -81
- agent_coderag-1.1.0/code_rag/storage/duckdb_impl.py +0 -111
- {agent_coderag-1.1.0 → agent_coderag-1.2.0}/LICENSE +0 -0
- {agent_coderag-1.1.0 → agent_coderag-1.2.0}/NOTICE +0 -0
- {agent_coderag-1.1.0 → agent_coderag-1.2.0}/agent_coderag.egg-info/dependency_links.txt +0 -0
- {agent_coderag-1.1.0 → agent_coderag-1.2.0}/agent_coderag.egg-info/entry_points.txt +0 -0
- {agent_coderag-1.1.0 → agent_coderag-1.2.0}/agent_coderag.egg-info/top_level.txt +0 -0
- {agent_coderag-1.1.0 → agent_coderag-1.2.0}/code_rag/__init__.py +0 -0
- {agent_coderag-1.1.0 → agent_coderag-1.2.0}/code_rag/core/__init__.py +0 -0
- {agent_coderag-1.1.0 → agent_coderag-1.2.0}/code_rag/discovery/__init__.py +0 -0
- {agent_coderag-1.1.0 → agent_coderag-1.2.0}/code_rag/entry/__init__.py +0 -0
- {agent_coderag-1.1.0 → agent_coderag-1.2.0}/code_rag/intelligence/__init__.py +0 -0
- {agent_coderag-1.1.0 → agent_coderag-1.2.0}/code_rag/intelligence/distiller.py +0 -0
- {agent_coderag-1.1.0 → agent_coderag-1.2.0}/code_rag/intelligence/embedder.py +0 -0
- {agent_coderag-1.1.0 → agent_coderag-1.2.0}/code_rag/parsers/__init__.py +0 -0
- {agent_coderag-1.1.0 → agent_coderag-1.2.0}/code_rag/storage/__init__.py +0 -0
- {agent_coderag-1.1.0 → agent_coderag-1.2.0}/setup.cfg +0 -0
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: agent-coderag
|
|
3
|
+
Version: 1.2.0
|
|
4
|
+
Summary: 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.
|
|
5
|
+
Author-email: Igor Boloban <naranor@gmail.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/naranor/agent-coderag
|
|
8
|
+
Project-URL: Repository, https://github.com/naranor/agent-coderag
|
|
9
|
+
Project-URL: Issues, https://github.com/naranor/agent-coderag/issues
|
|
10
|
+
Project-URL: Changelog, https://github.com/naranor/agent-coderag/blob/main/CHANGELOG.md
|
|
11
|
+
Keywords: rag,ai-agents,semantic-search,code-analysis,context-compression,onnx,local-embeddings
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
20
|
+
Classifier: Topic :: Text Processing :: Indexing
|
|
21
|
+
Requires-Python: >=3.10
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
License-File: NOTICE
|
|
25
|
+
Requires-Dist: duckdb
|
|
26
|
+
Requires-Dist: numpy
|
|
27
|
+
Requires-Dist: litellm
|
|
28
|
+
Requires-Dist: onnxruntime
|
|
29
|
+
Requires-Dist: tokenizers
|
|
30
|
+
Requires-Dist: pydantic
|
|
31
|
+
Requires-Dist: httpx
|
|
32
|
+
Requires-Dist: aiofiles
|
|
33
|
+
Requires-Dist: javalang
|
|
34
|
+
Dynamic: license-file
|
|
35
|
+
|
|
36
|
+
# Agent-CodeRAG
|
|
37
|
+
|
|
38
|
+
<p align="center">
|
|
39
|
+
<img src="https://raw.githubusercontent.com/naranor/agent-coderag/main/assets/banner.svg" alt="Agent-CodeRAG Banner" width="400">
|
|
40
|
+
</p>
|
|
41
|
+
|
|
42
|
+
> **Fast. Local. Agent-First. Token-Efficient.** Bridge the gap between AI coding agents and your local environment.
|
|
43
|
+
|
|
44
|
+
[](https://www.python.org/downloads/)
|
|
45
|
+
[](https://opensource.org/licenses/MIT)
|
|
46
|
+
[](https://pypi.org/project/agent-coderag/)
|
|
47
|
+
[](https://pypi.org/project/agent-coderag/)
|
|
48
|
+
[](https://github.com/naranor/agent-coderag/actions/workflows/ci.yml)
|
|
49
|
+
[](https://github.com/naranor/agent-coderag/actions)
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## Table of Contents
|
|
54
|
+
|
|
55
|
+
- [Why Agent-CodeRAG?](#why-agent-coderag)
|
|
56
|
+
- [Quick Start](#quick-start)
|
|
57
|
+
- [Features](#-features)
|
|
58
|
+
- [How It Works](#-how-it-works)
|
|
59
|
+
- [API Discovery](#-api-discovery)
|
|
60
|
+
- [For AI Agents](#-for-ai-agents)
|
|
61
|
+
- [Development](#-development)
|
|
62
|
+
- [Contributing](#-contributing)
|
|
63
|
+
- [License](#-license)
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## Why Agent-CodeRAG?
|
|
68
|
+
|
|
69
|
+
AI coding agents often **hallucinate** when calling library APIs because their training data is static. This leads to a **"Fail-Fix-Fail" cycle** — broken code, token waste, and frustration.
|
|
70
|
+
|
|
71
|
+
**The Problem:** Your agent knows Pydantic v1 (`model.dict()`), but your environment uses v2 (`model.model_dump()`). Result: 5000+ wasted tokens trying to "fix" something it doesn't understand.
|
|
72
|
+
|
|
73
|
+
**The Solution:** Agent-CodeRAG extracts *actual* API signatures from your installed libraries and provides the LLM with real-time, environment-specific context — saving up to **80% of context window tokens**.
|
|
74
|
+
|
|
75
|
+
[🔝 Back to top](#table-of-contents)
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## Quick Start
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
# 1. Install
|
|
83
|
+
pip install agent-coderag
|
|
84
|
+
|
|
85
|
+
# 2. Setup (download ONNX model)
|
|
86
|
+
agent-coderag setup
|
|
87
|
+
|
|
88
|
+
# 3. Configure LLM (optional, for AI distillation)
|
|
89
|
+
agent-coderag config --url "http://localhost:11434" --provider "ollama" --model "qwen2.5-coder:7b"
|
|
90
|
+
|
|
91
|
+
# 4. Index your project
|
|
92
|
+
agent-coderag sync --all
|
|
93
|
+
|
|
94
|
+
# 5. Search
|
|
95
|
+
agent-coderag search "how to handle errors"
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
**Docker:**
|
|
99
|
+
```bash
|
|
100
|
+
docker build -t agent-coderag .
|
|
101
|
+
docker run -v ~/.cache/agent-coderag:/root/.cache/agent-coderag agent-coderag setup
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
[🔝 Back to top](#table-of-contents)
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
## ✨ Features
|
|
109
|
+
|
|
110
|
+
- **⚡ No PyTorch** — Uses `onnxruntime` and `tokenizers` (Rust) for instant startup
|
|
111
|
+
- **💾 DuckDB VSS** — High-performance vector search in a single local file
|
|
112
|
+
- **🏗️ Multi-Language** — Native indexing for Python (AST) and Java (javalang)
|
|
113
|
+
- **🔄 Delta-Sync** — SHA-256 hashing re-distills only changed code
|
|
114
|
+
- **🔌 Hybrid Intelligence** — Works offline; adds AI-distilled reasoning when LLM is connected
|
|
115
|
+
- **📡 API Discovery** — Extract live API signatures from Python modules or Java JARs
|
|
116
|
+
|
|
117
|
+
[🔝 Back to top](#table-of-contents)
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## 🛠 How It Works
|
|
122
|
+
|
|
123
|
+
```mermaid
|
|
124
|
+
graph TD
|
|
125
|
+
A[Local Python Code] --> B[AST Parser]
|
|
126
|
+
B --> C{Delta-Sync}
|
|
127
|
+
C -- Changed/New --> D[LLM Distiller]
|
|
128
|
+
C -- Unchanged --> E[Local Cache]
|
|
129
|
+
D --> F[Semantic Summary]
|
|
130
|
+
E --> F
|
|
131
|
+
F --> G[ONNX Embedder]
|
|
132
|
+
G --> H[(DuckDB VSS)]
|
|
133
|
+
H --> I[Semantic Search / JSON API]
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
1. **AST Parser** — Parses your Python code
|
|
137
|
+
2. **Delta-Sync** — Uses SHA-256 to detect changes
|
|
138
|
+
3. **LLM Distiller** — Generates semantic summaries (optional)
|
|
139
|
+
4. **ONNX Embedder** — Creates embeddings locally
|
|
140
|
+
5. **DuckDB VSS** — Stores vectors for fast similarity search
|
|
141
|
+
|
|
142
|
+
[🔝 Back to top](#table-of-contents)
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
## 📡 API Discovery
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
agent-coderag api pydantic
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Returns the *live* public API, methods, and signatures for any installed library.
|
|
153
|
+
|
|
154
|
+
[🔝 Back to top](#table-of-contents)
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
## 🤖 For AI Agents
|
|
159
|
+
|
|
160
|
+
Agent-CodeRAG is built for programmatic consumption:
|
|
161
|
+
|
|
162
|
+
1. **Search First**: `agent-coderag --json search "topic" --limit 1`
|
|
163
|
+
2. **Use Intent**: The `summary` field provides technical intent — skip reading unnecessary files
|
|
164
|
+
|
|
165
|
+
[🔝 Back to top](#table-of-contents)
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
## 🔧 Development
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
# Run tests
|
|
173
|
+
pytest tests/
|
|
174
|
+
pytest e2e_tests/
|
|
175
|
+
|
|
176
|
+
# Setup pre-commit hooks
|
|
177
|
+
pip install pre-commit
|
|
178
|
+
pre-commit install
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
[🔝 Back to top](#table-of-contents)
|
|
182
|
+
|
|
183
|
+
---
|
|
184
|
+
|
|
185
|
+
## 🤝 Contributing
|
|
186
|
+
|
|
187
|
+
Contributions are welcome! Here's how to get started:
|
|
188
|
+
|
|
189
|
+
1. **Fork** the repository
|
|
190
|
+
2. **Clone** your fork: `git clone https://github.com/YOUR_USERNAME/agent-coderag.git`
|
|
191
|
+
3. **Create a branch**: `git checkout -b feature/your-feature`
|
|
192
|
+
4. **Make changes** and commit with [Conventional Commits](https://www.conventionalcommits.org/)
|
|
193
|
+
5. **Run tests**: `pytest tests/`
|
|
194
|
+
6. **Push** to your fork and create a **Pull Request**
|
|
195
|
+
|
|
196
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for detailed guidelines.
|
|
197
|
+
|
|
198
|
+
[🔝 Back to top](#table-of-contents)
|
|
199
|
+
|
|
200
|
+
---
|
|
201
|
+
|
|
202
|
+
## 📄 License
|
|
203
|
+
|
|
204
|
+
MIT © 2026 [Igor Boloban](https://github.com/naranor)
|
|
205
|
+
|
|
206
|
+
[🔝 Back to top](#table-of-contents)
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
# Agent-CodeRAG
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<img src="https://raw.githubusercontent.com/naranor/agent-coderag/main/assets/banner.svg" alt="Agent-CodeRAG Banner" width="400">
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
> **Fast. Local. Agent-First. Token-Efficient.** Bridge the gap between AI coding agents and your local environment.
|
|
8
|
+
|
|
9
|
+
[](https://www.python.org/downloads/)
|
|
10
|
+
[](https://opensource.org/licenses/MIT)
|
|
11
|
+
[](https://pypi.org/project/agent-coderag/)
|
|
12
|
+
[](https://pypi.org/project/agent-coderag/)
|
|
13
|
+
[](https://github.com/naranor/agent-coderag/actions/workflows/ci.yml)
|
|
14
|
+
[](https://github.com/naranor/agent-coderag/actions)
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## Table of Contents
|
|
19
|
+
|
|
20
|
+
- [Why Agent-CodeRAG?](#why-agent-coderag)
|
|
21
|
+
- [Quick Start](#quick-start)
|
|
22
|
+
- [Features](#-features)
|
|
23
|
+
- [How It Works](#-how-it-works)
|
|
24
|
+
- [API Discovery](#-api-discovery)
|
|
25
|
+
- [For AI Agents](#-for-ai-agents)
|
|
26
|
+
- [Development](#-development)
|
|
27
|
+
- [Contributing](#-contributing)
|
|
28
|
+
- [License](#-license)
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## Why Agent-CodeRAG?
|
|
33
|
+
|
|
34
|
+
AI coding agents often **hallucinate** when calling library APIs because their training data is static. This leads to a **"Fail-Fix-Fail" cycle** — broken code, token waste, and frustration.
|
|
35
|
+
|
|
36
|
+
**The Problem:** Your agent knows Pydantic v1 (`model.dict()`), but your environment uses v2 (`model.model_dump()`). Result: 5000+ wasted tokens trying to "fix" something it doesn't understand.
|
|
37
|
+
|
|
38
|
+
**The Solution:** Agent-CodeRAG extracts *actual* API signatures from your installed libraries and provides the LLM with real-time, environment-specific context — saving up to **80% of context window tokens**.
|
|
39
|
+
|
|
40
|
+
[🔝 Back to top](#table-of-contents)
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## Quick Start
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
# 1. Install
|
|
48
|
+
pip install agent-coderag
|
|
49
|
+
|
|
50
|
+
# 2. Setup (download ONNX model)
|
|
51
|
+
agent-coderag setup
|
|
52
|
+
|
|
53
|
+
# 3. Configure LLM (optional, for AI distillation)
|
|
54
|
+
agent-coderag config --url "http://localhost:11434" --provider "ollama" --model "qwen2.5-coder:7b"
|
|
55
|
+
|
|
56
|
+
# 4. Index your project
|
|
57
|
+
agent-coderag sync --all
|
|
58
|
+
|
|
59
|
+
# 5. Search
|
|
60
|
+
agent-coderag search "how to handle errors"
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
**Docker:**
|
|
64
|
+
```bash
|
|
65
|
+
docker build -t agent-coderag .
|
|
66
|
+
docker run -v ~/.cache/agent-coderag:/root/.cache/agent-coderag agent-coderag setup
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
[🔝 Back to top](#table-of-contents)
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## ✨ Features
|
|
74
|
+
|
|
75
|
+
- **⚡ No PyTorch** — Uses `onnxruntime` and `tokenizers` (Rust) for instant startup
|
|
76
|
+
- **💾 DuckDB VSS** — High-performance vector search in a single local file
|
|
77
|
+
- **🏗️ Multi-Language** — Native indexing for Python (AST) and Java (javalang)
|
|
78
|
+
- **🔄 Delta-Sync** — SHA-256 hashing re-distills only changed code
|
|
79
|
+
- **🔌 Hybrid Intelligence** — Works offline; adds AI-distilled reasoning when LLM is connected
|
|
80
|
+
- **📡 API Discovery** — Extract live API signatures from Python modules or Java JARs
|
|
81
|
+
|
|
82
|
+
[🔝 Back to top](#table-of-contents)
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## 🛠 How It Works
|
|
87
|
+
|
|
88
|
+
```mermaid
|
|
89
|
+
graph TD
|
|
90
|
+
A[Local Python Code] --> B[AST Parser]
|
|
91
|
+
B --> C{Delta-Sync}
|
|
92
|
+
C -- Changed/New --> D[LLM Distiller]
|
|
93
|
+
C -- Unchanged --> E[Local Cache]
|
|
94
|
+
D --> F[Semantic Summary]
|
|
95
|
+
E --> F
|
|
96
|
+
F --> G[ONNX Embedder]
|
|
97
|
+
G --> H[(DuckDB VSS)]
|
|
98
|
+
H --> I[Semantic Search / JSON API]
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
1. **AST Parser** — Parses your Python code
|
|
102
|
+
2. **Delta-Sync** — Uses SHA-256 to detect changes
|
|
103
|
+
3. **LLM Distiller** — Generates semantic summaries (optional)
|
|
104
|
+
4. **ONNX Embedder** — Creates embeddings locally
|
|
105
|
+
5. **DuckDB VSS** — Stores vectors for fast similarity search
|
|
106
|
+
|
|
107
|
+
[🔝 Back to top](#table-of-contents)
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
## 📡 API Discovery
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
agent-coderag api pydantic
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Returns the *live* public API, methods, and signatures for any installed library.
|
|
118
|
+
|
|
119
|
+
[🔝 Back to top](#table-of-contents)
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
## 🤖 For AI Agents
|
|
124
|
+
|
|
125
|
+
Agent-CodeRAG is built for programmatic consumption:
|
|
126
|
+
|
|
127
|
+
1. **Search First**: `agent-coderag --json search "topic" --limit 1`
|
|
128
|
+
2. **Use Intent**: The `summary` field provides technical intent — skip reading unnecessary files
|
|
129
|
+
|
|
130
|
+
[🔝 Back to top](#table-of-contents)
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
## 🔧 Development
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
# Run tests
|
|
138
|
+
pytest tests/
|
|
139
|
+
pytest e2e_tests/
|
|
140
|
+
|
|
141
|
+
# Setup pre-commit hooks
|
|
142
|
+
pip install pre-commit
|
|
143
|
+
pre-commit install
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
[🔝 Back to top](#table-of-contents)
|
|
147
|
+
|
|
148
|
+
---
|
|
149
|
+
|
|
150
|
+
## 🤝 Contributing
|
|
151
|
+
|
|
152
|
+
Contributions are welcome! Here's how to get started:
|
|
153
|
+
|
|
154
|
+
1. **Fork** the repository
|
|
155
|
+
2. **Clone** your fork: `git clone https://github.com/YOUR_USERNAME/agent-coderag.git`
|
|
156
|
+
3. **Create a branch**: `git checkout -b feature/your-feature`
|
|
157
|
+
4. **Make changes** and commit with [Conventional Commits](https://www.conventionalcommits.org/)
|
|
158
|
+
5. **Run tests**: `pytest tests/`
|
|
159
|
+
6. **Push** to your fork and create a **Pull Request**
|
|
160
|
+
|
|
161
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for detailed guidelines.
|
|
162
|
+
|
|
163
|
+
[🔝 Back to top](#table-of-contents)
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
## 📄 License
|
|
168
|
+
|
|
169
|
+
MIT © 2026 [Igor Boloban](https://github.com/naranor)
|
|
170
|
+
|
|
171
|
+
[🔝 Back to top](#table-of-contents)
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: agent-coderag
|
|
3
|
+
Version: 1.2.0
|
|
4
|
+
Summary: 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.
|
|
5
|
+
Author-email: Igor Boloban <naranor@gmail.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/naranor/agent-coderag
|
|
8
|
+
Project-URL: Repository, https://github.com/naranor/agent-coderag
|
|
9
|
+
Project-URL: Issues, https://github.com/naranor/agent-coderag/issues
|
|
10
|
+
Project-URL: Changelog, https://github.com/naranor/agent-coderag/blob/main/CHANGELOG.md
|
|
11
|
+
Keywords: rag,ai-agents,semantic-search,code-analysis,context-compression,onnx,local-embeddings
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
20
|
+
Classifier: Topic :: Text Processing :: Indexing
|
|
21
|
+
Requires-Python: >=3.10
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
License-File: NOTICE
|
|
25
|
+
Requires-Dist: duckdb
|
|
26
|
+
Requires-Dist: numpy
|
|
27
|
+
Requires-Dist: litellm
|
|
28
|
+
Requires-Dist: onnxruntime
|
|
29
|
+
Requires-Dist: tokenizers
|
|
30
|
+
Requires-Dist: pydantic
|
|
31
|
+
Requires-Dist: httpx
|
|
32
|
+
Requires-Dist: aiofiles
|
|
33
|
+
Requires-Dist: javalang
|
|
34
|
+
Dynamic: license-file
|
|
35
|
+
|
|
36
|
+
# Agent-CodeRAG
|
|
37
|
+
|
|
38
|
+
<p align="center">
|
|
39
|
+
<img src="https://raw.githubusercontent.com/naranor/agent-coderag/main/assets/banner.svg" alt="Agent-CodeRAG Banner" width="400">
|
|
40
|
+
</p>
|
|
41
|
+
|
|
42
|
+
> **Fast. Local. Agent-First. Token-Efficient.** Bridge the gap between AI coding agents and your local environment.
|
|
43
|
+
|
|
44
|
+
[](https://www.python.org/downloads/)
|
|
45
|
+
[](https://opensource.org/licenses/MIT)
|
|
46
|
+
[](https://pypi.org/project/agent-coderag/)
|
|
47
|
+
[](https://pypi.org/project/agent-coderag/)
|
|
48
|
+
[](https://github.com/naranor/agent-coderag/actions/workflows/ci.yml)
|
|
49
|
+
[](https://github.com/naranor/agent-coderag/actions)
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## Table of Contents
|
|
54
|
+
|
|
55
|
+
- [Why Agent-CodeRAG?](#why-agent-coderag)
|
|
56
|
+
- [Quick Start](#quick-start)
|
|
57
|
+
- [Features](#-features)
|
|
58
|
+
- [How It Works](#-how-it-works)
|
|
59
|
+
- [API Discovery](#-api-discovery)
|
|
60
|
+
- [For AI Agents](#-for-ai-agents)
|
|
61
|
+
- [Development](#-development)
|
|
62
|
+
- [Contributing](#-contributing)
|
|
63
|
+
- [License](#-license)
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## Why Agent-CodeRAG?
|
|
68
|
+
|
|
69
|
+
AI coding agents often **hallucinate** when calling library APIs because their training data is static. This leads to a **"Fail-Fix-Fail" cycle** — broken code, token waste, and frustration.
|
|
70
|
+
|
|
71
|
+
**The Problem:** Your agent knows Pydantic v1 (`model.dict()`), but your environment uses v2 (`model.model_dump()`). Result: 5000+ wasted tokens trying to "fix" something it doesn't understand.
|
|
72
|
+
|
|
73
|
+
**The Solution:** Agent-CodeRAG extracts *actual* API signatures from your installed libraries and provides the LLM with real-time, environment-specific context — saving up to **80% of context window tokens**.
|
|
74
|
+
|
|
75
|
+
[🔝 Back to top](#table-of-contents)
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## Quick Start
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
# 1. Install
|
|
83
|
+
pip install agent-coderag
|
|
84
|
+
|
|
85
|
+
# 2. Setup (download ONNX model)
|
|
86
|
+
agent-coderag setup
|
|
87
|
+
|
|
88
|
+
# 3. Configure LLM (optional, for AI distillation)
|
|
89
|
+
agent-coderag config --url "http://localhost:11434" --provider "ollama" --model "qwen2.5-coder:7b"
|
|
90
|
+
|
|
91
|
+
# 4. Index your project
|
|
92
|
+
agent-coderag sync --all
|
|
93
|
+
|
|
94
|
+
# 5. Search
|
|
95
|
+
agent-coderag search "how to handle errors"
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
**Docker:**
|
|
99
|
+
```bash
|
|
100
|
+
docker build -t agent-coderag .
|
|
101
|
+
docker run -v ~/.cache/agent-coderag:/root/.cache/agent-coderag agent-coderag setup
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
[🔝 Back to top](#table-of-contents)
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
## ✨ Features
|
|
109
|
+
|
|
110
|
+
- **⚡ No PyTorch** — Uses `onnxruntime` and `tokenizers` (Rust) for instant startup
|
|
111
|
+
- **💾 DuckDB VSS** — High-performance vector search in a single local file
|
|
112
|
+
- **🏗️ Multi-Language** — Native indexing for Python (AST) and Java (javalang)
|
|
113
|
+
- **🔄 Delta-Sync** — SHA-256 hashing re-distills only changed code
|
|
114
|
+
- **🔌 Hybrid Intelligence** — Works offline; adds AI-distilled reasoning when LLM is connected
|
|
115
|
+
- **📡 API Discovery** — Extract live API signatures from Python modules or Java JARs
|
|
116
|
+
|
|
117
|
+
[🔝 Back to top](#table-of-contents)
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## 🛠 How It Works
|
|
122
|
+
|
|
123
|
+
```mermaid
|
|
124
|
+
graph TD
|
|
125
|
+
A[Local Python Code] --> B[AST Parser]
|
|
126
|
+
B --> C{Delta-Sync}
|
|
127
|
+
C -- Changed/New --> D[LLM Distiller]
|
|
128
|
+
C -- Unchanged --> E[Local Cache]
|
|
129
|
+
D --> F[Semantic Summary]
|
|
130
|
+
E --> F
|
|
131
|
+
F --> G[ONNX Embedder]
|
|
132
|
+
G --> H[(DuckDB VSS)]
|
|
133
|
+
H --> I[Semantic Search / JSON API]
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
1. **AST Parser** — Parses your Python code
|
|
137
|
+
2. **Delta-Sync** — Uses SHA-256 to detect changes
|
|
138
|
+
3. **LLM Distiller** — Generates semantic summaries (optional)
|
|
139
|
+
4. **ONNX Embedder** — Creates embeddings locally
|
|
140
|
+
5. **DuckDB VSS** — Stores vectors for fast similarity search
|
|
141
|
+
|
|
142
|
+
[🔝 Back to top](#table-of-contents)
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
## 📡 API Discovery
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
agent-coderag api pydantic
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Returns the *live* public API, methods, and signatures for any installed library.
|
|
153
|
+
|
|
154
|
+
[🔝 Back to top](#table-of-contents)
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
## 🤖 For AI Agents
|
|
159
|
+
|
|
160
|
+
Agent-CodeRAG is built for programmatic consumption:
|
|
161
|
+
|
|
162
|
+
1. **Search First**: `agent-coderag --json search "topic" --limit 1`
|
|
163
|
+
2. **Use Intent**: The `summary` field provides technical intent — skip reading unnecessary files
|
|
164
|
+
|
|
165
|
+
[🔝 Back to top](#table-of-contents)
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
## 🔧 Development
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
# Run tests
|
|
173
|
+
pytest tests/
|
|
174
|
+
pytest e2e_tests/
|
|
175
|
+
|
|
176
|
+
# Setup pre-commit hooks
|
|
177
|
+
pip install pre-commit
|
|
178
|
+
pre-commit install
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
[🔝 Back to top](#table-of-contents)
|
|
182
|
+
|
|
183
|
+
---
|
|
184
|
+
|
|
185
|
+
## 🤝 Contributing
|
|
186
|
+
|
|
187
|
+
Contributions are welcome! Here's how to get started:
|
|
188
|
+
|
|
189
|
+
1. **Fork** the repository
|
|
190
|
+
2. **Clone** your fork: `git clone https://github.com/YOUR_USERNAME/agent-coderag.git`
|
|
191
|
+
3. **Create a branch**: `git checkout -b feature/your-feature`
|
|
192
|
+
4. **Make changes** and commit with [Conventional Commits](https://www.conventionalcommits.org/)
|
|
193
|
+
5. **Run tests**: `pytest tests/`
|
|
194
|
+
6. **Push** to your fork and create a **Pull Request**
|
|
195
|
+
|
|
196
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for detailed guidelines.
|
|
197
|
+
|
|
198
|
+
[🔝 Back to top](#table-of-contents)
|
|
199
|
+
|
|
200
|
+
---
|
|
201
|
+
|
|
202
|
+
## 📄 License
|
|
203
|
+
|
|
204
|
+
MIT © 2026 [Igor Boloban](https://github.com/naranor)
|
|
205
|
+
|
|
206
|
+
[🔝 Back to top](#table-of-contents)
|
|
@@ -15,6 +15,7 @@ code_rag/core/manager.py
|
|
|
15
15
|
code_rag/core/models.py
|
|
16
16
|
code_rag/discovery/__init__.py
|
|
17
17
|
code_rag/discovery/dependency.py
|
|
18
|
+
code_rag/discovery/java_discovery.py
|
|
18
19
|
code_rag/entry/__init__.py
|
|
19
20
|
code_rag/entry/cli.py
|
|
20
21
|
code_rag/intelligence/__init__.py
|
|
@@ -22,8 +23,17 @@ code_rag/intelligence/distiller.py
|
|
|
22
23
|
code_rag/intelligence/embedder.py
|
|
23
24
|
code_rag/parsers/__init__.py
|
|
24
25
|
code_rag/parsers/ast_index.py
|
|
26
|
+
code_rag/parsers/java_parser.py
|
|
27
|
+
code_rag/parsers/multi_parser.py
|
|
25
28
|
code_rag/storage/__init__.py
|
|
26
29
|
code_rag/storage/duckdb_impl.py
|
|
27
30
|
tests/test_ast_parser.py
|
|
31
|
+
tests/test_cli.py
|
|
28
32
|
tests/test_code_rag_simple.py
|
|
29
|
-
tests/test_dependency_discovery.py
|
|
33
|
+
tests/test_dependency_discovery.py
|
|
34
|
+
tests/test_distiller.py
|
|
35
|
+
tests/test_embedder.py
|
|
36
|
+
tests/test_interfaces.py
|
|
37
|
+
tests/test_java_parser.py
|
|
38
|
+
tests/test_multi_parser.py
|
|
39
|
+
tests/test_parsers.py
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
from abc import ABC, abstractmethod
|
|
2
2
|
from typing import List, Optional
|
|
3
|
-
from .models import KnowledgeUnit
|
|
3
|
+
from .models import KnowledgeUnit, Relation
|
|
4
4
|
|
|
5
5
|
class IParser(ABC):
|
|
6
6
|
"""Interface for extracting structure from code."""
|
|
@@ -22,6 +22,14 @@ class IStorage(ABC):
|
|
|
22
22
|
async def search_units(self, query: str, limit: int = 5) -> List[KnowledgeUnit]:
|
|
23
23
|
pass
|
|
24
24
|
|
|
25
|
+
@abstractmethod
|
|
26
|
+
async def upsert_relation(self, relation: Relation):
|
|
27
|
+
pass
|
|
28
|
+
|
|
29
|
+
@abstractmethod
|
|
30
|
+
async def get_relations(self, unit_id: str, direction: str = "out") -> List[Relation]:
|
|
31
|
+
pass
|
|
32
|
+
|
|
25
33
|
class IIntelligence(ABC):
|
|
26
34
|
"""Interface for LLM-based analysis (distillation, embeddings)."""
|
|
27
35
|
@abstractmethod
|
|
@@ -11,10 +11,11 @@ class CodeRAGManager:
|
|
|
11
11
|
Orchestrates the RAG workflow: parsing, distillation, and storage.
|
|
12
12
|
"""
|
|
13
13
|
|
|
14
|
-
def __init__(self, storage: IStorage, parser: IParser, intelligence: IIntelligence):
|
|
14
|
+
def __init__(self, storage: IStorage, parser: IParser, intelligence: IIntelligence, max_concurrency: int = 10):
|
|
15
15
|
self.storage = storage
|
|
16
16
|
self.parser = parser
|
|
17
17
|
self.intelligence = intelligence
|
|
18
|
+
self.semaphore = asyncio.Semaphore(max_concurrency)
|
|
18
19
|
|
|
19
20
|
async def sync_file(self, file_path: str, force_distill: bool = False):
|
|
20
21
|
"""
|
|
@@ -42,13 +43,14 @@ class CodeRAGManager:
|
|
|
42
43
|
logger.info("Summary missing for %s", unit.name)
|
|
43
44
|
|
|
44
45
|
if should_distill:
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
46
|
+
async with self.semaphore:
|
|
47
|
+
logger.info("Distilling summary for %s...", unit.id)
|
|
48
|
+
try:
|
|
49
|
+
unit.summary = await self.intelligence.summarize(raw_code, unit.name)
|
|
50
|
+
except Exception as e:
|
|
51
|
+
logger.error("Failed to distill %s: %s", unit.name, e)
|
|
52
|
+
# Keep old summary if available, otherwise stay None
|
|
53
|
+
unit.summary = existing_unit.summary if existing_unit else None
|
|
52
54
|
else:
|
|
53
55
|
# Reuse existing summary if code hasn't changed
|
|
54
56
|
unit.summary = existing_unit.summary if existing_unit else None
|