gitnexus 1.4.0 → 1.4.1

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.
Files changed (131) hide show
  1. package/README.md +194 -214
  2. package/dist/cli/ai-context.d.ts +1 -2
  3. package/dist/cli/ai-context.js +90 -117
  4. package/dist/cli/analyze.d.ts +0 -2
  5. package/dist/cli/analyze.js +2 -20
  6. package/dist/cli/index.js +25 -17
  7. package/dist/cli/setup.js +19 -17
  8. package/dist/core/augmentation/engine.js +20 -20
  9. package/dist/core/embeddings/embedding-pipeline.js +26 -26
  10. package/dist/core/graph/types.d.ts +2 -5
  11. package/dist/core/ingestion/ast-cache.js +2 -3
  12. package/dist/core/ingestion/call-processor.d.ts +5 -5
  13. package/dist/core/ingestion/call-processor.js +258 -173
  14. package/dist/core/ingestion/cluster-enricher.js +16 -16
  15. package/dist/core/ingestion/entry-point-scoring.d.ts +1 -2
  16. package/dist/core/ingestion/entry-point-scoring.js +22 -81
  17. package/dist/core/ingestion/framework-detection.d.ts +1 -5
  18. package/dist/core/ingestion/framework-detection.js +8 -39
  19. package/dist/core/ingestion/heritage-processor.d.ts +4 -13
  20. package/dist/core/ingestion/heritage-processor.js +28 -92
  21. package/dist/core/ingestion/import-processor.d.ts +19 -17
  22. package/dist/core/ingestion/import-processor.js +695 -170
  23. package/dist/core/ingestion/parsing-processor.d.ts +10 -1
  24. package/dist/core/ingestion/parsing-processor.js +177 -41
  25. package/dist/core/ingestion/pipeline.js +26 -49
  26. package/dist/core/ingestion/process-processor.js +1 -2
  27. package/dist/core/ingestion/symbol-table.d.ts +1 -12
  28. package/dist/core/ingestion/symbol-table.js +12 -19
  29. package/dist/core/ingestion/tree-sitter-queries.d.ts +11 -11
  30. package/dist/core/ingestion/tree-sitter-queries.js +485 -590
  31. package/dist/core/ingestion/utils.d.ts +0 -67
  32. package/dist/core/ingestion/utils.js +9 -692
  33. package/dist/core/ingestion/workers/parse-worker.d.ts +3 -20
  34. package/dist/core/ingestion/workers/parse-worker.js +345 -84
  35. package/dist/core/ingestion/workers/worker-pool.js +0 -8
  36. package/dist/core/kuzu/csv-generator.js +3 -19
  37. package/dist/core/kuzu/kuzu-adapter.js +19 -14
  38. package/dist/core/kuzu/schema.d.ts +3 -3
  39. package/dist/core/kuzu/schema.js +288 -303
  40. package/dist/core/search/bm25-index.js +6 -7
  41. package/dist/core/search/hybrid-search.js +3 -3
  42. package/dist/core/wiki/diagrams.d.ts +27 -0
  43. package/dist/core/wiki/diagrams.js +163 -0
  44. package/dist/core/wiki/generator.d.ts +50 -2
  45. package/dist/core/wiki/generator.js +548 -49
  46. package/dist/core/wiki/graph-queries.d.ts +42 -0
  47. package/dist/core/wiki/graph-queries.js +276 -97
  48. package/dist/core/wiki/html-viewer.js +192 -192
  49. package/dist/core/wiki/llm-client.js +73 -11
  50. package/dist/core/wiki/prompts.d.ts +52 -8
  51. package/dist/core/wiki/prompts.js +200 -86
  52. package/dist/mcp/core/kuzu-adapter.d.ts +3 -1
  53. package/dist/mcp/core/kuzu-adapter.js +44 -13
  54. package/dist/mcp/local/local-backend.js +128 -128
  55. package/dist/mcp/resources.js +42 -42
  56. package/dist/mcp/server.js +19 -18
  57. package/dist/mcp/tools.js +104 -103
  58. package/hooks/claude/gitnexus-hook.cjs +155 -238
  59. package/hooks/claude/pre-tool-use.sh +79 -79
  60. package/hooks/claude/session-start.sh +42 -42
  61. package/package.json +96 -96
  62. package/scripts/patch-tree-sitter-swift.cjs +74 -74
  63. package/skills/gitnexus-cli.md +82 -82
  64. package/skills/gitnexus-debugging.md +89 -89
  65. package/skills/gitnexus-exploring.md +78 -78
  66. package/skills/gitnexus-guide.md +64 -64
  67. package/skills/gitnexus-impact-analysis.md +97 -97
  68. package/skills/gitnexus-pr-review.md +163 -163
  69. package/skills/gitnexus-refactoring.md +121 -121
  70. package/vendor/leiden/index.cjs +355 -355
  71. package/vendor/leiden/utils.cjs +392 -392
  72. package/dist/cli/lazy-action.d.ts +0 -6
  73. package/dist/cli/lazy-action.js +0 -18
  74. package/dist/cli/skill-gen.d.ts +0 -26
  75. package/dist/cli/skill-gen.js +0 -549
  76. package/dist/core/ingestion/constants.d.ts +0 -16
  77. package/dist/core/ingestion/constants.js +0 -16
  78. package/dist/core/ingestion/export-detection.d.ts +0 -18
  79. package/dist/core/ingestion/export-detection.js +0 -230
  80. package/dist/core/ingestion/language-config.d.ts +0 -46
  81. package/dist/core/ingestion/language-config.js +0 -167
  82. package/dist/core/ingestion/mro-processor.d.ts +0 -45
  83. package/dist/core/ingestion/mro-processor.js +0 -369
  84. package/dist/core/ingestion/named-binding-extraction.d.ts +0 -61
  85. package/dist/core/ingestion/named-binding-extraction.js +0 -363
  86. package/dist/core/ingestion/resolvers/csharp.d.ts +0 -22
  87. package/dist/core/ingestion/resolvers/csharp.js +0 -109
  88. package/dist/core/ingestion/resolvers/go.d.ts +0 -19
  89. package/dist/core/ingestion/resolvers/go.js +0 -42
  90. package/dist/core/ingestion/resolvers/index.d.ts +0 -16
  91. package/dist/core/ingestion/resolvers/index.js +0 -11
  92. package/dist/core/ingestion/resolvers/jvm.d.ts +0 -23
  93. package/dist/core/ingestion/resolvers/jvm.js +0 -87
  94. package/dist/core/ingestion/resolvers/php.d.ts +0 -15
  95. package/dist/core/ingestion/resolvers/php.js +0 -35
  96. package/dist/core/ingestion/resolvers/rust.d.ts +0 -15
  97. package/dist/core/ingestion/resolvers/rust.js +0 -73
  98. package/dist/core/ingestion/resolvers/standard.d.ts +0 -28
  99. package/dist/core/ingestion/resolvers/standard.js +0 -145
  100. package/dist/core/ingestion/resolvers/utils.d.ts +0 -33
  101. package/dist/core/ingestion/resolvers/utils.js +0 -120
  102. package/dist/core/ingestion/symbol-resolver.d.ts +0 -32
  103. package/dist/core/ingestion/symbol-resolver.js +0 -83
  104. package/dist/core/ingestion/type-env.d.ts +0 -27
  105. package/dist/core/ingestion/type-env.js +0 -86
  106. package/dist/core/ingestion/type-extractors/c-cpp.d.ts +0 -2
  107. package/dist/core/ingestion/type-extractors/c-cpp.js +0 -60
  108. package/dist/core/ingestion/type-extractors/csharp.d.ts +0 -2
  109. package/dist/core/ingestion/type-extractors/csharp.js +0 -89
  110. package/dist/core/ingestion/type-extractors/go.d.ts +0 -2
  111. package/dist/core/ingestion/type-extractors/go.js +0 -105
  112. package/dist/core/ingestion/type-extractors/index.d.ts +0 -21
  113. package/dist/core/ingestion/type-extractors/index.js +0 -29
  114. package/dist/core/ingestion/type-extractors/jvm.d.ts +0 -3
  115. package/dist/core/ingestion/type-extractors/jvm.js +0 -121
  116. package/dist/core/ingestion/type-extractors/php.d.ts +0 -2
  117. package/dist/core/ingestion/type-extractors/php.js +0 -31
  118. package/dist/core/ingestion/type-extractors/python.d.ts +0 -2
  119. package/dist/core/ingestion/type-extractors/python.js +0 -41
  120. package/dist/core/ingestion/type-extractors/rust.d.ts +0 -2
  121. package/dist/core/ingestion/type-extractors/rust.js +0 -39
  122. package/dist/core/ingestion/type-extractors/shared.d.ts +0 -17
  123. package/dist/core/ingestion/type-extractors/shared.js +0 -97
  124. package/dist/core/ingestion/type-extractors/swift.d.ts +0 -2
  125. package/dist/core/ingestion/type-extractors/swift.js +0 -43
  126. package/dist/core/ingestion/type-extractors/types.d.ts +0 -14
  127. package/dist/core/ingestion/type-extractors/types.js +0 -1
  128. package/dist/core/ingestion/type-extractors/typescript.d.ts +0 -2
  129. package/dist/core/ingestion/type-extractors/typescript.js +0 -46
  130. package/dist/mcp/compatible-stdio-transport.d.ts +0 -25
  131. package/dist/mcp/compatible-stdio-transport.js +0 -200
@@ -22,7 +22,7 @@ export const NODE_TABLES = [
22
22
  // ============================================================================
23
23
  export const REL_TABLE_NAME = 'CodeRelation';
24
24
  // Valid relation types
25
- export const REL_TYPES = ['CONTAINS', 'DEFINES', 'IMPORTS', 'CALLS', 'EXTENDS', 'IMPLEMENTS', 'HAS_METHOD', 'OVERRIDES', 'MEMBER_OF', 'STEP_IN_PROCESS'];
25
+ export const REL_TYPES = ['CONTAINS', 'DEFINES', 'IMPORTS', 'CALLS', 'EXTENDS', 'IMPLEMENTS', 'MEMBER_OF', 'STEP_IN_PROCESS'];
26
26
  // ============================================================================
27
27
  // EMBEDDING TABLE
28
28
  // ============================================================================
@@ -30,128 +30,126 @@ export const EMBEDDING_TABLE_NAME = 'CodeEmbedding';
30
30
  // ============================================================================
31
31
  // NODE TABLE SCHEMAS
32
32
  // ============================================================================
33
- export const FILE_SCHEMA = `
34
- CREATE NODE TABLE File (
35
- id STRING,
36
- name STRING,
37
- filePath STRING,
38
- content STRING,
39
- PRIMARY KEY (id)
33
+ export const FILE_SCHEMA = `
34
+ CREATE NODE TABLE File (
35
+ id STRING,
36
+ name STRING,
37
+ filePath STRING,
38
+ content STRING,
39
+ PRIMARY KEY (id)
40
40
  )`;
41
- export const FOLDER_SCHEMA = `
42
- CREATE NODE TABLE Folder (
43
- id STRING,
44
- name STRING,
45
- filePath STRING,
46
- PRIMARY KEY (id)
41
+ export const FOLDER_SCHEMA = `
42
+ CREATE NODE TABLE Folder (
43
+ id STRING,
44
+ name STRING,
45
+ filePath STRING,
46
+ PRIMARY KEY (id)
47
47
  )`;
48
- export const FUNCTION_SCHEMA = `
49
- CREATE NODE TABLE Function (
50
- id STRING,
51
- name STRING,
52
- filePath STRING,
53
- startLine INT64,
54
- endLine INT64,
55
- isExported BOOLEAN,
56
- content STRING,
57
- description STRING,
58
- PRIMARY KEY (id)
48
+ export const FUNCTION_SCHEMA = `
49
+ CREATE NODE TABLE Function (
50
+ id STRING,
51
+ name STRING,
52
+ filePath STRING,
53
+ startLine INT64,
54
+ endLine INT64,
55
+ isExported BOOLEAN,
56
+ content STRING,
57
+ description STRING,
58
+ PRIMARY KEY (id)
59
59
  )`;
60
- export const CLASS_SCHEMA = `
61
- CREATE NODE TABLE Class (
62
- id STRING,
63
- name STRING,
64
- filePath STRING,
65
- startLine INT64,
66
- endLine INT64,
67
- isExported BOOLEAN,
68
- content STRING,
69
- description STRING,
70
- PRIMARY KEY (id)
60
+ export const CLASS_SCHEMA = `
61
+ CREATE NODE TABLE Class (
62
+ id STRING,
63
+ name STRING,
64
+ filePath STRING,
65
+ startLine INT64,
66
+ endLine INT64,
67
+ isExported BOOLEAN,
68
+ content STRING,
69
+ description STRING,
70
+ PRIMARY KEY (id)
71
71
  )`;
72
- export const INTERFACE_SCHEMA = `
73
- CREATE NODE TABLE Interface (
74
- id STRING,
75
- name STRING,
76
- filePath STRING,
77
- startLine INT64,
78
- endLine INT64,
79
- isExported BOOLEAN,
80
- content STRING,
81
- description STRING,
82
- PRIMARY KEY (id)
72
+ export const INTERFACE_SCHEMA = `
73
+ CREATE NODE TABLE Interface (
74
+ id STRING,
75
+ name STRING,
76
+ filePath STRING,
77
+ startLine INT64,
78
+ endLine INT64,
79
+ isExported BOOLEAN,
80
+ content STRING,
81
+ description STRING,
82
+ PRIMARY KEY (id)
83
83
  )`;
84
- export const METHOD_SCHEMA = `
85
- CREATE NODE TABLE Method (
86
- id STRING,
87
- name STRING,
88
- filePath STRING,
89
- startLine INT64,
90
- endLine INT64,
91
- isExported BOOLEAN,
92
- content STRING,
93
- description STRING,
94
- parameterCount INT32,
95
- returnType STRING,
96
- PRIMARY KEY (id)
84
+ export const METHOD_SCHEMA = `
85
+ CREATE NODE TABLE Method (
86
+ id STRING,
87
+ name STRING,
88
+ filePath STRING,
89
+ startLine INT64,
90
+ endLine INT64,
91
+ isExported BOOLEAN,
92
+ content STRING,
93
+ description STRING,
94
+ PRIMARY KEY (id)
97
95
  )`;
98
- export const CODE_ELEMENT_SCHEMA = `
99
- CREATE NODE TABLE CodeElement (
100
- id STRING,
101
- name STRING,
102
- filePath STRING,
103
- startLine INT64,
104
- endLine INT64,
105
- isExported BOOLEAN,
106
- content STRING,
107
- description STRING,
108
- PRIMARY KEY (id)
96
+ export const CODE_ELEMENT_SCHEMA = `
97
+ CREATE NODE TABLE CodeElement (
98
+ id STRING,
99
+ name STRING,
100
+ filePath STRING,
101
+ startLine INT64,
102
+ endLine INT64,
103
+ isExported BOOLEAN,
104
+ content STRING,
105
+ description STRING,
106
+ PRIMARY KEY (id)
109
107
  )`;
110
108
  // ============================================================================
111
109
  // COMMUNITY NODE TABLE (for Leiden algorithm clusters)
112
110
  // ============================================================================
113
- export const COMMUNITY_SCHEMA = `
114
- CREATE NODE TABLE Community (
115
- id STRING,
116
- label STRING,
117
- heuristicLabel STRING,
118
- keywords STRING[],
119
- description STRING,
120
- enrichedBy STRING,
121
- cohesion DOUBLE,
122
- symbolCount INT32,
123
- PRIMARY KEY (id)
111
+ export const COMMUNITY_SCHEMA = `
112
+ CREATE NODE TABLE Community (
113
+ id STRING,
114
+ label STRING,
115
+ heuristicLabel STRING,
116
+ keywords STRING[],
117
+ description STRING,
118
+ enrichedBy STRING,
119
+ cohesion DOUBLE,
120
+ symbolCount INT32,
121
+ PRIMARY KEY (id)
124
122
  )`;
125
123
  // ============================================================================
126
124
  // PROCESS NODE TABLE (for execution flow detection)
127
125
  // ============================================================================
128
- export const PROCESS_SCHEMA = `
129
- CREATE NODE TABLE Process (
130
- id STRING,
131
- label STRING,
132
- heuristicLabel STRING,
133
- processType STRING,
134
- stepCount INT32,
135
- communities STRING[],
136
- entryPointId STRING,
137
- terminalId STRING,
138
- PRIMARY KEY (id)
126
+ export const PROCESS_SCHEMA = `
127
+ CREATE NODE TABLE Process (
128
+ id STRING,
129
+ label STRING,
130
+ heuristicLabel STRING,
131
+ processType STRING,
132
+ stepCount INT32,
133
+ communities STRING[],
134
+ entryPointId STRING,
135
+ terminalId STRING,
136
+ PRIMARY KEY (id)
139
137
  )`;
140
138
  // ============================================================================
141
139
  // MULTI-LANGUAGE NODE TABLE SCHEMAS
142
140
  // ============================================================================
143
141
  // Generic code element with startLine/endLine for C, C++, Rust, Go, Java, C#
144
142
  // description: optional metadata (e.g. Eloquent $fillable fields, relationship targets)
145
- const CODE_ELEMENT_BASE = (name) => `
146
- CREATE NODE TABLE \`${name}\` (
147
- id STRING,
148
- name STRING,
149
- filePath STRING,
150
- startLine INT64,
151
- endLine INT64,
152
- content STRING,
153
- description STRING,
154
- PRIMARY KEY (id)
143
+ const CODE_ELEMENT_BASE = (name) => `
144
+ CREATE NODE TABLE \`${name}\` (
145
+ id STRING,
146
+ name STRING,
147
+ filePath STRING,
148
+ startLine INT64,
149
+ endLine INT64,
150
+ content STRING,
151
+ description STRING,
152
+ PRIMARY KEY (id)
155
153
  )`;
156
154
  export const STRUCT_SCHEMA = CODE_ELEMENT_BASE('Struct');
157
155
  export const ENUM_SCHEMA = CODE_ELEMENT_BASE('Enum');
@@ -175,216 +173,203 @@ export const MODULE_SCHEMA = CODE_ELEMENT_BASE('Module');
175
173
  // RELATION TABLE SCHEMA
176
174
  // Single table with 'type' property - connects all node tables
177
175
  // ============================================================================
178
- export const RELATION_SCHEMA = `
179
- CREATE REL TABLE ${REL_TABLE_NAME} (
180
- FROM File TO File,
181
- FROM File TO Folder,
182
- FROM File TO Function,
183
- FROM File TO Class,
184
- FROM File TO Interface,
185
- FROM File TO Method,
186
- FROM File TO CodeElement,
187
- FROM File TO \`Struct\`,
188
- FROM File TO \`Enum\`,
189
- FROM File TO \`Macro\`,
190
- FROM File TO \`Typedef\`,
191
- FROM File TO \`Union\`,
192
- FROM File TO \`Namespace\`,
193
- FROM File TO \`Trait\`,
194
- FROM File TO \`Impl\`,
195
- FROM File TO \`TypeAlias\`,
196
- FROM File TO \`Const\`,
197
- FROM File TO \`Static\`,
198
- FROM File TO \`Property\`,
199
- FROM File TO \`Record\`,
200
- FROM File TO \`Delegate\`,
201
- FROM File TO \`Annotation\`,
202
- FROM File TO \`Constructor\`,
203
- FROM File TO \`Template\`,
204
- FROM File TO \`Module\`,
205
- FROM Folder TO Folder,
206
- FROM Folder TO File,
207
- FROM Function TO Function,
208
- FROM Function TO Method,
209
- FROM Function TO Class,
210
- FROM Function TO Community,
211
- FROM Function TO \`Macro\`,
212
- FROM Function TO \`Struct\`,
213
- FROM Function TO \`Template\`,
214
- FROM Function TO \`Enum\`,
215
- FROM Function TO \`Namespace\`,
216
- FROM Function TO \`TypeAlias\`,
217
- FROM Function TO \`Module\`,
218
- FROM Function TO \`Impl\`,
219
- FROM Function TO Interface,
220
- FROM Function TO \`Constructor\`,
221
- FROM Function TO \`Const\`,
222
- FROM Function TO \`Typedef\`,
223
- FROM Function TO \`Union\`,
224
- FROM Function TO \`Property\`,
225
- FROM Class TO Method,
226
- FROM Class TO Function,
227
- FROM Class TO Class,
228
- FROM Class TO Interface,
229
- FROM Class TO Community,
230
- FROM Class TO \`Template\`,
231
- FROM Class TO \`TypeAlias\`,
232
- FROM Class TO \`Struct\`,
233
- FROM Class TO \`Enum\`,
234
- FROM Class TO \`Annotation\`,
235
- FROM Class TO \`Constructor\`,
236
- FROM Class TO \`Trait\`,
237
- FROM Class TO \`Macro\`,
238
- FROM Class TO \`Impl\`,
239
- FROM Class TO \`Union\`,
240
- FROM Class TO \`Namespace\`,
241
- FROM Class TO \`Typedef\`,
242
- FROM Class TO \`Property\`,
243
- FROM Method TO Function,
244
- FROM Method TO Method,
245
- FROM Method TO Class,
246
- FROM Method TO Community,
247
- FROM Method TO \`Template\`,
248
- FROM Method TO \`Struct\`,
249
- FROM Method TO \`TypeAlias\`,
250
- FROM Method TO \`Enum\`,
251
- FROM Method TO \`Macro\`,
252
- FROM Method TO \`Namespace\`,
253
- FROM Method TO \`Module\`,
254
- FROM Method TO \`Impl\`,
255
- FROM Method TO Interface,
256
- FROM Method TO \`Constructor\`,
257
- FROM Method TO \`Property\`,
258
- FROM \`Template\` TO \`Template\`,
259
- FROM \`Template\` TO Function,
260
- FROM \`Template\` TO Method,
261
- FROM \`Template\` TO Class,
262
- FROM \`Template\` TO \`Struct\`,
263
- FROM \`Template\` TO \`TypeAlias\`,
264
- FROM \`Template\` TO \`Enum\`,
265
- FROM \`Template\` TO \`Macro\`,
266
- FROM \`Template\` TO Interface,
267
- FROM \`Template\` TO \`Constructor\`,
268
- FROM \`Module\` TO \`Module\`,
269
- FROM CodeElement TO Community,
270
- FROM Interface TO Community,
271
- FROM Interface TO Function,
272
- FROM Interface TO Method,
273
- FROM Interface TO Class,
274
- FROM Interface TO Interface,
275
- FROM Interface TO \`TypeAlias\`,
276
- FROM Interface TO \`Struct\`,
277
- FROM Interface TO \`Constructor\`,
278
- FROM Interface TO \`Property\`,
279
- FROM \`Struct\` TO Community,
280
- FROM \`Struct\` TO \`Trait\`,
281
- FROM \`Struct\` TO \`Struct\`,
282
- FROM \`Struct\` TO Class,
283
- FROM \`Struct\` TO \`Enum\`,
284
- FROM \`Struct\` TO Function,
285
- FROM \`Struct\` TO Method,
286
- FROM \`Struct\` TO Interface,
287
- FROM \`Struct\` TO \`Constructor\`,
288
- FROM \`Struct\` TO \`Property\`,
289
- FROM \`Enum\` TO \`Enum\`,
290
- FROM \`Enum\` TO Community,
291
- FROM \`Enum\` TO Class,
292
- FROM \`Enum\` TO Interface,
293
- FROM \`Macro\` TO Community,
294
- FROM \`Macro\` TO Function,
295
- FROM \`Macro\` TO Method,
296
- FROM \`Module\` TO Function,
297
- FROM \`Module\` TO Method,
298
- FROM \`Typedef\` TO Community,
299
- FROM \`Union\` TO Community,
300
- FROM \`Namespace\` TO Community,
301
- FROM \`Namespace\` TO \`Struct\`,
302
- FROM \`Trait\` TO Method,
303
- FROM \`Trait\` TO \`Constructor\`,
304
- FROM \`Trait\` TO \`Property\`,
305
- FROM \`Trait\` TO Community,
306
- FROM \`Impl\` TO Method,
307
- FROM \`Impl\` TO \`Constructor\`,
308
- FROM \`Impl\` TO \`Property\`,
309
- FROM \`Impl\` TO Community,
310
- FROM \`Impl\` TO \`Trait\`,
311
- FROM \`Impl\` TO \`Struct\`,
312
- FROM \`Impl\` TO \`Impl\`,
313
- FROM \`TypeAlias\` TO Community,
314
- FROM \`TypeAlias\` TO \`Trait\`,
315
- FROM \`TypeAlias\` TO Class,
316
- FROM \`Const\` TO Community,
317
- FROM \`Static\` TO Community,
318
- FROM \`Property\` TO Community,
319
- FROM \`Record\` TO Method,
320
- FROM \`Record\` TO \`Constructor\`,
321
- FROM \`Record\` TO \`Property\`,
322
- FROM \`Record\` TO Community,
323
- FROM \`Delegate\` TO Community,
324
- FROM \`Annotation\` TO Community,
325
- FROM \`Constructor\` TO Community,
326
- FROM \`Constructor\` TO Interface,
327
- FROM \`Constructor\` TO Class,
328
- FROM \`Constructor\` TO Method,
329
- FROM \`Constructor\` TO Function,
330
- FROM \`Constructor\` TO \`Constructor\`,
331
- FROM \`Constructor\` TO \`Struct\`,
332
- FROM \`Constructor\` TO \`Macro\`,
333
- FROM \`Constructor\` TO \`Template\`,
334
- FROM \`Constructor\` TO \`TypeAlias\`,
335
- FROM \`Constructor\` TO \`Enum\`,
336
- FROM \`Constructor\` TO \`Annotation\`,
337
- FROM \`Constructor\` TO \`Impl\`,
338
- FROM \`Constructor\` TO \`Namespace\`,
339
- FROM \`Constructor\` TO \`Module\`,
340
- FROM \`Constructor\` TO \`Property\`,
341
- FROM \`Constructor\` TO \`Typedef\`,
342
- FROM \`Template\` TO Community,
343
- FROM \`Module\` TO Community,
344
- FROM Function TO Process,
345
- FROM Method TO Process,
346
- FROM Class TO Process,
347
- FROM Interface TO Process,
348
- FROM \`Struct\` TO Process,
349
- FROM \`Constructor\` TO Process,
350
- FROM \`Module\` TO Process,
351
- FROM \`Macro\` TO Process,
352
- FROM \`Impl\` TO Process,
353
- FROM \`Typedef\` TO Process,
354
- FROM \`TypeAlias\` TO Process,
355
- FROM \`Enum\` TO Process,
356
- FROM \`Union\` TO Process,
357
- FROM \`Namespace\` TO Process,
358
- FROM \`Trait\` TO Process,
359
- FROM \`Const\` TO Process,
360
- FROM \`Static\` TO Process,
361
- FROM \`Property\` TO Process,
362
- FROM \`Record\` TO Process,
363
- FROM \`Delegate\` TO Process,
364
- FROM \`Annotation\` TO Process,
365
- FROM \`Template\` TO Process,
366
- FROM CodeElement TO Process,
367
- type STRING,
368
- confidence DOUBLE,
369
- reason STRING,
370
- step INT32
176
+ export const RELATION_SCHEMA = `
177
+ CREATE REL TABLE ${REL_TABLE_NAME} (
178
+ FROM File TO File,
179
+ FROM File TO Folder,
180
+ FROM File TO Function,
181
+ FROM File TO Class,
182
+ FROM File TO Interface,
183
+ FROM File TO Method,
184
+ FROM File TO CodeElement,
185
+ FROM File TO \`Struct\`,
186
+ FROM File TO \`Enum\`,
187
+ FROM File TO \`Macro\`,
188
+ FROM File TO \`Typedef\`,
189
+ FROM File TO \`Union\`,
190
+ FROM File TO \`Namespace\`,
191
+ FROM File TO \`Trait\`,
192
+ FROM File TO \`Impl\`,
193
+ FROM File TO \`TypeAlias\`,
194
+ FROM File TO \`Const\`,
195
+ FROM File TO \`Static\`,
196
+ FROM File TO \`Property\`,
197
+ FROM File TO \`Record\`,
198
+ FROM File TO \`Delegate\`,
199
+ FROM File TO \`Annotation\`,
200
+ FROM File TO \`Constructor\`,
201
+ FROM File TO \`Template\`,
202
+ FROM File TO \`Module\`,
203
+ FROM Folder TO Folder,
204
+ FROM Folder TO File,
205
+ FROM Function TO Function,
206
+ FROM Function TO Method,
207
+ FROM Function TO Class,
208
+ FROM Function TO Community,
209
+ FROM Function TO \`Macro\`,
210
+ FROM Function TO \`Struct\`,
211
+ FROM Function TO \`Template\`,
212
+ FROM Function TO \`Enum\`,
213
+ FROM Function TO \`Namespace\`,
214
+ FROM Function TO \`TypeAlias\`,
215
+ FROM Function TO \`Module\`,
216
+ FROM Function TO \`Impl\`,
217
+ FROM Function TO Interface,
218
+ FROM Function TO \`Constructor\`,
219
+ FROM Function TO \`Const\`,
220
+ FROM Function TO \`Typedef\`,
221
+ FROM Function TO \`Union\`,
222
+ FROM Function TO \`Property\`,
223
+ FROM Class TO Method,
224
+ FROM Class TO Function,
225
+ FROM Class TO Class,
226
+ FROM Class TO Interface,
227
+ FROM Class TO Community,
228
+ FROM Class TO \`Template\`,
229
+ FROM Class TO \`TypeAlias\`,
230
+ FROM Class TO \`Struct\`,
231
+ FROM Class TO \`Enum\`,
232
+ FROM Class TO \`Annotation\`,
233
+ FROM Class TO \`Constructor\`,
234
+ FROM Class TO \`Trait\`,
235
+ FROM Class TO \`Macro\`,
236
+ FROM Class TO \`Impl\`,
237
+ FROM Class TO \`Union\`,
238
+ FROM Class TO \`Namespace\`,
239
+ FROM Class TO \`Typedef\`,
240
+ FROM Method TO Function,
241
+ FROM Method TO Method,
242
+ FROM Method TO Class,
243
+ FROM Method TO Community,
244
+ FROM Method TO \`Template\`,
245
+ FROM Method TO \`Struct\`,
246
+ FROM Method TO \`TypeAlias\`,
247
+ FROM Method TO \`Enum\`,
248
+ FROM Method TO \`Macro\`,
249
+ FROM Method TO \`Namespace\`,
250
+ FROM Method TO \`Module\`,
251
+ FROM Method TO \`Impl\`,
252
+ FROM Method TO Interface,
253
+ FROM Method TO \`Constructor\`,
254
+ FROM Method TO \`Property\`,
255
+ FROM \`Template\` TO \`Template\`,
256
+ FROM \`Template\` TO Function,
257
+ FROM \`Template\` TO Method,
258
+ FROM \`Template\` TO Class,
259
+ FROM \`Template\` TO \`Struct\`,
260
+ FROM \`Template\` TO \`TypeAlias\`,
261
+ FROM \`Template\` TO \`Enum\`,
262
+ FROM \`Template\` TO \`Macro\`,
263
+ FROM \`Template\` TO Interface,
264
+ FROM \`Template\` TO \`Constructor\`,
265
+ FROM \`Module\` TO \`Module\`,
266
+ FROM CodeElement TO Community,
267
+ FROM Interface TO Community,
268
+ FROM Interface TO Function,
269
+ FROM Interface TO Method,
270
+ FROM Interface TO Class,
271
+ FROM Interface TO Interface,
272
+ FROM Interface TO \`TypeAlias\`,
273
+ FROM Interface TO \`Struct\`,
274
+ FROM Interface TO \`Constructor\`,
275
+ FROM \`Struct\` TO Community,
276
+ FROM \`Struct\` TO \`Trait\`,
277
+ FROM \`Struct\` TO \`Struct\`,
278
+ FROM \`Struct\` TO Class,
279
+ FROM \`Struct\` TO \`Enum\`,
280
+ FROM \`Struct\` TO Function,
281
+ FROM \`Struct\` TO Method,
282
+ FROM \`Struct\` TO Interface,
283
+ FROM \`Enum\` TO \`Enum\`,
284
+ FROM \`Enum\` TO Community,
285
+ FROM \`Enum\` TO Class,
286
+ FROM \`Enum\` TO Interface,
287
+ FROM \`Macro\` TO Community,
288
+ FROM \`Macro\` TO Function,
289
+ FROM \`Macro\` TO Method,
290
+ FROM \`Module\` TO Function,
291
+ FROM \`Module\` TO Method,
292
+ FROM \`Typedef\` TO Community,
293
+ FROM \`Union\` TO Community,
294
+ FROM \`Namespace\` TO Community,
295
+ FROM \`Namespace\` TO \`Struct\`,
296
+ FROM \`Trait\` TO Community,
297
+ FROM \`Impl\` TO Community,
298
+ FROM \`Impl\` TO \`Trait\`,
299
+ FROM \`Impl\` TO \`Struct\`,
300
+ FROM \`Impl\` TO \`Impl\`,
301
+ FROM \`TypeAlias\` TO Community,
302
+ FROM \`TypeAlias\` TO \`Trait\`,
303
+ FROM \`TypeAlias\` TO Class,
304
+ FROM \`Const\` TO Community,
305
+ FROM \`Static\` TO Community,
306
+ FROM \`Property\` TO Community,
307
+ FROM \`Record\` TO Community,
308
+ FROM \`Delegate\` TO Community,
309
+ FROM \`Annotation\` TO Community,
310
+ FROM \`Constructor\` TO Community,
311
+ FROM \`Constructor\` TO Interface,
312
+ FROM \`Constructor\` TO Class,
313
+ FROM \`Constructor\` TO Method,
314
+ FROM \`Constructor\` TO Function,
315
+ FROM \`Constructor\` TO \`Constructor\`,
316
+ FROM \`Constructor\` TO \`Struct\`,
317
+ FROM \`Constructor\` TO \`Macro\`,
318
+ FROM \`Constructor\` TO \`Template\`,
319
+ FROM \`Constructor\` TO \`TypeAlias\`,
320
+ FROM \`Constructor\` TO \`Enum\`,
321
+ FROM \`Constructor\` TO \`Annotation\`,
322
+ FROM \`Constructor\` TO \`Impl\`,
323
+ FROM \`Constructor\` TO \`Namespace\`,
324
+ FROM \`Constructor\` TO \`Module\`,
325
+ FROM \`Constructor\` TO \`Property\`,
326
+ FROM \`Constructor\` TO \`Typedef\`,
327
+ FROM \`Template\` TO Community,
328
+ FROM \`Module\` TO Community,
329
+ FROM Function TO Process,
330
+ FROM Method TO Process,
331
+ FROM Class TO Process,
332
+ FROM Interface TO Process,
333
+ FROM \`Struct\` TO Process,
334
+ FROM \`Constructor\` TO Process,
335
+ FROM \`Module\` TO Process,
336
+ FROM \`Macro\` TO Process,
337
+ FROM \`Impl\` TO Process,
338
+ FROM \`Typedef\` TO Process,
339
+ FROM \`TypeAlias\` TO Process,
340
+ FROM \`Enum\` TO Process,
341
+ FROM \`Union\` TO Process,
342
+ FROM \`Namespace\` TO Process,
343
+ FROM \`Trait\` TO Process,
344
+ FROM \`Const\` TO Process,
345
+ FROM \`Static\` TO Process,
346
+ FROM \`Property\` TO Process,
347
+ FROM \`Record\` TO Process,
348
+ FROM \`Delegate\` TO Process,
349
+ FROM \`Annotation\` TO Process,
350
+ FROM \`Template\` TO Process,
351
+ FROM CodeElement TO Process,
352
+ type STRING,
353
+ confidence DOUBLE,
354
+ reason STRING,
355
+ step INT32
371
356
  )`;
372
357
  // ============================================================================
373
358
  // EMBEDDING TABLE SCHEMA
374
359
  // Separate table for vector storage to avoid copy-on-write overhead
375
360
  // ============================================================================
376
- export const EMBEDDING_SCHEMA = `
377
- CREATE NODE TABLE ${EMBEDDING_TABLE_NAME} (
378
- nodeId STRING,
379
- embedding FLOAT[384],
380
- PRIMARY KEY (nodeId)
361
+ export const EMBEDDING_SCHEMA = `
362
+ CREATE NODE TABLE ${EMBEDDING_TABLE_NAME} (
363
+ nodeId STRING,
364
+ embedding FLOAT[384],
365
+ PRIMARY KEY (nodeId)
381
366
  )`;
382
367
  /**
383
368
  * Create vector index for semantic search
384
369
  * Uses HNSW (Hierarchical Navigable Small World) algorithm with cosine similarity
385
370
  */
386
- export const CREATE_VECTOR_INDEX_QUERY = `
387
- CALL CREATE_VECTOR_INDEX('${EMBEDDING_TABLE_NAME}', 'code_embedding_idx', 'embedding', metric := 'cosine')
371
+ export const CREATE_VECTOR_INDEX_QUERY = `
372
+ CALL CREATE_VECTOR_INDEX('${EMBEDDING_TABLE_NAME}', 'code_embedding_idx', 'embedding', metric := 'cosine')
388
373
  `;
389
374
  // ============================================================================
390
375
  // ALL SCHEMA QUERIES IN ORDER
@@ -10,13 +10,12 @@ import { queryFTS } from '../kuzu/kuzu-adapter.js';
10
10
  * Returns the same shape as core queryFTS.
11
11
  */
12
12
  async function queryFTSViaExecutor(executor, tableName, indexName, query, limit) {
13
- // Escape single quotes and backslashes to prevent Cypher injection
14
- const escapedQuery = query.replace(/\\/g, '\\\\').replace(/'/g, "''");
15
- const cypher = `
16
- CALL QUERY_FTS_INDEX('${tableName}', '${indexName}', '${escapedQuery}', conjunctive := false)
17
- RETURN node, score
18
- ORDER BY score DESC
19
- LIMIT ${limit}
13
+ const escapedQuery = query.replace(/'/g, "''");
14
+ const cypher = `
15
+ CALL QUERY_FTS_INDEX('${tableName}', '${indexName}', '${escapedQuery}', conjunctive := false)
16
+ RETURN node, score
17
+ ORDER BY score DESC
18
+ LIMIT ${limit}
20
19
  `;
21
20
  try {
22
21
  const rows = await executor(cypher);
@@ -98,9 +98,9 @@ export const formatHybridResults = (results) => {
98
98
  const location = r.startLine ? ` (lines ${r.startLine}-${r.endLine})` : '';
99
99
  const label = r.label ? `${r.label}: ` : 'File: ';
100
100
  const name = r.name || r.filePath.split('/').pop() || r.filePath;
101
- return `[${i + 1}] ${label}${name}
102
- File: ${r.filePath}${location}
103
- Found by: ${sources}
101
+ return `[${i + 1}] ${label}${name}
102
+ File: ${r.filePath}${location}
103
+ Found by: ${sources}
104
104
  Relevance: ${r.score.toFixed(4)}`;
105
105
  });
106
106
  return `Found ${results.length} results:\n\n${formatted.join('\n\n')}`;