@veewo/gitnexus 1.3.11 → 1.4.6-rc
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 +37 -80
- package/dist/benchmark/agent-context/tool-runner.js +2 -2
- package/dist/benchmark/neonspark-candidates.js +3 -3
- package/dist/benchmark/tool-runner.js +2 -2
- package/dist/cli/ai-context.d.ts +2 -1
- package/dist/cli/ai-context.js +16 -12
- package/dist/cli/analyze.d.ts +2 -0
- package/dist/cli/analyze.js +68 -48
- package/dist/cli/augment.js +1 -1
- package/dist/cli/eval-server.d.ts +8 -1
- package/dist/cli/eval-server.js +30 -13
- package/dist/cli/index.js +28 -82
- package/dist/cli/lazy-action.d.ts +6 -0
- package/dist/cli/lazy-action.js +18 -0
- package/dist/cli/mcp.js +3 -1
- package/dist/cli/setup.js +87 -48
- package/dist/cli/setup.test.js +18 -13
- package/dist/cli/skill-gen.d.ts +26 -0
- package/dist/cli/skill-gen.js +549 -0
- package/dist/cli/status.js +13 -4
- package/dist/cli/tool.d.ts +3 -2
- package/dist/cli/tool.js +50 -16
- package/dist/cli/wiki.js +8 -4
- package/dist/config/ignore-service.d.ts +25 -0
- package/dist/config/ignore-service.js +76 -0
- package/dist/config/supported-languages.d.ts +4 -1
- package/dist/config/supported-languages.js +3 -2
- package/dist/core/augmentation/engine.js +94 -67
- package/dist/core/embeddings/embedder.d.ts +1 -1
- package/dist/core/embeddings/embedder.js +1 -1
- package/dist/core/embeddings/embedding-pipeline.d.ts +3 -3
- package/dist/core/embeddings/embedding-pipeline.js +52 -25
- package/dist/core/embeddings/types.d.ts +1 -1
- package/dist/core/graph/types.d.ts +7 -2
- package/dist/core/ingestion/ast-cache.js +3 -2
- package/dist/core/ingestion/call-processor.d.ts +8 -6
- package/dist/core/ingestion/call-processor.js +468 -206
- package/dist/core/ingestion/call-routing.d.ts +53 -0
- package/dist/core/ingestion/call-routing.js +108 -0
- package/dist/core/ingestion/constants.d.ts +16 -0
- package/dist/core/ingestion/constants.js +16 -0
- package/dist/core/ingestion/entry-point-scoring.d.ts +2 -1
- package/dist/core/ingestion/entry-point-scoring.js +116 -23
- package/dist/core/ingestion/export-detection.d.ts +18 -0
- package/dist/core/ingestion/export-detection.js +231 -0
- package/dist/core/ingestion/filesystem-walker.js +4 -3
- package/dist/core/ingestion/framework-detection.d.ts +19 -4
- package/dist/core/ingestion/framework-detection.js +182 -6
- package/dist/core/ingestion/heritage-processor.d.ts +13 -5
- package/dist/core/ingestion/heritage-processor.js +109 -55
- package/dist/core/ingestion/import-processor.d.ts +16 -20
- package/dist/core/ingestion/import-processor.js +199 -579
- package/dist/core/ingestion/language-config.d.ts +46 -0
- package/dist/core/ingestion/language-config.js +167 -0
- package/dist/core/ingestion/mro-processor.d.ts +45 -0
- package/dist/core/ingestion/mro-processor.js +369 -0
- package/dist/core/ingestion/named-binding-extraction.d.ts +61 -0
- package/dist/core/ingestion/named-binding-extraction.js +363 -0
- package/dist/core/ingestion/parsing-processor.d.ts +4 -1
- package/dist/core/ingestion/parsing-processor.js +107 -109
- package/dist/core/ingestion/pipeline.d.ts +6 -3
- package/dist/core/ingestion/pipeline.js +208 -114
- package/dist/core/ingestion/process-processor.js +8 -2
- package/dist/core/ingestion/resolution-context.d.ts +53 -0
- package/dist/core/ingestion/resolution-context.js +132 -0
- package/dist/core/ingestion/resolvers/csharp.d.ts +22 -0
- package/dist/core/ingestion/resolvers/csharp.js +109 -0
- package/dist/core/ingestion/resolvers/go.d.ts +19 -0
- package/dist/core/ingestion/resolvers/go.js +42 -0
- package/dist/core/ingestion/resolvers/index.d.ts +18 -0
- package/dist/core/ingestion/resolvers/index.js +13 -0
- package/dist/core/ingestion/resolvers/jvm.d.ts +23 -0
- package/dist/core/ingestion/resolvers/jvm.js +87 -0
- package/dist/core/ingestion/resolvers/php.d.ts +15 -0
- package/dist/core/ingestion/resolvers/php.js +35 -0
- package/dist/core/ingestion/resolvers/python.d.ts +19 -0
- package/dist/core/ingestion/resolvers/python.js +52 -0
- package/dist/core/ingestion/resolvers/ruby.d.ts +12 -0
- package/dist/core/ingestion/resolvers/ruby.js +15 -0
- package/dist/core/ingestion/resolvers/rust.d.ts +15 -0
- package/dist/core/ingestion/resolvers/rust.js +73 -0
- package/dist/core/ingestion/resolvers/standard.d.ts +28 -0
- package/dist/core/ingestion/resolvers/standard.js +123 -0
- package/dist/core/ingestion/resolvers/utils.d.ts +33 -0
- package/dist/core/ingestion/resolvers/utils.js +122 -0
- package/dist/core/ingestion/symbol-table.d.ts +21 -1
- package/dist/core/ingestion/symbol-table.js +40 -12
- package/dist/core/ingestion/tree-sitter-queries.d.ts +13 -10
- package/dist/core/ingestion/tree-sitter-queries.js +297 -7
- package/dist/core/ingestion/type-env.d.ts +49 -0
- package/dist/core/ingestion/type-env.js +611 -0
- package/dist/core/ingestion/type-extractors/c-cpp.d.ts +2 -0
- package/dist/core/ingestion/type-extractors/c-cpp.js +385 -0
- package/dist/core/ingestion/type-extractors/csharp.d.ts +2 -0
- package/dist/core/ingestion/type-extractors/csharp.js +383 -0
- package/dist/core/ingestion/type-extractors/go.d.ts +2 -0
- package/dist/core/ingestion/type-extractors/go.js +467 -0
- package/dist/core/ingestion/type-extractors/index.d.ts +22 -0
- package/dist/core/ingestion/type-extractors/index.js +31 -0
- package/dist/core/ingestion/type-extractors/jvm.d.ts +3 -0
- package/dist/core/ingestion/type-extractors/jvm.js +681 -0
- package/dist/core/ingestion/type-extractors/php.d.ts +2 -0
- package/dist/core/ingestion/type-extractors/php.js +549 -0
- package/dist/core/ingestion/type-extractors/python.d.ts +2 -0
- package/dist/core/ingestion/type-extractors/python.js +406 -0
- package/dist/core/ingestion/type-extractors/ruby.d.ts +2 -0
- package/dist/core/ingestion/type-extractors/ruby.js +389 -0
- package/dist/core/ingestion/type-extractors/rust.d.ts +2 -0
- package/dist/core/ingestion/type-extractors/rust.js +449 -0
- package/dist/core/ingestion/type-extractors/shared.d.ts +133 -0
- package/dist/core/ingestion/type-extractors/shared.js +703 -0
- package/dist/core/ingestion/type-extractors/swift.d.ts +2 -0
- package/dist/core/ingestion/type-extractors/swift.js +137 -0
- package/dist/core/ingestion/type-extractors/types.d.ts +127 -0
- package/dist/core/ingestion/type-extractors/typescript.d.ts +2 -0
- package/dist/core/ingestion/type-extractors/typescript.js +494 -0
- package/dist/core/ingestion/utils.d.ts +103 -0
- package/dist/core/ingestion/utils.js +1085 -4
- package/dist/core/ingestion/workers/parse-worker.d.ts +51 -4
- package/dist/core/ingestion/workers/parse-worker.js +634 -222
- package/dist/core/ingestion/workers/worker-pool.js +8 -0
- package/dist/core/{kuzu → lbug}/csv-generator.d.ts +12 -10
- package/dist/core/{kuzu → lbug}/csv-generator.js +82 -101
- package/dist/core/{kuzu/kuzu-adapter.d.ts → lbug/lbug-adapter.d.ts} +20 -25
- package/dist/core/{kuzu/kuzu-adapter.js → lbug/lbug-adapter.js} +150 -122
- package/dist/core/{kuzu → lbug}/schema.d.ts +4 -4
- package/dist/core/{kuzu → lbug}/schema.js +23 -22
- package/dist/core/lbug/schema.test.d.ts +1 -0
- package/dist/core/search/bm25-index.d.ts +4 -4
- package/dist/core/search/bm25-index.js +12 -11
- package/dist/core/search/hybrid-search.d.ts +2 -2
- package/dist/core/search/hybrid-search.js +6 -6
- package/dist/core/tree-sitter/parser-loader.d.ts +1 -0
- package/dist/core/tree-sitter/parser-loader.js +19 -0
- package/dist/core/wiki/generator.d.ts +2 -2
- package/dist/core/wiki/generator.js +6 -6
- package/dist/core/wiki/graph-queries.d.ts +4 -4
- package/dist/core/wiki/graph-queries.js +7 -7
- package/dist/mcp/compatible-stdio-transport.d.ts +25 -0
- package/dist/mcp/compatible-stdio-transport.js +200 -0
- package/dist/mcp/core/{kuzu-adapter.d.ts → lbug-adapter.d.ts} +11 -10
- package/dist/mcp/core/lbug-adapter.js +327 -0
- package/dist/mcp/local/local-backend.d.ts +21 -16
- package/dist/mcp/local/local-backend.js +306 -706
- package/dist/mcp/local/unity-parity-seed-loader.d.ts +6 -1
- package/dist/mcp/local/unity-parity-seed-loader.js +119 -9
- package/dist/mcp/local/unity-parity-seed-loader.test.js +95 -7
- package/dist/mcp/resources.js +2 -2
- package/dist/mcp/server.js +28 -13
- package/dist/mcp/staleness.js +2 -2
- package/dist/mcp/tools.js +12 -3
- package/dist/server/api.js +12 -12
- package/dist/server/mcp-http.d.ts +1 -1
- package/dist/server/mcp-http.js +1 -1
- package/dist/storage/git.js +4 -1
- package/dist/storage/repo-manager.d.ts +20 -2
- package/dist/storage/repo-manager.js +74 -4
- package/dist/types/pipeline.d.ts +1 -1
- package/hooks/claude/gitnexus-hook.cjs +149 -46
- package/hooks/claude/pre-tool-use.sh +2 -1
- package/hooks/claude/session-start.sh +0 -0
- package/package.json +20 -4
- package/scripts/patch-tree-sitter-swift.cjs +74 -0
- package/skills/gitnexus-cli.md +8 -8
- package/skills/gitnexus-debugging.md +1 -1
- package/skills/gitnexus-exploring.md +1 -1
- package/skills/gitnexus-guide.md +1 -1
- package/skills/gitnexus-impact-analysis.md +1 -1
- package/skills/gitnexus-pr-review.md +163 -0
- package/skills/gitnexus-refactoring.md +1 -1
- package/dist/cli/claude-hooks.d.ts +0 -22
- package/dist/cli/claude-hooks.js +0 -97
- package/dist/mcp/core/kuzu-adapter.js +0 -231
- /package/dist/core/{kuzu/csv-generator.test.d.ts → ingestion/type-extractors/types.js} +0 -0
- /package/dist/core/{kuzu/relationship-pair-buckets.test.d.ts → lbug/csv-generator.test.d.ts} +0 -0
- /package/dist/core/{kuzu → lbug}/csv-generator.test.js +0 -0
- /package/dist/core/{kuzu → lbug}/relationship-pair-buckets.d.ts +0 -0
- /package/dist/core/{kuzu → lbug}/relationship-pair-buckets.js +0 -0
- /package/dist/core/{kuzu/schema.test.d.ts → lbug/relationship-pair-buckets.test.d.ts} +0 -0
- /package/dist/core/{kuzu → lbug}/relationship-pair-buckets.test.js +0 -0
- /package/dist/core/{kuzu → lbug}/schema.test.js +0 -0
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
import fs from 'fs/promises';
|
|
2
|
+
import { createReadStream } from 'fs';
|
|
3
|
+
import { createInterface } from 'readline';
|
|
2
4
|
import path from 'path';
|
|
3
|
-
import
|
|
5
|
+
import lbug from '@ladybugdb/core';
|
|
4
6
|
import { NODE_TABLES, REL_TABLE_NAME, SCHEMA_QUERIES, EMBEDDING_TABLE_NAME, } from './schema.js';
|
|
5
7
|
import { streamAllCSVsToDisk } from './csv-generator.js';
|
|
6
|
-
import { streamRelationshipPairBucketsFromCsv } from './relationship-pair-buckets.js';
|
|
7
8
|
let db = null;
|
|
8
9
|
let conn = null;
|
|
9
10
|
let currentDbPath = null;
|
|
10
11
|
let ftsLoaded = false;
|
|
11
|
-
|
|
12
|
+
export const getOpenLbugDatabase = (dbPath) => {
|
|
13
|
+
if (currentDbPath !== dbPath || !db) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
return db;
|
|
17
|
+
};
|
|
18
|
+
// Global session lock for operations that touch module-level lbug globals.
|
|
12
19
|
// This guarantees no DB switch can happen while an operation is running.
|
|
13
20
|
let sessionLock = Promise.resolve();
|
|
14
21
|
const runWithSessionLock = async (operation) => {
|
|
@@ -26,27 +33,27 @@ const runWithSessionLock = async (operation) => {
|
|
|
26
33
|
}
|
|
27
34
|
};
|
|
28
35
|
const normalizeCopyPath = (filePath) => filePath.replace(/\\/g, '/');
|
|
29
|
-
export const
|
|
30
|
-
return runWithSessionLock(() =>
|
|
36
|
+
export const initLbug = async (dbPath) => {
|
|
37
|
+
return runWithSessionLock(() => ensureLbugInitialized(dbPath));
|
|
31
38
|
};
|
|
32
39
|
/**
|
|
33
40
|
* Execute multiple queries against one repo DB atomically.
|
|
34
41
|
* While the callback runs, no other request can switch the active DB.
|
|
35
42
|
*/
|
|
36
|
-
export const
|
|
43
|
+
export const withLbugDb = async (dbPath, operation) => {
|
|
37
44
|
return runWithSessionLock(async () => {
|
|
38
|
-
await
|
|
45
|
+
await ensureLbugInitialized(dbPath);
|
|
39
46
|
return operation();
|
|
40
47
|
});
|
|
41
48
|
};
|
|
42
|
-
const
|
|
49
|
+
const ensureLbugInitialized = async (dbPath) => {
|
|
43
50
|
if (conn && currentDbPath === dbPath) {
|
|
44
51
|
return { db, conn };
|
|
45
52
|
}
|
|
46
|
-
await
|
|
53
|
+
await doInitLbug(dbPath);
|
|
47
54
|
return { db, conn };
|
|
48
55
|
};
|
|
49
|
-
const
|
|
56
|
+
const doInitLbug = async (dbPath) => {
|
|
50
57
|
// Different database requested — close the old one first
|
|
51
58
|
if (conn || db) {
|
|
52
59
|
try {
|
|
@@ -64,32 +71,36 @@ const doInitKuzu = async (dbPath) => {
|
|
|
64
71
|
currentDbPath = null;
|
|
65
72
|
ftsLoaded = false;
|
|
66
73
|
}
|
|
67
|
-
//
|
|
68
|
-
// If the path already exists, it must be a valid
|
|
74
|
+
// LadybugDB stores the database as a single file (not a directory).
|
|
75
|
+
// If the path already exists, it must be a valid LadybugDB database file.
|
|
69
76
|
// Remove stale empty directories or files from older versions.
|
|
70
77
|
try {
|
|
71
|
-
const stat = await fs.
|
|
72
|
-
if (stat.
|
|
73
|
-
//
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
78
|
+
const stat = await fs.lstat(dbPath);
|
|
79
|
+
if (stat.isSymbolicLink()) {
|
|
80
|
+
// Never follow symlinks — just remove the link itself
|
|
81
|
+
await fs.unlink(dbPath);
|
|
82
|
+
}
|
|
83
|
+
else if (stat.isDirectory()) {
|
|
84
|
+
// Verify path is within expected storage directory before deleting
|
|
85
|
+
const realPath = await fs.realpath(dbPath);
|
|
86
|
+
const parentDir = path.dirname(dbPath);
|
|
87
|
+
const realParent = await fs.realpath(parentDir);
|
|
88
|
+
if (!realPath.startsWith(realParent + path.sep) && realPath !== realParent) {
|
|
89
|
+
throw new Error(`Refusing to delete ${dbPath}: resolved path ${realPath} is outside storage directory`);
|
|
81
90
|
}
|
|
91
|
+
// Old-style directory database or empty leftover - remove it
|
|
92
|
+
await fs.rm(dbPath, { recursive: true, force: true });
|
|
82
93
|
}
|
|
83
|
-
// If it's a file, assume it's an existing
|
|
94
|
+
// If it's a file, assume it's an existing LadybugDB database - LadybugDB will open it
|
|
84
95
|
}
|
|
85
96
|
catch {
|
|
86
|
-
// Path doesn't exist, which is what
|
|
97
|
+
// Path doesn't exist, which is what LadybugDB wants for a new database
|
|
87
98
|
}
|
|
88
99
|
// Ensure parent directory exists
|
|
89
100
|
const parentDir = path.dirname(dbPath);
|
|
90
101
|
await fs.mkdir(parentDir, { recursive: true });
|
|
91
|
-
db = new
|
|
92
|
-
conn = new
|
|
102
|
+
db = new lbug.Database(dbPath);
|
|
103
|
+
conn = new lbug.Connection(db);
|
|
93
104
|
for (const schemaQuery of SCHEMA_QUERIES) {
|
|
94
105
|
try {
|
|
95
106
|
await conn.query(schemaQuery);
|
|
@@ -105,9 +116,9 @@ const doInitKuzu = async (dbPath) => {
|
|
|
105
116
|
currentDbPath = dbPath;
|
|
106
117
|
return { db, conn };
|
|
107
118
|
};
|
|
108
|
-
export const
|
|
119
|
+
export const loadGraphToLbug = async (graph, repoPath, storagePath, onProgress) => {
|
|
109
120
|
if (!conn) {
|
|
110
|
-
throw new Error('
|
|
121
|
+
throw new Error('LadybugDB not initialized. Call initLbug first.');
|
|
111
122
|
}
|
|
112
123
|
const log = onProgress || (() => { });
|
|
113
124
|
const csvDir = path.join(storagePath, 'csv');
|
|
@@ -121,7 +132,7 @@ export const loadGraphToKuzu = async (graph, repoPath, storagePath, onProgress)
|
|
|
121
132
|
return 'Process';
|
|
122
133
|
return nodeId.split(':')[0];
|
|
123
134
|
};
|
|
124
|
-
// Bulk COPY all node CSVs (sequential —
|
|
135
|
+
// Bulk COPY all node CSVs (sequential — LadybugDB allows only one write txn at a time)
|
|
125
136
|
const nodeFiles = [...csvResult.nodeFiles.entries()];
|
|
126
137
|
const totalSteps = nodeFiles.length + 1; // +1 for relationships
|
|
127
138
|
let stepsDone = 0;
|
|
@@ -144,33 +155,61 @@ export const loadGraphToKuzu = async (graph, repoPath, storagePath, onProgress)
|
|
|
144
155
|
}
|
|
145
156
|
}
|
|
146
157
|
}
|
|
147
|
-
// Bulk COPY relationships — split by FROM→TO label pair (
|
|
148
|
-
// Stream relation CSV
|
|
149
|
-
|
|
150
|
-
const
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
158
|
+
// Bulk COPY relationships — split by FROM→TO label pair (LadybugDB requires it)
|
|
159
|
+
// Stream-read the relation CSV line by line to avoid exceeding V8 max string length
|
|
160
|
+
let relHeader = '';
|
|
161
|
+
const relsByPair = new Map();
|
|
162
|
+
let skippedRels = 0;
|
|
163
|
+
let totalValidRels = 0;
|
|
164
|
+
await new Promise((resolve, reject) => {
|
|
165
|
+
const rl = createInterface({ input: createReadStream(csvResult.relCsvPath, 'utf-8'), crlfDelay: Infinity });
|
|
166
|
+
let isFirst = true;
|
|
167
|
+
rl.on('line', (line) => {
|
|
168
|
+
if (isFirst) {
|
|
169
|
+
relHeader = line;
|
|
170
|
+
isFirst = false;
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
if (!line.trim())
|
|
174
|
+
return;
|
|
175
|
+
const match = line.match(/"([^"]*)","([^"]*)"/);
|
|
176
|
+
if (!match) {
|
|
177
|
+
skippedRels++;
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
const fromLabel = getNodeLabel(match[1]);
|
|
181
|
+
const toLabel = getNodeLabel(match[2]);
|
|
182
|
+
if (!validTables.has(fromLabel) || !validTables.has(toLabel)) {
|
|
183
|
+
skippedRels++;
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
const pairKey = `${fromLabel}|${toLabel}`;
|
|
187
|
+
let list = relsByPair.get(pairKey);
|
|
188
|
+
if (!list) {
|
|
189
|
+
list = [];
|
|
190
|
+
relsByPair.set(pairKey, list);
|
|
191
|
+
}
|
|
192
|
+
list.push(line);
|
|
193
|
+
totalValidRels++;
|
|
194
|
+
});
|
|
195
|
+
rl.on('close', resolve);
|
|
196
|
+
rl.on('error', reject);
|
|
155
197
|
});
|
|
156
|
-
const relHeader = pairBucketResult.relHeader;
|
|
157
|
-
const relsByPair = pairBucketResult.buckets;
|
|
158
|
-
const skippedRels = pairBucketResult.skippedRels;
|
|
159
|
-
const totalValidRels = pairBucketResult.totalValidRels;
|
|
160
198
|
const insertedRels = totalValidRels;
|
|
161
199
|
const warnings = [];
|
|
162
|
-
let fallbackStats = { attempted: 0, succeeded: 0, failed: 0 };
|
|
163
200
|
if (insertedRels > 0) {
|
|
164
201
|
log(`Loading edges: ${insertedRels.toLocaleString()} across ${relsByPair.size} types`);
|
|
165
202
|
let pairIdx = 0;
|
|
166
203
|
let failedPairEdges = 0;
|
|
167
|
-
const
|
|
168
|
-
for (const [pairKey,
|
|
204
|
+
const failedPairLines = [];
|
|
205
|
+
for (const [pairKey, lines] of relsByPair) {
|
|
169
206
|
pairIdx++;
|
|
170
207
|
const [fromLabel, toLabel] = pairKey.split('|');
|
|
171
|
-
const
|
|
208
|
+
const pairCsvPath = path.join(csvDir, `rel_${fromLabel}_${toLabel}.csv`);
|
|
209
|
+
await fs.writeFile(pairCsvPath, relHeader + '\n' + lines.join('\n'), 'utf-8');
|
|
210
|
+
const normalizedPath = normalizeCopyPath(pairCsvPath);
|
|
172
211
|
const copyQuery = `COPY ${REL_TABLE_NAME} FROM "${normalizedPath}" (from="${fromLabel}", to="${toLabel}", HEADER=true, ESCAPE='"', DELIM=',', QUOTE='"', PARALLEL=false, auto_detect=false)`;
|
|
173
|
-
if (pairIdx % 5 === 0 ||
|
|
212
|
+
if (pairIdx % 5 === 0 || lines.length > 1000) {
|
|
174
213
|
log(`Loading edges: ${pairIdx}/${relsByPair.size} types (${fromLabel} -> ${toLabel})`);
|
|
175
214
|
}
|
|
176
215
|
try {
|
|
@@ -183,31 +222,20 @@ export const loadGraphToKuzu = async (graph, repoPath, storagePath, onProgress)
|
|
|
183
222
|
}
|
|
184
223
|
catch (retryErr) {
|
|
185
224
|
const retryMsg = retryErr instanceof Error ? retryErr.message : String(retryErr);
|
|
186
|
-
warnings.push(`${fromLabel}->${toLabel} (${
|
|
187
|
-
failedPairEdges +=
|
|
188
|
-
|
|
225
|
+
warnings.push(`${fromLabel}->${toLabel} (${lines.length} edges): ${retryMsg.slice(0, 80)}`);
|
|
226
|
+
failedPairEdges += lines.length;
|
|
227
|
+
failedPairLines.push(...lines);
|
|
189
228
|
}
|
|
190
229
|
}
|
|
191
|
-
}
|
|
192
|
-
if (failedPairCsvPaths.length > 0) {
|
|
193
|
-
const failedPairLines = [relHeader];
|
|
194
|
-
for (const failedPairPath of failedPairCsvPaths) {
|
|
195
|
-
const raw = await fs.readFile(failedPairPath, 'utf-8');
|
|
196
|
-
const lines = raw
|
|
197
|
-
.split('\n')
|
|
198
|
-
.slice(1)
|
|
199
|
-
.filter(line => line.trim().length > 0);
|
|
200
|
-
failedPairLines.push(...lines);
|
|
201
|
-
}
|
|
202
|
-
log(`Inserting ${failedPairEdges} edges individually (missing schema pairs)`);
|
|
203
|
-
fallbackStats = await fallbackRelationshipInserts(failedPairLines, validTables, getNodeLabel);
|
|
204
|
-
}
|
|
205
|
-
for (const [, bucket] of relsByPair) {
|
|
206
230
|
try {
|
|
207
|
-
await fs.unlink(
|
|
231
|
+
await fs.unlink(pairCsvPath);
|
|
208
232
|
}
|
|
209
233
|
catch { }
|
|
210
234
|
}
|
|
235
|
+
if (failedPairLines.length > 0) {
|
|
236
|
+
log(`Inserting ${failedPairEdges} edges individually (missing schema pairs)`);
|
|
237
|
+
await fallbackRelationshipInserts([relHeader, ...failedPairLines], validTables, getNodeLabel);
|
|
238
|
+
}
|
|
211
239
|
}
|
|
212
240
|
// Cleanup all CSVs
|
|
213
241
|
try {
|
|
@@ -234,12 +262,12 @@ export const loadGraphToKuzu = async (graph, repoPath, storagePath, onProgress)
|
|
|
234
262
|
await fs.rmdir(csvDir);
|
|
235
263
|
}
|
|
236
264
|
catch { }
|
|
237
|
-
return { success: true, insertedRels, skippedRels, warnings
|
|
265
|
+
return { success: true, insertedRels, skippedRels, warnings };
|
|
238
266
|
};
|
|
239
|
-
//
|
|
267
|
+
// LadybugDB default ESCAPE is '\' (backslash), but our CSV uses RFC 4180 escaping ("" for literal quotes).
|
|
240
268
|
// Source code content is full of backslashes which confuse the auto-detection.
|
|
241
269
|
// We MUST explicitly set ESCAPE='"' to use RFC 4180 escaping, and disable auto_detect to prevent
|
|
242
|
-
//
|
|
270
|
+
// LadybugDB from overriding our settings based on sample rows.
|
|
243
271
|
const COPY_CSV_OPTS = `(HEADER=true, ESCAPE='"', DELIM=',', QUOTE='"', PARALLEL=false, auto_detect=false)`;
|
|
244
272
|
// Multi-language table names that were created with backticks in CODE_ELEMENT_BASE
|
|
245
273
|
// and must always be referenced with backticks in queries
|
|
@@ -253,44 +281,35 @@ const escapeTableName = (table) => {
|
|
|
253
281
|
};
|
|
254
282
|
/** Fallback: insert relationships one-by-one if COPY fails */
|
|
255
283
|
const fallbackRelationshipInserts = async (validRelLines, validTables, getNodeLabel) => {
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
return { attempted, succeeded: 0, failed: attempted };
|
|
259
|
-
}
|
|
284
|
+
if (!conn)
|
|
285
|
+
return;
|
|
260
286
|
const escapeLabel = (label) => {
|
|
261
287
|
return BACKTICK_TABLES.has(label) ? `\`${label}\`` : label;
|
|
262
288
|
};
|
|
263
|
-
let succeeded = 0;
|
|
264
|
-
let failed = 0;
|
|
265
289
|
for (let i = 1; i < validRelLines.length; i++) {
|
|
266
290
|
const line = validRelLines[i];
|
|
267
291
|
try {
|
|
268
292
|
const match = line.match(/"([^"]*)","([^"]*)","([^"]*)",([0-9.]+),"([^"]*)",([0-9-]+)/);
|
|
269
|
-
if (!match)
|
|
270
|
-
failed++;
|
|
293
|
+
if (!match)
|
|
271
294
|
continue;
|
|
272
|
-
}
|
|
273
295
|
const [, fromId, toId, relType, confidenceStr, reason, stepStr] = match;
|
|
274
296
|
const fromLabel = getNodeLabel(fromId);
|
|
275
297
|
const toLabel = getNodeLabel(toId);
|
|
276
|
-
if (!validTables.has(fromLabel) || !validTables.has(toLabel))
|
|
277
|
-
failed++;
|
|
298
|
+
if (!validTables.has(fromLabel) || !validTables.has(toLabel))
|
|
278
299
|
continue;
|
|
279
|
-
}
|
|
280
300
|
const confidence = parseFloat(confidenceStr) || 1.0;
|
|
281
301
|
const step = parseInt(stepStr) || 0;
|
|
302
|
+
const esc = (s) => s.replace(/'/g, "''").replace(/\\/g, '\\\\').replace(/\n/g, '\\n').replace(/\r/g, '\\r');
|
|
282
303
|
await conn.query(`
|
|
283
|
-
MATCH (a:${escapeLabel(fromLabel)} {id: '${fromId
|
|
284
|
-
(b:${escapeLabel(toLabel)} {id: '${toId
|
|
285
|
-
CREATE (a)-[:${REL_TABLE_NAME} {type: '${relType}', confidence: ${confidence}, reason: '${reason
|
|
304
|
+
MATCH (a:${escapeLabel(fromLabel)} {id: '${esc(fromId)}' }),
|
|
305
|
+
(b:${escapeLabel(toLabel)} {id: '${esc(toId)}' })
|
|
306
|
+
CREATE (a)-[:${REL_TABLE_NAME} {type: '${esc(relType)}', confidence: ${confidence}, reason: '${esc(reason)}', step: ${step}}]->(b)
|
|
286
307
|
`);
|
|
287
|
-
succeeded++;
|
|
288
308
|
}
|
|
289
309
|
catch {
|
|
290
|
-
|
|
310
|
+
// skip
|
|
291
311
|
}
|
|
292
312
|
}
|
|
293
|
-
return { attempted, succeeded, failed };
|
|
294
313
|
};
|
|
295
314
|
/** Tables with isExported column (TypeScript/JS-native types) */
|
|
296
315
|
const TABLES_WITH_EXPORTED = new Set(['Function', 'Class', 'Interface', 'Method', 'CodeElement']);
|
|
@@ -308,6 +327,9 @@ const getCopyQuery = (table, filePath) => {
|
|
|
308
327
|
if (table === 'Process') {
|
|
309
328
|
return `COPY ${t}(id, label, heuristicLabel, processType, stepCount, communities, entryPointId, terminalId) FROM "${filePath}" ${COPY_CSV_OPTS}`;
|
|
310
329
|
}
|
|
330
|
+
if (table === 'Method') {
|
|
331
|
+
return `COPY ${t}(id, name, filePath, startLine, endLine, isExported, content, description, parameterCount, returnType) FROM "${filePath}" ${COPY_CSV_OPTS}`;
|
|
332
|
+
}
|
|
311
333
|
// TypeScript/JS code element tables have isExported; multi-language tables do not
|
|
312
334
|
if (TABLES_WITH_EXPORTED.has(table)) {
|
|
313
335
|
return `COPY ${t}(id, name, filePath, startLine, endLine, isExported, content, description) FROM "${filePath}" ${COPY_CSV_OPTS}`;
|
|
@@ -316,16 +338,16 @@ const getCopyQuery = (table, filePath) => {
|
|
|
316
338
|
return `COPY ${t}(id, name, filePath, startLine, endLine, content, description) FROM "${filePath}" ${COPY_CSV_OPTS}`;
|
|
317
339
|
};
|
|
318
340
|
/**
|
|
319
|
-
* Insert a single node to
|
|
341
|
+
* Insert a single node to LadybugDB
|
|
320
342
|
* @param label - Node type (File, Function, Class, etc.)
|
|
321
343
|
* @param properties - Node properties
|
|
322
|
-
* @param dbPath - Path to
|
|
344
|
+
* @param dbPath - Path to LadybugDB database (optional if already initialized)
|
|
323
345
|
*/
|
|
324
|
-
export const
|
|
346
|
+
export const insertNodeToLbug = async (label, properties, dbPath) => {
|
|
325
347
|
// Use provided dbPath or fall back to module-level db
|
|
326
348
|
const targetDbPath = dbPath || (db ? undefined : null);
|
|
327
349
|
if (!targetDbPath && !db) {
|
|
328
|
-
throw new Error('
|
|
350
|
+
throw new Error('LadybugDB not initialized. Provide dbPath or call initLbug first.');
|
|
329
351
|
}
|
|
330
352
|
try {
|
|
331
353
|
const escapeValue = (v) => {
|
|
@@ -334,7 +356,7 @@ export const insertNodeToKuzu = async (label, properties, dbPath) => {
|
|
|
334
356
|
if (typeof v === 'number')
|
|
335
357
|
return String(v);
|
|
336
358
|
// Escape backslashes first (for Windows paths), then single quotes
|
|
337
|
-
return `'${String(v).replace(/\\/g, '\\\\').replace(/'/g, "''")}'`;
|
|
359
|
+
return `'${String(v).replace(/\\/g, '\\\\').replace(/'/g, "''").replace(/\n/g, '\\n').replace(/\r/g, '\\r')}'`;
|
|
338
360
|
};
|
|
339
361
|
// Build INSERT query based on node type
|
|
340
362
|
const t = escapeTableName(label);
|
|
@@ -356,8 +378,8 @@ export const insertNodeToKuzu = async (label, properties, dbPath) => {
|
|
|
356
378
|
}
|
|
357
379
|
// Use per-query connection if dbPath provided (avoids lock conflicts)
|
|
358
380
|
if (targetDbPath) {
|
|
359
|
-
const tempDb = new
|
|
360
|
-
const tempConn = new
|
|
381
|
+
const tempDb = new lbug.Database(targetDbPath);
|
|
382
|
+
const tempConn = new lbug.Connection(tempDb);
|
|
361
383
|
try {
|
|
362
384
|
await tempConn.query(query);
|
|
363
385
|
return true;
|
|
@@ -387,12 +409,12 @@ export const insertNodeToKuzu = async (label, properties, dbPath) => {
|
|
|
387
409
|
}
|
|
388
410
|
};
|
|
389
411
|
/**
|
|
390
|
-
* Batch insert multiple nodes to
|
|
412
|
+
* Batch insert multiple nodes to LadybugDB using a single connection
|
|
391
413
|
* @param nodes - Array of {label, properties} to insert
|
|
392
|
-
* @param dbPath - Path to
|
|
414
|
+
* @param dbPath - Path to LadybugDB database
|
|
393
415
|
* @returns Object with success count and error count
|
|
394
416
|
*/
|
|
395
|
-
export const
|
|
417
|
+
export const batchInsertNodesToLbug = async (nodes, dbPath) => {
|
|
396
418
|
if (nodes.length === 0)
|
|
397
419
|
return { inserted: 0, failed: 0 };
|
|
398
420
|
const escapeValue = (v) => {
|
|
@@ -400,12 +422,12 @@ export const batchInsertNodesToKuzu = async (nodes, dbPath) => {
|
|
|
400
422
|
return 'NULL';
|
|
401
423
|
if (typeof v === 'number')
|
|
402
424
|
return String(v);
|
|
403
|
-
// Escape backslashes first (for Windows paths), then single quotes
|
|
404
|
-
return `'${String(v).replace(/\\/g, '\\\\').replace(/'/g, "''")}'`;
|
|
425
|
+
// Escape backslashes first (for Windows paths), then single quotes, then newlines
|
|
426
|
+
return `'${String(v).replace(/\\/g, '\\\\').replace(/'/g, "''").replace(/\n/g, '\\n').replace(/\r/g, '\\r')}'`;
|
|
405
427
|
};
|
|
406
428
|
// Open a single connection for all inserts
|
|
407
|
-
const tempDb = new
|
|
408
|
-
const tempConn = new
|
|
429
|
+
const tempDb = new lbug.Database(dbPath);
|
|
430
|
+
const tempConn = new lbug.Connection(tempDb);
|
|
409
431
|
let inserted = 0;
|
|
410
432
|
let failed = 0;
|
|
411
433
|
try {
|
|
@@ -451,10 +473,10 @@ export const batchInsertNodesToKuzu = async (nodes, dbPath) => {
|
|
|
451
473
|
};
|
|
452
474
|
export const executeQuery = async (cypher) => {
|
|
453
475
|
if (!conn) {
|
|
454
|
-
throw new Error('
|
|
476
|
+
throw new Error('LadybugDB not initialized. Call initLbug first.');
|
|
455
477
|
}
|
|
456
478
|
const queryResult = await conn.query(cypher);
|
|
457
|
-
//
|
|
479
|
+
// LadybugDB uses getAll() instead of hasNext()/getNext()
|
|
458
480
|
// Query returns QueryResult for single queries, QueryResult[] for multi-statement
|
|
459
481
|
const result = Array.isArray(queryResult) ? queryResult[0] : queryResult;
|
|
460
482
|
const rows = await result.getAll();
|
|
@@ -462,7 +484,7 @@ export const executeQuery = async (cypher) => {
|
|
|
462
484
|
};
|
|
463
485
|
export const executeWithReusedStatement = async (cypher, paramsList) => {
|
|
464
486
|
if (!conn) {
|
|
465
|
-
throw new Error('
|
|
487
|
+
throw new Error('LadybugDB not initialized. Call initLbug first.');
|
|
466
488
|
}
|
|
467
489
|
if (paramsList.length === 0)
|
|
468
490
|
return;
|
|
@@ -483,10 +505,10 @@ export const executeWithReusedStatement = async (cypher, paramsList) => {
|
|
|
483
505
|
// Log the error and continue with next batch
|
|
484
506
|
console.warn('Batch execution error:', e);
|
|
485
507
|
}
|
|
486
|
-
// Note:
|
|
508
|
+
// Note: LadybugDB PreparedStatement doesn't require explicit close()
|
|
487
509
|
}
|
|
488
510
|
};
|
|
489
|
-
export const
|
|
511
|
+
export const getLbugStats = async () => {
|
|
490
512
|
if (!conn)
|
|
491
513
|
return { nodes: 0, edges: 0 };
|
|
492
514
|
let totalNodes = 0;
|
|
@@ -518,7 +540,7 @@ export const getKuzuStats = async () => {
|
|
|
518
540
|
return { nodes: totalNodes, edges: totalEdges };
|
|
519
541
|
};
|
|
520
542
|
/**
|
|
521
|
-
* Load cached embeddings from
|
|
543
|
+
* Load cached embeddings from LadybugDB before a rebuild.
|
|
522
544
|
* Returns all embedding vectors so they can be re-inserted after the graph is reloaded,
|
|
523
545
|
* avoiding expensive re-embedding of unchanged nodes.
|
|
524
546
|
*/
|
|
@@ -548,7 +570,7 @@ export const loadCachedEmbeddings = async () => {
|
|
|
548
570
|
catch { /* embedding table may not exist */ }
|
|
549
571
|
return { embeddingNodeIds, embeddings };
|
|
550
572
|
};
|
|
551
|
-
export const
|
|
573
|
+
export const closeLbug = async () => {
|
|
552
574
|
if (conn) {
|
|
553
575
|
try {
|
|
554
576
|
await conn.close();
|
|
@@ -566,11 +588,11 @@ export const closeKuzu = async () => {
|
|
|
566
588
|
currentDbPath = null;
|
|
567
589
|
ftsLoaded = false;
|
|
568
590
|
};
|
|
569
|
-
export const
|
|
591
|
+
export const isLbugReady = () => conn !== null && db !== null;
|
|
570
592
|
/**
|
|
571
|
-
* Delete all nodes (and their relationships) for a specific file from
|
|
593
|
+
* Delete all nodes (and their relationships) for a specific file from LadybugDB
|
|
572
594
|
* @param filePath - The file path to delete nodes for
|
|
573
|
-
* @param dbPath - Optional path to
|
|
595
|
+
* @param dbPath - Optional path to LadybugDB for per-query connection
|
|
574
596
|
* @returns Object with counts of deleted nodes
|
|
575
597
|
*/
|
|
576
598
|
export const deleteNodesForFile = async (filePath, dbPath) => {
|
|
@@ -580,12 +602,12 @@ export const deleteNodesForFile = async (filePath, dbPath) => {
|
|
|
580
602
|
let tempConn = null;
|
|
581
603
|
let targetConn = conn;
|
|
582
604
|
if (usePerQuery) {
|
|
583
|
-
tempDb = new
|
|
584
|
-
tempConn = new
|
|
605
|
+
tempDb = new lbug.Database(dbPath);
|
|
606
|
+
tempConn = new lbug.Connection(tempDb);
|
|
585
607
|
targetConn = tempConn;
|
|
586
608
|
}
|
|
587
609
|
else if (!conn) {
|
|
588
|
-
throw new Error('
|
|
610
|
+
throw new Error('LadybugDB not initialized. Provide dbPath or call initLbug first.');
|
|
589
611
|
}
|
|
590
612
|
try {
|
|
591
613
|
let deletedNodes = 0;
|
|
@@ -650,16 +672,22 @@ export const loadFTSExtension = async () => {
|
|
|
650
672
|
if (ftsLoaded)
|
|
651
673
|
return;
|
|
652
674
|
if (!conn) {
|
|
653
|
-
throw new Error('
|
|
675
|
+
throw new Error('LadybugDB not initialized. Call initLbug first.');
|
|
654
676
|
}
|
|
655
677
|
try {
|
|
656
678
|
await conn.query('INSTALL fts');
|
|
657
679
|
await conn.query('LOAD EXTENSION fts');
|
|
680
|
+
ftsLoaded = true;
|
|
658
681
|
}
|
|
659
|
-
catch {
|
|
660
|
-
|
|
682
|
+
catch (err) {
|
|
683
|
+
const msg = err?.message || '';
|
|
684
|
+
if (msg.includes('already loaded') || msg.includes('already installed') || msg.includes('already exists')) {
|
|
685
|
+
ftsLoaded = true;
|
|
686
|
+
}
|
|
687
|
+
else {
|
|
688
|
+
console.error('GitNexus: FTS extension load failed:', msg);
|
|
689
|
+
}
|
|
661
690
|
}
|
|
662
|
-
ftsLoaded = true;
|
|
663
691
|
};
|
|
664
692
|
/**
|
|
665
693
|
* Create a full-text search index on a table
|
|
@@ -670,7 +698,7 @@ export const loadFTSExtension = async () => {
|
|
|
670
698
|
*/
|
|
671
699
|
export const createFTSIndex = async (tableName, indexName, properties, stemmer = 'porter') => {
|
|
672
700
|
if (!conn) {
|
|
673
|
-
throw new Error('
|
|
701
|
+
throw new Error('LadybugDB not initialized. Call initLbug first.');
|
|
674
702
|
}
|
|
675
703
|
await loadFTSExtension();
|
|
676
704
|
const propList = properties.map(p => `'${p}'`).join(', ');
|
|
@@ -695,10 +723,10 @@ export const createFTSIndex = async (tableName, indexName, properties, stemmer =
|
|
|
695
723
|
*/
|
|
696
724
|
export const queryFTS = async (tableName, indexName, query, limit = 20, conjunctive = false) => {
|
|
697
725
|
if (!conn) {
|
|
698
|
-
throw new Error('
|
|
726
|
+
throw new Error('LadybugDB not initialized. Call initLbug first.');
|
|
699
727
|
}
|
|
700
|
-
// Escape single quotes
|
|
701
|
-
const escapedQuery = query.replace(/'/g, "''");
|
|
728
|
+
// Escape backslashes and single quotes to prevent Cypher injection
|
|
729
|
+
const escapedQuery = query.replace(/\\/g, '\\\\').replace(/'/g, "''");
|
|
702
730
|
const cypher = `
|
|
703
731
|
CALL QUERY_FTS_INDEX('${tableName}', '${indexName}', '${escapedQuery}', conjunctive := ${conjunctive})
|
|
704
732
|
RETURN node, score
|
|
@@ -734,7 +762,7 @@ export const queryFTS = async (tableName, indexName, query, limit = 20, conjunct
|
|
|
734
762
|
*/
|
|
735
763
|
export const dropFTSIndex = async (tableName, indexName) => {
|
|
736
764
|
if (!conn) {
|
|
737
|
-
throw new Error('
|
|
765
|
+
throw new Error('LadybugDB not initialized. Call initLbug first.');
|
|
738
766
|
}
|
|
739
767
|
try {
|
|
740
768
|
await conn.query(`CALL DROP_FTS_INDEX('${tableName}', '${indexName}')`);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* LadybugDB Schema Definitions
|
|
3
3
|
*
|
|
4
4
|
* Hybrid Schema:
|
|
5
5
|
* - Separate node tables for each code element type (File, Function, Class, etc.)
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
export declare const NODE_TABLES: readonly ["File", "Folder", "Function", "Class", "Interface", "Method", "CodeElement", "Community", "Process", "Struct", "Enum", "Macro", "Typedef", "Union", "Namespace", "Trait", "Impl", "TypeAlias", "Const", "Static", "Property", "Record", "Delegate", "Annotation", "Constructor", "Template", "Module"];
|
|
12
12
|
export type NodeTableName = typeof NODE_TABLES[number];
|
|
13
13
|
export declare const REL_TABLE_NAME = "CodeRelation";
|
|
14
|
-
export declare const REL_TYPES: readonly ["CONTAINS", "DEFINES", "IMPORTS", "CALLS", "EXTENDS", "IMPLEMENTS", "
|
|
14
|
+
export declare const REL_TYPES: readonly ["CONTAINS", "DEFINES", "IMPORTS", "CALLS", "EXTENDS", "IMPLEMENTS", "HAS_METHOD", "OVERRIDES", "MEMBER_OF", "STEP_IN_PROCESS"];
|
|
15
15
|
export type RelType = typeof REL_TYPES[number];
|
|
16
16
|
export declare const EMBEDDING_TABLE_NAME = "CodeEmbedding";
|
|
17
17
|
export declare const FILE_SCHEMA = "\nCREATE NODE TABLE File (\n id STRING,\n name STRING,\n filePath STRING,\n content STRING,\n PRIMARY KEY (id)\n)";
|
|
@@ -19,7 +19,7 @@ export declare const FOLDER_SCHEMA = "\nCREATE NODE TABLE Folder (\n id STRING,
|
|
|
19
19
|
export declare const FUNCTION_SCHEMA = "\nCREATE NODE TABLE Function (\n id STRING,\n name STRING,\n filePath STRING,\n startLine INT64,\n endLine INT64,\n isExported BOOLEAN,\n content STRING,\n description STRING,\n PRIMARY KEY (id)\n)";
|
|
20
20
|
export declare const CLASS_SCHEMA = "\nCREATE NODE TABLE Class (\n id STRING,\n name STRING,\n filePath STRING,\n startLine INT64,\n endLine INT64,\n isExported BOOLEAN,\n content STRING,\n description STRING,\n PRIMARY KEY (id)\n)";
|
|
21
21
|
export declare const INTERFACE_SCHEMA = "\nCREATE NODE TABLE Interface (\n id STRING,\n name STRING,\n filePath STRING,\n startLine INT64,\n endLine INT64,\n isExported BOOLEAN,\n content STRING,\n description STRING,\n PRIMARY KEY (id)\n)";
|
|
22
|
-
export declare const METHOD_SCHEMA = "\nCREATE NODE TABLE Method (\n id STRING,\n name STRING,\n filePath STRING,\n startLine INT64,\n endLine INT64,\n isExported BOOLEAN,\n content STRING,\n description STRING,\n PRIMARY KEY (id)\n)";
|
|
22
|
+
export declare const METHOD_SCHEMA = "\nCREATE NODE TABLE Method (\n id STRING,\n name STRING,\n filePath STRING,\n startLine INT64,\n endLine INT64,\n isExported BOOLEAN,\n content STRING,\n description STRING,\n parameterCount INT32,\n returnType STRING,\n PRIMARY KEY (id)\n)";
|
|
23
23
|
export declare const CODE_ELEMENT_SCHEMA = "\nCREATE NODE TABLE CodeElement (\n id STRING,\n name STRING,\n filePath STRING,\n startLine INT64,\n endLine INT64,\n isExported BOOLEAN,\n content STRING,\n description STRING,\n PRIMARY KEY (id)\n)";
|
|
24
24
|
export declare const COMMUNITY_SCHEMA = "\nCREATE NODE TABLE Community (\n id STRING,\n label STRING,\n heuristicLabel STRING,\n keywords STRING[],\n description STRING,\n enrichedBy STRING,\n cohesion DOUBLE,\n symbolCount INT32,\n PRIMARY KEY (id)\n)";
|
|
25
25
|
export declare const PROCESS_SCHEMA = "\nCREATE NODE TABLE Process (\n id STRING,\n label STRING,\n heuristicLabel STRING,\n processType STRING,\n stepCount INT32,\n communities STRING[],\n entryPointId STRING,\n terminalId STRING,\n PRIMARY KEY (id)\n)";
|
|
@@ -41,7 +41,7 @@ export declare const ANNOTATION_SCHEMA: string;
|
|
|
41
41
|
export declare const CONSTRUCTOR_SCHEMA: string;
|
|
42
42
|
export declare const TEMPLATE_SCHEMA: string;
|
|
43
43
|
export declare const MODULE_SCHEMA: string;
|
|
44
|
-
export declare const RELATION_SCHEMA = "\nCREATE REL TABLE CodeRelation (\n FROM File TO File,\n FROM File TO Folder,\n FROM File TO Function,\n FROM File TO Class,\n FROM File TO Interface,\n FROM File TO Method,\n FROM File TO CodeElement,\n FROM File TO `Struct`,\n FROM File TO `Enum`,\n FROM File TO `Macro`,\n FROM File TO `Typedef`,\n FROM File TO `Union`,\n FROM File TO `Namespace`,\n FROM File TO `Trait`,\n FROM File TO `Impl`,\n FROM File TO `TypeAlias`,\n FROM File TO `Const`,\n FROM File TO `Static`,\n FROM File TO `Property`,\n FROM File TO `Record`,\n FROM File TO `Delegate`,\n FROM File TO `Annotation`,\n FROM File TO `Constructor`,\n FROM File TO `Template`,\n FROM File TO `Module`,\n FROM Folder TO Folder,\n FROM Folder TO File,\n FROM Function TO Function,\n FROM Function TO Method,\n FROM Function TO Class,\n FROM Function TO Community,\n FROM Function TO `Macro`,\n FROM Function TO `Struct`,\n FROM Function TO `Template`,\n FROM Function TO `Enum`,\n FROM Function TO `Namespace`,\n FROM Function TO `TypeAlias`,\n FROM Function TO `Module`,\n FROM Function TO `Impl`,\n FROM Function TO Interface,\n FROM Function TO `Constructor`,\n FROM Function TO `
|
|
44
|
+
export declare const RELATION_SCHEMA = "\nCREATE REL TABLE CodeRelation (\n FROM File TO File,\n FROM File TO Folder,\n FROM File TO Function,\n FROM File TO Class,\n FROM File TO Interface,\n FROM File TO Method,\n FROM File TO CodeElement,\n FROM File TO `Struct`,\n FROM File TO `Enum`,\n FROM File TO `Macro`,\n FROM File TO `Typedef`,\n FROM File TO `Union`,\n FROM File TO `Namespace`,\n FROM File TO `Trait`,\n FROM File TO `Impl`,\n FROM File TO `TypeAlias`,\n FROM File TO `Const`,\n FROM File TO `Static`,\n FROM File TO `Property`,\n FROM File TO `Record`,\n FROM File TO `Delegate`,\n FROM File TO `Annotation`,\n FROM File TO `Constructor`,\n FROM File TO `Template`,\n FROM File TO `Module`,\n FROM Folder TO Folder,\n FROM Folder TO File,\n FROM Function TO Function,\n FROM Function TO Method,\n FROM Function TO Class,\n FROM Function TO Community,\n FROM Function TO `Macro`,\n FROM Function TO `Struct`,\n FROM Function TO `Template`,\n FROM Function TO `Enum`,\n FROM Function TO `Namespace`,\n FROM Function TO `TypeAlias`,\n FROM Function TO `Module`,\n FROM Function TO `Impl`,\n FROM Function TO Interface,\n FROM Function TO `Constructor`,\n FROM Function TO `Const`,\n FROM Function TO `Typedef`,\n FROM Function TO `Union`,\n FROM Function TO `Property`,\n FROM Class TO Method,\n FROM Class TO Function,\n FROM Class TO Class,\n FROM Class TO Interface,\n FROM Class TO Community,\n FROM Class TO `Template`,\n FROM Class TO `TypeAlias`,\n FROM Class TO `Struct`,\n FROM Class TO `Enum`,\n FROM Class TO `Annotation`,\n FROM Class TO `Constructor`,\n FROM Class TO `Trait`,\n FROM Class TO `Macro`,\n FROM Class TO `Impl`,\n FROM Class TO `Union`,\n FROM Class TO `Namespace`,\n FROM Class TO `Typedef`,\n FROM Class TO `Property`,\n FROM Method TO Function,\n FROM Method TO Method,\n FROM Method TO Class,\n FROM Method TO Community,\n FROM Method TO `Template`,\n FROM Method TO `Struct`,\n FROM Method TO `TypeAlias`,\n FROM Method TO `Enum`,\n FROM Method TO `Macro`,\n FROM Method TO `Namespace`,\n FROM Method TO `Module`,\n FROM Method TO `Impl`,\n FROM Method TO Interface,\n FROM Method TO `Constructor`,\n FROM Method TO `Property`,\n FROM `Template` TO `Template`,\n FROM `Template` TO Function,\n FROM `Template` TO Method,\n FROM `Template` TO Class,\n FROM `Template` TO `Struct`,\n FROM `Template` TO `TypeAlias`,\n FROM `Template` TO `Enum`,\n FROM `Template` TO `Macro`,\n FROM `Template` TO Interface,\n FROM `Template` TO `Constructor`,\n FROM `Module` TO `Module`,\n FROM CodeElement TO Community,\n FROM Interface TO Community,\n FROM Interface TO Function,\n FROM Interface TO Method,\n FROM Interface TO Class,\n FROM Interface TO Interface,\n FROM Interface TO `TypeAlias`,\n FROM Interface TO `Struct`,\n FROM Interface TO `Constructor`,\n FROM Interface TO `Property`,\n FROM `Struct` TO Community,\n FROM `Struct` TO `Trait`,\n FROM `Struct` TO `Struct`,\n FROM `Struct` TO Class,\n FROM `Struct` TO `Enum`,\n FROM `Struct` TO Function,\n FROM `Struct` TO Method,\n FROM `Struct` TO Interface,\n FROM `Struct` TO `Constructor`,\n FROM `Struct` TO `Property`,\n FROM `Enum` TO `Enum`,\n FROM `Enum` TO Community,\n FROM `Enum` TO Class,\n FROM `Enum` TO Interface,\n FROM `Macro` TO Community,\n FROM `Macro` TO Function,\n FROM `Macro` TO Method,\n FROM `Module` TO Function,\n FROM `Module` TO Method,\n FROM `Typedef` TO Community,\n FROM `Union` TO Community,\n FROM `Namespace` TO Community,\n FROM `Namespace` TO `Struct`,\n FROM `Trait` TO Method,\n FROM `Trait` TO `Constructor`,\n FROM `Trait` TO `Property`,\n FROM `Trait` TO Community,\n FROM `Impl` TO Method,\n FROM `Impl` TO `Constructor`,\n FROM `Impl` TO `Property`,\n FROM `Impl` TO Community,\n FROM `Impl` TO `Trait`,\n FROM `Impl` TO `Struct`,\n FROM `Impl` TO `Impl`,\n FROM `TypeAlias` TO Community,\n FROM `TypeAlias` TO `Trait`,\n FROM `TypeAlias` TO Class,\n FROM `Const` TO Community,\n FROM `Static` TO Community,\n FROM `Property` TO Community,\n FROM `Record` TO Method,\n FROM `Record` TO `Constructor`,\n FROM `Record` TO `Property`,\n FROM `Record` TO Community,\n FROM `Delegate` TO Community,\n FROM `Annotation` TO Community,\n FROM `Constructor` TO Community,\n FROM `Constructor` TO Interface,\n FROM `Constructor` TO Class,\n FROM `Constructor` TO Method,\n FROM `Constructor` TO Function,\n FROM `Constructor` TO `Constructor`,\n FROM `Constructor` TO `Struct`,\n FROM `Constructor` TO `Macro`,\n FROM `Constructor` TO `Template`,\n FROM `Constructor` TO `TypeAlias`,\n FROM `Constructor` TO `Enum`,\n FROM `Constructor` TO `Annotation`,\n FROM `Constructor` TO `Impl`,\n FROM `Constructor` TO `Namespace`,\n FROM `Constructor` TO `Module`,\n FROM `Constructor` TO `Property`,\n FROM `Constructor` TO `Typedef`,\n FROM `Template` TO Community,\n FROM `Module` TO Community,\n FROM Function TO Process,\n FROM Method TO Process,\n FROM Class TO Process,\n FROM Interface TO Process,\n FROM `Struct` TO Process,\n FROM `Constructor` TO Process,\n FROM `Module` TO Process,\n FROM `Macro` TO Process,\n FROM `Impl` TO Process,\n FROM `Typedef` TO Process,\n FROM `TypeAlias` TO Process,\n FROM `Enum` TO Process,\n FROM `Union` TO Process,\n FROM `Namespace` TO Process,\n FROM `Trait` TO Process,\n FROM `Const` TO Process,\n FROM `Static` TO Process,\n FROM `Property` TO Process,\n FROM `Record` TO Process,\n FROM `Delegate` TO Process,\n FROM `Annotation` TO Process,\n FROM `Template` TO Process,\n FROM CodeElement TO Process,\n type STRING,\n confidence DOUBLE,\n reason STRING,\n step INT32\n)";
|
|
45
45
|
export declare const EMBEDDING_SCHEMA = "\nCREATE NODE TABLE CodeEmbedding (\n nodeId STRING,\n embedding FLOAT[384],\n PRIMARY KEY (nodeId)\n)";
|
|
46
46
|
/**
|
|
47
47
|
* Create vector index for semantic search
|