gitnexus 1.4.8 → 1.4.9
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 +7 -0
- package/dist/cli/index-repo.d.ts +15 -0
- package/dist/cli/index-repo.js +115 -0
- package/dist/cli/index.js +11 -2
- package/dist/cli/setup.js +12 -9
- package/dist/cli/wiki.d.ts +4 -0
- package/dist/cli/wiki.js +174 -53
- package/dist/config/supported-languages.d.ts +7 -5
- package/dist/config/supported-languages.js +6 -4
- package/dist/core/graph/graph.js +9 -1
- package/dist/core/graph/types.d.ts +10 -2
- package/dist/core/ingestion/call-processor.d.ts +18 -1
- package/dist/core/ingestion/call-processor.js +297 -38
- package/dist/core/ingestion/call-routing.d.ts +3 -18
- package/dist/core/ingestion/call-routing.js +0 -19
- package/dist/core/ingestion/cobol/cobol-copy-expander.d.ts +57 -0
- package/dist/core/ingestion/cobol/cobol-copy-expander.js +385 -0
- package/dist/core/ingestion/cobol/cobol-preprocessor.d.ts +210 -0
- package/dist/core/ingestion/cobol/cobol-preprocessor.js +1509 -0
- package/dist/core/ingestion/cobol/jcl-parser.d.ts +68 -0
- package/dist/core/ingestion/cobol/jcl-parser.js +217 -0
- package/dist/core/ingestion/cobol/jcl-processor.d.ts +33 -0
- package/dist/core/ingestion/cobol/jcl-processor.js +229 -0
- package/dist/core/ingestion/cobol-processor.d.ts +54 -0
- package/dist/core/ingestion/cobol-processor.js +1186 -0
- package/dist/core/ingestion/entry-point-scoring.d.ts +17 -0
- package/dist/core/ingestion/entry-point-scoring.js +18 -4
- package/dist/core/ingestion/export-detection.d.ts +47 -8
- package/dist/core/ingestion/export-detection.js +29 -50
- package/dist/core/ingestion/field-extractor.d.ts +29 -0
- package/dist/core/ingestion/field-extractor.js +25 -0
- package/dist/core/ingestion/field-extractors/configs/c-cpp.d.ts +3 -0
- package/dist/core/ingestion/field-extractors/configs/c-cpp.js +108 -0
- package/dist/core/ingestion/field-extractors/configs/csharp.d.ts +8 -0
- package/dist/core/ingestion/field-extractors/configs/csharp.js +73 -0
- package/dist/core/ingestion/field-extractors/configs/dart.d.ts +8 -0
- package/dist/core/ingestion/field-extractors/configs/dart.js +76 -0
- package/dist/core/ingestion/field-extractors/configs/go.d.ts +11 -0
- package/dist/core/ingestion/field-extractors/configs/go.js +64 -0
- package/dist/core/ingestion/field-extractors/configs/helpers.d.ts +44 -0
- package/dist/core/ingestion/field-extractors/configs/helpers.js +134 -0
- package/dist/core/ingestion/field-extractors/configs/jvm.d.ts +3 -0
- package/dist/core/ingestion/field-extractors/configs/jvm.js +118 -0
- package/dist/core/ingestion/field-extractors/configs/php.d.ts +8 -0
- package/dist/core/ingestion/field-extractors/configs/php.js +67 -0
- package/dist/core/ingestion/field-extractors/configs/python.d.ts +12 -0
- package/dist/core/ingestion/field-extractors/configs/python.js +91 -0
- package/dist/core/ingestion/field-extractors/configs/ruby.d.ts +16 -0
- package/dist/core/ingestion/field-extractors/configs/ruby.js +75 -0
- package/dist/core/ingestion/field-extractors/configs/rust.d.ts +9 -0
- package/dist/core/ingestion/field-extractors/configs/rust.js +55 -0
- package/dist/core/ingestion/field-extractors/configs/swift.d.ts +8 -0
- package/dist/core/ingestion/field-extractors/configs/swift.js +63 -0
- package/dist/core/ingestion/field-extractors/configs/typescript-javascript.d.ts +3 -0
- package/dist/core/ingestion/field-extractors/configs/typescript-javascript.js +60 -0
- package/dist/core/ingestion/field-extractors/generic.d.ts +46 -0
- package/dist/core/ingestion/field-extractors/generic.js +111 -0
- package/dist/core/ingestion/field-extractors/typescript.d.ts +77 -0
- package/dist/core/ingestion/field-extractors/typescript.js +291 -0
- package/dist/core/ingestion/field-types.d.ts +59 -0
- package/dist/core/ingestion/field-types.js +2 -0
- package/dist/core/ingestion/framework-detection.d.ts +87 -0
- package/dist/core/ingestion/framework-detection.js +65 -2
- package/dist/core/ingestion/heritage-processor.js +15 -17
- package/dist/core/ingestion/import-processor.d.ts +9 -10
- package/dist/core/ingestion/import-processor.js +59 -14
- package/dist/core/ingestion/{resolvers → import-resolvers}/csharp.d.ts +6 -9
- package/dist/core/ingestion/{resolvers → import-resolvers}/csharp.js +20 -2
- package/dist/core/ingestion/import-resolvers/dart.d.ts +7 -0
- package/dist/core/ingestion/import-resolvers/dart.js +44 -0
- package/dist/core/ingestion/{resolvers → import-resolvers}/go.d.ts +4 -5
- package/dist/core/ingestion/{resolvers → import-resolvers}/go.js +17 -0
- package/dist/core/ingestion/{resolvers → import-resolvers}/jvm.d.ts +9 -1
- package/dist/core/ingestion/{resolvers → import-resolvers}/jvm.js +56 -0
- package/dist/core/ingestion/{resolvers → import-resolvers}/php.d.ts +6 -10
- package/dist/core/ingestion/{resolvers → import-resolvers}/php.js +7 -2
- package/dist/core/ingestion/{resolvers → import-resolvers}/python.d.ts +9 -3
- package/dist/core/ingestion/{resolvers → import-resolvers}/python.js +35 -3
- package/dist/core/ingestion/{resolvers → import-resolvers}/ruby.d.ts +5 -2
- package/dist/core/ingestion/{resolvers → import-resolvers}/ruby.js +7 -2
- package/dist/core/ingestion/{resolvers → import-resolvers}/rust.d.ts +5 -2
- package/dist/core/ingestion/{resolvers → import-resolvers}/rust.js +41 -2
- package/dist/core/ingestion/{resolvers → import-resolvers}/standard.d.ts +15 -7
- package/dist/core/ingestion/{resolvers → import-resolvers}/standard.js +22 -3
- package/dist/core/ingestion/import-resolvers/swift.d.ts +7 -0
- package/dist/core/ingestion/import-resolvers/swift.js +23 -0
- package/dist/core/ingestion/import-resolvers/types.d.ts +44 -0
- package/dist/core/ingestion/import-resolvers/types.js +6 -0
- package/dist/core/ingestion/{resolvers → import-resolvers}/utils.d.ts +0 -3
- package/dist/core/ingestion/{resolvers → import-resolvers}/utils.js +0 -9
- package/dist/core/ingestion/language-config.d.ts +4 -1
- package/dist/core/ingestion/language-provider.d.ts +121 -0
- package/dist/core/ingestion/language-provider.js +24 -0
- package/dist/core/ingestion/languages/c-cpp.d.ts +12 -0
- package/dist/core/ingestion/languages/c-cpp.js +71 -0
- package/dist/core/ingestion/languages/cobol.d.ts +1 -0
- package/dist/core/ingestion/languages/cobol.js +26 -0
- package/dist/core/ingestion/languages/csharp.d.ts +8 -0
- package/dist/core/ingestion/languages/csharp.js +49 -0
- package/dist/core/ingestion/languages/dart.d.ts +12 -0
- package/dist/core/ingestion/languages/dart.js +58 -0
- package/dist/core/ingestion/languages/go.d.ts +11 -0
- package/dist/core/ingestion/languages/go.js +28 -0
- package/dist/core/ingestion/languages/index.d.ts +38 -0
- package/dist/core/ingestion/languages/index.js +63 -0
- package/dist/core/ingestion/languages/java.d.ts +9 -0
- package/dist/core/ingestion/languages/java.js +29 -0
- package/dist/core/ingestion/languages/kotlin.d.ts +9 -0
- package/dist/core/ingestion/languages/kotlin.js +53 -0
- package/dist/core/ingestion/languages/php.d.ts +8 -0
- package/dist/core/ingestion/languages/php.js +145 -0
- package/dist/core/ingestion/languages/python.d.ts +12 -0
- package/dist/core/ingestion/languages/python.js +39 -0
- package/dist/core/ingestion/languages/ruby.d.ts +9 -0
- package/dist/core/ingestion/languages/ruby.js +44 -0
- package/dist/core/ingestion/languages/rust.d.ts +12 -0
- package/dist/core/ingestion/languages/rust.js +44 -0
- package/dist/core/ingestion/languages/swift.d.ts +12 -0
- package/dist/core/ingestion/languages/swift.js +133 -0
- package/dist/core/ingestion/languages/typescript.d.ts +10 -0
- package/dist/core/ingestion/languages/typescript.js +60 -0
- package/dist/core/ingestion/mro-processor.js +14 -15
- package/dist/core/ingestion/{named-binding-extraction.d.ts → named-binding-processor.d.ts} +0 -9
- package/dist/core/ingestion/named-binding-processor.js +42 -0
- package/dist/core/ingestion/named-bindings/csharp.d.ts +3 -0
- package/dist/core/ingestion/named-bindings/csharp.js +37 -0
- package/dist/core/ingestion/named-bindings/java.d.ts +3 -0
- package/dist/core/ingestion/named-bindings/java.js +29 -0
- package/dist/core/ingestion/named-bindings/kotlin.d.ts +3 -0
- package/dist/core/ingestion/named-bindings/kotlin.js +36 -0
- package/dist/core/ingestion/named-bindings/php.d.ts +3 -0
- package/dist/core/ingestion/named-bindings/php.js +61 -0
- package/dist/core/ingestion/named-bindings/python.d.ts +3 -0
- package/dist/core/ingestion/named-bindings/python.js +49 -0
- package/dist/core/ingestion/named-bindings/rust.d.ts +3 -0
- package/dist/core/ingestion/named-bindings/rust.js +64 -0
- package/dist/core/ingestion/named-bindings/types.d.ts +16 -0
- package/dist/core/ingestion/named-bindings/types.js +6 -0
- package/dist/core/ingestion/named-bindings/typescript.d.ts +3 -0
- package/dist/core/ingestion/named-bindings/typescript.js +58 -0
- package/dist/core/ingestion/parsing-processor.d.ts +5 -1
- package/dist/core/ingestion/parsing-processor.js +115 -16
- package/dist/core/ingestion/pipeline.js +925 -424
- package/dist/core/ingestion/resolution-context.js +1 -1
- package/dist/core/ingestion/route-extractors/expo.d.ts +1 -0
- package/dist/core/ingestion/route-extractors/expo.js +36 -0
- package/dist/core/ingestion/route-extractors/middleware.d.ts +47 -0
- package/dist/core/ingestion/route-extractors/middleware.js +143 -0
- package/dist/core/ingestion/route-extractors/nextjs.d.ts +3 -0
- package/dist/core/ingestion/route-extractors/nextjs.js +76 -0
- package/dist/core/ingestion/route-extractors/php.d.ts +7 -0
- package/dist/core/ingestion/route-extractors/php.js +21 -0
- package/dist/core/ingestion/route-extractors/response-shapes.d.ts +20 -0
- package/dist/core/ingestion/route-extractors/response-shapes.js +290 -0
- package/dist/core/ingestion/tree-sitter-queries.d.ts +8 -7
- package/dist/core/ingestion/tree-sitter-queries.js +231 -9
- package/dist/core/ingestion/type-env.d.ts +14 -17
- package/dist/core/ingestion/type-env.js +66 -14
- package/dist/core/ingestion/type-extractors/c-cpp.d.ts +1 -1
- package/dist/core/ingestion/type-extractors/csharp.js +1 -1
- package/dist/core/ingestion/type-extractors/dart.d.ts +15 -0
- package/dist/core/ingestion/type-extractors/dart.js +371 -0
- package/dist/core/ingestion/type-extractors/jvm.js +1 -1
- package/dist/core/ingestion/type-extractors/shared.d.ts +1 -13
- package/dist/core/ingestion/type-extractors/shared.js +9 -102
- package/dist/core/ingestion/type-extractors/swift.js +334 -4
- package/dist/core/ingestion/type-extractors/types.d.ts +3 -1
- package/dist/core/ingestion/{ast-helpers.d.ts → utils/ast-helpers.d.ts} +16 -13
- package/dist/core/ingestion/{ast-helpers.js → utils/ast-helpers.js} +111 -32
- package/dist/core/ingestion/{call-analysis.js → utils/call-analysis.js} +37 -0
- package/dist/core/ingestion/utils/event-loop.d.ts +5 -0
- package/dist/core/ingestion/utils/event-loop.js +5 -0
- package/dist/core/ingestion/utils/language-detection.d.ts +9 -0
- package/dist/core/ingestion/utils/language-detection.js +70 -0
- package/dist/core/ingestion/utils/verbose.d.ts +1 -0
- package/dist/core/ingestion/utils/verbose.js +7 -0
- package/dist/core/ingestion/workers/parse-worker.d.ts +43 -2
- package/dist/core/ingestion/workers/parse-worker.js +361 -150
- package/dist/core/lbug/csv-generator.js +34 -1
- package/dist/core/lbug/lbug-adapter.js +6 -0
- package/dist/core/lbug/schema.d.ts +5 -3
- package/dist/core/lbug/schema.js +39 -2
- package/dist/core/tree-sitter/parser-loader.js +7 -1
- package/dist/core/wiki/cursor-client.d.ts +31 -0
- package/dist/core/wiki/cursor-client.js +127 -0
- package/dist/core/wiki/generator.d.ts +28 -9
- package/dist/core/wiki/generator.js +115 -18
- package/dist/core/wiki/graph-queries.d.ts +4 -0
- package/dist/core/wiki/graph-queries.js +7 -1
- package/dist/core/wiki/llm-client.d.ts +2 -0
- package/dist/core/wiki/llm-client.js +8 -4
- package/dist/core/wiki/prompts.d.ts +3 -3
- package/dist/core/wiki/prompts.js +6 -0
- package/dist/mcp/core/lbug-adapter.d.ts +5 -0
- package/dist/mcp/core/lbug-adapter.js +11 -1
- package/dist/mcp/local/local-backend.d.ts +16 -5
- package/dist/mcp/local/local-backend.js +711 -74
- package/dist/mcp/tools.js +71 -2
- package/dist/storage/repo-manager.d.ts +3 -0
- package/package.json +17 -16
- package/dist/core/ingestion/import-resolution.d.ts +0 -101
- package/dist/core/ingestion/import-resolution.js +0 -251
- package/dist/core/ingestion/named-binding-extraction.js +0 -373
- package/dist/core/ingestion/resolvers/index.d.ts +0 -18
- package/dist/core/ingestion/resolvers/index.js +0 -13
- package/dist/core/ingestion/type-extractors/index.d.ts +0 -22
- package/dist/core/ingestion/type-extractors/index.js +0 -31
- package/dist/core/ingestion/utils.d.ts +0 -20
- package/dist/core/ingestion/utils.js +0 -242
- package/scripts/patch-tree-sitter-swift.cjs +0 -74
- /package/dist/core/ingestion/{call-analysis.d.ts → utils/call-analysis.d.ts} +0 -0
|
@@ -210,6 +210,10 @@ export const streamAllCSVsToDisk = async (graph, repoPath, csvDir) => {
|
|
|
210
210
|
const processWriter = new BufferedCSVWriter(path.join(csvDir, 'process.csv'), 'id,label,heuristicLabel,processType,stepCount,communities,entryPointId,terminalId');
|
|
211
211
|
// Section nodes have an extra 'level' column
|
|
212
212
|
const sectionWriter = new BufferedCSVWriter(path.join(csvDir, 'section.csv'), 'id,name,filePath,startLine,endLine,level,content,description');
|
|
213
|
+
// Route nodes for API endpoint mapping
|
|
214
|
+
const routeWriter = new BufferedCSVWriter(path.join(csvDir, 'route.csv'), 'id,name,filePath,responseKeys,errorKeys,middleware');
|
|
215
|
+
// Tool nodes for MCP tool definitions
|
|
216
|
+
const toolWriter = new BufferedCSVWriter(path.join(csvDir, 'tool.csv'), 'id,name,filePath,description');
|
|
213
217
|
// Multi-language node types share the same CSV shape (no isExported column)
|
|
214
218
|
const multiLangHeader = 'id,name,filePath,startLine,endLine,content,description';
|
|
215
219
|
const MULTI_LANG_TYPES = ['Struct', 'Enum', 'Macro', 'Typedef', 'Union', 'Namespace', 'Trait', 'Impl',
|
|
@@ -308,6 +312,33 @@ export const streamAllCSVsToDisk = async (graph, repoPath, csvDir) => {
|
|
|
308
312
|
].join(','));
|
|
309
313
|
break;
|
|
310
314
|
}
|
|
315
|
+
case 'Route': {
|
|
316
|
+
const responseKeys = node.properties.responseKeys || [];
|
|
317
|
+
// LadybugDB array literal inside a quoted CSV field: escapeCSVField wraps in "..."
|
|
318
|
+
// and the array uses single-quoted elements
|
|
319
|
+
const keysStr = `[${responseKeys.map((k) => `'${k.replace(/'/g, "''")}'`).join(',')}]`;
|
|
320
|
+
const errorKeys = node.properties.errorKeys || [];
|
|
321
|
+
const errorKeysStr = `[${errorKeys.map((k) => `'${k.replace(/'/g, "''")}'`).join(',')}]`;
|
|
322
|
+
const middleware = node.properties.middleware || [];
|
|
323
|
+
const middlewareStr = `[${middleware.map((m) => `'${m.replace(/'/g, "''")}'`).join(',')}]`;
|
|
324
|
+
await routeWriter.addRow([
|
|
325
|
+
escapeCSVField(node.id),
|
|
326
|
+
escapeCSVField(node.properties.name || ''),
|
|
327
|
+
escapeCSVField(node.properties.filePath || ''),
|
|
328
|
+
escapeCSVField(keysStr),
|
|
329
|
+
escapeCSVField(errorKeysStr),
|
|
330
|
+
escapeCSVField(middlewareStr),
|
|
331
|
+
].join(','));
|
|
332
|
+
break;
|
|
333
|
+
}
|
|
334
|
+
case 'Tool':
|
|
335
|
+
await toolWriter.addRow([
|
|
336
|
+
escapeCSVField(node.id),
|
|
337
|
+
escapeCSVField(node.properties.name || ''),
|
|
338
|
+
escapeCSVField(node.properties.filePath || ''),
|
|
339
|
+
escapeCSVField(node.properties.description || ''),
|
|
340
|
+
].join(','));
|
|
341
|
+
break;
|
|
311
342
|
default: {
|
|
312
343
|
// Code element nodes (Function, Class, Interface, CodeElement)
|
|
313
344
|
const writer = codeWriterMap[node.label];
|
|
@@ -345,7 +376,7 @@ export const streamAllCSVsToDisk = async (graph, repoPath, csvDir) => {
|
|
|
345
376
|
}
|
|
346
377
|
}
|
|
347
378
|
// Finish all node writers
|
|
348
|
-
const allWriters = [fileWriter, folderWriter, functionWriter, classWriter, interfaceWriter, methodWriter, codeElemWriter, communityWriter, processWriter, sectionWriter, ...multiLangWriters.values()];
|
|
379
|
+
const allWriters = [fileWriter, folderWriter, functionWriter, classWriter, interfaceWriter, methodWriter, codeElemWriter, communityWriter, processWriter, sectionWriter, routeWriter, toolWriter, ...multiLangWriters.values()];
|
|
349
380
|
await Promise.all(allWriters.map(w => w.finish()));
|
|
350
381
|
// --- Stream relationship CSV ---
|
|
351
382
|
const relCsvPath = path.join(csvDir, 'relations.csv');
|
|
@@ -370,6 +401,8 @@ export const streamAllCSVsToDisk = async (graph, repoPath, csvDir) => {
|
|
|
370
401
|
['CodeElement', codeElemWriter],
|
|
371
402
|
['Community', communityWriter], ['Process', processWriter],
|
|
372
403
|
['Section', sectionWriter],
|
|
404
|
+
['Route', routeWriter],
|
|
405
|
+
['Tool', toolWriter],
|
|
373
406
|
...Array.from(multiLangWriters.entries()).map(([name, w]) => [name, w]),
|
|
374
407
|
];
|
|
375
408
|
for (const [name, writer] of tableMap) {
|
|
@@ -380,6 +380,12 @@ const getCopyQuery = (table, filePath) => {
|
|
|
380
380
|
if (table === 'Section') {
|
|
381
381
|
return `COPY ${t}(id, name, filePath, startLine, endLine, level, content, description) FROM "${filePath}" ${COPY_CSV_OPTS}`;
|
|
382
382
|
}
|
|
383
|
+
if (table === 'Route') {
|
|
384
|
+
return `COPY ${t}(id, name, filePath, responseKeys, errorKeys, middleware) FROM "${filePath}" ${COPY_CSV_OPTS}`;
|
|
385
|
+
}
|
|
386
|
+
if (table === 'Tool') {
|
|
387
|
+
return `COPY ${t}(id, name, filePath, description) FROM "${filePath}" ${COPY_CSV_OPTS}`;
|
|
388
|
+
}
|
|
383
389
|
if (table === 'Method') {
|
|
384
390
|
return `COPY ${t}(id, name, filePath, startLine, endLine, isExported, content, description, parameterCount, returnType) FROM "${filePath}" ${COPY_CSV_OPTS}`;
|
|
385
391
|
}
|
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
* This allows LLMs to write natural Cypher queries like:
|
|
9
9
|
* MATCH (f:Function)-[r:CodeRelation {type: 'CALLS'}]->(g:Function) RETURN f, g
|
|
10
10
|
*/
|
|
11
|
-
export declare const NODE_TABLES: readonly ["File", "Folder", "Function", "Class", "Interface", "Method", "CodeElement", "Community", "Process", "Section", "Struct", "Enum", "Macro", "Typedef", "Union", "Namespace", "Trait", "Impl", "TypeAlias", "Const", "Static", "Property", "Record", "Delegate", "Annotation", "Constructor", "Template", "Module"];
|
|
11
|
+
export declare const NODE_TABLES: readonly ["File", "Folder", "Function", "Class", "Interface", "Method", "CodeElement", "Community", "Process", "Section", "Struct", "Enum", "Macro", "Typedef", "Union", "Namespace", "Trait", "Impl", "TypeAlias", "Const", "Static", "Property", "Record", "Delegate", "Annotation", "Constructor", "Template", "Module", "Route", "Tool"];
|
|
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", "HAS_METHOD", "HAS_PROPERTY", "ACCESSES", "OVERRIDES", "MEMBER_OF", "STEP_IN_PROCESS"];
|
|
14
|
+
export declare const REL_TYPES: readonly ["CONTAINS", "DEFINES", "IMPORTS", "CALLS", "EXTENDS", "IMPLEMENTS", "HAS_METHOD", "HAS_PROPERTY", "ACCESSES", "OVERRIDES", "MEMBER_OF", "STEP_IN_PROCESS", "HANDLES_ROUTE", "FETCHES", "HANDLES_TOOL", "ENTRY_POINT_OF", "WRAPS", "QUERIES"];
|
|
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)";
|
|
@@ -41,8 +41,10 @@ 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 ROUTE_SCHEMA = "\nCREATE NODE TABLE Route (\n id STRING,\n name STRING,\n filePath STRING,\n responseKeys STRING[],\n errorKeys STRING[],\n middleware STRING[],\n PRIMARY KEY (id)\n)";
|
|
45
|
+
export declare const TOOL_SCHEMA = "\nCREATE NODE TABLE Tool (\n id STRING,\n name STRING,\n filePath STRING,\n description STRING,\n PRIMARY KEY (id)\n)";
|
|
44
46
|
export declare const SECTION_SCHEMA = "\nCREATE NODE TABLE Section (\n id STRING,\n name STRING,\n filePath STRING,\n startLine INT64,\n endLine INT64,\n level INT64,\n content STRING,\n description STRING,\n PRIMARY KEY (id)\n)";
|
|
45
|
-
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 File TO Section,\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 Section TO Section,\n FROM Section TO File,\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)";
|
|
47
|
+
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 File TO Section,\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 Function TO CodeElement,\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 Method TO CodeElement,\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 Section TO Section,\n FROM Section TO File,\n FROM File TO Route,\n FROM Function TO Route,\n FROM Method TO Route,\n FROM File TO Tool,\n FROM Function TO Tool,\n FROM Method TO Tool,\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 FROM Route TO Process,\n FROM Tool TO Process,\n type STRING,\n confidence DOUBLE,\n reason STRING,\n step INT32\n)";
|
|
46
48
|
export declare const EMBEDDING_DIMS: number;
|
|
47
49
|
export declare const EMBEDDING_SCHEMA: string;
|
|
48
50
|
/**
|
package/dist/core/lbug/schema.js
CHANGED
|
@@ -15,14 +15,17 @@ export const NODE_TABLES = [
|
|
|
15
15
|
'File', 'Folder', 'Function', 'Class', 'Interface', 'Method', 'CodeElement', 'Community', 'Process', 'Section',
|
|
16
16
|
// Multi-language support
|
|
17
17
|
'Struct', 'Enum', 'Macro', 'Typedef', 'Union', 'Namespace', 'Trait', 'Impl',
|
|
18
|
-
'TypeAlias', 'Const', 'Static', 'Property', 'Record', 'Delegate', 'Annotation', 'Constructor', 'Template', 'Module'
|
|
18
|
+
'TypeAlias', 'Const', 'Static', 'Property', 'Record', 'Delegate', 'Annotation', 'Constructor', 'Template', 'Module',
|
|
19
|
+
'Route',
|
|
20
|
+
'Tool'
|
|
19
21
|
];
|
|
20
22
|
// ============================================================================
|
|
21
23
|
// RELATION TABLE
|
|
22
24
|
// ============================================================================
|
|
23
25
|
export const REL_TABLE_NAME = 'CodeRelation';
|
|
24
26
|
// Valid relation types
|
|
25
|
-
|
|
27
|
+
// Note: WRAPS is reserved for future middleware graph traversal (not yet emitted)
|
|
28
|
+
export const REL_TYPES = ['CONTAINS', 'DEFINES', 'IMPORTS', 'CALLS', 'EXTENDS', 'IMPLEMENTS', 'HAS_METHOD', 'HAS_PROPERTY', 'ACCESSES', 'OVERRIDES', 'MEMBER_OF', 'STEP_IN_PROCESS', 'HANDLES_ROUTE', 'FETCHES', 'HANDLES_TOOL', 'ENTRY_POINT_OF', 'WRAPS', 'QUERIES'];
|
|
26
29
|
// ============================================================================
|
|
27
30
|
// EMBEDDING TABLE
|
|
28
31
|
// ============================================================================
|
|
@@ -171,6 +174,26 @@ export const ANNOTATION_SCHEMA = CODE_ELEMENT_BASE('Annotation');
|
|
|
171
174
|
export const CONSTRUCTOR_SCHEMA = CODE_ELEMENT_BASE('Constructor');
|
|
172
175
|
export const TEMPLATE_SCHEMA = CODE_ELEMENT_BASE('Template');
|
|
173
176
|
export const MODULE_SCHEMA = CODE_ELEMENT_BASE('Module');
|
|
177
|
+
// API route endpoints (Next.js, Express, etc.)
|
|
178
|
+
export const ROUTE_SCHEMA = `
|
|
179
|
+
CREATE NODE TABLE Route (
|
|
180
|
+
id STRING,
|
|
181
|
+
name STRING,
|
|
182
|
+
filePath STRING,
|
|
183
|
+
responseKeys STRING[],
|
|
184
|
+
errorKeys STRING[],
|
|
185
|
+
middleware STRING[],
|
|
186
|
+
PRIMARY KEY (id)
|
|
187
|
+
)`;
|
|
188
|
+
// MCP tool definitions
|
|
189
|
+
export const TOOL_SCHEMA = `
|
|
190
|
+
CREATE NODE TABLE Tool (
|
|
191
|
+
id STRING,
|
|
192
|
+
name STRING,
|
|
193
|
+
filePath STRING,
|
|
194
|
+
description STRING,
|
|
195
|
+
PRIMARY KEY (id)
|
|
196
|
+
)`;
|
|
174
197
|
// Markdown heading sections
|
|
175
198
|
export const SECTION_SCHEMA = `
|
|
176
199
|
CREATE NODE TABLE Section (
|
|
@@ -236,6 +259,7 @@ CREATE REL TABLE ${REL_TABLE_NAME} (
|
|
|
236
259
|
FROM Function TO \`Typedef\`,
|
|
237
260
|
FROM Function TO \`Union\`,
|
|
238
261
|
FROM Function TO \`Property\`,
|
|
262
|
+
FROM Function TO CodeElement,
|
|
239
263
|
FROM Class TO Method,
|
|
240
264
|
FROM Class TO Function,
|
|
241
265
|
FROM Class TO Class,
|
|
@@ -269,6 +293,7 @@ CREATE REL TABLE ${REL_TABLE_NAME} (
|
|
|
269
293
|
FROM Method TO Interface,
|
|
270
294
|
FROM Method TO \`Constructor\`,
|
|
271
295
|
FROM Method TO \`Property\`,
|
|
296
|
+
FROM Method TO CodeElement,
|
|
272
297
|
FROM \`Template\` TO \`Template\`,
|
|
273
298
|
FROM \`Template\` TO Function,
|
|
274
299
|
FROM \`Template\` TO Method,
|
|
@@ -282,6 +307,12 @@ CREATE REL TABLE ${REL_TABLE_NAME} (
|
|
|
282
307
|
FROM \`Module\` TO \`Module\`,
|
|
283
308
|
FROM Section TO Section,
|
|
284
309
|
FROM Section TO File,
|
|
310
|
+
FROM File TO Route,
|
|
311
|
+
FROM Function TO Route,
|
|
312
|
+
FROM Method TO Route,
|
|
313
|
+
FROM File TO Tool,
|
|
314
|
+
FROM Function TO Tool,
|
|
315
|
+
FROM Method TO Tool,
|
|
285
316
|
FROM CodeElement TO Community,
|
|
286
317
|
FROM Interface TO Community,
|
|
287
318
|
FROM Interface TO Function,
|
|
@@ -380,6 +411,8 @@ CREATE REL TABLE ${REL_TABLE_NAME} (
|
|
|
380
411
|
FROM \`Annotation\` TO Process,
|
|
381
412
|
FROM \`Template\` TO Process,
|
|
382
413
|
FROM CodeElement TO Process,
|
|
414
|
+
FROM Route TO Process,
|
|
415
|
+
FROM Tool TO Process,
|
|
383
416
|
type STRING,
|
|
384
417
|
confidence DOUBLE,
|
|
385
418
|
reason STRING,
|
|
@@ -443,6 +476,10 @@ export const NODE_SCHEMA_QUERIES = [
|
|
|
443
476
|
MODULE_SCHEMA,
|
|
444
477
|
// Markdown support
|
|
445
478
|
SECTION_SCHEMA,
|
|
479
|
+
// API routes
|
|
480
|
+
ROUTE_SCHEMA,
|
|
481
|
+
// MCP tools
|
|
482
|
+
TOOL_SCHEMA,
|
|
446
483
|
];
|
|
447
484
|
export const REL_SCHEMA_QUERIES = [
|
|
448
485
|
RELATION_SCHEMA,
|
|
@@ -12,13 +12,18 @@ import PHP from 'tree-sitter-php';
|
|
|
12
12
|
import Ruby from 'tree-sitter-ruby';
|
|
13
13
|
import { createRequire } from 'node:module';
|
|
14
14
|
import { SupportedLanguages } from '../../config/supported-languages.js';
|
|
15
|
-
// tree-sitter-swift
|
|
15
|
+
// tree-sitter-swift and tree-sitter-dart are optionalDependencies — may not be installed
|
|
16
16
|
const _require = createRequire(import.meta.url);
|
|
17
17
|
let Swift = null;
|
|
18
18
|
try {
|
|
19
19
|
Swift = _require('tree-sitter-swift');
|
|
20
20
|
}
|
|
21
21
|
catch { }
|
|
22
|
+
let Dart = null;
|
|
23
|
+
try {
|
|
24
|
+
Dart = _require('tree-sitter-dart');
|
|
25
|
+
}
|
|
26
|
+
catch { }
|
|
22
27
|
// tree-sitter-kotlin is an optionalDependency — may not be installed
|
|
23
28
|
let Kotlin = null;
|
|
24
29
|
try {
|
|
@@ -40,6 +45,7 @@ const languageMap = {
|
|
|
40
45
|
...(Kotlin ? { [SupportedLanguages.Kotlin]: Kotlin } : {}),
|
|
41
46
|
[SupportedLanguages.PHP]: PHP.php_only,
|
|
42
47
|
[SupportedLanguages.Ruby]: Ruby,
|
|
48
|
+
...(Dart ? { [SupportedLanguages.Dart]: Dart } : {}),
|
|
43
49
|
...(Swift ? { [SupportedLanguages.Swift]: Swift } : {}),
|
|
44
50
|
};
|
|
45
51
|
export const isLanguageAvailable = (language) => language in languageMap;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cursor CLI Client for Wiki Generation
|
|
3
|
+
*
|
|
4
|
+
* Wrapper for the Cursor headless CLI (`agent` command).
|
|
5
|
+
* Uses print mode for non-interactive LLM calls.
|
|
6
|
+
*
|
|
7
|
+
* Docs: https://cursor.com/docs/cli/headless
|
|
8
|
+
*/
|
|
9
|
+
import type { LLMResponse, CallLLMOptions } from './llm-client.js';
|
|
10
|
+
export interface CursorConfig {
|
|
11
|
+
model?: string;
|
|
12
|
+
workingDirectory?: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Detect if Cursor CLI is available in PATH.
|
|
16
|
+
* Returns the binary name if found ('agent'), null otherwise.
|
|
17
|
+
* Result is cached after the first call.
|
|
18
|
+
*/
|
|
19
|
+
export declare function detectCursorCLI(): string | null;
|
|
20
|
+
/**
|
|
21
|
+
* Resolve Cursor CLI configuration.
|
|
22
|
+
* Model is optional - if not provided, Cursor CLI uses its default (auto).
|
|
23
|
+
*/
|
|
24
|
+
export declare function resolveCursorConfig(overrides?: Partial<CursorConfig>): CursorConfig;
|
|
25
|
+
/**
|
|
26
|
+
* Call the Cursor CLI in print mode.
|
|
27
|
+
*
|
|
28
|
+
* Uses `agent -p --output-format text` for clean non-streaming output.
|
|
29
|
+
* The prompt is passed as the final CLI argument.
|
|
30
|
+
*/
|
|
31
|
+
export declare function callCursorLLM(prompt: string, config: CursorConfig, systemPrompt?: string, options?: CallLLMOptions): Promise<LLMResponse>;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cursor CLI Client for Wiki Generation
|
|
3
|
+
*
|
|
4
|
+
* Wrapper for the Cursor headless CLI (`agent` command).
|
|
5
|
+
* Uses print mode for non-interactive LLM calls.
|
|
6
|
+
*
|
|
7
|
+
* Docs: https://cursor.com/docs/cli/headless
|
|
8
|
+
*/
|
|
9
|
+
import { spawn, execSync } from 'child_process';
|
|
10
|
+
function isVerbose() {
|
|
11
|
+
return process.env.GITNEXUS_VERBOSE === '1';
|
|
12
|
+
}
|
|
13
|
+
function verboseLog(...args) {
|
|
14
|
+
if (isVerbose()) {
|
|
15
|
+
console.log('[cursor-cli]', ...args);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
let cachedCursorBin;
|
|
19
|
+
/**
|
|
20
|
+
* Detect if Cursor CLI is available in PATH.
|
|
21
|
+
* Returns the binary name if found ('agent'), null otherwise.
|
|
22
|
+
* Result is cached after the first call.
|
|
23
|
+
*/
|
|
24
|
+
export function detectCursorCLI() {
|
|
25
|
+
if (cachedCursorBin !== undefined)
|
|
26
|
+
return cachedCursorBin;
|
|
27
|
+
try {
|
|
28
|
+
execSync('agent --version', { stdio: 'ignore' });
|
|
29
|
+
cachedCursorBin = 'agent';
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
cachedCursorBin = null;
|
|
33
|
+
}
|
|
34
|
+
return cachedCursorBin;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Resolve Cursor CLI configuration.
|
|
38
|
+
* Model is optional - if not provided, Cursor CLI uses its default (auto).
|
|
39
|
+
*/
|
|
40
|
+
export function resolveCursorConfig(overrides) {
|
|
41
|
+
return {
|
|
42
|
+
model: overrides?.model,
|
|
43
|
+
workingDirectory: overrides?.workingDirectory,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Call the Cursor CLI in print mode.
|
|
48
|
+
*
|
|
49
|
+
* Uses `agent -p --output-format text` for clean non-streaming output.
|
|
50
|
+
* The prompt is passed as the final CLI argument.
|
|
51
|
+
*/
|
|
52
|
+
export async function callCursorLLM(prompt, config, systemPrompt, options) {
|
|
53
|
+
const cursorBin = detectCursorCLI();
|
|
54
|
+
if (!cursorBin) {
|
|
55
|
+
throw new Error('Cursor CLI not found. Install it from https://cursor.com/docs/cli/installation');
|
|
56
|
+
}
|
|
57
|
+
// Always use text format to get clean output without agent narration/thinking.
|
|
58
|
+
// stream-json captures assistant messages which include "Let me explore..." narration
|
|
59
|
+
// that pollutes the actual content when using thinking models.
|
|
60
|
+
const fullPrompt = systemPrompt
|
|
61
|
+
? `${systemPrompt}\n\n---\n\n${prompt}`
|
|
62
|
+
: prompt;
|
|
63
|
+
const args = [
|
|
64
|
+
'-p',
|
|
65
|
+
'--output-format', 'text',
|
|
66
|
+
];
|
|
67
|
+
if (config.model) {
|
|
68
|
+
args.push('--model', config.model);
|
|
69
|
+
}
|
|
70
|
+
// Add the prompt as the final argument
|
|
71
|
+
args.push(fullPrompt);
|
|
72
|
+
verboseLog('Spawning:', cursorBin, args.slice(0, -1).join(' '), '[prompt length:', fullPrompt.length, 'chars]');
|
|
73
|
+
verboseLog('Working directory:', config.workingDirectory || process.cwd());
|
|
74
|
+
if (config.model) {
|
|
75
|
+
verboseLog('Model:', config.model);
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
verboseLog('Model: auto (default)');
|
|
79
|
+
}
|
|
80
|
+
const startTime = Date.now();
|
|
81
|
+
return new Promise((resolve, reject) => {
|
|
82
|
+
const child = spawn(cursorBin, args, {
|
|
83
|
+
cwd: config.workingDirectory || process.cwd(),
|
|
84
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
85
|
+
env: {
|
|
86
|
+
...process.env,
|
|
87
|
+
// Ensure non-interactive mode
|
|
88
|
+
CI: '1',
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
verboseLog('Process spawned with PID:', child.pid);
|
|
92
|
+
let stdout = '';
|
|
93
|
+
let stderr = '';
|
|
94
|
+
// Text mode - collect all output, report progress based on output size
|
|
95
|
+
child.stdout.on('data', (chunk) => {
|
|
96
|
+
const chunkStr = chunk.toString();
|
|
97
|
+
stdout += chunkStr;
|
|
98
|
+
verboseLog(`[stdout] received ${chunkStr.length} chars, total: ${stdout.length}`);
|
|
99
|
+
// Report progress if callback provided
|
|
100
|
+
if (options?.onChunk) {
|
|
101
|
+
options.onChunk(stdout.length);
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
child.on('close', (code) => {
|
|
105
|
+
const elapsed = ((Date.now() - startTime) / 1000).toFixed(1);
|
|
106
|
+
verboseLog(`Process exited with code ${code} after ${elapsed}s`);
|
|
107
|
+
verboseLog(`stdout length: ${stdout.length} chars`);
|
|
108
|
+
if (code !== 0) {
|
|
109
|
+
verboseLog('stderr:', stderr);
|
|
110
|
+
reject(new Error(`Cursor CLI exited with code ${code}: ${stderr}`));
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
resolve({ content: stdout.trim() });
|
|
114
|
+
});
|
|
115
|
+
child.stderr.on('data', (chunk) => {
|
|
116
|
+
const chunkStr = chunk.toString();
|
|
117
|
+
stderr += chunkStr;
|
|
118
|
+
verboseLog('[stderr]', chunkStr.trim());
|
|
119
|
+
});
|
|
120
|
+
child.on('error', (err) => {
|
|
121
|
+
verboseLog('Spawn error:', err.message);
|
|
122
|
+
reject(new Error(`Failed to spawn Cursor CLI: ${err.message}`));
|
|
123
|
+
});
|
|
124
|
+
// Close stdin immediately since we pass prompt as argument
|
|
125
|
+
child.stdin.end();
|
|
126
|
+
});
|
|
127
|
+
}
|
|
@@ -12,11 +12,10 @@
|
|
|
12
12
|
import { type LLMConfig } from './llm-client.js';
|
|
13
13
|
export interface WikiOptions {
|
|
14
14
|
force?: boolean;
|
|
15
|
-
model?: string;
|
|
16
|
-
baseUrl?: string;
|
|
17
|
-
apiKey?: string;
|
|
18
15
|
maxTokensPerModule?: number;
|
|
19
16
|
concurrency?: number;
|
|
17
|
+
/** If true, stop after building module tree for user review */
|
|
18
|
+
reviewOnly?: boolean;
|
|
20
19
|
}
|
|
21
20
|
export interface WikiMeta {
|
|
22
21
|
fromCommit: string;
|
|
@@ -32,6 +31,12 @@ export interface ModuleTreeNode {
|
|
|
32
31
|
children?: ModuleTreeNode[];
|
|
33
32
|
}
|
|
34
33
|
export type ProgressCallback = (phase: string, percent: number, detail?: string) => void;
|
|
34
|
+
export interface WikiRunResult {
|
|
35
|
+
pagesGenerated: number;
|
|
36
|
+
mode: 'full' | 'incremental' | 'up-to-date';
|
|
37
|
+
failedModules: string[];
|
|
38
|
+
moduleTree?: ModuleTreeNode[];
|
|
39
|
+
}
|
|
35
40
|
export declare class WikiGenerator {
|
|
36
41
|
private repoPath;
|
|
37
42
|
private storagePath;
|
|
@@ -47,17 +52,24 @@ export declare class WikiGenerator {
|
|
|
47
52
|
private lastPercent;
|
|
48
53
|
/**
|
|
49
54
|
* Create streaming options that report LLM progress to the progress bar.
|
|
50
|
-
*
|
|
55
|
+
*
|
|
56
|
+
* Progress calculation:
|
|
57
|
+
* - If fixedPercent is provided, we show incremental progress within that phase
|
|
58
|
+
* based on token generation (e.g., grouping at 15% → 15-28%)
|
|
59
|
+
* - If fixedPercent is NOT provided, we only update the label with token count
|
|
60
|
+
* but keep the current percentage (avoids fluctuation during module generation)
|
|
61
|
+
*
|
|
62
|
+
* Also touches the DB connection periodically to prevent idle timeout.
|
|
51
63
|
*/
|
|
52
64
|
private streamOpts;
|
|
65
|
+
/**
|
|
66
|
+
* Route LLM call to the appropriate provider (OpenAI-compatible or Cursor CLI).
|
|
67
|
+
*/
|
|
68
|
+
private invokeLLM;
|
|
53
69
|
/**
|
|
54
70
|
* Main entry point. Runs the full pipeline or incremental update.
|
|
55
71
|
*/
|
|
56
|
-
run(): Promise<
|
|
57
|
-
pagesGenerated: number;
|
|
58
|
-
mode: 'full' | 'incremental' | 'up-to-date';
|
|
59
|
-
failedModules: string[];
|
|
60
|
-
}>;
|
|
72
|
+
run(): Promise<WikiRunResult>;
|
|
61
73
|
private ensureHTMLViewer;
|
|
62
74
|
private fullGeneration;
|
|
63
75
|
private buildModuleTree;
|
|
@@ -71,6 +83,8 @@ export declare class WikiGenerator {
|
|
|
71
83
|
private fallbackGrouping;
|
|
72
84
|
/**
|
|
73
85
|
* Split a large module into sub-modules by subdirectory.
|
|
86
|
+
* Uses the full subDir path for naming to avoid slug collisions
|
|
87
|
+
* (e.g., "synapse-screen/src" vs "synapse-core/src").
|
|
74
88
|
*/
|
|
75
89
|
private splitBySubdirectory;
|
|
76
90
|
/**
|
|
@@ -84,6 +98,11 @@ export declare class WikiGenerator {
|
|
|
84
98
|
private generateOverview;
|
|
85
99
|
private incrementalUpdate;
|
|
86
100
|
private getCurrentCommit;
|
|
101
|
+
/**
|
|
102
|
+
* Check if fromCommit is an ancestor of toCommit (reachable in git history).
|
|
103
|
+
* Returns false if commits are on divergent branches or fromCommit doesn't exist.
|
|
104
|
+
*/
|
|
105
|
+
private isCommitReachable;
|
|
87
106
|
private getChangedFiles;
|
|
88
107
|
private readSourceFiles;
|
|
89
108
|
private truncateSource;
|