gitnexus 1.5.3 → 1.6.0

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 (201) hide show
  1. package/README.md +10 -0
  2. package/dist/_shared/graph/types.d.ts +1 -1
  3. package/dist/_shared/graph/types.d.ts.map +1 -1
  4. package/dist/_shared/index.d.ts +1 -0
  5. package/dist/_shared/index.d.ts.map +1 -1
  6. package/dist/_shared/language-detection.d.ts.map +1 -1
  7. package/dist/_shared/language-detection.js +2 -0
  8. package/dist/_shared/language-detection.js.map +1 -1
  9. package/dist/_shared/languages.d.ts +1 -0
  10. package/dist/_shared/languages.d.ts.map +1 -1
  11. package/dist/_shared/languages.js +1 -0
  12. package/dist/_shared/languages.js.map +1 -1
  13. package/dist/_shared/lbug/schema-constants.d.ts +1 -1
  14. package/dist/_shared/lbug/schema-constants.d.ts.map +1 -1
  15. package/dist/_shared/lbug/schema-constants.js +3 -1
  16. package/dist/_shared/lbug/schema-constants.js.map +1 -1
  17. package/dist/_shared/mro-strategy.d.ts +19 -0
  18. package/dist/_shared/mro-strategy.d.ts.map +1 -0
  19. package/dist/_shared/mro-strategy.js +2 -0
  20. package/dist/_shared/mro-strategy.js.map +1 -0
  21. package/dist/cli/ai-context.d.ts +1 -0
  22. package/dist/cli/ai-context.js +28 -4
  23. package/dist/cli/analyze.d.ts +2 -0
  24. package/dist/cli/analyze.js +2 -1
  25. package/dist/cli/group.d.ts +2 -0
  26. package/dist/cli/group.js +233 -0
  27. package/dist/cli/index.js +3 -0
  28. package/dist/cli/serve.js +4 -1
  29. package/dist/cli/setup.js +34 -3
  30. package/dist/config/ignore-service.js +8 -3
  31. package/dist/core/augmentation/engine.js +1 -1
  32. package/dist/core/git-staleness.d.ts +13 -0
  33. package/dist/core/git-staleness.js +29 -0
  34. package/dist/core/group/bridge-db.d.ts +82 -0
  35. package/dist/core/group/bridge-db.js +460 -0
  36. package/dist/core/group/bridge-schema.d.ts +27 -0
  37. package/dist/core/group/bridge-schema.js +55 -0
  38. package/dist/core/group/config-parser.d.ts +3 -0
  39. package/dist/core/group/config-parser.js +83 -0
  40. package/dist/core/group/contract-extractor.d.ts +7 -0
  41. package/dist/core/group/contract-extractor.js +1 -0
  42. package/dist/core/group/extractors/grpc-extractor.d.ts +16 -0
  43. package/dist/core/group/extractors/grpc-extractor.js +264 -0
  44. package/dist/core/group/extractors/http-route-extractor.d.ts +24 -0
  45. package/dist/core/group/extractors/http-route-extractor.js +428 -0
  46. package/dist/core/group/extractors/topic-extractor.d.ts +9 -0
  47. package/dist/core/group/extractors/topic-extractor.js +234 -0
  48. package/dist/core/group/matching.d.ts +13 -0
  49. package/dist/core/group/matching.js +198 -0
  50. package/dist/core/group/normalization.d.ts +3 -0
  51. package/dist/core/group/normalization.js +115 -0
  52. package/dist/core/group/service-boundary-detector.d.ts +8 -0
  53. package/dist/core/group/service-boundary-detector.js +155 -0
  54. package/dist/core/group/service.d.ts +46 -0
  55. package/dist/core/group/service.js +160 -0
  56. package/dist/core/group/storage.d.ts +9 -0
  57. package/dist/core/group/storage.js +91 -0
  58. package/dist/core/group/sync.d.ts +21 -0
  59. package/dist/core/group/sync.js +148 -0
  60. package/dist/core/group/types.d.ts +130 -0
  61. package/dist/core/group/types.js +1 -0
  62. package/dist/core/ingestion/binding-accumulator.d.ts +207 -0
  63. package/dist/core/ingestion/binding-accumulator.js +332 -0
  64. package/dist/core/ingestion/call-processor.d.ts +155 -24
  65. package/dist/core/ingestion/call-processor.js +1129 -247
  66. package/dist/core/ingestion/class-extractors/generic.d.ts +2 -0
  67. package/dist/core/ingestion/class-extractors/generic.js +135 -0
  68. package/dist/core/ingestion/class-types.d.ts +34 -0
  69. package/dist/core/ingestion/class-types.js +1 -0
  70. package/dist/core/ingestion/entry-point-scoring.d.ts +1 -0
  71. package/dist/core/ingestion/entry-point-scoring.js +1 -0
  72. package/dist/core/ingestion/field-types.d.ts +2 -2
  73. package/dist/core/ingestion/filesystem-walker.js +8 -0
  74. package/dist/core/ingestion/framework-detection.d.ts +1 -0
  75. package/dist/core/ingestion/framework-detection.js +1 -0
  76. package/dist/core/ingestion/heritage-processor.d.ts +8 -15
  77. package/dist/core/ingestion/heritage-processor.js +15 -28
  78. package/dist/core/ingestion/import-processor.d.ts +1 -11
  79. package/dist/core/ingestion/import-processor.js +0 -12
  80. package/dist/core/ingestion/import-resolvers/utils.js +1 -0
  81. package/dist/core/ingestion/import-resolvers/vue.d.ts +8 -0
  82. package/dist/core/ingestion/import-resolvers/vue.js +9 -0
  83. package/dist/core/ingestion/language-provider.d.ts +6 -3
  84. package/dist/core/ingestion/languages/c-cpp.js +168 -1
  85. package/dist/core/ingestion/languages/csharp.js +20 -0
  86. package/dist/core/ingestion/languages/dart.js +26 -4
  87. package/dist/core/ingestion/languages/go.js +22 -0
  88. package/dist/core/ingestion/languages/index.d.ts +1 -0
  89. package/dist/core/ingestion/languages/index.js +2 -0
  90. package/dist/core/ingestion/languages/java.js +17 -0
  91. package/dist/core/ingestion/languages/kotlin.js +24 -1
  92. package/dist/core/ingestion/languages/php.js +23 -11
  93. package/dist/core/ingestion/languages/python.js +9 -0
  94. package/dist/core/ingestion/languages/ruby.js +28 -0
  95. package/dist/core/ingestion/languages/rust.js +38 -0
  96. package/dist/core/ingestion/languages/swift.js +31 -0
  97. package/dist/core/ingestion/languages/typescript.d.ts +1 -0
  98. package/dist/core/ingestion/languages/typescript.js +52 -3
  99. package/dist/core/ingestion/languages/vue.d.ts +13 -0
  100. package/dist/core/ingestion/languages/vue.js +81 -0
  101. package/dist/core/ingestion/method-extractors/configs/c-cpp.d.ts +3 -0
  102. package/dist/core/ingestion/method-extractors/configs/c-cpp.js +387 -0
  103. package/dist/core/ingestion/method-extractors/configs/csharp.js +5 -1
  104. package/dist/core/ingestion/method-extractors/configs/dart.d.ts +2 -0
  105. package/dist/core/ingestion/method-extractors/configs/dart.js +376 -0
  106. package/dist/core/ingestion/method-extractors/configs/go.d.ts +2 -0
  107. package/dist/core/ingestion/method-extractors/configs/go.js +176 -0
  108. package/dist/core/ingestion/method-extractors/configs/jvm.js +13 -4
  109. package/dist/core/ingestion/method-extractors/configs/php.d.ts +2 -0
  110. package/dist/core/ingestion/method-extractors/configs/php.js +304 -0
  111. package/dist/core/ingestion/method-extractors/configs/python.d.ts +2 -0
  112. package/dist/core/ingestion/method-extractors/configs/python.js +309 -0
  113. package/dist/core/ingestion/method-extractors/configs/ruby.d.ts +2 -0
  114. package/dist/core/ingestion/method-extractors/configs/ruby.js +285 -0
  115. package/dist/core/ingestion/method-extractors/configs/rust.d.ts +2 -0
  116. package/dist/core/ingestion/method-extractors/configs/rust.js +195 -0
  117. package/dist/core/ingestion/method-extractors/configs/swift.d.ts +2 -0
  118. package/dist/core/ingestion/method-extractors/configs/swift.js +277 -0
  119. package/dist/core/ingestion/method-extractors/configs/typescript-javascript.js +85 -8
  120. package/dist/core/ingestion/method-extractors/generic.js +38 -15
  121. package/dist/core/ingestion/method-types.d.ts +25 -0
  122. package/dist/core/ingestion/model/field-registry.d.ts +18 -0
  123. package/dist/core/ingestion/model/field-registry.js +22 -0
  124. package/dist/core/ingestion/model/heritage-map.d.ts +70 -0
  125. package/dist/core/ingestion/model/heritage-map.js +159 -0
  126. package/dist/core/ingestion/model/index.d.ts +20 -0
  127. package/dist/core/ingestion/model/index.js +41 -0
  128. package/dist/core/ingestion/model/method-registry.d.ts +62 -0
  129. package/dist/core/ingestion/model/method-registry.js +130 -0
  130. package/dist/core/ingestion/model/registration-table.d.ts +139 -0
  131. package/dist/core/ingestion/model/registration-table.js +224 -0
  132. package/dist/core/ingestion/model/resolution-context.d.ts +93 -0
  133. package/dist/core/ingestion/model/resolution-context.js +337 -0
  134. package/dist/core/ingestion/model/resolve.d.ts +56 -0
  135. package/dist/core/ingestion/model/resolve.js +242 -0
  136. package/dist/core/ingestion/model/semantic-model.d.ts +86 -0
  137. package/dist/core/ingestion/model/semantic-model.js +120 -0
  138. package/dist/core/ingestion/model/symbol-table.d.ts +222 -0
  139. package/dist/core/ingestion/model/symbol-table.js +206 -0
  140. package/dist/core/ingestion/model/type-registry.d.ts +39 -0
  141. package/dist/core/ingestion/model/type-registry.js +62 -0
  142. package/dist/core/ingestion/mro-processor.d.ts +4 -3
  143. package/dist/core/ingestion/mro-processor.js +310 -106
  144. package/dist/core/ingestion/parsing-processor.d.ts +5 -4
  145. package/dist/core/ingestion/parsing-processor.js +210 -85
  146. package/dist/core/ingestion/pipeline.d.ts +2 -0
  147. package/dist/core/ingestion/pipeline.js +192 -68
  148. package/dist/core/ingestion/tree-sitter-queries.d.ts +5 -5
  149. package/dist/core/ingestion/tree-sitter-queries.js +21 -0
  150. package/dist/core/ingestion/type-env.d.ts +15 -2
  151. package/dist/core/ingestion/type-env.js +163 -102
  152. package/dist/core/ingestion/type-extractors/csharp.js +17 -0
  153. package/dist/core/ingestion/type-extractors/jvm.js +11 -0
  154. package/dist/core/ingestion/type-extractors/php.js +0 -55
  155. package/dist/core/ingestion/type-extractors/ruby.js +0 -32
  156. package/dist/core/ingestion/type-extractors/swift.js +13 -0
  157. package/dist/core/ingestion/type-extractors/types.d.ts +8 -8
  158. package/dist/core/ingestion/type-extractors/typescript.js +66 -69
  159. package/dist/core/ingestion/utils/ast-helpers.d.ts +33 -43
  160. package/dist/core/ingestion/utils/ast-helpers.js +129 -572
  161. package/dist/core/ingestion/utils/method-props.d.ts +32 -0
  162. package/dist/core/ingestion/utils/method-props.js +147 -0
  163. package/dist/core/ingestion/vue-sfc-extractor.d.ts +44 -0
  164. package/dist/core/ingestion/vue-sfc-extractor.js +94 -0
  165. package/dist/core/ingestion/workers/parse-worker.d.ts +31 -19
  166. package/dist/core/ingestion/workers/parse-worker.js +463 -198
  167. package/dist/core/lbug/lbug-adapter.d.ts +6 -0
  168. package/dist/core/lbug/lbug-adapter.js +68 -3
  169. package/dist/core/lbug/pool-adapter.d.ts +76 -0
  170. package/dist/core/lbug/pool-adapter.js +522 -0
  171. package/dist/core/run-analyze.d.ts +2 -0
  172. package/dist/core/run-analyze.js +1 -1
  173. package/dist/core/search/bm25-index.js +1 -1
  174. package/dist/core/tree-sitter/parser-loader.js +1 -0
  175. package/dist/core/wiki/graph-queries.js +1 -1
  176. package/dist/mcp/core/embedder.js +6 -5
  177. package/dist/mcp/core/lbug-adapter.d.ts +3 -63
  178. package/dist/mcp/core/lbug-adapter.js +3 -484
  179. package/dist/mcp/local/local-backend.d.ts +31 -2
  180. package/dist/mcp/local/local-backend.js +255 -46
  181. package/dist/mcp/resources.js +5 -4
  182. package/dist/mcp/staleness.d.ts +3 -13
  183. package/dist/mcp/staleness.js +2 -31
  184. package/dist/mcp/tools.js +80 -4
  185. package/dist/server/analyze-job.d.ts +2 -0
  186. package/dist/server/analyze-job.js +4 -0
  187. package/dist/server/api.d.ts +20 -1
  188. package/dist/server/api.js +306 -71
  189. package/dist/server/git-clone.d.ts +2 -1
  190. package/dist/server/git-clone.js +98 -5
  191. package/dist/storage/git.d.ts +13 -0
  192. package/dist/storage/git.js +25 -0
  193. package/dist/storage/repo-manager.js +1 -1
  194. package/package.json +8 -2
  195. package/scripts/patch-tree-sitter-swift.cjs +78 -0
  196. package/dist/core/ingestion/named-binding-processor.d.ts +0 -18
  197. package/dist/core/ingestion/named-binding-processor.js +0 -42
  198. package/dist/core/ingestion/resolution-context.d.ts +0 -58
  199. package/dist/core/ingestion/resolution-context.js +0 -135
  200. package/dist/core/ingestion/symbol-table.d.ts +0 -79
  201. package/dist/core/ingestion/symbol-table.js +0 -115
@@ -49,6 +49,7 @@ export declare const batchInsertNodesToLbug: (nodes: Array<{
49
49
  failed: number;
50
50
  }>;
51
51
  export declare const executeQuery: (cypher: string) => Promise<any[]>;
52
+ export declare const streamQuery: (cypher: string, onRow: (row: any) => void | Promise<void>) => Promise<number>;
52
53
  /**
53
54
  * Execute a single parameterized query (prepare/execute pattern).
54
55
  * Prevents Cypher injection by binding values as parameters.
@@ -88,6 +89,11 @@ export declare const getEmbeddingTableName: () => string;
88
89
  * Safe to call multiple times — tracks loaded state via module-level ftsLoaded.
89
90
  */
90
91
  export declare const loadFTSExtension: () => Promise<void>;
92
+ /**
93
+ * Load the VECTOR extension (required before using QUERY_VECTOR_INDEX).
94
+ * Safe to call multiple times -- tracks loaded state via module-level vectorExtensionLoaded.
95
+ */
96
+ export declare const loadVectorExtension: () => Promise<void>;
91
97
  /**
92
98
  * Create a full-text search index on a table
93
99
  * @param tableName - The node table name (e.g., 'File', 'CodeSymbol')
@@ -9,6 +9,7 @@ let db = null;
9
9
  let conn = null;
10
10
  let currentDbPath = null;
11
11
  let ftsLoaded = false;
12
+ let vectorExtensionLoaded = false;
12
13
  /** Expose the current Database for pool adapter reuse in tests. */
13
14
  export const getDatabase = () => db;
14
15
  // Global session lock for operations that touch module-level lbug globals.
@@ -91,6 +92,7 @@ export const withLbugDb = async (dbPath, operation) => {
91
92
  db = null;
92
93
  currentDbPath = null;
93
94
  ftsLoaded = false;
95
+ vectorExtensionLoaded = false;
94
96
  });
95
97
  // Sleep outside the lock — no need to block others while waiting
96
98
  await new Promise((resolve) => setTimeout(resolve, DB_LOCK_RETRY_DELAY_MS * attempt));
@@ -124,6 +126,7 @@ const doInitLbug = async (dbPath) => {
124
126
  db = null;
125
127
  currentDbPath = null;
126
128
  ftsLoaded = false;
129
+ vectorExtensionLoaded = false;
127
130
  }
128
131
  // LadybugDB stores the database as a single file (not a directory).
129
132
  // If the path already exists, it must be a valid LadybugDB database file.
@@ -167,6 +170,8 @@ const doInitLbug = async (dbPath) => {
167
170
  }
168
171
  }
169
172
  }
173
+ // Load VECTOR extension for semantic search support
174
+ await loadVectorExtension();
170
175
  currentDbPath = dbPath;
171
176
  return { db, conn };
172
177
  };
@@ -589,6 +594,30 @@ export const executeQuery = async (cypher) => {
589
594
  const rows = await result.getAll();
590
595
  return rows;
591
596
  };
597
+ export const streamQuery = async (cypher, onRow) => {
598
+ if (!conn) {
599
+ throw new Error('LadybugDB not initialized. Call initLbug first.');
600
+ }
601
+ const queryResult = await conn.query(cypher);
602
+ const result = Array.isArray(queryResult) ? queryResult[0] : queryResult;
603
+ let rowCount = 0;
604
+ try {
605
+ while (await result.hasNext()) {
606
+ const row = await result.getNext();
607
+ await onRow(row);
608
+ rowCount++;
609
+ }
610
+ return rowCount;
611
+ }
612
+ finally {
613
+ try {
614
+ await result.close();
615
+ }
616
+ catch {
617
+ // Best-effort cleanup only.
618
+ }
619
+ }
620
+ };
592
621
  /**
593
622
  * Execute a single parameterized query (prepare/execute pattern).
594
623
  * Prevents Cypher injection by binding values as parameters.
@@ -715,6 +744,7 @@ export const closeLbug = async () => {
715
744
  }
716
745
  currentDbPath = null;
717
746
  ftsLoaded = false;
747
+ vectorExtensionLoaded = false;
718
748
  };
719
749
  export const isLbugReady = () => conn !== null && db !== null;
720
750
  /**
@@ -803,19 +833,54 @@ export const loadFTSExtension = async () => {
803
833
  throw new Error('LadybugDB not initialized. Call initLbug first.');
804
834
  }
805
835
  try {
806
- await conn.query('INSTALL fts');
836
+ // Try loading locally first (no network required)
807
837
  await conn.query('LOAD EXTENSION fts');
808
838
  ftsLoaded = true;
809
839
  }
840
+ catch {
841
+ // Fall back to install + load (requires network)
842
+ try {
843
+ await conn.query('INSTALL fts');
844
+ await conn.query('LOAD EXTENSION fts');
845
+ ftsLoaded = true;
846
+ }
847
+ catch (err) {
848
+ const msg = err?.message || '';
849
+ if (msg.includes('already loaded') ||
850
+ msg.includes('already installed') ||
851
+ msg.includes('already exists')) {
852
+ ftsLoaded = true;
853
+ }
854
+ else {
855
+ console.error('GitNexus: FTS extension load failed:', msg);
856
+ }
857
+ }
858
+ }
859
+ };
860
+ /**
861
+ * Load the VECTOR extension (required before using QUERY_VECTOR_INDEX).
862
+ * Safe to call multiple times -- tracks loaded state via module-level vectorExtensionLoaded.
863
+ */
864
+ export const loadVectorExtension = async () => {
865
+ if (vectorExtensionLoaded)
866
+ return;
867
+ if (!conn) {
868
+ throw new Error('LadybugDB not initialized. Call initLbug first.');
869
+ }
870
+ try {
871
+ await conn.query('INSTALL VECTOR');
872
+ await conn.query('LOAD EXTENSION VECTOR');
873
+ vectorExtensionLoaded = true;
874
+ }
810
875
  catch (err) {
811
876
  const msg = err?.message || '';
812
877
  if (msg.includes('already loaded') ||
813
878
  msg.includes('already installed') ||
814
879
  msg.includes('already exists')) {
815
- ftsLoaded = true;
880
+ vectorExtensionLoaded = true;
816
881
  }
817
882
  else {
818
- console.error('GitNexus: FTS extension load failed:', msg);
883
+ console.error('GitNexus: VECTOR extension load failed:', msg);
819
884
  }
820
885
  }
821
886
  };
@@ -0,0 +1,76 @@
1
+ /**
2
+ * LadybugDB connection pool (core). Used by MCP, sync, search, wiki, etc.
3
+ *
4
+ * LadybugDB Adapter (Connection Pool)
5
+ *
6
+ * Manages a pool of LadybugDB databases keyed by repoId, each with
7
+ * multiple Connection objects for safe concurrent query execution.
8
+ *
9
+ * LadybugDB Connections are NOT thread-safe — a single Connection
10
+ * segfaults if concurrent .query() calls hit it simultaneously.
11
+ * This adapter provides a checkout/return connection pool so each
12
+ * concurrent query gets its own Connection from the same Database.
13
+ *
14
+ * @see https://docs.ladybugdb.com/concurrency — multiple Connections
15
+ * from the same Database is the officially supported concurrency pattern.
16
+ */
17
+ import lbug from '@ladybugdb/core';
18
+ /** Saved real stdout/stderr write — used to silence native module output without race conditions */
19
+ export declare const realStdoutWrite: any;
20
+ export declare const realStderrWrite: any;
21
+ /**
22
+ * Touch a repo to reset its idle timeout.
23
+ * Call this during long-running operations to prevent the connection from being closed.
24
+ */
25
+ export declare const touchRepo: (repoId: string) => void;
26
+ /**
27
+ * Silence stdout by replacing process.stdout.write with a no-op.
28
+ * Uses a reference counter so nested silence/restore pairs are safe.
29
+ * Exported so other modules (e.g. embedder) use the same mechanism instead
30
+ * of independently patching stdout, which causes restore-order conflicts.
31
+ */
32
+ export declare function silenceStdout(): void;
33
+ export declare function restoreStdout(): void;
34
+ /**
35
+ * Initialize (or reuse) a Database + connection pool for a specific repo.
36
+ * Retries on lock errors (e.g., when `gitnexus analyze` is running).
37
+ *
38
+ * Concurrent calls for the same repoId are deduplicated — the second caller
39
+ * awaits the first's in-progress init rather than starting a redundant one.
40
+ */
41
+ export declare const initLbug: (repoId: string, dbPath: string) => Promise<void>;
42
+ /**
43
+ * Initialize a pool entry from a pre-existing Database object.
44
+ *
45
+ * Used in tests to avoid the writable→close→read-only cycle that crashes
46
+ * on macOS due to N-API destructor segfaults. The pool adapter reuses
47
+ * the core adapter's writable Database instead of opening a new read-only one.
48
+ *
49
+ * The Database is registered in the shared dbCache so closeOne() decrements
50
+ * the refCount correctly. If the Database is already cached (e.g. another
51
+ * repoId already injected it), the existing entry is reused.
52
+ */
53
+ export declare function initLbugWithDb(repoId: string, existingDb: lbug.Database, dbPath: string): Promise<void>;
54
+ export declare const executeQuery: (repoId: string, cypher: string) => Promise<any[]>;
55
+ /**
56
+ * Execute a parameterized query on a specific repo's connection pool.
57
+ * Uses prepare/execute pattern to prevent Cypher injection.
58
+ */
59
+ export declare const executeParameterized: (repoId: string, cypher: string, params: Record<string, any>) => Promise<any[]>;
60
+ /**
61
+ * Close one or all repo pools.
62
+ * If repoId is provided, close only that repo's connections.
63
+ * If omitted, close all repos.
64
+ */
65
+ export declare const closeLbug: (repoId?: string) => Promise<void>;
66
+ /**
67
+ * Check if a specific repo's pool is active
68
+ */
69
+ export declare const isLbugReady: (repoId: string) => boolean;
70
+ /** Regex to detect write operations in user-supplied Cypher queries.
71
+ * Note: CALL is NOT blocked — it's used for read-only FTS (CALL QUERY_FTS_INDEX)
72
+ * and vector search (CALL QUERY_VECTOR_INDEX). The database is opened in
73
+ * read-only mode as defense-in-depth against write procedures. */
74
+ export declare const CYPHER_WRITE_RE: RegExp;
75
+ /** Check if a Cypher query contains write operations */
76
+ export declare function isWriteQuery(query: string): boolean;