@colbymchenry/codegraph 0.2.9 → 0.4.8
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.
Potentially problematic release.
This version of @colbymchenry/codegraph might be problematic. Click here for more details.
- package/LICENSE +21 -21
- package/README.md +647 -641
- package/dist/bin/codegraph.d.ts +7 -2
- package/dist/bin/codegraph.d.ts.map +1 -1
- package/dist/bin/codegraph.js +360 -140
- package/dist/bin/codegraph.js.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +8 -1
- package/dist/config.js.map +1 -1
- package/dist/context/index.d.ts +17 -4
- package/dist/context/index.d.ts.map +1 -1
- package/dist/context/index.js +182 -15
- package/dist/context/index.js.map +1 -1
- package/dist/db/index.d.ts.map +1 -1
- package/dist/db/index.js +16 -0
- package/dist/db/index.js.map +1 -1
- package/dist/db/migrations.d.ts +1 -1
- package/dist/db/migrations.d.ts.map +1 -1
- package/dist/db/migrations.js +11 -12
- package/dist/db/migrations.js.map +1 -1
- package/dist/db/queries.d.ts +19 -0
- package/dist/db/queries.d.ts.map +1 -1
- package/dist/db/queries.js +221 -107
- package/dist/db/queries.js.map +1 -1
- package/dist/db/schema.sql +154 -149
- package/dist/directory.d.ts +13 -1
- package/dist/directory.d.ts.map +1 -1
- package/dist/directory.js +62 -19
- package/dist/directory.js.map +1 -1
- package/dist/errors.d.ts +1 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +7 -1
- package/dist/errors.js.map +1 -1
- package/dist/extraction/grammars.d.ts +9 -4
- package/dist/extraction/grammars.d.ts.map +1 -1
- package/dist/extraction/grammars.js +133 -65
- package/dist/extraction/grammars.js.map +1 -1
- package/dist/extraction/index.d.ts.map +1 -1
- package/dist/extraction/index.js +119 -7
- package/dist/extraction/index.js.map +1 -1
- package/dist/extraction/tree-sitter.d.ts +62 -0
- package/dist/extraction/tree-sitter.d.ts.map +1 -1
- package/dist/extraction/tree-sitter.js +937 -34
- package/dist/extraction/tree-sitter.js.map +1 -1
- package/dist/graph/traversal.d.ts.map +1 -1
- package/dist/graph/traversal.js +6 -2
- package/dist/graph/traversal.js.map +1 -1
- package/dist/index.d.ts +6 -38
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +85 -74
- package/dist/index.js.map +1 -1
- package/dist/installer/banner.js +7 -7
- package/dist/installer/claude-md-template.js +32 -32
- package/dist/installer/config-writer.d.ts +9 -0
- package/dist/installer/config-writer.d.ts.map +1 -1
- package/dist/installer/config-writer.js +78 -0
- package/dist/installer/config-writer.js.map +1 -1
- package/dist/installer/index.d.ts.map +1 -1
- package/dist/installer/index.js +28 -16
- package/dist/installer/index.js.map +1 -1
- package/dist/mcp/index.d.ts +14 -3
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +109 -29
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/tools.d.ts +62 -1
- package/dist/mcp/tools.d.ts.map +1 -1
- package/dist/mcp/tools.js +414 -43
- package/dist/mcp/tools.js.map +1 -1
- package/dist/mcp/transport.d.ts.map +1 -1
- package/dist/mcp/transport.js +2 -0
- package/dist/mcp/transport.js.map +1 -1
- package/dist/resolution/frameworks/index.d.ts +1 -0
- package/dist/resolution/frameworks/index.d.ts.map +1 -1
- package/dist/resolution/frameworks/index.js +5 -1
- package/dist/resolution/frameworks/index.js.map +1 -1
- package/dist/resolution/frameworks/svelte.d.ts +9 -0
- package/dist/resolution/frameworks/svelte.d.ts.map +1 -0
- package/dist/resolution/frameworks/svelte.js +268 -0
- package/dist/resolution/frameworks/svelte.js.map +1 -0
- package/dist/resolution/index.d.ts +11 -2
- package/dist/resolution/index.d.ts.map +1 -1
- package/dist/resolution/index.js +94 -13
- package/dist/resolution/index.js.map +1 -1
- package/dist/sentry.d.ts +22 -0
- package/dist/sentry.d.ts.map +1 -0
- package/dist/sentry.js +159 -0
- package/dist/sentry.js.map +1 -0
- package/dist/sync/index.d.ts +4 -2
- package/dist/sync/index.d.ts.map +1 -1
- package/dist/sync/index.js +3 -5
- package/dist/sync/index.js.map +1 -1
- package/dist/types.d.ts +5 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +11 -0
- package/dist/types.js.map +1 -1
- package/dist/utils.d.ts +45 -2
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +114 -3
- package/dist/utils.js.map +1 -1
- package/dist/vectors/embedder.d.ts +1 -1
- package/dist/vectors/embedder.d.ts.map +1 -1
- package/dist/vectors/embedder.js +5 -2
- package/dist/vectors/embedder.js.map +1 -1
- package/dist/vectors/search.d.ts.map +1 -1
- package/dist/vectors/search.js +33 -32
- package/dist/vectors/search.js.map +1 -1
- package/package.json +72 -65
- package/scripts/patch-tree-sitter-dart.js +112 -0
- package/scripts/postinstall.js +71 -0
- package/dist/sync/git-hooks.d.ts +0 -66
- package/dist/sync/git-hooks.d.ts.map +0 -1
- package/dist/sync/git-hooks.js +0 -281
- package/dist/sync/git-hooks.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,641 +1,647 @@
|
|
|
1
|
-
<div align="center">
|
|
2
|
-
|
|
3
|
-
# 🔮 CodeGraph
|
|
4
|
-
|
|
5
|
-
### Supercharge Claude Code with Semantic Code Intelligence
|
|
6
|
-
|
|
7
|
-
**30% fewer tokens • 25% fewer tool calls • 100% local**
|
|
8
|
-
|
|
9
|
-
[](https://www.npmjs.com/package/@colbymchenry/codegraph)
|
|
10
|
-
[](https://opensource.org/licenses/MIT)
|
|
11
|
-
[](https://nodejs.org/)
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
│
|
|
74
|
-
│
|
|
75
|
-
│
|
|
76
|
-
│
|
|
77
|
-
│ │
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
│
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
│
|
|
87
|
-
│
|
|
88
|
-
│
|
|
89
|
-
│
|
|
90
|
-
│
|
|
91
|
-
│
|
|
92
|
-
│
|
|
93
|
-
│
|
|
94
|
-
│
|
|
95
|
-
│
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
###
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
"
|
|
214
|
-
"
|
|
215
|
-
"
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
|
242
|
-
|
|
243
|
-
| `
|
|
244
|
-
| `
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
**
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
codegraph
|
|
280
|
-
codegraph
|
|
281
|
-
codegraph
|
|
282
|
-
codegraph
|
|
283
|
-
codegraph
|
|
284
|
-
codegraph
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
```
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
```
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
```
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
```
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
```
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
###
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
const
|
|
480
|
-
|
|
481
|
-
//
|
|
482
|
-
const
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
|
581
|
-
|
|
582
|
-
| `
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
|
591
|
-
|
|
592
|
-
|
|
|
593
|
-
|
|
|
594
|
-
|
|
|
595
|
-
|
|
|
596
|
-
|
|
|
597
|
-
|
|
|
598
|
-
| C
|
|
599
|
-
|
|
|
600
|
-
|
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
###
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
---
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# 🔮 CodeGraph
|
|
4
|
+
|
|
5
|
+
### Supercharge Claude Code with Semantic Code Intelligence
|
|
6
|
+
|
|
7
|
+
**30% fewer tokens • 25% fewer tool calls • 100% local**
|
|
8
|
+
|
|
9
|
+
[](https://www.npmjs.com/package/@colbymchenry/codegraph)
|
|
10
|
+
[](https://opensource.org/licenses/MIT)
|
|
11
|
+
[](https://nodejs.org/)
|
|
12
|
+
|
|
13
|
+
[](#)
|
|
14
|
+
[](#)
|
|
15
|
+
[](#)
|
|
16
|
+
|
|
17
|
+
<br />
|
|
18
|
+
|
|
19
|
+
### Get Started
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npx @colbymchenry/codegraph
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
<sub>Interactive installer configures Claude Code automatically</sub>
|
|
26
|
+
|
|
27
|
+
</div>
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## 🚀 Why CodeGraph?
|
|
32
|
+
|
|
33
|
+
When you ask Claude Code to work on a complex task, it spawns **Explore agents** that scan your codebase using grep, glob, and file reads. These agents consume tokens with every tool call.
|
|
34
|
+
|
|
35
|
+
**CodeGraph gives those agents a semantic knowledge graph** — pre-indexed symbol relationships, call graphs, and code structure. Instead of scanning files, agents query the graph instantly.
|
|
36
|
+
|
|
37
|
+
### 📊 Benchmark Results
|
|
38
|
+
|
|
39
|
+
We ran the same complex task 3 times with and without CodeGraph:
|
|
40
|
+
|
|
41
|
+
| Metric | Without CodeGraph | With CodeGraph | Improvement |
|
|
42
|
+
|--------|-------------------|----------------|-------------|
|
|
43
|
+
| **Explore tokens** | 157.8k | 111.7k | **29% fewer** |
|
|
44
|
+
| **Per-agent tokens** | 74.0k | 46.4k | **37% fewer** |
|
|
45
|
+
| **Tool calls** | 60 | 45 | **25% fewer** |
|
|
46
|
+
| **Main context usage** | 28.7% | 24.0% | **4.7% less** |
|
|
47
|
+
|
|
48
|
+
<details>
|
|
49
|
+
<summary><strong>Full benchmark data</strong></summary>
|
|
50
|
+
|
|
51
|
+
**With CodeGraph:**
|
|
52
|
+
| Test | Agents | Tool Uses | Explore Tokens | Plan Tokens | Time |
|
|
53
|
+
|------|--------|-----------|----------------|-------------|------|
|
|
54
|
+
| 1 | 3 | 54 | 149.7k | 76.4k | 1m 43s |
|
|
55
|
+
| 2 | 2 | 41 | 102.1k | 74.8k | 1m 29s |
|
|
56
|
+
| 3 | 2 | 40 | 83.3k | 63.3k | 1m 25s |
|
|
57
|
+
| **Avg** | **2.3** | **45** | **111.7k** | **71.5k** | **1m 32s** |
|
|
58
|
+
|
|
59
|
+
**Without CodeGraph:**
|
|
60
|
+
| Test | Agents | Tool Uses | Explore Tokens | Plan Tokens | Time |
|
|
61
|
+
|------|--------|-----------|----------------|-------------|------|
|
|
62
|
+
| 1 | 3 | 74 | 177.3k | 80.5k | 1m 54s |
|
|
63
|
+
| 2 | 2 | 55 | 149.3k | 64.0k | 1m 27s |
|
|
64
|
+
| 3 | 2 | 51 | 146.7k | 62.3k | 1m 17s |
|
|
65
|
+
| **Avg** | **2.3** | **60** | **157.8k** | **68.9k** | **1m 33s** |
|
|
66
|
+
|
|
67
|
+
</details>
|
|
68
|
+
|
|
69
|
+
### 🔄 How It Works
|
|
70
|
+
|
|
71
|
+
```
|
|
72
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
73
|
+
│ Claude Code │
|
|
74
|
+
│ │
|
|
75
|
+
│ "Implement user authentication" │
|
|
76
|
+
│ │ │
|
|
77
|
+
│ ▼ │
|
|
78
|
+
│ ┌─────────────────┐ ┌─────────────────┐ │
|
|
79
|
+
│ │ Explore Agent │ ──── │ Explore Agent │ │
|
|
80
|
+
│ └────────┬────────┘ └────────┬────────┘ │
|
|
81
|
+
│ │ │ │
|
|
82
|
+
└───────────┼────────────────────────┼─────────────────────────────┘
|
|
83
|
+
│ │
|
|
84
|
+
▼ ▼
|
|
85
|
+
┌───────────────────────────────────────────────────────────────────┐
|
|
86
|
+
│ CodeGraph MCP Server │
|
|
87
|
+
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
|
|
88
|
+
│ │ Search │ │ Callers │ │ Context │ │
|
|
89
|
+
│ │ "auth" │ │ "login()" │ │ for task │ │
|
|
90
|
+
│ └──────┬──────┘ └──────┬──────┘ └──────┬──────┘ │
|
|
91
|
+
│ │ │ │ │
|
|
92
|
+
│ └────────────────┼────────────────┘ │
|
|
93
|
+
│ ▼ │
|
|
94
|
+
│ ┌───────────────────────┐ │
|
|
95
|
+
│ │ SQLite Graph DB │ │
|
|
96
|
+
│ │ • 387 symbols │ │
|
|
97
|
+
│ │ • 1,204 edges │ │
|
|
98
|
+
│ │ • Instant lookups │ │
|
|
99
|
+
│ └───────────────────────┘ │
|
|
100
|
+
└───────────────────────────────────────────────────────────────────┘
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
**Without CodeGraph:** Explore agents use `grep`, `glob`, and `Read` to scan files → many API calls, high token usage
|
|
104
|
+
|
|
105
|
+
**With CodeGraph:** Explore agents query the graph via MCP tools → instant results, local processing, fewer tokens
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
## ✨ Key Features
|
|
110
|
+
|
|
111
|
+
<table>
|
|
112
|
+
<tr>
|
|
113
|
+
<td width="33%" valign="top">
|
|
114
|
+
|
|
115
|
+
### 🧠 Smart Context Building
|
|
116
|
+
One tool call returns everything Claude needs—entry points, related symbols, and code snippets. No more expensive exploration agents.
|
|
117
|
+
|
|
118
|
+
</td>
|
|
119
|
+
<td width="33%" valign="top">
|
|
120
|
+
|
|
121
|
+
### 🔍 Semantic Search
|
|
122
|
+
Find code by meaning, not just text. Search for "authentication" and find `login`, `validateToken`, `AuthService`—even with different naming conventions.
|
|
123
|
+
|
|
124
|
+
</td>
|
|
125
|
+
<td width="33%" valign="top">
|
|
126
|
+
|
|
127
|
+
### 📈 Impact Analysis
|
|
128
|
+
Know exactly what breaks before you change it. Trace callers, callees, and the full impact radius of any symbol.
|
|
129
|
+
|
|
130
|
+
</td>
|
|
131
|
+
</tr>
|
|
132
|
+
<tr>
|
|
133
|
+
<td width="33%" valign="top">
|
|
134
|
+
|
|
135
|
+
### 🌍 17+ Languages
|
|
136
|
+
TypeScript, JavaScript, Python, Go, Rust, Java, C#, PHP, Ruby, C, C++, Swift, Kotlin, Dart, Svelte—all with the same API.
|
|
137
|
+
|
|
138
|
+
</td>
|
|
139
|
+
<td width="33%" valign="top">
|
|
140
|
+
|
|
141
|
+
### 🔒 100% Local
|
|
142
|
+
No data leaves your machine. No API keys. No external services. Everything runs on your local SQLite database.
|
|
143
|
+
|
|
144
|
+
</td>
|
|
145
|
+
<td width="33%" valign="top">
|
|
146
|
+
|
|
147
|
+
### ⚡ Always Fresh
|
|
148
|
+
Git hooks automatically sync the index on every commit. Your code intelligence is always up to date.
|
|
149
|
+
|
|
150
|
+
</td>
|
|
151
|
+
</tr>
|
|
152
|
+
</table>
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
## 🎯 Quick Start
|
|
157
|
+
|
|
158
|
+
### 1. Run the Installer
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
npx @colbymchenry/codegraph
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
The interactive installer will:
|
|
165
|
+
- Configure the MCP server in `~/.claude.json`
|
|
166
|
+
- Set up auto-allow permissions for CodeGraph tools
|
|
167
|
+
- Add global instructions to `~/.claude/CLAUDE.md` (teaches Claude how to use CodeGraph)
|
|
168
|
+
- Optionally initialize your current project
|
|
169
|
+
|
|
170
|
+
### 2. Restart Claude Code
|
|
171
|
+
|
|
172
|
+
Restart Claude Code for the MCP server to load.
|
|
173
|
+
|
|
174
|
+
### 3. Initialize Projects
|
|
175
|
+
|
|
176
|
+
For each project you want to use CodeGraph with:
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
cd your-project
|
|
180
|
+
codegraph init -i
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
That's it! Claude Code will now use CodeGraph tools automatically when a `.codegraph/` directory exists.
|
|
184
|
+
|
|
185
|
+
<details>
|
|
186
|
+
<summary><strong>Manual Setup (Alternative)</strong></summary>
|
|
187
|
+
|
|
188
|
+
If you prefer manual configuration:
|
|
189
|
+
|
|
190
|
+
**Install globally:**
|
|
191
|
+
```bash
|
|
192
|
+
npm install -g @colbymchenry/codegraph
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
**Add to `~/.claude.json`:**
|
|
196
|
+
```json
|
|
197
|
+
{
|
|
198
|
+
"mcpServers": {
|
|
199
|
+
"codegraph": {
|
|
200
|
+
"type": "stdio",
|
|
201
|
+
"command": "codegraph",
|
|
202
|
+
"args": ["serve", "--mcp"]
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
**Add to `~/.claude/settings.json` (optional, for auto-allow):**
|
|
209
|
+
```json
|
|
210
|
+
{
|
|
211
|
+
"permissions": {
|
|
212
|
+
"allow": [
|
|
213
|
+
"mcp__codegraph__codegraph_search",
|
|
214
|
+
"mcp__codegraph__codegraph_context",
|
|
215
|
+
"mcp__codegraph__codegraph_callers",
|
|
216
|
+
"mcp__codegraph__codegraph_callees",
|
|
217
|
+
"mcp__codegraph__codegraph_impact",
|
|
218
|
+
"mcp__codegraph__codegraph_node",
|
|
219
|
+
"mcp__codegraph__codegraph_status"
|
|
220
|
+
]
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
</details>
|
|
226
|
+
|
|
227
|
+
<details>
|
|
228
|
+
<summary><strong>Global Instructions Reference</strong></summary>
|
|
229
|
+
|
|
230
|
+
The installer automatically adds these instructions to `~/.claude/CLAUDE.md`. This is provided here for reference:
|
|
231
|
+
|
|
232
|
+
```markdown
|
|
233
|
+
## CodeGraph
|
|
234
|
+
|
|
235
|
+
CodeGraph builds a semantic knowledge graph of codebases for faster, smarter code exploration.
|
|
236
|
+
|
|
237
|
+
### If `.codegraph/` exists in the project
|
|
238
|
+
|
|
239
|
+
**Use codegraph tools for faster exploration.** These tools provide instant lookups via the code graph instead of scanning files:
|
|
240
|
+
|
|
241
|
+
| Tool | Use For |
|
|
242
|
+
|------|---------|
|
|
243
|
+
| `codegraph_search` | Find symbols by name (functions, classes, types) |
|
|
244
|
+
| `codegraph_context` | Get relevant code context for a task |
|
|
245
|
+
| `codegraph_callers` | Find what calls a function |
|
|
246
|
+
| `codegraph_callees` | Find what a function calls |
|
|
247
|
+
| `codegraph_impact` | See what's affected by changing a symbol |
|
|
248
|
+
| `codegraph_node` | Get details + source code for a symbol |
|
|
249
|
+
|
|
250
|
+
**When spawning Explore agents in a codegraph-enabled project:**
|
|
251
|
+
|
|
252
|
+
Tell the Explore agent to use codegraph tools for faster exploration.
|
|
253
|
+
|
|
254
|
+
**For quick lookups in the main session:**
|
|
255
|
+
- Use `codegraph_search` instead of grep for finding symbols
|
|
256
|
+
- Use `codegraph_callers`/`codegraph_callees` to trace code flow
|
|
257
|
+
- Use `codegraph_impact` before making changes to see what's affected
|
|
258
|
+
|
|
259
|
+
### If `.codegraph/` does NOT exist
|
|
260
|
+
|
|
261
|
+
At the start of a session, ask the user if they'd like to initialize CodeGraph:
|
|
262
|
+
|
|
263
|
+
"I notice this project doesn't have CodeGraph initialized. Would you like me to run `codegraph init -i` to build a code knowledge graph?"
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
</details>
|
|
267
|
+
|
|
268
|
+
---
|
|
269
|
+
|
|
270
|
+
## 📋 Requirements
|
|
271
|
+
|
|
272
|
+
- Node.js >= 18.0.0
|
|
273
|
+
|
|
274
|
+
---
|
|
275
|
+
|
|
276
|
+
## 💻 CLI Usage
|
|
277
|
+
|
|
278
|
+
```bash
|
|
279
|
+
codegraph # Run interactive installer
|
|
280
|
+
codegraph install # Run interactive installer (explicit)
|
|
281
|
+
codegraph init [path] # Initialize in a project
|
|
282
|
+
codegraph index [path] # Full index
|
|
283
|
+
codegraph sync [path] # Incremental update
|
|
284
|
+
codegraph status [path] # Show statistics
|
|
285
|
+
codegraph query <search> # Search symbols
|
|
286
|
+
codegraph context <task> # Build context for AI
|
|
287
|
+
codegraph hooks install # Install git auto-sync hook
|
|
288
|
+
codegraph serve --mcp # Start MCP server
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
## 📖 CLI Commands
|
|
292
|
+
|
|
293
|
+
### `codegraph` / `codegraph install`
|
|
294
|
+
|
|
295
|
+
Run the interactive installer for Claude Code integration. Configures MCP server and permissions automatically.
|
|
296
|
+
|
|
297
|
+
```bash
|
|
298
|
+
codegraph # Run installer (when no args)
|
|
299
|
+
codegraph install # Run installer (explicit)
|
|
300
|
+
npx @colbymchenry/codegraph # Run via npx (no global install needed)
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
The installer will:
|
|
304
|
+
1. Ask for installation location (global `~/.claude` or local `./.claude`)
|
|
305
|
+
2. Configure the MCP server in `claude.json`
|
|
306
|
+
3. Optionally set up auto-allow permissions
|
|
307
|
+
4. Add global instructions to `~/.claude/CLAUDE.md` (teaches Claude how to use CodeGraph)
|
|
308
|
+
5. For local installs: initialize and index the current project
|
|
309
|
+
|
|
310
|
+
### `codegraph init [path]`
|
|
311
|
+
|
|
312
|
+
Initialize CodeGraph in a project directory. Creates a `.codegraph/` directory with the database and configuration.
|
|
313
|
+
|
|
314
|
+
```bash
|
|
315
|
+
codegraph init # Initialize in current directory
|
|
316
|
+
codegraph init /path/to/project # Initialize in specific directory
|
|
317
|
+
codegraph init --index # Initialize and immediately index
|
|
318
|
+
codegraph init --no-hooks # Skip git hook installation
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
### `codegraph index [path]`
|
|
322
|
+
|
|
323
|
+
Index all files in the project. Extracts functions, classes, methods, and their relationships.
|
|
324
|
+
|
|
325
|
+
```bash
|
|
326
|
+
codegraph index # Index current directory
|
|
327
|
+
codegraph index --force # Force full re-index
|
|
328
|
+
codegraph index --quiet # Suppress progress output
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
### `codegraph sync [path]`
|
|
332
|
+
|
|
333
|
+
Incrementally sync changes since the last index. Only processes added, modified, or removed files.
|
|
334
|
+
|
|
335
|
+
```bash
|
|
336
|
+
codegraph sync # Sync current directory
|
|
337
|
+
codegraph sync --quiet # Suppress output
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
### `codegraph status [path]`
|
|
341
|
+
|
|
342
|
+
Show index status and statistics.
|
|
343
|
+
|
|
344
|
+
```bash
|
|
345
|
+
codegraph status
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
Output includes:
|
|
349
|
+
- Files indexed, nodes, edges
|
|
350
|
+
- Nodes by kind (functions, classes, methods, etc.)
|
|
351
|
+
- Files by language
|
|
352
|
+
- Pending changes (if any)
|
|
353
|
+
- Git hook status
|
|
354
|
+
|
|
355
|
+
### `codegraph query <search>`
|
|
356
|
+
|
|
357
|
+
Search for symbols in the codebase by name.
|
|
358
|
+
|
|
359
|
+
```bash
|
|
360
|
+
codegraph query "authenticate" # Search for symbols
|
|
361
|
+
codegraph query "User" --kind class # Filter by kind
|
|
362
|
+
codegraph query "process" --limit 20 # Limit results
|
|
363
|
+
codegraph query "validate" --json # Output as JSON
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
### `codegraph context <task>`
|
|
367
|
+
|
|
368
|
+
Build relevant code context for a task. Uses semantic search to find entry points, then expands through the graph to find related code.
|
|
369
|
+
|
|
370
|
+
```bash
|
|
371
|
+
codegraph context "fix checkout bug"
|
|
372
|
+
codegraph context "add user authentication" --format json
|
|
373
|
+
codegraph context "refactor payment service" --max-nodes 30
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
### `codegraph hooks`
|
|
377
|
+
|
|
378
|
+
Manage git hooks for automatic syncing.
|
|
379
|
+
|
|
380
|
+
```bash
|
|
381
|
+
codegraph hooks install # Install post-commit hook
|
|
382
|
+
codegraph hooks remove # Remove hook
|
|
383
|
+
codegraph hooks status # Check if hook is installed
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
### `codegraph serve`
|
|
387
|
+
|
|
388
|
+
Start CodeGraph as an MCP server for AI assistants.
|
|
389
|
+
|
|
390
|
+
```bash
|
|
391
|
+
codegraph serve # Show MCP configuration help
|
|
392
|
+
codegraph serve --mcp # Start MCP server (stdio)
|
|
393
|
+
codegraph serve --mcp --path /project # Specify project path
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
## 🔌 MCP Tools Reference
|
|
397
|
+
|
|
398
|
+
When running as an MCP server, CodeGraph exposes these tools to AI assistants. **These tools are designed to be used by Claude's Explore agents** for faster, more efficient codebase exploration.
|
|
399
|
+
|
|
400
|
+
### `codegraph_context`
|
|
401
|
+
|
|
402
|
+
Build context for a specific task. Good for focused queries.
|
|
403
|
+
|
|
404
|
+
```
|
|
405
|
+
codegraph_context(task: "fix checkout validation bug", maxNodes: 20)
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
### `codegraph_search`
|
|
409
|
+
|
|
410
|
+
Quick symbol search by name. Returns locations only.
|
|
411
|
+
|
|
412
|
+
```
|
|
413
|
+
codegraph_search(query: "UserService", kind: "class", limit: 10)
|
|
414
|
+
```
|
|
415
|
+
|
|
416
|
+
### `codegraph_callers` / `codegraph_callees`
|
|
417
|
+
|
|
418
|
+
Find what calls a function, or what a function calls.
|
|
419
|
+
|
|
420
|
+
```
|
|
421
|
+
codegraph_callers(symbol: "validatePayment", limit: 20)
|
|
422
|
+
codegraph_callees(symbol: "processOrder", limit: 20)
|
|
423
|
+
```
|
|
424
|
+
|
|
425
|
+
### `codegraph_impact`
|
|
426
|
+
|
|
427
|
+
Analyze what code would be affected by changing a symbol.
|
|
428
|
+
|
|
429
|
+
```
|
|
430
|
+
codegraph_impact(symbol: "UserService", depth: 2)
|
|
431
|
+
```
|
|
432
|
+
|
|
433
|
+
### `codegraph_node`
|
|
434
|
+
|
|
435
|
+
Get details about a specific symbol. Use `includeCode: true` only when needed.
|
|
436
|
+
|
|
437
|
+
```
|
|
438
|
+
codegraph_node(symbol: "authenticate", includeCode: true)
|
|
439
|
+
```
|
|
440
|
+
|
|
441
|
+
### `codegraph_status`
|
|
442
|
+
|
|
443
|
+
Check index health and statistics.
|
|
444
|
+
|
|
445
|
+
### How It Works With Claude Code
|
|
446
|
+
|
|
447
|
+
Claude's **Explore agents** use these tools instead of grep/glob/Read for faster exploration:
|
|
448
|
+
|
|
449
|
+
| Without CodeGraph | With CodeGraph | Benefit |
|
|
450
|
+
|-------------------|----------------|---------|
|
|
451
|
+
| `grep -r "auth"` | `codegraph_search("auth")` | Instant symbol lookup |
|
|
452
|
+
| Multiple `Read` calls | `codegraph_context(task)` | Related code in one call |
|
|
453
|
+
| Manual file tracing | `codegraph_callers/callees` | Call graph traversal |
|
|
454
|
+
| Guessing impact | `codegraph_impact(symbol)` | Know what breaks |
|
|
455
|
+
|
|
456
|
+
This hybrid approach gives you **~30% fewer tokens** and **~25% fewer tool calls** while letting Claude's native agents handle synthesis.
|
|
457
|
+
|
|
458
|
+
## 📚 Library Usage
|
|
459
|
+
|
|
460
|
+
CodeGraph can also be used as a library in your Node.js applications:
|
|
461
|
+
|
|
462
|
+
```typescript
|
|
463
|
+
import CodeGraph from '@colbymchenry/codegraph';
|
|
464
|
+
|
|
465
|
+
// Initialize a new project
|
|
466
|
+
const cg = await CodeGraph.init('/path/to/project');
|
|
467
|
+
|
|
468
|
+
// Or open an existing one
|
|
469
|
+
const cg = await CodeGraph.open('/path/to/project');
|
|
470
|
+
|
|
471
|
+
// Index with progress callback
|
|
472
|
+
await cg.indexAll({
|
|
473
|
+
onProgress: (progress) => {
|
|
474
|
+
console.log(`${progress.phase}: ${progress.current}/${progress.total}`);
|
|
475
|
+
}
|
|
476
|
+
});
|
|
477
|
+
|
|
478
|
+
// Search for symbols
|
|
479
|
+
const results = cg.searchNodes('UserService');
|
|
480
|
+
|
|
481
|
+
// Get callers of a function
|
|
482
|
+
const node = results[0].node;
|
|
483
|
+
const callers = cg.getCallers(node.id);
|
|
484
|
+
|
|
485
|
+
// Build context for a task
|
|
486
|
+
const context = await cg.buildContext('fix login bug', {
|
|
487
|
+
maxNodes: 20,
|
|
488
|
+
includeCode: true,
|
|
489
|
+
format: 'markdown'
|
|
490
|
+
});
|
|
491
|
+
|
|
492
|
+
// Get impact radius
|
|
493
|
+
const impact = cg.getImpactRadius(node.id, 2);
|
|
494
|
+
|
|
495
|
+
// Sync changes
|
|
496
|
+
const syncResult = await cg.sync();
|
|
497
|
+
|
|
498
|
+
// Clean up
|
|
499
|
+
cg.close();
|
|
500
|
+
```
|
|
501
|
+
|
|
502
|
+
## ⚙️ How It Works
|
|
503
|
+
|
|
504
|
+
### 1. Extraction
|
|
505
|
+
|
|
506
|
+
CodeGraph uses [tree-sitter](https://tree-sitter.github.io/) to parse source code into ASTs. Language-specific queries (`.scm` files) extract:
|
|
507
|
+
|
|
508
|
+
- **Nodes**: Functions, methods, classes, interfaces, types, variables
|
|
509
|
+
- **Edges**: Calls, imports, extends, implements, returns_type
|
|
510
|
+
|
|
511
|
+
Each node gets a unique ID based on its kind, file path, name, and line number.
|
|
512
|
+
|
|
513
|
+
### 2. Storage
|
|
514
|
+
|
|
515
|
+
All data is stored in a local SQLite database (`.codegraph/codegraph.db`):
|
|
516
|
+
|
|
517
|
+
- **nodes** table: All code entities with metadata
|
|
518
|
+
- **edges** table: Relationships between nodes
|
|
519
|
+
- **files** table: File tracking for incremental updates
|
|
520
|
+
- **node_vectors** / **vector_map**: Embeddings for semantic search (using sqlite-vss)
|
|
521
|
+
|
|
522
|
+
### 3. Reference Resolution
|
|
523
|
+
|
|
524
|
+
After extraction, CodeGraph resolves references:
|
|
525
|
+
|
|
526
|
+
1. Match function calls to function definitions
|
|
527
|
+
2. Resolve imports to their source files
|
|
528
|
+
3. Link class inheritance and interface implementations
|
|
529
|
+
4. Apply framework-specific patterns (Express routes, etc.)
|
|
530
|
+
|
|
531
|
+
### 4. Semantic Search
|
|
532
|
+
|
|
533
|
+
CodeGraph uses local embeddings (via [@xenova/transformers](https://github.com/xenova/transformers.js)) to enable semantic search:
|
|
534
|
+
|
|
535
|
+
1. Code symbols are embedded using a transformer model
|
|
536
|
+
2. Queries are embedded and compared using cosine similarity
|
|
537
|
+
3. Results are ranked by relevance
|
|
538
|
+
|
|
539
|
+
### 5. Graph Queries
|
|
540
|
+
|
|
541
|
+
The graph structure enables powerful queries:
|
|
542
|
+
|
|
543
|
+
- **Callers/Callees**: Direct call relationships
|
|
544
|
+
- **Impact Radius**: BFS traversal to find all potentially affected code
|
|
545
|
+
- **Dependencies**: What a symbol depends on
|
|
546
|
+
- **Dependents**: What depends on a symbol
|
|
547
|
+
|
|
548
|
+
### 6. Context Building
|
|
549
|
+
|
|
550
|
+
When you request context for a task:
|
|
551
|
+
|
|
552
|
+
1. Semantic search finds relevant entry points
|
|
553
|
+
2. Graph traversal expands to related code
|
|
554
|
+
3. Code snippets are extracted
|
|
555
|
+
4. Results are formatted for AI consumption
|
|
556
|
+
|
|
557
|
+
## ⚙️ Configuration
|
|
558
|
+
|
|
559
|
+
The `.codegraph/config.json` file controls indexing behavior:
|
|
560
|
+
|
|
561
|
+
```json
|
|
562
|
+
{
|
|
563
|
+
"version": 1,
|
|
564
|
+
"projectName": "my-project",
|
|
565
|
+
"languages": ["typescript", "javascript"],
|
|
566
|
+
"exclude": [
|
|
567
|
+
"node_modules/**",
|
|
568
|
+
"dist/**",
|
|
569
|
+
"build/**",
|
|
570
|
+
"*.min.js"
|
|
571
|
+
],
|
|
572
|
+
"frameworks": ["express", "react"],
|
|
573
|
+
"maxFileSize": 1048576,
|
|
574
|
+
"gitHooksEnabled": true
|
|
575
|
+
}
|
|
576
|
+
```
|
|
577
|
+
|
|
578
|
+
### Options
|
|
579
|
+
|
|
580
|
+
| Option | Description | Default |
|
|
581
|
+
|--------|-------------|---------|
|
|
582
|
+
| `languages` | Languages to index (auto-detected if empty) | `[]` |
|
|
583
|
+
| `exclude` | Glob patterns to ignore | `["node_modules/**", ...]` |
|
|
584
|
+
| `frameworks` | Framework hints for better resolution | `[]` |
|
|
585
|
+
| `maxFileSize` | Skip files larger than this (bytes) | `1048576` (1MB) |
|
|
586
|
+
| `gitHooksEnabled` | Enable git hook installation | `true` |
|
|
587
|
+
|
|
588
|
+
## 🌐 Supported Languages
|
|
589
|
+
|
|
590
|
+
| Language | Extension | Status |
|
|
591
|
+
|----------|-----------|--------|
|
|
592
|
+
| TypeScript | `.ts`, `.tsx` | Full support |
|
|
593
|
+
| JavaScript | `.js`, `.jsx`, `.mjs` | Full support |
|
|
594
|
+
| Python | `.py` | Full support |
|
|
595
|
+
| Go | `.go` | Full support |
|
|
596
|
+
| Rust | `.rs` | Full support |
|
|
597
|
+
| Java | `.java` | Full support |
|
|
598
|
+
| C# | `.cs` | Full support |
|
|
599
|
+
| PHP | `.php` | Full support |
|
|
600
|
+
| Ruby | `.rb` | Full support |
|
|
601
|
+
| C | `.c`, `.h` | Full support |
|
|
602
|
+
| C++ | `.cpp`, `.hpp`, `.cc` | Full support |
|
|
603
|
+
| Swift | `.swift` | Basic support |
|
|
604
|
+
| Kotlin | `.kt` | Basic support |
|
|
605
|
+
| Dart | `.dart` | Full support |
|
|
606
|
+
| Svelte | `.svelte` | Full support (script extraction, Svelte 5 runes, SvelteKit routes) |
|
|
607
|
+
|
|
608
|
+
## 🔧 Troubleshooting
|
|
609
|
+
|
|
610
|
+
### "CodeGraph not initialized"
|
|
611
|
+
|
|
612
|
+
Run `codegraph init` in your project directory first.
|
|
613
|
+
|
|
614
|
+
### Indexing is slow
|
|
615
|
+
|
|
616
|
+
- Check if `node_modules` or other large directories are excluded
|
|
617
|
+
- Use `--quiet` flag to reduce console output overhead
|
|
618
|
+
- Consider increasing `maxFileSize` if you have large files to skip
|
|
619
|
+
|
|
620
|
+
### MCP server not connecting
|
|
621
|
+
|
|
622
|
+
1. Ensure the project is initialized and indexed
|
|
623
|
+
2. Check the path in your MCP configuration is correct
|
|
624
|
+
3. Verify `codegraph serve --mcp` works from the command line
|
|
625
|
+
4. Check Claude Code logs for connection errors
|
|
626
|
+
|
|
627
|
+
### Missing symbols in search
|
|
628
|
+
|
|
629
|
+
- Run `codegraph sync` to pick up recent changes
|
|
630
|
+
- Check if the file's language is supported
|
|
631
|
+
- Verify the file isn't excluded by config patterns
|
|
632
|
+
|
|
633
|
+
---
|
|
634
|
+
|
|
635
|
+
## 📄 License
|
|
636
|
+
|
|
637
|
+
MIT
|
|
638
|
+
|
|
639
|
+
---
|
|
640
|
+
|
|
641
|
+
<div align="center">
|
|
642
|
+
|
|
643
|
+
**Made for the Claude Code community** 🤖
|
|
644
|
+
|
|
645
|
+
[Report Bug](https://github.com/colbymchenry/codegraph/issues) · [Request Feature](https://github.com/colbymchenry/codegraph/issues)
|
|
646
|
+
|
|
647
|
+
</div>
|