@ruverd/julius 0.0.0-stage → 0.24.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 (704) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/CREDITS.md +25 -0
  3. package/LICENSE +21 -0
  4. package/PROVENANCE.md +9 -0
  5. package/README.md +225 -2
  6. package/dist/ai/crux.d.ts +60 -0
  7. package/dist/ai/crux.d.ts.map +1 -0
  8. package/dist/ai/crux.js +141 -0
  9. package/dist/ai/crux.js.map +1 -0
  10. package/dist/ai/failure.d.ts +60 -0
  11. package/dist/ai/failure.d.ts.map +1 -0
  12. package/dist/ai/failure.js +86 -0
  13. package/dist/ai/failure.js.map +1 -0
  14. package/dist/ai/llm/anthropic.d.ts +37 -0
  15. package/dist/ai/llm/anthropic.d.ts.map +1 -0
  16. package/dist/ai/llm/anthropic.js +144 -0
  17. package/dist/ai/llm/anthropic.js.map +1 -0
  18. package/dist/ai/llm/factory.d.ts +28 -0
  19. package/dist/ai/llm/factory.d.ts.map +1 -0
  20. package/dist/ai/llm/factory.js +36 -0
  21. package/dist/ai/llm/factory.js.map +1 -0
  22. package/dist/ai/llm/litellm.d.ts +34 -0
  23. package/dist/ai/llm/litellm.d.ts.map +1 -0
  24. package/dist/ai/llm/litellm.js +45 -0
  25. package/dist/ai/llm/litellm.js.map +1 -0
  26. package/dist/ai/llm/openai.d.ts +44 -0
  27. package/dist/ai/llm/openai.d.ts.map +1 -0
  28. package/dist/ai/llm/openai.js +239 -0
  29. package/dist/ai/llm/openai.js.map +1 -0
  30. package/dist/ai/llm/orcarouter.d.ts +34 -0
  31. package/dist/ai/llm/orcarouter.d.ts.map +1 -0
  32. package/dist/ai/llm/orcarouter.js +45 -0
  33. package/dist/ai/llm/orcarouter.js.map +1 -0
  34. package/dist/ai/llm/recover-tool.d.ts +19 -0
  35. package/dist/ai/llm/recover-tool.d.ts.map +1 -0
  36. package/dist/ai/llm/recover-tool.js +109 -0
  37. package/dist/ai/llm/recover-tool.js.map +1 -0
  38. package/dist/ai/llm/types.d.ts +122 -0
  39. package/dist/ai/llm/types.d.ts.map +1 -0
  40. package/dist/ai/llm/types.js +33 -0
  41. package/dist/ai/llm/types.js.map +1 -0
  42. package/dist/ai/providers.d.ts +59 -0
  43. package/dist/ai/providers.d.ts.map +1 -0
  44. package/dist/ai/providers.js +54 -0
  45. package/dist/ai/providers.js.map +1 -0
  46. package/dist/ai/summarize.d.ts +25 -0
  47. package/dist/ai/summarize.d.ts.map +1 -0
  48. package/dist/ai/summarize.js +34 -0
  49. package/dist/ai/summarize.js.map +1 -0
  50. package/dist/ai/synthesize.d.ts +40 -0
  51. package/dist/ai/synthesize.d.ts.map +1 -0
  52. package/dist/ai/synthesize.js +131 -0
  53. package/dist/ai/synthesize.js.map +1 -0
  54. package/dist/app/checkout.d.ts +46 -0
  55. package/dist/app/checkout.d.ts.map +1 -0
  56. package/dist/app/checkout.js +223 -0
  57. package/dist/app/checkout.js.map +1 -0
  58. package/dist/app/events.d.ts +44 -0
  59. package/dist/app/events.d.ts.map +1 -0
  60. package/dist/app/events.js +64 -0
  61. package/dist/app/events.js.map +1 -0
  62. package/dist/app/identity.d.ts +54 -0
  63. package/dist/app/identity.d.ts.map +1 -0
  64. package/dist/app/identity.js +96 -0
  65. package/dist/app/identity.js.map +1 -0
  66. package/dist/app/main.d.ts +2 -0
  67. package/dist/app/main.d.ts.map +1 -0
  68. package/dist/app/main.js +62 -0
  69. package/dist/app/main.js.map +1 -0
  70. package/dist/app/pages.d.ts +56 -0
  71. package/dist/app/pages.d.ts.map +1 -0
  72. package/dist/app/pages.js +193 -0
  73. package/dist/app/pages.js.map +1 -0
  74. package/dist/app/queue.d.ts +40 -0
  75. package/dist/app/queue.d.ts.map +1 -0
  76. package/dist/app/queue.js +68 -0
  77. package/dist/app/queue.js.map +1 -0
  78. package/dist/app/review-process.d.ts +66 -0
  79. package/dist/app/review-process.d.ts.map +1 -0
  80. package/dist/app/review-process.js +200 -0
  81. package/dist/app/review-process.js.map +1 -0
  82. package/dist/app/review-worker.d.ts +2 -0
  83. package/dist/app/review-worker.d.ts.map +1 -0
  84. package/dist/app/review-worker.js +108 -0
  85. package/dist/app/review-worker.js.map +1 -0
  86. package/dist/app/review.d.ts +23 -0
  87. package/dist/app/review.d.ts.map +1 -0
  88. package/dist/app/review.js +142 -0
  89. package/dist/app/review.js.map +1 -0
  90. package/dist/app/server.d.ts +49 -0
  91. package/dist/app/server.d.ts.map +1 -0
  92. package/dist/app/server.js +123 -0
  93. package/dist/app/server.js.map +1 -0
  94. package/dist/ask/ask.d.ts +195 -0
  95. package/dist/ask/ask.d.ts.map +1 -0
  96. package/dist/ask/ask.js +1252 -0
  97. package/dist/ask/ask.js.map +1 -0
  98. package/dist/ask/file-rank.d.ts +72 -0
  99. package/dist/ask/file-rank.d.ts.map +1 -0
  100. package/dist/ask/file-rank.js +160 -0
  101. package/dist/ask/file-rank.js.map +1 -0
  102. package/dist/ask/file-selection.d.ts +22 -0
  103. package/dist/ask/file-selection.d.ts.map +1 -0
  104. package/dist/ask/file-selection.js +66 -0
  105. package/dist/ask/file-selection.js.map +1 -0
  106. package/dist/ask/fuse.d.ts +195 -0
  107. package/dist/ask/fuse.d.ts.map +1 -0
  108. package/dist/ask/fuse.js +344 -0
  109. package/dist/ask/fuse.js.map +1 -0
  110. package/dist/ask/graphrank.d.ts +61 -0
  111. package/dist/ask/graphrank.d.ts.map +1 -0
  112. package/dist/ask/graphrank.js +130 -0
  113. package/dist/ask/graphrank.js.map +1 -0
  114. package/dist/ask/index-file.d.ts +44 -0
  115. package/dist/ask/index-file.d.ts.map +1 -0
  116. package/dist/ask/index-file.js +128 -0
  117. package/dist/ask/index-file.js.map +1 -0
  118. package/dist/bin/julius.d.ts +3 -0
  119. package/dist/bin/julius.d.ts.map +1 -0
  120. package/dist/bin/julius.js +4 -0
  121. package/dist/bin/julius.js.map +1 -0
  122. package/dist/blast/blast-cli.d.ts +35 -0
  123. package/dist/blast/blast-cli.d.ts.map +1 -0
  124. package/dist/blast/blast-cli.js +155 -0
  125. package/dist/blast/blast-cli.js.map +1 -0
  126. package/dist/blast/blast.d.ts +128 -0
  127. package/dist/blast/blast.d.ts.map +1 -0
  128. package/dist/blast/blast.js +383 -0
  129. package/dist/blast/blast.js.map +1 -0
  130. package/dist/blast/diff.d.ts +53 -0
  131. package/dist/blast/diff.d.ts.map +1 -0
  132. package/dist/blast/diff.js +193 -0
  133. package/dist/blast/diff.js.map +1 -0
  134. package/dist/blast/evidence.d.ts +51 -0
  135. package/dist/blast/evidence.d.ts.map +1 -0
  136. package/dist/blast/evidence.js +162 -0
  137. package/dist/blast/evidence.js.map +1 -0
  138. package/dist/blast/modules.d.ts +33 -0
  139. package/dist/blast/modules.d.ts.map +1 -0
  140. package/dist/blast/modules.js +83 -0
  141. package/dist/blast/modules.js.map +1 -0
  142. package/dist/blast/name.d.ts +74 -0
  143. package/dist/blast/name.d.ts.map +1 -0
  144. package/dist/blast/name.js +269 -0
  145. package/dist/blast/name.js.map +1 -0
  146. package/dist/blast/owners.d.ts +85 -0
  147. package/dist/blast/owners.d.ts.map +1 -0
  148. package/dist/blast/owners.js +272 -0
  149. package/dist/blast/owners.js.map +1 -0
  150. package/dist/blast/render.d.ts +46 -0
  151. package/dist/blast/render.d.ts.map +1 -0
  152. package/dist/blast/render.js +422 -0
  153. package/dist/blast/render.js.map +1 -0
  154. package/dist/blast/viz.d.ts +37 -0
  155. package/dist/blast/viz.d.ts.map +1 -0
  156. package/dist/blast/viz.js +180 -0
  157. package/dist/blast/viz.js.map +1 -0
  158. package/dist/brand.d.ts +13 -0
  159. package/dist/brand.d.ts.map +1 -0
  160. package/dist/brand.js +43 -0
  161. package/dist/brand.js.map +1 -0
  162. package/dist/check/learning-edits.d.ts +9 -0
  163. package/dist/check/learning-edits.d.ts.map +1 -0
  164. package/dist/check/learning-edits.js +62 -0
  165. package/dist/check/learning-edits.js.map +1 -0
  166. package/dist/check/local-check.d.ts +104 -0
  167. package/dist/check/local-check.d.ts.map +1 -0
  168. package/dist/check/local-check.js +830 -0
  169. package/dist/check/local-check.js.map +1 -0
  170. package/dist/check/types.d.ts +31 -0
  171. package/dist/check/types.d.ts.map +1 -0
  172. package/dist/check/types.js +2 -0
  173. package/dist/check/types.js.map +1 -0
  174. package/dist/claude/build-progress.d.ts +29 -0
  175. package/dist/claude/build-progress.d.ts.map +1 -0
  176. package/dist/claude/build-progress.js +76 -0
  177. package/dist/claude/build-progress.js.map +1 -0
  178. package/dist/claude/format.d.ts +131 -0
  179. package/dist/claude/format.d.ts.map +1 -0
  180. package/dist/claude/format.js +328 -0
  181. package/dist/claude/format.js.map +1 -0
  182. package/dist/claude/hook-layers.d.ts +8 -0
  183. package/dist/claude/hook-layers.d.ts.map +1 -0
  184. package/dist/claude/hook-layers.js +74 -0
  185. package/dist/claude/hook-layers.js.map +1 -0
  186. package/dist/claude/hooks.d.ts +101 -0
  187. package/dist/claude/hooks.d.ts.map +1 -0
  188. package/dist/claude/hooks.js +849 -0
  189. package/dist/claude/hooks.js.map +1 -0
  190. package/dist/claude/init.d.ts +70 -0
  191. package/dist/claude/init.d.ts.map +1 -0
  192. package/dist/claude/init.js +207 -0
  193. package/dist/claude/init.js.map +1 -0
  194. package/dist/claude/note-signals.d.ts +28 -0
  195. package/dist/claude/note-signals.d.ts.map +1 -0
  196. package/dist/claude/note-signals.js +325 -0
  197. package/dist/claude/note-signals.js.map +1 -0
  198. package/dist/claude/paths.d.ts +9 -0
  199. package/dist/claude/paths.d.ts.map +1 -0
  200. package/dist/claude/paths.js +22 -0
  201. package/dist/claude/paths.js.map +1 -0
  202. package/dist/claude/session-metrics.d.ts +73 -0
  203. package/dist/claude/session-metrics.d.ts.map +1 -0
  204. package/dist/claude/session-metrics.js +209 -0
  205. package/dist/claude/session-metrics.js.map +1 -0
  206. package/dist/claude/settings-merge.d.ts +66 -0
  207. package/dist/claude/settings-merge.d.ts.map +1 -0
  208. package/dist/claude/settings-merge.js +249 -0
  209. package/dist/claude/settings-merge.js.map +1 -0
  210. package/dist/claude/shim-template.d.ts +18 -0
  211. package/dist/claude/shim-template.d.ts.map +1 -0
  212. package/dist/claude/shim-template.js +226 -0
  213. package/dist/claude/shim-template.js.map +1 -0
  214. package/dist/claude/skill-template.d.ts +12 -0
  215. package/dist/claude/skill-template.d.ts.map +1 -0
  216. package/dist/claude/skill-template.js +294 -0
  217. package/dist/claude/skill-template.js.map +1 -0
  218. package/dist/claude/state.d.ts +73 -0
  219. package/dist/claude/state.d.ts.map +1 -0
  220. package/dist/claude/state.js +33 -0
  221. package/dist/claude/state.js.map +1 -0
  222. package/dist/claude/stats.d.ts +5 -0
  223. package/dist/claude/stats.d.ts.map +1 -0
  224. package/dist/claude/stats.js +24 -0
  225. package/dist/claude/stats.js.map +1 -0
  226. package/dist/claude/statusline.d.ts +14 -0
  227. package/dist/claude/statusline.d.ts.map +1 -0
  228. package/dist/claude/statusline.js +45 -0
  229. package/dist/claude/statusline.js.map +1 -0
  230. package/dist/claude/sync-run.d.ts +3 -0
  231. package/dist/claude/sync-run.d.ts.map +1 -0
  232. package/dist/claude/sync-run.js +46 -0
  233. package/dist/claude/sync-run.js.map +1 -0
  234. package/dist/claude/tally.d.ts +50 -0
  235. package/dist/claude/tally.d.ts.map +1 -0
  236. package/dist/claude/tally.js +211 -0
  237. package/dist/claude/tally.js.map +1 -0
  238. package/dist/cli-epilogue.d.ts +12 -0
  239. package/dist/cli-epilogue.d.ts.map +1 -0
  240. package/dist/cli-epilogue.js +55 -0
  241. package/dist/cli-epilogue.js.map +1 -0
  242. package/dist/cli-meta.d.ts +45 -0
  243. package/dist/cli-meta.d.ts.map +1 -0
  244. package/dist/cli-meta.js +145 -0
  245. package/dist/cli-meta.js.map +1 -0
  246. package/dist/cli-picker.d.ts +129 -0
  247. package/dist/cli-picker.d.ts.map +1 -0
  248. package/dist/cli-picker.js +432 -0
  249. package/dist/cli-picker.js.map +1 -0
  250. package/dist/cli.d.ts +3 -0
  251. package/dist/cli.d.ts.map +1 -0
  252. package/dist/cli.js +2213 -0
  253. package/dist/cli.js.map +1 -0
  254. package/dist/cloud/diff.d.ts +20 -0
  255. package/dist/cloud/diff.d.ts.map +1 -0
  256. package/dist/cloud/diff.js +59 -0
  257. package/dist/cloud/diff.js.map +1 -0
  258. package/dist/cloud/nudge.d.ts +66 -0
  259. package/dist/cloud/nudge.d.ts.map +1 -0
  260. package/dist/cloud/nudge.js +268 -0
  261. package/dist/cloud/nudge.js.map +1 -0
  262. package/dist/cloud/workspace-sync.d.ts +58 -0
  263. package/dist/cloud/workspace-sync.d.ts.map +1 -0
  264. package/dist/cloud/workspace-sync.js +268 -0
  265. package/dist/cloud/workspace-sync.js.map +1 -0
  266. package/dist/cloud/workspace.d.ts +159 -0
  267. package/dist/cloud/workspace.d.ts.map +1 -0
  268. package/dist/cloud/workspace.js +134 -0
  269. package/dist/cloud/workspace.js.map +1 -0
  270. package/dist/context/build.d.ts +52 -0
  271. package/dist/context/build.d.ts.map +1 -0
  272. package/dist/context/build.js +362 -0
  273. package/dist/context/build.js.map +1 -0
  274. package/dist/context/check.d.ts +42 -0
  275. package/dist/context/check.d.ts.map +1 -0
  276. package/dist/context/check.js +162 -0
  277. package/dist/context/check.js.map +1 -0
  278. package/dist/context/map-dir.d.ts +4 -0
  279. package/dist/context/map-dir.d.ts.map +1 -0
  280. package/dist/context/map-dir.js +6 -0
  281. package/dist/context/map-dir.js.map +1 -0
  282. package/dist/context/node-file.d.ts +109 -0
  283. package/dist/context/node-file.d.ts.map +1 -0
  284. package/dist/context/node-file.js +362 -0
  285. package/dist/context/node-file.js.map +1 -0
  286. package/dist/context/price.d.ts +49 -0
  287. package/dist/context/price.d.ts.map +1 -0
  288. package/dist/context/price.js +83 -0
  289. package/dist/context/price.js.map +1 -0
  290. package/dist/context/savings.d.ts +26 -0
  291. package/dist/context/savings.d.ts.map +1 -0
  292. package/dist/context/savings.js +59 -0
  293. package/dist/context/savings.js.map +1 -0
  294. package/dist/economy/cli.d.ts +3 -0
  295. package/dist/economy/cli.d.ts.map +1 -0
  296. package/dist/economy/cli.js +52 -0
  297. package/dist/economy/cli.js.map +1 -0
  298. package/dist/economy/delivery.d.ts +49 -0
  299. package/dist/economy/delivery.d.ts.map +1 -0
  300. package/dist/economy/delivery.js +176 -0
  301. package/dist/economy/delivery.js.map +1 -0
  302. package/dist/economy/index.d.ts +67 -0
  303. package/dist/economy/index.d.ts.map +1 -0
  304. package/dist/economy/index.js +519 -0
  305. package/dist/economy/index.js.map +1 -0
  306. package/dist/engine.d.ts +83 -0
  307. package/dist/engine.d.ts.map +1 -0
  308. package/dist/engine.js +122 -0
  309. package/dist/engine.js.map +1 -0
  310. package/dist/evaluation/index.d.ts +41 -0
  311. package/dist/evaluation/index.d.ts.map +1 -0
  312. package/dist/evaluation/index.js +61 -0
  313. package/dist/evaluation/index.js.map +1 -0
  314. package/dist/graph/bindings.d.ts +64 -0
  315. package/dist/graph/bindings.d.ts.map +1 -0
  316. package/dist/graph/bindings.js +713 -0
  317. package/dist/graph/bindings.js.map +1 -0
  318. package/dist/graph/build.d.ts +88 -0
  319. package/dist/graph/build.d.ts.map +1 -0
  320. package/dist/graph/build.js +375 -0
  321. package/dist/graph/build.js.map +1 -0
  322. package/dist/graph/cards.d.ts +46 -0
  323. package/dist/graph/cards.d.ts.map +1 -0
  324. package/dist/graph/cards.js +280 -0
  325. package/dist/graph/cards.js.map +1 -0
  326. package/dist/graph/check.d.ts +25 -0
  327. package/dist/graph/check.d.ts.map +1 -0
  328. package/dist/graph/check.js +192 -0
  329. package/dist/graph/check.js.map +1 -0
  330. package/dist/graph/container.d.ts +63 -0
  331. package/dist/graph/container.d.ts.map +1 -0
  332. package/dist/graph/container.js +190 -0
  333. package/dist/graph/container.js.map +1 -0
  334. package/dist/graph/enrich.d.ts +62 -0
  335. package/dist/graph/enrich.d.ts.map +1 -0
  336. package/dist/graph/enrich.js +253 -0
  337. package/dist/graph/enrich.js.map +1 -0
  338. package/dist/graph/extract-cache.d.ts +101 -0
  339. package/dist/graph/extract-cache.d.ts.map +1 -0
  340. package/dist/graph/extract-cache.js +199 -0
  341. package/dist/graph/extract-cache.js.map +1 -0
  342. package/dist/graph/extract.d.ts +85 -0
  343. package/dist/graph/extract.d.ts.map +1 -0
  344. package/dist/graph/extract.js +2376 -0
  345. package/dist/graph/extract.js.map +1 -0
  346. package/dist/graph/fingerprint.d.ts +76 -0
  347. package/dist/graph/fingerprint.d.ts.map +1 -0
  348. package/dist/graph/fingerprint.js +160 -0
  349. package/dist/graph/fingerprint.js.map +1 -0
  350. package/dist/graph/generic.d.ts +74 -0
  351. package/dist/graph/generic.d.ts.map +1 -0
  352. package/dist/graph/generic.js +580 -0
  353. package/dist/graph/generic.js.map +1 -0
  354. package/dist/graph/invariants.d.ts +33 -0
  355. package/dist/graph/invariants.d.ts.map +1 -0
  356. package/dist/graph/invariants.js +52 -0
  357. package/dist/graph/invariants.js.map +1 -0
  358. package/dist/graph/load.d.ts +29 -0
  359. package/dist/graph/load.d.ts.map +1 -0
  360. package/dist/graph/load.js +97 -0
  361. package/dist/graph/load.js.map +1 -0
  362. package/dist/graph/lsp/client.d.ts +43 -0
  363. package/dist/graph/lsp/client.d.ts.map +1 -0
  364. package/dist/graph/lsp/client.js +179 -0
  365. package/dist/graph/lsp/client.js.map +1 -0
  366. package/dist/graph/lsp/enrich.d.ts +11 -0
  367. package/dist/graph/lsp/enrich.d.ts.map +1 -0
  368. package/dist/graph/lsp/enrich.js +155 -0
  369. package/dist/graph/lsp/enrich.js.map +1 -0
  370. package/dist/graph/lsp/registry.d.ts +15 -0
  371. package/dist/graph/lsp/registry.d.ts.map +1 -0
  372. package/dist/graph/lsp/registry.js +46 -0
  373. package/dist/graph/lsp/registry.js.map +1 -0
  374. package/dist/graph/map.d.ts +107 -0
  375. package/dist/graph/map.d.ts.map +1 -0
  376. package/dist/graph/map.js +239 -0
  377. package/dist/graph/map.js.map +1 -0
  378. package/dist/graph/native.d.ts +38 -0
  379. package/dist/graph/native.d.ts.map +1 -0
  380. package/dist/graph/native.js +169 -0
  381. package/dist/graph/native.js.map +1 -0
  382. package/dist/graph/queries/c.scm +13 -0
  383. package/dist/graph/queries/c_sharp.scm +19 -0
  384. package/dist/graph/queries/clojure.scm +58 -0
  385. package/dist/graph/queries/cpp.scm +23 -0
  386. package/dist/graph/queries/dart.scm +42 -0
  387. package/dist/graph/queries/elixir.scm +54 -0
  388. package/dist/graph/queries/java.scm +20 -0
  389. package/dist/graph/queries/kotlin.scm +43 -0
  390. package/dist/graph/queries/lua.scm +36 -0
  391. package/dist/graph/queries/nix.scm +32 -0
  392. package/dist/graph/queries/php.scm +40 -0
  393. package/dist/graph/queries/ruby.scm +65 -0
  394. package/dist/graph/queries/rust.scm +41 -0
  395. package/dist/graph/queries/scala.scm +66 -0
  396. package/dist/graph/queries/solidity.scm +43 -0
  397. package/dist/graph/queries/swift.scm +51 -0
  398. package/dist/graph/refresh.d.ts +49 -0
  399. package/dist/graph/refresh.d.ts.map +1 -0
  400. package/dist/graph/refresh.js +255 -0
  401. package/dist/graph/refresh.js.map +1 -0
  402. package/dist/graph/relations.d.ts +14 -0
  403. package/dist/graph/relations.d.ts.map +1 -0
  404. package/dist/graph/relations.js +8 -0
  405. package/dist/graph/relations.js.map +1 -0
  406. package/dist/graph/resolve.d.ts +17 -0
  407. package/dist/graph/resolve.d.ts.map +1 -0
  408. package/dist/graph/resolve.js +654 -0
  409. package/dist/graph/resolve.js.map +1 -0
  410. package/dist/graph/root.d.ts +11 -0
  411. package/dist/graph/root.d.ts.map +1 -0
  412. package/dist/graph/root.js +40 -0
  413. package/dist/graph/root.js.map +1 -0
  414. package/dist/graph/scopes.d.ts +42 -0
  415. package/dist/graph/scopes.d.ts.map +1 -0
  416. package/dist/graph/scopes.js +342 -0
  417. package/dist/graph/scopes.js.map +1 -0
  418. package/dist/graph/seed.d.ts +38 -0
  419. package/dist/graph/seed.d.ts.map +1 -0
  420. package/dist/graph/seed.js +226 -0
  421. package/dist/graph/seed.js.map +1 -0
  422. package/dist/graph/source-files.d.ts +40 -0
  423. package/dist/graph/source-files.d.ts.map +1 -0
  424. package/dist/graph/source-files.js +85 -0
  425. package/dist/graph/source-files.js.map +1 -0
  426. package/dist/graph/traverse-cli.d.ts +55 -0
  427. package/dist/graph/traverse-cli.d.ts.map +1 -0
  428. package/dist/graph/traverse-cli.js +189 -0
  429. package/dist/graph/traverse-cli.js.map +1 -0
  430. package/dist/graph/traverse.d.ts +112 -0
  431. package/dist/graph/traverse.d.ts.map +1 -0
  432. package/dist/graph/traverse.js +192 -0
  433. package/dist/graph/traverse.js.map +1 -0
  434. package/dist/graph/types.d.ts +78 -0
  435. package/dist/graph/types.d.ts.map +1 -0
  436. package/dist/graph/types.js +14 -0
  437. package/dist/graph/types.js.map +1 -0
  438. package/dist/graph/workspace-cli.d.ts +48 -0
  439. package/dist/graph/workspace-cli.d.ts.map +1 -0
  440. package/dist/graph/workspace-cli.js +102 -0
  441. package/dist/graph/workspace-cli.js.map +1 -0
  442. package/dist/graph/workspace.d.ts +135 -0
  443. package/dist/graph/workspace.d.ts.map +1 -0
  444. package/dist/graph/workspace.js +598 -0
  445. package/dist/graph/workspace.js.map +1 -0
  446. package/dist/graph/write.d.ts +13 -0
  447. package/dist/graph/write.d.ts.map +1 -0
  448. package/dist/graph/write.js +86 -0
  449. package/dist/graph/write.js.map +1 -0
  450. package/dist/hosts/antigravity.d.ts +8 -0
  451. package/dist/hosts/antigravity.d.ts.map +1 -0
  452. package/dist/hosts/antigravity.js +42 -0
  453. package/dist/hosts/antigravity.js.map +1 -0
  454. package/dist/hosts/claude-global.d.ts +36 -0
  455. package/dist/hosts/claude-global.d.ts.map +1 -0
  456. package/dist/hosts/claude-global.js +153 -0
  457. package/dist/hosts/claude-global.js.map +1 -0
  458. package/dist/hosts/codex-hooks.d.ts +11 -0
  459. package/dist/hosts/codex-hooks.d.ts.map +1 -0
  460. package/dist/hosts/codex-hooks.js +80 -0
  461. package/dist/hosts/codex-hooks.js.map +1 -0
  462. package/dist/hosts/config-write.d.ts +36 -0
  463. package/dist/hosts/config-write.d.ts.map +1 -0
  464. package/dist/hosts/config-write.js +64 -0
  465. package/dist/hosts/config-write.js.map +1 -0
  466. package/dist/hosts/cursor-hooks.d.ts +21 -0
  467. package/dist/hosts/cursor-hooks.d.ts.map +1 -0
  468. package/dist/hosts/cursor-hooks.js +103 -0
  469. package/dist/hosts/cursor-hooks.js.map +1 -0
  470. package/dist/hosts/init.d.ts +26 -0
  471. package/dist/hosts/init.d.ts.map +1 -0
  472. package/dist/hosts/init.js +82 -0
  473. package/dist/hosts/init.js.map +1 -0
  474. package/dist/hosts/install.d.ts +12 -0
  475. package/dist/hosts/install.d.ts.map +1 -0
  476. package/dist/hosts/install.js +347 -0
  477. package/dist/hosts/install.js.map +1 -0
  478. package/dist/hosts/instructions.d.ts +7 -0
  479. package/dist/hosts/instructions.d.ts.map +1 -0
  480. package/dist/hosts/instructions.js +71 -0
  481. package/dist/hosts/instructions.js.map +1 -0
  482. package/dist/hosts/investigation-instructions.d.ts +2 -0
  483. package/dist/hosts/investigation-instructions.d.ts.map +1 -0
  484. package/dist/hosts/investigation-instructions.js +2 -0
  485. package/dist/hosts/investigation-instructions.js.map +1 -0
  486. package/dist/hosts/mcp-config.d.ts +59 -0
  487. package/dist/hosts/mcp-config.d.ts.map +1 -0
  488. package/dist/hosts/mcp-config.js +229 -0
  489. package/dist/hosts/mcp-config.js.map +1 -0
  490. package/dist/hosts/plan.d.ts +32 -0
  491. package/dist/hosts/plan.d.ts.map +1 -0
  492. package/dist/hosts/plan.js +77 -0
  493. package/dist/hosts/plan.js.map +1 -0
  494. package/dist/hosts/registry.d.ts +35 -0
  495. package/dist/hosts/registry.d.ts.map +1 -0
  496. package/dist/hosts/registry.js +157 -0
  497. package/dist/hosts/registry.js.map +1 -0
  498. package/dist/hosts/retract.d.ts +47 -0
  499. package/dist/hosts/retract.d.ts.map +1 -0
  500. package/dist/hosts/retract.js +541 -0
  501. package/dist/hosts/retract.js.map +1 -0
  502. package/dist/hosts/sections.d.ts +46 -0
  503. package/dist/hosts/sections.d.ts.map +1 -0
  504. package/dist/hosts/sections.js +126 -0
  505. package/dist/hosts/sections.js.map +1 -0
  506. package/dist/index.d.ts +43 -0
  507. package/dist/index.d.ts.map +1 -0
  508. package/dist/index.js +33 -0
  509. package/dist/index.js.map +1 -0
  510. package/dist/ingest/fs.d.ts +79 -0
  511. package/dist/ingest/fs.d.ts.map +1 -0
  512. package/dist/ingest/fs.js +307 -0
  513. package/dist/ingest/fs.js.map +1 -0
  514. package/dist/init-guard.d.ts +11 -0
  515. package/dist/init-guard.d.ts.map +1 -0
  516. package/dist/init-guard.js +21 -0
  517. package/dist/init-guard.js.map +1 -0
  518. package/dist/investigation/index.d.ts +57 -0
  519. package/dist/investigation/index.d.ts.map +1 -0
  520. package/dist/investigation/index.js +315 -0
  521. package/dist/investigation/index.js.map +1 -0
  522. package/dist/mcp/compact.d.ts +9 -0
  523. package/dist/mcp/compact.d.ts.map +1 -0
  524. package/dist/mcp/compact.js +133 -0
  525. package/dist/mcp/compact.js.map +1 -0
  526. package/dist/mcp/instructions.d.ts +5 -0
  527. package/dist/mcp/instructions.d.ts.map +1 -0
  528. package/dist/mcp/instructions.js +57 -0
  529. package/dist/mcp/instructions.js.map +1 -0
  530. package/dist/mcp/server.d.ts +7 -0
  531. package/dist/mcp/server.d.ts.map +1 -0
  532. package/dist/mcp/server.js +128 -0
  533. package/dist/mcp/server.js.map +1 -0
  534. package/dist/mcp/tool-names.d.ts +20 -0
  535. package/dist/mcp/tool-names.d.ts.map +1 -0
  536. package/dist/mcp/tool-names.js +36 -0
  537. package/dist/mcp/tool-names.js.map +1 -0
  538. package/dist/mcp/tools.d.ts +22 -0
  539. package/dist/mcp/tools.d.ts.map +1 -0
  540. package/dist/mcp/tools.js +300 -0
  541. package/dist/mcp/tools.js.map +1 -0
  542. package/dist/notes/ask-notes.d.ts +8 -0
  543. package/dist/notes/ask-notes.d.ts.map +1 -0
  544. package/dist/notes/ask-notes.js +19 -0
  545. package/dist/notes/ask-notes.js.map +1 -0
  546. package/dist/notes/branches.d.ts +102 -0
  547. package/dist/notes/branches.d.ts.map +1 -0
  548. package/dist/notes/branches.js +304 -0
  549. package/dist/notes/branches.js.map +1 -0
  550. package/dist/notes/cold-start.d.ts +177 -0
  551. package/dist/notes/cold-start.d.ts.map +1 -0
  552. package/dist/notes/cold-start.js +537 -0
  553. package/dist/notes/cold-start.js.map +1 -0
  554. package/dist/notes/edit-overlap.d.ts +62 -0
  555. package/dist/notes/edit-overlap.d.ts.map +1 -0
  556. package/dist/notes/edit-overlap.js +202 -0
  557. package/dist/notes/edit-overlap.js.map +1 -0
  558. package/dist/notes/git-facts.d.ts +21 -0
  559. package/dist/notes/git-facts.d.ts.map +1 -0
  560. package/dist/notes/git-facts.js +121 -0
  561. package/dist/notes/git-facts.js.map +1 -0
  562. package/dist/notes/home.d.ts +87 -0
  563. package/dist/notes/home.d.ts.map +1 -0
  564. package/dist/notes/home.js +430 -0
  565. package/dist/notes/home.js.map +1 -0
  566. package/dist/notes/learning-fields.d.ts +102 -0
  567. package/dist/notes/learning-fields.d.ts.map +1 -0
  568. package/dist/notes/learning-fields.js +217 -0
  569. package/dist/notes/learning-fields.js.map +1 -0
  570. package/dist/notes/note-gate.d.ts +42 -0
  571. package/dist/notes/note-gate.d.ts.map +1 -0
  572. package/dist/notes/note-gate.js +181 -0
  573. package/dist/notes/note-gate.js.map +1 -0
  574. package/dist/notes/notes.d.ts +214 -0
  575. package/dist/notes/notes.d.ts.map +1 -0
  576. package/dist/notes/notes.js +591 -0
  577. package/dist/notes/notes.js.map +1 -0
  578. package/dist/notes/pr-reviews.d.ts +108 -0
  579. package/dist/notes/pr-reviews.d.ts.map +1 -0
  580. package/dist/notes/pr-reviews.js +325 -0
  581. package/dist/notes/pr-reviews.js.map +1 -0
  582. package/dist/notes/repo-julius.d.ts +18 -0
  583. package/dist/notes/repo-julius.d.ts.map +1 -0
  584. package/dist/notes/repo-julius.js +111 -0
  585. package/dist/notes/repo-julius.js.map +1 -0
  586. package/dist/notes/session-cost.d.ts +35 -0
  587. package/dist/notes/session-cost.d.ts.map +1 -0
  588. package/dist/notes/session-cost.js +276 -0
  589. package/dist/notes/session-cost.js.map +1 -0
  590. package/dist/search/grep-cli.d.ts +35 -0
  591. package/dist/search/grep-cli.d.ts.map +1 -0
  592. package/dist/search/grep-cli.js +115 -0
  593. package/dist/search/grep-cli.js.map +1 -0
  594. package/dist/search/grep.d.ts +60 -0
  595. package/dist/search/grep.d.ts.map +1 -0
  596. package/dist/search/grep.js +176 -0
  597. package/dist/search/grep.js.map +1 -0
  598. package/dist/search/ignored-code.d.ts +9 -0
  599. package/dist/search/ignored-code.d.ts.map +1 -0
  600. package/dist/search/ignored-code.js +73 -0
  601. package/dist/search/ignored-code.js.map +1 -0
  602. package/dist/skills/skills.d.ts +118 -0
  603. package/dist/skills/skills.d.ts.map +1 -0
  604. package/dist/skills/skills.js +370 -0
  605. package/dist/skills/skills.js.map +1 -0
  606. package/dist/telemetry/contract.d.ts +103 -0
  607. package/dist/telemetry/contract.d.ts.map +1 -0
  608. package/dist/telemetry/contract.js +270 -0
  609. package/dist/telemetry/contract.js.map +1 -0
  610. package/dist/telemetry/flush.d.ts +21 -0
  611. package/dist/telemetry/flush.d.ts.map +1 -0
  612. package/dist/telemetry/flush.js +85 -0
  613. package/dist/telemetry/flush.js.map +1 -0
  614. package/dist/telemetry/gate.d.ts +30 -0
  615. package/dist/telemetry/gate.d.ts.map +1 -0
  616. package/dist/telemetry/gate.js +81 -0
  617. package/dist/telemetry/gate.js.map +1 -0
  618. package/dist/telemetry/identity.d.ts +40 -0
  619. package/dist/telemetry/identity.d.ts.map +1 -0
  620. package/dist/telemetry/identity.js +80 -0
  621. package/dist/telemetry/identity.js.map +1 -0
  622. package/dist/telemetry/index.d.ts +18 -0
  623. package/dist/telemetry/index.d.ts.map +1 -0
  624. package/dist/telemetry/index.js +16 -0
  625. package/dist/telemetry/index.js.map +1 -0
  626. package/dist/telemetry/key.d.ts +4 -0
  627. package/dist/telemetry/key.d.ts.map +1 -0
  628. package/dist/telemetry/key.js +4 -0
  629. package/dist/telemetry/key.js.map +1 -0
  630. package/dist/telemetry/notice.d.ts +19 -0
  631. package/dist/telemetry/notice.d.ts.map +1 -0
  632. package/dist/telemetry/notice.js +93 -0
  633. package/dist/telemetry/notice.js.map +1 -0
  634. package/dist/telemetry/queue.d.ts +35 -0
  635. package/dist/telemetry/queue.d.ts.map +1 -0
  636. package/dist/telemetry/queue.js +162 -0
  637. package/dist/telemetry/queue.js.map +1 -0
  638. package/dist/telemetry/send.d.ts +19 -0
  639. package/dist/telemetry/send.d.ts.map +1 -0
  640. package/dist/telemetry/send.js +84 -0
  641. package/dist/telemetry/send.js.map +1 -0
  642. package/dist/telemetry/sessions.d.ts +25 -0
  643. package/dist/telemetry/sessions.d.ts.map +1 -0
  644. package/dist/telemetry/sessions.js +104 -0
  645. package/dist/telemetry/sessions.js.map +1 -0
  646. package/dist/telemetry/track.d.ts +62 -0
  647. package/dist/telemetry/track.d.ts.map +1 -0
  648. package/dist/telemetry/track.js +142 -0
  649. package/dist/telemetry/track.js.map +1 -0
  650. package/dist/upkeep-run.d.ts +15 -0
  651. package/dist/upkeep-run.d.ts.map +1 -0
  652. package/dist/upkeep-run.js +71 -0
  653. package/dist/upkeep-run.js.map +1 -0
  654. package/dist/upkeep.d.ts +125 -0
  655. package/dist/upkeep.d.ts.map +1 -0
  656. package/dist/upkeep.js +255 -0
  657. package/dist/upkeep.js.map +1 -0
  658. package/dist/util/browser.d.ts +3 -0
  659. package/dist/util/browser.d.ts.map +1 -0
  660. package/dist/util/browser.js +14 -0
  661. package/dist/util/browser.js.map +1 -0
  662. package/dist/util/front-matter.d.ts +19 -0
  663. package/dist/util/front-matter.d.ts.map +1 -0
  664. package/dist/util/front-matter.js +21 -0
  665. package/dist/util/front-matter.js.map +1 -0
  666. package/dist/util/id.d.ts +7 -0
  667. package/dist/util/id.d.ts.map +1 -0
  668. package/dist/util/id.js +14 -0
  669. package/dist/util/id.js.map +1 -0
  670. package/dist/util/paths.d.ts +29 -0
  671. package/dist/util/paths.d.ts.map +1 -0
  672. package/dist/util/paths.js +71 -0
  673. package/dist/util/paths.js.map +1 -0
  674. package/dist/util/source.d.ts +4 -0
  675. package/dist/util/source.d.ts.map +1 -0
  676. package/dist/util/source.js +12 -0
  677. package/dist/util/source.js.map +1 -0
  678. package/dist/util/spinner.d.ts +15 -0
  679. package/dist/util/spinner.d.ts.map +1 -0
  680. package/dist/util/spinner.js +52 -0
  681. package/dist/util/spinner.js.map +1 -0
  682. package/dist/util/state.d.ts +100 -0
  683. package/dist/util/state.d.ts.map +1 -0
  684. package/dist/util/state.js +186 -0
  685. package/dist/util/state.js.map +1 -0
  686. package/dist/viewer/app.js +2 -0
  687. package/dist/viewer/index.html +49 -0
  688. package/dist/viewer/style.css +154 -0
  689. package/dist/viz/assemble.d.ts +83 -0
  690. package/dist/viz/assemble.d.ts.map +1 -0
  691. package/dist/viz/assemble.js +101 -0
  692. package/dist/viz/assemble.js.map +1 -0
  693. package/dist/viz/export.d.ts +39 -0
  694. package/dist/viz/export.d.ts.map +1 -0
  695. package/dist/viz/export.js +98 -0
  696. package/dist/viz/export.js.map +1 -0
  697. package/dist/viz/serve.d.ts +12 -0
  698. package/dist/viz/serve.d.ts.map +1 -0
  699. package/dist/viz/serve.js +129 -0
  700. package/dist/viz/serve.js.map +1 -0
  701. package/docs/assets/context-benchmark.svg +31 -0
  702. package/docs/assets/julius-hero.png +0 -0
  703. package/docs/upstream-changelog.md +785 -0
  704. package/package.json +138 -4
@@ -0,0 +1,654 @@
1
+ /**
2
+ * Resolve {@link RawEdge} intents into concrete {@link EdgeV1} edges by matching
3
+ * names/specifiers against the whole-repo node index.
4
+ *
5
+ * Confidence is a two-tier provenance model:
6
+ * - `extracted`: the target is certain — a match within the same file, an
7
+ * import specifier, or a structural containment.
8
+ * - `inferred`: a bare function target was resolved by a unique name match
9
+ * across files, which name-shadowing could in principle fool.
10
+ * Ambiguous cross-file matches (a name defined in several files) are dropped
11
+ * rather than guessed. Member calls are stricter: they require a receiver type
12
+ * and owner-qualified method match because a unique bare method name says
13
+ * nothing about the receiver.
14
+ */
15
+ import { posix } from "node:path";
16
+ import { toPosixPath } from "../util/paths.js";
17
+ import { languageOf } from "./extract.js";
18
+ import { genericLangOf } from "./generic.js";
19
+ const IMPORT_EXTS = [".ts", ".tsx", ".mts", ".cts", ".js", ".jsx", ".mjs", ".cjs", ".py"];
20
+ /** C/C++ source + header extensions, for resolving `#include` targets. */
21
+ const C_EXT = /\.(c|h|cc|cpp|cxx|hpp|hh|hxx|inl|ipp|c\+\+|h\+\+)$/i;
22
+ /** Python source + stub extensions, for the constructor-call fallback below. */
23
+ const PY_EXT = /\.pyi?$/i;
24
+ /** What a bare Python call falls back to when no function of that name exists:
25
+ * construction. Only `class` — Python enums, dataclasses and NamedTuples are all
26
+ * classes, so no other kind is reachable this way. */
27
+ const PY_CTOR_KINDS = ["class"];
28
+ /** Swift is Python's case with more nominal kinds: `Animal(legs: 4)` is an ordinary
29
+ * call node with no `new` to mark construction, and struct/enum initializers are as
30
+ * routine as class ones (a struct gets a memberwise init for free). Same fallback
31
+ * shape — types are tried only once functions (and methods, see extract.ts's
32
+ * implicit-self widening) have found nothing. */
33
+ const SWIFT_EXT = /\.swift$/i;
34
+ const SWIFT_CTOR_KINDS = ["class", "struct", "enum"];
35
+ /**
36
+ * Languages whose symbols can genuinely reach each other. A call edge may not
37
+ * cross a family boundary.
38
+ *
39
+ * This exists because name resolution is repo-wide and used to be language-blind.
40
+ * A Go file calling the builtin `make(...)` has nothing in the repo to resolve
41
+ * against, so the unique-global fallback below matched a TypeScript helper named
42
+ * `make` in a frontend test file — and then every `make(map[...])` in the backend
43
+ * became an edge into that file. One symbol collected 1040 in-edges across 476
44
+ * files, and any pull request touching that test dragged the entire Go backend
45
+ * into its blast radius. Uniqueness is what made it fire: the rarer the collision,
46
+ * the more confident the old code was that it had found the right target.
47
+ *
48
+ * Only real interop is grouped here. TS/TSX/JS import each other freely; Kotlin,
49
+ * Scala and Clojure compile against Java on one classpath; C and C++ share
50
+ * headers. Everything else stands alone.
51
+ */
52
+ const FAMILIES = [
53
+ ["typescript", "tsx"],
54
+ ["java", "kotlin", "scala", "clojure"],
55
+ ["c", "cpp"],
56
+ ];
57
+ const FAMILY_OF = new Map();
58
+ for (const group of FAMILIES)
59
+ for (const lang of group)
60
+ FAMILY_OF.set(lang, group[0]);
61
+ /**
62
+ * The language family a path belongs to, or null when no tier claims the file.
63
+ * A language of its own is its own family, so the common case needs no entry above.
64
+ */
65
+ function familyOf(path) {
66
+ const lang = languageOf(path) ?? genericLangOf(path)?.name ?? null;
67
+ if (!lang)
68
+ return null;
69
+ return FAMILY_OF.get(lang) ?? lang;
70
+ }
71
+ /**
72
+ * Could a reference in `file` reach a definition in `candidatePath`?
73
+ *
74
+ * An unknown family never filters: absence of data is not evidence of a mismatch,
75
+ * and refusing edges for every extension julius cannot name would lose real ones.
76
+ */
77
+ function reachable(file, candidatePath) {
78
+ const from = familyOf(file);
79
+ if (from === null)
80
+ return true;
81
+ const to = familyOf(candidatePath);
82
+ return to === null || from === to;
83
+ }
84
+ export function resolveEdges(nodes, rawEdges, opts = {}) {
85
+ const byId = new Map(nodes.map((n) => [n.id, n]));
86
+ const globalName = new Map();
87
+ const perFileName = new Map();
88
+ // Owner-qualified method index: "Owner.method" → candidate method nodes, for
89
+ // typed member-call resolution (recvType + name → a specific class's method).
90
+ const ownerMethod = new Map();
91
+ // Go package resolution: dir (posix) → its `.go` file node ids, for import mapping.
92
+ const goFilesByDir = new Map();
93
+ // Java package resolution: a file's package-path suffix (`com/acme/Foo.java`) → its
94
+ // file node ids. A Java import names a type by its fully-qualified name, which by
95
+ // language convention mirrors the directory path under whatever source root the
96
+ // project uses (`src/main/java/`, `src/`, …) — so the suffix is the portable key.
97
+ const javaFilesBySuffix = new Map();
98
+ // C/C++ header resolution: a file's path-suffix (`net/socket.h`, `socket.h`) → its
99
+ // file node ids, so an `#include` reached through an `-I` dir (not relative to the
100
+ // including file) still resolves to the in-repo header when the suffix is unique.
101
+ const cFilesBySuffix = new Map();
102
+ // Rust crate roots: the directory holding a `lib.rs` or `main.rs`. A `use crate::a::b`
103
+ // resolves to `<crate root>/a/b.rs` (or `.../a/b/mod.rs`), relative to the crate the
104
+ // importing file belongs to — so a workspace with several crates stays unambiguous.
105
+ const rustCrateRoots = [];
106
+ // PHP class resolution: a file's path-suffix (`Models/User.php`, `User.php`) → its file
107
+ // node ids. A `use App\Models\User` names a PSR-4 class whose file mirrors the namespace
108
+ // tail under some (unknown) source root, so the suffix is the portable key.
109
+ const phpFilesBySuffix = new Map();
110
+ const hasGoModules = !!opts.goModules?.length;
111
+ for (const n of nodes) {
112
+ if (n.kind === "file") {
113
+ if (hasGoModules && n.path.endsWith(".go")) {
114
+ const dir = posix.dirname(toPosixPath(n.path));
115
+ push(goFilesByDir, dir, n.id);
116
+ }
117
+ if (n.path.endsWith(".java")) {
118
+ // Index every directory-boundary suffix, since the source root is unknown:
119
+ // `src/main/java/com/acme/Foo.java` is reachable as `com/acme/Foo.java`,
120
+ // `acme/Foo.java`, and so on. The import's own FQN picks the right depth.
121
+ const parts = toPosixPath(n.path).split("/");
122
+ for (let i = 0; i < parts.length; i++)
123
+ push(javaFilesBySuffix, parts.slice(i).join("/"), n.id);
124
+ }
125
+ if (C_EXT.test(n.path)) {
126
+ const parts = toPosixPath(n.path).split("/");
127
+ for (let i = 0; i < parts.length; i++)
128
+ push(cFilesBySuffix, parts.slice(i).join("/"), n.id);
129
+ }
130
+ if (n.path.endsWith(".php")) {
131
+ const parts = toPosixPath(n.path).split("/");
132
+ for (let i = 0; i < parts.length; i++)
133
+ push(phpFilesBySuffix, parts.slice(i).join("/"), n.id);
134
+ }
135
+ {
136
+ const p = toPosixPath(n.path);
137
+ if (p === "lib.rs" || p === "main.rs")
138
+ rustCrateRoots.push("");
139
+ else if (p.endsWith("/lib.rs") || p.endsWith("/main.rs"))
140
+ rustCrateRoots.push(posix.dirname(p));
141
+ }
142
+ continue;
143
+ }
144
+ push(globalName, n.name, n);
145
+ let fileMap = perFileName.get(n.path);
146
+ if (!fileMap)
147
+ perFileName.set(n.path, (fileMap = new Map()));
148
+ push(fileMap, n.name, n);
149
+ if (n.kind === "method") {
150
+ const owner = n.owner ?? ownerFromMethodId(n.id);
151
+ if (owner)
152
+ push(ownerMethod, `${owner}.${n.name}`, n);
153
+ }
154
+ }
155
+ // classParents: class/interface name → its declared base-class names, from raw
156
+ // `extends` edges (source id's own name → the base name). Used to walk up an
157
+ // inheritance chain when a receiver's own type has no matching method.
158
+ const classParents = new Map();
159
+ for (const e of rawEdges) {
160
+ if (e.relation !== "extends" || !e.name)
161
+ continue;
162
+ // The declaring class's own bare name — read from its node (keyed by n.name, set
163
+ // once at mint time) rather than re-derived by slicing e.source, which breaks once
164
+ // ids can carry a dedup ordinal (A3's `Cache~2`).
165
+ const ownName = byId.get(e.source)?.name;
166
+ if (!ownName)
167
+ continue;
168
+ push(classParents, ownName, e.name);
169
+ }
170
+ // classTraits: class name → trait names from raw `implements` edges in PHP files.
171
+ // PHP models `use SomeTrait;` as implements; trait methods live on the trait owner,
172
+ // not the using class, so resolveTypedMember walks these after the class lookup fails.
173
+ const classTraits = new Map();
174
+ for (const e of rawEdges) {
175
+ if (e.relation !== "implements" || !e.name || !e.file.endsWith(".php"))
176
+ continue;
177
+ const ownName = byId.get(e.source)?.name;
178
+ if (!ownName)
179
+ continue;
180
+ push(classTraits, ownName, e.name);
181
+ }
182
+ const out = [];
183
+ const seen = new Set();
184
+ const add = (source, target, relation, confidence) => {
185
+ const key = `${source}\0${relation}\0${target}`;
186
+ if (seen.has(key))
187
+ return;
188
+ seen.add(key);
189
+ out.push({ source, target, relation, confidence });
190
+ };
191
+ for (const e of rawEdges) {
192
+ if (e.relation === "contains" && e.targetId) {
193
+ add(e.source, e.targetId, "contains", "extracted");
194
+ }
195
+ else if (e.relation === "imports" && e.specifier) {
196
+ const target = hasGoModules && e.file.endsWith(".go")
197
+ ? resolveGoImport(e.specifier, opts.goModules, goFilesByDir)
198
+ : e.file.endsWith(".java")
199
+ ? resolveJavaImport(e.specifier, javaFilesBySuffix)
200
+ : C_EXT.test(e.file)
201
+ ? resolveCInclude(e.specifier, e.file, byId, cFilesBySuffix)
202
+ : e.file.endsWith(".rs")
203
+ ? resolveRustUse(e.specifier, e.file, byId, rustCrateRoots)
204
+ : e.file.endsWith(".php")
205
+ ? resolvePhpUse(e.specifier, phpFilesBySuffix)
206
+ : resolveImport(e.specifier, e.file, byId);
207
+ add(e.source, target, "imports", "extracted");
208
+ }
209
+ else if (e.relation === "extends" || e.relation === "implements") {
210
+ // `implements` also resolves to a `trait` — PHP models trait composition
211
+ // (`use SomeTrait;`) as an implements edge, and a trait is a valid target.
212
+ const kinds = e.relation === "implements" ? ["interface", "trait"] : ["class", "interface"];
213
+ const hit = resolveName(e.name, e.file, kinds, perFileName, globalName);
214
+ // an unresolved base is usually an external/imported type — keep the name.
215
+ add(e.source, hit?.id ?? e.name, e.relation, hit?.confidence ?? "inferred");
216
+ }
217
+ else if (e.relation === "references" && e.name) {
218
+ if (e.specifier) {
219
+ // A named import gives both halves needed for sound resolution: the module
220
+ // it came from and the exported name. Resolve inside that file only, so a
221
+ // same-named symbol elsewhere in the repo cannot become a false edge.
222
+ const targetFile = e.file.endsWith(".php")
223
+ ? resolvePhpUse(e.specifier, phpFilesBySuffix)
224
+ : resolveImport(e.specifier, e.file, byId);
225
+ if (!byId.has(targetFile))
226
+ continue; // external or unresolved module
227
+ const candidates = perFileName.get(targetFile)?.get(e.name) ?? [];
228
+ if (candidates.length === 1)
229
+ add(e.source, candidates[0].id, "references", "extracted");
230
+ }
231
+ else if (e.file.endsWith(".php") && byId.get(e.source)?.origin === "ast") {
232
+ // PHP attribute without a `use` import (same-file or globally unique class).
233
+ const refKinds = ["class", "interface", "trait", "enum"];
234
+ const hit = resolveName(e.name, e.file, refKinds, perFileName, globalName);
235
+ if (hit && hit.id !== e.source)
236
+ add(e.source, hit.id, "references", hit.confidence);
237
+ }
238
+ else if (e.file.endsWith(".java") && byId.get(e.source)?.origin === "ast") {
239
+ // Java annotation without a specifier (same-file or globally unique
240
+ // `@interface`). Annotation types are `interface` kind — a class of the
241
+ // same name is not a match, so `@Entity` cannot collapse onto an in-repo
242
+ // `class Entity` (#103). Kind alone still cannot tell `@interface Service`
243
+ // from `interface Service`, so only accept a candidate whose header
244
+ // contains the literal `@interface` (`includes`, not `startsWith`: a
245
+ // meta-annotated type is `@Documented @Retention(...) public @interface
246
+ // JsonAdapter`). Unresolved targets keep the bare name, matching
247
+ // heritage, rather than dropping the way PHP attributes do.
248
+ const refKinds = ["interface"];
249
+ const hit = resolveName(e.name, e.file, refKinds, perFileName, globalName);
250
+ const anno = hit ? byId.get(hit.id) : undefined;
251
+ if (hit && hit.id !== e.source && anno?.signature?.includes("@interface"))
252
+ add(e.source, hit.id, "references", hit.confidence);
253
+ else
254
+ add(e.source, e.name, "references", "inferred");
255
+ }
256
+ else if (byId.get(e.source)?.origin === "generic") {
257
+ // Breadth tier: a bare-name structural reference (extends / implements /
258
+ // object-creation / module alias) the grammar marked but cannot type. Resolve
259
+ // to a type-like definition, drop-rather-than-guess, never a self-loop. Gated on
260
+ // generic origin so depth-tier references (which always carry a specifier) are
261
+ // provably untouched.
262
+ const refKinds = ["class", "interface", "struct", "enum", "type", "module"];
263
+ const hit = resolveName(e.name, e.file, refKinds, perFileName, globalName);
264
+ if (hit && hit.id !== e.source)
265
+ add(e.source, hit.id, "references", hit.confidence);
266
+ }
267
+ }
268
+ else if (e.relation === "calls") {
269
+ if (e.viaMember) {
270
+ if (!e.recvType)
271
+ continue;
272
+ const hit = resolveTypedMember(e.recvType, e.name, e.file, ownerMethod, classParents, classTraits, e.argCount);
273
+ if (hit === "ambiguous")
274
+ continue; // drop — never guess past an ambiguous owner
275
+ if (hit) {
276
+ add(e.source, hit.id, "calls", hit.confidence);
277
+ continue;
278
+ }
279
+ // No owner-qualified match means the call is unresolved. A unique bare
280
+ // method name is not evidence that this receiver has that method — a
281
+ // name-fallback here was measured to HALVE call-edge precision (73%→37%
282
+ // vs a compiler-grade oracle) for a 3x count inflation, i.e. noise. See #35.
283
+ //
284
+ // One carve-out, which is NOT that fallback: a Swift `implicitSelf` edge
285
+ // carries two readings of one bare call — member (tried above, in
286
+ // Swift's own inner-scope-first order) and free function. Zero members
287
+ // on the whole owner chain means the call was a free-function call after
288
+ // all, so it falls through to bare-name resolution; an ambiguous member
289
+ // set has already dropped it above, and a resolved member never reaches
290
+ // here — a name defined as both member and free function yields the
291
+ // member edge alone, exactly as Swift dispatches it.
292
+ if (!e.implicitSelf)
293
+ continue;
294
+ }
295
+ // Every language's bare-name call is a free function, except R (Phase 4):
296
+ // an untyped `obj$method()` there sets e.kinds to also allow a "method"
297
+ // match — see extract.ts's calleeName R branch for why (R6 methods are
298
+ // never kind "function", so without this every such call would be
299
+ // unconditionally unresolvable rather than just occasionally ambiguous).
300
+ // Three cases, because "a bare call" means something different per tier:
301
+ //
302
+ // - generic (breadth tier): tags.scm captures ALL calls as bare names, since it
303
+ // cannot type a receiver. In method-heavy languages those target methods, so
304
+ // widen to methods — ONLY here, leaving depth-tier precision untouched (an
305
+ // ambiguous function-vs-method name still drops).
306
+ // - Java (depth tier): an implicit-`this` call is spelled as a member call in
307
+ // extract.ts, so the only bare call reaching here is `new Foo()`, whose target
308
+ // is a TYPE. Against the function index every constructor edge would drop.
309
+ // - everything else: functions, exactly as before.
310
+ //
311
+ // R (depth tier, Phase 4) sets `e.kinds` itself for an untyped `obj$method()`
312
+ // (see above), and that explicit choice wins over the per-tier default.
313
+ const srcOrigin = byId.get(e.source)?.origin;
314
+ const callKinds = e.kinds ??
315
+ (srcOrigin === "generic"
316
+ ? ["function", "method"]
317
+ : e.file.endsWith(".java")
318
+ ? ["class", "struct", "enum", "interface"]
319
+ : ["function"]);
320
+ let hit = resolveName(e.name, e.file, callKinds, perFileName, globalName);
321
+ // Python is the Java case without the `new` to mark it: `Widget()` is an
322
+ // ordinary call node, so a constructor edge dies against the function-only
323
+ // index. Java can widen to types outright; Python has free functions, so
324
+ // widening would trade real function edges for type ones. Hence a fallback,
325
+ // not a swap — types are tried only once functions have found nothing, and
326
+ // resolveName's same-file-then-unique-global rule still drops the ambiguous.
327
+ if (!hit && PY_EXT.test(e.file)) {
328
+ hit = resolveName(e.name, e.file, PY_CTOR_KINDS, perFileName, globalName);
329
+ }
330
+ if (!hit && SWIFT_EXT.test(e.file)) {
331
+ hit = resolveName(e.name, e.file, SWIFT_CTOR_KINDS, perFileName, globalName);
332
+ }
333
+ if (hit)
334
+ add(e.source, hit.id, "calls", hit.confidence); // drop unresolved calls (too noisy)
335
+ }
336
+ }
337
+ return out;
338
+ }
339
+ function push(map, key, val) {
340
+ const arr = map.get(key);
341
+ if (arr)
342
+ arr.push(val);
343
+ else
344
+ map.set(key, [val]);
345
+ }
346
+ /** Derive a method's owner from its dotted id when extract did not stamp `owner`
347
+ * (PHP trait/interface methods today). `app.php#Loggable.log` → `Loggable`. */
348
+ function ownerFromMethodId(id) {
349
+ const post = id.includes("#") ? id.split("#")[1] : id;
350
+ const segs = post.split(".");
351
+ return segs.length >= 2 ? segs[segs.length - 2] : undefined;
352
+ }
353
+ /**
354
+ * Resolve a bare symbol name: same-file match first (certain → `extracted`),
355
+ * else a unique cross-file match (→ `inferred`), else null (ambiguous/unknown).
356
+ */
357
+ function resolveName(name, file, kinds, perFileName, globalName) {
358
+ const local = (perFileName.get(file)?.get(name) ?? []).filter((n) => kinds.includes(n.kind));
359
+ // Same-file requires a UNIQUE match, exactly as the cross-file branch below does.
360
+ // Returning `local[0]` meant a file holding two same-named types (`Alpha.Builder` and
361
+ // `Beta.Builder`, `Alpha.Inner` and `Beta.Inner`) silently resolved to whichever came
362
+ // first in document order — and labelled it `extracted`, i.e. certain. That is the
363
+ // guess this module's header says it does not make.
364
+ if (local.length === 1)
365
+ return { id: local[0].id, confidence: "extracted" };
366
+ // Cross-file: also require a language that could actually reach this one.
367
+ // Without it a unique name match ANYWHERE in the repo wins, which is how a Go
368
+ // builtin ended up resolving into a TypeScript test — see FAMILIES above.
369
+ const global = (globalName.get(name) ?? []).filter((n) => kinds.includes(n.kind) && reachable(file, n.path));
370
+ if (global.length === 1)
371
+ return { id: global[0].id, confidence: "inferred" };
372
+ return null;
373
+ }
374
+ /**
375
+ * Resolve a typed member call (`recvType.name`) against the owner-qualified method
376
+ * index, walking the receiver's extends chain when its own type has no match.
377
+ *
378
+ * Returns:
379
+ * - `{ id, confidence }` — resolved: a single candidate at some owner level (or the
380
+ * same-file one among several).
381
+ * - `"ambiguous"` — several candidates at some owner level and none is same-file;
382
+ * per the inviolable philosophy we drop and stop rather than guess, and we do
383
+ * NOT continue up the chain past this level.
384
+ * - `null` — the whole chain (recvType + ancestors, breadth-first, depth ≤ 3,
385
+ * cycle-guarded) had zero candidates at every level.
386
+ */
387
+ /**
388
+ * Narrow an overload set to the candidates a call of `argCount` arguments could
389
+ * reach. Only Java emits `argCount`/`arity`, so for every other language this is
390
+ * the identity function and resolution is byte-for-byte what it was.
391
+ *
392
+ * Deliberately conservative in both directions:
393
+ * - A variadic candidate (`String... xs`) accepts anything from `arity - 1`
394
+ * upward, so it is never filtered out by count.
395
+ * - A candidate with no recorded arity (a graph built before this field) is
396
+ * kept, since absence of data is not evidence of a mismatch.
397
+ * - If narrowing leaves nothing, the ORIGINAL set is returned. An empty result
398
+ * would silently drop a real edge; handing the full set back lets the existing
399
+ * same-file / "ambiguous" logic make the call exactly as before.
400
+ */
401
+ function narrowByArity(candidates, argCount) {
402
+ if (argCount === undefined || candidates.length < 2)
403
+ return candidates;
404
+ const fits = candidates.filter((c) => {
405
+ if (c.arity === undefined)
406
+ return true;
407
+ return c.variadic ? argCount >= c.arity - 1 : c.arity === argCount;
408
+ });
409
+ return fits.length > 0 ? fits : candidates;
410
+ }
411
+ function resolveTypedMember(recvType, name, file, ownerMethod, classParents, classTraits, argCount) {
412
+ const MAX_DEPTH = 3;
413
+ const visited = new Set([recvType]);
414
+ let frontier = [recvType];
415
+ for (let depth = 0; depth <= MAX_DEPTH && frontier.length; depth++) {
416
+ for (const type of frontier) {
417
+ const all = ownerMethod.get(`${type}.${name}`)?.filter((c) => reachable(file, c.path));
418
+ if (all && all.length > 0) {
419
+ const candidates = narrowByArity(all, argCount);
420
+ if (candidates.length === 1) {
421
+ const c = candidates[0];
422
+ return { id: c.id, confidence: c.path === file ? "extracted" : "inferred" };
423
+ }
424
+ // Swift: several candidates surviving arity narrowing are a genuine
425
+ // overload set distinguished only by parameter TYPES (`save(Int)` vs
426
+ // `save(String)`), which this pass cannot read — the same-file tiebreak
427
+ // below would pick whichever overload appears first in the file and
428
+ // stamp it `extracted`, a confidently wrong edge. Drop instead.
429
+ if (SWIFT_EXT.test(file))
430
+ return "ambiguous";
431
+ const sameFile = candidates.find((c) => c.path === file);
432
+ if (sameFile)
433
+ return { id: sameFile.id, confidence: "extracted" };
434
+ return "ambiguous"; // several, none same-file — drop and stop
435
+ }
436
+ const traitHit = resolveTraitMember(type, name, file, ownerMethod, classTraits, argCount);
437
+ if (traitHit === "ambiguous")
438
+ return "ambiguous";
439
+ if (traitHit)
440
+ return traitHit;
441
+ }
442
+ const next = [];
443
+ for (const type of frontier) {
444
+ for (const parent of classParents.get(type) ?? []) {
445
+ if (visited.has(parent))
446
+ continue;
447
+ visited.add(parent);
448
+ next.push(parent);
449
+ }
450
+ }
451
+ frontier = next;
452
+ }
453
+ return null; // chain exhausted, no candidate anywhere
454
+ }
455
+ /** Resolve a member call against methods declared on PHP traits used by `type`. */
456
+ function resolveTraitMember(type, name, file, ownerMethod, classTraits, argCount) {
457
+ const traits = classTraits.get(type);
458
+ if (!traits?.length)
459
+ return null;
460
+ const matches = [];
461
+ for (const trait of traits) {
462
+ const all = ownerMethod.get(`${trait}.${name}`)?.filter((c) => reachable(file, c.path));
463
+ if (!all?.length)
464
+ continue;
465
+ matches.push(...narrowByArity(all, argCount));
466
+ }
467
+ if (matches.length === 0)
468
+ return null;
469
+ if (matches.length === 1) {
470
+ const c = matches[0];
471
+ return { id: c.id, confidence: c.path === file ? "extracted" : "inferred" };
472
+ }
473
+ return "ambiguous";
474
+ }
475
+ /**
476
+ * Resolve a module specifier to a file node id when it points inside the repo;
477
+ * otherwise return the raw specifier (external package or unresolved path).
478
+ */
479
+ function resolveImport(spec, file, byId) {
480
+ if (!spec.startsWith("."))
481
+ return spec;
482
+ // Belt-and-braces: `node.path` is posix by construction (`../util/paths.ts`),
483
+ // but this also accepts a hand-written or hand-edited graph.
484
+ const dir = posix.dirname(toPosixPath(file));
485
+ const base = posix.normalize(posix.join(dir, spec));
486
+ const noExt = base.replace(/\.(js|jsx|mjs|cjs|ts|tsx|py)$/, "");
487
+ const candidates = [
488
+ base,
489
+ ...IMPORT_EXTS.map((e) => noExt + e),
490
+ ...IMPORT_EXTS.map((e) => `${noExt}/index${e}`),
491
+ ];
492
+ for (const c of candidates)
493
+ if (byId.has(c))
494
+ return c;
495
+ return spec;
496
+ }
497
+ /**
498
+ * Resolve a Java import's fully-qualified type name to an in-repo file node;
499
+ * otherwise return the raw specifier (JDK or third-party type).
500
+ *
501
+ * Java names a *type*, not a path, and states no source root — `com.acme.Foo` may
502
+ * live under `src/main/java/`, `src/`, or a module dir. Matching on the path SUFFIX
503
+ * (`com/acme/Foo.java`) is therefore root-agnostic and needs no build-file parsing,
504
+ * which is what keeps this deterministic and dependency-free.
505
+ *
506
+ * `import static com.acme.Foo.bar` names a member, so when the full name misses, the
507
+ * last segment is dropped and the enclosing type retried. A wildcard (`com.acme.*`)
508
+ * names a package rather than one file and is deliberately left unresolved: picking a
509
+ * representative would invent an edge the source does not state.
510
+ *
511
+ * A suffix shared by two files (the same FQN under two source roots, e.g. a
512
+ * duplicated test tree) is ambiguous, so it stays unresolved rather than guessing.
513
+ */
514
+ function resolveJavaImport(spec, filesBySuffix) {
515
+ const hit = (fqn) => {
516
+ const suffix = `${fqn.split(".").join("/")}.java`;
517
+ const files = filesBySuffix.get(suffix);
518
+ return files && files.length === 1 ? files[0] : null;
519
+ };
520
+ const direct = hit(spec);
521
+ if (direct)
522
+ return direct;
523
+ // `import static a.b.C.member` → retry as `a.b.C`.
524
+ const dot = spec.lastIndexOf(".");
525
+ if (dot > 0) {
526
+ const enclosing = hit(spec.slice(0, dot));
527
+ if (enclosing)
528
+ return enclosing;
529
+ }
530
+ return spec;
531
+ }
532
+ /**
533
+ * Resolve a C/C++ `#include "path"` to an in-repo file node: relative to the including
534
+ * file first (the common case, and certain), else a UNIQUE path-suffix match — which
535
+ * covers a header reached through an `-I` include directory rather than a relative path.
536
+ * Anything ambiguous or not found stays the raw path (a system or out-of-repo header),
537
+ * never a guessed edge.
538
+ */
539
+ function resolveCInclude(spec, file, byId, bySuffix) {
540
+ const dir = posix.dirname(toPosixPath(file));
541
+ const relJoin = posix.normalize(posix.join(dir, spec));
542
+ if (byId.has(relJoin))
543
+ return relJoin; // relative to the including file — certain
544
+ const hits = bySuffix.get(spec.replace(/^\.?\//, ""));
545
+ if (hits && hits.length === 1)
546
+ return hits[0]; // unique suffix — an -I-reached header
547
+ return spec; // system/out-of-repo/ambiguous — keep the string, do not guess
548
+ }
549
+ /**
550
+ * Resolve a PHP `use` fully-qualified name (`App\Models\User`) to the in-repo class file.
551
+ * PSR-4 maps the namespace to a directory under some (unknown) source root and the class
552
+ * to a `<Class>.php` file, so we match the longest namespace-tail suffix that names exactly
553
+ * one file: `App/Models/User.php`, then `Models/User.php`, then `User.php`. The longest
554
+ * unique match wins; an ambiguous tail or a vendor/out-of-repo class stays the raw name.
555
+ */
556
+ function resolvePhpUse(fqn, bySuffix) {
557
+ const parts = fqn.split("\\").filter(Boolean);
558
+ if (parts.length === 0)
559
+ return fqn;
560
+ for (let i = 0; i < parts.length; i++) {
561
+ const suffix = `${parts.slice(i).join("/")}.php`;
562
+ const hits = bySuffix.get(suffix);
563
+ if (hits && hits.length === 1)
564
+ return hits[0];
565
+ if (hits && hits.length > 1)
566
+ break; // ambiguous at the most specific level — do not guess
567
+ }
568
+ return fqn;
569
+ }
570
+ /**
571
+ * Resolve a Rust `crate`-relative module path (`crate/a/b`, from `use crate::a::b::Item`)
572
+ * to the in-repo module file — `<crate root>/a/b.rs` or `<crate root>/a/b/mod.rs`, where
573
+ * the crate root is the `lib.rs`/`main.rs` directory the importing file lives under. The
574
+ * per-file crate root keeps a multi-crate workspace unambiguous. Not found or ambiguous
575
+ * (two roots, both `a/b.rs` and `a/b/mod.rs`) stays a `crate::…` string — never a guess.
576
+ */
577
+ function resolveRustUse(spec, file, byId, crateRoots) {
578
+ const full = spec.replace(/^crate\/?/, ""); // "crate/a/b/Item" → "a/b/Item"; "crate" → ""
579
+ const fpath = toPosixPath(file);
580
+ // the crate this file belongs to: the longest root that contains it (workspace-safe)
581
+ const owning = crateRoots
582
+ .filter((r) => r === "" ? true : fpath === r || fpath.startsWith(`${r}/`))
583
+ .sort((a, b) => b.length - a.length);
584
+ // No owning crate root (e.g. an integration test under `tests/`, whose `crate::` is the
585
+ // TEST binary's own root, not a lib) → do NOT search every crate in a workspace: that
586
+ // resolves `crate::util` to some unrelated crate's util.rs. Keep it a string instead.
587
+ if (owning.length === 0)
588
+ return full === "" ? "crate" : `crate::${full.replace(/\//g, "::")}`;
589
+ const roots = [owning[0]];
590
+ const segs = full === "" ? [] : full.split("/");
591
+ const hitsFor = (rels) => {
592
+ const hits = new Set();
593
+ for (const r of roots)
594
+ for (const rel of rels) {
595
+ const cand = r === "" ? rel : `${r}/${rel}`;
596
+ if (byId.has(cand))
597
+ hits.add(cand);
598
+ }
599
+ return hits;
600
+ };
601
+ // Try the longest module prefix first, shrinking toward — but NOT past — the first
602
+ // segment. `crate::a::b::C` resolves as module `a/b` (C is the item); `crate::net` as
603
+ // module `net`. The first prefix naming exactly one in-repo file wins; two matches at a
604
+ // level are ambiguous → drop rather than guess.
605
+ for (let k = segs.length; k >= 1; k--) {
606
+ const modPath = segs.slice(0, k).join("/");
607
+ const hits = hitsFor([`${modPath}.rs`, `${modPath}/mod.rs`]);
608
+ if (hits.size === 1)
609
+ return [...hits][0];
610
+ if (hits.size > 1)
611
+ break;
612
+ }
613
+ // The crate root (`lib.rs`/`main.rs`) is a target ONLY for `use crate::Item` or
614
+ // `use crate::{…}` — a deeper path whose module chain didn't resolve is genuinely
615
+ // unknown (a re-export, an inline `mod`, or out-of-tree), so keep it as a string.
616
+ if (segs.length <= 1) {
617
+ const hits = hitsFor(["lib.rs", "main.rs"]);
618
+ if (hits.size === 1)
619
+ return [...hits][0];
620
+ }
621
+ return full === "" ? "crate" : `crate::${full.replace(/\//g, "::")}`;
622
+ }
623
+ /**
624
+ * Resolve a Go import package path to an in-repo file node when it points inside one of
625
+ * the repo's modules; otherwise return the raw specifier (stdlib or third-party package).
626
+ *
627
+ * Go imports name a *package* (a directory), not a file. The package path is relative to
628
+ * the owning module's path, so the in-repo directory is `<module go.mod dir>/<subpath>`.
629
+ * This handles a `go.mod` anywhere in the tree — repo root or a subdirectory (monorepo).
630
+ * When several modules' paths prefix the spec, the longest (most specific) wins. A package
631
+ * dir may hold several `.go` files; we pick a deterministic representative (lowest id).
632
+ */
633
+ function resolveGoImport(spec, modules, filesByDir) {
634
+ let best = null;
635
+ for (const mod of modules) {
636
+ let subpath = null;
637
+ if (spec === mod.module)
638
+ subpath = "";
639
+ else if (spec.startsWith(mod.module + "/"))
640
+ subpath = spec.slice(mod.module.length + 1);
641
+ if (subpath === null)
642
+ continue;
643
+ if (!best || mod.module.length > best.mod.module.length)
644
+ best = { mod, subpath };
645
+ }
646
+ if (!best)
647
+ return spec; // stdlib / third-party — keep the package path
648
+ const dir = posix.normalize(posix.join(best.mod.dir, best.subpath));
649
+ const files = filesByDir.get(dir);
650
+ if (!files || files.length === 0)
651
+ return spec;
652
+ return [...files].sort()[0];
653
+ }
654
+ //# sourceMappingURL=resolve.js.map