@vizalice/codegraph 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (821) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +872 -0
  3. package/dist/bin/codegraph.d.ts +26 -0
  4. package/dist/bin/codegraph.d.ts.map +1 -0
  5. package/dist/bin/codegraph.js +2324 -0
  6. package/dist/bin/codegraph.js.map +1 -0
  7. package/dist/bin/command-supervision.d.ts +49 -0
  8. package/dist/bin/command-supervision.d.ts.map +1 -0
  9. package/dist/bin/command-supervision.js +95 -0
  10. package/dist/bin/command-supervision.js.map +1 -0
  11. package/dist/bin/fatal-handler.d.ts +20 -0
  12. package/dist/bin/fatal-handler.d.ts.map +1 -0
  13. package/dist/bin/fatal-handler.js +118 -0
  14. package/dist/bin/fatal-handler.js.map +1 -0
  15. package/dist/bin/node-version-check.d.ts +37 -0
  16. package/dist/bin/node-version-check.d.ts.map +1 -0
  17. package/dist/bin/node-version-check.js +79 -0
  18. package/dist/bin/node-version-check.js.map +1 -0
  19. package/dist/bin/uninstall.d.ts +14 -0
  20. package/dist/bin/uninstall.d.ts.map +1 -0
  21. package/dist/bin/uninstall.js +36 -0
  22. package/dist/bin/uninstall.js.map +1 -0
  23. package/dist/context/formatter.d.ts +36 -0
  24. package/dist/context/formatter.d.ts.map +1 -0
  25. package/dist/context/formatter.js +269 -0
  26. package/dist/context/formatter.js.map +1 -0
  27. package/dist/context/index.d.ts +119 -0
  28. package/dist/context/index.d.ts.map +1 -0
  29. package/dist/context/index.js +1333 -0
  30. package/dist/context/index.js.map +1 -0
  31. package/dist/context/markers.d.ts +19 -0
  32. package/dist/context/markers.d.ts.map +1 -0
  33. package/dist/context/markers.js +22 -0
  34. package/dist/context/markers.js.map +1 -0
  35. package/dist/db/index.d.ts +378 -0
  36. package/dist/db/index.d.ts.map +1 -0
  37. package/dist/db/index.js +831 -0
  38. package/dist/db/index.js.map +1 -0
  39. package/dist/db/migrations.d.ts +44 -0
  40. package/dist/db/migrations.d.ts.map +1 -0
  41. package/dist/db/migrations.js +236 -0
  42. package/dist/db/migrations.js.map +1 -0
  43. package/dist/db/queries.d.ts +705 -0
  44. package/dist/db/queries.d.ts.map +1 -0
  45. package/dist/db/queries.js +2435 -0
  46. package/dist/db/queries.js.map +1 -0
  47. package/dist/db/schema.sql +207 -0
  48. package/dist/db/sqlite-adapter.d.ts +55 -0
  49. package/dist/db/sqlite-adapter.d.ts.map +1 -0
  50. package/dist/db/sqlite-adapter.js +135 -0
  51. package/dist/db/sqlite-adapter.js.map +1 -0
  52. package/dist/db/wal-valve.d.ts +119 -0
  53. package/dist/db/wal-valve.d.ts.map +1 -0
  54. package/dist/db/wal-valve.js +290 -0
  55. package/dist/db/wal-valve.js.map +1 -0
  56. package/dist/directory.d.ts +183 -0
  57. package/dist/directory.d.ts.map +1 -0
  58. package/dist/directory.js +797 -0
  59. package/dist/directory.js.map +1 -0
  60. package/dist/errors.d.ts +136 -0
  61. package/dist/errors.d.ts.map +1 -0
  62. package/dist/errors.js +219 -0
  63. package/dist/errors.js.map +1 -0
  64. package/dist/extraction/astro-extractor.d.ts +79 -0
  65. package/dist/extraction/astro-extractor.d.ts.map +1 -0
  66. package/dist/extraction/astro-extractor.js +320 -0
  67. package/dist/extraction/astro-extractor.js.map +1 -0
  68. package/dist/extraction/cfml-extractor.d.ts +107 -0
  69. package/dist/extraction/cfml-extractor.d.ts.map +1 -0
  70. package/dist/extraction/cfml-extractor.js +494 -0
  71. package/dist/extraction/cfml-extractor.js.map +1 -0
  72. package/dist/extraction/dfm-extractor.d.ts +31 -0
  73. package/dist/extraction/dfm-extractor.d.ts.map +1 -0
  74. package/dist/extraction/dfm-extractor.js +151 -0
  75. package/dist/extraction/dfm-extractor.js.map +1 -0
  76. package/dist/extraction/extraction-version.d.ts +25 -0
  77. package/dist/extraction/extraction-version.d.ts.map +1 -0
  78. package/dist/extraction/extraction-version.js +28 -0
  79. package/dist/extraction/extraction-version.js.map +1 -0
  80. package/dist/extraction/function-ref.d.ts +118 -0
  81. package/dist/extraction/function-ref.d.ts.map +1 -0
  82. package/dist/extraction/function-ref.js +733 -0
  83. package/dist/extraction/function-ref.js.map +1 -0
  84. package/dist/extraction/generated-detection.d.ts +66 -0
  85. package/dist/extraction/generated-detection.d.ts.map +1 -0
  86. package/dist/extraction/generated-detection.js +248 -0
  87. package/dist/extraction/generated-detection.js.map +1 -0
  88. package/dist/extraction/grammars.d.ts +138 -0
  89. package/dist/extraction/grammars.d.ts.map +1 -0
  90. package/dist/extraction/grammars.js +694 -0
  91. package/dist/extraction/grammars.js.map +1 -0
  92. package/dist/extraction/index.d.ts +308 -0
  93. package/dist/extraction/index.d.ts.map +1 -0
  94. package/dist/extraction/index.js +2711 -0
  95. package/dist/extraction/index.js.map +1 -0
  96. package/dist/extraction/kernel/decode.d.ts +9 -0
  97. package/dist/extraction/kernel/decode.d.ts.map +1 -0
  98. package/dist/extraction/kernel/decode.js +162 -0
  99. package/dist/extraction/kernel/decode.js.map +1 -0
  100. package/dist/extraction/kernel/index.d.ts +64 -0
  101. package/dist/extraction/kernel/index.d.ts.map +1 -0
  102. package/dist/extraction/kernel/index.js +279 -0
  103. package/dist/extraction/kernel/index.js.map +1 -0
  104. package/dist/extraction/kernel/layout.d.ts +101 -0
  105. package/dist/extraction/kernel/layout.d.ts.map +1 -0
  106. package/dist/extraction/kernel/layout.js +104 -0
  107. package/dist/extraction/kernel/layout.js.map +1 -0
  108. package/dist/extraction/kernel/loader.d.ts +103 -0
  109. package/dist/extraction/kernel/loader.d.ts.map +1 -0
  110. package/dist/extraction/kernel/loader.js +146 -0
  111. package/dist/extraction/kernel/loader.js.map +1 -0
  112. package/dist/extraction/languages/arkts.d.ts +3 -0
  113. package/dist/extraction/languages/arkts.d.ts.map +1 -0
  114. package/dist/extraction/languages/arkts.js +127 -0
  115. package/dist/extraction/languages/arkts.js.map +1 -0
  116. package/dist/extraction/languages/c-cpp.d.ts +124 -0
  117. package/dist/extraction/languages/c-cpp.d.ts.map +1 -0
  118. package/dist/extraction/languages/c-cpp.js +1689 -0
  119. package/dist/extraction/languages/c-cpp.js.map +1 -0
  120. package/dist/extraction/languages/cfquery.d.ts +12 -0
  121. package/dist/extraction/languages/cfquery.d.ts.map +1 -0
  122. package/dist/extraction/languages/cfquery.js +28 -0
  123. package/dist/extraction/languages/cfquery.js.map +1 -0
  124. package/dist/extraction/languages/cfscript.d.ts +3 -0
  125. package/dist/extraction/languages/cfscript.d.ts.map +1 -0
  126. package/dist/extraction/languages/cfscript.js +73 -0
  127. package/dist/extraction/languages/cfscript.js.map +1 -0
  128. package/dist/extraction/languages/cobol.d.ts +33 -0
  129. package/dist/extraction/languages/cobol.d.ts.map +1 -0
  130. package/dist/extraction/languages/cobol.js +499 -0
  131. package/dist/extraction/languages/cobol.js.map +1 -0
  132. package/dist/extraction/languages/csharp.d.ts +25 -0
  133. package/dist/extraction/languages/csharp.d.ts.map +1 -0
  134. package/dist/extraction/languages/csharp.js +175 -0
  135. package/dist/extraction/languages/csharp.js.map +1 -0
  136. package/dist/extraction/languages/dart.d.ts +3 -0
  137. package/dist/extraction/languages/dart.d.ts.map +1 -0
  138. package/dist/extraction/languages/dart.js +374 -0
  139. package/dist/extraction/languages/dart.js.map +1 -0
  140. package/dist/extraction/languages/erlang.d.ts +3 -0
  141. package/dist/extraction/languages/erlang.d.ts.map +1 -0
  142. package/dist/extraction/languages/erlang.js +350 -0
  143. package/dist/extraction/languages/erlang.js.map +1 -0
  144. package/dist/extraction/languages/go.d.ts +3 -0
  145. package/dist/extraction/languages/go.d.ts.map +1 -0
  146. package/dist/extraction/languages/go.js +111 -0
  147. package/dist/extraction/languages/go.js.map +1 -0
  148. package/dist/extraction/languages/index.d.ts +10 -0
  149. package/dist/extraction/languages/index.d.ts.map +1 -0
  150. package/dist/extraction/languages/index.js +71 -0
  151. package/dist/extraction/languages/index.js.map +1 -0
  152. package/dist/extraction/languages/java.d.ts +3 -0
  153. package/dist/extraction/languages/java.d.ts.map +1 -0
  154. package/dist/extraction/languages/java.js +315 -0
  155. package/dist/extraction/languages/java.js.map +1 -0
  156. package/dist/extraction/languages/javascript.d.ts +3 -0
  157. package/dist/extraction/languages/javascript.d.ts.map +1 -0
  158. package/dist/extraction/languages/javascript.js +106 -0
  159. package/dist/extraction/languages/javascript.js.map +1 -0
  160. package/dist/extraction/languages/kotlin.d.ts +3 -0
  161. package/dist/extraction/languages/kotlin.d.ts.map +1 -0
  162. package/dist/extraction/languages/kotlin.js +379 -0
  163. package/dist/extraction/languages/kotlin.js.map +1 -0
  164. package/dist/extraction/languages/lua.d.ts +3 -0
  165. package/dist/extraction/languages/lua.d.ts.map +1 -0
  166. package/dist/extraction/languages/lua.js +150 -0
  167. package/dist/extraction/languages/lua.js.map +1 -0
  168. package/dist/extraction/languages/luau.d.ts +3 -0
  169. package/dist/extraction/languages/luau.d.ts.map +1 -0
  170. package/dist/extraction/languages/luau.js +37 -0
  171. package/dist/extraction/languages/luau.js.map +1 -0
  172. package/dist/extraction/languages/nix.d.ts +3 -0
  173. package/dist/extraction/languages/nix.d.ts.map +1 -0
  174. package/dist/extraction/languages/nix.js +294 -0
  175. package/dist/extraction/languages/nix.js.map +1 -0
  176. package/dist/extraction/languages/objc.d.ts +3 -0
  177. package/dist/extraction/languages/objc.d.ts.map +1 -0
  178. package/dist/extraction/languages/objc.js +179 -0
  179. package/dist/extraction/languages/objc.js.map +1 -0
  180. package/dist/extraction/languages/pascal.d.ts +3 -0
  181. package/dist/extraction/languages/pascal.d.ts.map +1 -0
  182. package/dist/extraction/languages/pascal.js +77 -0
  183. package/dist/extraction/languages/pascal.js.map +1 -0
  184. package/dist/extraction/languages/php.d.ts +3 -0
  185. package/dist/extraction/languages/php.d.ts.map +1 -0
  186. package/dist/extraction/languages/php.js +196 -0
  187. package/dist/extraction/languages/php.js.map +1 -0
  188. package/dist/extraction/languages/python.d.ts +3 -0
  189. package/dist/extraction/languages/python.d.ts.map +1 -0
  190. package/dist/extraction/languages/python.js +56 -0
  191. package/dist/extraction/languages/python.js.map +1 -0
  192. package/dist/extraction/languages/r.d.ts +3 -0
  193. package/dist/extraction/languages/r.d.ts.map +1 -0
  194. package/dist/extraction/languages/r.js +314 -0
  195. package/dist/extraction/languages/r.js.map +1 -0
  196. package/dist/extraction/languages/ruby.d.ts +3 -0
  197. package/dist/extraction/languages/ruby.d.ts.map +1 -0
  198. package/dist/extraction/languages/ruby.js +149 -0
  199. package/dist/extraction/languages/ruby.js.map +1 -0
  200. package/dist/extraction/languages/rust.d.ts +3 -0
  201. package/dist/extraction/languages/rust.d.ts.map +1 -0
  202. package/dist/extraction/languages/rust.js +145 -0
  203. package/dist/extraction/languages/rust.js.map +1 -0
  204. package/dist/extraction/languages/scala.d.ts +3 -0
  205. package/dist/extraction/languages/scala.d.ts.map +1 -0
  206. package/dist/extraction/languages/scala.js +209 -0
  207. package/dist/extraction/languages/scala.js.map +1 -0
  208. package/dist/extraction/languages/solidity.d.ts +3 -0
  209. package/dist/extraction/languages/solidity.d.ts.map +1 -0
  210. package/dist/extraction/languages/solidity.js +293 -0
  211. package/dist/extraction/languages/solidity.js.map +1 -0
  212. package/dist/extraction/languages/swift.d.ts +3 -0
  213. package/dist/extraction/languages/swift.d.ts.map +1 -0
  214. package/dist/extraction/languages/swift.js +152 -0
  215. package/dist/extraction/languages/swift.js.map +1 -0
  216. package/dist/extraction/languages/terraform.d.ts +3 -0
  217. package/dist/extraction/languages/terraform.d.ts.map +1 -0
  218. package/dist/extraction/languages/terraform.js +641 -0
  219. package/dist/extraction/languages/terraform.js.map +1 -0
  220. package/dist/extraction/languages/typescript.d.ts +16 -0
  221. package/dist/extraction/languages/typescript.d.ts.map +1 -0
  222. package/dist/extraction/languages/typescript.js +167 -0
  223. package/dist/extraction/languages/typescript.js.map +1 -0
  224. package/dist/extraction/languages/vbnet.d.ts +11 -0
  225. package/dist/extraction/languages/vbnet.d.ts.map +1 -0
  226. package/dist/extraction/languages/vbnet.js +141 -0
  227. package/dist/extraction/languages/vbnet.js.map +1 -0
  228. package/dist/extraction/liquid-extractor.d.ts +59 -0
  229. package/dist/extraction/liquid-extractor.d.ts.map +1 -0
  230. package/dist/extraction/liquid-extractor.js +357 -0
  231. package/dist/extraction/liquid-extractor.js.map +1 -0
  232. package/dist/extraction/mybatis-extractor.d.ts +68 -0
  233. package/dist/extraction/mybatis-extractor.d.ts.map +1 -0
  234. package/dist/extraction/mybatis-extractor.js +300 -0
  235. package/dist/extraction/mybatis-extractor.js.map +1 -0
  236. package/dist/extraction/parse-pool.d.ts +160 -0
  237. package/dist/extraction/parse-pool.d.ts.map +1 -0
  238. package/dist/extraction/parse-pool.js +402 -0
  239. package/dist/extraction/parse-pool.js.map +1 -0
  240. package/dist/extraction/parse-worker.d.ts +8 -0
  241. package/dist/extraction/parse-worker.d.ts.map +1 -0
  242. package/dist/extraction/parse-worker.js +138 -0
  243. package/dist/extraction/parse-worker.js.map +1 -0
  244. package/dist/extraction/razor-extractor.d.ts +42 -0
  245. package/dist/extraction/razor-extractor.d.ts.map +1 -0
  246. package/dist/extraction/razor-extractor.js +285 -0
  247. package/dist/extraction/razor-extractor.js.map +1 -0
  248. package/dist/extraction/store-worker.d.ts +24 -0
  249. package/dist/extraction/store-worker.d.ts.map +1 -0
  250. package/dist/extraction/store-worker.js +139 -0
  251. package/dist/extraction/store-worker.js.map +1 -0
  252. package/dist/extraction/store-writer.d.ts +63 -0
  253. package/dist/extraction/store-writer.d.ts.map +1 -0
  254. package/dist/extraction/store-writer.js +174 -0
  255. package/dist/extraction/store-writer.js.map +1 -0
  256. package/dist/extraction/svelte-extractor.d.ts +56 -0
  257. package/dist/extraction/svelte-extractor.d.ts.map +1 -0
  258. package/dist/extraction/svelte-extractor.js +275 -0
  259. package/dist/extraction/svelte-extractor.js.map +1 -0
  260. package/dist/extraction/tree-sitter-helpers.d.ts +28 -0
  261. package/dist/extraction/tree-sitter-helpers.d.ts.map +1 -0
  262. package/dist/extraction/tree-sitter-helpers.js +153 -0
  263. package/dist/extraction/tree-sitter-helpers.js.map +1 -0
  264. package/dist/extraction/tree-sitter-types.d.ts +260 -0
  265. package/dist/extraction/tree-sitter-types.d.ts.map +1 -0
  266. package/dist/extraction/tree-sitter-types.js +10 -0
  267. package/dist/extraction/tree-sitter-types.js.map +1 -0
  268. package/dist/extraction/tree-sitter.d.ts +728 -0
  269. package/dist/extraction/tree-sitter.d.ts.map +1 -0
  270. package/dist/extraction/tree-sitter.js +6676 -0
  271. package/dist/extraction/tree-sitter.js.map +1 -0
  272. package/dist/extraction/vue-extractor.d.ts +51 -0
  273. package/dist/extraction/vue-extractor.d.ts.map +1 -0
  274. package/dist/extraction/vue-extractor.js +254 -0
  275. package/dist/extraction/vue-extractor.js.map +1 -0
  276. package/dist/extraction/wasm/tree-sitter-arkts.wasm +0 -0
  277. package/dist/extraction/wasm/tree-sitter-c.wasm +0 -0
  278. package/dist/extraction/wasm/tree-sitter-c_sharp.wasm +0 -0
  279. package/dist/extraction/wasm/tree-sitter-cfml.wasm +0 -0
  280. package/dist/extraction/wasm/tree-sitter-cfquery.wasm +0 -0
  281. package/dist/extraction/wasm/tree-sitter-cfscript.wasm +0 -0
  282. package/dist/extraction/wasm/tree-sitter-cobol.wasm +0 -0
  283. package/dist/extraction/wasm/tree-sitter-cpp.wasm +0 -0
  284. package/dist/extraction/wasm/tree-sitter-dart.wasm +0 -0
  285. package/dist/extraction/wasm/tree-sitter-erlang.wasm +0 -0
  286. package/dist/extraction/wasm/tree-sitter-go.wasm +0 -0
  287. package/dist/extraction/wasm/tree-sitter-java.wasm +0 -0
  288. package/dist/extraction/wasm/tree-sitter-javascript.wasm +0 -0
  289. package/dist/extraction/wasm/tree-sitter-kotlin.wasm +0 -0
  290. package/dist/extraction/wasm/tree-sitter-lua.wasm +0 -0
  291. package/dist/extraction/wasm/tree-sitter-luau.wasm +0 -0
  292. package/dist/extraction/wasm/tree-sitter-nix.wasm +0 -0
  293. package/dist/extraction/wasm/tree-sitter-pascal.wasm +0 -0
  294. package/dist/extraction/wasm/tree-sitter-php.wasm +0 -0
  295. package/dist/extraction/wasm/tree-sitter-python.wasm +0 -0
  296. package/dist/extraction/wasm/tree-sitter-r.wasm +0 -0
  297. package/dist/extraction/wasm/tree-sitter-ruby.wasm +0 -0
  298. package/dist/extraction/wasm/tree-sitter-rust.wasm +0 -0
  299. package/dist/extraction/wasm/tree-sitter-scala.wasm +0 -0
  300. package/dist/extraction/wasm/tree-sitter-swift.wasm +0 -0
  301. package/dist/extraction/wasm/tree-sitter-terraform.wasm +0 -0
  302. package/dist/extraction/wasm/tree-sitter-tsx.wasm +0 -0
  303. package/dist/extraction/wasm/tree-sitter-typescript.wasm +0 -0
  304. package/dist/extraction/wasm/tree-sitter-vbnet.wasm +0 -0
  305. package/dist/extraction/wasm-runtime-flags.d.ts +53 -0
  306. package/dist/extraction/wasm-runtime-flags.d.ts.map +1 -0
  307. package/dist/extraction/wasm-runtime-flags.js +130 -0
  308. package/dist/extraction/wasm-runtime-flags.js.map +1 -0
  309. package/dist/graph/index.d.ts +8 -0
  310. package/dist/graph/index.d.ts.map +1 -0
  311. package/dist/graph/index.js +13 -0
  312. package/dist/graph/index.js.map +1 -0
  313. package/dist/graph/queries.d.ts +106 -0
  314. package/dist/graph/queries.d.ts.map +1 -0
  315. package/dist/graph/queries.js +341 -0
  316. package/dist/graph/queries.js.map +1 -0
  317. package/dist/graph/traversal.d.ts +127 -0
  318. package/dist/graph/traversal.d.ts.map +1 -0
  319. package/dist/graph/traversal.js +599 -0
  320. package/dist/graph/traversal.js.map +1 -0
  321. package/dist/index.d.ts +677 -0
  322. package/dist/index.d.ts.map +1 -0
  323. package/dist/index.js +1718 -0
  324. package/dist/index.js.map +1 -0
  325. package/dist/installer/beta-signup.d.ts +54 -0
  326. package/dist/installer/beta-signup.d.ts.map +1 -0
  327. package/dist/installer/beta-signup.js +178 -0
  328. package/dist/installer/beta-signup.js.map +1 -0
  329. package/dist/installer/config-writer.d.ts +28 -0
  330. package/dist/installer/config-writer.d.ts.map +1 -0
  331. package/dist/installer/config-writer.js +91 -0
  332. package/dist/installer/config-writer.js.map +1 -0
  333. package/dist/installer/index.d.ts +144 -0
  334. package/dist/installer/index.d.ts.map +1 -0
  335. package/dist/installer/index.js +634 -0
  336. package/dist/installer/index.js.map +1 -0
  337. package/dist/installer/instructions-template.d.ts +41 -0
  338. package/dist/installer/instructions-template.d.ts.map +1 -0
  339. package/dist/installer/instructions-template.js +53 -0
  340. package/dist/installer/instructions-template.js.map +1 -0
  341. package/dist/installer/targets/antigravity.d.ts +57 -0
  342. package/dist/installer/targets/antigravity.d.ts.map +1 -0
  343. package/dist/installer/targets/antigravity.js +308 -0
  344. package/dist/installer/targets/antigravity.js.map +1 -0
  345. package/dist/installer/targets/claude.d.ts +62 -0
  346. package/dist/installer/targets/claude.d.ts.map +1 -0
  347. package/dist/installer/targets/claude.js +486 -0
  348. package/dist/installer/targets/claude.js.map +1 -0
  349. package/dist/installer/targets/codex.d.ts +18 -0
  350. package/dist/installer/targets/codex.d.ts.map +1 -0
  351. package/dist/installer/targets/codex.js +185 -0
  352. package/dist/installer/targets/codex.js.map +1 -0
  353. package/dist/installer/targets/copilot-cli.d.ts +32 -0
  354. package/dist/installer/targets/copilot-cli.d.ts.map +1 -0
  355. package/dist/installer/targets/copilot-cli.js +209 -0
  356. package/dist/installer/targets/copilot-cli.js.map +1 -0
  357. package/dist/installer/targets/copilot-jetbrains.d.ts +42 -0
  358. package/dist/installer/targets/copilot-jetbrains.d.ts.map +1 -0
  359. package/dist/installer/targets/copilot-jetbrains.js +238 -0
  360. package/dist/installer/targets/copilot-jetbrains.js.map +1 -0
  361. package/dist/installer/targets/copilot-vscode.d.ts +47 -0
  362. package/dist/installer/targets/copilot-vscode.d.ts.map +1 -0
  363. package/dist/installer/targets/copilot-vscode.js +219 -0
  364. package/dist/installer/targets/copilot-vscode.js.map +1 -0
  365. package/dist/installer/targets/cursor.d.ts +35 -0
  366. package/dist/installer/targets/cursor.d.ts.map +1 -0
  367. package/dist/installer/targets/cursor.js +254 -0
  368. package/dist/installer/targets/cursor.js.map +1 -0
  369. package/dist/installer/targets/dsh.d.ts +97 -0
  370. package/dist/installer/targets/dsh.d.ts.map +1 -0
  371. package/dist/installer/targets/dsh.js +358 -0
  372. package/dist/installer/targets/dsh.js.map +1 -0
  373. package/dist/installer/targets/gemini.d.ts +26 -0
  374. package/dist/installer/targets/gemini.d.ts.map +1 -0
  375. package/dist/installer/targets/gemini.js +165 -0
  376. package/dist/installer/targets/gemini.js.map +1 -0
  377. package/dist/installer/targets/hermes.d.ts +18 -0
  378. package/dist/installer/targets/hermes.d.ts.map +1 -0
  379. package/dist/installer/targets/hermes.js +359 -0
  380. package/dist/installer/targets/hermes.js.map +1 -0
  381. package/dist/installer/targets/kiro.d.ts +27 -0
  382. package/dist/installer/targets/kiro.d.ts.map +1 -0
  383. package/dist/installer/targets/kiro.js +178 -0
  384. package/dist/installer/targets/kiro.js.map +1 -0
  385. package/dist/installer/targets/opencode.d.ts +38 -0
  386. package/dist/installer/targets/opencode.d.ts.map +1 -0
  387. package/dist/installer/targets/opencode.js +288 -0
  388. package/dist/installer/targets/opencode.js.map +1 -0
  389. package/dist/installer/targets/registry.d.ts +35 -0
  390. package/dist/installer/targets/registry.d.ts.map +1 -0
  391. package/dist/installer/targets/registry.js +101 -0
  392. package/dist/installer/targets/registry.js.map +1 -0
  393. package/dist/installer/targets/shared.d.ts +132 -0
  394. package/dist/installer/targets/shared.d.ts.map +1 -0
  395. package/dist/installer/targets/shared.js +314 -0
  396. package/dist/installer/targets/shared.js.map +1 -0
  397. package/dist/installer/targets/toml.d.ts +53 -0
  398. package/dist/installer/targets/toml.d.ts.map +1 -0
  399. package/dist/installer/targets/toml.js +226 -0
  400. package/dist/installer/targets/toml.js.map +1 -0
  401. package/dist/installer/targets/types.d.ts +109 -0
  402. package/dist/installer/targets/types.d.ts.map +1 -0
  403. package/dist/installer/targets/types.js +16 -0
  404. package/dist/installer/targets/types.js.map +1 -0
  405. package/dist/installer/targets/zcode.d.ts +106 -0
  406. package/dist/installer/targets/zcode.d.ts.map +1 -0
  407. package/dist/installer/targets/zcode.js +451 -0
  408. package/dist/installer/targets/zcode.js.map +1 -0
  409. package/dist/mcp/daemon-manager.d.ts +42 -0
  410. package/dist/mcp/daemon-manager.d.ts.map +1 -0
  411. package/dist/mcp/daemon-manager.js +129 -0
  412. package/dist/mcp/daemon-manager.js.map +1 -0
  413. package/dist/mcp/daemon-paths.d.ts +73 -0
  414. package/dist/mcp/daemon-paths.d.ts.map +1 -0
  415. package/dist/mcp/daemon-paths.js +165 -0
  416. package/dist/mcp/daemon-paths.js.map +1 -0
  417. package/dist/mcp/daemon-registry.d.ts +47 -0
  418. package/dist/mcp/daemon-registry.d.ts.map +1 -0
  419. package/dist/mcp/daemon-registry.js +233 -0
  420. package/dist/mcp/daemon-registry.js.map +1 -0
  421. package/dist/mcp/daemon.d.ts +290 -0
  422. package/dist/mcp/daemon.d.ts.map +1 -0
  423. package/dist/mcp/daemon.js +862 -0
  424. package/dist/mcp/daemon.js.map +1 -0
  425. package/dist/mcp/dynamic-boundaries.d.ts +41 -0
  426. package/dist/mcp/dynamic-boundaries.d.ts.map +1 -0
  427. package/dist/mcp/dynamic-boundaries.js +360 -0
  428. package/dist/mcp/dynamic-boundaries.js.map +1 -0
  429. package/dist/mcp/early-ppid.d.ts +26 -0
  430. package/dist/mcp/early-ppid.d.ts.map +1 -0
  431. package/dist/mcp/early-ppid.js +29 -0
  432. package/dist/mcp/early-ppid.js.map +1 -0
  433. package/dist/mcp/engine.d.ts +122 -0
  434. package/dist/mcp/engine.d.ts.map +1 -0
  435. package/dist/mcp/engine.js +350 -0
  436. package/dist/mcp/engine.js.map +1 -0
  437. package/dist/mcp/explore-dedup.d.ts +137 -0
  438. package/dist/mcp/explore-dedup.d.ts.map +1 -0
  439. package/dist/mcp/explore-dedup.js +236 -0
  440. package/dist/mcp/explore-dedup.js.map +1 -0
  441. package/dist/mcp/explore-diagnostics.d.ts +287 -0
  442. package/dist/mcp/explore-diagnostics.d.ts.map +1 -0
  443. package/dist/mcp/explore-diagnostics.js +555 -0
  444. package/dist/mcp/explore-diagnostics.js.map +1 -0
  445. package/dist/mcp/explore-session-state.d.ts +217 -0
  446. package/dist/mcp/explore-session-state.d.ts.map +1 -0
  447. package/dist/mcp/explore-session-state.js +322 -0
  448. package/dist/mcp/explore-session-state.js.map +1 -0
  449. package/dist/mcp/index.d.ts +137 -0
  450. package/dist/mcp/index.d.ts.map +1 -0
  451. package/dist/mcp/index.js +554 -0
  452. package/dist/mcp/index.js.map +1 -0
  453. package/dist/mcp/liveness-watchdog.d.ts +35 -0
  454. package/dist/mcp/liveness-watchdog.d.ts.map +1 -0
  455. package/dist/mcp/liveness-watchdog.js +269 -0
  456. package/dist/mcp/liveness-watchdog.js.map +1 -0
  457. package/dist/mcp/ppid-watchdog.d.ts +62 -0
  458. package/dist/mcp/ppid-watchdog.d.ts.map +1 -0
  459. package/dist/mcp/ppid-watchdog.js +64 -0
  460. package/dist/mcp/ppid-watchdog.js.map +1 -0
  461. package/dist/mcp/proxy.d.ts +87 -0
  462. package/dist/mcp/proxy.d.ts.map +1 -0
  463. package/dist/mcp/proxy.js +672 -0
  464. package/dist/mcp/proxy.js.map +1 -0
  465. package/dist/mcp/query-pool.d.ts +108 -0
  466. package/dist/mcp/query-pool.d.ts.map +1 -0
  467. package/dist/mcp/query-pool.js +315 -0
  468. package/dist/mcp/query-pool.js.map +1 -0
  469. package/dist/mcp/query-worker.d.ts +24 -0
  470. package/dist/mcp/query-worker.d.ts.map +1 -0
  471. package/dist/mcp/query-worker.js +87 -0
  472. package/dist/mcp/query-worker.js.map +1 -0
  473. package/dist/mcp/server-instructions.d.ts +34 -0
  474. package/dist/mcp/server-instructions.d.ts.map +1 -0
  475. package/dist/mcp/server-instructions.js +111 -0
  476. package/dist/mcp/server-instructions.js.map +1 -0
  477. package/dist/mcp/session.d.ts +109 -0
  478. package/dist/mcp/session.d.ts.map +1 -0
  479. package/dist/mcp/session.js +375 -0
  480. package/dist/mcp/session.js.map +1 -0
  481. package/dist/mcp/startup-handshake.d.ts +44 -0
  482. package/dist/mcp/startup-handshake.d.ts.map +1 -0
  483. package/dist/mcp/startup-handshake.js +73 -0
  484. package/dist/mcp/startup-handshake.js.map +1 -0
  485. package/dist/mcp/stdin-teardown.d.ts +27 -0
  486. package/dist/mcp/stdin-teardown.d.ts.map +1 -0
  487. package/dist/mcp/stdin-teardown.js +49 -0
  488. package/dist/mcp/stdin-teardown.js.map +1 -0
  489. package/dist/mcp/tools.d.ts +862 -0
  490. package/dist/mcp/tools.d.ts.map +1 -0
  491. package/dist/mcp/tools.js +6526 -0
  492. package/dist/mcp/tools.js.map +1 -0
  493. package/dist/mcp/transport.d.ts +188 -0
  494. package/dist/mcp/transport.d.ts.map +1 -0
  495. package/dist/mcp/transport.js +377 -0
  496. package/dist/mcp/transport.js.map +1 -0
  497. package/dist/mcp/version.d.ts +19 -0
  498. package/dist/mcp/version.d.ts.map +1 -0
  499. package/dist/mcp/version.js +71 -0
  500. package/dist/mcp/version.js.map +1 -0
  501. package/dist/project-config.d.ts +94 -0
  502. package/dist/project-config.d.ts.map +1 -0
  503. package/dist/project-config.js +374 -0
  504. package/dist/project-config.js.map +1 -0
  505. package/dist/prompt-hook-output.d.ts +23 -0
  506. package/dist/prompt-hook-output.d.ts.map +1 -0
  507. package/dist/prompt-hook-output.js +35 -0
  508. package/dist/prompt-hook-output.js.map +1 -0
  509. package/dist/resolution/c-fnptr-synthesizer.d.ts +6 -0
  510. package/dist/resolution/c-fnptr-synthesizer.d.ts.map +1 -0
  511. package/dist/resolution/c-fnptr-synthesizer.js +1506 -0
  512. package/dist/resolution/c-fnptr-synthesizer.js.map +1 -0
  513. package/dist/resolution/callback-synthesizer.d.ts +59 -0
  514. package/dist/resolution/callback-synthesizer.d.ts.map +1 -0
  515. package/dist/resolution/callback-synthesizer.js +4030 -0
  516. package/dist/resolution/callback-synthesizer.js.map +1 -0
  517. package/dist/resolution/cooperative-yield.d.ts +40 -0
  518. package/dist/resolution/cooperative-yield.d.ts.map +1 -0
  519. package/dist/resolution/cooperative-yield.js +44 -0
  520. package/dist/resolution/cooperative-yield.js.map +1 -0
  521. package/dist/resolution/frameworks/astro.d.ts +9 -0
  522. package/dist/resolution/frameworks/astro.d.ts.map +1 -0
  523. package/dist/resolution/frameworks/astro.js +169 -0
  524. package/dist/resolution/frameworks/astro.js.map +1 -0
  525. package/dist/resolution/frameworks/cargo-workspace.d.ts +18 -0
  526. package/dist/resolution/frameworks/cargo-workspace.d.ts.map +1 -0
  527. package/dist/resolution/frameworks/cargo-workspace.js +225 -0
  528. package/dist/resolution/frameworks/cargo-workspace.js.map +1 -0
  529. package/dist/resolution/frameworks/cics.d.ts +20 -0
  530. package/dist/resolution/frameworks/cics.d.ts.map +1 -0
  531. package/dist/resolution/frameworks/cics.js +90 -0
  532. package/dist/resolution/frameworks/cics.js.map +1 -0
  533. package/dist/resolution/frameworks/csharp.d.ts +8 -0
  534. package/dist/resolution/frameworks/csharp.d.ts.map +1 -0
  535. package/dist/resolution/frameworks/csharp.js +241 -0
  536. package/dist/resolution/frameworks/csharp.js.map +1 -0
  537. package/dist/resolution/frameworks/drupal.d.ts +51 -0
  538. package/dist/resolution/frameworks/drupal.d.ts.map +1 -0
  539. package/dist/resolution/frameworks/drupal.js +367 -0
  540. package/dist/resolution/frameworks/drupal.js.map +1 -0
  541. package/dist/resolution/frameworks/expo-modules.d.ts +3 -0
  542. package/dist/resolution/frameworks/expo-modules.d.ts.map +1 -0
  543. package/dist/resolution/frameworks/expo-modules.js +148 -0
  544. package/dist/resolution/frameworks/expo-modules.js.map +1 -0
  545. package/dist/resolution/frameworks/express.d.ts +8 -0
  546. package/dist/resolution/frameworks/express.d.ts.map +1 -0
  547. package/dist/resolution/frameworks/express.js +308 -0
  548. package/dist/resolution/frameworks/express.js.map +1 -0
  549. package/dist/resolution/frameworks/fabric.d.ts +3 -0
  550. package/dist/resolution/frameworks/fabric.d.ts.map +1 -0
  551. package/dist/resolution/frameworks/fabric.js +354 -0
  552. package/dist/resolution/frameworks/fabric.js.map +1 -0
  553. package/dist/resolution/frameworks/go.d.ts +8 -0
  554. package/dist/resolution/frameworks/go.d.ts.map +1 -0
  555. package/dist/resolution/frameworks/go.js +184 -0
  556. package/dist/resolution/frameworks/go.js.map +1 -0
  557. package/dist/resolution/frameworks/goframe.d.ts +41 -0
  558. package/dist/resolution/frameworks/goframe.d.ts.map +1 -0
  559. package/dist/resolution/frameworks/goframe.js +112 -0
  560. package/dist/resolution/frameworks/goframe.js.map +1 -0
  561. package/dist/resolution/frameworks/index.d.ts +50 -0
  562. package/dist/resolution/frameworks/index.d.ts.map +1 -0
  563. package/dist/resolution/frameworks/index.js +175 -0
  564. package/dist/resolution/frameworks/index.js.map +1 -0
  565. package/dist/resolution/frameworks/java.d.ts +8 -0
  566. package/dist/resolution/frameworks/java.d.ts.map +1 -0
  567. package/dist/resolution/frameworks/java.js +517 -0
  568. package/dist/resolution/frameworks/java.js.map +1 -0
  569. package/dist/resolution/frameworks/laravel.d.ts +13 -0
  570. package/dist/resolution/frameworks/laravel.d.ts.map +1 -0
  571. package/dist/resolution/frameworks/laravel.js +257 -0
  572. package/dist/resolution/frameworks/laravel.js.map +1 -0
  573. package/dist/resolution/frameworks/nestjs.d.ts +26 -0
  574. package/dist/resolution/frameworks/nestjs.d.ts.map +1 -0
  575. package/dist/resolution/frameworks/nestjs.js +698 -0
  576. package/dist/resolution/frameworks/nestjs.js.map +1 -0
  577. package/dist/resolution/frameworks/play.d.ts +19 -0
  578. package/dist/resolution/frameworks/play.d.ts.map +1 -0
  579. package/dist/resolution/frameworks/play.js +111 -0
  580. package/dist/resolution/frameworks/play.js.map +1 -0
  581. package/dist/resolution/frameworks/python.d.ts +10 -0
  582. package/dist/resolution/frameworks/python.d.ts.map +1 -0
  583. package/dist/resolution/frameworks/python.js +400 -0
  584. package/dist/resolution/frameworks/python.js.map +1 -0
  585. package/dist/resolution/frameworks/react-native.d.ts +3 -0
  586. package/dist/resolution/frameworks/react-native.d.ts.map +1 -0
  587. package/dist/resolution/frameworks/react-native.js +410 -0
  588. package/dist/resolution/frameworks/react-native.js.map +1 -0
  589. package/dist/resolution/frameworks/react.d.ts +8 -0
  590. package/dist/resolution/frameworks/react.d.ts.map +1 -0
  591. package/dist/resolution/frameworks/react.js +334 -0
  592. package/dist/resolution/frameworks/react.js.map +1 -0
  593. package/dist/resolution/frameworks/ruby.d.ts +8 -0
  594. package/dist/resolution/frameworks/ruby.d.ts.map +1 -0
  595. package/dist/resolution/frameworks/ruby.js +302 -0
  596. package/dist/resolution/frameworks/ruby.js.map +1 -0
  597. package/dist/resolution/frameworks/rust.d.ts +8 -0
  598. package/dist/resolution/frameworks/rust.d.ts.map +1 -0
  599. package/dist/resolution/frameworks/rust.js +304 -0
  600. package/dist/resolution/frameworks/rust.js.map +1 -0
  601. package/dist/resolution/frameworks/svelte.d.ts +9 -0
  602. package/dist/resolution/frameworks/svelte.d.ts.map +1 -0
  603. package/dist/resolution/frameworks/svelte.js +253 -0
  604. package/dist/resolution/frameworks/svelte.js.map +1 -0
  605. package/dist/resolution/frameworks/swift-objc.d.ts +37 -0
  606. package/dist/resolution/frameworks/swift-objc.d.ts.map +1 -0
  607. package/dist/resolution/frameworks/swift-objc.js +252 -0
  608. package/dist/resolution/frameworks/swift-objc.js.map +1 -0
  609. package/dist/resolution/frameworks/swift.d.ts +10 -0
  610. package/dist/resolution/frameworks/swift.d.ts.map +1 -0
  611. package/dist/resolution/frameworks/swift.js +400 -0
  612. package/dist/resolution/frameworks/swift.js.map +1 -0
  613. package/dist/resolution/frameworks/terraform.d.ts +38 -0
  614. package/dist/resolution/frameworks/terraform.d.ts.map +1 -0
  615. package/dist/resolution/frameworks/terraform.js +277 -0
  616. package/dist/resolution/frameworks/terraform.js.map +1 -0
  617. package/dist/resolution/frameworks/vue.d.ts +9 -0
  618. package/dist/resolution/frameworks/vue.d.ts.map +1 -0
  619. package/dist/resolution/frameworks/vue.js +303 -0
  620. package/dist/resolution/frameworks/vue.js.map +1 -0
  621. package/dist/resolution/go-module.d.ts +26 -0
  622. package/dist/resolution/go-module.d.ts.map +1 -0
  623. package/dist/resolution/go-module.js +78 -0
  624. package/dist/resolution/go-module.js.map +1 -0
  625. package/dist/resolution/goframe-synthesizer.d.ts +29 -0
  626. package/dist/resolution/goframe-synthesizer.d.ts.map +1 -0
  627. package/dist/resolution/goframe-synthesizer.js +163 -0
  628. package/dist/resolution/goframe-synthesizer.js.map +1 -0
  629. package/dist/resolution/import-resolver.d.ts +84 -0
  630. package/dist/resolution/import-resolver.d.ts.map +1 -0
  631. package/dist/resolution/import-resolver.js +2134 -0
  632. package/dist/resolution/import-resolver.js.map +1 -0
  633. package/dist/resolution/index.d.ts +343 -0
  634. package/dist/resolution/index.d.ts.map +1 -0
  635. package/dist/resolution/index.js +2339 -0
  636. package/dist/resolution/index.js.map +1 -0
  637. package/dist/resolution/lru-cache.d.ts +24 -0
  638. package/dist/resolution/lru-cache.d.ts.map +1 -0
  639. package/dist/resolution/lru-cache.js +62 -0
  640. package/dist/resolution/lru-cache.js.map +1 -0
  641. package/dist/resolution/memory-budget.d.ts +48 -0
  642. package/dist/resolution/memory-budget.d.ts.map +1 -0
  643. package/dist/resolution/memory-budget.js +162 -0
  644. package/dist/resolution/memory-budget.js.map +1 -0
  645. package/dist/resolution/name-matcher.d.ts +123 -0
  646. package/dist/resolution/name-matcher.d.ts.map +1 -0
  647. package/dist/resolution/name-matcher.js +2134 -0
  648. package/dist/resolution/name-matcher.js.map +1 -0
  649. package/dist/resolution/path-aliases.d.ts +68 -0
  650. package/dist/resolution/path-aliases.d.ts.map +1 -0
  651. package/dist/resolution/path-aliases.js +238 -0
  652. package/dist/resolution/path-aliases.js.map +1 -0
  653. package/dist/resolution/resolver-pool.d.ts +106 -0
  654. package/dist/resolution/resolver-pool.d.ts.map +1 -0
  655. package/dist/resolution/resolver-pool.js +344 -0
  656. package/dist/resolution/resolver-pool.js.map +1 -0
  657. package/dist/resolution/resolver-worker.d.ts +17 -0
  658. package/dist/resolution/resolver-worker.d.ts.map +1 -0
  659. package/dist/resolution/resolver-worker.js +141 -0
  660. package/dist/resolution/resolver-worker.js.map +1 -0
  661. package/dist/resolution/strip-comments.d.ts +27 -0
  662. package/dist/resolution/strip-comments.d.ts.map +1 -0
  663. package/dist/resolution/strip-comments.js +492 -0
  664. package/dist/resolution/strip-comments.js.map +1 -0
  665. package/dist/resolution/swift-objc-bridge.d.ts +134 -0
  666. package/dist/resolution/swift-objc-bridge.d.ts.map +1 -0
  667. package/dist/resolution/swift-objc-bridge.js +256 -0
  668. package/dist/resolution/swift-objc-bridge.js.map +1 -0
  669. package/dist/resolution/types.d.ts +265 -0
  670. package/dist/resolution/types.d.ts.map +1 -0
  671. package/dist/resolution/types.js +8 -0
  672. package/dist/resolution/types.js.map +1 -0
  673. package/dist/resolution/workspace-packages.d.ts +58 -0
  674. package/dist/resolution/workspace-packages.d.ts.map +1 -0
  675. package/dist/resolution/workspace-packages.js +346 -0
  676. package/dist/resolution/workspace-packages.js.map +1 -0
  677. package/dist/search/identifier-segments.d.ts +60 -0
  678. package/dist/search/identifier-segments.d.ts.map +1 -0
  679. package/dist/search/identifier-segments.js +176 -0
  680. package/dist/search/identifier-segments.js.map +1 -0
  681. package/dist/search/query-parser.d.ts +57 -0
  682. package/dist/search/query-parser.d.ts.map +1 -0
  683. package/dist/search/query-parser.js +177 -0
  684. package/dist/search/query-parser.js.map +1 -0
  685. package/dist/search/query-utils.d.ts +87 -0
  686. package/dist/search/query-utils.d.ts.map +1 -0
  687. package/dist/search/query-utils.js +450 -0
  688. package/dist/search/query-utils.js.map +1 -0
  689. package/dist/sync/git-hooks.d.ts +45 -0
  690. package/dist/sync/git-hooks.d.ts.map +1 -0
  691. package/dist/sync/git-hooks.js +227 -0
  692. package/dist/sync/git-hooks.js.map +1 -0
  693. package/dist/sync/index.d.ts +19 -0
  694. package/dist/sync/index.d.ts.map +1 -0
  695. package/dist/sync/index.js +35 -0
  696. package/dist/sync/index.js.map +1 -0
  697. package/dist/sync/watch-policy.d.ts +48 -0
  698. package/dist/sync/watch-policy.d.ts.map +1 -0
  699. package/dist/sync/watch-policy.js +124 -0
  700. package/dist/sync/watch-policy.js.map +1 -0
  701. package/dist/sync/watcher.d.ts +379 -0
  702. package/dist/sync/watcher.d.ts.map +1 -0
  703. package/dist/sync/watcher.js +921 -0
  704. package/dist/sync/watcher.js.map +1 -0
  705. package/dist/sync/worktree.d.ts +63 -0
  706. package/dist/sync/worktree.d.ts.map +1 -0
  707. package/dist/sync/worktree.js +182 -0
  708. package/dist/sync/worktree.js.map +1 -0
  709. package/dist/telemetry/index.d.ts +143 -0
  710. package/dist/telemetry/index.d.ts.map +1 -0
  711. package/dist/telemetry/index.js +541 -0
  712. package/dist/telemetry/index.js.map +1 -0
  713. package/dist/types.d.ts +465 -0
  714. package/dist/types.d.ts.map +1 -0
  715. package/dist/types.js +117 -0
  716. package/dist/types.js.map +1 -0
  717. package/dist/ui/color.d.ts +21 -0
  718. package/dist/ui/color.d.ts.map +1 -0
  719. package/dist/ui/color.js +42 -0
  720. package/dist/ui/color.js.map +1 -0
  721. package/dist/ui/glyphs.d.ts +67 -0
  722. package/dist/ui/glyphs.d.ts.map +1 -0
  723. package/dist/ui/glyphs.js +125 -0
  724. package/dist/ui/glyphs.js.map +1 -0
  725. package/dist/ui/shimmer-progress.d.ts +11 -0
  726. package/dist/ui/shimmer-progress.d.ts.map +1 -0
  727. package/dist/ui/shimmer-progress.js +164 -0
  728. package/dist/ui/shimmer-progress.js.map +1 -0
  729. package/dist/ui/shimmer-worker.d.ts +2 -0
  730. package/dist/ui/shimmer-worker.d.ts.map +1 -0
  731. package/dist/ui/shimmer-worker.js +126 -0
  732. package/dist/ui/shimmer-worker.js.map +1 -0
  733. package/dist/ui/types.d.ts +15 -0
  734. package/dist/ui/types.d.ts.map +1 -0
  735. package/dist/ui/types.js +3 -0
  736. package/dist/ui/types.js.map +1 -0
  737. package/dist/upgrade/index.d.ts +171 -0
  738. package/dist/upgrade/index.d.ts.map +1 -0
  739. package/dist/upgrade/index.js +659 -0
  740. package/dist/upgrade/index.js.map +1 -0
  741. package/dist/upgrade/remove-binary.d.ts +87 -0
  742. package/dist/upgrade/remove-binary.d.ts.map +1 -0
  743. package/dist/upgrade/remove-binary.js +289 -0
  744. package/dist/upgrade/remove-binary.js.map +1 -0
  745. package/dist/upgrade/update-check.d.ts +92 -0
  746. package/dist/upgrade/update-check.d.ts.map +1 -0
  747. package/dist/upgrade/update-check.js +258 -0
  748. package/dist/upgrade/update-check.js.map +1 -0
  749. package/dist/utils.d.ts +224 -0
  750. package/dist/utils.d.ts.map +1 -0
  751. package/dist/utils.js +583 -0
  752. package/dist/utils.js.map +1 -0
  753. package/package.json +61 -0
  754. package/scripts/add-lang/bench.sh +60 -0
  755. package/scripts/add-lang/check-grammar.mjs +75 -0
  756. package/scripts/add-lang/dump-ast.mjs +103 -0
  757. package/scripts/add-lang/verify-extraction.mjs +70 -0
  758. package/scripts/agent-eval/ab-adoption.sh +91 -0
  759. package/scripts/agent-eval/ab-hook.sh +86 -0
  760. package/scripts/agent-eval/ab-impl.sh +78 -0
  761. package/scripts/agent-eval/ab-new-vs-baseline.sh +161 -0
  762. package/scripts/agent-eval/ab-sufficiency.sh +78 -0
  763. package/scripts/agent-eval/allocation-fixtures.json +344 -0
  764. package/scripts/agent-eval/arms-F.sh +21 -0
  765. package/scripts/agent-eval/arms-matrix.sh +37 -0
  766. package/scripts/agent-eval/audit.sh +68 -0
  767. package/scripts/agent-eval/bench-readme.sh +48 -0
  768. package/scripts/agent-eval/bench-why-repo.sh +22 -0
  769. package/scripts/agent-eval/block-read-hook.sh +19 -0
  770. package/scripts/agent-eval/compare-arms.mjs +209 -0
  771. package/scripts/agent-eval/diff-index-drift.mjs +102 -0
  772. package/scripts/agent-eval/hook-settings.json +15 -0
  773. package/scripts/agent-eval/itrun.sh +120 -0
  774. package/scripts/agent-eval/no-cli-shim.sh +96 -0
  775. package/scripts/agent-eval/offload-eval-3arm.sh +72 -0
  776. package/scripts/agent-eval/offload-eval-cost.mjs +133 -0
  777. package/scripts/agent-eval/offload-eval-effort.mjs +108 -0
  778. package/scripts/agent-eval/offload-eval-frontload-matrix.sh +25 -0
  779. package/scripts/agent-eval/offload-eval-frontload.sh +47 -0
  780. package/scripts/agent-eval/offload-eval-ground-truth.json +18 -0
  781. package/scripts/agent-eval/offload-eval-hook.mjs +84 -0
  782. package/scripts/agent-eval/offload-eval-judge.mjs +103 -0
  783. package/scripts/agent-eval/offload-eval-matrix.sh +20 -0
  784. package/scripts/agent-eval/offload-eval-metrics.mjs +94 -0
  785. package/scripts/agent-eval/offload-eval-refs1.sh +50 -0
  786. package/scripts/agent-eval/offload-eval-setup.sh +24 -0
  787. package/scripts/agent-eval/offload-eval-styles.sh +72 -0
  788. package/scripts/agent-eval/offload-eval-summarize.mjs +68 -0
  789. package/scripts/agent-eval/offload-eval.md +76 -0
  790. package/scripts/agent-eval/parse-arms.mjs +116 -0
  791. package/scripts/agent-eval/parse-bench-readme.mjs +238 -0
  792. package/scripts/agent-eval/parse-run.mjs +1401 -0
  793. package/scripts/agent-eval/parse-session.mjs +130 -0
  794. package/scripts/agent-eval/probe-allocation.mjs +335 -0
  795. package/scripts/agent-eval/probe-context.mjs +21 -0
  796. package/scripts/agent-eval/probe-decl-only.mjs +198 -0
  797. package/scripts/agent-eval/probe-explore.mjs +40 -0
  798. package/scripts/agent-eval/probe-factory-closure.mjs +147 -0
  799. package/scripts/agent-eval/probe-file-spend.mjs +195 -0
  800. package/scripts/agent-eval/probe-named-symbol.mjs +163 -0
  801. package/scripts/agent-eval/probe-node.mjs +20 -0
  802. package/scripts/agent-eval/probe-suite-envelope.mjs +124 -0
  803. package/scripts/agent-eval/probe-sweep.mjs +119 -0
  804. package/scripts/agent-eval/probe-trace.mjs +20 -0
  805. package/scripts/agent-eval/redirect-read-hook.sh +38 -0
  806. package/scripts/agent-eval/repro-concurrent-explore.mjs +119 -0
  807. package/scripts/agent-eval/repro-daemon-clients.mjs +125 -0
  808. package/scripts/agent-eval/run-agent.sh +34 -0
  809. package/scripts/agent-eval/run-all.sh +149 -0
  810. package/scripts/agent-eval/run-arms.sh +56 -0
  811. package/scripts/agent-eval/seq-matrix.mjs +137 -0
  812. package/scripts/build-bundle.sh +145 -0
  813. package/scripts/build-kernel.sh +87 -0
  814. package/scripts/dump-graph.mjs +57 -0
  815. package/scripts/extract-release-notes.mjs +130 -0
  816. package/scripts/kernel-parity.mjs +283 -0
  817. package/scripts/local-install.sh +41 -0
  818. package/scripts/npm-sdk.js +75 -0
  819. package/scripts/npm-shim.js +279 -0
  820. package/scripts/pack-npm.sh +123 -0
  821. package/scripts/prepare-release.mjs +270 -0
@@ -0,0 +1,2134 @@
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.isNixPathImportRef = isNixPathImportRef;
42
+ exports.clearImportResolverMemos = clearImportResolverMemos;
43
+ exports.resolveImportPath = resolveImportPath;
44
+ exports.clearCppIncludeDirCache = clearCppIncludeDirCache;
45
+ exports.loadCppIncludeDirs = loadCppIncludeDirs;
46
+ exports.isPhpIncludePathRef = isPhpIncludePathRef;
47
+ exports.isCobolCopybookRef = isCobolCopybookRef;
48
+ exports.extractImportMappings = extractImportMappings;
49
+ exports.clearImportMappingCache = clearImportMappingCache;
50
+ exports.extractReExports = extractReExports;
51
+ exports.resolveJvmImport = resolveJvmImport;
52
+ exports.resolveViaImport = resolveViaImport;
53
+ const fs = __importStar(require("fs"));
54
+ const path = __importStar(require("path"));
55
+ const path_aliases_1 = require("./path-aliases");
56
+ const workspace_packages_1 = require("./workspace-packages");
57
+ const name_matcher_1 = require("./name-matcher");
58
+ /**
59
+ * Extension resolution order by language
60
+ */
61
+ const EXTENSION_RESOLUTION = {
62
+ typescript: ['.ts', '.tsx', '.d.ts', '.js', '.jsx', '/index.ts', '/index.tsx', '/index.js'],
63
+ // ArkTS imports both `.ets` components and plain `.ts` logic modules —
64
+ // HarmonyOS projects are always a mix. `/Index.ets` (capital I) is ohpm's
65
+ // module-entry convention, hit when a bare workspace import ("data") is
66
+ // rewritten to the member's directory; lowercase variants for safety.
67
+ arkts: ['.ets', '.ts', '.d.ts', '.js', '/Index.ets', '/index.ets', '/index.ts', '/index.js'],
68
+ javascript: ['.js', '.jsx', '.mjs', '.cjs', '/index.js', '/index.jsx'],
69
+ tsx: ['.tsx', '.ts', '.d.ts', '.js', '.jsx', '/index.tsx', '/index.ts', '/index.js'],
70
+ jsx: ['.jsx', '.js', '/index.jsx', '/index.js'],
71
+ // SFC consumers import plain TS/JS, sibling components, and barrels
72
+ // (`./lib` → `./lib/index.ts`). Without a list, relative imports from a
73
+ // `.svelte`/`.vue` file resolve to nothing, so barrel callers vanish (#629).
74
+ svelte: ['.ts', '.js', '.svelte', '.tsx', '.jsx', '/index.ts', '/index.js', '/index.svelte'],
75
+ vue: ['.ts', '.js', '.vue', '.tsx', '.jsx', '/index.ts', '/index.js', '/index.vue'],
76
+ astro: ['.ts', '.js', '.astro', '.tsx', '.jsx', '/index.ts', '/index.js', '/index.astro'],
77
+ python: ['.py', '/__init__.py'],
78
+ go: ['.go'],
79
+ rust: ['.rs', '/mod.rs'],
80
+ java: ['.java'],
81
+ c: ['.h', '.c'],
82
+ cpp: ['.h', '.hpp', '.hxx', '.cpp', '.cc', '.cxx'],
83
+ csharp: ['.cs'],
84
+ php: ['.php'],
85
+ ruby: ['.rb'],
86
+ objc: ['.h', '.m', '.mm'],
87
+ nix: ['.nix', '/default.nix'],
88
+ };
89
+ function isNixPathImportRef(ref) {
90
+ return (ref.language === 'nix' &&
91
+ ref.referenceKind === 'imports' &&
92
+ (ref.referenceName.startsWith('./') || ref.referenceName.startsWith('../')) &&
93
+ !/[\s{}()[\];"'<>$]/.test(ref.referenceName));
94
+ }
95
+ /**
96
+ * Resolve an import path to an actual file
97
+ */
98
+ // Per-context memos for the two hottest pure lookups on the resolution path:
99
+ // import-specifier → file resolution and exported-symbol lookup. Both are pure
100
+ // given a stable file set + node table, which is exactly the window between
101
+ // ReferenceResolver.clearCaches() calls — clearImportResolverMemos() is invoked
102
+ // there, so the staleness discipline matches the resolver's own caches.
103
+ const importPathMemos = new WeakMap();
104
+ const exportedSymbolMemos = new WeakMap();
105
+ const fileExportIndexes = new WeakMap();
106
+ function getFileExportIndex(filePath, context) {
107
+ let perFile = fileExportIndexes.get(context);
108
+ if (!perFile) {
109
+ perFile = new Map();
110
+ fileExportIndexes.set(context, perFile);
111
+ }
112
+ let idx = perFile.get(filePath);
113
+ if (!idx) {
114
+ idx = { byName: new Map(), defaultComponent: undefined, defaultFnClass: undefined };
115
+ for (const n of context.getNodesInFile(filePath)) {
116
+ if (!n.isExported)
117
+ continue;
118
+ if (!idx.byName.has(n.name))
119
+ idx.byName.set(n.name, n);
120
+ if (idx.defaultComponent === undefined && n.kind === 'component')
121
+ idx.defaultComponent = n;
122
+ if (idx.defaultFnClass === undefined && (n.kind === 'function' || n.kind === 'class'))
123
+ idx.defaultFnClass = n;
124
+ }
125
+ perFile.set(filePath, idx);
126
+ }
127
+ return idx;
128
+ }
129
+ /** Drop the per-context memo tables (see ReferenceResolver.clearCaches). */
130
+ function clearImportResolverMemos(context) {
131
+ importPathMemos.delete(context);
132
+ exportedSymbolMemos.delete(context);
133
+ fileExportIndexes.delete(context);
134
+ luaFileBasenameIndexes.delete(context);
135
+ cobolCopybookIndexes.delete(context);
136
+ }
137
+ function resolveImportPath(importPath, fromFile, language, context) {
138
+ let memo = importPathMemos.get(context);
139
+ if (!memo) {
140
+ memo = new Map();
141
+ importPathMemos.set(context, memo);
142
+ }
143
+ const key = `${language}\0${fromFile}\0${importPath}`;
144
+ const hit = memo.get(key);
145
+ if (hit !== undefined || memo.has(key))
146
+ return hit ?? null;
147
+ const resolved = resolveImportPathUncached(importPath, fromFile, language, context);
148
+ memo.set(key, resolved);
149
+ return resolved;
150
+ }
151
+ function resolveImportPathUncached(importPath, fromFile, language, context) {
152
+ // COBOL COPY/EXEC SQL INCLUDE names a copybook member, not a path — the
153
+ // compiler searches a library, so we match against indexed file basenames.
154
+ // Must run before isExternalImport: a bare member name would otherwise be
155
+ // misclassified as an external package.
156
+ if (language === 'cobol') {
157
+ return resolveCobolCopybook(importPath, fromFile, context);
158
+ }
159
+ // Skip external/npm packages — but pass the context so the
160
+ // bare-specifier heuristic can consult the project's tsconfig
161
+ // alias map first (custom prefixes like `@components/*` would
162
+ // otherwise be misclassified as npm).
163
+ if (isExternalImport(importPath, language, context)) {
164
+ return null;
165
+ }
166
+ const projectRoot = context.getProjectRoot();
167
+ const fromDir = path.dirname(path.join(projectRoot, fromFile));
168
+ // Handle relative imports
169
+ if (importPath.startsWith('.')) {
170
+ return resolveRelativeImport(importPath, fromDir, language, context);
171
+ }
172
+ // Handle absolute/aliased imports (like @/ or src/)
173
+ const aliased = resolveAliasedImport(importPath, projectRoot, language, context);
174
+ if (aliased)
175
+ return aliased;
176
+ // C/C++ include directory search: when neither relative nor aliased
177
+ // resolution found a match, search -I directories from
178
+ // compile_commands.json or heuristic probing.
179
+ if (language === 'c' || language === 'cpp') {
180
+ return resolveCppIncludePath(importPath, language, context);
181
+ }
182
+ return null;
183
+ }
184
+ /**
185
+ * COBOL copybook lookup: `COPY CVACT01Y` (or `EXEC SQL INCLUDE X`) names a
186
+ * library member resolved by the compiler's copybook search path, so we match
187
+ * the member against indexed file basenames, case-insensitively. `.cpy` wins
188
+ * over a same-named program; a same-directory hit wins within a tier. The
189
+ * stem index is built once per resolution context (a per-ref scan of every
190
+ * file node would go quadratic on copybook-heavy repos).
191
+ */
192
+ const cobolCopybookIndexes = new WeakMap();
193
+ /**
194
+ * Per-context basename → file-paths index for Lua/Luau require resolution
195
+ * (cobolCopybookIndexes pattern). resolveLuaRequire previously ran
196
+ * `getAllFiles().filter(endsWith)` FOUR times per require ref — ~7.5k string
197
+ * suffix scans each, measured at ~0.9ms/ref (2.7s combined on kong's 3k
198
+ * requires). Buckets preserve getAllFiles() iteration order so the per-suffix
199
+ * candidate list filters to exactly the array the full scan produced —
200
+ * identical matches, identical stable sort, identical winner.
201
+ */
202
+ const luaFileBasenameIndexes = new WeakMap();
203
+ function luaBasenameIndex(context) {
204
+ let index = luaFileBasenameIndexes.get(context);
205
+ if (!index) {
206
+ index = new Map();
207
+ for (const f of context.getAllFiles()) {
208
+ const base = f.split('/').pop() ?? '';
209
+ const paths = index.get(base);
210
+ if (paths)
211
+ paths.push(f);
212
+ else
213
+ index.set(base, [f]);
214
+ }
215
+ luaFileBasenameIndexes.set(context, index);
216
+ }
217
+ return index;
218
+ }
219
+ function resolveCobolCopybook(member, fromFile, context) {
220
+ let index = cobolCopybookIndexes.get(context);
221
+ if (!index) {
222
+ index = new Map();
223
+ for (const fileNode of context.getNodesByKind('file')) {
224
+ const normalized = fileNode.filePath.replace(/\\/g, '/');
225
+ const base = normalized.split('/').pop() ?? '';
226
+ const dot = base.lastIndexOf('.');
227
+ const stem = (dot > 0 ? base.slice(0, dot) : base).toLowerCase();
228
+ const paths = index.get(stem);
229
+ if (paths)
230
+ paths.push(fileNode.filePath);
231
+ else
232
+ index.set(stem, [fileNode.filePath]);
233
+ }
234
+ cobolCopybookIndexes.set(context, index);
235
+ }
236
+ const candidates = index.get(member.toLowerCase());
237
+ if (!candidates || candidates.length === 0)
238
+ return null;
239
+ const fromDir = fromFile.replace(/\\/g, '/').split('/').slice(0, -1).join('/');
240
+ let best = null;
241
+ let bestScore = -1;
242
+ for (const candidate of candidates) {
243
+ const normalized = candidate.replace(/\\/g, '/');
244
+ const ext = normalized.slice(normalized.lastIndexOf('.')).toLowerCase();
245
+ let score = 0;
246
+ if (ext === '.cpy')
247
+ score += 4;
248
+ else if (ext === '.cbl' || ext === '.cob' || ext === '.cobol')
249
+ score += 2;
250
+ if (normalized.split('/').slice(0, -1).join('/') === fromDir)
251
+ score += 1;
252
+ if (score > bestScore) {
253
+ bestScore = score;
254
+ best = candidate;
255
+ }
256
+ }
257
+ return best;
258
+ }
259
+ /**
260
+ * C and C++ standard library header names (without delimiters).
261
+ * Used by isExternalImport to filter system includes from resolution.
262
+ */
263
+ const C_CPP_STDLIB_HEADERS = new Set([
264
+ // C standard library headers
265
+ 'assert.h', 'complex.h', 'ctype.h', 'errno.h', 'fenv.h', 'float.h',
266
+ 'inttypes.h', 'iso646.h', 'limits.h', 'locale.h', 'math.h', 'setjmp.h',
267
+ 'signal.h', 'stdalign.h', 'stdarg.h', 'stdatomic.h', 'stdbool.h',
268
+ 'stddef.h', 'stdint.h', 'stdio.h', 'stdlib.h', 'stdnoreturn.h',
269
+ 'string.h', 'tgmath.h', 'threads.h', 'time.h', 'uchar.h', 'wchar.h',
270
+ 'wctype.h',
271
+ // C++ C-library wrappers (cname form)
272
+ 'cassert', 'ccomplex', 'cctype', 'cerrno', 'cfenv', 'cfloat',
273
+ 'cinttypes', 'ciso646', 'climits', 'clocale', 'cmath', 'csetjmp',
274
+ 'csignal', 'cstdalign', 'cstdarg', 'cstdbool', 'cstddef', 'cstdint',
275
+ 'cstdio', 'cstdlib', 'cstring', 'ctgmath', 'ctime', 'cuchar',
276
+ 'cwchar', 'cwctype',
277
+ // C++ STL headers
278
+ 'algorithm', 'any', 'array', 'atomic', 'barrier', 'bit', 'bitset',
279
+ 'charconv', 'chrono', 'codecvt', 'compare', 'complex', 'concepts',
280
+ 'condition_variable', 'coroutine', 'deque', 'exception', 'execution',
281
+ 'expected', 'filesystem', 'format', 'forward_list', 'fstream',
282
+ 'functional', 'future', 'generator', 'initializer_list', 'iomanip',
283
+ 'ios', 'iosfwd', 'iostream', 'istream', 'iterator', 'latch',
284
+ 'limits', 'list', 'locale', 'map', 'mdspan', 'memory', 'memory_resource',
285
+ 'mutex', 'new', 'numbers', 'numeric', 'optional', 'ostream', 'print',
286
+ 'queue', 'random', 'ranges', 'ratio', 'regex', 'scoped_allocator',
287
+ 'semaphore', 'set', 'shared_mutex', 'source_location', 'span',
288
+ 'spanstream', 'sstream', 'stack', 'stacktrace', 'stdexcept',
289
+ 'stdfloat', 'stop_token', 'streambuf', 'string', 'string_view',
290
+ 'strstream', 'syncstream', 'system_error', 'thread', 'tuple',
291
+ 'type_traits', 'typeindex', 'typeinfo', 'unordered_map',
292
+ 'unordered_set', 'utility', 'valarray', 'variant', 'vector',
293
+ 'version',
294
+ ]);
295
+ /**
296
+ * Check if an import is external (npm package, etc.)
297
+ *
298
+ * `context` is consulted for project-defined path aliases
299
+ * (tsconfig/jsconfig `paths`). Without that check, custom prefixes
300
+ * like `@components/*` would fail the bare-specifier heuristic and
301
+ * be classified as external before alias resolution can run.
302
+ */
303
+ function isExternalImport(importPath, language, context) {
304
+ // Relative imports are not external
305
+ if (importPath.startsWith('.')) {
306
+ return false;
307
+ }
308
+ // Workspace-member imports (`@scope/ui`, `@scope/ui/widgets`) are LOCAL to
309
+ // a monorepo even though they look like bare npm specifiers. Consult the
310
+ // workspace map first so they aren't misclassified as external (#629). The
311
+ // map is null for single-package repos, so this is a no-op there.
312
+ const workspaces = context?.getWorkspacePackages?.();
313
+ if (workspaces && (0, workspace_packages_1.resolveWorkspaceImport)(importPath, workspaces)) {
314
+ return false;
315
+ }
316
+ // Common external patterns
317
+ if (language === 'typescript' || language === 'javascript' || language === 'tsx' || language === 'jsx' || language === 'arkts') {
318
+ // Node built-ins
319
+ if (['fs', 'path', 'os', 'crypto', 'http', 'https', 'url', 'util', 'events', 'stream', 'child_process', 'buffer'].includes(importPath)) {
320
+ return true;
321
+ }
322
+ // Project-defined alias prefix? Treat as local.
323
+ const aliases = context?.getProjectAliases?.();
324
+ if (aliases) {
325
+ for (const pat of aliases.patterns) {
326
+ if (importPath.startsWith(pat.prefix))
327
+ return false;
328
+ }
329
+ }
330
+ // Scoped packages or bare specifiers that don't start with aliases
331
+ if (!importPath.startsWith('@/') && !importPath.startsWith('~/') && !importPath.startsWith('src/')) {
332
+ // Likely an npm package
333
+ return true;
334
+ }
335
+ }
336
+ if (language === 'python') {
337
+ // Standard library modules
338
+ const stdLibs = ['os', 'sys', 'json', 're', 'math', 'datetime', 'collections', 'typing', 'pathlib', 'logging'];
339
+ if (stdLibs.includes(importPath.split('.')[0])) {
340
+ return true;
341
+ }
342
+ }
343
+ if (language === 'go') {
344
+ // Relative imports (rare in idiomatic Go but the grammar allows them).
345
+ if (importPath.startsWith('.')) {
346
+ return false;
347
+ }
348
+ // In-module imports look like `<module-path>/sub/pkg` — local to
349
+ // this project. Without the module-path check we'd flag every
350
+ // cross-package call in a Go monorepo as external (issue #388).
351
+ const mod = context?.getGoModule?.();
352
+ if (mod && (importPath === mod.modulePath || importPath.startsWith(mod.modulePath + '/'))) {
353
+ return false;
354
+ }
355
+ // `internal/` packages stay local even when go.mod is missing —
356
+ // preserves the pre-#388 escape hatch for repos without a parsed module path.
357
+ if (importPath.includes('/internal/')) {
358
+ return false;
359
+ }
360
+ // Anything else is the Go standard library or a third-party module.
361
+ return true;
362
+ }
363
+ if (language === 'c' || language === 'cpp') {
364
+ // C/C++ standard library headers — both C-style (<stdio.h>) and
365
+ // C++-style (<cstdio>, <vector>) forms. Checked against the import
366
+ // path (which the extractor strips of <> or "" delimiters).
367
+ if (C_CPP_STDLIB_HEADERS.has(importPath))
368
+ return true;
369
+ // C++ headers without .h extension (e.g. "vector", "string")
370
+ const withoutExt = importPath.replace(/\.h$/, '');
371
+ if (C_CPP_STDLIB_HEADERS.has(withoutExt))
372
+ return true;
373
+ }
374
+ return false;
375
+ }
376
+ /**
377
+ * Resolve a relative import
378
+ */
379
+ function resolveRelativeImport(importPath, fromDir, language, context) {
380
+ const projectRoot = context.getProjectRoot();
381
+ const extensions = EXTENSION_RESOLUTION[language] || [];
382
+ // Python dotted-relative imports (`from .certs import x`, `from ..pkg.mod
383
+ // import y`): leading dots are PACKAGE levels (1 = current package), and the
384
+ // remainder is a dotted submodule path. `path.resolve(dir, '.certs')` would
385
+ // treat `.certs` as a literal hidden filename, so translate the Python form
386
+ // to a real filesystem-relative path before resolving.
387
+ if (language === 'python' && importPath.startsWith('.')) {
388
+ const dots = importPath.length - importPath.replace(/^\.+/, '').length;
389
+ const up = '../'.repeat(Math.max(0, dots - 1)); // 1 dot = current dir
390
+ const rest = importPath.slice(dots).replace(/\./g, '/'); // 'sub.mod' -> 'sub/mod'
391
+ const pyBase = path.resolve(fromDir, up + rest);
392
+ const pyRel = path.relative(projectRoot, pyBase).replace(/\\/g, '/');
393
+ for (const ext of extensions) {
394
+ if (context.fileExists(pyRel + ext))
395
+ return pyRel + ext;
396
+ }
397
+ if (pyRel && context.fileExists(pyRel))
398
+ return pyRel;
399
+ return null;
400
+ }
401
+ // Try the path as-is first
402
+ const basePath = path.resolve(fromDir, importPath);
403
+ const relativePath = path.relative(projectRoot, basePath).replace(/\\/g, '/');
404
+ // Try each extension
405
+ for (const ext of extensions) {
406
+ const candidatePath = relativePath + ext;
407
+ if (context.fileExists(candidatePath)) {
408
+ return candidatePath;
409
+ }
410
+ }
411
+ // Try without extension (might already have one)
412
+ if (context.fileExists(relativePath)) {
413
+ return relativePath;
414
+ }
415
+ return null;
416
+ }
417
+ /**
418
+ * Resolve an aliased/absolute import.
419
+ *
420
+ * Tries, in order:
421
+ * 1. Project-defined `compilerOptions.paths` (tsconfig/jsconfig).
422
+ * Each pattern can have multiple replacements; tried in tsconfig
423
+ * priority order with extension permutations.
424
+ * 2. The legacy hard-coded fallback list (`@/`, `~/`, `src/`, ...)
425
+ * for projects that have aliases but no tsconfig paths block.
426
+ * 3. Direct path lookup (with extensions).
427
+ */
428
+ function resolveAliasedImport(importPath, projectRoot, language, context) {
429
+ const extensions = EXTENSION_RESOLUTION[language] || [];
430
+ const tryWithExt = (basePath) => {
431
+ for (const ext of extensions) {
432
+ const candidate = basePath + ext;
433
+ if (context.fileExists(candidate))
434
+ return candidate;
435
+ }
436
+ if (context.fileExists(basePath))
437
+ return basePath;
438
+ return null;
439
+ };
440
+ // 1. Project tsconfig/jsconfig paths.
441
+ const aliasMap = context.getProjectAliases?.();
442
+ if (aliasMap) {
443
+ const candidates = (0, path_aliases_1.applyAliases)(importPath, aliasMap, projectRoot);
444
+ for (const c of candidates) {
445
+ const hit = tryWithExt(c);
446
+ if (hit)
447
+ return hit;
448
+ }
449
+ }
450
+ // 1.5 Workspace packages (`@scope/ui/widgets` → `packages/ui/widgets`).
451
+ // Resolves a monorepo member import to the member's directory; the
452
+ // extension/index permutations below then find its barrel (#629).
453
+ const workspaces = context.getWorkspacePackages?.();
454
+ if (workspaces) {
455
+ const base = (0, workspace_packages_1.resolveWorkspaceImport)(importPath, workspaces);
456
+ if (base) {
457
+ const hit = tryWithExt(base);
458
+ if (hit)
459
+ return hit;
460
+ }
461
+ }
462
+ // 2. Hard-coded fallback list. Kept for projects that use these
463
+ // conventional aliases without declaring them in tsconfig.
464
+ const fallbackAliases = {
465
+ '@/': 'src/',
466
+ '~/': 'src/',
467
+ '@src/': 'src/',
468
+ 'src/': 'src/',
469
+ '@app/': 'app/',
470
+ 'app/': 'app/',
471
+ };
472
+ for (const [alias, replacement] of Object.entries(fallbackAliases)) {
473
+ if (importPath.startsWith(alias)) {
474
+ const hit = tryWithExt(importPath.replace(alias, replacement));
475
+ if (hit)
476
+ return hit;
477
+ }
478
+ }
479
+ // 3. Direct path.
480
+ return tryWithExt(importPath);
481
+ }
482
+ /**
483
+ * C/C++ include directory cache (keyed by project root).
484
+ * Loaded once per resolver instance, shared across calls.
485
+ */
486
+ const cppIncludeDirCache = new Map();
487
+ /**
488
+ * Clear the C/C++ include directory cache (call between indexing runs)
489
+ */
490
+ function clearCppIncludeDirCache() {
491
+ cppIncludeDirCache.clear();
492
+ }
493
+ /**
494
+ * Discover C/C++ include search directories for a project.
495
+ *
496
+ * Strategy:
497
+ * 1. Look for compile_commands.json (Clang compilation database) in the
498
+ * project root and common build subdirectories. Parse -I and -isystem
499
+ * flags from compiler commands.
500
+ * 2. If no compilation database is found, probe for common convention
501
+ * directories (include/, src/, lib/, api/) and top-level directories
502
+ * containing .h/.hpp files.
503
+ *
504
+ * Returns paths relative to projectRoot.
505
+ */
506
+ function loadCppIncludeDirs(projectRoot) {
507
+ const cached = cppIncludeDirCache.get(projectRoot);
508
+ if (cached !== undefined)
509
+ return cached;
510
+ const dirs = loadCppIncludeDirsFromCompileDB(projectRoot)
511
+ || loadCppIncludeDirsHeuristic(projectRoot);
512
+ cppIncludeDirCache.set(projectRoot, dirs);
513
+ return dirs;
514
+ }
515
+ /**
516
+ * Try to load include directories from compile_commands.json.
517
+ * Returns null if no compilation database is found (so the heuristic
518
+ * fallback can run). Returns an array (possibly empty) otherwise.
519
+ */
520
+ function loadCppIncludeDirsFromCompileDB(projectRoot) {
521
+ const candidates = [
522
+ path.join(projectRoot, 'compile_commands.json'),
523
+ path.join(projectRoot, 'build', 'compile_commands.json'),
524
+ path.join(projectRoot, 'cmake-build-debug', 'compile_commands.json'),
525
+ path.join(projectRoot, 'cmake-build-release', 'compile_commands.json'),
526
+ path.join(projectRoot, 'out', 'compile_commands.json'),
527
+ ];
528
+ let dbPath;
529
+ for (const c of candidates) {
530
+ try {
531
+ if (fs.existsSync(c)) {
532
+ dbPath = c;
533
+ break;
534
+ }
535
+ }
536
+ catch {
537
+ // ignore
538
+ }
539
+ }
540
+ if (!dbPath)
541
+ return null;
542
+ try {
543
+ const content = fs.readFileSync(dbPath, 'utf-8');
544
+ const entries = JSON.parse(content);
545
+ if (!Array.isArray(entries))
546
+ return null;
547
+ const dirSet = new Set();
548
+ for (const entry of entries) {
549
+ const dir = entry.directory || projectRoot;
550
+ const args = entry.arguments || (entry.command ? shlexSplit(entry.command) : []);
551
+ for (let i = 0; i < args.length; i++) {
552
+ const arg = args[i];
553
+ let includeDir;
554
+ // -I<dir> (no space)
555
+ if (arg.startsWith('-I') && arg.length > 2) {
556
+ includeDir = arg.substring(2);
557
+ }
558
+ // -isystem <dir> (space-separated)
559
+ else if ((arg === '-isystem' || arg === '-I') && i + 1 < args.length) {
560
+ includeDir = args[i + 1];
561
+ i++; // skip next arg
562
+ }
563
+ if (includeDir) {
564
+ // Normalize: resolve relative to the compilation directory
565
+ const absPath = path.isAbsolute(includeDir)
566
+ ? includeDir
567
+ : path.resolve(dir, includeDir);
568
+ const relPath = path.relative(projectRoot, absPath).replace(/\\/g, '/');
569
+ // Skip system directories and paths outside the project
570
+ // (relative paths starting with .. or absolute paths like
571
+ // /usr/include or C:\usr on Windows)
572
+ if (!relPath.startsWith('..') && relPath.length > 0 && !path.isAbsolute(relPath)) {
573
+ dirSet.add(relPath);
574
+ }
575
+ }
576
+ }
577
+ }
578
+ return Array.from(dirSet);
579
+ }
580
+ catch {
581
+ return null;
582
+ }
583
+ }
584
+ /**
585
+ * Minimal shlex-style split for compiler command strings.
586
+ * Handles double-quoted and single-quoted arguments.
587
+ */
588
+ function shlexSplit(cmd) {
589
+ const result = [];
590
+ let i = 0;
591
+ while (i < cmd.length) {
592
+ // Skip whitespace
593
+ while (i < cmd.length && /\s/.test(cmd[i]))
594
+ i++;
595
+ if (i >= cmd.length)
596
+ break;
597
+ const ch = cmd[i];
598
+ if (ch === '"') {
599
+ i++;
600
+ let arg = '';
601
+ while (i < cmd.length && cmd[i] !== '"') {
602
+ if (cmd[i] === '\\' && i + 1 < cmd.length) {
603
+ i++;
604
+ arg += cmd[i];
605
+ }
606
+ else {
607
+ arg += cmd[i];
608
+ }
609
+ i++;
610
+ }
611
+ i++; // closing quote
612
+ result.push(arg);
613
+ }
614
+ else if (ch === "'") {
615
+ i++;
616
+ let arg = '';
617
+ while (i < cmd.length && cmd[i] !== "'") {
618
+ arg += cmd[i];
619
+ i++;
620
+ }
621
+ i++; // closing quote
622
+ result.push(arg);
623
+ }
624
+ else {
625
+ let arg = '';
626
+ while (i < cmd.length && !/\s/.test(cmd[i])) {
627
+ arg += cmd[i];
628
+ i++;
629
+ }
630
+ result.push(arg);
631
+ }
632
+ }
633
+ return result;
634
+ }
635
+ /**
636
+ * Heuristic include directory discovery when no compile_commands.json exists.
637
+ * Checks common convention directories and scans top-level dirs for headers.
638
+ */
639
+ function loadCppIncludeDirsHeuristic(projectRoot) {
640
+ const dirs = [];
641
+ const conventionDirs = ['include', 'src', 'lib', 'api', 'inc'];
642
+ try {
643
+ const entries = fs.readdirSync(projectRoot, { withFileTypes: true });
644
+ for (const entry of entries) {
645
+ if (!entry.isDirectory())
646
+ continue;
647
+ const name = entry.name;
648
+ // Convention directories
649
+ if (conventionDirs.includes(name.toLowerCase())) {
650
+ dirs.push(name);
651
+ continue;
652
+ }
653
+ // Any top-level directory containing .h or .hpp files
654
+ try {
655
+ const subFiles = fs.readdirSync(path.join(projectRoot, name));
656
+ if (subFiles.some(f => /\.(h|hpp|hxx|hh)$/i.test(f))) {
657
+ dirs.push(name);
658
+ }
659
+ }
660
+ catch {
661
+ // ignore permission errors
662
+ }
663
+ }
664
+ }
665
+ catch {
666
+ // ignore
667
+ }
668
+ return dirs;
669
+ }
670
+ /**
671
+ * Resolve a C/C++ include path by searching include directories.
672
+ * Called as a fallback after relative and aliased resolution fail.
673
+ */
674
+ function resolveCppIncludePath(importPath, language, context) {
675
+ const includeDirs = context.getCppIncludeDirs?.() ?? [];
676
+ const extensions = EXTENSION_RESOLUTION[language] ?? [];
677
+ for (const dir of includeDirs) {
678
+ const normalizedDir = dir.replace(/\\/g, '/');
679
+ for (const ext of extensions) {
680
+ const candidate = normalizedDir + '/' + importPath + ext;
681
+ if (context.fileExists(candidate))
682
+ return candidate;
683
+ }
684
+ // Try as-is (already has extension)
685
+ const candidate = normalizedDir + '/' + importPath;
686
+ if (context.fileExists(candidate))
687
+ return candidate;
688
+ }
689
+ return null;
690
+ }
691
+ /**
692
+ * Is this reference a PHP include/require PATH (vs a namespace `use` symbol)?
693
+ *
694
+ * include/require emit a file path ("lib.php", "inc/db.php", "../x.php"),
695
+ * whereas namespace use is an FQN (App\Foo\Bar) or a bare class symbol
696
+ * (Closure). PHP identifiers contain neither '/' nor '.', so a slash or dot
697
+ * marks a path-shaped include. Such references resolve to files only — never
698
+ * to a same-named symbol — so callers must not fall back to the name-matcher.
699
+ */
700
+ function isPhpIncludePathRef(ref) {
701
+ return (ref.language === 'php' &&
702
+ ref.referenceKind === 'imports' &&
703
+ (ref.referenceName.includes('/') || ref.referenceName.includes('.')));
704
+ }
705
+ /**
706
+ * Is this a COBOL COPY / EXEC SQL INCLUDE copybook reference? These resolve
707
+ * to files only (or stay unresolved for compiler-supplied members) — never
708
+ * to a same-named symbol via the name-matcher.
709
+ */
710
+ function isCobolCopybookRef(ref) {
711
+ return ref.language === 'cobol' && ref.referenceKind === 'imports';
712
+ }
713
+ /**
714
+ * Resolve a PHP include/require path to a project-relative file path.
715
+ *
716
+ * PHP resolves includes relative to the including file's directory (the
717
+ * common case for procedural codebases); php.ini `include_path` is not
718
+ * modeled. Callers pass an already-extracted static literal path.
719
+ */
720
+ function resolvePhpIncludePath(includePath, fromFile, context) {
721
+ const projectRoot = context.getProjectRoot();
722
+ const fromDir = path.dirname(path.join(projectRoot, fromFile));
723
+ const basePath = path.resolve(fromDir, includePath);
724
+ const relativePath = path.relative(projectRoot, basePath).replace(/\\/g, '/');
725
+ if (context.fileExists(relativePath))
726
+ return relativePath;
727
+ // The literal may omit the .php extension (e.g. include "config").
728
+ for (const ext of EXTENSION_RESOLUTION.php ?? []) {
729
+ if (context.fileExists(relativePath + ext))
730
+ return relativePath + ext;
731
+ }
732
+ return null;
733
+ }
734
+ /**
735
+ * Extract import mappings from a file
736
+ */
737
+ function extractImportMappings(_filePath, content, language) {
738
+ const mappings = [];
739
+ if (language === 'typescript' || language === 'javascript' || language === 'tsx' || language === 'jsx' || language === 'arkts') {
740
+ mappings.push(...extractJSImports(content));
741
+ }
742
+ else if (language === 'svelte' || language === 'vue' || language === 'astro') {
743
+ // Svelte/Vue single-file components import via plain ES6 inside their
744
+ // `<script>` block (Astro: the `---` frontmatter). Without this, a
745
+ // `.svelte`/`.vue`/`.astro` consumer produces
746
+ // zero import mappings, so `resolveViaImport` can't run and a barrel
747
+ // import (`import { Foo } from './lib'`) falls back to name-matching —
748
+ // which silently fails whenever the re-export alias differs from the
749
+ // component's real name, yielding a false 0 callers (#629). The ES6
750
+ // import regex only matches `import … from '…'`, so running it over the
751
+ // whole SFC (markup + styles included) is safe.
752
+ mappings.push(...extractJSImports(content));
753
+ }
754
+ else if (language === 'python') {
755
+ mappings.push(...extractPythonImports(content));
756
+ }
757
+ else if (language === 'go') {
758
+ mappings.push(...extractGoImports(content));
759
+ }
760
+ else if (language === 'java' || language === 'kotlin') {
761
+ mappings.push(...extractJavaImports(content));
762
+ }
763
+ else if (language === 'php') {
764
+ mappings.push(...extractPHPImports(content));
765
+ }
766
+ else if (language === 'c' || language === 'cpp') {
767
+ mappings.push(...extractCppImports(content));
768
+ }
769
+ return mappings;
770
+ }
771
+ /**
772
+ * Extract JS/TS import mappings
773
+ */
774
+ function extractJSImports(content) {
775
+ const mappings = [];
776
+ // ES6 imports
777
+ const importRegex = /import\s+(?:(\w+)\s*,?\s*)?(?:\{([^}]+)\})?\s*(?:(\*)\s+as\s+(\w+))?\s*from\s*['"]([^'"]+)['"]/g;
778
+ let match;
779
+ while ((match = importRegex.exec(content)) !== null) {
780
+ const [, defaultImport, namedImports, star, namespaceAlias, source] = match;
781
+ // Default import
782
+ if (defaultImport) {
783
+ mappings.push({
784
+ localName: defaultImport,
785
+ exportedName: 'default',
786
+ source: source,
787
+ isDefault: true,
788
+ isNamespace: false,
789
+ });
790
+ }
791
+ // Named imports
792
+ if (namedImports) {
793
+ const names = namedImports.split(',').map((s) => s.trim());
794
+ for (const name of names) {
795
+ const aliasMatch = name.match(/(\w+)\s+as\s+(\w+)/);
796
+ if (aliasMatch) {
797
+ mappings.push({
798
+ localName: aliasMatch[2],
799
+ exportedName: aliasMatch[1],
800
+ source: source,
801
+ isDefault: false,
802
+ isNamespace: false,
803
+ });
804
+ }
805
+ else if (name) {
806
+ mappings.push({
807
+ localName: name,
808
+ exportedName: name,
809
+ source: source,
810
+ isDefault: false,
811
+ isNamespace: false,
812
+ });
813
+ }
814
+ }
815
+ }
816
+ // Namespace import
817
+ if (star && namespaceAlias) {
818
+ mappings.push({
819
+ localName: namespaceAlias,
820
+ exportedName: '*',
821
+ source: source,
822
+ isDefault: false,
823
+ isNamespace: true,
824
+ });
825
+ }
826
+ }
827
+ // Require statements
828
+ const requireRegex = /(?:const|let|var)\s+(?:(\w+)|{([^}]+)})\s*=\s*require\(['"]([^'"]+)['"]\)/g;
829
+ while ((match = requireRegex.exec(content)) !== null) {
830
+ const [, defaultName, destructured, source] = match;
831
+ if (defaultName) {
832
+ mappings.push({
833
+ localName: defaultName,
834
+ exportedName: 'default',
835
+ source: source,
836
+ isDefault: true,
837
+ isNamespace: false,
838
+ });
839
+ }
840
+ if (destructured) {
841
+ const names = destructured.split(',').map((s) => s.trim());
842
+ for (const name of names) {
843
+ const aliasMatch = name.match(/(\w+)\s*:\s*(\w+)/);
844
+ if (aliasMatch) {
845
+ mappings.push({
846
+ localName: aliasMatch[2],
847
+ exportedName: aliasMatch[1],
848
+ source: source,
849
+ isDefault: false,
850
+ isNamespace: false,
851
+ });
852
+ }
853
+ else if (name) {
854
+ mappings.push({
855
+ localName: name,
856
+ exportedName: name,
857
+ source: source,
858
+ isDefault: false,
859
+ isNamespace: false,
860
+ });
861
+ }
862
+ }
863
+ }
864
+ }
865
+ return mappings;
866
+ }
867
+ /**
868
+ * Extract Python import mappings
869
+ */
870
+ function extractPythonImports(content) {
871
+ const mappings = [];
872
+ // from X import Y
873
+ const fromImportRegex = /from\s+([\w.]+)\s+import\s+([^#\n]+)/g;
874
+ let match;
875
+ while ((match = fromImportRegex.exec(content)) !== null) {
876
+ const [, source, imports] = match;
877
+ const names = imports.split(',').map((s) => s.trim());
878
+ for (const name of names) {
879
+ const aliasMatch = name.match(/(\w+)\s+as\s+(\w+)/);
880
+ if (aliasMatch) {
881
+ mappings.push({
882
+ localName: aliasMatch[2],
883
+ exportedName: aliasMatch[1],
884
+ source: source,
885
+ isDefault: false,
886
+ isNamespace: false,
887
+ });
888
+ }
889
+ else if (name && name !== '*') {
890
+ mappings.push({
891
+ localName: name,
892
+ exportedName: name,
893
+ source: source,
894
+ isDefault: false,
895
+ isNamespace: false,
896
+ });
897
+ }
898
+ }
899
+ }
900
+ // import X
901
+ const importRegex = /^import\s+([\w.]+)(?:\s+as\s+(\w+))?/gm;
902
+ while ((match = importRegex.exec(content)) !== null) {
903
+ const [, source, alias] = match;
904
+ const localName = alias || source.split('.').pop();
905
+ mappings.push({
906
+ localName,
907
+ exportedName: '*',
908
+ source: source,
909
+ isDefault: false,
910
+ isNamespace: true,
911
+ });
912
+ }
913
+ return mappings;
914
+ }
915
+ /**
916
+ * Extract Go import mappings
917
+ */
918
+ function extractGoImports(content) {
919
+ const mappings = [];
920
+ // import "path" or import alias "path"
921
+ const singleImportRegex = /import\s+(?:(\w+)\s+)?["']([^"']+)["']/g;
922
+ let match;
923
+ while ((match = singleImportRegex.exec(content)) !== null) {
924
+ const [, alias, source] = match;
925
+ const packageName = source.split('/').pop();
926
+ mappings.push({
927
+ localName: alias || packageName,
928
+ exportedName: '*',
929
+ source: source,
930
+ isDefault: false,
931
+ isNamespace: true,
932
+ });
933
+ }
934
+ // import ( ... ) block
935
+ const blockImportRegex = /import\s*\(\s*([^)]+)\s*\)/gs;
936
+ while ((match = blockImportRegex.exec(content)) !== null) {
937
+ const block = match[1];
938
+ const lineRegex = /(?:(\w+)\s+)?["']([^"']+)["']/g;
939
+ let lineMatch;
940
+ while ((lineMatch = lineRegex.exec(block)) !== null) {
941
+ const [, alias, source] = lineMatch;
942
+ const packageName = source.split('/').pop();
943
+ mappings.push({
944
+ localName: alias || packageName,
945
+ exportedName: '*',
946
+ source: source,
947
+ isDefault: false,
948
+ isNamespace: true,
949
+ });
950
+ }
951
+ }
952
+ return mappings;
953
+ }
954
+ /**
955
+ * Extract Java / Kotlin import mappings.
956
+ *
957
+ * Java/Kotlin imports carry the full qualified name of the imported
958
+ * symbol — `import com.example.dao.converter.FooConverter;` — which is
959
+ * exactly the disambiguation signal we need when two packages both
960
+ * declare a `FooConverter`. Pre-#314 the resolver had no Java branch
961
+ * here at all, so this mapping was empty and cross-module name
962
+ * collisions were resolved by file-path proximity (often wrongly).
963
+ *
964
+ * `import static com.example.Foo.bar;` is parsed as a local-name `bar`
965
+ * pointing at FQN `com.example.Foo.bar` so static-method call sites
966
+ * (`bar(...)`) can resolve through the same import lookup.
967
+ */
968
+ function extractJavaImports(content) {
969
+ const mappings = [];
970
+ // Strip line and block comments so `// import foo;` doesn't false-match.
971
+ const stripped = content
972
+ .replace(/\/\*[\s\S]*?\*\//g, '')
973
+ .replace(/\/\/[^\n]*/g, '');
974
+ // `import [static] <fqn>[.*];`
975
+ const re = /^\s*import\s+(static\s+)?([\w.]+(?:\.\*)?)\s*;/gm;
976
+ let match;
977
+ while ((match = re.exec(stripped)) !== null) {
978
+ const fqn = match[2];
979
+ // `import com.example.*;` — wildcard. We can't materialize a single
980
+ // local name; skip and let name-matching handle members reachable
981
+ // through the wildcard. (Future enhancement: enumerate package files.)
982
+ if (fqn.endsWith('.*'))
983
+ continue;
984
+ const parts = fqn.split('.');
985
+ const localName = parts[parts.length - 1];
986
+ if (!localName)
987
+ continue;
988
+ mappings.push({
989
+ localName,
990
+ exportedName: localName,
991
+ source: fqn,
992
+ isDefault: false,
993
+ isNamespace: false,
994
+ });
995
+ }
996
+ return mappings;
997
+ }
998
+ /**
999
+ * Extract PHP import mappings (use statements)
1000
+ */
1001
+ function extractPHPImports(content) {
1002
+ const mappings = [];
1003
+ // use Namespace\Class; or use Namespace\Class as Alias;
1004
+ const useRegex = /use\s+([\w\\]+)(?:\s+as\s+(\w+))?;/g;
1005
+ let match;
1006
+ while ((match = useRegex.exec(content)) !== null) {
1007
+ const [, fullPath, alias] = match;
1008
+ const className = fullPath.split('\\').pop();
1009
+ mappings.push({
1010
+ localName: alias || className,
1011
+ exportedName: className,
1012
+ source: fullPath,
1013
+ isDefault: false,
1014
+ isNamespace: false,
1015
+ });
1016
+ }
1017
+ return mappings;
1018
+ }
1019
+ /**
1020
+ * Extract C/C++ import mappings from #include directives.
1021
+ *
1022
+ * #include brings all symbols from the included header into scope
1023
+ * (namespace import), so each mapping uses isNamespace: true and
1024
+ * exportedName: '*'. The localName is set to the header's basename
1025
+ * without extension so that symbol references like `MyClass` can
1026
+ * match against any include that might provide it.
1027
+ */
1028
+ function extractCppImports(content) {
1029
+ const mappings = [];
1030
+ // Match both #include <...> and #include "..."
1031
+ const includeRegex = /^\s*#\s*include\s+[<"]([^>"]+)[>"]/gm;
1032
+ let match;
1033
+ while ((match = includeRegex.exec(content)) !== null) {
1034
+ const modulePath = match[1];
1035
+ // Basename without extension for localName matching
1036
+ const basename = modulePath.split('/').pop().replace(/\.(h|hpp|hxx|hh|inl|ipp|cxx|cc|cpp)$/, '');
1037
+ mappings.push({
1038
+ localName: basename || modulePath,
1039
+ exportedName: '*',
1040
+ source: modulePath,
1041
+ isDefault: false,
1042
+ isNamespace: true,
1043
+ });
1044
+ }
1045
+ return mappings;
1046
+ }
1047
+ // Cache import mappings per file to avoid re-reading and re-parsing
1048
+ const importMappingCache = new Map();
1049
+ /**
1050
+ * Clear the import mapping cache (call between indexing runs)
1051
+ */
1052
+ function clearImportMappingCache() {
1053
+ importMappingCache.clear();
1054
+ cppIncludeDirCache.clear();
1055
+ }
1056
+ /**
1057
+ * Strip JS line + block comments from `content` while preserving
1058
+ * string literals (so `"//"` inside a string stays intact). Used by
1059
+ * {@link extractReExports} so commented-out export-from statements
1060
+ * don't generate phantom re-export edges.
1061
+ *
1062
+ * Scanner is deliberately small: it only tracks the three contexts
1063
+ * relevant for JS/TS — single-quote string, double-quote string, and
1064
+ * template literal. Comment recognition is the JS spec subset, no
1065
+ * regex-literal awareness (which is fine for our use case: we don't
1066
+ * apply this to function bodies, only to top-level files).
1067
+ */
1068
+ function stripJsComments(content) {
1069
+ let out = '';
1070
+ let i = 0;
1071
+ let str = null;
1072
+ while (i < content.length) {
1073
+ const ch = content[i];
1074
+ if (str !== null) {
1075
+ out += ch;
1076
+ if (ch === '\\' && i + 1 < content.length) {
1077
+ out += content[i + 1];
1078
+ i += 2;
1079
+ continue;
1080
+ }
1081
+ if (ch === str)
1082
+ str = null;
1083
+ i++;
1084
+ continue;
1085
+ }
1086
+ if (ch === '"' || ch === "'" || ch === '`') {
1087
+ str = ch;
1088
+ out += ch;
1089
+ i++;
1090
+ continue;
1091
+ }
1092
+ if (ch === '/' && content[i + 1] === '/') {
1093
+ while (i < content.length && content[i] !== '\n')
1094
+ i++;
1095
+ continue;
1096
+ }
1097
+ if (ch === '/' && content[i + 1] === '*') {
1098
+ i += 2;
1099
+ while (i < content.length && !(content[i] === '*' && content[i + 1] === '/'))
1100
+ i++;
1101
+ i += 2;
1102
+ continue;
1103
+ }
1104
+ out += ch;
1105
+ i++;
1106
+ }
1107
+ return out;
1108
+ }
1109
+ /**
1110
+ * Extract JS/TS re-export declarations from `content`.
1111
+ *
1112
+ * Recognised forms:
1113
+ * export { foo } from './a';
1114
+ * export { foo as bar } from './a';
1115
+ * export * from './a';
1116
+ * export * as ns from './a'; (treated as wildcard for chasing)
1117
+ * export { default as Foo } from './a';
1118
+ *
1119
+ * The walker intentionally stays regex-based — the import-resolver
1120
+ * elsewhere in this file already chooses regex over a fresh
1121
+ * tree-sitter pass, and this function shares that trade-off. Errors
1122
+ * fall through silently; resolution simply skips the broken file.
1123
+ */
1124
+ function extractReExports(content, language) {
1125
+ if (language !== 'typescript' &&
1126
+ language !== 'javascript' &&
1127
+ language !== 'tsx' &&
1128
+ language !== 'jsx' &&
1129
+ language !== 'arkts') {
1130
+ return [];
1131
+ }
1132
+ const out = [];
1133
+ // Pre-strip block comments + line comments so a commented-out
1134
+ // `// export { x } from '...'` doesn't produce a phantom edge.
1135
+ // (Template literals are still a possible source of false positives;
1136
+ // a project that builds export statements as runtime strings is
1137
+ // out of scope.)
1138
+ const cleaned = stripJsComments(content);
1139
+ // Wildcard: `export * from '...'` or `export * as ns from '...'`
1140
+ const wildcardRe = /export\s*\*(?:\s+as\s+\w+)?\s*from\s*['"]([^'"]+)['"]/g;
1141
+ let m;
1142
+ while ((m = wildcardRe.exec(cleaned)) !== null) {
1143
+ out.push({ kind: 'wildcard', source: m[1] });
1144
+ }
1145
+ // Named: `export { a, b as c } from '...'`
1146
+ const namedRe = /export\s*\{([^}]+)\}\s*from\s*['"]([^'"]+)['"]/g;
1147
+ while ((m = namedRe.exec(cleaned)) !== null) {
1148
+ const inner = m[1];
1149
+ const source = m[2];
1150
+ for (const raw of inner.split(',')) {
1151
+ const item = raw.trim();
1152
+ if (!item)
1153
+ continue;
1154
+ const aliasMatch = item.match(/^(\w+)\s+as\s+(\w+)$/);
1155
+ if (aliasMatch) {
1156
+ out.push({
1157
+ kind: 'named',
1158
+ exportedName: aliasMatch[2],
1159
+ originalName: aliasMatch[1],
1160
+ source,
1161
+ });
1162
+ }
1163
+ else if (/^\w+$/.test(item)) {
1164
+ out.push({
1165
+ kind: 'named',
1166
+ exportedName: item,
1167
+ originalName: item,
1168
+ source,
1169
+ });
1170
+ }
1171
+ }
1172
+ }
1173
+ return out;
1174
+ }
1175
+ /**
1176
+ * Resolve a reference using import mappings
1177
+ */
1178
+ /**
1179
+ * JVM (Java / Kotlin) imports use fully-qualified names (`import
1180
+ * com.example.foo.Bar`) decoupled from filenames, so the JS/Python
1181
+ * style filesystem path lookup misses them whenever the file isn't
1182
+ * named after its primary symbol (Kotlin `Utils.kt` exporting `Bar`,
1183
+ * top-level fns, extension fns). Resolve them through the
1184
+ * `qualifiedName` index instead — populated by the package_header /
1185
+ * package_declaration namespace wrappers in the extractor.
1186
+ */
1187
+ function resolveJvmImport(ref, context) {
1188
+ if (ref.referenceKind !== 'imports')
1189
+ return null;
1190
+ if (ref.language !== 'java' && ref.language !== 'kotlin')
1191
+ return null;
1192
+ const fqn = ref.referenceName;
1193
+ const lastDot = fqn.lastIndexOf('.');
1194
+ if (lastDot <= 0)
1195
+ return null;
1196
+ const pkg = fqn.substring(0, lastDot);
1197
+ const sym = fqn.substring(lastDot + 1);
1198
+ // Wildcard imports (`com.example.*`) deliberately punt to name-matcher.
1199
+ if (sym === '*')
1200
+ return null;
1201
+ const candidates = context.getNodesByQualifiedName(`${pkg}::${sym}`);
1202
+ if (candidates.length === 0)
1203
+ return null;
1204
+ // Kotlin Multiplatform: an `expect` declaration and its `actual`s share one
1205
+ // FQN across source sets (commonMain / androidMain / appleMain). Taking the
1206
+ // first candidate let a single platform `actual` absorb every common-side
1207
+ // import, so the `expect` (the canonical API a commonMain file imports)
1208
+ // looked unused. Prefer the candidate CLOSEST to the importing file by
1209
+ // directory proximity — a commonMain import resolves to the commonMain
1210
+ // declaration — with the `expect` side as a tiebreak.
1211
+ const best = candidates.length === 1 ? candidates[0] : pickClosestJvmCandidate(candidates, ref.filePath);
1212
+ return {
1213
+ original: ref,
1214
+ targetNodeId: best.id,
1215
+ confidence: 0.95,
1216
+ resolvedBy: 'import',
1217
+ };
1218
+ }
1219
+ /**
1220
+ * Pick the same-FQN candidate closest to `fromPath` by shared directory
1221
+ * prefix, preferring an `expect` declaration on a tie. Used to keep a Kotlin
1222
+ * Multiplatform `expect`/`actual` import resolving within the importer's own
1223
+ * source set instead of an arbitrary platform `actual`.
1224
+ */
1225
+ function pickClosestJvmCandidate(candidates, fromPath) {
1226
+ const fromDirs = fromPath.split('/').slice(0, -1);
1227
+ const sharedPrefix = (p) => {
1228
+ const d = p.split('/').slice(0, -1);
1229
+ let shared = 0;
1230
+ for (let i = 0; i < Math.min(fromDirs.length, d.length); i++) {
1231
+ if (fromDirs[i] === d[i])
1232
+ shared++;
1233
+ else
1234
+ break;
1235
+ }
1236
+ return shared;
1237
+ };
1238
+ const isExpect = (n) => Array.isArray(n.decorators) && n.decorators.includes('expect');
1239
+ let best = candidates[0];
1240
+ let bestProx = sharedPrefix(best.filePath);
1241
+ for (let i = 1; i < candidates.length; i++) {
1242
+ const c = candidates[i];
1243
+ const prox = sharedPrefix(c.filePath);
1244
+ if (prox > bestProx || (prox === bestProx && isExpect(c) && !isExpect(best))) {
1245
+ best = c;
1246
+ bestProx = prox;
1247
+ }
1248
+ }
1249
+ return best;
1250
+ }
1251
+ function resolveViaImport(ref, context) {
1252
+ // C/C++ #include references — resolve directly to the included file
1253
+ // (file→file edge), bypassing symbol lookup. The extractor emits these
1254
+ // with `referenceKind: 'imports'` and `referenceName: <include path>`
1255
+ // (e.g. "uint256.h" or "common/args.h"). Without this branch the
1256
+ // include-dir scan path inside resolveImportPath never produces an
1257
+ // edge — resolveViaImport's symbol lookup below would search the
1258
+ // resolved file for a symbol named like the file extension and fail.
1259
+ if ((ref.language === 'c' || ref.language === 'cpp') && ref.referenceKind === 'imports') {
1260
+ // C/C++ quoted includes (`#include "X.h"`) resolve relative to the
1261
+ // INCLUDING file's own directory first (the C standard's quoted-include
1262
+ // search order). Prefer a same-directory header over an -I directory or a
1263
+ // same-named header on another platform (windows/code/RNCAsyncStorage.h vs
1264
+ // apple/.../RNCAsyncStorage.h) — the include-dir heuristic below would
1265
+ // otherwise pick an arbitrary same-named header, leaving the real local one
1266
+ // with no dependents.
1267
+ const slash = ref.filePath.lastIndexOf('/');
1268
+ const fromDir = slash >= 0 ? ref.filePath.slice(0, slash) : '';
1269
+ const siblingPath = path.posix.normalize(fromDir ? `${fromDir}/${ref.referenceName}` : ref.referenceName);
1270
+ const siblingBase = siblingPath.split('/').pop();
1271
+ const sibling = context
1272
+ .getNodesByName(siblingBase)
1273
+ .find((n) => n.kind === 'file' && n.filePath === siblingPath);
1274
+ if (sibling) {
1275
+ return { original: ref, targetNodeId: sibling.id, confidence: 0.92, resolvedBy: 'import' };
1276
+ }
1277
+ const resolvedPath = resolveImportPath(ref.referenceName, ref.filePath, ref.language, context);
1278
+ if (!resolvedPath)
1279
+ return null;
1280
+ const basename = resolvedPath.split('/').pop();
1281
+ const fileNodes = context.getNodesByName(basename).filter((n) => n.kind === 'file');
1282
+ const fileNode = fileNodes.find((n) => n.filePath === resolvedPath);
1283
+ if (fileNode) {
1284
+ return {
1285
+ original: ref,
1286
+ targetNodeId: fileNode.id,
1287
+ confidence: 0.9,
1288
+ resolvedBy: 'import',
1289
+ };
1290
+ }
1291
+ return null;
1292
+ }
1293
+ // COBOL COPY / EXEC SQL INCLUDE — resolve the copybook member to a
1294
+ // file→file edge, mirroring the C/C++ include branch above. A member that
1295
+ // matches no indexed file (compiler-supplied copybooks like SQLCA/DFHAID)
1296
+ // stays unresolved — callers must not fall back to the symbol name-matcher,
1297
+ // which would connect it to a same-named import symbol elsewhere.
1298
+ if (isCobolCopybookRef(ref)) {
1299
+ const resolvedPath = resolveImportPath(ref.referenceName, ref.filePath, ref.language, context);
1300
+ if (!resolvedPath)
1301
+ return null;
1302
+ const basename = resolvedPath.split('/').pop();
1303
+ const fileNode = context
1304
+ .getNodesByName(basename)
1305
+ .find((n) => n.kind === 'file' && n.filePath === resolvedPath);
1306
+ if (fileNode) {
1307
+ return {
1308
+ original: ref,
1309
+ targetNodeId: fileNode.id,
1310
+ confidence: 0.9,
1311
+ resolvedBy: 'import',
1312
+ };
1313
+ }
1314
+ return null;
1315
+ }
1316
+ // PHP include/require — resolve the static string path to a file→file
1317
+ // edge, mirroring the C/C++ branch above. Distinguish include PATHS from
1318
+ // namespace `use` symbols by shape: an include path contains a slash or a
1319
+ // file extension ("lib.php", "inc/db.php", "../x.php"), whereas a namespace
1320
+ // use is an FQN (App\Foo\Bar) or a bare class symbol (Closure) — PHP
1321
+ // identifiers contain neither '/' nor '.'. Only path-shaped references are
1322
+ // includes; symbol references fall through to the namespace resolution.
1323
+ if (isPhpIncludePathRef(ref)) {
1324
+ const resolvedPath = resolvePhpIncludePath(ref.referenceName, ref.filePath, context);
1325
+ if (resolvedPath) {
1326
+ const basename = resolvedPath.split('/').pop();
1327
+ const fileNode = context
1328
+ .getNodesByName(basename)
1329
+ .find((n) => n.kind === 'file' && n.filePath === resolvedPath);
1330
+ if (fileNode) {
1331
+ return {
1332
+ original: ref,
1333
+ targetNodeId: fileNode.id,
1334
+ confidence: 0.9,
1335
+ resolvedBy: 'import',
1336
+ };
1337
+ }
1338
+ }
1339
+ // A path-shaped include that doesn't resolve to a known project file is a
1340
+ // dead end. Return unresolved rather than falling through to the symbol
1341
+ // name-matcher, which would mis-connect e.g. "inc/db.php" to an unrelated
1342
+ // db.php elsewhere in the tree — a wrong edge is worse than a missing one.
1343
+ return null;
1344
+ }
1345
+ // Nix static project-path imports (`import ./x.nix`, `builtins.import ./dir`,
1346
+ // `import ./x.nix {}`) resolve to file nodes only. Do not resolve
1347
+ // angle-bracket channels, attribute expressions, variables, or other dynamic
1348
+ // expressions as project files.
1349
+ if (isNixPathImportRef(ref)) {
1350
+ const resolvedPath = resolveImportPath(ref.referenceName, ref.filePath, ref.language, context);
1351
+ if (!resolvedPath)
1352
+ return null;
1353
+ const basename = resolvedPath.split('/').pop();
1354
+ const fileNode = context
1355
+ .getNodesByName(basename)
1356
+ .find((n) => n.kind === 'file' && n.filePath === resolvedPath);
1357
+ if (fileNode) {
1358
+ return {
1359
+ original: ref,
1360
+ targetNodeId: fileNode.id,
1361
+ confidence: 0.9,
1362
+ resolvedBy: 'import',
1363
+ };
1364
+ }
1365
+ return null;
1366
+ }
1367
+ // Use cached import mappings (avoids re-reading and re-parsing per ref)
1368
+ const imports = context.getImportMappings(ref.filePath, ref.language);
1369
+ if (imports.length === 0 && !context.readFile(ref.filePath)) {
1370
+ return null;
1371
+ }
1372
+ // Go cross-package calls: `pkga.FuncX(...)` extracts to referenceName
1373
+ // `pkga.FuncX` and the import `github.com/example/myproject/pkga`
1374
+ // maps to a *package directory* containing one or more .go files.
1375
+ // The generic file-based lookup below can't follow that — issue #388.
1376
+ if (ref.language === 'go') {
1377
+ const goResult = resolveGoCrossPackageReference(ref, imports, context);
1378
+ if (goResult)
1379
+ return goResult;
1380
+ }
1381
+ // Java / Kotlin: imports are FQNs (`import com.example.Foo;`) — no
1382
+ // resolvable file path the JS/TS-style chain below could follow. Look
1383
+ // up the symbol by name and filter to the candidate whose file path
1384
+ // matches the imported FQN. This is the disambiguation signal that
1385
+ // breaks the same-name class collision the path-proximity matcher
1386
+ // can't resolve (issue #314).
1387
+ if (ref.language === 'java' || ref.language === 'kotlin') {
1388
+ const javaResult = resolveJavaImportedReference(ref, imports, context);
1389
+ if (javaResult)
1390
+ return javaResult;
1391
+ }
1392
+ // Python qualified access through an imported MODULE: `certs.where()` after
1393
+ // `from . import certs`, `mod.func()` after `import mod`. The receiver names a
1394
+ // submodule (a file), not a symbol, so the generic symbol lookup below would
1395
+ // search the *package* for `certs` instead of looking inside the module.
1396
+ if (ref.language === 'python') {
1397
+ const pyResult = resolvePythonModuleMember(ref, imports, context);
1398
+ if (pyResult)
1399
+ return pyResult;
1400
+ // Absolute dotted module import: `import conduit.apps.articles.signals`
1401
+ // (the standard Django AppConfig.ready() signal-registration pattern, and
1402
+ // any side-effect `import pkg.mod`). Map the dotted path to its file.
1403
+ const pyModResult = resolvePythonAbsoluteModule(ref, context);
1404
+ if (pyModResult)
1405
+ return pyModResult;
1406
+ }
1407
+ // Rust qualified path: resolve the module prefix of `crate::m::Item` /
1408
+ // `self::sub::Item` / `super::m::func` to a file, then find the leaf symbol in
1409
+ // it. Disambiguates common-name `pub use self::read::read` re-exports that
1410
+ // name-matching would land on the wrong same-named symbol.
1411
+ if (ref.language === 'rust' && ref.referenceName.includes('::')) {
1412
+ const rustResult = resolveRustPathReference(ref, context);
1413
+ if (rustResult)
1414
+ return rustResult;
1415
+ }
1416
+ // Lua / Luau `require(...)`: a dotted module path (`a.b.c` from
1417
+ // `require("a.b.c")`) or an instance-path leaf (`Signal` from
1418
+ // `require(script.Parent.Signal)`) — map it to a module file. There's no static
1419
+ // import statement, so the generic path-matcher can't bridge the dot↔slash /
1420
+ // leaf↔basename gap; resolve it explicitly to the module file.
1421
+ if ((ref.language === 'lua' || ref.language === 'luau') && ref.referenceKind === 'imports') {
1422
+ const luaResult = resolveLuaRequire(ref, context);
1423
+ if (luaResult)
1424
+ return luaResult;
1425
+ }
1426
+ // Whole-module / namespace imports → link the importing file to the module
1427
+ // file. Python `from . import certs` / `import mod`, and TS/JS `import * as ns
1428
+ // from './x'` (so a namespace touched only via a value-member read still
1429
+ // records the dependency). A named TS/JS import returns null here and falls
1430
+ // through to symbol resolution below.
1431
+ if (ref.language === 'python' ||
1432
+ ref.language === 'typescript' ||
1433
+ ref.language === 'tsx' ||
1434
+ ref.language === 'javascript' ||
1435
+ ref.language === 'jsx' ||
1436
+ ref.language === 'arkts') {
1437
+ const moduleFile = resolveModuleImportToFile(ref, imports, context);
1438
+ if (moduleFile)
1439
+ return moduleFile;
1440
+ }
1441
+ // Check if the reference name matches any import
1442
+ for (const imp of imports) {
1443
+ if (imp.localName === ref.referenceName || ref.referenceName.startsWith(imp.localName + '.')) {
1444
+ // Resolve the import path
1445
+ const resolvedPath = resolveImportPath(imp.source, ref.filePath, ref.language, context);
1446
+ if (resolvedPath) {
1447
+ const exportedName = imp.isDefault ? 'default' : imp.exportedName;
1448
+ const memberName = imp.isNamespace
1449
+ ? ref.referenceName.replace(imp.localName + '.', '')
1450
+ : null;
1451
+ const targetNode = findExportedSymbol(resolvedPath, { isDefault: imp.isDefault, isNamespace: imp.isNamespace, exportedName, memberName }, ref.language, context, new Set());
1452
+ if (targetNode) {
1453
+ // `Foo.bar()` / `Foo.CONST` — a NAMED (non-namespace) class import
1454
+ // accessed through a member. `findExportedSymbol` resolved `Foo` to
1455
+ // the class itself; descend into it so the reference links to the
1456
+ // member `bar`, not the class. Without this the edge points at the
1457
+ // class and `createEdges` then mis-promotes the call to an
1458
+ // `instantiates` edge, so the static method shows zero callers and a
1459
+ // hollow impact radius. (#825)
1460
+ if (!imp.isNamespace && ref.referenceName.startsWith(imp.localName + '.')) {
1461
+ const memberNode = resolveStaticMember(targetNode, ref, imp.localName, context);
1462
+ if (memberNode) {
1463
+ return {
1464
+ original: ref,
1465
+ targetNodeId: memberNode.id,
1466
+ confidence: 0.9,
1467
+ resolvedBy: 'import',
1468
+ };
1469
+ }
1470
+ // An imported VALUE (singleton constant / shared instance) called
1471
+ // through a member: `reproStore.notifyJoinGuildStatus()` after
1472
+ // `import { reproStore } from './store'`. findExportedSymbol
1473
+ // resolved the CONSTANT itself; linking the CALL there hides the
1474
+ // real callee — callers of the method miss every cross-file use
1475
+ // and the method can look unused (#1292). Infer the value's type
1476
+ // from its own declaration in the exporting file and resolve the
1477
+ // member on that type. resolveMethodOnType VALIDATES the type
1478
+ // declares the method, so a mis-inference falls through to the
1479
+ // constant edge below rather than fabricating a wrong one.
1480
+ const instanceMember = resolveImportedInstanceMember(targetNode, ref, imp.localName, context);
1481
+ if (instanceMember)
1482
+ return instanceMember;
1483
+ }
1484
+ return {
1485
+ original: ref,
1486
+ targetNodeId: targetNode.id,
1487
+ confidence: 0.9,
1488
+ resolvedBy: 'import',
1489
+ };
1490
+ }
1491
+ }
1492
+ }
1493
+ }
1494
+ return null;
1495
+ }
1496
+ /**
1497
+ * Resolve a Python qualified reference whose receiver is an imported MODULE:
1498
+ * `certs.where()` after `from . import certs`, `mod.func()` after `import mod`
1499
+ * or `from pkg import mod`. The receiver names a submodule (a file), not a
1500
+ * symbol, so the generic symbol lookup in `resolveViaImport` can't follow it —
1501
+ * it would search the *package* for `certs`/`mod` instead of looking inside the
1502
+ * module. This is the Python half of the cross-package qualified-call problem
1503
+ * (cf. `resolveGoCrossPackageReference` for Go's `pkg.Func`, issue #388).
1504
+ *
1505
+ * Builds the module's dotted import path from the binding — `from . import
1506
+ * certs` → `.certs`; `from pkg import mod` → `pkg.mod`; `import mod` → `mod` —
1507
+ * resolves it to the module file, and finds the member defined there. Returns
1508
+ * null when no module file exists at that path, so attribute access on an
1509
+ * imported *value* (`helper.attr` where `helper` is a function) falls through
1510
+ * to the other strategies untouched.
1511
+ */
1512
+ function resolvePythonModuleMember(ref, imports, context) {
1513
+ const dotIdx = ref.referenceName.indexOf('.');
1514
+ if (dotIdx <= 0)
1515
+ return null;
1516
+ const receiver = ref.referenceName.substring(0, dotIdx);
1517
+ // The immediate member of the module (first segment after the receiver).
1518
+ const member = ref.referenceName.substring(dotIdx + 1).split('.')[0];
1519
+ if (!member)
1520
+ return null;
1521
+ for (const imp of imports) {
1522
+ if (imp.localName !== receiver)
1523
+ continue;
1524
+ // `import mod` / `import numpy as np` bind the module at `source` itself;
1525
+ // `from . import certs` / `from pkg import mod` bind a SUBMODULE whose
1526
+ // dotted path is the source joined with the imported name.
1527
+ const modulePath = imp.isNamespace
1528
+ ? imp.source
1529
+ : imp.source.endsWith('.')
1530
+ ? imp.source + imp.localName
1531
+ : imp.source + '.' + imp.localName;
1532
+ // resolveImportPath only maps RELATIVE dotted paths (`.mod`, `..pkg.mod`); an
1533
+ // ABSOLUTE package path (`pkg.module` from `from pkg import module`, or a bare
1534
+ // `import pkg.mod`) resolves to null there, so fall back to the dotted-module
1535
+ // file lookup — the same asymmetry resolveModuleImportToFile already handles
1536
+ // for the file→file import edge. Without this, a `module.func()` call after
1537
+ // `from pkg import module` dropped its `calls` edge even though the import
1538
+ // edge resolved (#578).
1539
+ let resolvedPath = resolveImportPath(modulePath, ref.filePath, ref.language, context);
1540
+ if (!resolvedPath) {
1541
+ resolvedPath = findPythonModuleFile(modulePath, context, ref.filePath)?.filePath ?? null;
1542
+ }
1543
+ if (!resolvedPath || resolvedPath === ref.filePath)
1544
+ continue;
1545
+ // Find the member as a top-level definition in the module file. Exclude
1546
+ // `method` so `mod.foo` never lands on a same-named class method.
1547
+ const target = context.getNodesInFile(resolvedPath).find((n) => n.name === member &&
1548
+ (n.kind === 'function' ||
1549
+ n.kind === 'class' ||
1550
+ n.kind === 'variable' ||
1551
+ n.kind === 'constant'));
1552
+ if (target) {
1553
+ return { original: ref, targetNodeId: target.id, confidence: 0.85, resolvedBy: 'import' };
1554
+ }
1555
+ }
1556
+ return null;
1557
+ }
1558
+ /**
1559
+ * Resolve a whole-MODULE import to that module's file (a file→file dependency).
1560
+ * The imported name is a module, not a symbol, so there's nothing to resolve to
1561
+ * — but importing a module IS a dependency on it. Covers:
1562
+ * - Python submodule imports — `from . import certs`, `from pkg import sub`;
1563
+ * - namespace imports — Python `import mod` / `import numpy as np`, and
1564
+ * TS/JS `import * as ns from './x'`.
1565
+ *
1566
+ * It is also the robust backstop for {@link resolvePythonModuleMember} and for
1567
+ * TS namespace usage: it records the dependency even when the used member is
1568
+ * re-exported elsewhere (requests' `certs.where`, re-exported from `certifi`),
1569
+ * the usage is module-level code that isn't extracted as a call, or a TS
1570
+ * namespace is touched only via a value-member read (`ns.SOME_CONST`).
1571
+ *
1572
+ * Only fires for dot-free `imports`-kind refs whose module path resolves to a
1573
+ * real file. A NAMED TS/JS import (`import { widget }`) is not a module, so it
1574
+ * returns null and normal symbol resolution handles it.
1575
+ */
1576
+ /**
1577
+ * Resolve a Lua/Luau `require(...)` to its module file. The reference name is
1578
+ * either a dotted module path (`telescope.config` → `telescope/config.lua`) or a
1579
+ * Roblox instance-path leaf (`Signal` from `require(script.Parent.Signal)` →
1580
+ * `Signal.luau`). We try `<path>.lua|.luau` and `<path>/init.lua|.luau`, matched
1581
+ * by path suffix (the module root — `lua/`, `src/`, … — is project-specific).
1582
+ * Among suffix matches, the one sharing the longest directory prefix with the
1583
+ * requiring file wins (instance-path requires resolve within the same package).
1584
+ */
1585
+ function resolveLuaRequire(ref, context) {
1586
+ const name = ref.referenceName;
1587
+ if (!name)
1588
+ return null;
1589
+ const base = name.includes('.') ? name.replace(/\./g, '/') : name;
1590
+ const suffixes = [`${base}.lua`, `${base}.luau`, `${base}/init.lua`, `${base}/init.luau`];
1591
+ const byBasename = luaBasenameIndex(context);
1592
+ const shared = (a, b) => {
1593
+ let i = 0;
1594
+ while (i < a.length && i < b.length && a[i] === b[i])
1595
+ i++;
1596
+ return i;
1597
+ };
1598
+ for (const suffix of suffixes) {
1599
+ // Only files sharing the suffix's basename can match — the bucket is in
1600
+ // getAllFiles() order, so this filter yields exactly what the full-list
1601
+ // scan did.
1602
+ const candidates = byBasename.get(suffix.split('/').pop() ?? '') ?? [];
1603
+ const matches = candidates.filter((f) => f === suffix || f.endsWith('/' + suffix));
1604
+ if (matches.length === 0)
1605
+ continue;
1606
+ matches.sort((x, y) => shared(y, ref.filePath) - shared(x, ref.filePath));
1607
+ const best = matches[0];
1608
+ if (best === ref.filePath)
1609
+ continue;
1610
+ const fileNode = context.getNodesInFile(best).find((n) => n.kind === 'file');
1611
+ if (fileNode) {
1612
+ // Confidence ≥ 0.9 so this deterministic path/suffix match wins over
1613
+ // name-matching, which otherwise resolves the require to the import node
1614
+ // itself (a same-name self-match).
1615
+ return { original: ref, targetNodeId: fileNode.id, confidence: 0.9, resolvedBy: 'import' };
1616
+ }
1617
+ }
1618
+ return null;
1619
+ }
1620
+ function resolveModuleImportToFile(ref, imports, context) {
1621
+ if (ref.referenceKind !== 'imports')
1622
+ return null;
1623
+ if (ref.referenceName.includes('.'))
1624
+ return null;
1625
+ for (const imp of imports) {
1626
+ if (imp.localName !== ref.referenceName)
1627
+ continue;
1628
+ let modulePath;
1629
+ if (imp.isNamespace || imp.isDefault) {
1630
+ // `import * as ns from './x'` (namespace) or `import x from './x'`
1631
+ // (default) — the dependency is on the MODULE FILE. A default import binds
1632
+ // a (possibly renamed) local to whatever the module's default export is
1633
+ // (`import articlesController from './article.controller'` ← `export
1634
+ // default router`), so the binding name can't be found as a symbol — link
1635
+ // the file the import resolves to instead. External modules don't resolve
1636
+ // (no file), so `import React from 'react'` creates no edge.
1637
+ modulePath = imp.source;
1638
+ }
1639
+ else if (ref.language === 'python') {
1640
+ // `from . import certs` — the imported NAME is a submodule of the source.
1641
+ modulePath = imp.source.endsWith('.')
1642
+ ? imp.source + imp.localName
1643
+ : imp.source + '.' + imp.localName;
1644
+ }
1645
+ else {
1646
+ // A named TS/JS import binds a symbol, not a module — leave it alone.
1647
+ continue;
1648
+ }
1649
+ const resolvedPath = resolveImportPath(modulePath, ref.filePath, ref.language, context);
1650
+ if (resolvedPath && resolvedPath !== ref.filePath) {
1651
+ const fileNode = context.getNodesInFile(resolvedPath).find((n) => n.kind === 'file');
1652
+ if (fileNode) {
1653
+ return { original: ref, targetNodeId: fileNode.id, confidence: 0.9, resolvedBy: 'import' };
1654
+ }
1655
+ }
1656
+ // Python absolute `from a.b import submodule` (a FastAPI router aggregator's
1657
+ // `from app.api.routes import authentication`): resolveImportPath only maps
1658
+ // RELATIVE dotted paths to a file, so resolve the absolute dotted module
1659
+ // directly to its file node.
1660
+ if (ref.language === 'python') {
1661
+ const modFile = findPythonModuleFile(modulePath, context, ref.filePath);
1662
+ if (modFile) {
1663
+ return { original: ref, targetNodeId: modFile.id, confidence: 0.9, resolvedBy: 'import' };
1664
+ }
1665
+ }
1666
+ }
1667
+ return null;
1668
+ }
1669
+ /**
1670
+ * Find the file node for a Python dotted module path `a.b.c` — a module file
1671
+ * ending in `a/b/c.py`, or a package `a/b/c/__init__.py` (suffix-matched, so a
1672
+ * package rooted under `src/` etc. still resolves). Returns null for
1673
+ * stdlib/external modules (no matching repo file node), so `import os` creates
1674
+ * no edge. Shared by absolute `import a.b.c` and absolute `from a.b import c`
1675
+ * (where `c` is a submodule) resolution.
1676
+ */
1677
+ function findPythonModuleFile(mod, context, excludeFilePath) {
1678
+ if (!mod || mod.startsWith('.'))
1679
+ return null; // relative imports handled elsewhere
1680
+ const rel = mod.replace(/\./g, '/');
1681
+ const lastSeg = mod.split('.').pop();
1682
+ const endsWith = (p, want) => p === want || p.endsWith('/' + want);
1683
+ const moduleFile = context
1684
+ .getNodesByName(`${lastSeg}.py`)
1685
+ .find((n) => n.kind === 'file' && n.filePath !== excludeFilePath && endsWith(n.filePath, `${rel}.py`));
1686
+ if (moduleFile)
1687
+ return moduleFile;
1688
+ const pkgFile = context
1689
+ .getNodesByName('__init__.py')
1690
+ .find((n) => n.kind === 'file' && n.filePath !== excludeFilePath && endsWith(n.filePath, `${rel}/__init__.py`));
1691
+ return pkgFile ?? null;
1692
+ }
1693
+ /**
1694
+ * Resolve a Python ABSOLUTE dotted module import (`import a.b.c`) to its file —
1695
+ * the Django `AppConfig.ready(): import myapp.signals` pattern and any
1696
+ * side-effect module import.
1697
+ */
1698
+ function resolvePythonAbsoluteModule(ref, context) {
1699
+ if (ref.referenceKind !== 'imports')
1700
+ return null;
1701
+ // Only a DOTTED `import a.b.c` ref carries its full module path. A bare leaf
1702
+ // (`from app.api.routes import authentication`) is ambiguous on its own — three
1703
+ // `authentication.py` files may exist — so leave it to resolveModuleImportToFile,
1704
+ // which uses the import's source (`app.api.routes`) to build the full path.
1705
+ if (!ref.referenceName.includes('.'))
1706
+ return null;
1707
+ const hit = findPythonModuleFile(ref.referenceName, context, ref.filePath);
1708
+ return hit ? { original: ref, targetNodeId: hit.id, confidence: 0.9, resolvedBy: 'import' } : null;
1709
+ }
1710
+ /**
1711
+ * Resolve a Rust qualified reference `A::B::C` by mapping the MODULE prefix
1712
+ * (`A::B`) to a file and finding the leaf symbol (`C`) in it. This is the Rust
1713
+ * analog of {@link resolvePythonModuleMember} / {@link resolveGoCrossPackageReference}
1714
+ * and the precise answer to common-name re-exports (`pub use self::read::read`)
1715
+ * that name-matching can't disambiguate. Returns null when the prefix isn't a
1716
+ * real module path (e.g. `Widget::new` — `Widget` is a struct, not a module),
1717
+ * so associated-function calls and enum-variant paths fall through untouched.
1718
+ */
1719
+ function resolveRustPathReference(ref, context) {
1720
+ const segments = ref.referenceName.split('::').filter((s) => s.length > 0);
1721
+ if (segments.length < 2)
1722
+ return null;
1723
+ const leaf = segments[segments.length - 1];
1724
+ const modSegs = segments.slice(0, -1);
1725
+ const file = resolveRustModuleFile(modSegs, ref.filePath, context);
1726
+ if (!file || file === ref.filePath)
1727
+ return null;
1728
+ const target = context.getNodesInFile(file).find((n) => n.name === leaf &&
1729
+ (n.kind === 'function' ||
1730
+ n.kind === 'struct' ||
1731
+ n.kind === 'union' ||
1732
+ n.kind === 'enum' ||
1733
+ n.kind === 'trait' ||
1734
+ n.kind === 'type_alias' ||
1735
+ n.kind === 'constant' ||
1736
+ n.kind === 'method' ||
1737
+ n.kind === 'class' ||
1738
+ n.kind === 'interface'));
1739
+ if (target) {
1740
+ return { original: ref, targetNodeId: target.id, confidence: 0.9, resolvedBy: 'import' };
1741
+ }
1742
+ return null;
1743
+ }
1744
+ /** The crate-root directory (holds `lib.rs`/`main.rs`), walking up from a file. */
1745
+ function rustCrateRootDir(fromFileAbs, context) {
1746
+ const projectRoot = context.getProjectRoot();
1747
+ const toRel = (p) => path.relative(projectRoot, p).replace(/\\/g, '/');
1748
+ let dir = path.dirname(fromFileAbs);
1749
+ for (let i = 0; i < 64; i++) {
1750
+ if (context.fileExists(toRel(path.join(dir, 'lib.rs'))) ||
1751
+ context.fileExists(toRel(path.join(dir, 'main.rs')))) {
1752
+ return dir;
1753
+ }
1754
+ const parent = path.dirname(dir);
1755
+ if (parent === dir)
1756
+ return null;
1757
+ dir = parent;
1758
+ }
1759
+ return null;
1760
+ }
1761
+ /** Directory under which the current file's module declares its SUBMODULES. */
1762
+ function rustSelfModuleDir(fromFileAbs) {
1763
+ const base = path.basename(fromFileAbs);
1764
+ const dir = path.dirname(fromFileAbs);
1765
+ // mod.rs / lib.rs / main.rs own their directory; `foo.rs`'s submodules live in `foo/`.
1766
+ if (base === 'mod.rs' || base === 'lib.rs' || base === 'main.rs')
1767
+ return dir;
1768
+ return path.join(dir, base.replace(/\.rs$/, ''));
1769
+ }
1770
+ /**
1771
+ * Resolve a Rust module path (segments WITHOUT the leaf symbol) to the file of
1772
+ * the last module segment — `crate::a::b` → `<crate>/a/b.rs` (or `.../b/mod.rs`).
1773
+ * Anchors on `crate` / `self` / `super`; a bare path is tried crate-relative.
1774
+ */
1775
+ function resolveRustModuleFile(segments, fromFile, context) {
1776
+ if (segments.length === 0)
1777
+ return null;
1778
+ const projectRoot = context.getProjectRoot();
1779
+ const fromAbs = path.join(projectRoot, fromFile);
1780
+ const toRel = (p) => path.relative(projectRoot, p).replace(/\\/g, '/');
1781
+ // Walk a sequence of module segments down from `startDir`, mapping each to a
1782
+ // `<seg>.rs` or `<seg>/mod.rs` file. Returns the leaf module's file, or null
1783
+ // if `startDir` is null or any segment has no file on disk.
1784
+ const resolveUnder = (startDir, rest) => {
1785
+ if (!startDir)
1786
+ return null;
1787
+ let dir = startDir;
1788
+ let targetFile = null;
1789
+ for (const seg of rest) {
1790
+ if (seg === 'self' || seg === 'crate' || seg === 'super')
1791
+ continue;
1792
+ const asFile = toRel(path.join(dir, seg + '.rs'));
1793
+ const asMod = toRel(path.join(dir, seg, 'mod.rs'));
1794
+ if (context.fileExists(asFile))
1795
+ targetFile = asFile;
1796
+ else if (context.fileExists(asMod))
1797
+ targetFile = asMod;
1798
+ else
1799
+ return null;
1800
+ dir = path.join(dir, seg);
1801
+ }
1802
+ return targetFile;
1803
+ };
1804
+ const first = segments[0];
1805
+ if (first === 'crate') {
1806
+ return resolveUnder(rustCrateRootDir(fromAbs, context), segments.slice(1));
1807
+ }
1808
+ if (first === 'self') {
1809
+ return resolveUnder(rustSelfModuleDir(fromAbs), segments.slice(1));
1810
+ }
1811
+ if (first === 'super') {
1812
+ let supers = 0;
1813
+ while (segments[supers] === 'super')
1814
+ supers++;
1815
+ let dir = rustSelfModuleDir(fromAbs);
1816
+ for (let s = 0; s < supers && dir; s++)
1817
+ dir = path.dirname(dir);
1818
+ return resolveUnder(dir, segments.slice(supers));
1819
+ }
1820
+ // Bare path. In expression position (`submodule::item()` — the router-assembly
1821
+ // and general cross-module-call pattern) the prefix is a SUBMODULE of the
1822
+ // current module, i.e. 2018 `self::`-relative — so try self-relative FIRST.
1823
+ // Fall back to crate-relative for 2015-edition / crate-root items. External
1824
+ // crate paths (`serde::de::Error`) miss both and fall through to name-matching.
1825
+ return (resolveUnder(rustSelfModuleDir(fromAbs), segments) ??
1826
+ resolveUnder(rustCrateRootDir(fromAbs, context), segments));
1827
+ }
1828
+ /**
1829
+ * Resolve a Java/Kotlin reference whose receiver is the simple name of
1830
+ * an imported FQN: `Foo.bar(...)` where `import com.example.Foo;`. The
1831
+ * imported FQN converts to a file-path suffix (`com/example/Foo.java`
1832
+ * or `.kt`) which uniquely identifies the right symbol when multiple
1833
+ * classes share the same simple name.
1834
+ *
1835
+ * Also handles bare references to the imported class itself
1836
+ * (`new Foo()` extraction emits `Foo` as a `references`/`instantiates`
1837
+ * ref) and `import static <Foo>.bar` style imports of a single member.
1838
+ */
1839
+ function resolveJavaImportedReference(ref, imports, context) {
1840
+ if (imports.length === 0)
1841
+ return null;
1842
+ const ext = ref.language === 'kotlin' ? '.kt' : '.java';
1843
+ for (const imp of imports) {
1844
+ const matchesBare = imp.localName === ref.referenceName;
1845
+ const matchesQualified = ref.referenceName.startsWith(imp.localName + '.');
1846
+ if (!matchesBare && !matchesQualified)
1847
+ continue;
1848
+ // Convert FQN to a file-path suffix. `com.example.Foo` ->
1849
+ // `com/example/Foo.java` (or `.kt`). The actual file may live
1850
+ // under any source root (`src/main/java/`, `src/`, etc.), so match
1851
+ // by suffix rather than exact path.
1852
+ const fqnPath = imp.source.replace(/\./g, '/') + ext;
1853
+ // Which symbol name to look up: the class itself, or a member.
1854
+ const memberName = matchesBare
1855
+ ? imp.localName
1856
+ : ref.referenceName.substring(imp.localName.length + 1);
1857
+ const candidates = context.getNodesByName(memberName);
1858
+ for (const node of candidates) {
1859
+ if (node.language !== ref.language)
1860
+ continue;
1861
+ const fp = node.filePath.replace(/\\/g, '/');
1862
+ if (fp.endsWith(fqnPath) || fp.endsWith('/' + fqnPath)) {
1863
+ return {
1864
+ original: ref,
1865
+ targetNodeId: node.id,
1866
+ confidence: 0.9,
1867
+ resolvedBy: 'import',
1868
+ };
1869
+ }
1870
+ }
1871
+ // `import static com.example.Foo.bar;` — the FQN's tail is the
1872
+ // member name, the part before is the owner class. Look up the
1873
+ // member named `<imp.localName>` (e.g. `bar`) and prefer the
1874
+ // candidate whose file matches the parent FQN's path.
1875
+ if (matchesBare) {
1876
+ const dot = imp.source.lastIndexOf('.');
1877
+ if (dot > 0) {
1878
+ const ownerFqn = imp.source.substring(0, dot);
1879
+ const ownerPath = ownerFqn.replace(/\./g, '/') + ext;
1880
+ for (const node of candidates) {
1881
+ if (node.language !== ref.language)
1882
+ continue;
1883
+ const fp = node.filePath.replace(/\\/g, '/');
1884
+ if (fp.endsWith(ownerPath) || fp.endsWith('/' + ownerPath)) {
1885
+ return {
1886
+ original: ref,
1887
+ targetNodeId: node.id,
1888
+ confidence: 0.9,
1889
+ resolvedBy: 'import',
1890
+ };
1891
+ }
1892
+ }
1893
+ }
1894
+ }
1895
+ }
1896
+ return null;
1897
+ }
1898
+ /**
1899
+ * Resolve a Go cross-package qualified reference (`pkga.FuncX`) by matching
1900
+ * the package alias against an in-module import, stripping the module prefix
1901
+ * to a project-relative directory, and locating the exported symbol in any
1902
+ * `.go` file under that directory. Returns `null` for stdlib / third-party
1903
+ * imports (no `go.mod`-relative match) so the rest of `resolveViaImport`
1904
+ * can still try the file-based path.
1905
+ */
1906
+ function resolveGoCrossPackageReference(ref, imports, context) {
1907
+ const mod = context.getGoModule?.();
1908
+ if (!mod)
1909
+ return null;
1910
+ // Qualified call: receiver before `.`, member after. A bare reference
1911
+ // (no dot) is a same-file/in-package call — handled elsewhere.
1912
+ const dotIdx = ref.referenceName.indexOf('.');
1913
+ if (dotIdx <= 0)
1914
+ return null;
1915
+ const receiver = ref.referenceName.substring(0, dotIdx);
1916
+ const memberName = ref.referenceName.substring(dotIdx + 1);
1917
+ if (!memberName)
1918
+ return null;
1919
+ for (const imp of imports) {
1920
+ if (imp.localName !== receiver)
1921
+ continue;
1922
+ // Only in-module imports map to a known directory.
1923
+ if (imp.source !== mod.modulePath && !imp.source.startsWith(mod.modulePath + '/')) {
1924
+ continue;
1925
+ }
1926
+ const pkgDir = imp.source === mod.modulePath
1927
+ ? ''
1928
+ : imp.source.substring(mod.modulePath.length + 1);
1929
+ // Look up the member by name and pick the candidate whose file lives
1930
+ // directly in the package directory. Match the immediate parent dir
1931
+ // exactly so a call to `pkga.FuncX` doesn't accidentally land on a
1932
+ // `FuncX` declared in `pkga/subpkg/`.
1933
+ const candidates = context.getNodesByName(memberName);
1934
+ for (const node of candidates) {
1935
+ if (node.language !== 'go')
1936
+ continue;
1937
+ if (!node.isExported)
1938
+ continue;
1939
+ const fp = node.filePath.replace(/\\/g, '/');
1940
+ const lastSlash = fp.lastIndexOf('/');
1941
+ const fileDir = lastSlash >= 0 ? fp.substring(0, lastSlash) : '';
1942
+ if (fileDir === pkgDir) {
1943
+ return {
1944
+ original: ref,
1945
+ targetNodeId: node.id,
1946
+ confidence: 0.9,
1947
+ resolvedBy: 'import',
1948
+ };
1949
+ }
1950
+ }
1951
+ }
1952
+ return null;
1953
+ }
1954
+ /** Recursive depth cap for re-export chain following. Real codebases
1955
+ * rarely chain barrels more than 2–3 deep; 8 is a generous safety
1956
+ * net that still bounds worst-case work. */
1957
+ const REEXPORT_MAX_DEPTH = 8;
1958
+ /**
1959
+ * Find an exported symbol in `filePath`, following `export { x } from
1960
+ * './other'` and `export * from './other'` chains until the original
1961
+ * declaration is reached. Cycle-safe via the `visited` set.
1962
+ *
1963
+ * Without this, every barrel-style import (`import { Foo } from
1964
+ * './index'` where `index.ts` only re-exports) used to resolve to
1965
+ * nothing — the existing code only looked for declarations IN the
1966
+ * resolved file, not declarations the file forwarded.
1967
+ */
1968
+ function findExportedSymbol(filePath, want, language, context, visited, depth = 0) {
1969
+ // Memoize fresh (top-level) lookups only: recursive re-export steps carry a
1970
+ // populated `visited` set, whose contents change the reachable answer.
1971
+ // Every ref to the same imported symbol repeats this exact walk, so the
1972
+ // top-level memo removes the re-export chase + per-file linear scans from
1973
+ // all but the first occurrence.
1974
+ if (depth === 0 && visited.size === 0) {
1975
+ let memo = exportedSymbolMemos.get(context);
1976
+ if (!memo) {
1977
+ memo = new Map();
1978
+ exportedSymbolMemos.set(context, memo);
1979
+ }
1980
+ const key = `${filePath}\0${want.isDefault ? 1 : 0}${want.isNamespace ? 1 : 0}\0${want.exportedName}\0${want.memberName ?? ''}\0${language}`;
1981
+ if (memo.has(key))
1982
+ return memo.get(key);
1983
+ const result = findExportedSymbolWalk(filePath, want, language, context, visited, depth);
1984
+ memo.set(key, result);
1985
+ return result;
1986
+ }
1987
+ return findExportedSymbolWalk(filePath, want, language, context, visited, depth);
1988
+ }
1989
+ function findExportedSymbolWalk(filePath, want, language, context, visited, depth) {
1990
+ if (depth > REEXPORT_MAX_DEPTH)
1991
+ return undefined;
1992
+ if (visited.has(filePath))
1993
+ return undefined;
1994
+ visited.add(filePath);
1995
+ const exportIndex = getFileExportIndex(filePath, context);
1996
+ // 1. Direct hit: the symbol is declared in this file.
1997
+ if (want.isDefault) {
1998
+ // Svelte/Vue single-file components ARE the module's default export,
1999
+ // but are extracted as kind 'component' (not function/class). Prefer
2000
+ // the component node; fall back to an exported function/class for the
2001
+ // `.ts`/`.tsx` `export default fn`/`class` case. Without the component
2002
+ // branch, an `export { default as X } from './X.svelte'` barrel never
2003
+ // resolves and the component shows a false 0 callers (#629).
2004
+ const direct = exportIndex.defaultComponent ?? exportIndex.defaultFnClass;
2005
+ if (direct)
2006
+ return direct;
2007
+ }
2008
+ else if (want.isNamespace && want.memberName) {
2009
+ const direct = exportIndex.byName.get(want.memberName);
2010
+ if (direct)
2011
+ return direct;
2012
+ }
2013
+ else {
2014
+ const direct = exportIndex.byName.get(want.exportedName);
2015
+ if (direct)
2016
+ return direct;
2017
+ }
2018
+ // 2. Re-export hit: the file forwards the symbol to another module.
2019
+ const reExports = context.getReExports?.(filePath, language) ?? [];
2020
+ if (reExports.length === 0)
2021
+ return undefined;
2022
+ // Look for explicit `export { want } from './other'` (with optional rename).
2023
+ const targetName = want.isDefault ? 'default' : want.exportedName;
2024
+ for (const rex of reExports) {
2025
+ if (rex.kind === 'named' && rex.exportedName === targetName) {
2026
+ const next = resolveImportPath(rex.source, filePath, language, context);
2027
+ if (!next)
2028
+ continue;
2029
+ // After rename: `export { foo as bar } from './x'` — to chase
2030
+ // `bar`, we look for `foo` in `./x`.
2031
+ const chained = findExportedSymbol(next, {
2032
+ isDefault: rex.originalName === 'default',
2033
+ isNamespace: false,
2034
+ exportedName: rex.originalName,
2035
+ memberName: null,
2036
+ }, language, context, visited, depth + 1);
2037
+ if (chained)
2038
+ return chained;
2039
+ }
2040
+ }
2041
+ // 3. Wildcard re-export: `export * from './other'` — try every
2042
+ // forwarding source. This is the barrel-of-barrels case.
2043
+ for (const rex of reExports) {
2044
+ if (rex.kind === 'wildcard') {
2045
+ const next = resolveImportPath(rex.source, filePath, language, context);
2046
+ if (!next)
2047
+ continue;
2048
+ const chained = findExportedSymbol(next, want, language, context, visited, depth + 1);
2049
+ if (chained)
2050
+ return chained;
2051
+ }
2052
+ }
2053
+ return undefined;
2054
+ }
2055
+ /** Node kinds that own static members reachable as `Container.member`. */
2056
+ const STATIC_MEMBER_CONTAINERS = new Set([
2057
+ 'class', 'struct', 'union', 'interface', 'enum', 'trait', 'protocol',
2058
+ ]);
2059
+ /**
2060
+ * Resolve `Container.member` — a static method/property access on a NAMED class
2061
+ * import (`import { Foo } …; Foo.bar()`) — to the member node, given the
2062
+ * already-resolved container class.
2063
+ *
2064
+ * Members carry a `Container::member` qualifiedName, so we look up
2065
+ * `${container.qualifiedName}::${member}` within the container's own file (the
2066
+ * file filter disambiguates same-named classes in other modules). Returns
2067
+ * undefined when the container isn't a member-owning kind or the member isn't
2068
+ * found, so the caller falls back to the container itself (prior behavior) —
2069
+ * languages whose members aren't `::`-qualified, and genuine class references,
2070
+ * are unaffected. See #825.
2071
+ */
2072
+ /**
2073
+ * Resolve a CALL through an imported value to the method on the value's own
2074
+ * type: `reproStore.notifyJoinGuildStatus()` where `reproStore` is
2075
+ * `export const reproStore = new ReproStore()` in the imported file (#1292).
2076
+ * The same-file form of this call already resolves via local-variable
2077
+ * receiver inference (#1108); this is the cross-file/import half. The type is
2078
+ * recovered from the VALUE'S OWN declaration lines in the exporting file
2079
+ * (initializer `= new T(...)` or a type annotation, per the shared #1108
2080
+ * pattern table), then the member is resolved AND VALIDATED on that type by
2081
+ * resolveMethodOnType — a failed inference or validation returns null so the
2082
+ * caller keeps its existing constant-edge behavior.
2083
+ */
2084
+ function resolveImportedInstanceMember(value, ref, localName, context) {
2085
+ if (ref.referenceKind !== 'calls')
2086
+ return null;
2087
+ if (value.kind !== 'constant' && value.kind !== 'variable')
2088
+ return null;
2089
+ const member = ref.referenceName.slice(localName.length + 1).split('.')[0];
2090
+ if (!member)
2091
+ return null;
2092
+ const source = context.readFile(value.filePath);
2093
+ if (!source)
2094
+ return null;
2095
+ // Only the value's own declaration lines — never the whole file, so a
2096
+ // same-named identifier elsewhere can't donate a type.
2097
+ const lines = source.split('\n');
2098
+ const declSlice = lines.slice(Math.max(0, value.startLine - 1), value.endLine).join('\n');
2099
+ const receiver = value.name.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
2100
+ for (const pattern of (0, name_matcher_1.localReceiverTypePatterns)(value.language, receiver)) {
2101
+ const m = declSlice.match(pattern);
2102
+ if (!m || !m[1])
2103
+ continue;
2104
+ const typeName = (0, name_matcher_1.normalizeInferredTypeName)(m[1]);
2105
+ if (!typeName)
2106
+ continue;
2107
+ const resolved = (0, name_matcher_1.resolveMethodOnType)(typeName, member, ref, context, 0.85, 'instance-method');
2108
+ if (resolved)
2109
+ return resolved;
2110
+ }
2111
+ return null;
2112
+ }
2113
+ function resolveStaticMember(container, ref, localName, context) {
2114
+ if (!STATIC_MEMBER_CONTAINERS.has(container.kind))
2115
+ return undefined;
2116
+ // First segment after the receiver: `Foo.bar.baz` → `bar`.
2117
+ const member = ref.referenceName.slice(localName.length + 1).split('.')[0];
2118
+ if (!member)
2119
+ return undefined;
2120
+ const candidates = context
2121
+ .getNodesByQualifiedName(`${container.qualifiedName}::${member}`)
2122
+ .filter((n) => n.filePath === container.filePath);
2123
+ if (candidates.length === 0)
2124
+ return undefined;
2125
+ // When the reference is a call, prefer a callable member if several nodes
2126
+ // share the qualifiedName (e.g. a static property and a method).
2127
+ if (ref.referenceKind === 'calls') {
2128
+ const callable = candidates.find((n) => n.kind === 'method' || n.kind === 'function');
2129
+ if (callable)
2130
+ return callable;
2131
+ }
2132
+ return candidates[0];
2133
+ }
2134
+ //# sourceMappingURL=import-resolver.js.map