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