gitnexus 1.4.1 → 1.4.6

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 (169) hide show
  1. package/README.md +215 -194
  2. package/dist/cli/ai-context.d.ts +2 -1
  3. package/dist/cli/ai-context.js +117 -90
  4. package/dist/cli/analyze.d.ts +2 -0
  5. package/dist/cli/analyze.js +57 -30
  6. package/dist/cli/augment.js +1 -1
  7. package/dist/cli/eval-server.d.ts +1 -1
  8. package/dist/cli/eval-server.js +14 -6
  9. package/dist/cli/index.js +18 -25
  10. package/dist/cli/lazy-action.d.ts +6 -0
  11. package/dist/cli/lazy-action.js +18 -0
  12. package/dist/cli/mcp.js +1 -1
  13. package/dist/cli/setup.js +42 -32
  14. package/dist/cli/skill-gen.d.ts +26 -0
  15. package/dist/cli/skill-gen.js +549 -0
  16. package/dist/cli/status.js +13 -4
  17. package/dist/cli/tool.d.ts +3 -2
  18. package/dist/cli/tool.js +48 -13
  19. package/dist/cli/wiki.js +2 -2
  20. package/dist/config/ignore-service.d.ts +25 -0
  21. package/dist/config/ignore-service.js +76 -0
  22. package/dist/config/supported-languages.d.ts +1 -0
  23. package/dist/config/supported-languages.js +1 -1
  24. package/dist/core/augmentation/engine.js +99 -72
  25. package/dist/core/embeddings/embedder.d.ts +1 -1
  26. package/dist/core/embeddings/embedder.js +1 -1
  27. package/dist/core/embeddings/embedding-pipeline.d.ts +3 -3
  28. package/dist/core/embeddings/embedding-pipeline.js +74 -47
  29. package/dist/core/embeddings/types.d.ts +1 -1
  30. package/dist/core/graph/types.d.ts +5 -2
  31. package/dist/core/ingestion/ast-cache.js +3 -2
  32. package/dist/core/ingestion/call-processor.d.ts +5 -7
  33. package/dist/core/ingestion/call-processor.js +430 -283
  34. package/dist/core/ingestion/call-routing.d.ts +53 -0
  35. package/dist/core/ingestion/call-routing.js +108 -0
  36. package/dist/core/ingestion/cluster-enricher.js +16 -16
  37. package/dist/core/ingestion/constants.d.ts +16 -0
  38. package/dist/core/ingestion/constants.js +16 -0
  39. package/dist/core/ingestion/entry-point-scoring.d.ts +2 -1
  40. package/dist/core/ingestion/entry-point-scoring.js +94 -24
  41. package/dist/core/ingestion/export-detection.d.ts +18 -0
  42. package/dist/core/ingestion/export-detection.js +231 -0
  43. package/dist/core/ingestion/filesystem-walker.js +4 -3
  44. package/dist/core/ingestion/framework-detection.d.ts +5 -1
  45. package/dist/core/ingestion/framework-detection.js +48 -8
  46. package/dist/core/ingestion/heritage-processor.d.ts +13 -5
  47. package/dist/core/ingestion/heritage-processor.js +109 -55
  48. package/dist/core/ingestion/import-processor.d.ts +16 -20
  49. package/dist/core/ingestion/import-processor.js +202 -696
  50. package/dist/core/ingestion/language-config.d.ts +46 -0
  51. package/dist/core/ingestion/language-config.js +167 -0
  52. package/dist/core/ingestion/mro-processor.d.ts +45 -0
  53. package/dist/core/ingestion/mro-processor.js +369 -0
  54. package/dist/core/ingestion/named-binding-extraction.d.ts +61 -0
  55. package/dist/core/ingestion/named-binding-extraction.js +363 -0
  56. package/dist/core/ingestion/parsing-processor.d.ts +3 -11
  57. package/dist/core/ingestion/parsing-processor.js +85 -181
  58. package/dist/core/ingestion/pipeline.d.ts +5 -1
  59. package/dist/core/ingestion/pipeline.js +192 -116
  60. package/dist/core/ingestion/process-processor.js +2 -1
  61. package/dist/core/ingestion/resolution-context.d.ts +53 -0
  62. package/dist/core/ingestion/resolution-context.js +132 -0
  63. package/dist/core/ingestion/resolvers/csharp.d.ts +22 -0
  64. package/dist/core/ingestion/resolvers/csharp.js +109 -0
  65. package/dist/core/ingestion/resolvers/go.d.ts +19 -0
  66. package/dist/core/ingestion/resolvers/go.js +42 -0
  67. package/dist/core/ingestion/resolvers/index.d.ts +18 -0
  68. package/dist/core/ingestion/resolvers/index.js +13 -0
  69. package/dist/core/ingestion/resolvers/jvm.d.ts +23 -0
  70. package/dist/core/ingestion/resolvers/jvm.js +87 -0
  71. package/dist/core/ingestion/resolvers/php.d.ts +15 -0
  72. package/dist/core/ingestion/resolvers/php.js +35 -0
  73. package/dist/core/ingestion/resolvers/python.d.ts +19 -0
  74. package/dist/core/ingestion/resolvers/python.js +52 -0
  75. package/dist/core/ingestion/resolvers/ruby.d.ts +12 -0
  76. package/dist/core/ingestion/resolvers/ruby.js +15 -0
  77. package/dist/core/ingestion/resolvers/rust.d.ts +15 -0
  78. package/dist/core/ingestion/resolvers/rust.js +73 -0
  79. package/dist/core/ingestion/resolvers/standard.d.ts +28 -0
  80. package/dist/core/ingestion/resolvers/standard.js +123 -0
  81. package/dist/core/ingestion/resolvers/utils.d.ts +33 -0
  82. package/dist/core/ingestion/resolvers/utils.js +122 -0
  83. package/dist/core/ingestion/symbol-table.d.ts +21 -1
  84. package/dist/core/ingestion/symbol-table.js +40 -12
  85. package/dist/core/ingestion/tree-sitter-queries.d.ts +12 -11
  86. package/dist/core/ingestion/tree-sitter-queries.js +642 -485
  87. package/dist/core/ingestion/type-env.d.ts +49 -0
  88. package/dist/core/ingestion/type-env.js +611 -0
  89. package/dist/core/ingestion/type-extractors/c-cpp.d.ts +2 -0
  90. package/dist/core/ingestion/type-extractors/c-cpp.js +385 -0
  91. package/dist/core/ingestion/type-extractors/csharp.d.ts +2 -0
  92. package/dist/core/ingestion/type-extractors/csharp.js +383 -0
  93. package/dist/core/ingestion/type-extractors/go.d.ts +2 -0
  94. package/dist/core/ingestion/type-extractors/go.js +467 -0
  95. package/dist/core/ingestion/type-extractors/index.d.ts +22 -0
  96. package/dist/core/ingestion/type-extractors/index.js +31 -0
  97. package/dist/core/ingestion/type-extractors/jvm.d.ts +3 -0
  98. package/dist/core/ingestion/type-extractors/jvm.js +681 -0
  99. package/dist/core/ingestion/type-extractors/php.d.ts +2 -0
  100. package/dist/core/ingestion/type-extractors/php.js +549 -0
  101. package/dist/core/ingestion/type-extractors/python.d.ts +2 -0
  102. package/dist/core/ingestion/type-extractors/python.js +406 -0
  103. package/dist/core/ingestion/type-extractors/ruby.d.ts +2 -0
  104. package/dist/core/ingestion/type-extractors/ruby.js +389 -0
  105. package/dist/core/ingestion/type-extractors/rust.d.ts +2 -0
  106. package/dist/core/ingestion/type-extractors/rust.js +449 -0
  107. package/dist/core/ingestion/type-extractors/shared.d.ts +133 -0
  108. package/dist/core/ingestion/type-extractors/shared.js +703 -0
  109. package/dist/core/ingestion/type-extractors/swift.d.ts +2 -0
  110. package/dist/core/ingestion/type-extractors/swift.js +137 -0
  111. package/dist/core/ingestion/type-extractors/types.d.ts +127 -0
  112. package/dist/core/ingestion/type-extractors/types.js +1 -0
  113. package/dist/core/ingestion/type-extractors/typescript.d.ts +2 -0
  114. package/dist/core/ingestion/type-extractors/typescript.js +494 -0
  115. package/dist/core/ingestion/utils.d.ts +98 -0
  116. package/dist/core/ingestion/utils.js +1064 -9
  117. package/dist/core/ingestion/workers/parse-worker.d.ts +38 -4
  118. package/dist/core/ingestion/workers/parse-worker.js +251 -359
  119. package/dist/core/ingestion/workers/worker-pool.js +8 -0
  120. package/dist/core/{kuzu → lbug}/csv-generator.d.ts +1 -1
  121. package/dist/core/{kuzu → lbug}/csv-generator.js +20 -4
  122. package/dist/core/{kuzu/kuzu-adapter.d.ts → lbug/lbug-adapter.d.ts} +19 -19
  123. package/dist/core/{kuzu/kuzu-adapter.js → lbug/lbug-adapter.js} +82 -82
  124. package/dist/core/{kuzu → lbug}/schema.d.ts +4 -4
  125. package/dist/core/{kuzu → lbug}/schema.js +304 -289
  126. package/dist/core/search/bm25-index.d.ts +4 -4
  127. package/dist/core/search/bm25-index.js +17 -16
  128. package/dist/core/search/hybrid-search.d.ts +2 -2
  129. package/dist/core/search/hybrid-search.js +9 -9
  130. package/dist/core/tree-sitter/parser-loader.js +9 -2
  131. package/dist/core/wiki/generator.d.ts +4 -52
  132. package/dist/core/wiki/generator.js +53 -552
  133. package/dist/core/wiki/graph-queries.d.ts +4 -46
  134. package/dist/core/wiki/graph-queries.js +103 -282
  135. package/dist/core/wiki/html-viewer.js +192 -192
  136. package/dist/core/wiki/llm-client.js +11 -73
  137. package/dist/core/wiki/prompts.d.ts +8 -52
  138. package/dist/core/wiki/prompts.js +86 -200
  139. package/dist/mcp/compatible-stdio-transport.d.ts +25 -0
  140. package/dist/mcp/compatible-stdio-transport.js +200 -0
  141. package/dist/mcp/core/{kuzu-adapter.d.ts → lbug-adapter.d.ts} +7 -9
  142. package/dist/mcp/core/{kuzu-adapter.js → lbug-adapter.js} +77 -79
  143. package/dist/mcp/local/local-backend.d.ts +7 -6
  144. package/dist/mcp/local/local-backend.js +176 -147
  145. package/dist/mcp/resources.js +42 -42
  146. package/dist/mcp/server.js +18 -19
  147. package/dist/mcp/tools.js +103 -104
  148. package/dist/server/api.js +12 -12
  149. package/dist/server/mcp-http.d.ts +1 -1
  150. package/dist/server/mcp-http.js +1 -1
  151. package/dist/storage/repo-manager.d.ts +20 -2
  152. package/dist/storage/repo-manager.js +55 -1
  153. package/dist/types/pipeline.d.ts +1 -1
  154. package/hooks/claude/gitnexus-hook.cjs +238 -155
  155. package/hooks/claude/pre-tool-use.sh +79 -79
  156. package/hooks/claude/session-start.sh +42 -42
  157. package/package.json +99 -96
  158. package/scripts/patch-tree-sitter-swift.cjs +74 -74
  159. package/skills/gitnexus-cli.md +82 -82
  160. package/skills/gitnexus-debugging.md +89 -89
  161. package/skills/gitnexus-exploring.md +78 -78
  162. package/skills/gitnexus-guide.md +64 -64
  163. package/skills/gitnexus-impact-analysis.md +97 -97
  164. package/skills/gitnexus-pr-review.md +163 -163
  165. package/skills/gitnexus-refactoring.md +121 -121
  166. package/vendor/leiden/index.cjs +355 -355
  167. package/vendor/leiden/utils.cjs +392 -392
  168. package/dist/core/wiki/diagrams.d.ts +0 -27
  169. package/dist/core/wiki/diagrams.js +0 -163
@@ -1,5 +1,7 @@
1
1
  import { Worker } from 'node:worker_threads';
2
2
  import os from 'node:os';
3
+ import fs from 'node:fs';
4
+ import { fileURLToPath } from 'node:url';
3
5
  /**
4
6
  * Max files to send to a worker in a single postMessage.
5
7
  * Keeps structured-clone memory bounded per sub-batch.
@@ -12,6 +14,12 @@ const SUB_BATCH_TIMEOUT_MS = 30_000;
12
14
  * Create a pool of worker threads.
13
15
  */
14
16
  export const createWorkerPool = (workerUrl, poolSize) => {
17
+ // Validate worker script exists before spawning to prevent uncaught
18
+ // MODULE_NOT_FOUND crashes in worker threads (e.g. when running from src/ via vitest)
19
+ const workerPath = fileURLToPath(workerUrl);
20
+ if (!fs.existsSync(workerPath)) {
21
+ throw new Error(`Worker script not found: ${workerPath}`);
22
+ }
15
23
  const size = poolSize ?? Math.min(8, Math.max(1, os.cpus().length - 1));
16
24
  const workers = [];
17
25
  for (let i = 0; i < size; i++) {
@@ -1,5 +1,5 @@
1
1
  /**
2
- * CSV Generator for KuzuDB Hybrid Schema
2
+ * CSV Generator for LadybugDB Hybrid Schema
3
3
  *
4
4
  * Streams CSV rows directly to disk files in a single pass over graph nodes.
5
5
  * File contents are lazy-read from disk per-node to avoid holding the entire
@@ -1,5 +1,5 @@
1
1
  /**
2
- * CSV Generator for KuzuDB Hybrid Schema
2
+ * CSV Generator for LadybugDB Hybrid Schema
3
3
  *
4
4
  * Streams CSV rows directly to disk files in a single pass over graph nodes.
5
5
  * File contents are lazy-read from disk per-node to avoid holding the entire
@@ -203,7 +203,8 @@ export const streamAllCSVsToDisk = async (graph, repoPath, csvDir) => {
203
203
  const functionWriter = new BufferedCSVWriter(path.join(csvDir, 'function.csv'), codeElementHeader);
204
204
  const classWriter = new BufferedCSVWriter(path.join(csvDir, 'class.csv'), codeElementHeader);
205
205
  const interfaceWriter = new BufferedCSVWriter(path.join(csvDir, 'interface.csv'), codeElementHeader);
206
- const methodWriter = new BufferedCSVWriter(path.join(csvDir, 'method.csv'), codeElementHeader);
206
+ const methodHeader = 'id,name,filePath,startLine,endLine,isExported,content,description,parameterCount,returnType';
207
+ const methodWriter = new BufferedCSVWriter(path.join(csvDir, 'method.csv'), methodHeader);
207
208
  const codeElemWriter = new BufferedCSVWriter(path.join(csvDir, 'codeelement.csv'), codeElementHeader);
208
209
  const communityWriter = new BufferedCSVWriter(path.join(csvDir, 'community.csv'), 'id,label,heuristicLabel,keywords,description,enrichedBy,cohesion,symbolCount');
209
210
  const processWriter = new BufferedCSVWriter(path.join(csvDir, 'process.csv'), 'id,label,heuristicLabel,processType,stepCount,communities,entryPointId,terminalId');
@@ -219,7 +220,6 @@ export const streamAllCSVsToDisk = async (graph, repoPath, csvDir) => {
219
220
  'Function': functionWriter,
220
221
  'Class': classWriter,
221
222
  'Interface': interfaceWriter,
222
- 'Method': methodWriter,
223
223
  'CodeElement': codeElemWriter,
224
224
  };
225
225
  const seenFileIds = new Set();
@@ -276,8 +276,24 @@ export const streamAllCSVsToDisk = async (graph, repoPath, csvDir) => {
276
276
  ].join(','));
277
277
  break;
278
278
  }
279
+ case 'Method': {
280
+ const content = await extractContent(node, contentCache);
281
+ await methodWriter.addRow([
282
+ escapeCSVField(node.id),
283
+ escapeCSVField(node.properties.name || ''),
284
+ escapeCSVField(node.properties.filePath || ''),
285
+ escapeCSVNumber(node.properties.startLine, -1),
286
+ escapeCSVNumber(node.properties.endLine, -1),
287
+ node.properties.isExported ? 'true' : 'false',
288
+ escapeCSVField(content),
289
+ escapeCSVField(node.properties.description || ''),
290
+ escapeCSVNumber(node.properties.parameterCount, 0),
291
+ escapeCSVField(node.properties.returnType || ''),
292
+ ].join(','));
293
+ break;
294
+ }
279
295
  default: {
280
- // Code element nodes (Function, Class, Interface, Method, CodeElement)
296
+ // Code element nodes (Function, Class, Interface, CodeElement)
281
297
  const writer = codeWriterMap[node.label];
282
298
  if (writer) {
283
299
  const content = await extractContent(node, contentCache);
@@ -1,35 +1,35 @@
1
- import kuzu from 'kuzu';
1
+ import lbug from '@ladybugdb/core';
2
2
  import { KnowledgeGraph } from '../graph/types.js';
3
- export declare const initKuzu: (dbPath: string) => Promise<{
4
- db: kuzu.Database;
5
- conn: kuzu.Connection;
3
+ export declare const initLbug: (dbPath: string) => Promise<{
4
+ db: lbug.Database;
5
+ conn: lbug.Connection;
6
6
  }>;
7
7
  /**
8
8
  * Execute multiple queries against one repo DB atomically.
9
9
  * While the callback runs, no other request can switch the active DB.
10
10
  */
11
- export declare const withKuzuDb: <T>(dbPath: string, operation: () => Promise<T>) => Promise<T>;
12
- export type KuzuProgressCallback = (message: string) => void;
13
- export declare const loadGraphToKuzu: (graph: KnowledgeGraph, repoPath: string, storagePath: string, onProgress?: KuzuProgressCallback) => Promise<{
11
+ export declare const withLbugDb: <T>(dbPath: string, operation: () => Promise<T>) => Promise<T>;
12
+ export type LbugProgressCallback = (message: string) => void;
13
+ export declare const loadGraphToLbug: (graph: KnowledgeGraph, repoPath: string, storagePath: string, onProgress?: LbugProgressCallback) => Promise<{
14
14
  success: boolean;
15
15
  insertedRels: number;
16
16
  skippedRels: number;
17
17
  warnings: string[];
18
18
  }>;
19
19
  /**
20
- * Insert a single node to KuzuDB
20
+ * Insert a single node to LadybugDB
21
21
  * @param label - Node type (File, Function, Class, etc.)
22
22
  * @param properties - Node properties
23
- * @param dbPath - Path to KuzuDB database (optional if already initialized)
23
+ * @param dbPath - Path to LadybugDB database (optional if already initialized)
24
24
  */
25
- export declare const insertNodeToKuzu: (label: string, properties: Record<string, any>, dbPath?: string) => Promise<boolean>;
25
+ export declare const insertNodeToLbug: (label: string, properties: Record<string, any>, dbPath?: string) => Promise<boolean>;
26
26
  /**
27
- * Batch insert multiple nodes to KuzuDB using a single connection
27
+ * Batch insert multiple nodes to LadybugDB using a single connection
28
28
  * @param nodes - Array of {label, properties} to insert
29
- * @param dbPath - Path to KuzuDB database
29
+ * @param dbPath - Path to LadybugDB database
30
30
  * @returns Object with success count and error count
31
31
  */
32
- export declare const batchInsertNodesToKuzu: (nodes: Array<{
32
+ export declare const batchInsertNodesToLbug: (nodes: Array<{
33
33
  label: string;
34
34
  properties: Record<string, any>;
35
35
  }>, dbPath: string) => Promise<{
@@ -38,12 +38,12 @@ export declare const batchInsertNodesToKuzu: (nodes: Array<{
38
38
  }>;
39
39
  export declare const executeQuery: (cypher: string) => Promise<any[]>;
40
40
  export declare const executeWithReusedStatement: (cypher: string, paramsList: Array<Record<string, any>>) => Promise<void>;
41
- export declare const getKuzuStats: () => Promise<{
41
+ export declare const getLbugStats: () => Promise<{
42
42
  nodes: number;
43
43
  edges: number;
44
44
  }>;
45
45
  /**
46
- * Load cached embeddings from KuzuDB before a rebuild.
46
+ * Load cached embeddings from LadybugDB before a rebuild.
47
47
  * Returns all embedding vectors so they can be re-inserted after the graph is reloaded,
48
48
  * avoiding expensive re-embedding of unchanged nodes.
49
49
  */
@@ -54,12 +54,12 @@ export declare const loadCachedEmbeddings: () => Promise<{
54
54
  embedding: number[];
55
55
  }>;
56
56
  }>;
57
- export declare const closeKuzu: () => Promise<void>;
58
- export declare const isKuzuReady: () => boolean;
57
+ export declare const closeLbug: () => Promise<void>;
58
+ export declare const isLbugReady: () => boolean;
59
59
  /**
60
- * Delete all nodes (and their relationships) for a specific file from KuzuDB
60
+ * Delete all nodes (and their relationships) for a specific file from LadybugDB
61
61
  * @param filePath - The file path to delete nodes for
62
- * @param dbPath - Optional path to KuzuDB for per-query connection
62
+ * @param dbPath - Optional path to LadybugDB for per-query connection
63
63
  * @returns Object with counts of deleted nodes
64
64
  */
65
65
  export declare const deleteNodesForFile: (filePath: string, dbPath?: string) => Promise<{
@@ -2,14 +2,14 @@ import fs from 'fs/promises';
2
2
  import { createReadStream } from 'fs';
3
3
  import { createInterface } from 'readline';
4
4
  import path from 'path';
5
- import kuzu from 'kuzu';
5
+ import lbug from '@ladybugdb/core';
6
6
  import { NODE_TABLES, REL_TABLE_NAME, SCHEMA_QUERIES, EMBEDDING_TABLE_NAME, } from './schema.js';
7
7
  import { streamAllCSVsToDisk } from './csv-generator.js';
8
8
  let db = null;
9
9
  let conn = null;
10
10
  let currentDbPath = null;
11
11
  let ftsLoaded = false;
12
- // Global session lock for operations that touch module-level kuzu globals.
12
+ // Global session lock for operations that touch module-level lbug globals.
13
13
  // This guarantees no DB switch can happen while an operation is running.
14
14
  let sessionLock = Promise.resolve();
15
15
  const runWithSessionLock = async (operation) => {
@@ -27,27 +27,27 @@ const runWithSessionLock = async (operation) => {
27
27
  }
28
28
  };
29
29
  const normalizeCopyPath = (filePath) => filePath.replace(/\\/g, '/');
30
- export const initKuzu = async (dbPath) => {
31
- return runWithSessionLock(() => ensureKuzuInitialized(dbPath));
30
+ export const initLbug = async (dbPath) => {
31
+ return runWithSessionLock(() => ensureLbugInitialized(dbPath));
32
32
  };
33
33
  /**
34
34
  * Execute multiple queries against one repo DB atomically.
35
35
  * While the callback runs, no other request can switch the active DB.
36
36
  */
37
- export const withKuzuDb = async (dbPath, operation) => {
37
+ export const withLbugDb = async (dbPath, operation) => {
38
38
  return runWithSessionLock(async () => {
39
- await ensureKuzuInitialized(dbPath);
39
+ await ensureLbugInitialized(dbPath);
40
40
  return operation();
41
41
  });
42
42
  };
43
- const ensureKuzuInitialized = async (dbPath) => {
43
+ const ensureLbugInitialized = async (dbPath) => {
44
44
  if (conn && currentDbPath === dbPath) {
45
45
  return { db, conn };
46
46
  }
47
- await doInitKuzu(dbPath);
47
+ await doInitLbug(dbPath);
48
48
  return { db, conn };
49
49
  };
50
- const doInitKuzu = async (dbPath) => {
50
+ const doInitLbug = async (dbPath) => {
51
51
  // Different database requested — close the old one first
52
52
  if (conn || db) {
53
53
  try {
@@ -65,32 +65,36 @@ const doInitKuzu = async (dbPath) => {
65
65
  currentDbPath = null;
66
66
  ftsLoaded = false;
67
67
  }
68
- // kuzu v0.11 stores the database as a single file (not a directory).
69
- // If the path already exists, it must be a valid kuzu database file.
68
+ // LadybugDB stores the database as a single file (not a directory).
69
+ // If the path already exists, it must be a valid LadybugDB database file.
70
70
  // Remove stale empty directories or files from older versions.
71
71
  try {
72
- const stat = await fs.stat(dbPath);
73
- if (stat.isDirectory()) {
74
- // Old-style directory database or empty leftover - remove it
75
- const files = await fs.readdir(dbPath);
76
- if (files.length === 0) {
77
- await fs.rmdir(dbPath);
78
- }
79
- else {
80
- // Non-empty directory from older kuzu version - remove entire directory
81
- await fs.rm(dbPath, { recursive: true, force: true });
72
+ const stat = await fs.lstat(dbPath);
73
+ if (stat.isSymbolicLink()) {
74
+ // Never follow symlinks just remove the link itself
75
+ await fs.unlink(dbPath);
76
+ }
77
+ else if (stat.isDirectory()) {
78
+ // Verify path is within expected storage directory before deleting
79
+ const realPath = await fs.realpath(dbPath);
80
+ const parentDir = path.dirname(dbPath);
81
+ const realParent = await fs.realpath(parentDir);
82
+ if (!realPath.startsWith(realParent + path.sep) && realPath !== realParent) {
83
+ throw new Error(`Refusing to delete ${dbPath}: resolved path ${realPath} is outside storage directory`);
82
84
  }
85
+ // Old-style directory database or empty leftover - remove it
86
+ await fs.rm(dbPath, { recursive: true, force: true });
83
87
  }
84
- // If it's a file, assume it's an existing kuzu database - kuzu will open it
88
+ // If it's a file, assume it's an existing LadybugDB database - LadybugDB will open it
85
89
  }
86
90
  catch {
87
- // Path doesn't exist, which is what kuzu wants for a new database
91
+ // Path doesn't exist, which is what LadybugDB wants for a new database
88
92
  }
89
93
  // Ensure parent directory exists
90
94
  const parentDir = path.dirname(dbPath);
91
95
  await fs.mkdir(parentDir, { recursive: true });
92
- db = new kuzu.Database(dbPath);
93
- conn = new kuzu.Connection(db);
96
+ db = new lbug.Database(dbPath);
97
+ conn = new lbug.Connection(db);
94
98
  for (const schemaQuery of SCHEMA_QUERIES) {
95
99
  try {
96
100
  await conn.query(schemaQuery);
@@ -104,17 +108,11 @@ const doInitKuzu = async (dbPath) => {
104
108
  }
105
109
  }
106
110
  currentDbPath = dbPath;
107
- // Pre-load FTS extension so QUERY_FTS_INDEX works immediately
108
- // (without this, queryFTS and raw cypher queries using FTS would fail)
109
- try {
110
- await loadFTSExtension();
111
- }
112
- catch { /* non-fatal */ }
113
111
  return { db, conn };
114
112
  };
115
- export const loadGraphToKuzu = async (graph, repoPath, storagePath, onProgress) => {
113
+ export const loadGraphToLbug = async (graph, repoPath, storagePath, onProgress) => {
116
114
  if (!conn) {
117
- throw new Error('KuzuDB not initialized. Call initKuzu first.');
115
+ throw new Error('LadybugDB not initialized. Call initLbug first.');
118
116
  }
119
117
  const log = onProgress || (() => { });
120
118
  const csvDir = path.join(storagePath, 'csv');
@@ -128,7 +126,7 @@ export const loadGraphToKuzu = async (graph, repoPath, storagePath, onProgress)
128
126
  return 'Process';
129
127
  return nodeId.split(':')[0];
130
128
  };
131
- // Bulk COPY all node CSVs (sequential — KuzuDB allows only one write txn at a time)
129
+ // Bulk COPY all node CSVs (sequential — LadybugDB allows only one write txn at a time)
132
130
  const nodeFiles = [...csvResult.nodeFiles.entries()];
133
131
  const totalSteps = nodeFiles.length + 1; // +1 for relationships
134
132
  let stepsDone = 0;
@@ -151,7 +149,7 @@ export const loadGraphToKuzu = async (graph, repoPath, storagePath, onProgress)
151
149
  }
152
150
  }
153
151
  }
154
- // Bulk COPY relationships — split by FROM→TO label pair (KuzuDB requires it)
152
+ // Bulk COPY relationships — split by FROM→TO label pair (LadybugDB requires it)
155
153
  // Stream-read the relation CSV line by line to avoid exceeding V8 max string length
156
154
  let relHeader = '';
157
155
  const relsByPair = new Map();
@@ -260,10 +258,10 @@ export const loadGraphToKuzu = async (graph, repoPath, storagePath, onProgress)
260
258
  catch { }
261
259
  return { success: true, insertedRels, skippedRels, warnings };
262
260
  };
263
- // KuzuDB default ESCAPE is '\' (backslash), but our CSV uses RFC 4180 escaping ("" for literal quotes).
261
+ // LadybugDB default ESCAPE is '\' (backslash), but our CSV uses RFC 4180 escaping ("" for literal quotes).
264
262
  // Source code content is full of backslashes which confuse the auto-detection.
265
263
  // We MUST explicitly set ESCAPE='"' to use RFC 4180 escaping, and disable auto_detect to prevent
266
- // KuzuDB from overriding our settings based on sample rows.
264
+ // LadybugDB from overriding our settings based on sample rows.
267
265
  const COPY_CSV_OPTS = `(HEADER=true, ESCAPE='"', DELIM=',', QUOTE='"', PARALLEL=false, auto_detect=false)`;
268
266
  // Multi-language table names that were created with backticks in CODE_ELEMENT_BASE
269
267
  // and must always be referenced with backticks in queries
@@ -295,10 +293,11 @@ const fallbackRelationshipInserts = async (validRelLines, validTables, getNodeLa
295
293
  continue;
296
294
  const confidence = parseFloat(confidenceStr) || 1.0;
297
295
  const step = parseInt(stepStr) || 0;
298
- await conn.query(`
299
- MATCH (a:${escapeLabel(fromLabel)} {id: '${fromId.replace(/'/g, "''")}' }),
300
- (b:${escapeLabel(toLabel)} {id: '${toId.replace(/'/g, "''")}' })
301
- CREATE (a)-[:${REL_TABLE_NAME} {type: '${relType}', confidence: ${confidence}, reason: '${reason.replace(/'/g, "''")}', step: ${step}}]->(b)
296
+ const esc = (s) => s.replace(/'/g, "''").replace(/\\/g, '\\\\').replace(/\n/g, '\\n').replace(/\r/g, '\\r');
297
+ await conn.query(`
298
+ MATCH (a:${escapeLabel(fromLabel)} {id: '${esc(fromId)}' }),
299
+ (b:${escapeLabel(toLabel)} {id: '${esc(toId)}' })
300
+ CREATE (a)-[:${REL_TABLE_NAME} {type: '${esc(relType)}', confidence: ${confidence}, reason: '${esc(reason)}', step: ${step}}]->(b)
302
301
  `);
303
302
  }
304
303
  catch {
@@ -322,6 +321,9 @@ const getCopyQuery = (table, filePath) => {
322
321
  if (table === 'Process') {
323
322
  return `COPY ${t}(id, label, heuristicLabel, processType, stepCount, communities, entryPointId, terminalId) FROM "${filePath}" ${COPY_CSV_OPTS}`;
324
323
  }
324
+ if (table === 'Method') {
325
+ return `COPY ${t}(id, name, filePath, startLine, endLine, isExported, content, description, parameterCount, returnType) FROM "${filePath}" ${COPY_CSV_OPTS}`;
326
+ }
325
327
  // TypeScript/JS code element tables have isExported; multi-language tables do not
326
328
  if (TABLES_WITH_EXPORTED.has(table)) {
327
329
  return `COPY ${t}(id, name, filePath, startLine, endLine, isExported, content, description) FROM "${filePath}" ${COPY_CSV_OPTS}`;
@@ -330,16 +332,16 @@ const getCopyQuery = (table, filePath) => {
330
332
  return `COPY ${t}(id, name, filePath, startLine, endLine, content, description) FROM "${filePath}" ${COPY_CSV_OPTS}`;
331
333
  };
332
334
  /**
333
- * Insert a single node to KuzuDB
335
+ * Insert a single node to LadybugDB
334
336
  * @param label - Node type (File, Function, Class, etc.)
335
337
  * @param properties - Node properties
336
- * @param dbPath - Path to KuzuDB database (optional if already initialized)
338
+ * @param dbPath - Path to LadybugDB database (optional if already initialized)
337
339
  */
338
- export const insertNodeToKuzu = async (label, properties, dbPath) => {
340
+ export const insertNodeToLbug = async (label, properties, dbPath) => {
339
341
  // Use provided dbPath or fall back to module-level db
340
342
  const targetDbPath = dbPath || (db ? undefined : null);
341
343
  if (!targetDbPath && !db) {
342
- throw new Error('KuzuDB not initialized. Provide dbPath or call initKuzu first.');
344
+ throw new Error('LadybugDB not initialized. Provide dbPath or call initLbug first.');
343
345
  }
344
346
  try {
345
347
  const escapeValue = (v) => {
@@ -348,7 +350,7 @@ export const insertNodeToKuzu = async (label, properties, dbPath) => {
348
350
  if (typeof v === 'number')
349
351
  return String(v);
350
352
  // Escape backslashes first (for Windows paths), then single quotes
351
- return `'${String(v).replace(/\\/g, '\\\\').replace(/'/g, "''")}'`;
353
+ return `'${String(v).replace(/\\/g, '\\\\').replace(/'/g, "''").replace(/\n/g, '\\n').replace(/\r/g, '\\r')}'`;
352
354
  };
353
355
  // Build INSERT query based on node type
354
356
  const t = escapeTableName(label);
@@ -370,8 +372,8 @@ export const insertNodeToKuzu = async (label, properties, dbPath) => {
370
372
  }
371
373
  // Use per-query connection if dbPath provided (avoids lock conflicts)
372
374
  if (targetDbPath) {
373
- const tempDb = new kuzu.Database(targetDbPath);
374
- const tempConn = new kuzu.Connection(tempDb);
375
+ const tempDb = new lbug.Database(targetDbPath);
376
+ const tempConn = new lbug.Connection(tempDb);
375
377
  try {
376
378
  await tempConn.query(query);
377
379
  return true;
@@ -401,12 +403,12 @@ export const insertNodeToKuzu = async (label, properties, dbPath) => {
401
403
  }
402
404
  };
403
405
  /**
404
- * Batch insert multiple nodes to KuzuDB using a single connection
406
+ * Batch insert multiple nodes to LadybugDB using a single connection
405
407
  * @param nodes - Array of {label, properties} to insert
406
- * @param dbPath - Path to KuzuDB database
408
+ * @param dbPath - Path to LadybugDB database
407
409
  * @returns Object with success count and error count
408
410
  */
409
- export const batchInsertNodesToKuzu = async (nodes, dbPath) => {
411
+ export const batchInsertNodesToLbug = async (nodes, dbPath) => {
410
412
  if (nodes.length === 0)
411
413
  return { inserted: 0, failed: 0 };
412
414
  const escapeValue = (v) => {
@@ -414,12 +416,12 @@ export const batchInsertNodesToKuzu = async (nodes, dbPath) => {
414
416
  return 'NULL';
415
417
  if (typeof v === 'number')
416
418
  return String(v);
417
- // Escape backslashes first (for Windows paths), then single quotes
418
- return `'${String(v).replace(/\\/g, '\\\\').replace(/'/g, "''")}'`;
419
+ // Escape backslashes first (for Windows paths), then single quotes, then newlines
420
+ return `'${String(v).replace(/\\/g, '\\\\').replace(/'/g, "''").replace(/\n/g, '\\n').replace(/\r/g, '\\r')}'`;
419
421
  };
420
422
  // Open a single connection for all inserts
421
- const tempDb = new kuzu.Database(dbPath);
422
- const tempConn = new kuzu.Connection(tempDb);
423
+ const tempDb = new lbug.Database(dbPath);
424
+ const tempConn = new lbug.Connection(tempDb);
423
425
  let inserted = 0;
424
426
  let failed = 0;
425
427
  try {
@@ -465,10 +467,10 @@ export const batchInsertNodesToKuzu = async (nodes, dbPath) => {
465
467
  };
466
468
  export const executeQuery = async (cypher) => {
467
469
  if (!conn) {
468
- throw new Error('KuzuDB not initialized. Call initKuzu first.');
470
+ throw new Error('LadybugDB not initialized. Call initLbug first.');
469
471
  }
470
472
  const queryResult = await conn.query(cypher);
471
- // kuzu v0.11 uses getAll() instead of hasNext()/getNext()
473
+ // LadybugDB uses getAll() instead of hasNext()/getNext()
472
474
  // Query returns QueryResult for single queries, QueryResult[] for multi-statement
473
475
  const result = Array.isArray(queryResult) ? queryResult[0] : queryResult;
474
476
  const rows = await result.getAll();
@@ -476,7 +478,7 @@ export const executeQuery = async (cypher) => {
476
478
  };
477
479
  export const executeWithReusedStatement = async (cypher, paramsList) => {
478
480
  if (!conn) {
479
- throw new Error('KuzuDB not initialized. Call initKuzu first.');
481
+ throw new Error('LadybugDB not initialized. Call initLbug first.');
480
482
  }
481
483
  if (paramsList.length === 0)
482
484
  return;
@@ -497,10 +499,10 @@ export const executeWithReusedStatement = async (cypher, paramsList) => {
497
499
  // Log the error and continue with next batch
498
500
  console.warn('Batch execution error:', e);
499
501
  }
500
- // Note: kuzu 0.8.2 PreparedStatement doesn't require explicit close()
502
+ // Note: LadybugDB PreparedStatement doesn't require explicit close()
501
503
  }
502
504
  };
503
- export const getKuzuStats = async () => {
505
+ export const getLbugStats = async () => {
504
506
  if (!conn)
505
507
  return { nodes: 0, edges: 0 };
506
508
  let totalNodes = 0;
@@ -532,7 +534,7 @@ export const getKuzuStats = async () => {
532
534
  return { nodes: totalNodes, edges: totalEdges };
533
535
  };
534
536
  /**
535
- * Load cached embeddings from KuzuDB before a rebuild.
537
+ * Load cached embeddings from LadybugDB before a rebuild.
536
538
  * Returns all embedding vectors so they can be re-inserted after the graph is reloaded,
537
539
  * avoiding expensive re-embedding of unchanged nodes.
538
540
  */
@@ -562,7 +564,7 @@ export const loadCachedEmbeddings = async () => {
562
564
  catch { /* embedding table may not exist */ }
563
565
  return { embeddingNodeIds, embeddings };
564
566
  };
565
- export const closeKuzu = async () => {
567
+ export const closeLbug = async () => {
566
568
  if (conn) {
567
569
  try {
568
570
  await conn.close();
@@ -580,11 +582,11 @@ export const closeKuzu = async () => {
580
582
  currentDbPath = null;
581
583
  ftsLoaded = false;
582
584
  };
583
- export const isKuzuReady = () => conn !== null && db !== null;
585
+ export const isLbugReady = () => conn !== null && db !== null;
584
586
  /**
585
- * Delete all nodes (and their relationships) for a specific file from KuzuDB
587
+ * Delete all nodes (and their relationships) for a specific file from LadybugDB
586
588
  * @param filePath - The file path to delete nodes for
587
- * @param dbPath - Optional path to KuzuDB for per-query connection
589
+ * @param dbPath - Optional path to LadybugDB for per-query connection
588
590
  * @returns Object with counts of deleted nodes
589
591
  */
590
592
  export const deleteNodesForFile = async (filePath, dbPath) => {
@@ -594,12 +596,12 @@ export const deleteNodesForFile = async (filePath, dbPath) => {
594
596
  let tempConn = null;
595
597
  let targetConn = conn;
596
598
  if (usePerQuery) {
597
- tempDb = new kuzu.Database(dbPath);
598
- tempConn = new kuzu.Connection(tempDb);
599
+ tempDb = new lbug.Database(dbPath);
600
+ tempConn = new lbug.Connection(tempDb);
599
601
  targetConn = tempConn;
600
602
  }
601
603
  else if (!conn) {
602
- throw new Error('KuzuDB not initialized. Provide dbPath or call initKuzu first.');
604
+ throw new Error('LadybugDB not initialized. Provide dbPath or call initLbug first.');
603
605
  }
604
606
  try {
605
607
  let deletedNodes = 0;
@@ -664,7 +666,7 @@ export const loadFTSExtension = async () => {
664
666
  if (ftsLoaded)
665
667
  return;
666
668
  if (!conn) {
667
- throw new Error('KuzuDB not initialized. Call initKuzu first.');
669
+ throw new Error('LadybugDB not initialized. Call initLbug first.');
668
670
  }
669
671
  try {
670
672
  await conn.query('INSTALL fts');
@@ -690,7 +692,7 @@ export const loadFTSExtension = async () => {
690
692
  */
691
693
  export const createFTSIndex = async (tableName, indexName, properties, stemmer = 'porter') => {
692
694
  if (!conn) {
693
- throw new Error('KuzuDB not initialized. Call initKuzu first.');
695
+ throw new Error('LadybugDB not initialized. Call initLbug first.');
694
696
  }
695
697
  await loadFTSExtension();
696
698
  const propList = properties.map(p => `'${p}'`).join(', ');
@@ -715,17 +717,15 @@ export const createFTSIndex = async (tableName, indexName, properties, stemmer =
715
717
  */
716
718
  export const queryFTS = async (tableName, indexName, query, limit = 20, conjunctive = false) => {
717
719
  if (!conn) {
718
- throw new Error('KuzuDB not initialized. Call initKuzu first.');
719
- }
720
- // Ensure FTS extension is loaded (safe to call multiple times)
721
- await loadFTSExtension();
722
- // Escape single quotes in query
723
- const escapedQuery = query.replace(/'/g, "''");
724
- const cypher = `
725
- CALL QUERY_FTS_INDEX('${tableName}', '${indexName}', '${escapedQuery}', conjunctive := ${conjunctive})
726
- RETURN node, score
727
- ORDER BY score DESC
728
- LIMIT ${limit}
720
+ throw new Error('LadybugDB not initialized. Call initLbug first.');
721
+ }
722
+ // Escape backslashes and single quotes to prevent Cypher injection
723
+ const escapedQuery = query.replace(/\\/g, '\\\\').replace(/'/g, "''");
724
+ const cypher = `
725
+ CALL QUERY_FTS_INDEX('${tableName}', '${indexName}', '${escapedQuery}', conjunctive := ${conjunctive})
726
+ RETURN node, score
727
+ ORDER BY score DESC
728
+ LIMIT ${limit}
729
729
  `;
730
730
  try {
731
731
  const queryResult = await conn.query(cypher);
@@ -756,7 +756,7 @@ export const queryFTS = async (tableName, indexName, query, limit = 20, conjunct
756
756
  */
757
757
  export const dropFTSIndex = async (tableName, indexName) => {
758
758
  if (!conn) {
759
- throw new Error('KuzuDB not initialized. Call initKuzu first.');
759
+ throw new Error('LadybugDB not initialized. Call initLbug first.');
760
760
  }
761
761
  try {
762
762
  await conn.query(`CALL DROP_FTS_INDEX('${tableName}', '${indexName}')`);
@@ -1,5 +1,5 @@
1
1
  /**
2
- * KuzuDB Schema Definitions
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", "MEMBER_OF", "STEP_IN_PROCESS"];
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 `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 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 `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 `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 Community,\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 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)";
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