codegraph-voyage 0.1.0__py3-none-any.whl

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.
@@ -0,0 +1,196 @@
1
+ Metadata-Version: 2.5
2
+ Name: codegraph-voyage
3
+ Version: 0.1.0
4
+ Summary: Hybrid semantic retrieval sidecar for CodeGraph
5
+ Author-email: Jarad <delorenj@delo.sh>
6
+ License: MIT
7
+ Requires-Python: >=3.10
8
+ Provides-Extra: mcp
9
+ Requires-Dist: mcp>=1.0.0; extra == 'mcp'
10
+ Description-Content-Type: text/markdown
11
+
12
+ # codegraph-voyage
13
+
14
+ Hybrid semantic retrieval sidecar for [CodeGraph](https://github.com/nousresearch/codegraph).
15
+
16
+ ## What it does
17
+
18
+ Builds symbol-level documents from a CodeGraph index, generates embedding vectors
19
+ via the Voyage AI API (or a deterministic fake for testing), stores them in a
20
+ sidecar SQLite database, and fuses lexical + vector retrieval via **weighted
21
+ reciprocal-rank fusion (RRF)**.
22
+
23
+ ## Setup
24
+
25
+ ```bash
26
+ # No dependencies beyond stdlib (Python 3.10+)
27
+ # Optional: set VOYAGE_API_KEY for real embedding
28
+ export VOYAGE_API_KEY="paas-...-...-..."
29
+ ```
30
+
31
+ ## Privacy & retention risk
32
+
33
+ Source text is transmitted to Voyage AI when the Voyage provider is selected.
34
+ The locally sanitized/redacted document content is what is sent, and Voyage
35
+ AI's data-use and retention policy applies to that transmission. Embeddings can
36
+ retain information about their inputs and should still be treated as sensitive.
37
+ The sidecar also stores the sanitized document text locally alongside each
38
+ embedding for provenance. It lives at `.codegraph/codegraph-voyage.db`; deleting
39
+ that sidecar removes these local text and embedding copies without affecting the
40
+ CodeGraph index.
41
+
42
+ ## Source exclusions
43
+
44
+ Before any content is sent to the remote embedding API, the sanitizer
45
+ removes or redacts:
46
+
47
+ - **Sensitive paths**: `.env`, `credentials/`, `secrets/`, `*.pem`, `*.key`,
48
+ `.git/`, `__pycache__/`, `node_modules/`, `.venv/`, `dist/`, `build/`, etc.
49
+ - **Sensitive line patterns**: Lines matching `password=`, `api_key=`,
50
+ `token=`, `secret=`, etc. with apparent values are replaced with a
51
+ `[redacted]` comment.
52
+
53
+ These checks happen **locally, before the API call**. The Voyage API never
54
+ sees the excluded content.
55
+
56
+ ## Commands
57
+
58
+ | Command | Description |
59
+ |---|---|
60
+ | `codegraph-voyage index` | Build documents and store embeddings |
61
+ | `codegraph-voyage search <query>` | Hybrid semantic search |
62
+ | `codegraph-voyage status` | Show sidecar & CodeGraph status |
63
+ | `codegraph-voyage explore <query>` | Search + `codegraph explore` integration |
64
+
65
+ ### `index`
66
+
67
+ Reads the CodeGraph DB at `.codegraph/codegraph.db`, builds symbol-level
68
+ documents from node metadata and source line ranges, generates embeddings
69
+ via the configured provider, and stores them in `.codegraph/codegraph-voyage.db`.
70
+
71
+ Incremental: only changed/new documents are re-embedded. Stale records are
72
+ removed.
73
+
74
+ ```bash
75
+ # Index with fake provider (no API key, for testing)
76
+ codegraph-voyage index
77
+
78
+ # Index with voyage-code-4
79
+ VOYAGE_API_KEY="paas-..." codegraph-voyage index --provider voyage
80
+
81
+ # Index only functions and classes
82
+ codegraph-voyage index --kind "function,class"
83
+
84
+ # Index only files matching a pattern
85
+ codegraph-voyage index --file-filter "src/auth"
86
+ ```
87
+
88
+ ### `search` / `semantic_candidates`
89
+
90
+ Performs hybrid lexical + vector search on the indexed corpus. Results are
91
+ fused via weighted RRF. Exact identifier and path matches are **pinned** to
92
+ the top of results.
93
+
94
+ ```bash
95
+ codegraph-voyage search "user authentication"
96
+ codegraph-voyage search "AuthService" --top-k 10 --json
97
+ ```
98
+
99
+ ### `explore`
100
+
101
+ Runs hybrid search, then passes the top-ranked candidate symbols to
102
+ `codegraph explore` for a full dependency-graph walk.
103
+
104
+ ```bash
105
+ codegraph-voyage explore "PaymentGateway" --max-files 8
106
+ codegraph-voyage explore "UserManager" --dry-run # preview only
107
+ ```
108
+
109
+ ### `status`
110
+
111
+ Shows the project root, CodeGraph DB stats, and sidecar embedding status.
112
+
113
+ ```bash
114
+ codegraph-voyage status
115
+ ```
116
+
117
+ ## Architecture
118
+
119
+ ```
120
+ tools/codegraph_voyage/
121
+ ├── __init__.py # Package metadata
122
+ ├── __main__.py # python -m entry point
123
+ ├── cli.py # CLI argument parsing and command dispatch
124
+ ├── document.py # Symbol-level document construction from CodeGraph nodes
125
+ ├── providers.py # EmbeddingProvider ABC, FakeEmbeddingProvider, VoyageEmbeddingProvider
126
+ ├── ranking.py # Weighted RRF, pinned candidates, cosine similarity
127
+ ├── sidecar.py # SQLite sidecar for embedding storage with incremental indexing
128
+ ├── sanitize.py # Path/content sanitization before remote transmission
129
+ ├── explore.py # Integration with `codegraph explore` CLI
130
+ └── tests/
131
+ ├── __init__.py
132
+ ├── test_all.py # Unit test suite
133
+ └── benchmark.py # Retrieval quality benchmark (smoke)
134
+ ```
135
+
136
+ The importable Python path is `tools.codegraph_voyage` (the underscore is
137
+ standard for multi-word CLI package names).
138
+
139
+ ## Offline / fake mode
140
+
141
+ By default, the provider is `fake`, which produces deterministic embeddings
142
+ from text content. No API key or network access is needed. The fake provider
143
+ is suitable for development, testing, and CI.
144
+
145
+ ```bash
146
+ codegraph-voyage index # uses fake by default
147
+ codegraph-voyage index --provider fake # explicit
148
+ ```
149
+
150
+ ## Real Voyage AI (opt-in)
151
+
152
+ Set `VOYAGE_API_KEY` in your environment and pass `--provider voyage`:
153
+
154
+ ```bash
155
+ export VOYAGE_API_KEY="paas-..."
156
+ codegraph-voyage index --provider voyage
157
+ ```
158
+
159
+ The API key is **never** accepted via CLI flags to prevent secret leakage
160
+ through process listings or shell history.
161
+
162
+ ## Benchmark
163
+
164
+ A smoke benchmark is included to verify the retrieval pipeline works:
165
+
166
+ ```bash
167
+ python -m codegraph_voyage.tests.benchmark
168
+ ```
169
+
170
+ This uses a tiny synthetic corpus (10 documents, 5 queries). It reports
171
+ Recall@5, MRR, and NDCG@10 separately for lexical, vector, and fused
172
+ strategies. **No quality-lift claims should be made from these results.**
173
+ The benchmark exists to verify that the pipeline produces measurable output
174
+ and that fusion can improve over the worst single strategy.
175
+
176
+ ## Testing
177
+
178
+ ```bash
179
+ python -m codegraph_voyage.tests.test_all
180
+ ```
181
+
182
+ ## Limitations
183
+
184
+ - **Small corpus**: Real-world benefit requires hundreds of indexed symbols.
185
+ - **Lexical ranker**: Uses a simple TF-IDF-like scorer, not a full BM25
186
+ implementation. Adequate for moderate queries but not tuned for maximum
187
+ lexical precision.
188
+ - **Vector search**: Brute-force cosine similarity. For large corpora
189
+ (>10K vectors), an approximate nearest-neighbor index would be needed.
190
+ - **Sidecar DB**: All embeddings are stored in a single SQLite database.
191
+ For very large projects, consider sharding by model or module.
192
+ - **Voyage API**: Requires network access. The `input_type` parameter is
193
+ set to `document` for indexing and `query` for search queries, as
194
+ recommended by Voyage AI's documentation.
195
+ - **No `requests` dependency**: The Voyage provider uses `urllib.request`
196
+ from stdlib, so no pip install is needed for the runtime.
@@ -0,0 +1,17 @@
1
+ codegraph_voyage/__init__.py,sha256=WeM51YjX-VmIRjrm4c_e8ngzLSZuE5NWfVCI1x6mcso,332
2
+ codegraph_voyage/__main__.py,sha256=m8pmvKpdIjtXEp8J0xdU3npkdQT8EJQImRc4EdINL64,130
3
+ codegraph_voyage/cli.py,sha256=g55yY4uRx72oQwy_urJGQswsy_O3VgklILc-RloEyxo,22776
4
+ codegraph_voyage/document.py,sha256=ipcCFZfYA_-C4UzWKTY1wk_MYiz2kBxona0xGZzOxB0,7940
5
+ codegraph_voyage/explore.py,sha256=HKCTs71BJmBf2OQef2a5eoD-s76BY--t1FX3xxhlqEs,4419
6
+ codegraph_voyage/mcp_server.py,sha256=j4wXUG-bczkPfnikSOQR2aMEv1bYX96b7qKidQ9siA4,2698
7
+ codegraph_voyage/providers.py,sha256=in2RancPfpqE0F-qBeFLpeQdPrGv-DvGH28WZwfXeL0,9935
8
+ codegraph_voyage/ranking.py,sha256=diYbw1eNPyVCZhI7Nj4FSDEe1H0_uFE_gpR4HIXNTsE,15351
9
+ codegraph_voyage/sanitize.py,sha256=IYjxUVPU7gEw7I2wTafODTgGHCaKQpxXT7XFwdKch4s,4735
10
+ codegraph_voyage/sidecar.py,sha256=BB1rVG-foJojkpZYl86qQ3JMX-K-xpdwq6OTTEgxS_Q,12244
11
+ codegraph_voyage/tests/__init__.py,sha256=xI4bGIHKRB-DV2x_-VOj24h7_ZUbl2ufi_2iO8SJ8_0,33
12
+ codegraph_voyage/tests/benchmark.py,sha256=nOB0ESnj-SGdlp_zrqTRZdVFqySRPP3u7Q4cvSU2M3Q,11512
13
+ codegraph_voyage/tests/test_all.py,sha256=i9cb_HLN02D5jM2IPVl6Z20acZLItUITh4GiNkt6iJw,48561
14
+ codegraph_voyage-0.1.0.dist-info/METADATA,sha256=uW1bofW0TBWHln19hWormaiHNlSrCT-EBBzZnpTHG5Y,6811
15
+ codegraph_voyage-0.1.0.dist-info/WHEEL,sha256=zOwg4jB6zX2kU910N-cMawjivD6tO8NEWvE12je1bVk,87
16
+ codegraph_voyage-0.1.0.dist-info/entry_points.txt,sha256=SLm0zX2FRFL34a6ks_2msSORMM4mrT96OkI9Muxx7Hs,119
17
+ codegraph_voyage-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.32.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,3 @@
1
+ [console_scripts]
2
+ codegraph-voyage = codegraph_voyage.cli:main
3
+ codegraph-voyage-mcp = codegraph_voyage.mcp_server:main