nervapack 0.1.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.
- nervapack-0.1.0/LICENSE +21 -0
- nervapack-0.1.0/PKG-INFO +251 -0
- nervapack-0.1.0/README.md +215 -0
- nervapack-0.1.0/pyproject.toml +49 -0
- nervapack-0.1.0/setup.cfg +4 -0
- nervapack-0.1.0/src/nervapack/__init__.py +1 -0
- nervapack-0.1.0/src/nervapack/cli.py +278 -0
- nervapack-0.1.0/src/nervapack/git/__init__.py +0 -0
- nervapack-0.1.0/src/nervapack/git/tracker.py +46 -0
- nervapack-0.1.0/src/nervapack/graph/__init__.py +0 -0
- nervapack-0.1.0/src/nervapack/graph/builder.py +58 -0
- nervapack-0.1.0/src/nervapack/graph/retrieval.py +75 -0
- nervapack-0.1.0/src/nervapack/graph/vector_store.py +63 -0
- nervapack-0.1.0/src/nervapack/llm/__init__.py +0 -0
- nervapack-0.1.0/src/nervapack/llm/summarizer.py +45 -0
- nervapack-0.1.0/src/nervapack/parser/__init__.py +0 -0
- nervapack-0.1.0/src/nervapack/parser/ast_parser.py +91 -0
- nervapack-0.1.0/src/nervapack/parser/md_chunker.py +64 -0
- nervapack-0.1.0/src/nervapack.egg-info/PKG-INFO +251 -0
- nervapack-0.1.0/src/nervapack.egg-info/SOURCES.txt +22 -0
- nervapack-0.1.0/src/nervapack.egg-info/dependency_links.txt +1 -0
- nervapack-0.1.0/src/nervapack.egg-info/entry_points.txt +2 -0
- nervapack-0.1.0/src/nervapack.egg-info/requires.txt +10 -0
- nervapack-0.1.0/src/nervapack.egg-info/top_level.txt +1 -0
nervapack-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Preetam Ramdhave
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
nervapack-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: nervapack
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Privacy-first, offline knowledge graph for developers
|
|
5
|
+
Author-email: Preetam Ramdhave <ramdhavepreetam@gmail.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/ramdhavepreetam/NervaPack
|
|
8
|
+
Project-URL: Repository, https://github.com/ramdhavepreetam/NervaPack
|
|
9
|
+
Project-URL: Bug Tracker, https://github.com/ramdhavepreetam/NervaPack/issues
|
|
10
|
+
Project-URL: Documentation, https://github.com/ramdhavepreetam/NervaPack#readme
|
|
11
|
+
Keywords: knowledge-graph,rag,ast,code-search,offline,llm,developer-tools
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Environment :: Console
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Topic :: Software Development :: Build Tools
|
|
16
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Operating System :: OS Independent
|
|
22
|
+
Requires-Python: >=3.10
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
License-File: LICENSE
|
|
25
|
+
Requires-Dist: typer>=0.9.0
|
|
26
|
+
Requires-Dist: rich>=13.0.0
|
|
27
|
+
Requires-Dist: tree-sitter>=0.22.3
|
|
28
|
+
Requires-Dist: tree-sitter-python>=0.21.0
|
|
29
|
+
Requires-Dist: tree-sitter-javascript>=0.21.2
|
|
30
|
+
Requires-Dist: tree-sitter-typescript>=0.21.2
|
|
31
|
+
Requires-Dist: networkx>=3.1
|
|
32
|
+
Requires-Dist: ollama>=0.2.0
|
|
33
|
+
Requires-Dist: gitpython>=3.1.30
|
|
34
|
+
Requires-Dist: chromadb>=0.4.24
|
|
35
|
+
Dynamic: license-file
|
|
36
|
+
|
|
37
|
+
# NervaPack
|
|
38
|
+
|
|
39
|
+
[](https://pypi.org/project/nervapack/)
|
|
40
|
+
[](https://pypi.org/project/nervapack/)
|
|
41
|
+
[](https://opensource.org/licenses/MIT)
|
|
42
|
+
|
|
43
|
+
**NervaPack** is a privacy-first, offline knowledge graph for your codebase. It solves two fundamental problems with standard Vector RAG:
|
|
44
|
+
|
|
45
|
+
- **Token waste** — chunk-based RAG retrieves blobs of text that may only tangentially relate to your query, bloating your context window.
|
|
46
|
+
- **Privacy risk** — sending code to cloud embedding APIs leaks your proprietary logic.
|
|
47
|
+
|
|
48
|
+
NervaPack runs 100% on your machine. It uses `tree-sitter` to parse your codebase into a deterministic Abstract Syntax Tree graph, then uses a local Ollama model to draw hard semantic edges between your documentation and your code. Queries traverse this graph with a K-Hop BFS, returning a hyper-targeted, token-efficient context window — no cloud required.
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## Why NervaPack vs. standard Vector RAG
|
|
53
|
+
|
|
54
|
+
| | Standard Vector RAG | NervaPack |
|
|
55
|
+
|---|---|---|
|
|
56
|
+
| **Parsing** | Arbitrary text chunks | Deterministic AST nodes (class, function, import) |
|
|
57
|
+
| **Retrieval** | Nearest-neighbor blob | K-Hop BFS on a structural graph |
|
|
58
|
+
| **Doc ↔ Code links** | None | Hard `EXPLAINS` edges drawn by local LLM |
|
|
59
|
+
| **Privacy** | Cloud embeddings | 100% local (ChromaDB + Ollama) |
|
|
60
|
+
| **Incremental sync** | Re-index everything | Surgical per-file update via GitPython diff |
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## Prerequisites
|
|
65
|
+
|
|
66
|
+
- **Python 3.10+**
|
|
67
|
+
- **Ollama** — install from [ollama.com](https://ollama.com/), then pull a model:
|
|
68
|
+
```bash
|
|
69
|
+
ollama pull llama3
|
|
70
|
+
```
|
|
71
|
+
NervaPack defaults to `llama3`. Any model that can follow instructions works.
|
|
72
|
+
- **Git** — your project must be a git repository (`git init` if not).
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## Installation
|
|
77
|
+
|
|
78
|
+
**Option A — Homebrew (Mac/Linux, recommended)**
|
|
79
|
+
```bash
|
|
80
|
+
brew tap ramdhavepreetam/nervapack
|
|
81
|
+
brew install nervapack
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
**Option B — pipx (any platform, cleanest Python install)**
|
|
85
|
+
```bash
|
|
86
|
+
pipx install nervapack
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
**Option C — pip**
|
|
90
|
+
```bash
|
|
91
|
+
pip install nervapack
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
> On first run, `chromadb` downloads `onnxruntime` embedding models to your cache and `tree-sitter` compiles its language bindings. This is a one-time setup (~1–2 min).
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## Quick Start
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
cd your-project/
|
|
102
|
+
|
|
103
|
+
# 1. Build the knowledge graph (run once)
|
|
104
|
+
nervapack ingest .
|
|
105
|
+
|
|
106
|
+
# 2. Query for context
|
|
107
|
+
nervapack query "How does authentication work?"
|
|
108
|
+
|
|
109
|
+
# 3. After modifying files, sync the graph incrementally
|
|
110
|
+
nervapack sync .
|
|
111
|
+
|
|
112
|
+
# 4. Check graph health
|
|
113
|
+
nervapack status
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
## Command Reference
|
|
119
|
+
|
|
120
|
+
### `nervapack ingest [PATH]`
|
|
121
|
+
|
|
122
|
+
Scans `PATH` (default: `.`) and builds the full knowledge graph.
|
|
123
|
+
|
|
124
|
+
What happens:
|
|
125
|
+
1. `tree-sitter` parses all `.py`, `.js`, `.jsx`, `.ts`, `.tsx` files into Classes, Functions, and Imports — exact AST nodes, not text chunks.
|
|
126
|
+
2. All `.md` files are chunked by header hierarchy.
|
|
127
|
+
3. Each Markdown chunk is sent to your local Ollama model. If the model identifies a code entity the prose explains, a hard `EXPLAINS` edge is written into the graph.
|
|
128
|
+
4. All nodes are embedded and stored in a local ChromaDB instance (`.nervapack/chroma_db`).
|
|
129
|
+
|
|
130
|
+
> The initial LLM binding pass is the slowest step. On a large repo with many docs, budget several minutes.
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
### `nervapack query PROMPT`
|
|
135
|
+
|
|
136
|
+
Retrieves context from the graph for a natural-language prompt.
|
|
137
|
+
|
|
138
|
+
What happens:
|
|
139
|
+
1. The prompt is embedded and ChromaDB returns the top-3 most semantically similar nodes.
|
|
140
|
+
2. Those nodes seed a K-Hop Breadth-First Search (default `max_hops=1`) through the NetworkX graph.
|
|
141
|
+
3. Adjacent nodes — including any Markdown docs linked via `EXPLAINS` edges — are collected into a compressed Markdown snippet and printed to your terminal.
|
|
142
|
+
|
|
143
|
+
The output is designed to be pasted directly into an LLM prompt as context.
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
### `nervapack sync [PATH]`
|
|
148
|
+
|
|
149
|
+
Incrementally updates the graph for files changed since the last ingest.
|
|
150
|
+
|
|
151
|
+
What happens:
|
|
152
|
+
1. `GitPython` diffs your working tree to find modified and deleted files.
|
|
153
|
+
2. For each changed file, old graph nodes and ChromaDB vectors are pruned.
|
|
154
|
+
3. Only the changed files are re-parsed and re-ingested.
|
|
155
|
+
|
|
156
|
+
A full `ingest` on a large codebase can take minutes. `sync` turns that into a 2–5 second surgical update.
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
### `nervapack status`
|
|
161
|
+
|
|
162
|
+
Prints the current state of the graph: node count, edge count, and any files that are out of sync with the graph.
|
|
163
|
+
|
|
164
|
+
---
|
|
165
|
+
|
|
166
|
+
## Configuration
|
|
167
|
+
|
|
168
|
+
NervaPack reads the Ollama model from the `LLMSummarizer` class (`src/nervapack/llm/summarizer.py`). To use a different model, set `model` to any model you have pulled locally:
|
|
169
|
+
|
|
170
|
+
```python
|
|
171
|
+
# src/nervapack/llm/summarizer.py
|
|
172
|
+
self.model = "phi3" # or "mistral", "codellama", etc.
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
Ollama is expected at `http://localhost:11434` (its default). To use a remote Ollama instance, set `OLLAMA_HOST`:
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
OLLAMA_HOST=http://my-server:11434 nervapack ingest .
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
---
|
|
182
|
+
|
|
183
|
+
## Architecture
|
|
184
|
+
|
|
185
|
+
```
|
|
186
|
+
nervapack ingest .
|
|
187
|
+
│
|
|
188
|
+
├─ ASTParser (tree-sitter)
|
|
189
|
+
│ └─ ParsedEntity[]: class, function, import
|
|
190
|
+
│
|
|
191
|
+
├─ GraphBuilder (NetworkX DiGraph)
|
|
192
|
+
│ ├─ Nodes: file, class, function, import, markdown
|
|
193
|
+
│ └─ Edges: DEFINES, EXPLAINS
|
|
194
|
+
│
|
|
195
|
+
├─ LLMSummarizer (Ollama)
|
|
196
|
+
│ └─ Draws EXPLAINS edges: markdown → code entity
|
|
197
|
+
│
|
|
198
|
+
└─ VectorStore (ChromaDB)
|
|
199
|
+
└─ Embeds node summaries for semantic search
|
|
200
|
+
|
|
201
|
+
nervapack query "..."
|
|
202
|
+
│
|
|
203
|
+
├─ VectorStore.search() → seed node IDs
|
|
204
|
+
└─ GraphRetriever.retrieve_context() → BFS subgraph → Markdown
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
**Storage layout** (inside your project root):
|
|
208
|
+
```
|
|
209
|
+
.nervapack/
|
|
210
|
+
├── graph.graphml # NetworkX graph (deterministic structure)
|
|
211
|
+
└── chroma_db/ # ChromaDB (semantic embeddings)
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
**Source modules:**
|
|
215
|
+
| Module | Responsibility |
|
|
216
|
+
|---|---|
|
|
217
|
+
| `nervapack.parser.ast_parser` | Tree-sitter parsing → `ParsedEntity` objects |
|
|
218
|
+
| `nervapack.parser.md_chunker` | Markdown → header-delimited chunks |
|
|
219
|
+
| `nervapack.graph.builder` | Build and persist the NetworkX DiGraph |
|
|
220
|
+
| `nervapack.graph.vector_store` | ChromaDB ingest and semantic search |
|
|
221
|
+
| `nervapack.graph.retrieval` | K-Hop BFS context extraction |
|
|
222
|
+
| `nervapack.llm.summarizer` | Local Ollama interface for LLM binding |
|
|
223
|
+
| `nervapack.git.tracker` | GitPython diff for incremental sync |
|
|
224
|
+
|
|
225
|
+
---
|
|
226
|
+
|
|
227
|
+
## Privacy
|
|
228
|
+
|
|
229
|
+
NervaPack is 100% offline. No code, documentation, or query ever leaves your machine:
|
|
230
|
+
|
|
231
|
+
- Embeddings are generated by ChromaDB's built-in local model.
|
|
232
|
+
- LLM calls go exclusively to `localhost:11434` (your Ollama instance).
|
|
233
|
+
- All graph and vector data is stored in `.nervapack/` inside your project.
|
|
234
|
+
|
|
235
|
+
Add `.nervapack/` to your `.gitignore` to keep it out of version control.
|
|
236
|
+
|
|
237
|
+
---
|
|
238
|
+
|
|
239
|
+
## Contributing
|
|
240
|
+
|
|
241
|
+
1. Fork the repo and create a branch.
|
|
242
|
+
2. Make your changes with tests where applicable.
|
|
243
|
+
3. Open a pull request against `master`.
|
|
244
|
+
|
|
245
|
+
Bug reports and feature requests go to the [issue tracker](https://github.com/ramdhavepreetam/NervaPack/issues).
|
|
246
|
+
|
|
247
|
+
---
|
|
248
|
+
|
|
249
|
+
## License
|
|
250
|
+
|
|
251
|
+
MIT — see [LICENSE](LICENSE).
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
# NervaPack
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/nervapack/)
|
|
4
|
+
[](https://pypi.org/project/nervapack/)
|
|
5
|
+
[](https://opensource.org/licenses/MIT)
|
|
6
|
+
|
|
7
|
+
**NervaPack** is a privacy-first, offline knowledge graph for your codebase. It solves two fundamental problems with standard Vector RAG:
|
|
8
|
+
|
|
9
|
+
- **Token waste** — chunk-based RAG retrieves blobs of text that may only tangentially relate to your query, bloating your context window.
|
|
10
|
+
- **Privacy risk** — sending code to cloud embedding APIs leaks your proprietary logic.
|
|
11
|
+
|
|
12
|
+
NervaPack runs 100% on your machine. It uses `tree-sitter` to parse your codebase into a deterministic Abstract Syntax Tree graph, then uses a local Ollama model to draw hard semantic edges between your documentation and your code. Queries traverse this graph with a K-Hop BFS, returning a hyper-targeted, token-efficient context window — no cloud required.
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Why NervaPack vs. standard Vector RAG
|
|
17
|
+
|
|
18
|
+
| | Standard Vector RAG | NervaPack |
|
|
19
|
+
|---|---|---|
|
|
20
|
+
| **Parsing** | Arbitrary text chunks | Deterministic AST nodes (class, function, import) |
|
|
21
|
+
| **Retrieval** | Nearest-neighbor blob | K-Hop BFS on a structural graph |
|
|
22
|
+
| **Doc ↔ Code links** | None | Hard `EXPLAINS` edges drawn by local LLM |
|
|
23
|
+
| **Privacy** | Cloud embeddings | 100% local (ChromaDB + Ollama) |
|
|
24
|
+
| **Incremental sync** | Re-index everything | Surgical per-file update via GitPython diff |
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Prerequisites
|
|
29
|
+
|
|
30
|
+
- **Python 3.10+**
|
|
31
|
+
- **Ollama** — install from [ollama.com](https://ollama.com/), then pull a model:
|
|
32
|
+
```bash
|
|
33
|
+
ollama pull llama3
|
|
34
|
+
```
|
|
35
|
+
NervaPack defaults to `llama3`. Any model that can follow instructions works.
|
|
36
|
+
- **Git** — your project must be a git repository (`git init` if not).
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## Installation
|
|
41
|
+
|
|
42
|
+
**Option A — Homebrew (Mac/Linux, recommended)**
|
|
43
|
+
```bash
|
|
44
|
+
brew tap ramdhavepreetam/nervapack
|
|
45
|
+
brew install nervapack
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
**Option B — pipx (any platform, cleanest Python install)**
|
|
49
|
+
```bash
|
|
50
|
+
pipx install nervapack
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
**Option C — pip**
|
|
54
|
+
```bash
|
|
55
|
+
pip install nervapack
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
> On first run, `chromadb` downloads `onnxruntime` embedding models to your cache and `tree-sitter` compiles its language bindings. This is a one-time setup (~1–2 min).
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## Quick Start
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
cd your-project/
|
|
66
|
+
|
|
67
|
+
# 1. Build the knowledge graph (run once)
|
|
68
|
+
nervapack ingest .
|
|
69
|
+
|
|
70
|
+
# 2. Query for context
|
|
71
|
+
nervapack query "How does authentication work?"
|
|
72
|
+
|
|
73
|
+
# 3. After modifying files, sync the graph incrementally
|
|
74
|
+
nervapack sync .
|
|
75
|
+
|
|
76
|
+
# 4. Check graph health
|
|
77
|
+
nervapack status
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## Command Reference
|
|
83
|
+
|
|
84
|
+
### `nervapack ingest [PATH]`
|
|
85
|
+
|
|
86
|
+
Scans `PATH` (default: `.`) and builds the full knowledge graph.
|
|
87
|
+
|
|
88
|
+
What happens:
|
|
89
|
+
1. `tree-sitter` parses all `.py`, `.js`, `.jsx`, `.ts`, `.tsx` files into Classes, Functions, and Imports — exact AST nodes, not text chunks.
|
|
90
|
+
2. All `.md` files are chunked by header hierarchy.
|
|
91
|
+
3. Each Markdown chunk is sent to your local Ollama model. If the model identifies a code entity the prose explains, a hard `EXPLAINS` edge is written into the graph.
|
|
92
|
+
4. All nodes are embedded and stored in a local ChromaDB instance (`.nervapack/chroma_db`).
|
|
93
|
+
|
|
94
|
+
> The initial LLM binding pass is the slowest step. On a large repo with many docs, budget several minutes.
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
### `nervapack query PROMPT`
|
|
99
|
+
|
|
100
|
+
Retrieves context from the graph for a natural-language prompt.
|
|
101
|
+
|
|
102
|
+
What happens:
|
|
103
|
+
1. The prompt is embedded and ChromaDB returns the top-3 most semantically similar nodes.
|
|
104
|
+
2. Those nodes seed a K-Hop Breadth-First Search (default `max_hops=1`) through the NetworkX graph.
|
|
105
|
+
3. Adjacent nodes — including any Markdown docs linked via `EXPLAINS` edges — are collected into a compressed Markdown snippet and printed to your terminal.
|
|
106
|
+
|
|
107
|
+
The output is designed to be pasted directly into an LLM prompt as context.
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
### `nervapack sync [PATH]`
|
|
112
|
+
|
|
113
|
+
Incrementally updates the graph for files changed since the last ingest.
|
|
114
|
+
|
|
115
|
+
What happens:
|
|
116
|
+
1. `GitPython` diffs your working tree to find modified and deleted files.
|
|
117
|
+
2. For each changed file, old graph nodes and ChromaDB vectors are pruned.
|
|
118
|
+
3. Only the changed files are re-parsed and re-ingested.
|
|
119
|
+
|
|
120
|
+
A full `ingest` on a large codebase can take minutes. `sync` turns that into a 2–5 second surgical update.
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
### `nervapack status`
|
|
125
|
+
|
|
126
|
+
Prints the current state of the graph: node count, edge count, and any files that are out of sync with the graph.
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## Configuration
|
|
131
|
+
|
|
132
|
+
NervaPack reads the Ollama model from the `LLMSummarizer` class (`src/nervapack/llm/summarizer.py`). To use a different model, set `model` to any model you have pulled locally:
|
|
133
|
+
|
|
134
|
+
```python
|
|
135
|
+
# src/nervapack/llm/summarizer.py
|
|
136
|
+
self.model = "phi3" # or "mistral", "codellama", etc.
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Ollama is expected at `http://localhost:11434` (its default). To use a remote Ollama instance, set `OLLAMA_HOST`:
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
OLLAMA_HOST=http://my-server:11434 nervapack ingest .
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## Architecture
|
|
148
|
+
|
|
149
|
+
```
|
|
150
|
+
nervapack ingest .
|
|
151
|
+
│
|
|
152
|
+
├─ ASTParser (tree-sitter)
|
|
153
|
+
│ └─ ParsedEntity[]: class, function, import
|
|
154
|
+
│
|
|
155
|
+
├─ GraphBuilder (NetworkX DiGraph)
|
|
156
|
+
│ ├─ Nodes: file, class, function, import, markdown
|
|
157
|
+
│ └─ Edges: DEFINES, EXPLAINS
|
|
158
|
+
│
|
|
159
|
+
├─ LLMSummarizer (Ollama)
|
|
160
|
+
│ └─ Draws EXPLAINS edges: markdown → code entity
|
|
161
|
+
│
|
|
162
|
+
└─ VectorStore (ChromaDB)
|
|
163
|
+
└─ Embeds node summaries for semantic search
|
|
164
|
+
|
|
165
|
+
nervapack query "..."
|
|
166
|
+
│
|
|
167
|
+
├─ VectorStore.search() → seed node IDs
|
|
168
|
+
└─ GraphRetriever.retrieve_context() → BFS subgraph → Markdown
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
**Storage layout** (inside your project root):
|
|
172
|
+
```
|
|
173
|
+
.nervapack/
|
|
174
|
+
├── graph.graphml # NetworkX graph (deterministic structure)
|
|
175
|
+
└── chroma_db/ # ChromaDB (semantic embeddings)
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
**Source modules:**
|
|
179
|
+
| Module | Responsibility |
|
|
180
|
+
|---|---|
|
|
181
|
+
| `nervapack.parser.ast_parser` | Tree-sitter parsing → `ParsedEntity` objects |
|
|
182
|
+
| `nervapack.parser.md_chunker` | Markdown → header-delimited chunks |
|
|
183
|
+
| `nervapack.graph.builder` | Build and persist the NetworkX DiGraph |
|
|
184
|
+
| `nervapack.graph.vector_store` | ChromaDB ingest and semantic search |
|
|
185
|
+
| `nervapack.graph.retrieval` | K-Hop BFS context extraction |
|
|
186
|
+
| `nervapack.llm.summarizer` | Local Ollama interface for LLM binding |
|
|
187
|
+
| `nervapack.git.tracker` | GitPython diff for incremental sync |
|
|
188
|
+
|
|
189
|
+
---
|
|
190
|
+
|
|
191
|
+
## Privacy
|
|
192
|
+
|
|
193
|
+
NervaPack is 100% offline. No code, documentation, or query ever leaves your machine:
|
|
194
|
+
|
|
195
|
+
- Embeddings are generated by ChromaDB's built-in local model.
|
|
196
|
+
- LLM calls go exclusively to `localhost:11434` (your Ollama instance).
|
|
197
|
+
- All graph and vector data is stored in `.nervapack/` inside your project.
|
|
198
|
+
|
|
199
|
+
Add `.nervapack/` to your `.gitignore` to keep it out of version control.
|
|
200
|
+
|
|
201
|
+
---
|
|
202
|
+
|
|
203
|
+
## Contributing
|
|
204
|
+
|
|
205
|
+
1. Fork the repo and create a branch.
|
|
206
|
+
2. Make your changes with tests where applicable.
|
|
207
|
+
3. Open a pull request against `master`.
|
|
208
|
+
|
|
209
|
+
Bug reports and feature requests go to the [issue tracker](https://github.com/ramdhavepreetam/NervaPack/issues).
|
|
210
|
+
|
|
211
|
+
---
|
|
212
|
+
|
|
213
|
+
## License
|
|
214
|
+
|
|
215
|
+
MIT — see [LICENSE](LICENSE).
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=77.0.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "nervapack"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Privacy-first, offline knowledge graph for developers"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
license-files = ["LICENSE"]
|
|
13
|
+
authors = [
|
|
14
|
+
{name = "Preetam Ramdhave", email = "ramdhavepreetam@gmail.com"}
|
|
15
|
+
]
|
|
16
|
+
keywords = ["knowledge-graph", "rag", "ast", "code-search", "offline", "llm", "developer-tools"]
|
|
17
|
+
classifiers = [
|
|
18
|
+
"Development Status :: 4 - Beta",
|
|
19
|
+
"Environment :: Console",
|
|
20
|
+
"Intended Audience :: Developers",
|
|
21
|
+
"Topic :: Software Development :: Build Tools",
|
|
22
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
23
|
+
"Programming Language :: Python :: 3",
|
|
24
|
+
"Programming Language :: Python :: 3.10",
|
|
25
|
+
"Programming Language :: Python :: 3.11",
|
|
26
|
+
"Programming Language :: Python :: 3.12",
|
|
27
|
+
"Operating System :: OS Independent"
|
|
28
|
+
]
|
|
29
|
+
dependencies = [
|
|
30
|
+
"typer>=0.9.0",
|
|
31
|
+
"rich>=13.0.0",
|
|
32
|
+
"tree-sitter>=0.22.3",
|
|
33
|
+
"tree-sitter-python>=0.21.0",
|
|
34
|
+
"tree-sitter-javascript>=0.21.2",
|
|
35
|
+
"tree-sitter-typescript>=0.21.2",
|
|
36
|
+
"networkx>=3.1",
|
|
37
|
+
"ollama>=0.2.0",
|
|
38
|
+
"gitpython>=3.1.30",
|
|
39
|
+
"chromadb>=0.4.24"
|
|
40
|
+
]
|
|
41
|
+
|
|
42
|
+
[project.urls]
|
|
43
|
+
Homepage = "https://github.com/ramdhavepreetam/NervaPack"
|
|
44
|
+
Repository = "https://github.com/ramdhavepreetam/NervaPack"
|
|
45
|
+
"Bug Tracker" = "https://github.com/ramdhavepreetam/NervaPack/issues"
|
|
46
|
+
Documentation = "https://github.com/ramdhavepreetam/NervaPack#readme"
|
|
47
|
+
|
|
48
|
+
[project.scripts]
|
|
49
|
+
nervapack = "nervapack.cli:app"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# NervaPack module
|