gitnexus 1.4.7 → 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.
Files changed (242) hide show
  1. package/README.md +29 -1
  2. package/dist/cli/ai-context.d.ts +1 -1
  3. package/dist/cli/ai-context.js +1 -1
  4. package/dist/cli/analyze.d.ts +2 -0
  5. package/dist/cli/analyze.js +54 -21
  6. package/dist/cli/index-repo.d.ts +15 -0
  7. package/dist/cli/index-repo.js +115 -0
  8. package/dist/cli/index.js +13 -3
  9. package/dist/cli/setup.js +90 -10
  10. package/dist/cli/wiki.d.ts +4 -0
  11. package/dist/cli/wiki.js +174 -53
  12. package/dist/config/supported-languages.d.ts +33 -1
  13. package/dist/config/supported-languages.js +32 -0
  14. package/dist/core/embeddings/embedder.d.ts +6 -1
  15. package/dist/core/embeddings/embedder.js +65 -5
  16. package/dist/core/embeddings/embedding-pipeline.js +11 -9
  17. package/dist/core/embeddings/http-client.d.ts +31 -0
  18. package/dist/core/embeddings/http-client.js +179 -0
  19. package/dist/core/embeddings/index.d.ts +1 -0
  20. package/dist/core/embeddings/index.js +1 -0
  21. package/dist/core/embeddings/types.d.ts +1 -1
  22. package/dist/core/graph/graph.js +9 -1
  23. package/dist/core/graph/types.d.ts +11 -2
  24. package/dist/core/ingestion/call-processor.d.ts +66 -2
  25. package/dist/core/ingestion/call-processor.js +650 -30
  26. package/dist/core/ingestion/call-routing.d.ts +9 -18
  27. package/dist/core/ingestion/call-routing.js +0 -19
  28. package/dist/core/ingestion/cobol/cobol-copy-expander.d.ts +57 -0
  29. package/dist/core/ingestion/cobol/cobol-copy-expander.js +385 -0
  30. package/dist/core/ingestion/cobol/cobol-preprocessor.d.ts +210 -0
  31. package/dist/core/ingestion/cobol/cobol-preprocessor.js +1509 -0
  32. package/dist/core/ingestion/cobol/jcl-parser.d.ts +68 -0
  33. package/dist/core/ingestion/cobol/jcl-parser.js +217 -0
  34. package/dist/core/ingestion/cobol/jcl-processor.d.ts +33 -0
  35. package/dist/core/ingestion/cobol/jcl-processor.js +229 -0
  36. package/dist/core/ingestion/cobol-processor.d.ts +54 -0
  37. package/dist/core/ingestion/cobol-processor.js +1186 -0
  38. package/dist/core/ingestion/entry-point-scoring.d.ts +17 -0
  39. package/dist/core/ingestion/entry-point-scoring.js +52 -28
  40. package/dist/core/ingestion/export-detection.d.ts +47 -8
  41. package/dist/core/ingestion/export-detection.js +29 -50
  42. package/dist/core/ingestion/field-extractor.d.ts +29 -0
  43. package/dist/core/ingestion/field-extractor.js +25 -0
  44. package/dist/core/ingestion/field-extractors/configs/c-cpp.d.ts +3 -0
  45. package/dist/core/ingestion/field-extractors/configs/c-cpp.js +108 -0
  46. package/dist/core/ingestion/field-extractors/configs/csharp.d.ts +8 -0
  47. package/dist/core/ingestion/field-extractors/configs/csharp.js +73 -0
  48. package/dist/core/ingestion/field-extractors/configs/dart.d.ts +8 -0
  49. package/dist/core/ingestion/field-extractors/configs/dart.js +76 -0
  50. package/dist/core/ingestion/field-extractors/configs/go.d.ts +11 -0
  51. package/dist/core/ingestion/field-extractors/configs/go.js +64 -0
  52. package/dist/core/ingestion/field-extractors/configs/helpers.d.ts +44 -0
  53. package/dist/core/ingestion/field-extractors/configs/helpers.js +134 -0
  54. package/dist/core/ingestion/field-extractors/configs/jvm.d.ts +3 -0
  55. package/dist/core/ingestion/field-extractors/configs/jvm.js +118 -0
  56. package/dist/core/ingestion/field-extractors/configs/php.d.ts +8 -0
  57. package/dist/core/ingestion/field-extractors/configs/php.js +67 -0
  58. package/dist/core/ingestion/field-extractors/configs/python.d.ts +12 -0
  59. package/dist/core/ingestion/field-extractors/configs/python.js +91 -0
  60. package/dist/core/ingestion/field-extractors/configs/ruby.d.ts +16 -0
  61. package/dist/core/ingestion/field-extractors/configs/ruby.js +75 -0
  62. package/dist/core/ingestion/field-extractors/configs/rust.d.ts +9 -0
  63. package/dist/core/ingestion/field-extractors/configs/rust.js +55 -0
  64. package/dist/core/ingestion/field-extractors/configs/swift.d.ts +8 -0
  65. package/dist/core/ingestion/field-extractors/configs/swift.js +63 -0
  66. package/dist/core/ingestion/field-extractors/configs/typescript-javascript.d.ts +3 -0
  67. package/dist/core/ingestion/field-extractors/configs/typescript-javascript.js +60 -0
  68. package/dist/core/ingestion/field-extractors/generic.d.ts +46 -0
  69. package/dist/core/ingestion/field-extractors/generic.js +111 -0
  70. package/dist/core/ingestion/field-extractors/typescript.d.ts +77 -0
  71. package/dist/core/ingestion/field-extractors/typescript.js +291 -0
  72. package/dist/core/ingestion/field-types.d.ts +59 -0
  73. package/dist/core/ingestion/field-types.js +2 -0
  74. package/dist/core/ingestion/framework-detection.d.ts +97 -2
  75. package/dist/core/ingestion/framework-detection.js +114 -14
  76. package/dist/core/ingestion/heritage-processor.js +62 -66
  77. package/dist/core/ingestion/import-processor.d.ts +9 -10
  78. package/dist/core/ingestion/import-processor.js +150 -196
  79. package/dist/core/ingestion/{resolvers → import-resolvers}/csharp.d.ts +6 -9
  80. package/dist/core/ingestion/{resolvers → import-resolvers}/csharp.js +20 -2
  81. package/dist/core/ingestion/import-resolvers/dart.d.ts +7 -0
  82. package/dist/core/ingestion/import-resolvers/dart.js +44 -0
  83. package/dist/core/ingestion/{resolvers → import-resolvers}/go.d.ts +4 -5
  84. package/dist/core/ingestion/{resolvers → import-resolvers}/go.js +17 -0
  85. package/dist/core/ingestion/{resolvers → import-resolvers}/jvm.d.ts +10 -1
  86. package/dist/core/ingestion/import-resolvers/jvm.js +159 -0
  87. package/dist/core/ingestion/import-resolvers/php.d.ts +25 -0
  88. package/dist/core/ingestion/import-resolvers/php.js +80 -0
  89. package/dist/core/ingestion/{resolvers → import-resolvers}/python.d.ts +9 -3
  90. package/dist/core/ingestion/{resolvers → import-resolvers}/python.js +35 -3
  91. package/dist/core/ingestion/{resolvers → import-resolvers}/ruby.d.ts +5 -2
  92. package/dist/core/ingestion/{resolvers → import-resolvers}/ruby.js +7 -2
  93. package/dist/core/ingestion/{resolvers → import-resolvers}/rust.d.ts +5 -2
  94. package/dist/core/ingestion/{resolvers → import-resolvers}/rust.js +41 -2
  95. package/dist/core/ingestion/{resolvers → import-resolvers}/standard.d.ts +15 -7
  96. package/dist/core/ingestion/{resolvers → import-resolvers}/standard.js +22 -3
  97. package/dist/core/ingestion/import-resolvers/swift.d.ts +7 -0
  98. package/dist/core/ingestion/import-resolvers/swift.js +23 -0
  99. package/dist/core/ingestion/import-resolvers/types.d.ts +44 -0
  100. package/dist/core/ingestion/import-resolvers/types.js +6 -0
  101. package/dist/core/ingestion/{resolvers → import-resolvers}/utils.d.ts +2 -0
  102. package/dist/core/ingestion/{resolvers → import-resolvers}/utils.js +7 -0
  103. package/dist/core/ingestion/language-config.d.ts +6 -0
  104. package/dist/core/ingestion/language-config.js +13 -0
  105. package/dist/core/ingestion/language-provider.d.ts +121 -0
  106. package/dist/core/ingestion/language-provider.js +24 -0
  107. package/dist/core/ingestion/languages/c-cpp.d.ts +12 -0
  108. package/dist/core/ingestion/languages/c-cpp.js +71 -0
  109. package/dist/core/ingestion/languages/cobol.d.ts +1 -0
  110. package/dist/core/ingestion/languages/cobol.js +26 -0
  111. package/dist/core/ingestion/languages/csharp.d.ts +8 -0
  112. package/dist/core/ingestion/languages/csharp.js +49 -0
  113. package/dist/core/ingestion/languages/dart.d.ts +12 -0
  114. package/dist/core/ingestion/languages/dart.js +58 -0
  115. package/dist/core/ingestion/languages/go.d.ts +11 -0
  116. package/dist/core/ingestion/languages/go.js +28 -0
  117. package/dist/core/ingestion/languages/index.d.ts +38 -0
  118. package/dist/core/ingestion/languages/index.js +63 -0
  119. package/dist/core/ingestion/languages/java.d.ts +9 -0
  120. package/dist/core/ingestion/languages/java.js +29 -0
  121. package/dist/core/ingestion/languages/kotlin.d.ts +9 -0
  122. package/dist/core/ingestion/languages/kotlin.js +53 -0
  123. package/dist/core/ingestion/languages/php.d.ts +8 -0
  124. package/dist/core/ingestion/languages/php.js +145 -0
  125. package/dist/core/ingestion/languages/python.d.ts +12 -0
  126. package/dist/core/ingestion/languages/python.js +39 -0
  127. package/dist/core/ingestion/languages/ruby.d.ts +9 -0
  128. package/dist/core/ingestion/languages/ruby.js +44 -0
  129. package/dist/core/ingestion/languages/rust.d.ts +12 -0
  130. package/dist/core/ingestion/languages/rust.js +44 -0
  131. package/dist/core/ingestion/languages/swift.d.ts +12 -0
  132. package/dist/core/ingestion/languages/swift.js +133 -0
  133. package/dist/core/ingestion/languages/typescript.d.ts +10 -0
  134. package/dist/core/ingestion/languages/typescript.js +60 -0
  135. package/dist/core/ingestion/markdown-processor.d.ts +17 -0
  136. package/dist/core/ingestion/markdown-processor.js +124 -0
  137. package/dist/core/ingestion/mro-processor.js +22 -18
  138. package/dist/core/ingestion/named-binding-processor.d.ts +18 -0
  139. package/dist/core/ingestion/named-binding-processor.js +42 -0
  140. package/dist/core/ingestion/named-bindings/csharp.d.ts +3 -0
  141. package/dist/core/ingestion/named-bindings/csharp.js +37 -0
  142. package/dist/core/ingestion/named-bindings/java.d.ts +3 -0
  143. package/dist/core/ingestion/named-bindings/java.js +29 -0
  144. package/dist/core/ingestion/named-bindings/kotlin.d.ts +3 -0
  145. package/dist/core/ingestion/named-bindings/kotlin.js +36 -0
  146. package/dist/core/ingestion/named-bindings/php.d.ts +3 -0
  147. package/dist/core/ingestion/named-bindings/php.js +61 -0
  148. package/dist/core/ingestion/named-bindings/python.d.ts +3 -0
  149. package/dist/core/ingestion/named-bindings/python.js +49 -0
  150. package/dist/core/ingestion/named-bindings/rust.d.ts +3 -0
  151. package/dist/core/ingestion/named-bindings/rust.js +64 -0
  152. package/dist/core/ingestion/named-bindings/types.d.ts +16 -0
  153. package/dist/core/ingestion/named-bindings/types.js +6 -0
  154. package/dist/core/ingestion/named-bindings/typescript.d.ts +3 -0
  155. package/dist/core/ingestion/named-bindings/typescript.js +58 -0
  156. package/dist/core/ingestion/parsing-processor.d.ts +6 -2
  157. package/dist/core/ingestion/parsing-processor.js +125 -85
  158. package/dist/core/ingestion/pipeline.d.ts +10 -0
  159. package/dist/core/ingestion/pipeline.js +1235 -317
  160. package/dist/core/ingestion/resolution-context.d.ts +5 -0
  161. package/dist/core/ingestion/resolution-context.js +8 -5
  162. package/dist/core/ingestion/route-extractors/expo.d.ts +1 -0
  163. package/dist/core/ingestion/route-extractors/expo.js +36 -0
  164. package/dist/core/ingestion/route-extractors/middleware.d.ts +47 -0
  165. package/dist/core/ingestion/route-extractors/middleware.js +143 -0
  166. package/dist/core/ingestion/route-extractors/nextjs.d.ts +3 -0
  167. package/dist/core/ingestion/route-extractors/nextjs.js +76 -0
  168. package/dist/core/ingestion/route-extractors/php.d.ts +7 -0
  169. package/dist/core/ingestion/route-extractors/php.js +21 -0
  170. package/dist/core/ingestion/route-extractors/response-shapes.d.ts +20 -0
  171. package/dist/core/ingestion/route-extractors/response-shapes.js +290 -0
  172. package/dist/core/ingestion/symbol-table.d.ts +16 -0
  173. package/dist/core/ingestion/symbol-table.js +20 -6
  174. package/dist/core/ingestion/tree-sitter-queries.d.ts +10 -9
  175. package/dist/core/ingestion/tree-sitter-queries.js +274 -11
  176. package/dist/core/ingestion/type-env.d.ts +42 -18
  177. package/dist/core/ingestion/type-env.js +481 -106
  178. package/dist/core/ingestion/type-extractors/c-cpp.d.ts +5 -0
  179. package/dist/core/ingestion/type-extractors/c-cpp.js +119 -0
  180. package/dist/core/ingestion/type-extractors/csharp.js +149 -16
  181. package/dist/core/ingestion/type-extractors/dart.d.ts +15 -0
  182. package/dist/core/ingestion/type-extractors/dart.js +371 -0
  183. package/dist/core/ingestion/type-extractors/jvm.js +169 -66
  184. package/dist/core/ingestion/type-extractors/rust.js +35 -1
  185. package/dist/core/ingestion/type-extractors/shared.d.ts +1 -15
  186. package/dist/core/ingestion/type-extractors/shared.js +14 -112
  187. package/dist/core/ingestion/type-extractors/swift.js +338 -7
  188. package/dist/core/ingestion/type-extractors/types.d.ts +40 -8
  189. package/dist/core/ingestion/type-extractors/typescript.js +141 -9
  190. package/dist/core/ingestion/utils/ast-helpers.d.ts +83 -0
  191. package/dist/core/ingestion/utils/ast-helpers.js +817 -0
  192. package/dist/core/ingestion/utils/call-analysis.d.ts +73 -0
  193. package/dist/core/ingestion/utils/call-analysis.js +527 -0
  194. package/dist/core/ingestion/utils/event-loop.d.ts +5 -0
  195. package/dist/core/ingestion/utils/event-loop.js +5 -0
  196. package/dist/core/ingestion/utils/language-detection.d.ts +9 -0
  197. package/dist/core/ingestion/utils/language-detection.js +70 -0
  198. package/dist/core/ingestion/utils/verbose.d.ts +1 -0
  199. package/dist/core/ingestion/utils/verbose.js +7 -0
  200. package/dist/core/ingestion/workers/parse-worker.d.ts +55 -5
  201. package/dist/core/ingestion/workers/parse-worker.js +415 -225
  202. package/dist/core/lbug/csv-generator.js +51 -1
  203. package/dist/core/lbug/lbug-adapter.d.ts +10 -0
  204. package/dist/core/lbug/lbug-adapter.js +75 -4
  205. package/dist/core/lbug/schema.d.ts +8 -4
  206. package/dist/core/lbug/schema.js +65 -4
  207. package/dist/core/tree-sitter/parser-loader.js +7 -1
  208. package/dist/core/wiki/cursor-client.d.ts +31 -0
  209. package/dist/core/wiki/cursor-client.js +127 -0
  210. package/dist/core/wiki/generator.d.ts +28 -9
  211. package/dist/core/wiki/generator.js +115 -18
  212. package/dist/core/wiki/graph-queries.d.ts +4 -0
  213. package/dist/core/wiki/graph-queries.js +7 -1
  214. package/dist/core/wiki/llm-client.d.ts +2 -0
  215. package/dist/core/wiki/llm-client.js +8 -4
  216. package/dist/core/wiki/prompts.d.ts +3 -3
  217. package/dist/core/wiki/prompts.js +6 -0
  218. package/dist/mcp/core/embedder.js +11 -3
  219. package/dist/mcp/core/lbug-adapter.d.ts +5 -0
  220. package/dist/mcp/core/lbug-adapter.js +23 -2
  221. package/dist/mcp/local/local-backend.d.ts +38 -5
  222. package/dist/mcp/local/local-backend.js +804 -63
  223. package/dist/mcp/resources.js +2 -0
  224. package/dist/mcp/tools.js +73 -4
  225. package/dist/server/api.d.ts +19 -1
  226. package/dist/server/api.js +66 -6
  227. package/dist/storage/git.d.ts +12 -0
  228. package/dist/storage/git.js +21 -0
  229. package/dist/storage/repo-manager.d.ts +3 -0
  230. package/package.json +25 -16
  231. package/dist/core/ingestion/named-binding-extraction.d.ts +0 -61
  232. package/dist/core/ingestion/named-binding-extraction.js +0 -363
  233. package/dist/core/ingestion/resolvers/index.d.ts +0 -18
  234. package/dist/core/ingestion/resolvers/index.js +0 -13
  235. package/dist/core/ingestion/resolvers/jvm.js +0 -87
  236. package/dist/core/ingestion/resolvers/php.d.ts +0 -15
  237. package/dist/core/ingestion/resolvers/php.js +0 -35
  238. package/dist/core/ingestion/type-extractors/index.d.ts +0 -22
  239. package/dist/core/ingestion/type-extractors/index.js +0 -31
  240. package/dist/core/ingestion/utils.d.ts +0 -138
  241. package/dist/core/ingestion/utils.js +0 -1290
  242. package/scripts/patch-tree-sitter-swift.cjs +0 -74
@@ -1,363 +0,0 @@
1
- import { SupportedLanguages } from '../../config/supported-languages.js';
2
- /**
3
- * Walk a named-binding re-export chain through NamedImportMap.
4
- *
5
- * When file A imports { User } from B, and B re-exports { User } from C,
6
- * the NamedImportMap for A points to B, but B has no User definition.
7
- * This function follows the chain: A→B→C until a definition is found.
8
- *
9
- * Returns the definitions found at the end of the chain, or null if the
10
- * chain breaks (missing binding, circular reference, or depth exceeded).
11
- * Max depth 5 to prevent infinite loops.
12
- *
13
- * @param allDefs Pre-computed `symbolTable.lookupFuzzy(name)` result — must be the
14
- * complete unfiltered result. Passing a file-filtered subset will cause
15
- * silent misses at depth=0 for non-aliased bindings.
16
- */
17
- export function walkBindingChain(name, currentFilePath, symbolTable, namedImportMap, allDefs) {
18
- let lookupFile = currentFilePath;
19
- let lookupName = name;
20
- const visited = new Set();
21
- for (let depth = 0; depth < 5; depth++) {
22
- const bindings = namedImportMap.get(lookupFile);
23
- if (!bindings)
24
- return null;
25
- const binding = bindings.get(lookupName);
26
- if (!binding)
27
- return null;
28
- const key = `${binding.sourcePath}:${binding.exportedName}`;
29
- if (visited.has(key))
30
- return null; // circular
31
- visited.add(key);
32
- const targetName = binding.exportedName;
33
- const resolvedDefs = targetName !== lookupName || depth > 0
34
- ? symbolTable.lookupFuzzy(targetName).filter(def => def.filePath === binding.sourcePath)
35
- : allDefs.filter(def => def.filePath === binding.sourcePath);
36
- if (resolvedDefs.length > 0)
37
- return resolvedDefs;
38
- // No definition in source file → follow re-export chain
39
- lookupFile = binding.sourcePath;
40
- lookupName = targetName;
41
- }
42
- return null;
43
- }
44
- /**
45
- * Extract named bindings from an import AST node.
46
- * Returns undefined if the import is not a named import (e.g., import * or default).
47
- *
48
- * TS: import { User, Repo as R } from './models'
49
- * → [{local:'User', exported:'User'}, {local:'R', exported:'Repo'}]
50
- *
51
- * Python: from models import User, Repo as R
52
- * → [{local:'User', exported:'User'}, {local:'R', exported:'Repo'}]
53
- */
54
- export function extractNamedBindings(importNode, language) {
55
- if (language === SupportedLanguages.TypeScript || language === SupportedLanguages.JavaScript) {
56
- return extractTsNamedBindings(importNode);
57
- }
58
- if (language === SupportedLanguages.Python) {
59
- return extractPythonNamedBindings(importNode);
60
- }
61
- if (language === SupportedLanguages.Kotlin) {
62
- return extractKotlinNamedBindings(importNode);
63
- }
64
- if (language === SupportedLanguages.Rust) {
65
- return extractRustNamedBindings(importNode);
66
- }
67
- if (language === SupportedLanguages.PHP) {
68
- return extractPhpNamedBindings(importNode);
69
- }
70
- if (language === SupportedLanguages.CSharp) {
71
- return extractCsharpNamedBindings(importNode);
72
- }
73
- if (language === SupportedLanguages.Java) {
74
- return extractJavaNamedBindings(importNode);
75
- }
76
- return undefined;
77
- }
78
- export function extractTsNamedBindings(importNode) {
79
- // import_statement > import_clause > named_imports > import_specifier*
80
- const importClause = findChild(importNode, 'import_clause');
81
- if (importClause) {
82
- const namedImports = findChild(importClause, 'named_imports');
83
- if (!namedImports)
84
- return undefined; // default import, namespace import, or side-effect
85
- const bindings = [];
86
- for (let i = 0; i < namedImports.namedChildCount; i++) {
87
- const specifier = namedImports.namedChild(i);
88
- if (specifier?.type !== 'import_specifier')
89
- continue;
90
- const identifiers = [];
91
- for (let j = 0; j < specifier.namedChildCount; j++) {
92
- const child = specifier.namedChild(j);
93
- if (child?.type === 'identifier')
94
- identifiers.push(child.text);
95
- }
96
- if (identifiers.length === 1) {
97
- bindings.push({ local: identifiers[0], exported: identifiers[0] });
98
- }
99
- else if (identifiers.length === 2) {
100
- // import { Foo as Bar } → exported='Foo', local='Bar'
101
- bindings.push({ local: identifiers[1], exported: identifiers[0] });
102
- }
103
- }
104
- return bindings.length > 0 ? bindings : undefined;
105
- }
106
- // Re-export: export { X } from './y' → export_statement > export_clause > export_specifier
107
- const exportClause = findChild(importNode, 'export_clause');
108
- if (exportClause) {
109
- const bindings = [];
110
- for (let i = 0; i < exportClause.namedChildCount; i++) {
111
- const specifier = exportClause.namedChild(i);
112
- if (specifier?.type !== 'export_specifier')
113
- continue;
114
- const identifiers = [];
115
- for (let j = 0; j < specifier.namedChildCount; j++) {
116
- const child = specifier.namedChild(j);
117
- if (child?.type === 'identifier')
118
- identifiers.push(child.text);
119
- }
120
- if (identifiers.length === 1) {
121
- // export { User } from './base' → re-exports User as User
122
- bindings.push({ local: identifiers[0], exported: identifiers[0] });
123
- }
124
- else if (identifiers.length === 2) {
125
- // export { Repo as Repository } from './models' → name=Repo, alias=Repository
126
- // For re-exports, the first id is the source name, second is what's exported
127
- // When another file imports { Repository }, they get Repo from the source
128
- bindings.push({ local: identifiers[1], exported: identifiers[0] });
129
- }
130
- }
131
- return bindings.length > 0 ? bindings : undefined;
132
- }
133
- return undefined;
134
- }
135
- export function extractPythonNamedBindings(importNode) {
136
- // Only from import_from_statement, not plain import_statement
137
- if (importNode.type !== 'import_from_statement')
138
- return undefined;
139
- const bindings = [];
140
- for (let i = 0; i < importNode.namedChildCount; i++) {
141
- const child = importNode.namedChild(i);
142
- if (!child)
143
- continue;
144
- if (child.type === 'dotted_name') {
145
- // Skip the module_name (first dotted_name is the source module)
146
- const fieldName = importNode.childForFieldName?.('module_name');
147
- if (fieldName && child.startIndex === fieldName.startIndex)
148
- continue;
149
- // This is an imported name: from x import User
150
- const name = child.text;
151
- if (name)
152
- bindings.push({ local: name, exported: name });
153
- }
154
- if (child.type === 'aliased_import') {
155
- // from x import Repo as R
156
- const dottedName = findChild(child, 'dotted_name');
157
- const aliasIdent = findChild(child, 'identifier');
158
- if (dottedName && aliasIdent) {
159
- bindings.push({ local: aliasIdent.text, exported: dottedName.text });
160
- }
161
- }
162
- }
163
- return bindings.length > 0 ? bindings : undefined;
164
- }
165
- export function extractKotlinNamedBindings(importNode) {
166
- // import_header > identifier + import_alias > simple_identifier
167
- if (importNode.type !== 'import_header')
168
- return undefined;
169
- const fullIdent = findChild(importNode, 'identifier');
170
- if (!fullIdent)
171
- return undefined;
172
- const fullText = fullIdent.text;
173
- const exportedName = fullText.includes('.') ? fullText.split('.').pop() : fullText;
174
- const importAlias = findChild(importNode, 'import_alias');
175
- if (importAlias) {
176
- // Aliased: import com.example.User as U
177
- const aliasIdent = findChild(importAlias, 'simple_identifier');
178
- if (!aliasIdent)
179
- return undefined;
180
- return [{ local: aliasIdent.text, exported: exportedName }];
181
- }
182
- // Non-aliased: import com.example.User → local="User", exported="User"
183
- // Skip wildcard imports (ending in *)
184
- if (fullText.endsWith('.*') || fullText.endsWith('*'))
185
- return undefined;
186
- // Skip lowercase last segments — those are member/function imports (e.g.,
187
- // import util.OneArg.writeAudit), not class imports. Multiple member imports
188
- // with the same function name would collide in NamedImportMap, breaking
189
- // arity-based disambiguation.
190
- if (exportedName[0] && exportedName[0] === exportedName[0].toLowerCase())
191
- return undefined;
192
- return [{ local: exportedName, exported: exportedName }];
193
- }
194
- export function extractRustNamedBindings(importNode) {
195
- // use_declaration may contain use_as_clause at any depth
196
- if (importNode.type !== 'use_declaration')
197
- return undefined;
198
- const bindings = [];
199
- collectRustBindings(importNode, bindings);
200
- return bindings.length > 0 ? bindings : undefined;
201
- }
202
- function collectRustBindings(node, bindings) {
203
- if (node.type === 'use_as_clause') {
204
- // First identifier = exported name, second identifier = local alias
205
- const idents = [];
206
- for (let i = 0; i < node.namedChildCount; i++) {
207
- const child = node.namedChild(i);
208
- if (child?.type === 'identifier')
209
- idents.push(child.text);
210
- // For scoped_identifier, extract the last segment
211
- if (child?.type === 'scoped_identifier') {
212
- const nameNode = child.childForFieldName?.('name');
213
- if (nameNode)
214
- idents.push(nameNode.text);
215
- }
216
- }
217
- if (idents.length === 2) {
218
- bindings.push({ local: idents[1], exported: idents[0] });
219
- }
220
- return;
221
- }
222
- // Terminal identifier in a use_list: use crate::models::{User, Repo}
223
- if (node.type === 'identifier' && node.parent?.type === 'use_list') {
224
- bindings.push({ local: node.text, exported: node.text });
225
- return;
226
- }
227
- // Skip scoped_identifier that serves as path prefix in scoped_use_list
228
- // e.g. use crate::models::{User, Repo} — the path node "crate::models" is not an importable symbol
229
- if (node.type === 'scoped_identifier' && node.parent?.type === 'scoped_use_list') {
230
- return; // path prefix — the use_list sibling handles the actual symbols
231
- }
232
- // Terminal scoped_identifier: use crate::models::User;
233
- // Only extract if this is a leaf (no deeper use_list/use_as_clause/scoped_use_list)
234
- if (node.type === 'scoped_identifier') {
235
- let hasDeeper = false;
236
- for (let i = 0; i < node.namedChildCount; i++) {
237
- const child = node.namedChild(i);
238
- if (child?.type === 'use_list' || child?.type === 'use_as_clause' || child?.type === 'scoped_use_list') {
239
- hasDeeper = true;
240
- break;
241
- }
242
- }
243
- if (!hasDeeper) {
244
- const nameNode = node.childForFieldName?.('name');
245
- if (nameNode) {
246
- bindings.push({ local: nameNode.text, exported: nameNode.text });
247
- }
248
- return;
249
- }
250
- }
251
- // Recurse into children
252
- for (let i = 0; i < node.namedChildCount; i++) {
253
- const child = node.namedChild(i);
254
- if (child)
255
- collectRustBindings(child, bindings);
256
- }
257
- }
258
- export function extractPhpNamedBindings(importNode) {
259
- // namespace_use_declaration > namespace_use_clause* (flat)
260
- // namespace_use_declaration > namespace_use_group > namespace_use_clause* (grouped)
261
- if (importNode.type !== 'namespace_use_declaration')
262
- return undefined;
263
- const bindings = [];
264
- // Collect all clauses — from direct children AND from namespace_use_group
265
- const clauses = [];
266
- for (let i = 0; i < importNode.namedChildCount; i++) {
267
- const child = importNode.namedChild(i);
268
- if (child?.type === 'namespace_use_clause') {
269
- clauses.push(child);
270
- }
271
- else if (child?.type === 'namespace_use_group') {
272
- for (let j = 0; j < child.namedChildCount; j++) {
273
- const groupChild = child.namedChild(j);
274
- if (groupChild?.type === 'namespace_use_clause')
275
- clauses.push(groupChild);
276
- }
277
- }
278
- }
279
- for (const clause of clauses) {
280
- // Flat imports: qualified_name + name (alias)
281
- let qualifiedName = null;
282
- const names = [];
283
- for (let j = 0; j < clause.namedChildCount; j++) {
284
- const child = clause.namedChild(j);
285
- if (child?.type === 'qualified_name')
286
- qualifiedName = child;
287
- else if (child?.type === 'name')
288
- names.push(child);
289
- }
290
- if (qualifiedName && names.length > 0) {
291
- // Flat aliased import: use App\Models\Repo as R;
292
- const fullText = qualifiedName.text;
293
- const exportedName = fullText.includes('\\') ? fullText.split('\\').pop() : fullText;
294
- bindings.push({ local: names[0].text, exported: exportedName });
295
- }
296
- else if (qualifiedName && names.length === 0) {
297
- // Flat non-aliased import: use App\Models\User;
298
- const fullText = qualifiedName.text;
299
- const lastSegment = fullText.includes('\\') ? fullText.split('\\').pop() : fullText;
300
- bindings.push({ local: lastSegment, exported: lastSegment });
301
- }
302
- else if (!qualifiedName && names.length >= 2) {
303
- // Grouped aliased import: {Repo as R} — first name = exported, second = alias
304
- bindings.push({ local: names[1].text, exported: names[0].text });
305
- }
306
- else if (!qualifiedName && names.length === 1) {
307
- // Grouped non-aliased import: {User} in use App\Models\{User, Repo as R}
308
- bindings.push({ local: names[0].text, exported: names[0].text });
309
- }
310
- }
311
- return bindings.length > 0 ? bindings : undefined;
312
- }
313
- export function extractCsharpNamedBindings(importNode) {
314
- // using_directive with identifier (alias) + qualified_name (target)
315
- if (importNode.type !== 'using_directive')
316
- return undefined;
317
- let aliasIdent = null;
318
- let qualifiedName = null;
319
- for (let i = 0; i < importNode.namedChildCount; i++) {
320
- const child = importNode.namedChild(i);
321
- if (child?.type === 'identifier' && !aliasIdent)
322
- aliasIdent = child;
323
- else if (child?.type === 'qualified_name')
324
- qualifiedName = child;
325
- }
326
- if (!aliasIdent || !qualifiedName)
327
- return undefined;
328
- const fullText = qualifiedName.text;
329
- const exportedName = fullText.includes('.') ? fullText.split('.').pop() : fullText;
330
- return [{ local: aliasIdent.text, exported: exportedName }];
331
- }
332
- export function extractJavaNamedBindings(importNode) {
333
- // import_declaration > scoped_identifier "com.example.models.User"
334
- // Wildcard imports (.*) don't produce named bindings
335
- if (importNode.type !== 'import_declaration')
336
- return undefined;
337
- // Check for asterisk (wildcard import) — skip those
338
- for (let i = 0; i < importNode.childCount; i++) {
339
- const child = importNode.child(i);
340
- if (child?.type === 'asterisk')
341
- return undefined;
342
- }
343
- const scopedId = findChild(importNode, 'scoped_identifier');
344
- if (!scopedId)
345
- return undefined;
346
- const fullText = scopedId.text;
347
- const lastDot = fullText.lastIndexOf('.');
348
- if (lastDot === -1)
349
- return undefined;
350
- const className = fullText.slice(lastDot + 1);
351
- // Skip lowercase names — those are package imports, not class imports
352
- if (className[0] && className[0] === className[0].toLowerCase())
353
- return undefined;
354
- return [{ local: className, exported: className }];
355
- }
356
- function findChild(node, type) {
357
- for (let i = 0; i < node.namedChildCount; i++) {
358
- const child = node.namedChild(i);
359
- if (child?.type === type)
360
- return child;
361
- }
362
- return null;
363
- }
@@ -1,18 +0,0 @@
1
- /**
2
- * Language-specific import resolvers.
3
- * Extracted from import-processor.ts for maintainability.
4
- */
5
- export { EXTENSIONS, tryResolveWithExtensions, buildSuffixIndex, suffixResolve } from './utils.js';
6
- export type { SuffixIndex } from './utils.js';
7
- export { KOTLIN_EXTENSIONS, appendKotlinWildcard, resolveJvmWildcard, resolveJvmMemberImport } from './jvm.js';
8
- export { resolveGoPackageDir, resolveGoPackage } from './go.js';
9
- export type { GoModuleConfig } from './go.js';
10
- export { resolveCSharpImport, resolveCSharpNamespaceDir } from './csharp.js';
11
- export type { CSharpProjectConfig } from './csharp.js';
12
- export { resolvePhpImport } from './php.js';
13
- export type { ComposerConfig } from './php.js';
14
- export { resolveRustImport, tryRustModulePath } from './rust.js';
15
- export { resolveRubyImport } from './ruby.js';
16
- export { resolvePythonImport } from './python.js';
17
- export { resolveImportPath, RESOLVE_CACHE_CAP } from './standard.js';
18
- export type { TsconfigPaths } from './standard.js';
@@ -1,13 +0,0 @@
1
- /**
2
- * Language-specific import resolvers.
3
- * Extracted from import-processor.ts for maintainability.
4
- */
5
- export { EXTENSIONS, tryResolveWithExtensions, buildSuffixIndex, suffixResolve } from './utils.js';
6
- export { KOTLIN_EXTENSIONS, appendKotlinWildcard, resolveJvmWildcard, resolveJvmMemberImport } from './jvm.js';
7
- export { resolveGoPackageDir, resolveGoPackage } from './go.js';
8
- export { resolveCSharpImport, resolveCSharpNamespaceDir } from './csharp.js';
9
- export { resolvePhpImport } from './php.js';
10
- export { resolveRustImport, tryRustModulePath } from './rust.js';
11
- export { resolveRubyImport } from './ruby.js';
12
- export { resolvePythonImport } from './python.js';
13
- export { resolveImportPath, RESOLVE_CACHE_CAP } from './standard.js';
@@ -1,87 +0,0 @@
1
- /**
2
- * JVM import resolution (Java + Kotlin).
3
- * Handles wildcard imports, member/static imports, and Kotlin-specific patterns.
4
- */
5
- /** Kotlin file extensions for JVM resolver reuse */
6
- export const KOTLIN_EXTENSIONS = ['.kt', '.kts'];
7
- /**
8
- * Append .* to a Kotlin import path if the AST has a wildcard_import sibling node.
9
- * Pure function — returns a new string without mutating the input.
10
- */
11
- export const appendKotlinWildcard = (importPath, importNode) => {
12
- for (let i = 0; i < importNode.childCount; i++) {
13
- if (importNode.child(i)?.type === 'wildcard_import') {
14
- return importPath.endsWith('.*') ? importPath : `${importPath}.*`;
15
- }
16
- }
17
- return importPath;
18
- };
19
- /**
20
- * Resolve a JVM wildcard import (com.example.*) to all matching files.
21
- * Works for both Java (.java) and Kotlin (.kt, .kts).
22
- */
23
- export function resolveJvmWildcard(importPath, normalizedFileList, allFileList, extensions, index) {
24
- // "com.example.util.*" -> "com/example/util"
25
- const packagePath = importPath.slice(0, -2).replace(/\./g, '/');
26
- if (index) {
27
- const candidates = extensions.flatMap(ext => index.getFilesInDir(packagePath, ext));
28
- // Filter to only direct children (no subdirectories)
29
- const packageSuffix = '/' + packagePath + '/';
30
- return candidates.filter(f => {
31
- const normalized = f.replace(/\\/g, '/');
32
- const idx = normalized.indexOf(packageSuffix);
33
- if (idx < 0)
34
- return false;
35
- const afterPkg = normalized.substring(idx + packageSuffix.length);
36
- return !afterPkg.includes('/');
37
- });
38
- }
39
- // Fallback: linear scan
40
- const packageSuffix = '/' + packagePath + '/';
41
- const matches = [];
42
- for (let i = 0; i < normalizedFileList.length; i++) {
43
- const normalized = normalizedFileList[i];
44
- if (normalized.includes(packageSuffix) &&
45
- extensions.some(ext => normalized.endsWith(ext))) {
46
- const afterPackage = normalized.substring(normalized.indexOf(packageSuffix) + packageSuffix.length);
47
- if (!afterPackage.includes('/')) {
48
- matches.push(allFileList[i]);
49
- }
50
- }
51
- }
52
- return matches;
53
- }
54
- /**
55
- * Try to resolve a JVM member/static import by stripping the member name.
56
- * Java: "com.example.Constants.VALUE" -> resolve "com.example.Constants"
57
- * Kotlin: "com.example.Constants.VALUE" -> resolve "com.example.Constants"
58
- */
59
- export function resolveJvmMemberImport(importPath, normalizedFileList, allFileList, extensions, index) {
60
- // Member imports: com.example.Constants.VALUE or com.example.Constants.*
61
- // The last segment is a member name if it starts with lowercase, is ALL_CAPS, or is a wildcard
62
- const segments = importPath.split('.');
63
- if (segments.length < 3)
64
- return null;
65
- const lastSeg = segments[segments.length - 1];
66
- if (lastSeg === '*' || /^[a-z]/.test(lastSeg) || /^[A-Z_]+$/.test(lastSeg)) {
67
- const classPath = segments.slice(0, -1).join('/');
68
- for (const ext of extensions) {
69
- const classSuffix = classPath + ext;
70
- if (index) {
71
- const result = index.get(classSuffix) || index.getInsensitive(classSuffix);
72
- if (result)
73
- return result;
74
- }
75
- else {
76
- const fullSuffix = '/' + classSuffix;
77
- for (let i = 0; i < normalizedFileList.length; i++) {
78
- if (normalizedFileList[i].endsWith(fullSuffix) ||
79
- normalizedFileList[i].toLowerCase().endsWith(fullSuffix.toLowerCase())) {
80
- return allFileList[i];
81
- }
82
- }
83
- }
84
- }
85
- }
86
- return null;
87
- }
@@ -1,15 +0,0 @@
1
- /**
2
- * PHP PSR-4 import resolution.
3
- * Handles use-statement resolution via composer.json autoload mappings.
4
- */
5
- import type { SuffixIndex } from './utils.js';
6
- /** PHP Composer PSR-4 autoload config */
7
- export interface ComposerConfig {
8
- /** Map of namespace prefix -> directory (e.g., "App\\" -> "app/") */
9
- psr4: Map<string, string>;
10
- }
11
- /**
12
- * Resolve a PHP use-statement import path using PSR-4 mappings.
13
- * e.g. "App\Http\Controllers\UserController" -> "app/Http/Controllers/UserController.php"
14
- */
15
- export declare function resolvePhpImport(importPath: string, composerConfig: ComposerConfig | null, allFiles: Set<string>, normalizedFileList: string[], allFileList: string[], index?: SuffixIndex): string | null;
@@ -1,35 +0,0 @@
1
- /**
2
- * PHP PSR-4 import resolution.
3
- * Handles use-statement resolution via composer.json autoload mappings.
4
- */
5
- import { suffixResolve } from './utils.js';
6
- /**
7
- * Resolve a PHP use-statement import path using PSR-4 mappings.
8
- * e.g. "App\Http\Controllers\UserController" -> "app/Http/Controllers/UserController.php"
9
- */
10
- export function resolvePhpImport(importPath, composerConfig, allFiles, normalizedFileList, allFileList, index) {
11
- // Normalize: replace backslashes with forward slashes
12
- const normalized = importPath.replace(/\\/g, '/');
13
- // Try PSR-4 resolution if composer.json was found
14
- if (composerConfig) {
15
- // Sort namespaces by length descending (longest match wins)
16
- const sorted = [...composerConfig.psr4.entries()].sort((a, b) => b[0].length - a[0].length);
17
- for (const [nsPrefix, dirPrefix] of sorted) {
18
- const nsPrefixSlash = nsPrefix.replace(/\\/g, '/');
19
- if (normalized.startsWith(nsPrefixSlash + '/') || normalized === nsPrefixSlash) {
20
- const remainder = normalized.slice(nsPrefixSlash.length).replace(/^\//, '');
21
- const filePath = dirPrefix + (remainder ? '/' + remainder : '') + '.php';
22
- if (allFiles.has(filePath))
23
- return filePath;
24
- if (index) {
25
- const result = index.getInsensitive(filePath);
26
- if (result)
27
- return result;
28
- }
29
- }
30
- }
31
- }
32
- // Fallback: suffix matching (works without composer.json)
33
- const pathParts = normalized.split('/').filter(Boolean);
34
- return suffixResolve(pathParts, normalizedFileList, allFileList, index);
35
- }
@@ -1,22 +0,0 @@
1
- /**
2
- * Per-language type extraction configurations.
3
- * Assembled here into a dispatch map keyed by SupportedLanguages.
4
- */
5
- import type { LanguageTypeConfig } from './types.js';
6
- export declare const typeConfigs: {
7
- javascript: LanguageTypeConfig;
8
- typescript: LanguageTypeConfig;
9
- java: LanguageTypeConfig;
10
- kotlin: LanguageTypeConfig;
11
- csharp: LanguageTypeConfig;
12
- go: LanguageTypeConfig;
13
- rust: LanguageTypeConfig;
14
- python: LanguageTypeConfig;
15
- swift: LanguageTypeConfig;
16
- c: LanguageTypeConfig;
17
- cpp: LanguageTypeConfig;
18
- php: LanguageTypeConfig;
19
- ruby: LanguageTypeConfig;
20
- };
21
- export type { LanguageTypeConfig, TypeBindingExtractor, ParameterExtractor, ConstructorBindingScanner, ForLoopExtractor, PendingAssignmentExtractor, PatternBindingExtractor, } from './types.js';
22
- export { TYPED_PARAMETER_TYPES, extractSimpleTypeName, extractGenericTypeArgs, extractVarName, findChildByType, extractRubyConstructorAssignment } from './shared.js';
@@ -1,31 +0,0 @@
1
- /**
2
- * Per-language type extraction configurations.
3
- * Assembled here into a dispatch map keyed by SupportedLanguages.
4
- */
5
- import { SupportedLanguages } from '../../../config/supported-languages.js';
6
- import { typeConfig as typescriptConfig } from './typescript.js';
7
- import { javaTypeConfig, kotlinTypeConfig } from './jvm.js';
8
- import { typeConfig as csharpConfig } from './csharp.js';
9
- import { typeConfig as goConfig } from './go.js';
10
- import { typeConfig as rustConfig } from './rust.js';
11
- import { typeConfig as pythonConfig } from './python.js';
12
- import { typeConfig as swiftConfig } from './swift.js';
13
- import { typeConfig as cCppConfig } from './c-cpp.js';
14
- import { typeConfig as phpConfig } from './php.js';
15
- import { typeConfig as rubyConfig } from './ruby.js';
16
- export const typeConfigs = {
17
- [SupportedLanguages.JavaScript]: typescriptConfig,
18
- [SupportedLanguages.TypeScript]: typescriptConfig,
19
- [SupportedLanguages.Java]: javaTypeConfig,
20
- [SupportedLanguages.Kotlin]: kotlinTypeConfig,
21
- [SupportedLanguages.CSharp]: csharpConfig,
22
- [SupportedLanguages.Go]: goConfig,
23
- [SupportedLanguages.Rust]: rustConfig,
24
- [SupportedLanguages.Python]: pythonConfig,
25
- [SupportedLanguages.Swift]: swiftConfig,
26
- [SupportedLanguages.C]: cCppConfig,
27
- [SupportedLanguages.CPlusPlus]: cCppConfig,
28
- [SupportedLanguages.PHP]: phpConfig,
29
- [SupportedLanguages.Ruby]: rubyConfig,
30
- };
31
- export { TYPED_PARAMETER_TYPES, extractSimpleTypeName, extractGenericTypeArgs, extractVarName, findChildByType, extractRubyConstructorAssignment } from './shared.js';