@kkvcrobatz107/codegraph 0.9.6-pkm.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (501) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +595 -0
  3. package/dist/bin/codegraph.d.ts +25 -0
  4. package/dist/bin/codegraph.d.ts.map +1 -0
  5. package/dist/bin/codegraph.js +1563 -0
  6. package/dist/bin/codegraph.js.map +1 -0
  7. package/dist/bin/node-version-check.d.ts +37 -0
  8. package/dist/bin/node-version-check.d.ts.map +1 -0
  9. package/dist/bin/node-version-check.js +79 -0
  10. package/dist/bin/node-version-check.js.map +1 -0
  11. package/dist/bin/uninstall.d.ts +14 -0
  12. package/dist/bin/uninstall.d.ts.map +1 -0
  13. package/dist/bin/uninstall.js +36 -0
  14. package/dist/bin/uninstall.js.map +1 -0
  15. package/dist/context/formatter.d.ts +30 -0
  16. package/dist/context/formatter.d.ts.map +1 -0
  17. package/dist/context/formatter.js +244 -0
  18. package/dist/context/formatter.js.map +1 -0
  19. package/dist/context/index.d.ts +110 -0
  20. package/dist/context/index.d.ts.map +1 -0
  21. package/dist/context/index.js +1169 -0
  22. package/dist/context/index.js.map +1 -0
  23. package/dist/db/index.d.ts +101 -0
  24. package/dist/db/index.d.ts.map +1 -0
  25. package/dist/db/index.js +251 -0
  26. package/dist/db/index.js.map +1 -0
  27. package/dist/db/migrations.d.ts +44 -0
  28. package/dist/db/migrations.d.ts.map +1 -0
  29. package/dist/db/migrations.js +131 -0
  30. package/dist/db/migrations.js.map +1 -0
  31. package/dist/db/queries.d.ts +281 -0
  32. package/dist/db/queries.d.ts.map +1 -0
  33. package/dist/db/queries.js +1300 -0
  34. package/dist/db/queries.js.map +1 -0
  35. package/dist/db/schema.sql +151 -0
  36. package/dist/db/sqlite-adapter.d.ts +46 -0
  37. package/dist/db/sqlite-adapter.d.ts.map +1 -0
  38. package/dist/db/sqlite-adapter.js +114 -0
  39. package/dist/db/sqlite-adapter.js.map +1 -0
  40. package/dist/directory.d.ts +57 -0
  41. package/dist/directory.d.ts.map +1 -0
  42. package/dist/directory.js +264 -0
  43. package/dist/directory.js.map +1 -0
  44. package/dist/errors.d.ts +136 -0
  45. package/dist/errors.d.ts.map +1 -0
  46. package/dist/errors.js +219 -0
  47. package/dist/errors.js.map +1 -0
  48. package/dist/extraction/dfm-extractor.d.ts +31 -0
  49. package/dist/extraction/dfm-extractor.d.ts.map +1 -0
  50. package/dist/extraction/dfm-extractor.js +151 -0
  51. package/dist/extraction/dfm-extractor.js.map +1 -0
  52. package/dist/extraction/grammars.d.ts +90 -0
  53. package/dist/extraction/grammars.d.ts.map +1 -0
  54. package/dist/extraction/grammars.js +407 -0
  55. package/dist/extraction/grammars.js.map +1 -0
  56. package/dist/extraction/index.d.ts +138 -0
  57. package/dist/extraction/index.d.ts.map +1 -0
  58. package/dist/extraction/index.js +1378 -0
  59. package/dist/extraction/index.js.map +1 -0
  60. package/dist/extraction/languages/c-cpp.d.ts +4 -0
  61. package/dist/extraction/languages/c-cpp.d.ts.map +1 -0
  62. package/dist/extraction/languages/c-cpp.js +171 -0
  63. package/dist/extraction/languages/c-cpp.js.map +1 -0
  64. package/dist/extraction/languages/csharp.d.ts +3 -0
  65. package/dist/extraction/languages/csharp.d.ts.map +1 -0
  66. package/dist/extraction/languages/csharp.js +73 -0
  67. package/dist/extraction/languages/csharp.js.map +1 -0
  68. package/dist/extraction/languages/dart.d.ts +3 -0
  69. package/dist/extraction/languages/dart.d.ts.map +1 -0
  70. package/dist/extraction/languages/dart.js +192 -0
  71. package/dist/extraction/languages/dart.js.map +1 -0
  72. package/dist/extraction/languages/go.d.ts +3 -0
  73. package/dist/extraction/languages/go.d.ts.map +1 -0
  74. package/dist/extraction/languages/go.js +70 -0
  75. package/dist/extraction/languages/go.js.map +1 -0
  76. package/dist/extraction/languages/index.d.ts +10 -0
  77. package/dist/extraction/languages/index.d.ts.map +1 -0
  78. package/dist/extraction/languages/index.js +51 -0
  79. package/dist/extraction/languages/index.js.map +1 -0
  80. package/dist/extraction/languages/java.d.ts +3 -0
  81. package/dist/extraction/languages/java.d.ts.map +1 -0
  82. package/dist/extraction/languages/java.js +70 -0
  83. package/dist/extraction/languages/java.js.map +1 -0
  84. package/dist/extraction/languages/javascript.d.ts +3 -0
  85. package/dist/extraction/languages/javascript.d.ts.map +1 -0
  86. package/dist/extraction/languages/javascript.js +90 -0
  87. package/dist/extraction/languages/javascript.js.map +1 -0
  88. package/dist/extraction/languages/kotlin.d.ts +3 -0
  89. package/dist/extraction/languages/kotlin.d.ts.map +1 -0
  90. package/dist/extraction/languages/kotlin.js +259 -0
  91. package/dist/extraction/languages/kotlin.js.map +1 -0
  92. package/dist/extraction/languages/lua.d.ts +3 -0
  93. package/dist/extraction/languages/lua.d.ts.map +1 -0
  94. package/dist/extraction/languages/lua.js +150 -0
  95. package/dist/extraction/languages/lua.js.map +1 -0
  96. package/dist/extraction/languages/luau.d.ts +3 -0
  97. package/dist/extraction/languages/luau.d.ts.map +1 -0
  98. package/dist/extraction/languages/luau.js +37 -0
  99. package/dist/extraction/languages/luau.js.map +1 -0
  100. package/dist/extraction/languages/objc.d.ts +3 -0
  101. package/dist/extraction/languages/objc.d.ts.map +1 -0
  102. package/dist/extraction/languages/objc.js +133 -0
  103. package/dist/extraction/languages/objc.js.map +1 -0
  104. package/dist/extraction/languages/pascal.d.ts +3 -0
  105. package/dist/extraction/languages/pascal.d.ts.map +1 -0
  106. package/dist/extraction/languages/pascal.js +66 -0
  107. package/dist/extraction/languages/pascal.js.map +1 -0
  108. package/dist/extraction/languages/php.d.ts +3 -0
  109. package/dist/extraction/languages/php.d.ts.map +1 -0
  110. package/dist/extraction/languages/php.js +107 -0
  111. package/dist/extraction/languages/php.js.map +1 -0
  112. package/dist/extraction/languages/python.d.ts +3 -0
  113. package/dist/extraction/languages/python.d.ts.map +1 -0
  114. package/dist/extraction/languages/python.js +56 -0
  115. package/dist/extraction/languages/python.js.map +1 -0
  116. package/dist/extraction/languages/ruby.d.ts +3 -0
  117. package/dist/extraction/languages/ruby.d.ts.map +1 -0
  118. package/dist/extraction/languages/ruby.js +114 -0
  119. package/dist/extraction/languages/ruby.js.map +1 -0
  120. package/dist/extraction/languages/rust.d.ts +3 -0
  121. package/dist/extraction/languages/rust.d.ts.map +1 -0
  122. package/dist/extraction/languages/rust.js +109 -0
  123. package/dist/extraction/languages/rust.js.map +1 -0
  124. package/dist/extraction/languages/scala.d.ts +3 -0
  125. package/dist/extraction/languages/scala.d.ts.map +1 -0
  126. package/dist/extraction/languages/scala.js +139 -0
  127. package/dist/extraction/languages/scala.js.map +1 -0
  128. package/dist/extraction/languages/swift.d.ts +3 -0
  129. package/dist/extraction/languages/swift.d.ts.map +1 -0
  130. package/dist/extraction/languages/swift.js +91 -0
  131. package/dist/extraction/languages/swift.js.map +1 -0
  132. package/dist/extraction/languages/typescript.d.ts +3 -0
  133. package/dist/extraction/languages/typescript.d.ts.map +1 -0
  134. package/dist/extraction/languages/typescript.js +129 -0
  135. package/dist/extraction/languages/typescript.js.map +1 -0
  136. package/dist/extraction/liquid-extractor.d.ts +52 -0
  137. package/dist/extraction/liquid-extractor.d.ts.map +1 -0
  138. package/dist/extraction/liquid-extractor.js +313 -0
  139. package/dist/extraction/liquid-extractor.js.map +1 -0
  140. package/dist/extraction/mybatis-extractor.d.ts +48 -0
  141. package/dist/extraction/mybatis-extractor.d.ts.map +1 -0
  142. package/dist/extraction/mybatis-extractor.js +198 -0
  143. package/dist/extraction/mybatis-extractor.js.map +1 -0
  144. package/dist/extraction/parse-worker.d.ts +8 -0
  145. package/dist/extraction/parse-worker.d.ts.map +1 -0
  146. package/dist/extraction/parse-worker.js +94 -0
  147. package/dist/extraction/parse-worker.js.map +1 -0
  148. package/dist/extraction/svelte-extractor.d.ts +56 -0
  149. package/dist/extraction/svelte-extractor.d.ts.map +1 -0
  150. package/dist/extraction/svelte-extractor.js +272 -0
  151. package/dist/extraction/svelte-extractor.js.map +1 -0
  152. package/dist/extraction/tree-sitter-helpers.d.ts +28 -0
  153. package/dist/extraction/tree-sitter-helpers.d.ts.map +1 -0
  154. package/dist/extraction/tree-sitter-helpers.js +103 -0
  155. package/dist/extraction/tree-sitter-helpers.js.map +1 -0
  156. package/dist/extraction/tree-sitter-types.d.ts +193 -0
  157. package/dist/extraction/tree-sitter-types.d.ts.map +1 -0
  158. package/dist/extraction/tree-sitter-types.js +10 -0
  159. package/dist/extraction/tree-sitter-types.js.map +1 -0
  160. package/dist/extraction/tree-sitter.d.ts +291 -0
  161. package/dist/extraction/tree-sitter.d.ts.map +1 -0
  162. package/dist/extraction/tree-sitter.js +2961 -0
  163. package/dist/extraction/tree-sitter.js.map +1 -0
  164. package/dist/extraction/vue-extractor.d.ts +36 -0
  165. package/dist/extraction/vue-extractor.d.ts.map +1 -0
  166. package/dist/extraction/vue-extractor.js +163 -0
  167. package/dist/extraction/vue-extractor.js.map +1 -0
  168. package/dist/extraction/wasm/tree-sitter-lua.wasm +0 -0
  169. package/dist/extraction/wasm/tree-sitter-luau.wasm +0 -0
  170. package/dist/extraction/wasm/tree-sitter-pascal.wasm +0 -0
  171. package/dist/extraction/wasm/tree-sitter-scala.wasm +0 -0
  172. package/dist/extraction/wasm-runtime-flags.d.ts +38 -0
  173. package/dist/extraction/wasm-runtime-flags.d.ts.map +1 -0
  174. package/dist/extraction/wasm-runtime-flags.js +105 -0
  175. package/dist/extraction/wasm-runtime-flags.js.map +1 -0
  176. package/dist/graph/index.d.ts +8 -0
  177. package/dist/graph/index.d.ts.map +1 -0
  178. package/dist/graph/index.js +13 -0
  179. package/dist/graph/index.js.map +1 -0
  180. package/dist/graph/queries.d.ts +106 -0
  181. package/dist/graph/queries.d.ts.map +1 -0
  182. package/dist/graph/queries.js +366 -0
  183. package/dist/graph/queries.js.map +1 -0
  184. package/dist/graph/traversal.d.ts +127 -0
  185. package/dist/graph/traversal.d.ts.map +1 -0
  186. package/dist/graph/traversal.js +528 -0
  187. package/dist/graph/traversal.js.map +1 -0
  188. package/dist/index.d.ts +460 -0
  189. package/dist/index.d.ts.map +1 -0
  190. package/dist/index.js +863 -0
  191. package/dist/index.js.map +1 -0
  192. package/dist/installer/claude-md-template.d.ts +14 -0
  193. package/dist/installer/claude-md-template.d.ts.map +1 -0
  194. package/dist/installer/claude-md-template.js +21 -0
  195. package/dist/installer/claude-md-template.js.map +1 -0
  196. package/dist/installer/config-writer.d.ts +29 -0
  197. package/dist/installer/config-writer.d.ts.map +1 -0
  198. package/dist/installer/config-writer.js +111 -0
  199. package/dist/installer/config-writer.js.map +1 -0
  200. package/dist/installer/index.d.ts +117 -0
  201. package/dist/installer/index.d.ts.map +1 -0
  202. package/dist/installer/index.js +528 -0
  203. package/dist/installer/index.js.map +1 -0
  204. package/dist/installer/instructions-template.d.ts +28 -0
  205. package/dist/installer/instructions-template.d.ts.map +1 -0
  206. package/dist/installer/instructions-template.js +65 -0
  207. package/dist/installer/instructions-template.js.map +1 -0
  208. package/dist/installer/targets/antigravity.d.ts +57 -0
  209. package/dist/installer/targets/antigravity.d.ts.map +1 -0
  210. package/dist/installer/targets/antigravity.js +307 -0
  211. package/dist/installer/targets/antigravity.js.map +1 -0
  212. package/dist/installer/targets/claude.d.ts +47 -0
  213. package/dist/installer/targets/claude.d.ts.map +1 -0
  214. package/dist/installer/targets/claude.js +401 -0
  215. package/dist/installer/targets/claude.js.map +1 -0
  216. package/dist/installer/targets/codex.d.ts +18 -0
  217. package/dist/installer/targets/codex.d.ts.map +1 -0
  218. package/dist/installer/targets/codex.js +185 -0
  219. package/dist/installer/targets/codex.js.map +1 -0
  220. package/dist/installer/targets/cursor.d.ts +35 -0
  221. package/dist/installer/targets/cursor.d.ts.map +1 -0
  222. package/dist/installer/targets/cursor.js +283 -0
  223. package/dist/installer/targets/cursor.js.map +1 -0
  224. package/dist/installer/targets/gemini.d.ts +26 -0
  225. package/dist/installer/targets/gemini.d.ts.map +1 -0
  226. package/dist/installer/targets/gemini.js +165 -0
  227. package/dist/installer/targets/gemini.js.map +1 -0
  228. package/dist/installer/targets/hermes.d.ts +18 -0
  229. package/dist/installer/targets/hermes.d.ts.map +1 -0
  230. package/dist/installer/targets/hermes.js +359 -0
  231. package/dist/installer/targets/hermes.js.map +1 -0
  232. package/dist/installer/targets/kiro.d.ts +27 -0
  233. package/dist/installer/targets/kiro.d.ts.map +1 -0
  234. package/dist/installer/targets/kiro.js +196 -0
  235. package/dist/installer/targets/kiro.js.map +1 -0
  236. package/dist/installer/targets/opencode.d.ts +30 -0
  237. package/dist/installer/targets/opencode.d.ts.map +1 -0
  238. package/dist/installer/targets/opencode.js +235 -0
  239. package/dist/installer/targets/opencode.js.map +1 -0
  240. package/dist/installer/targets/registry.d.ts +35 -0
  241. package/dist/installer/targets/registry.d.ts.map +1 -0
  242. package/dist/installer/targets/registry.js +91 -0
  243. package/dist/installer/targets/registry.js.map +1 -0
  244. package/dist/installer/targets/shared.d.ts +77 -0
  245. package/dist/installer/targets/shared.d.ts.map +1 -0
  246. package/dist/installer/targets/shared.js +246 -0
  247. package/dist/installer/targets/shared.js.map +1 -0
  248. package/dist/installer/targets/toml.d.ts +52 -0
  249. package/dist/installer/targets/toml.d.ts.map +1 -0
  250. package/dist/installer/targets/toml.js +147 -0
  251. package/dist/installer/targets/toml.js.map +1 -0
  252. package/dist/installer/targets/types.d.ts +116 -0
  253. package/dist/installer/targets/types.d.ts.map +1 -0
  254. package/dist/installer/targets/types.js +16 -0
  255. package/dist/installer/targets/types.js.map +1 -0
  256. package/dist/mcp/daemon-paths.d.ts +46 -0
  257. package/dist/mcp/daemon-paths.d.ts.map +1 -0
  258. package/dist/mcp/daemon-paths.js +125 -0
  259. package/dist/mcp/daemon-paths.js.map +1 -0
  260. package/dist/mcp/daemon.d.ts +161 -0
  261. package/dist/mcp/daemon.d.ts.map +1 -0
  262. package/dist/mcp/daemon.js +403 -0
  263. package/dist/mcp/daemon.js.map +1 -0
  264. package/dist/mcp/engine.d.ts +100 -0
  265. package/dist/mcp/engine.d.ts.map +1 -0
  266. package/dist/mcp/engine.js +291 -0
  267. package/dist/mcp/engine.js.map +1 -0
  268. package/dist/mcp/index.d.ts +109 -0
  269. package/dist/mcp/index.d.ts.map +1 -0
  270. package/dist/mcp/index.js +470 -0
  271. package/dist/mcp/index.js.map +1 -0
  272. package/dist/mcp/proxy.d.ts +46 -0
  273. package/dist/mcp/proxy.d.ts.map +1 -0
  274. package/dist/mcp/proxy.js +276 -0
  275. package/dist/mcp/proxy.js.map +1 -0
  276. package/dist/mcp/server-instructions.d.ts +19 -0
  277. package/dist/mcp/server-instructions.d.ts.map +1 -0
  278. package/dist/mcp/server-instructions.js +73 -0
  279. package/dist/mcp/server-instructions.js.map +1 -0
  280. package/dist/mcp/session.d.ts +67 -0
  281. package/dist/mcp/session.d.ts.map +1 -0
  282. package/dist/mcp/session.js +276 -0
  283. package/dist/mcp/session.js.map +1 -0
  284. package/dist/mcp/tools.d.ts +385 -0
  285. package/dist/mcp/tools.d.ts.map +1 -0
  286. package/dist/mcp/tools.js +2545 -0
  287. package/dist/mcp/tools.js.map +1 -0
  288. package/dist/mcp/transport.d.ts +188 -0
  289. package/dist/mcp/transport.d.ts.map +1 -0
  290. package/dist/mcp/transport.js +343 -0
  291. package/dist/mcp/transport.js.map +1 -0
  292. package/dist/mcp/version.d.ts +19 -0
  293. package/dist/mcp/version.d.ts.map +1 -0
  294. package/dist/mcp/version.js +71 -0
  295. package/dist/mcp/version.js.map +1 -0
  296. package/dist/resolution/callback-synthesizer.d.ts +10 -0
  297. package/dist/resolution/callback-synthesizer.d.ts.map +1 -0
  298. package/dist/resolution/callback-synthesizer.js +924 -0
  299. package/dist/resolution/callback-synthesizer.js.map +1 -0
  300. package/dist/resolution/frameworks/cargo-workspace.d.ts +18 -0
  301. package/dist/resolution/frameworks/cargo-workspace.d.ts.map +1 -0
  302. package/dist/resolution/frameworks/cargo-workspace.js +225 -0
  303. package/dist/resolution/frameworks/cargo-workspace.js.map +1 -0
  304. package/dist/resolution/frameworks/csharp.d.ts +8 -0
  305. package/dist/resolution/frameworks/csharp.d.ts.map +1 -0
  306. package/dist/resolution/frameworks/csharp.js +241 -0
  307. package/dist/resolution/frameworks/csharp.js.map +1 -0
  308. package/dist/resolution/frameworks/drupal.d.ts +51 -0
  309. package/dist/resolution/frameworks/drupal.d.ts.map +1 -0
  310. package/dist/resolution/frameworks/drupal.js +367 -0
  311. package/dist/resolution/frameworks/drupal.js.map +1 -0
  312. package/dist/resolution/frameworks/expo-modules.d.ts +3 -0
  313. package/dist/resolution/frameworks/expo-modules.d.ts.map +1 -0
  314. package/dist/resolution/frameworks/expo-modules.js +143 -0
  315. package/dist/resolution/frameworks/expo-modules.js.map +1 -0
  316. package/dist/resolution/frameworks/express.d.ts +8 -0
  317. package/dist/resolution/frameworks/express.d.ts.map +1 -0
  318. package/dist/resolution/frameworks/express.js +308 -0
  319. package/dist/resolution/frameworks/express.js.map +1 -0
  320. package/dist/resolution/frameworks/fabric.d.ts +3 -0
  321. package/dist/resolution/frameworks/fabric.d.ts.map +1 -0
  322. package/dist/resolution/frameworks/fabric.js +354 -0
  323. package/dist/resolution/frameworks/fabric.js.map +1 -0
  324. package/dist/resolution/frameworks/go.d.ts +8 -0
  325. package/dist/resolution/frameworks/go.d.ts.map +1 -0
  326. package/dist/resolution/frameworks/go.js +161 -0
  327. package/dist/resolution/frameworks/go.js.map +1 -0
  328. package/dist/resolution/frameworks/index.d.ts +48 -0
  329. package/dist/resolution/frameworks/index.d.ts.map +1 -0
  330. package/dist/resolution/frameworks/index.js +161 -0
  331. package/dist/resolution/frameworks/index.js.map +1 -0
  332. package/dist/resolution/frameworks/java.d.ts +8 -0
  333. package/dist/resolution/frameworks/java.d.ts.map +1 -0
  334. package/dist/resolution/frameworks/java.js +504 -0
  335. package/dist/resolution/frameworks/java.js.map +1 -0
  336. package/dist/resolution/frameworks/laravel.d.ts +13 -0
  337. package/dist/resolution/frameworks/laravel.d.ts.map +1 -0
  338. package/dist/resolution/frameworks/laravel.js +257 -0
  339. package/dist/resolution/frameworks/laravel.js.map +1 -0
  340. package/dist/resolution/frameworks/nestjs.d.ts +26 -0
  341. package/dist/resolution/frameworks/nestjs.d.ts.map +1 -0
  342. package/dist/resolution/frameworks/nestjs.js +698 -0
  343. package/dist/resolution/frameworks/nestjs.js.map +1 -0
  344. package/dist/resolution/frameworks/play.d.ts +19 -0
  345. package/dist/resolution/frameworks/play.d.ts.map +1 -0
  346. package/dist/resolution/frameworks/play.js +111 -0
  347. package/dist/resolution/frameworks/play.js.map +1 -0
  348. package/dist/resolution/frameworks/python.d.ts +10 -0
  349. package/dist/resolution/frameworks/python.d.ts.map +1 -0
  350. package/dist/resolution/frameworks/python.js +396 -0
  351. package/dist/resolution/frameworks/python.js.map +1 -0
  352. package/dist/resolution/frameworks/react-native.d.ts +3 -0
  353. package/dist/resolution/frameworks/react-native.d.ts.map +1 -0
  354. package/dist/resolution/frameworks/react-native.js +360 -0
  355. package/dist/resolution/frameworks/react-native.js.map +1 -0
  356. package/dist/resolution/frameworks/react.d.ts +8 -0
  357. package/dist/resolution/frameworks/react.d.ts.map +1 -0
  358. package/dist/resolution/frameworks/react.js +365 -0
  359. package/dist/resolution/frameworks/react.js.map +1 -0
  360. package/dist/resolution/frameworks/ruby.d.ts +8 -0
  361. package/dist/resolution/frameworks/ruby.d.ts.map +1 -0
  362. package/dist/resolution/frameworks/ruby.js +302 -0
  363. package/dist/resolution/frameworks/ruby.js.map +1 -0
  364. package/dist/resolution/frameworks/rust.d.ts +8 -0
  365. package/dist/resolution/frameworks/rust.d.ts.map +1 -0
  366. package/dist/resolution/frameworks/rust.js +304 -0
  367. package/dist/resolution/frameworks/rust.js.map +1 -0
  368. package/dist/resolution/frameworks/svelte.d.ts +9 -0
  369. package/dist/resolution/frameworks/svelte.d.ts.map +1 -0
  370. package/dist/resolution/frameworks/svelte.js +249 -0
  371. package/dist/resolution/frameworks/svelte.js.map +1 -0
  372. package/dist/resolution/frameworks/swift-objc.d.ts +37 -0
  373. package/dist/resolution/frameworks/swift-objc.d.ts.map +1 -0
  374. package/dist/resolution/frameworks/swift-objc.js +252 -0
  375. package/dist/resolution/frameworks/swift-objc.js.map +1 -0
  376. package/dist/resolution/frameworks/swift.d.ts +10 -0
  377. package/dist/resolution/frameworks/swift.d.ts.map +1 -0
  378. package/dist/resolution/frameworks/swift.js +400 -0
  379. package/dist/resolution/frameworks/swift.js.map +1 -0
  380. package/dist/resolution/frameworks/vue.d.ts +9 -0
  381. package/dist/resolution/frameworks/vue.d.ts.map +1 -0
  382. package/dist/resolution/frameworks/vue.js +306 -0
  383. package/dist/resolution/frameworks/vue.js.map +1 -0
  384. package/dist/resolution/go-module.d.ts +26 -0
  385. package/dist/resolution/go-module.d.ts.map +1 -0
  386. package/dist/resolution/go-module.js +78 -0
  387. package/dist/resolution/go-module.js.map +1 -0
  388. package/dist/resolution/import-resolver.d.ts +68 -0
  389. package/dist/resolution/import-resolver.d.ts.map +1 -0
  390. package/dist/resolution/import-resolver.js +1231 -0
  391. package/dist/resolution/import-resolver.js.map +1 -0
  392. package/dist/resolution/index.d.ts +116 -0
  393. package/dist/resolution/index.d.ts.map +1 -0
  394. package/dist/resolution/index.js +878 -0
  395. package/dist/resolution/index.js.map +1 -0
  396. package/dist/resolution/lru-cache.d.ts +24 -0
  397. package/dist/resolution/lru-cache.d.ts.map +1 -0
  398. package/dist/resolution/lru-cache.js +62 -0
  399. package/dist/resolution/lru-cache.js.map +1 -0
  400. package/dist/resolution/name-matcher.d.ts +32 -0
  401. package/dist/resolution/name-matcher.d.ts.map +1 -0
  402. package/dist/resolution/name-matcher.js +596 -0
  403. package/dist/resolution/name-matcher.js.map +1 -0
  404. package/dist/resolution/path-aliases.d.ts +68 -0
  405. package/dist/resolution/path-aliases.d.ts.map +1 -0
  406. package/dist/resolution/path-aliases.js +238 -0
  407. package/dist/resolution/path-aliases.js.map +1 -0
  408. package/dist/resolution/strip-comments.d.ts +27 -0
  409. package/dist/resolution/strip-comments.d.ts.map +1 -0
  410. package/dist/resolution/strip-comments.js +441 -0
  411. package/dist/resolution/strip-comments.js.map +1 -0
  412. package/dist/resolution/swift-objc-bridge.d.ts +134 -0
  413. package/dist/resolution/swift-objc-bridge.d.ts.map +1 -0
  414. package/dist/resolution/swift-objc-bridge.js +256 -0
  415. package/dist/resolution/swift-objc-bridge.js.map +1 -0
  416. package/dist/resolution/types.d.ts +209 -0
  417. package/dist/resolution/types.d.ts.map +1 -0
  418. package/dist/resolution/types.js +8 -0
  419. package/dist/resolution/types.js.map +1 -0
  420. package/dist/search/query-parser.d.ts +57 -0
  421. package/dist/search/query-parser.d.ts.map +1 -0
  422. package/dist/search/query-parser.js +177 -0
  423. package/dist/search/query-parser.js.map +1 -0
  424. package/dist/search/query-utils.d.ts +53 -0
  425. package/dist/search/query-utils.d.ts.map +1 -0
  426. package/dist/search/query-utils.js +350 -0
  427. package/dist/search/query-utils.js.map +1 -0
  428. package/dist/sync/git-hooks.d.ts +45 -0
  429. package/dist/sync/git-hooks.d.ts.map +1 -0
  430. package/dist/sync/git-hooks.js +223 -0
  431. package/dist/sync/git-hooks.js.map +1 -0
  432. package/dist/sync/index.d.ts +19 -0
  433. package/dist/sync/index.d.ts.map +1 -0
  434. package/dist/sync/index.js +35 -0
  435. package/dist/sync/index.js.map +1 -0
  436. package/dist/sync/watch-policy.d.ts +48 -0
  437. package/dist/sync/watch-policy.d.ts.map +1 -0
  438. package/dist/sync/watch-policy.js +124 -0
  439. package/dist/sync/watch-policy.js.map +1 -0
  440. package/dist/sync/watcher.d.ts +191 -0
  441. package/dist/sync/watcher.d.ts.map +1 -0
  442. package/dist/sync/watcher.js +398 -0
  443. package/dist/sync/watcher.js.map +1 -0
  444. package/dist/sync/worktree.d.ts +54 -0
  445. package/dist/sync/worktree.d.ts.map +1 -0
  446. package/dist/sync/worktree.js +136 -0
  447. package/dist/sync/worktree.js.map +1 -0
  448. package/dist/types.d.ts +369 -0
  449. package/dist/types.d.ts.map +1 -0
  450. package/dist/types.js +78 -0
  451. package/dist/types.js.map +1 -0
  452. package/dist/ui/glyphs.d.ts +42 -0
  453. package/dist/ui/glyphs.d.ts.map +1 -0
  454. package/dist/ui/glyphs.js +78 -0
  455. package/dist/ui/glyphs.js.map +1 -0
  456. package/dist/ui/shimmer-progress.d.ts +11 -0
  457. package/dist/ui/shimmer-progress.d.ts.map +1 -0
  458. package/dist/ui/shimmer-progress.js +90 -0
  459. package/dist/ui/shimmer-progress.js.map +1 -0
  460. package/dist/ui/shimmer-worker.d.ts +2 -0
  461. package/dist/ui/shimmer-worker.d.ts.map +1 -0
  462. package/dist/ui/shimmer-worker.js +118 -0
  463. package/dist/ui/shimmer-worker.js.map +1 -0
  464. package/dist/ui/types.d.ts +17 -0
  465. package/dist/ui/types.d.ts.map +1 -0
  466. package/dist/ui/types.js +3 -0
  467. package/dist/ui/types.js.map +1 -0
  468. package/dist/utils.d.ts +205 -0
  469. package/dist/utils.d.ts.map +1 -0
  470. package/dist/utils.js +549 -0
  471. package/dist/utils.js.map +1 -0
  472. package/package.json +59 -0
  473. package/scripts/add-lang/bench.sh +60 -0
  474. package/scripts/add-lang/check-grammar.mjs +75 -0
  475. package/scripts/add-lang/dump-ast.mjs +103 -0
  476. package/scripts/add-lang/verify-extraction.mjs +70 -0
  477. package/scripts/agent-eval/arms-F.sh +21 -0
  478. package/scripts/agent-eval/arms-matrix.sh +37 -0
  479. package/scripts/agent-eval/audit.sh +68 -0
  480. package/scripts/agent-eval/bench-readme.sh +28 -0
  481. package/scripts/agent-eval/block-read-hook.sh +19 -0
  482. package/scripts/agent-eval/hook-settings.json +15 -0
  483. package/scripts/agent-eval/itrun.sh +107 -0
  484. package/scripts/agent-eval/parse-arms.mjs +116 -0
  485. package/scripts/agent-eval/parse-bench-readme.mjs +67 -0
  486. package/scripts/agent-eval/parse-run.mjs +45 -0
  487. package/scripts/agent-eval/parse-session.mjs +93 -0
  488. package/scripts/agent-eval/probe-context.mjs +21 -0
  489. package/scripts/agent-eval/probe-explore.mjs +40 -0
  490. package/scripts/agent-eval/probe-node.mjs +20 -0
  491. package/scripts/agent-eval/probe-trace.mjs +20 -0
  492. package/scripts/agent-eval/run-agent.sh +34 -0
  493. package/scripts/agent-eval/run-all.sh +67 -0
  494. package/scripts/agent-eval/run-arms.sh +56 -0
  495. package/scripts/agent-eval/seq-matrix.mjs +137 -0
  496. package/scripts/build-bundle.sh +118 -0
  497. package/scripts/extract-release-notes.mjs +130 -0
  498. package/scripts/local-install.sh +41 -0
  499. package/scripts/npm-shim.js +246 -0
  500. package/scripts/pack-npm.sh +95 -0
  501. package/scripts/prepare-release.mjs +270 -0
@@ -0,0 +1,1231 @@
1
+ "use strict";
2
+ /**
3
+ * Import Resolver
4
+ *
5
+ * Resolves import paths to actual files and symbols.
6
+ */
7
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8
+ if (k2 === undefined) k2 = k;
9
+ var desc = Object.getOwnPropertyDescriptor(m, k);
10
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11
+ desc = { enumerable: true, get: function() { return m[k]; } };
12
+ }
13
+ Object.defineProperty(o, k2, desc);
14
+ }) : (function(o, m, k, k2) {
15
+ if (k2 === undefined) k2 = k;
16
+ o[k2] = m[k];
17
+ }));
18
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
19
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
20
+ }) : function(o, v) {
21
+ o["default"] = v;
22
+ });
23
+ var __importStar = (this && this.__importStar) || (function () {
24
+ var ownKeys = function(o) {
25
+ ownKeys = Object.getOwnPropertyNames || function (o) {
26
+ var ar = [];
27
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
28
+ return ar;
29
+ };
30
+ return ownKeys(o);
31
+ };
32
+ return function (mod) {
33
+ if (mod && mod.__esModule) return mod;
34
+ var result = {};
35
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
36
+ __setModuleDefault(result, mod);
37
+ return result;
38
+ };
39
+ })();
40
+ Object.defineProperty(exports, "__esModule", { value: true });
41
+ exports.resolveImportPath = resolveImportPath;
42
+ exports.clearCppIncludeDirCache = clearCppIncludeDirCache;
43
+ exports.loadCppIncludeDirs = loadCppIncludeDirs;
44
+ exports.extractImportMappings = extractImportMappings;
45
+ exports.clearImportMappingCache = clearImportMappingCache;
46
+ exports.extractReExports = extractReExports;
47
+ exports.resolveJvmImport = resolveJvmImport;
48
+ exports.resolveViaImport = resolveViaImport;
49
+ const fs = __importStar(require("fs"));
50
+ const path = __importStar(require("path"));
51
+ const path_aliases_1 = require("./path-aliases");
52
+ /**
53
+ * Extension resolution order by language
54
+ */
55
+ const EXTENSION_RESOLUTION = {
56
+ typescript: ['.ts', '.tsx', '.d.ts', '.js', '.jsx', '/index.ts', '/index.tsx', '/index.js'],
57
+ javascript: ['.js', '.jsx', '.mjs', '.cjs', '/index.js', '/index.jsx'],
58
+ tsx: ['.tsx', '.ts', '.d.ts', '.js', '.jsx', '/index.tsx', '/index.ts', '/index.js'],
59
+ jsx: ['.jsx', '.js', '/index.jsx', '/index.js'],
60
+ python: ['.py', '/__init__.py'],
61
+ go: ['.go'],
62
+ rust: ['.rs', '/mod.rs'],
63
+ java: ['.java'],
64
+ c: ['.h', '.c'],
65
+ cpp: ['.h', '.hpp', '.hxx', '.cpp', '.cc', '.cxx'],
66
+ csharp: ['.cs'],
67
+ php: ['.php'],
68
+ ruby: ['.rb'],
69
+ objc: ['.h', '.m', '.mm'],
70
+ };
71
+ /**
72
+ * Resolve an import path to an actual file
73
+ */
74
+ function resolveImportPath(importPath, fromFile, language, context) {
75
+ // Skip external/npm packages — but pass the context so the
76
+ // bare-specifier heuristic can consult the project's tsconfig
77
+ // alias map first (custom prefixes like `@components/*` would
78
+ // otherwise be misclassified as npm).
79
+ if (isExternalImport(importPath, language, context)) {
80
+ return null;
81
+ }
82
+ const projectRoot = context.getProjectRoot();
83
+ const fromDir = path.dirname(path.join(projectRoot, fromFile));
84
+ // Handle relative imports
85
+ if (importPath.startsWith('.')) {
86
+ return resolveRelativeImport(importPath, fromDir, language, context);
87
+ }
88
+ // Handle absolute/aliased imports (like @/ or src/)
89
+ const aliased = resolveAliasedImport(importPath, projectRoot, language, context);
90
+ if (aliased)
91
+ return aliased;
92
+ // C/C++ include directory search: when neither relative nor aliased
93
+ // resolution found a match, search -I directories from
94
+ // compile_commands.json or heuristic probing.
95
+ if (language === 'c' || language === 'cpp') {
96
+ return resolveCppIncludePath(importPath, language, context);
97
+ }
98
+ return null;
99
+ }
100
+ /**
101
+ * C and C++ standard library header names (without delimiters).
102
+ * Used by isExternalImport to filter system includes from resolution.
103
+ */
104
+ const C_CPP_STDLIB_HEADERS = new Set([
105
+ // C standard library headers
106
+ 'assert.h', 'complex.h', 'ctype.h', 'errno.h', 'fenv.h', 'float.h',
107
+ 'inttypes.h', 'iso646.h', 'limits.h', 'locale.h', 'math.h', 'setjmp.h',
108
+ 'signal.h', 'stdalign.h', 'stdarg.h', 'stdatomic.h', 'stdbool.h',
109
+ 'stddef.h', 'stdint.h', 'stdio.h', 'stdlib.h', 'stdnoreturn.h',
110
+ 'string.h', 'tgmath.h', 'threads.h', 'time.h', 'uchar.h', 'wchar.h',
111
+ 'wctype.h',
112
+ // C++ C-library wrappers (cname form)
113
+ 'cassert', 'ccomplex', 'cctype', 'cerrno', 'cfenv', 'cfloat',
114
+ 'cinttypes', 'ciso646', 'climits', 'clocale', 'cmath', 'csetjmp',
115
+ 'csignal', 'cstdalign', 'cstdarg', 'cstdbool', 'cstddef', 'cstdint',
116
+ 'cstdio', 'cstdlib', 'cstring', 'ctgmath', 'ctime', 'cuchar',
117
+ 'cwchar', 'cwctype',
118
+ // C++ STL headers
119
+ 'algorithm', 'any', 'array', 'atomic', 'barrier', 'bit', 'bitset',
120
+ 'charconv', 'chrono', 'codecvt', 'compare', 'complex', 'concepts',
121
+ 'condition_variable', 'coroutine', 'deque', 'exception', 'execution',
122
+ 'expected', 'filesystem', 'format', 'forward_list', 'fstream',
123
+ 'functional', 'future', 'generator', 'initializer_list', 'iomanip',
124
+ 'ios', 'iosfwd', 'iostream', 'istream', 'iterator', 'latch',
125
+ 'limits', 'list', 'locale', 'map', 'mdspan', 'memory', 'memory_resource',
126
+ 'mutex', 'new', 'numbers', 'numeric', 'optional', 'ostream', 'print',
127
+ 'queue', 'random', 'ranges', 'ratio', 'regex', 'scoped_allocator',
128
+ 'semaphore', 'set', 'shared_mutex', 'source_location', 'span',
129
+ 'spanstream', 'sstream', 'stack', 'stacktrace', 'stdexcept',
130
+ 'stdfloat', 'stop_token', 'streambuf', 'string', 'string_view',
131
+ 'strstream', 'syncstream', 'system_error', 'thread', 'tuple',
132
+ 'type_traits', 'typeindex', 'typeinfo', 'unordered_map',
133
+ 'unordered_set', 'utility', 'valarray', 'variant', 'vector',
134
+ 'version',
135
+ ]);
136
+ /**
137
+ * Check if an import is external (npm package, etc.)
138
+ *
139
+ * `context` is consulted for project-defined path aliases
140
+ * (tsconfig/jsconfig `paths`). Without that check, custom prefixes
141
+ * like `@components/*` would fail the bare-specifier heuristic and
142
+ * be classified as external before alias resolution can run.
143
+ */
144
+ function isExternalImport(importPath, language, context) {
145
+ // Relative imports are not external
146
+ if (importPath.startsWith('.')) {
147
+ return false;
148
+ }
149
+ // Common external patterns
150
+ if (language === 'typescript' || language === 'javascript' || language === 'tsx' || language === 'jsx') {
151
+ // Node built-ins
152
+ if (['fs', 'path', 'os', 'crypto', 'http', 'https', 'url', 'util', 'events', 'stream', 'child_process', 'buffer'].includes(importPath)) {
153
+ return true;
154
+ }
155
+ // Project-defined alias prefix? Treat as local.
156
+ const aliases = context?.getProjectAliases?.();
157
+ if (aliases) {
158
+ for (const pat of aliases.patterns) {
159
+ if (importPath.startsWith(pat.prefix))
160
+ return false;
161
+ }
162
+ }
163
+ // Scoped packages or bare specifiers that don't start with aliases
164
+ if (!importPath.startsWith('@/') && !importPath.startsWith('~/') && !importPath.startsWith('src/')) {
165
+ // Likely an npm package
166
+ return true;
167
+ }
168
+ }
169
+ if (language === 'python') {
170
+ // Standard library modules
171
+ const stdLibs = ['os', 'sys', 'json', 're', 'math', 'datetime', 'collections', 'typing', 'pathlib', 'logging'];
172
+ if (stdLibs.includes(importPath.split('.')[0])) {
173
+ return true;
174
+ }
175
+ }
176
+ if (language === 'go') {
177
+ // Relative imports (rare in idiomatic Go but the grammar allows them).
178
+ if (importPath.startsWith('.')) {
179
+ return false;
180
+ }
181
+ // In-module imports look like `<module-path>/sub/pkg` — local to
182
+ // this project. Without the module-path check we'd flag every
183
+ // cross-package call in a Go monorepo as external (issue #388).
184
+ const mod = context?.getGoModule?.();
185
+ if (mod && (importPath === mod.modulePath || importPath.startsWith(mod.modulePath + '/'))) {
186
+ return false;
187
+ }
188
+ // `internal/` packages stay local even when go.mod is missing —
189
+ // preserves the pre-#388 escape hatch for repos without a parsed module path.
190
+ if (importPath.includes('/internal/')) {
191
+ return false;
192
+ }
193
+ // Anything else is the Go standard library or a third-party module.
194
+ return true;
195
+ }
196
+ if (language === 'c' || language === 'cpp') {
197
+ // C/C++ standard library headers — both C-style (<stdio.h>) and
198
+ // C++-style (<cstdio>, <vector>) forms. Checked against the import
199
+ // path (which the extractor strips of <> or "" delimiters).
200
+ if (C_CPP_STDLIB_HEADERS.has(importPath))
201
+ return true;
202
+ // C++ headers without .h extension (e.g. "vector", "string")
203
+ const withoutExt = importPath.replace(/\.h$/, '');
204
+ if (C_CPP_STDLIB_HEADERS.has(withoutExt))
205
+ return true;
206
+ }
207
+ return false;
208
+ }
209
+ /**
210
+ * Resolve a relative import
211
+ */
212
+ function resolveRelativeImport(importPath, fromDir, language, context) {
213
+ const projectRoot = context.getProjectRoot();
214
+ const extensions = EXTENSION_RESOLUTION[language] || [];
215
+ // Try the path as-is first
216
+ const basePath = path.resolve(fromDir, importPath);
217
+ const relativePath = path.relative(projectRoot, basePath).replace(/\\/g, '/');
218
+ // Try each extension
219
+ for (const ext of extensions) {
220
+ const candidatePath = relativePath + ext;
221
+ if (context.fileExists(candidatePath)) {
222
+ return candidatePath;
223
+ }
224
+ }
225
+ // Try without extension (might already have one)
226
+ if (context.fileExists(relativePath)) {
227
+ return relativePath;
228
+ }
229
+ return null;
230
+ }
231
+ /**
232
+ * Resolve an aliased/absolute import.
233
+ *
234
+ * Tries, in order:
235
+ * 1. Project-defined `compilerOptions.paths` (tsconfig/jsconfig).
236
+ * Each pattern can have multiple replacements; tried in tsconfig
237
+ * priority order with extension permutations.
238
+ * 2. The legacy hard-coded fallback list (`@/`, `~/`, `src/`, ...)
239
+ * for projects that have aliases but no tsconfig paths block.
240
+ * 3. Direct path lookup (with extensions).
241
+ */
242
+ function resolveAliasedImport(importPath, projectRoot, language, context) {
243
+ const extensions = EXTENSION_RESOLUTION[language] || [];
244
+ const tryWithExt = (basePath) => {
245
+ for (const ext of extensions) {
246
+ const candidate = basePath + ext;
247
+ if (context.fileExists(candidate))
248
+ return candidate;
249
+ }
250
+ if (context.fileExists(basePath))
251
+ return basePath;
252
+ return null;
253
+ };
254
+ // 1. Project tsconfig/jsconfig paths.
255
+ const aliasMap = context.getProjectAliases?.();
256
+ if (aliasMap) {
257
+ const candidates = (0, path_aliases_1.applyAliases)(importPath, aliasMap, projectRoot);
258
+ for (const c of candidates) {
259
+ const hit = tryWithExt(c);
260
+ if (hit)
261
+ return hit;
262
+ }
263
+ }
264
+ // 2. Hard-coded fallback list. Kept for projects that use these
265
+ // conventional aliases without declaring them in tsconfig.
266
+ const fallbackAliases = {
267
+ '@/': 'src/',
268
+ '~/': 'src/',
269
+ '@src/': 'src/',
270
+ 'src/': 'src/',
271
+ '@app/': 'app/',
272
+ 'app/': 'app/',
273
+ };
274
+ for (const [alias, replacement] of Object.entries(fallbackAliases)) {
275
+ if (importPath.startsWith(alias)) {
276
+ const hit = tryWithExt(importPath.replace(alias, replacement));
277
+ if (hit)
278
+ return hit;
279
+ }
280
+ }
281
+ // 3. Direct path.
282
+ return tryWithExt(importPath);
283
+ }
284
+ /**
285
+ * C/C++ include directory cache (keyed by project root).
286
+ * Loaded once per resolver instance, shared across calls.
287
+ */
288
+ const cppIncludeDirCache = new Map();
289
+ /**
290
+ * Clear the C/C++ include directory cache (call between indexing runs)
291
+ */
292
+ function clearCppIncludeDirCache() {
293
+ cppIncludeDirCache.clear();
294
+ }
295
+ /**
296
+ * Discover C/C++ include search directories for a project.
297
+ *
298
+ * Strategy:
299
+ * 1. Look for compile_commands.json (Clang compilation database) in the
300
+ * project root and common build subdirectories. Parse -I and -isystem
301
+ * flags from compiler commands.
302
+ * 2. If no compilation database is found, probe for common convention
303
+ * directories (include/, src/, lib/, api/) and top-level directories
304
+ * containing .h/.hpp files.
305
+ *
306
+ * Returns paths relative to projectRoot.
307
+ */
308
+ function loadCppIncludeDirs(projectRoot) {
309
+ const cached = cppIncludeDirCache.get(projectRoot);
310
+ if (cached !== undefined)
311
+ return cached;
312
+ const dirs = loadCppIncludeDirsFromCompileDB(projectRoot)
313
+ || loadCppIncludeDirsHeuristic(projectRoot);
314
+ cppIncludeDirCache.set(projectRoot, dirs);
315
+ return dirs;
316
+ }
317
+ /**
318
+ * Try to load include directories from compile_commands.json.
319
+ * Returns null if no compilation database is found (so the heuristic
320
+ * fallback can run). Returns an array (possibly empty) otherwise.
321
+ */
322
+ function loadCppIncludeDirsFromCompileDB(projectRoot) {
323
+ const candidates = [
324
+ path.join(projectRoot, 'compile_commands.json'),
325
+ path.join(projectRoot, 'build', 'compile_commands.json'),
326
+ path.join(projectRoot, 'cmake-build-debug', 'compile_commands.json'),
327
+ path.join(projectRoot, 'cmake-build-release', 'compile_commands.json'),
328
+ path.join(projectRoot, 'out', 'compile_commands.json'),
329
+ ];
330
+ let dbPath;
331
+ for (const c of candidates) {
332
+ try {
333
+ if (fs.existsSync(c)) {
334
+ dbPath = c;
335
+ break;
336
+ }
337
+ }
338
+ catch {
339
+ // ignore
340
+ }
341
+ }
342
+ if (!dbPath)
343
+ return null;
344
+ try {
345
+ const content = fs.readFileSync(dbPath, 'utf-8');
346
+ const entries = JSON.parse(content);
347
+ if (!Array.isArray(entries))
348
+ return null;
349
+ const dirSet = new Set();
350
+ for (const entry of entries) {
351
+ const dir = entry.directory || projectRoot;
352
+ const args = entry.arguments || (entry.command ? shlexSplit(entry.command) : []);
353
+ for (let i = 0; i < args.length; i++) {
354
+ const arg = args[i];
355
+ let includeDir;
356
+ // -I<dir> (no space)
357
+ if (arg.startsWith('-I') && arg.length > 2) {
358
+ includeDir = arg.substring(2);
359
+ }
360
+ // -isystem <dir> (space-separated)
361
+ else if ((arg === '-isystem' || arg === '-I') && i + 1 < args.length) {
362
+ includeDir = args[i + 1];
363
+ i++; // skip next arg
364
+ }
365
+ if (includeDir) {
366
+ // Normalize: resolve relative to the compilation directory
367
+ const absPath = path.isAbsolute(includeDir)
368
+ ? includeDir
369
+ : path.resolve(dir, includeDir);
370
+ const relPath = path.relative(projectRoot, absPath).replace(/\\/g, '/');
371
+ // Skip system directories and paths outside the project
372
+ // (relative paths starting with .. or absolute paths like
373
+ // /usr/include or C:\usr on Windows)
374
+ if (!relPath.startsWith('..') && relPath.length > 0 && !path.isAbsolute(relPath)) {
375
+ dirSet.add(relPath);
376
+ }
377
+ }
378
+ }
379
+ }
380
+ return Array.from(dirSet);
381
+ }
382
+ catch {
383
+ return null;
384
+ }
385
+ }
386
+ /**
387
+ * Minimal shlex-style split for compiler command strings.
388
+ * Handles double-quoted and single-quoted arguments.
389
+ */
390
+ function shlexSplit(cmd) {
391
+ const result = [];
392
+ let i = 0;
393
+ while (i < cmd.length) {
394
+ // Skip whitespace
395
+ while (i < cmd.length && /\s/.test(cmd[i]))
396
+ i++;
397
+ if (i >= cmd.length)
398
+ break;
399
+ const ch = cmd[i];
400
+ if (ch === '"') {
401
+ i++;
402
+ let arg = '';
403
+ while (i < cmd.length && cmd[i] !== '"') {
404
+ if (cmd[i] === '\\' && i + 1 < cmd.length) {
405
+ i++;
406
+ arg += cmd[i];
407
+ }
408
+ else {
409
+ arg += cmd[i];
410
+ }
411
+ i++;
412
+ }
413
+ i++; // closing quote
414
+ result.push(arg);
415
+ }
416
+ else if (ch === "'") {
417
+ i++;
418
+ let arg = '';
419
+ while (i < cmd.length && cmd[i] !== "'") {
420
+ arg += cmd[i];
421
+ i++;
422
+ }
423
+ i++; // closing quote
424
+ result.push(arg);
425
+ }
426
+ else {
427
+ let arg = '';
428
+ while (i < cmd.length && !/\s/.test(cmd[i])) {
429
+ arg += cmd[i];
430
+ i++;
431
+ }
432
+ result.push(arg);
433
+ }
434
+ }
435
+ return result;
436
+ }
437
+ /**
438
+ * Heuristic include directory discovery when no compile_commands.json exists.
439
+ * Checks common convention directories and scans top-level dirs for headers.
440
+ */
441
+ function loadCppIncludeDirsHeuristic(projectRoot) {
442
+ const dirs = [];
443
+ const conventionDirs = ['include', 'src', 'lib', 'api', 'inc'];
444
+ try {
445
+ const entries = fs.readdirSync(projectRoot, { withFileTypes: true });
446
+ for (const entry of entries) {
447
+ if (!entry.isDirectory())
448
+ continue;
449
+ const name = entry.name;
450
+ // Convention directories
451
+ if (conventionDirs.includes(name.toLowerCase())) {
452
+ dirs.push(name);
453
+ continue;
454
+ }
455
+ // Any top-level directory containing .h or .hpp files
456
+ try {
457
+ const subFiles = fs.readdirSync(path.join(projectRoot, name));
458
+ if (subFiles.some(f => /\.(h|hpp|hxx|hh)$/i.test(f))) {
459
+ dirs.push(name);
460
+ }
461
+ }
462
+ catch {
463
+ // ignore permission errors
464
+ }
465
+ }
466
+ }
467
+ catch {
468
+ // ignore
469
+ }
470
+ return dirs;
471
+ }
472
+ /**
473
+ * Resolve a C/C++ include path by searching include directories.
474
+ * Called as a fallback after relative and aliased resolution fail.
475
+ */
476
+ function resolveCppIncludePath(importPath, language, context) {
477
+ const includeDirs = context.getCppIncludeDirs?.() ?? [];
478
+ const extensions = EXTENSION_RESOLUTION[language] ?? [];
479
+ for (const dir of includeDirs) {
480
+ const normalizedDir = dir.replace(/\\/g, '/');
481
+ for (const ext of extensions) {
482
+ const candidate = normalizedDir + '/' + importPath + ext;
483
+ if (context.fileExists(candidate))
484
+ return candidate;
485
+ }
486
+ // Try as-is (already has extension)
487
+ const candidate = normalizedDir + '/' + importPath;
488
+ if (context.fileExists(candidate))
489
+ return candidate;
490
+ }
491
+ return null;
492
+ }
493
+ /**
494
+ * Extract import mappings from a file
495
+ */
496
+ function extractImportMappings(_filePath, content, language) {
497
+ const mappings = [];
498
+ if (language === 'typescript' || language === 'javascript' || language === 'tsx' || language === 'jsx') {
499
+ mappings.push(...extractJSImports(content));
500
+ }
501
+ else if (language === 'python') {
502
+ mappings.push(...extractPythonImports(content));
503
+ }
504
+ else if (language === 'go') {
505
+ mappings.push(...extractGoImports(content));
506
+ }
507
+ else if (language === 'java' || language === 'kotlin') {
508
+ mappings.push(...extractJavaImports(content));
509
+ }
510
+ else if (language === 'php') {
511
+ mappings.push(...extractPHPImports(content));
512
+ }
513
+ else if (language === 'c' || language === 'cpp') {
514
+ mappings.push(...extractCppImports(content));
515
+ }
516
+ return mappings;
517
+ }
518
+ /**
519
+ * Extract JS/TS import mappings
520
+ */
521
+ function extractJSImports(content) {
522
+ const mappings = [];
523
+ // ES6 imports
524
+ const importRegex = /import\s+(?:(\w+)\s*,?\s*)?(?:\{([^}]+)\})?\s*(?:(\*)\s+as\s+(\w+))?\s*from\s*['"]([^'"]+)['"]/g;
525
+ let match;
526
+ while ((match = importRegex.exec(content)) !== null) {
527
+ const [, defaultImport, namedImports, star, namespaceAlias, source] = match;
528
+ // Default import
529
+ if (defaultImport) {
530
+ mappings.push({
531
+ localName: defaultImport,
532
+ exportedName: 'default',
533
+ source: source,
534
+ isDefault: true,
535
+ isNamespace: false,
536
+ });
537
+ }
538
+ // Named imports
539
+ if (namedImports) {
540
+ const names = namedImports.split(',').map((s) => s.trim());
541
+ for (const name of names) {
542
+ const aliasMatch = name.match(/(\w+)\s+as\s+(\w+)/);
543
+ if (aliasMatch) {
544
+ mappings.push({
545
+ localName: aliasMatch[2],
546
+ exportedName: aliasMatch[1],
547
+ source: source,
548
+ isDefault: false,
549
+ isNamespace: false,
550
+ });
551
+ }
552
+ else if (name) {
553
+ mappings.push({
554
+ localName: name,
555
+ exportedName: name,
556
+ source: source,
557
+ isDefault: false,
558
+ isNamespace: false,
559
+ });
560
+ }
561
+ }
562
+ }
563
+ // Namespace import
564
+ if (star && namespaceAlias) {
565
+ mappings.push({
566
+ localName: namespaceAlias,
567
+ exportedName: '*',
568
+ source: source,
569
+ isDefault: false,
570
+ isNamespace: true,
571
+ });
572
+ }
573
+ }
574
+ // Require statements
575
+ const requireRegex = /(?:const|let|var)\s+(?:(\w+)|{([^}]+)})\s*=\s*require\(['"]([^'"]+)['"]\)/g;
576
+ while ((match = requireRegex.exec(content)) !== null) {
577
+ const [, defaultName, destructured, source] = match;
578
+ if (defaultName) {
579
+ mappings.push({
580
+ localName: defaultName,
581
+ exportedName: 'default',
582
+ source: source,
583
+ isDefault: true,
584
+ isNamespace: false,
585
+ });
586
+ }
587
+ if (destructured) {
588
+ const names = destructured.split(',').map((s) => s.trim());
589
+ for (const name of names) {
590
+ const aliasMatch = name.match(/(\w+)\s*:\s*(\w+)/);
591
+ if (aliasMatch) {
592
+ mappings.push({
593
+ localName: aliasMatch[2],
594
+ exportedName: aliasMatch[1],
595
+ source: source,
596
+ isDefault: false,
597
+ isNamespace: false,
598
+ });
599
+ }
600
+ else if (name) {
601
+ mappings.push({
602
+ localName: name,
603
+ exportedName: name,
604
+ source: source,
605
+ isDefault: false,
606
+ isNamespace: false,
607
+ });
608
+ }
609
+ }
610
+ }
611
+ }
612
+ return mappings;
613
+ }
614
+ /**
615
+ * Extract Python import mappings
616
+ */
617
+ function extractPythonImports(content) {
618
+ const mappings = [];
619
+ // from X import Y
620
+ const fromImportRegex = /from\s+([\w.]+)\s+import\s+([^#\n]+)/g;
621
+ let match;
622
+ while ((match = fromImportRegex.exec(content)) !== null) {
623
+ const [, source, imports] = match;
624
+ const names = imports.split(',').map((s) => s.trim());
625
+ for (const name of names) {
626
+ const aliasMatch = name.match(/(\w+)\s+as\s+(\w+)/);
627
+ if (aliasMatch) {
628
+ mappings.push({
629
+ localName: aliasMatch[2],
630
+ exportedName: aliasMatch[1],
631
+ source: source,
632
+ isDefault: false,
633
+ isNamespace: false,
634
+ });
635
+ }
636
+ else if (name && name !== '*') {
637
+ mappings.push({
638
+ localName: name,
639
+ exportedName: name,
640
+ source: source,
641
+ isDefault: false,
642
+ isNamespace: false,
643
+ });
644
+ }
645
+ }
646
+ }
647
+ // import X
648
+ const importRegex = /^import\s+([\w.]+)(?:\s+as\s+(\w+))?/gm;
649
+ while ((match = importRegex.exec(content)) !== null) {
650
+ const [, source, alias] = match;
651
+ const localName = alias || source.split('.').pop();
652
+ mappings.push({
653
+ localName,
654
+ exportedName: '*',
655
+ source: source,
656
+ isDefault: false,
657
+ isNamespace: true,
658
+ });
659
+ }
660
+ return mappings;
661
+ }
662
+ /**
663
+ * Extract Go import mappings
664
+ */
665
+ function extractGoImports(content) {
666
+ const mappings = [];
667
+ // import "path" or import alias "path"
668
+ const singleImportRegex = /import\s+(?:(\w+)\s+)?["']([^"']+)["']/g;
669
+ let match;
670
+ while ((match = singleImportRegex.exec(content)) !== null) {
671
+ const [, alias, source] = match;
672
+ const packageName = source.split('/').pop();
673
+ mappings.push({
674
+ localName: alias || packageName,
675
+ exportedName: '*',
676
+ source: source,
677
+ isDefault: false,
678
+ isNamespace: true,
679
+ });
680
+ }
681
+ // import ( ... ) block
682
+ const blockImportRegex = /import\s*\(\s*([^)]+)\s*\)/gs;
683
+ while ((match = blockImportRegex.exec(content)) !== null) {
684
+ const block = match[1];
685
+ const lineRegex = /(?:(\w+)\s+)?["']([^"']+)["']/g;
686
+ let lineMatch;
687
+ while ((lineMatch = lineRegex.exec(block)) !== null) {
688
+ const [, alias, source] = lineMatch;
689
+ const packageName = source.split('/').pop();
690
+ mappings.push({
691
+ localName: alias || packageName,
692
+ exportedName: '*',
693
+ source: source,
694
+ isDefault: false,
695
+ isNamespace: true,
696
+ });
697
+ }
698
+ }
699
+ return mappings;
700
+ }
701
+ /**
702
+ * Extract Java / Kotlin import mappings.
703
+ *
704
+ * Java/Kotlin imports carry the full qualified name of the imported
705
+ * symbol — `import com.example.dao.converter.FooConverter;` — which is
706
+ * exactly the disambiguation signal we need when two packages both
707
+ * declare a `FooConverter`. Pre-#314 the resolver had no Java branch
708
+ * here at all, so this mapping was empty and cross-module name
709
+ * collisions were resolved by file-path proximity (often wrongly).
710
+ *
711
+ * `import static com.example.Foo.bar;` is parsed as a local-name `bar`
712
+ * pointing at FQN `com.example.Foo.bar` so static-method call sites
713
+ * (`bar(...)`) can resolve through the same import lookup.
714
+ */
715
+ function extractJavaImports(content) {
716
+ const mappings = [];
717
+ // Strip line and block comments so `// import foo;` doesn't false-match.
718
+ const stripped = content
719
+ .replace(/\/\*[\s\S]*?\*\//g, '')
720
+ .replace(/\/\/[^\n]*/g, '');
721
+ // `import [static] <fqn>[.*];`
722
+ const re = /^\s*import\s+(static\s+)?([\w.]+(?:\.\*)?)\s*;/gm;
723
+ let match;
724
+ while ((match = re.exec(stripped)) !== null) {
725
+ const fqn = match[2];
726
+ // `import com.example.*;` — wildcard. We can't materialize a single
727
+ // local name; skip and let name-matching handle members reachable
728
+ // through the wildcard. (Future enhancement: enumerate package files.)
729
+ if (fqn.endsWith('.*'))
730
+ continue;
731
+ const parts = fqn.split('.');
732
+ const localName = parts[parts.length - 1];
733
+ if (!localName)
734
+ continue;
735
+ mappings.push({
736
+ localName,
737
+ exportedName: localName,
738
+ source: fqn,
739
+ isDefault: false,
740
+ isNamespace: false,
741
+ });
742
+ }
743
+ return mappings;
744
+ }
745
+ /**
746
+ * Extract PHP import mappings (use statements)
747
+ */
748
+ function extractPHPImports(content) {
749
+ const mappings = [];
750
+ // use Namespace\Class; or use Namespace\Class as Alias;
751
+ const useRegex = /use\s+([\w\\]+)(?:\s+as\s+(\w+))?;/g;
752
+ let match;
753
+ while ((match = useRegex.exec(content)) !== null) {
754
+ const [, fullPath, alias] = match;
755
+ const className = fullPath.split('\\').pop();
756
+ mappings.push({
757
+ localName: alias || className,
758
+ exportedName: className,
759
+ source: fullPath,
760
+ isDefault: false,
761
+ isNamespace: false,
762
+ });
763
+ }
764
+ return mappings;
765
+ }
766
+ /**
767
+ * Extract C/C++ import mappings from #include directives.
768
+ *
769
+ * #include brings all symbols from the included header into scope
770
+ * (namespace import), so each mapping uses isNamespace: true and
771
+ * exportedName: '*'. The localName is set to the header's basename
772
+ * without extension so that symbol references like `MyClass` can
773
+ * match against any include that might provide it.
774
+ */
775
+ function extractCppImports(content) {
776
+ const mappings = [];
777
+ // Match both #include <...> and #include "..."
778
+ const includeRegex = /^\s*#\s*include\s+[<"]([^>"]+)[>"]/gm;
779
+ let match;
780
+ while ((match = includeRegex.exec(content)) !== null) {
781
+ const modulePath = match[1];
782
+ // Basename without extension for localName matching
783
+ const basename = modulePath.split('/').pop().replace(/\.(h|hpp|hxx|hh|inl|ipp|cxx|cc|cpp)$/, '');
784
+ mappings.push({
785
+ localName: basename || modulePath,
786
+ exportedName: '*',
787
+ source: modulePath,
788
+ isDefault: false,
789
+ isNamespace: true,
790
+ });
791
+ }
792
+ return mappings;
793
+ }
794
+ // Cache import mappings per file to avoid re-reading and re-parsing
795
+ const importMappingCache = new Map();
796
+ /**
797
+ * Clear the import mapping cache (call between indexing runs)
798
+ */
799
+ function clearImportMappingCache() {
800
+ importMappingCache.clear();
801
+ cppIncludeDirCache.clear();
802
+ }
803
+ /**
804
+ * Strip JS line + block comments from `content` while preserving
805
+ * string literals (so `"//"` inside a string stays intact). Used by
806
+ * {@link extractReExports} so commented-out export-from statements
807
+ * don't generate phantom re-export edges.
808
+ *
809
+ * Scanner is deliberately small: it only tracks the three contexts
810
+ * relevant for JS/TS — single-quote string, double-quote string, and
811
+ * template literal. Comment recognition is the JS spec subset, no
812
+ * regex-literal awareness (which is fine for our use case: we don't
813
+ * apply this to function bodies, only to top-level files).
814
+ */
815
+ function stripJsComments(content) {
816
+ let out = '';
817
+ let i = 0;
818
+ let str = null;
819
+ while (i < content.length) {
820
+ const ch = content[i];
821
+ if (str !== null) {
822
+ out += ch;
823
+ if (ch === '\\' && i + 1 < content.length) {
824
+ out += content[i + 1];
825
+ i += 2;
826
+ continue;
827
+ }
828
+ if (ch === str)
829
+ str = null;
830
+ i++;
831
+ continue;
832
+ }
833
+ if (ch === '"' || ch === "'" || ch === '`') {
834
+ str = ch;
835
+ out += ch;
836
+ i++;
837
+ continue;
838
+ }
839
+ if (ch === '/' && content[i + 1] === '/') {
840
+ while (i < content.length && content[i] !== '\n')
841
+ i++;
842
+ continue;
843
+ }
844
+ if (ch === '/' && content[i + 1] === '*') {
845
+ i += 2;
846
+ while (i < content.length && !(content[i] === '*' && content[i + 1] === '/'))
847
+ i++;
848
+ i += 2;
849
+ continue;
850
+ }
851
+ out += ch;
852
+ i++;
853
+ }
854
+ return out;
855
+ }
856
+ /**
857
+ * Extract JS/TS re-export declarations from `content`.
858
+ *
859
+ * Recognised forms:
860
+ * export { foo } from './a';
861
+ * export { foo as bar } from './a';
862
+ * export * from './a';
863
+ * export * as ns from './a'; (treated as wildcard for chasing)
864
+ * export { default as Foo } from './a';
865
+ *
866
+ * The walker intentionally stays regex-based — the import-resolver
867
+ * elsewhere in this file already chooses regex over a fresh
868
+ * tree-sitter pass, and this function shares that trade-off. Errors
869
+ * fall through silently; resolution simply skips the broken file.
870
+ */
871
+ function extractReExports(content, language) {
872
+ if (language !== 'typescript' &&
873
+ language !== 'javascript' &&
874
+ language !== 'tsx' &&
875
+ language !== 'jsx') {
876
+ return [];
877
+ }
878
+ const out = [];
879
+ // Pre-strip block comments + line comments so a commented-out
880
+ // `// export { x } from '...'` doesn't produce a phantom edge.
881
+ // (Template literals are still a possible source of false positives;
882
+ // a project that builds export statements as runtime strings is
883
+ // out of scope.)
884
+ const cleaned = stripJsComments(content);
885
+ // Wildcard: `export * from '...'` or `export * as ns from '...'`
886
+ const wildcardRe = /export\s*\*(?:\s+as\s+\w+)?\s*from\s*['"]([^'"]+)['"]/g;
887
+ let m;
888
+ while ((m = wildcardRe.exec(cleaned)) !== null) {
889
+ out.push({ kind: 'wildcard', source: m[1] });
890
+ }
891
+ // Named: `export { a, b as c } from '...'`
892
+ const namedRe = /export\s*\{([^}]+)\}\s*from\s*['"]([^'"]+)['"]/g;
893
+ while ((m = namedRe.exec(cleaned)) !== null) {
894
+ const inner = m[1];
895
+ const source = m[2];
896
+ for (const raw of inner.split(',')) {
897
+ const item = raw.trim();
898
+ if (!item)
899
+ continue;
900
+ const aliasMatch = item.match(/^(\w+)\s+as\s+(\w+)$/);
901
+ if (aliasMatch) {
902
+ out.push({
903
+ kind: 'named',
904
+ exportedName: aliasMatch[2],
905
+ originalName: aliasMatch[1],
906
+ source,
907
+ });
908
+ }
909
+ else if (/^\w+$/.test(item)) {
910
+ out.push({
911
+ kind: 'named',
912
+ exportedName: item,
913
+ originalName: item,
914
+ source,
915
+ });
916
+ }
917
+ }
918
+ }
919
+ return out;
920
+ }
921
+ /**
922
+ * Resolve a reference using import mappings
923
+ */
924
+ /**
925
+ * JVM (Java / Kotlin) imports use fully-qualified names (`import
926
+ * com.example.foo.Bar`) decoupled from filenames, so the JS/Python
927
+ * style filesystem path lookup misses them whenever the file isn't
928
+ * named after its primary symbol (Kotlin `Utils.kt` exporting `Bar`,
929
+ * top-level fns, extension fns). Resolve them through the
930
+ * `qualifiedName` index instead — populated by the package_header /
931
+ * package_declaration namespace wrappers in the extractor.
932
+ */
933
+ function resolveJvmImport(ref, context) {
934
+ if (ref.referenceKind !== 'imports')
935
+ return null;
936
+ if (ref.language !== 'java' && ref.language !== 'kotlin')
937
+ return null;
938
+ const fqn = ref.referenceName;
939
+ const lastDot = fqn.lastIndexOf('.');
940
+ if (lastDot <= 0)
941
+ return null;
942
+ const pkg = fqn.substring(0, lastDot);
943
+ const sym = fqn.substring(lastDot + 1);
944
+ // Wildcard imports (`com.example.*`) deliberately punt to name-matcher.
945
+ if (sym === '*')
946
+ return null;
947
+ const candidates = context.getNodesByQualifiedName(`${pkg}::${sym}`);
948
+ if (candidates.length === 0)
949
+ return null;
950
+ return {
951
+ original: ref,
952
+ targetNodeId: candidates[0].id,
953
+ confidence: 0.95,
954
+ resolvedBy: 'import',
955
+ };
956
+ }
957
+ function resolveViaImport(ref, context) {
958
+ // C/C++ #include references — resolve directly to the included file
959
+ // (file→file edge), bypassing symbol lookup. The extractor emits these
960
+ // with `referenceKind: 'imports'` and `referenceName: <include path>`
961
+ // (e.g. "uint256.h" or "common/args.h"). Without this branch the
962
+ // include-dir scan path inside resolveImportPath never produces an
963
+ // edge — resolveViaImport's symbol lookup below would search the
964
+ // resolved file for a symbol named like the file extension and fail.
965
+ if ((ref.language === 'c' || ref.language === 'cpp') && ref.referenceKind === 'imports') {
966
+ const resolvedPath = resolveImportPath(ref.referenceName, ref.filePath, ref.language, context);
967
+ if (!resolvedPath)
968
+ return null;
969
+ const basename = resolvedPath.split('/').pop();
970
+ const fileNodes = context.getNodesByName(basename).filter((n) => n.kind === 'file');
971
+ const fileNode = fileNodes.find((n) => n.filePath === resolvedPath);
972
+ if (fileNode) {
973
+ return {
974
+ original: ref,
975
+ targetNodeId: fileNode.id,
976
+ confidence: 0.9,
977
+ resolvedBy: 'import',
978
+ };
979
+ }
980
+ return null;
981
+ }
982
+ // Use cached import mappings (avoids re-reading and re-parsing per ref)
983
+ const imports = context.getImportMappings(ref.filePath, ref.language);
984
+ if (imports.length === 0 && !context.readFile(ref.filePath)) {
985
+ return null;
986
+ }
987
+ // Go cross-package calls: `pkga.FuncX(...)` extracts to referenceName
988
+ // `pkga.FuncX` and the import `github.com/example/myproject/pkga`
989
+ // maps to a *package directory* containing one or more .go files.
990
+ // The generic file-based lookup below can't follow that — issue #388.
991
+ if (ref.language === 'go') {
992
+ const goResult = resolveGoCrossPackageReference(ref, imports, context);
993
+ if (goResult)
994
+ return goResult;
995
+ }
996
+ // Java / Kotlin: imports are FQNs (`import com.example.Foo;`) — no
997
+ // resolvable file path the JS/TS-style chain below could follow. Look
998
+ // up the symbol by name and filter to the candidate whose file path
999
+ // matches the imported FQN. This is the disambiguation signal that
1000
+ // breaks the same-name class collision the path-proximity matcher
1001
+ // can't resolve (issue #314).
1002
+ if (ref.language === 'java' || ref.language === 'kotlin') {
1003
+ const javaResult = resolveJavaImportedReference(ref, imports, context);
1004
+ if (javaResult)
1005
+ return javaResult;
1006
+ }
1007
+ // Check if the reference name matches any import
1008
+ for (const imp of imports) {
1009
+ if (imp.localName === ref.referenceName || ref.referenceName.startsWith(imp.localName + '.')) {
1010
+ // Resolve the import path
1011
+ const resolvedPath = resolveImportPath(imp.source, ref.filePath, ref.language, context);
1012
+ if (resolvedPath) {
1013
+ const exportedName = imp.isDefault ? 'default' : imp.exportedName;
1014
+ const memberName = imp.isNamespace
1015
+ ? ref.referenceName.replace(imp.localName + '.', '')
1016
+ : null;
1017
+ const targetNode = findExportedSymbol(resolvedPath, { isDefault: imp.isDefault, isNamespace: imp.isNamespace, exportedName, memberName }, ref.language, context, new Set());
1018
+ if (targetNode) {
1019
+ return {
1020
+ original: ref,
1021
+ targetNodeId: targetNode.id,
1022
+ confidence: 0.9,
1023
+ resolvedBy: 'import',
1024
+ };
1025
+ }
1026
+ }
1027
+ }
1028
+ }
1029
+ return null;
1030
+ }
1031
+ /**
1032
+ * Resolve a Java/Kotlin reference whose receiver is the simple name of
1033
+ * an imported FQN: `Foo.bar(...)` where `import com.example.Foo;`. The
1034
+ * imported FQN converts to a file-path suffix (`com/example/Foo.java`
1035
+ * or `.kt`) which uniquely identifies the right symbol when multiple
1036
+ * classes share the same simple name.
1037
+ *
1038
+ * Also handles bare references to the imported class itself
1039
+ * (`new Foo()` extraction emits `Foo` as a `references`/`instantiates`
1040
+ * ref) and `import static <Foo>.bar` style imports of a single member.
1041
+ */
1042
+ function resolveJavaImportedReference(ref, imports, context) {
1043
+ if (imports.length === 0)
1044
+ return null;
1045
+ const ext = ref.language === 'kotlin' ? '.kt' : '.java';
1046
+ for (const imp of imports) {
1047
+ const matchesBare = imp.localName === ref.referenceName;
1048
+ const matchesQualified = ref.referenceName.startsWith(imp.localName + '.');
1049
+ if (!matchesBare && !matchesQualified)
1050
+ continue;
1051
+ // Convert FQN to a file-path suffix. `com.example.Foo` ->
1052
+ // `com/example/Foo.java` (or `.kt`). The actual file may live
1053
+ // under any source root (`src/main/java/`, `src/`, etc.), so match
1054
+ // by suffix rather than exact path.
1055
+ const fqnPath = imp.source.replace(/\./g, '/') + ext;
1056
+ // Which symbol name to look up: the class itself, or a member.
1057
+ const memberName = matchesBare
1058
+ ? imp.localName
1059
+ : ref.referenceName.substring(imp.localName.length + 1);
1060
+ const candidates = context.getNodesByName(memberName);
1061
+ for (const node of candidates) {
1062
+ if (node.language !== ref.language)
1063
+ continue;
1064
+ const fp = node.filePath.replace(/\\/g, '/');
1065
+ if (fp.endsWith(fqnPath) || fp.endsWith('/' + fqnPath)) {
1066
+ return {
1067
+ original: ref,
1068
+ targetNodeId: node.id,
1069
+ confidence: 0.9,
1070
+ resolvedBy: 'import',
1071
+ };
1072
+ }
1073
+ }
1074
+ // `import static com.example.Foo.bar;` — the FQN's tail is the
1075
+ // member name, the part before is the owner class. Look up the
1076
+ // member named `<imp.localName>` (e.g. `bar`) and prefer the
1077
+ // candidate whose file matches the parent FQN's path.
1078
+ if (matchesBare) {
1079
+ const dot = imp.source.lastIndexOf('.');
1080
+ if (dot > 0) {
1081
+ const ownerFqn = imp.source.substring(0, dot);
1082
+ const ownerPath = ownerFqn.replace(/\./g, '/') + ext;
1083
+ for (const node of candidates) {
1084
+ if (node.language !== ref.language)
1085
+ continue;
1086
+ const fp = node.filePath.replace(/\\/g, '/');
1087
+ if (fp.endsWith(ownerPath) || fp.endsWith('/' + ownerPath)) {
1088
+ return {
1089
+ original: ref,
1090
+ targetNodeId: node.id,
1091
+ confidence: 0.9,
1092
+ resolvedBy: 'import',
1093
+ };
1094
+ }
1095
+ }
1096
+ }
1097
+ }
1098
+ }
1099
+ return null;
1100
+ }
1101
+ /**
1102
+ * Resolve a Go cross-package qualified reference (`pkga.FuncX`) by matching
1103
+ * the package alias against an in-module import, stripping the module prefix
1104
+ * to a project-relative directory, and locating the exported symbol in any
1105
+ * `.go` file under that directory. Returns `null` for stdlib / third-party
1106
+ * imports (no `go.mod`-relative match) so the rest of `resolveViaImport`
1107
+ * can still try the file-based path.
1108
+ */
1109
+ function resolveGoCrossPackageReference(ref, imports, context) {
1110
+ const mod = context.getGoModule?.();
1111
+ if (!mod)
1112
+ return null;
1113
+ // Qualified call: receiver before `.`, member after. A bare reference
1114
+ // (no dot) is a same-file/in-package call — handled elsewhere.
1115
+ const dotIdx = ref.referenceName.indexOf('.');
1116
+ if (dotIdx <= 0)
1117
+ return null;
1118
+ const receiver = ref.referenceName.substring(0, dotIdx);
1119
+ const memberName = ref.referenceName.substring(dotIdx + 1);
1120
+ if (!memberName)
1121
+ return null;
1122
+ for (const imp of imports) {
1123
+ if (imp.localName !== receiver)
1124
+ continue;
1125
+ // Only in-module imports map to a known directory.
1126
+ if (imp.source !== mod.modulePath && !imp.source.startsWith(mod.modulePath + '/')) {
1127
+ continue;
1128
+ }
1129
+ const pkgDir = imp.source === mod.modulePath
1130
+ ? ''
1131
+ : imp.source.substring(mod.modulePath.length + 1);
1132
+ // Look up the member by name and pick the candidate whose file lives
1133
+ // directly in the package directory. Match the immediate parent dir
1134
+ // exactly so a call to `pkga.FuncX` doesn't accidentally land on a
1135
+ // `FuncX` declared in `pkga/subpkg/`.
1136
+ const candidates = context.getNodesByName(memberName);
1137
+ for (const node of candidates) {
1138
+ if (node.language !== 'go')
1139
+ continue;
1140
+ if (!node.isExported)
1141
+ continue;
1142
+ const fp = node.filePath.replace(/\\/g, '/');
1143
+ const lastSlash = fp.lastIndexOf('/');
1144
+ const fileDir = lastSlash >= 0 ? fp.substring(0, lastSlash) : '';
1145
+ if (fileDir === pkgDir) {
1146
+ return {
1147
+ original: ref,
1148
+ targetNodeId: node.id,
1149
+ confidence: 0.9,
1150
+ resolvedBy: 'import',
1151
+ };
1152
+ }
1153
+ }
1154
+ }
1155
+ return null;
1156
+ }
1157
+ /** Recursive depth cap for re-export chain following. Real codebases
1158
+ * rarely chain barrels more than 2–3 deep; 8 is a generous safety
1159
+ * net that still bounds worst-case work. */
1160
+ const REEXPORT_MAX_DEPTH = 8;
1161
+ /**
1162
+ * Find an exported symbol in `filePath`, following `export { x } from
1163
+ * './other'` and `export * from './other'` chains until the original
1164
+ * declaration is reached. Cycle-safe via the `visited` set.
1165
+ *
1166
+ * Without this, every barrel-style import (`import { Foo } from
1167
+ * './index'` where `index.ts` only re-exports) used to resolve to
1168
+ * nothing — the existing code only looked for declarations IN the
1169
+ * resolved file, not declarations the file forwarded.
1170
+ */
1171
+ function findExportedSymbol(filePath, want, language, context, visited, depth = 0) {
1172
+ if (depth > REEXPORT_MAX_DEPTH)
1173
+ return undefined;
1174
+ if (visited.has(filePath))
1175
+ return undefined;
1176
+ visited.add(filePath);
1177
+ const nodesInFile = context.getNodesInFile(filePath);
1178
+ // 1. Direct hit: the symbol is declared in this file.
1179
+ if (want.isDefault) {
1180
+ const direct = nodesInFile.find((n) => n.isExported && (n.kind === 'function' || n.kind === 'class'));
1181
+ if (direct)
1182
+ return direct;
1183
+ }
1184
+ else if (want.isNamespace && want.memberName) {
1185
+ const direct = nodesInFile.find((n) => n.name === want.memberName && n.isExported);
1186
+ if (direct)
1187
+ return direct;
1188
+ }
1189
+ else {
1190
+ const direct = nodesInFile.find((n) => n.name === want.exportedName && n.isExported);
1191
+ if (direct)
1192
+ return direct;
1193
+ }
1194
+ // 2. Re-export hit: the file forwards the symbol to another module.
1195
+ const reExports = context.getReExports?.(filePath, language) ?? [];
1196
+ if (reExports.length === 0)
1197
+ return undefined;
1198
+ // Look for explicit `export { want } from './other'` (with optional rename).
1199
+ const targetName = want.isDefault ? 'default' : want.exportedName;
1200
+ for (const rex of reExports) {
1201
+ if (rex.kind === 'named' && rex.exportedName === targetName) {
1202
+ const next = resolveImportPath(rex.source, filePath, language, context);
1203
+ if (!next)
1204
+ continue;
1205
+ // After rename: `export { foo as bar } from './x'` — to chase
1206
+ // `bar`, we look for `foo` in `./x`.
1207
+ const chained = findExportedSymbol(next, {
1208
+ isDefault: rex.originalName === 'default',
1209
+ isNamespace: false,
1210
+ exportedName: rex.originalName,
1211
+ memberName: null,
1212
+ }, language, context, visited, depth + 1);
1213
+ if (chained)
1214
+ return chained;
1215
+ }
1216
+ }
1217
+ // 3. Wildcard re-export: `export * from './other'` — try every
1218
+ // forwarding source. This is the barrel-of-barrels case.
1219
+ for (const rex of reExports) {
1220
+ if (rex.kind === 'wildcard') {
1221
+ const next = resolveImportPath(rex.source, filePath, language, context);
1222
+ if (!next)
1223
+ continue;
1224
+ const chained = findExportedSymbol(next, want, language, context, visited, depth + 1);
1225
+ if (chained)
1226
+ return chained;
1227
+ }
1228
+ }
1229
+ return undefined;
1230
+ }
1231
+ //# sourceMappingURL=import-resolver.js.map