gitnexus 1.4.8 → 1.4.10

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 (211) hide show
  1. package/README.md +7 -0
  2. package/dist/cli/index-repo.d.ts +15 -0
  3. package/dist/cli/index-repo.js +115 -0
  4. package/dist/cli/index.js +11 -2
  5. package/dist/cli/setup.js +12 -9
  6. package/dist/cli/wiki.d.ts +4 -0
  7. package/dist/cli/wiki.js +174 -53
  8. package/dist/config/supported-languages.d.ts +7 -5
  9. package/dist/config/supported-languages.js +6 -4
  10. package/dist/core/graph/graph.js +9 -1
  11. package/dist/core/graph/types.d.ts +10 -2
  12. package/dist/core/ingestion/call-processor.d.ts +18 -1
  13. package/dist/core/ingestion/call-processor.js +297 -38
  14. package/dist/core/ingestion/call-routing.d.ts +3 -18
  15. package/dist/core/ingestion/call-routing.js +0 -19
  16. package/dist/core/ingestion/cobol/cobol-copy-expander.d.ts +57 -0
  17. package/dist/core/ingestion/cobol/cobol-copy-expander.js +385 -0
  18. package/dist/core/ingestion/cobol/cobol-preprocessor.d.ts +210 -0
  19. package/dist/core/ingestion/cobol/cobol-preprocessor.js +1509 -0
  20. package/dist/core/ingestion/cobol/jcl-parser.d.ts +68 -0
  21. package/dist/core/ingestion/cobol/jcl-parser.js +217 -0
  22. package/dist/core/ingestion/cobol/jcl-processor.d.ts +33 -0
  23. package/dist/core/ingestion/cobol/jcl-processor.js +229 -0
  24. package/dist/core/ingestion/cobol-processor.d.ts +54 -0
  25. package/dist/core/ingestion/cobol-processor.js +1186 -0
  26. package/dist/core/ingestion/entry-point-scoring.d.ts +17 -0
  27. package/dist/core/ingestion/entry-point-scoring.js +18 -4
  28. package/dist/core/ingestion/export-detection.d.ts +47 -8
  29. package/dist/core/ingestion/export-detection.js +29 -50
  30. package/dist/core/ingestion/field-extractor.d.ts +29 -0
  31. package/dist/core/ingestion/field-extractor.js +25 -0
  32. package/dist/core/ingestion/field-extractors/configs/c-cpp.d.ts +3 -0
  33. package/dist/core/ingestion/field-extractors/configs/c-cpp.js +108 -0
  34. package/dist/core/ingestion/field-extractors/configs/csharp.d.ts +8 -0
  35. package/dist/core/ingestion/field-extractors/configs/csharp.js +73 -0
  36. package/dist/core/ingestion/field-extractors/configs/dart.d.ts +8 -0
  37. package/dist/core/ingestion/field-extractors/configs/dart.js +76 -0
  38. package/dist/core/ingestion/field-extractors/configs/go.d.ts +11 -0
  39. package/dist/core/ingestion/field-extractors/configs/go.js +64 -0
  40. package/dist/core/ingestion/field-extractors/configs/helpers.d.ts +44 -0
  41. package/dist/core/ingestion/field-extractors/configs/helpers.js +134 -0
  42. package/dist/core/ingestion/field-extractors/configs/jvm.d.ts +3 -0
  43. package/dist/core/ingestion/field-extractors/configs/jvm.js +118 -0
  44. package/dist/core/ingestion/field-extractors/configs/php.d.ts +8 -0
  45. package/dist/core/ingestion/field-extractors/configs/php.js +67 -0
  46. package/dist/core/ingestion/field-extractors/configs/python.d.ts +12 -0
  47. package/dist/core/ingestion/field-extractors/configs/python.js +91 -0
  48. package/dist/core/ingestion/field-extractors/configs/ruby.d.ts +16 -0
  49. package/dist/core/ingestion/field-extractors/configs/ruby.js +75 -0
  50. package/dist/core/ingestion/field-extractors/configs/rust.d.ts +9 -0
  51. package/dist/core/ingestion/field-extractors/configs/rust.js +55 -0
  52. package/dist/core/ingestion/field-extractors/configs/swift.d.ts +8 -0
  53. package/dist/core/ingestion/field-extractors/configs/swift.js +63 -0
  54. package/dist/core/ingestion/field-extractors/configs/typescript-javascript.d.ts +3 -0
  55. package/dist/core/ingestion/field-extractors/configs/typescript-javascript.js +60 -0
  56. package/dist/core/ingestion/field-extractors/generic.d.ts +46 -0
  57. package/dist/core/ingestion/field-extractors/generic.js +111 -0
  58. package/dist/core/ingestion/field-extractors/typescript.d.ts +77 -0
  59. package/dist/core/ingestion/field-extractors/typescript.js +291 -0
  60. package/dist/core/ingestion/field-types.d.ts +59 -0
  61. package/dist/core/ingestion/field-types.js +2 -0
  62. package/dist/core/ingestion/framework-detection.d.ts +87 -0
  63. package/dist/core/ingestion/framework-detection.js +65 -2
  64. package/dist/core/ingestion/heritage-processor.js +15 -17
  65. package/dist/core/ingestion/import-processor.d.ts +9 -10
  66. package/dist/core/ingestion/import-processor.js +59 -14
  67. package/dist/core/ingestion/{resolvers → import-resolvers}/csharp.d.ts +6 -9
  68. package/dist/core/ingestion/{resolvers → import-resolvers}/csharp.js +20 -2
  69. package/dist/core/ingestion/import-resolvers/dart.d.ts +7 -0
  70. package/dist/core/ingestion/import-resolvers/dart.js +44 -0
  71. package/dist/core/ingestion/{resolvers → import-resolvers}/go.d.ts +4 -5
  72. package/dist/core/ingestion/{resolvers → import-resolvers}/go.js +17 -0
  73. package/dist/core/ingestion/{resolvers → import-resolvers}/jvm.d.ts +9 -1
  74. package/dist/core/ingestion/{resolvers → import-resolvers}/jvm.js +56 -0
  75. package/dist/core/ingestion/{resolvers → import-resolvers}/php.d.ts +6 -10
  76. package/dist/core/ingestion/{resolvers → import-resolvers}/php.js +7 -2
  77. package/dist/core/ingestion/{resolvers → import-resolvers}/python.d.ts +9 -3
  78. package/dist/core/ingestion/{resolvers → import-resolvers}/python.js +35 -3
  79. package/dist/core/ingestion/{resolvers → import-resolvers}/ruby.d.ts +5 -2
  80. package/dist/core/ingestion/{resolvers → import-resolvers}/ruby.js +7 -2
  81. package/dist/core/ingestion/{resolvers → import-resolvers}/rust.d.ts +5 -2
  82. package/dist/core/ingestion/{resolvers → import-resolvers}/rust.js +41 -2
  83. package/dist/core/ingestion/{resolvers → import-resolvers}/standard.d.ts +15 -7
  84. package/dist/core/ingestion/{resolvers → import-resolvers}/standard.js +22 -3
  85. package/dist/core/ingestion/import-resolvers/swift.d.ts +7 -0
  86. package/dist/core/ingestion/import-resolvers/swift.js +23 -0
  87. package/dist/core/ingestion/import-resolvers/types.d.ts +44 -0
  88. package/dist/core/ingestion/import-resolvers/types.js +6 -0
  89. package/dist/core/ingestion/{resolvers → import-resolvers}/utils.d.ts +0 -3
  90. package/dist/core/ingestion/{resolvers → import-resolvers}/utils.js +0 -9
  91. package/dist/core/ingestion/language-config.d.ts +4 -1
  92. package/dist/core/ingestion/language-provider.d.ts +121 -0
  93. package/dist/core/ingestion/language-provider.js +24 -0
  94. package/dist/core/ingestion/languages/c-cpp.d.ts +12 -0
  95. package/dist/core/ingestion/languages/c-cpp.js +71 -0
  96. package/dist/core/ingestion/languages/cobol.d.ts +1 -0
  97. package/dist/core/ingestion/languages/cobol.js +26 -0
  98. package/dist/core/ingestion/languages/csharp.d.ts +8 -0
  99. package/dist/core/ingestion/languages/csharp.js +49 -0
  100. package/dist/core/ingestion/languages/dart.d.ts +12 -0
  101. package/dist/core/ingestion/languages/dart.js +58 -0
  102. package/dist/core/ingestion/languages/go.d.ts +11 -0
  103. package/dist/core/ingestion/languages/go.js +28 -0
  104. package/dist/core/ingestion/languages/index.d.ts +38 -0
  105. package/dist/core/ingestion/languages/index.js +63 -0
  106. package/dist/core/ingestion/languages/java.d.ts +9 -0
  107. package/dist/core/ingestion/languages/java.js +29 -0
  108. package/dist/core/ingestion/languages/kotlin.d.ts +9 -0
  109. package/dist/core/ingestion/languages/kotlin.js +53 -0
  110. package/dist/core/ingestion/languages/php.d.ts +8 -0
  111. package/dist/core/ingestion/languages/php.js +145 -0
  112. package/dist/core/ingestion/languages/python.d.ts +12 -0
  113. package/dist/core/ingestion/languages/python.js +39 -0
  114. package/dist/core/ingestion/languages/ruby.d.ts +9 -0
  115. package/dist/core/ingestion/languages/ruby.js +44 -0
  116. package/dist/core/ingestion/languages/rust.d.ts +12 -0
  117. package/dist/core/ingestion/languages/rust.js +44 -0
  118. package/dist/core/ingestion/languages/swift.d.ts +12 -0
  119. package/dist/core/ingestion/languages/swift.js +133 -0
  120. package/dist/core/ingestion/languages/typescript.d.ts +10 -0
  121. package/dist/core/ingestion/languages/typescript.js +60 -0
  122. package/dist/core/ingestion/mro-processor.js +14 -15
  123. package/dist/core/ingestion/{named-binding-extraction.d.ts → named-binding-processor.d.ts} +0 -9
  124. package/dist/core/ingestion/named-binding-processor.js +42 -0
  125. package/dist/core/ingestion/named-bindings/csharp.d.ts +3 -0
  126. package/dist/core/ingestion/named-bindings/csharp.js +37 -0
  127. package/dist/core/ingestion/named-bindings/java.d.ts +3 -0
  128. package/dist/core/ingestion/named-bindings/java.js +29 -0
  129. package/dist/core/ingestion/named-bindings/kotlin.d.ts +3 -0
  130. package/dist/core/ingestion/named-bindings/kotlin.js +36 -0
  131. package/dist/core/ingestion/named-bindings/php.d.ts +3 -0
  132. package/dist/core/ingestion/named-bindings/php.js +61 -0
  133. package/dist/core/ingestion/named-bindings/python.d.ts +3 -0
  134. package/dist/core/ingestion/named-bindings/python.js +49 -0
  135. package/dist/core/ingestion/named-bindings/rust.d.ts +3 -0
  136. package/dist/core/ingestion/named-bindings/rust.js +64 -0
  137. package/dist/core/ingestion/named-bindings/types.d.ts +16 -0
  138. package/dist/core/ingestion/named-bindings/types.js +6 -0
  139. package/dist/core/ingestion/named-bindings/typescript.d.ts +3 -0
  140. package/dist/core/ingestion/named-bindings/typescript.js +58 -0
  141. package/dist/core/ingestion/parsing-processor.d.ts +5 -1
  142. package/dist/core/ingestion/parsing-processor.js +115 -16
  143. package/dist/core/ingestion/pipeline.js +925 -424
  144. package/dist/core/ingestion/resolution-context.js +1 -1
  145. package/dist/core/ingestion/route-extractors/expo.d.ts +1 -0
  146. package/dist/core/ingestion/route-extractors/expo.js +36 -0
  147. package/dist/core/ingestion/route-extractors/middleware.d.ts +47 -0
  148. package/dist/core/ingestion/route-extractors/middleware.js +143 -0
  149. package/dist/core/ingestion/route-extractors/nextjs.d.ts +3 -0
  150. package/dist/core/ingestion/route-extractors/nextjs.js +76 -0
  151. package/dist/core/ingestion/route-extractors/php.d.ts +7 -0
  152. package/dist/core/ingestion/route-extractors/php.js +21 -0
  153. package/dist/core/ingestion/route-extractors/response-shapes.d.ts +20 -0
  154. package/dist/core/ingestion/route-extractors/response-shapes.js +290 -0
  155. package/dist/core/ingestion/tree-sitter-queries.d.ts +8 -7
  156. package/dist/core/ingestion/tree-sitter-queries.js +231 -9
  157. package/dist/core/ingestion/type-env.d.ts +14 -17
  158. package/dist/core/ingestion/type-env.js +66 -14
  159. package/dist/core/ingestion/type-extractors/c-cpp.d.ts +1 -1
  160. package/dist/core/ingestion/type-extractors/csharp.js +1 -1
  161. package/dist/core/ingestion/type-extractors/dart.d.ts +15 -0
  162. package/dist/core/ingestion/type-extractors/dart.js +371 -0
  163. package/dist/core/ingestion/type-extractors/jvm.js +1 -1
  164. package/dist/core/ingestion/type-extractors/shared.d.ts +1 -13
  165. package/dist/core/ingestion/type-extractors/shared.js +9 -102
  166. package/dist/core/ingestion/type-extractors/swift.js +334 -4
  167. package/dist/core/ingestion/type-extractors/types.d.ts +3 -1
  168. package/dist/core/ingestion/{ast-helpers.d.ts → utils/ast-helpers.d.ts} +16 -13
  169. package/dist/core/ingestion/{ast-helpers.js → utils/ast-helpers.js} +111 -32
  170. package/dist/core/ingestion/{call-analysis.js → utils/call-analysis.js} +37 -0
  171. package/dist/core/ingestion/utils/event-loop.d.ts +5 -0
  172. package/dist/core/ingestion/utils/event-loop.js +5 -0
  173. package/dist/core/ingestion/utils/language-detection.d.ts +9 -0
  174. package/dist/core/ingestion/utils/language-detection.js +70 -0
  175. package/dist/core/ingestion/utils/verbose.d.ts +1 -0
  176. package/dist/core/ingestion/utils/verbose.js +7 -0
  177. package/dist/core/ingestion/workers/parse-worker.d.ts +43 -2
  178. package/dist/core/ingestion/workers/parse-worker.js +361 -150
  179. package/dist/core/lbug/csv-generator.js +34 -1
  180. package/dist/core/lbug/lbug-adapter.js +6 -0
  181. package/dist/core/lbug/schema.d.ts +5 -3
  182. package/dist/core/lbug/schema.js +39 -2
  183. package/dist/core/tree-sitter/parser-loader.js +7 -1
  184. package/dist/core/wiki/cursor-client.d.ts +31 -0
  185. package/dist/core/wiki/cursor-client.js +127 -0
  186. package/dist/core/wiki/generator.d.ts +28 -9
  187. package/dist/core/wiki/generator.js +115 -18
  188. package/dist/core/wiki/graph-queries.d.ts +4 -0
  189. package/dist/core/wiki/graph-queries.js +7 -1
  190. package/dist/core/wiki/llm-client.d.ts +2 -0
  191. package/dist/core/wiki/llm-client.js +8 -4
  192. package/dist/core/wiki/prompts.d.ts +3 -3
  193. package/dist/core/wiki/prompts.js +6 -0
  194. package/dist/mcp/core/lbug-adapter.d.ts +5 -0
  195. package/dist/mcp/core/lbug-adapter.js +11 -1
  196. package/dist/mcp/local/local-backend.d.ts +16 -5
  197. package/dist/mcp/local/local-backend.js +711 -74
  198. package/dist/mcp/tools.js +71 -2
  199. package/dist/storage/repo-manager.d.ts +3 -0
  200. package/package.json +14 -14
  201. package/dist/core/ingestion/import-resolution.d.ts +0 -101
  202. package/dist/core/ingestion/import-resolution.js +0 -251
  203. package/dist/core/ingestion/named-binding-extraction.js +0 -373
  204. package/dist/core/ingestion/resolvers/index.d.ts +0 -18
  205. package/dist/core/ingestion/resolvers/index.js +0 -13
  206. package/dist/core/ingestion/type-extractors/index.d.ts +0 -22
  207. package/dist/core/ingestion/type-extractors/index.js +0 -31
  208. package/dist/core/ingestion/utils.d.ts +0 -20
  209. package/dist/core/ingestion/utils.js +0 -242
  210. package/scripts/patch-tree-sitter-swift.cjs +0 -74
  211. /package/dist/core/ingestion/{call-analysis.d.ts → utils/call-analysis.d.ts} +0 -0
package/dist/mcp/tools.js CHANGED
@@ -58,10 +58,10 @@ WHEN TO USE: Complex structural queries that search/explore can't answer. READ g
58
58
  AFTER THIS: Use context() on result symbols for deeper context.
59
59
 
60
60
  SCHEMA:
61
- - Nodes: File, Folder, Function, Class, Interface, Method, CodeElement, Community, Process
61
+ - Nodes: File, Folder, Function, Class, Interface, Method, CodeElement, Community, Process, Route, Tool
62
62
  - Multi-language nodes (use backticks): \`Struct\`, \`Enum\`, \`Trait\`, \`Impl\`, etc.
63
63
  - All edges via single CodeRelation table with 'type' property
64
- - Edge types: CONTAINS, DEFINES, CALLS, IMPORTS, EXTENDS, IMPLEMENTS, HAS_METHOD, HAS_PROPERTY, ACCESSES, OVERRIDES, MEMBER_OF, STEP_IN_PROCESS
64
+ - Edge types: CONTAINS, DEFINES, CALLS, IMPORTS, EXTENDS, IMPLEMENTS, HAS_METHOD, HAS_PROPERTY, ACCESSES, OVERRIDES, MEMBER_OF, STEP_IN_PROCESS, HANDLES_ROUTE, FETCHES, HANDLES_TOOL, ENTRY_POINT_OF
65
65
  - Edge properties: type (STRING), confidence (DOUBLE), reason (STRING), step (INT32)
66
66
 
67
67
  EXAMPLES:
@@ -209,4 +209,73 @@ Confidence: 1.0 = certain, <0.8 = fuzzy match`,
209
209
  required: ['target', 'direction'],
210
210
  },
211
211
  },
212
+ {
213
+ name: 'route_map',
214
+ description: `Show API route mappings: which components/hooks fetch which API endpoints, and which handler files serve them.
215
+
216
+ WHEN TO USE: Understanding API consumption patterns, finding orphaned routes. For pre-change analysis, prefer \`api_impact\` which combines this data with mismatch detection and risk assessment.
217
+ AFTER THIS: Use impact() on specific route handlers to see full blast radius.
218
+
219
+ Returns: route nodes with their handlers, middleware wrapper chains (e.g., withAuth, withRateLimit), and consumers.`,
220
+ inputSchema: {
221
+ type: 'object',
222
+ properties: {
223
+ route: { type: 'string', description: 'Filter by route path (e.g., "/api/grants"). Omit for all routes.' },
224
+ repo: { type: 'string', description: 'Repository name or path. Omit if only one repo is indexed.' },
225
+ },
226
+ required: [],
227
+ },
228
+ },
229
+ {
230
+ name: 'tool_map',
231
+ description: `Show MCP/RPC tool definitions: which tools are defined, where they're handled, and their descriptions.
232
+
233
+ WHEN TO USE: Understanding tool APIs, finding tool implementations, impact analysis for tool changes.
234
+
235
+ Returns: tool nodes with their handler files and descriptions.`,
236
+ inputSchema: {
237
+ type: 'object',
238
+ properties: {
239
+ tool: { type: 'string', description: 'Filter by tool name. Omit for all tools.' },
240
+ repo: { type: 'string', description: 'Repository name or path.' },
241
+ },
242
+ required: [],
243
+ },
244
+ },
245
+ {
246
+ name: 'shape_check',
247
+ description: `Check response shapes for API routes against their consumers' property accesses.
248
+
249
+ WHEN TO USE: Detecting mismatches between what an API route returns and what consumers expect. Finding shape drift. For pre-change analysis, prefer \`api_impact\` which combines this data with mismatch detection and risk assessment.
250
+ REQUIRES: Route nodes with responseKeys (extracted from .json({...}) calls during indexing).
251
+
252
+ Returns routes that have both detected response keys AND consumers. Shows top-level keys each endpoint returns (e.g., data, pagination, error) and what keys each consumer accesses. Reports MISMATCH status when a consumer accesses keys not present in the route's response shape.`,
253
+ inputSchema: {
254
+ type: 'object',
255
+ properties: {
256
+ route: { type: 'string', description: 'Check a specific route (e.g., "/api/grants"). Omit to check all routes.' },
257
+ repo: { type: 'string', description: 'Repository name or path. Omit if only one repo is indexed.' },
258
+ },
259
+ required: [],
260
+ },
261
+ },
262
+ {
263
+ name: 'api_impact',
264
+ description: `Pre-change impact report for an API route handler.
265
+
266
+ WHEN TO USE: BEFORE modifying any API route handler. Shows what consumers depend on, what response fields they access, what middleware protects the route, and what execution flows it triggers. Requires at least "route" or "file" parameter.
267
+
268
+ Risk levels: LOW (0-3 consumers), MEDIUM (4-9 or any mismatches), HIGH (10+ consumers or mismatches with 4+ consumers). Mismatches with confidence "low" indicate the consumer file fetches multiple routes — property attribution is approximate.
269
+
270
+ Returns: single route object when one match, or { routes: [...], total: N } for multiple matches. Combines route_map, shape_check, and impact data.`,
271
+ inputSchema: {
272
+ type: 'object',
273
+ properties: {
274
+ route: { type: 'string', description: 'Route path (e.g., "/api/grants")' },
275
+ file: { type: 'string', description: 'Handler file path (alternative to route)' },
276
+ repo: { type: 'string', description: 'Repository name or path.' },
277
+ },
278
+ required: [],
279
+ },
280
+ },
212
281
  ];
@@ -119,10 +119,13 @@ export declare const unregisterRepo: (repoPath: string) => Promise<void>;
119
119
  export declare const listRegisteredRepos: (opts?: {
120
120
  validate?: boolean;
121
121
  }) => Promise<RegistryEntry[]>;
122
+ export type LLMProvider = 'openai' | 'cursor';
122
123
  export interface CLIConfig {
123
124
  apiKey?: string;
124
125
  model?: string;
125
126
  baseUrl?: string;
127
+ provider?: LLMProvider;
128
+ cursorModel?: string;
126
129
  }
127
130
  /**
128
131
  * Get the path to the global CLI config file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gitnexus",
3
- "version": "1.4.8",
3
+ "version": "1.4.10",
4
4
  "description": "Graph-powered code intelligence for AI agents. Index any codebase, query via MCP or CLI.",
5
5
  "author": "Abhigyan Patwari",
6
6
  "license": "PolyForm-Noncommercial-1.0.0",
@@ -46,7 +46,6 @@
46
46
  "test:watch": "vitest",
47
47
  "test:coverage": "vitest run --coverage",
48
48
  "prepare": "npm run build",
49
- "postinstall": "node scripts/patch-tree-sitter-swift.cjs",
50
49
  "prepack": "npm run build && chmod +x dist/cli/index.js"
51
50
  },
52
51
  "dependencies": {
@@ -66,21 +65,22 @@
66
65
  "mnemonist": "^0.39.0",
67
66
  "onnxruntime-node": "^1.24.0",
68
67
  "pandemonium": "^2.4.0",
69
- "tree-sitter": "^0.21.0",
70
- "tree-sitter-c": "^0.21.0",
71
- "tree-sitter-c-sharp": "^0.21.0",
72
- "tree-sitter-cpp": "^0.22.0",
73
- "tree-sitter-go": "^0.21.0",
74
- "tree-sitter-java": "^0.21.0",
75
- "tree-sitter-javascript": "^0.21.0",
76
- "tree-sitter-php": "^0.23.12",
77
- "tree-sitter-python": "^0.21.0",
68
+ "tree-sitter": "^0.21.1",
69
+ "tree-sitter-c": "0.23.2",
70
+ "tree-sitter-c-sharp": "^0.23.1",
71
+ "tree-sitter-cpp": "^0.23.4",
72
+ "tree-sitter-go": "^0.23.0",
73
+ "tree-sitter-java": "^0.23.5",
74
+ "tree-sitter-javascript": "^0.23.0",
75
+ "tree-sitter-php": "^0.23.0",
76
+ "tree-sitter-python": "0.23.4",
78
77
  "tree-sitter-ruby": "^0.23.1",
79
- "tree-sitter-rust": "^0.21.0",
80
- "tree-sitter-typescript": "^0.21.0",
78
+ "tree-sitter-rust": "0.23.1",
79
+ "tree-sitter-typescript": "^0.23.2",
81
80
  "uuid": "^13.0.0"
82
81
  },
83
82
  "optionalDependencies": {
83
+ "tree-sitter-dart": "github:UserNobody14/tree-sitter-dart#80e23c07b64494f7e21090bb3450223ef0b192f4",
84
84
  "tree-sitter-kotlin": "^0.3.8",
85
85
  "tree-sitter-swift": "^0.6.0"
86
86
  },
@@ -102,6 +102,6 @@
102
102
  }
103
103
  },
104
104
  "engines": {
105
- "node": ">=18.0.0"
105
+ "node": ">=20.0.0"
106
106
  }
107
107
  }
@@ -1,101 +0,0 @@
1
- /**
2
- * Import Resolution Dispatch
3
- *
4
- * Per-language dispatch table for import resolution and named binding extraction.
5
- * Replaces the 120-line if-chain in resolveLanguageImport() and the 7-branch
6
- * dispatch in extractNamedBindings() with a single table lookup each.
7
- *
8
- * Follows the existing ExportChecker / CallRouter pattern:
9
- * - Function aliases (not interfaces) to avoid megamorphic inline-cache issues
10
- * - `satisfies Record<SupportedLanguages, ...>` for compile-time exhaustiveness
11
- * - Const dispatch table — configs are accessed via ctx.configs at call time
12
- */
13
- import { SupportedLanguages } from '../../config/supported-languages.js';
14
- import type { SyntaxNode } from './utils.js';
15
- import type { TsconfigPaths, GoModuleConfig, CSharpProjectConfig, ComposerConfig } from './resolvers/index.js';
16
- import type { SwiftPackageConfig } from './language-config.js';
17
- import { extractTsNamedBindings, extractPythonNamedBindings, extractKotlinNamedBindings, extractRustNamedBindings, extractPhpNamedBindings, extractCsharpNamedBindings, extractJavaNamedBindings } from './named-binding-extraction.js';
18
- import type { ImportResolutionContext } from './import-processor.js';
19
- /**
20
- * Result of resolving an import via language-specific dispatch.
21
- * - 'files': resolved to one or more files -> add to ImportMap
22
- * - 'package': resolved to a directory -> add graph edges + store dirSuffix in PackageMap
23
- * - null: no resolution (external dependency, etc.)
24
- */
25
- export type ImportResult = {
26
- kind: 'files';
27
- files: string[];
28
- } | {
29
- kind: 'package';
30
- files: string[];
31
- dirSuffix: string;
32
- } | null;
33
- /** Bundled language-specific configs loaded once per ingestion run. */
34
- export interface ImportConfigs {
35
- tsconfigPaths: TsconfigPaths | null;
36
- goModule: GoModuleConfig | null;
37
- composerConfig: ComposerConfig | null;
38
- swiftPackageConfig: SwiftPackageConfig | null;
39
- csharpConfigs: CSharpProjectConfig[];
40
- }
41
- /** Full context for import resolution: file lookups + language configs. */
42
- export interface ResolveCtx extends ImportResolutionContext {
43
- configs: ImportConfigs;
44
- }
45
- /** Per-language import resolver -- function alias matching ExportChecker/CallRouter pattern. */
46
- export type ImportResolverFn = (rawImportPath: string, filePath: string, resolveCtx: ResolveCtx) => ImportResult;
47
- /** A single named import binding: local name in the importing file and exported name from the source.
48
- * When `isModuleAlias` is true, the binding represents a Python `import X as Y` module alias
49
- * and is routed to moduleAliasMap instead of namedImportMap during import processing. */
50
- export interface NamedBinding {
51
- local: string;
52
- exported: string;
53
- isModuleAlias?: boolean;
54
- }
55
- /**
56
- * Clean and preprocess a raw import source text into a resolved import path.
57
- * Strips quotes/angle brackets (universal) and applies language-specific
58
- * transformations (currently only Kotlin wildcard import detection).
59
- */
60
- export declare function preprocessImportPath(sourceText: string, importNode: SyntaxNode, language: SupportedLanguages): string | null;
61
- /**
62
- * Per-language import resolver dispatch table.
63
- * Configs are accessed via ctx.configs at call time — no factory closure needed.
64
- * Each resolver encapsulates the full resolution flow for its language, including
65
- * fallthrough to standard resolution where appropriate.
66
- */
67
- export declare const importResolvers: {
68
- javascript: (raw: string, fp: string, ctx: ResolveCtx) => ImportResult;
69
- typescript: (raw: string, fp: string, ctx: ResolveCtx) => ImportResult;
70
- python: (raw: string, fp: string, ctx: ResolveCtx) => ImportResult;
71
- java: (raw: string, fp: string, ctx: ResolveCtx) => ImportResult;
72
- c: (raw: string, fp: string, ctx: ResolveCtx) => ImportResult;
73
- cpp: (raw: string, fp: string, ctx: ResolveCtx) => ImportResult;
74
- csharp: (raw: string, fp: string, ctx: ResolveCtx) => ImportResult;
75
- go: (raw: string, fp: string, ctx: ResolveCtx) => ImportResult;
76
- ruby: (raw: string, fp: string, ctx: ResolveCtx) => ImportResult;
77
- rust: (raw: string, fp: string, ctx: ResolveCtx) => ImportResult;
78
- php: (raw: string, fp: string, ctx: ResolveCtx) => ImportResult;
79
- kotlin: (raw: string, fp: string, ctx: ResolveCtx) => ImportResult;
80
- swift: (raw: string, fp: string, ctx: ResolveCtx) => ImportResult;
81
- };
82
- /**
83
- * Per-language named binding extractor dispatch table.
84
- * Languages with whole-module import semantics (Go, Ruby, C/C++, Swift) return undefined --
85
- * their bindings are synthesized post-parse by synthesizeWildcardImportBindings() in pipeline.ts.
86
- */
87
- export declare const namedBindingExtractors: {
88
- javascript: typeof extractTsNamedBindings;
89
- typescript: typeof extractTsNamedBindings;
90
- python: typeof extractPythonNamedBindings;
91
- java: typeof extractJavaNamedBindings;
92
- c: any;
93
- cpp: any;
94
- csharp: typeof extractCsharpNamedBindings;
95
- go: any;
96
- ruby: any;
97
- rust: typeof extractRustNamedBindings;
98
- php: typeof extractPhpNamedBindings;
99
- kotlin: typeof extractKotlinNamedBindings;
100
- swift: any;
101
- };
@@ -1,251 +0,0 @@
1
- /**
2
- * Import Resolution Dispatch
3
- *
4
- * Per-language dispatch table for import resolution and named binding extraction.
5
- * Replaces the 120-line if-chain in resolveLanguageImport() and the 7-branch
6
- * dispatch in extractNamedBindings() with a single table lookup each.
7
- *
8
- * Follows the existing ExportChecker / CallRouter pattern:
9
- * - Function aliases (not interfaces) to avoid megamorphic inline-cache issues
10
- * - `satisfies Record<SupportedLanguages, ...>` for compile-time exhaustiveness
11
- * - Const dispatch table — configs are accessed via ctx.configs at call time
12
- */
13
- import { SupportedLanguages } from '../../config/supported-languages.js';
14
- import { KOTLIN_EXTENSIONS, appendKotlinWildcard, resolveJvmWildcard, resolveJvmMemberImport, resolveGoPackageDir, resolveGoPackage, resolveCSharpImport as resolveCSharpImportHelper, resolveCSharpNamespaceDir, resolvePhpImport as resolvePhpImportHelper, resolveRustImport as resolveRustImportHelper, resolveRubyImport as resolveRubyImportHelper, resolvePythonImport as resolvePythonImportHelper, resolveImportPath, } from './resolvers/index.js';
15
- import { extractTsNamedBindings, extractPythonNamedBindings, extractKotlinNamedBindings, extractRustNamedBindings, extractPhpNamedBindings, extractCsharpNamedBindings, extractJavaNamedBindings, } from './named-binding-extraction.js';
16
- // ============================================================================
17
- // Import path preprocessing
18
- // ============================================================================
19
- /**
20
- * Clean and preprocess a raw import source text into a resolved import path.
21
- * Strips quotes/angle brackets (universal) and applies language-specific
22
- * transformations (currently only Kotlin wildcard import detection).
23
- */
24
- export function preprocessImportPath(sourceText, importNode, language) {
25
- const cleaned = sourceText.replace(/['"<>]/g, '');
26
- // Defense-in-depth: reject null bytes and control characters (matches Ruby call-routing pattern)
27
- if (!cleaned || cleaned.length > 2048 || /[\x00-\x1f]/.test(cleaned))
28
- return null;
29
- if (language === SupportedLanguages.Kotlin) {
30
- return appendKotlinWildcard(cleaned, importNode);
31
- }
32
- return cleaned;
33
- }
34
- // ============================================================================
35
- // Per-language resolver functions
36
- // ============================================================================
37
- /**
38
- * Standard single-file resolution (TS/JS/C/C++ and fallback for other languages).
39
- * Handles relative imports, tsconfig path aliases, and suffix matching.
40
- */
41
- function resolveStandard(rawImportPath, filePath, ctx, language) {
42
- const resolvedPath = resolveImportPath(filePath, rawImportPath, ctx.allFilePaths, ctx.allFileList, ctx.normalizedFileList, ctx.resolveCache, language, ctx.configs.tsconfigPaths, ctx.index);
43
- return resolvedPath ? { kind: 'files', files: [resolvedPath] } : null;
44
- }
45
- /** Java: JVM wildcard -> member import -> standard fallthrough */
46
- function resolveJavaImport(rawImportPath, filePath, ctx) {
47
- if (rawImportPath.endsWith('.*')) {
48
- const matchedFiles = resolveJvmWildcard(rawImportPath, ctx.normalizedFileList, ctx.allFileList, ['.java'], ctx.index);
49
- if (matchedFiles.length > 0)
50
- return { kind: 'files', files: matchedFiles };
51
- }
52
- else {
53
- const memberResolved = resolveJvmMemberImport(rawImportPath, ctx.normalizedFileList, ctx.allFileList, ['.java'], ctx.index);
54
- if (memberResolved)
55
- return { kind: 'files', files: [memberResolved] };
56
- }
57
- return resolveStandard(rawImportPath, filePath, ctx, SupportedLanguages.Java);
58
- }
59
- /**
60
- * Kotlin: JVM wildcard/member with Java-interop fallback -> top-level function imports -> standard.
61
- * Kotlin can import from .kt/.kts files OR from .java files (Java interop).
62
- */
63
- function resolveKotlinImport(rawImportPath, filePath, ctx) {
64
- if (rawImportPath.endsWith('.*')) {
65
- const matchedFiles = resolveJvmWildcard(rawImportPath, ctx.normalizedFileList, ctx.allFileList, KOTLIN_EXTENSIONS, ctx.index);
66
- if (matchedFiles.length === 0) {
67
- const javaMatches = resolveJvmWildcard(rawImportPath, ctx.normalizedFileList, ctx.allFileList, ['.java'], ctx.index);
68
- if (javaMatches.length > 0)
69
- return { kind: 'files', files: javaMatches };
70
- }
71
- if (matchedFiles.length > 0)
72
- return { kind: 'files', files: matchedFiles };
73
- }
74
- else {
75
- let memberResolved = resolveJvmMemberImport(rawImportPath, ctx.normalizedFileList, ctx.allFileList, KOTLIN_EXTENSIONS, ctx.index);
76
- if (!memberResolved) {
77
- memberResolved = resolveJvmMemberImport(rawImportPath, ctx.normalizedFileList, ctx.allFileList, ['.java'], ctx.index);
78
- }
79
- if (memberResolved)
80
- return { kind: 'files', files: [memberResolved] };
81
- // Kotlin: top-level function imports (e.g. import models.getUser) have only 2 segments,
82
- // which resolveJvmMemberImport skips (requires >=3). Fall back to package-directory scan
83
- // for lowercase last segments (function/property imports). Uppercase last segments
84
- // (class imports like models.User) fall through to standard suffix resolution.
85
- const segments = rawImportPath.split('.');
86
- const lastSeg = segments[segments.length - 1];
87
- if (segments.length >= 2 && lastSeg[0] && lastSeg[0] === lastSeg[0].toLowerCase()) {
88
- const pkgWildcard = segments.slice(0, -1).join('.') + '.*';
89
- let dirFiles = resolveJvmWildcard(pkgWildcard, ctx.normalizedFileList, ctx.allFileList, KOTLIN_EXTENSIONS, ctx.index);
90
- if (dirFiles.length === 0) {
91
- dirFiles = resolveJvmWildcard(pkgWildcard, ctx.normalizedFileList, ctx.allFileList, ['.java'], ctx.index);
92
- }
93
- if (dirFiles.length > 0)
94
- return { kind: 'files', files: dirFiles };
95
- }
96
- }
97
- return resolveStandard(rawImportPath, filePath, ctx, SupportedLanguages.Kotlin);
98
- }
99
- /** Go: package-level imports via go.mod module path. */
100
- function resolveGoImport(rawImportPath, filePath, ctx) {
101
- const goModule = ctx.configs.goModule;
102
- if (goModule && rawImportPath.startsWith(goModule.modulePath)) {
103
- const pkgSuffix = resolveGoPackageDir(rawImportPath, goModule);
104
- if (pkgSuffix) {
105
- const pkgFiles = resolveGoPackage(rawImportPath, goModule, ctx.normalizedFileList, ctx.allFileList);
106
- if (pkgFiles.length > 0) {
107
- return { kind: 'package', files: pkgFiles, dirSuffix: pkgSuffix };
108
- }
109
- }
110
- // Fall through if no files found (package might be external)
111
- }
112
- return resolveStandard(rawImportPath, filePath, ctx, SupportedLanguages.Go);
113
- }
114
- /** C#: namespace-based resolution via .csproj configs, with suffix-match fallback. */
115
- function resolveCSharpImportDispatch(rawImportPath, filePath, ctx) {
116
- const csharpConfigs = ctx.configs.csharpConfigs;
117
- if (csharpConfigs.length > 0) {
118
- const resolvedFiles = resolveCSharpImportHelper(rawImportPath, csharpConfigs, ctx.normalizedFileList, ctx.allFileList, ctx.index);
119
- if (resolvedFiles.length > 1) {
120
- const dirSuffix = resolveCSharpNamespaceDir(rawImportPath, csharpConfigs);
121
- if (dirSuffix) {
122
- return { kind: 'package', files: resolvedFiles, dirSuffix };
123
- }
124
- }
125
- if (resolvedFiles.length > 0)
126
- return { kind: 'files', files: resolvedFiles };
127
- }
128
- return resolveStandard(rawImportPath, filePath, ctx, SupportedLanguages.CSharp);
129
- }
130
- /** PHP: namespace-based resolution via composer.json PSR-4. */
131
- function resolvePhpImportDispatch(rawImportPath, _filePath, ctx) {
132
- const resolved = resolvePhpImportHelper(rawImportPath, ctx.configs.composerConfig, ctx.allFilePaths, ctx.normalizedFileList, ctx.allFileList, ctx.index);
133
- return resolved ? { kind: 'files', files: [resolved] } : null;
134
- }
135
- /** Swift: module imports via Package.swift target map. */
136
- function resolveSwiftImportDispatch(rawImportPath, _filePath, ctx) {
137
- const swiftPackageConfig = ctx.configs.swiftPackageConfig;
138
- if (swiftPackageConfig) {
139
- const targetDir = swiftPackageConfig.targets.get(rawImportPath);
140
- if (targetDir) {
141
- const dirPrefix = targetDir + '/';
142
- const files = [];
143
- for (let i = 0; i < ctx.normalizedFileList.length; i++) {
144
- if (ctx.normalizedFileList[i].startsWith(dirPrefix) && ctx.normalizedFileList[i].endsWith('.swift')) {
145
- files.push(ctx.allFileList[i]);
146
- }
147
- }
148
- if (files.length > 0)
149
- return { kind: 'files', files };
150
- }
151
- }
152
- return null; // External framework (Foundation, UIKit, etc.)
153
- }
154
- /**
155
- * Python: relative imports (PEP 328) + proximity-based bare imports.
156
- * Falls through to standard suffix resolution when proximity finds no match.
157
- */
158
- function resolvePythonImportDispatch(rawImportPath, filePath, ctx) {
159
- const resolved = resolvePythonImportHelper(filePath, rawImportPath, ctx.allFilePaths);
160
- if (resolved)
161
- return { kind: 'files', files: [resolved] };
162
- if (rawImportPath.startsWith('.'))
163
- return null; // relative but unresolved -- don't suffix-match
164
- return resolveStandard(rawImportPath, filePath, ctx, SupportedLanguages.Python);
165
- }
166
- /** Ruby: require / require_relative. */
167
- function resolveRubyImportDispatch(rawImportPath, _filePath, ctx) {
168
- const resolved = resolveRubyImportHelper(rawImportPath, ctx.normalizedFileList, ctx.allFileList, ctx.index);
169
- return resolved ? { kind: 'files', files: [resolved] } : null;
170
- }
171
- /** Rust: expand grouped imports: use {crate::a, crate::b} and use crate::models::{User, Repo}. */
172
- function resolveRustImportDispatch(rawImportPath, filePath, ctx) {
173
- // Top-level grouped: use {crate::a, crate::b}
174
- if (rawImportPath.startsWith('{') && rawImportPath.endsWith('}')) {
175
- const inner = rawImportPath.slice(1, -1);
176
- const parts = inner.split(',').map(p => p.trim()).filter(Boolean);
177
- const resolved = [];
178
- for (const part of parts) {
179
- const r = resolveRustImportHelper(filePath, part, ctx.allFilePaths);
180
- if (r)
181
- resolved.push(r);
182
- }
183
- return resolved.length > 0 ? { kind: 'files', files: resolved } : null;
184
- }
185
- // Scoped grouped: use crate::models::{User, Repo}
186
- const braceIdx = rawImportPath.indexOf('::{');
187
- if (braceIdx !== -1 && rawImportPath.endsWith('}')) {
188
- const pathPrefix = rawImportPath.substring(0, braceIdx);
189
- const braceContent = rawImportPath.substring(braceIdx + 3, rawImportPath.length - 1);
190
- const items = braceContent.split(',').map(s => s.trim()).filter(Boolean);
191
- const resolved = [];
192
- for (const item of items) {
193
- // Handle `use crate::models::{User, Repo as R}` — strip alias for resolution
194
- const itemName = item.includes(' as ') ? item.split(' as ')[0].trim() : item;
195
- const r = resolveRustImportHelper(filePath, `${pathPrefix}::${itemName}`, ctx.allFilePaths);
196
- if (r)
197
- resolved.push(r);
198
- }
199
- if (resolved.length > 0)
200
- return { kind: 'files', files: resolved };
201
- // Fallback: resolve the prefix path itself (e.g. crate::models -> models.rs)
202
- const prefixResult = resolveRustImportHelper(filePath, pathPrefix, ctx.allFilePaths);
203
- if (prefixResult)
204
- return { kind: 'files', files: [prefixResult] };
205
- }
206
- return resolveStandard(rawImportPath, filePath, ctx, SupportedLanguages.Rust);
207
- }
208
- // ============================================================================
209
- // Dispatch tables
210
- // ============================================================================
211
- /**
212
- * Per-language import resolver dispatch table.
213
- * Configs are accessed via ctx.configs at call time — no factory closure needed.
214
- * Each resolver encapsulates the full resolution flow for its language, including
215
- * fallthrough to standard resolution where appropriate.
216
- */
217
- export const importResolvers = {
218
- [SupportedLanguages.JavaScript]: (raw, fp, ctx) => resolveStandard(raw, fp, ctx, SupportedLanguages.JavaScript),
219
- [SupportedLanguages.TypeScript]: (raw, fp, ctx) => resolveStandard(raw, fp, ctx, SupportedLanguages.TypeScript),
220
- [SupportedLanguages.Python]: (raw, fp, ctx) => resolvePythonImportDispatch(raw, fp, ctx),
221
- [SupportedLanguages.Java]: (raw, fp, ctx) => resolveJavaImport(raw, fp, ctx),
222
- [SupportedLanguages.C]: (raw, fp, ctx) => resolveStandard(raw, fp, ctx, SupportedLanguages.C),
223
- [SupportedLanguages.CPlusPlus]: (raw, fp, ctx) => resolveStandard(raw, fp, ctx, SupportedLanguages.CPlusPlus),
224
- [SupportedLanguages.CSharp]: (raw, fp, ctx) => resolveCSharpImportDispatch(raw, fp, ctx),
225
- [SupportedLanguages.Go]: (raw, fp, ctx) => resolveGoImport(raw, fp, ctx),
226
- [SupportedLanguages.Ruby]: (raw, fp, ctx) => resolveRubyImportDispatch(raw, fp, ctx),
227
- [SupportedLanguages.Rust]: (raw, fp, ctx) => resolveRustImportDispatch(raw, fp, ctx),
228
- [SupportedLanguages.PHP]: (raw, fp, ctx) => resolvePhpImportDispatch(raw, fp, ctx),
229
- [SupportedLanguages.Kotlin]: (raw, fp, ctx) => resolveKotlinImport(raw, fp, ctx),
230
- [SupportedLanguages.Swift]: (raw, fp, ctx) => resolveSwiftImportDispatch(raw, fp, ctx),
231
- };
232
- /**
233
- * Per-language named binding extractor dispatch table.
234
- * Languages with whole-module import semantics (Go, Ruby, C/C++, Swift) return undefined --
235
- * their bindings are synthesized post-parse by synthesizeWildcardImportBindings() in pipeline.ts.
236
- */
237
- export const namedBindingExtractors = {
238
- [SupportedLanguages.JavaScript]: extractTsNamedBindings,
239
- [SupportedLanguages.TypeScript]: extractTsNamedBindings,
240
- [SupportedLanguages.Python]: extractPythonNamedBindings,
241
- [SupportedLanguages.Java]: extractJavaNamedBindings,
242
- [SupportedLanguages.C]: undefined,
243
- [SupportedLanguages.CPlusPlus]: undefined,
244
- [SupportedLanguages.CSharp]: extractCsharpNamedBindings,
245
- [SupportedLanguages.Go]: undefined,
246
- [SupportedLanguages.Ruby]: undefined,
247
- [SupportedLanguages.Rust]: extractRustNamedBindings,
248
- [SupportedLanguages.PHP]: extractPhpNamedBindings,
249
- [SupportedLanguages.Kotlin]: extractKotlinNamedBindings,
250
- [SupportedLanguages.Swift]: undefined,
251
- };