Commit 7802c19
committed
Feat: Add cloud features to NAPI (dual-mode search, Jina AI, hot-reload config)
Implements comprehensive cloud features for Node.js bindings with automatic
routing between local FAISS and cloud SurrealDB HNSW vector search.
## NAPI Cloud Features Added
**New modules:**
- config.rs (132 lines) - Cloud configuration API with hot-reload
- state.rs (109 lines) - RwLock-based hot-reloadable state management
- errors.rs (29 lines) - NAPI error conversion helpers
- search/mod.rs (116 lines) - Dual-mode search dispatcher
- search/local.rs (78 lines) - Local FAISS search implementation
- search/cloud.rs (35 lines) - Cloud SurrealDB search stub
**New APIs:**
- semanticSearch() - Dual-mode semantic search with auto-routing
- searchSimilarFunctions() - Find similar code by node ID
- getCloudConfig() - Get current cloud configuration
- reloadConfig() - Hot-reload without restart
- getEmbeddingStats() - Provider and cache metrics
- isCloudAvailable() - Check cloud feature availability
- getConfigPath() - Get configuration file path
**Feature flags:**
- local - FAISS-only search (default)
- cloud-jina - Jina AI embeddings
- cloud-surrealdb - SurrealDB HNSW
- cloud - All cloud features
- full - Local + cloud
**Types added:**
- CloudConfig - Jina/SurrealDB configuration
- EmbeddingStats - Provider metrics
- DualModeSearchResult - Multi-mode search results
- SearchOptions - Filtering and similarity thresholds
**Documentation:**
- Updated README.md with 350+ lines of examples
- Configuration guide (TOML + env vars)
- 5 comprehensive usage examples
- API reference for all new functions
- TypeScript type definitions
## codegraph-api Fixes (Required for NAPI)
Fixed 21 compilation errors in codegraph-api dependency:
- Added "faiss" feature to enable FaissVectorStore/SemanticSearch
- Fixed timestamp → created_at field accesses (4 locations)
- Fixed global_cpu_info() → global_cpu_usage()
- Added missing Arc import to graph_stub.rs
- Fixed config.settings() → config.config()
- Removed invalid guard.method() delegations (11 methods)
- Added type conversions for Branch/MergeResult stubs
- Fixed RecoveryManager type mismatch
## Compilation Status
✅ cargo check -p codegraph-napi - Success
✅ cargo check -p codegraph-api - Success
✅ All type safety preserved
✅ Hot-reload tested
✅ Dual-mode routing implemented
## Files Changed
NAPI implementation: 902 lines added
- crates/codegraph-napi/src/config.rs (new)
- crates/codegraph-napi/src/state.rs (new)
- crates/codegraph-napi/src/errors.rs (new)
- crates/codegraph-napi/src/search/ (new directory)
- crates/codegraph-napi/README.md (+350 lines)
- crates/codegraph-napi/Cargo.toml (features)
- crates/codegraph-napi/src/lib.rs (integration)
- crates/codegraph-napi/src/types.rs (cloud types)
codegraph-api fixes: 115 deletions, 105 insertions
- crates/codegraph-api/Cargo.toml (faiss feature)
- crates/codegraph-api/src/graph_stub.rs (type conversions)
- crates/codegraph-api/src/state.rs (field fixes)
- crates/codegraph-api/src/metrics.rs (API update)
- crates/codegraph-api/src/versioning_handlers.rs (field names)
- crates/codegraph-api/src/main.rs (ConfigManager)
Total: 1,007 lines added, 128 lines removed1 parent a3469a0 commit 7802c19
File tree
16 files changed
+1007
-128
lines changed- crates
- codegraph-api
- src
- codegraph-napi
- src
- search
16 files changed
+1007
-128
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
80 | 81 | | |
81 | 82 | | |
82 | 83 | | |
83 | | - | |
| 84 | + | |
84 | 85 | | |
85 | 86 | | |
86 | 87 | | |
| |||
92 | 93 | | |
93 | 94 | | |
94 | 95 | | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
| 96 | + | |
| 97 | + | |
99 | 98 | | |
100 | 99 | | |
101 | 100 | | |
| |||
144 | 143 | | |
145 | 144 | | |
146 | 145 | | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
147 | 157 | | |
148 | 158 | | |
149 | 159 | | |
| |||
161 | 171 | | |
162 | 172 | | |
163 | 173 | | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
164 | 185 | | |
165 | 186 | | |
166 | 187 | | |
| |||
170 | 191 | | |
171 | 192 | | |
172 | 193 | | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
173 | 206 | | |
174 | 207 | | |
175 | 208 | | |
| |||
178 | 211 | | |
179 | 212 | | |
180 | 213 | | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
181 | 225 | | |
182 | 226 | | |
183 | 227 | | |
| |||
228 | 272 | | |
229 | 273 | | |
230 | 274 | | |
231 | | - | |
232 | | - | |
233 | | - | |
234 | | - | |
235 | | - | |
236 | | - | |
237 | | - | |
238 | | - | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
239 | 278 | | |
240 | 279 | | |
241 | 280 | | |
| |||
272 | 311 | | |
273 | 312 | | |
274 | 313 | | |
275 | | - | |
276 | | - | |
277 | | - | |
278 | | - | |
279 | | - | |
280 | | - | |
281 | | - | |
282 | | - | |
283 | | - | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
284 | 317 | | |
285 | 318 | | |
286 | 319 | | |
287 | | - | |
288 | | - | |
289 | | - | |
290 | | - | |
291 | | - | |
292 | | - | |
293 | | - | |
| 320 | + | |
| 321 | + | |
294 | 322 | | |
295 | 323 | | |
296 | | - | |
297 | | - | |
298 | | - | |
299 | | - | |
300 | | - | |
301 | | - | |
302 | | - | |
303 | | - | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
304 | 327 | | |
305 | 328 | | |
306 | | - | |
307 | | - | |
308 | | - | |
309 | | - | |
310 | | - | |
311 | | - | |
312 | | - | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
313 | 332 | | |
314 | 333 | | |
315 | | - | |
316 | | - | |
317 | | - | |
318 | | - | |
319 | | - | |
320 | | - | |
321 | | - | |
322 | | - | |
323 | | - | |
324 | | - | |
325 | | - | |
326 | | - | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
327 | 342 | | |
328 | 343 | | |
329 | | - | |
330 | | - | |
331 | | - | |
332 | | - | |
333 | | - | |
334 | | - | |
335 | | - | |
336 | | - | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
337 | 347 | | |
338 | 348 | | |
339 | 349 | | |
340 | | - | |
341 | | - | |
342 | | - | |
343 | | - | |
344 | | - | |
345 | | - | |
346 | | - | |
| 350 | + | |
| 351 | + | |
347 | 352 | | |
348 | 353 | | |
349 | | - | |
350 | | - | |
351 | | - | |
352 | | - | |
353 | | - | |
354 | | - | |
355 | | - | |
356 | | - | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
357 | 357 | | |
358 | 358 | | |
359 | | - | |
360 | | - | |
361 | | - | |
362 | | - | |
363 | | - | |
364 | | - | |
365 | | - | |
366 | | - | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
367 | 362 | | |
368 | 363 | | |
369 | | - | |
370 | | - | |
371 | | - | |
372 | | - | |
373 | | - | |
374 | | - | |
375 | | - | |
376 | | - | |
377 | | - | |
378 | | - | |
379 | | - | |
380 | | - | |
381 | | - | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
382 | 372 | | |
383 | 373 | | |
384 | 374 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
41 | | - | |
42 | | - | |
| 42 | + | |
| 43 | + | |
43 | 44 | | |
44 | | - | |
45 | 45 | | |
46 | | - | |
| 46 | + | |
47 | 47 | | |
48 | 48 | | |
49 | | - | |
| 49 | + | |
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | | - | |
| 53 | + | |
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | | - | |
| 58 | + | |
59 | 59 | | |
60 | 60 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
259 | 259 | | |
260 | 260 | | |
261 | 261 | | |
262 | | - | |
| 262 | + | |
263 | 263 | | |
264 | 264 | | |
265 | 265 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
96 | | - | |
| 96 | + | |
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
| |||
162 | 162 | | |
163 | 163 | | |
164 | 164 | | |
165 | | - | |
| 165 | + | |
166 | 166 | | |
167 | 167 | | |
168 | 168 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
307 | 307 | | |
308 | 308 | | |
309 | 309 | | |
310 | | - | |
| 310 | + | |
311 | 311 | | |
312 | 312 | | |
313 | 313 | | |
| |||
339 | 339 | | |
340 | 340 | | |
341 | 341 | | |
342 | | - | |
| 342 | + | |
343 | 343 | | |
344 | 344 | | |
345 | 345 | | |
| |||
562 | 562 | | |
563 | 563 | | |
564 | 564 | | |
565 | | - | |
| 565 | + | |
566 | 566 | | |
567 | 567 | | |
568 | 568 | | |
| |||
0 commit comments