scip-query 0.23.0 → 0.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (650) hide show
  1. package/CHANGELOG.md +491 -2
  2. package/README.md +111 -122
  3. package/dist/augment-vue-worker.js +1 -1
  4. package/dist/by-kind-PRVFAGTQ.js +2 -0
  5. package/dist/call-graph-DVPAQV2F.js +2 -0
  6. package/dist/call-graph-evidence-CUtj8V2I.d.ts +19 -0
  7. package/dist/chunk-2FSBGL5P.js +2 -0
  8. package/dist/chunk-2HLAFUCY.js +2 -0
  9. package/dist/chunk-2IWUT6CJ.js +3 -0
  10. package/dist/chunk-2KNN7GTQ.js +2 -0
  11. package/dist/chunk-2LHXRE2B.js +8 -0
  12. package/dist/{chunk-EG2CPZMJ.js → chunk-2YXE77TJ.js} +2 -2
  13. package/dist/chunk-36SGVCGX.js +2 -0
  14. package/dist/chunk-3ABBFPTP.js +2 -0
  15. package/dist/chunk-3IVFU4FD.js +3 -0
  16. package/dist/chunk-3JIQS44J.js +7 -0
  17. package/dist/chunk-3ZRB6DNK.js +7 -0
  18. package/dist/{chunk-6YTSKJJ3.js → chunk-42EOW5VI.js} +1 -1
  19. package/dist/{chunk-6I6L7Z62.js → chunk-4BHGBMNO.js} +2 -2
  20. package/dist/chunk-4BP3UBDG.js +2 -0
  21. package/dist/chunk-4D6RO7G4.js +2 -0
  22. package/dist/chunk-4FEWQ6RH.js +2 -0
  23. package/dist/chunk-4IGEOBG7.js +2 -0
  24. package/dist/chunk-4QZXBUKC.js +2 -0
  25. package/dist/chunk-4WBDEVX2.js +4 -0
  26. package/dist/chunk-4WCUBZU3.js +8 -0
  27. package/dist/chunk-4WTUBQ36.js +40 -0
  28. package/dist/chunk-4XQ4O6IM.js +3 -0
  29. package/dist/chunk-55UQAMZO.js +4 -0
  30. package/dist/chunk-5D2LVK7O.js +125 -0
  31. package/dist/chunk-5IYJ56TT.js +2 -0
  32. package/dist/chunk-5PLMJC7Q.js +2 -0
  33. package/dist/chunk-5TNQJUR2.js +5 -0
  34. package/dist/chunk-62BDNPMI.js +2 -0
  35. package/dist/chunk-64DZ5TXR.js +7 -0
  36. package/dist/chunk-65245JCM.js +2 -0
  37. package/dist/chunk-6FFVZZL4.js +2 -0
  38. package/dist/chunk-6KO5JHAR.js +2 -0
  39. package/dist/chunk-6LRXOOSX.js +2 -0
  40. package/dist/chunk-6LSEIIF7.js +2 -0
  41. package/dist/chunk-6YMNWD3H.js +6 -0
  42. package/dist/chunk-72AD6ZRR.js +5 -0
  43. package/dist/chunk-73AAKPUC.js +4 -0
  44. package/dist/chunk-76CZ77DF.js +2 -0
  45. package/dist/chunk-7VPEEAAG.js +2 -0
  46. package/dist/chunk-7WTPQ4NX.js +14 -0
  47. package/dist/chunk-7Y5T6XDP.js +2 -0
  48. package/dist/chunk-A2IIGFMJ.js +5 -0
  49. package/dist/chunk-AB5KCTEV.js +2 -0
  50. package/dist/chunk-AC566WBP.js +6 -0
  51. package/dist/chunk-AGWFSTXC.js +3 -0
  52. package/dist/chunk-AOSIYPTA.js +2 -0
  53. package/dist/chunk-AUVEWPIF.js +2 -0
  54. package/dist/chunk-B56T42J3.js +25 -0
  55. package/dist/chunk-BIQEF5NE.js +2 -0
  56. package/dist/chunk-BL6XJKTA.js +3 -0
  57. package/dist/chunk-BMKOQJRI.js +2 -0
  58. package/dist/chunk-BOZ4EXBB.js +3 -0
  59. package/dist/chunk-BUTWYEPH.js +2 -0
  60. package/dist/chunk-BZB4QPIP.js +2 -0
  61. package/dist/{chunk-ILTDAWEF.js → chunk-CE357GEE.js} +4 -4
  62. package/dist/chunk-CFN45HFP.js +2 -0
  63. package/dist/chunk-CFYMZFXT.js +368 -0
  64. package/dist/chunk-CN5EH7O3.js +2 -0
  65. package/dist/chunk-D254DNNQ.js +4 -0
  66. package/dist/chunk-D3FDISIC.js +2 -0
  67. package/dist/chunk-D3NX5XIE.js +3 -0
  68. package/dist/chunk-DA7RPPDF.js +3 -0
  69. package/dist/chunk-DDMC3FON.js +3 -0
  70. package/dist/chunk-DIO3FUSG.js +2 -0
  71. package/dist/chunk-DJ2NNSUK.js +3 -0
  72. package/dist/chunk-DKYQIM3C.js +18 -0
  73. package/dist/{chunk-JTQVMR42.js → chunk-DOOEL2IV.js} +2 -2
  74. package/dist/chunk-DVFP6PZI.js +2 -0
  75. package/dist/chunk-E3FDPXZK.js +2 -0
  76. package/dist/chunk-E7YNJLCB.js +2 -0
  77. package/dist/chunk-EFGW5JPH.js +2 -0
  78. package/dist/chunk-EJVTR244.js +13 -0
  79. package/dist/chunk-EOV7RTRZ.js +2 -0
  80. package/dist/chunk-ETOIKRHO.js +2 -0
  81. package/dist/chunk-EYK3ZAO2.js +3 -0
  82. package/dist/chunk-F2V2LPET.js +52 -0
  83. package/dist/chunk-F4LUHJTF.js +2 -0
  84. package/dist/chunk-F4PUT6IT.js +2 -0
  85. package/dist/chunk-F56GCXXS.js +5 -0
  86. package/dist/chunk-FC2EVQRM.js +2 -0
  87. package/dist/chunk-FL7NBMHP.js +3 -0
  88. package/dist/chunk-FMRN2TRL.js +3 -0
  89. package/dist/chunk-FVULPZDF.js +20 -0
  90. package/dist/chunk-GCKCF5FL.js +43 -0
  91. package/dist/chunk-GH2PYF46.js +2 -0
  92. package/dist/chunk-GHJAGXIP.js +2 -0
  93. package/dist/{chunk-WIWY3CRX.js → chunk-GMVSHUKZ.js} +2 -2
  94. package/dist/chunk-GS6KDO4R.js +2 -0
  95. package/dist/chunk-GUUBXNN7.js +2 -0
  96. package/dist/chunk-GVWX5T43.js +80 -0
  97. package/dist/chunk-GZKFETP5.js +2 -0
  98. package/dist/chunk-H4EQHO6J.js +9 -0
  99. package/dist/chunk-H73WY2RM.js +2 -0
  100. package/dist/chunk-H75GSPRV.js +60 -0
  101. package/dist/chunk-HDR3AHSV.js +61 -0
  102. package/dist/chunk-HQBSL74Y.js +2 -0
  103. package/dist/chunk-HRRFKWPZ.js +2 -0
  104. package/dist/chunk-HXENDJC6.js +2 -0
  105. package/dist/chunk-IIBAZNSW.js +21 -0
  106. package/dist/chunk-INLMWEUU.js +12 -0
  107. package/dist/chunk-IWQPAF4F.js +2 -0
  108. package/dist/chunk-IZJ6YUKP.js +35 -0
  109. package/dist/chunk-J2TMAIN5.js +60 -0
  110. package/dist/chunk-J5FJMODQ.js +142 -0
  111. package/dist/chunk-J7HZPIO3.js +2 -0
  112. package/dist/chunk-JEVRKFRL.js +2 -0
  113. package/dist/chunk-JFXSGAEB.js +30 -0
  114. package/dist/chunk-JVRTHGFS.js +3 -0
  115. package/dist/chunk-JYWEX7RR.js +360 -0
  116. package/dist/chunk-K3YL22N6.js +2 -0
  117. package/dist/chunk-K4CN7GXK.js +12 -0
  118. package/dist/chunk-K5TBVXU4.js +30 -0
  119. package/dist/chunk-KDDIE2DP.js +9 -0
  120. package/dist/chunk-KHWRRPV4.js +2 -0
  121. package/dist/chunk-KI6NBKDY.js +14 -0
  122. package/dist/chunk-KU3QRSTH.js +2 -0
  123. package/dist/chunk-KZBJWZJB.js +2 -0
  124. package/dist/chunk-L7GFM3NP.js +3 -0
  125. package/dist/chunk-LMO6PK3V.js +35 -0
  126. package/dist/chunk-LN4YXJJU.js +2 -0
  127. package/dist/chunk-LOVIZBJ4.js +43 -0
  128. package/dist/chunk-LPCRK4A2.js +11 -0
  129. package/dist/chunk-MMHZKBFA.js +2 -0
  130. package/dist/{chunk-M2O5NY6W.js → chunk-MOQQBQRD.js} +2 -2
  131. package/dist/chunk-N2WN6I3L.js +2 -0
  132. package/dist/chunk-N3ORQT7L.js +2 -0
  133. package/dist/chunk-NAZ3RAIW.js +2 -0
  134. package/dist/chunk-NDUNO5JQ.js +2 -0
  135. package/dist/chunk-NEIWRNAZ.js +4 -0
  136. package/dist/chunk-NJJMVD65.js +2 -0
  137. package/dist/chunk-NLOQOBXI.js +20 -0
  138. package/dist/chunk-NOLZOVCU.js +2 -0
  139. package/dist/chunk-NOWINRRN.js +2 -0
  140. package/dist/chunk-NZAXKGRL.js +16 -0
  141. package/dist/chunk-O2C4UILI.js +2 -0
  142. package/dist/chunk-O3RHA6ZT.js +3 -0
  143. package/dist/chunk-O4UZSPPI.js +3 -0
  144. package/dist/chunk-OGFV2BUX.js +2 -0
  145. package/dist/chunk-OZCJXZK6.js +499 -0
  146. package/dist/chunk-P6ODM7BY.js +2 -0
  147. package/dist/{chunk-XBGWL66K.js → chunk-PAVGPRHJ.js} +2 -2
  148. package/dist/chunk-PH52RA7D.js +2 -0
  149. package/dist/chunk-PKN354TH.js +3 -0
  150. package/dist/chunk-PWOASWEG.js +11 -0
  151. package/dist/chunk-QIWXRW72.js +2 -0
  152. package/dist/chunk-QJRMOK5N.js +2 -0
  153. package/dist/{chunk-YXPUP5G2.js → chunk-QOIXNWQR.js} +2 -2
  154. package/dist/chunk-QXEUDXBT.js +3 -0
  155. package/dist/chunk-QYUVVBMR.js +6 -0
  156. package/dist/chunk-QZ7KQZRN.js +2 -0
  157. package/dist/chunk-R6LQBUDH.js +2 -0
  158. package/dist/chunk-RBS42E55.js +20 -0
  159. package/dist/chunk-RSJKPCFX.js +26 -0
  160. package/dist/chunk-S6CZA3MV.js +2 -0
  161. package/dist/chunk-STMVAHJP.js +2 -0
  162. package/dist/chunk-SYVPTTVW.js +2 -0
  163. package/dist/chunk-T3I6NHBH.js +2 -0
  164. package/dist/chunk-T6DK3ZP7.js +2 -0
  165. package/dist/chunk-TKD34PHN.js +4 -0
  166. package/dist/chunk-TNNQFH7W.js +2 -0
  167. package/dist/chunk-TNV7SSUF.js +2 -0
  168. package/dist/chunk-TO7ZR3EH.js +8 -0
  169. package/dist/chunk-TOU3CHK4.js +2 -0
  170. package/dist/chunk-TRBI4UKT.js +2 -0
  171. package/dist/chunk-TZCVNCAN.js +4 -0
  172. package/dist/chunk-U4LZA5LL.js +3 -0
  173. package/dist/chunk-U5RIG3JP.js +3 -0
  174. package/dist/chunk-UP5KXN2I.js +2 -0
  175. package/dist/chunk-UQFR3NDH.js +5 -0
  176. package/dist/chunk-UXYXF7GV.js +2 -0
  177. package/dist/chunk-VB3GOKOS.js +2 -0
  178. package/dist/chunk-VF5JZICY.js +2 -0
  179. package/dist/chunk-VTY3VK6E.js +2 -0
  180. package/dist/chunk-VX2O4RIS.js +2 -0
  181. package/dist/chunk-WKPV2TDZ.js +2 -0
  182. package/dist/chunk-WOFQ5DTB.js +2 -0
  183. package/dist/chunk-WS4C6TCK.js +2 -0
  184. package/dist/chunk-WXU3DGPU.js +2 -0
  185. package/dist/chunk-X6RMKHJQ.js +81 -0
  186. package/dist/{chunk-4ILJCCXV.js → chunk-XHMN6ZX7.js} +2 -2
  187. package/dist/chunk-XHTVFLWW.js +2 -0
  188. package/dist/chunk-XKIDJCIK.js +2 -0
  189. package/dist/chunk-XTYTYZPT.js +2 -0
  190. package/dist/chunk-Y2JHHTTA.js +2 -0
  191. package/dist/chunk-YGVRMGYN.js +4 -0
  192. package/dist/chunk-YNQCGEQE.js +2 -0
  193. package/dist/chunk-YOQVEXVE.js +14 -0
  194. package/dist/chunk-YRT2WLYY.js +2 -0
  195. package/dist/chunk-YTAP5Y2G.js +2 -0
  196. package/dist/chunk-YTYWI7VB.js +2 -0
  197. package/dist/chunk-YULZRALL.js +2 -0
  198. package/dist/chunk-Z33WQG4Q.js +2 -0
  199. package/dist/chunk-ZGTYGDMF.js +16 -0
  200. package/dist/chunk-ZHMRSZFD.js +43 -0
  201. package/dist/chunk-ZHSP366W.js +10 -0
  202. package/dist/chunk-ZIBYCYKK.js +7 -0
  203. package/dist/{chunk-GAS2LJMP.js → chunk-ZLADLUE6.js} +3 -3
  204. package/dist/chunk-ZO4YXUT6.js +4 -0
  205. package/dist/{chunk-HYO3NP5Q.js → chunk-ZR4HBC2H.js} +2 -2
  206. package/dist/cli-main.js +6 -6
  207. package/dist/cli.js +1 -1
  208. package/dist/{code-B17qEMbt.d.ts → code-BNyrCF3_.d.ts} +3 -2
  209. package/dist/code-IL5WH3NZ.js +2 -0
  210. package/dist/code-result-json-ANTBEDFP.js +4 -0
  211. package/dist/command-descriptors-HEEMDHTU.js +222 -0
  212. package/dist/deps-EOWFC6FD.js +2 -0
  213. package/dist/direct-navigation-Y5B6OSIQ.js +3 -0
  214. package/dist/{exploration-topology-BG4v30HZ.d.ts → exploration-topology-CSgEyAz-.d.ts} +3 -1
  215. package/dist/files-K4AI3JUM.js +2 -0
  216. package/dist/frontend-profile-roles-D7eCum8P.d.ts +10 -0
  217. package/dist/{health-CPp2Jf1Z.d.ts → health-BtfmNrfa.d.ts} +58 -74
  218. package/dist/hierarchy-6W5NDIFI.js +2 -0
  219. package/dist/imports-WH365QY4.js +2 -0
  220. package/dist/index.d.ts +13 -1
  221. package/dist/index.js +1 -1
  222. package/dist/members-K3PHMF5S.js +2 -0
  223. package/dist/methods-E7KVMBX4.js +2 -0
  224. package/dist/output-continuation-command-BJSY67SN.js +3 -0
  225. package/dist/output-pagination-UZJ5ACIX.js +24 -0
  226. package/dist/postinstall.js +1 -1
  227. package/dist/project-reindex-EP24WT4X.js +3 -0
  228. package/dist/queries/affected.js +1 -1
  229. package/dist/queries/architecture.d.ts +15 -4
  230. package/dist/queries/architecture.js +1 -1
  231. package/dist/queries/bottlenecks.js +1 -1
  232. package/dist/queries/by-kind.js +1 -1
  233. package/dist/queries/call-graph.d.ts +3 -1
  234. package/dist/queries/call-graph.js +1 -1
  235. package/dist/queries/change-surface.d.ts +1 -0
  236. package/dist/queries/change-surface.js +1 -1
  237. package/dist/queries/cleanup-plan.d.ts +3 -3
  238. package/dist/queries/cleanup-plan.js +1 -1
  239. package/dist/queries/co-change.d.ts +20 -2
  240. package/dist/queries/co-change.js +1 -1
  241. package/dist/queries/code.d.ts +1 -1
  242. package/dist/queries/code.js +1 -1
  243. package/dist/queries/complexity.d.ts +6 -3
  244. package/dist/queries/complexity.js +1 -1
  245. package/dist/queries/context.d.ts +1 -7
  246. package/dist/queries/context.js +1 -1
  247. package/dist/queries/coupling.js +1 -1
  248. package/dist/queries/cycles.js +1 -1
  249. package/dist/queries/dead.d.ts +2 -0
  250. package/dist/queries/dead.js +1 -1
  251. package/dist/queries/decorative-checkers.js +1 -1
  252. package/dist/queries/dependence-slice.d.ts +46 -22
  253. package/dist/queries/dependence-slice.js +1 -1
  254. package/dist/queries/dependency-depth.d.ts +1 -7
  255. package/dist/queries/dependency-depth.js +1 -1
  256. package/dist/queries/deps.js +1 -1
  257. package/dist/queries/diff-impact.d.ts +3 -1
  258. package/dist/queries/diff-impact.js +1 -1
  259. package/dist/queries/doc-drift.js +1 -1
  260. package/dist/queries/drift.d.ts +1 -1
  261. package/dist/queries/drift.js +1 -1
  262. package/dist/queries/duplicate-bodies.d.ts +29 -2
  263. package/dist/queries/duplicate-bodies.js +1 -1
  264. package/dist/queries/entry-map.d.ts +2 -4
  265. package/dist/queries/entry-map.js +1 -1
  266. package/dist/queries/evidence.d.ts +121 -61
  267. package/dist/queries/evidence.js +1 -1
  268. package/dist/queries/fan.js +1 -1
  269. package/dist/queries/files.js +1 -1
  270. package/dist/queries/health.d.ts +1 -1
  271. package/dist/queries/health.js +1 -1
  272. package/dist/queries/hierarchy.d.ts +2 -2
  273. package/dist/queries/hierarchy.js +1 -1
  274. package/dist/queries/hotspots.d.ts +1 -1
  275. package/dist/queries/hotspots.js +1 -1
  276. package/dist/queries/imports.d.ts +1 -0
  277. package/dist/queries/imports.js +1 -1
  278. package/dist/queries/incomplete-migration.d.ts +3 -3
  279. package/dist/queries/incomplete-migration.js +1 -1
  280. package/dist/queries/index.d.ts +17 -65
  281. package/dist/queries/index.js +1 -1
  282. package/dist/queries/locality-candidates.d.ts +4 -4
  283. package/dist/queries/locality-candidates.js +1 -1
  284. package/dist/queries/members.d.ts +2 -2
  285. package/dist/queries/members.js +1 -1
  286. package/dist/queries/methods.js +1 -1
  287. package/dist/queries/not-implemented.d.ts +2 -6
  288. package/dist/queries/not-implemented.js +1 -1
  289. package/dist/queries/outline.js +1 -1
  290. package/dist/queries/passthrough-candidates.d.ts +9 -1
  291. package/dist/queries/passthrough-candidates.js +1 -1
  292. package/dist/queries/react-component-duplicates.d.ts +19 -3
  293. package/dist/queries/react-component-duplicates.js +1 -1
  294. package/dist/queries/react-hook-candidates.d.ts +22 -3
  295. package/dist/queries/react-hook-candidates.js +1 -1
  296. package/dist/queries/react-large-component-pressure.d.ts +17 -3
  297. package/dist/queries/react-large-component-pressure.js +1 -1
  298. package/dist/queries/recent-duplicates.js +1 -1
  299. package/dist/queries/redundant-reexports.d.ts +4 -14
  300. package/dist/queries/redundant-reexports.js +1 -1
  301. package/dist/queries/refs.d.ts +4 -1
  302. package/dist/queries/refs.js +1 -1
  303. package/dist/queries/review.d.ts +188 -0
  304. package/dist/queries/review.js +2 -0
  305. package/dist/queries/similar-files.d.ts +7 -10
  306. package/dist/queries/similar-files.js +1 -1
  307. package/dist/queries/similar-signatures.js +1 -1
  308. package/dist/queries/similar.d.ts +19 -1
  309. package/dist/queries/similar.js +1 -1
  310. package/dist/queries/slice-cohesion.d.ts +205 -0
  311. package/dist/queries/slice-cohesion.js +2 -0
  312. package/dist/queries/source-inspection.d.ts +6 -202
  313. package/dist/queries/source-inspection.js +1 -1
  314. package/dist/queries/source-search.d.ts +2 -3
  315. package/dist/queries/source-search.js +1 -1
  316. package/dist/queries/stats.d.ts +1 -0
  317. package/dist/queries/stats.js +1 -1
  318. package/dist/queries/surface.js +1 -1
  319. package/dist/queries/symbols.js +1 -1
  320. package/dist/queries/system.d.ts +4 -2
  321. package/dist/queries/system.js +1 -1
  322. package/dist/queries/test-quality.d.ts +1 -1
  323. package/dist/queries/test-quality.js +1 -1
  324. package/dist/queries/twin-drift.d.ts +23 -7
  325. package/dist/queries/twin-drift.js +1 -1
  326. package/dist/queries/unused-imports.js +1 -1
  327. package/dist/queries/unused-params.d.ts +3 -15
  328. package/dist/queries/unused-params.js +1 -1
  329. package/dist/queries/vue-component-duplicates.js +1 -1
  330. package/dist/queries/vue-composable-candidates.js +1 -1
  331. package/dist/queries/vue-large-view-pressure.js +1 -1
  332. package/dist/query-service-fastpath.js +5 -5
  333. package/dist/query-service-server.js +4 -4
  334. package/dist/refs-CCBJG7WK.js +2 -0
  335. package/dist/refs-pagination-DRNLVU4S.js +2 -0
  336. package/dist/reindex-worker.js +79 -29
  337. package/dist/reindex.js +45 -45
  338. package/dist/repository-cache-worker.js +2 -0
  339. package/dist/runtime.d.ts +8 -8
  340. package/dist/runtime.js +3 -4
  341. package/dist/rust-semantic-session-server.js +1 -1
  342. package/dist/rust-semantic-session-worker.js +1 -1
  343. package/dist/rust-semantic-worker.js +1 -1
  344. package/dist/service-queries-2WAJI7R6.js +6 -0
  345. package/dist/source-inspection-91U9zdO3.d.ts +341 -0
  346. package/dist/{source-search-types-Dwz8KeuW.d.ts → source-search-types-DWGYNg8M.d.ts} +15 -2
  347. package/dist/stats-G7DIV6VU.js +2 -0
  348. package/dist/surface-IO55UALI.js +2 -0
  349. package/dist/system-ZBMSHJXU.js +2 -0
  350. package/dist/{queries/trace.d.ts → trace-BMjw3prn.d.ts} +1 -18
  351. package/dist/typescript-indexer.js +2 -0
  352. package/dist/typescript-mailbox-worker.js +1 -1
  353. package/dist/watch-server.js +3 -3
  354. package/docs/AGENT_GUIDE.md +19 -128
  355. package/docs/CLI_JSON_OUTPUT.md +21 -17
  356. package/docs/COMMAND_REFERENCE.md +34 -49
  357. package/docs/CURRENT_COMMANDS.md +123 -0
  358. package/docs/DETECTOR_EVIDENCE_CONTRACTS.md +0 -40
  359. package/docs/DETECTOR_GUIDE.md +55 -12
  360. package/docs/PRODUCT_VISION.md +135 -0
  361. package/docs/PROPERTY_TESTING.md +73 -0
  362. package/docs/REVIEW.md +76 -0
  363. package/docs/SKILLS.md +51 -0
  364. package/docs/WINDOWS_SIDECAR_RELEASE.md +12 -3
  365. package/docs/accuracy-audit-checklist.md +70 -13
  366. package/docs/analyzer-inventory.md +2 -2
  367. package/docs/locality-analyzer-design.md +9 -9
  368. package/package.json +18 -80
  369. package/scripts/evidence-product-contract.mjs +7 -3
  370. package/scripts/record-review-coverage.mjs +118 -0
  371. package/scripts/scip-windows-provenance.mjs +29 -19
  372. package/skills/scip-architecture-review/SKILL.md +57 -0
  373. package/skills/scip-architecture-review/agents/openai.yaml +4 -0
  374. package/skills/scip-architecture-review/references/design-checks.md +17 -0
  375. package/skills/scip-explore/SKILL.md +15 -59
  376. package/skills/scip-explore/agents/openai.yaml +3 -3
  377. package/skills/scip-explore/references/external-evidence.md +2 -2
  378. package/skills/scip-explore/references/information-model.md +26 -29
  379. package/skills/scip-explore/scripts/capture-evidence.mjs +68 -34
  380. package/skills/scip-integrity-audit/SKILL.md +53 -181
  381. package/skills/scip-integrity-audit/agents/openai.yaml +3 -3
  382. package/skills/scip-integrity-audit/references/integrity-probes.md +27 -0
  383. package/skills/scip-plan/SKILL.md +39 -65
  384. package/skills/scip-plan/agents/openai.yaml +2 -2
  385. package/skills/scip-query/SKILL.md +28 -81
  386. package/skills/scip-query/agents/openai.yaml +2 -2
  387. package/skills/scip-query/references/command-guide.md +169 -0
  388. package/skills/scip-setup/SKILL.md +4 -2
  389. package/skills/scip-setup/agents/openai.yaml +3 -3
  390. package/dist/by-kind-XI2CSWEY.js +0 -2
  391. package/dist/call-graph-UONR6JR5.js +0 -2
  392. package/dist/call-graph-evidence-lZa2dwQA.d.ts +0 -11
  393. package/dist/chunk-26CT72HM.js +0 -2
  394. package/dist/chunk-2E7CX53V.js +0 -2
  395. package/dist/chunk-2GRUZAQF.js +0 -43
  396. package/dist/chunk-2LDBDR6J.js +0 -29
  397. package/dist/chunk-2OOY75BW.js +0 -2
  398. package/dist/chunk-2R3V3PSD.js +0 -4
  399. package/dist/chunk-2WC2OEDO.js +0 -4
  400. package/dist/chunk-35NLDRZC.js +0 -2
  401. package/dist/chunk-3AF4TUFK.js +0 -3
  402. package/dist/chunk-3D3QG236.js +0 -2
  403. package/dist/chunk-3FHOF22C.js +0 -21
  404. package/dist/chunk-3JKSW6LJ.js +0 -2
  405. package/dist/chunk-3L2ZBPEX.js +0 -133
  406. package/dist/chunk-3PJABJSU.js +0 -2
  407. package/dist/chunk-3SVF22I5.js +0 -2
  408. package/dist/chunk-3WR4E3A3.js +0 -3
  409. package/dist/chunk-4FTZ4P5G.js +0 -2
  410. package/dist/chunk-4UX2F3JX.js +0 -2
  411. package/dist/chunk-4WNW27SX.js +0 -2
  412. package/dist/chunk-5ENOG4VP.js +0 -61
  413. package/dist/chunk-64BFSI5I.js +0 -2
  414. package/dist/chunk-66DVSJQG.js +0 -455
  415. package/dist/chunk-6HFCYNYE.js +0 -9
  416. package/dist/chunk-6PQNKL3G.js +0 -3
  417. package/dist/chunk-6V5CNXL6.js +0 -2
  418. package/dist/chunk-6VVV4WRR.js +0 -4
  419. package/dist/chunk-7BWFZPPZ.js +0 -2
  420. package/dist/chunk-7CYG22FH.js +0 -2
  421. package/dist/chunk-7F45LJKI.js +0 -2
  422. package/dist/chunk-7IWV2EG3.js +0 -3
  423. package/dist/chunk-7KCZELVM.js +0 -2
  424. package/dist/chunk-AFHTBORT.js +0 -2
  425. package/dist/chunk-AVRYW5OZ.js +0 -2
  426. package/dist/chunk-B3X6KU75.js +0 -2
  427. package/dist/chunk-B5D7QPBE.js +0 -4
  428. package/dist/chunk-BBCIS4DX.js +0 -16
  429. package/dist/chunk-BDUVI7TO.js +0 -3
  430. package/dist/chunk-BE7ZZTMC.js +0 -2
  431. package/dist/chunk-BHVUJOCQ.js +0 -3
  432. package/dist/chunk-BJT7LSPK.js +0 -3
  433. package/dist/chunk-BKVWUP7Y.js +0 -2
  434. package/dist/chunk-BQGB4HBD.js +0 -2
  435. package/dist/chunk-BRV7PIFF.js +0 -2
  436. package/dist/chunk-CEEZJXEF.js +0 -2
  437. package/dist/chunk-CIYLO6SI.js +0 -7
  438. package/dist/chunk-CJZXN4NU.js +0 -2
  439. package/dist/chunk-CNO7TOKL.js +0 -2
  440. package/dist/chunk-COF23M5F.js +0 -2
  441. package/dist/chunk-CWFP7GM5.js +0 -2
  442. package/dist/chunk-D2DHWI3D.js +0 -2
  443. package/dist/chunk-D4N5SQ2M.js +0 -4
  444. package/dist/chunk-DBRSYFXR.js +0 -2
  445. package/dist/chunk-DHUIOLDT.js +0 -2
  446. package/dist/chunk-DIRJWYBM.js +0 -6
  447. package/dist/chunk-DIUFNHRJ.js +0 -35
  448. package/dist/chunk-DRENNWRG.js +0 -2
  449. package/dist/chunk-DTZCKZEU.js +0 -4
  450. package/dist/chunk-DULC3QFP.js +0 -5
  451. package/dist/chunk-DYGHBZ2N.js +0 -16
  452. package/dist/chunk-E5R6AQ73.js +0 -40
  453. package/dist/chunk-E73UNJTF.js +0 -38
  454. package/dist/chunk-EKV5HX33.js +0 -2
  455. package/dist/chunk-EQHFIL6T.js +0 -3
  456. package/dist/chunk-ESIQ66Z7.js +0 -2
  457. package/dist/chunk-EVFUMY4R.js +0 -3
  458. package/dist/chunk-F7DY272B.js +0 -2
  459. package/dist/chunk-FBN2FGXG.js +0 -2
  460. package/dist/chunk-FDLOBR6P.js +0 -4
  461. package/dist/chunk-FESCRNVV.js +0 -5
  462. package/dist/chunk-FFRKR4EQ.js +0 -2
  463. package/dist/chunk-FGA2U4OR.js +0 -8
  464. package/dist/chunk-FIQRSHVM.js +0 -2
  465. package/dist/chunk-FPYLNQPT.js +0 -2
  466. package/dist/chunk-FRUSVINH.js +0 -2
  467. package/dist/chunk-GSP44ENC.js +0 -2
  468. package/dist/chunk-GUFSG5TX.js +0 -2
  469. package/dist/chunk-GYIZ4NXB.js +0 -2
  470. package/dist/chunk-GZIUDL6G.js +0 -2
  471. package/dist/chunk-H5EXS3HM.js +0 -2
  472. package/dist/chunk-HCXEQRFF.js +0 -18
  473. package/dist/chunk-HEHOQQKH.js +0 -2
  474. package/dist/chunk-HKGFPJ4T.js +0 -4
  475. package/dist/chunk-HLZTEXRA.js +0 -2
  476. package/dist/chunk-HOENASQM.js +0 -3
  477. package/dist/chunk-HVF5VBG6.js +0 -2
  478. package/dist/chunk-I55I7XXP.js +0 -2
  479. package/dist/chunk-IDFEUFKS.js +0 -2
  480. package/dist/chunk-IHGQTTVW.js +0 -2
  481. package/dist/chunk-IICPE7B2.js +0 -20
  482. package/dist/chunk-IL676XCC.js +0 -18
  483. package/dist/chunk-IW5XQG5G.js +0 -2
  484. package/dist/chunk-IZDPJ2QI.js +0 -2
  485. package/dist/chunk-J66VOFW6.js +0 -5
  486. package/dist/chunk-JFMEXGFE.js +0 -2
  487. package/dist/chunk-JGKUET5J.js +0 -3
  488. package/dist/chunk-JS4PGXMV.js +0 -3
  489. package/dist/chunk-JWTGMPIT.js +0 -80
  490. package/dist/chunk-JYR66JN5.js +0 -5
  491. package/dist/chunk-KFOYCQAJ.js +0 -9
  492. package/dist/chunk-KLFEXGQA.js +0 -2
  493. package/dist/chunk-KMVGRIO2.js +0 -2
  494. package/dist/chunk-KYSDI3GE.js +0 -5
  495. package/dist/chunk-L6PJPETJ.js +0 -29
  496. package/dist/chunk-LDVT66YM.js +0 -2
  497. package/dist/chunk-LEECKFCJ.js +0 -2
  498. package/dist/chunk-LMZ5PRUV.js +0 -2
  499. package/dist/chunk-LQRQN2XA.js +0 -2
  500. package/dist/chunk-LXABEJX3.js +0 -2
  501. package/dist/chunk-MNV5FSBW.js +0 -3
  502. package/dist/chunk-MPQ4OTBM.js +0 -2
  503. package/dist/chunk-MTDBHTSF.js +0 -2
  504. package/dist/chunk-MV3CDXPI.js +0 -38
  505. package/dist/chunk-MWN53KRN.js +0 -60
  506. package/dist/chunk-MXNGIEPU.js +0 -3
  507. package/dist/chunk-N2ZSIIGR.js +0 -117
  508. package/dist/chunk-N5B2NILC.js +0 -5
  509. package/dist/chunk-NJITK2GP.js +0 -2
  510. package/dist/chunk-NOGJXYFO.js +0 -2
  511. package/dist/chunk-NOYBFVJA.js +0 -554
  512. package/dist/chunk-NWQXSFFU.js +0 -3
  513. package/dist/chunk-ODDUPDP7.js +0 -13
  514. package/dist/chunk-OLIWTZI3.js +0 -3
  515. package/dist/chunk-OLNV6I6U.js +0 -2
  516. package/dist/chunk-OR2E3AGZ.js +0 -2
  517. package/dist/chunk-OSR2GEHQ.js +0 -2
  518. package/dist/chunk-OSSESPDX.js +0 -3
  519. package/dist/chunk-OWOOWNJ5.js +0 -7
  520. package/dist/chunk-P42EIXTA.js +0 -2
  521. package/dist/chunk-PJFGPYTU.js +0 -2
  522. package/dist/chunk-PP7KNN7L.js +0 -2
  523. package/dist/chunk-PU7T5QYQ.js +0 -2
  524. package/dist/chunk-PWWAJSKV.js +0 -74
  525. package/dist/chunk-PZL5T7SU.js +0 -73
  526. package/dist/chunk-QBE3YX64.js +0 -23
  527. package/dist/chunk-QGVTFRY2.js +0 -7
  528. package/dist/chunk-QOJONDS7.js +0 -2
  529. package/dist/chunk-QU5XRYB5.js +0 -4
  530. package/dist/chunk-QUU5OBVK.js +0 -11
  531. package/dist/chunk-RBLQNW26.js +0 -20
  532. package/dist/chunk-RTQ7NEKG.js +0 -81
  533. package/dist/chunk-SQXRS7BG.js +0 -4
  534. package/dist/chunk-SSK6LDPC.js +0 -2
  535. package/dist/chunk-SZHGTCPP.js +0 -7
  536. package/dist/chunk-T4N4P2K5.js +0 -16
  537. package/dist/chunk-TA3QKLLU.js +0 -2
  538. package/dist/chunk-TEBQMNVI.js +0 -43
  539. package/dist/chunk-TPFHAQ2G.js +0 -2
  540. package/dist/chunk-TQPCBMWT.js +0 -5
  541. package/dist/chunk-TQZV7KV4.js +0 -2
  542. package/dist/chunk-TRNAEQ6P.js +0 -3
  543. package/dist/chunk-TY7CRN3Z.js +0 -2
  544. package/dist/chunk-UHFYCMZO.js +0 -35
  545. package/dist/chunk-UICY4GTQ.js +0 -7
  546. package/dist/chunk-UVGEWT4Y.js +0 -26
  547. package/dist/chunk-UXW33INU.js +0 -29
  548. package/dist/chunk-VMPRET3I.js +0 -5
  549. package/dist/chunk-VNLGKHS6.js +0 -6
  550. package/dist/chunk-VQILFTEH.js +0 -2
  551. package/dist/chunk-VUPHCS7Y.js +0 -57
  552. package/dist/chunk-VVZSBTSU.js +0 -23
  553. package/dist/chunk-VZRNID6A.js +0 -2
  554. package/dist/chunk-W5OXRYGE.js +0 -7
  555. package/dist/chunk-W6STWDQI.js +0 -57
  556. package/dist/chunk-W7CXK74K.js +0 -2
  557. package/dist/chunk-WB3WYIRE.js +0 -4
  558. package/dist/chunk-WDNVY4E7.js +0 -20
  559. package/dist/chunk-WK46TNUM.js +0 -3
  560. package/dist/chunk-WNTFFKAX.js +0 -12
  561. package/dist/chunk-WOIKCX6A.js +0 -2
  562. package/dist/chunk-WUN6KBHV.js +0 -2
  563. package/dist/chunk-WYCTJDVR.js +0 -2
  564. package/dist/chunk-WYPL7GF7.js +0 -2
  565. package/dist/chunk-XDAUYDFT.js +0 -2
  566. package/dist/chunk-XDQMU3BT.js +0 -2
  567. package/dist/chunk-XFA4SSO3.js +0 -3
  568. package/dist/chunk-XGZEP6GR.js +0 -8
  569. package/dist/chunk-XPDPNWTQ.js +0 -368
  570. package/dist/chunk-XRYABF57.js +0 -8
  571. package/dist/chunk-YBGKCQIS.js +0 -2
  572. package/dist/chunk-YEN6CYC7.js +0 -16
  573. package/dist/chunk-YF5IB2LF.js +0 -2
  574. package/dist/chunk-YI2AWIHC.js +0 -3
  575. package/dist/chunk-YPWBKGFU.js +0 -2
  576. package/dist/chunk-YPWHBBIS.js +0 -2
  577. package/dist/chunk-YSH6U3L4.js +0 -3
  578. package/dist/chunk-YU5DZUZI.js +0 -10
  579. package/dist/chunk-YWO5DDRC.js +0 -16
  580. package/dist/chunk-Z4CDXYNQ.js +0 -2
  581. package/dist/chunk-ZF5KHH7C.js +0 -2
  582. package/dist/chunk-ZOHS7AQV.js +0 -21
  583. package/dist/chunk-ZTI4SBFV.js +0 -3
  584. package/dist/code-MI6F2TTU.js +0 -2
  585. package/dist/code-result-json-FXALY4HE.js +0 -2
  586. package/dist/command-descriptors-P34VABY5.js +0 -343
  587. package/dist/dataflow-4KEMJPC6.js +0 -2
  588. package/dist/dependence-slice-R7FPWD5M.js +0 -2
  589. package/dist/deps-7EMQUYUT.js +0 -2
  590. package/dist/direct-navigation-6YO234F2.js +0 -3
  591. package/dist/entry-map-KOOLR26E.js +0 -2
  592. package/dist/files-OPIPJIGZ.js +0 -2
  593. package/dist/graph-evidence-Bjyky2V4.d.ts +0 -126
  594. package/dist/hierarchy-QPD2CAER.js +0 -2
  595. package/dist/imports-M6HUXRXC.js +0 -2
  596. package/dist/members-I5MEFOCT.js +0 -2
  597. package/dist/methods-5JYGGHXA.js +0 -2
  598. package/dist/next-anchor-candidates-BwMczMvX.d.ts +0 -90
  599. package/dist/output-continuation-command-UPQAAKBP.js +0 -3
  600. package/dist/output-pagination-3OFL2MJV.js +0 -19
  601. package/dist/project-reindex-UKKQ5PLS.js +0 -3
  602. package/dist/queries/anchors.d.ts +0 -123
  603. package/dist/queries/anchors.js +0 -2
  604. package/dist/queries/complexity-hotspots.d.ts +0 -40
  605. package/dist/queries/complexity-hotspots.js +0 -2
  606. package/dist/queries/convergence.d.ts +0 -33
  607. package/dist/queries/convergence.js +0 -2
  608. package/dist/queries/dataflow.d.ts +0 -77
  609. package/dist/queries/dataflow.js +0 -2
  610. package/dist/queries/deep-chains.d.ts +0 -5
  611. package/dist/queries/deep-chains.js +0 -2
  612. package/dist/queries/extract-candidates.d.ts +0 -52
  613. package/dist/queries/extract-candidates.js +0 -2
  614. package/dist/queries/isolated.d.ts +0 -24
  615. package/dist/queries/isolated.js +0 -2
  616. package/dist/queries/plan-context.d.ts +0 -33
  617. package/dist/queries/plan-context.js +0 -2
  618. package/dist/queries/reference-neighborhood.d.ts +0 -4
  619. package/dist/queries/reference-neighborhood.js +0 -2
  620. package/dist/queries/reference-reachability.d.ts +0 -48
  621. package/dist/queries/reference-reachability.js +0 -2
  622. package/dist/queries/self-audit.d.ts +0 -63
  623. package/dist/queries/self-audit.js +0 -2
  624. package/dist/queries/similar-chains.d.ts +0 -48
  625. package/dist/queries/similar-chains.js +0 -2
  626. package/dist/queries/slice.d.ts +0 -4
  627. package/dist/queries/slice.js +0 -2
  628. package/dist/queries/stale-abstractions.d.ts +0 -72
  629. package/dist/queries/stale-abstractions.js +0 -2
  630. package/dist/queries/system-map.d.ts +0 -449
  631. package/dist/queries/system-map.js +0 -2
  632. package/dist/queries/trace.js +0 -2
  633. package/dist/queries/twin-ab.d.ts +0 -66
  634. package/dist/queries/twin-ab.js +0 -2
  635. package/dist/queries/value-flow.d.ts +0 -43
  636. package/dist/queries/value-flow.js +0 -2
  637. package/dist/queries/wrapper-candidates.d.ts +0 -34
  638. package/dist/queries/wrapper-candidates.js +0 -2
  639. package/dist/refs-PSU4JZZW.js +0 -2
  640. package/dist/refs-pagination-JG6CJMRC.js +0 -2
  641. package/dist/slice-HYRATV64.js +0 -2
  642. package/dist/source-snippet-_wrcgmZc.d.ts +0 -15
  643. package/dist/stats-OOJ74B32.js +0 -2
  644. package/dist/surface-VTGDYWF5.js +0 -2
  645. package/dist/symbol-resolution-WD5EU5JE.js +0 -2
  646. package/dist/system-LRQNFOR2.js +0 -2
  647. package/dist/trace-F4B6OLL4.js +0 -2
  648. package/dist/value-flow-VRPZY72V.js +0 -2
  649. package/skills/concrete-plan/SKILL.md +0 -8
  650. package/skills/concrete-plan/agents/openai.yaml +0 -4
@@ -1,3 +0,0 @@
1
- import{a as te}from"./chunk-P5XHIJHI.js";import{A as St,B as gt,C as kn,a as vn,i as Dn,j as ge,k as Y,l as Ue,m as ne,n as re,o as Be,q as mt,r as qe,s as je,t as ie,u as Cn,v as Tn,w as We,x as Pn,y as yt}from"./chunk-WB3WYIRE.js";import{d as Mn}from"./chunk-KK7GPALL.js";import{a as Pe,b as ke,c as Ae,d as Fe,e as q,o as xn}from"./chunk-TRNAEQ6P.js";import{b as hn,e as $,f as Oe,h as In,j as Se,t as z,u as ee}from"./chunk-N2ZSIIGR.js";import{a as ye,n as Le,w as Rn,y as bn}from"./chunk-ODDUPDP7.js";import{D as gn,a as Ne,c as dn,d as mn,q as pt,z as Sn}from"./chunk-ZOHS7AQV.js";import{c as dt,d as me,e as V}from"./chunk-FESCRNVV.js";import{A as _e,a as ln,c as un,d as ut,h as ft,j as Z,s as fn,u as pn,v as _,x as yn,y as k}from"./chunk-JWTGMPIT.js";import{Aa as an,Ba as de,C as rn,D as H,E as we,Ea as cn,H as Ee,I as B,J as sn,O as ct,ca as lt,n as pe,q as N,wa as on}from"./chunk-N5B2NILC.js";import{randomUUID as Ni}from"crypto";import{existsSync as _i}from"fs";import{dirname as tr}from"path";function wn(t){if(!t||typeof t!="object"||Array.isArray(t))return null;let e=t;if(typeof e.available!="boolean"||e.dependencyAvailable!==void 0&&typeof e.dependencyAvailable!="boolean"||e.tsconfigPath!==void 0&&typeof e.tsconfigPath!="string"||e.tsconfigPaths!==void 0&&(!Array.isArray(e.tsconfigPaths)||!e.tsconfigPaths.every(n=>typeof n=="string"))||e.resolvedBinary!==void 0&&typeof e.resolvedBinary!="string"||e.note!==void 0&&typeof e.note!="string")return null;if(e.available===!0){if(e.reason!==void 0)return null}else if(typeof e.reason!="string"||e.reason.length===0)return null;return e}import{performance as D}from"perf_hooks";function L(t,e,n){if(t.has(e))return t.get(e);let r=n();return t.set(e,r),r}import Fn from"path";import{realpathSync as En}from"fs";function ai(t,e){return t.getReferences().map(n=>{let r=n.getNode();return ze(r,e)})}function ci(t){let e=t;return typeof e.findReferences=="function"?e.findReferences():[]}function Nn(t,e,n,r){let i=[];for(let s of ci(t))for(let o of ai(s,r))o.file===e.relativePath&&o.line>=e.startLine&&o.line<=e.endLine||i.push(o);for(let s of n)i.push(s);return se(i)}function _n(t,e,n,r){let i=[],s=n?.getStart();for(let o of t.getReferences()){let a=o.getNode();oe(r,a.getSourceFile().getFilePath())===e&&(s!==void 0&&a.getStart()===s||i.push({location:ze(a,r),node:a}))}return i}function ze(t,e){let n=t.getSourceFile(),r=n.getLineAndColumnAtPos(t.getStart());return{file:oe(e,n.getFilePath())??n.getBaseName(),line:r.line-1,column:r.column-1}}function Ln(t,e,n){let r=t.getSourceFile(),i=bt(r,t),s=t.getText(),o=new RegExp(`\\b${ye(s)}\\b`,"g"),a=r.getFullText().split(`
2
- `),l=[];for(let u=0;u<a.length;u++){if(u===i)continue;let f=a[u]??"";o.lastIndex=0;let c;for(;(c=o.exec(f))!==null;)l.push({file:e,line:u,column:c.index})}return se(l.filter(u=>oe(n,Fn.join(n,u.file))===e))}function Rt(t){for(let e=t;e;e=e.getParent()){let n=e.getKindName();if(n.includes("Type")||n==="InterfaceDeclaration"||n==="TypeAliasDeclaration")return!0;if(n==="CallExpression"||n==="NewExpression"||n==="ExpressionStatement")return!1}return!1}function bt(t,e){return t.getLineAndColumnAtPos(e.getStart()).line-1}function se(t){let e=new Set,n=[];for(let r of t){let i=`${r.file}:${r.line}:${r.column}`;e.has(i)||(e.add(i),n.push(r))}return n}function oe(t,e){let n=t||process.cwd(),r=An(n,e);if(r)return r;try{return An(En(n),En(e))}catch{return null}}function An(t,e){let n=Fn.relative(t,e).replace(/\\/g,"/");return!n||n===".."||n.startsWith("../")?null:n}function On(t,e,n,r){let i=li(e,r);return i.size===0?new Map:ui(t,n,i)}function li(t,e){let n=new Map;for(let r of z(t,e)){let i=$(r.symbol)??r.leaf;if(!i)continue;let s=n.get(i);s||(s=[],n.set(i,s)),s.push(r)}return n}function ui(t,e,n){let r=new Map,i=new Map;return e.forEachDescendant(s=>{for(let o of fi(t,s)){let a=n.get(o);if(!a)continue;let l=bt(e,s);for(let u of a){if(l<u.startLine-1||l>u.endLine+1)continue;let f=Math.abs(l-u.startLine),c=i.get(u.symbolId);c!==void 0&&c<=f||(i.set(u.symbolId,f),r.set(u.symbolId,s))}}}),r}function fi(t,e){let n=[],r=i=>{i&&!n.includes(i)&&n.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 t.Node.isIdentifier(e)&&r(e.getText()),n}var pi=un("ts-definition-leaf-candidates",{clearGroups:["definition-catalog"]});function Un(t,e,n,r){let i=Mt(t,e),s=ht(i.get(r)??[],n);if(s)return s;let o=[];for(let a of i.values())for(let l of a)((l.leaf||$(l.symbol)||"").includes(r)||l.symbol.includes(r))&&o.push(l);return ht(o,n)}function It(t,e,n,r){return ht(Mt(t,e).get(r)??[],n)}function Bn(t,e){let n=new Map;for(let[r,i]of Mt(t,e)){let s=i[0];s&&n.set(r,s)}return n}function Mt(t,e){return pi.get(t,e,()=>{let n=new Map;for(let r of z(t,e)){let i=r.leaf||$(r.symbol);if(!i)continue;let s=n.get(i);s||(s=[],n.set(i,s)),s.push({...r,leaf:i})}for(let r of n.values())r.sort((i,s)=>i.startLine-s.startLine||i.endLine-s.endLine||i.symbolId-s.symbolId);return n})}function ht(t,e){let n=null,r=Number.POSITIVE_INFINITY;for(let i of t){let s=Math.abs(i.startLine-e);(s<r||s===r&&n&&i.startLine<n.startLine)&&(n=i,r=s)}return n}import di from"path";import{realpathSync as mi}from"fs";function qn(t,e){let n=new Map,r=null,i=null,s=()=>(i??=Ne(t,{extensions:je}),i),o=()=>(r??=k("typescript.source-file-index",()=>yi(t.config.projectRoot,e,s()),()=>({projects:e.length,indexedDocuments:s().length})),r),a=l=>ie(l)?L(n,l,()=>{let u=jn(t.config.projectRoot,l);if(!u)return null;for(let{project:f,sourceFiles:c}of o()){let p=c.get(u)??null;if(p||(p=f.addSourceFileAtPathIfExists(u)??null,p&&vt(c,p)),p)return{project:f,sourceFile:p}}return null}):null;return{sourceFile:l=>a(l)?.sourceFile??null,sourceFileMatch:a,indexedTypeScriptLikeDocuments:s}}function yi(t,e,n){let r=e.map(({project:i})=>{let s=new Map;for(let o of i.getSourceFiles())vt(s,o);return{project:i,sourceFiles:s}});for(let i of n){let s=jn(t,i);if(s)for(let o of r){if(o.sourceFiles.has(s))break;let a=o.project.addSourceFileAtPathIfExists(s)??null;if(a){vt(o.sourceFiles,a);break}}}return r}function vt(t,e){let n=Dt(e.getFilePath());t.set(n,e);try{t.set(Dt(mi(n)),e)}catch(r){if(!de(r))throw r}}function jn(t,e){try{return Dt(on(t,e,{inputKind:"indexed TypeScript source file"}).absolutePath)}catch(n){if(!de(n))throw n;return null}}function Dt(t){return di.resolve(t)}function xt(t,e){for(let n of t)if(e===n.name||e.startsWith(`${n.name}/`))return n.name;return null}function Wn(t){let e=`${t.relativeDir}/src`;return[`${e}/index.ts`,`${e}/index.tsx`,`${e}/index.mts`,`${e}/index.cts`]}import{existsSync as Re}from"fs";import A from"path";var Ct=["tsconfig.json","tsconfig.app.json","tsconfig.node.json","tsconfig.base.json"];function Tt(t,e){let r=e?A.dirname(A.join(t,e)):t,i=A.resolve(t);for(;r.startsWith(i);){for(let o of Ct){let a=A.join(r,o);if(Re(a))return a}let s=A.dirname(r);if(s===r)break;r=s}for(let s of Ct){let o=A.join(t,s);if(Re(o))return o}return null}function zn(t){let e=t.config.projectRoot,n=new Set(Si(e,t.config.semantic?.typescript?.tsconfigs)),r=Ne(t,{includeIgnored:!1,extensions:je});for(let i of r){let s=Tt(e,i);s&&n.add(A.resolve(s))}if(n.size===0){let i=Tt(e);i&&n.add(A.resolve(i))}return[...n].filter(i=>!Kn(e,i)).sort((i,s)=>i.localeCompare(s))}function Si(t,e=[]){let n=new Set;for(let r of e){let i=A.isAbsolute(r)?r:A.join(t,r);Re(i)&&n.add(A.resolve(i))}for(let r of gi(t))for(let i of Ct){let s=A.join(r,i);Re(s)&&n.add(A.resolve(s))}if(n.size===0){let r=Tt(t);r&&n.add(A.resolve(r))}return[...n].filter(r=>!Kn(t,r)).sort((r,i)=>r.localeCompare(i))}function gi(t){let e=A.join(t,"package.json");if(!Re(e))return[];let n;try{n=JSON.parse(sn(e,"project package manifest"))}catch{return[]}return(Array.isArray(n.workspaces)?n.workspaces:n.workspaces?.packages??[]).flatMap(i=>mn(t,i))}function Kn(t,e){let n=A.relative(t,e).replace(/\\/g,"/");return n.startsWith("..")||n.includes("/node_modules/")||n.startsWith("node_modules/")||n.includes("/dist/")||n.startsWith("dist/")}var Ri=32;function Qn(t,e){let n=k("typescript.provider.load",()=>Cn());if(!n)return We("ts-morph is not installed");let r=k("typescript.provider.tsconfig-discovery",()=>zn(t));if(r.length===0)return We("no tsconfig found");try{let i=k("typescript.provider.project-bundles",()=>Tn(n,r),()=>({tsconfigs:r.length}));return bi(t,n,i)}catch(i){return We(i instanceof Error?i.message:String(i),r[0],r)}}function bi(t,e,n,r={}){return k("typescript.provider.construct",()=>new Pt(t,e,n),()=>({tsconfigs:n.length,reusedProjects:r.reusedProjects===!0}))}var Pt=class{constructor(e,n,r){this.db=e;this.tsMorph=n;this.projects=r;this.workspacePackages=dn(e.config.projectRoot),this.sourceFiles=qn(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 n=this.sourceFiles.sourceFile(e);if(!n)return[];let r=Ii();return k("typescript.import-usage.file",()=>this.importUsageForSourceFile(e,n,r),()=>({file:e,...r}))})}referencesFor(e){return L(this.referencesCache,e.symbolId,()=>{let n=this.nodeForDefinition(e);return this.referencesForDefinitionNode(e,n)})}referencesForDefinitions(e,n={}){let r=new Map,i=_(),s=[];for(let f of e){let c=this.referencesCache.get(f.symbolId);c?r.set(f.symbolId,c):s.push(f)}if(s.length===0)return r;let o=s,a=n.exact?[]:s.filter(f=>!Vn(f));if(a.length>=Ri){let f=this.referencesForDefinitionsBySymbolScan(a);for(let c of a){let p=f.get(c.symbolId)??[];this.referencesCache.set(c.symbolId,p),r.set(c.symbolId,p)}if(o=s.filter(c=>Vn(c)),o.length===0)return r}let l=new Map;for(let f of o){let c=l.get(f.relativePath);c?c.push(f):l.set(f.relativePath,[f])}let u=[];for(let[f,c]of l){let p=$n();k("typescript.references-map.file",()=>{let d=this.definitionNodesForFile(f);for(let y of c){i&&(p.cacheMisses+=1);let R=d.get(y.symbolId)??null;i&&(R?p.nodeHits+=1:p.nodeMisses+=1);try{let b=this.referencesForDefinitionNode(y,R,i?p:void 0);this.referencesCache.set(y.symbolId,b),r.set(y.symbolId,b)}catch{p.preciseSearchFailures+=1,u.push(y)}}},()=>({relativePath:f,definitions:c.length,...Jn(p)}))}if(u.length>0){let f=this.referencesForDefinitionsBySymbolScan(u);for(let c of u){let p=f.get(c.symbolId)??[];this.referencesCache.set(c.symbolId,p),r.set(c.symbolId,p)}}return r}referenceFragmentsForFiles(e){let n=ee(this.db).filter(s=>ie(s.relativePath)),r=e.filter(s=>this.sourceFiles.sourceFile(s)!==null),i=this.referencesForDefinitionsBySymbolScan(n,r);return Pn(n,i,r)}referencesForDefinitionsBySymbolScan(e,n){let r=_(),i=$n(),s=new Map,o=new Set(e.map(l=>l.symbolId)),a=new Map(e.map(l=>[l.symbolId,l]));for(let l of e)s.set(l.symbolId,[]);return k("typescript.references-map.inverted-scan",()=>{let l=r?D.now():0,u=n?this.packageImportReferencesForFiles(n):this.packageImportReferences();for(let b of e){let S=u.get(b.symbolId)??[];if(S.length>0){let M=s.get(b.symbolId)??[];M.push(...S),s.set(b.symbolId,M)}r&&(i.packageReferenceCount+=S.length)}r&&(i.packageRefsMs+=D.now()-l);let f=new Map,c=new Map,p=this.hierarchyTargetsForDefinitions(e),d=new Set(e.map(b=>b.leaf).filter(Boolean)),y=r?D.now():0;for(let b of n??this.sourceFiles.indexedTypeScriptLikeDocuments()){if(this.db.isIgnored(b))continue;let S=this.sourceFiles.sourceFile(b);S&&(r&&(i.scanFiles+=1),this.addReferencesFromSourceFileScan(S,b,o,a,p,d,f,c,s,r?i:void 0))}r&&(i.scanMs+=D.now()-y);let R=r?D.now():0;this.addHierarchyMemberReferences(e,s,r?i:void 0),r&&(i.hierarchyMs+=D.now()-R);for(let[b,S]of s){let M=se(S);s.set(b,M),r&&(i.referenceCount+=M.length)}},()=>({definitions:e.length,...Jn(i)})),s}addReferencesFromSourceFileScan(e,n,r,i,s,o,a,l,u,f){let c=this.compilerCheckerForSourceFile(e),p=e.compilerNode,d=Di(e),y=R=>{if(this.tsMorph.ts.isIdentifier(R)){if(f&&(f.identifiers+=1),!o.has(R.text)&&!d.has(R.text)){this.tsMorph.ts.forEachChild(R,y);return}let b=this.compilerReferenceSymbol(c,R,f);if(b){let S;a.has(b)?S=a.get(b)??null:(S=this.referenceDefinitionFromCompilerSymbol(b),a.set(b,S)),f&&(S?f.targetHits+=1:f.targetMisses+=1);let M=L(l,b,()=>this.compilerSymbolKeys(b)),w=null,h=null,C=S&&r.has(S.symbolId)?i.get(S.symbolId):void 0;if(C&&(w=Ke(p,R),!Hn(C,n,w))){let x=p.getLineAndCharacterOfPosition(R.getStart(p));h={file:n,line:x.line,column:x.character};let v=u.get(C.symbolId)??[];v.push(h),u.set(C.symbolId,v),f&&(f.requestedHits+=1)}for(let x of M)for(let v of s.get(x)?.values()??[]){if(w??=Ke(p,R),Hn(v,n,w))continue;if(!h){let m=p.getLineAndCharacterOfPosition(R.getStart(p));h={file:n,line:m.line,column:m.character}}let g=u.get(v.symbolId)??[];g.push(h),u.set(v.symbolId,g),f&&(f.requestedHits+=1)}}}this.tsMorph.ts.forEachChild(R,y)};y(p)}hierarchyTargetsMemo=null;hierarchyTargetsForDefinitions(e){let n=ki(e);if(this.hierarchyTargetsMemo?.key===n)return this.hierarchyTargetsMemo.targets;let r=Z(this.db),i=`definitions:${n}`,s=!1,o=k("typescript.references-map.hierarchy-targets",()=>{if(r){let l=Yn.read(this.db,i,r);if(l&&l.projectRoot===this.db.config.projectRoot)return s=!0,Pi(l,e)}let a=this.computeHierarchyTargets(e);return r&&Yn.write(this.db,i,r,{version:Xn,projectRoot:this.db.config.projectRoot,entries:[...a].map(([l,u])=>[l,[...u.values()].map(f=>f.symbol)])}),a},()=>({definitions:e.length,hit:s}));return this.hierarchyTargetsMemo={key:n,targets:o},o}computeHierarchyTargets(e){let n=new Map;for(let r of e){let i=this.nodeForDefinition(r),s=i?.compilerNode;if(!s||!this.isHierarchyMethod(s))continue;let o=s.parent;if(!this.isHierarchyContainer(o))continue;let a=this.compilerCheckerForSourceFile(i.getSourceFile()),l=a.getSymbolAtLocation(s.name);if(l)for(let u of this.hierarchyMemberSymbols(a,o,l))for(let f of this.compilerSymbolKeys(u)){let c=n.get(f)??new Map;c.set(r.symbolId,r),n.set(f,c)}}return n}hierarchyMemberSymbols(e,n,r){let i=new Set,s=new Set,o=(a,l,u)=>{if(!s.has(a)){s.add(a),i.add(l);for(let f of u){let c=f.getProperty(r.name);c&&o(f,c,this.hierarchyAncestorTypesForType(e,f))}}};return o(e.getTypeAtLocation(n),r,this.hierarchyAncestorTypes(e,n)),i}addHierarchyMemberReferences(e,n,r){let i=new Map;for(let s of e){let o=this.nodeForDefinition(s),a=o?.compilerNode;if(!a||!this.isHierarchyMethod(a))continue;let l=a.parent;if(!this.isHierarchyContainer(l))continue;let u=this.compilerCheckerForSourceFile(o.getSourceFile()),f=u.getSymbolAtLocation(a.name);if(!f)continue;let c=a.getSourceFile(),p=c.getLineAndCharacterOfPosition(a.name.getStart(c)),d={definition:s,location:{file:s.relativePath,line:p.line,column:p.character}},y=n.get(s.symbolId)??[];for(let b of this.hierarchyMemberSymbols(u,l,f))if(b!==f)for(let S of this.compilerSymbolLocations(b))y.push(S),r&&(r.hierarchyReferences+=1);n.set(s.symbolId,y);let R=this.hierarchyRootMemberSymbols(u,l,f);for(let b of R){let S=i.get(b)??new Map;S.set(s.symbolId,d),i.set(b,S)}r&&(r.hierarchyDefinitions+=1)}for(let s of i.values())if(!(s.size<2)){r&&(r.hierarchyFamilies+=1);for(let{definition:o}of s.values()){let a=n.get(o.symbolId)??[];for(let l of s.values())l.definition.symbolId!==o.symbolId&&(a.push(l.location),r&&(r.hierarchyReferences+=1));n.set(o.symbolId,a)}}}hierarchyRootMemberSymbols(e,n,r){let i=new Set,s=new Set,o=(a,l,u)=>{if(s.has(a))return;s.add(a);let f=!1;for(let c of u){let p=c.getProperty(r.name);p&&(f=!0,o(c,p,this.hierarchyAncestorTypesForType(e,c)))}if(!f)for(let c of this.compilerSymbolKeys(l))i.add(c)};return o(e.getTypeAtLocation(n),r,this.hierarchyAncestorTypes(e,n)),i}compilerSymbolKeys(e){return(e.declarations??[]).map(n=>{let r=n.getSourceFile();return`${r.fileName}\0${n.getStart(r)}\0${e.name}`})}compilerSymbolLocations(e){let n=[];for(let r of e.declarations??[]){let i=r.getSourceFile(),s=oe(this.db.config.projectRoot,i.fileName);if(!s)continue;let o=r.name,a=i.getLineAndCharacterOfPosition((o??r).getStart(i));n.push({file:s,line:a.line,column:a.character})}return n}baseTypes(e,n){try{return e.getBaseTypes(n)??[]}catch{return[]}}hierarchyAncestorTypes(e,n){let r=new Set(this.hierarchyAncestorTypesForType(e,e.getTypeAtLocation(n)));for(let i of n.heritageClauses??[])for(let s of i.types)r.add(e.getTypeAtLocation(s));return[...r]}hierarchyAncestorTypesForType(e,n){let r=new Set(this.baseTypes(e,n));for(let i of n.getSymbol()?.declarations??[])if(this.isHierarchyContainer(i))for(let s of i.heritageClauses??[])for(let o of s.types)r.add(e.getTypeAtLocation(o));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,n,r){r&&(r.symbolLookups+=1);let i=e.getSymbolAtLocation(n);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 n=new Map,r=new Map;for(let i of e){let s=r.get(i.relativePath);s?s.push(i):r.set(i.relativePath,[i])}for(let[i,s]of r){let o=this.fileCalleesCache.get(i),a=new Set(s.map(u=>u.symbolId)),l=o??this.calleeMapForFile(i,a);for(let u of s){let f=l.get(u.symbolId)??[];this.calleesCache.set(u.symbolId,f),n.set(u.symbolId,f)}}return n}referencesForDefinitionNode(e,n,r){let i=r?D.now():0,s=this.packageImportReferencesForDefinition(e);if(r&&(r.packageRefsMs+=D.now()-i,r.packageReferenceCount+=s.length),!n)return s;let o=r?D.now():0,a=Nn(n,e,s,this.db.config.projectRoot);return r&&(r.semanticRefsMs+=D.now()-o,r.referenceCount+=a.length),a}signatureFor(e){return L(this.signatureCache,e.symbolId,()=>{let n=this.nodeForDefinition(e);if(!n||!this.tsMorph.Node.isFunctionDeclaration(n)&&!this.tsMorph.Node.isMethodDeclaration(n)&&!this.tsMorph.Node.isArrowFunction(n)&&!this.tsMorph.Node.isFunctionExpression(n)&&!this.tsMorph.Node.isConstructorDeclaration(n))return null;let r=n.getType().getCallSignatures()[0];if(!r)return null;let i=r.getParameters().map(o=>{let a=o.getDeclarations()[0],l=a?o.getTypeAtLocation(a).getText(a):o.getValueDeclaration()?.getType().getText()??"unknown";return Gn(l)}),s=r.getReturnType().getText(n);return`(${i.join(",")})=>${Gn(s)}`})}importUsageForSourceFile(e,n,r){let i=[],s=new Map;for(let o of n.getImportDeclarations()){r.declarations+=1;let a=pt(this.db,e,o.getModuleSpecifierValue()),l=o.getImportClause()?.isTypeOnly()??!1;for(let u of kt(o)){r.entries+=1;let f=l?null:u.identifier?.getSymbol()?.compilerSymbol??null;!l&&u.identifier&&(f?r.bindingSymbols+=1:r.missingBindingSymbols+=1);let c={sourcePath:a,entry:u,typeOnlyDeclaration:l,bindingSymbol:f,references:[]};if(i.push(c),l||!u.localName||!f)continue;let p=s.get(u.localName);p?p.push(c):s.set(u.localName,[c])}}return s.size>0&&n.forEachDescendant(o=>{if(o.getKindName()!=="Identifier")return;let a=s.get(o.getText());if(!a||Mi(o))return;r.scannedIdentifiers+=1;let l=o.getSymbol()?.compilerSymbol;if(r.symbolLookups+=1,!!l){for(let u of a)if(u.bindingSymbol===l){u.references.push({location:ze(o,this.db.config.projectRoot),node:o}),r.matchedReferences+=1;break}}}),i.map(o=>o.typeOnlyDeclaration?hi(e,o.sourcePath,o.entry):o.entry.identifier&&!o.bindingSymbol?(r.fallbackEntries+=1,this.valueImportUsageForEntry(e,o.sourcePath,o.entry)):this.valueImportUsageFromLocations(e,o.sourcePath,o.entry,o.references))}valueImportUsageForEntry(e,n,r){let i=r.identifier?r.identifier.findReferences():[],s=[];for(let o of i)for(let a of _n(o,e,r.identifier,this.db.config.projectRoot))s.push(a);return this.valueImportUsageFromLocations(e,n,r,s)}valueImportUsageFromLocations(e,n,r,i){let s=i.some(l=>!Rt(l.node)),o=i.some(l=>Rt(l.node)),a=r.isTypeOnly;return{importer:e,sourcePath:n,importedName:r.importedName,localName:r.localName,kind:r.kind,isTypeOnly:a,isUsed:a||i.length>0,isTypeUsed:a||o,isValueUsed:s,references:i.map(l=>l.location)}}packageImportReferencesForDefinition(e){return this.packageImportReferences().get(e.symbolId)??[]}packageImportReferencesForFiles(e){let n=new Map,r=new Set;for(let s of e){let o=this.sourceFiles.sourceFile(s);if(o)for(let a of o.getImportDeclarations()){let l=xt(this.workspacePackages,a.getModuleSpecifierValue());l&&r.add(l)}}if(r.size===0)return n;let i=this.packageExportsForNames(r);for(let s of e)this.addPackageImportReferencesForDocument(n,i,s);for(let[s,o]of n)n.set(s,se(o));return n}packageImportReferences(){if(this.packageImportReferenceIndex)return this.packageImportReferenceIndex;let e=new Map,n=this.packageExports();for(let r of this.sourceFiles.indexedTypeScriptLikeDocuments())this.addPackageImportReferencesForDocument(e,n,r);for(let[r,i]of e)e.set(r,se(i));return this.packageImportReferenceIndex=e,e}addPackageImportReferencesForDocument(e,n,r){if(this.db.isIgnored(r))return;let i=this.sourceFiles.sourceFileMatch(r);if(i)for(let s of i.sourceFile.getImportDeclarations())this.addPackageImportReferencesForDeclaration(e,n,r,s)}addPackageImportReferencesForDeclaration(e,n,r,i){let s=xt(this.workspacePackages,i.getModuleSpecifierValue());if(!s)return;let o=n.get(s);if(o)for(let a of kt(i)){if(a.kind!=="named"||!a.identifier)continue;let l=o.get(a.importedName);if(!l||l.size===0)continue;let u=Ln(a.identifier,r,this.db.config.projectRoot);u.length>0&&wi(e,l,u)}}packageExports(){return this.packageExportIndex?this.packageExportIndex:(this.packageExportIndex=this.packageExportsForNames(new Set(this.workspacePackages.map(e=>e.name))),this.packageExportIndex)}packageExportsForNames(e){let n=new Map;for(let r of this.workspacePackages){if(!e.has(r.name))continue;let i=new Map;for(let s of Wn(r))this.collectPackageExports(r,s,i,new Set);i.size>0&&n.set(r.name,i)}return n}collectPackageExports(e,n,r,i){if(i.has(n))return;i.add(n);let s=this.sourceFiles.sourceFile(n);if(s)for(let o of s.getExportDeclarations()){let a=o.getModuleSpecifierValue(),l=a?pt(this.db,n,a):n;if(!l||!l.startsWith(`${e.relativeDir}/src/`))continue;let u=o.getNamedExports();if(u.length===0){if(o.isNamespaceExport())continue;this.collectPackageExports(e,l,r,i);continue}for(let f of u){let c=f.getNameNode().getText(),p=f.getAliasNode()?.getText()??c,d=this.indexedDefinitionByLeaf(l,c);if(!d)continue;let y=r.get(p);y||(y=new Set,r.set(p,y)),y.add(d.symbolId)}}}indexedDefinitionByLeaf(e,n){return L(this.indexedDefinitionLeafCache,e,()=>Bn(this.db,e)).get(n)??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 n=this.sourceFiles.sourceFile(e);return n?On(this.tsMorph,this.db,n,e):new Map})}referenceDefinitionFromCompilerSymbol(e){return this.definitionFromCompilerSymbol(e,void 0,!0)}definitionFromCompilerSymbol(e,n,r=!1){let i=e.name,s=n?D.now():0,o=e.declarations??[];n&&(n.declarationsMs+=D.now()-s,n.declarationChecks+=o.length);for(let a of o){let l=n?D.now():0,u=a.getSourceFile(),f=oe(this.db.config.projectRoot,u.fileName),c=u.getLineAndCharacterOfPosition(a.getStart(u)).line;if(n&&(n.declarationLocationMs+=D.now()-l),!f||this.db.isIgnored(f))continue;let p=n?D.now():0,d=this.compilerDeclarationName(a),y=r?It(this.db,f,c,i)??(d&&d!==i?It(this.db,f,c,d):null):Un(this.db,f,c,i);if(n&&(n.indexedLookupMs+=D.now()-p),y)return{symbolId:y.symbolId,symbol:y.symbol,file:y.relativePath,line:y.startLine}}return null}compilerDeclarationName(e){let n=e.name;return n&&this.tsMorph.ts.isIdentifier(n)?n.text:null}calleeMapForFile(e,n){let r=_(),i=0,s=0,o=0,a=0,l=0,u=0,f=0,c=0,p=r?Ci():void 0;return k("typescript.callee-map.file",()=>{let d=r?D.now():0,y=this.sourceFiles.sourceFile(e);if(r&&(l=Math.round(D.now()-d)),!y)return new Map;let R=r?D.now():0,b=z(this.db,e).sort((g,m)=>g.startLine-m.startLine||m.endLine-g.endLine);if(r&&(u=Math.round(D.now()-R)),i=b.length,b.length===0)return new Map;let S=new Map,M=r?D.now():0,w=this.compilerCheckerForSourceFile(y),h=y.compilerNode;r&&(f=Math.round(D.now()-M));let C=new Map,x=g=>{if(this.tsMorph.ts.isCallExpression(g)||this.tsMorph.ts.isNewExpression(g)){r&&(s+=1);let m=this.semanticCalleeForCallNode(w,h,b,g,C,n,p);m&&(r&&(o+=1),vi(S,m.callerId,m.target))}this.tsMorph.ts.forEachChild(g,x)},v=r?D.now():0;x(h),r&&(c=Math.round(D.now()-v));for(let[g,m]of S)S.set(g,Ei(m));return a=S.size,S},()=>({relativePath:e,definitions:i,callNodes:s,resolvedCallees:o,outputRows:a,requestedDefinitions:n?.size??i,sourceFileLookupMs:l,definitionsLoadMs:u,checkerLookupMs:f,traversalMs:c,...p?Ti(p):{}}))}semanticCalleeForCallNode(e,n,r,i,s,o,a){let l=a?D.now():0,u=xi(r,Ke(n,i));if(a&&(a.callerLookupMs+=D.now()-l),!u)return null;if(o&&!o.has(u.symbolId))return a&&(a.skippedUnrequestedCallers+=1),null;let f=i.expression,c=this.compilerSymbolForExpression(e,f,a),p=null;if(c)if(a&&(a.targetSymbolHits+=1),s.has(c))a&&(a.compilerSymbolCacheHits+=1),p=s.get(c)??null;else{a&&(a.compilerSymbolCacheMisses+=1);let d=a?D.now():0;p=this.definitionFromCompilerSymbol(c,a),a&&(a.targetLookupMs+=D.now()-d),s.set(c,p)}else a&&(a.targetMisses+=1);return p?{callerId:u.symbolId,target:{symbol:p.symbol,file:p.file,line:p.line,callsiteLine:Ke(n,i)}}:null}compilerSymbolForExpression(e,n,r){let i=r?D.now():0,s=e.getSymbolAtLocation(n);if(r&&(r.expressionSymbolMs+=D.now()-i),s)return s;r&&(r.typeFallbacks+=1);let o=r?D.now():0,a=e.getTypeAtLocation(n).getSymbol();return r&&(r.typeSymbolMs+=D.now()-o),a}compilerCheckerForSourceFile(e){let n=e.getProject(),r=this.compilerCheckerCache.get(n);return r||(r=n.getTypeChecker().compilerObject,this.compilerCheckerCache.set(n,r)),r}};function kt(t){let e=[],n=t.getDefaultImport();n&&e.push({identifier:n,importedName:"default",localName:n.getText(),kind:"default",isTypeOnly:t.getImportClause()?.isTypeOnly()??!1});let r=t.getNamespaceImport();r&&e.push({identifier:r,importedName:"*",localName:r.getText(),kind:"namespace",isTypeOnly:t.getImportClause()?.isTypeOnly()??!1});for(let i of t.getNamedImports()){let s=i.getNameNode(),a=i.getAliasNode()??(s.getKindName()==="Identifier"?s:null);e.push({identifier:a,importedName:s.getText(),localName:a?.getText()??s.getText(),kind:"named",isTypeOnly:i.isTypeOnly()||(t.getImportClause()?.isTypeOnly()??!1)})}return e.length===0&&e.push({identifier:null,importedName:"*",localName:null,kind:"side-effect",isTypeOnly:!1}),e}function hi(t,e,n){return{importer:t,sourcePath:e,importedName:n.importedName,localName:n.localName,kind:n.kind,isTypeOnly:!0,isUsed:!0,isTypeUsed:!0,isValueUsed:!1,references:[]}}function Ii(){return{declarations:0,entries:0,bindingSymbols:0,missingBindingSymbols:0,scannedIdentifiers:0,symbolLookups:0,matchedReferences:0,fallbackEntries:0}}function Mi(t){for(let e=t;e;e=e.getParent())if(e.getKindName()==="ImportDeclaration")return!0;return!1}function vi(t,e,n){let r=t.get(e);r||(r=[],t.set(e,r)),r.push(n)}function Di(t){let e=new Set;for(let n of t.getImportDeclarations())for(let r of kt(n))r.localName&&e.add(r.localName);return e}function xi(t,e){let n=null;for(let r of t)e<r.startLine||e>r.endLine||(!n||r.startLine>=n.startLine)&&(n=r);return n}function Ke(t,e){return t.getLineAndCharacterOfPosition(e.getStart(t)).line}function Hn(t,e,n){return e===t.relativePath&&n>=t.startLine&&n<=t.endLine}function Vn(t){return t.symbol.includes("#")?Oe(t.symbol)==="type"&&t.relativePath.endsWith(".d.ts"):!1}function Ci(){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 Ti(t){return{...t,callerLookupMs:Math.round(t.callerLookupMs),expressionSymbolMs:Math.round(t.expressionSymbolMs),typeSymbolMs:Math.round(t.typeSymbolMs),targetLookupMs:Math.round(t.targetLookupMs),declarationsMs:Math.round(t.declarationsMs),declarationLocationMs:Math.round(t.declarationLocationMs),indexedLookupMs:Math.round(t.indexedLookupMs)}}function $n(){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}}var Xn=1,Yn=me({kind:"typescript-hierarchy-targets",invalidation:V("typescript-hierarchy-targets"),serialize:t=>JSON.stringify(t),deserialize:t=>{try{let e=JSON.parse(t);return e.version!==Xn||typeof e.projectRoot!="string"||!Array.isArray(e.entries)?null:e}catch{return null}}});function Pi(t,e){let n=new Map(e.map(i=>[i.symbol,i])),r=new Map;for(let[i,s]of t.entries){let o=new Map;for(let a of s){let l=n.get(a);l&&o.set(l.symbolId,l)}o.size>0&&r.set(i,o)}return r}function ki(t){let e=2166136261;for(let n of t)e^=n.symbolId,e=Math.imul(e,16777619)>>>0;return`${t.length}:${e.toString(16)}`}function Jn(t){return{...t,scanMs:Math.round(t.scanMs),packageRefsMs:Math.round(t.packageRefsMs),semanticRefsMs:Math.round(t.semanticRefsMs),hierarchyMs:Math.round(t.hierarchyMs)}}function wi(t,e,n){for(let r of e){let i=t.get(r)??[];i.push(...n),t.set(r,i)}}function Ei(t){let e=new Set,n=[];for(let r of t){let i=`${r.symbol}|${r.file}|${r.line}|${r.callsiteLine??""}`;e.has(i)||(e.add(i),n.push(r))}return n}function Gn(t){return t.replace(/\s+/g," ").replace(/\bimport\("[^"]+"\)\./g,"").trim()}import{join as Ai}from"path";var He=3;var Fi="typescript-semantic";function Zn(t){let e=Ai(t,Fi),n=Ue(e);return{...n,requestDir:n.legacyRequestDir}}var Li=12e4,Oi=5;function nr(t,e,n={}){let r=new wt(t,n),i=null,s=null,o=process.env.SCIP_QUERY_SKIP_WATCH_SERVICE==="1",a=()=>(i??=Qn(t,e),i),l=(c,p,d)=>{if(o)return d();try{return p(r.request(c))}catch{return o=!0,d()}},u=(c,p)=>l({kind:"references",definitions:[...c],...p?.exact?{exact:!0}:{}},d=>er(d),()=>a().referencesForDefinitions?.(c,p)??new Map(c.map(d=>[d.symbolId,a().referencesFor(d)]))),f=c=>l({kind:"callees",definitions:[...c]},p=>er(p),()=>a().calleesForDefinitions?.(c)??new Map(c.map(p=>[p.symbolId,a().calleesFor(p)])));return{language:"typescript",availability:()=>(s??=l({kind:"availability"},qi,()=>a().availability()),s),importUsage:c=>l({kind:"import-usage",file:c},p=>p,()=>a().importUsage(c)),referencesFor:c=>u([c]).get(c.symbolId)??[],referencesForDefinitions:u,referenceFragmentsForFiles:c=>l({kind:"reference-fragments",files:[...c]},p=>Bi(p),()=>a().referenceFragmentsForFiles?.(c)??new Map),calleesFor:c=>f([c]).get(c.symbolId)??[],calleesForDefinitions:f,signatureFor:c=>l({kind:"signature",definition:c},ji,()=>a().signatureFor(c)),dispose:()=>i?.dispose?.()}}var wt=class{constructor(e,n={}){this.db=e;this.runtime=n.runtime??ir,this.timeoutMs=n.timeoutMs??Wi(),this.mailboxLimits=n.mailboxLimits??{},this.cacheDir=tr(e.config.dbPath),this.projectRoot=lt(e.config.projectRoot)}db;runtime;timeoutMs;cacheDir;projectRoot;mailboxLimits;request(e){let n=mt(this.cacheDir),r=Zn(this.cacheDir),i=qe(n.statePath);if(!Et(i,this.projectRoot,this.runtime))throw new Error("Compatible TypeScript semantic service is not running.");let s=this.db.generation.identity;if(!s)throw new Error("Published TypeScript generation identity is unavailable.");let o=this.runtime.now(),a=o+this.timeoutMs,l=(this.runtime.monotonicNow??q)()+this.timeoutMs,u=yn(),f=ne("typescript-semantic-v3",{generation:s,profileEnvironment:u,request:e}),c=re(f),p=Be(r,{mailboxVersion:Y,operationKey:f,clientId:this.runtime.randomId(),enqueuedAtMs:o,deadlineAtMs:a,protocolVersion:He,id:c,generation:s,profileEnvironment:u,request:e},{nowMs:o,limits:this.mailboxLimits});for(;(this.runtime.monotonicNow??q)()<=l;){if(_i(p.responsePath))return Ui(B(p.responsePath,{maxBytes:this.mailboxLimits.maxItemBytes??64*1024*1024,inputKind:"TypeScript semantic mailbox response"}),c,s,f);let d=qe(n.statePath);if(!Et(d,this.projectRoot,this.runtime))throw new Error("TypeScript semantic service stopped while processing a request.");this.runtime.sleep(Oi)}throw new Error(`TypeScript semantic service timed out after ${this.timeoutMs}ms.`)}};function rr(t){if(process.env.SCIP_QUERY_SKIP_WATCH_SERVICE==="1")return!1;try{let e=qe(mt(tr(t.config.dbPath)).statePath);return Et(e,lt(t.config.projectRoot),ir)}catch{return!1}}function Et(t,e,n){let r=t?.processIdentity?n.readProcessIdentity?.(t.pid):null;return t!==null&&t.projectRoot===e&&t.typescriptSemantic?.protocolVersion===He&&n.isProcessAlive(t.pid)&&(!t.processIdentity||r!=null&&ke(t.processIdentity,r))}function Ui(t,e,n,r){let i=JSON.parse(t);if(i.protocolVersion!==He||i.id!==e||i.operationKey!==r||i.ok===!0&&i.generation!==n)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(t){if(!Array.isArray(t))throw new Error("TypeScript semantic service wrote an invalid numeric map.");return new Map(t)}function Bi(t){if(!Array.isArray(t))throw new Error("TypeScript semantic service wrote an invalid string map.");return new Map(t)}function qi(t){let e=wn(t);if(!e)throw new Error("TypeScript semantic service wrote invalid availability.");return e}function ji(t){if(t!==null&&typeof t!="string")throw new Error("TypeScript semantic service wrote an invalid signature.");return t}function Wi(){let t=Number(process.env.SCIP_TYPESCRIPT_SEMANTIC_TIMEOUT_MS);return Number.isInteger(t)&&t>0?t:Li}var ir={now:Date.now,monotonicNow:q,randomId:Ni,sleep(t){let e=new Int32Array(new SharedArrayBuffer(4));Atomics.wait(e,0,0,t)},isProcessAlive:Fe,readProcessIdentity:Ae};function sr(t){let e=new Map,n=Ki(t),r=new Map;return i=>{let s=zi(i),o=r.get(s);if(o!==void 0)return o;if(!n.has(i.file))return r.set(s,i.symbol),i.symbol;let a=e.get(i.file);a||(a=Hi(z(t,i.file)),e.set(i.file,a));let l=Vi(a,i);return r.set(s,l),l}}function zi(t){return`${t.file}\0${t.symbol}\0${t.line}`}function Ki(t){return new Set(t.all("SELECT relative_path FROM documents").map(e=>e.relative_path))}function Hi(t){let e=new Map,n=new Map;for(let r of t){let i=e.get(r.leaf);i?i.push(r):e.set(r.leaf,[r]);let s=n.get(r.startLine);s?s.push(r):n.set(r.startLine,[r])}return{definitions:t,byLeaf:e,byStartLine:n}}function Vi(t,e){if(t.definitions.length===0)return e.symbol;let n=Ji(e.symbol),r=$i(t.byLeaf,n),i=Yi(r,e.line);if(i)return i.symbol;let s=t.byStartLine.get(e.line)??[];return s.length===1?s[0].symbol:e.symbol}function $i(t,e){let n=[],r=new Set;for(let i of e)for(let s of t.get(i)??[])r.has(s.symbolId)||(r.add(s.symbolId),n.push(s));return n}function Yi(t,e){let n=null;for(let r of t)if(!(r.startLine>e||r.endLine<e)){if(r.startLine===e)return r;(!n||r.endLine-r.startLine<n.endLine-n.startLine)&&(n=r)}return n}function Ji(t){let e=new Set([t]),r=t.split(/::|\.|#/).filter(Boolean).at(-1);return r&&e.add(r),e}function or(t,e){let r=bn(t,e).map(i=>Qi(e,i));return{usage:r,positions:Xi(t,e,r)}}function ar(t,e){return{importUsage(n){let r=t.importUsageFacts(n);if(!e||r.positions.length===0)return r.usage;let i=e.importDefinitionsForFile(n,r.positions);return i.available?Gi(r.usage,i.sourcePaths):r.usage}}}function Gi(t,e){return t.map((n,r)=>{let i=e.get(String(r));return i?{...n,sourcePath:i}:n})}function Qi(t,e){let n=e.isTypeOnly===!0,r=e.kind==="side-effect"||n||e.used;return{importer:t,sourcePath:e.sourcePath,importedName:e.importedName,localName:e.localName,kind:e.kind,isTypeOnly:n,isUsed:r,isTypeUsed:n,isValueUsed:e.kind==="side-effect"||!n&&e.used,references:[]}}function Xi(t,e,n){let r=gn(t,e);if(!r)return[];let i=Zi(r.rootNode),s=new Map;for(let a of i){let l=s.get(Ft(a.importedName,a.localName));l?l.push(a.position):s.set(Ft(a.importedName,a.localName),[a.position])}let o=[];return n.forEach((a,l)=>{let u=s.get(Ft(a.importedName,a.localName??a.importedName))?.shift();u&&o.push({...u,id:String(l),file:e})}),o}function Zi(t){let e=[];for(let n of t.descendantsOfType("use_declaration")){let r=n.namedChildren.find(i=>i.type!=="visibility_modifier");r&&e.push(...Ve(r,""))}return e.filter(n=>n.importedName!=="*")}function Ve(t,e){switch(t.type){case"identifier":case"super":case"self":case"crate":return[{importedName:t.text,localName:t.text,position:At(t,t.text)}];case"scoped_identifier":{let n=t.text.split("::").pop()??t.text;return[{importedName:n,localName:n,position:At(t,n)}]}case"scoped_use_list":{let n=t.namedChild(0),r=t.namedChild(1);if(!n||!r)return[];let i=Rn(e,n.text);return r.namedChildren.flatMap(s=>Ve(s,i))}case"use_list":return t.namedChildren.flatMap(n=>Ve(n,e));case"use_as_clause":{let n=t.namedChild(0),r=t.namedChild(1);return!n||!r?[]:Ve(n,e).map(i=>({...i,localName:r.text}))}case"use_wildcard":{let n=t.namedChild(0),r="*";return[{importedName:r,localName:r,position:At(n??t,r)}]}default:return[]}}function At(t,e){let n=Math.max(0,t.text.lastIndexOf(e));return{id:"",file:"",line:t.startPosition.row,column:t.startPosition.column+n+es(e)}}function es(t){return Math.max(0,Math.min(t.length-1,1))}function Ft(t,e){return`${t}\0${e}`}import{spawnSync as Kt}from"child_process";import{existsSync as Ht}from"fs";import{fileURLToPath as no}from"url";function $e(t){let e=Dn(vn,t),n=e.runnable;return n?{available:!0,dependencyAvailable:n,resolvedBinary:e.resolvedBinary??void 0,note:"rust-analyzer semantic reference queries are enabled."}:{available:!1,dependencyAvailable:n,resolvedBinary:e.resolvedBinary??void 0,reason:"rust-analyzer is not runnable; Rust semantic checks will use SCIP/source evidence only."}}import{existsSync as Bs,mkdtempSync as Er,rmSync as Bt}from"fs";import{tmpdir as Ar}from"os";import{join as qt}from"path";import{fileURLToPath as et,pathToFileURL as qs}from"url";import{SHARE_ENV as js,Worker as Ws}from"worker_threads";function K(t,e,n=new Set){let r=new Map;for(let i of t)n.has(i.symbolId)||r.set(i.symbolId,e.get(i.symbolId)??[]);return r}function J(t,e,n){let r=te(process.env.SCIP_RUST_SEMANTIC_BATCH_TIMEOUT_MS)??0;if(r>0)return r;let i=Math.max(1,Math.ceil(t/Math.max(1,n)));return Math.max(12e4,3e4+i*e)}import{spawn as bs}from"child_process";import{createHash as hs,randomUUID as Is}from"crypto";import{existsSync as Mr,realpathSync as Ms,rmSync as vs}from"fs";import{tmpdir as Ds}from"os";import{resolve as ce}from"path";import{execFileSync as cs}from"child_process";import{existsSync as ts}from"fs";import{deserializeSCIP as ns,SymbolRole as rs}from"@c4312/scip";import{realpathSync as yc}from"fs";import{basename as gc,dirname as Rc,join as bc,relative as hc,sep as Ic}from"path";import{fileURLToPath as vc,pathToFileURL as Dc}from"url";function Ye(t){let e=new Map;for(let n of t)e.set(`${n.file}\0${n.line}\0${n.column}`,n);return[...e.values()].sort((n,r)=>{let i=n.file.localeCompare(r.file);return i!==0?i:n.line!==r.line?n.line-r.line:n.column-r.column})}var Nt=new WeakMap,is="SCIP_RUST_SCIP_OCCURRENCE_REFERENCE_MODE";function cr(t,e){let n=new Map,r=Je(),i=e.filter(o=>fr(o,r));if(i.length===0)return n;let s=pr(t);if(!s)return n;for(let o of i){let a=ur(s,o);a!==null&&n.set(o.symbolId,a)}return n}function lr(t,e){if(!fr(e,Je()))return null;let n=pr(t);return n?ur(n,e):null}function ur(t,e){return t.referencesBySymbol.get(e.symbol)??[]}function fr(t,e="safe"){if(!t.symbol.startsWith("rust-analyzer ")||!t.relativePath.endsWith(".rs")||Se(t.symbol)||/impl#\[[^\]]+\]\[Default\]default\(\)\.$/.test(t.symbol))return!1;if(e==="all")return!0;let n=Oe(t.symbol);if(n==="method")return!0;if(n!=="term")return!1;let r=hn(t.symbol);return"kind"in r?!1:!ss(r)}function ss(t){for(let e=0;e<t.descriptors.length-1;e+=1)if(t.descriptors[e]?.suffix==="type")return!0;return!1}function pr(t){if(Nt.has(t))return Nt.get(t)??null;let e=os(t);return Nt.set(t,e),e}function os(t){if(!t.generation.indexPath||!ts(t.generation.indexPath))return null;try{let e=ns(Ee(t.generation.indexPath,{inputKind:"SCIP occurrence-reference index",maxBytes:we})),n=new Map;for(let r of e.documents??[]){let i=r.relativePath;if(!(!i||t.isIgnored(i)))for(let s of r.occurrences??[]){if(!s.symbol||(s.symbolRoles&rs.Definition)!==0)continue;let o=as(i,s.range);if(!o)continue;let a=n.get(s.symbol)??[];a.push(o),n.set(s.symbol,a)}}for(let[r,i]of n)n.set(r,Ye(i));return{referencesBySymbol:n}}catch{return null}}function as(t,e){if(e.length<3)return null;let n=e[0],r=e[1];return!Number.isInteger(n)||!Number.isInteger(r)?null:{file:t,line:n,column:r}}function Je(){return process.env[is]==="all"?"all":"safe"}var dr=new Map;function _t(t){let n=$e(t).resolvedBinary??null;return{engine:"rust-analyzer",resolvedBinary:n,version:n?ls(t,n):"unavailable"}}function Lt(t){return{..._t(t),scipOccurrenceReferenceMode:Je()}}function ls(t,e){let n=`${t}\0${e}`,r=dr.get(n);if(r)return r;let i;try{i=cs(e,["--version"],{cwd:t,encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:2e3}).trim()}catch{i="unknown"}return dr.set(n,i),i}import{createHash as us}from"crypto";var fs=new Set(["Cargo.lock","Cargo.toml","rust-project.json","rust-toolchain","rust-toolchain.toml"]);function mr(t){let e=cn(t,{includePath:ps});return us("sha256").update(JSON.stringify(e)).digest("hex")}function ps(t){let e=t.replaceAll("\\","/"),n=e.split("/").at(-1)??e;return e.endsWith(".rs")||fs.has(n)?!0:e===".cargo/config"||e===".cargo/config.toml"||e.endsWith("/.cargo/config")||e.endsWith("/.cargo/config.toml")}import{createHash as ds}from"crypto";import{resolve as ms}from"path";var ae=3;function Ut(t){return ds("sha256").update(ge({kind:"scip-query-durable-rust-mailbox",protocolVersion:ae,sessionDir:ms(t)})).digest("hex")}function gr(t,e){return pe(t)?t.protocolVersion!==ae?Sr(t.protocolVersion===void 0?"helper wrote a prior uncorrelated response protocol":`helper wrote unsupported response protocol ${String(t.protocolVersion)}`):t.mailboxVersion!==Y||t.id!==e.requestId||t.operationKey!==e.operationKey||t.sessionIdentity!==e.sessionIdentity||t.deadlineAtMs!==e.deadlineAtMs?Sr("helper wrote an incompatible response identity"):typeof t.completedAtMs!="number"||!Number.isFinite(t.completedAtMs)||t.completedAtMs>e.deadlineAtMs||e.nowMs>e.deadlineAtMs?{ok:!1,code:"expired-request",error:"helper response arrived after the durable request deadline"}:t.ok===!1?typeof t.error!="string"||!Rs(t.errorCode)?Ot("helper wrote an invalid rejection response"):{ok:!1,code:t.errorCode,error:t.error}:t.ok!==!0||t.session!=="created"&&t.session!=="reused"&&t.session!=="invalidated"||!ys(t.response,e.requestKind)?Ot("helper wrote an invalid success response"):{ok:!0,session:t.session,response:t.response}:Ot("helper wrote an invalid response object")}function ys(t,e){return!pe(t)||typeof t.available!="boolean"||t.available===!1&&(typeof t.reason!="string"||t.reason.length===0)||t.available===!0&&t.reason!==void 0?!1:e==="import-definitions"?Array.isArray(t.sourcePaths)&&t.sourcePaths.every(n=>Array.isArray(n)&&n.length===2&&typeof n[0]=="string"&&(n[1]===null||typeof n[1]=="string")):yr(t.references,Ss)&&(t.incompleteReferenceSymbolIds===void 0||Array.isArray(t.incompleteReferenceSymbolIds)&&t.incompleteReferenceSymbolIds.every(n=>Number.isSafeInteger(n)))&&(t.callees===void 0||yr(t.callees,gs))&&(t.signatures===void 0||Array.isArray(t.signatures)&&t.signatures.every(n=>Array.isArray(n)&&n.length===2&&Number.isSafeInteger(n[0])&&(n[1]===null||typeof n[1]=="string")))}function yr(t,e){return Array.isArray(t)&&t.every(n=>Array.isArray(n)&&n.length===2&&Number.isSafeInteger(n[0])&&Array.isArray(n[1])&&n[1].every(e))}function Ss(t){return pe(t)&&typeof t.file=="string"&&N(t.line)&&N(t.column)}function gs(t){return pe(t)&&typeof t.symbol=="string"&&typeof t.file=="string"&&N(t.line)&&(t.callsiteLine===void 0||N(t.callsiteLine))}function Rs(t){return t==="unsupported-protocol"||t==="malformed-request"||t==="expired-request"||t==="handler-error"}function Ot(t){return{ok:!1,code:"malformed-response",error:t}}function Sr(t){return{ok:!1,code:"incompatible-response",error:t}}var xs=5e3,vr=10,Cs=3e4;function Rr(t,e,n,r=Pr){let i=r.engineIdentity(t),s={protocolVersion:ae,projectRoot:r.canonicalProjectRoot(t),projectFingerprint:r.projectFingerprint(t),engine:{engine:i.engine,resolvedBinary:i.resolvedBinary,version:i.version},workerFingerprint:r.fileFingerprint(e),environment:xr(r.environment())};return{key:kr(ge(s)),...s}}function Ge(t,e,n,r){if(t.protocolVersion!==ae||!n(t.pid))return!1;if(!t.processIdentity)return!0;let i=r?.(t.pid);return i!=null&&ke(t.processIdentity,i)}function Dr(t,e,n){let r;try{r=ct(e,{maxBytes:H,inputKind:"Rust semantic engine artifact"})}catch{r="missing"}let i=kr(ge({projectRoot:ce(t),serverPath:ce(e),serverFingerprint:r})).slice(0,20);return ce(n,`scip-query-rust-session-${i}`)}function br(t){let e=t===void 0?Number.NaN:Number(t);return Number.isInteger(e)&&e>=0?e:0}function xr(t){return Object.fromEntries(Object.entries(t).filter(([e])=>Tr(e)).sort(([e],[n])=>e.localeCompare(n)).map(([e,n])=>[e,n??null]))}function Cr(t,e){let n=e.runtime??As,r=e.identityRuntime??Pr,i=Dr(t,e.serverPath,e.tempRoot??Ds()),s=!1,o=(a,l)=>{if(s)throw new Error("Durable Rust semantic session was already disposed.");return Ps(i,e.serverPath,e.semanticWorkerPath,a,l,n,e.mailboxLimits)};return{requestSemantic(a,l){let u=Rr(t,e.semanticWorkerPath,a,r),{readinessDeadlineMs:f,...c}=a;return o({kind:"semantic",identityKey:u.key,workerEnvironment:Ir(),request:{...c,referenceRetryTimeoutMs:Ts(process.env.SCIP_RUST_SEMANTIC_REFERENCE_RETRY_TIMEOUT_MS,a.referenceRetryTimeoutMs),settleDelayMs:process.env.SCIP_RUST_SEMANTIC_SETTLE_MS===void 0?a.settleDelayMs:br(process.env.SCIP_RUST_SEMANTIC_SETTLE_MS)},timeoutMs:l},l)},requestImportDefinitions(a,l){let u=Rr(t,e.semanticWorkerPath,a,r),{readinessDeadlineMs:f,...c}=a;return o({kind:"import-definitions",identityKey:u.key,workerEnvironment:Ir(),request:{...c,settleDelayMs:process.env.SCIP_RUST_SEMANTIC_SETTLE_MS===void 0?a.settleDelayMs:br(process.env.SCIP_RUST_SEMANTIC_SETTLE_MS)},timeoutMs:l},l)},shutdown(){s=!0}}}function Ts(t,e){return e!==void 0?e:t===void 0?Cs:void 0}function Ps(t,e,n,r,i,s,o={}){let a=s.now(),l=a+i,u=(s.monotonicNow??q)(),f=u+i,c=ne("rust-semantic-v3",r),p=re(c),d=Ue(t),y=Ut(t),R=Be(d,{mailboxVersion:Y,protocolVersion:ae,id:p,operationKey:c,clientId:s.randomId(),enqueuedAtMs:a,deadlineAtMs:l,sessionIdentity:y,request:r},{nowMs:a,limits:o});for(hr(t,e,n,f,s);(s.monotonicNow??q)()<=f;){if(Mr(R.responsePath)){let S=ks(B(R.responsePath,{maxBytes:o.maxItemBytes??H,inputKind:"durable Rust semantic mailbox response"}),{requestId:p,operationKey:c,sessionIdentity:y,deadlineAtMs:R.authoritativeDeadlineAtMs,requestKind:r.kind,nowMs:s.now()});if(!S.ok)throw new Error(S.error);return _()&&_e({type:"span",name:"rust.semantic.durable-session.request",durationMs:(s.monotonicNow??q)()-u,ok:!0,session:S.session,kind:r.kind}),S.response}let b=Qe(t);(!b||!Ge(b,s.now(),s.isProcessAlive,s.readProcessIdentity))&&hr(t,e,n,f,s),s.sleep(vr)}throw new Error(`Durable Rust semantic session timed out after ${(i/1e3).toFixed(0)}s.`)}function hr(t,e,n,r,i){let s=Qe(t);if(s&&Ge(s,i.now(),i.isProcessAlive,i.readProcessIdentity))return;vs(ce(t,"server.json"),{force:!0}),i.spawnServer(e,t,n);let o=i.monotonicNow??q,a=Math.min(r,o()+xs);for(;o()<=a;){let l=Qe(t);if(l&&Ge(l,i.now(),i.isProcessAlive,i.readProcessIdentity))return;i.sleep(vr)}throw new Error("Durable Rust semantic session helper did not become ready within 5s.")}function Qe(t){try{let e=JSON.parse(B(ce(t,"server.json"),{maxBytes:rn,inputKind:"durable Rust session state"}));if(typeof e.protocolVersion!="number"||e.sessionIdentity!==void 0&&(typeof e.sessionIdentity!="string"||e.sessionIdentity!==Ut(t))||typeof e.pid!="number"||typeof e.heartbeatAtMs!="number"||e.busyUntilMs!==void 0&&typeof e.busyUntilMs!="number"||e.mailbox!==void 0&&!ws(e.mailbox))return null;let n=e.processIdentity===void 0?null:Pe(e.processIdentity);return e.processIdentity!==void 0&&(!n||n.pid!==e.pid)?null:{protocolVersion:e.protocolVersion,...e.sessionIdentity===void 0?{}:{sessionIdentity:e.sessionIdentity},pid:e.pid,...n?{processIdentity:n}:{},heartbeatAtMs:e.heartbeatAtMs,...e.busyUntilMs===void 0?{}:{busyUntilMs:e.busyUntilMs},...e.mailbox===void 0?{}:{mailbox:e.mailbox}}}catch{return null}}function ks(t,e){try{return gr(JSON.parse(t),e)}catch(n){return{ok:!1,code:"malformed-response",error:`helper wrote malformed JSON: ${n instanceof Error?n.message:String(n)}`}}}function ws(t){if(!t||typeof t!="object")return!1;let e=t;return N(e.pending)&&N(e.inflight)&&N(e.responses)&&N(e.deadLetters)&&N(e.invalid)&&N(e.totalItems)&&typeof e.totalBytes=="number"&&Number.isFinite(e.totalBytes)&&e.totalBytes>=0&&(e.oldestPendingAt===void 0||Number.isFinite(Date.parse(e.oldestPendingAt)))}function Ir(){return Object.fromEntries(Object.entries(process.env).filter(([t])=>Es(t)).sort(([t],[e])=>t.localeCompare(e)).map(([t,e])=>[t,e??null]))}function Tr(t){return t==="HOME"||t==="PATH"||t.startsWith("CARGO_")||t.startsWith("RA_")||t.startsWith("RUST")}function Es(t){return Tr(t)||t.startsWith("SCIP_RUST_")||t==="SCIP_QUERY_PROFILE"||t==="SCIP_QUERY_PROFILE_CACHE_STATE"||t==="SCIP_QUERY_PROFILE_COMMAND"||t==="SCIP_QUERY_PROFILE_OUT"||t==="SCIP_QUERY_PROFILE_RUN_ID"||t==="SCIP_QUERY_PROFILE_WORKLOAD_IDENTITY"||t==="SCIP_QUERY_PROFILE_WORKLOAD_IDENTITY_KIND"||t==="SCIP_QUERY_PROFILE_MIN_MS"}var Pr={canonicalProjectRoot(t){try{return Ms(t)}catch{return ce(t)}},projectFingerprint(t){return mr(t)},engineIdentity:_t,fileFingerprint(t){return ct(t,{maxBytes:H,inputKind:"Rust semantic engine artifact"})},environment(){return xr(process.env)}},As={now:Date.now,monotonicNow:q,randomId:Is,isProcessAlive:Fe,readProcessIdentity:Ae,spawnServer(t,e,n){if(!Mr(t))throw new Error(`Durable Rust semantic session helper was not found at ${t}. Run npm run build first.`);bs(process.execPath,[t,e,n],{detached:!0,stdio:"ignore"}).unref()},sleep(t){let e=new Int32Array(new SharedArrayBuffer(4));Atomics.wait(e,0,0,t)}};function kr(t){return hs("sha256").update(t).digest("hex")}import{randomUUID as ml}from"crypto";import{readdirSync as Fs,rmSync as Sl,writeFileSync as gl}from"fs";import{join as Ns}from"path";var _s="rust-analyzer-owner-",Ls=".json",Os=16*1024;async function wr(t,e){if(!t)return[];let n;try{n=Fs(t)}catch{return[]}let r=n.filter(o=>o.startsWith(_s)&&o.endsWith(Ls)).map(o=>Ns(t,o)),i=[],s=[];for(let o of r){let a=Us(o);a?s.push(a):i.push({reaped:!1,reason:"identity-unavailable",detail:`Rust analyzer ownership record ${o} could not be validated.`})}return i.push(...await Promise.all(s.map(o=>xn(o,e)))),i}function Us(t){try{let e=B(t,{maxBytes:Os,inputKind:"rust-analyzer process ownership record"}),n=JSON.parse(e),r=Pe(n.rootIdentity);return n.version!==1||!r||typeof n.ownsProcessGroup!="boolean"?null:{rootPid:r.pid,rootIdentity:r,ownsProcessGroup:n.ownsProcessGroup,knownMembers:new Map([[r.pid,r]])}}catch{return null}}var Fr=15e3,Nr=8,Lr=5e3,zs=64,Ks=96,Wt=class{constructor(e,n,r={}){this.projectRoot=e;this.status=n;this.opts=r;this.requester=r.requester??Ys(e,process.env.SCIP_RUST_SEMANTIC_DURABLE_SESSION)}projectRoot;status;opts;requester;referencesForDefinitions(e){let n=this.status(this.projectRoot);if(!n.available||!n.resolvedBinary)return{available:!1,resolvedBinary:n.resolvedBinary,reason:he(n),references:Ie(e)};try{let r=this.requestSession(n.resolvedBinary,e,{includeReferences:!0});return{...be(r),resolvedBinary:n.resolvedBinary,references:K(e,new Map(r.references),new Set(r.incompleteReferenceSymbolIds??[]))}}catch(r){return this.opts.fallbackReferenceResolver?.referencesForDefinitions(e)??{available:!1,resolvedBinary:n.resolvedBinary,reason:r instanceof Error?r.message:String(r),references:Ie(e)}}}calleesForDefinitions(e){let n=this.status(this.projectRoot);if(!n.available||!n.resolvedBinary)return{available:!1,resolvedBinary:n.resolvedBinary,reason:he(n),callees:Me(e)};try{let r=this.requestSession(n.resolvedBinary,e,{includeReferences:!1,includeCallees:!0});return{...be(r),resolvedBinary:n.resolvedBinary,callees:jt(e,new Map(r.callees??[]))}}catch(r){return this.opts.fallbackCalleeResolver?.calleesForDefinitions(e)??{available:!1,resolvedBinary:n.resolvedBinary,reason:r instanceof Error?r.message:String(r),callees:Me(e)}}}referencesAndCalleesForDefinitions(e,n){let r=this.status(this.projectRoot);if(!r.available||!r.resolvedBinary)return{available:!1,resolvedBinary:r.resolvedBinary,reason:he(r),references:Ie(e),callees:Me(n)};let i=[...e,...n];try{let s=this.requestSession(r.resolvedBinary,i,{includeReferences:e.length>0,includeCallees:n.length>0,referenceDefinitions:e,calleeDefinitions:n});return{...be(s),resolvedBinary:r.resolvedBinary,references:K(e,new Map(s.references),new Set(s.incompleteReferenceSymbolIds??[])),callees:jt(n,new Map(s.callees??[]))}}catch(s){return this.fallbackReferencesAndCallees(r,e,n,s)}}signaturesForDefinitions(e){let n=this.status(this.projectRoot);if(!n.available||!n.resolvedBinary)return{available:!1,resolvedBinary:n.resolvedBinary,reason:he(n),signatures:_r(e)};try{let r=this.requestSession(n.resolvedBinary,e,{includeReferences:!1,includeCallees:!1,includeSignatures:!0});return{...be(r),resolvedBinary:n.resolvedBinary,signatures:Zs(e,new Map(r.signatures??[]))}}catch(r){return this.opts.fallbackSignatureResolver?.signaturesForDefinitions(e)??{available:!1,resolvedBinary:n.resolvedBinary,reason:r instanceof Error?r.message:String(r),signatures:_r(e)}}}importDefinitionsForFile(e,n){let r=this.status(this.projectRoot);if(n.length===0)return r.available?{available:!0,resolvedBinary:r.resolvedBinary,sourcePaths:new Map}:{available:!1,reason:r.reason,resolvedBinary:r.resolvedBinary,sourcePaths:new Map};if(!r.available||!r.resolvedBinary)return{available:!1,resolvedBinary:r.resolvedBinary,reason:he(r),sourcePaths:new Map(n.map(i=>[i.id,null]))};try{let i=this.requestImportDefinitions(r.resolvedBinary,e,n);return{...be(i),resolvedBinary:r.resolvedBinary,sourcePaths:new Map(i.sourcePaths)}}catch(i){return{available:!1,resolvedBinary:r.resolvedBinary,reason:i instanceof Error?i.message:String(i),sourcePaths:new Map(n.map(s=>[s.id,null]))}}}dispose(){this.requester.shutdown()}requestSession(e,n,r){let i=Xe(process.env.SCIP_RUST_SEMANTIC_REQUEST_TIMEOUT_MS,Fr),s=Ze(process.env.SCIP_RUST_SEMANTIC_REFERENCE_RETRY_TIMEOUT_MS,0),o=Xe(process.env.SCIP_RUST_SEMANTIC_CONCURRENCY,Nr),a=Ze(process.env.SCIP_RUST_SEMANTIC_DIAGNOSTICS_TIMEOUT_MS,Math.min(i,1e4)),l=r.referenceDefinitions?[...r.referenceDefinitions]:void 0,u=r.calleeDefinitions?[...r.calleeDefinitions]:void 0,f=r.signatureDefinitions?[...r.signatureDefinitions]:void 0,c=ve(process.env.SCIP_RUST_SEMANTIC_SETTLE_MS,{definitionCount:n.length,...r}),p={projectRoot:this.projectRoot,rustAnalyzerBinary:e,definitions:[...n],...l?{referenceDefinitions:l}:{},...u?{calleeDefinitions:u}:{},...f?{signatureDefinitions:f}:{},requestTimeoutMs:i,...r.includeReferences!==!1&&s>0?{referenceRetryTimeoutMs:s}:{},diagnosticsTimeoutMs:a,settleDelayMs:c,concurrency:o,includeReferences:r.includeReferences,includeCallees:r.includeCallees,includeSignatures:r.includeSignatures},d=eo(p);return k("rust.semantic.session.request",()=>this.requester.requestSemantic(p,J(d,zt(i,p.referenceRetryTimeoutMs),o)),()=>({definitions:n.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,n,r,i){let s=n.length===0?{available:!0,resolvedBinary:e.resolvedBinary,references:Ie(n)}:this.opts.fallbackReferenceResolver?.referencesForDefinitions(n),o=r.length===0?{available:!0,resolvedBinary:e.resolvedBinary,callees:Me(r)}:this.opts.fallbackCalleeResolver?.calleesForDefinitions(r);if(s&&o){let a={resolvedBinary:s.resolvedBinary??o.resolvedBinary??e.resolvedBinary,references:K(n,s.references),callees:jt(r,o.callees)};return s.available&&o.available?{available:!0,...a}:{available:!1,reason:(s.available?void 0:s.reason)??(o.available?void 0:o.reason)??"Rust semantic fallback was unavailable.",...a}}return{available:!1,resolvedBinary:e.resolvedBinary,reason:i instanceof Error?i.message:String(i),references:Ie(n),callees:Me(r)}}requestImportDefinitions(e,n,r){let i=Xe(process.env.SCIP_RUST_SEMANTIC_REQUEST_TIMEOUT_MS,Fr),s=Xe(process.env.SCIP_RUST_SEMANTIC_CONCURRENCY,Nr),o=Ze(process.env.SCIP_RUST_SEMANTIC_DIAGNOSTICS_TIMEOUT_MS,Math.min(i,1e4)),a=Ze(process.env.SCIP_RUST_SEMANTIC_SETTLE_MS,Lr),l={projectRoot:this.projectRoot,rustAnalyzerBinary:e,file:n,positions:[...r],requestTimeoutMs:i,diagnosticsTimeoutMs:o,settleDelayMs:a,concurrency:s};return k("rust.semantic.import-definitions.session.request",()=>this.requester.requestImportDefinitions(l,J(r.length,i,s)),()=>({file:n,positions:r.length}))}};function be(t){return t.available?{available:!0}:{available:!1,reason:t.reason}}function he(t){return t.available?"rust-analyzer binary path is unavailable.":t.reason}function Or(t,e,n={}){return new Wt(t,e,n)}function ve(t,e){let n=Br(t);if(n!==null)return n;let r=e.includeReferences!==!1;return r&&e.includeCallees!==!0&&e.includeSignatures!==!0&&e.definitionCount<=zs||r&&e.includeCallees===!0&&e.includeSignatures!==!0&&e.definitionCount<=Ks?0:Lr}function Hs(t){let e=t?.trim().toLowerCase(),n=e==="0"||e==="false"||e==="off"||e==="worker",r=e==="1"||e==="true"||e==="on"||e==="durable",i=e===void 0||e==="";return{transport:n||!i&&!r?"worker":"durable",source:i?"default":"environment",fallback:"worker",valid:i||n||r,optOut:"SCIP_RUST_SEMANTIC_DURABLE_SESSION=0"}}function Vs(t){return Hs(t).transport}function $s(t,e){let n=null,r=!1,i=!1,s=!1,o=()=>n??=e(),a=()=>{i||(t.shutdown(),i=!0)},l=(f,c,p)=>{let d=Xs(f);r=!0;try{a()}catch{}_()&&_e({type:"span",name:"rust.semantic.durable-session.request",durationMs:p,ok:!1,kind:c,session:"worker-fallback",reason:d})},u=(f,c,p)=>{if(s)throw new Error("Rust semantic failover session was already disposed.");if(r)return p(o());let d=performance.now();try{return c(t)}catch(y){l(y,f,performance.now()-d)}return p(o())};return{requestSemantic(f,c){return u("semantic",p=>p.requestSemantic(f,c),p=>p.requestSemantic(f,c))},requestImportDefinitions(f,c){return u("import-definitions",p=>p.requestImportDefinitions(f,c),p=>p.requestImportDefinitions(f,c))},shutdown(){if(s)return;s=!0;let f=[];try{a()}catch(c){f.push(c)}try{n?.shutdown()}catch(c){f.push(c)}if(f.length>0)throw f[0]}}}function Ys(t,e,n={worker:()=>Js(),durable:()=>Cr(t,{serverPath:et(to()),semanticWorkerPath:et(Ur())})}){return Vs(e)==="durable"?$s(n.durable(),n.worker):n.worker()}function Js(t={}){let e=null,n=null,r=1,i=!1,s=null,o=null,a=c=>{c&&Bt(c,{recursive:!0,force:!0})},l=()=>{if(s)return;let c=e,p=n;e=null,n=null;let d=c?c.terminate():Promise.resolve(0);s=Promise.allSettled([d,wr(p,{gracefulMs:1e3,forceMs:1e3})]).then(([y,R])=>{let S=(R.status==="fulfilled"?R.value:[{reaped:!1,detail:String(R.reason)}]).filter(M=>!M.reaped);if(y.status==="rejected"||S.length>0){o=new Error(`Rust semantic worker cleanup did not complete; ownership evidence remains at ${p??"unknown"}.`);return}a(p)}).finally(()=>{s=null})},u=()=>{if(e)return e;if(s)throw new Error("The previous Rust semantic session worker is still terminating; retry the request.");if(o)throw o;let c=t.semanticWorkerPath?qs(t.semanticWorkerPath):Ur();if(!Bs(et(c)))throw new Error(`Rust semantic session worker was not found at ${et(c)}. Run npm run build before using built semantic Rust queries.`);return n=Er(qt(Ar(),"scip-query-rust-session-")),e=new Ws(c,t.shareEnvironment?{env:js}:void 0),e.unref(),e},f=()=>{let c=n??Er(qt(Ar(),"scip-query-rust-session-"));return n=c,qt(c,`${r++}.json`)};return{requestSemantic(c,p){if(i)throw new Error("Rust semantic session was already disposed.");let d=u(),y=f(),R=new SharedArrayBuffer(4),b=new Int32Array(R);if(d.postMessage({kind:"semantic",request:c,responsePath:y,sharedBuffer:R}),Atomics.wait(b,0,0,p)==="timed-out")throw l(),new Error(`Rust semantic session worker timed out after ${(p/1e3).toFixed(0)}s`);try{let M=Gs(B(y,{maxBytes:H,inputKind:"Rust semantic worker response"}));if(!M.ok)throw new Error(M.error);return M.response}finally{Bt(y,{force:!0})}},requestImportDefinitions(c,p){if(i)throw new Error("Rust semantic session was already disposed.");let d=u(),y=f(),R=new SharedArrayBuffer(4),b=new Int32Array(R);if(d.postMessage({kind:"import-definitions",request:c,responsePath:y,sharedBuffer:R}),Atomics.wait(b,0,0,p)==="timed-out")throw l(),new Error(`Rust semantic import-definition session worker timed out after ${(p/1e3).toFixed(0)}s`);try{let M=Qs(B(y,{maxBytes:H,inputKind:"Rust import-definition worker response"}));if(!M.ok)throw new Error(M.error);return M.response}finally{Bt(y,{force:!0})}},shutdown(){if(i)return;if(i=!0,!e){a(n),n=null;return}let c=f(),p=new SharedArrayBuffer(4),d=new Int32Array(p);e.postMessage({kind:"shutdown",responsePath:c,sharedBuffer:p}),Atomics.wait(d,0,0,5e3),l()}}}function Gs(t){let e=JSON.parse(t);if(!e||typeof e!="object")return{ok:!1,error:"Rust semantic session worker wrote a non-object response."};let n=e;return n.ok===!0&&"response"in n?{ok:!0,response:n.response}:{ok:!1,error:typeof e.error=="string"?e.error:"Rust semantic session worker failed."}}function Qs(t){let e=JSON.parse(t);if(!e||typeof e!="object")return{ok:!1,error:"Rust semantic session worker wrote a non-object response."};let n=e;return n.ok===!0&&"response"in n?{ok:!0,response:n.response}:{ok:!1,error:typeof e.error=="string"?e.error:"Rust semantic session worker failed."}}function Xs(t){let e=t instanceof Error?`${t.name} ${t.message}`.toLowerCase():String(t).toLowerCase();return e.includes("readiness")?"readiness":e.includes("timeout")||e.includes("timed out")?"timeout":e.includes("helper")?"helper":"request"}function Ie(t){return new Map(t.map(e=>[e.symbolId,[]]))}function Me(t){return new Map(t.map(e=>[e.symbolId,[]]))}function _r(t){return new Map(t.map(e=>[e.symbolId,null]))}function jt(t,e){return new Map(t.map(n=>[n.symbolId,e.get(n.symbolId)??[]]))}function Zs(t,e){return new Map(t.map(n=>[n.symbolId,e.get(n.symbolId)??null]))}function eo(t){let e=0;return t.includeReferences!==!1&&(e+=(t.referenceDefinitions??t.definitions).length),t.includeCallees===!0&&(e+=(t.calleeDefinitions??t.definitions).length),t.includeSignatures===!0&&(e+=(t.signatureDefinitions??t.definitions).length),Math.max(1,e)}function zt(t,e){return e&&e>0?Math.max(t,e):t}function Ur(){return new URL("./rust-semantic-session-worker.js",import.meta.url)}function to(){return new URL("./rust-semantic-session-server.js",import.meta.url)}function Xe(t,e){return te(t)??e}function Ze(t,e){return Br(t)??e}function Br(t){if(!t)return null;let e=Number(t);return Number.isInteger(e)&&e>=0?e:null}var Vt=15e3,$t=8;function zr(t,e={}){let n=e.status??$e,r=so(t,n),i=oo(t,n),s=ao(t,n),o=e.referenceResolver||e.calleeResolver||e.signatureResolver||!ro(e)?null:Or(t,n,{fallbackReferenceResolver:r,fallbackCalleeResolver:i,fallbackSignatureResolver:s}),a=e.referenceResolver??o??r,l=e.calleeResolver??o??i,u=e.signatureResolver??o??s,f=e.importUsageResolver??ar(e.sourceImportUsageResolver??io(),e.importDefinitionResolver??o),c=e.calleeSymbolResolver,p=e.sourceZeroCalleeOracle,d=e.scipOccurrenceCalleeOracle,y=new Map,R=new Map,b=null,S=null,M=()=>(b??=n(t),b),w=()=>{let g=M();return g.dependencyAvailable?S??g:g},h=g=>{if(g.length===0)return new Map;let m=xe(g);try{let I=a.referencesForDefinitions(m),T=M();return S=tt(T,I),I.available?new Map(I.references):K(m,I.references)}catch(I){let T=M();return S=De(T,I),G(m)}},C=g=>{if(g.length===0)return new Map;let m=xe(g),I=m.filter(qr);if(I.length===0)return Q(m);let T=new Map,W=Wr(I,d),F=[];for(let P of I)R.has(P.symbolId)?T.set(P.symbolId,R.get(P.symbolId)??[]):W.has(P.symbolId)?T.set(P.symbolId,W.get(P.symbolId)??[]):jr(P,p)?T.set(P.symbolId,[]):F.push(P);if(F.length===0)return le(m,T,void 0);try{let P=l.calleesForDefinitions(F),U=M();S=tt(U,P);let E=le(F,P.callees,c);for(let[fe,st]of E)T.set(fe,st);return le(m,T,void 0)}catch(P){let U=M();return S=De(U,P),Q(m)}},x=(g,m)=>{let I=xe(g),T=xe(m),W=T.filter(qr),F=new Map,P=Wr(W,d),U=[];for(let E of W)P.has(E.symbolId)?F.set(E.symbolId,P.get(E.symbolId)??[]):jr(E,p)?F.set(E.symbolId,[]):U.push(E);if(I.length===0&&U.length===0)return{references:G(I),callees:le(T,F,void 0)};try{let E=o?o.referencesAndCalleesForDefinitions(I,U):fo(a,l,{referenceDefinitions:I,calleeDefinitions:U}),fe=M();S=tt(fe,E);let st=E.available?new Map(E.references):K(I,E.references);for(let[ot,at]of E.callees)F.set(ot,at);let nn=le(T,F,c);for(let[ot,at]of nn)R.set(ot,at);return{references:st,callees:nn}}catch(E){let fe=M();return S=De(fe,E),{references:G(I),callees:Q(T)}}},v=g=>{if(g.length===0)return new Map;let m=xe(g);try{let I=u.signaturesForDefinitions(m),T=M();return S=tt(T,I),Kr(m,I.signatures)}catch(I){let T=M();return S=De(T,I),nt(m)}};return{language:"rust",availability:w,dispose:()=>{o?.dispose()},importUsage:g=>{let m=y.get(g);if(m)return m;try{let I=f.importUsage(g);return y.set(g,I),I}catch(I){let T=M();return S=De(T,I),[]}},referencesFor:g=>h([g]).get(g.symbolId)??[],referencesForDefinitions:h,referencesAndCalleesForDefinitions:x,calleesFor:g=>C([g]).get(g.symbolId)??[],calleesForDefinitions:C,signatureFor:g=>v([g]).get(g.symbolId)??null}}function tt(t,e){let n={dependencyAvailable:t.dependencyAvailable,resolvedBinary:e.resolvedBinary??t.resolvedBinary,...t.note?{note:t.note}:{}};return e.available?{available:!0,...n}:{available:!1,reason:e.reason,...n}}function De(t,e){return{available:!1,dependencyAvailable:t.dependencyAvailable,resolvedBinary:t.resolvedBinary,...t.note?{note:t.note}:{},reason:e instanceof Error?e.message:String(e)}}function ro(t){if(t.usePersistentSession!==void 0)return t.usePersistentSession;let e=process.env.SCIP_RUST_SEMANTIC_SESSION;return e!=="0"&&e!=="false"}function io(){return{importUsageFacts:()=>({usage:[],positions:[]})}}function xe(t){return t.map(e=>{let n=e;return{...e,leaf:typeof n.leaf=="string"?n.leaf:$(e.symbol),parentTypeName:n.parentTypeName??null,isFunctionLike:typeof n.isFunctionLike=="boolean"?n.isFunctionLike:In(e.symbol),isTypeLike:n.isTypeLike??!1,kind:n.kind??null,documentation:n.documentation??null,enclosingSymbol:n.enclosingSymbol??null}})}function qr(t){return t.isFunctionLike}function jr(t,e){if(!e)return!1;try{return e(t)}catch{return!1}}function Wr(t,e){if(!e||t.length===0)return new Map;try{return e(t)}catch{return new Map}}function so(t,e){return{referencesForDefinitions:n=>co(t,e,n)}}function oo(t,e){return{calleesForDefinitions:n=>lo(t,e,n)}}function ao(t,e){return{signaturesForDefinitions:n=>uo(t,e,n)}}function co(t,e,n){let r=e(t);if(!r.available||!r.resolvedBinary)return{available:!1,resolvedBinary:r.resolvedBinary,reason:Gt(r),references:G(n)};let i=Yt();if(!Ht(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:G(n)};let s=ue(process.env.SCIP_RUST_SEMANTIC_REQUEST_TIMEOUT_MS,Vt),o=rt(process.env.SCIP_RUST_SEMANTIC_REFERENCE_RETRY_TIMEOUT_MS,0),a=ue(process.env.SCIP_RUST_SEMANTIC_CONCURRENCY,$t),l=rt(process.env.SCIP_RUST_SEMANTIC_DIAGNOSTICS_TIMEOUT_MS,Math.min(s,1e4)),u=ve(process.env.SCIP_RUST_SEMANTIC_SETTLE_MS,{definitionCount:n.length,includeReferences:!0}),f={projectRoot:t,rustAnalyzerBinary:r.resolvedBinary,definitions:[...n],requestTimeoutMs:s,...o>0?{referenceRetryTimeoutMs:o}:{},diagnosticsTimeoutMs:l,settleDelayMs:u,concurrency:a},c=Kt(process.execPath,[i],{cwd:t,input:JSON.stringify(f),encoding:"utf8",maxBuffer:50*1024*1024,timeout:J(n.length,zt(s,f.referenceRetryTimeoutMs),a)}),p=Qt(c.stdout);if(p)return{...Jt(p),resolvedBinary:r.resolvedBinary,references:K(n,new Map(p.references),new Set(p.incompleteReferenceSymbolIds??[]))};let d=c.error instanceof Error?c.error.message:c.stderr.trim()||`Rust semantic worker exited with status ${c.status??"unknown"}.`;return{available:!1,resolvedBinary:r.resolvedBinary,reason:d,references:G(n)}}function lo(t,e,n){let r=e(t);if(!r.available||!r.resolvedBinary)return{available:!1,resolvedBinary:r.resolvedBinary,reason:Gt(r),callees:Q(n)};let i=Yt();if(!Ht(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:Q(n)};let s=ue(process.env.SCIP_RUST_SEMANTIC_REQUEST_TIMEOUT_MS,Vt),o=ue(process.env.SCIP_RUST_SEMANTIC_CONCURRENCY,$t),a=rt(process.env.SCIP_RUST_SEMANTIC_DIAGNOSTICS_TIMEOUT_MS,Math.min(s,1e4)),l=ve(process.env.SCIP_RUST_SEMANTIC_SETTLE_MS,{definitionCount:n.length,includeReferences:!1,includeCallees:!0}),u={projectRoot:t,rustAnalyzerBinary:r.resolvedBinary,definitions:[...n],requestTimeoutMs:s,diagnosticsTimeoutMs:a,settleDelayMs:l,concurrency:o,includeReferences:!1,includeCallees:!0},f=Kt(process.execPath,[i],{cwd:t,input:JSON.stringify(u),encoding:"utf8",maxBuffer:50*1024*1024,timeout:J(n.length,s,o)}),c=Qt(f.stdout);if(c)return{...Jt(c),resolvedBinary:r.resolvedBinary,callees:le(n,new Map(c.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:Q(n)}}function uo(t,e,n){let r=e(t);if(!r.available||!r.resolvedBinary)return{available:!1,resolvedBinary:r.resolvedBinary,reason:Gt(r),signatures:nt(n)};let i=Yt();if(!Ht(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:nt(n)};let s=ue(process.env.SCIP_RUST_SEMANTIC_REQUEST_TIMEOUT_MS,Vt),o=ue(process.env.SCIP_RUST_SEMANTIC_CONCURRENCY,$t),a=rt(process.env.SCIP_RUST_SEMANTIC_DIAGNOSTICS_TIMEOUT_MS,Math.min(s,1e4)),l=ve(process.env.SCIP_RUST_SEMANTIC_SETTLE_MS,{definitionCount:n.length,includeReferences:!1,includeCallees:!1,includeSignatures:!0}),u={projectRoot:t,rustAnalyzerBinary:r.resolvedBinary,definitions:[...n],requestTimeoutMs:s,diagnosticsTimeoutMs:a,settleDelayMs:l,concurrency:o,includeReferences:!1,includeCallees:!1,includeSignatures:!0},f=Kt(process.execPath,[i],{cwd:t,input:JSON.stringify(u),encoding:"utf8",maxBuffer:50*1024*1024,timeout:J(n.length,s,o)}),c=Qt(f.stdout);if(c)return{...Jt(c),resolvedBinary:r.resolvedBinary,signatures:Kr(n,new Map(c.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:nt(n)}}function fo(t,e,n){let r=n.referenceDefinitions.length>0?t.referencesForDefinitions(n.referenceDefinitions):{available:!0,references:G(n.referenceDefinitions)},i=n.calleeDefinitions.length>0?e.calleesForDefinitions(n.calleeDefinitions):{available:!0,callees:Q(n.calleeDefinitions)},s={resolvedBinary:r.resolvedBinary??i.resolvedBinary,references:r.references,callees:i.callees};return r.available&&i.available?{available:!0,...s}:{available:!1,reason:(r.available?void 0:r.reason)??(i.available?void 0:i.reason)??"Rust semantic resolution was unavailable.",...s}}function G(t){return new Map(t.map(e=>[e.symbolId,[]]))}function Q(t){return new Map(t.map(e=>[e.symbolId,[]]))}function nt(t){return new Map(t.map(e=>[e.symbolId,null]))}function le(t,e,n){let r=0,i=0;return k("rust.semantic.callees.complete-map",()=>{let s=new Map;for(let o of t){let a=e.get(o.symbolId)??[];a.length>0&&(r+=1),i+=a.length,s.set(o.symbolId,a.map(l=>({...l,symbol:n?n(l):l.symbol})))}return s},()=>({definitions:t.length,rows:r,callees:i,resolveSymbols:!!n}))}function Kr(t,e){return new Map(t.map(n=>[n.symbolId,e.get(n.symbolId)??null]))}function Yt(){return no(new URL("./rust-semantic-worker.js",import.meta.url))}function Jt(t){return t.available?{available:!0}:{available:!1,reason:t.reason}}function Gt(t){return t.available?"rust-analyzer binary path is unavailable.":t.reason}function Qt(t){try{let e=JSON.parse(t);if(!e||typeof e!="object")return null;let n=e;if(typeof n.available!="boolean"||!Array.isArray(n.references)||n.available===!1&&typeof n.reason!="string"||n.available===!0&&n.reason!==void 0)return null;let r={references:n.references,incompleteReferenceSymbolIds:Array.isArray(n.incompleteReferenceSymbolIds)?n.incompleteReferenceSymbolIds.filter(i=>typeof i=="number"):void 0,callees:Array.isArray(n.callees)?n.callees:void 0,signatures:Array.isArray(n.signatures)?n.signatures:void 0};return n.available===!0?{available:!0,...r}:{available:!1,reason:String(n.reason),...r}}catch{return null}}function ue(t,e){return te(t)??e}function rt(t,e){if(!t)return e;let n=Number(t);return Number.isInteger(n)&&n>=0?n:e}import{existsSync as po}from"fs";import{deserializeSCIP as mo,SymbolRole as yo}from"@c4312/scip";var Xt=new WeakMap;function Vr(t,e){let n=e.filter(So);if(n.length===0)return new Map;let r=!1,i=0,s=0;return k("rust.scip-occurrence.callees",()=>{let o=bo(t);if(r=!!o,!o)return new Map;let a=new Map;for(let l of n){let u=go(t,o,l);u!==null&&(a.set(l.symbolId,u),i+=1,s+=u.length)}return a},()=>({definitions:e.length,candidates:n.length,indexAvailable:r,resolvedDefinitions:i,resolvedCallees:s}))}function So(t){return!(!t.symbol.startsWith("rust-analyzer ")||!t.relativePath.endsWith(".rs")||!t.isFunctionLike||t.leaf==="main"||Se(t.symbol))}function go(t,e,n){let r=Le(t,n.relativePath);if(!r||r.language!=="rust")return null;let i=r.callables.find(u=>u.startLine!==n.startLine||u.endLine!==n.endLine?!1:u.name===n.leaf||n.leaf.endsWith(u.name)||u.name.endsWith(n.leaf));if(!i)return null;let s=r.callSites.filter(u=>u.line>=i.startLine&&u.line<=i.endLine);if(s.length===0)return null;let o=(e.occurrencesByFile.get(n.relativePath)??[]).filter(u=>u.line>=i.startLine&&u.line<=i.endLine&&u.callee.symbol!==n.symbol);if(o.some(u=>u.traitImplMember)||!Ro(s,o))return null;let a=[],l=new Set;for(let u of o){let f=`${u.callee.symbol}\0${u.callee.file}\0${u.callee.line}`;l.has(f)||(l.add(f),a.push(u.callee))}return a}function Ro(t,e){let n=Hr(t),r=Hr(e);if(n.size!==r.size)return!1;for(let[i,s]of n)if(r.get(i)!==s)return!1;return!0}function Hr(t){let e=new Map;for(let n of t){let r=n.calleeLeaf??n.leaf;if(!r)continue;let i=`${n.line}\0${r}`;e.set(i,(e.get(i)??0)+1)}return e}function bo(t){if(Xt.has(t))return Xt.get(t)??null;let e=ho(t);return Xt.set(t,e),e}function ho(t){if(!t.generation.indexPath||!po(t.generation.indexPath))return null;try{let e=ee(t).filter(s=>s.symbol.startsWith("rust-analyzer ")&&s.relativePath.endsWith(".rs")&&s.isFunctionLike),n=new Map(e.map(s=>[s.symbol,s])),r=mo(Ee(t.generation.indexPath,{inputKind:"SCIP occurrence-callee index",maxBytes:we})),i=new Map;for(let s of r.documents??[]){let o=s.relativePath;if(!o||!o.endsWith(".rs")||t.isIgnored(o))continue;let a=[];for(let l of s.occurrences??[]){if(!l.symbol||(l.symbolRoles&yo.Definition)!==0)continue;let u=n.get(l.symbol);if(!u)continue;let f=l.range?.[0];Number.isInteger(f)&&a.push({line:f,leaf:u.leaf,traitImplMember:Se(u.symbol),callee:{symbol:u.symbol,file:u.relativePath,line:u.startLine,callsiteLine:f}})}i.set(o,a)}return{occurrencesByFile:i}}catch{return null}}var it=class{sessions=new WeakMap;getOrCreate(e,n,r){let i=Io(e,n),s=this.sessions.get(e);s||(s=new Map,this.sessions.set(e,s));let o=s.get(i);if(o)return o.hits+=1,o.lastUsedAtMs=Date.now(),o.provider;let a=Date.now(),l=r();return s.set(i,{key:i,language:n,projectRoot:e.config.projectRoot,provider:l,createdAtMs:a,lastUsedAtMs:a,hits:1}),l}sessionsFor(e){return[...this.sessions.get(e)?.values()??[]]}clear(e){let n=this.sessions.get(e);if(n)for(let r of n.values())r.provider.dispose?.();this.sessions.delete(e)}};function Io(t,e){return`${t.config.projectRoot}:${e}-workspace`}var $r=new it;ln({name:"semantic-provider",groups:["semantic-provider"],clearAll:t=>$r.clear(t)});function X(t,e){let n=O(e)??"typescript";return $r.getOrCreate(t,n,()=>n==="rust"?zr(t.config.projectRoot,{sourceImportUsageResolver:{importUsageFacts:r=>or(t,r)},calleeSymbolResolver:sr(t),sourceZeroCalleeOracle:r=>Mo(t,r),scipOccurrenceCalleeOracle:r=>Vr(t,r)}):nr(t,e))}function O(t){return t?Sn(t)==="rust"?"rust":ie(t)?"typescript":null:"typescript"}function Mo(t,e){let n=Le(t,e.relativePath);if(!n||n.language!=="rust")return!1;let r=n.callables.find(i=>i.startLine===e.startLine&&i.endLine===e.endLine&&i.name===e.leaf)??n.callables.find(i=>i.startLine===e.startLine&&i.endLine===e.endLine);return r?!n.callSites.some(i=>i.line>=r.startLine&&i.line<=r.endLine):!1}var vo=/^[A-Za-z_][A-Za-z0-9_]*$/,Yr=/\bDefault::default\b/g,Do=/^\.\.\s*Default::default\b/;function Jr(t,e){let n=new Map,r=new Map;for(let i of e){let s=Zt(t,i,r);s!==null&&n.set(i.symbolId,s)}return n}function Zt(t,e,n=new Map){let r=Co(e.symbol);if(!r)return null;let i=Mn(t,[e.symbolId]);if(i.length===0)return null;let s=new RegExp(`(^|[^A-Za-z0-9_])${ye(r)}::default\\b`,"g"),o=new RegExp(`(^|[^A-Za-z0-9_])${ye(r)}\\s*$`),a=xo(t,e.symbolId),l=[];for(let u of i){let f=To(t,u.relative_path,n);if(f===null)return null;let c=f.split(/\r?\n/),p=0,d=[],y=0;for(let R=u.chunk_start;R<=u.chunk_end&&R<c.length;R+=1){let S=c[R]??"",M=new Set;s.lastIndex=0;let w;for(;w=s.exec(S);)l.push({file:u.relative_path,line:R,column:w.index+w[1].length+r.length+2}),y+=1;for(let h=0;h<S.length;h+=1){let C=Do.exec(S.slice(h));if(C){if(a&&d.includes(p)){let v=h+C[0].lastIndexOf("default");l.push({file:u.relative_path,line:R,column:v}),M.add(v),y+=1}h+=C[0].length-1;continue}let x=S[h];if(x==="{"){let v=o.test(S.slice(0,h));p+=1,v&&d.push(p);continue}if(x==="}")for(p=Math.max(0,p-1);d.length>0&&d[d.length-1]>p;)d.pop()}for(Yr.lastIndex=0;w=Yr.exec(S);){let h=w.index+9;if(!M.has(h))return null}}if(y===0)return null}return Ye(l)}function xo(t,e){return t.get("SELECT 1 AS present FROM mentions WHERE symbol_id = ? AND role = 1 LIMIT 1",e)?.present===1}function Co(t){let e=/impl#\[([^\]]+)\]\[Default\]default\(\)\./.exec(t)?.[1]??null;return!e||!vo.test(e)?null:e}function To(t,e,n){if(n.has(e))return n.get(e)??null;let r=t.get("SELECT text FROM documents WHERE relative_path = ?",e),i=typeof r?.text=="string"?r.text:Po(t,e);return n.set(e,i),i}function Po(t,e){try{return an(t.config.projectRoot,e,{inputKind:"indexed Rust source file"})}catch(n){if(!de(n))throw n;return null}}function Gr(t){let e=new Map;for(let n of t){let r=e.get(n.relativePath)??[];r.push(n),e.set(n.relativePath,r)}return e}var ko="typescript-import-usage-v1",wo="typescript-signatures-v1",en=ut("semantic-prefetched-callees",{clearGroups:["whole-project","source-file","semantic-provider"]}),Qr=me({kind:"semantic-import-usage",invalidation:V("semantic-import-usage"),serialize:t=>JSON.stringify(t),deserialize:si}),Xr=me({kind:"semantic-signatures",invalidation:V("semantic-signatures"),serialize:t=>JSON.stringify(t),deserialize:zo}),Zr=dt({kind:"typescript-import-usage",invalidation:V("typescript-import-usage"),serialize:t=>JSON.stringify(t),deserialize:si}),ei=dt({kind:"typescript-signatures",invalidation:V("typescript-signatures"),serialize:t=>JSON.stringify(t),deserialize:Ko}),Eo=256;function Eu(t,e={}){let n=e.coldFragmentLimit??Eo,r=kn(t);return r===null||r.missing<=n?{ready:!0}:(e.serviceAvailable??rr)(t)?{ready:!0}:{ready:!1,reason:`TypeScript reference fragments are cold for ${r.missing} of ${r.files} files and no watch service is running; run \`scip-query health --full\` once or start the service with \`scip-query watch --daemon\`, then re-run this command.`}}var Ao=ut("typescript-reference-map",{clearGroups:["whole-project"]});function Fo(t){return Ao.get(t,()=>{let e=Z(t);if(!e)return null;let n=ee(t).filter(i=>O(i.relativePath)==="typescript"),r=gt(t,n,i=>X(t,i));return r?{projectFingerprint:e,references:r.references,files:r.files,cacheHits:r.cacheHits,cacheMisses:r.cacheMisses,computedFiles:r.computedFiles}:null})}function Te(t){let e=new Map,n=new Set;return{capability:(r,i)=>oi(t,r,i),importUsage:r=>_o(t,r),references:r=>ni(t,r),materializeReferences:(r,i)=>ri(t,r,e,n,i),callerMap:r=>Lo(t,r,e,n),calleeMap:r=>qo(t,r),signature:r=>jo(t,r)}}function No(t,e){if(e.size===0)return;let n=en.get(t,()=>new Map);for(let[r,i]of e)n.set(r,[...i])}function Au(t,e){if(!en.has(t))return{hits:[],misses:[...e]};let n=en.get(t,()=>new Map),r=[],i=[];for(let s of e)n.has(s.symbolId)?r.push({definition:s,callees:n.get(s.symbolId)??[]}):i.push(s);return{hits:r,misses:i}}function Fu(t,e){return Te(t).importUsage(e)}function _o(t,e){if(O(e)==="typescript"){let s="fallback",o=0,a=0,l=0,u=0;return k("typescript.import-usage.materialize",()=>{let f=yt(t,e,ko);if(f?.key){o=1;let p=Zr.read(t,e,f.key);if(p)return s="hit",a=1,p;l=1;let d=j(t,e);if(!d)return s="unavailable",[];let y=d.importUsage(e);return Zr.write(t,e,f.key,y),s="computed",y}u=1;let c=j(t,e);return c?(s="direct-fallback",c.importUsage(e)):(s="unavailable",[])},()=>({state:s,eligible:o,cacheHits:a,cacheMisses:l,fallbacks:u}))}let n=ii(t,"semantic-import-usage",e);if(n){let s=Qr.read(t,e,n);if(s)return s}let r=j(t,e);if(!r)return[];let i=r.importUsage(e);return n&&Qr.write(t,e,n,i),i}function Nu(t,e){return Te(t).references(e)}function ni(t,e){let n=Zt(t,e);if(n)return n;let r=lr(t,e);if(r)return r;let i=j(t,e.relativePath);return i?i.referencesFor(e):[]}function _u(t,e){return Te(t).callerMap(e)}function Lu(t,e){let n=new Map,r=[];for(let i of e){if(O(i.relativePath)==="typescript"){r.push(i);continue}tn(t,n,i,ni(t,i))}if(r.length>0){let s=gt(t,r,o=>X(t,o))?.references;if(!s){let o=j(t,r[0].relativePath);s=o?o.referencesForDefinitions?o.referencesForDefinitions(r,{exact:!0}):new Map(r.map(a=>[a.symbolId,o.referencesFor(a)])):new Map,o&&_()&&St(t,r,s,a=>X(t,a))}for(let o of r)tn(t,n,o,s.get(o.symbolId)??[])}return n}function Lo(t,e,n=new Map,r=new Set){let i=new Map,s=ri(t,e,n,r),o=0;return k("semantic.callers.from-references",()=>{for(let a of e)o+=tn(t,i,a,n.get(a.symbolId)??[])},()=>({definitions:e.length,materialized:s.definitions,inMemoryHits:s.inMemoryHits,incompleteInMemoryHits:s.incompleteInMemoryHits,resultRows:i.size,callerFiles:o})),i}function ri(t,e,n,r,i={}){let s=Z(t),o=[],a=[],l=[],u=0,f=0,c=0,p=0,d=0,y=0,R=0,b=0,S=0,M=0,w=0,h=0,C=[],x=new Map,v=e.filter(m=>O(m.relativePath)==="typescript"&&!n.has(m.symbolId)&&!r.has(m.symbolId)),g=v.length>0?Fo(t):null;if(g){S=v.length,M=g.cacheHits,w=g.cacheMisses,h=g.computedFiles;for(let m of v)n.set(m.symbolId,g.references.get(m.symbolId)??[])}if(k("semantic.references.cache-scan",()=>{for(let[m,I]of Gr(e)){let T=[];for(let P of I)n.has(P.symbolId)?f+=1:r.has(P.symbolId)?b+=1:T.push(P);if(T.length===0){R+=1;continue}let W=Oo(t,s,m);if(!W){for(let P of T)O(P.relativePath)||(u+=1),l.push(P);continue}y+=1;let F=fn(t,m,W);for(let P of T){let U=F.get(P.symbol)??null;if(U!==null){let E=Bo(U);if(E){c+=1,n.set(P.symbolId,E);continue}p+=1}a.push({definition:P,cacheFingerprint:W})}}},()=>({definitions:e.length,skippedUnsupportedLanguage:u,cacheHits:c,parseFailures:p,misses:a.length,unkeyed:l.length,inMemoryHits:f,incompleteInMemoryHits:b,fullyInMemoryFiles:R,cacheReadFiles:y})),a.length>0||l.length>0){C=[...l,...a.map(m=>m.definition)],x=k("semantic.references.compute-misses",()=>{let m=Uo(t,C,i);return d=m.size,m},()=>({definitions:C.length,misses:a.length,unkeyed:l.length,rows:d}));for(let m of C)x.has(m.symbolId)?(n.set(m.symbolId,x.get(m.symbolId)??[]),r.delete(m.symbolId)):r.add(m.symbolId);for(let{definition:m,cacheFingerprint:I}of a)x.has(m.symbolId)&&oi(t,"semantic-references",m.relativePath).available&&o.push({relativePath:m.relativePath,symbol:m.symbol,projectFingerprint:I,payload:JSON.stringify(x.get(m.symbolId)??[])})}return o.length>0&&k("semantic.references.cache-write",()=>pn(t,o),()=>({entries:o.length})),x.size>0&&St(t,C,x,m=>X(t,m)),{definitions:e.length,inMemoryHits:f,incompleteInMemoryHits:b,cacheHits:c,misses:a.length,unkeyed:l.length,skippedUnsupportedLanguage:u,parseFailures:p,computed:d,incomplete:r.size,cacheWrites:o.length,fragmentDefinitions:S,fragmentCacheHits:M,fragmentCacheMisses:w,fragmentComputedFiles:h}}function Oo(t,e,n){if(!e)return null;let r=O(n);return r==="typescript"?e:r==="rust"?ft(JSON.stringify({kind:"semantic-references",language:r,engine:Lt(t.config.projectRoot),projectFingerprint:e})):null}function Uo(t,e,n={}){let r=_(),i=new Map,s=0,o=0,a=0,l=0,u=0,f=0,c=0,p=0,d=0;return k("semantic.references.provider-loop",()=>{let y=Jr(t,e),R=cr(t,e),b=new Map,S=n.prefetchCallees?new Map:null,M=[];for(let h of e){let C,x=()=>(C??=j(t,h.relativePath),C);if(S){let I=x();if(I?.referencesAndCalleesForDefinitions){let T=S.get(I);T?T.push(h):S.set(I,[h]),d+=1}}let v=y.get(h.symbolId);if(v){a+=1,l+=v.length,Ce(i,h.symbolId,v,r,I=>{c+=1,p+=I});continue}let g=R.get(h.symbolId);if(g){u+=1,f+=g.length,Ce(i,h.symbolId,g,r,I=>{c+=1,p+=I});continue}let m=x();if(!m){r&&(o+=1);continue}if(r&&(s+=1),m.referencesForDefinitions){let I=b.get(m);I?I.push(h):b.set(m,[h])}else M.push({provider:m,definition:h})}let w=new Set;if(S)for(let[h,C]of S){if(!h.referencesAndCalleesForDefinitions)continue;let x=b.get(h)??[],v=h.referencesAndCalleesForDefinitions(x,C);w.add(h),No(t,v.callees);for(let g of x){if(!v.references.has(g.symbolId))continue;let m=v.references.get(g.symbolId)??[];Ce(i,g.symbolId,m,r,I=>{c+=1,p+=I})}}for(let[h,C]of b){if(w.has(h))continue;let x=h.referencesForDefinitions(C);for(let v of C){if(!x.has(v.symbolId))continue;let g=x.get(v.symbolId)??[];Ce(i,v.symbolId,g,r,m=>{c+=1,p+=m})}}for(let{provider:h,definition:C}of M){let x=h.referencesFor(C);Ce(i,C.symbolId,x,r,v=>{c+=1,p+=v})}return i},()=>({definitions:e.length,providerHits:s,providerMisses:o,rustDefaultFastPathRows:a,rustDefaultFastPathReferences:l,rustScipOccurrenceFastPathRows:u,rustScipOccurrenceFastPathReferences:f,prefetchCalleeDefinitions:d,definitionsWithReferences:c,referenceCount:p,rows:i.size}))}function Ce(t,e,n,r,i){t.set(e,n),r&&n.length>0&&i(n.length)}function tn(t,e,n,r){let i=0;for(let s of r){if(s.file===n.relativePath||t.isIgnored(s.file))continue;let o=e.get(n.symbolId);o||(o=new Set,e.set(n.symbolId,o));let a=o.size;o.add(s.file),o.size!==a&&(i+=1)}return i}function Bo(t){try{return JSON.parse(t)}catch{return null}}function Ou(t,e){return Te(t).calleeMap(e)}function qo(t,e){let n=_(),r=new Map,i=0,s=0,o=0,a=0;return k("semantic.callees.provider-loop",()=>{let l=new Map,u=[];for(let f of e){let c=j(t,f.relativePath);if(!c){n&&(s+=1);continue}n&&(i+=1);let p=f;if(c.calleesForDefinitions){let d=l.get(c);d?d.push(p):l.set(c,[p])}else u.push({provider:c,definition:p})}for(let[f,c]of l){let p=f.calleesForDefinitions(c);for(let d of c){let y=p.get(d.symbolId)??[];ti(r,d.symbolId,y,n,R=>{o+=1,a+=R})}}for(let{provider:f,definition:c}of u){let p=f.calleesFor(c);ti(r,c.symbolId,p,n,d=>{o+=1,a+=d})}return r},()=>({definitions:e.length,providerHits:i,providerMisses:s,definitionsWithCallees:o,calleeCount:a,rows:r.size}))}function ti(t,e,n,r,i){n.length>0&&(t.set(e,n),r&&i(n.length))}function Uu(t,e){return Te(t).signature(e)}function jo(t,e){if(O(e.relativePath)==="typescript"){let o="fallback",a=0,l=0,u=0,f=0;return k("typescript.signature.materialize",()=>{let c=yt(t,e.relativePath,wo);if(c?.key){a=1;let d=ei.read(t,e.relativePath,c.key)??{};if(Object.prototype.hasOwnProperty.call(d,e.symbol))return o="hit",l=1,d[e.symbol]??null;u=1;let y=j(t,e.relativePath);if(!y)return o="unavailable",null;let R=y.signatureFor(e);return ei.write(t,e.relativePath,c.key,{...d,[e.symbol]:R}),o="computed",R}f=1;let p=j(t,e.relativePath);return p?(o="direct-fallback",p.signatureFor(e)):(o="unavailable",null)},()=>({state:o,eligible:a,cacheHits:l,cacheMisses:u,fallbacks:f}))}let n=ii(t,"semantic-signatures",e.relativePath),r=Wo(e);if(n){let o=Xr.read(t,r,n);if(o)return o.signature}let i=j(t,e.relativePath);if(!i)return null;let s=i.signatureFor(e);return n&&Xr.write(t,r,n,{signature:s}),s}function ii(t,e,n){let r=Z(t);if(!r)return null;let i=O(n);return i!=="rust"?null:ft(JSON.stringify({kind:e,language:i,engine:Lt(t.config.projectRoot),projectFingerprint:r}))}function Wo(t){return`${t.relativePath}\0${t.symbol}`}function si(t){try{let e=JSON.parse(t);return Array.isArray(e)?e:null}catch{return null}}function zo(t){try{let e=JSON.parse(t);if(!e||typeof e!="object")return null;let n=e.signature;return n!==null&&typeof n!="string"?null:{signature:n}}catch{return null}}function Ko(t){try{let e=JSON.parse(t);if(!e||typeof e!="object"||Array.isArray(e))return null;for(let n of Object.values(e))if(n!==null&&typeof n!="string")return null;return e}catch{return null}}function oi(t,e,n){let r=O(n);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,...X(t,n).availability()}}catch(i){return{slot:e,language:r,available:!1,reason:i instanceof Error?i.message:String(i)}}}function j(t,e){if(!O(e))return null;let n=X(t,e);return n.availability().available?n:null}export{Gr as a,Lt as b,O as c,Eu as d,Te as e,Au as f,Fu as g,Nu as h,_u as i,Lu as j,Uo as k,Ou as l,Uu as m};
3
- //# sourceMappingURL=chunk-NWQXSFFU.js.map
@@ -1,13 +0,0 @@
1
- import{A as Q,C as Qe,D as j,E as oe,F as Ze,G as be,H as et,I as ie,K as tt,e as qe,f as Ve,g as P,h as ze,i as We,j as He,k as q,l as Ke,m as K,n as Je,o as Xe,p as Ye,q as F,r as J,s as A,t as ge,u as Se,v as h,w as he,x as Ge,y as xe,z as G}from"./chunk-ZOHS7AQV.js";import{a as ye,c as X,e as Y,h as L}from"./chunk-FESCRNVV.js";import{a as Ue,c as U,f as se,i as H}from"./chunk-JWTGMPIT.js";import{Aa as $e,Ba as Be,c as W}from"./chunk-N5B2NILC.js";function O(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function qt(e){return e.replace(/'''[\s\S]*?'''/g,w).replace(/"""[\s\S]*?"""/g,w).replace(/#.*$/gm,w).replace(/\/\/.*$/gm,w).replace(/\/\*[\s\S]*?\*\//g,w).replace(/`(?:\\[\s\S]|[^`])*`/g,w).replace(/'(?:\\.|[^'\\\r\n])*'/g,w).replace(/"(?:\\.|[^"\\\r\n])*"/g,w)}function gs(e){return rt(e,{maskStrings:!1})}function Ss(e){return rt(e,{maskStrings:!0})}function rt(e,r){let t="",n=0,s=e.length;for(;n<s;){if(e[n]==="/"&&e[n+1]==="/"){let i=e.indexOf(`
2
- `,n),a=i===-1?s:i;t+=Ne(e,n,a),n=a;continue}if(e[n]==="/"&&e[n+1]==="*"){let i=e.indexOf("*/",n+2),a=i===-1?s:i+2;t+=Ne(e,n,a),n=a;continue}let o=e[n];if(o==="`"||o==="'"||o==='"'){let i=o,a=n+1;for(;a<s;){if(e[a]==="\\"){a+=2;continue}if(e[a]===i){a+=1;break}if(i!=="`"&&e[a]===`
3
- `)break;a+=1}t+=r.maskStrings?Ne(e,n,a):e.slice(n,a),n=a;continue}t+=o,n+=1}return t}function Ne(e,r,t){let n="";for(let s=r;s<t;s+=1)n+=e[s]===`
4
- `?`
5
- `:" ";return n}function w(e){return e.replace(/[^\r\n]/g," ")}var hs=se("stripped-lines",{clearGroups:["whole-project","source-file"]});Ue({name:"stripped-source-singleton",groups:["whole-project","source-file"],clearAll:()=>{ae=null,Z=""},clearFile:()=>{ae=null,Z=""}});var ae=null,Z="";function Vt(e){return ae===e||(ae=e,Z=qt(e)),Z}function k(e,r,t){let n=Vt(e);return`${n.slice(0,r)}${" ".repeat(t-r)}${n.slice(t)}`}function x(e,r){return new RegExp(`\\b${O(r)}\\b`,"m").test(e)}function V(e,r){let t=new Set,n=new RegExp(`\\b${O(r)}\\s*\\.\\s*([A-Za-z_$][\\w$]*)`,"g");for(let s of e.matchAll(n)){let o=s[1];o&&t.add(o)}return[...t]}function Ie(e){let r=0;for(let t of e)t==="("&&(r+=1),t===")"&&(r-=1);return r}var nt=new WeakMap,st=new Set(["call_expression","call","decorator","pair","string","string_literal","template_string","variable_declarator"]);function zt(e,r){let t=Array.isArray(r)?r:[r];if(!t.every(o=>st.has(o)))return e.descendantsOfType(r);let n=Wt(e);return t.length===1?n.get(t[0])??[]:t.flatMap(o=>n.get(o)??[]).sort((o,i)=>o.startIndex-i.startIndex)}function _e(e,r){let t=e.walk(),n=0,s=!1;for(;!s;){if(r(t),t.gotoFirstChild()){n+=1;continue}for(;;){if(n===0){s=!0;break}if(t.gotoNextSibling())break;t.gotoParent(),n-=1}}}function Wt(e){let r=nt.get(e);if(r)return r;let t=new Map;return _e(e,n=>{let s=n.nodeType;if(!st.has(s))return;let o=t.get(s);o?o.push(n.currentNode):t.set(s,[n.currentNode])}),nt.set(e,t),t}function it(e,r){r(e);for(let t of e.namedChildren)it(t,r)}var Ht=/(?:function|method|lambda)/u,ot=new WeakMap;function Kt(e){let r=ot.get(e);if(r)return r;let t=[];return _e(e,n=>{if(!n.nodeIsNamed)return;let s=n.nodeType;(s==="arrow_function"||Ht.test(s))&&t.push(n.currentNode)}),ot.set(e,t),t}function Jt(e,r,t){let n=null;for(let s of Kt(e))s.startPosition.row>r||s.endPosition.row<t||(!n||s.endIndex-s.startIndex<n.endIndex-n.startIndex)&&(n=s);return n}function at(e,r,t){if(e.startPosition.row>r||e.endPosition.row<t)return null;for(let n of e.namedChildren){let s=at(n,r,t);if(s)return s}return e}function Xt(e){let r=e;for(;["as_expression","satisfies_expression","type_assertion","parenthesized_expression"].includes(r.type)&&r.namedChildren.length>0;)r=r.namedChildren[0];return r}function Ce(e){if(e.type==="identifier")return e.text;let r=e.childForFieldName("name")??e.childForFieldName("pattern");return r?Ce(r):e.namedChildren.find(t=>t.type==="identifier")?.text??null}function Yt(e){return(e.childForFieldName("parameters")??e.namedChildren.find(t=>/parameters/u.test(t.type)))?.namedChildren.map(Ce)??[]}var Gt=new Set(["if_statement","conditional_expression","ternary_expression","for_statement","for_in_statement","for_of_statement","while_statement","do_statement","switch_case","case_statement","catch_clause","except_clause","elif_clause","match_arm"]);function ct(e){return Gt.has(e.type)?1:e.type==="binary_expression"&&e.parent?.type!=="binary_expression"&&(e.text.includes("&&")||e.text.includes("||"))?Qt(e.text):0}function Qt(e){return(e.match(/&&|\|\|/g)??[]).length}var Zt=new Set(["identifier","type_identifier","field_identifier"]),er=new Set(["identifier"]),tr=new Set(["identifier","property_identifier","type_identifier","shorthand_property_identifier","shorthand_property_identifier_pattern"]),rr=new Set(["rust","python"]),nr=/\{([^{}]*)\}/g,sr=/\b([A-Za-z_][\w]*)\b/g;function lt(e,r){return or(r).has(e.type)}function pt(e,r){return rr.has(r)&&e.type==="string_content"}function Pe(e){let r=0;for(let n of e.values()){let s=n[n.length-1];s!==void 0&&s>r&&(r=s)}let t=new Array(r+1);for(let n=0;n<=r;n+=1)t[n]=new Set;for(let[n,s]of e)for(let o of s)t[o].add(n);return t}function or(e){return e==="rust"?Zt:e==="python"?er:tr}function ut(e,r){let t=e.startPosition.row;for(let n of e.text.matchAll(nr)){let s=n[1]??"";for(let o of s.matchAll(sr))o[1]&&r(o[1],t)}}var ir=[/\bdefault\s*=\s*"([^"]+)"/g,/\bwith\s*=\s*"([^"]+)"/g,/\bserialize_with\s*=\s*"([^"]+)"/g,/\bdeserialize_with\s*=\s*"([^"]+)"/g,/\bskip_serializing_if\s*=\s*"([^"]+)"/g,/\bgetter\s*=\s*"([^"]+)"/g,/\brename_all_with\s*=\s*"([^"]+)"/g,/\bschema_with\s*=\s*"([^"]+)"/g],ar=/^#!?\[\s*serde\s*\(/,cr=/^#!?\[\s*schemars\s*\(/,lr=/^#!?\[\s*validate\s*\(/,pr=new Set(["invoke","invokeTauriCommand","listen","once","emit","subscribe","dispatch","sendCommand","callRust"]);function mt(e,r,t){if(r!=="typescript"&&r!=="tsx"&&r!=="javascript"||e.type!=="call_expression")return;let n=e.childForFieldName("function")??e.namedChild(0);if(!n)return;let s=be(n);if(!s||!pr.has(s))return;let o=e.namedChildren.find(c=>c.type==="arguments");if(!o)return;let i=o.namedChild(0);if(!i||i.type!=="string")return;let a=i.namedChildren.find(c=>c.type==="string_fragment");a&&t.add(a.text)}function dt(e,r){let t=ar.test(e),n=cr.test(e),s=lr.test(e);if(!(!t&&!n&&!s))for(let o of ir){o.lastIndex=0;let i;for(;(i=o.exec(e))!==null;){let a=i[1],c=a.split("::").pop()??a;c==="is_none"&&/\bOption\b/.test(a)||c==="is_empty"&&/\b(String|Vec|HashMap|BTreeMap|HashSet|BTreeSet)\b/.test(a)||c&&r.add(c)}}}function ft(e,r){let t=new Map,n=(i,a)=>{if(i===a)return;let c=t.get(i);c||(c=new Set,t.set(i,c)),c.add(a)},s=r==="python"?new Set(["identifier"]):new Set(["type_identifier"]),o=(i,a)=>{let c=p=>{s.has(p.type)&&p.text!==a&&n(p.text,a);for(let l of p.children)c(l)};for(let p of i.children)c(p)};if(r==="rust")for(let i of e.rootNode.descendantsOfType(["struct_item","enum_item","union_item","type_item"])){let a=i.namedChildren.find(p=>p.type==="type_identifier")?.text;if(!a)continue;let c=i.namedChildren.find(p=>p.type==="field_declaration_list"||p.type==="enum_variant_list"||p.type==="ordered_field_declaration_list");c&&o(c,a),i.type==="type_item"&&o(i,a)}else if(r==="python")for(let i of e.rootNode.descendantsOfType("class_definition")){let a=i.namedChildren.find(l=>l.type==="identifier")?.text;if(!a)continue;let c=i.childForFieldName("superclasses");c&&o(c,a);let p=i.namedChildren.find(l=>l.type==="block");if(p)for(let l of p.descendantsOfType("type"))for(let u of l.descendantsOfType("identifier"))u.text!==a&&n(u.text,a)}else for(let i of e.rootNode.descendantsOfType(["interface_declaration","type_alias_declaration","class_declaration"])){let a=i.namedChildren.find(c=>c.type==="type_identifier")?.text;a&&o(i,a)}return t}var ur=new Map([["defn","function"],["defn-","function"],["defmacro","macro"],["defmacro-","macro"],["defmethod","method"]]),Te=new Set(["catch","comment","def","defprotocol","defrecord","deftype","defmethod","defmacro","defmacro-","defn","defn-","do","doseq","dotimes","fn","for","if","let","loop","ns","quote","recur","throw","try","extend-protocol","extend-type","when","when-let","when-not"]);function gt(e){let r=[],t=[],n=[],s=new Map,o=[],i=0,a=0,c=(p,l)=>{let u=s.get(p);if(!u){s.set(p,[l]);return}u[u.length-1]!==l&&u.push(l)};for(;a<e.length;){let p=e[a];if(p===`
6
- `){i+=1,a+=1;continue}if(/\s|,/.test(p)){a+=1;continue}if(p===";"){a=le(e,a);continue}if(p==='"'){let f=te(e,a,i);i=f.line,a=f.index;continue}if(p==="("||p==="["||p==="{"){o.push({kind:p,startLine:i,endLine:i,headTokens:[],tokens:[],children:[]}),a+=1;continue}if(p===")"||p==="]"||p==="}"){let f=o.pop();f&&(f.endLine=i,mr(f,{callables:r,callSites:t,clojureMembers:n,recordIdentifier:c}),o[o.length-1]?.children.push(f)),a+=1;continue}if(Ee(p)){a+=1;continue}let l=i,u=a;for(;a<e.length&&!Re(e[a]);)a+=1;let m=e.slice(u,a);if(!m)continue;let d={text:m,line:l};dr(o[o.length-1],d),c(N(m),l)}return{language:"clojure",callables:r,callSites:t,clojureMembers:n,typeContainerMap:new Map,identifierLineMap:s,identifiersByLine:xr(s),fileIdentifiers:new Set(s.keys()),rustAttrReferencedNames:new Set,crossLanguageDispatchNames:new Set}}function mr(e,r){if(e.kind!=="("||e.headTokens.length===0)return;let t=e.headTokens[0],n=N(t.text),s=ur.get(t.text);if(s){let i=e.headTokens[1];if(i){let a=N(i.text);r.recordIdentifier(a,i.line),r.callables.push({name:a,startLine:e.startLine,endLine:e.endLine,paramCount:0,params:[],paramsEndLine:i.line,isLiteralPassthrough:!1,clojureKind:s})}}if(fr(e,r),!n||Te.has(t.text)||Te.has(n)||n.startsWith(":"))return;let o=hr(t.text);r.callSites.push({calleeLeaf:o.leaf,calleeQualifier:o.qualifier,calleeText:o.text,memberAccess:!1,line:t.line})}function dr(e,r){e&&(e.headTokens.length<2&&e.headTokens.push(r),e.tokens.length<200&&e.tokens.push(r))}function fr(e,r){let t=N(e.tokens[0]?.text??"");if(t==="defprotocol"){let n=N(e.tokens[1]?.text??"");if(!n)return;for(let s of ce(e))ee(r,n,"protocol",s,"protocol-method");return}if(t==="defrecord"||t==="deftype"){let n=N(e.tokens[1]?.text??"");if(!n)return;let s=t==="defrecord"?"record":"type",o=t==="defrecord"?"record-method":"type-method";for(let i of ce(e))ee(r,n,s,i,o);return}if(t==="extend-type"){let n=N(e.tokens[1]?.text??"");if(!n)return;for(let s of ce(e))ee(r,n,"extension",s,"extension-method");return}if(t==="extend-protocol"){let n=N(e.tokens[1]?.text??"");for(let s of ce(e)){n&&ee(r,n,"extension",s,"extension-method");let o=Sr(e,s.startLine);o&&o!==n&&ee(r,o,"extension",s,"extension-method")}}}function ce(e){return e.children.filter(gr)}function gr(e){if(e.kind!=="(")return!1;let r=N(e.tokens[0]?.text??"");return!!(r&&!Te.has(r)&&!r.startsWith(":"))}function ee(e,r,t,n,s){let o=n.tokens[0],i=N(o?.text??"");!o||!i||(e.recordIdentifier(i,o.line),e.clojureMembers.push({ownerName:r,ownerKind:t,memberName:i,memberKind:s,startLine:n.startLine,endLine:n.endLine}))}function Sr(e,r){let t=null;for(let n=2;n<e.tokens.length;n+=1){let s=e.tokens[n];if(s.line>r)break;let o=N(s.text);o&&!o.startsWith(":")&&(t=o)}return t}function N(e){return e.replace(/^#?['`~@]+/,"").split("/").pop()?.replace(/^\./,"")??""}function hr(e){let r=e.replace(/^#?['`~@]+/,""),t=r.lastIndexOf("/"),n=N(r);if(t<=0)return{leaf:n,text:r};let s=r.slice(0,t);return{leaf:n,qualifier:s,text:r}}function le(e,r){let t=r;for(;t<e.length&&e[t]!==`
7
- `;)t+=1;return t}function te(e,r,t){let n=r+1,s=t;for(;n<e.length;){let o=e[n];if(o==="\\"){n+=2;continue}if(o===`
8
- `&&(s+=1),n+=1,o==='"')break}return{index:n,line:s}}function Ee(e){return e==="'"||e==="`"||e==="~"||e==="@"||e==="^"||e==="#"}function Re(e){return/\s|,/.test(e)||e==="("||e===")"||e==="["||e==="]"||e==="{"||e==="}"||e==='"'||e===";"}function xr(e){let r=[];for(let[t,n]of e)for(let s of n)r[s]??=new Set,r[s].add(t);return r}var St=7,br=se("source-facts",{clearGroups:["whole-project","source-file"]}),Fe=X({kind:"source-facts",invalidation:Y("source-facts"),serialize:Cr,deserialize:Pr});function E(e,r){return Nr(e,r).facts}function Nr(e,r){let t=L(e,r);if(!t)return{facts:null};let n=Ir(e,r,t);return n?br.get(e,r,t,()=>_r(e,r,n,t)):{facts:null}}function Ir(e,r,t){return Q(r)?Qe(e,r,t)?.language??null:G(r)}function _r(e,r,t,n){let s=H(e,r,n),o=Fe.read(e,r,s);if(o&&o.language===t)return{facts:o};if(t==="clojure"){let c=gt(n);return Fe.write(e,r,s,c),{facts:c}}let i=j(e,r);if(!i)return{facts:null,unavailable:{language:t,reason:"parser-unavailable"}};let a=Fr(i,t);return Fe.write(e,r,s,a),{facts:a}}function Cr(e){let r={version:St,language:e.language,callables:e.callables,callSites:e.callSites,clojureMembers:e.clojureMembers,typeContainerMap:[...e.typeContainerMap.entries()].map(([t,n])=>[t,[...n]]),identifierLineMap:[...e.identifierLineMap.entries()],rustAttrReferencedNames:[...e.rustAttrReferencedNames],crossLanguageDispatchNames:[...e.crossLanguageDispatchNames]};return JSON.stringify(r)}function Pr(e){try{let r=JSON.parse(e);if(r.version!==St||r.language==="clojure"&&(r.clojureMembers===void 0||r.callSites.some(n=>n.calleeText===void 0)))return null;let t=new Map(r.identifierLineMap);return{language:r.language,callables:r.callables,callSites:r.callSites,clojureMembers:r.clojureMembers??[],typeContainerMap:new Map(r.typeContainerMap.map(([n,s])=>[n,new Set(s)])),identifierLineMap:t,identifiersByLine:Pe(t),fileIdentifiers:new Set(t.keys()),rustAttrReferencedNames:new Set(r.rustAttrReferencedNames),crossLanguageDispatchNames:new Set(r.crossLanguageDispatchNames)}}catch{return null}}function Tr(e,r,t,n){let s=E(e,r);return s?Rr(s,t,n)?.isLiteralPassthrough??!0:!0}function Er(e,r){return r.relativePath.includes(".clj-kondo/hooks/")?!0:E(e,r.relativePath)?.callables.find(n=>n.startLine===r.startLine&&n.endLine===r.endLine)?.clojureKind==="macro"}function Rr(e,r,t){return e.callables.find(n=>n.startLine===r&&n.endLine===t)??null}function Fr(e,r){let t=[],n=[],s=new Set,o=new Set,i=new Map,a=(l,u)=>{let m=i.get(l);if(!m){i.set(l,[u]);return}m[m.length-1]!==u&&m.push(u)},c=[],p=l=>{let u=ie(l,r);u&&(u.branches=0,t.push(u),c.push(u));let m=ct(l);if(m>0)for(let f of c)f.branches=(f.branches??0)+m;let d=Ze(l,r);d&&n.push(d),mt(l,r,o),r==="rust"&&(l.type==="attribute_item"||l.type==="inner_attribute_item")&&dt(l.text,s),lt(l,r)&&a(l.text,l.startPosition.row),pt(l,r)&&ut(l,a);for(let f of l.children)p(f);u&&c.pop()};return p(e.rootNode),{language:r,callables:t,callSites:n,clojureMembers:[],typeContainerMap:ft(e,r),identifierLineMap:i,identifiersByLine:Pe(i),fileIdentifiers:new Set(i.keys()),rustAttrReferencedNames:s,crossLanguageDispatchNames:o}}var ht=new Set(["rust","typescript","tsx","javascript","python","clojure"]),Ar=new Set(["rust","typescript","tsx","javascript","python"]);function Lr(e,r){let t=E(e,r);return!t||!ht.has(t.language)?null:t.callables.map(n=>({name:n.name,startLine:n.startLine,endLine:n.endLine}))}function wr(e,r){if(!Ar.has(r))return null;let t=[];for(let n of e.descendantsOfType([...et(r)])){let s=ie(n,r);s&&t.push({name:s.name,startLine:s.startLine,endLine:s.endLine})}return t}function kr(e,r){let t=E(e,r);return!t||!ht.has(t.language)?null:t.callSites}function Dr(e,r){return E(e,r)?.typeContainerMap??new Map}function jr(e,r,t={}){let n=E(e,r);if(!n)return[];let s=[];if(t.includeCrossLanguageDispatchNames)for(let o of n.crossLanguageDispatchNames)s.push({name:o,kind:"cross-language-dispatch",occurrences:1});if(t.includeRustAttributeNames&&n.language==="rust")for(let o of n.rustAttrReferencedNames)s.push({name:o,kind:"rust-attribute",occurrences:1});return s}import{basename as xt}from"path";var Or=new Set(["identifier","type_identifier","property_identifier","shorthand_property_identifier","field_identifier"]);function y(e){let r=[],t=0,n=0;for(let s=0;s<e.length;s++){let o=e[s];(o==="{"||o==="["||o==="(")&&t++,(o==="}"||o==="]"||o===")")&&t--,o===","&&t===0&&(r.push(e.slice(n,s)),n=s+1)}return r.push(e.slice(n)),r}function b(e,r){for(let t of e.namedChildren)if(t.type===r)return t;return null}function S(e,r){let t=new Set,n=(s,o)=>{let i=o||r.has(s.type);!i&&Or.has(s.type)&&t.add(s.text);for(let a of s.children)n(a,i)};return n(e.rootNode,!1),t}function T(e,r,t,n,s,o,i){return{importedName:s,localName:o,sourcePath:i??h(e,n,Ye(r)),kind:"named",used:x(t,o),usedMembers:[]}}function g(e,r,t,n,s="named",o={}){return{importedName:e,localName:r,sourcePath:t,kind:s,used:n.has(r),usedMembers:[],isTypeOnly:o.isTypeOnly}}function R(e,r,t,n,s="named",o=[],i={}){return{importedName:e,localName:r,sourcePath:t,kind:s,used:n,usedMembers:o,isTypeOnly:i.isTypeOnly}}function M(e,r){return{importedName:e,localName:null,sourcePath:r,kind:"side-effect",used:!0,usedMembers:[]}}function v(e,r,t={}){return{importedName:e,localName:t.localName??null,sourcePath:r,kind:"namespace",used:t.used??!0,usedMembers:t.usedMembers??[],isTypeOnly:t.isTypeOnly}}function I(e,r,t){let n=[];for(let s of e.matchAll(r)){let o=s[0];if(!o||typeof s.index!="number")continue;let i=k(e,s.index,s.index+o.length);for(let a of t(s,i))n.push(a)}return n}function _(e,r,t,n,s){let o=oe(e,r,s);if(o){let i=t(o);if(i)return i}return n()}function pe(e,r,t,n,s){let o=oe(e,r,s),i=G(r),a=i?t[i]:void 0;return o&&a?a(o):n()}function yt(e,r,t){return _(e,r,n=>vr(e,r,n),()=>Mr(e,r,t),t)}function Mr(e,r,t){return I(t,/^[ \t]*#include\s+[<"]([^">]+)[">]\s*$/gm,(n,s)=>{let o=n[1]?.trim();if(!o)return[];let i=xt(o).replace(/\.[^.]+$/,"");return[R(o,i,Se(e,r,o),x(s,i))]})}function vr(e,r,t){let n=S(t,new Set(["preproc_include"])),s=[];for(let o of t.rootNode.descendantsOfType("preproc_include")){let i=null;for(let c of o.namedChildren){if(c.type==="system_lib_string"){i=c.text.replace(/^<|>$/g,"");break}if(c.type==="string_literal"){i=c.namedChildren.find(l=>l.type==="string_content")?.text??c.text.replace(/^"|"$/g,"");break}}if(!i)continue;let a=xt(i).replace(/\.[^.]+$/,"");s.push(g(i,a,Se(e,r,i),n))}return s}var $r=new Set([":require",":require-macros",":use"]),we=String.raw`A-Za-z0-9_$*+!?.<>=-`;function Nt(e,r,t){let n=Yr(t);if(!n)return[];let s=Xr(t,n.start,n.end),o=[];for(let i of n.children.slice(2)){if(i.type!=="list"||i.children.length===0)continue;let a=C(i.children[0]);if(a){if($r.has(a)){for(let c of qr(i.children.slice(1)))o.push(...Ur(e,c,s));continue}if(a===":import")for(let c of zr(i.children.slice(1)))o.push(c)}}return o}function Br(e){return e.type==="list"&&C(e.children[0])==="ns"}function Ur(e,r,t){let n=Ge(e,r.namespace),s=r.alias??r.namespace,o=Hr(t,s),i=[{importedName:r.namespace,localName:s,sourcePath:n,kind:"namespace",used:r.refers.length>0||r.referAll||o.length>0||Kr(t,r.namespace),usedMembers:o}];r.referAll&&i.push({importedName:"*",localName:null,sourcePath:n,kind:"side-effect",used:!0,usedMembers:[]});for(let a of r.refers)i.push({importedName:a,localName:a,sourcePath:n,kind:"named",used:Jr(t,a),usedMembers:[]});return i}function qr(e){return e.flatMap(r=>ue(r,null))}function ue(e,r){if(e.type==="atom")return e.text.startsWith(":")?[]:[{namespace:Le(r,e.text),alias:null,refers:[],referAll:!1}];if(e.type==="vector")return e.children.length>0&&C(e.children[0])===null?e.children.flatMap(t=>ue(t,r)):Vr(e,r);if(e.type==="list"&&e.children.length>0){let t=C(e.children[0]);return t?!t||t.startsWith(":")?[]:e.children.slice(1).flatMap(n=>ue(n,Le(r,t))):e.children.flatMap(n=>ue(n,r))}return[]}function Vr(e,r){let t=C(e.children[0]);if(!t||t.startsWith(":"))return[];let n={namespace:Le(r,t),alias:null,refers:[],referAll:!1};for(let s=1;s<e.children.length;s+=1){let o=C(e.children[s]);if(!o?.startsWith(":"))continue;let i=e.children[s+1];if((o===":as"||o===":as-alias")&&i){n.alias=C(i),s+=1;continue}o===":refer"&&i&&(C(i)===":all"?n.referAll=!0:(i.type==="vector"||i.type==="list")&&n.refers.push(...i.children.map(C).filter(Wr)),s+=1)}return[n]}function zr(e){let r=[];for(let t of e){if(t.type==="atom"){let s=t.text.split(".").pop()??t.text;r.push(R(s,s,null,!0));continue}if(t.type!=="vector")continue;let n=C(t.children[0]);if(n)for(let s of t.children.slice(1)){let o=C(s);o&&r.push(R(`${n}.${o}`,o,null,!0))}}return r}function Le(e,r){return e?`${e}.${r}`:r}function C(e){return e?.type==="atom"?e.text:null}function Wr(e){return!!(e&&!e.startsWith(":"))}function Hr(e,r){let t=new Set,n=new RegExp(`${ke()}${O(r)}\\s*/\\s*([${we}]+)`,"g");for(let s of e.matchAll(n)){let o=s[1];o&&t.add(o)}return[...t]}function Kr(e,r){return new RegExp(`${ke()}${O(r)}\\s*/`,"m").test(e)}function Jr(e,r){return new RegExp(`${ke()}${O(r)}(?![${we}])`,"m").test(e)}function ke(){return`(?<![${we}])`}function Xr(e,r,t){let n="",s=0;for(;s<e.length;){if(s>=r&&s<t){n+=e[s]===`
9
- `?`
10
- `:" ",s+=1;continue}let o=e[s];if(o===";"){let i=le(e,s);n+=bt(e.slice(s,i)),s=i;continue}if(o==='"'){let i=te(e,s,0).index;n+=bt(e.slice(s,i)),s=i;continue}n+=o,s+=1}return n}function Yr(e){let r=0;for(;r<e.length&&(r=De(e,r),!(r>=e.length));){let t=me(e,r);if(!t){r+=1;continue}if(Br(t.form))return t.form;r=t.index}return null}function me(e,r){let t=De(e,r);if(e.startsWith("#?@",t)||e.startsWith("#?",t))return Gr(e,t);if(e.startsWith("#_",t)){let s=me(e,t+2);return s?{form:{type:"atom",text:"",start:t,end:s.index},index:s.index}:null}for(;Ee(e[t]);)t+=1;let n=e[t];return n?n==="("?Ae(e,t,"list",")"):n==="["?Ae(e,t,"vector","]"):n==="{"?Ae(e,t,"map","}"):n==='"'?{form:{type:"atom",text:"",start:t,end:te(e,t,0).index},index:te(e,t,0).index}:Zr(e,t):null}function Gr(e,r){let t=e.startsWith("#?@",r)?3:2,n=me(e,r+t);return n?{form:{type:"list",children:n.form.type==="list"||n.form.type==="vector"||n.form.type==="map"?Qr(n.form.children):[],start:r,end:n.index},index:n.index}:null}function Qr(e){let r=[];for(let t=0;t<e.length;t+=2){let n=C(e[t]),s=e[t+1];n?.startsWith(":")&&s&&r.push(s)}return r}function Ae(e,r,t,n){let s=[],o=r+1;for(;o<e.length;){if(o=De(e,o),e[o]===n)return{form:{type:t,children:s,start:r,end:o+1},index:o+1};let i=me(e,o);if(!i){o+=1;continue}i.form.type==="atom"&&i.form.text===""||s.push(i.form),o=i.index}return{form:{type:t,children:s,start:r,end:e.length},index:e.length}}function Zr(e,r){let t=r;for(;t<e.length&&!Re(e[t]);)t+=1;return{form:{type:"atom",text:e.slice(r,t),start:r,end:t},index:t}}function De(e,r){let t=r;for(;t<e.length;){let n=e[t];if(/\s|,/.test(n)){t+=1;continue}if(n===";"){t=le(e,t);continue}break}return t}function bt(e){return e.replace(/[^\r\n]/g," ")}function It(e,r,t){let n=[];for(let s of t.matchAll(/^[ \t]*import\s+['"]([^'"]+)['"](?:\s+as\s+([A-Za-z_]\w*))?[\s\S]*?;$/gm)){let o=s[1]?.trim(),i=s[2]?.trim()??null,a=s[0];if(!o||!a||typeof s.index!="number")continue;let c=k(t,s.index,s.index+a.length);n.push({importedName:o,localName:i,sourcePath:he(e,r,o),kind:i?"namespace":"side-effect",used:i?x(c,i):!0,usedMembers:i?V(c,i):[]})}return n}function _t(e,r,t){let n=[];for(let s of t.matchAll(/^[ \t]*export\s+['"]([^'"]+)['"][\s\S]*?;$/gm)){let o=s[1]?.trim();o&&n.push({specifier:o,sourcePath:he(e,r,o)})}return n}function Ct(e,r,t){return pe(e,r,{csharp:n=>tn(e,r,n),vb:n=>en(e,r,n)},()=>{let n=Xe(r)?/^[ \t]*Imports\s+(.+?)\s*$/gm:/^[ \t]*using\s+(.+?)\s*;$/gm;return I(t,n,(s,o)=>{let i=s[1]?.trim();if(!i)return[];let[a,c]=i.split(/\s*=\s*/),p=!!c,l=(p?c:a)?.trim()??i,u=l.split(".").pop()??l,m=p?a?.trim()??u:u;return[T(e,r,o,l,u,m,h(e,l,q))]})},t)}function en(e,r,t){let n=S(t,new Set(["imports_statement"])),s=[];for(let o of t.rootNode.descendantsOfType("imports_statement")){let i=o.namedChildren.filter(m=>m.type==="namespace_name");if(i.length===0)continue;let a=i[i.length-1],c=i.length>1?i[0]:null,p=a.text,l=p.split(".").pop()??p,u=c?.text??l;s.push(g(l,u,h(e,p,q),n,c?"namespace":"named"))}return s}function tn(e,r,t){let n=S(t,new Set(["using_directive"])),s=[];for(let o of t.rootNode.descendantsOfType("using_directive")){let i=o.namedChildren;if(i.length===0)continue;let a=null,c;i.length>=2&&i[0].type==="identifier"&&(i[1].type==="qualified_name"||i[1].type==="identifier")?(a=i[0],c=i[1]):c=i[i.length-1];let p=c.text,l=p.split(".").pop()??p,u=a?.text??l;s.push(g(l,u,h(e,p,q),n,a?"namespace":"named"))}return s}var rn=U("vue-non-script-identifiers",{clearGroups:["whole-project","source-file"]});function Pt(e,r){return rn.get(e,r,()=>{let t=new Set,n=L(e,r);if(!n)return t;let o=n.replace(/<script\b[^>]*>[\s\S]*?<\/script>/g,i=>i.replace(/[^\r\n]/g," ")).replace(/<!--[\s\S]*?-->/g,i=>i.replace(/[^\r\n]/g," ")).replace(/\/\*[\s\S]*?\*\//g,i=>i.replace(/[^\r\n]/g," "));for(let i of o.matchAll(/[A-Za-z_$][\w$]*/g))t.add(i[0]);return t})}function je(e,r,t){return _(e,r,n=>sn(e,r,n),()=>nn(e,r,t),t)}function nn(e,r,t){return Sn(t).flatMap(n=>hn(e,r,n.clause,n.specifier,n.start,n.end,t))}function sn(e,r,t){let n=on(e,r,t),s=[];for(let o of t.rootNode.descendantsOfType("import_statement"))s.push(...an(e,r,t,o,n));return s}function on(e,r,t){let n=S(t,new Set(["import_statement"]));if(Q(r))for(let s of Pt(e,r))n.add(s);return n}function an(e,r,t,n,s){let o=mn(n);if(!o)return[];let i=F(e,r,o),a=b(n,"import_clause");return a?cn(t,a,i,s,dn(n.text)):[M("*",i)]}function cn(e,r,t,n,s){let o=[];for(let i of r.namedChildren)if(i.type==="identifier")o.push(ln(i.text,t,n,s));else if(i.type==="namespace_import"){let a=pn(e,i,t,n,s);a&&o.push(a)}else i.type==="named_imports"&&o.push(...un(i,t,n,s));return o}function ln(e,r,t,n){return g("default",e,r,t,"default",{isTypeOnly:n})}function pn(e,r,t,n,s){let i=b(r,"identifier")?.text??"";if(!i)return null;let a=gn(e,i);return v("*",t,{localName:i,usedMembers:a,isTypeOnly:s,used:a.length>0||n.has(i)})}function un(e,r,t,n){let s=[];for(let o of e.namedChildren){if(o.type!=="import_specifier")continue;let i=o.namedChild(0),a=o.namedChild(1);if(!i)continue;let c=i.text,p=a?.text??c;s.push(g(c,p,r,t,"named",{isTypeOnly:n||fn(o.text)}))}return s}function mn(e){let r=b(e,"string");if(!r)return null;let t=b(r,"string_fragment");return t?t.text:null}function dn(e){return/^\s*import\s+type\b/.test(e)}function fn(e){return/^\s*type\b/.test(e.trim())}function gn(e,r){let t=new Set;for(let n of e.rootNode.descendantsOfType("member_expression")){let s=n.namedChild(0),o=n.namedChild(1);!s||!o||s.type!=="identifier"||s.text!==r||(o.type==="property_identifier"||o.type==="identifier")&&t.add(o.text)}return[...t]}function Sn(e){let r=[],t=/^[ \t]*import\s+([\s\S]*?)\s+from\s+['"]([^'"]+)['"]\s*;?/gm;for(let s of e.matchAll(t)){let o=s[0],i=s[1],a=s[2];!o||!a||typeof s.index!="number"||r.push({clause:i,specifier:a,start:s.index,end:s.index+o.length})}let n=/^[ \t]*import\s+['"]([^'"]+)['"]\s*;?/gm;for(let s of e.matchAll(n)){let o=s[0],i=s[1];!o||!i||typeof s.index!="number"||r.push({clause:null,specifier:i,start:s.index,end:s.index+o.length})}return r.sort((s,o)=>s.start-o.start)}function hn(e,r,t,n,s,o,i){let a=F(e,r,n),c=k(i,s,o);return t?xn(t).map(l=>({...l,sourcePath:a})).map(l=>{if(l.kind==="namespace"){let u=V(c,l.localName);return v(l.importedName,l.sourcePath,{localName:l.localName,usedMembers:u,used:u.length>0||x(c,l.localName),isTypeOnly:l.isTypeOnly})}return l.kind==="side-effect"?M(l.importedName,l.sourcePath):R(l.importedName,l.localName??"",l.sourcePath,l.localName?x(c,l.localName):!1,l.kind,[],{isTypeOnly:l.isTypeOnly})}):[M("*",a)]}function xn(e){let r=e.trim(),t=/^type\b/.test(r),n=r.replace(/^type\s+/,""),[s,o]=yn(n),i=[];return s&&i.push(...Tt(s,t)),o&&i.push(...Tt(o,t)),i}function Tt(e,r){let t=e.trim();if(!t)return[];if(t.startsWith("{")){let n=t.slice(1,-1).trim();return n?y(n).map(s=>{let o=s.trim(),i=r||/^type\b/.test(o),a=o.replace(/^type\s+/,""),[c,p]=a.split(/\s+as\s+/);return{importedName:c.trim(),localName:(p??c).trim(),kind:"named",isTypeOnly:i}}):[]}return t.startsWith("* as ")?[{importedName:"*",localName:t.slice(5).trim(),kind:"namespace",isTypeOnly:r}]:[{importedName:"default",localName:t,kind:"default",isTypeOnly:r}]}function yn(e){let r=0;for(let t=0;t<e.length;t++){let n=e[t];if(n==="{"&&r++,n==="}"&&r--,n===","&&r===0)return[e.slice(0,t).trim(),e.slice(t+1).trim()]}return[e.trim(),null]}function Oe(e,r,t){let n=j(e,r);return n?Pn(e,r,n):bn(e,r,t)}function bn(e,r,t){return[...Nn(e,r,t),...In(e,r,t),..._n(e,r,t)]}function Nn(e,r,t){let n=[],s=/^[ \t]*export\s+(?:type\s+)?\{([\s\S]*?)\}\s+from\s+['"]([^'"]+)['"]\s*;?/gm;for(let o of t.matchAll(s)){if(typeof o.index!="number")continue;let i=o[1]??"",a=o[2]??"",c=y(i).map(u=>Cn(u.trim())).filter(u=>!!u),p=z(t,o.index),l=z(t,o.index+o[0].length-1);n.push({kind:"named",sourcePath:F(e,r,a),names:c,startLine:p,endLine:l})}return n}function In(e,r,t){let n=[],s=/^[ \t]*export\s+\*\s+as\s+(\w+)\s+from\s+['"]([^'"]+)['"]\s*;?/gm;for(let o of t.matchAll(s)){if(typeof o.index!="number")continue;let i=o[2]??"",a=z(t,o.index),c=z(t,o.index+o[0].length-1);n.push({kind:"star-as",sourcePath:F(e,r,i),names:o[1]?[o[1]]:[],startLine:a,endLine:c})}return n}function _n(e,r,t){let n=[],s=/^[ \t]*export\s+\*\s+from\s+['"]([^'"]+)['"]\s*;?/gm;for(let o of t.matchAll(s)){if(typeof o.index!="number")continue;let i=o[1]??"",a=z(t,o.index),c=z(t,o.index+o[0].length-1);n.push({kind:"star",sourcePath:F(e,r,i),names:[],startLine:a,endLine:c})}return n}function Cn(e){if(!e)return null;let r=e.replace(/^type\s+/,"").trim();if(!r)return null;let t=r.match(/^(\w+)\s+as\s+(\w+)$/);if(t)return t[2]??null;let n=r.match(/^(\w+)$/);return n?n[1]??null:null}function z(e,r){let t=0;for(let n=0;n<r&&n<e.length;n++)e.charCodeAt(n)===10&&t++;return t}function Pn(e,r,t){let n=[];for(let s of t.rootNode.descendantsOfType("export_statement")){let o=Tn(e,r,s);if(o===void 0)continue;let i=s.startPosition.row,a=s.endPosition.row,c=En(s,o,i,a);n.push(c)}return n}function Tn(e,r,t){let n=b(t,"string");if(!n)return;let s=b(n,"string_fragment");if(s)return F(e,r,s.text)}function En(e,r,t,n){let s=b(e,"export_clause");if(s){let i=[];for(let a of s.namedChildren){if(a.type!=="export_specifier")continue;let c=a.namedChild(0),p=a.namedChild(1);c&&i.push((p??c).text)}return{kind:"named",sourcePath:r,names:i,startLine:t,endLine:n}}let o=b(e,"namespace_export");if(o){let i=o.namedChildren.find(a=>a.type==="identifier"||a.type==="type_identifier")?.text;return{kind:"star-as",sourcePath:r,names:i?[i]:[],startLine:t,endLine:n}}return{kind:"star",sourcePath:r,names:[],startLine:t,endLine:n}}function Et(e,r,t){return pe(e,r,{java:n=>Rn(e,r,n),kotlin:n=>Fn(e,r,n),scala:n=>An(e,r,n)},()=>I(t,/^[ \t]*import\s+(?:static\s+)?(.+?)\s*;?$/gm,(n,s)=>{let o=n[1]?.trim();return o?Ln(e,r,o,s):[]}),t)}function Rn(e,r,t){let n=S(t,new Set(["import_declaration"])),s=[];for(let o of t.rootNode.descendantsOfType("import_declaration")){let i=o.children.some(u=>u.type==="asterisk"),c=o.namedChildren.find(u=>u.type==="scoped_identifier")??o.namedChildren.find(u=>u.type==="identifier");if(!c)continue;let p=c.text;if(i){s.push(v("*",h(e,p,P)));continue}let l=p.split(".").pop()??p;s.push(g(l,l,h(e,p,P),n))}return s}function Fn(e,r,t){let n=S(t,new Set(["import_header","import_list"])),s=[];for(let o of t.rootNode.descendantsOfType("import_header")){let i=o.namedChildren.find(d=>d.type==="identifier");if(!i)continue;let a=o.namedChildren.some(d=>d.type==="wildcard_import"),c=o.namedChildren.find(d=>d.type==="import_alias");if(a){s.push(v("*",h(e,i.text,P)));continue}let p=i.text,l=p.split(".").pop()??p,m=c?.namedChild(0)?.text??l;s.push(g(l,m,h(e,p,P),n))}return s}function An(e,r,t){let n=S(t,new Set(["import_declaration"])),s=[];for(let o of t.rootNode.descendantsOfType("import_declaration")){let i=o.namedChildren.find(u=>u.type==="namespace_selectors"||u.type==="namespace_wildcard"),a=o.namedChildren.filter(u=>u!==i&&(u.type==="identifier"||u.type==="stable_identifier")),c=a.map(u=>u.text).join(".");if(!c)continue;if(i?.type==="namespace_wildcard"){s.push(v("*",h(e,c,P)));continue}if(i?.type==="namespace_selectors"){for(let u of i.namedChildren)if(u.type==="arrow_renamed_identifier"){let[m,d]=u.namedChildren;if(!m)continue;let f=m.text,$=d?.text??f;if(f==="_")continue;s.push(g(f,$,h(e,`${c}.${f}`,P),n))}else if(u.type==="identifier"){let m=u.text;s.push(g(m,m,h(e,`${c}.${m}`,P),n))}continue}let p=a[a.length-1]?.text??c,l=a.slice(0,-1).map(u=>u.text).join(".")||c;s.push(g(p,p,h(e,l&&a.length>1?`${l}.${p}`:c,P),n))}return s}function Ln(e,r,t,n){if(t.includes("{")&&t.includes("}")){let s=t.slice(0,t.indexOf("{")).replace(/\.$/,"").trim(),o=t.slice(t.indexOf("{")+1,t.lastIndexOf("}")).trim();return y(o).flatMap(i=>{let a=i.trim();if(!a)return[];let[c,p]=a.includes("=>")?a.split(/\s*=>\s*/):a.split(/\s+as\s+/),l=c?.trim();if(!l||l==="_")return[];let u=(p??l.split(".").pop()??l).trim(),m=l==="_"?s:`${s}.${l}`.replace(/\.\./g,".");return[T(e,r,n,m,l,u)]})}return[T(e,r,n,t,t.split(".").pop()??t,t.split(".").pop()??t)]}function Ft(e,r,t){return _(e,r,n=>wn(e,r,n),()=>I(t,/^[ \t]*use\s+(.+?)\s*;$/gm,(n,s)=>{let o=n[1]?.trim();return o?y(o).flatMap(i=>{let a=i.trim();if(!a)return[];let[c,p]=a.split(/\s+as\s+/i),l=c?.trim()??a,u=l.split("\\").pop()??l,m=(p??u).trim();return[T(e,r,s,l,u,m,h(e,l.replace(/\\/g,"."),K))]}):[]}),t)}function wn(e,r,t){let n=S(t,new Set(["namespace_use_declaration"])),s=[],o=(i,a,c)=>{s.push(g(a,c,h(e,i.replace(/\\/g,"."),K),n))};for(let i of t.rootNode.descendantsOfType("namespace_use_declaration")){let a=i.namedChildren.find(c=>c.type==="namespace_use_group");if(a){let c=i.namedChildren.find(p=>p.type==="namespace_name")?.text??"";for(let p of a.namedChildren){if(p.type!=="namespace_use_clause")continue;let{importedName:l,localName:u,qualified:m}=Rt(p,c);l&&o(m,l,u)}continue}for(let c of i.namedChildren){if(c.type!=="namespace_use_clause")continue;let{importedName:p,localName:l,qualified:u}=Rt(c,"");p&&o(u,p,l)}}return s}function Rt(e,r){let t=e.namedChildren.find(p=>p.type==="qualified_name"),n=e.namedChildren.filter(p=>p.type==="name"),s="";t?s=t.text:n.length>=1&&(s=n[0].text);let o=t&&n.length>0?n[n.length-1]:null,i=s.split("\\").pop()??s,a=o?.text??i,c=r?`${r}\\${s}`:s;return{importedName:i,localName:a,qualified:c}}function Lt(e,r,t){return _(e,r,n=>kn(e,r,n),()=>jn(t).flatMap(n=>Mn(e,r,n,t)),t)}function kn(e,r,t){let n=S(t,new Set(["import_statement","import_from_statement"])),s=[];for(let o of t.rootNode.descendantsOfType("import_statement"))for(let i of o.namedChildren){let a=At(i);if(!a)continue;let c=J(e,r,a.qualifiedName);s.push({importedName:a.qualifiedName,localName:a.localName,sourcePath:c,kind:"namespace",used:n.has(a.localName),usedMembers:[]})}for(let o of t.rootNode.descendantsOfType("import_from_statement")){let i=o.namedChild(0);if(!i)continue;let a=Dn(i);if(a===null)continue;let c=J(e,r,a);for(let p=1;p<o.namedChildCount;p+=1){let l=o.namedChild(p);if(l.type==="wildcard_import"){s.push({importedName:"*",localName:null,sourcePath:c,kind:"side-effect",used:!0,usedMembers:[]});continue}let u=At(l);u&&s.push({importedName:u.qualifiedName,localName:u.localName,sourcePath:c,kind:"named",used:n.has(u.localName),usedMembers:[]})}}return s}function At(e){if(e.type==="aliased_import"){let r=e.namedChild(0),t=e.namedChild(1);return!r||!t?null:{qualifiedName:r.text,localName:t.text}}if(e.type==="dotted_name"){let r=e.text;return{qualifiedName:r,localName:r.split(".")[0]??r}}return e.type==="identifier"?{qualifiedName:e.text,localName:e.text}:null}function Dn(e){if(e.type==="dotted_name")return e.text;if(e.type==="relative_import"){let r=b(e,"import_prefix")?.text??"",t=b(e,"dotted_name")?.text??"";return`${r}${t}`}return null}function jn(e){let r=e.split(`
11
- `),t=[],n=0;for(let s=0;s<r.length;s++){let o=r[s],i=o.trimStart(),a=n;if(n+=o.length+1,!i.startsWith("import ")&&!i.startsWith("from "))continue;let c=o,p=a+o.length,l=Ie(o);for(;s+1<r.length&&(l>0||c.trimEnd().endsWith("\\"));){s++;let m=r[s];c+=`
12
- ${m}`,p+=1+m.length,l+=Ie(m),n+=m.length+1}let u=On(c);u&&t.push({...u,start:a,end:p})}return t}function On(e){let r=e.replace(/\\\s*\n/g," ").trim();if(r.startsWith("import "))return{kind:"import",module:null,clause:r.slice(7).trim()};let t=r.match(/^from\s+([.\w]+)\s+import\s+([\s\S]+)$/);if(!t)return null;let n=t[2].trim();return n.startsWith("(")&&n.endsWith(")")&&(n=n.slice(1,-1).trim()),{kind:"from",module:t[1],clause:n}}function Mn(e,r,t,n){let s=k(n,t.start,t.end),o=t.clause.replace(/\n/g," ").trim();if(t.kind==="import")return y(o).flatMap(c=>{let p=c.trim().replace(/,$/,"");if(!p)return[];let[l,u]=p.split(/\s+as\s+/),m=l.trim(),d=(u??m.split(".")[0]??m).trim(),f=J(e,r,m),$=V(s,d);return[{importedName:m,localName:d,sourcePath:f,kind:"namespace",used:x(s,d)||$.length>0,usedMembers:$}]});let i=t.module?J(e,r,t.module):null,a=[];for(let c of y(o)){let p=c.trim().replace(/,$/,"");if(!p)continue;if(p==="*"){a.push({importedName:"*",localName:null,sourcePath:i,kind:"side-effect",used:!0,usedMembers:[]});continue}let[l,u]=p.split(/\s+as\s+/),m=(u??l).trim();a.push({importedName:l.trim(),localName:m,sourcePath:i,kind:"named",used:x(s,m),usedMembers:[]})}return a}import{basename as vn}from"path";function wt(e,r,t){return _(e,r,n=>Bn(e,r,n),()=>$n(e,r,t),t)}function $n(e,r,t){return I(t,/^[ \t]*(require_relative|require)\s+["']([^"']+)["']\s*$/gm,(n,s)=>{let o=n[1],i=n[2];if(!o||!i)return[];let a=o==="require_relative"?ge(e,r,i):null;if(a){let c=kt(i);return[R(c,c,a,x(s,c))]}return[M(i,a)]})}function Bn(e,r,t){let n=S(t,new Set([])),s=[],o=new Set(["require","require_relative","load"]);for(let i of t.rootNode.descendantsOfType("call")){let a=i.namedChild(0);if(!a||a.type!=="identifier"||!o.has(a.text))continue;let p=i.namedChildren.find(d=>d.type==="argument_list")?.namedChild(0);if(!p||p.type!=="string")continue;let u=p.namedChildren.find(d=>d.type==="string_content")?.text;if(!u)continue;let m=a.text==="require_relative"?ge(e,r,u):null;if(m){let d=kt(u);s.push(g(d,d,m,n))}else s.push(M(u,m))}return s}function kt(e){return tt(vn(e).replace(/\.[^.]+$/,""),/_/)}function Dt(e,r,t){return _(e,r,n=>Un(e,r,n),()=>I(t,/^[ \t]*use\s+(.+?)\s*;$/gm,(n,s)=>{let o=n[1]?.trim();return o?qn(e,r,o,s):[]}),t)}function Un(e,r,t){let n=S(t,new Set(["use_declaration"])),s=[];for(let o of t.rootNode.descendantsOfType("use_declaration")){let i=o.namedChild(0);if(i)for(let a of re(i,"")){if(!a.importedName||a.importedName==="*")continue;let c=A(e,r,a.qualifiedName)??A(e,r,a.qualifiedName.split("::").slice(0,-1).join("::"));s.push(g(a.importedName,a.localName,c,n))}}return s}function re(e,r){switch(e.type){case"identifier":case"super":case"crate":{let t=e.text;return[{qualifiedName:de(r,t),importedName:t,localName:t}]}case"self":{let t=r.split("::").filter(Boolean).pop()??"self";return[{qualifiedName:r||"self",importedName:t,localName:t}]}case"scoped_identifier":{let t=e.text,n=t.split("::").pop()??t;return[{qualifiedName:de(r,t),importedName:n,localName:n}]}case"scoped_use_list":{let t=e.namedChild(0),n=e.namedChild(1);if(!t||!n)return[];let s=de(r,t.text),o=[];for(let i of n.namedChildren)o.push(...re(i,s));return o}case"use_list":{let t=[];for(let n of e.namedChildren)t.push(...re(n,r));return t}case"use_as_clause":{let t=e.namedChild(0),n=e.namedChild(1);if(!t||!n)return[];let s=re(t,r),o=n.text;return s.map(i=>({...i,localName:o}))}case"use_wildcard":{let t=e.namedChild(0),n=t?t.text:"";return[{qualifiedName:de(r,`${n}::*`),importedName:"*",localName:"*"}]}default:return[]}}function de(e,r){return e?r?`${e}::${r}`:e:r}function qn(e,r,t,n){let s=t.trim();if(s.includes("{")&&s.includes("}")){let l=s.slice(0,s.indexOf("{")).replace(/::$/,"").trim(),u=s.slice(s.indexOf("{")+1,s.lastIndexOf("}")).trim();return y(u).flatMap(m=>{let d=m.trim();if(!d)return[];if(d==="self"){let fe=l.split("::").filter(Boolean).pop();return fe?[T(e,r,n,l,fe,fe)]:[]}let[f,$]=d.split(/\s+as\s+/),B=f?.trim();if(!B)return[];let Bt=($??B.split("::").pop()??B).trim(),Ut=`${l}::${B}`.replace(/::::/g,"::");return[T(e,r,n,Ut,B.split("::").pop()??B,Bt,A(e,r,l))]})}let[o,i]=s.split(/\s+as\s+/),a=o?.trim()??s,c=(i??a.split("::").pop()??a).trim(),p=A(e,r,a)??A(e,r,a.split("::").slice(0,-1).join("::"));return[T(e,r,n,a,a.split("::").pop()??a,c,p)]}function jt(e,r,t){let n=j(e,r);if(n)return Vn(e,r,n);let s=[];for(let o of t.matchAll(/^[ \t]*pub\s+use\s+(.+?)\s*;$/gm)){let i=o[1]?.trim();i&&s.push(...Wn(e,r,i))}return s}function Vn(e,r,t){let n=[];for(let s of t.rootNode.descendantsOfType("use_declaration")){if(!zn(s))continue;let o=s.namedChildren.find(i=>i.type!=="visibility_modifier");if(o)for(let i of re(o,""))i.importedName&&n.push(Me(e,r,i.qualifiedName))}return n}function zn(e){for(let r of e.children)if(r.type==="visibility_modifier"&&r.text.startsWith("pub"))return!0;return!1}function Wn(e,r,t){let n=t.trim();if(n.includes("{")&&n.includes("}")){let s=n.slice(0,n.indexOf("{")).replace(/::$/,"").trim(),o=n.slice(n.indexOf("{")+1,n.lastIndexOf("}")).trim();return y(o).flatMap(i=>{let a=i.trim();if(!a||a==="self")return[];let[c]=a.split(/\s+as\s+/),p=`${s}::${c?.trim()??a}`.replace(/::::/g,"::");return[Me(e,r,p)]})}return[Me(e,r,n)]}function Me(e,r,t){return{specifier:t,sourcePath:A(e,r,t)??A(e,r,t.split("::").slice(0,-1).join("::"))}}function D({language:e,extensions:r,imports:t,parseImports:n}){return{language:e,extensions:r,capabilities:{imports:t},parseImports:n}}function Ot(e,r){let t=r.toLowerCase();for(let n of e)for(let s of n.extensions)if(t.endsWith(s))return n;return null}var Hn={language:"javascript",extensions:qe,capabilities:{imports:"ast-with-regex-fallback",reExports:"ast-with-regex-fallback"},parseImports:je,parseReExports:Oe},Kn=D({language:"python",extensions:Ve,imports:"ast-with-regex-fallback",parseImports:Lt}),Jn=D({language:"jvm",extensions:P,imports:"ast-dispatch-with-regex-fallback",parseImports:Et}),Xn={language:"rust",extensions:ze,capabilities:{imports:"ast-with-regex-fallback",exports:"ast-with-regex-fallback"},parseImports:Dt,parseExports:jt},Yn=D({language:"ruby",extensions:We,imports:"ast-with-regex-fallback",parseImports:wt}),Gn=D({language:"c/cpp",extensions:He,imports:"ast-with-regex-fallback",parseImports:yt}),Qn=D({language:"dotnet",extensions:q,imports:"ast-dispatch-with-regex-fallback",parseImports:Ct}),Zn={language:"dart",extensions:Ke,capabilities:{imports:"regex-only",exports:"regex-only"},parseImports:It,parseExports:_t},es=D({language:"php",extensions:K,imports:"ast-with-regex-fallback",parseImports:Ft}),ts=D({language:"clojure",extensions:Je,imports:"regex-only",parseImports:Nt}),rs=[Hn,Kn,Jn,Xn,Yn,Gn,Qn,Zn,es,ts];function ne(e){return Ot(rs,e)}var ve={clearGroups:["whole-project","source-file"]},ns=U("source-imports",ve),ss=U("source-exports",ve),os=U("source-reexports",ve),Mt=X({kind:"source-imports",invalidation:Y("source-imports"),serialize:as,deserialize:cs}),vt=X({kind:"source-reexports",invalidation:Y("source-reexports"),serialize:ls,deserialize:ps});function Li(e,r){let t=W(r);return os.get(e,t,()=>{let n=ne(t);if(!n?.parseReExports)return[];let s=L(e,t);if(!s)return[];let o=H(e,t,s),i=xe(e),a=vt.read(e,t,o);if(a?.resolutionFingerprint===i)return a.reExports;let c=n.parseReExports(e,t,s);return vt.write(e,t,o,{resolutionFingerprint:i,reExports:c}),c})}function is(e,r){let t=W(r);return ns.get(e,t,()=>{let n=ne(t);if(!n)return[];let s=L(e,t);return s?$t(e,t,s,n):[]})}function wi(e,r){let t=W(r),n=ne(t);if(!n)return[];let s;try{s=$e(e.config.projectRoot,t,{inputKind:"indexed source file"})}catch(o){if(Be(o))return[];throw o}return $t(e,t,s,n)}function $t(e,r,t,n){let s=H(e,r,t),o=xe(e),i=Mt.read(e,r,s);if(i?.resolutionFingerprint===o)return i.imports;let a=n.parseImports(e,r,t);return Mt.write(e,r,s,{parserVersion:2,resolutionFingerprint:o,imports:a}),a}function ki(e,r,t){let n=is(e,r).filter(s=>s.kind==="named"&&s.isTypeOnly!==!0&&s.localName===t&&s.sourcePath!==null);return n.length===1?n[0]:null}function Di(e,r){let t=W(r);return ss.get(e,t,()=>{let n=ne(t);if(!n?.parseExports)return[];let s=L(e,t);return s?n.parseExports(e,t,s):[]})}function as(e){return JSON.stringify(e)}function cs(e){try{let r=JSON.parse(e);return!ye(r)||r.parserVersion!==2||typeof r.resolutionFingerprint!="string"||!Array.isArray(r.imports)?null:{parserVersion:2,resolutionFingerprint:r.resolutionFingerprint,imports:r.imports}}catch{return null}}function ls(e){return JSON.stringify(e)}function ps(e){try{let r=JSON.parse(e);return!ye(r)||typeof r.resolutionFingerprint!="string"||!Array.isArray(r.reExports)?null:{resolutionFingerprint:r.resolutionFingerprint,reExports:r.reExports}}catch{return null}}export{O as a,qt as b,gs as c,Ss as d,Ie as e,zt as f,it as g,Jt as h,at as i,Xt as j,Ce as k,Yt as l,ct as m,E as n,Nr as o,Tr as p,Er as q,Lr as r,wr as s,kr as t,Dr as u,jr as v,de as w,Li as x,is as y,wi as z,ki as A,Di as B};
13
- //# sourceMappingURL=chunk-ODDUPDP7.js.map
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
- import{B as te,C as Ee}from"./chunk-NOYBFVJA.js";import{C as K,Fe as re,Ge as Ae,H as Re,He as ne,Ie as Pe,J as Ie,Je as xe,Ke as ie,M as Q,Md as S,Nd as We,Od as L,Pd as X,Qd as M,Wa as ke,Wd as k,X as Y,Xd as G,Y as C,Z as be,aa as w,ba as Ce,ca as we,ha as A,if as Te,jf as qe,ke as Z,le as ee,me as R,ne as $,oe as j,tf as _e,u as v,ya as P}from"./chunk-66DVSJQG.js";import{spawn as Tt}from"child_process";import{existsSync as qt,rmSync as Ue}from"fs";import{dirname as _t,resolve as z}from"path";import{fileURLToPath as Dt}from"url";import{createHash as gt,randomUUID as oe}from"crypto";import{existsSync as vt,linkSync as St,readdirSync as Rt,rmSync as W}from"fs";import{basename as It,dirname as bt,join as m}from"path";var I=1,Ct=10*6e4,wt=10080*6e4,F="requests",x="claims",N="completions",Oe="staging";function Le(e,t,r={}){let n=r.now?.()??new Date,i=Et(r.ttlMs),o=At(r.idempotencyKey),a=o?`key-${gt("sha256").update(o).digest("hex")}`:`request-${(r.randomId??oe)()}`,s={version:I,requestId:a,...o?{idempotencyKey:o}:{},createdAt:n.toISOString(),deadlineAt:new Date(n.getTime()+i).toISOString(),detail:t.trim().slice(0,2048)||"stale index observed by a command"},c=Fe(e,a),d=ae(e,c,s,r.onStage);if(d.published)return{disposition:"accepted",request:s,achievedDurability:d.achievedDurability,directorySync:d.directorySync};let l=se(c);if(!l)throw new Error(`Watch refresh request identity ${a} exists but is malformed.`);return{disposition:"duplicate",request:l}}function sr(e,t={}){let r=t.now?.()??new Date,n=`claim-${(t.randomId??oe)()}`,i=Math.max(1,Math.floor(t.limit??64)),o=$e(e).sort(Pt),a=[];for(let s of o){if(a.length>=i)break;if(De(e,s.requestId))continue;if(Date.parse(s.deadlineAt)<=r.getTime()){Ge(e,{version:I,requestId:s.requestId,outcome:"expired",completedAt:r.toISOString()});continue}let c={version:I,requestId:s.requestId,claimId:n,claimedAt:r.toISOString()};if(ae(e,He(e,s.requestId),c).published){if(De(e,s.requestId)){je(e,s.requestId,n);continue}a.push(s)}}return{claimId:n,requests:a}}function ar(e,t,r=()=>new Date,n){let i=r().toISOString();for(let o of t.requests)Ge(e,{version:I,requestId:o.requestId,claimId:t.claimId,outcome:"completed",completedAt:i});n?.("after-completion"),kt(e,t),n?.("after-claim-release")}function kt(e,t){for(let r of t.requests)je(e,r.requestId,t.claimId)}function cr(e){let t=0;for(let r of b(m(e,x)))W(r,{force:!0}),t++;return t>0&&C(m(e,x)),Ne(e),t}function dr(e){let t=$e(e),r=new Map,n=Wt(m(e,F),se);for(let c of b(m(e,N))){let d=H(c);if(!d){n++;continue}r.set(d.requestId,d)}let i=new Set;for(let c of b(m(e,x))){let d=Me(c);if(!d){n++;continue}i.add(d.requestId)}let o=t.filter(c=>!r.has(c.requestId)&&!i.has(c.requestId)),a=[...r.values()].filter(c=>c.outcome==="completed").length,s=[...r.values()].filter(c=>c.outcome==="expired").length;return{pending:o.length,claimed:t.filter(c=>!r.has(c.requestId)&&i.has(c.requestId)).length,completed:a,expired:s,invalid:n,...o.length>0?{oldestPendingAt:o.map(c=>c.createdAt).reduce((c,d)=>xt(c,d))}:{}}}function lr(e,t={}){let r=(t.now?.()??new Date).getTime(),n=Math.max(0,t.retentionMs??wt),i=0;for(let o of b(m(e,N))){let a=H(o);!a||r-Date.parse(a.completedAt)<n||(W(o,{force:!0}),W(Fe(e,a.requestId),{force:!0}),i++)}return i>0&&(C(m(e,N)),C(m(e,F))),Ne(e),i}function se(e){return ce(e,t=>{let r=t;return r.version===I&&T(r.requestId)&&(r.idempotencyKey===void 0||typeof r.idempotencyKey=="string")&&P(r.createdAt)&&P(r.deadlineAt)&&Date.parse(r.deadlineAt)>=Date.parse(r.createdAt)&&typeof r.detail=="string"&&r.detail.length>0})}function Me(e){return ce(e,t=>{let r=t;return r.version===I&&T(r.requestId)&&T(r.claimId)&&P(r.claimedAt)})}function H(e){return ce(e,t=>{let r=t;return r.version===I&&T(r.requestId)&&(r.claimId===void 0||T(r.claimId))&&(r.outcome==="completed"||r.outcome==="expired")&&P(r.completedAt)})}function Ge(e,t){let r=Ve(e,t.requestId);if(ae(e,r,t).published)return;let n=H(r);if(!n||n.requestId!==t.requestId||n.outcome!==t.outcome)throw new Error(`Watch refresh completion ${t.requestId} conflicts with an existing record.`)}function ae(e,t,r,n){let i=m(e,Oe),o=bt(t),a=Y(i),s=Y(o),c=m(i,`${It(t)}.${process.pid}.${oe()}.tmp`);try{let d=G(c,r,{spacing:2,trailingNewline:!0});n?.("after-staged");try{St(c,t)}catch(u){if(u.code==="EEXIST")return{published:!1};throw u}let l=be(a,s,d.directorySync,C(o));return n?.("after-published"),{published:!0,achievedDurability:l==="synced"?"directory-durable":"file-flushed",directorySync:l}}finally{W(c,{force:!0})}}function $e(e){let t=[];for(let r of b(m(e,F))){let n=se(r);n&&t.push(n)}return t}function je(e,t,r){let n=He(e,t),i=Me(n);!i||i.claimId!==r||(W(n,{force:!0}),C(m(e,x)))}function Ne(e){for(let t of b(m(e,Oe),".tmp"))W(t,{force:!0})}function Wt(e,t){return b(e).filter(r=>!t(r)).length}function b(e,t=".json"){return vt(e)?Rt(e,{withFileTypes:!0}).filter(r=>r.isFile()&&r.name.endsWith(t)).map(r=>m(e,r.name)).sort():[]}function ce(e,t){try{let r=JSON.parse(v(e,"watch refresh request record"));return t(r)?r:null}catch{return null}}function Fe(e,t){return m(e,F,`${t}.json`)}function He(e,t){return m(e,x,`${t}.json`)}function Ve(e,t){return m(e,N,`${t}.json`)}function De(e,t){return H(Ve(e,t))!==null}function Et(e){if(e===void 0)return Ct;if(!Number.isFinite(e)||e<=0)throw new Error("Watch refresh request ttlMs must be positive.");return Math.floor(e)}function At(e){let t=e?.trim();return t?t.slice(0,512):void 0}function T(e){return typeof e=="string"&&/^[a-z0-9][a-z0-9-]{0,127}$/i.test(e)}function Pt(e,t){return Date.parse(e.createdAt)-Date.parse(t.createdAt)||e.requestId.localeCompare(t.requestId)}function xt(e,t){return Date.parse(t)<Date.parse(e)?t:e}var Be=5e3,Ot=6e3,Lt=1e3,le=10,Mt=new Set(["capabilities","check-deps","config-validate","continue","doctor","init","install-skills","reindex","setup","setup-agent","status","suppress","uninstall","watch"]);function xr(e){let t=e.classification;if(t.kind!=="live")return;let{state:r}=t;return r.watcher.state==="idle"&&r.lastError===void 0?r.indexGeneration:void 0}function Gt(e,t=process.env){return t.SCIP_QUERY_SKIP_WATCH_SERVICE!=="1"&&!e.startsWith("__")&&!Mt.has(e)}function Tr(e){let t=e.env??process.env;if(t.SCIP_QUERY_SKIP_WATCH_SERVICE==="1")return{kind:"skipped",reason:"environment"};if(!Gt(e.commandName,t))return{kind:"skipped",reason:"excluded-command"};if(e.config.watch?.enabled!==!0)return{kind:"skipped",reason:"disabled"};if(e.config.watch.autoStart===!1)return{kind:"skipped",reason:"auto-start-disabled"};try{let r=$t({projectRoot:e.projectRoot,cacheDir:e.cacheDir,cliVersion:e.cliVersion,gitContext:e.gitContext,runtime:e.runtime});return{kind:r.disposition,state:r.state}}catch(r){return{kind:"failed",message:r instanceof Error?r.message:String(r)}}}function Qe(e,t,r){let n=Q(z(e));if(r&&Q(r.projectRoot)===n)return{projectRoot:n,worktreeKind:"git",worktreeId:r.worktreeId,cliVersion:t};let i=Re(n);if(i.kind==="error")throw new Error(`Could not establish Git worktree identity for ${n}: ${i.message}`);return i.kind==="non-git"?{projectRoot:n,worktreeKind:"non-git",cliVersion:t}:{projectRoot:n,worktreeKind:"git",worktreeId:i.identity.worktreeId,cliVersion:t}}function qr(e){return U(e,Qe(e.projectRoot,e.cliVersion,e.gitContext))}function U(e,t){let r=e.runtime??fe,n=R(e.cacheDir),i=$(n.statePath),o=he(n.lockPath);return{identity:t,classification:jt(i,t,r.now(),r.isProcessAlive),lock:o,lockIsLive:o!==null&&r.isProcessAlive(o.pid),paths:n}}function $t(e){let t=e.runtime??fe,r=Qe(e.projectRoot,e.cliVersion,e.gitContext),n=U(e,r),i=ue("ensure",n.classification);if(i.kind==="reuse")return V(n.paths.activityPath,t),{disposition:"reused",state:i.state};if(i.kind==="refuse-replace")throw new Error(`scip-query watch service pid ${i.state.pid} is still alive but its heartbeat is old. Refusing automatic replacement because civil-clock age alone cannot authorize a process signal.`);if(i.kind==="replace")pe(i.state,e,t),q(n.paths,i.state.pid,t);else if(i.kind==="start"){if(n.lockIsLive){let s=ze(e,r,t,Math.min(e.startupTimeoutMs??1e3,1e3));if(s)return V(n.paths.activityPath,t),{disposition:"reused",state:s};throw new Error(`scip-query watch is already running for ${z(e.projectRoot)} (pid ${n.lock?.pid}; lock: ${n.paths.lockPath}) without compatible daemon state. Stop the foreground watcher before starting the service.`)}n.classification.kind==="stale"&&q(n.paths,n.classification.state.pid,t)}else throw new Error(`Unexpected ensure action: ${i.kind}`);if(n=U(e,r),i=ue("ensure",n.classification),i.kind==="reuse")return V(n.paths.activityPath,t),{disposition:"reused",state:i.state};if(i.kind==="refuse-replace")throw new Error(`scip-query watch service pid ${i.state.pid} remains alive with an old heartbeat; automatic replacement is not authorized.`);let o=e.serverPath??Dt(new URL("./watch-server.js",import.meta.url));t.spawnServer(o,r.projectRoot,e.cliVersion,e.watchOverrides??{});let a=ze(e,r,t,e.startupTimeoutMs??Be);if(!a)throw new Error(`scip-query watch service did not become ready within ${e.startupTimeoutMs??Be}ms.`);return V(n.paths.activityPath,t),{disposition:"started",state:a}}function Ye(e){let t=e.runtime??fe,r=R(e.cacheDir),n=$(r.statePath),i=n?Je(n,t)?{kind:"live",state:n}:{kind:"stale",state:n,reason:"dead-process"}:{kind:"stopped"},o=ue("stop",i);if(o.kind==="signal-stop")return pe(o.state,e,t),q(r,o.state.pid,t),{disposition:"stopped",pid:o.state.pid};if(o.kind==="clean-stale")return q(r,o.state.pid,t),{disposition:"stopped",pid:o.state.pid};let a=he(r.lockPath);return o.kind==="already-stopped"&&a?(Je(a,t)&&pe(a,e,t),q(r,a.pid,t),{disposition:"stopped",pid:a.pid}):{disposition:"already-stopped"}}function _r(e,t,r={}){let{durability:n="durable",...i}=r;n==="durable"?G(e,t,i):k(e,t,i)}function Xe(e,t=Date.now()){k(e,{version:1,at:new Date(t).toISOString()})}function Dr(e,t,r=Date.now(),n={}){Le(R(_t(e)).refreshRequestsPath,t,{...n,now:()=>new Date(r)}),Xe(e,r)}function Or(e){try{let t=JSON.parse(v(e,"watch activity record"));return t.version!==1||!j(t.at)||t.refreshRequestedAt!==void 0&&!j(t.refreshRequestedAt)||t.refreshDetail!==void 0&&typeof t.refreshDetail!="string"?null:{atMs:Date.parse(t.at),...t.refreshRequestedAt===void 0?{}:{refreshRequestedAtMs:Date.parse(t.refreshRequestedAt)},...t.refreshDetail===void 0?{}:{refreshDetail:t.refreshDetail}}}catch{return null}}function Lr(e,t,r={}){let n=r.pid??process.pid,i=r.isProcessAlive??S,o=()=>{},a=r.readProcessIdentity??X,s=r.now??(()=>new Date),c={...re,wallNow:()=>s().getTime(),isProcessAlive:i,readProcessIdentity:a},d=Ae(e,{kind:"watch",pid:n,processIdentity:a(n),detail:{projectRoot:z(t)},parseLegacy:B,runtime:c});if(d.kind==="contended"){let l=Ze(d.observation);return{acquired:!1,lockPath:e,message:Nt(e,t,l),release:o}}return{acquired:!0,lockPath:e,message:"",release:()=>{d.lock.release()}}}function he(e){return Ze(ne(e,{parseLegacy:B}))}var B=e=>{let t=et(e);return t?{pid:t.pid,...t.processIdentity?{processIdentity:t.processIdentity}:{}}:null};function Ze(e){if(e.state==="valid"&&e.record?.kind==="watch"){let t=e.record.detail?.projectRoot;return typeof t!="string"?null:{version:1,pid:e.record.pid,...e.record.processIdentity?{processIdentity:e.record.processIdentity}:{},projectRoot:t,startedAt:e.record.startedAt}}return et(e.parsed)}function et(e){try{let t=e;if(t.version!==1||typeof t.pid!="number"||!Number.isInteger(t.pid)||t.pid<=0||typeof t.projectRoot!="string"||!j(t.startedAt))return null;let r=t.processIdentity===void 0?null:We(t.processIdentity);return t.processIdentity!==void 0&&(!r||r.pid!==t.pid)?null:{version:1,pid:t.pid,...r?{processIdentity:r}:{},projectRoot:t.projectRoot,startedAt:t.startedAt}}catch{return null}}function jt(e,t,r,n){if(!e)return{kind:"stopped"};if(e.protocolVersion!==Z)return{kind:"incompatible",state:e,reason:"protocol"};if(e.projectRoot!==t.projectRoot)return{kind:"incompatible",state:e,reason:"project"};let i=t.worktreeKind==="git"?t.worktreeId:void 0;if(e.worktreeId!==i)return{kind:"incompatible",state:e,reason:"worktree"};if(e.cliVersion!==t.cliVersion)return{kind:"incompatible",state:e,reason:"cli-version"};if(!n(e.pid))return{kind:"stale",state:e,reason:"dead-process"};let o=Date.parse(e.heartbeatAt);return r-o>ee?{kind:"stale",state:e,reason:"old-heartbeat"}:{kind:"live",state:e}}function ue(e,t){switch(e){case"status":return{kind:"report",classification:t};case"ensure":switch(t.kind){case"stopped":return{kind:"start"};case"stale":return t.reason==="old-heartbeat"?{kind:"refuse-replace",state:t.state,reason:"old-heartbeat"}:{kind:"start"};case"live":return{kind:"reuse",state:t.state};case"incompatible":return{kind:"replace",state:t.state};default:return de(t)}case"stop":switch(t.kind){case"stopped":return{kind:"already-stopped"};case"stale":return t.reason==="old-heartbeat"?{kind:"signal-stop",state:t.state}:{kind:"clean-stale",state:t.state};case"live":case"incompatible":return{kind:"signal-stop",state:t.state};default:return de(t)}default:return de(e)}}function Mr(e){return e.idleTimeoutMs===0||e.watcher.state!=="idle"?!1:e.nowMs-e.lastActivityAtMs>=e.idleTimeoutMs}function ze(e,t,r,n){let i=r.monotonicNow??M,o=i()+n;for(;i()<=o;){let a=U(e,t).classification;if(a.kind==="live")return a.state;r.sleep(le)}return null}function pe(e,t,r){let{pid:n}=e;if(!r.isProcessAlive(n))return;Ke(e,r),r.signalProcess(n);let i=t.stopTimeoutMs??Ot,o=r.monotonicNow??M,a=o()+i;for(;o()<=a;){if(!r.isProcessAlive(n))return;r.sleep(le)}if(!r.forceSignalProcess)throw new Error(`scip-query watch service pid ${n} did not stop within ${i}ms and forced termination is unavailable.`);Ke(e,r),r.forceSignalProcess(n);let s=t.forceStopTimeoutMs??Lt,c=o()+s;for(;o()<=c;){if(!r.isProcessAlive(n))return;let d=r.readProcessIdentity(n);if(e.processIdentity&&d&&!L(e.processIdentity,d))return;r.sleep(le)}throw new Error(`scip-query watch service pid ${n} remained alive ${s}ms after forced termination.`)}function q(e,t,r){if(Ue(e.statePath,{force:!0}),Ue(e.activityPath,{force:!0}),he(e.lockPath)?.pid===t){let i={...re,wallNow:r.now,isProcessAlive:r.isProcessAlive,readProcessIdentity:r.readProcessIdentity},o=ne(e.lockPath,{parseLegacy:B,runtime:i});Pe(e.lockPath,o,{parseLegacy:B,runtime:i})}}function Je(e,t){if(!t.isProcessAlive(e.pid))return!1;if(!e.processIdentity)return!0;let r=t.readProcessIdentity(e.pid);return r===null||L(e.processIdentity,r)}function Nt(e,t,r){return`error: scip-query watch is already running for ${z(t)}${r?` (pid ${r.pid}, started ${r.startedAt}; lock: ${e})`:` (lock: ${e})`}. Stop that watcher before starting another.`}function V(e,t){try{(t.recordActivity??Xe)(e,t.now())}catch(r){let n=Ft(r);if(n!=="EPERM"&&n!=="EACCES"&&n!=="EROFS")throw r}}function Ft(e){return e.code}var fe={now:Date.now,monotonicNow:M,isProcessAlive:S,readProcessIdentity:X,spawnServer(e,t,r,n){if(!qt(e))throw new Error(`Watch service helper was not found at ${e}. Run npm run build first.`);Tt(process.execPath,[e,t,r,JSON.stringify(n)],{detached:!0,stdio:"ignore",env:{...process.env,SCIP_QUERY_SKIP_WATCH_SERVICE:"1"}}).unref()},signalProcess(e){process.kill(e,"SIGTERM")},forceSignalProcess(e){process.kill(e,"SIGKILL")},sleep(e){let t=new Int32Array(new SharedArrayBuffer(4));Atomics.wait(t,0,0,e)}};function Ke(e,t){if(!e.processIdentity)throw new Error(`Refusing to signal scip-query watch pid ${e.pid}: its ownership record has no process identity.`);let r=t.readProcessIdentity(e.pid);if(!r)throw new Error(`Refusing to signal scip-query watch pid ${e.pid}: its process identity is unavailable.`);if(!L(e.processIdentity,r))throw new Error(`Refusing to signal scip-query watch pid ${e.pid}: its process identity does not match the ownership record.`)}function de(e){throw new Error(`Unhandled watch service value: ${JSON.stringify(e)}`)}import{existsSync as J,lstatSync as _,readdirSync as nt,realpathSync as tt,rmSync as E,statSync as it}from"fs";import{join as p,resolve as D,sep as ot}from"path";var Ht=3600*1e3,Vt=2*1024*1024*1024,st=300*1e3,Ut="gc-state.json",Bt="gc.lock";function zt(e){let t=e.leases.filter(s=>s.managed&&!s.live&&!s.busy),r=at(e.leases,e.locks),n={};for(let s of e.generations)r.has(s.generationId)||(n[s.generationId]=s.unreferencedAt??e.nowMs);let i=e.generations.filter(s=>!r.has(s.generationId)).sort((s,c)=>n[s.generationId]-n[c.generationId]||s.generationId.localeCompare(c.generationId)),o=new Set;for(let s of i)e.nowMs-n[s.generationId]>=e.policy.generationTtlMs&&o.add(s.generationId);let a=e.generations.filter(s=>!o.has(s.generationId)).reduce((s,c)=>s+c.size,0);for(let s of i){if(a<=e.policy.budgetBytes)break;o.has(s.generationId)||(o.add(s.generationId),a-=s.size)}for(let s of o)delete n[s];return{deleteWorktrees:t,deleteGenerations:e.generations.filter(s=>o.has(s.generationId)),deleteLocks:e.locks.filter(s=>!s.live),deleteTemporaries:e.temporaries.filter(s=>!s.live),protectedGenerationIds:[...r].sort(),unreferencedSince:n}}function at(e,t){let r=new Set(e.filter(n=>n.managed&&(n.live||n.busy)).flatMap(n=>[n.lease.baseGenerationId,n.lease.activeGenerationId]).filter(n=>n!==void 0));for(let n of t)n.live&&r.add(n.generationId);return r}function Xr(e,t,r={}){if(!we())return{kind:"disabled"};let n=r.repositoryId===void 0?K(e)?.repositoryId:r.repositoryId;if(!n)return{kind:"unavailable"};let i=p(w(),"repositories",n),o=(r.now??Date.now)(),a=J(i)?ct(e,i,n,t,o,r):{kind:"unavailable"};return Jt(e,n,t,o,r),a}function ct(e,t,r,n,i,o){let a=p(t,"gc-state.json"),s=lt(a);if(!o.force&&s&&i-Date.parse(s.lastSweepAt)<st)return{kind:"throttled",sweptAt:s.lastSweepAt};let c=xe(t,{now:()=>i});if(!c)return{kind:"busy"};try{let d=dt(e,t,r,s?.unreferencedSince??{}),l=zt({nowMs:i,...d,policy:{generationTtlMs:o.policy?.generationTtlMs??Ht,budgetBytes:o.policy?.budgetBytes??Vt}}),u=0,f=0;for(let h of l.deleteWorktrees){if(!ge(h.lease))continue;if(!J(h.lease.localCacheDir)){E(h.leasePath,{force:!0}),f+=1;continue}if(!Qt(h.lease))continue;let Se=ie(p(h.lease.localCacheDir,"cache-lifecycle.lock"));if(Se)try{if(me(h.lease,!0))continue;try{Ye({projectRoot:h.lease.projectRoot,cacheDir:h.lease.localCacheDir,cliVersion:n})}catch{continue}if(me(h.lease,!0))continue;E(h.lease.localCacheDir,{recursive:!0,force:!0}),E(h.leasePath,{force:!0}),f+=1}finally{Se.release()}}for(let h of l.deleteLocks)E(h.path,{force:!0});for(let h of l.deleteTemporaries)E(h.path,{recursive:!0,force:!0});for(let h of l.deleteGenerations)E(h.path,{recursive:!0,force:!0}),u+=h.size;ke(p(t,"evidence.db"));let g={kind:"swept",sweptAt:new Date(i).toISOString(),deletedWorktrees:f,deletedGenerations:l.deleteGenerations.length,deletedBytes:u,protectedGenerations:l.protectedGenerationIds.length},y={version:1,lastSweepAt:g.sweptAt,unreferencedSince:l.unreferencedSince,lastResult:g};return k(a,y,{spacing:2,trailingNewline:!0}),g}catch(d){return{kind:"failed",error:d instanceof Error?d.message:String(d)}}finally{c.release()}}function Jt(e,t,r,n,i){let o=p(w(),"repositories");if(!J(o))return;let a=p(o,Ut),s=Xt(a);if(!i.force&&s!==void 0&&n-s<st)return;let c=ie(p(o,Bt));if(c)try{for(let d of O(o)){if(d===t||!/^[a-f0-9]{24}$/.test(d))continue;let l=p(o,d),u;try{u=_(l)}catch{continue}if(!u.isDirectory()||u.isSymbolicLink())continue;let f=Yt(l)??e;ct(f,l,d,r,n,i)}k(a,{version:1,lastSweepAt:new Date(n).toISOString()},{spacing:2,trailingNewline:!0})}finally{c.release()}}function Zr(e,t,r){let n=Te(e,r.dbPath,t);if(n)return{state:"bypassed",reason:n,localCacheDir:r.cacheDir,generations:0,generationBytes:0,protectedGenerations:0,unreferencedGenerations:0,unreferencedBytes:0,temporaryGenerations:0,sharedEvidence:{exists:!1,bytes:0}};let i=K(e);if(!i)return{state:"unavailable",reason:"Git worktree identity is unavailable",localCacheDir:r.cacheDir,generations:0,generationBytes:0,protectedGenerations:0,unreferencedGenerations:0,unreferencedBytes:0,temporaryGenerations:0,sharedEvidence:{exists:!1,bytes:0}};let o=p(w(),"repositories",i.repositoryId),a=ve(p(o,"worktrees",`${i.worktreeId}.json`)),s=lt(p(o,"gc-state.json")),c=dt(e,o,i.repositoryId,s?.unreferencedSince??{}),d=at(c.leases,c.locks),l=c.generations.filter(y=>!d.has(y.generationId)),u=c.generations.reduce((y,h)=>y+h.size,0),f=qe(e,t),g=0;return f&&(g=Kt(f)),{state:"managed",repositoryId:i.repositoryId,worktreeId:i.worktreeId,localCacheDir:r.cacheDir,...a?{baseGenerationId:a.baseGenerationId,activeGenerationId:a.activeGenerationId,lastAction:a.lastAction,reason:a.lastReason,lastSeenAt:a.lastSeenAt}:{},generations:c.generations.length,generationBytes:u,protectedGenerations:c.generations.filter(y=>d.has(y.generationId)).length,unreferencedGenerations:l.length,unreferencedBytes:l.reduce((y,h)=>y+h.size,0),temporaryGenerations:c.temporaries.length,sharedEvidence:{path:f,exists:g>0,bytes:g},cleanup:s?.lastResult}}function Kt(e){return[e,`${e}-wal`,`${e}-shm`].reduce((t,r)=>{try{return t+it(r).size}catch{return t}},0)}function dt(e,t,r,n){let i=new Set(Ie(e).map(d=>D(d.path))),o=[];for(let d of O(p(t,"worktrees"))){if(!d.endsWith(".json"))continue;let l=p(t,"worktrees",d),u=ve(l);if(!u)continue;let f=D(u.projectRoot);o.push({leasePath:l,lease:u,managed:u.repositoryId===r&&ge(u),live:i.has(f)||J(f),busy:me(u)})}let a=[];for(let d of O(p(t,"locks"))){let l=/^([a-f0-9]{64})\.lock$/.exec(d);if(!l)continue;let u=p(t,"locks",d),f=ye(u),g=f!==void 0&&S(f),y=l[1];a.push({generationId:y,path:u,live:g})}let s=[],c=[];for(let d of O(p(t,"generations"))){let l=/^\.tmp-(\d+)-/.exec(d);if(l){let g=p(t,"generations",d),y=Number(l[1]);try{c.push({path:g,size:rt(g),live:Number.isSafeInteger(y)&&S(y)})}catch{}continue}if(!/^[a-f0-9]{64}$/.test(d))continue;let u=p(t,"generations",d),f;try{f=_(u)}catch{continue}!f.isDirectory()||f.isSymbolicLink()||s.push({generationId:d,path:u,size:rt(u),...n[d]===void 0?{}:{unreferencedAt:n[d]}})}return{leases:o,generations:s,locks:a,temporaries:c}}function ge(e){if(e.ownershipChecksum!==_e(e)||A(e.localCacheDir)!==A(Ce(e.projectRoot)))return!1;let t=A(p(w(),"projects"));return A(e.localCacheDir).startsWith(`${t}${ot}`)}function Qt(e){if(!ge(e))return!1;let t=D(w()),r=D(p(t,"projects")),n=D(e.localCacheDir);try{let i=_(t),o=_(r),a=_(n);if(!i.isDirectory()||i.isSymbolicLink()||!o.isDirectory()||o.isSymbolicLink()||!a.isDirectory()||a.isSymbolicLink())return!1;let s=tt(r);return tt(n).startsWith(`${s}${ot}`)}catch{return!1}}function Yt(e){for(let t of O(p(e,"worktrees"))){if(!t.endsWith(".json"))continue;let r=ve(p(e,"worktrees",t));if(r)return r.projectRoot}}function me(e,t=!1){for(let n of t?["index.lock"]:["index.lock","cache-lifecycle.lock"]){let i=ye(p(e.localCacheDir,n));if(i!==void 0&&S(i))return!0}let r=ye(R(e.localCacheDir).lockPath);return r!==void 0&&S(r)}function ve(e){try{let t=JSON.parse(v(e,"worktree cache lease"));return t.version!==1||typeof t.repositoryId!="string"||typeof t.worktreeId!="string"||typeof t.projectRoot!="string"||t.treeOid!==void 0&&typeof t.treeOid!="string"||typeof t.localCacheDir!="string"||t.baseGenerationId!==void 0&&typeof t.baseGenerationId!="string"||t.activeGenerationId!==void 0&&typeof t.activeGenerationId!="string"||typeof t.ownershipChecksum!="string"||!/^[a-f0-9]{64}$/.test(t.ownershipChecksum)||typeof t.lastAction!="string"||t.lastReason!==void 0&&typeof t.lastReason!="string"||typeof t.lastSeenAt!="string"?null:t}catch{return null}}function ye(e){try{let t=JSON.parse(v(e,"watch lock record"));return typeof t.pid=="number"&&Number.isSafeInteger(t.pid)&&t.pid>0?t.pid:void 0}catch{return}}function lt(e){try{let t=JSON.parse(v(e,"repository cache GC state"));return t.version!==1||typeof t.lastSweepAt!="string"||!Number.isFinite(Date.parse(t.lastSweepAt))||!t.unreferencedSince||typeof t.unreferencedSince!="object"||!t.lastResult?null:t}catch{return null}}function Xt(e){try{let t=JSON.parse(v(e,"global repository cache GC state"));if(t.version!==1||typeof t.lastSweepAt!="string")return;let r=Date.parse(t.lastSweepAt);return Number.isFinite(r)?r:void 0}catch{return}}function O(e){try{return nt(e)}catch{return[]}}function rt(e){let t=0,r=[e];for(;r.length>0;){let n=r.pop();for(let i of nt(n,{withFileTypes:!0})){let o=p(n,i.name);i.isDirectory()?r.push(o):i.isFile()&&(t+=it(o).size)}}return t}var ut=[{question:"Who can call or reach this?",family:"execution",direction:"incoming"},{question:"What can this call or reach?",family:"execution",direction:"outgoing"},{question:"Where can this value come from?",family:"dataflow",direction:"incoming"},{question:"Where can this value go?",family:"dataflow",direction:"outgoing"},{question:"Which producer and consumer rendezvous?",family:"runtime",direction:"both"},{question:"What resource is observed or changed?",family:"state",direction:"both"},{question:"What occurs before or after this?",family:"temporal",direction:"both"},{question:"What interface constrains this?",family:"contract",direction:"both"},{question:"Are these observations the same entity?",family:"identity",direction:"both"},{question:"What contains or owns this?",family:"ownership",direction:"both"},{question:"What does this statically rely on?",family:"dependencies",direction:"outgoing"}],pt={execution:{establishes:"Static may-call reachability between resolved program constructs.",nonClaims:["A may-call edge does not prove that a runtime invocation occurred."]},runtime:{establishes:"A source-grounded handoff between producer and consumer participants through a runtime mechanism.",nonClaims:["An unresolved or candidate join does not prove a runtime handoff."]},dataflow:{establishes:"A value, definition, argument, parameter, return, or statically resolved value may flow to another construct.",nonClaims:["Current partial providers do not establish general interprocedural definition-use coverage."]},state:{establishes:"A construct reads, writes, creates, deletes, or otherwise changes an identified state resource.",nonClaims:["A state edge does not prove transactionality, durability, or exclusive ownership unless qualified."]},temporal:{establishes:"One observed construct is locally ordered before or after another under the reported source evidence.",nonClaims:["Source order does not imply cross-process happens-before or durability."]},contract:{establishes:"A program construct implements, constrains, or is typed by an identified contract.",nonClaims:["Contract identity does not prove runtime invocation or conformance outside reported checks."]},identity:{establishes:"Two observations refer to the same compiler-owned or source-owned program entity.",nonClaims:["Shared identity does not establish execution or value transfer."]},ownership:{establishes:"A source construct, symbol, runtime observation, or state resource is contained or owned by another program entity.",nonClaims:["Structural ownership does not establish lifetime, singleton scope, or runtime execution unless qualified."]},dependencies:{establishes:"A file, module, or symbol statically relies on another indexed entity.",nonClaims:["A dependency edge does not establish that the depended-on code executes."]}};function ht(e){return te.flatMap(t=>t.relations.filter(r=>r.family===e).map(r=>({...r,providerId:t.id,providerLabel:t.label})))}function ft(e){return[...new Set(te.filter(t=>t.relations.some(r=>r.family===e)).map(t=>t.label))]}var nn=Ee.map(e=>({family:e,...pt[e],providers:ft(e),relations:ht(e)}));function mt(e){return{family:e,...pt[e],providers:ft(e),relations:ht(e)}}var an=["search","outline","entrypoints","evidence","inspect","code"];function cn(){return ut.map(e=>{let t=mt(e.family);return{...e,establishes:t.establishes,evidenceStrengths:yt(t.relations.flatMap(r=>r.evidenceStrengths)),supportCeilings:yt(t.relations.map(r=>r.supportCeiling)),nonClaim:t.nonClaims.join(" ")}})}function yt(e){return[...new Set(e)]}export{nn as a,Le as b,sr as c,ar as d,kt as e,cr as f,dr as g,lr as h,xr as i,Gt as j,Tr as k,Qe as l,qr as m,$t as n,Ye as o,_r as p,Dr as q,Or as r,Lr as s,he as t,Mr as u,st as v,Xr as w,Zr as x,an as y,cn as z};
3
- //# sourceMappingURL=chunk-OLIWTZI3.js.map
@@ -1,2 +0,0 @@
1
- import{e as p}from"./chunk-2WC2OEDO.js";import{a as h}from"./chunk-MV3CDXPI.js";import{a as y}from"./chunk-WYCTJDVR.js";import{p as u}from"./chunk-YEN6CYC7.js";import{a as S,c as b}from"./chunk-HOENASQM.js";import{_ as d}from"./chunk-3L2ZBPEX.js";import{c as m}from"./chunk-DRENNWRG.js";function x(e,o,r={}){let{direction:c="backward",maxDepth:s=3}=r,l=S(e,o);return l?c==="backward"?k(e,l,s,{semantic:r.semantic!==!1}):D(e,l,{semantic:r.semantic!==!1}):null}function j(e,o,r={}){return x(e,o,r)}function k(e,o,r,c){let s=[],l=new Set([o.symbol]),t=[o];for(let n=1;n<=r&&t.length!==0;n++){let i=[];for(let g of t){let w=h(e,g,{semantic:c.semantic,semanticEvidence:y});for(let a of w){if(l.has(a.symbol))continue;l.add(a.symbol),s.push({symbol:a.symbol,shortName:m(a.symbol),file:a.file,relationship:n===1?"referenced within definition (callee)":`depth ${n} callee`});let f=b(e,a.symbol);f&&!e.isIgnored(f.relativePath)&&i.push(f)}}t=i}return{symbol:o.symbol,shortName:m(o.symbol),direction:"backward",connectedSymbols:s}}function D(e,o,r){let c=new Set,s=[],l=new p(e);for(let t of u(e,o,{semantic:r.semantic,semanticEvidence:y})){if(s.length>=30)break;let n=t.enclosingSymbol??d(l.definitionsForFile(t.file),t.line)?.symbol??null;if(!n||n===o.symbol)continue;let i=b(e,n);!i||e.isIgnored(i.relativePath)||c.has(i.symbol)||(c.add(i.symbol),s.push({symbol:i.symbol,shortName:m(i.symbol),file:i.relativePath,relationship:`references target at ${t.file}:${t.line+1}`}))}return s.sort((t,n)=>t.file.localeCompare(n.file)),{symbol:o.symbol,shortName:m(o.symbol),direction:"forward",connectedSymbols:s}}export{x as a,j as b};
2
- //# sourceMappingURL=chunk-OLNV6I6U.js.map
@@ -1,2 +0,0 @@
1
- import{Ba as b,Da as j,f as T,ua as x,x as v,xa as m,ya as P,za as k}from"./chunk-N5B2NILC.js";import{createHash as A}from"crypto";import{isUtf8 as K}from"buffer";import{TextDecoder as _}from"util";var O=new _("utf-8",{fatal:!0});function H(e){return j(e.config.projectRoot)}function V(e,t){let i=T(t),n;try{n=m(e.config.projectRoot,i,{inputKind:"repository text file"})}catch(o){if(b(o)||o instanceof x)return null;throw o}let r=W(n);return r===null?null:w(i,n,r,E(e),L(e))}function X(e,t={}){let i=[],n=C(e,t,r=>i.push(r));return{files:i,candidateFiles:n.candidateFiles,scannedBytes:n.scannedBytes,skippedBinaryPaths:n.skippedBinaryPaths,skippedUnreadablePaths:n.skippedUnreadablePaths,skippedOversizedPaths:n.skippedOversizedPaths}}function C(e,t,i){let n=H(e).filter(s=>!t.scope||s.includes(t.scope)),r=E(e),o=L(e),u=[],S=[],B=[],f=0,d=0,h={aligned:0,stale:0,unavailable:0},l=t.literalBytes?Buffer.isBuffer(t.literalBytes)?[t.literalBytes]:[...t.literalBytes]:[],F=l.length>0?Buffer.allocUnsafe(1024*1024):void 0;for(let s of n){let c,p,g=[],y=o.has(s);try{if(l.length>0){let a=l.length===1?P(e.config.projectRoot,s,l[0],{inputKind:"repository text file",computeSha256:y,scratchBuffer:F}):k(e.config.projectRoot,s,l,{inputKind:"repository text file",computeSha256:y,scratchBuffer:F});if(!a.isUtf8Text){u.push(s);continue}f+=a.byteLength,d+=1,p=a.sha256;let z=R(s,p,r,o);if(h[z.state]+=1,g="matchedLiteralIndexes"in a?a.matchedLiteralIndexes:a.includesLiteral?[0]:[],g.length===0||!a.bytes)continue;c=a.bytes}else c=m(e.config.projectRoot,s,{inputKind:"repository text file"})}catch(a){if(a instanceof x){B.push(s);continue}if(b(a))continue;S.push(s);continue}if(l.length===0&&!I(c)){u.push(s);continue}if(l.length===0){f+=c.byteLength,d+=1,p=y?M(c):void 0;let a=R(s,p,r,o);h[a.state]+=1}if(t.includeBytes&&!t.includeBytes(s,c))continue;let U=O.decode(c);i(w(s,c,U,r,o,p),g)}return{candidateFiles:n.length,scannedTextFiles:d,semanticFiles:h,scannedBytes:f,skippedBinaryPaths:u,skippedUnreadablePaths:S,skippedOversizedPaths:B}}function w(e,t,i,n,r,o){let u=o??M(t);return{relativePath:e,text:i,bytes:t.byteLength,freshness:{exactText:{state:"current",basis:"working-tree-read",sha256:u},semantic:R(e,u,n,r)}}}function R(e,t,i,n){if(!n.has(e))return{state:"unavailable",basis:"no-compiler-document"};let r=i.get(e);return!r||!t?{state:"unavailable",basis:"fingerprint-unavailable"}:{state:r===t?"aligned":"stale",basis:"indexed-input-fingerprint"}}function L(e){return new Set(e.all(`SELECT documents.relative_path FROM documents WHERE 1 = 1 ${e.pathExclusionsFor("documents")}`).map(t=>t.relative_path))}function E(e){let t=new Map;if(!e.generation.metadataRaw)return t;let i=v(e.generation.metadataRaw);if(i.kind!=="legacy"&&i.kind!=="supported")return t;let n=i.metadata.fingerprint;if(!D(n)||!Array.isArray(n.files))return t;for(let r of n.files)!D(r)||typeof r.path!="string"||typeof r.hash!="string"||t.set(r.path,r.hash);return t}function W(e){return I(e)?O.decode(e):null}function I(e){return!e.includes(0)&&K(e)}function M(e){return A("sha256").update(e).digest("hex")}function D(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}export{H as a,V as b,X as c,C as d};
2
- //# sourceMappingURL=chunk-OR2E3AGZ.js.map
@@ -1,2 +0,0 @@
1
- import{b as T}from"./chunk-2GRUZAQF.js";import{b,d as I,g as U,h as L,i as J}from"./chunk-TQZV7KV4.js";import{a as G,b as z,d as O}from"./chunk-3L2ZBPEX.js";import{a as W}from"./chunk-YXPUP5G2.js";import{b as E}from"./chunk-RTQ7NEKG.js";import{d as _}from"./chunk-GUFSG5TX.js";import{b as B,d as N}from"./chunk-IW5XQG5G.js";import{e as M,f as A}from"./chunk-HGFDYOVB.js";import{a as H,c as C}from"./chunk-KYSDI3GE.js";function v(e){let t=P(e.projectFiles),r=new Set(t),s=new Map(e.snapshot.files.map(a=>[a.path,a])),c=e.snapshot.files.filter(a=>{let o=H(a.path,["typescript"]);return o==="config"||o==="ambient"}).map(a=>a.path),i=P([...t,...c]),n=i.find(a=>!s.has(a)),p=new Set(e.snapshot.files.map(a=>a.path)).size!==e.snapshot.files.length,d=!n&&i.some(a=>V(s.get(a))),l=E(JSON.stringify({pnpmWorkspaces:e.snapshot.pnpmWorkspaces,typescriptProjectMode:e.snapshot.typescriptProjectMode,typescriptProjects:P(e.snapshot.typescriptProjects),membership:t})),y,f;return{identityFor(a,o){if(!r.has(a))return g("target-outside-project");if(p)return g("duplicate-input-path");if(n)return g("missing-input-fingerprint");if(d)return g("unreadable-input");let m=[],u,w;if(e.graph===null)m.push("dependency-graph-unavailable"),w="whole-project",u=i;else{let h=a===y&&f?f:Z(a,e.graph);if(y=a,f=h,h.find(k=>!s.has(k)))return g("missing-input-fingerprint");if(u=P([...h,...c]),u.some(k=>V(s.get(k))))return g("unreadable-input");w="dependency-closure"}let X=u.map(h=>Q(s.get(h)));return{version:1,key:E(JSON.stringify({version:1,engineIdentity:e.engineIdentity,schemaVersion:o,projectIdentity:l,inputs:X})),mode:w,inputFiles:u,reasons:m}}}}function Z(e,t){let r=new Set,s=[e];for(let c=0;c<s.length;c+=1){let i=s[c];if(!(i===void 0||r.has(i))){r.add(i);for(let n of[...t.get(i)??[]].sort())r.has(n)||s.push(n)}}return[...r].sort()}function Q(e){return e.semanticHash===void 0?{path:e.path,size:e.size,hash:e.hash}:{path:e.path,semanticHash:e.semanticHash}}function V(e){return e.size<0||e.hash==="unreadable"}function g(e){return{version:1,key:null,mode:"unkeyed",inputFiles:[],reasons:[e]}}function P(e){return[...new Set(e)].sort()}var ee=N("typescript-semantic-identity-context",{clearGroups:["whole-project"]});function x(e,t,r){let s=ee.get(e,()=>te(e));if(!s)return null;let c=`${r}\0${t}`,i=s.identities.get(c);if(i)return i;let n=s.builder.identityFor(t,r);return s.identities.set(c,n),n}function S(e){return W(e,{includeIgnored:!1}).filter(b).sort()}function te(e){try{if(!e.generation.metadataRaw)return null;let t=_(e.generation.metadataRaw);if(t.kind!=="legacy"&&t.kind!=="supported"||!t.capabilities.usableForEvidenceCache)return null;let r=C(t.metadata.fingerprint);return r?{builder:v({projectFiles:S(e),snapshot:r,graph:T(e),engineIdentity:I()}),identities:new Map}:null}catch{return null}}import{getHeapStatistics as ne}from"v8";var j="typescript-reference-fragment-v2",Y=128,R=z({kind:"typescript-reference-fragments",invalidation:O("typescript-reference-fragments"),serialize:e=>JSON.stringify(e),deserialize:ce});function Ce(e,t,r,s=e,c,i=new Set(r.keys())){let n=S(e),p=v({projectFiles:n,snapshot:t,graph:c??T(e),engineIdentity:I()}),d=[],l=0;for(let[f,a]of r){let o=p.identityFor(f,j).key;if(!o){l+=1;continue}d.push({relativePath:f,contentHash:o,value:[...a]})}let y=n.filter(f=>!i.has(f)&&!r.has(f)).length;return R.writeBatch(s,d),{affectedFiles:d.length,carriedFiles:y,skippedAffectedFiles:l}}function _e(e,t,r,s){let c=t.filter(n=>b(n.relativePath));if(c.length===0)return F("no TypeScript definitions");let i=F("shadow did not run");return M("typescript.reference-fragments.shadow",()=>{try{let n=s(c[0].relativePath);if(!n.availability().available||!n.referenceFragmentsForFiles)return i=F("TypeScript reference fragment provider is unavailable"),i;let p=S(e),d=new Set(p),l=new Map;for(let o of D(p)){let m=n.referenceFragmentsForFiles(o);if(o.some(u=>!m.has(u)))return i=F("TypeScript reference fragment provider returned an incomplete batch"),i;for(let u of o)l.set(u,m.get(u)??[])}let y=U(c,l),f=J(c,re(r,d),y);if(!f.passed)return i={state:"failing",files:p.length,keyedFiles:0,writtenFiles:0,...f},i;let a=[];for(let o of p){let m=x(e,o,j);m?.key&&a.push({relativePath:o,contentHash:m.key,value:l.get(o)??[]})}return R.writeBatch(e,a),i={state:"passing",files:p.length,keyedFiles:a.length,writtenFiles:a.length,...f},i}catch(n){return i=F(n instanceof Error?n.message:String(n)),i}},()=>({...i}))}function re(e,t){return new Map([...e].map(([r,s])=>[r,s.filter(c=>t.has(c.file))]))}function Ae(e,t,r){if(t.length===0)return{references:new Map,files:0,cacheHits:0,cacheMisses:0,computedFiles:0};let s="fallback",c=0,i=0,n=0,p=0;return M("typescript.reference-fragments.materialize",()=>{try{let d=S(e);c=d.length;let l=L(t),y=[];for(let a of d){let o=x(e,a,j);if(!o?.key)return null;let m=R.read(e,a,o.key);m===null?(n+=1,y.push({file:a,contentHash:o.key})):(i+=1,l.add(m))}return n===0?(s="hit",{references:l.finish(),files:c,cacheHits:i,cacheMisses:n,computedFiles:p}):ae(e,y,r,a=>{for(let{fragments:o}of a)l.add(o);p+=a.length})?(s="computed",{references:l.finish(),files:c,cacheHits:i,cacheMisses:n,computedFiles:p}):null}catch{return null}},()=>({state:s,files:c,cacheHits:i,cacheMisses:n,computedFiles:p}))}function D(e){let t=[];for(let r=0;r<e.length;r+=Y)t.push(e.slice(r,r+Y));return t}var ie=.75;function q(e){return{heapUsedFraction:()=>{let t=ne();return t.heap_size_limit>0?t.used_heap_size/t.heap_size_limit:0},collect:G,release:()=>B(e,{groups:["semantic-provider"]})}}function $(e,t=ie){return e.heapUsedFraction()<t||e.collect()&&e.heapUsedFraction()<t?!1:(e.release(),!0)}function ae(e,t,r,s,c=q(e)){for(let i of D(t)){let n=K(e,i,r);if(!n)return!1;s(n),$(c)}return!0}function K(e,t,r){let s=t.map(({file:n})=>n),c=r(s[0]);if(!c.availability().available||!c.referenceFragmentsForFiles)return null;let i=c.referenceFragmentsForFiles(s);return s.some(n=>!i.has(n))?null:(R.writeBatch(e,t.map(({file:n,contentHash:p})=>({relativePath:n,contentHash:p,value:i.get(n)??[]}))),s.map(n=>({file:n,fragments:i.get(n)??[]})))}var se=()=>new Promise(e=>setImmediate(e));async function Be(e,t,r={}){let s=r.yieldToEventLoop??se,c=r.probe??q(e),i="fallback",n=0,p=0,d=0,l=0;return A("typescript.reference-fragments.warm",async()=>{try{let y=S(e),f=r.files?new Set(r.files):null,a=f?y.filter(m=>f.has(m)):y;n=a.length;let o=[];for(let m of a){let u=x(e,m,j);if(!u?.key)return null;R.has(e,m,u.key)?p+=1:(d+=1,o.push({file:m,contentHash:u.key}))}if(o.length===0)return i="hit",{files:n,cacheHits:p,cacheMisses:d,computedFiles:l};for(let m of D(o)){let u=K(e,m,t);if(!u)return null;l+=u.length,$(c),r.onBatch?.({computedFiles:l,missingFiles:o.length}),await s()}return i="computed",{files:n,cacheHits:p,cacheMisses:d,computedFiles:l}}catch{return null}},()=>({state:i,files:n,cacheHits:p,cacheMisses:d,computedFiles:l}))}function F(e){return{state:"unavailable",files:0,keyedFiles:0,writtenFiles:0,expectedCount:0,actualCount:0,missing:[],extra:[],reason:e}}function ce(e){try{let t=JSON.parse(e);return!Array.isArray(t)||!t.every(oe)?null:t}catch{return null}}function oe(e){if(!e||typeof e!="object")return!1;let t=e,r=t.location;return typeof t.targetSymbol=="string"&&!!r&&typeof r.file=="string"&&typeof r.line=="number"&&typeof r.column=="number"}export{x as a,Ce as b,_e as c,Ae as d,Be as e};
2
- //# sourceMappingURL=chunk-OSR2GEHQ.js.map
@@ -1,3 +0,0 @@
1
- import{B as M,c as N,d as _,e as w,g as k,h as A,i as z,n as f,o as S,r as R}from"./chunk-N2ZSIIGR.js";import{b as B}from"./chunk-ZOHS7AQV.js";import{c as O}from"./chunk-JWTGMPIT.js";var T=O("symbol-resolution",{clearGroups:[]});function he(e,n){return G(e,n).match}function G(e,n){return T.get(e,n,()=>{let t=W(e,n.trim()).filter(i=>!e.isIgnored(i.relative_path));if(t.length>0)return L(e,t);let o=P(e,n);if(o&&!e.isIgnored(o.relative_path))return L(e,[o]);let r=H(e,n);if(r.length>0)return L(e,r);let s=U(e,n);return s.length>0?L(e,s):J(e,n)})}function H(e,n){let t=n.trim().replace(/\(\)$/u,""),o=t.lastIndexOf(":");if(o<=0||o===t.length-1||t.startsWith("local:"))return[];let r=t.slice(o+1);if(!/^[\p{L}_$][\p{L}\p{N}_$]*$/u.test(r))return[];let s=[`/${r}().`,`/${r}.`,`/${r}#`,`#${r}().`,`#${r}.`,`/${r}/`],i=`gs.display_name = ? OR ${s.map(()=>"instr(gs.symbol, ?) > 0").join(" OR ")}`,a=[r,...s],l=f(e,{where:i,params:a,orderBy:"d.relative_path, der.start_line",limit:200}),u=l.length>0?[]:S(e,{where:i,params:a,orderBy:"d.relative_path, start_line",limit:200}),p=R(l,u).filter(m=>!e.isIgnored(m.relative_path)).filter(m=>_(m.symbol).replace(/\(\)$/u,"")===t);return[...new Map(p.map(m=>[`${m.symbol}\0${m.relative_path}`,m])).values()]}function U(e,n){let t=Q(n),o=E(t);if(!o)return[];let r=`%${o.path}%`,s=o.leaf;return X(e,r,s,t)}function X(e,n,t,o){let r=R([],[...Y(e,n,t),...Z(e,n,t)]).filter(s=>!e.isIgnored(s.relative_path)).filter(s=>C(s,o)>1);return r.sort((s,i)=>C(i,o)-C(s,o)||s.end_line-s.start_line-(i.end_line-i.start_line)||s.start_line-i.start_line||s.symbol.localeCompare(i.symbol)),r}function Y(e,n,t){return f(e,{where:"d.relative_path LIKE ? AND (gs.display_name = ? OR gs.symbol LIKE ?)",params:[n,t,`%/${t}.%`]})}function Z(e,n,t){return S(e,{where:"d.relative_path LIKE ? AND (gs.display_name = ? OR gs.symbol LIKE ?)",params:[n,t,`%/${t}.%`]})}function J(e,n){let t=Q(n),o=ae(n),r=oe(e,o),s=se(r,n,t).filter(a=>!e.isIgnored(a.relative_path));if(s.length>0)return L(e,s);let i=[];for(let a of r){if(e.isIgnored(a.relative_path))continue;let l=re(a,n,t,o);l<=0||i.push({row:a,score:l})}return i.sort((a,l)=>l.score-a.score||a.row.end_line-a.row.start_line-(l.row.end_line-l.row.start_line)||a.row.relative_path.localeCompare(l.row.relative_path)||a.row.symbol.localeCompare(l.row.symbol)),L(e,i.map(a=>a.row))}function L(e,n){let t=n.map(r=>M(e,r)),o=t[0]??null;return{match:o,candidates:o?V(t,o):[],total:t.length}}function V(e,n){let t=new Set([`${n.symbolId}:${n.relativePath}:${n.startLine}`]),o=[];for(let r of e){let s=`${r.symbolId}:${r.relativePath}:${r.startLine}`;if(!t.has(s)&&(t.add(s),o.push({symbol:r.symbol,shortName:_(r.symbol),relativePath:r.relativePath,startLine:r.startLine}),o.length>=5))break}return o}function P(e,n){let t=n.match(/^(.+):(\d+)(?:-(\d+))?$/);if(!t)return;let[,o,r,s]=t,i=B(e,o,{allowMultiple:!1,requirePathMatch:!0})[0]?.relativePath;if(!i)return;let a=Math.max(0,parseInt(r,10)-1),l=s?Math.max(a,parseInt(s,10)-1):a;return ee(e,i,a,l)??te(e,i,a,l)}function ee(e,n,t,o){return f(e,{where:"d.relative_path = ? AND der.start_line <= ? AND der.end_line >= ?",params:[n,t,o],orderBy:"(der.end_line - der.start_line) ASC",limit:1})[0]}function te(e,n,t,o){return S(e,{where:"d.relative_path = ? AND c.start_line <= ? AND c.end_line >= ?",params:[n,t,o],orderBy:"(MAX(c.end_line) - MIN(c.start_line)) ASC",limit:1})[0]}function be(e,n){let t=W(e,n).find(o=>!e.isIgnored(o.relative_path));return t?M(e,t):null}function W(e,n){let t=f(e,{where:"gs.symbol = ?",params:[n],orderBy:"d.relative_path, der.start_line"}),o=t.length>0?[]:S(e,{where:"gs.symbol = ?",params:[n],orderBy:"d.relative_path, start_line"});return R(t,o)}function Se(e,n){if("symbol"in n&&"relativePath"in n)return n;let t=ne(e,n.symbolId)[0];return t?M(e,t):null}function ne(e,n){let t=f(e,{where:"gs.id = ?",params:[n],orderBy:"der.start_line, der.end_line"}),o=S(e,{where:"gs.id = ?",params:[n],orderBy:"start_line, end_line"});return R(t,o)}function oe(e,n){let t=n.map(()=>"(gs.symbol LIKE ? OR d.relative_path LIKE ? OR COALESCE(gs.display_name, '') LIKE ?)"),o=n.flatMap(a=>{let l=`%${a}%`;return[l,l,l]}),r=t.join(`
2
- AND `),s=f(e,{where:r,params:o,limit:200}),i=S(e,{where:r,params:o,limit:200});return R(s,i)}function re(e,n,t,o){let r=n.trim(),s=t,i=s.replace(/\(\)$/,""),a=n.toLowerCase(),l=t.toLowerCase(),u=l.replace(/\(\)$/,""),p=e.symbol,m=_(e.symbol),y=w(e.symbol),g=e.display_name??"",$=e.symbol.toLowerCase(),d=m.toLowerCase(),h=y.toLowerCase(),x=g.toLowerCase(),b=e.relative_path.toLowerCase(),j=/[/:.]/.test(t),I=E(t),v=I?.leaf.toLowerCase(),c=0;return(p===r||p===s)&&(c+=1150),(m===r||m===s)&&(c+=1100),g===i&&(c+=1180),y===i&&(c+=1160),(`${y}()`===r||`${y}()`===s)&&(c+=955),($===a||$===l)&&(c+=1e3),(d===a||d===l)&&(c+=950),(b===a||b===l)&&(c+=925),(b.endsWith(`/${l}`)||b.endsWith(`/${a}`))&&(c+=875),x===u&&(c+=850),h===u&&(c+=825),(`${h}()`===a||`${h}()`===l)&&(c+=820),(d.endsWith(`:${l}`)||d.endsWith(`:${u}`)||d.endsWith(`:${u}()`))&&(c+=800),$.includes(l)&&(c+=120),d.includes(l)&&(c+=140),b.includes(l)&&(c+=140),x.includes(l)&&(c+=110),o.every(q=>{let D=q.toLowerCase();return $.includes(D)||d.includes(D)||b.includes(D)||x.includes(D)})&&(c+=100+o.length*15),I&&b.includes(I.path.toLowerCase())&&(c+=360,v&&(h===v||`${h}()`===v||`${h}()`==`${v}()`)&&(c+=700),k(e.symbol)&&(c+=180)),A(e.symbol)&&h===u&&(c+=60),!j&&z(e.symbol)&&(c-=160),c-=Math.min(50,Math.max(0,e.end_line-e.start_line)),c}function E(e){let n=e.trim().replace(/\\/g,"/"),t=n.lastIndexOf("/");if(t<=0||t===n.length-1)return null;let o=n.slice(t+1).replace(/\(\)$/,"");return!o||o.includes(".")?null:{path:n.slice(0,t),leaf:o}}function Q(e){return e.trim().replace(/\(\)$/,"").replace(/\(.*$/,"")}function ae(e){let n=Q(e),t=n.split(/[^A-Za-z0-9_]+/).map(o=>o.trim()).filter(o=>o.length>0);return t.length>0?[...new Set(t)]:[n]}function se(e,n,t){let o=n.trim(),r=e.filter(a=>{let l=_(a.symbol),u=w(a.symbol),p=(a.display_name??"").trim();return a.symbol===o||l===o||l===t||u===o||u===t||`${u}()`===o||p===o||p===t||`${p}()`===o||C(a,t)>1||a.relative_path===o});if(r.length===0)return[];let s=t.replace(/\(\)$/u,""),i=r.filter(a=>w(a.symbol)===s);if(i.length>0){i.sort((l,u)=>F(l,u,t));let a=i.filter(l=>A(l.symbol));return a.length>0?a:i}return r.sort((a,l)=>F(a,l,t)),r}function F(e,n,t){return C(n,t)-C(e,t)||e.end_line-e.start_line-(n.end_line-n.start_line)||e.relative_path.localeCompare(n.relative_path)||e.symbol.localeCompare(n.symbol)}function C(e,n){let t=E(n);if(!t)return 0;let o=e.relative_path.toLowerCase(),r=w(e.symbol).toLowerCase(),s=t.path.toLowerCase(),i=t.leaf.toLowerCase();return o.includes(s)?r!==i?1:k(e.symbol)?N(e.symbol)===null?5:4:N(e.symbol)===null?3:2:0}function ge(e,n,t=5){let o=K(n);if(!o)return[];let r=f(e,{where:"1 = 1",orderBy:"d.relative_path, der.start_line",limit:5e3}),s=new Map;for(let i of r){if(e.isIgnored(i.relative_path))continue;let a=_(i.symbol),l=w(i.symbol),u=i.display_name??l,p=[a,l,u].filter(g=>g.trim().length>0),m=Math.min(...p.map(g=>ie(K(g),o))),y=s.get(a);(!y||m<y.distance)&&s.set(a,{shortName:a,distance:m})}return[...s.values()].sort((i,a)=>i.distance-a.distance||i.shortName.localeCompare(a.shortName)).slice(0,t).map(i=>i.shortName)}function K(e){return Q(e).toLowerCase().replace(/[^a-z0-9_]+/g,"")}function ie(e,n){if(e===n)return 0;if(e.length===0)return n.length;if(n.length===0)return e.length;let t=Array.from({length:n.length+1},(o,r)=>r);for(let o=0;o<e.length;o++){let r=[o+1];for(let s=0;s<n.length;s++){let i=e[o]===n[s]?0:1;r[s+1]=Math.min(r[s]+1,t[s+1]+1,t[s]+i)}t=r}return t[n.length]}export{he as a,G as b,be as c,Se as d,ge as e};
3
- //# sourceMappingURL=chunk-OSSESPDX.js.map
@@ -1,7 +0,0 @@
1
- import{a as R,b as v}from"./chunk-GAS2LJMP.js";import{a as b,b as L}from"./chunk-2OOY75BW.js";import{d}from"./chunk-JFMEXGFE.js";import{spawn as B}from"child_process";import{platform as P}from"os";var u=class extends Error{},h=class extends Error{},m=class extends Error{constructor(t,r,i){super(`rust-analyzer LSP request ${r} failed: ${i}`);this.code=t}code},k=3e4,M=16*1024,O=64*1024*1024,z=64*1024,A=256*1024*1024,p=Buffer.from(`\r
2
- \r
3
- `,"ascii"),x=class{constructor(e,t={}){this.transport=e;this.requestTimeoutMs=t.requestTimeoutMs??k,this.configuration=t.configuration??{};let r=D(t.maxHeaderBytes,t.maxMessageBytes);this.maxHeaderBytes=r.maxHeaderBytes,this.maxMessageBytes=r.maxMessageBytes,this.monotonicNow=t.monotonicNow??d,this.headerBuffer=Buffer.allocUnsafe(this.maxHeaderBytes+p.length),this.transport.onData(i=>this.handleData(i)),this.transport.onClose((i,s)=>this.failTransport(new Error(H(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;transportKillPromise=null;currentServerStatusGeneration=0;latestServerStatus=null;shutdownStarted=!1;async initialize(e,t={}){let r=e.capabilities??{},i=r.experimental&&typeof r.experimental=="object"&&!Array.isArray(r.experimental)?r.experimental:{},s=await this.request("initialize",{...e,capabilities:{...r,experimental:{...i,serverStatusNotification:!0}}},t);return this.notify("initialized",{}),s}async references(e,t={}){let r=await this.request("textDocument/references",e,t);return Array.isArray(r)?r:[]}async definition(e,t={}){let r=await this.request("textDocument/definition",e,t);return W(r)}async prepareCallHierarchy(e,t={}){let r=await this.request("textDocument/prepareCallHierarchy",e,t);return Array.isArray(r)?r:[]}async outgoingCalls(e,t={}){let r=await this.request("callHierarchy/outgoingCalls",{item:e},t);return Array.isArray(r)?r:[]}async hover(e,t={}){let r=await this.request("textDocument/hover",e,t);return r&&typeof r=="object"?r:null}async readinessBarrier(e={}){try{await this.request("scip-query/readinessBarrier",null,e)}catch(t){if(t instanceof m&&t.code===-32601)return;throw t}}serverStatusGeneration(){return this.currentServerStatusGeneration}serverStatusSnapshot(){let e=this.latestServerStatus;return e?{generation:e.generation,status:{...e.status}}:null}waitForQuiescence(e,t){if(this.transportFailure)return Promise.reject(this.transportFailure);let r=this.latestServerStatus;if(r&&r.generation>e){if(r.status.health==="error")return Promise.reject(E());if(r.status.quiescent)return Promise.resolve(r.status)}return new Promise((i,s)=>{let a={afterGeneration:e,resolve:i,reject:s,timeout:setTimeout(()=>{this.readinessWaiters.delete(a),s(new Error(`rust-analyzer readiness timed out after ${t}ms`))},t)};this.readinessWaiters.add(a)})}didOpenTextDocument(e){this.notify("textDocument/didOpen",{textDocument:e})}waitForDiagnostics(e,t){return this.transportFailure?Promise.resolve(!1):this.diagnosedUris.has(e)?Promise.resolve(!0):new Promise(r=>{let i=l=>{clearTimeout(s),r(l)},s=setTimeout(()=>{let l=this.diagnosticWaiters.get(e)?.filter(o=>o!==i);l&&l.length>0?this.diagnosticWaiters.set(e,l):this.diagnosticWaiters.delete(e),r(!1)},t),a=this.diagnosticWaiters.get(e)??[];a.push(i),this.diagnosticWaiters.set(e,a)})}async shutdown(e={}){if(!this.shutdownStarted){this.shutdownStarted=!0;try{await this.request("shutdown",null,e),this.notify("exit",null)}catch(t){throw this.notify("exit",null),this.killTransportOnce(),t}}}async shutdownAndReap(e={}){let t;try{await this.shutdown(e)}catch(r){t=r}try{await this.killTransportOnce()}catch(r){throw new Error(`rust-analyzer process-tree cleanup failed: ${r instanceof Error?r.message:String(r)}`,{cause:r})}if(t)throw t}request(e,t,r={}){if(this.transportFailure)return Promise.reject(this.transportFailure);let i=y(r.timeoutMs??this.requestTimeoutMs,r.deadlineMs,this.monotonicNow),s=this.nextId++,a={jsonrpc:"2.0",id:s,method:e,params:t};return new Promise((l,o)=>{let c=setTimeout(()=>{let w=i.deadlineLimited?new u(`rust-analyzer readiness deadline expired during LSP request ${e}`):new Error(`rust-analyzer LSP request ${e} timed out after ${i.timeoutMs}ms`);this.cancelAndFailTimedOutRequest(s,w)},i.timeoutMs);this.pending.set(s,{method:e,deadlineMs:r.deadlineMs,resolve:w=>l(w),reject:o,timeout:c}),this.transport.write(f(a))})}notify(e,t){this.transportFailure||this.transport.write(f({jsonrpc:"2.0",method:e,params:t}))}handleData(e){if(this.transportFailure||e.length===0)return;let t=0;for(;t<e.length&&!this.transportFailure;){if(this.bodyBuffer){let a=Math.min(e.length-t,this.bodyBuffer.length-this.bodyLength);if(e.copy(this.bodyBuffer,this.bodyLength,t,t+a),t+=a,this.bodyLength+=a,this.bodyLength===this.bodyBuffer.length){let l=this.bodyBuffer.toString("utf8");this.bodyBuffer=null,this.bodyLength=0;let o;try{o=$(l)}catch{this.failProtocol("rust-analyzer LSP response body was not a valid JSON object");continue}try{this.dispatchMessage(o)}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[t++],!this.headerDelimiterComplete())continue;let r=this.headerLength-p.length;if(r>this.maxHeaderBytes){this.failProtocol(`rust-analyzer LSP header exceeded ${this.maxHeaderBytes} byte limit`);return}let i=this.headerBuffer.subarray(0,r).toString("ascii");this.headerLength=0;let s;try{s=C(i,this.maxMessageBytes)}catch(a){this.failProtocol(a instanceof Error?a.message:String(a));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<p.length)return!1;let e=this.headerLength-p.length;return this.headerBuffer.subarray(e,this.headerLength).equals(p)}failProtocol(e){this.failTransport(new h(e),!0)}failTransport(e,t){this.transportFailure||(this.transportFailure=e,this.headerLength=0,this.bodyBuffer=null,this.bodyLength=0,t&&this.killTransportOnce().catch(()=>{}),this.rejectPending(e),this.resolveDiagnosticWaiters(!1))}killTransportOnce(){return this.transportKilled?this.transportKillPromise??Promise.resolve():(this.transportKilled=!0,this.transportKillPromise=Promise.resolve(this.transport.kill()),this.transportKillPromise)}async cancelAndFailTimedOutRequest(e,t){let r=this.pending.get(e);if(!r)return;this.pending.delete(e);try{this.transport.write(f({jsonrpc:"2.0",method:"$/cancelRequest",params:{id:e}}))}catch{}this.transportFailure||(this.transportFailure=t,this.headerLength=0,this.bodyBuffer=null,this.bodyLength=0);let i=t;try{await this.killTransportOnce()}catch(s){i=new Error(`${t.message}; rust-analyzer cleanup failed: ${s instanceof Error?s.message:String(s)}`,{cause:s})}r.reject(i),this.rejectPending(i),this.resolveDiagnosticWaiters(!1)}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 t=this.pending.get(e.id);if(t){if(clearTimeout(t.timeout),this.pending.delete(e.id),e.error){t.reject(new m(e.error.code,t.method,e.error.message));return}if(t.deadlineMs!==void 0&&this.monotonicNow()>=t.deadlineMs){t.reject(new u(`rust-analyzer readiness deadline expired during LSP request ${t.method}`));return}t.resolve(e.result)}}recordDiagnosticNotification(e){if(e.method!=="textDocument/publishDiagnostics")return;let t=e.params,r=t&&typeof t=="object"&&typeof t.uri=="string"?t.uri:null;if(!r)return;this.diagnosedUris.add(r);let i=this.diagnosticWaiters.get(r)??[];this.diagnosticWaiters.delete(r),i.forEach(s=>s(!0))}recordServerStatusNotification(e){if(e.method!=="experimental/serverStatus"||e.id!==void 0||!j(e.params))return;let t=e.params,r={health:t.health,quiescent:t.quiescent,...typeof t.message=="string"?{message:t.message}:{}},i=++this.currentServerStatusGeneration;if(this.latestServerStatus={generation:i,status:r},r.health==="error"){this.rejectReadinessWaiters(E());return}if(r.quiescent)for(let s of this.readinessWaiters)i<=s.afterGeneration||(clearTimeout(s.timeout),this.readinessWaiters.delete(s),s.resolve(r))}respondToServerRequest(e){if(e.id===void 0||e.id===null||!e.method)return;let t=e.method==="workspace/configuration"?this.workspaceConfiguration(e.params):null;this.transport.write(f({jsonrpc:"2.0",id:e.id,result:t}))}workspaceConfiguration(e){return(e&&typeof e=="object"&&Array.isArray(e.items)?e.items:[]).map(r=>typeof r.section=="string"?F(this.configuration,r.section):this.configuration)}rejectPending(e){for(let[t,r]of this.pending)clearTimeout(r.timeout),r.reject(e),this.pending.delete(t);this.rejectReadinessWaiters(e)}resolveDiagnosticWaiters(e){for(let t of this.diagnosticWaiters.values())t.forEach(r=>r(e));this.diagnosticWaiters.clear()}rejectReadinessWaiters(e){for(let t of this.readinessWaiters)clearTimeout(t.timeout),t.reject(e),this.readinessWaiters.delete(t)}};function D(n=M,e=O){if(!Number.isSafeInteger(n)||n<=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(n>z)throw new RangeError(`maxHeaderBytes cannot exceed ${z} bytes for rust-analyzer LSP.`);if(n+p.length+e>A)throw new RangeError(`Combined rust-analyzer LSP header and message limits cannot exceed ${A} bytes.`);return{maxHeaderBytes:n,maxMessageBytes:e}}function C(n,e){let t=[];for(let s of n.split(`\r
4
- `)){let a=s.indexOf(":");a<0||s.slice(0,a).trim().toLowerCase()!=="content-length"||t.push(s.slice(a+1).trim())}if(t.length===0)throw new h("rust-analyzer LSP response missing Content-Length header");if(t.length>1){let s=new Set(t).size>1?"rust-analyzer LSP response has conflicting Content-Length headers":"rust-analyzer LSP response has duplicate Content-Length headers";throw new h(s)}let r=t[0];if(!/^\d+$/.test(r))throw new h("rust-analyzer LSP Content-Length must be a non-negative safe integer");let i=Number(r);if(!Number.isSafeInteger(i))throw new h("rust-analyzer LSP Content-Length must be a non-negative safe integer");if(i>e)throw new h(`rust-analyzer LSP Content-Length exceeds ${e} byte message limit`);return i}function y(n,e,t=d){if(e===void 0)return{timeoutMs:n,deadlineLimited:!1};let r=e-t();if(r<=0)throw new u("rust-analyzer readiness deadline expired before LSP operation");return{timeoutMs:Math.min(n,r),deadlineLimited:r<=n}}function j(n){if(!n||typeof n!="object"||Array.isArray(n))return!1;let e=n;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 E(){return new u("rust-analyzer reported error health before reaching readiness")}function F(n,e){let t=e.startsWith("rust-analyzer.")?e.slice(14):e;if(t===""||t==="rust-analyzer")return n;let r=n;for(let i of t.split(".")){if(!r||typeof r!="object")return null;r=r[i]}return r??null}function W(n){return n?(Array.isArray(n)?n:[n]).flatMap(t=>N(t)?[t]:_(t)?[{uri:t.targetUri,range:t.targetSelectionRange}]:[]):[]}function N(n){return!!(n&&typeof n=="object"&&typeof n.uri=="string")}function _(n){return!!(n&&typeof n=="object"&&typeof n.targetUri=="string")}function Z(n,e,t=process.env,r){let i=B(n,[],{cwd:e,env:t,detached:P()!=="win32",stdio:["pipe","pipe","pipe"]}),s=i.pid===void 0?null:b(i.pid,P()!=="win32"),a=s?R(r,s):null,l=null;return i.on("close",()=>v(a)),{write(o){i.stdin.write(o)},onData(o){i.stdout.on("data",o)},onClose(o){i.on("close",o)},onError(o){i.on("error",o)},kill(){if(!s){i.kill();return}return l??=L(s,{gracefulMs:1e3,forceMs:1e3}).then(o=>{if(!o.reaped)throw new Error(o.detail??`rust-analyzer process tree ${s.rootPid} was not reaped.`);v(a)}),l}}}function f(n){let e=JSON.stringify(n);return`Content-Length: ${Buffer.byteLength(e,"utf8")}\r
5
- \r
6
- ${e}`}function $(n){let e=JSON.parse(n);if(!e||typeof e!="object")throw new Error("rust-analyzer LSP response was not a JSON object");return e}function H(n,e){return`rust-analyzer LSP transport closed${e?` by ${e}`:n===null?"":` with code ${n}`}`}async function q(n,e,t,r=d){let i=t-r();if(i<=0)throw new u("rust-analyzer readiness deadline expired before quiescence");try{let s=await n.waitForQuiescence(e,i);if(g(t,r,"during quiescence"),s.health==="error")throw new u("rust-analyzer reported error health before reaching readiness");if(!s.quiescent)throw new u("rust-analyzer did not report quiescence before reaching readiness");return s}catch(s){throw s instanceof u?s:new u(s instanceof Error?s.message:String(s))}}async function te(n,e,t,r,i,s=d,a=S){let l=await q(n,e,r,s);if(t===0)return l;let o=n.serverStatusSnapshot();if(!o)throw new u("rust-analyzer status is unavailable after initial document open");return await J(n,o,t,r,i,s,a)??l}async function J(n,e,t,r,i,s=d,a=S){if(t===0)return null;if(!e)throw new u("rust-analyzer status is unavailable before document open");T(e.status,"before document open");try{await n.readinessBarrier({deadlineMs:r}),g(r,s,"during post-open synchronization")}catch(c){throw c instanceof u?c:new u(c instanceof Error?c.message:String(c))}let l=n.serverStatusSnapshot();if(!l||l.generation<e.generation)throw new u("rust-analyzer status is unavailable after document open");let o;return l.generation===e.generation?(T(l.status,"after document open"),o=l.status):o=await q(n,e.generation,r,s),await U(i,r,s,a),o}async function re(n,e,t,r=d){let i=y(e,t,r);await n(i.timeoutMs),g(t,r,"during diagnostics")}async function U(n,e,t=d,r=S){if(n<=0)return;if(y(n,e,t).deadlineLimited)throw new u("rust-analyzer readiness deadline cannot accommodate delay");await r(n),g(e,t,"during delay")}async function ne(n,e){try{return await n()}catch(t){throw t instanceof u&&await e(),t}}function se(n){return n instanceof u?{ok:!1,error:n.message}:null}function g(n,e,t){if(n-e()<=0)throw new u(`rust-analyzer readiness deadline expired ${t}`)}function T(n,e){if(n.health==="error")throw new u(`rust-analyzer reported error health ${e}`);if(!n.quiescent)throw new u(`rust-analyzer did not report quiescence ${e}`)}function S(n){return new Promise(e=>setTimeout(e,n))}export{u as a,x as b,Z as c,te as d,J as e,re as f,U as g,ne as h,se as i,S as j};
7
- //# sourceMappingURL=chunk-OWOOWNJ5.js.map
@@ -1,2 +0,0 @@
1
- import{a as k}from"./chunk-FIQRSHVM.js";import{c as R,d as E}from"./chunk-JFMEXGFE.js";import{h as S}from"./chunk-7F45LJKI.js";import{randomUUID as q}from"crypto";import{getHeapStatistics as V}from"v8";import{resolve as H}from"path";import{createRequire as L}from"module";import{dirname as I,isAbsolute as j,relative as P,resolve as m,sep as b}from"path";var u=L(import.meta.url),_=1,D="0.4.0";function z(){try{let t=M();if(!t.available)return t;let{packageRoot:e}=t,r=u.resolve("typescript",{paths:[e]}),i=u(r),{FileIndexer:n}=u(m(e,"dist/src/FileIndexer.js")),{Input:s}=u(m(e,"dist/src/Input.js")),{Packages:o}=u(m(e,"dist/src/Packages.js")),c=u(m(e,"dist/src/scip.js"));if(!n||!s||!o||!c.scip?.Document||!c.scip.Index)return{available:!1,reason:"scip-typescript document runtime has an unsupported module shape"};let a={packageVersion:t.packageVersion,typescript:i,Document:c.scip.Document,Index:c.scip.Index,FileIndexer:n,Input:s,Packages:o};return{available:!0,runtime:a,producerIdentity:x(a)}}catch(t){return{available:!1,reason:`scip-typescript document runtime unavailable: ${t instanceof Error?t.message:String(t)}`}}}function J(){let t=M();return t.available?{available:!0,packageVersion:t.packageVersion,typescriptVersion:t.typescriptVersion,producerIdentity:t.producerIdentity}:t}function M(){try{let t=u.resolve("@sourcegraph/scip-typescript/package.json"),e=JSON.parse(S(t,"scip-typescript package manifest"));if(e.version!==D)return{available:!1,reason:`unsupported scip-typescript version ${String(e.version??"unknown")}; expected ${D}`};let r=I(t),i=u.resolve("typescript/package.json",{paths:[r]}),n=JSON.parse(S(i,"TypeScript package manifest"));return typeof n.version!="string"||!n.version?{available:!1,reason:"scip-typescript TypeScript compiler version is unavailable"}:{available:!0,packageRoot:r,packageVersion:e.version,typescriptVersion:n.version,producerIdentity:C(e.version,n.version)}}catch(t){return{available:!1,reason:`scip-typescript document producer unavailable: ${t instanceof Error?t.message:String(t)}`}}}function A(t){let e=t.runtime===void 0?z():t.runtime===null?{available:!1,reason:"scip-typescript document runtime unavailable"}:{available:!0,runtime:t.runtime,producerIdentity:x(t.runtime)};return e.available?{available:!0,emitter:new T(t,e.runtime)}:e}var T=class{producerIdentity;workspaceRoot;tsconfigPath;projectRoot;maxFileByteSize;runtime;host;config=null;includedFiles=new Set;program=null;checker=null;symbolTable=new Map;constructorTable=new Map;packages;fragments=new Map;stats={initializations:0,programUpdates:0,documentsEmitted:0,documentsRemoved:0,sourceNodesReused:0,sourceNodesReplaced:0,symbolEntriesPruned:0};constructor(e,r){this.workspaceRoot=m(e.workspaceRoot),this.tsconfigPath=m(this.workspaceRoot,e.tsconfigPath),this.projectRoot=e.projectRoot??O(this.workspaceRoot,I(this.tsconfigPath)),this.maxFileByteSize=e.maxFileByteSize??1024*1024,this.runtime=r,this.producerIdentity=x(r);let i=v(r.typescript,this.tsconfigPath);this.config=i,this.host=new w(r.typescript,i.options,this.workspaceRoot),this.packages=new r.Packages(this.projectRoot)}initialize(){let e=performance.now();this.initializeProgram();let r=[];for(let i of this.program.getSourceFiles())this.includedFiles.has(f(i.fileName))&&r.push(this.emitSourceFile(i));return this.result(r,e)}advance(e){if(!this.program||!this.checker||!this.config)return this.initializeAndAdvance(e);let r=performance.now(),i=h(e.modifiedFiles),n=h(e.removedFiles??[]),s=h(e.affectedFiles);if(this.fragments.clear(),i.length===0&&n.length===0)return this.validateAffectedPaths(s),this.result(this.emitAffectedFiles(s),r);let o=v(this.runtime.typescript,this.tsconfigPath);this.config=o,this.includedFiles=new Set(o.fileNames.map(f));let c=this.program,a=new Map;for(let d of[...i,...n]){let p=y(this.workspaceRoot,d),l=c.getSourceFile(p);l&&(a.set(d,l),this.stats.symbolEntriesPruned+=F(this.symbolTable,l),this.stats.symbolEntriesPruned+=F(this.constructorTable,l)),this.host.invalidate(p)}this.program=this.runtime.typescript.createProgram(o.fileNames,o.options,this.host.compilerHost,c),this.checker=this.program.getTypeChecker(),this.stats.programUpdates+=1,this.validateIncrementalPaths(i,n,s),this.stats.documentsRemoved+=n.length;for(let[d,p]of a)this.program.getSourceFile(y(this.workspaceRoot,d))===p?this.stats.sourceNodesReused+=1:this.stats.sourceNodesReplaced+=1;return this.result(this.emitAffectedFiles(s),r)}fragment(e){return this.fragments.get(g(e))??null}snapshotStats(){return{...this.stats}}initializeAndAdvance(e){let r=performance.now();this.initializeProgram();let i=h(e.modifiedFiles),n=h(e.removedFiles??[]),s=h(e.affectedFiles);return this.fragments.clear(),this.validateIncrementalPaths(i,n,s,!0),this.stats.documentsRemoved+=n.length,this.result(this.emitAffectedFiles(s),r)}initializeProgram(){let e=this.config??v(this.runtime.typescript,this.tsconfigPath);this.includedFiles=new Set(e.fileNames.map(f)),this.program=this.runtime.typescript.createProgram(e.fileNames,e.options,this.host.compilerHost),this.checker=this.program.getTypeChecker(),this.stats.initializations+=1}validateIncrementalPaths(e,r,i,n=!1){if(!n&&e.length===0&&r.length===0)throw new Error("incremental TypeScript document update requires a modified or removed file");if(i.length===0&&r.length===0)throw new Error("incremental TypeScript document update requires an affected or removed file");for(let s of e){let o=y(this.workspaceRoot,s);if(!this.program?.getSourceFile(o))throw new Error(`modified TypeScript dependency is unavailable to the configured project: ${s}`)}for(let s of r){let o=y(this.workspaceRoot,s);if(this.program?.getSourceFile(o))throw new Error(`removed TypeScript source is still present in the configured project: ${s}`)}this.validateAffectedPaths(i)}validateAffectedPaths(e){for(let r of e){let i=y(this.workspaceRoot,r);if(!this.includedFiles.has(f(i)))throw new Error(`affected TypeScript file is outside the configured project: ${r}`)}}emitAffectedFiles(e){return e.map(r=>{let i=this.program.getSourceFile(y(this.workspaceRoot,r));if(!i)throw new Error(`affected TypeScript source is unavailable: ${r}`);return this.emitSourceFile(i)})}emitSourceFile(e){if(!this.checker)throw new Error("TypeScript document emitter is not initialized");let r=g(P(this.workspaceRoot,e.fileName)),i=new this.runtime.Document({relative_path:r,occurrences:[]});if(new this.runtime.FileIndexer(this.checker,{cwd:this.workspaceRoot,projectRoot:this.projectRoot,projectDisplayName:this.projectRoot,maxFileByteSizeNumber:this.maxFileByteSize},new this.runtime.Input(e.fileName,e.getText()),i,this.symbolTable,this.constructorTable,this.packages,e).index(),this.stats.documentsEmitted+=1,i.occurrences.length===0)return this.fragments.delete(r),this.stats.documentsRemoved+=1,{relativePath:r,bytes:null,occurrences:0,symbols:i.symbols.length,referenceFragments:[]};let s=i.serializeBinary();return this.fragments.set(r,s),{relativePath:r,bytes:s,occurrences:i.occurrences.length,symbols:i.symbols.length,referenceFragments:U(r,i)}}result(e,r){return{producerIdentity:this.producerIdentity,fragments:e,durationMs:performance.now()-r,stats:this.snapshotStats()}}};function U(t,e){let r=new Map;for(let i of e.occurrences){if(!i.symbol||(i.symbol_roles&1)!==0||i.range.length<3)continue;let n=i.range[0],s=i.range[1];if(!Number.isInteger(n)||!Number.isInteger(s))continue;let o={targetSymbol:i.symbol,location:{file:t,line:n,column:s}};r.set(`${i.symbol}\0${n}\0${s}`,o)}return[...r.values()].sort((i,n)=>i.targetSymbol.localeCompare(n.targetSymbol)||i.location.line-n.location.line||i.location.column-n.location.column)}var w=class{compilerHost;sourceFiles=new Map;constructor(e,r,i){let n=e.createCompilerHost(r),s=n.getSourceFile.bind(n);this.compilerHost={...n,getCurrentDirectory:()=>i,getSourceFile:(o,c,a,d)=>{let p=f(o);if(this.sourceFiles.has(p))return this.sourceFiles.get(p);let l=s(o,c,a,d);return this.sourceFiles.set(p,l),l}}}invalidate(e){this.sourceFiles.delete(f(e))}};function v(t,e){let r=t.readConfigFile(e,t.sys.readFile);if(r.error)throw new Error(t.formatDiagnostics([r.error],t.createCompilerHost({})));let i=t.parseJsonConfigFileContent(r.config,t.sys,I(e)),n=i.errors.filter(s=>s.code!==18003);if(n.length>0)throw new Error(t.formatDiagnostics(n,t.createCompilerHost({})));return i}function x(t){return C(t.packageVersion,t.typescript.version)}function C(t,e){return`scip-typescript:${t}:typescript:${e}:document-adapter:${_}`}function O(t,e){return g(P(t,e))||"."}function y(t,e){if(j(e))throw new Error(`expected a project-relative path: ${e}`);let r=m(t,e),i=t.endsWith(b)?t:`${t}${b}`;if(r!==t&&!r.startsWith(i))throw new Error(`path escapes the project root: ${e}`);return r}function h(t){return[...new Set(t.map(g))].sort()}function g(t){return t.split(b).join("/").replace(/^\.\//,"")}function f(t){return m(t)}function F(t,e){let r=0;for(let i of t.keys())if($(i)){try{if(i.getSourceFile()!==e)continue}catch{continue}t.delete(i),r+=1}return r}function $(t){return!!(t&&typeof t=="object"&&"kind"in t&&"getSourceFile"in t)}var N=class{projectRoot;currentGeneration;createEmitter;wallNow;monotonicNow;maxActiveSessions;softMemoryLimitBytes;memoryUsage;active=new Map;requests=0;sessionsCreated=0;sessionsReplaced=0;sessionsEvicted=0;lastRequestAtMs=null;lastDurationMs=null;lastError=null;unavailable=!1;constructor(e){if(this.projectRoot=H(e.projectRoot),this.currentGeneration=e.currentGeneration,this.createEmitter=e.createEmitter??A,this.wallNow=e.wallNow??e.now??Date.now,this.monotonicNow=e.monotonicNow??e.now??E,e.maxActiveSessions!==void 0&&(!Number.isInteger(e.maxActiveSessions)||e.maxActiveSessions<1))throw new Error("TypeScript index maxActiveSessions must be a positive integer.");if(this.maxActiveSessions=e.maxActiveSessions??8,e.softMemoryLimitMb!==void 0&&(!Number.isInteger(e.softMemoryLimitMb)||e.softMemoryLimitMb<1))throw new Error("TypeScript index softMemoryLimitMb must be a positive integer.");this.softMemoryLimitBytes=e.softMemoryLimitMb===void 0?null:e.softMemoryLimitMb*1024*1024,this.memoryUsage=e.memoryUsage??(()=>({heapUsedBytes:process.memoryUsage().heapUsed,heapLimitBytes:V().heap_size_limit}))}handle(e,r){let i=this.monotonicNow();try{if(this.currentGeneration()!==e)throw new Error("TypeScript index request does not match the currently published generation.");let n=this.emitterFor(r);if(n.emitter.producerIdentity!==r.producerIdentity)throw new Error("TypeScript index producer identity changed.");let s=n.emitter.snapshotStats(),o=n.emitter.advance({modifiedFiles:r.modifiedFiles,removedFiles:r.removedFiles,affectedFiles:r.affectedFiles}),c=this.monotonicNow()-i;return this.requests+=1,this.lastRequestAtMs=this.wallNow(),this.lastDurationMs=c,this.lastError=null,this.unavailable=!1,{producerIdentity:o.producerIdentity,cold:o.stats.initializations>s.initializations,durationMs:c,fragments:o.fragments.map(a=>({relativePath:a.relativePath,bytesBase64:a.bytes===null?null:Buffer.from(a.bytes).toString("base64"),occurrences:a.occurrences,symbols:a.symbols,referenceFragments:a.referenceFragments}))}}catch(n){throw this.lastError=n instanceof Error?n.message:String(n),n}}status(e){let r=[...this.active.values()].map(o=>o.emitter.snapshotStats()),i=o=>r.reduce((c,a)=>c+a[o],0),n=this.memoryUsage(),s=this.softMemoryLimitBytes!==null&&n.heapUsedBytes>=this.softMemoryLimitBytes;return{protocolVersion:k,state:this.unavailable?"unavailable":this.lastError?"error":this.active.size>0?"ready":"idle",requests:this.requests,sessionsCreated:this.sessionsCreated,sessionsReplaced:this.sessionsReplaced,sessionsEvicted:this.sessionsEvicted,activeSessions:this.active.size,maxActiveSessions:this.maxActiveSessions,heapUsedBytes:n.heapUsedBytes,heapLimitBytes:n.heapLimitBytes,...this.softMemoryLimitBytes===null?{}:{softMemoryLimitBytes:this.softMemoryLimitBytes},retireRequested:s,initializations:i("initializations"),programUpdates:i("programUpdates"),documentsEmitted:i("documentsEmitted"),documentsRemoved:i("documentsRemoved"),...this.lastRequestAtMs===null?{}:{lastRequestAt:new Date(this.lastRequestAtMs).toISOString()},...this.lastDurationMs===null?{}:{lastDurationMs:this.lastDurationMs},...this.lastError?{lastError:this.lastError}:{},...e?{mailbox:e}:{}}}close(){this.active.clear()}emitterFor(e){let r=`${e.tsconfigPath}\0${e.projectArgument}`,i=this.active.get(r);if(i?.projectIdentity===e.projectIdentity)return this.active.delete(r),this.active.set(r,i),i;if(i)this.active.delete(r);else if(this.active.size>=this.maxActiveSessions){let o=this.active.keys().next().value;o!==void 0&&(this.active.delete(o),this.sessionsEvicted+=1)}let n=this.createEmitter({workspaceRoot:this.projectRoot,tsconfigPath:e.tsconfigPath,projectRoot:e.projectArgument});if(!n.available)throw this.unavailable=!0,new Error(n.reason);i&&(this.sessionsReplaced+=1);let s={projectIdentity:e.projectIdentity,emitter:n.emitter};return this.active.set(r,s),this.sessionsCreated+=1,s}};var se=`typescript-index-${process.pid}-${q()}`,B=R(process.pid),oe={pid:process.pid,...B?{processIdentity:B}:{}};export{J as a,N as b};
2
- //# sourceMappingURL=chunk-P42EIXTA.js.map
@@ -1,2 +0,0 @@
1
- import{b as i}from"./chunk-TQPCBMWT.js";function l(n,o,s,t={}){let e=i(n,o,s,t);return e?{symbolA:e.symbolA,symbolB:e.symbolB,similarity:e.similarity,sharedCallees:e.sharedEvidence,uniqueToA:e.uniqueToA,uniqueToB:e.uniqueToB,consolidationStrategy:e.consolidationStrategy}:null}export{l as a};
2
- //# sourceMappingURL=chunk-PJFGPYTU.js.map