scip-query 0.19.8 → 0.19.10

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 (365) hide show
  1. package/CHANGELOG.md +79 -0
  2. package/README.md +132 -33
  3. package/dist/augment-vue-worker.js +1 -1
  4. package/dist/chunk-26QA6FAI.js +8 -0
  5. package/dist/{chunk-KJ2IIBZN.js → chunk-2HPVVXM5.js} +2 -2
  6. package/dist/chunk-2KAZEZ6M.js +2 -0
  7. package/dist/chunk-32LVLCLN.js +40 -0
  8. package/dist/{chunk-24GTWJ3N.js → chunk-3CLX5EOX.js} +2 -2
  9. package/dist/{chunk-QGGLL3UH.js → chunk-3G66UZBH.js} +2 -2
  10. package/dist/{chunk-AA4UWRNL.js → chunk-3ORVDL3H.js} +2 -2
  11. package/dist/chunk-4MAK2HOY.js +6 -0
  12. package/dist/{chunk-QIQ63BHW.js → chunk-4TURLRL5.js} +2 -2
  13. package/dist/chunk-4UQVNCQE.js +2 -0
  14. package/dist/chunk-55Q3WLZX.js +2 -0
  15. package/dist/{chunk-CTF2GDEX.js → chunk-5E4WNAVD.js} +2 -2
  16. package/dist/{chunk-ZCEJ63SP.js → chunk-5I5G2QOX.js} +2 -2
  17. package/dist/chunk-6LDJQXAH.js +2 -0
  18. package/dist/{chunk-3EDFLQ6A.js → chunk-6O5TICIZ.js} +2 -2
  19. package/dist/{chunk-ACAM6O5R.js → chunk-6SHPK5ZE.js} +2 -2
  20. package/dist/chunk-7BAVHKMJ.js +49 -0
  21. package/dist/chunk-7O5IKBTZ.js +16 -0
  22. package/dist/{chunk-WJL2L6MV.js → chunk-7PIO7NKH.js} +2 -2
  23. package/dist/chunk-7S5E7KWT.js +2 -0
  24. package/dist/{chunk-YLFORA5G.js → chunk-7SQQWSY3.js} +2 -2
  25. package/dist/chunk-7WPLAODU.js +5 -0
  26. package/dist/chunk-A73XVBCR.js +20 -0
  27. package/dist/chunk-AFHORGLH.js +42 -0
  28. package/dist/chunk-AIE7TFJW.js +9 -0
  29. package/dist/{chunk-TWMJ3Y3G.js → chunk-AZJQQKDD.js} +2 -2
  30. package/dist/{chunk-BDOIKGDI.js → chunk-B2PX5I6M.js} +2 -2
  31. package/dist/{chunk-DQBCO2UY.js → chunk-B7PBSLZN.js} +2 -2
  32. package/dist/chunk-BBW6JFHN.js +2 -0
  33. package/dist/{chunk-YTVWB7YJ.js → chunk-BDCC2NPY.js} +2 -2
  34. package/dist/{chunk-O23I56NA.js → chunk-BNXCIFVY.js} +2 -2
  35. package/dist/{chunk-MLFZP76A.js → chunk-BPAPWKP6.js} +2 -2
  36. package/dist/chunk-BS2NMXQZ.js +4 -0
  37. package/dist/chunk-C3KV2II6.js +2 -0
  38. package/dist/chunk-C43RDDP4.js +20 -0
  39. package/dist/{chunk-K2WO7XY7.js → chunk-CJST5ETY.js} +2 -2
  40. package/dist/chunk-DAFAHMNB.js +42 -0
  41. package/dist/{chunk-KKME5ZAI.js → chunk-DQGFVPUV.js} +2 -2
  42. package/dist/chunk-DQLPXMH6.js +8 -0
  43. package/dist/chunk-EKZTZXHZ.js +117 -0
  44. package/dist/{chunk-FJ5UDTQF.js → chunk-EN3O7VJA.js} +2 -2
  45. package/dist/{chunk-HZYDQPNY.js → chunk-EW2NTSFA.js} +2 -2
  46. package/dist/chunk-F3Z4OUDS.js +8 -0
  47. package/dist/chunk-FJH2NW7J.js +66 -0
  48. package/dist/{chunk-MSBDMFER.js → chunk-FKSELJQF.js} +2 -2
  49. package/dist/chunk-FTFP6O3L.js +11 -0
  50. package/dist/chunk-FYLK2DEJ.js +2 -0
  51. package/dist/{chunk-WUW7YUAH.js → chunk-GH74ASD6.js} +2 -2
  52. package/dist/{chunk-464PLI5O.js → chunk-GMXWZP2B.js} +2 -2
  53. package/dist/chunk-GOUBFH5O.js +3 -0
  54. package/dist/{chunk-FIJCV235.js → chunk-HLF2TX6R.js} +2 -2
  55. package/dist/{chunk-WWKWUPSU.js → chunk-HX4GQPZP.js} +2 -2
  56. package/dist/chunk-HX7M4BDI.js +30 -0
  57. package/dist/chunk-HZ72SESS.js +128 -0
  58. package/dist/{chunk-SERUIGV5.js → chunk-IB2N4FIY.js} +2 -2
  59. package/dist/chunk-ILMHV3KM.js +2 -0
  60. package/dist/chunk-IZYYAFN5.js +2 -0
  61. package/dist/{chunk-GNC4JVAN.js → chunk-JAYYFEQY.js} +2 -2
  62. package/dist/{chunk-QJIVBYEK.js → chunk-JDOEX4E6.js} +2 -2
  63. package/dist/chunk-JFGGXWQF.js +947 -0
  64. package/dist/chunk-JN4NMBEX.js +8 -0
  65. package/dist/{chunk-6M7RONVB.js → chunk-JVYA47YU.js} +2 -2
  66. package/dist/{chunk-7KYNAMMH.js → chunk-JW56N3KI.js} +2 -2
  67. package/dist/{chunk-OUBAF226.js → chunk-JZ2OXNWB.js} +2 -2
  68. package/dist/chunk-KMKTIO2G.js +8 -0
  69. package/dist/chunk-L5GJNV2T.js +8 -0
  70. package/dist/{chunk-MNSTUIDD.js → chunk-L7AW2QB5.js} +2 -2
  71. package/dist/chunk-L7JDSCDF.js +4 -0
  72. package/dist/chunk-LU47HG23.js +14 -0
  73. package/dist/chunk-LVY7NPF7.js +2 -0
  74. package/dist/chunk-LY4WC4AD.js +74 -0
  75. package/dist/{chunk-7FT5Y65S.js → chunk-MKCDWWGV.js} +2 -2
  76. package/dist/chunk-MNE7YG56.js +2 -0
  77. package/dist/{chunk-7QHY3H7P.js → chunk-MRXBEXSY.js} +2 -2
  78. package/dist/chunk-MV7OWDUX.js +2 -0
  79. package/dist/{chunk-ZJ5CBXK3.js → chunk-N5W4YZMK.js} +2 -2
  80. package/dist/chunk-NGEXCJJW.js +11 -0
  81. package/dist/{chunk-7SWJEWJF.js → chunk-NIW6JDC5.js} +2 -2
  82. package/dist/{chunk-O3O4XXO6.js → chunk-O64IZ6UX.js} +2 -2
  83. package/dist/{chunk-3ZSJ3PWF.js → chunk-PBUQFCNB.js} +2 -2
  84. package/dist/{chunk-7RAG65VK.js → chunk-POAVPHH7.js} +2 -2
  85. package/dist/{chunk-A3QXWFBK.js → chunk-PQCI4SQX.js} +2 -2
  86. package/dist/{chunk-4BV4QAZJ.js → chunk-PXY7F6Y4.js} +2 -2
  87. package/dist/chunk-RDO52JGY.js +2 -0
  88. package/dist/chunk-RJT3TUUZ.js +2 -0
  89. package/dist/{chunk-S4S2WOIX.js → chunk-RUJURYSV.js} +2 -2
  90. package/dist/{chunk-JAY7YWS3.js → chunk-RVLDN63O.js} +2 -2
  91. package/dist/chunk-RXOXSKY3.js +2 -0
  92. package/dist/chunk-S7OYBOCK.js +2 -0
  93. package/dist/chunk-SMNXQT5Z.js +3 -0
  94. package/dist/{chunk-NE3TZUCI.js → chunk-SRAFT254.js} +2 -2
  95. package/dist/{chunk-ELLMY7XJ.js → chunk-SXP2MBJH.js} +2 -2
  96. package/dist/chunk-T7YQSHPQ.js +3 -0
  97. package/dist/{chunk-WY45BHKQ.js → chunk-TFRAYKN6.js} +2 -2
  98. package/dist/{chunk-2SNGN6U4.js → chunk-UJCOIXDY.js} +2 -2
  99. package/dist/{chunk-MZZBAITE.js → chunk-UJPRPGCO.js} +2 -2
  100. package/dist/chunk-W4ETQAXM.js +2 -0
  101. package/dist/chunk-WCCFZ7V7.js +113 -0
  102. package/dist/chunk-WUPW3UN3.js +3 -0
  103. package/dist/{chunk-7LSVMFX7.js → chunk-WXZLAAWK.js} +2 -2
  104. package/dist/{chunk-5ML2BNRH.js → chunk-X54AGLVX.js} +2 -2
  105. package/dist/chunk-XKWKXZKW.js +20 -0
  106. package/dist/{chunk-5YLUDDAF.js → chunk-XSRF6Q77.js} +2 -2
  107. package/dist/chunk-Y2MVPNKY.js +5 -0
  108. package/dist/{chunk-JHF3E4YM.js → chunk-YKUU5AIC.js} +2 -2
  109. package/dist/{chunk-E3HYEQO7.js → chunk-YLCJLTPL.js} +2 -2
  110. package/dist/{chunk-7VCOXZH3.js → chunk-YTQVETEO.js} +2 -2
  111. package/dist/chunk-Z4N3MZYA.js +38 -0
  112. package/dist/chunk-ZHXX42OH.js +18 -0
  113. package/dist/chunk-ZJOOT3BG.js +2 -0
  114. package/dist/{chunk-P3UO3EH3.js → chunk-ZK26BAQL.js} +2 -2
  115. package/dist/{chunk-33KUO7CG.js → chunk-ZTETIQ35.js} +2 -2
  116. package/dist/cli.js +3 -8
  117. package/dist/command-descriptors-4A4HWV4F.js +642 -0
  118. package/dist/{config-types-B6MEoRNy.d.ts → config-types-jVM3D7MA.d.ts} +68 -2
  119. package/dist/{db-DYLKr9Wn.d.ts → db-B5PM5yNk.d.ts} +20 -2
  120. package/dist/{diff-gate-types-C9BoYwYD.d.ts → diff-gate-types-B0QYpDv1.d.ts} +2 -1
  121. package/dist/direct-navigation-6YHV6IB5.js +3 -0
  122. package/dist/{health-DgxIDXJC.d.ts → health-Do5TKSJI.d.ts} +1 -1
  123. package/dist/index.d.ts +3 -3
  124. package/dist/index.js +1 -1
  125. package/dist/queries/affected.d.ts +2 -2
  126. package/dist/queries/affected.js +1 -1
  127. package/dist/queries/architecture.d.ts +2 -2
  128. package/dist/queries/architecture.js +1 -1
  129. package/dist/queries/bottlenecks.d.ts +2 -2
  130. package/dist/queries/bottlenecks.js +1 -1
  131. package/dist/queries/by-kind.d.ts +2 -2
  132. package/dist/queries/by-kind.js +1 -1
  133. package/dist/queries/call-graph.d.ts +2 -2
  134. package/dist/queries/call-graph.js +1 -1
  135. package/dist/queries/change-surface.d.ts +22 -3
  136. package/dist/queries/change-surface.js +1 -1
  137. package/dist/queries/cleanup-plan.d.ts +2 -2
  138. package/dist/queries/cleanup-plan.js +1 -1
  139. package/dist/queries/co-change.d.ts +2 -2
  140. package/dist/queries/co-change.js +1 -1
  141. package/dist/queries/code.d.ts +2 -2
  142. package/dist/queries/code.js +1 -1
  143. package/dist/queries/complexity-hotspots.d.ts +3 -3
  144. package/dist/queries/complexity-hotspots.js +1 -1
  145. package/dist/queries/complexity.d.ts +3 -3
  146. package/dist/queries/complexity.js +1 -1
  147. package/dist/queries/convergence.d.ts +2 -2
  148. package/dist/queries/convergence.js +1 -1
  149. package/dist/queries/coupling.d.ts +2 -2
  150. package/dist/queries/coupling.js +1 -1
  151. package/dist/queries/cycles.d.ts +2 -2
  152. package/dist/queries/cycles.js +1 -1
  153. package/dist/queries/dataflow.d.ts +2 -2
  154. package/dist/queries/dataflow.js +1 -1
  155. package/dist/queries/dead.d.ts +2 -2
  156. package/dist/queries/dead.js +1 -1
  157. package/dist/queries/decorative-checkers.d.ts +2 -2
  158. package/dist/queries/decorative-checkers.js +1 -1
  159. package/dist/queries/deep-chains.d.ts +2 -2
  160. package/dist/queries/deep-chains.js +1 -1
  161. package/dist/queries/deps.d.ts +2 -2
  162. package/dist/queries/deps.js +1 -1
  163. package/dist/queries/diff-gate.d.ts +40 -7
  164. package/dist/queries/diff-gate.js +1 -1
  165. package/dist/queries/diff-impact.d.ts +84 -6
  166. package/dist/queries/diff-impact.js +1 -1
  167. package/dist/queries/doc-drift.d.ts +3 -3
  168. package/dist/queries/doc-drift.js +1 -1
  169. package/dist/queries/drift.d.ts +2 -2
  170. package/dist/queries/drift.js +1 -1
  171. package/dist/queries/duplicate-bodies.d.ts +3 -3
  172. package/dist/queries/duplicate-bodies.js +1 -1
  173. package/dist/queries/extract-candidates.d.ts +2 -2
  174. package/dist/queries/extract-candidates.js +1 -1
  175. package/dist/queries/fan.d.ts +2 -2
  176. package/dist/queries/fan.js +1 -1
  177. package/dist/queries/files.d.ts +12 -3
  178. package/dist/queries/files.js +1 -1
  179. package/dist/queries/health.d.ts +3 -3
  180. package/dist/queries/health.js +1 -1
  181. package/dist/queries/hierarchy.d.ts +2 -2
  182. package/dist/queries/hierarchy.js +1 -1
  183. package/dist/queries/hotspots.d.ts +2 -2
  184. package/dist/queries/hotspots.js +1 -1
  185. package/dist/queries/imports.d.ts +2 -2
  186. package/dist/queries/imports.js +1 -1
  187. package/dist/queries/incomplete-migration.d.ts +8 -6
  188. package/dist/queries/incomplete-migration.js +1 -1
  189. package/dist/queries/index.d.ts +141 -10
  190. package/dist/queries/index.js +1 -1
  191. package/dist/queries/isolated.d.ts +2 -2
  192. package/dist/queries/isolated.js +1 -1
  193. package/dist/queries/locality-candidates.d.ts +2 -2
  194. package/dist/queries/locality-candidates.js +1 -1
  195. package/dist/queries/members.d.ts +2 -2
  196. package/dist/queries/members.js +1 -1
  197. package/dist/queries/methods.d.ts +34 -3
  198. package/dist/queries/methods.js +1 -1
  199. package/dist/queries/not-implemented.d.ts +2 -2
  200. package/dist/queries/not-implemented.js +1 -1
  201. package/dist/queries/outline.d.ts +2 -2
  202. package/dist/queries/outline.js +1 -1
  203. package/dist/queries/passthrough-candidates.d.ts +3 -3
  204. package/dist/queries/passthrough-candidates.js +1 -1
  205. package/dist/queries/plan-context.d.ts +3 -3
  206. package/dist/queries/plan-context.js +1 -1
  207. package/dist/queries/react-component-duplicates.d.ts +2 -2
  208. package/dist/queries/react-component-duplicates.js +1 -1
  209. package/dist/queries/react-hook-candidates.d.ts +2 -2
  210. package/dist/queries/react-hook-candidates.js +1 -1
  211. package/dist/queries/react-large-component-pressure.d.ts +2 -2
  212. package/dist/queries/react-large-component-pressure.js +1 -1
  213. package/dist/queries/recent-duplicates.d.ts +2 -2
  214. package/dist/queries/recent-duplicates.js +1 -1
  215. package/dist/queries/redundant-reexports.d.ts +2 -2
  216. package/dist/queries/redundant-reexports.js +1 -1
  217. package/dist/queries/refs.d.ts +2 -2
  218. package/dist/queries/refs.js +1 -1
  219. package/dist/queries/self-audit.d.ts +2 -2
  220. package/dist/queries/self-audit.js +1 -1
  221. package/dist/queries/similar-chains.d.ts +2 -2
  222. package/dist/queries/similar-chains.js +1 -1
  223. package/dist/queries/similar-files.d.ts +2 -2
  224. package/dist/queries/similar-files.js +1 -1
  225. package/dist/queries/similar-signatures.d.ts +2 -2
  226. package/dist/queries/similar-signatures.js +1 -1
  227. package/dist/queries/similar.d.ts +2 -2
  228. package/dist/queries/similar.js +1 -1
  229. package/dist/queries/slice.d.ts +2 -2
  230. package/dist/queries/slice.js +1 -1
  231. package/dist/queries/stale-abstractions.d.ts +2 -2
  232. package/dist/queries/stale-abstractions.js +1 -1
  233. package/dist/queries/stats.d.ts +2 -2
  234. package/dist/queries/surface.d.ts +2 -2
  235. package/dist/queries/surface.js +1 -1
  236. package/dist/queries/symbols.d.ts +2 -2
  237. package/dist/queries/symbols.js +1 -1
  238. package/dist/queries/system.d.ts +2 -2
  239. package/dist/queries/system.js +1 -1
  240. package/dist/queries/test-quality.d.ts +2 -2
  241. package/dist/queries/test-quality.js +1 -1
  242. package/dist/queries/trace.d.ts +2 -2
  243. package/dist/queries/trace.js +1 -1
  244. package/dist/queries/twin-ab.d.ts +14 -3
  245. package/dist/queries/twin-ab.js +1 -1
  246. package/dist/queries/twin-drift.d.ts +2 -2
  247. package/dist/queries/twin-drift.js +1 -1
  248. package/dist/queries/unused-imports.d.ts +2 -2
  249. package/dist/queries/unused-imports.js +1 -1
  250. package/dist/queries/unused-params.d.ts +2 -2
  251. package/dist/queries/unused-params.js +1 -1
  252. package/dist/queries/vue-component-duplicates.d.ts +2 -2
  253. package/dist/queries/vue-component-duplicates.js +1 -1
  254. package/dist/queries/vue-composable-candidates.d.ts +2 -2
  255. package/dist/queries/vue-composable-candidates.js +1 -1
  256. package/dist/queries/vue-large-view-pressure.d.ts +2 -2
  257. package/dist/queries/vue-large-view-pressure.js +1 -1
  258. package/dist/queries/wrapper-candidates.d.ts +2 -2
  259. package/dist/queries/wrapper-candidates.js +1 -1
  260. package/dist/reindex-worker.js +21 -21
  261. package/dist/reindex.d.ts +3 -3
  262. package/dist/reindex.js +33 -33
  263. package/dist/runtime.d.ts +5 -3
  264. package/dist/runtime.js +3 -3
  265. package/dist/rust-semantic-session-server.js +1 -1
  266. package/dist/rust-semantic-session-worker.js +1 -1
  267. package/dist/rust-semantic-worker.js +1 -1
  268. package/dist/{scip-cli-Cc6c00-a.d.ts → scip-cli-BnEwZRLJ.d.ts} +1 -1
  269. package/dist/{symbol-types-BgWU6lhL.d.ts → symbol-types-BIQwfoAx.d.ts} +7 -1
  270. package/dist/typescript-mailbox-worker.js +2 -0
  271. package/dist/watch-server.js +2 -42
  272. package/docs/AGENT_GUIDE.md +13 -6
  273. package/docs/CLI_JSON_OUTPUT.md +110 -22
  274. package/docs/COMMAND_REFERENCE.md +88 -88
  275. package/docs/COMMITTED_RECORD_COMPATIBILITY.md +55 -18
  276. package/docs/DURABILITY.md +88 -38
  277. package/docs/INDEX_GENERATIONS.md +65 -19
  278. package/docs/MAILBOX_LIFECYCLE.md +28 -1
  279. package/docs/REINDEX_METADATA_COMPATIBILITY.md +18 -8
  280. package/docs/SECURITY_MODEL.md +31 -14
  281. package/docs/TELEMETRY_RETENTION.md +11 -4
  282. package/docs/WATCH_REFRESH_REQUESTS.md +34 -21
  283. package/docs/WINDOWS_SIDECAR_RELEASE.md +9 -4
  284. package/docs/analyzer-inventory.md +31 -22
  285. package/docs/analyzer-validation-ledger.md +8 -0
  286. package/docs/schemas/outcome-event-record.schema.json +57 -1
  287. package/docs/schemas/project-config.schema.json +82 -1
  288. package/docs/schemas/suppression-record.schema.json +84 -3
  289. package/package.json +2 -2
  290. package/skills/_shared/SKILL.md +2 -2
  291. package/skills/_shared/references/agent-contract-catalog.md +1 -1
  292. package/skills/_shared/references/detector-precision-and-diffgate.md +1 -1
  293. package/skills/scip-audit/SKILL.md +6 -6
  294. package/skills/scip-audit/references/claims.md +1 -1
  295. package/skills/scip-audit/references/cleanup.md +19 -20
  296. package/skills/scip-audit/references/directory.md +4 -4
  297. package/skills/scip-audit/references/frontend.md +10 -10
  298. package/skills/scip-audit/references/twin-drift.md +2 -2
  299. package/skills/scip-diagnose/references/debug.md +8 -8
  300. package/skills/scip-diagnose/references/root-cause.md +3 -3
  301. package/skills/scip-diagnose/references/triage.md +10 -10
  302. package/skills/scip-explore/SKILL.md +3 -3
  303. package/skills/scip-improve/SKILL.md +10 -10
  304. package/skills/scip-improve/references/cleanup-batches.md +3 -3
  305. package/skills/scip-improve/references/directory-moves.md +3 -3
  306. package/skills/scip-improve/references/doc-reconcile.md +1 -1
  307. package/skills/scip-improve/references/frontend-extraction.md +2 -2
  308. package/skills/scip-improve/references/twin-drift.md +3 -3
  309. package/skills/scip-plan/SKILL.md +2 -2
  310. package/skills/scip-plan/references/api-impact.md +5 -5
  311. package/skills/scip-plan/references/conductor.md +2 -2
  312. package/skills/scip-plan/references/hyper-optimization.md +1 -1
  313. package/skills/scip-query/SKILL.md +15 -5
  314. package/skills/scip-setup/references/bootstrap-workflow.md +7 -8
  315. package/skills/scip-setup/references/language-verification.md +2 -2
  316. package/skills/scip-setup/references/per-repo-triage.md +1 -1
  317. package/skills/scip-verify/SKILL.md +10 -10
  318. package/skills/scip-verify/references/calibrate-detectors.md +7 -7
  319. package/dist/chunk-2465DLHK.js +0 -3
  320. package/dist/chunk-2U3OLUNJ.js +0 -61
  321. package/dist/chunk-33XTHFKR.js +0 -2
  322. package/dist/chunk-43KC6EQZ.js +0 -2
  323. package/dist/chunk-47BU5Z4T.js +0 -8
  324. package/dist/chunk-4YTUWQ6M.js +0 -18
  325. package/dist/chunk-64MNV6AB.js +0 -8
  326. package/dist/chunk-67QRR5YC.js +0 -6
  327. package/dist/chunk-6GXYN7YA.js +0 -40
  328. package/dist/chunk-A2TNXAXO.js +0 -8
  329. package/dist/chunk-APMMR5Y2.js +0 -2
  330. package/dist/chunk-AZFUMCQB.js +0 -2
  331. package/dist/chunk-BNXICU42.js +0 -33
  332. package/dist/chunk-C5Q44Q5D.js +0 -3
  333. package/dist/chunk-DQGSM7RZ.js +0 -20
  334. package/dist/chunk-E2LAW7SL.js +0 -30
  335. package/dist/chunk-E4NFOAD4.js +0 -6
  336. package/dist/chunk-E5HNT4X2.js +0 -3
  337. package/dist/chunk-FD3HFKXR.js +0 -5
  338. package/dist/chunk-GHKEJTCE.js +0 -35
  339. package/dist/chunk-GLZTVKAB.js +0 -16
  340. package/dist/chunk-HIB452NU.js +0 -949
  341. package/dist/chunk-IF6FP6B2.js +0 -66
  342. package/dist/chunk-JORHF5AL.js +0 -108
  343. package/dist/chunk-KSGTULOS.js +0 -9
  344. package/dist/chunk-KXDJAG4N.js +0 -38
  345. package/dist/chunk-L4S2A7BV.js +0 -2
  346. package/dist/chunk-LP3ARJKF.js +0 -8
  347. package/dist/chunk-LSOR3LQG.js +0 -3
  348. package/dist/chunk-NTUMF2X3.js +0 -56
  349. package/dist/chunk-QOXBSI6G.js +0 -20
  350. package/dist/chunk-QXK6UUSM.js +0 -2
  351. package/dist/chunk-RA3AYNWP.js +0 -112
  352. package/dist/chunk-RJMDJR3A.js +0 -2
  353. package/dist/chunk-RLH5VUMG.js +0 -2
  354. package/dist/chunk-SMQWE25B.js +0 -3
  355. package/dist/chunk-TAVELHYR.js +0 -2
  356. package/dist/chunk-VAXNI5NE.js +0 -146
  357. package/dist/chunk-VVY2G5ET.js +0 -2
  358. package/dist/chunk-W3DBTGL4.js +0 -11
  359. package/dist/chunk-WANA4KAQ.js +0 -5
  360. package/dist/chunk-X4FR5BZF.js +0 -9
  361. package/dist/chunk-X6RKPDY7.js +0 -2
  362. package/dist/chunk-YCPASUCX.js +0 -2
  363. package/dist/chunk-ZL2OGDCD.js +0 -2
  364. package/dist/command-descriptors-ZW5J4ZEM.js +0 -631
  365. package/dist/direct-navigation-42YHQPOI.js +0 -3
@@ -1,8 +0,0 @@
1
- import{a as T,c as E,g as L,h as D}from"./chunk-4YTUWQ6M.js";import{j as O,o as A}from"./chunk-WANA4KAQ.js";import{d as H}from"./chunk-KMVGRIO2.js";import{c as _}from"./chunk-2SNGN6U4.js";import{d as C,e as F}from"./chunk-RA3AYNWP.js";import{a as w}from"./chunk-MZZBAITE.js";var J=5;function ae(e,t={}){let{base:a="HEAD",minContainment:o=.7,minCallees:r=3,minSiteCoverage:n=.4,maxHelpers:c=Number.POSITIVE_INFINITY,limit:m=20,scanLimit:g}=t,f=t.semantic!==!1,s=t.diffPlan??E(e,{base:a}),l={available:s.note!==T,base:a,changedFiles:s.changedFiles,helpersChecked:0,skipped:[],findings:[]};if(!l.available||s.changedFiles.length===0)return l;let x=new _(e),k=new Set(s.changedFiles),$=new Map(s.renamedFiles.map(i=>[i.to,i.from])),j=t.baseContentAt??L(e.config.projectRoot,a,D(s)),h=Z(x,k,$,j);if(h.length===0)return l;let R=h.slice(0,c);h.length>c&&(l.note=`helper scoring capped at ${c} of ${h.length} new symbols`);let q=x.calleeMap(R,{semantic:f}),B=R.map(i=>({def:i,callees:A((q.get(i.symbolId)??[]).map(p=>p.symbol))})),V=O(e),M,G=()=>(M??=V.calleeIndex({minCallees:Math.min(3,r),scanLimit:g,semantic:f}),M);for(let{def:i,callees:p}of B){let d=C(i.symbol);if(p.size<r){l.skipped.push({helperShortName:d,helperFile:i.relativePath,reason:`fewer than ${r} meaningful callees \u2014 too small to score`});continue}let P=G(),N=Y(p,P);if(N===0){l.skipped.push({helperShortName:d,helperFile:i.relativePath,reason:"helper callee pattern is all project-wide infrastructure \u2014 too generic to score"});continue}let b=Q(e,i.symbolId);if(b.length===0){l.skipped.push({helperShortName:d,helperFile:i.relativePath,reason:"no references yet \u2014 covered by the new-dead check"});continue}l.helpersChecked+=1;let I=K({candidateIndex:P,changed:k,helperCallees:p,helperFile:i.relativePath,helperSymbol:i.symbol,minContainment:o,minSiteCoverage:n,migratedFiles:b});I.length!==0&&(I.sort((u,S)=>z(S.migrationScope)-z(u.migrationScope)||S.containment-u.containment||S.siteCoverage-u.siteCoverage||u.file.localeCompare(S.file)),l.findings.push({helperSymbol:i.symbol,helperShortName:d,helperFile:i.relativePath,helperShape:"specific-callee-cluster",helperCalleeCount:p.size,specificHelperCalleeCount:N,migratedFiles:b.sort(),leftovers:I.slice(0,J)}))}return l.findings.sort((i,p)=>(p.leftovers[0]?.containment??0)-(i.leftovers[0]?.containment??0)||i.helperFile.localeCompare(p.helperFile)),l.findings=l.findings.slice(0,m),l}function K(e){let t=[],a=U(e.helperSymbol,e.helperFile,e.migratedFiles),o=new Set;for(let r of e.helperCallees)for(let n of e.candidateIndex.candidateIndexesByCallee.get(r)??[])o.add(n);for(let r of o){let n=e.candidateIndex.corpus[r];if(n.symbol===e.helperSymbol||e.changed.has(n.file)||n.callees.has(e.helperSymbol))continue;let c=H(e.helperCallees,n.callees);if(c<e.minContainment)continue;let m=[...e.helperCallees].filter(s=>n.callees.has(s)),g=n.callees.size===0?0:m.length/n.callees.size;if(g<e.minSiteCoverage||!m.some(s=>(e.candidateIndex.docFreq.get(s)??0)<=e.candidateIndex.ubiquityThreshold))continue;let f=W(a,n.symbol,n.file);t.push({symbol:n.symbol,shortName:C(n.symbol),file:n.file,...f,containment:c,siteCoverage:g,uniqueSiteCalleeCount:Math.max(0,n.callees.size-m.length),sharedCallees:m.map(C).sort()})}return t}function z(e){return e==="same-scope"?2:e==="unknown"?1:0}function U(e,t,a){let o=new Set([...y(t),...v(F(e))]);for(let r of a)for(let n of y(r))o.add(n);return o}function W(e,t,a){let o=new Set([...y(a),...v(F(t))]);if(e.size===0||o.size===0)return{migrationScope:"unknown",migrationScopeReasons:["insufficient path/name tokens to infer migration scope"]};let r=[...o].filter(n=>e.has(n)).sort();return r.length>0?{migrationScope:"same-scope",migrationScopeReasons:[`shares migration-scope token(s): ${r.slice(0,5).join(", ")}`]}:{migrationScope:"possible-subtype",migrationScopeReasons:["no path/name tokens shared with the helper or already migrated files"]}}var X=new Set(["app","apps","common","component","components","helper","helpers","index","lib","package","packages","page","pages","route","routes","service","services","shared","spec","src","test","tests","util","utils"]);function y(e){return v(e.replace(/\.[^.]+$/,""))}function v(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").toLowerCase().split(/[^a-z0-9]+/).filter(t=>t.length>1&&!X.has(t))}function Y(e,t){let a=0;for(let o of e)(t.docFreq.get(o)??0)<=t.ubiquityThreshold&&(a+=1);return a}function Z(e,t,a,o){return e.productionCallableDefinitions({files:[...t],requireFunctionLikeSymbol:!0}).filter(r=>{if(!t.has(r.relativePath))return!1;let n=a.get(r.relativePath)??r.relativePath,c=o(n);return c===null||!new RegExp(`\\b${w(r.leaf)}\\b`).test(c)})}function Q(e,t){return e.all(`SELECT DISTINCT ref_d.relative_path
2
- FROM mentions m
3
- JOIN chunks c ON m.chunk_id = c.id
4
- JOIN documents ref_d ON c.document_id = ref_d.id
5
- WHERE m.symbol_id = ?
6
- AND m.role != 1
7
- ${e.pathExclusionsFor("ref_d")}`,t).map(o=>o.relative_path)}export{ae as a};
8
- //# sourceMappingURL=chunk-47BU5Z4T.js.map
@@ -1,18 +0,0 @@
1
- import{a as A}from"./chunk-QOKYJ33H.js";import{a as _,c as B}from"./chunk-2SNGN6U4.js";import{l as v}from"./chunk-E2LAW7SL.js";import{n as y}from"./chunk-LSOR3LQG.js";import{d as M,g as b,i as N}from"./chunk-RA3AYNWP.js";import{A as x}from"./chunk-WUW7YUAH.js";import{J as w}from"./chunk-JORHF5AL.js";import{execFileSync as g}from"child_process";import{existsSync as q}from"fs";import{basename as P}from"path";var H="Unable to compute git diff.";function Ae(e,n={}){let i=n.plan??J(e,n);return i.note?V(i.note,i.changedFileLines):i.changedFiles.length===0?K(i.changedFileLines):Y(i.changedFiles,[Z(e,i.changedFiles,i.changedFiles,i.changedRanges)])}function J(e,n={}){let{base:i="HEAD"}=n;try{let t=y(e.config.projectRoot,i),r=Q(e.config.projectRoot,t),s=r.changedFileLines,a=se(e,s),o=oe(e,r.changedRanges);return{changedFileLines:s,changedFiles:a,changedRanges:o,renamedFiles:te(e.config.projectRoot,t,a,r),note:s.length===0?"No changed files found.":void 0}}catch{return{changedFileLines:[],changedFiles:[],changedRanges:[],renamedFiles:[],note:H}}}function Z(e,n,i,t=[]){let r=new B(e),s=new Set(i),a=A(t),o=[],c=new Map,u=n.flatMap(f=>r.definitionsForFile(f)).filter(Le),d=u.filter(f=>le(f,a)),l=de(e,u,d,a),m=me([...d,...l.definitions]).sort((f,h)=>f.relativePath.localeCompare(h.relativePath)||f.startLine-h.startLine),p=m.map(f=>f.symbolId),F=ye(e,p),G=be(e,p,i),I=m.filter(f=>(F.get(f.symbolId)??0)===0),R=$(()=>v(e,I)),j=I.filter(f=>(R.get(f.symbolId)?.size??0)===0),U=$(()=>_(e,j));for(let f of m)he(e,f,s,o,c,R.get(f.symbolId)??new Set,U.get(f.symbolId)??new Set,F.get(f.symbolId)??0,G.get(f.symbolId)??new Set);return{changedSymbols:o,consumerEntries:[...c.entries()].map(([f,h])=>({file:f,symbols:[...h].sort()})),attributionNotes:l.notes}}function Y(e,n){let i=new Map,t=n.flatMap(a=>a.changedSymbols),r=n.flatMap(a=>a.attributionNotes??[]);for(let a of n)for(let o of a.consumerEntries){let c=i.get(o.file);c||(c=new Set,i.set(o.file,c));for(let u of o.symbols)c.add(u)}let s=Se(i);return{changedFiles:[...e],changedSymbols:t,affectedConsumers:s,attributionNotes:r,summary:{totalChangedFiles:e.length,totalChangedSymbols:t.length,totalAffectedFiles:s.length}}}function V(e,n=[]){return{changedFiles:n,changedSymbols:[],affectedConsumers:[],attributionNotes:[],summary:{totalChangedFiles:n.length,totalChangedSymbols:0,totalAffectedFiles:0,note:e}}}function K(e){return{changedFiles:e,changedSymbols:[],affectedConsumers:[],attributionNotes:[],summary:{totalChangedFiles:e.length,totalChangedSymbols:0,totalAffectedFiles:0,note:"Changed files are not present in the current SCIP index."}}}function Q(e,n){let i=g("git",["diff","--name-status","--find-renames",n,"--"],{encoding:"utf-8",cwd:e,timeout:3e4,maxBuffer:67108864}),t=g("git",["diff","--name-status","--find-renames","--cached",n,"--"],{encoding:"utf-8",cwd:e,timeout:3e4,maxBuffer:64*1024*1024}),r=g("git",["ls-files","--others","--exclude-standard"],{encoding:"utf-8",cwd:e,timeout:3e4,maxBuffer:64*1024*1024}),s=g("git",["diff","--unified=0",n,"--"],{encoding:"utf-8",cwd:e,timeout:3e4,maxBuffer:64*1024*1024}),a=g("git",["diff","--unified=0","--cached",n,"--"],{encoding:"utf-8",cwd:e,timeout:3e4,maxBuffer:64*1024*1024}),o=ie([i,t]);return{changedFileLines:[...new Set([...o.changedFiles,...O(r)])],changedRanges:z([...T(s),...T(a)]),renamedFiles:o.renamedFiles,deletedFiles:o.deletedFiles}}function D(e,n,i){try{let t=y(e,n);return X(e,t,i)}catch{return null}}function X(e,n,i){try{return g("git",["show",`${n}:./${i}`],{encoding:"utf-8",cwd:e,timeout:1e4,stdio:["ignore","pipe","ignore"]})}catch{return null}}function Pe(e,n,i=[]){let t=ee(e,n,i);return r=>(t.has(r)||t.set(r,D(e,n,r)),t.get(r)??null)}function Ee(e,n=e.changedFiles){let i=new Map(e.renamedFiles.map(t=>[t.to,t.from]));return[...new Set(n.map(t=>i.get(t)??t))]}function ee(e,n,i){let t=[...new Set(i)],r=new Map;if(t.length===0)return r;try{let s=y(e,n),a=t.map(c=>`${s}:./${c}
2
- `).join(""),o=g("git",["cat-file","--batch"],{cwd:e,input:a,maxBuffer:256*1024*1024,timeout:1e4,stdio:["pipe","pipe","ignore"]});return ne(o,t)}catch{for(let s of t)r.set(s,D(e,n,s));return r}}function ne(e,n){let i=new Map,t=0;for(let r of n){let s=e.indexOf(10,t);if(s<0)throw new Error("git cat-file batch output ended before object header");let a=e.subarray(t,s).toString("utf-8");if(t=s+1,a.endsWith(" missing")){i.set(r,null);continue}let o=/^[0-9a-f]+ ([^ ]+) (\d+)$/.exec(a);if(!o)throw new Error(`unexpected git cat-file batch header: ${a}`);let[,c,u]=o,d=Number(u);if(!Number.isFinite(d)||d<0)throw new Error(`unexpected git cat-file batch size: ${a}`);if(t+d>e.length)throw new Error("git cat-file batch output ended before blob payload");let l=e.subarray(t,t+d);i.set(r,c==="blob"?l.toString("utf-8"):null),t+=d,e[t]===10&&(t+=1)}return i}function te(e,n,i,t){if(i.length===0)return[];let r=new Map,s=new Set;for(let o of t.renamedFiles)i.includes(o.to)&&(r.set(o.to,o),s.add(o.from));let a=t.deletedFiles;if(a.length===0)return[...r.values()].sort((o,c)=>o.to.localeCompare(c.to));for(let o of i){if(r.has(o)||!q(`${e}/${o}`))continue;let c=a.filter(l=>!s.has(l)).filter(l=>P(l)===P(o));if(c.length===0)continue;let u=w(e,o),d=c.map(l=>({from:l,to:o,similarity:re(D(e,n,l)??"",u)})).sort((l,m)=>m.similarity-l.similarity)[0];d&&d.similarity>=.45&&(r.set(o,d),s.add(d.from))}return[...r.values()].sort((o,c)=>o.to.localeCompare(c.to))}function ie(e){let n=new Set,i=new Map,t=new Set;for(let r of e.flatMap(s=>O(s))){let[s,a,o]=r.split(" ");if(!(!s||!a)){if(s.startsWith("R")&&o){n.add(o),i.set(o,{from:a,to:o,similarity:Number(s.slice(1))/100});continue}n.add(a),s.startsWith("D")&&t.add(a)}}return{changedFiles:[...n],renamedFiles:[...i.values()],deletedFiles:[...t]}}function re(e,n){let i=new Set(E(e)),t=new Set(E(n));if(i.size===0&&t.size===0)return 1;if(i.size===0||t.size===0)return 0;let r=0;for(let s of i)t.has(s)&&(r+=1);return 2*r/(i.size+t.size)}function E(e){return e.match(/[A-Za-z_$][\w$]*|[{}()[\].,]/g)??[]}function O(e){return e.split(`
3
- `).map(n=>n.trim()).filter(n=>n.length>0)}function se(e,n){let i=k(e),t=[];for(let r of n){let s=i(r);s&&!e.isIgnored(s)&&t.push(s)}return t}function oe(e,n){let i=k(e),t=[];for(let r of n){let s=i(r.file);s&&!e.isIgnored(s)&&t.push({...r,file:s})}return z(t)}function k(e){let n=e.all(`SELECT relative_path FROM documents
4
- ORDER BY id`).map(t=>t.relative_path),i=new Map(n.map(t=>[t,t]));return t=>{let r=t.replace(/\\/g,"/"),s=i.get(r);return s||(n.find(a=>a.endsWith(r))??null)}}function T(e){let n=[],i=null;for(let t of e.split(`
5
- `)){if(t.startsWith("+++ ")){i=ae(t.slice(4).trim());continue}if(!i||!t.startsWith("@@ "))continue;let r=/@@ -\d+(?:,\d+)? \+(\d+)(?:,(\d+))? @@/.exec(t);if(!r)continue;let s=Math.max(0,Number(r[1])-1),a=r[2]===void 0?1:Number(r[2]);n.push({file:i,startLine:s,endLine:Math.max(s,s+Math.max(a,1)-1)})}return n}function ae(e){return e==="/dev/null"?null:e.startsWith("a/")||e.startsWith("b/")?e.slice(2):e}function z(e){let n=new Set,i=[];for(let t of e){let r=`${t.file}:${t.startLine}:${t.endLine}`;n.has(r)||(n.add(r),i.push(t))}return i}function le(e,n){let i=n.get(e.relativePath);return!i||i.length===0?!0:i.some(t=>C(e.startLine,e.endLine,t.startLine,t.endLine))}function ce(e,n,i){let t=new Map,r=[],s=W(e),a=ge(i);for(let o of n){let c=s.get(o.file)??[];if(c.some(l=>C(l.startLine,l.endLine,o.startLine,o.endLine)))continue;let u=a.get(o.file)??[],d=pe(u,o);if(d){let l=c.find(m=>m.startLine>=d.startLine&&m.startLine<=d.endLine);if(l){t.set(l.symbolId,l),r.push(S(o,"ast-widened"));continue}}if(u.length===0){let l=[...c].filter(m=>m.startLine<=o.startLine).sort((m,p)=>p.startLine-m.startLine||m.endLine-p.endLine)[0];if(l){t.set(l.symbolId,l),r.push(S(o,"nearest-preceding"));continue}}r.push(S(o,"unattributed"))}return{definitions:[...t.values()],notes:r}}function de(e,n,i,t){let r=W(i),s=[],a=[],o=[...new Set(n.map(c=>c.relativePath))];for(let c of o){let u=t.get(c)??[];if(u.length===0)continue;let d=r.get(c)??[];for(let l of u)d.some(m=>C(m.startLine,m.endLine,l.startLine,l.endLine))||s.push(l);s.some(l=>l.file===c)&&a.push(...fe(e,c))}return ce(n,s,a)}function fe(e,n){let i=x(e,n);return i?i.rootNode.namedChildren.filter(ue).map(t=>({file:n,startLine:t.startPosition.row,endLine:t.endPosition.row})).filter(t=>t.endLine>=t.startLine):[]}function ue(e){return e.endPosition.row<e.startPosition.row?!1:!new Set(["import_statement","comment"]).has(e.type)}function me(e){let n=new Map;for(let i of e)n.set(i.symbolId,i);return[...n.values()]}function W(e){let n=new Map;for(let i of e){let t=n.get(i.relativePath)??[];t.push(i),n.set(i.relativePath,t)}return n}function ge(e){let n=new Map;for(let i of e){let t=n.get(i.file)??[];t.push(i),n.set(i.file,t)}return n}function pe(e,n){return e.filter(i=>i.startLine<=n.startLine&&i.endLine>=n.endLine).sort((i,t)=>i.endLine-i.startLine-(t.endLine-t.startLine))[0]}function S(e,n){return{file:e.file,startLine:e.startLine,endLine:e.endLine,method:n}}function C(e,n,i,t){return e<=t&&i<=n}function he(e,n,i,t,r,s,a,o,c){let u=Math.max(o,s.size,a.size);if(!De(n,u))return;let d=M(n.symbol);t.push({symbol:n.symbol,shortName:d,file:n.relativePath,startLine:n.startLine,endLine:n.endLine,fanIn:u});for(let l of c)L(e,i,r,l,d);for(let l of s)L(e,i,r,l,d);for(let l of a)L(e,i,r,l,d)}function $(e){try{return e()}catch(n){return console.error(`warning: diff-impact enrichment scan failed, continuing without it: ${n instanceof Error?n.message:n}`),new Map}}function ye(e,n){if(n.length===0)return new Map;let i=e.all(`SELECT m.symbol_id, COUNT(DISTINCT c.document_id) AS fan_in
6
- FROM mentions m
7
- JOIN chunks c ON m.chunk_id = c.id
8
- WHERE m.symbol_id IN (${n.map(()=>"?").join(",")})
9
- AND m.role != 1
10
- GROUP BY m.symbol_id`,...n);return new Map(i.map(t=>[t.symbol_id,t.fan_in]))}function be(e,n,i){if(n.length===0||i.length===0)return new Map;let t=e.all(`SELECT DISTINCT m.symbol_id, ref_d.relative_path
11
- FROM mentions m
12
- JOIN chunks c ON m.chunk_id = c.id
13
- JOIN documents ref_d ON c.document_id = ref_d.id
14
- WHERE m.symbol_id IN (${n.map(()=>"?").join(",")})
15
- AND m.role != 1
16
- AND ref_d.relative_path NOT IN (${i.map(()=>"?").join(",")})
17
- ${e.pathExclusionsFor("ref_d")}`,...n,...i),r=new Map;for(let s of t){let a=r.get(s.symbol_id);a||(a=new Set,r.set(s.symbol_id,a)),a.add(s.relative_path)}return r}function L(e,n,i,t,r){if(e.isIgnored(t)||n.has(t))return;let s=i.get(t);s||(s=new Set,i.set(t,s)),s.add(r)}function Se(e){return[...e.entries()].map(([n,i])=>({file:n,consumedSymbols:i.size})).sort((n,i)=>i.consumedSymbols-n.consumedSymbols)}function Le(e){return!(N(e.symbol)||e.parentTypeName!==null&&!b(e.symbol))}function De(e,n){return b(e.symbol)||e.isTypeLike?!0:e.parentTypeName===null&&n>0}export{H as a,Ae as b,J as c,Z as d,Y as e,D as f,Pe as g,Ee as h,ee as i,ce as j};
18
- //# sourceMappingURL=chunk-4YTUWQ6M.js.map
@@ -1,8 +0,0 @@
1
- function c(n,e={}){let s=e.scope?"AND relative_path LIKE ?":"",o=e.like?"AND relative_path LIKE ?":"",r=[...e.scope?[`%${e.scope}%`]:[],...e.like?[e.like]:[]],i=n.all(`SELECT relative_path
2
- FROM documents
3
- WHERE 1 = 1
4
- ${n.pathExclusionsFor("documents")}
5
- ${s}
6
- ${o}
7
- ORDER BY relative_path`,...r).map(t=>t.relative_path),a=e.extensions?i.filter(t=>e.extensions.some(l=>t.toLowerCase().endsWith(l.toLowerCase()))):i;return e.includeIgnored===!1?a.filter(t=>!n.isIgnored(t)):a}export{c as a};
8
- //# sourceMappingURL=chunk-64MNV6AB.js.map
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env node
2
- import{$e as C,Ge as R,He as B,Se as b,Ue as A,Ve as F,Wc as M,We as p,Ye as V,_ as N,cf as W,da as y,ea as v,ee as G,kb as J,qe as u,re as k,se as T,ue as d,vb as E}from"./chunk-HIB452NU.js";var ae=G,q=(e=>parseInt(e,10)),K=(e=>{let t=parseInt(e,10);if(!Number.isFinite(t)||t<1)throw new Error(`Expected a positive integer, got ${e}`);return t}),me=parseFloat,le=parseInt;function l(e,t,o,...n){return n.length>0?{flags:e,description:t,parser:o,defaultValue:n[0]}:{flags:e,description:t,parser:o}}function X(){return l("--json","Output as JSON for programmatic consumption")}function Y(){return l("--compact","Emit minified one-line JSON (use with --json)")}function Q(e=[]){let t=w(e);return t.some(o=>o.flags==="--compact")?t:[...t,Y()]}function w(e=[]){return e.some(t=>t.flags==="--json")?e:[...e,X()]}function x(e,t=[]){return{category:e,examples:t}}function S(e,t,o,n,r){return{answers:typeof e=="string"?[e]:e,returns:typeof t=="string"?[t]:t,inputs:o,coverage:n,...r?{scope:r}:{}}}function z(e){return e.generation.identity}function H(e){return W({version:1,...e})}function U(e,t){let o;try{o=JSON.parse(Buffer.from(e,"base64url").toString("utf8"))}catch{throw new Error("Invalid result cursor. Run the command again without --cursor.")}if(!Z(o))throw new Error("Invalid result cursor. Run the command again without --cursor.");if(o.command!==t.command||o.target!==t.target)throw new Error("This cursor belongs to a different command or target. Run again without --cursor.");if(o.indexGeneration!==t.indexGeneration)throw new Error("The index changed after this cursor was issued. Run again without --cursor.");return o}function Z(e){if(!e||typeof e!="object")return!1;let t=e;return t.version===1&&typeof t.command=="string"&&typeof t.target=="string"&&Number.isSafeInteger(t.offset)&&(t.offset??-1)>=0&&typeof t.indexGeneration=="string"&&t.indexGeneration.length>0}function P(e,t){let o=y(e,t),n=te(o);for(let r of n)console.log(r)}function $(e,t,o="No results found for resolved symbol."){return y(e,t).match?o:ee(t,v(e,t,5))}function O(e,t,o,n){return{..._(e,t),[n]:o}}function _(e,t){let o=y(e,t);return o.match?{matched:!0,resolved:{symbol:o.match.symbol,shortName:N(o.match.symbol),relativePath:o.match.relativePath},otherMatches:o.candidates.map(n=>({shortName:n.shortName,relativePath:n.relativePath,startLine:n.startLine})),totalMatches:o.total}:{matched:!1,suggestions:v(e,t,5)}}function ee(e,t){let o=`No definition matched '${e}'.`;return t.length>0?`${o} Suggestions: ${t.join(", ")}`:o}function te(e){if(!e.match||e.total<=1)return[];let t=e.match,o=Math.max(0,e.total-1),n=[`Resolved: ${N(t.symbol)} (${t.relativePath}) -- ${o} other definition(s) share this name; qualify as <dir/leaf> to target another.`],r=e.candidates.slice(0,3);return r.length>0&&n.push(`Alternates: ${r.map(s=>`${s.shortName} (${s.relativePath}:${u(s.startLine)})`).join("; ")}`),n.push(""),n}var oe=R(({db:e,args:t,opts:o})=>{let n=b(t,0),r=p(o,"signatures"),s=E(e,n);if(p(o,"json")){C("outline",t,o,s);return}if(s.length===0)return d.empty(`No symbols found for "${n}".`);function i(D,f){for(let a of D){let c=" ".repeat(f),m=r&&a.signature?` - ${ne(a.signature)}`:"";console.log(`${c}${k(a.startLine,a.endLine)} ${a.shortName}${m}`),i(a.children,f+1)}}i(s,0)});function ne(e){return e.length>120?`${e.slice(0,117)}...`:e}var re=B("refs",({db:e,args:t,opts:o,budget:n})=>{let r=b(t,0),s=J(e,r,{semantic:n.semantic}).sort((h,j)=>h.relativePath.localeCompare(j.relativePath)||h.line-j.line),i=A(o,"cursor"),f=F(o,"limit")??(i?50:s.length),a=z(e),c=i?U(i,{command:"refs",target:r,indexGeneration:a}).offset:0;if(c>s.length)throw new Error("This cursor points past the current result set. Run again without --cursor.");let m=s.slice(c,c+f),L=c+m.length,g=L<s.length?{cursor:H({command:"refs",target:r,offset:L,indexGeneration:a}),indexGeneration:a}:void 0,I={complete:c===0&&m.length===s.length,totalKnown:!0,returned:m.length,total:s.length,omitted:s.length-m.length,...g?{continuation:g}:{}};if(p(o,"json")){C("refs",t,o,O(e,r,m,"references"),{analysisBudget:n.analysisBudget,coverage:I});return}if(m.length===0)return d.empty($(e,r,"No references found."));P(e,r),d.groupedByFile(m,h=>` line ${u(h.line)}`),g&&console.log(`
3
- ${I.omitted} omitted; continue with --cursor ${g.cursor}`)}),se=R(({db:e,args:t,opts:o})=>{let n=b(t,0),r=M(e,n,{context:V(o,"context",0)});if(p(o,"json")){C("code",t,o,O(e,n,r,"code"));return}if(!r)return d.empty($(e,n,"Symbol found, but source was unreadable."));P(e,n),console.log(`${T(r.relativePath,r.startLine,r.endLine)} ${r.shortName} [${r.language??"unknown"}]
4
- `);let s=r.source.split(`
5
- `);for(let i=0;i<s.length;i++)console.log(` ${String(u(r.startLine+i)).padStart(4)} ${s[i]}`)}),Se=[{id:"refs",command:"refs <symbol>",description:"Find all files referencing a symbol",options:Q([l("--full","Run unbounded semantic analysis on large indexes"),l("-n, --limit <n>","Maximum reference sites to return",K),l("--cursor <cursor>","Continue a prior bounded result (implies --limit 50 when omitted)")]),budget:"semantic",agent:{answers:["Which files reference this symbol?","Is this symbol used anywhere, or only defined?"],returns:["referencing file paths","reference line numbers grouped by file"],inputs:["symbol"],coverage:"bounded",contrasts:[{command:"imported-by",distinction:"imported-by lists files importing the symbol; refs covers every reference site, imported or not."},{command:"affected",distinction:"refs is one hop out; affected is the transitive closure of what could break."}]},renderShape:"grouped-by-file",docs:x("Navigation",["scip-query refs login"]),handler:re},{id:"outline",command:"outline <file>",description:"Tree view of symbols in a file, with line ranges",agent:S("What symbols and nesting exist in this file?","symbol names, nesting, and line ranges",["file"],"complete"),options:w([l("--signatures","Show trimmed symbol signatures")]),renderShape:"custom",docs:x("Navigation"),handler:oe},{id:"code",command:"code <symbol>",description:"Read the source code for a symbol (bounded to its definition range)",agent:S("What is the compiler-resolved definition source for this symbol?","definition identity, source, and line range",["symbol"],"complete"),options:w([l("-C, --context <n>","Extra lines of context above/below",q,0)]),renderShape:"custom",docs:x("Navigation"),handler:se}];export{ae as a,q as b,K as c,me as d,le as e,l as f,X as g,Y as h,Q as i,w as j,x as k,S as l,P as m,$ as n,O as o,_ as p,Se as q};
6
- //# sourceMappingURL=chunk-67QRR5YC.js.map
@@ -1,40 +0,0 @@
1
- import{b as w}from"./chunk-3EDFLQ6A.js";import{b as g}from"./chunk-SMQWE25B.js";import{c as h,d as f}from"./chunk-MTDBHTSF.js";import{d as c,e as u,h as m,p as b,q as p}from"./chunk-RA3AYNWP.js";import{dirname as $,relative as T,resolve as k}from"path";var A=new Set(f());function O(t,n){return`tests/generated/twin-ab/${y(t)}-vs-${y(n)}.test.ts`}function y(t){return(t.split(/[/#]/).pop()||t).replace(/[^A-Za-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")||"symbol"}function I(t,n,a,e){let o=d(t,n);if(!o.ok)return o;let i=d(t,a);if(!i.ok)return i;let r=o.symbol.paramCount===null||i.symbol.paramCount===null?null:o.symbol.paramCount===i.symbol.paramCount,s=v(o.symbol,i.symbol,t.config.projectRoot,e,r);return{ok:!0,a:o.symbol,b:i.symbol,signatureCompatible:r,testSource:s}}function d(t,n){let e=g(t,n).match;if(!e)return{ok:!1,reason:`${n} does not resolve to an indexed symbol.`};let i=t.get("SELECT kind FROM global_symbols WHERE id = ?",e.symbolId)?.kind??null;if(!(i!==null?A.has(i):m(e.symbol)))return{ok:!1,reason:`${n} resolves to ${c(e.symbol)}${i!==null?` with SCIP kind ${h(i)}`:""} \u2014 twin-ab compares call outputs, so both referents must be functions or methods.`};if(!w(t,e))return{ok:!1,reason:`${n} (${c(e.symbol)} at ${e.relativePath}:${e.startLine+1}) is not exported \u2014 twin-ab needs an importable named binding for both twins.`};let s=t.get("SELECT documentation FROM global_symbols WHERE id = ?",e.symbolId),l=b(p(s?.documentation??null));return{ok:!0,symbol:{ref:n,symbol:e.symbol,shortName:u(e.symbol)||c(e.symbol),file:e.relativePath,startLine:e.startLine,signature:l,paramCount:l?x(l):null}}}function x(t){let n=t.indexOf("(");if(n===-1)return null;let a=0,e=-1;for(let s=n;s<t.length;s+=1){let l=t[s];if(l==="(")a+=1;else if(l===")"&&(a-=1,a===0)){e=s;break}}if(e===-1)return null;let o=t.slice(n+1,e).trim();if(!o)return 0;let i=1,r=0;for(let s of o)s==="("||s==="["||s==="{"?r+=1:s===")"||s==="]"||s==="}"?r=Math.max(0,r-1):s===","&&r===0&&(i+=1);return i}function S(t,n,a){let e=$(n),o=k(t,a),r=T(e,o).replace(/\\/g,"/").replace(/\.tsx?$/,".js");return r.startsWith(".")?r:`./${r}`}function v(t,n,a,e,o){let i=S(a,e,t.file),r=S(a,e,n.file),s=o===null?"Signature comparison: unknown (one or both signatures unavailable in the index) \u2014 check by hand.":o?"Signature comparison: param counts match.":"Signature comparison: param counts DIFFER \u2014 twins may not be directly comparable; check by hand.";return`/**
2
- * Generated by 'scip-query twin-ab'. scip-audit integrity scenario.
3
- * ("cross-examine same-concept twins"): where one concept is computed in
4
- * more than one place, feed both the same input and require the same
5
- * answer. Disagreement between twins means at least one is wrong \u2014
6
- * determine which before consolidating.
7
- *
8
- * Twin A: ${t.shortName} (${t.file}:${t.startLine+1})
9
- * ${t.signature??"(signature unavailable)"}
10
- * Twin B: ${n.shortName} (${n.file}:${n.startLine+1})
11
- * ${n.signature??"(signature unavailable)"}
12
- * ${s}
13
- *
14
- * Fill in the TODO input table below with inputs both twins should agree
15
- * on, then run this file with vitest.
16
- */
17
- import { describe, expect, it } from 'vitest';
18
- import { ${t.shortName} as twinA } from '${i}';
19
- import { ${n.shortName} as twinB } from '${r}';
20
-
21
- // TODO: fill in shared inputs both twins should agree on \u2014 one arg array per call.
22
- const inputs: any[][] = [
23
- // [/* arg1, arg2, ... */],
24
- ];
25
-
26
- // Cast to a variadic signature so the input table can hold any arg shape \u2014
27
- // the real twins have fixed, non-rest parameter lists, and TS rejects
28
- // spreading a generic args array into those (TS2556) even when the array
29
- // itself is 'any'; casting the callee's signature, not the args, satisfies
30
- // the checker without weakening the twins' real exported types elsewhere.
31
- const callA = twinA as (...callArgs: any[]) => any;
32
- const callB = twinB as (...callArgs: any[]) => any;
33
-
34
- describe.skipIf(inputs.length === 0)('twin-ab: ${t.shortName} vs ${n.shortName}', () => {
35
- it.each(inputs)('agrees on input %#', (...args) => {
36
- expect(callA(...args)).toEqual(callB(...args));
37
- });
38
- });
39
- `}export{O as a,I as b};
40
- //# sourceMappingURL=chunk-6GXYN7YA.js.map
@@ -1,8 +0,0 @@
1
- import{j as H,l as w,m as b}from"./chunk-C5Q44Q5D.js";import{a as d}from"./chunk-APMMR5Y2.js";import m from"process";import{existsSync as De}from"fs";import{dirname as O,join as ke,resolve as B,sep as Ee}from"path";import{fileURLToPath as Ie}from"url";import{spawn as ae}from"child_process";var l=class extends Error{},p=class extends Error{},S=class extends Error{constructor(r,n,i){super(`rust-analyzer LSP request ${n} failed: ${i}`);this.code=r}code},ue=3e4,le=16*1024,ce=64*1024*1024,N=64*1024,_=256*1024*1024,g=Buffer.from(`\r
2
- \r
3
- `,"ascii"),L=class{constructor(e,r={}){this.transport=e;this.requestTimeoutMs=r.requestTimeoutMs??ue,this.configuration=r.configuration??{};let n=fe(r.maxHeaderBytes,r.maxMessageBytes);this.maxHeaderBytes=n.maxHeaderBytes,this.maxMessageBytes=n.maxMessageBytes,this.monotonicNow=r.monotonicNow??d,this.headerBuffer=Buffer.allocUnsafe(this.maxHeaderBytes+g.length),this.transport.onData(i=>this.handleData(i)),this.transport.onClose((i,s)=>this.failTransport(new Error(we(i,s)),!1)),this.transport.onError(i=>this.failTransport(i,!0))}transport;nextId=1;pending=new Map;diagnosedUris=new Set;diagnosticWaiters=new Map;readinessWaiters=new Set;requestTimeoutMs;configuration;maxHeaderBytes;maxMessageBytes;monotonicNow;headerBuffer;headerLength=0;bodyBuffer=null;bodyLength=0;transportFailure=null;transportKilled=!1;currentServerStatusGeneration=0;latestServerStatus=null;shutdownStarted=!1;async initialize(e,r={}){let n=e.capabilities??{},i=n.experimental&&typeof n.experimental=="object"&&!Array.isArray(n.experimental)?n.experimental:{},s=await this.request("initialize",{...e,capabilities:{...n,experimental:{...i,serverStatusNotification:!0}}},r);return this.notify("initialized",{}),s}async references(e,r={}){let n=await this.request("textDocument/references",e,r);return Array.isArray(n)?n:[]}async definition(e,r={}){let n=await this.request("textDocument/definition",e,r);return ye(n)}async prepareCallHierarchy(e,r={}){let n=await this.request("textDocument/prepareCallHierarchy",e,r);return Array.isArray(n)?n:[]}async outgoingCalls(e,r={}){let n=await this.request("callHierarchy/outgoingCalls",{item:e},r);return Array.isArray(n)?n:[]}async hover(e,r={}){let n=await this.request("textDocument/hover",e,r);return n&&typeof n=="object"?n:null}async readinessBarrier(e={}){try{await this.request("scip-query/readinessBarrier",null,e)}catch(r){if(r instanceof S&&r.code===-32601)return;throw r}}serverStatusGeneration(){return this.currentServerStatusGeneration}serverStatusSnapshot(){let e=this.latestServerStatus;return e?{generation:e.generation,status:{...e.status}}:null}waitForQuiescence(e,r){if(this.transportFailure)return Promise.reject(this.transportFailure);let n=this.latestServerStatus;if(n&&n.generation>e){if(n.status.health==="error")return Promise.reject(U());if(n.status.quiescent)return Promise.resolve(n.status)}return new Promise((i,s)=>{let o={afterGeneration:e,resolve:i,reject:s,timeout:setTimeout(()=>{this.readinessWaiters.delete(o),s(new Error(`rust-analyzer readiness timed out after ${r}ms`))},r)};this.readinessWaiters.add(o)})}didOpenTextDocument(e){this.notify("textDocument/didOpen",{textDocument:e})}waitForDiagnostics(e,r){return this.transportFailure?Promise.resolve(!1):this.diagnosedUris.has(e)?Promise.resolve(!0):new Promise(n=>{let i=u=>{clearTimeout(s),n(u)},s=setTimeout(()=>{let u=this.diagnosticWaiters.get(e)?.filter(c=>c!==i);u&&u.length>0?this.diagnosticWaiters.set(e,u):this.diagnosticWaiters.delete(e),n(!1)},r),o=this.diagnosticWaiters.get(e)??[];o.push(i),this.diagnosticWaiters.set(e,o)})}async shutdown(e={}){if(!this.shutdownStarted){this.shutdownStarted=!0;try{await this.request("shutdown",null,e),this.notify("exit",null)}catch(r){throw this.notify("exit",null),this.killTransportOnce(),r}}}request(e,r,n={}){if(this.transportFailure)return Promise.reject(this.transportFailure);let i=v(n.timeoutMs??this.requestTimeoutMs,n.deadlineMs,this.monotonicNow),s=this.nextId++,o={jsonrpc:"2.0",id:s,method:e,params:r};return new Promise((u,c)=>{let f=setTimeout(()=>{this.pending.delete(s),c(i.deadlineLimited?new l(`rust-analyzer readiness deadline expired during LSP request ${e}`):new Error(`rust-analyzer LSP request ${e} timed out after ${i.timeoutMs}ms`))},i.timeoutMs);this.pending.set(s,{method:e,deadlineMs:n.deadlineMs,resolve:R=>u(R),reject:c,timeout:f}),this.transport.write(C(o))})}notify(e,r){this.transportFailure||this.transport.write(C({jsonrpc:"2.0",method:e,params:r}))}handleData(e){if(this.transportFailure||e.length===0)return;let r=0;for(;r<e.length&&!this.transportFailure;){if(this.bodyBuffer){let o=Math.min(e.length-r,this.bodyBuffer.length-this.bodyLength);if(e.copy(this.bodyBuffer,this.bodyLength,r,r+o),r+=o,this.bodyLength+=o,this.bodyLength===this.bodyBuffer.length){let u=this.bodyBuffer.toString("utf8");this.bodyBuffer=null,this.bodyLength=0;let c;try{c=Re(u)}catch{this.failProtocol("rust-analyzer LSP response body was not a valid JSON object");continue}try{this.dispatchMessage(c)}catch{this.failTransport(new Error("rust-analyzer LSP message handling failed"),!0)}}continue}if(this.headerLength===this.headerBuffer.length){this.failProtocol(`rust-analyzer LSP header exceeded ${this.maxHeaderBytes} byte limit`);return}if(this.headerBuffer[this.headerLength++]=e[r++],!this.headerDelimiterComplete())continue;let n=this.headerLength-g.length;if(n>this.maxHeaderBytes){this.failProtocol(`rust-analyzer LSP header exceeded ${this.maxHeaderBytes} byte limit`);return}let i=this.headerBuffer.subarray(0,n).toString("ascii");this.headerLength=0;let s;try{s=de(i,this.maxMessageBytes)}catch(o){this.failProtocol(o instanceof Error?o.message:String(o));return}this.bodyBuffer=Buffer.allocUnsafe(s),this.bodyLength=0,s===0&&(this.bodyBuffer=null,this.failProtocol("rust-analyzer LSP response body was not a valid JSON object"))}}headerDelimiterComplete(){if(this.headerLength<g.length)return!1;let e=this.headerLength-g.length;return this.headerBuffer.subarray(e,this.headerLength).equals(g)}failProtocol(e){this.failTransport(new p(e),!0)}failTransport(e,r){this.transportFailure||(this.transportFailure=e,this.headerLength=0,this.bodyBuffer=null,this.bodyLength=0,r&&this.killTransportOnce(),this.rejectPending(e),this.resolveDiagnosticWaiters(!1))}killTransportOnce(){this.transportKilled||(this.transportKilled=!0,this.transport.kill())}dispatchMessage(e){if(this.recordDiagnosticNotification(e),this.recordServerStatusNotification(e),e.id!==void 0&&e.id!==null&&e.method){this.respondToServerRequest(e);return}if(e.id===void 0||e.id===null)return;let r=this.pending.get(e.id);if(r){if(clearTimeout(r.timeout),this.pending.delete(e.id),e.error){r.reject(new S(e.error.code,r.method,e.error.message));return}if(r.deadlineMs!==void 0&&this.monotonicNow()>=r.deadlineMs){r.reject(new l(`rust-analyzer readiness deadline expired during LSP request ${r.method}`));return}r.resolve(e.result)}}recordDiagnosticNotification(e){if(e.method!=="textDocument/publishDiagnostics")return;let r=e.params,n=r&&typeof r=="object"&&typeof r.uri=="string"?r.uri:null;if(!n)return;this.diagnosedUris.add(n);let i=this.diagnosticWaiters.get(n)??[];this.diagnosticWaiters.delete(n),i.forEach(s=>s(!0))}recordServerStatusNotification(e){if(e.method!=="experimental/serverStatus"||e.id!==void 0||!me(e.params))return;let r=e.params,n={health:r.health,quiescent:r.quiescent,...typeof r.message=="string"?{message:r.message}:{}},i=++this.currentServerStatusGeneration;if(this.latestServerStatus={generation:i,status:n},n.health==="error"){this.rejectReadinessWaiters(U());return}if(n.quiescent)for(let s of this.readinessWaiters)i<=s.afterGeneration||(clearTimeout(s.timeout),this.readinessWaiters.delete(s),s.resolve(n))}respondToServerRequest(e){if(e.id===void 0||e.id===null||!e.method)return;let r=e.method==="workspace/configuration"?this.workspaceConfiguration(e.params):null;this.transport.write(C({jsonrpc:"2.0",id:e.id,result:r}))}workspaceConfiguration(e){return(e&&typeof e=="object"&&Array.isArray(e.items)?e.items:[]).map(n=>typeof n.section=="string"?pe(this.configuration,n.section):this.configuration)}rejectPending(e){for(let[r,n]of this.pending)clearTimeout(n.timeout),n.reject(e),this.pending.delete(r);this.rejectReadinessWaiters(e)}resolveDiagnosticWaiters(e){for(let r of this.diagnosticWaiters.values())r.forEach(n=>n(e));this.diagnosticWaiters.clear()}rejectReadinessWaiters(e){for(let r of this.readinessWaiters)clearTimeout(r.timeout),r.reject(e),this.readinessWaiters.delete(r)}};function fe(t=le,e=ce){if(!Number.isSafeInteger(t)||t<=0)throw new TypeError("maxHeaderBytes must be a positive safe integer.");if(!Number.isSafeInteger(e)||e<=0)throw new TypeError("maxMessageBytes must be a positive safe integer.");if(t>N)throw new RangeError(`maxHeaderBytes cannot exceed ${N} bytes for rust-analyzer LSP.`);if(t+g.length+e>_)throw new RangeError(`Combined rust-analyzer LSP header and message limits cannot exceed ${_} bytes.`);return{maxHeaderBytes:t,maxMessageBytes:e}}function de(t,e){let r=[];for(let s of t.split(`\r
4
- `)){let o=s.indexOf(":");o<0||s.slice(0,o).trim().toLowerCase()!=="content-length"||r.push(s.slice(o+1).trim())}if(r.length===0)throw new p("rust-analyzer LSP response missing Content-Length header");if(r.length>1){let s=new Set(r).size>1?"rust-analyzer LSP response has conflicting Content-Length headers":"rust-analyzer LSP response has duplicate Content-Length headers";throw new p(s)}let n=r[0];if(!/^\d+$/.test(n))throw new p("rust-analyzer LSP Content-Length must be a non-negative safe integer");let i=Number(n);if(!Number.isSafeInteger(i))throw new p("rust-analyzer LSP Content-Length must be a non-negative safe integer");if(i>e)throw new p(`rust-analyzer LSP Content-Length exceeds ${e} byte message limit`);return i}function v(t,e,r=d){if(e===void 0)return{timeoutMs:t,deadlineLimited:!1};let n=e-r();if(n<=0)throw new l("rust-analyzer readiness deadline expired before LSP operation");return{timeoutMs:Math.min(t,n),deadlineLimited:n<=t}}function me(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let e=t;return(e.health==="ok"||e.health==="warning"||e.health==="error")&&typeof e.quiescent=="boolean"&&(e.message===void 0||e.message===null||typeof e.message=="string")}function U(){return new l("rust-analyzer reported error health before reaching readiness")}function pe(t,e){let r=e.startsWith("rust-analyzer.")?e.slice(14):e;if(r===""||r==="rust-analyzer")return t;let n=t;for(let i of r.split(".")){if(!n||typeof n!="object")return null;n=n[i]}return n??null}function ye(t){return t?(Array.isArray(t)?t:[t]).flatMap(r=>he(r)?[r]:ge(r)?[{uri:r.targetUri,range:r.targetSelectionRange}]:[]):[]}function he(t){return!!(t&&typeof t=="object"&&typeof t.uri=="string")}function ge(t){return!!(t&&typeof t=="object"&&typeof t.targetUri=="string")}function $(t,e,r=process.env){let n=ae(t,[],{cwd:e,env:r,stdio:["pipe","pipe","pipe"]});return{write(i){n.stdin.write(i)},onData(i){n.stdout.on("data",i)},onClose(i){n.on("close",i)},onError(i){n.on("error",i)},kill(){n.kill()}}}function C(t){let e=JSON.stringify(t);return`Content-Length: ${Buffer.byteLength(e,"utf8")}\r
5
- \r
6
- ${e}`}function Re(t){let e=JSON.parse(t);if(!e||typeof e!="object")throw new Error("rust-analyzer LSP response was not a JSON object");return e}function we(t,e){return`rust-analyzer LSP transport closed${e?` by ${e}`:t===null?"":` with code ${t}`}`}async function G(t,e,r,n=d){let i=r-n();if(i<=0)throw new l("rust-analyzer readiness deadline expired before quiescence");try{let s=await t.waitForQuiescence(e,i);if(x(r,n,"during quiescence"),s.health==="error")throw new l("rust-analyzer reported error health before reaching readiness");if(!s.quiescent)throw new l("rust-analyzer did not report quiescence before reaching readiness");return s}catch(s){throw s instanceof l?s:new l(s instanceof Error?s.message:String(s))}}async function ut(t,e,r,n,i,s=d,o=D){let u=await G(t,e,n,s);if(r===0)return u;let c=t.serverStatusSnapshot();if(!c)throw new l("rust-analyzer status is unavailable after initial document open");return await be(t,c,r,n,i,s,o)??u}async function be(t,e,r,n,i,s=d,o=D){if(r===0)return null;if(!e)throw new l("rust-analyzer status is unavailable before document open");J(e.status,"before document open");try{await t.readinessBarrier({deadlineMs:n}),x(n,s,"during post-open synchronization")}catch(f){throw f instanceof l?f:new l(f instanceof Error?f.message:String(f))}let u=t.serverStatusSnapshot();if(!u||u.generation<e.generation)throw new l("rust-analyzer status is unavailable after document open");let c;return u.generation===e.generation?(J(u.status,"after document open"),c=u.status):c=await G(t,e.generation,n,s),await M(i,n,s,o),c}async function lt(t,e,r,n=d){let i=v(e,r,n);await t(i.timeoutMs),x(r,n,"during diagnostics")}async function M(t,e,r=d,n=D){if(t<=0)return;if(v(t,e,r).deadlineLimited)throw new l("rust-analyzer readiness deadline cannot accommodate delay");await n(t),x(e,r,"during delay")}async function ct(t,e){try{return await t()}catch(r){throw r instanceof l&&await e(),r}}function ft(t){return t instanceof l?{ok:!1,error:t.message}:null}function x(t,e,r){if(t-e()<=0)throw new l(`rust-analyzer readiness deadline expired ${r}`)}function J(t,e){if(t.health==="error")throw new l(`rust-analyzer reported error health ${e}`);if(!t.quiescent)throw new l(`rust-analyzer did not report quiescence ${e}`)}function D(t){return new Promise(e=>setTimeout(e,t))}import{realpathSync as P}from"fs";import{basename as Se,dirname as Le,join as ve,relative as xe,sep as Pe}from"path";import{fileURLToPath as ze,pathToFileURL as Y}from"url";function z(t,e){return e==="."||e==="./"?Y(P(t)).href:Y(H(t,e).absolutePath).href}function E(t,e){let r=ze(e);return xe(P(t),Ae(r)).split(Pe).join("/")}function Ae(t){try{return P(t)}catch{try{return ve(P(Le(t)),Se(t))}catch{return t}}}function A(t,e,r){return{textDocument:{uri:z(t,e.relativePath)},position:Te(t,e),context:{includeDeclaration:r}}}function Te(t,e){let r={line:e.startLine,character:e.startChar??0};try{return Ce(w(t,e.relativePath,{inputKind:"indexed Rust source file"}),e,r)}catch(n){if(!b(n))throw n;return r}}function Ce(t,e,r={line:e.startLine,character:e.startChar??0}){let n=t.split(/\r?\n/),i=n[e.startLine];if(i===void 0||e.leaf.length===0)return r;let s=Math.max(0,Math.min(r.character,i.length)),o=i.indexOf(e.leaf,s);if(o>=0)return{line:e.startLine,character:k(o,e.leaf)};let u=i.indexOf(e.leaf);if(u>=0)return{line:e.startLine,character:k(u,e.leaf)};let c=Me(n,e.startLine,e.leaf);return c||r}function k(t,e){return t+Math.max(0,e.length-2)}function Me(t,e,r){for(let n of[-1,1,-2,2]){let i=e+n;if(i<0||i>=t.length)continue;let s=t[i].indexOf(r);if(s>=0)return{line:i,character:k(s,r)}}return null}function K(t,e){return e.map(r=>({file:E(t,r.uri),line:r.range.start.line,column:r.range.start.character}))}function Q(t){let e=new Map;for(let r of t)e.set(`${r.file}\0${r.line}\0${r.column}`,r);return[...e.values()].sort((r,n)=>{let i=r.file.localeCompare(n.file);return i!==0?i:r.line!==n.line?r.line-n.line:r.column-n.column})}async function Oe(t){let e=t.includeReferences!==!1,r=t.includeCallees===!0,n=t.includeSignatures===!0,i={timeoutMs:t.requestTimeoutMs},s=Be(t),o=Z(t),u=X(t),c=V(t),f=$e(t.projectRoot,s),R=Ue(t.projectRoot,f),j=_e(f),y=new L($(t.rustAnalyzerBinary,R),{requestTimeoutMs:t.requestTimeoutMs,configuration:j});try{let T=await y.initialize({processId:m.pid,rootUri:z(R,"."),capabilities:{textDocument:{references:{dynamicRegistration:!1},callHierarchy:{dynamicRegistration:!1},hover:{dynamicRegistration:!1}}},initializationOptions:j});if(e&&!T.capabilities.referencesProvider)return{available:!1,reason:"rust-analyzer initialized without textDocument/references support.",references:o.map(a=>[a.symbolId,[]]),...r?{callees:u.map(a=>[a.symbolId,[]])}:{}};if(r&&!T.capabilities.callHierarchyProvider)return{available:!1,reason:"rust-analyzer initialized without call hierarchy support.",references:o.map(a=>[a.symbolId,[]]),callees:u.map(a=>[a.symbolId,[]]),...n?{signatures:c.map(a=>[a.symbolId,null])}:{}};if(n&&!T.capabilities.hoverProvider)return{available:!1,reason:"rust-analyzer initialized without hover support.",references:o.map(a=>[a.symbolId,[]]),...r?{callees:u.map(a=>[a.symbolId,[]])}:{},signatures:c.map(a=>[a.symbolId,null])};let ie=Je(y,t.projectRoot,s);await Ge(y,ie,t.diagnosticsTimeoutMs??1e4),await ne(t.settleDelayMs??5e3);let q=e?await I(o,t.concurrency??8,async a=>{let F=await ee(y,A(t.projectRoot,a,!1),{requestTimeoutMs:t.requestTimeoutMs,retryTimeoutMs:t.referenceRetryTimeoutMs});return{symbolId:a.symbolId,references:Q(K(t.projectRoot,F.locations)),complete:F.complete}}):o.map(a=>({symbolId:a.symbolId,references:[],complete:!0})),se=r?await I(u,t.concurrency??8,async a=>({symbolId:a.symbolId,callees:await Ke(y,t.projectRoot,a,i)})):[],oe=n?await I(c,t.concurrency??8,async a=>({symbolId:a.symbolId,signature:await We(y,t.projectRoot,a,i)})):[];return{available:!0,references:q.filter(a=>a.complete).map(a=>[a.symbolId,a.references]),incompleteReferenceSymbolIds:q.filter(a=>!a.complete).map(a=>a.symbolId),...r?{callees:se.map(a=>[a.symbolId,a.callees])}:{},...n?{signatures:oe.map(a=>[a.symbolId,a.signature])}:{}}}finally{await y.shutdown().catch(()=>{})}}function Z(t){return t.referenceDefinitions??t.definitions}function X(t){return t.calleeDefinitions??t.definitions}function V(t){return t.signatureDefinitions??t.definitions}function Be(t){return[...t.includeReferences!==!1?Z(t):[],...t.includeCallees===!0?X(t):[],...t.includeSignatures===!0?V(t):[]]}async function We(t,e,r,n={}){let i=A(e,r,!1),s=await je(t,{textDocument:i.textDocument,position:i.position},n);return qe(s)}async function je(t,e,r={}){try{return await t.hover(e,r)}catch(n){if(h(n),!(n instanceof Error?n.message:String(n)).includes("content modified"))return null;await re(r.deadlineMs);try{return await t.hover(e,r)}catch(s){return h(s),null}}}function qe(t){if(!t)return null;let e=Fe(t.contents),r=/```(?:rust)?\s*([\s\S]*?)```/i.exec(e),n=r?r[1]:e;for(let i of n.split(/\r?\n/)){let s=i.replace(/^`+|`+$/g,"").trim();if(s&&Ne(s))return s}return null}function Fe(t){return typeof t=="string"?t:Array.isArray(t)?t.map(He).join(`
7
- `):"value"in t?t.value:""}function He(t){return typeof t=="string"?t:t.value}function Ne(t){return/^(?:pub(?:\([^)]*\))?\s+)?(?:async\s+)?(?:const\s+)?(?:unsafe\s+)?(?:extern\s+(?:"[^"]+"\s+)?)?(?:fn|struct|enum|trait|type|const|static|mod)\b/.test(t)}function _e(t){return{...t.length>0?{linkedProjects:t}:{},references:{excludeImports:!1,excludeTests:!1}}}function Ue(t,e){return e.length===1?O(e[0]):B(t)}function $e(t,e){let r=B(t),n=[],i=new Set;for(let s of e){let o=O(B(r,s.relativePath));for(;et(r,o);){let u=ke(o,"Cargo.toml");if(De(u)){i.has(u)||(i.add(u),n.push(u));break}let c=O(o);if(c===o)break;o=c}}return n}function Je(t,e,r){let n=new Set,i=[];for(let s of r)if(!n.has(s.relativePath)){n.add(s.relativePath);try{let o=z(e,s.relativePath);t.didOpenTextDocument({uri:o,languageId:"rust",version:1,text:w(e,s.relativePath,{inputKind:"indexed Rust source file"})}),i.push(o)}catch(o){if(!b(o))throw o}}return i}async function Ge(t,e,r){await Promise.all(e.map(n=>t.waitForDiagnostics(n,r).catch(()=>!1)))}async function zt(t,e){return(await ee(t,e)).locations}async function ee(t,e,r={}){try{return{locations:await t.references(e,{timeoutMs:r.requestTimeoutMs,deadlineMs:r.deadlineMs}),complete:!0}}catch(n){h(n);let i=n instanceof Error?n.message:String(n);if(W(n))return Ye(t,e,r);if(!i.includes("content modified"))return{locations:[],complete:!0};await re(r.deadlineMs);try{return{locations:await t.references(e,te(r)),complete:!0}}catch(s){return h(s),{locations:[],complete:!W(s)}}}}async function Ye(t,e,r){if(!r.retryTimeoutMs||r.retryTimeoutMs<=0)return{locations:[],complete:!1};let n=te(r);try{return{locations:await t.references(e,n),complete:!0}}catch(i){return h(i),{locations:[],complete:!W(i)}}}function te(t){return{...t.retryTimeoutMs&&t.retryTimeoutMs>0?{timeoutMs:t.retryTimeoutMs}:{},...t.deadlineMs!==void 0?{deadlineMs:t.deadlineMs}:{}}}function W(t){let e=t instanceof Error?t.message:String(t);return e.includes("rust-analyzer LSP request")&&e.includes("timed out after")}async function Ke(t,e,r,n={}){let i=A(e,r,!1),s=await Qe(t,{textDocument:i.textDocument,position:i.position},n),o=(await Promise.all(s.map(u=>Ze(t,u,n)))).flat();return Ve(Xe(e,o))}async function Qe(t,e,r={}){try{return await t.prepareCallHierarchy(e,r)}catch(n){return h(n),[]}}async function Ze(t,e,r={}){try{return await t.outgoingCalls(e,r)}catch(n){return h(n),[]}}async function re(t){if(t===void 0){await ne(1e3);return}await M(1e3,t)}function h(t){if(t instanceof l)throw t}function Xe(t,e){return e.map(r=>({symbol:r.to.name,file:E(t,r.to.uri),line:r.to.selectionRange.start.line}))}function Ve(t){let e=new Set,r=[];for(let n of t){let i=`${n.symbol}\0${n.file}\0${n.line}`;e.has(i)||(e.add(i),r.push(n))}return r.sort((n,i)=>n.file.localeCompare(i.file)||n.line-i.line||n.symbol.localeCompare(i.symbol))}function ne(t){return t<=0?Promise.resolve():new Promise(e=>setTimeout(e,t))}function et(t,e){return e===t||e.startsWith(`${t}${Ee}`)}async function I(t,e,r){let n=new Array(t.length),i=0,s=Math.max(1,Math.min(t.length,Math.floor(e)));return await Promise.all(Array.from({length:s},async()=>{for(;i<t.length;){let o=i++;n[o]=await r(t[o])}})),n}async function tt(){return new Promise((t,e)=>{let r=[];m.stdin.on("data",n=>r.push(n)),m.stdin.on("error",e),m.stdin.on("end",()=>t(Buffer.concat(r).toString("utf8")))})}async function rt(){try{let t=JSON.parse(await tt()),e=await Oe(t);m.stdout.write(JSON.stringify(e))}catch(t){let e={available:!1,reason:t instanceof Error?t.message:String(t),references:[]};m.stdout.write(JSON.stringify(e)),m.exitCode=1}}m.argv[1]&&Ie(import.meta.url)===m.argv[1]&&rt();export{L as a,$ as b,ut as c,be as d,lt as e,ct as f,ft as g,z as h,E as i,A as j,K as k,Q as l,Oe as m,Z as n,X as o,V as p,Be as q,We as r,je as s,qe as t,_e as u,Ue as v,$e as w,Je as x,Ge as y,zt as z,ee as A,Ke as B,ne as C,I as D};
8
- //# sourceMappingURL=chunk-A2TNXAXO.js.map
@@ -1,2 +0,0 @@
1
- function n(){return performance.now()}export{n as a};
2
- //# sourceMappingURL=chunk-APMMR5Y2.js.map
@@ -1,2 +0,0 @@
1
- import{b as r}from"./chunk-33XTHFKR.js";import{x as e}from"./chunk-RA3AYNWP.js";function l(t,s){let o=r(t,s);return e(t,o).map(({relativePath:n,...a})=>a)}export{l as a};
2
- //# sourceMappingURL=chunk-AZFUMCQB.js.map
@@ -1,33 +0,0 @@
1
- import{a as s}from"./chunk-33XTHFKR.js";function m(e,d){let i=s(e,d);return i?e.all(`SELECT DISTINCT d2.relative_path
2
- FROM mentions m
3
- JOIN chunks c ON m.chunk_id = c.id
4
- JOIN documents d1 ON c.document_id = d1.id
5
- JOIN global_symbols gs ON m.symbol_id = gs.id
6
- JOIN (
7
- SELECT m2.symbol_id, c2.document_id
8
- FROM mentions m2
9
- JOIN chunks c2 ON m2.chunk_id = c2.id
10
- WHERE m2.role = 1
11
- GROUP BY m2.symbol_id
12
- ) sym_def ON sym_def.symbol_id = gs.id
13
- JOIN documents d2 ON sym_def.document_id = d2.id
14
- WHERE d1.relative_path = ?
15
- AND d2.relative_path <> d1.relative_path
16
- AND ${e.localSymbolPredicate}
17
- ORDER BY d2.relative_path`,i).filter(t=>!e.isIgnored(t.relative_path)).map(t=>({relativePath:t.relative_path})):[]}function o(e,d){let i=s(e,d);return i?e.all(`SELECT DISTINCT d1.relative_path
18
- FROM mentions m
19
- JOIN chunks c ON m.chunk_id = c.id
20
- JOIN documents d1 ON c.document_id = d1.id
21
- JOIN global_symbols gs ON m.symbol_id = gs.id
22
- JOIN (
23
- SELECT m2.symbol_id, c2.document_id
24
- FROM mentions m2
25
- JOIN chunks c2 ON m2.chunk_id = c2.id
26
- WHERE m2.role = 1
27
- GROUP BY m2.symbol_id
28
- ) sym_def ON sym_def.symbol_id = gs.id
29
- JOIN documents d2 ON sym_def.document_id = d2.id
30
- WHERE d2.relative_path = ?
31
- AND d1.relative_path != ?
32
- ORDER BY d1.relative_path`,i,i).filter(t=>!e.isIgnored(t.relative_path)).map(t=>({relativePath:t.relative_path})):[]}export{m as a,o as b};
33
- //# sourceMappingURL=chunk-BNXICU42.js.map
@@ -1,3 +0,0 @@
1
- import{j as y}from"./chunk-46XGSFNI.js";import{execFileSync as _}from"child_process";import{createHash as k}from"crypto";import{closeSync as A,fstatSync as C,lstatSync as I,openSync as N,readdirSync as W,readFileSync as B,readlinkSync as U,realpathSync as g}from"fs";import{isAbsolute as $,join as v,relative as D,resolve as K,sep as G}from"path";function R(e,t){let n=e.split("/").at(-1)??e;if(F.has(n)||n===".scipquery.json"||/^tsconfig(?:\..+)?\.json$/.test(n))return"config";if(/\.d\.(?:ts|mts|cts)$/.test(e.toLowerCase()))return"ambient";let r=e.includes(".")?`.${e.split(".").at(-1).toLowerCase()}`:"";return t.some(o=>(x[o]??[]).includes(r))?"source":"other"}function b(e,t,n){let r=e.split("/").at(-1)??e;if(n?.includes(e)||n?.includes(r)||F.has(r))return!0;let o=e.includes(".")?`.${e.split(".").at(-1).toLowerCase()}`:"";return(x[t]??[]).includes(o)}function ne(e){if(typeof e!="object"||e===null)return null;let t=e;return typeof t.version!="number"||!j(t.languages)||typeof t.pnpmWorkspaces!="boolean"||typeof t.typescriptProjectMode!="string"||!j(t.typescriptProjects)||t.clojureConfigPath!==void 0&&typeof t.clojureConfigPath!="string"||!Array.isArray(t.files)||!t.files.every(M)?null:t}function re(e,t){let n=new Map((e?.files??[]).map(s=>[s.path,s])),r=new Map(t.files.map(s=>[s.path,s])),o=new Set([...n.keys(),...r.keys()]),a=[];for(let s of[...o].sort()){let c=n.get(s),p=r.get(s),u=R(s,t.languages);!c&&p?a.push({kind:"added",path:s,inputKind:u,after:p}):c&&!p?a.push({kind:"deleted",path:s,inputKind:u,before:c}):c&&p&&(c.hash!==p.hash||c.size!==p.size)&&a.push({kind:"modified",path:s,inputKind:u,before:c,after:p})}let i=new Set;return e||i.add("prior-snapshot-unavailable"),e&&e.version!==t.version&&i.add("snapshot-version-changed"),(m(e?.files??[])||m(t.files))&&i.add("duplicate-input-path"),[...e?.files??[],...t.files].some(L)&&i.add("unreadable-input"),{version:1,changes:a,projectIdentityChanged:e?!E(e,t):!0,uncertainty:[...i].sort()}}function j(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function m(e){return new Set(e.map(t=>t.path)).size!==e.length}function M(e){if(typeof e!="object"||e===null)return!1;let t=e;return typeof t.path=="string"&&typeof t.size=="number"&&Number.isFinite(t.size)&&typeof t.hash=="string"}function L(e){return e.hash==="unreadable"||e.size<0}function E(e,t){return P(e.languages,t.languages)&&e.pnpmWorkspaces===t.pnpmWorkspaces&&e.typescriptProjectMode===t.typescriptProjectMode&&P(e.typescriptProjects,t.typescriptProjects)&&e.clojureConfigPath===t.clojureConfigPath}function P(e,t){if(e.length!==t.length)return!1;let n=[...e].sort(),r=[...t].sort();return n.every((o,a)=>o===r[a])}var F=new Set(["package.json","package-lock.json","pnpm-lock.yaml","yarn.lock","bun.lockb","tsconfig.json","tsconfig.base.json","pyproject.toml","setup.py","setup.cfg","Cargo.toml","Cargo.lock","go.mod","go.sum","pom.xml","build.gradle","build.gradle.kts","build.sbt","compile_commands.json","CMakeLists.txt","Makefile","Gemfile","Gemfile.lock","composer.json","composer.lock","pubspec.yaml","pubspec.lock","deps.edn","project.clj","bb.edn","shadow-cljs.edn"]),x={typescript:[".ts",".tsx",".mts",".cts"],javascript:[".js",".jsx",".mjs",".cjs"],java:[".java"],scala:[".scala"],kotlin:[".kt",".kts"],rust:[".rs"],python:[".py",".pyi"],ruby:[".rb"],go:[".go"],cpp:[".cc",".cpp",".cxx",".hpp",".hh",".hxx"],c:[".c",".h"],csharp:[".cs"],vb:[".vb"],dart:[".dart"],php:[".php"],clojure:[".clj",".cljs",".cljc"]};import{isAbsolute as S,relative as O}from"path";var l=class extends Error{constructor(n,r){super(`refusing unsafe project file path ${JSON.stringify(n)} (${r})`);this.relativePath=n;this.reason=r;this.name="UnsafeProjectPathError"}relativePath;reason;code="SCIP_QUERY_UNSAFE_PROJECT_PATH"};function T(e){return e.replace(/\\/g,"/").replace(/^\.\//,"")}function se(e){return e.replace(/\\/g,"/")}function f(e,t){let n=O(e,t);return n===""||!n.startsWith("..")&&!S(n)}function w(e){if(!e)throw new l(e,"empty-path");if(e.includes("\0"))throw new l(e,"nul-byte");if(S(e)||/^[A-Za-z]:/.test(e)||e.startsWith("//")||e.startsWith("\\\\"))throw new l(e,"absolute-path");let t=T(e);if(t.split("/").some(r=>r===".."))throw new l(e,"parent-traversal");if(!t||t===".")throw new l(e,"empty-path");return t}var h=64*1024*1024,d=class extends Error{constructor(n,r,o,a){super(`${n} ${JSON.stringify(r)} is ${o} bytes; the safety limit is ${a} bytes`);this.inputKind=n;this.inputPath=r;this.observedBytes=o;this.limitBytes=a;this.name="InputTooLargeError"}inputKind;inputPath;observedBytes;limitBytes;code="SCIP_QUERY_INPUT_TOO_LARGE"};function J(e){return[...new Set((e??[]).map(t=>t.trim()).filter(Boolean))].sort((t,n)=>t.localeCompare(n))}function q(e,t,n={}){let r=w(t),o=g(e),a=K(o,...r.split("/"));if(!f(o,a)||a===o)throw new l(t,"outside-project");let i=g(a);if(!f(o,i)||i===o)throw new l(t,"outside-project");let s=I(i);if(!s.isFile())throw new l(t,"not-a-file");let c={projectRoot:o,relativePath:r,absolutePath:i,size:s.size,mtimeMs:s.mtimeMs,device:s.dev,inode:s.ino},p=n.maxBytes??h;if(H(p),c.size>p)throw new d(n.inputKind??"project file",c.relativePath,c.size,p);return c}function Y(e,t,n={}){let r=q(e,t,n),o=n.maxBytes??h,a=N(r.absolutePath,"r");try{let i=C(a);if(!i.isFile()||i.dev!==r.device||i.ino!==r.inode||i.size!==r.size)throw new l(t,"changed-during-read");if(i.size>o)throw new d(n.inputKind??"project file",r.relativePath,i.size,o);let s=B(a),c=C(a);if(c.dev!==i.dev||c.ino!==i.ino||c.size!==i.size||s.byteLength!==i.size)throw new l(t,"changed-during-read");return s}finally{A(a)}}function he(e,t,n={}){return Y(e,t,n).toString("utf8")}function ye(e){return typeof e=="object"&&e!==null&&"code"in e&&(e.code==="ENOENT"||e.code==="ENOTDIR")}function H(e){if(!Number.isSafeInteger(e)||e<0)throw new RangeError(`maxBytes must be a non-negative safe integer; received ${e}`)}function Q(e){return(V(e)??ee(e)).filter(t=>t&&!z(t)).sort()}function X(e,t={}){let n=Q(e).filter(o=>!t.language||b(o,t.language,t.markerFiles)).filter(o=>!t.includePath||t.includePath(o)),r=g(e);return n.map(o=>{let a=v(e,o);try{if(I(a).isSymbolicLink()){let c=g(a),p=D(r,c);if(p===".."||p.startsWith(`..${G}`)||$(p))throw new Error("external symlink");let u=U(a);return{path:o,size:Buffer.byteLength(u),hash:k("sha256").update("symlink\0").update(u).digest("hex")}}let i=k("sha256"),s=y(a,{inputKind:"project fingerprint input",maxBytes:h},c=>i.update(c));return{path:o,size:s,hash:i.digest("hex")}}catch{return{path:o,size:-1,hash:"unreadable"}}})}function je(e,t,n){return{version:2,languages:[...t].sort(),pnpmWorkspaces:n.typescriptProjectMode!=="workspace"&&n.pnpmWorkspaces===!0,typescriptProjectMode:n.typescriptProjectMode??"single",typescriptProjects:J(n.typescriptProjects),clojureConfigPath:Z(n.clojureConfigPath),files:X(e)}}function Z(e){return e?.trim()||void 0}function V(e){try{return _("git",["-C",e,"ls-files","-co","--exclude-standard","--","."],{encoding:"utf-8",maxBuffer:50*1024*1024,stdio:["ignore","pipe","ignore"],timeout:3e4,killSignal:"SIGKILL"}).split(`
2
- `).filter(Boolean)}catch{return null}}function ee(e){let t=[],n=[""];for(;n.length>0;){let r=n.pop(),o=r?v(e,r):e,a;try{a=W(o,{withFileTypes:!0})}catch{continue}for(let i of a){let s=r?`${r}/${i.name}`:i.name;if(i.isDirectory()){z(s)||n.push(s);continue}t.push(s)}}return t}function z(e){let t=e.split("/");return e==="meta.json"||t.some(n=>te.has(n))||e.endsWith(".db")||e.endsWith(".db-wal")||e.endsWith(".db-shm")||e.endsWith(".scip")}var te=new Set([".git","node_modules",".scipquery-cache",".scipquery-generations",".stryker-tmp","dist","build","coverage",".next",".nuxt","target"]);export{R as a,ne as b,re as c,M as d,l as e,se as f,f as g,w as h,J as i,q as j,Y as k,he as l,ye as m,X as n,je as o};
3
- //# sourceMappingURL=chunk-C5Q44Q5D.js.map
@@ -1,20 +0,0 @@
1
- import{o as O,p as A}from"./chunk-MZZBAITE.js";import{A as y,E as C,F as N,k as F,o as S,q as _}from"./chunk-JORHF5AL.js";import{a as P}from"./chunk-64MNV6AB.js";var G=C({kind:"file-dependency-graph",invalidation:N("file-dependency-graph"),serialize:e=>JSON.stringify(e),deserialize:k}),I=F("file-dep-graph",{clearGroups:["whole-project"]});function W(e,n,t={}){let s=t.scipEdges??"all-references",i=t.sourceEdges??"imports-only",o=v(n,s,i);return I.get(e,o,()=>{let d=new Set(P(e,{includeIgnored:!1})),c=_(e),p=0,l=0,m=null,E=!1,a=0,h=0;return y("file-dep-graph.product",()=>{if(c){let r=G.read(e,o,c);if(r){E=!0;let f=R(r);return p=r.sourceFileCount,l=r.sourceEdgeCount,a=r.scipEdgeCount,h=f.size,m=r.sourceDependencyFingerprint,f}}let g=y("file-dep-graph.source-imports",()=>{let r=M(e,d,n,i);return p=r.files.length,l=r.edges.length,m=r.fingerprint,r},()=>({scope:n??null,sourceEdges:i,files:p,edges:l})),u=new Map,D=(r,f)=>j(e,u,d,r,f);y("file-dep-graph.scip-edges",()=>{for(let r of $(e,n,s))a+=1,D(r.from_file,r.to_file)},()=>({scope:n??null,edges:a}));for(let r of g.edges)D(r.fromFile,r.toFile);return h=u.size,c&&G.write(e,o,c,{sourceDependencyFingerprint:g.fingerprint,sourceFileCount:g.files.length,sourceEdgeCount:g.edges.length,scipEdgeCount:a,graph:w(u)}),u},()=>({scope:n??null,available:c!==null,hit:E,files:p,sourceEdges:l,sourceEdgeMode:i,scipEdges:a,graphFiles:h,sourceDependencyFingerprint:m}))})}function M(e,n,t,s){let i=[],o=[];for(let d of n)if(!(t&&!d.includes(t))){i.push(d);for(let c of A(e,d))c.sourcePath&&o.push({fromFile:d,toFile:c.sourcePath});if(s==="imports-and-reexports")for(let c of O(e,d))c.sourcePath&&o.push({fromFile:d,toFile:c.sourcePath})}return{files:i,edges:o,fingerprint:b(i,o)}}function b(e,n){let t=n.map(s=>`${s.fromFile}\0${s.toFile}`).sort();return S(JSON.stringify({files:e,edges:t}))}function v(e,n,t){return`edge-mode-v3:${n}:${t}:${e??"<all>"}`}function w(e){return[...e].map(([n,t])=>[n,[...t]])}function R(e){return new Map(e.graph.map(([n,t])=>[n,new Set(t)]))}function k(e){let n=JSON.parse(e);return x(n)?n:null}function x(e){if(!e||typeof e!="object")return!1;let n=e;return typeof n.sourceDependencyFingerprint=="string"&&typeof n.sourceFileCount=="number"&&typeof n.sourceEdgeCount=="number"&&typeof n.scipEdgeCount=="number"&&Array.isArray(n.graph)&&n.graph.every(J)}function J(e){return Array.isArray(e)&&e.length===2&&typeof e[0]=="string"&&Array.isArray(e[1])&&e[1].every(n=>typeof n=="string")}function $(e,n,t){let s=n?"AND d1.relative_path LIKE ?":"",i=n?[`%${n}%`]:[],o=t==="imports-only"?"AND m.role = 2":"AND m.role != 1";return e.all(`SELECT DISTINCT
2
- d1.relative_path AS from_file,
3
- d2.relative_path AS to_file
4
- FROM mentions m
5
- JOIN chunks c ON m.chunk_id = c.id
6
- JOIN documents d1 ON c.document_id = d1.id
7
- JOIN global_symbols gs ON m.symbol_id = gs.id
8
- JOIN (
9
- SELECT m2.symbol_id, c2.document_id
10
- FROM mentions m2
11
- JOIN chunks c2 ON m2.chunk_id = c2.id
12
- WHERE m2.role = 1
13
- GROUP BY m2.symbol_id
14
- ) sym_def ON sym_def.symbol_id = gs.id
15
- JOIN documents d2 ON sym_def.document_id = d2.id
16
- WHERE d1.id != d2.id
17
- ${o}
18
- ${e.pathExclusionsFor("d1","d2")}
19
- ${s}`,...i)}function j(e,n,t,s,i){if(s===i||e.isIgnored(s)||e.isIgnored(i)||!t.has(i))return;let o=n.get(s);o||(o=new Set,n.set(s,o)),o.add(i)}export{W as a};
20
- //# sourceMappingURL=chunk-DQGSM7RZ.js.map
@@ -1,30 +0,0 @@
1
- import{a as X}from"./chunk-P5XHIJHI.js";import{A as ne,B as Ae,C as St,D as an,E as _e,F as te,G as Rt,H as bt,I as Ne,J as ht,L as cn,N as ln,O as un,l as dt,t as mt,u as me,x as V,y as Fe,z as ee}from"./chunk-FD3HFKXR.js";import{d as we,e as yt,f as Ee,g as Pe,h as q,r as gt}from"./chunk-LSOR3LQG.js";import{b as ft,e as $,f as Te,h as pt,j as de,s as K,t as ke}from"./chunk-RA3AYNWP.js";import{a as pe,f as Ce,n as lt,p as ut}from"./chunk-MZZBAITE.js";import{A as ct,a as nt,b as tt,o as rn,x as at}from"./chunk-WUW7YUAH.js";import{A as w,C as xe,D as on,E as sn,F as ue,H as it,J as ot,K as fe,M as st,i as Gn,k as Qn,l as Zn,o as nn,q as tn,s as Xn,u as et,y as N,z as rt}from"./chunk-JORHF5AL.js";import{a as ve}from"./chunk-64MNV6AB.js";import{g as le,i as O,k as Yn,l as H,m as Me,p as De,q as W,r as Jn,v as en}from"./chunk-VVY2G5ET.js";function It(n){let e=new Map,t=Yr(n),r=new Map;return i=>{let o=Vr(i),s=r.get(o);if(s!==void 0)return s;if(!t.has(i.file))return r.set(o,i.symbol),i.symbol;let a=e.get(i.file);a||(a=Jr(K(n,i.file)),e.set(i.file,a));let c=Gr(a,i);return r.set(o,c),c}}function Vr(n){return`${n.file}\0${n.symbol}\0${n.line}`}function Yr(n){return new Set(n.all("SELECT relative_path FROM documents").map(e=>e.relative_path))}function Jr(n){let e=new Map,t=new Map;for(let r of n){let i=e.get(r.leaf);i?i.push(r):e.set(r.leaf,[r]);let o=t.get(r.startLine);o?o.push(r):t.set(r.startLine,[r])}return{definitions:n,byLeaf:e,byStartLine:t}}function Gr(n,e){if(n.definitions.length===0)return e.symbol;let t=Xr(e.symbol),r=Qr(n.byLeaf,t),i=Zr(r,e.line);if(i)return i.symbol;let o=n.byStartLine.get(e.line)??[];return o.length===1?o[0].symbol:e.symbol}function Qr(n,e){let t=[],r=new Set;for(let i of e)for(let o of n.get(i)??[])r.has(o.symbolId)||(r.add(o.symbolId),t.push(o));return t}function Zr(n,e){let t=null;for(let r of n)if(!(r.startLine>e||r.endLine<e)){if(r.startLine===e)return r;(!t||r.endLine-r.startLine<t.endLine-t.startLine)&&(t=r)}return t}function Xr(n){let e=new Set([n]),r=n.split(/::|\.|#/).filter(Boolean).at(-1);return r&&e.add(r),e}function Mt(n,e){let r=ut(n,e).map(i=>ni(e,i));return{usage:r,positions:ti(n,e,r)}}function Dt(n,e){return{importUsage(t){let r=n.importUsageFacts(t);if(!e||r.positions.length===0)return r.usage;let i=e.importDefinitionsForFile(t,r.positions);return i.available?ei(r.usage,i.sourcePaths):r.usage}}}function ei(n,e){return n.map((t,r)=>{let i=e.get(String(r));return i?{...t,sourcePath:i}:t})}function ni(n,e){let t=e.isTypeOnly===!0,r=e.kind==="side-effect"||t||e.used;return{importer:n,sourcePath:e.sourcePath,importedName:e.importedName,localName:e.localName,kind:e.kind,isTypeOnly:t,isUsed:r,isTypeUsed:t,isValueUsed:e.kind==="side-effect"||!t&&e.used,references:[]}}function ti(n,e,t){let r=ct(n,e);if(!r)return[];let i=ri(r.rootNode),o=new Map;for(let a of i){let c=o.get(pn(a.importedName,a.localName));c?c.push(a.position):o.set(pn(a.importedName,a.localName),[a.position])}let s=[];return t.forEach((a,c)=>{let u=o.get(pn(a.importedName,a.localName??a.importedName))?.shift();u&&s.push({...u,id:String(c),file:e})}),s}function ri(n){let e=[];for(let t of n.descendantsOfType("use_declaration")){let r=t.namedChildren.find(i=>i.type!=="visibility_modifier");r&&e.push(...Le(r,""))}return e.filter(t=>t.importedName!=="*")}function Le(n,e){switch(n.type){case"identifier":case"super":case"self":case"crate":return[{importedName:n.text,localName:n.text,position:fn(n,n.text)}];case"scoped_identifier":{let t=n.text.split("::").pop()??n.text;return[{importedName:t,localName:t,position:fn(n,t)}]}case"scoped_use_list":{let t=n.namedChild(0),r=n.namedChild(1);if(!t||!r)return[];let i=lt(e,t.text);return r.namedChildren.flatMap(o=>Le(o,i))}case"use_list":return n.namedChildren.flatMap(t=>Le(t,e));case"use_as_clause":{let t=n.namedChild(0),r=n.namedChild(1);return!t||!r?[]:Le(t,e).map(i=>({...i,localName:r.text}))}case"use_wildcard":{let t=n.namedChild(0),r="*";return[{importedName:r,localName:r,position:fn(t??n,r)}]}default:return[]}}function fn(n,e){let t=Math.max(0,n.text.lastIndexOf(e));return{id:"",file:"",line:n.startPosition.row,column:n.startPosition.column+t+ii(e)}}function ii(n){return Math.max(0,Math.min(n.length-1,1))}function pn(n,e){return`${n}\0${e}`}import{spawnSync as Dn}from"child_process";import{existsSync as vn}from"fs";import{fileURLToPath as eo}from"url";function Oe(n){let e=mt(dt,n),t=e.runnable;return{available:t,dependencyAvailable:t,resolvedBinary:e.resolvedBinary??void 0,reason:t?"rust-analyzer semantic reference queries are enabled.":"rust-analyzer is not runnable; Rust semantic checks will use SCIP/source evidence only."}}import{existsSync as Oi,mkdtempSync as $t,rmSync as Rn}from"fs";import{tmpdir as Vt}from"os";import{join as bn}from"path";import{fileURLToPath as ze,pathToFileURL as Ui}from"url";import{SHARE_ENV as qi,Worker as Bi}from"worker_threads";function z(n,e,t=new Set){let r=new Map;for(let i of n)t.has(i.symbolId)||r.set(i.symbolId,e.get(i.symbolId)??[]);return r}function Y(n,e,t){let r=X(process.env.SCIP_RUST_SEMANTIC_BATCH_TIMEOUT_MS)??0;if(r>0)return r;let i=Math.max(1,Math.ceil(n/Math.max(1,t)));return Math.max(12e4,3e4+i*e)}import{spawn as Di}from"child_process";import{createHash as vi,randomUUID as xi}from"crypto";import{existsSync as Ut,realpathSync as Ci,rmSync as Ti}from"fs";import{tmpdir as ki}from"os";import{resolve as ie}from"path";import{execFileSync as pi}from"child_process";import{existsSync as oi}from"fs";import{deserializeSCIP as si,SymbolRole as ai}from"@c4312/scip";import{realpathSync as As}from"fs";import{basename as Ns,dirname as Ls,join as Os,relative as Us,sep as qs}from"path";import{fileURLToPath as js,pathToFileURL as Ws}from"url";function Ue(n){let e=new Map;for(let t of n)e.set(`${t.file}\0${t.line}\0${t.column}`,t);return[...e.values()].sort((t,r)=>{let i=t.file.localeCompare(r.file);return i!==0?i:t.line!==r.line?t.line-r.line:t.column-r.column})}var dn=new WeakMap,ci="SCIP_RUST_SCIP_OCCURRENCE_REFERENCE_MODE";function vt(n,e){let t=new Map,r=qe(),i=e.filter(s=>Tt(s,r));if(i.length===0)return t;let o=kt(n);if(!o)return t;for(let s of i){let a=Ct(o,s);a!==null&&t.set(s.symbolId,a)}return t}function xt(n,e){if(!Tt(e,qe()))return null;let t=kt(n);return t?Ct(t,e):null}function Ct(n,e){return n.referencesBySymbol.get(e.symbol)??[]}function Tt(n,e="safe"){if(!n.symbol.startsWith("rust-analyzer ")||!n.relativePath.endsWith(".rs")||de(n.symbol)||/impl#\[[^\]]+\]\[Default\]default\(\)\.$/.test(n.symbol))return!1;if(e==="all")return!0;let t=Te(n.symbol);if(t==="method")return!0;if(t!=="term")return!1;let r=ft(n.symbol);return"kind"in r?!1:!li(r)}function li(n){for(let e=0;e<n.descriptors.length-1;e+=1)if(n.descriptors[e]?.suffix==="type")return!0;return!1}function kt(n){if(dn.has(n))return dn.get(n)??null;let e=ui(n);return dn.set(n,e),e}function ui(n){if(!n.generation.indexPath||!oi(n.generation.indexPath))return null;try{let e=si(De(n.generation.indexPath,{inputKind:"SCIP occurrence-reference index",maxBytes:Me})),t=new Map;for(let r of e.documents??[]){let i=r.relativePath;if(!(!i||n.isIgnored(i)))for(let o of r.occurrences??[]){if(!o.symbol||(o.symbolRoles&ai.Definition)!==0)continue;let s=fi(i,o.range);if(!s)continue;let a=t.get(o.symbol)??[];a.push(s),t.set(o.symbol,a)}}for(let[r,i]of t)t.set(r,Ue(i));return{referencesBySymbol:t}}catch{return null}}function fi(n,e){if(e.length<3)return null;let t=e[0],r=e[1];return!Number.isInteger(t)||!Number.isInteger(r)?null:{file:n,line:t,column:r}}function qe(){return process.env[ci]==="all"?"all":"safe"}var wt=new Map;function mn(n){let t=Oe(n).resolvedBinary??null;return{engine:"rust-analyzer",resolvedBinary:t,version:t?di(n,t):"unavailable"}}function yn(n){return{...mn(n),scipOccurrenceReferenceMode:qe()}}function di(n,e){let t=`${n}\0${e}`,r=wt.get(t);if(r)return r;let i;try{i=pi(e,["--version"],{cwd:n,encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:2e3}).trim()}catch{i="unknown"}return wt.set(t,i),i}import{createHash as mi}from"crypto";var yi=new Set(["Cargo.lock","Cargo.toml","rust-project.json","rust-toolchain","rust-toolchain.toml"]);function Et(n){let e=st(n,{includePath:Si});return mi("sha256").update(JSON.stringify(e)).digest("hex")}function Si(n){let e=n.replaceAll("\\","/"),t=e.split("/").at(-1)??e;return e.endsWith(".rs")||yi.has(t)?!0:e===".cargo/config"||e===".cargo/config.toml"||e.endsWith("/.cargo/config")||e.endsWith("/.cargo/config.toml")}import{createHash as gi}from"crypto";import{resolve as Ri}from"path";var re=3;function gn(n){return gi("sha256").update(me({kind:"scip-query-durable-rust-mailbox",protocolVersion:re,sessionDir:Ri(n)})).digest("hex")}function At(n,e){return le(n)?n.protocolVersion!==re?Ft(n.protocolVersion===void 0?"helper wrote a prior uncorrelated response protocol":`helper wrote unsupported response protocol ${String(n.protocolVersion)}`):n.mailboxVersion!==V||n.id!==e.requestId||n.operationKey!==e.operationKey||n.sessionIdentity!==e.sessionIdentity||n.deadlineAtMs!==e.deadlineAtMs?Ft("helper wrote an incompatible response identity"):typeof n.completedAtMs!="number"||!Number.isFinite(n.completedAtMs)||n.completedAtMs>e.deadlineAtMs||e.nowMs>e.deadlineAtMs?{ok:!1,code:"expired-request",error:"helper response arrived after the durable request deadline"}:n.ok===!1?typeof n.error!="string"||!Mi(n.errorCode)?Sn("helper wrote an invalid rejection response"):{ok:!1,code:n.errorCode,error:n.error}:n.ok!==!0||n.session!=="created"&&n.session!=="reused"&&n.session!=="invalidated"||!bi(n.response,e.requestKind)?Sn("helper wrote an invalid success response"):{ok:!0,session:n.session,response:n.response}:Sn("helper wrote an invalid response object")}function bi(n,e){return!le(n)||typeof n.available!="boolean"||n.reason!==void 0&&typeof n.reason!="string"?!1:e==="import-definitions"?Array.isArray(n.sourcePaths)&&n.sourcePaths.every(t=>Array.isArray(t)&&t.length===2&&typeof t[0]=="string"&&(t[1]===null||typeof t[1]=="string")):Pt(n.references,hi)&&(n.incompleteReferenceSymbolIds===void 0||Array.isArray(n.incompleteReferenceSymbolIds)&&n.incompleteReferenceSymbolIds.every(t=>Number.isSafeInteger(t)))&&(n.callees===void 0||Pt(n.callees,Ii))&&(n.signatures===void 0||Array.isArray(n.signatures)&&n.signatures.every(t=>Array.isArray(t)&&t.length===2&&Number.isSafeInteger(t[0])&&(t[1]===null||typeof t[1]=="string")))}function Pt(n,e){return Array.isArray(n)&&n.every(t=>Array.isArray(t)&&t.length===2&&Number.isSafeInteger(t[0])&&Array.isArray(t[1])&&t[1].every(e))}function hi(n){return le(n)&&typeof n.file=="string"&&O(n.line)&&O(n.column)}function Ii(n){return le(n)&&typeof n.symbol=="string"&&typeof n.file=="string"&&O(n.line)}function Mi(n){return n==="unsupported-protocol"||n==="malformed-request"||n==="expired-request"||n==="handler-error"}function Sn(n){return{ok:!1,code:"malformed-response",error:n}}function Ft(n){return{ok:!1,code:"incompatible-response",error:n}}var wi=5e3,qt=10,Ei=3e4;function _t(n,e,t,r=zt){let i=r.engineIdentity(n),o={protocolVersion:re,projectRoot:r.canonicalProjectRoot(n),projectFingerprint:r.projectFingerprint(n),engine:{engine:i.engine,resolvedBinary:i.resolvedBinary,version:i.version},workerFingerprint:r.fileFingerprint(e),environment:jt(r.environment())};return{key:Ht(me(o)),...o}}function Be(n,e,t,r){if(n.protocolVersion!==re||!t(n.pid))return!1;if(!n.processIdentity)return!0;let i=r?.(n.pid);return i!=null&&Ee(n.processIdentity,i)}function Bt(n,e,t){let r;try{r=en(e,{maxBytes:H,inputKind:"Rust semantic engine artifact"})}catch{r="missing"}let i=Ht(me({projectRoot:ie(n),serverPath:ie(e),serverFingerprint:r})).slice(0,20);return ie(t,`scip-query-rust-session-${i}`)}function Nt(n){let e=n===void 0?Number.NaN:Number(n);return Number.isInteger(e)&&e>=0?e:0}function jt(n){return Object.fromEntries(Object.entries(n).filter(([e])=>Kt(e)).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>[e,t??null]))}function Wt(n,e){let t=e.runtime??Li,r=e.identityRuntime??zt,i=Bt(n,e.serverPath,e.tempRoot??ki()),o=!1,s=(a,c)=>{if(o)throw new Error("Durable Rust semantic session was already disposed.");return Fi(i,e.serverPath,e.semanticWorkerPath,a,c,t,e.mailboxLimits)};return{requestSemantic(a,c){let u=_t(n,e.semanticWorkerPath,a,r),{readinessDeadlineMs:f,...l}=a;return s({kind:"semantic",identityKey:u.key,workerEnvironment:Ot(),request:{...l,referenceRetryTimeoutMs:Pi(process.env.SCIP_RUST_SEMANTIC_REFERENCE_RETRY_TIMEOUT_MS,a.referenceRetryTimeoutMs),settleDelayMs:process.env.SCIP_RUST_SEMANTIC_SETTLE_MS===void 0?a.settleDelayMs:Nt(process.env.SCIP_RUST_SEMANTIC_SETTLE_MS)},timeoutMs:c},c)},requestImportDefinitions(a,c){let u=_t(n,e.semanticWorkerPath,a,r),{readinessDeadlineMs:f,...l}=a;return s({kind:"import-definitions",identityKey:u.key,workerEnvironment:Ot(),request:{...l,settleDelayMs:process.env.SCIP_RUST_SEMANTIC_SETTLE_MS===void 0?a.settleDelayMs:Nt(process.env.SCIP_RUST_SEMANTIC_SETTLE_MS)},timeoutMs:c},c)},shutdown(){o=!0}}}function Pi(n,e){return e!==void 0?e:n===void 0?Ei:void 0}function Fi(n,e,t,r,i,o,s={}){let a=o.now(),c=a+i,u=(o.monotonicNow??q)(),f=u+i,l=ee("rust-semantic-v3",r),p=ne(l),d=Fe(n),S=gn(n),h=Ae(d,{mailboxVersion:V,protocolVersion:re,id:p,operationKey:l,clientId:o.randomId(),enqueuedAtMs:a,deadlineAtMs:c,sessionIdentity:S,request:r},{nowMs:a,limits:s});for(Lt(n,e,t,f,o);(o.monotonicNow??q)()<=f;){if(Ut(h.responsePath)){let y=Ai(W(h.responsePath,{maxBytes:s.maxItemBytes??H,inputKind:"durable Rust semantic mailbox response"}),{requestId:p,operationKey:l,sessionIdentity:S,deadlineAtMs:h.authoritativeDeadlineAtMs,requestKind:r.kind,nowMs:o.now()});if(!y.ok)throw new Error(y.error);return N()&&xe({type:"span",name:"rust.semantic.durable-session.request",durationMs:(o.monotonicNow??q)()-u,ok:!0,session:y.session,kind:r.kind}),y.response}let g=je(n);(!g||!Be(g,o.now(),o.isProcessAlive,o.readProcessIdentity))&&Lt(n,e,t,f,o),o.sleep(qt)}throw new Error(`Durable Rust semantic session timed out after ${(i/1e3).toFixed(0)}s.`)}function Lt(n,e,t,r,i){let o=je(n);if(o&&Be(o,i.now(),i.isProcessAlive,i.readProcessIdentity))return;Ti(ie(n,"server.json"),{force:!0}),i.spawnServer(e,n,t);let s=i.monotonicNow??q,a=Math.min(r,s()+wi);for(;s()<=a;){let c=je(n);if(c&&Be(c,i.now(),i.isProcessAlive,i.readProcessIdentity))return;i.sleep(qt)}throw new Error("Durable Rust semantic session helper did not become ready within 5s.")}function je(n){try{let e=JSON.parse(W(ie(n,"server.json"),{maxBytes:Yn,inputKind:"durable Rust session state"}));if(typeof e.protocolVersion!="number"||e.sessionIdentity!==void 0&&(typeof e.sessionIdentity!="string"||e.sessionIdentity!==gn(n))||typeof e.pid!="number"||typeof e.heartbeatAtMs!="number"||e.busyUntilMs!==void 0&&typeof e.busyUntilMs!="number"||e.mailbox!==void 0&&!_i(e.mailbox))return null;let t=e.processIdentity===void 0?null:yt(e.processIdentity);return e.processIdentity!==void 0&&(!t||t.pid!==e.pid)?null:{protocolVersion:e.protocolVersion,...e.sessionIdentity===void 0?{}:{sessionIdentity:e.sessionIdentity},pid:e.pid,...t?{processIdentity:t}:{},heartbeatAtMs:e.heartbeatAtMs,...e.busyUntilMs===void 0?{}:{busyUntilMs:e.busyUntilMs},...e.mailbox===void 0?{}:{mailbox:e.mailbox}}}catch{return null}}function Ai(n,e){try{return At(JSON.parse(n),e)}catch(t){return{ok:!1,code:"malformed-response",error:`helper wrote malformed JSON: ${t instanceof Error?t.message:String(t)}`}}}function _i(n){if(!n||typeof n!="object")return!1;let e=n;return O(e.pending)&&O(e.inflight)&&O(e.responses)&&O(e.deadLetters)&&O(e.invalid)&&O(e.totalItems)&&typeof e.totalBytes=="number"&&Number.isFinite(e.totalBytes)&&e.totalBytes>=0&&(e.oldestPendingAt===void 0||Number.isFinite(Date.parse(e.oldestPendingAt)))}function Ot(){return Object.fromEntries(Object.entries(process.env).filter(([n])=>Ni(n)).sort(([n],[e])=>n.localeCompare(e)).map(([n,e])=>[n,e??null]))}function Kt(n){return n==="HOME"||n==="PATH"||n.startsWith("CARGO_")||n.startsWith("RA_")||n.startsWith("RUST")}function Ni(n){return Kt(n)||n.startsWith("SCIP_RUST_")||n==="SCIP_QUERY_PROFILE"||n==="SCIP_QUERY_PROFILE_CACHE_STATE"||n==="SCIP_QUERY_PROFILE_COMMAND"||n==="SCIP_QUERY_PROFILE_OUT"||n==="SCIP_QUERY_PROFILE_RUN_ID"||n==="SCIP_QUERY_PROFILE_WORKLOAD_IDENTITY"||n==="SCIP_QUERY_PROFILE_WORKLOAD_IDENTITY_KIND"||n==="SCIP_QUERY_PROFILE_MIN_MS"}var zt={canonicalProjectRoot(n){try{return Ci(n)}catch{return ie(n)}},projectFingerprint(n){return Et(n)},engineIdentity:mn,fileFingerprint(n){return en(n,{maxBytes:H,inputKind:"Rust semantic engine artifact"})},environment(){return jt(process.env)}},Li={now:Date.now,monotonicNow:q,randomId:xi,isProcessAlive:we,readProcessIdentity:Pe,spawnServer(n,e,t){if(!Ut(n))throw new Error(`Durable Rust semantic session helper was not found at ${n}. Run npm run build first.`);Di(process.execPath,[n,e,t],{detached:!0,stdio:"ignore"}).unref()},sleep(n){let e=new Int32Array(new SharedArrayBuffer(4));Atomics.wait(e,0,0,n)}};function Ht(n){return vi("sha256").update(n).digest("hex")}var Yt=15e3,Jt=8,Qt=5e3,ji=64,Wi=96,In=class{constructor(e,t,r={}){this.projectRoot=e;this.status=t;this.opts=r;this.requester=r.requester??$i(e,process.env.SCIP_RUST_SEMANTIC_DURABLE_SESSION)}projectRoot;status;opts;requester;referencesForDefinitions(e){let t=this.status(this.projectRoot);if(!t.available||!t.resolvedBinary)return{available:!1,resolvedBinary:t.resolvedBinary,reason:t.reason,references:ye(e)};try{let r=this.requestSession(t.resolvedBinary,e,{includeReferences:!0});return{available:r.available,resolvedBinary:t.resolvedBinary,reason:r.reason,references:z(e,new Map(r.references),new Set(r.incompleteReferenceSymbolIds??[]))}}catch(r){return this.opts.fallbackReferenceResolver?.referencesForDefinitions(e)??{available:!1,resolvedBinary:t.resolvedBinary,reason:r instanceof Error?r.message:String(r),references:ye(e)}}}calleesForDefinitions(e){let t=this.status(this.projectRoot);if(!t.available||!t.resolvedBinary)return{available:!1,resolvedBinary:t.resolvedBinary,reason:t.reason,callees:Se(e)};try{let r=this.requestSession(t.resolvedBinary,e,{includeReferences:!1,includeCallees:!0});return{available:r.available,resolvedBinary:t.resolvedBinary,reason:r.reason,callees:hn(e,new Map(r.callees??[]))}}catch(r){return this.opts.fallbackCalleeResolver?.calleesForDefinitions(e)??{available:!1,resolvedBinary:t.resolvedBinary,reason:r instanceof Error?r.message:String(r),callees:Se(e)}}}referencesAndCalleesForDefinitions(e,t){let r=this.status(this.projectRoot);if(!r.available||!r.resolvedBinary)return{available:!1,resolvedBinary:r.resolvedBinary,reason:r.reason,references:ye(e),callees:Se(t)};let i=[...e,...t];try{let o=this.requestSession(r.resolvedBinary,i,{includeReferences:e.length>0,includeCallees:t.length>0,referenceDefinitions:e,calleeDefinitions:t});return{available:o.available,resolvedBinary:r.resolvedBinary,reason:o.reason,references:z(e,new Map(o.references),new Set(o.incompleteReferenceSymbolIds??[])),callees:hn(t,new Map(o.callees??[]))}}catch(o){return this.fallbackReferencesAndCallees(r,e,t,o)}}signaturesForDefinitions(e){let t=this.status(this.projectRoot);if(!t.available||!t.resolvedBinary)return{available:!1,resolvedBinary:t.resolvedBinary,reason:t.reason,signatures:Gt(e)};try{let r=this.requestSession(t.resolvedBinary,e,{includeReferences:!1,includeCallees:!1,includeSignatures:!0});return{available:r.available,resolvedBinary:t.resolvedBinary,reason:r.reason,signatures:Qi(e,new Map(r.signatures??[]))}}catch(r){return this.opts.fallbackSignatureResolver?.signaturesForDefinitions(e)??{available:!1,resolvedBinary:t.resolvedBinary,reason:r instanceof Error?r.message:String(r),signatures:Gt(e)}}}importDefinitionsForFile(e,t){let r=this.status(this.projectRoot);if(t.length===0)return{available:r.available,resolvedBinary:r.resolvedBinary,reason:r.reason,sourcePaths:new Map};if(!r.available||!r.resolvedBinary)return{available:!1,resolvedBinary:r.resolvedBinary,reason:r.reason,sourcePaths:new Map(t.map(i=>[i.id,null]))};try{let i=this.requestImportDefinitions(r.resolvedBinary,e,t);return{available:i.available,resolvedBinary:r.resolvedBinary,reason:i.reason,sourcePaths:new Map(i.sourcePaths)}}catch(i){return{available:!1,resolvedBinary:r.resolvedBinary,reason:i instanceof Error?i.message:String(i),sourcePaths:new Map(t.map(o=>[o.id,null]))}}}dispose(){this.requester.shutdown()}requestSession(e,t,r){let i=We(process.env.SCIP_RUST_SEMANTIC_REQUEST_TIMEOUT_MS,Yt),o=Ke(process.env.SCIP_RUST_SEMANTIC_REFERENCE_RETRY_TIMEOUT_MS,0),s=We(process.env.SCIP_RUST_SEMANTIC_CONCURRENCY,Jt),a=Ke(process.env.SCIP_RUST_SEMANTIC_DIAGNOSTICS_TIMEOUT_MS,Math.min(i,1e4)),c=r.referenceDefinitions?[...r.referenceDefinitions]:void 0,u=r.calleeDefinitions?[...r.calleeDefinitions]:void 0,f=r.signatureDefinitions?[...r.signatureDefinitions]:void 0,l=ge(process.env.SCIP_RUST_SEMANTIC_SETTLE_MS,{definitionCount:t.length,...r}),p={projectRoot:this.projectRoot,rustAnalyzerBinary:e,definitions:[...t],...c?{referenceDefinitions:c}:{},...u?{calleeDefinitions:u}:{},...f?{signatureDefinitions:f}:{},requestTimeoutMs:i,...r.includeReferences!==!1&&o>0?{referenceRetryTimeoutMs:o}:{},diagnosticsTimeoutMs:a,settleDelayMs:l,concurrency:s,includeReferences:r.includeReferences,includeCallees:r.includeCallees,includeSignatures:r.includeSignatures},d=Zi(p);return w("rust.semantic.session.request",()=>this.requester.requestSemantic(p,Y(d,Mn(i,p.referenceRetryTimeoutMs),s)),()=>({definitions:t.length,operationDefinitions:d,referenceDefinitions:p.referenceDefinitions?.length,calleeDefinitions:p.calleeDefinitions?.length,signatureDefinitions:p.signatureDefinitions?.length,references:p.includeReferences!==!1,callees:p.includeCallees===!0,signatures:p.includeSignatures===!0,referenceRetryTimeoutMs:p.referenceRetryTimeoutMs}))}fallbackReferencesAndCallees(e,t,r,i){let o=t.length===0?{available:!0,references:ye(t)}:this.opts.fallbackReferenceResolver?.referencesForDefinitions(t),s=r.length===0?{available:!0,callees:Se(r)}:this.opts.fallbackCalleeResolver?.calleesForDefinitions(r);return o&&s?{available:o.available&&s.available,resolvedBinary:o.resolvedBinary??s.resolvedBinary??e.resolvedBinary,reason:o.reason??s.reason,references:z(t,o.references),callees:hn(r,s.callees)}:{available:!1,resolvedBinary:e.resolvedBinary,reason:i instanceof Error?i.message:String(i),references:ye(t),callees:Se(r)}}requestImportDefinitions(e,t,r){let i=We(process.env.SCIP_RUST_SEMANTIC_REQUEST_TIMEOUT_MS,Yt),o=We(process.env.SCIP_RUST_SEMANTIC_CONCURRENCY,Jt),s=Ke(process.env.SCIP_RUST_SEMANTIC_DIAGNOSTICS_TIMEOUT_MS,Math.min(i,1e4)),a=Ke(process.env.SCIP_RUST_SEMANTIC_SETTLE_MS,Qt),c={projectRoot:this.projectRoot,rustAnalyzerBinary:e,file:t,positions:[...r],requestTimeoutMs:i,diagnosticsTimeoutMs:s,settleDelayMs:a,concurrency:o};return w("rust.semantic.import-definitions.session.request",()=>this.requester.requestImportDefinitions(c,Y(r.length,i,o)),()=>({file:t,positions:r.length}))}};function Zt(n,e,t={}){return new In(n,e,t)}function ge(n,e){let t=er(n);if(t!==null)return t;let r=e.includeReferences!==!1;return r&&e.includeCallees!==!0&&e.includeSignatures!==!0&&e.definitionCount<=ji||r&&e.includeCallees===!0&&e.includeSignatures!==!0&&e.definitionCount<=Wi?0:Qt}function Ki(n){let e=n?.trim().toLowerCase(),t=e==="0"||e==="false"||e==="off"||e==="worker",r=e==="1"||e==="true"||e==="on"||e==="durable",i=e===void 0||e==="";return{transport:t||!i&&!r?"worker":"durable",source:i?"default":"environment",fallback:"worker",valid:i||t||r,optOut:"SCIP_RUST_SEMANTIC_DURABLE_SESSION=0"}}function zi(n){return Ki(n).transport}function Hi(n,e){let t=null,r=!1,i=!1,o=!1,s=()=>t??=e(),a=()=>{i||(n.shutdown(),i=!0)},c=(f,l,p)=>{let d=Gi(f);r=!0;try{a()}catch{}N()&&xe({type:"span",name:"rust.semantic.durable-session.request",durationMs:p,ok:!1,kind:l,session:"worker-fallback",reason:d})},u=(f,l,p)=>{if(o)throw new Error("Rust semantic failover session was already disposed.");if(r)return p(s());let d=performance.now();try{return l(n)}catch(S){c(S,f,performance.now()-d)}return p(s())};return{requestSemantic(f,l){return u("semantic",p=>p.requestSemantic(f,l),p=>p.requestSemantic(f,l))},requestImportDefinitions(f,l){return u("import-definitions",p=>p.requestImportDefinitions(f,l),p=>p.requestImportDefinitions(f,l))},shutdown(){if(o)return;o=!0;let f=[];try{a()}catch(l){f.push(l)}try{t?.shutdown()}catch(l){f.push(l)}if(f.length>0)throw f[0]}}}function $i(n,e,t={worker:()=>Vi(),durable:()=>Wt(n,{serverPath:ze(Xi()),semanticWorkerPath:ze(Xt())})}){return zi(e)==="durable"?Hi(t.durable(),t.worker):t.worker()}function Vi(n={}){let e=null,t=null,r=1,i=!1,o=()=>{t&&(Rn(t,{recursive:!0,force:!0}),t=null)},s=()=>{let u=e;e=null,u&&u.terminate(),o()},a=()=>{if(e)return e;let u=n.semanticWorkerPath?Ui(n.semanticWorkerPath):Xt();if(!Oi(ze(u)))throw new Error(`Rust semantic session worker was not found at ${ze(u)}. Run npm run build before using built semantic Rust queries.`);return t=$t(bn(Vt(),"scip-query-rust-session-")),e=new Bi(u,n.shareEnvironment?{env:qi}:void 0),e.unref(),e},c=()=>{let u=t??$t(bn(Vt(),"scip-query-rust-session-"));return t=u,bn(u,`${r++}.json`)};return{requestSemantic(u,f){if(i)throw new Error("Rust semantic session was already disposed.");let l=a(),p=c(),d=new SharedArrayBuffer(4),S=new Int32Array(d);if(l.postMessage({kind:"semantic",request:u,responsePath:p,sharedBuffer:d}),Atomics.wait(S,0,0,f)==="timed-out")throw s(),new Error(`Rust semantic session worker timed out after ${(f/1e3).toFixed(0)}s`);try{let g=Yi(W(p,{maxBytes:H,inputKind:"Rust semantic worker response"}));if(!g.ok)throw new Error(g.error);return g.response}finally{Rn(p,{force:!0})}},requestImportDefinitions(u,f){if(i)throw new Error("Rust semantic session was already disposed.");let l=a(),p=c(),d=new SharedArrayBuffer(4),S=new Int32Array(d);if(l.postMessage({kind:"import-definitions",request:u,responsePath:p,sharedBuffer:d}),Atomics.wait(S,0,0,f)==="timed-out")throw s(),new Error(`Rust semantic import-definition session worker timed out after ${(f/1e3).toFixed(0)}s`);try{let g=Ji(W(p,{maxBytes:H,inputKind:"Rust import-definition worker response"}));if(!g.ok)throw new Error(g.error);return g.response}finally{Rn(p,{force:!0})}},shutdown(){if(i)return;if(i=!0,!e){o();return}let u=c(),f=new SharedArrayBuffer(4),l=new Int32Array(f);e.postMessage({kind:"shutdown",responsePath:u,sharedBuffer:f}),Atomics.wait(l,0,0,5e3),s()}}}function Yi(n){let e=JSON.parse(n);if(!e||typeof e!="object")return{ok:!1,error:"Rust semantic session worker wrote a non-object response."};let t=e;return t.ok===!0&&"response"in t?{ok:!0,response:t.response}:{ok:!1,error:typeof e.error=="string"?e.error:"Rust semantic session worker failed."}}function Ji(n){let e=JSON.parse(n);if(!e||typeof e!="object")return{ok:!1,error:"Rust semantic session worker wrote a non-object response."};let t=e;return t.ok===!0&&"response"in t?{ok:!0,response:t.response}:{ok:!1,error:typeof e.error=="string"?e.error:"Rust semantic session worker failed."}}function Gi(n){let e=n instanceof Error?`${n.name} ${n.message}`.toLowerCase():String(n).toLowerCase();return e.includes("readiness")?"readiness":e.includes("timeout")||e.includes("timed out")?"timeout":e.includes("helper")?"helper":"request"}function ye(n){return new Map(n.map(e=>[e.symbolId,[]]))}function Se(n){return new Map(n.map(e=>[e.symbolId,[]]))}function Gt(n){return new Map(n.map(e=>[e.symbolId,null]))}function hn(n,e){return new Map(n.map(t=>[t.symbolId,e.get(t.symbolId)??[]]))}function Qi(n,e){return new Map(n.map(t=>[t.symbolId,e.get(t.symbolId)??null]))}function Zi(n){let e=0;return n.includeReferences!==!1&&(e+=(n.referenceDefinitions??n.definitions).length),n.includeCallees===!0&&(e+=(n.calleeDefinitions??n.definitions).length),n.includeSignatures===!0&&(e+=(n.signatureDefinitions??n.definitions).length),Math.max(1,e)}function Mn(n,e){return e&&e>0?Math.max(n,e):n}function Xt(){return new URL("./rust-semantic-session-worker.js",import.meta.url)}function Xi(){return new URL("./rust-semantic-session-server.js",import.meta.url)}function We(n,e){return X(n)??e}function Ke(n,e){return er(n)??e}function er(n){if(!n)return null;let e=Number(n);return Number.isInteger(e)&&e>=0?e:null}var xn=15e3,Cn=8;function ir(n,e={}){let t=e.status??Oe,r=ro(n,t),i=io(n,t),o=oo(n,t),s=e.referenceResolver||e.calleeResolver||e.signatureResolver||!no(e)?null:Zt(n,t,{fallbackReferenceResolver:r,fallbackCalleeResolver:i,fallbackSignatureResolver:o}),a=e.referenceResolver??s??r,c=e.calleeResolver??s??i,u=e.signatureResolver??s??o,f=e.importUsageResolver??Dt(e.sourceImportUsageResolver??to(),e.importDefinitionResolver??s),l=e.calleeSymbolResolver,p=e.sourceZeroCalleeOracle,d=e.scipOccurrenceCalleeOracle,S=new Map,h=new Map,g=null,y=null,k=()=>(g??=t(n),g),P=()=>{let R=k();return R.dependencyAvailable?y??R:R},I=R=>{if(R.length===0)return new Map;let m=Re(R);try{let b=a.referencesForDefinitions(m),T=k();return y={...T,available:b.available,resolvedBinary:b.resolvedBinary??T.resolvedBinary,reason:b.reason??T.reason},b.available?new Map(b.references):z(m,b.references)}catch(b){return y={...k(),available:!1,reason:b instanceof Error?b.message:String(b)},J(m)}},C=R=>{if(R.length===0)return new Map;let m=Re(R),b=m.filter(nr);if(b.length===0)return G(m);let T=new Map,j=rr(b,d),A=[];for(let D of b)h.has(D.symbolId)?T.set(D.symbolId,h.get(D.symbolId)??[]):j.has(D.symbolId)?T.set(D.symbolId,j.get(D.symbolId)??[]):tr(D,p)?T.set(D.symbolId,[]):A.push(D);if(A.length===0)return oe(m,T,void 0);try{let D=c.calleesForDefinitions(A),_=k();y={..._,available:D.available,resolvedBinary:D.resolvedBinary??_.resolvedBinary,reason:D.reason??_.reason};let E=oe(A,D.callees,l);for(let[Z,Qe]of E)T.set(Z,Qe);return oe(m,T,void 0)}catch(D){return y={...k(),available:!1,reason:D instanceof Error?D.message:String(D)},G(m)}},x=(R,m)=>{let b=Re(R),T=Re(m),j=T.filter(nr),A=new Map,D=rr(j,d),_=[];for(let E of j)D.has(E.symbolId)?A.set(E.symbolId,D.get(E.symbolId)??[]):tr(E,p)?A.set(E.symbolId,[]):_.push(E);if(b.length===0&&_.length===0)return{references:J(b),callees:oe(T,A,void 0)};try{let E=s?s.referencesAndCalleesForDefinitions(b,_):lo(a,c,{referenceDefinitions:b,calleeDefinitions:_}),Z=k();y={...Z,available:E.available,resolvedBinary:E.resolvedBinary??Z.resolvedBinary,reason:E.reason??Z.reason};let Qe=E.available?new Map(E.references):z(b,E.references);for(let[Ze,Xe]of E.callees)A.set(Ze,Xe);let Vn=oe(T,A,l);for(let[Ze,Xe]of Vn)h.set(Ze,Xe);return{references:Qe,callees:Vn}}catch(E){return y={...k(),available:!1,reason:E instanceof Error?E.message:String(E)},{references:J(b),callees:G(T)}}},M=R=>{if(R.length===0)return new Map;let m=Re(R);try{let b=u.signaturesForDefinitions(m),T=k();return y={...T,available:b.available,resolvedBinary:b.resolvedBinary??T.resolvedBinary,reason:b.reason??T.reason},or(m,b.signatures)}catch(b){return y={...k(),available:!1,reason:b instanceof Error?b.message:String(b)},He(m)}};return{language:"rust",availability:P,dispose:()=>{s?.dispose()},importUsage:R=>{let m=S.get(R);if(m)return m;try{let b=f.importUsage(R);return S.set(R,b),b}catch(b){return y={...k(),available:!1,reason:b instanceof Error?b.message:String(b)},[]}},referencesFor:R=>I([R]).get(R.symbolId)??[],referencesForDefinitions:I,referencesAndCalleesForDefinitions:x,calleesFor:R=>C([R]).get(R.symbolId)??[],calleesForDefinitions:C,signatureFor:R=>M([R]).get(R.symbolId)??null}}function no(n){if(n.usePersistentSession!==void 0)return n.usePersistentSession;let e=process.env.SCIP_RUST_SEMANTIC_SESSION;return e!=="0"&&e!=="false"}function to(){return{importUsageFacts:()=>({usage:[],positions:[]})}}function Re(n){return n.map(e=>{let t=e;return{...e,leaf:typeof t.leaf=="string"?t.leaf:$(e.symbol),parentTypeName:t.parentTypeName??null,isFunctionLike:typeof t.isFunctionLike=="boolean"?t.isFunctionLike:pt(e.symbol),isTypeLike:t.isTypeLike??!1,kind:t.kind??null,documentation:t.documentation??null,enclosingSymbol:t.enclosingSymbol??null}})}function nr(n){return n.isFunctionLike}function tr(n,e){if(!e)return!1;try{return e(n)}catch{return!1}}function rr(n,e){if(!e||n.length===0)return new Map;try{return e(n)}catch{return new Map}}function ro(n,e){return{referencesForDefinitions:t=>so(n,e,t)}}function io(n,e){return{calleesForDefinitions:t=>ao(n,e,t)}}function oo(n,e){return{signaturesForDefinitions:t=>co(n,e,t)}}function so(n,e,t){let r=e(n);if(!r.available||!r.resolvedBinary)return{available:!1,resolvedBinary:r.resolvedBinary,reason:r.reason,references:J(t)};let i=Tn();if(!vn(i))return{available:!1,resolvedBinary:r.resolvedBinary,reason:`Rust semantic worker was not found at ${i}. Run npm run build before using built semantic Rust queries.`,references:J(t)};let o=se(process.env.SCIP_RUST_SEMANTIC_REQUEST_TIMEOUT_MS,xn),s=$e(process.env.SCIP_RUST_SEMANTIC_REFERENCE_RETRY_TIMEOUT_MS,0),a=se(process.env.SCIP_RUST_SEMANTIC_CONCURRENCY,Cn),c=$e(process.env.SCIP_RUST_SEMANTIC_DIAGNOSTICS_TIMEOUT_MS,Math.min(o,1e4)),u=ge(process.env.SCIP_RUST_SEMANTIC_SETTLE_MS,{definitionCount:t.length,includeReferences:!0}),f={projectRoot:n,rustAnalyzerBinary:r.resolvedBinary,definitions:[...t],requestTimeoutMs:o,...s>0?{referenceRetryTimeoutMs:s}:{},diagnosticsTimeoutMs:c,settleDelayMs:u,concurrency:a},l=Dn(process.execPath,[i],{cwd:n,input:JSON.stringify(f),encoding:"utf8",maxBuffer:50*1024*1024,timeout:Y(t.length,Mn(o,f.referenceRetryTimeoutMs),a)}),p=kn(l.stdout);if(p)return{available:p.available,resolvedBinary:r.resolvedBinary,reason:p.reason,references:z(t,new Map(p.references),new Set(p.incompleteReferenceSymbolIds??[]))};let d=l.error instanceof Error?l.error.message:l.stderr.trim()||`Rust semantic worker exited with status ${l.status??"unknown"}.`;return{available:!1,resolvedBinary:r.resolvedBinary,reason:d,references:J(t)}}function ao(n,e,t){let r=e(n);if(!r.available||!r.resolvedBinary)return{available:!1,resolvedBinary:r.resolvedBinary,reason:r.reason,callees:G(t)};let i=Tn();if(!vn(i))return{available:!1,resolvedBinary:r.resolvedBinary,reason:`Rust semantic worker was not found at ${i}. Run npm run build before using built semantic Rust queries.`,callees:G(t)};let o=se(process.env.SCIP_RUST_SEMANTIC_REQUEST_TIMEOUT_MS,xn),s=se(process.env.SCIP_RUST_SEMANTIC_CONCURRENCY,Cn),a=$e(process.env.SCIP_RUST_SEMANTIC_DIAGNOSTICS_TIMEOUT_MS,Math.min(o,1e4)),c=ge(process.env.SCIP_RUST_SEMANTIC_SETTLE_MS,{definitionCount:t.length,includeReferences:!1,includeCallees:!0}),u={projectRoot:n,rustAnalyzerBinary:r.resolvedBinary,definitions:[...t],requestTimeoutMs:o,diagnosticsTimeoutMs:a,settleDelayMs:c,concurrency:s,includeReferences:!1,includeCallees:!0},f=Dn(process.execPath,[i],{cwd:n,input:JSON.stringify(u),encoding:"utf8",maxBuffer:50*1024*1024,timeout:Y(t.length,o,s)}),l=kn(f.stdout);if(l)return{available:l.available,resolvedBinary:r.resolvedBinary,reason:l.reason,callees:oe(t,new Map(l.callees??[]),void 0)};let p=f.error instanceof Error?f.error.message:f.stderr.trim()||`Rust semantic worker exited with status ${f.status??"unknown"}.`;return{available:!1,resolvedBinary:r.resolvedBinary,reason:p,callees:G(t)}}function co(n,e,t){let r=e(n);if(!r.available||!r.resolvedBinary)return{available:!1,resolvedBinary:r.resolvedBinary,reason:r.reason,signatures:He(t)};let i=Tn();if(!vn(i))return{available:!1,resolvedBinary:r.resolvedBinary,reason:`Rust semantic worker was not found at ${i}. Run npm run build before using built semantic Rust queries.`,signatures:He(t)};let o=se(process.env.SCIP_RUST_SEMANTIC_REQUEST_TIMEOUT_MS,xn),s=se(process.env.SCIP_RUST_SEMANTIC_CONCURRENCY,Cn),a=$e(process.env.SCIP_RUST_SEMANTIC_DIAGNOSTICS_TIMEOUT_MS,Math.min(o,1e4)),c=ge(process.env.SCIP_RUST_SEMANTIC_SETTLE_MS,{definitionCount:t.length,includeReferences:!1,includeCallees:!1,includeSignatures:!0}),u={projectRoot:n,rustAnalyzerBinary:r.resolvedBinary,definitions:[...t],requestTimeoutMs:o,diagnosticsTimeoutMs:a,settleDelayMs:c,concurrency:s,includeReferences:!1,includeCallees:!1,includeSignatures:!0},f=Dn(process.execPath,[i],{cwd:n,input:JSON.stringify(u),encoding:"utf8",maxBuffer:50*1024*1024,timeout:Y(t.length,o,s)}),l=kn(f.stdout);if(l)return{available:l.available,resolvedBinary:r.resolvedBinary,reason:l.reason,signatures:or(t,new Map(l.signatures??[]))};let p=f.error instanceof Error?f.error.message:f.stderr.trim()||`Rust semantic worker exited with status ${f.status??"unknown"}.`;return{available:!1,resolvedBinary:r.resolvedBinary,reason:p,signatures:He(t)}}function lo(n,e,t){let r=t.referenceDefinitions.length>0?n.referencesForDefinitions(t.referenceDefinitions):{available:!0,references:J(t.referenceDefinitions)},i=t.calleeDefinitions.length>0?e.calleesForDefinitions(t.calleeDefinitions):{available:!0,callees:G(t.calleeDefinitions)};return{available:r.available&&i.available,resolvedBinary:r.resolvedBinary??i.resolvedBinary,reason:r.reason??i.reason,references:r.references,callees:i.callees}}function J(n){return new Map(n.map(e=>[e.symbolId,[]]))}function G(n){return new Map(n.map(e=>[e.symbolId,[]]))}function He(n){return new Map(n.map(e=>[e.symbolId,null]))}function oe(n,e,t){let r=0,i=0;return w("rust.semantic.callees.complete-map",()=>{let o=new Map;for(let s of n){let a=e.get(s.symbolId)??[];a.length>0&&(r+=1),i+=a.length,o.set(s.symbolId,a.map(c=>({...c,symbol:t?t(c):c.symbol})))}return o},()=>({definitions:n.length,rows:r,callees:i,resolveSymbols:!!t}))}function or(n,e){return new Map(n.map(t=>[t.symbolId,e.get(t.symbolId)??null]))}function Tn(){return eo(new URL("./rust-semantic-worker.js",import.meta.url))}function kn(n){try{let e=JSON.parse(n);if(!e||typeof e!="object")return null;let t=e;return typeof t.available!="boolean"||!Array.isArray(t.references)?null:{available:t.available,reason:typeof t.reason=="string"?t.reason:void 0,references:t.references,incompleteReferenceSymbolIds:Array.isArray(t.incompleteReferenceSymbolIds)?t.incompleteReferenceSymbolIds.filter(r=>typeof r=="number"):void 0,callees:Array.isArray(t.callees)?t.callees:void 0,signatures:Array.isArray(t.signatures)?t.signatures:void 0}}catch{return null}}function se(n,e){return X(n)??e}function $e(n,e){if(!n)return e;let t=Number(n);return Number.isInteger(t)&&t>=0?t:e}import{existsSync as uo}from"fs";import{deserializeSCIP as fo,SymbolRole as po}from"@c4312/scip";var wn=new WeakMap;function ar(n,e){let t=e.filter(mo);if(t.length===0)return new Map;let r=!1,i=0,o=0;return w("rust.scip-occurrence.callees",()=>{let s=go(n);if(r=!!s,!s)return new Map;let a=new Map;for(let c of t){let u=yo(n,s,c);u!==null&&(a.set(c.symbolId,u),i+=1,o+=u.length)}return a},()=>({definitions:e.length,candidates:t.length,indexAvailable:r,resolvedDefinitions:i,resolvedCallees:o}))}function mo(n){return!(!n.symbol.startsWith("rust-analyzer ")||!n.relativePath.endsWith(".rs")||!n.isFunctionLike||n.leaf==="main"||de(n.symbol))}function yo(n,e,t){let r=Ce(n,t.relativePath);if(!r||r.language!=="rust")return null;let i=r.callables.find(u=>u.startLine!==t.startLine||u.endLine!==t.endLine?!1:u.name===t.leaf||t.leaf.endsWith(u.name)||u.name.endsWith(t.leaf));if(!i)return null;let o=r.callSites.filter(u=>u.line>=i.startLine&&u.line<=i.endLine);if(o.length===0)return null;let s=(e.occurrencesByFile.get(t.relativePath)??[]).filter(u=>u.line>=i.startLine&&u.line<=i.endLine&&u.callee.symbol!==t.symbol);if(s.some(u=>u.traitImplMember)||!So(o,s))return null;let a=[],c=new Set;for(let u of s){let f=`${u.callee.symbol}\0${u.callee.file}\0${u.callee.line}`;c.has(f)||(c.add(f),a.push(u.callee))}return a}function So(n,e){let t=sr(n),r=sr(e);if(t.size!==r.size)return!1;for(let[i,o]of t)if(r.get(i)!==o)return!1;return!0}function sr(n){let e=new Map;for(let t of n){let r=t.calleeLeaf??t.leaf;if(!r)continue;let i=`${t.line}\0${r}`;e.set(i,(e.get(i)??0)+1)}return e}function go(n){if(wn.has(n))return wn.get(n)??null;let e=Ro(n);return wn.set(n,e),e}function Ro(n){if(!n.generation.indexPath||!uo(n.generation.indexPath))return null;try{let e=ke(n).filter(o=>o.symbol.startsWith("rust-analyzer ")&&o.relativePath.endsWith(".rs")&&o.isFunctionLike),t=new Map(e.map(o=>[o.symbol,o])),r=fo(De(n.generation.indexPath,{inputKind:"SCIP occurrence-callee index",maxBytes:Me})),i=new Map;for(let o of r.documents??[]){let s=o.relativePath;if(!s||!s.endsWith(".rs")||n.isIgnored(s))continue;let a=[];for(let c of o.occurrences??[]){if(!c.symbol||(c.symbolRoles&po.Definition)!==0)continue;let u=t.get(c.symbol);if(!u)continue;let f=c.range?.[0];Number.isInteger(f)&&a.push({line:f,leaf:u.leaf,traitImplMember:de(u.symbol),callee:{symbol:u.symbol,file:u.relativePath,line:u.startLine}})}i.set(s,a)}return{occurrencesByFile:i}}catch{return null}}var Ve=class{sessions=new WeakMap;getOrCreate(e,t,r){let i=bo(e,t),o=this.sessions.get(e);o||(o=new Map,this.sessions.set(e,o));let s=o.get(i);if(s)return s.hits+=1,s.lastUsedAtMs=Date.now(),s.provider;let a=Date.now(),c=r();return o.set(i,{key:i,language:t,projectRoot:e.config.projectRoot,provider:c,createdAtMs:a,lastUsedAtMs:a,hits:1}),c}sessionsFor(e){return[...this.sessions.get(e)?.values()??[]]}clear(e){let t=this.sessions.get(e);if(t)for(let r of t.values())r.provider.dispose?.();this.sessions.delete(e)}};function bo(n,e){return`${n.config.projectRoot}:${e}-workspace`}import{randomUUID as Ho}from"crypto";import{existsSync as $o}from"fs";import{dirname as Vo}from"path";import{performance as v}from"perf_hooks";function L(n,e,t){if(n.has(e))return n.get(e);let r=t();return n.set(e,r),r}import ur from"path";import{realpathSync as cr}from"fs";function ho(n,e){return n.getReferences().map(t=>{let r=t.getNode();return Ye(r,e)})}function Io(n){let e=n;return typeof e.findReferences=="function"?e.findReferences():[]}function fr(n,e,t,r){let i=[];for(let o of Io(n))for(let s of ho(o,r))s.file===e.relativePath&&s.line>=e.startLine&&s.line<=e.endLine||i.push(s);for(let o of t)i.push(o);return ae(i)}function pr(n,e,t,r){let i=[],o=t?.getStart();for(let s of n.getReferences()){let a=s.getNode();ce(r,a.getSourceFile().getFilePath())===e&&(o!==void 0&&a.getStart()===o||i.push({location:Ye(a,r),node:a}))}return i}function Ye(n,e){let t=n.getSourceFile(),r=t.getLineAndColumnAtPos(n.getStart());return{file:ce(e,t.getFilePath())??t.getBaseName(),line:r.line-1,column:r.column-1}}function dr(n,e,t){let r=n.getSourceFile(),i=Pn(r,n),o=n.getText(),s=new RegExp(`\\b${pe(o)}\\b`,"g"),a=r.getFullText().split(`
2
- `),c=[];for(let u=0;u<a.length;u++){if(u===i)continue;let f=a[u]??"";s.lastIndex=0;let l;for(;(l=s.exec(f))!==null;)c.push({file:e,line:u,column:l.index})}return ae(c.filter(u=>ce(t,ur.join(t,u.file))===e))}function En(n){for(let e=n;e;e=e.getParent()){let t=e.getKindName();if(t.includes("Type")||t==="InterfaceDeclaration"||t==="TypeAliasDeclaration")return!0;if(t==="CallExpression"||t==="NewExpression"||t==="ExpressionStatement")return!1}return!1}function Pn(n,e){return n.getLineAndColumnAtPos(e.getStart()).line-1}function ae(n){let e=new Set,t=[];for(let r of n){let i=`${r.file}:${r.line}:${r.column}`;e.has(i)||(e.add(i),t.push(r))}return t}function ce(n,e){let t=n||process.cwd(),r=lr(t,e);if(r)return r;try{return lr(cr(t),cr(e))}catch{return null}}function lr(n,e){let t=ur.relative(n,e).replace(/\\/g,"/");return!t||t===".."||t.startsWith("../")?null:t}function mr(n,e,t,r){let i=Mo(e,r);return i.size===0?new Map:Do(n,t,i)}function Mo(n,e){let t=new Map;for(let r of K(n,e)){let i=$(r.symbol)??r.leaf;if(!i)continue;let o=t.get(i);o||(o=[],t.set(i,o)),o.push(r)}return t}function Do(n,e,t){let r=new Map,i=new Map;return e.forEachDescendant(o=>{for(let s of vo(n,o)){let a=t.get(s);if(!a)continue;let c=Pn(e,o);for(let u of a){if(c<u.startLine-1||c>u.endLine+1)continue;let f=Math.abs(c-u.startLine),l=i.get(u.symbolId);l!==void 0&&l<=f||(i.set(u.symbolId,f),r.set(u.symbolId,o))}}}),r}function vo(n,e){let t=[],r=i=>{i&&!t.includes(i)&&t.push(i)};if("getNameNode"in e&&typeof e.getNameNode=="function"){let i=e.getNameNode();r(i?.getText())}if("getName"in e&&typeof e.getName=="function"){let i=e.getName();r(i)}return n.Node.isIdentifier(e)&&r(e.getText()),t}var xo=Qn("ts-definition-leaf-candidates",{clearGroups:["definition-catalog"]});function yr(n,e,t,r){let i=_n(n,e),o=Fn(i.get(r)??[],t);if(o)return o;let s=[];for(let a of i.values())for(let c of a)((c.leaf||$(c.symbol)||"").includes(r)||c.symbol.includes(r))&&s.push(c);return Fn(s,t)}function An(n,e,t,r){return Fn(_n(n,e).get(r)??[],t)}function Sr(n,e){let t=new Map;for(let[r,i]of _n(n,e)){let o=i[0];o&&t.set(r,o)}return t}function _n(n,e){return xo.get(n,e,()=>{let t=new Map;for(let r of K(n,e)){let i=r.leaf||$(r.symbol);if(!i)continue;let o=t.get(i);o||(o=[],t.set(i,o)),o.push({...r,leaf:i})}for(let r of t.values())r.sort((i,o)=>i.startLine-o.startLine||i.endLine-o.endLine||i.symbolId-o.symbolId);return t})}function Fn(n,e){let t=null,r=Number.POSITIVE_INFINITY;for(let i of n){let o=Math.abs(i.startLine-e);(o<r||o===r&&t&&i.startLine<t.startLine)&&(t=i,r=o)}return t}import Co from"path";import{realpathSync as To}from"fs";function gr(n,e){let t=new Map,r=null,i=null,o=()=>(i??=ve(n,{extensions:_e}),i),s=()=>(r??=w("typescript.source-file-index",()=>ko(n.config.projectRoot,e,o()),()=>({projects:e.length,indexedDocuments:o().length})),r),a=c=>te(c)?L(t,c,()=>{let u=Rr(n.config.projectRoot,c);if(!u)return null;for(let{project:f,sourceFiles:l}of s()){let p=l.get(u)??null;if(p||(p=f.addSourceFileAtPathIfExists(u)??null,p&&Nn(l,p)),p)return{project:f,sourceFile:p}}return null}):null;return{sourceFile:c=>a(c)?.sourceFile??null,sourceFileMatch:a,indexedTypeScriptLikeDocuments:o}}function ko(n,e,t){let r=e.map(({project:i})=>{let o=new Map;for(let s of i.getSourceFiles())Nn(o,s);return{project:i,sourceFiles:o}});for(let i of t){let o=Rr(n,i);if(o)for(let s of r){if(s.sourceFiles.has(o))break;let a=s.project.addSourceFileAtPathIfExists(o)??null;if(a){Nn(s.sourceFiles,a);break}}}return r}function Nn(n,e){let t=Ln(e.getFilePath());n.set(t,e);try{n.set(Ln(To(t)),e)}catch(r){if(!fe(r))throw r}}function Rr(n,e){try{return Ln(it(n,e,{inputKind:"indexed TypeScript source file"}).absolutePath)}catch(t){if(!fe(t))throw t;return null}}function Ln(n){return Co.resolve(n)}function On(n,e){for(let t of n)if(e===t.name||e.startsWith(`${t.name}/`))return t.name;return null}function br(n){let e=`${n.relativeDir}/src`;return[`${e}/index.ts`,`${e}/index.tsx`,`${e}/index.mts`,`${e}/index.cts`]}import{existsSync as be}from"fs";import F from"path";var Un=["tsconfig.json","tsconfig.app.json","tsconfig.node.json","tsconfig.base.json"];function qn(n,e){let r=e?F.dirname(F.join(n,e)):n,i=F.resolve(n);for(;r.startsWith(i);){for(let s of Un){let a=F.join(r,s);if(be(a))return a}let o=F.dirname(r);if(o===r)break;r=o}for(let o of Un){let s=F.join(n,o);if(be(s))return s}return null}function hr(n){let e=n.config.projectRoot,t=new Set(wo(e,n.config.semantic?.typescript?.tsconfigs)),r=ve(n,{includeIgnored:!1,extensions:_e});for(let i of r){let o=qn(e,i);o&&t.add(F.resolve(o))}if(t.size===0){let i=qn(e);i&&t.add(F.resolve(i))}return[...t].filter(i=>!Ir(e,i)).sort((i,o)=>i.localeCompare(o))}function wo(n,e=[]){let t=new Set;for(let r of e){let i=F.isAbsolute(r)?r:F.join(n,r);be(i)&&t.add(F.resolve(i))}for(let r of Eo(n))for(let i of Un){let o=F.join(r,i);be(o)&&t.add(F.resolve(o))}if(t.size===0){let r=qn(n);r&&t.add(F.resolve(r))}return[...t].filter(r=>!Ir(n,r)).sort((r,i)=>r.localeCompare(i))}function Eo(n){let e=F.join(n,"package.json");if(!be(e))return[];let t;try{t=JSON.parse(Jn(e,"project package manifest"))}catch{return[]}return(Array.isArray(t.workspaces)?t.workspaces:t.workspaces?.packages??[]).flatMap(i=>tt(n,i))}function Ir(n,e){let t=F.relative(n,e).replace(/\\/g,"/");return t.startsWith("..")||t.includes("/node_modules/")||t.startsWith("node_modules/")||t.includes("/dist/")||t.startsWith("dist/")}var Po=32;function Tr(n,e){let t=w("typescript.provider.load",()=>Rt());if(!t)return Ne("ts-morph is not installed");let r=w("typescript.provider.tsconfig-discovery",()=>hr(n));if(r.length===0)return Ne("no tsconfig found");try{let i=w("typescript.provider.project-bundles",()=>bt(t,r),()=>({tsconfigs:r.length}));return Fo(n,t,i)}catch(i){return Ne(i instanceof Error?i.message:String(i),r[0],r)}}function Fo(n,e,t,r={}){return w("typescript.provider.construct",()=>new jn(n,e,t),()=>({tsconfigs:t.length,reusedProjects:r.reusedProjects===!0}))}var jn=class{constructor(e,t,r){this.db=e;this.tsMorph=t;this.projects=r;this.workspacePackages=nt(e.config.projectRoot),this.sourceFiles=gr(e,r)}db;tsMorph;projects;language="typescript";importUsageCache=new Map;referencesCache=new Map;calleesCache=new Map;fileCalleesCache=new Map;signatureCache=new Map;definitionNodeCache=new Map;fileDefinitionNodeCache=new Map;indexedDefinitionLeafCache=new Map;compilerCheckerCache=new WeakMap;packageImportReferenceIndex=null;packageExportIndex=null;workspacePackages;sourceFiles;availability(){return{available:!0,tsconfigPath:this.projects[0]?.tsconfigPath,tsconfigPaths:this.projects.map(e=>e.tsconfigPath)}}importUsage(e){return L(this.importUsageCache,e,()=>{let t=this.sourceFiles.sourceFile(e);if(!t)return[];let r=_o();return w("typescript.import-usage.file",()=>this.importUsageForSourceFile(e,t,r),()=>({file:e,...r}))})}referencesFor(e){return L(this.referencesCache,e.symbolId,()=>{let t=this.nodeForDefinition(e);return this.referencesForDefinitionNode(e,t)})}referencesForDefinitions(e,t={}){let r=new Map,i=N(),o=[];for(let f of e){let l=this.referencesCache.get(f.symbolId);l?r.set(f.symbolId,l):o.push(f)}if(o.length===0)return r;let s=o,a=t.exact?[]:o.filter(f=>!Dr(f));if(a.length>=Po){let f=this.referencesForDefinitionsBySymbolScan(a);for(let l of a){let p=f.get(l.symbolId)??[];this.referencesCache.set(l.symbolId,p),r.set(l.symbolId,p)}if(s=o.filter(l=>Dr(l)),s.length===0)return r}let c=new Map;for(let f of s){let l=c.get(f.relativePath);l?l.push(f):c.set(f.relativePath,[f])}let u=[];for(let[f,l]of c){let p=vr();w("typescript.references-map.file",()=>{let d=this.definitionNodesForFile(f);for(let S of l){i&&(p.cacheMisses+=1);let h=d.get(S.symbolId)??null;i&&(h?p.nodeHits+=1:p.nodeMisses+=1);try{let g=this.referencesForDefinitionNode(S,h,i?p:void 0);this.referencesCache.set(S.symbolId,g),r.set(S.symbolId,g)}catch{p.preciseSearchFailures+=1,u.push(S)}}},()=>({relativePath:f,definitions:l.length,...xr(p)}))}if(u.length>0){let f=this.referencesForDefinitionsBySymbolScan(u);for(let l of u){let p=f.get(l.symbolId)??[];this.referencesCache.set(l.symbolId,p),r.set(l.symbolId,p)}}return r}referenceFragmentsForFiles(e){let t=ke(this.db).filter(o=>te(o.relativePath)),r=e.filter(o=>this.sourceFiles.sourceFile(o)!==null),i=this.referencesForDefinitionsBySymbolScan(t,r);return ht(t,i,r)}referencesForDefinitionsBySymbolScan(e,t){let r=N(),i=vr(),o=new Map,s=new Set(e.map(c=>c.symbolId)),a=new Map(e.map(c=>[c.symbolId,c]));for(let c of e)o.set(c.symbolId,[]);return w("typescript.references-map.inverted-scan",()=>{let c=r?v.now():0,u=t?this.packageImportReferencesForFiles(t):this.packageImportReferences();for(let g of e){let y=u.get(g.symbolId)??[];if(y.length>0){let k=o.get(g.symbolId)??[];k.push(...y),o.set(g.symbolId,k)}r&&(i.packageReferenceCount+=y.length)}r&&(i.packageRefsMs+=v.now()-c);let f=new Map,l=new Map,p=this.hierarchyTargetsForDefinitions(e),d=new Set(e.map(g=>g.leaf).filter(Boolean)),S=r?v.now():0;for(let g of t??this.sourceFiles.indexedTypeScriptLikeDocuments()){if(this.db.isIgnored(g))continue;let y=this.sourceFiles.sourceFile(g);y&&(r&&(i.scanFiles+=1),this.addReferencesFromSourceFileScan(y,g,s,a,p,d,f,l,o,r?i:void 0))}r&&(i.scanMs+=v.now()-S);let h=r?v.now():0;this.addHierarchyMemberReferences(e,o,r?i:void 0),r&&(i.hierarchyMs+=v.now()-h);for(let[g,y]of o){let k=ae(y);o.set(g,k),r&&(i.referenceCount+=k.length)}},()=>({definitions:e.length,...xr(i)})),o}addReferencesFromSourceFileScan(e,t,r,i,o,s,a,c,u,f){let l=this.compilerCheckerForSourceFile(e),p=e.compilerNode,d=Oo(e),S=h=>{if(this.tsMorph.ts.isIdentifier(h)){if(f&&(f.identifiers+=1),!s.has(h.text)&&!d.has(h.text)){this.tsMorph.ts.forEachChild(h,S);return}let g=this.compilerReferenceSymbol(l,h,f);if(g){let y;a.has(g)?y=a.get(g)??null:(y=this.referenceDefinitionFromCompilerSymbol(g),a.set(g,y)),f&&(y?f.targetHits+=1:f.targetMisses+=1);let k=L(c,g,()=>this.compilerSymbolKeys(g)),P=null,I=null,C=y&&r.has(y.symbolId)?i.get(y.symbolId):void 0;if(C&&(P=Bn(p,h),!Mr(C,t,P))){let x=p.getLineAndCharacterOfPosition(h.getStart(p));I={file:t,line:x.line,column:x.character};let M=u.get(C.symbolId)??[];M.push(I),u.set(C.symbolId,M),f&&(f.requestedHits+=1)}for(let x of k)for(let M of o.get(x)?.values()??[]){if(P??=Bn(p,h),Mr(M,t,P))continue;if(!I){let m=p.getLineAndCharacterOfPosition(h.getStart(p));I={file:t,line:m.line,column:m.character}}let R=u.get(M.symbolId)??[];R.push(I),u.set(M.symbolId,R),f&&(f.requestedHits+=1)}}}this.tsMorph.ts.forEachChild(h,S)};S(p)}hierarchyTargetsForDefinitions(e){let t=new Map;for(let r of e){let i=this.nodeForDefinition(r),o=i?.compilerNode;if(!o||!this.isHierarchyMethod(o))continue;let s=o.parent;if(!this.isHierarchyContainer(s))continue;let a=this.compilerCheckerForSourceFile(i.getSourceFile()),c=a.getSymbolAtLocation(o.name);if(c)for(let u of this.hierarchyMemberSymbols(a,s,c))for(let f of this.compilerSymbolKeys(u)){let l=t.get(f)??new Map;l.set(r.symbolId,r),t.set(f,l)}}return t}hierarchyMemberSymbols(e,t,r){let i=new Set,o=new Set,s=(a,c,u)=>{if(!o.has(a)){o.add(a),i.add(c);for(let f of u){let l=f.getProperty(r.name);l&&s(f,l,this.hierarchyAncestorTypesForType(e,f))}}};return s(e.getTypeAtLocation(t),r,this.hierarchyAncestorTypes(e,t)),i}addHierarchyMemberReferences(e,t,r){let i=new Map;for(let o of e){let s=this.nodeForDefinition(o),a=s?.compilerNode;if(!a||!this.isHierarchyMethod(a))continue;let c=a.parent;if(!this.isHierarchyContainer(c))continue;let u=this.compilerCheckerForSourceFile(s.getSourceFile()),f=u.getSymbolAtLocation(a.name);if(!f)continue;let l=a.getSourceFile(),p=l.getLineAndCharacterOfPosition(a.name.getStart(l)),d={definition:o,location:{file:o.relativePath,line:p.line,column:p.character}},S=t.get(o.symbolId)??[];for(let g of this.hierarchyMemberSymbols(u,c,f))if(g!==f)for(let y of this.compilerSymbolLocations(g))S.push(y),r&&(r.hierarchyReferences+=1);t.set(o.symbolId,S);let h=this.hierarchyRootMemberSymbols(u,c,f);for(let g of h){let y=i.get(g)??new Map;y.set(o.symbolId,d),i.set(g,y)}r&&(r.hierarchyDefinitions+=1)}for(let o of i.values())if(!(o.size<2)){r&&(r.hierarchyFamilies+=1);for(let{definition:s}of o.values()){let a=t.get(s.symbolId)??[];for(let c of o.values())c.definition.symbolId!==s.symbolId&&(a.push(c.location),r&&(r.hierarchyReferences+=1));t.set(s.symbolId,a)}}}hierarchyRootMemberSymbols(e,t,r){let i=new Set,o=new Set,s=(a,c,u)=>{if(o.has(a))return;o.add(a);let f=!1;for(let l of u){let p=l.getProperty(r.name);p&&(f=!0,s(l,p,this.hierarchyAncestorTypesForType(e,l)))}if(!f)for(let l of this.compilerSymbolKeys(c))i.add(l)};return s(e.getTypeAtLocation(t),r,this.hierarchyAncestorTypes(e,t)),i}compilerSymbolKeys(e){return(e.declarations??[]).map(t=>{let r=t.getSourceFile();return`${r.fileName}\0${t.getStart(r)}\0${e.name}`})}compilerSymbolLocations(e){let t=[];for(let r of e.declarations??[]){let i=r.getSourceFile(),o=ce(this.db.config.projectRoot,i.fileName);if(!o)continue;let s=r.name,a=i.getLineAndCharacterOfPosition((s??r).getStart(i));t.push({file:o,line:a.line,column:a.character})}return t}baseTypes(e,t){try{return e.getBaseTypes(t)??[]}catch{return[]}}hierarchyAncestorTypes(e,t){let r=new Set(this.hierarchyAncestorTypesForType(e,e.getTypeAtLocation(t)));for(let i of t.heritageClauses??[])for(let o of i.types)r.add(e.getTypeAtLocation(o));return[...r]}hierarchyAncestorTypesForType(e,t){let r=new Set(this.baseTypes(e,t));for(let i of t.getSymbol()?.declarations??[])if(this.isHierarchyContainer(i))for(let o of i.heritageClauses??[])for(let s of o.types)r.add(e.getTypeAtLocation(s));return[...r]}isHierarchyMethod(e){return this.tsMorph.ts.isMethodDeclaration(e)||this.tsMorph.ts.isMethodSignature(e)}isHierarchyContainer(e){return this.tsMorph.ts.isClassDeclaration(e)||this.tsMorph.ts.isClassExpression(e)||this.tsMorph.ts.isInterfaceDeclaration(e)}compilerReferenceSymbol(e,t,r){r&&(r.symbolLookups+=1);let i=e.getSymbolAtLocation(t);if(i){if((i.flags&this.tsMorph.ts.SymbolFlags.Alias)===0)return i;try{return r&&(r.aliasResolutions+=1),e.getAliasedSymbol(i)}catch{return i}}}calleesFor(e){return L(this.calleesCache,e.symbolId,()=>L(this.fileCalleesCache,e.relativePath,()=>this.calleeMapForFile(e.relativePath)).get(e.symbolId)??[])}calleesForDefinitions(e){let t=new Map,r=new Map;for(let i of e){let o=r.get(i.relativePath);o?o.push(i):r.set(i.relativePath,[i])}for(let[i,o]of r){let s=this.fileCalleesCache.get(i),a=new Set(o.map(u=>u.symbolId)),c=s??this.calleeMapForFile(i,a);for(let u of o){let f=c.get(u.symbolId)??[];this.calleesCache.set(u.symbolId,f),t.set(u.symbolId,f)}}return t}referencesForDefinitionNode(e,t,r){let i=r?v.now():0,o=this.packageImportReferencesForDefinition(e);if(r&&(r.packageRefsMs+=v.now()-i,r.packageReferenceCount+=o.length),!t)return o;let s=r?v.now():0,a=fr(t,e,o,this.db.config.projectRoot);return r&&(r.semanticRefsMs+=v.now()-s,r.referenceCount+=a.length),a}signatureFor(e){return L(this.signatureCache,e.symbolId,()=>{let t=this.nodeForDefinition(e);if(!t||!this.tsMorph.Node.isFunctionDeclaration(t)&&!this.tsMorph.Node.isMethodDeclaration(t)&&!this.tsMorph.Node.isArrowFunction(t)&&!this.tsMorph.Node.isFunctionExpression(t)&&!this.tsMorph.Node.isConstructorDeclaration(t))return null;let r=t.getType().getCallSignatures()[0];if(!r)return null;let i=r.getParameters().map(s=>{let a=s.getDeclarations()[0],c=a?s.getTypeAtLocation(a).getText(a):s.getValueDeclaration()?.getType().getText()??"unknown";return Cr(c)}),o=r.getReturnType().getText(t);return`(${i.join(",")})=>${Cr(o)}`})}importUsageForSourceFile(e,t,r){let i=[],o=new Map;for(let s of t.getImportDeclarations()){r.declarations+=1;let a=rn(this.db,e,s.getModuleSpecifierValue()),c=s.getImportClause()?.isTypeOnly()??!1;for(let u of Wn(s)){r.entries+=1;let f=c?null:u.identifier?.getSymbol()?.compilerSymbol??null;!c&&u.identifier&&(f?r.bindingSymbols+=1:r.missingBindingSymbols+=1);let l={sourcePath:a,entry:u,typeOnlyDeclaration:c,bindingSymbol:f,references:[]};if(i.push(l),c||!u.localName||!f)continue;let p=o.get(u.localName);p?p.push(l):o.set(u.localName,[l])}}return o.size>0&&t.forEachDescendant(s=>{if(s.getKindName()!=="Identifier")return;let a=o.get(s.getText());if(!a||No(s))return;r.scannedIdentifiers+=1;let c=s.getSymbol()?.compilerSymbol;if(r.symbolLookups+=1,!!c){for(let u of a)if(u.bindingSymbol===c){u.references.push({location:Ye(s,this.db.config.projectRoot),node:s}),r.matchedReferences+=1;break}}}),i.map(s=>s.typeOnlyDeclaration?Ao(e,s.sourcePath,s.entry):s.entry.identifier&&!s.bindingSymbol?(r.fallbackEntries+=1,this.valueImportUsageForEntry(e,s.sourcePath,s.entry)):this.valueImportUsageFromLocations(e,s.sourcePath,s.entry,s.references))}valueImportUsageForEntry(e,t,r){let i=r.identifier?r.identifier.findReferences():[],o=[];for(let s of i)for(let a of pr(s,e,r.identifier,this.db.config.projectRoot))o.push(a);return this.valueImportUsageFromLocations(e,t,r,o)}valueImportUsageFromLocations(e,t,r,i){let o=i.some(c=>!En(c.node)),s=i.some(c=>En(c.node)),a=r.isTypeOnly;return{importer:e,sourcePath:t,importedName:r.importedName,localName:r.localName,kind:r.kind,isTypeOnly:a,isUsed:a||i.length>0,isTypeUsed:a||s,isValueUsed:o,references:i.map(c=>c.location)}}packageImportReferencesForDefinition(e){return this.packageImportReferences().get(e.symbolId)??[]}packageImportReferencesForFiles(e){let t=new Map,r=new Set;for(let o of e){let s=this.sourceFiles.sourceFile(o);if(s)for(let a of s.getImportDeclarations()){let c=On(this.workspacePackages,a.getModuleSpecifierValue());c&&r.add(c)}}if(r.size===0)return t;let i=this.packageExportsForNames(r);for(let o of e)this.addPackageImportReferencesForDocument(t,i,o);for(let[o,s]of t)t.set(o,ae(s));return t}packageImportReferences(){if(this.packageImportReferenceIndex)return this.packageImportReferenceIndex;let e=new Map,t=this.packageExports();for(let r of this.sourceFiles.indexedTypeScriptLikeDocuments())this.addPackageImportReferencesForDocument(e,t,r);for(let[r,i]of e)e.set(r,ae(i));return this.packageImportReferenceIndex=e,e}addPackageImportReferencesForDocument(e,t,r){if(this.db.isIgnored(r))return;let i=this.sourceFiles.sourceFileMatch(r);if(i)for(let o of i.sourceFile.getImportDeclarations())this.addPackageImportReferencesForDeclaration(e,t,r,o)}addPackageImportReferencesForDeclaration(e,t,r,i){let o=On(this.workspacePackages,i.getModuleSpecifierValue());if(!o)return;let s=t.get(o);if(s)for(let a of Wn(i)){if(a.kind!=="named"||!a.identifier)continue;let c=s.get(a.importedName);if(!c||c.size===0)continue;let u=dr(a.identifier,r,this.db.config.projectRoot);u.length>0&&jo(e,c,u)}}packageExports(){return this.packageExportIndex?this.packageExportIndex:(this.packageExportIndex=this.packageExportsForNames(new Set(this.workspacePackages.map(e=>e.name))),this.packageExportIndex)}packageExportsForNames(e){let t=new Map;for(let r of this.workspacePackages){if(!e.has(r.name))continue;let i=new Map;for(let o of br(r))this.collectPackageExports(r,o,i,new Set);i.size>0&&t.set(r.name,i)}return t}collectPackageExports(e,t,r,i){if(i.has(t))return;i.add(t);let o=this.sourceFiles.sourceFile(t);if(o)for(let s of o.getExportDeclarations()){let a=s.getModuleSpecifierValue(),c=a?rn(this.db,t,a):t;if(!c||!c.startsWith(`${e.relativeDir}/src/`))continue;let u=s.getNamedExports();if(u.length===0){if(s.isNamespaceExport())continue;this.collectPackageExports(e,c,r,i);continue}for(let f of u){let l=f.getNameNode().getText(),p=f.getAliasNode()?.getText()??l,d=this.indexedDefinitionByLeaf(c,l);if(!d)continue;let S=r.get(p);S||(S=new Set,r.set(p,S)),S.add(d.symbolId)}}}indexedDefinitionByLeaf(e,t){return L(this.indexedDefinitionLeafCache,e,()=>Sr(this.db,e)).get(t)??null}nodeForDefinition(e){return L(this.definitionNodeCache,e.symbolId,()=>this.definitionNodesForFile(e.relativePath).get(e.symbolId)??null)}definitionNodesForFile(e){return L(this.fileDefinitionNodeCache,e,()=>{let t=this.sourceFiles.sourceFile(e);return t?mr(this.tsMorph,this.db,t,e):new Map})}referenceDefinitionFromCompilerSymbol(e){return this.definitionFromCompilerSymbol(e,void 0,!0)}definitionFromCompilerSymbol(e,t,r=!1){let i=e.name,o=t?v.now():0,s=e.declarations??[];t&&(t.declarationsMs+=v.now()-o,t.declarationChecks+=s.length);for(let a of s){let c=t?v.now():0,u=a.getSourceFile(),f=ce(this.db.config.projectRoot,u.fileName),l=u.getLineAndCharacterOfPosition(a.getStart(u)).line;if(t&&(t.declarationLocationMs+=v.now()-c),!f||this.db.isIgnored(f))continue;let p=t?v.now():0,d=this.compilerDeclarationName(a),S=r?An(this.db,f,l,i)??(d&&d!==i?An(this.db,f,l,d):null):yr(this.db,f,l,i);if(t&&(t.indexedLookupMs+=v.now()-p),S)return{symbolId:S.symbolId,symbol:S.symbol,file:S.relativePath,line:S.startLine}}return null}compilerDeclarationName(e){let t=e.name;return t&&this.tsMorph.ts.isIdentifier(t)?t.text:null}calleeMapForFile(e,t){let r=N(),i=0,o=0,s=0,a=0,c=0,u=0,f=0,l=0,p=r?qo():void 0;return w("typescript.callee-map.file",()=>{let d=r?v.now():0,S=this.sourceFiles.sourceFile(e);if(r&&(c=Math.round(v.now()-d)),!S)return new Map;let h=r?v.now():0,g=K(this.db,e).sort((R,m)=>R.startLine-m.startLine||m.endLine-R.endLine);if(r&&(u=Math.round(v.now()-h)),i=g.length,g.length===0)return new Map;let y=new Map,k=r?v.now():0,P=this.compilerCheckerForSourceFile(S),I=S.compilerNode;r&&(f=Math.round(v.now()-k));let C=new Map,x=R=>{if(this.tsMorph.ts.isCallExpression(R)||this.tsMorph.ts.isNewExpression(R)){r&&(o+=1);let m=this.semanticCalleeForCallNode(P,I,g,R,C,t,p);m&&(r&&(s+=1),Lo(y,m.callerId,m.target))}this.tsMorph.ts.forEachChild(R,x)},M=r?v.now():0;x(I),r&&(l=Math.round(v.now()-M));for(let[R,m]of y)y.set(R,Wo(m));return a=y.size,y},()=>({relativePath:e,definitions:i,callNodes:o,resolvedCallees:s,outputRows:a,requestedDefinitions:t?.size??i,sourceFileLookupMs:c,definitionsLoadMs:u,checkerLookupMs:f,traversalMs:l,...p?Bo(p):{}}))}semanticCalleeForCallNode(e,t,r,i,o,s,a){let c=a?v.now():0,u=Uo(r,Bn(t,i));if(a&&(a.callerLookupMs+=v.now()-c),!u)return null;if(s&&!s.has(u.symbolId))return a&&(a.skippedUnrequestedCallers+=1),null;let f=i.expression,l=this.compilerSymbolForExpression(e,f,a),p=null;if(l)if(a&&(a.targetSymbolHits+=1),o.has(l))a&&(a.compilerSymbolCacheHits+=1),p=o.get(l)??null;else{a&&(a.compilerSymbolCacheMisses+=1);let d=a?v.now():0;p=this.definitionFromCompilerSymbol(l,a),a&&(a.targetLookupMs+=v.now()-d),o.set(l,p)}else a&&(a.targetMisses+=1);return p?{callerId:u.symbolId,target:{symbol:p.symbol,file:p.file,line:p.line}}:null}compilerSymbolForExpression(e,t,r){let i=r?v.now():0,o=e.getSymbolAtLocation(t);if(r&&(r.expressionSymbolMs+=v.now()-i),o)return o;r&&(r.typeFallbacks+=1);let s=r?v.now():0,a=e.getTypeAtLocation(t).getSymbol();return r&&(r.typeSymbolMs+=v.now()-s),a}compilerCheckerForSourceFile(e){let t=e.getProject(),r=this.compilerCheckerCache.get(t);return r||(r=t.getTypeChecker().compilerObject,this.compilerCheckerCache.set(t,r)),r}};function Wn(n){let e=[],t=n.getDefaultImport();t&&e.push({identifier:t,importedName:"default",localName:t.getText(),kind:"default",isTypeOnly:n.getImportClause()?.isTypeOnly()??!1});let r=n.getNamespaceImport();r&&e.push({identifier:r,importedName:"*",localName:r.getText(),kind:"namespace",isTypeOnly:n.getImportClause()?.isTypeOnly()??!1});for(let i of n.getNamedImports()){let o=i.getNameNode(),a=i.getAliasNode()??(o.getKindName()==="Identifier"?o:null);e.push({identifier:a,importedName:o.getText(),localName:a?.getText()??o.getText(),kind:"named",isTypeOnly:i.isTypeOnly()||(n.getImportClause()?.isTypeOnly()??!1)})}return e.length===0&&e.push({identifier:null,importedName:"*",localName:null,kind:"side-effect",isTypeOnly:!1}),e}function Ao(n,e,t){return{importer:n,sourcePath:e,importedName:t.importedName,localName:t.localName,kind:t.kind,isTypeOnly:!0,isUsed:!0,isTypeUsed:!0,isValueUsed:!1,references:[]}}function _o(){return{declarations:0,entries:0,bindingSymbols:0,missingBindingSymbols:0,scannedIdentifiers:0,symbolLookups:0,matchedReferences:0,fallbackEntries:0}}function No(n){for(let e=n;e;e=e.getParent())if(e.getKindName()==="ImportDeclaration")return!0;return!1}function Lo(n,e,t){let r=n.get(e);r||(r=[],n.set(e,r)),r.push(t)}function Oo(n){let e=new Set;for(let t of n.getImportDeclarations())for(let r of Wn(t))r.localName&&e.add(r.localName);return e}function Uo(n,e){let t=null;for(let r of n)e<r.startLine||e>r.endLine||(!t||r.startLine>=t.startLine)&&(t=r);return t}function Bn(n,e){return n.getLineAndCharacterOfPosition(e.getStart(n)).line}function Mr(n,e,t){return e===n.relativePath&&t>=n.startLine&&t<=n.endLine}function Dr(n){return n.symbol.includes("#")?Te(n.symbol)==="type"&&n.relativePath.endsWith(".d.ts"):!1}function qo(){return{callerLookupMs:0,expressionSymbolMs:0,typeSymbolMs:0,targetLookupMs:0,declarationsMs:0,declarationLocationMs:0,indexedLookupMs:0,compilerSymbolCacheHits:0,compilerSymbolCacheMisses:0,targetSymbolHits:0,targetMisses:0,typeFallbacks:0,declarationChecks:0,skippedUnrequestedCallers:0}}function Bo(n){return{...n,callerLookupMs:Math.round(n.callerLookupMs),expressionSymbolMs:Math.round(n.expressionSymbolMs),typeSymbolMs:Math.round(n.typeSymbolMs),targetLookupMs:Math.round(n.targetLookupMs),declarationsMs:Math.round(n.declarationsMs),declarationLocationMs:Math.round(n.declarationLocationMs),indexedLookupMs:Math.round(n.indexedLookupMs)}}function vr(){return{cacheHits:0,cacheMisses:0,nodeHits:0,nodeMisses:0,scanFiles:0,identifiers:0,symbolLookups:0,aliasResolutions:0,targetHits:0,targetMisses:0,requestedHits:0,scanMs:0,packageRefsMs:0,semanticRefsMs:0,packageReferenceCount:0,referenceCount:0,preciseSearchFailures:0,hierarchyDefinitions:0,hierarchyFamilies:0,hierarchyReferences:0,hierarchyMs:0}}function xr(n){return{...n,scanMs:Math.round(n.scanMs),packageRefsMs:Math.round(n.packageRefsMs),semanticRefsMs:Math.round(n.semanticRefsMs),hierarchyMs:Math.round(n.hierarchyMs)}}function jo(n,e,t){for(let r of e){let i=n.get(r)??[];i.push(...t),n.set(r,i)}}function Wo(n){let e=new Set,t=[];for(let r of n){let i=`${r.symbol}|${r.file}|${r.line}`;e.has(i)||(e.add(i),t.push(r))}return t}function Cr(n){return n.replace(/\s+/g," ").replace(/\bimport\("[^"]+"\)\./g,"").trim()}import{join as Ko}from"path";var Je=3;var zo="typescript-semantic";function kr(n){let e=Ko(n,zo),t=Fe(e);return{...t,requestDir:t.legacyRequestDir}}var Yo=12e4,Jo=5;function Pr(n,e,t={}){let r=new Kn(n,t),i=null,o=null,s=process.env.SCIP_QUERY_SKIP_WATCH_SERVICE==="1",a=()=>(i??=Tr(n,e),i),c=(l,p,d)=>{if(s)return d();try{return p(r.request(l))}catch{return s=!0,d()}},u=(l,p)=>c({kind:"references",definitions:[...l],...p?.exact?{exact:!0}:{}},d=>Er(d),()=>a().referencesForDefinitions?.(l,p)??new Map(l.map(d=>[d.symbolId,a().referencesFor(d)]))),f=l=>c({kind:"callees",definitions:[...l]},p=>Er(p),()=>a().calleesForDefinitions?.(l)??new Map(l.map(p=>[p.symbolId,a().calleesFor(p)])));return{language:"typescript",availability:()=>(o??=c({kind:"availability"},Zo,()=>a().availability()),o),importUsage:l=>c({kind:"import-usage",file:l},p=>p,()=>a().importUsage(l)),referencesFor:l=>u([l]).get(l.symbolId)??[],referencesForDefinitions:u,referenceFragmentsForFiles:l=>c({kind:"reference-fragments",files:[...l]},p=>Qo(p),()=>a().referenceFragmentsForFiles?.(l)??new Map),calleesFor:l=>f([l]).get(l.symbolId)??[],calleesForDefinitions:f,signatureFor:l=>c({kind:"signature",definition:l},Xo,()=>a().signatureFor(l)),dispose:()=>i?.dispose?.()}}var Kn=class{constructor(e,t={}){this.db=e;this.runtime=t.runtime??ns,this.timeoutMs=t.timeoutMs??es(),this.mailboxLimits=t.mailboxLimits??{},this.cacheDir=Vo(e.config.dbPath),this.projectRoot=gt(e.config.projectRoot)}db;runtime;timeoutMs;cacheDir;projectRoot;mailboxLimits;request(e){let t=St(this.cacheDir),r=kr(this.cacheDir),i=an(t.statePath);if(!wr(i,this.projectRoot,this.runtime))throw new Error("Compatible TypeScript semantic service is not running.");let o=this.db.generation.identity;if(!o)throw new Error("Published TypeScript generation identity is unavailable.");let s=this.runtime.now(),a=s+this.timeoutMs,c=(this.runtime.monotonicNow??q)()+this.timeoutMs,u=rt(),f=ee("typescript-semantic-v3",{generation:o,profileEnvironment:u,request:e}),l=ne(f),p=Ae(r,{mailboxVersion:V,operationKey:f,clientId:this.runtime.randomId(),enqueuedAtMs:s,deadlineAtMs:a,protocolVersion:Je,id:l,generation:o,profileEnvironment:u,request:e},{nowMs:s,limits:this.mailboxLimits});for(;(this.runtime.monotonicNow??q)()<=c;){if($o(p.responsePath))return Go(W(p.responsePath,{maxBytes:this.mailboxLimits.maxItemBytes??64*1024*1024,inputKind:"TypeScript semantic mailbox response"}),l,o,f);let d=an(t.statePath);if(!wr(d,this.projectRoot,this.runtime))throw new Error("TypeScript semantic service stopped while processing a request.");this.runtime.sleep(Jo)}throw new Error(`TypeScript semantic service timed out after ${this.timeoutMs}ms.`)}};function wr(n,e,t){let r=n?.processIdentity?t.readProcessIdentity?.(n.pid):null;return n!==null&&n.projectRoot===e&&n.typescriptSemantic?.protocolVersion===Je&&t.isProcessAlive(n.pid)&&(!n.processIdentity||r!=null&&Ee(n.processIdentity,r))}function Go(n,e,t,r){let i=JSON.parse(n);if(i.protocolVersion!==Je||i.id!==e||i.operationKey!==r||i.ok===!0&&i.generation!==t)throw new Error("TypeScript semantic service wrote an incompatible response.");if(i.ok===!0)return i.response;throw new Error(typeof i.error=="string"?i.error:"TypeScript semantic service request failed.")}function Er(n){if(!Array.isArray(n))throw new Error("TypeScript semantic service wrote an invalid numeric map.");return new Map(n)}function Qo(n){if(!Array.isArray(n))throw new Error("TypeScript semantic service wrote an invalid string map.");return new Map(n)}function Zo(n){if(!n||typeof n!="object"||typeof n.available!="boolean")throw new Error("TypeScript semantic service wrote invalid availability.");return n}function Xo(n){if(n!==null&&typeof n!="string")throw new Error("TypeScript semantic service wrote an invalid signature.");return n}function es(){let n=Number(process.env.SCIP_TYPESCRIPT_SEMANTIC_TIMEOUT_MS);return Number.isInteger(n)&&n>0?n:Yo}var ns={now:Date.now,monotonicNow:q,randomId:Ho,sleep(n){let e=new Int32Array(new SharedArrayBuffer(4));Atomics.wait(e,0,0,n)},isProcessAlive:we,readProcessIdentity:Pe};var Fr=new Ve;Gn({name:"semantic-provider",groups:["semantic-provider"],clearAll:n=>Fr.clear(n)});function Q(n,e){let t=U(e)??"typescript";return Fr.getOrCreate(n,t,()=>t==="rust"?ir(n.config.projectRoot,{sourceImportUsageResolver:{importUsageFacts:r=>Mt(n,r)},calleeSymbolResolver:It(n),sourceZeroCalleeOracle:r=>ts(n,r),scipOccurrenceCalleeOracle:r=>ar(n,r)}):Pr(n,e))}function U(n){return n?at(n)==="rust"?"rust":te(n)?"typescript":null:"typescript"}function ts(n,e){let t=Ce(n,e.relativePath);if(!t||t.language!=="rust")return!1;let r=t.callables.find(i=>i.startLine===e.startLine&&i.endLine===e.endLine&&i.name===e.leaf)??t.callables.find(i=>i.startLine===e.startLine&&i.endLine===e.endLine);return r?!t.callSites.some(i=>i.line>=r.startLine&&i.line<=r.endLine):!1}function Cl(n,e){return Ge(n,e,t=>{let r=t?`AND m.symbol_id IN (${t.map(()=>"?").join(",")})`:"";return n.all(`SELECT
3
- m.symbol_id,
4
- d.relative_path,
5
- COUNT(*) AS ref_count
6
- FROM mentions m
7
- JOIN chunks c ON m.chunk_id = c.id
8
- JOIN documents d ON c.document_id = d.id
9
- WHERE m.role != 1
10
- ${r}
11
- ${n.pathExclusionsFor("d")}
12
- GROUP BY m.symbol_id, d.relative_path`,...t??[])})}function Tl(n,e){return Ge(n,e,t=>{let r=t?`AND m.symbol_id IN (${t.map(()=>"?").join(",")})`:"";return n.all(`SELECT DISTINCT m.symbol_id, d.relative_path
13
- FROM mentions m
14
- JOIN chunks c ON m.chunk_id = c.id
15
- JOIN documents d ON c.document_id = d.id
16
- WHERE m.role != 1
17
- ${r}
18
- ${n.pathExclusionsFor("d")}`,...t??[])}).filter(t=>t.symbol_id!==null)}function kl(n,e){return Ge(n,e,t=>{let r=t?`AND m.symbol_id IN (${t.map(()=>"?").join(",")})`:"";return n.all(`SELECT DISTINCT m.symbol_id
19
- FROM mentions m
20
- WHERE m.role != 1
21
- ${r}`,...t??[])}).filter(t=>t.symbol_id!==null)}function Ar(n,e){return Ge(n,e,t=>{let r=t?`AND m.symbol_id IN (${t.map(()=>"?").join(",")})`:"";return n.all(`SELECT DISTINCT m.symbol_id, d.relative_path, c.document_id,
22
- c.start_line AS chunk_start, c.end_line AS chunk_end
23
- FROM mentions m
24
- JOIN chunks c ON m.chunk_id = c.id
25
- JOIN documents d ON c.document_id = d.id
26
- WHERE m.role != 1
27
- ${r}
28
- ${n.pathExclusionsFor("d")}
29
- ORDER BY d.relative_path, c.start_line`,...t??[])})}function Ge(n,e,t){if(!e)return t();if(e.length===0)return[];let r=[];for(let i=0;i<e.length;i+=750)r.push(...t(e.slice(i,i+750)));return r}var rs=/^[A-Za-z_][A-Za-z0-9_]*$/,_r=/\bDefault::default\b/g,is=/^\.\.\s*Default::default\b/;function Nr(n,e){let t=new Map,r=new Map;for(let i of e){let o=zn(n,i,r);o!==null&&t.set(i.symbolId,o)}return t}function zn(n,e,t=new Map){let r=ss(e.symbol);if(!r)return null;let i=Ar(n,[e.symbolId]);if(i.length===0)return null;let o=new RegExp(`(^|[^A-Za-z0-9_])${pe(r)}::default\\b`,"g"),s=new RegExp(`(^|[^A-Za-z0-9_])${pe(r)}\\s*$`),a=os(n,e.symbolId),c=[];for(let u of i){let f=as(n,u.relative_path,t);if(f===null)return null;let l=f.split(/\r?\n/),p=0,d=[],S=0;for(let h=u.chunk_start;h<=u.chunk_end&&h<l.length;h+=1){let y=l[h]??"",k=new Set;o.lastIndex=0;let P;for(;P=o.exec(y);)c.push({file:u.relative_path,line:h,column:P.index+P[1].length+r.length+2}),S+=1;for(let I=0;I<y.length;I+=1){let C=is.exec(y.slice(I));if(C){if(a&&d.includes(p)){let M=I+C[0].lastIndexOf("default");c.push({file:u.relative_path,line:h,column:M}),k.add(M),S+=1}I+=C[0].length-1;continue}let x=y[I];if(x==="{"){let M=s.test(y.slice(0,I));p+=1,M&&d.push(p);continue}if(x==="}")for(p=Math.max(0,p-1);d.length>0&&d[d.length-1]>p;)d.pop()}for(_r.lastIndex=0;P=_r.exec(y);){let I=P.index+9;if(!k.has(I))return null}}if(S===0)return null}return Ue(c)}function os(n,e){return n.get("SELECT 1 AS present FROM mentions WHERE symbol_id = ? AND role = 1 LIMIT 1",e)?.present===1}function ss(n){let e=/impl#\[([^\]]+)\]\[Default\]default\(\)\./.exec(n)?.[1]??null;return!e||!rs.test(e)?null:e}function as(n,e,t){if(t.has(e))return t.get(e)??null;let r=n.get("SELECT text FROM documents WHERE relative_path = ?",e),i=typeof r?.text=="string"?r.text:cs(n,e);return t.set(e,i),i}function cs(n,e){try{return ot(n.config.projectRoot,e,{inputKind:"indexed Rust source file"})}catch(t){if(!fe(t))throw t;return null}}function Lr(n){let e=new Map;for(let t of n){let r=e.get(t.relativePath)??[];r.push(t),e.set(t.relativePath,r)}return e}var ls="typescript-import-usage-v1",us="typescript-signatures-v1",Hn=Zn("semantic-prefetched-callees",{clearGroups:["whole-project","source-file","semantic-provider"]}),Or=sn({kind:"semantic-import-usage",invalidation:ue("semantic-import-usage"),serialize:n=>JSON.stringify(n),deserialize:Hr}),Ur=sn({kind:"semantic-signatures",invalidation:ue("semantic-signatures"),serialize:n=>JSON.stringify(n),deserialize:hs}),qr=on({kind:"typescript-import-usage",invalidation:ue("typescript-import-usage"),serialize:n=>JSON.stringify(n),deserialize:Hr}),Br=on({kind:"typescript-signatures",invalidation:ue("typescript-signatures"),serialize:n=>JSON.stringify(n),deserialize:Is});function Ie(n){let e=new Map,t=new Set;return{capability:(r,i)=>$r(n,r,i),importUsage:r=>ps(n,r),references:r=>Wr(n,r),materializeReferences:(r,i)=>Kr(n,r,e,t,i),callerMap:r=>ds(n,r,e,t),calleeMap:r=>gs(n,r),signature:r=>Rs(n,r)}}function fs(n,e){if(e.size===0)return;let t=Hn.get(n,()=>new Map);for(let[r,i]of e)t.set(r,[...i])}function Vl(n,e){if(!Hn.has(n))return{hits:[],misses:[...e]};let t=Hn.get(n,()=>new Map),r=[],i=[];for(let o of e)t.has(o.symbolId)?r.push({definition:o,callees:t.get(o.symbolId)??[]}):i.push(o);return{hits:r,misses:i}}function Yl(n,e){return Ie(n).importUsage(e)}function ps(n,e){if(U(e)==="typescript"){let o="fallback",s=0,a=0,c=0,u=0;return w("typescript.import-usage.materialize",()=>{let f=cn(n,e,ls);if(f?.key){s=1;let p=qr.read(n,e,f.key);if(p)return o="hit",a=1,p;c=1;let d=B(n,e);if(!d)return o="unavailable",[];let S=d.importUsage(e);return qr.write(n,e,f.key,S),o="computed",S}u=1;let l=B(n,e);return l?(o="direct-fallback",l.importUsage(e)):(o="unavailable",[])},()=>({state:o,eligible:s,cacheHits:a,cacheMisses:c,fallbacks:u}))}let t=zr(n,"semantic-import-usage",e);if(t){let o=Or.read(n,e,t);if(o)return o}let r=B(n,e);if(!r)return[];let i=r.importUsage(e);return t&&Or.write(n,e,t,i),i}function Jl(n,e){return Ie(n).references(e)}function Wr(n,e){let t=zn(n,e);if(t)return t;let r=xt(n,e);if(r)return r;let i=B(n,e.relativePath);return i?i.referencesFor(e):[]}function Gl(n,e){return Ie(n).callerMap(e)}function Ql(n,e){let t=new Map,r=new Map;for(let i of e){if(U(i.relativePath)==="typescript"){let o=B(n,i.relativePath);if(!o)continue;let s=r.get(o)??[];s.push(i),r.set(o,s);continue}$n(n,t,i,Wr(n,i))}for(let[i,o]of r){let s=un(n,o,c=>Q(n,c)),a=s?.references??(i.referencesForDefinitions?i.referencesForDefinitions(o,{exact:!0}):new Map(o.map(c=>[c.symbolId,i.referencesFor(c)])));!s&&N()&&ln(n,o,a,c=>Q(n,c));for(let c of o)$n(n,t,c,a.get(c.symbolId)??[])}return t}function ds(n,e,t=new Map,r=new Set){let i=new Map,o=Kr(n,e,t,r),s=0;return w("semantic.callers.from-references",()=>{for(let a of e)s+=$n(n,i,a,t.get(a.symbolId)??[])},()=>({definitions:e.length,materialized:o.definitions,inMemoryHits:o.inMemoryHits,incompleteInMemoryHits:o.incompleteInMemoryHits,resultRows:i.size,callerFiles:s})),i}function Kr(n,e,t,r,i={}){let o=tn(n),s=[],a=[],c=[],u=0,f=0,l=0,p=0,d=0,S=0,h=0,g=0,y=0,k=0,P=0,I=0,C=[],x=new Map,M=e.filter(m=>U(m.relativePath)==="typescript"&&!t.has(m.symbolId)&&!r.has(m.symbolId)),R=un(n,M,m=>Q(n,m));if(R){y=M.length,k=R.cacheHits,P=R.cacheMisses,I=R.computedFiles;for(let m of M)t.set(m.symbolId,R.references.get(m.symbolId)??[])}if(w("semantic.references.cache-scan",()=>{for(let[m,b]of Lr(e)){let T=[];for(let D of b)t.has(D.symbolId)?f+=1:r.has(D.symbolId)?g+=1:T.push(D);if(T.length===0){h+=1;continue}let j=ms(n,o,m);if(!j){for(let D of T)U(D.relativePath)||(u+=1),c.push(D);continue}S+=1;let A=Xn(n,m,j);for(let D of T){let _=A.get(D.symbol)??null;if(_!==null){let E=Ss(_);if(E){l+=1,t.set(D.symbolId,E);continue}p+=1}a.push({definition:D,cacheFingerprint:j})}}},()=>({definitions:e.length,skippedUnsupportedLanguage:u,cacheHits:l,parseFailures:p,misses:a.length,unkeyed:c.length,inMemoryHits:f,incompleteInMemoryHits:g,fullyInMemoryFiles:h,cacheReadFiles:S})),a.length>0||c.length>0){C=[...c,...a.map(m=>m.definition)],x=w("semantic.references.compute-misses",()=>{let m=ys(n,C,i);return d=m.size,m},()=>({definitions:C.length,misses:a.length,unkeyed:c.length,rows:d}));for(let m of C)x.has(m.symbolId)?(t.set(m.symbolId,x.get(m.symbolId)??[]),r.delete(m.symbolId)):r.add(m.symbolId);for(let{definition:m,cacheFingerprint:b}of a)x.has(m.symbolId)&&$r(n,"semantic-references",m.relativePath).available&&s.push({relativePath:m.relativePath,symbol:m.symbol,projectFingerprint:b,payload:JSON.stringify(x.get(m.symbolId)??[])})}return s.length>0&&w("semantic.references.cache-write",()=>et(n,s),()=>({entries:s.length})),x.size>0&&ln(n,C,x,m=>Q(n,m)),{definitions:e.length,inMemoryHits:f,incompleteInMemoryHits:g,cacheHits:l,misses:a.length,unkeyed:c.length,skippedUnsupportedLanguage:u,parseFailures:p,computed:d,incomplete:r.size,cacheWrites:s.length,fragmentDefinitions:y,fragmentCacheHits:k,fragmentCacheMisses:P,fragmentComputedFiles:I}}function ms(n,e,t){if(!e)return null;let r=U(t);return r==="typescript"?e:r==="rust"?nn(JSON.stringify({kind:"semantic-references",language:r,engine:yn(n.config.projectRoot),projectFingerprint:e})):null}function ys(n,e,t={}){let r=N(),i=new Map,o=0,s=0,a=0,c=0,u=0,f=0,l=0,p=0,d=0;return w("semantic.references.provider-loop",()=>{let S=Nr(n,e),h=vt(n,e),g=new Map,y=t.prefetchCallees?new Map:null,k=[];for(let I of e){let C,x=()=>(C??=B(n,I.relativePath),C);if(y){let b=x();if(b?.referencesAndCalleesForDefinitions){let T=y.get(b);T?T.push(I):y.set(b,[I]),d+=1}}let M=S.get(I.symbolId);if(M){a+=1,c+=M.length,he(i,I.symbolId,M,r,b=>{l+=1,p+=b});continue}let R=h.get(I.symbolId);if(R){u+=1,f+=R.length,he(i,I.symbolId,R,r,b=>{l+=1,p+=b});continue}let m=x();if(!m){r&&(s+=1);continue}if(r&&(o+=1),m.referencesForDefinitions){let b=g.get(m);b?b.push(I):g.set(m,[I])}else k.push({provider:m,definition:I})}let P=new Set;if(y)for(let[I,C]of y){if(!I.referencesAndCalleesForDefinitions)continue;let x=g.get(I)??[],M=I.referencesAndCalleesForDefinitions(x,C);P.add(I),fs(n,M.callees);for(let R of x){if(!M.references.has(R.symbolId))continue;let m=M.references.get(R.symbolId)??[];he(i,R.symbolId,m,r,b=>{l+=1,p+=b})}}for(let[I,C]of g){if(P.has(I))continue;let x=I.referencesForDefinitions(C);for(let M of C){if(!x.has(M.symbolId))continue;let R=x.get(M.symbolId)??[];he(i,M.symbolId,R,r,m=>{l+=1,p+=m})}}for(let{provider:I,definition:C}of k){let x=I.referencesFor(C);he(i,C.symbolId,x,r,M=>{l+=1,p+=M})}return i},()=>({definitions:e.length,providerHits:o,providerMisses:s,rustDefaultFastPathRows:a,rustDefaultFastPathReferences:c,rustScipOccurrenceFastPathRows:u,rustScipOccurrenceFastPathReferences:f,prefetchCalleeDefinitions:d,definitionsWithReferences:l,referenceCount:p,rows:i.size}))}function he(n,e,t,r,i){n.set(e,t),r&&t.length>0&&i(t.length)}function $n(n,e,t,r){let i=0;for(let o of r){if(o.file===t.relativePath||n.isIgnored(o.file))continue;let s=e.get(t.symbolId);s||(s=new Set,e.set(t.symbolId,s));let a=s.size;s.add(o.file),s.size!==a&&(i+=1)}return i}function Ss(n){try{return JSON.parse(n)}catch{return null}}function Zl(n,e){return Ie(n).calleeMap(e)}function gs(n,e){let t=N(),r=new Map,i=0,o=0,s=0,a=0;return w("semantic.callees.provider-loop",()=>{let c=new Map,u=[];for(let f of e){let l=B(n,f.relativePath);if(!l){t&&(o+=1);continue}t&&(i+=1);let p=f;if(l.calleesForDefinitions){let d=c.get(l);d?d.push(p):c.set(l,[p])}else u.push({provider:l,definition:p})}for(let[f,l]of c){let p=f.calleesForDefinitions(l);for(let d of l){let S=p.get(d.symbolId)??[];jr(r,d.symbolId,S,t,h=>{s+=1,a+=h})}}for(let{provider:f,definition:l}of u){let p=f.calleesFor(l);jr(r,l.symbolId,p,t,d=>{s+=1,a+=d})}return r},()=>({definitions:e.length,providerHits:i,providerMisses:o,definitionsWithCallees:s,calleeCount:a,rows:r.size}))}function jr(n,e,t,r,i){t.length>0&&(n.set(e,t),r&&i(t.length))}function Xl(n,e){return Ie(n).signature(e)}function Rs(n,e){if(U(e.relativePath)==="typescript"){let s="fallback",a=0,c=0,u=0,f=0;return w("typescript.signature.materialize",()=>{let l=cn(n,e.relativePath,us);if(l?.key){a=1;let d=Br.read(n,e.relativePath,l.key)??{};if(Object.prototype.hasOwnProperty.call(d,e.symbol))return s="hit",c=1,d[e.symbol]??null;u=1;let S=B(n,e.relativePath);if(!S)return s="unavailable",null;let h=S.signatureFor(e);return Br.write(n,e.relativePath,l.key,{...d,[e.symbol]:h}),s="computed",h}f=1;let p=B(n,e.relativePath);return p?(s="direct-fallback",p.signatureFor(e)):(s="unavailable",null)},()=>({state:s,eligible:a,cacheHits:c,cacheMisses:u,fallbacks:f}))}let t=zr(n,"semantic-signatures",e.relativePath),r=bs(e);if(t){let s=Ur.read(n,r,t);if(s)return s.signature}let i=B(n,e.relativePath);if(!i)return null;let o=i.signatureFor(e);return t&&Ur.write(n,r,t,{signature:o}),o}function zr(n,e,t){let r=tn(n);if(!r)return null;let i=U(t);return i!=="rust"?null:nn(JSON.stringify({kind:e,language:i,engine:yn(n.config.projectRoot),projectFingerprint:r}))}function bs(n){return`${n.relativePath}\0${n.symbol}`}function Hr(n){try{let e=JSON.parse(n);return Array.isArray(e)?e:null}catch{return null}}function hs(n){try{let e=JSON.parse(n);if(!e||typeof e!="object")return null;let t=e.signature;return t!==null&&typeof t!="string"?null:{signature:t}}catch{return null}}function Is(n){try{let e=JSON.parse(n);if(!e||typeof e!="object"||Array.isArray(e))return null;for(let t of Object.values(e))if(t!==null&&typeof t!="string")return null;return e}catch{return null}}function $r(n,e,t){let r=U(t);if(!r)return{slot:e,language:"typescript",available:!1,reason:"semantic evidence is only available for TypeScript or Rust files"};try{return{slot:e,language:r,...Q(n,t).availability()}}catch(i){return{slot:e,language:r,available:!1,reason:i instanceof Error?i.message:String(i)}}}function B(n,e){if(!U(e))return null;let t=Q(n,e);return t.availability().available?t:null}export{Cl as a,Tl as b,kl as c,Ar as d,Lr as e,yn as f,U as g,Ie as h,Vl as i,Yl as j,Jl as k,Gl as l,Ql as m,ys as n,Zl as o,Xl as p};
30
- //# sourceMappingURL=chunk-E2LAW7SL.js.map
@@ -1,6 +0,0 @@
1
- import{a as d}from"./chunk-33XTHFKR.js";import{a as f}from"./chunk-SMQWE25B.js";import{d as m}from"./chunk-RA3AYNWP.js";import{J as u,K as p}from"./chunk-JORHF5AL.js";import{extname as y}from"path";function C(t,e,a={}){let{context:s=0}=a,r=L(e);if(r)return R(t,r.filePath,r.startLine,r.endLine,s);let i=f(t,e);return i?x(t,i,s):null}function L(t){let e=t.match(/^(.+\.\w+):(\d+)-(\d+)$/);return e?{filePath:e[1],startLine:parseInt(e[2],10),endLine:parseInt(e[3],10)}:null}function x(t,e,a){let s=t.get("SELECT language FROM documents WHERE relative_path = ?",e.relativePath),r;try{r=u(t.config.projectRoot,e.relativePath,{inputKind:"indexed source file"})}catch(c){if(!p(c))throw c;return null}let i=r.split(`
2
- `),n=Math.max(0,e.startLine-a),l=Math.min(i.length-1,e.endLine+a),o=i.slice(n,l+1).join(`
3
- `);return{symbol:e.symbol,shortName:m(e.symbol),relativePath:e.relativePath,startLine:n,endLine:l,language:s?.language??v(e.relativePath),source:o}}function R(t,e,a,s,r){let i=d(t,e);if(!i)return null;let n=t.get("SELECT relative_path, language FROM documents WHERE relative_path = ?",i);if(!n)return null;let l;try{l=u(t.config.projectRoot,n.relative_path,{inputKind:"indexed source file"})}catch(h){if(!p(h))throw h;return null}let o=l.split(`
4
- `),c=Math.max(0,a-1-r),g=Math.min(o.length-1,s-1+r),b=o.slice(c,g+1).join(`
5
- `);return{symbol:`${n.relative_path}:${a}-${s}`,shortName:`${n.relative_path}:${a}-${s}`,relativePath:n.relative_path,startLine:c,endLine:g,language:n.language??v(n.relative_path),source:b}}function v(t){switch(y(t).toLowerCase()){case".ts":case".tsx":case".mts":case".cts":return"typescript";case".js":case".jsx":case".mjs":case".cjs":return"javascript";case".py":case".pyi":return"python";case".rs":return"rust";case".go":return"go";case".java":return"java";case".kt":case".kts":return"kotlin";case".scala":return"scala";case".rb":return"ruby";case".php":return"php";case".cs":return"csharp";case".vb":return"vb";case".dart":return"dart";case".c":case".h":return"c";case".cc":case".cpp":case".cxx":case".hpp":case".hh":case".hxx":return"cpp";case".vue":return"vue";default:return null}}export{C as a};
6
- //# sourceMappingURL=chunk-E4NFOAD4.js.map