gitnexus 1.2.7 → 1.2.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.
- package/README.md +186 -186
- package/dist/cli/ai-context.js +71 -71
- package/dist/cli/analyze.d.ts +1 -1
- package/dist/cli/analyze.js +59 -15
- package/dist/cli/index.js +1 -1
- package/dist/core/augmentation/engine.js +20 -20
- package/dist/core/embeddings/embedder.js +1 -0
- package/dist/core/embeddings/embedding-pipeline.js +26 -26
- package/dist/core/ingestion/cluster-enricher.js +16 -16
- package/dist/core/ingestion/tree-sitter-queries.js +282 -282
- package/dist/core/kuzu/kuzu-adapter.js +9 -9
- package/dist/core/kuzu/schema.js +256 -256
- package/dist/core/search/bm25-index.js +5 -5
- package/dist/core/search/hybrid-search.js +3 -3
- package/dist/core/wiki/graph-queries.js +52 -52
- package/dist/core/wiki/html-viewer.js +192 -192
- package/dist/core/wiki/prompts.js +82 -82
- package/dist/mcp/local/local-backend.js +112 -112
- package/dist/mcp/resources.js +42 -42
- package/dist/mcp/server.js +16 -16
- package/dist/mcp/tools.js +77 -77
- package/hooks/claude/gitnexus-hook.cjs +135 -135
- package/hooks/claude/pre-tool-use.sh +78 -78
- package/hooks/claude/session-start.sh +42 -42
- package/package.json +82 -82
- package/skills/debugging.md +85 -85
- package/skills/exploring.md +75 -75
- package/skills/impact-analysis.md +94 -94
- package/skills/refactoring.md +113 -113
- package/vendor/leiden/index.cjs +355 -355
- package/vendor/leiden/utils.cjs +392 -392
package/dist/core/kuzu/schema.js
CHANGED
|
@@ -30,119 +30,119 @@ 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
|
-
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
|
+
PRIMARY KEY (id)
|
|
58
58
|
)`;
|
|
59
|
-
export const CLASS_SCHEMA = `
|
|
60
|
-
CREATE NODE TABLE Class (
|
|
61
|
-
id STRING,
|
|
62
|
-
name STRING,
|
|
63
|
-
filePath STRING,
|
|
64
|
-
startLine INT64,
|
|
65
|
-
endLine INT64,
|
|
66
|
-
isExported BOOLEAN,
|
|
67
|
-
content STRING,
|
|
68
|
-
PRIMARY KEY (id)
|
|
59
|
+
export const CLASS_SCHEMA = `
|
|
60
|
+
CREATE NODE TABLE Class (
|
|
61
|
+
id STRING,
|
|
62
|
+
name STRING,
|
|
63
|
+
filePath STRING,
|
|
64
|
+
startLine INT64,
|
|
65
|
+
endLine INT64,
|
|
66
|
+
isExported BOOLEAN,
|
|
67
|
+
content STRING,
|
|
68
|
+
PRIMARY KEY (id)
|
|
69
69
|
)`;
|
|
70
|
-
export const INTERFACE_SCHEMA = `
|
|
71
|
-
CREATE NODE TABLE Interface (
|
|
72
|
-
id STRING,
|
|
73
|
-
name STRING,
|
|
74
|
-
filePath STRING,
|
|
75
|
-
startLine INT64,
|
|
76
|
-
endLine INT64,
|
|
77
|
-
isExported BOOLEAN,
|
|
78
|
-
content STRING,
|
|
79
|
-
PRIMARY KEY (id)
|
|
70
|
+
export const INTERFACE_SCHEMA = `
|
|
71
|
+
CREATE NODE TABLE Interface (
|
|
72
|
+
id STRING,
|
|
73
|
+
name STRING,
|
|
74
|
+
filePath STRING,
|
|
75
|
+
startLine INT64,
|
|
76
|
+
endLine INT64,
|
|
77
|
+
isExported BOOLEAN,
|
|
78
|
+
content STRING,
|
|
79
|
+
PRIMARY KEY (id)
|
|
80
80
|
)`;
|
|
81
|
-
export const METHOD_SCHEMA = `
|
|
82
|
-
CREATE NODE TABLE Method (
|
|
83
|
-
id STRING,
|
|
84
|
-
name STRING,
|
|
85
|
-
filePath STRING,
|
|
86
|
-
startLine INT64,
|
|
87
|
-
endLine INT64,
|
|
88
|
-
isExported BOOLEAN,
|
|
89
|
-
content STRING,
|
|
90
|
-
PRIMARY KEY (id)
|
|
81
|
+
export const METHOD_SCHEMA = `
|
|
82
|
+
CREATE NODE TABLE Method (
|
|
83
|
+
id STRING,
|
|
84
|
+
name STRING,
|
|
85
|
+
filePath STRING,
|
|
86
|
+
startLine INT64,
|
|
87
|
+
endLine INT64,
|
|
88
|
+
isExported BOOLEAN,
|
|
89
|
+
content STRING,
|
|
90
|
+
PRIMARY KEY (id)
|
|
91
91
|
)`;
|
|
92
|
-
export const CODE_ELEMENT_SCHEMA = `
|
|
93
|
-
CREATE NODE TABLE CodeElement (
|
|
94
|
-
id STRING,
|
|
95
|
-
name STRING,
|
|
96
|
-
filePath STRING,
|
|
97
|
-
startLine INT64,
|
|
98
|
-
endLine INT64,
|
|
99
|
-
isExported BOOLEAN,
|
|
100
|
-
content STRING,
|
|
101
|
-
PRIMARY KEY (id)
|
|
92
|
+
export const CODE_ELEMENT_SCHEMA = `
|
|
93
|
+
CREATE NODE TABLE CodeElement (
|
|
94
|
+
id STRING,
|
|
95
|
+
name STRING,
|
|
96
|
+
filePath STRING,
|
|
97
|
+
startLine INT64,
|
|
98
|
+
endLine INT64,
|
|
99
|
+
isExported BOOLEAN,
|
|
100
|
+
content STRING,
|
|
101
|
+
PRIMARY KEY (id)
|
|
102
102
|
)`;
|
|
103
103
|
// ============================================================================
|
|
104
104
|
// COMMUNITY NODE TABLE (for Leiden algorithm clusters)
|
|
105
105
|
// ============================================================================
|
|
106
|
-
export const COMMUNITY_SCHEMA = `
|
|
107
|
-
CREATE NODE TABLE Community (
|
|
108
|
-
id STRING,
|
|
109
|
-
label STRING,
|
|
110
|
-
heuristicLabel STRING,
|
|
111
|
-
keywords STRING[],
|
|
112
|
-
description STRING,
|
|
113
|
-
enrichedBy STRING,
|
|
114
|
-
cohesion DOUBLE,
|
|
115
|
-
symbolCount INT32,
|
|
116
|
-
PRIMARY KEY (id)
|
|
106
|
+
export const COMMUNITY_SCHEMA = `
|
|
107
|
+
CREATE NODE TABLE Community (
|
|
108
|
+
id STRING,
|
|
109
|
+
label STRING,
|
|
110
|
+
heuristicLabel STRING,
|
|
111
|
+
keywords STRING[],
|
|
112
|
+
description STRING,
|
|
113
|
+
enrichedBy STRING,
|
|
114
|
+
cohesion DOUBLE,
|
|
115
|
+
symbolCount INT32,
|
|
116
|
+
PRIMARY KEY (id)
|
|
117
117
|
)`;
|
|
118
118
|
// ============================================================================
|
|
119
119
|
// PROCESS NODE TABLE (for execution flow detection)
|
|
120
120
|
// ============================================================================
|
|
121
|
-
export const PROCESS_SCHEMA = `
|
|
122
|
-
CREATE NODE TABLE Process (
|
|
123
|
-
id STRING,
|
|
124
|
-
label STRING,
|
|
125
|
-
heuristicLabel STRING,
|
|
126
|
-
processType STRING,
|
|
127
|
-
stepCount INT32,
|
|
128
|
-
communities STRING[],
|
|
129
|
-
entryPointId STRING,
|
|
130
|
-
terminalId STRING,
|
|
131
|
-
PRIMARY KEY (id)
|
|
121
|
+
export const PROCESS_SCHEMA = `
|
|
122
|
+
CREATE NODE TABLE Process (
|
|
123
|
+
id STRING,
|
|
124
|
+
label STRING,
|
|
125
|
+
heuristicLabel STRING,
|
|
126
|
+
processType STRING,
|
|
127
|
+
stepCount INT32,
|
|
128
|
+
communities STRING[],
|
|
129
|
+
entryPointId STRING,
|
|
130
|
+
terminalId STRING,
|
|
131
|
+
PRIMARY KEY (id)
|
|
132
132
|
)`;
|
|
133
133
|
// ============================================================================
|
|
134
134
|
// MULTI-LANGUAGE NODE TABLE SCHEMAS
|
|
135
135
|
// ============================================================================
|
|
136
136
|
// Generic code element with startLine/endLine for C, C++, Rust, Go, Java, C#
|
|
137
|
-
const CODE_ELEMENT_BASE = (name) => `
|
|
138
|
-
CREATE NODE TABLE \`${name}\` (
|
|
139
|
-
id STRING,
|
|
140
|
-
name STRING,
|
|
141
|
-
filePath STRING,
|
|
142
|
-
startLine INT64,
|
|
143
|
-
endLine INT64,
|
|
144
|
-
content STRING,
|
|
145
|
-
PRIMARY KEY (id)
|
|
137
|
+
const CODE_ELEMENT_BASE = (name) => `
|
|
138
|
+
CREATE NODE TABLE \`${name}\` (
|
|
139
|
+
id STRING,
|
|
140
|
+
name STRING,
|
|
141
|
+
filePath STRING,
|
|
142
|
+
startLine INT64,
|
|
143
|
+
endLine INT64,
|
|
144
|
+
content STRING,
|
|
145
|
+
PRIMARY KEY (id)
|
|
146
146
|
)`;
|
|
147
147
|
export const STRUCT_SCHEMA = CODE_ELEMENT_BASE('Struct');
|
|
148
148
|
export const ENUM_SCHEMA = CODE_ELEMENT_BASE('Enum');
|
|
@@ -166,178 +166,178 @@ export const MODULE_SCHEMA = CODE_ELEMENT_BASE('Module');
|
|
|
166
166
|
// RELATION TABLE SCHEMA
|
|
167
167
|
// Single table with 'type' property - connects all node tables
|
|
168
168
|
// ============================================================================
|
|
169
|
-
export const RELATION_SCHEMA = `
|
|
170
|
-
CREATE REL TABLE ${REL_TABLE_NAME} (
|
|
171
|
-
FROM File TO File,
|
|
172
|
-
FROM File TO Folder,
|
|
173
|
-
FROM File TO Function,
|
|
174
|
-
FROM File TO Class,
|
|
175
|
-
FROM File TO Interface,
|
|
176
|
-
FROM File TO Method,
|
|
177
|
-
FROM File TO CodeElement,
|
|
178
|
-
FROM File TO \`Struct\`,
|
|
179
|
-
FROM File TO \`Enum\`,
|
|
180
|
-
FROM File TO \`Macro\`,
|
|
181
|
-
FROM File TO \`Typedef\`,
|
|
182
|
-
FROM File TO \`Union\`,
|
|
183
|
-
FROM File TO \`Namespace\`,
|
|
184
|
-
FROM File TO \`Trait\`,
|
|
185
|
-
FROM File TO \`Impl\`,
|
|
186
|
-
FROM File TO \`TypeAlias\`,
|
|
187
|
-
FROM File TO \`Const\`,
|
|
188
|
-
FROM File TO \`Static\`,
|
|
189
|
-
FROM File TO \`Property\`,
|
|
190
|
-
FROM File TO \`Record\`,
|
|
191
|
-
FROM File TO \`Delegate\`,
|
|
192
|
-
FROM File TO \`Annotation\`,
|
|
193
|
-
FROM File TO \`Constructor\`,
|
|
194
|
-
FROM File TO \`Template\`,
|
|
195
|
-
FROM File TO \`Module\`,
|
|
196
|
-
FROM Folder TO Folder,
|
|
197
|
-
FROM Folder TO File,
|
|
198
|
-
FROM Function TO Function,
|
|
199
|
-
FROM Function TO Method,
|
|
200
|
-
FROM Function TO Class,
|
|
201
|
-
FROM Function TO Community,
|
|
202
|
-
FROM Function TO \`Macro\`,
|
|
203
|
-
FROM Function TO \`Struct\`,
|
|
204
|
-
FROM Function TO \`Template\`,
|
|
205
|
-
FROM Function TO \`Enum\`,
|
|
206
|
-
FROM Function TO \`Namespace\`,
|
|
207
|
-
FROM Function TO \`TypeAlias\`,
|
|
208
|
-
FROM Function TO \`Module\`,
|
|
209
|
-
FROM Function TO \`Impl\`,
|
|
210
|
-
FROM Function TO Interface,
|
|
211
|
-
FROM Function TO \`Constructor\`,
|
|
212
|
-
FROM Class TO Method,
|
|
213
|
-
FROM Class TO Function,
|
|
214
|
-
FROM Class TO Class,
|
|
215
|
-
FROM Class TO Interface,
|
|
216
|
-
FROM Class TO Community,
|
|
217
|
-
FROM Class TO \`Template\`,
|
|
218
|
-
FROM Class TO \`TypeAlias\`,
|
|
219
|
-
FROM Class TO \`Struct\`,
|
|
220
|
-
FROM Class TO \`Enum\`,
|
|
221
|
-
FROM Class TO \`Annotation\`,
|
|
222
|
-
FROM Class TO \`Constructor\`,
|
|
223
|
-
FROM Method TO Function,
|
|
224
|
-
FROM Method TO Method,
|
|
225
|
-
FROM Method TO Class,
|
|
226
|
-
FROM Method TO Community,
|
|
227
|
-
FROM Method TO \`Template\`,
|
|
228
|
-
FROM Method TO \`Struct\`,
|
|
229
|
-
FROM Method TO \`TypeAlias\`,
|
|
230
|
-
FROM Method TO \`Enum\`,
|
|
231
|
-
FROM Method TO \`Macro\`,
|
|
232
|
-
FROM Method TO \`Namespace\`,
|
|
233
|
-
FROM Method TO \`Module\`,
|
|
234
|
-
FROM Method TO \`Impl\`,
|
|
235
|
-
FROM Method TO Interface,
|
|
236
|
-
FROM Method TO \`Constructor\`,
|
|
237
|
-
FROM \`Template\` TO \`Template\`,
|
|
238
|
-
FROM \`Template\` TO Function,
|
|
239
|
-
FROM \`Template\` TO Method,
|
|
240
|
-
FROM \`Template\` TO Class,
|
|
241
|
-
FROM \`Template\` TO \`Struct\`,
|
|
242
|
-
FROM \`Template\` TO \`TypeAlias\`,
|
|
243
|
-
FROM \`Template\` TO \`Enum\`,
|
|
244
|
-
FROM \`Template\` TO \`Macro\`,
|
|
245
|
-
FROM \`Template\` TO Interface,
|
|
246
|
-
FROM \`Template\` TO \`Constructor\`,
|
|
247
|
-
FROM \`Module\` TO \`Module\`,
|
|
248
|
-
FROM CodeElement TO Community,
|
|
249
|
-
FROM Interface TO Community,
|
|
250
|
-
FROM Interface TO Function,
|
|
251
|
-
FROM Interface TO Method,
|
|
252
|
-
FROM Interface TO Class,
|
|
253
|
-
FROM Interface TO Interface,
|
|
254
|
-
FROM Interface TO \`TypeAlias\`,
|
|
255
|
-
FROM Interface TO \`Struct\`,
|
|
256
|
-
FROM Interface TO \`Constructor\`,
|
|
257
|
-
FROM \`Struct\` TO Community,
|
|
258
|
-
FROM \`Struct\` TO \`Trait\`,
|
|
259
|
-
FROM \`Struct\` TO Function,
|
|
260
|
-
FROM \`Struct\` TO Method,
|
|
261
|
-
FROM \`Enum\` TO Community,
|
|
262
|
-
FROM \`Macro\` TO Community,
|
|
263
|
-
FROM \`Macro\` TO Function,
|
|
264
|
-
FROM \`Macro\` TO Method,
|
|
265
|
-
FROM \`Module\` TO Function,
|
|
266
|
-
FROM \`Module\` TO Method,
|
|
267
|
-
FROM \`Typedef\` TO Community,
|
|
268
|
-
FROM \`Union\` TO Community,
|
|
269
|
-
FROM \`Namespace\` TO Community,
|
|
270
|
-
FROM \`Trait\` TO Community,
|
|
271
|
-
FROM \`Impl\` TO Community,
|
|
272
|
-
FROM \`Impl\` TO \`Trait\`,
|
|
273
|
-
FROM \`TypeAlias\` TO Community,
|
|
274
|
-
FROM \`Const\` TO Community,
|
|
275
|
-
FROM \`Static\` TO Community,
|
|
276
|
-
FROM \`Property\` TO Community,
|
|
277
|
-
FROM \`Record\` TO Community,
|
|
278
|
-
FROM \`Delegate\` TO Community,
|
|
279
|
-
FROM \`Annotation\` TO Community,
|
|
280
|
-
FROM \`Constructor\` TO Community,
|
|
281
|
-
FROM \`Constructor\` TO Interface,
|
|
282
|
-
FROM \`Constructor\` TO Class,
|
|
283
|
-
FROM \`Constructor\` TO Method,
|
|
284
|
-
FROM \`Constructor\` TO Function,
|
|
285
|
-
FROM \`Constructor\` TO \`Constructor\`,
|
|
286
|
-
FROM \`Constructor\` TO \`Struct\`,
|
|
287
|
-
FROM \`Constructor\` TO \`Macro\`,
|
|
288
|
-
FROM \`Constructor\` TO \`Template\`,
|
|
289
|
-
FROM \`Constructor\` TO \`TypeAlias\`,
|
|
290
|
-
FROM \`Constructor\` TO \`Enum\`,
|
|
291
|
-
FROM \`Constructor\` TO \`Annotation\`,
|
|
292
|
-
FROM \`Constructor\` TO \`Impl\`,
|
|
293
|
-
FROM \`Constructor\` TO \`Namespace\`,
|
|
294
|
-
FROM \`Constructor\` TO \`Module\`,
|
|
295
|
-
FROM \`Template\` TO Community,
|
|
296
|
-
FROM \`Module\` TO Community,
|
|
297
|
-
FROM Function TO Process,
|
|
298
|
-
FROM Method TO Process,
|
|
299
|
-
FROM Class TO Process,
|
|
300
|
-
FROM Interface TO Process,
|
|
301
|
-
FROM \`Struct\` TO Process,
|
|
302
|
-
FROM \`Constructor\` TO Process,
|
|
303
|
-
FROM \`Module\` TO Process,
|
|
304
|
-
FROM \`Macro\` TO Process,
|
|
305
|
-
FROM \`Impl\` TO Process,
|
|
306
|
-
FROM \`Typedef\` TO Process,
|
|
307
|
-
FROM \`TypeAlias\` TO Process,
|
|
308
|
-
FROM \`Enum\` TO Process,
|
|
309
|
-
FROM \`Union\` TO Process,
|
|
310
|
-
FROM \`Namespace\` TO Process,
|
|
311
|
-
FROM \`Trait\` TO Process,
|
|
312
|
-
FROM \`Const\` TO Process,
|
|
313
|
-
FROM \`Static\` TO Process,
|
|
314
|
-
FROM \`Property\` TO Process,
|
|
315
|
-
FROM \`Record\` TO Process,
|
|
316
|
-
FROM \`Delegate\` TO Process,
|
|
317
|
-
FROM \`Annotation\` TO Process,
|
|
318
|
-
FROM \`Template\` TO Process,
|
|
319
|
-
FROM CodeElement TO Process,
|
|
320
|
-
type STRING,
|
|
321
|
-
confidence DOUBLE,
|
|
322
|
-
reason STRING,
|
|
323
|
-
step INT32
|
|
169
|
+
export const RELATION_SCHEMA = `
|
|
170
|
+
CREATE REL TABLE ${REL_TABLE_NAME} (
|
|
171
|
+
FROM File TO File,
|
|
172
|
+
FROM File TO Folder,
|
|
173
|
+
FROM File TO Function,
|
|
174
|
+
FROM File TO Class,
|
|
175
|
+
FROM File TO Interface,
|
|
176
|
+
FROM File TO Method,
|
|
177
|
+
FROM File TO CodeElement,
|
|
178
|
+
FROM File TO \`Struct\`,
|
|
179
|
+
FROM File TO \`Enum\`,
|
|
180
|
+
FROM File TO \`Macro\`,
|
|
181
|
+
FROM File TO \`Typedef\`,
|
|
182
|
+
FROM File TO \`Union\`,
|
|
183
|
+
FROM File TO \`Namespace\`,
|
|
184
|
+
FROM File TO \`Trait\`,
|
|
185
|
+
FROM File TO \`Impl\`,
|
|
186
|
+
FROM File TO \`TypeAlias\`,
|
|
187
|
+
FROM File TO \`Const\`,
|
|
188
|
+
FROM File TO \`Static\`,
|
|
189
|
+
FROM File TO \`Property\`,
|
|
190
|
+
FROM File TO \`Record\`,
|
|
191
|
+
FROM File TO \`Delegate\`,
|
|
192
|
+
FROM File TO \`Annotation\`,
|
|
193
|
+
FROM File TO \`Constructor\`,
|
|
194
|
+
FROM File TO \`Template\`,
|
|
195
|
+
FROM File TO \`Module\`,
|
|
196
|
+
FROM Folder TO Folder,
|
|
197
|
+
FROM Folder TO File,
|
|
198
|
+
FROM Function TO Function,
|
|
199
|
+
FROM Function TO Method,
|
|
200
|
+
FROM Function TO Class,
|
|
201
|
+
FROM Function TO Community,
|
|
202
|
+
FROM Function TO \`Macro\`,
|
|
203
|
+
FROM Function TO \`Struct\`,
|
|
204
|
+
FROM Function TO \`Template\`,
|
|
205
|
+
FROM Function TO \`Enum\`,
|
|
206
|
+
FROM Function TO \`Namespace\`,
|
|
207
|
+
FROM Function TO \`TypeAlias\`,
|
|
208
|
+
FROM Function TO \`Module\`,
|
|
209
|
+
FROM Function TO \`Impl\`,
|
|
210
|
+
FROM Function TO Interface,
|
|
211
|
+
FROM Function TO \`Constructor\`,
|
|
212
|
+
FROM Class TO Method,
|
|
213
|
+
FROM Class TO Function,
|
|
214
|
+
FROM Class TO Class,
|
|
215
|
+
FROM Class TO Interface,
|
|
216
|
+
FROM Class TO Community,
|
|
217
|
+
FROM Class TO \`Template\`,
|
|
218
|
+
FROM Class TO \`TypeAlias\`,
|
|
219
|
+
FROM Class TO \`Struct\`,
|
|
220
|
+
FROM Class TO \`Enum\`,
|
|
221
|
+
FROM Class TO \`Annotation\`,
|
|
222
|
+
FROM Class TO \`Constructor\`,
|
|
223
|
+
FROM Method TO Function,
|
|
224
|
+
FROM Method TO Method,
|
|
225
|
+
FROM Method TO Class,
|
|
226
|
+
FROM Method TO Community,
|
|
227
|
+
FROM Method TO \`Template\`,
|
|
228
|
+
FROM Method TO \`Struct\`,
|
|
229
|
+
FROM Method TO \`TypeAlias\`,
|
|
230
|
+
FROM Method TO \`Enum\`,
|
|
231
|
+
FROM Method TO \`Macro\`,
|
|
232
|
+
FROM Method TO \`Namespace\`,
|
|
233
|
+
FROM Method TO \`Module\`,
|
|
234
|
+
FROM Method TO \`Impl\`,
|
|
235
|
+
FROM Method TO Interface,
|
|
236
|
+
FROM Method TO \`Constructor\`,
|
|
237
|
+
FROM \`Template\` TO \`Template\`,
|
|
238
|
+
FROM \`Template\` TO Function,
|
|
239
|
+
FROM \`Template\` TO Method,
|
|
240
|
+
FROM \`Template\` TO Class,
|
|
241
|
+
FROM \`Template\` TO \`Struct\`,
|
|
242
|
+
FROM \`Template\` TO \`TypeAlias\`,
|
|
243
|
+
FROM \`Template\` TO \`Enum\`,
|
|
244
|
+
FROM \`Template\` TO \`Macro\`,
|
|
245
|
+
FROM \`Template\` TO Interface,
|
|
246
|
+
FROM \`Template\` TO \`Constructor\`,
|
|
247
|
+
FROM \`Module\` TO \`Module\`,
|
|
248
|
+
FROM CodeElement TO Community,
|
|
249
|
+
FROM Interface TO Community,
|
|
250
|
+
FROM Interface TO Function,
|
|
251
|
+
FROM Interface TO Method,
|
|
252
|
+
FROM Interface TO Class,
|
|
253
|
+
FROM Interface TO Interface,
|
|
254
|
+
FROM Interface TO \`TypeAlias\`,
|
|
255
|
+
FROM Interface TO \`Struct\`,
|
|
256
|
+
FROM Interface TO \`Constructor\`,
|
|
257
|
+
FROM \`Struct\` TO Community,
|
|
258
|
+
FROM \`Struct\` TO \`Trait\`,
|
|
259
|
+
FROM \`Struct\` TO Function,
|
|
260
|
+
FROM \`Struct\` TO Method,
|
|
261
|
+
FROM \`Enum\` TO Community,
|
|
262
|
+
FROM \`Macro\` TO Community,
|
|
263
|
+
FROM \`Macro\` TO Function,
|
|
264
|
+
FROM \`Macro\` TO Method,
|
|
265
|
+
FROM \`Module\` TO Function,
|
|
266
|
+
FROM \`Module\` TO Method,
|
|
267
|
+
FROM \`Typedef\` TO Community,
|
|
268
|
+
FROM \`Union\` TO Community,
|
|
269
|
+
FROM \`Namespace\` TO Community,
|
|
270
|
+
FROM \`Trait\` TO Community,
|
|
271
|
+
FROM \`Impl\` TO Community,
|
|
272
|
+
FROM \`Impl\` TO \`Trait\`,
|
|
273
|
+
FROM \`TypeAlias\` TO Community,
|
|
274
|
+
FROM \`Const\` TO Community,
|
|
275
|
+
FROM \`Static\` TO Community,
|
|
276
|
+
FROM \`Property\` TO Community,
|
|
277
|
+
FROM \`Record\` TO Community,
|
|
278
|
+
FROM \`Delegate\` TO Community,
|
|
279
|
+
FROM \`Annotation\` TO Community,
|
|
280
|
+
FROM \`Constructor\` TO Community,
|
|
281
|
+
FROM \`Constructor\` TO Interface,
|
|
282
|
+
FROM \`Constructor\` TO Class,
|
|
283
|
+
FROM \`Constructor\` TO Method,
|
|
284
|
+
FROM \`Constructor\` TO Function,
|
|
285
|
+
FROM \`Constructor\` TO \`Constructor\`,
|
|
286
|
+
FROM \`Constructor\` TO \`Struct\`,
|
|
287
|
+
FROM \`Constructor\` TO \`Macro\`,
|
|
288
|
+
FROM \`Constructor\` TO \`Template\`,
|
|
289
|
+
FROM \`Constructor\` TO \`TypeAlias\`,
|
|
290
|
+
FROM \`Constructor\` TO \`Enum\`,
|
|
291
|
+
FROM \`Constructor\` TO \`Annotation\`,
|
|
292
|
+
FROM \`Constructor\` TO \`Impl\`,
|
|
293
|
+
FROM \`Constructor\` TO \`Namespace\`,
|
|
294
|
+
FROM \`Constructor\` TO \`Module\`,
|
|
295
|
+
FROM \`Template\` TO Community,
|
|
296
|
+
FROM \`Module\` TO Community,
|
|
297
|
+
FROM Function TO Process,
|
|
298
|
+
FROM Method TO Process,
|
|
299
|
+
FROM Class TO Process,
|
|
300
|
+
FROM Interface TO Process,
|
|
301
|
+
FROM \`Struct\` TO Process,
|
|
302
|
+
FROM \`Constructor\` TO Process,
|
|
303
|
+
FROM \`Module\` TO Process,
|
|
304
|
+
FROM \`Macro\` TO Process,
|
|
305
|
+
FROM \`Impl\` TO Process,
|
|
306
|
+
FROM \`Typedef\` TO Process,
|
|
307
|
+
FROM \`TypeAlias\` TO Process,
|
|
308
|
+
FROM \`Enum\` TO Process,
|
|
309
|
+
FROM \`Union\` TO Process,
|
|
310
|
+
FROM \`Namespace\` TO Process,
|
|
311
|
+
FROM \`Trait\` TO Process,
|
|
312
|
+
FROM \`Const\` TO Process,
|
|
313
|
+
FROM \`Static\` TO Process,
|
|
314
|
+
FROM \`Property\` TO Process,
|
|
315
|
+
FROM \`Record\` TO Process,
|
|
316
|
+
FROM \`Delegate\` TO Process,
|
|
317
|
+
FROM \`Annotation\` TO Process,
|
|
318
|
+
FROM \`Template\` TO Process,
|
|
319
|
+
FROM CodeElement TO Process,
|
|
320
|
+
type STRING,
|
|
321
|
+
confidence DOUBLE,
|
|
322
|
+
reason STRING,
|
|
323
|
+
step INT32
|
|
324
324
|
)`;
|
|
325
325
|
// ============================================================================
|
|
326
326
|
// EMBEDDING TABLE SCHEMA
|
|
327
327
|
// Separate table for vector storage to avoid copy-on-write overhead
|
|
328
328
|
// ============================================================================
|
|
329
|
-
export const EMBEDDING_SCHEMA = `
|
|
330
|
-
CREATE NODE TABLE ${EMBEDDING_TABLE_NAME} (
|
|
331
|
-
nodeId STRING,
|
|
332
|
-
embedding FLOAT[384],
|
|
333
|
-
PRIMARY KEY (nodeId)
|
|
329
|
+
export const EMBEDDING_SCHEMA = `
|
|
330
|
+
CREATE NODE TABLE ${EMBEDDING_TABLE_NAME} (
|
|
331
|
+
nodeId STRING,
|
|
332
|
+
embedding FLOAT[384],
|
|
333
|
+
PRIMARY KEY (nodeId)
|
|
334
334
|
)`;
|
|
335
335
|
/**
|
|
336
336
|
* Create vector index for semantic search
|
|
337
337
|
* Uses HNSW (Hierarchical Navigable Small World) algorithm with cosine similarity
|
|
338
338
|
*/
|
|
339
|
-
export const CREATE_VECTOR_INDEX_QUERY = `
|
|
340
|
-
CALL CREATE_VECTOR_INDEX('${EMBEDDING_TABLE_NAME}', 'code_embedding_idx', 'embedding', metric := 'cosine')
|
|
339
|
+
export const CREATE_VECTOR_INDEX_QUERY = `
|
|
340
|
+
CALL CREATE_VECTOR_INDEX('${EMBEDDING_TABLE_NAME}', 'code_embedding_idx', 'embedding', metric := 'cosine')
|
|
341
341
|
`;
|
|
342
342
|
// ============================================================================
|
|
343
343
|
// ALL SCHEMA QUERIES IN ORDER
|
|
@@ -11,11 +11,11 @@ import { queryFTS } from '../kuzu/kuzu-adapter.js';
|
|
|
11
11
|
*/
|
|
12
12
|
async function queryFTSViaExecutor(executor, tableName, indexName, query, limit) {
|
|
13
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}
|
|
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}
|
|
19
19
|
`;
|
|
20
20
|
try {
|
|
21
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')}`;
|