gitnexus 1.3.11 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/README.md +194 -194
  2. package/dist/cli/ai-context.js +87 -105
  3. package/dist/cli/analyze.js +0 -8
  4. package/dist/cli/index.js +25 -15
  5. package/dist/cli/setup.js +19 -17
  6. package/dist/core/augmentation/engine.js +20 -20
  7. package/dist/core/embeddings/embedding-pipeline.js +26 -26
  8. package/dist/core/ingestion/ast-cache.js +2 -3
  9. package/dist/core/ingestion/call-processor.js +5 -7
  10. package/dist/core/ingestion/cluster-enricher.js +16 -16
  11. package/dist/core/ingestion/pipeline.js +2 -23
  12. package/dist/core/ingestion/tree-sitter-queries.js +484 -484
  13. package/dist/core/ingestion/utils.js +5 -1
  14. package/dist/core/ingestion/workers/worker-pool.js +0 -8
  15. package/dist/core/kuzu/kuzu-adapter.js +19 -11
  16. package/dist/core/kuzu/schema.js +287 -287
  17. package/dist/core/search/bm25-index.js +6 -7
  18. package/dist/core/search/hybrid-search.js +3 -3
  19. package/dist/core/wiki/diagrams.d.ts +27 -0
  20. package/dist/core/wiki/diagrams.js +163 -0
  21. package/dist/core/wiki/generator.d.ts +50 -2
  22. package/dist/core/wiki/generator.js +548 -49
  23. package/dist/core/wiki/graph-queries.d.ts +42 -0
  24. package/dist/core/wiki/graph-queries.js +276 -97
  25. package/dist/core/wiki/html-viewer.js +192 -192
  26. package/dist/core/wiki/llm-client.js +73 -11
  27. package/dist/core/wiki/prompts.d.ts +52 -8
  28. package/dist/core/wiki/prompts.js +200 -86
  29. package/dist/mcp/core/kuzu-adapter.d.ts +3 -1
  30. package/dist/mcp/core/kuzu-adapter.js +44 -13
  31. package/dist/mcp/local/local-backend.js +128 -128
  32. package/dist/mcp/resources.js +42 -42
  33. package/dist/mcp/server.js +19 -18
  34. package/dist/mcp/tools.js +103 -93
  35. package/hooks/claude/gitnexus-hook.cjs +155 -238
  36. package/hooks/claude/pre-tool-use.sh +79 -79
  37. package/hooks/claude/session-start.sh +42 -42
  38. package/package.json +96 -96
  39. package/scripts/patch-tree-sitter-swift.cjs +74 -74
  40. package/skills/gitnexus-cli.md +82 -82
  41. package/skills/gitnexus-debugging.md +89 -89
  42. package/skills/gitnexus-exploring.md +78 -78
  43. package/skills/gitnexus-guide.md +64 -64
  44. package/skills/gitnexus-impact-analysis.md +97 -97
  45. package/skills/gitnexus-pr-review.md +163 -163
  46. package/skills/gitnexus-refactoring.md +121 -121
  47. package/vendor/leiden/index.cjs +355 -355
  48. package/vendor/leiden/utils.cjs +392 -392
  49. package/dist/cli/lazy-action.d.ts +0 -6
  50. package/dist/cli/lazy-action.js +0 -18
  51. package/dist/mcp/compatible-stdio-transport.d.ts +0 -25
  52. package/dist/mcp/compatible-stdio-transport.js +0 -200
@@ -30,11 +30,15 @@ export const getLanguageFromFilename = (filename) => {
30
30
  return SupportedLanguages.TypeScript;
31
31
  if (filename.endsWith('.ts'))
32
32
  return SupportedLanguages.TypeScript;
33
- // JavaScript (including JSX)
33
+ // JavaScript (including JSX, CJS, MJS)
34
34
  if (filename.endsWith('.jsx'))
35
35
  return SupportedLanguages.JavaScript;
36
36
  if (filename.endsWith('.js'))
37
37
  return SupportedLanguages.JavaScript;
38
+ if (filename.endsWith('.cjs'))
39
+ return SupportedLanguages.JavaScript;
40
+ if (filename.endsWith('.mjs'))
41
+ return SupportedLanguages.JavaScript;
38
42
  // Python
39
43
  if (filename.endsWith('.py'))
40
44
  return SupportedLanguages.Python;
@@ -1,7 +1,5 @@
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';
5
3
  /**
6
4
  * Max files to send to a worker in a single postMessage.
7
5
  * Keeps structured-clone memory bounded per sub-batch.
@@ -14,12 +12,6 @@ const SUB_BATCH_TIMEOUT_MS = 30_000;
14
12
  * Create a pool of worker threads.
15
13
  */
16
14
  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
- }
23
15
  const size = poolSize ?? Math.min(8, Math.max(1, os.cpus().length - 1));
24
16
  const workers = [];
25
17
  for (let i = 0; i < size; i++) {
@@ -104,6 +104,12 @@ const doInitKuzu = async (dbPath) => {
104
104
  }
105
105
  }
106
106
  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 */ }
107
113
  return { db, conn };
108
114
  };
109
115
  export const loadGraphToKuzu = async (graph, repoPath, storagePath, onProgress) => {
@@ -289,10 +295,10 @@ const fallbackRelationshipInserts = async (validRelLines, validTables, getNodeLa
289
295
  continue;
290
296
  const confidence = parseFloat(confidenceStr) || 1.0;
291
297
  const step = parseInt(stepStr) || 0;
292
- await conn.query(`
293
- MATCH (a:${escapeLabel(fromLabel)} {id: '${fromId.replace(/'/g, "''")}' }),
294
- (b:${escapeLabel(toLabel)} {id: '${toId.replace(/'/g, "''")}' })
295
- CREATE (a)-[:${REL_TABLE_NAME} {type: '${relType}', confidence: ${confidence}, reason: '${reason.replace(/'/g, "''")}', step: ${step}}]->(b)
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
302
  `);
297
303
  }
298
304
  catch {
@@ -711,13 +717,15 @@ export const queryFTS = async (tableName, indexName, query, limit = 20, conjunct
711
717
  if (!conn) {
712
718
  throw new Error('KuzuDB not initialized. Call initKuzu first.');
713
719
  }
714
- // Escape backslashes and single quotes to prevent Cypher injection
715
- const escapedQuery = query.replace(/\\/g, '\\\\').replace(/'/g, "''");
716
- const cypher = `
717
- CALL QUERY_FTS_INDEX('${tableName}', '${indexName}', '${escapedQuery}', conjunctive := ${conjunctive})
718
- RETURN node, score
719
- ORDER BY score DESC
720
- LIMIT ${limit}
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}
721
729
  `;
722
730
  try {
723
731
  const queryResult = await conn.query(cypher);