scip-query 0.21.0 → 0.22.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 (496) hide show
  1. package/CHANGELOG.md +72 -0
  2. package/dist/augment-vue-worker.js +1 -1
  3. package/dist/by-kind-4IYG2SKW.js +2 -0
  4. package/dist/call-graph-WQNXMNNN.js +2 -0
  5. package/dist/{chunk-AQDWTCDC.js → chunk-25GWKRUZ.js} +2 -2
  6. package/dist/chunk-2BTJALUS.js +454 -0
  7. package/dist/chunk-2KVU55CW.js +11 -0
  8. package/dist/{chunk-BBWPOMGU.js → chunk-2OXVP5U5.js} +2 -2
  9. package/dist/{chunk-D5W4UZY5.js → chunk-2RE5OCHZ.js} +2 -2
  10. package/dist/{chunk-2I3RSUWX.js → chunk-2XCGSDIT.js} +2 -2
  11. package/dist/{chunk-V7LQZTTZ.js → chunk-2YC7YNKT.js} +2 -2
  12. package/dist/chunk-3QXC54FQ.js +3 -0
  13. package/dist/{chunk-32A42O5B.js → chunk-3TJY6M3B.js} +2 -2
  14. package/dist/chunk-42W3LFUK.js +13 -0
  15. package/dist/chunk-44T4DUAA.js +2 -0
  16. package/dist/chunk-4GAQ6FI4.js +43 -0
  17. package/dist/{chunk-4S4DF62J.js → chunk-4HE7MVWD.js} +2 -2
  18. package/dist/{chunk-TGWNNMPF.js → chunk-4TQU4TX2.js} +2 -2
  19. package/dist/{chunk-SKUMCCC5.js → chunk-56NQAEPJ.js} +2 -2
  20. package/dist/chunk-57N6LN2A.js +3 -0
  21. package/dist/{chunk-LPGDO2XA.js → chunk-5H5WTJSD.js} +2 -2
  22. package/dist/{chunk-EA4SH4U5.js → chunk-5YRQIE2B.js} +2 -2
  23. package/dist/{chunk-O2RM7E7L.js → chunk-5ZMBRQFC.js} +4 -4
  24. package/dist/{chunk-ICHBVITH.js → chunk-6HRZQLOI.js} +2 -2
  25. package/dist/{chunk-WULAPQUD.js → chunk-6NC3YSPY.js} +2 -2
  26. package/dist/{chunk-IDPLC3FI.js → chunk-6VEFRPTD.js} +2 -2
  27. package/dist/{chunk-IOKWFRFQ.js → chunk-7C26EKLZ.js} +2 -2
  28. package/dist/{chunk-S3RTPPLQ.js → chunk-7IQXARSQ.js} +2 -2
  29. package/dist/chunk-7JYHQAH2.js +22 -0
  30. package/dist/chunk-7KSO2OAP.js +2 -0
  31. package/dist/{chunk-2ZBMOQGG.js → chunk-7U2YQSDE.js} +2 -2
  32. package/dist/{chunk-EKZRF57O.js → chunk-7XA3OM44.js} +2 -2
  33. package/dist/{chunk-4EXFZP6H.js → chunk-7XZGZBSQ.js} +2 -2
  34. package/dist/chunk-7YQOCABQ.js +2 -0
  35. package/dist/chunk-A77SCPW2.js +3 -0
  36. package/dist/chunk-AK3PYTIK.js +5 -0
  37. package/dist/chunk-AMIMMNA4.js +11 -0
  38. package/dist/{chunk-MOBF2GH6.js → chunk-AQ2PORIO.js} +2 -2
  39. package/dist/{chunk-YUFWLWIC.js → chunk-ARVO6TTW.js} +2 -2
  40. package/dist/chunk-AUY5BL74.js +2 -0
  41. package/dist/{chunk-RGCJ4646.js → chunk-AYPDH2LU.js} +2 -2
  42. package/dist/{chunk-73Z33VFI.js → chunk-AZS7YPCB.js} +2 -2
  43. package/dist/{chunk-SYUNTKO2.js → chunk-BDGTPN27.js} +2 -2
  44. package/dist/{chunk-BATIVRU2.js → chunk-BDHFVH2M.js} +2 -2
  45. package/dist/chunk-BECZLYNU.js +8 -0
  46. package/dist/chunk-BJT7LSPK.js +3 -0
  47. package/dist/{chunk-6SWA6B24.js → chunk-BTVKZGWT.js} +2 -2
  48. package/dist/{chunk-QD7IFBCR.js → chunk-BUTEIZKP.js} +2 -2
  49. package/dist/{chunk-UZFCZ7SJ.js → chunk-BVFYEEBH.js} +2 -2
  50. package/dist/{chunk-ICUQONOG.js → chunk-BWVQP3LB.js} +2 -2
  51. package/dist/chunk-BYDAFMSR.js +57 -0
  52. package/dist/{chunk-BHE44MHT.js → chunk-C76O5MDS.js} +2 -2
  53. package/dist/chunk-C7IJMOFP.js +134 -0
  54. package/dist/{chunk-CN2WGM7D.js → chunk-CBBHFNLX.js} +2 -2
  55. package/dist/{chunk-COTMS5KM.js → chunk-CKRWA452.js} +2 -2
  56. package/dist/{chunk-ANWGXPPN.js → chunk-CLG6DWVS.js} +2 -2
  57. package/dist/chunk-D2MVJSP4.js +21 -0
  58. package/dist/chunk-D35XIZGN.js +2 -0
  59. package/dist/{chunk-U7DR7MJD.js → chunk-DEAB5TGT.js} +2 -2
  60. package/dist/{chunk-6GJAP4OE.js → chunk-DJAO2OZJ.js} +2 -2
  61. package/dist/chunk-DKM723YF.js +79 -0
  62. package/dist/{chunk-4IIMPWMR.js → chunk-DPWKKNKI.js} +2 -2
  63. package/dist/chunk-E44IVWIJ.js +367 -0
  64. package/dist/chunk-EDMB6SSO.js +7 -0
  65. package/dist/{chunk-KWARB5FZ.js → chunk-EELG7D3Q.js} +2 -2
  66. package/dist/chunk-EELPBR7E.js +3 -0
  67. package/dist/chunk-EETGXQY7.js +3 -0
  68. package/dist/chunk-ENWQWA2R.js +2 -0
  69. package/dist/{chunk-HUZNZ3H2.js → chunk-ERCYGVAM.js} +2 -2
  70. package/dist/{chunk-WSG3DK5H.js → chunk-EWWY2ZFL.js} +2 -2
  71. package/dist/chunk-F24G5NBE.js +3 -0
  72. package/dist/{chunk-XRXCANFQ.js → chunk-F24QUEQP.js} +2 -2
  73. package/dist/{chunk-KFK7GF5C.js → chunk-FBCVASUG.js} +2 -2
  74. package/dist/{chunk-35IW3P4H.js → chunk-FELGD32K.js} +2 -2
  75. package/dist/{chunk-UNORWZIJ.js → chunk-FFJQZG6J.js} +5 -5
  76. package/dist/{chunk-5SE323LF.js → chunk-FGNCOQUX.js} +2 -2
  77. package/dist/chunk-FKGQOTKD.js +2 -0
  78. package/dist/chunk-GDRJB3SB.js +3 -0
  79. package/dist/chunk-GH5YSGZL.js +5 -0
  80. package/dist/{chunk-X7PJJYKX.js → chunk-GIQ6CSL4.js} +2 -2
  81. package/dist/{chunk-2RP27XLR.js → chunk-GPGRZJ3R.js} +2 -2
  82. package/dist/{chunk-IYV2YBHM.js → chunk-GQIDEID3.js} +2 -2
  83. package/dist/chunk-GRX7JOXQ.js +2 -0
  84. package/dist/{chunk-H46QMB7E.js → chunk-GVOMSPGL.js} +2 -2
  85. package/dist/{chunk-KTRGJLY7.js → chunk-GY7CCCEZ.js} +2 -2
  86. package/dist/{chunk-VNKYRJKN.js → chunk-H7CG6LOE.js} +2 -2
  87. package/dist/chunk-HCVJR2V4.js +3 -0
  88. package/dist/chunk-HG722PO7.js +3 -0
  89. package/dist/{chunk-LHTT5C3Z.js → chunk-HISEUIL2.js} +2 -2
  90. package/dist/{chunk-K5MZYZV7.js → chunk-HXOU4XNH.js} +2 -2
  91. package/dist/chunk-I6UTXNHU.js +6 -0
  92. package/dist/{chunk-I7PFL5P3.js → chunk-IJMD6BRI.js} +2 -2
  93. package/dist/{chunk-XXJ7WL3F.js → chunk-IKVNEGTW.js} +2 -2
  94. package/dist/chunk-IMKZEXZG.js +2 -0
  95. package/dist/chunk-ISIQLPJ2.js +61 -0
  96. package/dist/{chunk-DEUGHURX.js → chunk-ISWFRGJ6.js} +2 -2
  97. package/dist/chunk-IW5XQG5G.js +2 -0
  98. package/dist/chunk-IXESDH3J.js +2 -0
  99. package/dist/{chunk-FGB567HK.js → chunk-JAT6C3VX.js} +2 -2
  100. package/dist/{chunk-7TWP3MCP.js → chunk-JFQBRL3J.js} +2 -2
  101. package/dist/{chunk-Q7HB7BFJ.js → chunk-JHH5SCZ3.js} +2 -2
  102. package/dist/{chunk-ZHSARYVS.js → chunk-JJ62MTQH.js} +2 -2
  103. package/dist/chunk-JT6XX7QY.js +8 -0
  104. package/dist/{chunk-5H7IWVXJ.js → chunk-JUN5DOAK.js} +2 -2
  105. package/dist/{chunk-DOPCR5BY.js → chunk-K3XFWJI2.js} +2 -2
  106. package/dist/{chunk-Y4XQ7LES.js → chunk-KFOYCQAJ.js} +1 -1
  107. package/dist/{chunk-N5C65OFK.js → chunk-KFVSJX25.js} +2 -2
  108. package/dist/chunk-KK7GPALL.js +28 -0
  109. package/dist/{chunk-DHKBIOXF.js → chunk-KQHJEU6V.js} +2 -2
  110. package/dist/{chunk-WB6LGCFB.js → chunk-KZYID5KV.js} +2 -2
  111. package/dist/{chunk-KW6B5OL4.js → chunk-LO5JSW2C.js} +2 -2
  112. package/dist/{chunk-ZW44MCJM.js → chunk-LRI5OMPE.js} +2 -2
  113. package/dist/{chunk-HG5YI7PV.js → chunk-LXQUF2RP.js} +2 -2
  114. package/dist/{chunk-TM5XEDDR.js → chunk-MHIEP7EG.js} +2 -2
  115. package/dist/{chunk-FHV7NMFU.js → chunk-MSR2QRUE.js} +2 -2
  116. package/dist/chunk-N7FP5H5U.js +57 -0
  117. package/dist/{chunk-3653GTR7.js → chunk-NEIQPFBI.js} +2 -2
  118. package/dist/chunk-NK3JMP22.js +2 -0
  119. package/dist/{chunk-7IOAZRVL.js → chunk-NRBNAECH.js} +2 -2
  120. package/dist/{chunk-HGKEAP7F.js → chunk-NVSZNESQ.js} +2 -2
  121. package/dist/{chunk-R2MOKIVO.js → chunk-OJNK5ALA.js} +2 -2
  122. package/dist/{chunk-RFWAUHVW.js → chunk-OPSAW5DT.js} +2 -2
  123. package/dist/chunk-OTSPRVNW.js +2 -0
  124. package/dist/chunk-OXYAWIEA.js +2 -0
  125. package/dist/chunk-OZETODHH.js +2 -0
  126. package/dist/chunk-PBUH2P5S.js +3 -0
  127. package/dist/{chunk-QBANU5BQ.js → chunk-PIFTZEEM.js} +2 -2
  128. package/dist/{chunk-CKDOY6JA.js → chunk-PLJUQFQN.js} +2 -2
  129. package/dist/{chunk-JVZNWJBH.js → chunk-PLYUVM4F.js} +2 -2
  130. package/dist/chunk-PXXYQK55.js +2 -0
  131. package/dist/{chunk-WZQFY5S7.js → chunk-Q55NF3ZG.js} +2 -2
  132. package/dist/{chunk-OVPS2ILI.js → chunk-Q5TA4OY4.js} +2 -2
  133. package/dist/{chunk-OUB4J26T.js → chunk-Q6T2CAJL.js} +2 -2
  134. package/dist/chunk-Q7GBK5T7.js +81 -0
  135. package/dist/chunk-QKT4UI2Y.js +2 -0
  136. package/dist/{chunk-PIZY2GX6.js → chunk-QLBSG7U5.js} +2 -2
  137. package/dist/chunk-QWKHW6VZ.js +2 -0
  138. package/dist/{chunk-E7BJXRNV.js → chunk-R6M456QG.js} +2 -2
  139. package/dist/{chunk-MJNV7OCG.js → chunk-RDULNRSJ.js} +2 -2
  140. package/dist/{chunk-SSSJO4RG.js → chunk-RHHCLWQ6.js} +2 -2
  141. package/dist/chunk-RNKPYYYE.js +4 -0
  142. package/dist/{chunk-IXJ26KJJ.js → chunk-RPL3ARU7.js} +2 -2
  143. package/dist/{chunk-3EX7DNBC.js → chunk-RYOYJMGF.js} +2 -2
  144. package/dist/chunk-SB25YMEQ.js +2 -0
  145. package/dist/chunk-SV2LEFVM.js +2 -0
  146. package/dist/{chunk-ZBNL3QCY.js → chunk-SVHTMVA4.js} +3 -3
  147. package/dist/{chunk-6IEVHGWG.js → chunk-SWK4XPUS.js} +2 -2
  148. package/dist/chunk-T6QD2ZQB.js +43 -0
  149. package/dist/{chunk-VETXXOYU.js → chunk-TAYD3AE7.js} +2 -2
  150. package/dist/chunk-TD7VKJ2Y.js +117 -0
  151. package/dist/{chunk-UQ7XPRWU.js → chunk-TH6IC56G.js} +2 -2
  152. package/dist/{chunk-XVDMJMES.js → chunk-TKDNDQA7.js} +2 -2
  153. package/dist/{chunk-CSDDOUA4.js → chunk-TNG2FYS5.js} +2 -2
  154. package/dist/chunk-TQZV7KV4.js +2 -0
  155. package/dist/{chunk-AJVMVE7X.js → chunk-TUQIPUDS.js} +2 -2
  156. package/dist/chunk-TUSPIVZ3.js +4 -0
  157. package/dist/{chunk-ORBKAUCH.js → chunk-U2N2KE7A.js} +2 -2
  158. package/dist/{chunk-3PII3JI5.js → chunk-UAQ4T73O.js} +2 -2
  159. package/dist/{chunk-OFY4HTMI.js → chunk-UDY7MIAW.js} +2 -2
  160. package/dist/{chunk-WKPZCQLI.js → chunk-URSGGIZX.js} +2 -2
  161. package/dist/{chunk-UL4VJUMD.js → chunk-UT7TADJX.js} +2 -2
  162. package/dist/chunk-V4NG5OMS.js +554 -0
  163. package/dist/{chunk-2H4IAJHO.js → chunk-VMWUV6WB.js} +2 -2
  164. package/dist/{chunk-46JLFIGA.js → chunk-VTCIYFEK.js} +2 -2
  165. package/dist/chunk-VU6LIWHT.js +2 -0
  166. package/dist/chunk-VUSKPCUB.js +2 -0
  167. package/dist/{chunk-URMZLV2N.js → chunk-VXJJTQYE.js} +2 -2
  168. package/dist/{chunk-IPAL6DP2.js → chunk-VZ7NXSHV.js} +2 -2
  169. package/dist/{chunk-FUG6RPYY.js → chunk-WHADK6OS.js} +2 -2
  170. package/dist/chunk-WN3TCGJ4.js +2 -0
  171. package/dist/{chunk-B7ECWJAZ.js → chunk-WOOAY3PA.js} +2 -2
  172. package/dist/chunk-WRQXLNYE.js +9 -0
  173. package/dist/chunk-WSLEJSFR.js +2 -0
  174. package/dist/chunk-WYZIHUPZ.js +16 -0
  175. package/dist/{chunk-ZYREOING.js → chunk-XE33FV5W.js} +2 -2
  176. package/dist/chunk-XFMVKFSF.js +2 -0
  177. package/dist/{chunk-BBEDPVPB.js → chunk-XGGBK66W.js} +2 -2
  178. package/dist/{chunk-OFUBXBYX.js → chunk-XJX6LGHL.js} +2 -2
  179. package/dist/{chunk-Z3GCK3PD.js → chunk-XN22RGSR.js} +2 -2
  180. package/dist/{chunk-HWLCBKFE.js → chunk-XSWYJCAK.js} +2 -2
  181. package/dist/{chunk-IGKKTHJR.js → chunk-XU75YQN4.js} +2 -2
  182. package/dist/{chunk-E4EJBGDZ.js → chunk-Y2VM4CJC.js} +2 -2
  183. package/dist/{chunk-U7LRSQG6.js → chunk-Y334QQU5.js} +2 -2
  184. package/dist/{chunk-APLKXICZ.js → chunk-YAGYMBEX.js} +2 -2
  185. package/dist/{chunk-XITQLISP.js → chunk-YIHNPKWD.js} +2 -2
  186. package/dist/chunk-YXPUP5G2.js +11 -0
  187. package/dist/{chunk-6BJ7SOY7.js → chunk-Z2AWCTN6.js} +2 -2
  188. package/dist/{chunk-PHSPBQM6.js → chunk-Z2PZVKPR.js} +2 -2
  189. package/dist/{chunk-QXR5QPSF.js → chunk-ZAZGGSM3.js} +2 -2
  190. package/dist/{chunk-5236NQV3.js → chunk-ZGW4HLPD.js} +2 -2
  191. package/dist/chunk-ZOXKSQQB.js +2 -0
  192. package/dist/{chunk-BD6CV7PN.js → chunk-ZPASRBLF.js} +2 -2
  193. package/dist/{chunk-DMUGTKMD.js → chunk-ZYM4HOFA.js} +2 -2
  194. package/dist/{chunk-4ILHWBYF.js → chunk-ZZ3Z7D56.js} +2 -2
  195. package/dist/cli-main.js +4 -4
  196. package/dist/{code-CczEvHui.d.ts → code-B17qEMbt.d.ts} +1 -1
  197. package/dist/code-EQJFDT6I.js +2 -0
  198. package/dist/code-result-json-7UWIWBOO.js +2 -0
  199. package/dist/command-descriptors-ORNTVNYV.js +342 -0
  200. package/dist/{config-types-Cm-VSEBb.d.ts → config-types-B9B60MiR.d.ts} +10 -0
  201. package/dist/dataflow-6VL54GX5.js +2 -0
  202. package/dist/{db-LKJXAlNS.d.ts → db-BwIVAYNB.d.ts} +1 -1
  203. package/dist/dependence-slice-DT2NUHD2.js +2 -0
  204. package/dist/deps-DB7H5IKC.js +2 -0
  205. package/dist/direct-navigation-O3LUAYWQ.js +3 -0
  206. package/dist/entry-map-6K62RV3D.js +2 -0
  207. package/dist/files-MSLD7MO6.js +2 -0
  208. package/dist/{graph-evidence-CbUPCSKV.d.ts → graph-evidence-Bjyky2V4.d.ts} +1 -1
  209. package/dist/{health-Wl5G_LRt.d.ts → health-CPp2Jf1Z.d.ts} +1 -1
  210. package/dist/hierarchy-IVBXAKFA.js +2 -0
  211. package/dist/imports-FRAVZ3Y2.js +2 -0
  212. package/dist/index.d.ts +2 -2
  213. package/dist/index.js +1 -1
  214. package/dist/members-KJOJDYGO.js +2 -0
  215. package/dist/methods-2AYABBT3.js +2 -0
  216. package/dist/output-continuation-command-JHMPH6NC.js +3 -0
  217. package/dist/{output-pagination-VAWOGX4R.js → output-pagination-3OFL2MJV.js} +2 -2
  218. package/dist/project-reindex-HYO4WD7Z.js +3 -0
  219. package/dist/queries/affected.d.ts +2 -2
  220. package/dist/queries/affected.js +1 -1
  221. package/dist/queries/anchors.d.ts +2 -2
  222. package/dist/queries/anchors.js +1 -1
  223. package/dist/queries/architecture.d.ts +2 -2
  224. package/dist/queries/architecture.js +1 -1
  225. package/dist/queries/bottlenecks.d.ts +2 -2
  226. package/dist/queries/bottlenecks.js +1 -1
  227. package/dist/queries/by-kind.d.ts +2 -2
  228. package/dist/queries/by-kind.js +1 -1
  229. package/dist/queries/call-graph.d.ts +2 -2
  230. package/dist/queries/call-graph.js +1 -1
  231. package/dist/queries/change-surface.d.ts +2 -2
  232. package/dist/queries/change-surface.js +1 -1
  233. package/dist/queries/cleanup-plan.d.ts +2 -2
  234. package/dist/queries/cleanup-plan.js +1 -1
  235. package/dist/queries/co-change.d.ts +2 -2
  236. package/dist/queries/co-change.js +1 -1
  237. package/dist/queries/code.d.ts +3 -3
  238. package/dist/queries/code.js +1 -1
  239. package/dist/queries/complexity-hotspots.d.ts +2 -2
  240. package/dist/queries/complexity-hotspots.js +1 -1
  241. package/dist/queries/complexity.d.ts +13 -2
  242. package/dist/queries/complexity.js +1 -1
  243. package/dist/queries/context.d.ts +2 -2
  244. package/dist/queries/context.js +1 -1
  245. package/dist/queries/convergence.d.ts +2 -2
  246. package/dist/queries/convergence.js +1 -1
  247. package/dist/queries/coupling.d.ts +2 -2
  248. package/dist/queries/coupling.js +1 -1
  249. package/dist/queries/cycles.d.ts +2 -2
  250. package/dist/queries/cycles.js +1 -1
  251. package/dist/queries/dataflow.d.ts +2 -2
  252. package/dist/queries/dataflow.js +1 -1
  253. package/dist/queries/dead.d.ts +2 -2
  254. package/dist/queries/dead.js +1 -1
  255. package/dist/queries/decorative-checkers.d.ts +2 -2
  256. package/dist/queries/decorative-checkers.js +1 -1
  257. package/dist/queries/deep-chains.d.ts +2 -2
  258. package/dist/queries/deep-chains.js +1 -1
  259. package/dist/queries/dependence-slice.d.ts +3 -3
  260. package/dist/queries/dependence-slice.js +1 -1
  261. package/dist/queries/dependency-depth.d.ts +2 -2
  262. package/dist/queries/dependency-depth.js +1 -1
  263. package/dist/queries/deps.d.ts +2 -2
  264. package/dist/queries/deps.js +1 -1
  265. package/dist/queries/diff-impact.d.ts +2 -2
  266. package/dist/queries/diff-impact.js +1 -1
  267. package/dist/queries/doc-drift.d.ts +2 -2
  268. package/dist/queries/doc-drift.js +1 -1
  269. package/dist/queries/drift.d.ts +2 -2
  270. package/dist/queries/drift.js +1 -1
  271. package/dist/queries/duplicate-bodies.d.ts +2 -2
  272. package/dist/queries/duplicate-bodies.js +1 -1
  273. package/dist/queries/entry-map.d.ts +2 -2
  274. package/dist/queries/entry-map.js +1 -1
  275. package/dist/queries/evidence.d.ts +3 -3
  276. package/dist/queries/evidence.js +1 -1
  277. package/dist/queries/extract-candidates.d.ts +2 -2
  278. package/dist/queries/extract-candidates.js +1 -1
  279. package/dist/queries/fan.d.ts +2 -2
  280. package/dist/queries/fan.js +1 -1
  281. package/dist/queries/files.d.ts +2 -2
  282. package/dist/queries/files.js +1 -1
  283. package/dist/queries/health.d.ts +3 -3
  284. package/dist/queries/health.js +1 -1
  285. package/dist/queries/hierarchy.d.ts +2 -2
  286. package/dist/queries/hierarchy.js +1 -1
  287. package/dist/queries/hotspots.d.ts +2 -2
  288. package/dist/queries/hotspots.js +1 -1
  289. package/dist/queries/imports.d.ts +2 -2
  290. package/dist/queries/imports.js +1 -1
  291. package/dist/queries/incomplete-migration.d.ts +2 -2
  292. package/dist/queries/incomplete-migration.js +1 -1
  293. package/dist/queries/index.d.ts +5 -5
  294. package/dist/queries/index.js +1 -1
  295. package/dist/queries/isolated.d.ts +2 -2
  296. package/dist/queries/isolated.js +1 -1
  297. package/dist/queries/locality-candidates.d.ts +2 -2
  298. package/dist/queries/locality-candidates.js +1 -1
  299. package/dist/queries/members.d.ts +2 -2
  300. package/dist/queries/members.js +1 -1
  301. package/dist/queries/methods.d.ts +2 -2
  302. package/dist/queries/methods.js +1 -1
  303. package/dist/queries/not-implemented.d.ts +2 -2
  304. package/dist/queries/not-implemented.js +1 -1
  305. package/dist/queries/outline.d.ts +2 -2
  306. package/dist/queries/outline.js +1 -1
  307. package/dist/queries/passthrough-candidates.d.ts +2 -2
  308. package/dist/queries/passthrough-candidates.js +1 -1
  309. package/dist/queries/plan-context.d.ts +2 -2
  310. package/dist/queries/plan-context.js +1 -1
  311. package/dist/queries/react-component-duplicates.d.ts +2 -2
  312. package/dist/queries/react-component-duplicates.js +1 -1
  313. package/dist/queries/react-hook-candidates.d.ts +2 -2
  314. package/dist/queries/react-hook-candidates.js +1 -1
  315. package/dist/queries/react-large-component-pressure.d.ts +2 -2
  316. package/dist/queries/react-large-component-pressure.js +1 -1
  317. package/dist/queries/recent-duplicates.d.ts +2 -2
  318. package/dist/queries/recent-duplicates.js +1 -1
  319. package/dist/queries/redundant-reexports.d.ts +2 -2
  320. package/dist/queries/redundant-reexports.js +1 -1
  321. package/dist/queries/reference-neighborhood.d.ts +2 -2
  322. package/dist/queries/reference-neighborhood.js +1 -1
  323. package/dist/queries/reference-reachability.d.ts +2 -2
  324. package/dist/queries/reference-reachability.js +1 -1
  325. package/dist/queries/refs.d.ts +2 -2
  326. package/dist/queries/refs.js +1 -1
  327. package/dist/queries/self-audit.d.ts +2 -2
  328. package/dist/queries/self-audit.js +1 -1
  329. package/dist/queries/similar-chains.d.ts +2 -2
  330. package/dist/queries/similar-chains.js +1 -1
  331. package/dist/queries/similar-files.d.ts +2 -2
  332. package/dist/queries/similar-files.js +1 -1
  333. package/dist/queries/similar-signatures.d.ts +2 -2
  334. package/dist/queries/similar-signatures.js +1 -1
  335. package/dist/queries/similar.d.ts +2 -2
  336. package/dist/queries/similar.js +1 -1
  337. package/dist/queries/slice.d.ts +2 -2
  338. package/dist/queries/slice.js +1 -1
  339. package/dist/queries/source-inspection.d.ts +4 -4
  340. package/dist/queries/source-inspection.js +1 -1
  341. package/dist/queries/source-search.d.ts +2 -2
  342. package/dist/queries/source-search.js +1 -1
  343. package/dist/queries/stale-abstractions.d.ts +2 -2
  344. package/dist/queries/stale-abstractions.js +1 -1
  345. package/dist/queries/stats.d.ts +2 -2
  346. package/dist/queries/surface.d.ts +2 -2
  347. package/dist/queries/surface.js +1 -1
  348. package/dist/queries/symbols.d.ts +2 -2
  349. package/dist/queries/symbols.js +1 -1
  350. package/dist/queries/system-map.d.ts +2 -2
  351. package/dist/queries/system-map.js +1 -1
  352. package/dist/queries/system.d.ts +2 -2
  353. package/dist/queries/system.js +1 -1
  354. package/dist/queries/test-quality.d.ts +2 -2
  355. package/dist/queries/test-quality.js +1 -1
  356. package/dist/queries/trace.d.ts +2 -2
  357. package/dist/queries/trace.js +1 -1
  358. package/dist/queries/twin-ab.d.ts +2 -2
  359. package/dist/queries/twin-ab.js +1 -1
  360. package/dist/queries/twin-drift.d.ts +2 -2
  361. package/dist/queries/twin-drift.js +1 -1
  362. package/dist/queries/unused-imports.d.ts +2 -2
  363. package/dist/queries/unused-imports.js +1 -1
  364. package/dist/queries/unused-params.d.ts +2 -2
  365. package/dist/queries/unused-params.js +1 -1
  366. package/dist/queries/value-flow.d.ts +3 -3
  367. package/dist/queries/value-flow.js +1 -1
  368. package/dist/queries/vue-component-duplicates.d.ts +2 -2
  369. package/dist/queries/vue-component-duplicates.js +1 -1
  370. package/dist/queries/vue-composable-candidates.d.ts +2 -2
  371. package/dist/queries/vue-composable-candidates.js +1 -1
  372. package/dist/queries/vue-large-view-pressure.d.ts +2 -2
  373. package/dist/queries/vue-large-view-pressure.js +1 -1
  374. package/dist/queries/wrapper-candidates.d.ts +2 -2
  375. package/dist/queries/wrapper-candidates.js +1 -1
  376. package/dist/query-service-fastpath.js +5 -5
  377. package/dist/query-service-server.js +2 -2
  378. package/dist/refs-ARMA6XUJ.js +2 -0
  379. package/dist/refs-pagination-VUGIWN6U.js +2 -0
  380. package/dist/reindex-worker.js +125 -66
  381. package/dist/reindex.d.ts +5 -3
  382. package/dist/reindex.js +135 -76
  383. package/dist/runtime.d.ts +5 -5
  384. package/dist/runtime.js +4 -4
  385. package/dist/rust-semantic-session-server.js +1 -1
  386. package/dist/rust-semantic-session-worker.js +1 -1
  387. package/dist/rust-semantic-worker.js +1 -1
  388. package/dist/{scip-cli-CppzF5MK.d.ts → scip-cli-H-n59izO.d.ts} +1 -1
  389. package/dist/slice-YOB5YFAM.js +2 -0
  390. package/dist/surface-VY5EFWTW.js +2 -0
  391. package/dist/symbol-resolution-DGQN4XIV.js +2 -0
  392. package/dist/system-2KQ3QD2P.js +2 -0
  393. package/dist/trace-HTIPTXAE.js +2 -0
  394. package/dist/typescript-mailbox-worker.js +1 -1
  395. package/dist/value-flow-5FV3VQI7.js +2 -0
  396. package/dist/watch-server.js +3 -3
  397. package/docs/CLI_JSON_OUTPUT.md +2 -2
  398. package/docs/COMMAND_REFERENCE.md +2 -2
  399. package/docs/schemas/project-config.schema.json +11 -1
  400. package/package.json +6 -5
  401. package/skills/scip-explore/SKILL.md +73 -3
  402. package/skills/scip-explore/agents/openai.yaml +3 -3
  403. package/skills/scip-explore/references/delegated-exploration.md +51 -0
  404. package/skills/scip-explore/references/external-evidence.md +72 -0
  405. package/skills/scip-explore/references/information-model.md +51 -0
  406. package/skills/scip-explore/scripts/capture-evidence.mjs +666 -0
  407. package/skills/scip-query/SKILL.md +22 -1
  408. package/dist/by-kind-CI3O6PQG.js +0 -2
  409. package/dist/call-graph-6QTUTXH7.js +0 -2
  410. package/dist/chunk-2COFMIVK.js +0 -60
  411. package/dist/chunk-35ELD3RM.js +0 -2
  412. package/dist/chunk-3FQ3KMCD.js +0 -2
  413. package/dist/chunk-3VLJ2DCA.js +0 -2
  414. package/dist/chunk-4DCKBY6T.js +0 -5
  415. package/dist/chunk-4N6QSEMZ.js +0 -10
  416. package/dist/chunk-4OE2JO6I.js +0 -2
  417. package/dist/chunk-4UUCUASK.js +0 -554
  418. package/dist/chunk-54EOGFBR.js +0 -2
  419. package/dist/chunk-5IZTXSOL.js +0 -117
  420. package/dist/chunk-5ZJH6DDE.js +0 -2
  421. package/dist/chunk-63MBA7EG.js +0 -3
  422. package/dist/chunk-6T7H2AFY.js +0 -3
  423. package/dist/chunk-7COHFNJK.js +0 -38
  424. package/dist/chunk-7HU2IJ2T.js +0 -3
  425. package/dist/chunk-7PPYXENX.js +0 -2
  426. package/dist/chunk-AA7K3XLM.js +0 -21
  427. package/dist/chunk-AUP6YI5M.js +0 -2
  428. package/dist/chunk-CA5RE6H7.js +0 -2
  429. package/dist/chunk-CT5SI2I4.js +0 -2
  430. package/dist/chunk-D5EKVZPI.js +0 -2
  431. package/dist/chunk-DMQ7ZKJG.js +0 -81
  432. package/dist/chunk-ELNRLMC5.js +0 -29
  433. package/dist/chunk-F7WQ337U.js +0 -308
  434. package/dist/chunk-FEQIQ26E.js +0 -2
  435. package/dist/chunk-FN6EJM6Q.js +0 -2
  436. package/dist/chunk-FTSQNONX.js +0 -2
  437. package/dist/chunk-G2F6T5BV.js +0 -2
  438. package/dist/chunk-G6OGPXJW.js +0 -9
  439. package/dist/chunk-GFLTPNWV.js +0 -3
  440. package/dist/chunk-GTDP2SKQ.js +0 -2
  441. package/dist/chunk-HEOMG7IM.js +0 -8
  442. package/dist/chunk-I3U2FN2T.js +0 -13
  443. package/dist/chunk-IUJ3ZFEE.js +0 -7
  444. package/dist/chunk-LXLD46LH.js +0 -21
  445. package/dist/chunk-MEI3PTUK.js +0 -2
  446. package/dist/chunk-MO226P4Q.js +0 -4
  447. package/dist/chunk-MYUKI5VN.js +0 -4
  448. package/dist/chunk-OIRWZIYL.js +0 -38
  449. package/dist/chunk-OIVZ7PW6.js +0 -438
  450. package/dist/chunk-PNISDVYC.js +0 -3
  451. package/dist/chunk-PQOL42AW.js +0 -2
  452. package/dist/chunk-PUVZNFVY.js +0 -11
  453. package/dist/chunk-PZEI2TVL.js +0 -4
  454. package/dist/chunk-Q2J2VZZT.js +0 -2
  455. package/dist/chunk-QDCCHMVZ.js +0 -2
  456. package/dist/chunk-QLQBZOJH.js +0 -3
  457. package/dist/chunk-S73HBCGI.js +0 -11
  458. package/dist/chunk-SDPA5DKN.js +0 -210
  459. package/dist/chunk-SEUJVWT2.js +0 -3
  460. package/dist/chunk-SF7X6QNW.js +0 -2
  461. package/dist/chunk-SWFAFA4G.js +0 -49
  462. package/dist/chunk-T6FRID7Y.js +0 -3
  463. package/dist/chunk-TNOHGHZQ.js +0 -2
  464. package/dist/chunk-U2GPTA5U.js +0 -3
  465. package/dist/chunk-URTX2BEA.js +0 -6
  466. package/dist/chunk-VGRUM7JI.js +0 -3
  467. package/dist/chunk-VWLIOEEF.js +0 -11
  468. package/dist/chunk-WK4FD4PG.js +0 -2
  469. package/dist/chunk-X434XZAI.js +0 -2
  470. package/dist/chunk-YIEFEPG6.js +0 -16
  471. package/dist/chunk-YRVERHJR.js +0 -49
  472. package/dist/chunk-ZD3Z54IW.js +0 -2
  473. package/dist/chunk-ZDVDSDFG.js +0 -4
  474. package/dist/code-EQL6ZBLH.js +0 -2
  475. package/dist/code-result-json-6E4J6LGZ.js +0 -2
  476. package/dist/command-descriptors-QH3G2OVD.js +0 -346
  477. package/dist/dataflow-2BLMUZBP.js +0 -2
  478. package/dist/dependence-slice-MGAJDZXB.js +0 -2
  479. package/dist/deps-GQMUYVKW.js +0 -2
  480. package/dist/direct-navigation-6RUJKLAV.js +0 -3
  481. package/dist/entry-map-V2NQP5JU.js +0 -2
  482. package/dist/files-VM53I4IU.js +0 -2
  483. package/dist/hierarchy-D553WRSZ.js +0 -2
  484. package/dist/imports-DOZAJWLW.js +0 -2
  485. package/dist/members-HE67475K.js +0 -2
  486. package/dist/methods-K5JK4PPH.js +0 -2
  487. package/dist/output-continuation-command-LKBUTNRL.js +0 -3
  488. package/dist/project-reindex-4ARU6QCM.js +0 -3
  489. package/dist/refs-NBHKL4UQ.js +0 -2
  490. package/dist/refs-pagination-BBVTIHMH.js +0 -2
  491. package/dist/slice-U6S6LBSB.js +0 -2
  492. package/dist/surface-C7SS5CDQ.js +0 -2
  493. package/dist/symbol-resolution-3FVEKDTJ.js +0 -2
  494. package/dist/system-6K2NOO5C.js +0 -2
  495. package/dist/trace-II5K2TMH.js +0 -2
  496. package/dist/value-flow-MKFUUE5B.js +0 -2
package/dist/runtime.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { P as ProjectConfig, W as WatchConfig, b as WatchResourceBudgetConfig, a as SupportedLanguage, T as TypeScriptProjectMode, D as DerivedObservationStateAuthority, O as ObservationSourceKind, c as ObservationReceipt } from './config-types-Cm-VSEBb.js';
2
- export { d as DecodedObservationReceipt, L as LEGACY_OBSERVATION_RECEIPT_SCHEMA_VERSION, e as OBSERVATION_IDENTITY_CANONICALIZATION_VERSION, f as OBSERVATION_IDENTITY_HASH_ALGORITHM, g as OBSERVATION_IDENTITY_SCHEMA_VERSION, h as OBSERVATION_RECEIPT_SCHEMA_VERSION, i as OBSERVATION_STATE_AUTHORITY_POLICY_VERSION, j as ObservationAuthorityKind, k as ObservationComparedFact, l as ObservationComparisonReason, m as ObservationIdentity, n as ObservationReceiptComparison, o as ObservationReceiptV1, p as ObservationReceiptV2, q as ObservationRelationshipJudgment, r as ObservationRelationshipState, s as ObservationSourceFact, t as ObservationStabilityProof, u as ObservationStabilityProofKind, v as ObservationStateAuthority, R as RelevantInputIdentity, w as RelevantInputRelationshipJudgment, x as compareObservationReceipts, y as createObservationIdentity, z as decodeObservationReceipt, A as deriveObservationStateAuthority, B as isObservationReceipt, C as observationReceiptGenerationIdentity, E as observationReceiptStabilityLabel, F as observationReceiptWorkspaceIdentity } from './config-types-Cm-VSEBb.js';
1
+ import { P as ProjectConfig, W as WatchConfig, b as WatchResourceBudgetConfig, a as SupportedLanguage, T as TypeScriptProjectMode, D as DerivedObservationStateAuthority, O as ObservationSourceKind, c as ObservationReceipt } from './config-types-B9B60MiR.js';
2
+ export { d as DecodedObservationReceipt, L as LEGACY_OBSERVATION_RECEIPT_SCHEMA_VERSION, e as OBSERVATION_IDENTITY_CANONICALIZATION_VERSION, f as OBSERVATION_IDENTITY_HASH_ALGORITHM, g as OBSERVATION_IDENTITY_SCHEMA_VERSION, h as OBSERVATION_RECEIPT_SCHEMA_VERSION, i as OBSERVATION_STATE_AUTHORITY_POLICY_VERSION, j as ObservationAuthorityKind, k as ObservationComparedFact, l as ObservationComparisonReason, m as ObservationIdentity, n as ObservationReceiptComparison, o as ObservationReceiptV1, p as ObservationReceiptV2, q as ObservationRelationshipJudgment, r as ObservationRelationshipState, s as ObservationSourceFact, t as ObservationStabilityProof, u as ObservationStabilityProofKind, v as ObservationStateAuthority, R as RelevantInputIdentity, w as RelevantInputRelationshipJudgment, x as compareObservationReceipts, y as createObservationIdentity, z as decodeObservationReceipt, A as deriveObservationStateAuthority, B as isObservationReceipt, C as observationReceiptGenerationIdentity, E as observationReceiptStabilityLabel, F as observationReceiptWorkspaceIdentity } from './config-types-B9B60MiR.js';
3
3
  import { watch } from 'chokidar';
4
- import { R as RefreshTrigger, P as ProjectInputChangeJournal, W as WatcherStatus } from './scip-cli-CppzF5MK.js';
5
- export { g as getScipVersion, i as isScipInstalled, p as printScipInstallInstructions } from './scip-cli-CppzF5MK.js';
4
+ import { R as RefreshTrigger, P as ProjectInputChangeJournal, W as WatcherStatus } from './scip-cli-H-n59izO.js';
5
+ export { g as getScipVersion, i as isScipInstalled, p as printScipInstallInstructions } from './scip-cli-H-n59izO.js';
6
6
 
7
7
  /**
8
8
  * One operating-system process instance. A PID alone names a reusable slot;
@@ -163,7 +163,7 @@ interface WatchClock {
163
163
  * Design:
164
164
  * - Debounce: waits for a configurable quiet period after the last file change
165
165
  * - Single-flight: only one reindex runs at a time, never queued
166
- * - Dirty flag: changes during reindex schedule ONE follow-up
166
+ * - Dirty flag: changes during reindex cancel stale work and schedule ONE follow-up
167
167
  * - Cooldown: minimum interval between reindex completions
168
168
  * - Atomic publish: the reindexer writes temp artifacts, then promotes them
169
169
  */
package/dist/runtime.js CHANGED
@@ -1,5 +1,5 @@
1
- import{b as Me,c as Ve,e as qt,f as Yt,g as Kt,k as De,n as Le}from"./chunk-S73HBCGI.js";import{a as je}from"./chunk-2COFMIVK.js";import{D as Pe,c as xe,e as $,h as Ee,n as ke,o as _e}from"./chunk-MYUKI5VN.js";import"./chunk-DHEQMPLW.js";import{A as Re,B as Se,G as Ie,H as w,I as Oe,R as we,W as Te,Z as z,_ as Ae,ba as Ne,g as be,ga as X,l as u,n as g,o as E,p as N,q as ve,r as m,t as j}from"./chunk-MO226P4Q.js";import{existsSync as On}from"fs";import{randomUUID as xn}from"crypto";import{isAbsolute as Xi,join as rt,relative as Zi,resolve as er}from"path";var S=1,k=2,Qt="./node_modules/scip-query/docs/schemas/project-config.schema.json";function Z(e){let t=e;if(typeof e=="string")try{t=JSON.parse(e)}catch(c){return{kind:"malformed",reason:`invalid JSON: ${c instanceof Error?c.message:String(c)}`}}if(!u(t))return{kind:"malformed",reason:"project config must be a JSON object"};let n=t.schemaVersion;if(n!==void 0&&!Number.isInteger(n))return{kind:"malformed",reason:"schemaVersion must be an integer"};let i=n===void 0?S:n;if(i!==S&&i!==k)return{kind:"unsupported",schemaVersion:i,direction:i<S?"older":"future"};let r=t.$schema;if(r!==void 0&&(typeof r!="string"||r.trim()===""))return{kind:"malformed",reason:"$schema must be a non-empty string when present"};let o=F(t),s=i!==k||typeof t.$schema!="string";return i===S?{kind:"legacy",sourceVersion:S,config:o,needsMigration:s}:{kind:"supported",sourceVersion:k,config:o,needsMigration:s}}function F(e){let t=e,{$schema:n,schemaVersion:i,...r}=t;return{$schema:typeof n=="string"&&n.trim()!==""?n:Qt,schemaVersion:k,...r}}function $e(e){return`${JSON.stringify(F(e),null,2)}
2
- `}import{createHash as zt}from"crypto";var h=1,R=2,W=1,V=1,M="sha256",ne=1;function Be(e,t,n){if(!m(e)||!N(t))throw new Error("Observation identity requires a bounded projection name and positive projection version.");return{schemaVersion:W,canonicalizationVersion:V,hashAlgorithm:M,projection:{name:e,version:t},digest:zt(M).update(Xt(e,t,n)).digest("hex")}}function Xt(e,t,n){return`{"canonicalizationVersion":${V},"projection":${JSON.stringify(e)},"projectionVersion":${t},"value":${JSON.stringify(n)}}`}function ie(e){if(!u(e))return{kind:"malformed",reason:"observation receipt must be an object"};let t=e.schemaVersion;if(!Number.isInteger(t))return{kind:"malformed",reason:"observation receipt schemaVersion must be an integer"};if(t===h)return on(e)?{kind:"legacy",schemaVersion:h,receipt:e}:{kind:"malformed",reason:"observation receipt v1 fields are malformed or contradictory"};if(t===R)return sn(e)?{kind:"supported",schemaVersion:R,receipt:e}:{kind:"malformed",reason:"observation receipt v2 facts are malformed or contradictory"};let n=t;return{kind:"unsupported",schemaVersion:n,direction:n<h?"older":"future"}}function G(e){let t=ie(e);return t.kind==="legacy"||t.kind==="supported"}function re(e,t){return{collaborationDomain:I(y(e,n=>n.facts.collaborationDomain),y(t,n=>n.facts.collaborationDomain)),repositoryLineage:I(y(e,n=>n.facts.repositoryLineage),y(t,n=>n.facts.repositoryLineage)),workspaceInstance:I(y(e,n=>n.facts.workspaceInstance),y(t,n=>n.facts.workspaceInstance)),wholeContent:I(y(e,n=>n.facts.wholeContent),y(t,n=>n.facts.wholeContent)),relevantInputs:Zt(e,t),indexInput:I(y(e,n=>n.facts.index?.inputs),y(t,n=>n.facts.index?.inputs)),indexGeneration:en(e,t),observationStability:nn(e,t)}}function J(e,t,n=re(e,t)){let i=[["collaborationDomain",n.collaborationDomain],["wholeContent",n.wholeContent],["observationStability",n.observationStability]],r=[];for(let[s,c]of i)c.state!=="established"&&r.push(`${s}:${c.state}`);for(let[s,c]of[["left",e],["right",t]]){let a=rn(c);a!=="not-applicable"&&a!=="established"&&r.push(`${s}IndexAlignment:${a}`)}let o=i.some(([,s])=>s.state==="disproven")||r.some(s=>s.endsWith(":disproven"));return{policyVersion:ne,authority:r.length===0?"completion":o?"none":"advisory",requiredRelationships:["collaborationDomain","wholeContent","observationStability"],reasons:r}}function Ue(e){return e.schemaVersion===h?e.index?.generationIdentity:e.facts.index?.generation.digest}function He(e){return e.schemaVersion===h?void 0:e.facts.workspaceInstance?.digest}function qe(e){if(e.schemaVersion===h)return e.index?.alignment??"not-established";let t=e.stabilityProofs.filter(n=>n.source!=="process");return t.some(n=>n.kind==="invalidated")?"invalidated":t.length>0&&t.every(n=>n.kind==="immutable"||n.kind==="fixed-snapshot")?"fixed":t.some(n=>n.kind==="bracketed")?"bracketed":"not-established"}function Zt(e,t){let n=Fe(e),i=Fe(t);return[...new Set([...n.keys(),...i.keys()])].sort().map(o=>{let s=n.get(o),c=i.get(o),a=s?.subject??c?.subject??o,d=s?.identity.projection.name??c?.identity.projection.name??o;return{subject:a,projection:d,judgment:I(s?.identity,c?.identity)}})}function Fe(e){return e.schemaVersion!==R?new Map:new Map((e.facts.relevantInputs??[]).map(t=>[`${t.subject}\0${t.identity.projection.name}`,t]))}function en(e,t){return e.schemaVersion===h&&t.schemaVersion===h?tn(e.index?.generationIdentity,t.index?.generationIdentity):e.schemaVersion===h||t.schemaVersion===h?C("unknown",["legacy-fact-not-comparable"],Ge(e),Ge(t)):I(e.facts.index?.generation,t.facts.index?.generation)}function tn(e,t){let n=e?[{kind:"legacy-index-generation",value:e}]:[],i=t?[{kind:"legacy-index-generation",value:t}]:[];return e===void 0||t===void 0?Ye(n,i):C(e===t?"established":"disproven",[e===t?"identities-equal":"identities-different"],n,i)}function I(e,t){let n=e?[{kind:"identity",identity:e}]:[],i=t?[{kind:"identity",identity:t}]:[];return!e||!t?Ye(n,i):oe(e,t)?C(e.digest===t.digest?"established":"disproven",[e.digest===t.digest?"identities-equal":"identities-different"],n,i):C("unknown",["identity-projections-not-comparable"],n,i)}function nn(e,t){if(e.schemaVersion===h||t.schemaVersion===h)return C("unknown",["legacy-fact-not-comparable"],[],[]);let n=Je(e),i=Je(t),r=We(e),o=We(t);return r==="invalidated"||o==="invalidated"?C("disproven",[...r==="invalidated"?["left-observation-invalidated"]:[],...o==="invalidated"?["right-observation-invalidated"]:[]],n,i):r!=="fixed"||o!=="fixed"?C("unknown",[...r==="no-repository-source"?["left-observation-has-no-repository-source"]:r!=="fixed"?["left-observation-not-fixed"]:[],...o==="no-repository-source"?["right-observation-has-no-repository-source"]:o!=="fixed"?["right-observation-not-fixed"]:[]],n,i):C("established",["all-observed-sources-fixed"],n,i)}function We(e){let t=e.observedSources.filter(i=>i.kind!=="process");if(t.length===0)return"no-repository-source";let n=new Map(e.stabilityProofs.map(i=>[i.source,i.kind]));return t.some(i=>n.get(i.kind)==="invalidated")?"invalidated":t.every(i=>{let r=n.get(i.kind);return r==="immutable"||r==="fixed-snapshot"})?"fixed":"unknown"}function rn(e){if(e.schemaVersion!==R)return e.index?"unknown":"not-applicable";if(!e.observedSources.some(i=>i.kind==="index-generation"))return"not-applicable";let t=e.facts.index?.inputs;if(!t)return"unknown";let n=(e.facts.relevantInputs??[]).find(i=>oe(i.identity,t))?.identity;return n?n.digest===t.digest?"established":"disproven":"unknown"}function y(e,t){return e.schemaVersion===R?t(e):void 0}function Ge(e){return e.schemaVersion===h&&e.index?[{kind:"legacy-index-generation",value:e.index.generationIdentity}]:e.schemaVersion===R&&e.facts.index?[{kind:"identity",identity:e.facts.index.generation}]:[]}function Je(e){return e.stabilityProofs.map(t=>({kind:"stability",proof:t}))}function Ye(e,t){let n=e.length===0&&t.length===0?"both-facts-missing":e.length===0?"left-fact-missing":"right-fact-missing";return C("unknown",[n],e,t)}function C(e,t,n,i){return{state:e,reasons:t,facts:{left:n,right:i}}}function oe(e,t){return e.schemaVersion===t.schemaVersion&&e.canonicalizationVersion===t.canonicalizationVersion&&e.hashAlgorithm===t.hashAlgorithm&&e.projection.name===t.projection.name&&e.projection.version===t.projection.version}function on(e){if(!u(e))return!1;let t=e.index,n=e.worktree;return Qe(e.observedAt)&&m(e.projectIdentity)&&fn(e.authorityKind)&&(t===void 0||u(t)&&m(t.generationIdentity)&&(t.source==="immutable"||t.source==="legacy")&&(t.alignment==="not-certified"||t.alignment==="leased"))&&(n===void 0||u(n)&&m(n.identity)&&typeof n.clean=="boolean"&&(n.headCommit===void 0||m(n.headCommit))&&(n.treeOid===void 0||m(n.treeOid)))&&pn(e.authorityKind,t,n)}function sn(e){if(!u(e))return!1;let t=e.facts,n=e.observedSources,i=e.stabilityProofs;if(!Qe(e.observedAt)||!u(t)||!Array.isArray(n)||n.length===0||!n.every(cn)||!te(n,a=>a.kind)||!Array.isArray(i)||!i.every(dn)||!te(i,a=>a.source)||i.some(a=>!n.some(d=>d.kind===a.source))||!i.every(a=>ln(a,t))||["collaborationDomain","repositoryLineage","workspaceInstance","wholeContent"].some(a=>t[a]!==void 0&&!v(t[a])))return!1;let o=t.relevantInputs;if(o!==void 0&&(!Array.isArray(o)||!o.every(an)||!te(o,a=>`${a.subject}\0${a.identity.projection.name}`)))return!1;let s=t.index;if(s!==void 0&&(!u(s)||!v(s.generation)||s.inputs!==void 0&&!v(s.inputs)||s.source!=="immutable"&&s.source!=="legacy"))return!1;let c=e.diagnostics;return(c===void 0||u(c)&&(c.clean===void 0||typeof c.clean=="boolean")&&(c.headCommit===void 0||m(c.headCommit))&&(c.treeOid===void 0||m(c.treeOid)))&&un(t,n)}function v(e){return!u(e)||!u(e.projection)?!1:e.schemaVersion===W&&e.canonicalizationVersion===V&&e.hashAlgorithm===M&&m(e.projection.name)&&N(e.projection.version)&&ve(e.digest)}function an(e){return u(e)&&m(e.subject)&&v(e.identity)}function cn(e){return u(e)&&Ke(e.kind)&&(e.identity===void 0||v(e.identity))}function dn(e){return u(e)&&Ke(e.source)&&(e.kind==="immutable"||e.kind==="fixed-snapshot"||e.kind==="bracketed"||e.kind==="not-established"||e.kind==="invalidated")}function un(e,t){let n=e.index,i=t.find(a=>a.kind==="index-generation");if(i){if(!u(n)||!v(n.generation)||i.identity&&!ee(i.identity,n.generation))return!1}else if(n!==void 0)return!1;let r=e.workspaceInstance,o=t.find(a=>a.kind==="live-workspace");if(o?.identity&&(!v(r)||!ee(o.identity,r)))return!1;let s=e.wholeContent,c=t.find(a=>a.kind==="repository-snapshot");return!(c?.identity&&(!v(s)||!ee(c.identity,s)))}function ln(e,t){return e.kind==="not-established"||e.kind==="invalidated"?!0:e.source==="index-generation"?e.kind==="immutable"&&u(t.index)&&t.index.source==="immutable":e.source==="repository-snapshot"?e.kind==="fixed-snapshot":e.source==="live-workspace"?e.kind==="bracketed":!1}function ee(e,t){return oe(e,t)&&e.digest===t.digest}function pn(e,t,n){return e==="index-worktree"?t!==void 0&&n!==void 0:e==="index-only"?t!==void 0&&n===void 0:e==="worktree-only"?t===void 0&&n!==void 0:e==="process-local"&&t===void 0&&n===void 0}function fn(e){return e==="index-worktree"||e==="index-only"||e==="worktree-only"||e==="process-local"}function Ke(e){return e==="index-generation"||e==="repository-snapshot"||e==="live-workspace"||e==="process"}function Qe(e){return typeof e=="string"&&!Number.isNaN(Date.parse(e))}function te(e,t){return new Set(e.map(t)).size===e.length}import{createHash as ze}from"crypto";import{closeSync as hn,fstatSync as Xe,openSync as mn,rmSync as gn}from"fs";import{dirname as yn}from"path";var Cn=2e3,bn=10,vn=3,U=class extends Error{constructor(n,i,r){super(`Concurrent edit detected for ${n}; expected revision ${et(i)}, but found ${et(r)}. The latest file was left untouched.`);this.path=n;this.original=i;this.latest=r;this.name="FileRevisionConflictError"}path;original;latest};function tt(e,t,n={}){let i=Rn(e,n.lockTimeoutMs??Cn,n.monotonicNow??$);try{let r=Math.max(0,Math.floor(n.maxRetries??vn));for(let o=0;;o+=1){let s=B(e),c=t(s,o);if(c.kind==="unchanged")return{changed:!1,attempts:o+1,previous:s,current:s};n.onBeforeCommit?.({attempt:o,snapshot:s,mutation:c});let a=B(e);if(!In(s.revision,a.revision)){if(o<r)continue;throw new U(e,s.revision,a.revision)}try{Sn(e,c,s.revision)}catch(d){if(d.code==="EEXIST"){let l=B(e);if(o<r)continue;throw new U(e,s.revision,l.revision)}throw d}return{changed:!0,attempts:o+1,previous:s,current:B(e)}}}finally{i.release()}}function B(e){for(let t=0;t<4;t+=1){let n;try{n=mn(e,"r");let i=Ze(Xe(n)),r=Oe(n,{maxBytes:Se,inputKind:"revisioned text file"}),o=Ze(Xe(n));if(!nt(i,o))continue;return{path:e,text:r,revision:{exists:!0,hash:ze("sha256").update(r).digest("hex"),identity:o}}}catch(i){if(i.code==="ENOENT")return{path:e,text:"",revision:{exists:!1,hash:ze("sha256").update("").digest("hex")}};throw i}finally{n!==void 0&&hn(n)}}throw new Error(`Could not read a stable revision of ${e}; the file is changing continuously.`)}function Rn(e,t,n){let i=`${e}.scip-query-write.lock`,r=n()+Math.max(0,t);for(;;){let o=Ee(i,{kind:"revisioned-file-mutation",detail:{target:e}});if(o.kind==="acquired")return o.lock;if(n()>=r)throw new Error(`Timed out after ${t}ms waiting to update ${e}; the file was left untouched.`);Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,bn)}}function Sn(e,t,n){if(t.kind==="delete"){if(!n.exists)return;gn(e),we(yn(e));return}let i=t.mode??n.identity?.mode;n.exists?ke(e,t.text,{durability:"durable",mode:i}):_e(e,t.text,{durability:"durable",mode:i})}function In(e,t){return e.exists===t.exists&&e.hash===t.hash&&(e.identity===void 0?t.identity===void 0:t.identity!==void 0&&nt(e.identity,t.identity))}function Ze(e){return{dev:e.dev,ino:e.ino,size:e.size,mtimeMs:e.mtimeMs,mode:e.mode&511}}function nt(e,t){return e.dev===t.dev&&e.ino===t.ino&&e.size===t.size&&e.mtimeMs===t.mtimeMs&&e.mode===t.mode}function et(e){return e.exists?e.hash.slice(0,12):"<absent>"}var D=".scipquery.json",ot=2e3,st=5e3,se=st,at=15*6e4,ae={enabled:!0,windowMs:15*6e4,maxRebuilds:2,maxEstimatedWriteBytes:1024*1024*1024},En={enabled:!1,debounceMs:ot,cooldownMs:se,gitPollMs:2e3,idleTimeoutMs:at,autoRefresh:!0,ignore:[],resourceBudget:ae};var or=new Set(j);function H(e){let t=rt(e,D);if(!On(t))return{};let n;try{n=Ie(t,{maxBytes:Re,inputKind:"scip-query project config"})}catch(i){let r=i instanceof Error?i.message:String(i);throw new Error(`unable to read ${D} at ${t}: ${r}`,{cause:i})}return dt(Z(n),t,"read").config}function ct(e){return{...En,...e.watch,cooldownMs:Math.max(st,e.watch?.cooldownMs??se),resourceBudget:{...ae,...e.watch?.resourceBudget}}}function wn(e,t){return kn(e,t).configPath}function kn(e,t){let n=rt(e,D),i=xn(),r={collaborationDomainId:i,languages:t,watch:{enabled:!0,debounceMs:ot,cooldownMs:se,gitPollMs:2e3,idleTimeoutMs:at,autoRefresh:!0,resourceBudget:{...ae}}},o=tt(n,s=>{if(!s.revision.exists)return{kind:"write",text:it(r)};let c=_n(s,r);return c.config.collaborationDomainId?{kind:"unchanged"}:{kind:"write",text:it({...c.config,collaborationDomainId:i})}});return{configPath:n,changed:o.changed}}function _n(e,t){if(!e.revision.exists)return{config:F(t),needsMigration:!0};let n=dt(Z(e.text),e.path,"update");return{config:n.config,needsMigration:n.needsMigration}}function it(e){return $e(e)}function dt(e,t,n){if(e.kind==="legacy"||e.kind==="supported")return e;if(e.kind==="malformed"){let r=n==="read"?`invalid ${D} at ${t}: ${e.reason}`:`Cannot update ${t}: the latest project config is ${e.reason}.`;throw new Error(`${r} The file was left untouched.`)}let i=n==="read"?`invalid ${D} at ${t}`:`Cannot update ${t}: the latest project config is invalid`;throw new Error(`${i} (unsupported ${e.direction} schemaVersion ${e.schemaVersion}; this scip-query reads legacy v${S} and current v${k}). Upgrade scip-query before retrying; the file was left untouched.`)}import{existsSync as vt,lstatSync as Tn,statSync as An}from"fs";import{basename as Nn,dirname as jn,isAbsolute as le,join as b,relative as Rt,resolve as St}from"path";import{watch as Mn}from"chokidar";import Vn from"ignore";function ce(e){let t=JSON.stringify(e);return Buffer.byteLength(t)<=65536?t:void 0}var It=5e3,ue=class{projectRoot;config;watchConfig;outputDb;languages;pnpmWorkspaces;typescriptProjectMode;typescriptProjects;clojureConfigPath;indexerConcurrency;onStatus;onReindexComplete;onReindexError;onRefreshSuppressed;onError;reindexRunner;subscriptionFactory;budgetInspector;clock;activeOperation=null;stopPromise=null;stopInProgress=!1;status={state:"idle"};debounceTimer=null;cooldownTimer=null;budgetTimer=null;dirty=!1;changedFiles=0;pendingTrigger=null;pendingChanges=new Map;pendingChangesComplete=!0;pendingChangesIncompleteReason;reindexInFlight=!1;lastReindexEnd=0;fsWatchers=[];sourcePollingFallbackStarted=!1;gitPollTimer=null;lastGitState=null;preferFilesystemGitState=!0;watchGitLayout=null;localCacheWatchPath;gitignoreFilter;extraIgnore;stopped=!1;constructor(t){this.projectRoot=t.projectRoot,this.config=t.config,this.watchConfig=ct(t.config),this.outputDb=t.outputDb??b(Ne(this.projectRoot,t.config),"index.db"),this.preferFilesystemGitState=t.gitReader===void 0,this.localCacheWatchPath=Zn(this.projectRoot,jn(this.outputDb)),this.languages=t.languages,this.pnpmWorkspaces=t.config.indexer?.typescript?.pnpmWorkspaces??!1,this.typescriptProjectMode=t.config.indexer?.typescript?.projectMode,this.typescriptProjects=t.config.indexer?.typescript?.projects,this.clojureConfigPath=t.config.indexer?.clojure?.configPath,this.indexerConcurrency=t.config.indexerConcurrency,this.onStatus=t.onStatus??(()=>{}),this.onReindexComplete=t.onReindexComplete??(()=>{}),this.onReindexError=t.onReindexError??(()=>{}),this.onRefreshSuppressed=t.onRefreshSuppressed??(()=>{}),this.onError=t.onError??(n=>console.error(n.message)),this.clock=t.clock??Fn,Ot.set(this,ei(t.stopTimeoutMs??It,"watcher stop timeout")),this.reindexRunner=t.reindexRunner??wt(),this.subscriptionFactory=t.subscriptionFactory??Wn,this.budgetInspector=t.budgetInspector??Le,xt.set(this,{gitReader:t.gitReader??Te,languages:kt(t.languages??t.config.languages),stagedIndexEntries:null}),this.gitignoreFilter=je(t.projectRoot),this.extraIgnore=Vn(),this.watchConfig.ignore.length>0&&this.extraIgnore.add(this.watchConfig.ignore)}start(){if(this.stopInProgress)throw new Error("Cannot restart a watcher while its previous ownership is still draining.");this.stopped=!1,this.stopPromise=null,q(this).errors=[],this.sourcePollingFallbackStarted=!1,this.setStatus({state:"idle"}),this.startGitStatePolling();try{this.startSourceWatcher()}catch(t){this.onError(new Error(`Failed to watch ${this.projectRoot}: ${String(t)}`))}}stop(){if(this.stopPromise)return this.stopPromise;this.stopped=!0,this.stopInProgress=!0;let t=this.fsWatchers;this.fsWatchers=[],this.clearDebounceTimer(),this.clearCooldownTimer(),this.clearBudgetTimer(),this.clearGitPollTimer();let n=this.activeOperation;n&&this.setStatus({state:"draining",startedAt:this.wallNow(),reason:"waiting for the active reindex worker to exit"});let i=[...q(this).closures],r=Ln(this),o=this.clock.now()+r;return this.stopPromise=this.finishStop(t,i,n,o,r).catch(s=>{throw this.stopInProgress=!1,s}),this.stopPromise}requestRefresh(t,n={}){if(!this.stopped){if(this.markPendingChangesIncomplete(`unstructured-trigger:${t.kind}`),!n.immediate||this.reindexInFlight||this.status.state==="cooldown"||this.status.state==="budget-paused"){this.scheduleReindex(t);return}this.pendingTrigger=ft(this.pendingTrigger,t),this.changedFiles+=1,this.clearDebounceTimer(),this.triggerReindex()}}startSourceWatcher(t=!1){let n=this.subscriptionFactory(this.projectRoot,{ignoreInitial:!0,ignored:(i,r)=>this.isIgnoredWatchPath(i,r?.isDirectory()??!1),usePolling:t,ignorePermissionErrors:!0,...t?{interval:5e3,binaryInterval:1e4}:{}});n.on("all",(i,r)=>{!this.stopped&&i!=="addDir"&&i!=="unlinkDir"&&this.handleFileChange(i,r)}),n.on("error",i=>this.handleSourceWatcherError(n,i,t)),this.fsWatchers.push(n)}handleSourceWatcherError(t,n,i){if(this.markPendingChangesIncomplete("source-watcher-error"),i||this.sourcePollingFallbackStarted||!Yn(n)||this.stopped){this.onError(new Error(`Failed to watch ${this.projectRoot}: ${String(n)}`));return}this.sourcePollingFallbackStarted=!0,this.fsWatchers=this.fsWatchers.filter(r=>r!==t),$n(q(this),t,r=>this.onError(r));try{this.startSourceWatcher(!0)}catch(r){this.onError(new Error(`Failed to watch ${this.projectRoot}: ${String(r)}`))}}isIgnoredWatchPath(t,n){let i=this.relativeWatchPath(t);if(!i)return!1;if(ht(i,this.localCacheWatchPath))return!0;let r=n?`${i}/`:i;return this.gitignoreFilter.isIgnored(r)||this.extraIgnore.ignores(r)}handleFileChange(t,n){let i=this.relativeWatchPath(n);if(!i||i===".."||i.startsWith("../")||ht(i,this.localCacheWatchPath)||this.gitignoreFilter.isIgnored(i)||this.extraIgnore.ignores(i)||i.endsWith("index.db")||i.endsWith("index.scip")||i.endsWith("index.db.tmp")||Nn(i).startsWith(De)||(i===".scipquery.json"&&yt(this,this.projectRoot),!Ct(this,i)))return;let r=Hn(t);r||this.markPendingChangesIncomplete(`unsupported-source-event:${t}`),this.scheduleReindex({kind:"watch-source",detail:i},r?[{path:i,kind:r}]:void 0,r!==void 0)}relativeWatchPath(t){let n=le(t)?t:b(this.projectRoot,t);return Rt(this.projectRoot,n).replaceAll("\\","/")}scheduleReindex(t,n,i=!1){this.pendingTrigger=ft(this.pendingTrigger,t),i||this.markPendingChangesIncomplete(`unstructured-trigger:${t.kind}`);for(let o of n??[])this.recordPendingChange(o);if(this.changedFiles++,this.reindexInFlight){this.dirty=!0,this.setStatus({state:"indexing",startedAt:this.status.startedAt});return}if(this.status.state==="cooldown"){this.dirty=!0,this.setStatus({state:"cooldown",until:this.status.until,dirty:!0});return}if(this.status.state==="budget-paused"){this.dirty=!0,this.setStatus({...this.status,dirty:!0});return}this.clearDebounceTimer();let r=this.wallNow()+this.watchConfig.debounceMs;this.setStatus({state:"waiting",changedFiles:this.changedFiles,reindexAt:r}),this.debounceTimer=this.clock.setTimeout(()=>{this.debounceTimer=null,this.triggerReindex()},this.watchConfig.debounceMs)}triggerReindex(){if(this.reindexInFlight||this.stopped)return;let t=this.inspectBudget(),n=t.state!=="paused";if(t.state==="paused"&&t.reason!=="rebuild-count"){this.dirty=!0;let a=Math.max(this.wallNow()+1,t.until);this.setStatus({state:"budget-paused",until:a,dirty:!0,reason:t.detail,rebuilt:t.rebuilt,estimatedWriteBytes:t.estimatedWriteBytes}),this.clearBudgetTimer(),this.budgetTimer=this.clock.setTimeout(()=>{this.budgetTimer=null,this.dirty&&!this.stopped&&(this.dirty=!1,this.triggerReindex())},Math.min(2147483647,Math.max(1,a-this.wallNow())));return}let i=this.clock.now()-this.lastReindexEnd;if(this.lastReindexEnd>0&&i<this.watchConfig.cooldownMs){let a=this.watchConfig.cooldownMs-i;this.dirty=!0;let d=this.wallNow()+a;this.setStatus({state:"cooldown",until:d,dirty:!0}),this.cooldownTimer=this.clock.setTimeout(()=>{this.cooldownTimer=null,this.dirty&&!this.stopped&&(this.dirty=!1,this.triggerReindex())},a);return}this.reindexInFlight=!0,this.dirty=!1,this.changedFiles=0;let r=this.pendingTrigger??{kind:"watch-source"};this.pendingTrigger=null;let o=this.consumePendingChangeJournal(),s=this.wallNow();this.setStatus({state:"indexing",startedAt:s});let c=this.reindexRunner.start(this.reindexRequest(r,n,o));this.activeOperation=c,c.completion.then(a=>{if(this.reindexInFlight=!1,this.lastReindexEnd=this.clock.now(),this.stopped)return;let d=!1;try{d=this.onReindexComplete(a,r,{pendingChanges:this.dirty})===!0}catch(l){this.onError(l instanceof Error?l:new Error(String(l)))}if(this.dirty&&!this.stopped){if(d){let p=this.pendingTrigger??{kind:"unknown"};this.dirty=!1,this.changedFiles=0,this.pendingTrigger=null,this.resetPendingChanges(),this.onRefreshSuppressed(p),this.setStatus({state:"idle"});return}let l=this.wallNow()+this.watchConfig.cooldownMs;this.setStatus({state:"cooldown",until:l,dirty:!0}),this.cooldownTimer=this.clock.setTimeout(()=>{this.cooldownTimer=null,this.dirty&&!this.stopped?(this.dirty=!1,this.triggerReindex()):this.setStatus({state:"idle"})},this.watchConfig.cooldownMs)}else this.setStatus({state:"idle"})}).catch(a=>{if(this.reindexInFlight=!1,this.lastReindexEnd=this.clock.now(),this.stopped)return;let d=a instanceof Error?a:new Error(String(a));this.restorePendingChangeJournal(o),this.onReindexError(d,r),this.onError(d),this.setStatus({state:"idle"})}).finally(()=>{this.activeOperation===c&&(this.activeOperation=null)})}async finishStop(t,n,i,r,o){let s=[],c=t.map(async f=>{try{await f.close()}catch(x){s.push(`watch subscription close failed: ${String(x)}`)}});c.push(...n),i&&c.push((async()=>{try{let f=await i.cancel();f.state==="degraded"&&s.push(f.reason)}catch(f){s.push(`reindex cancellation failed: ${f instanceof Error?f.message:String(f)}`)}})());let a=c.length,d=c.map(f=>f.finally(()=>{a-=1})),l=await Dn(d,r,this.clock),p=q(this);return s.push(...p.errors),p.errors=[],l?this.stopInProgress=!1:(s.push(`watch shutdown exceeded the ${o}ms deadline with ${a} operation(s) still pending`),Promise.all(d).then(()=>{this.stopInProgress=!1})),s.length>0?(this.setStatus({state:"draining",startedAt:this.wallNow(),reason:s.join("; ")}),{state:"degraded",reasons:s}):(this.setStatus({state:"idle"}),{state:"stopped"})}wallNow(){return this.clock.wallNow?.()??this.clock.now()}inspectBudget(){try{return this.budgetInspector(this.outputDb,this.watchConfig.resourceBudget,new Date(this.wallNow()))}catch(t){return{state:"paused",reason:"activity-evidence",until:this.wallNow()+this.watchConfig.resourceBudget.windowMs,rebuilt:0,estimatedWriteBytes:0,detail:`reindex activity evidence could not be read: ${t instanceof Error?t.message:String(t)}`}}}reindexRequest(t,n=!0,i){return{projectRoot:this.projectRoot,config:this.config,languages:this.languages,pnpmWorkspaces:this.pnpmWorkspaces,typescriptProjectMode:this.typescriptProjectMode,typescriptProjects:this.typescriptProjects,clojureConfigPath:this.clojureConfigPath,indexerConcurrency:this.indexerConcurrency,trigger:t,changeJournal:i,allowExpensiveRebuild:n}}setStatus(t){this.status=t,this.onStatus(t)}recordPendingChange(t){if(this.pendingChanges.size>=1024&&!this.pendingChanges.has(t.path)){this.pendingChanges.clear(),this.markPendingChangesIncomplete("change-entry-limit");return}let n=this.pendingChanges.get(t.path),i=qn(n,t.kind);i===null?this.pendingChanges.delete(t.path):this.pendingChanges.set(t.path,i)}markPendingChangesIncomplete(t){this.pendingChangesComplete=!1,this.pendingChangesIncompleteReason??=t}consumePendingChangeJournal(){let t=Pe(this.outputDb),n=[...this.pendingChanges.entries()].map(([s,c])=>({path:s,kind:c})).sort((s,c)=>s.path.localeCompare(c.path)),i=this.pendingChangesComplete,r=this.pendingChangesIncompleteReason;t||(i=!1,r??="accepted-generation-unavailable");let o={version:1,baseGeneration:t,complete:i,...r?{incompleteReason:r}:{},entries:n};return ce(o)||(o={version:1,baseGeneration:t,complete:!1,incompleteReason:"change-journal-byte-limit",entries:[]}),this.resetPendingChanges(),o}restorePendingChangeJournal(t){let n=[...this.pendingChanges.entries()].map(([o,s])=>({path:o,kind:s})),i=this.pendingChangesComplete,r=this.pendingChangesIncompleteReason;this.resetPendingChanges(),t.complete||this.markPendingChangesIncomplete(t.incompleteReason??"failed-reindex");for(let o of t.entries)this.recordPendingChange(o);i||this.markPendingChangesIncomplete(r??"failed-reindex");for(let o of n)this.recordPendingChange(o)}resetPendingChanges(){this.pendingChanges.clear(),this.pendingChangesComplete=!0,this.pendingChangesIncompleteReason=void 0}clearDebounceTimer(){this.debounceTimer&&(this.clock.clearTimeout(this.debounceTimer),this.debounceTimer=null)}clearCooldownTimer(){this.cooldownTimer&&(this.clock.clearTimeout(this.cooldownTimer),this.cooldownTimer=null)}clearBudgetTimer(){this.budgetTimer&&(this.clock.clearTimeout(this.budgetTimer),this.budgetTimer=null)}startGitStatePolling(){this.lastGitState=this.readGitState(),this.lastGitState&&(O(this).stagedIndexEntries=bt(this.projectRoot,O(this).gitReader),this.gitPollTimer=this.clock.setInterval(()=>this.pollGitState(),this.watchConfig.gitPollMs),this.gitPollTimer.unref?.())}pollGitState(){if(this.reindexInFlight||this.stopped)return;let t=this.lastGitState,n=this.readGitState();if(!t||!n||this.stopped){this.lastGitState=n;return}this.lastGitState=n;let i=t.head!==n.head,r=t.indexPath!==n.indexPath||t.indexMtimeMs!==n.indexMtimeMs||t.indexSize!==n.indexSize;if(!i&&!r)return;let o=O(this),s=o.stagedIndexEntries,c=bt(this.projectRoot,o.gitReader);o.stagedIndexEntries=c;let a=ti(this.projectRoot,o.gitReader,t,n,s,c,i,r),d=null;if(a!==null&&(a.includes(".scipquery.json")&&yt(this,this.projectRoot),d=a.filter(p=>Ct(this,p)),d.length===0))return;let l=d?.map(p=>({path:p,kind:vt(b(this.projectRoot,p))?"change":"delete"}));i&&r?this.scheduleReindex({kind:"watch-git-state",detail:de("HEAD and index changed",d)},l,l!==void 0):i?this.scheduleReindex({kind:"watch-git-head",detail:de("HEAD changed",d)},l,l!==void 0):r&&this.scheduleReindex({kind:"watch-git-index",detail:de(n.indexPath??"index changed",d)},l,l!==void 0)}readGitState(){if(this.preferFilesystemGitState){let t=this.readFilesystemGitState();if(t)return t}return this.readGitStateFromGit()}readFilesystemGitState(){let t=this.watchGitLayout??Kn(this.projectRoot);if(!t)return null;this.watchGitLayout=t;let n=Qn(t.gitDir);return n?gt(n,t.indexPath):null}readGitStateFromGit(){let t=O(this).gitReader,n=z(this.projectRoot,["rev-parse","--git-path","index"],t);if(!n)return null;let i=Ae(this.projectRoot,n);return gt(z(this.projectRoot,["rev-parse","--verify","HEAD"],t),i)}clearGitPollTimer(){this.gitPollTimer&&(this.clock.clearInterval(this.gitPollTimer),this.gitPollTimer=null)}};async function Dn(e,t,n){if(e.length===0)return!0;let i=Promise.all(e).then(()=>!0),r=Math.max(0,t-n.now()),o=null,s=new Promise(a=>{o=n.setTimeout(()=>a(!1),r)}),c=await Promise.race([i,s]);return c&&o&&n.clearTimeout(o),c}var lt=new WeakMap,Ot=new WeakMap,xt=new WeakMap;function q(e){let t=lt.get(e);if(t)return t;let n={closures:new Set,errors:[]};return lt.set(e,n),n}function Ln(e){return Ot.get(e)??It}function O(e){let t=xt.get(e);if(!t)throw new Error("Watcher input state was not initialized.");return t}function $n(e,t,n){let i=Promise.resolve().then(()=>t.close()).catch(r=>{let o=`watch subscription close failed during polling fallback: ${String(r)}`;e.errors.push(o),n(new Error(o))});e.closures.add(i),i.then(()=>e.closures.delete(i))}function Et(e,t=xe){let{projectRoot:n,config:i,languages:r,pnpmWorkspaces:o,typescriptProjectMode:s,typescriptProjects:c,clojureConfigPath:a,indexerConcurrency:d,trigger:l}=e,p=H(n),f=Object.keys(p).length>0?p:i,x=X(n,f),Q=f.indexer?.typescript,Ht=f.indexer?.clojure,Ce=t(process.pid);if(!Ce)throw new Error(`Could not establish watcher process identity for reindex worker ownership (pid ${process.pid}).`);return{workerPath:new URL("./reindex-worker.js",import.meta.url).pathname,env:{...process.env,SCIP_REINDEX_PROJECT_ROOT:n,SCIP_REINDEX_OUTPUT_SCIP:x.indexPath,SCIP_REINDEX_OUTPUT_DB:x.dbPath,SCIP_REINDEX_LANGUAGES:(f.languages??r)?.join(",")??"",SCIP_REINDEX_INDEXER_CONCURRENCY:String(f.indexerConcurrency??d??""),SCIP_REINDEX_PNPM_WORKSPACES:Q?.pnpmWorkspaces??o?"1":"",SCIP_REINDEX_TYPESCRIPT_CONFIG:JSON.stringify({projectMode:Q?.projectMode??s,projects:Q?.projects??c??[]}),SCIP_REINDEX_CLOJURE_CONFIG_PATH:Ht?.configPath??a??"",SCIP_REINDEX_TRIGGER_KIND:l.kind,SCIP_REINDEX_TRIGGER_DETAIL:l.detail??"",SCIP_REINDEX_CHANGE_JOURNAL:e.changeJournal?ce(e.changeJournal)??"":"",SCIP_REINDEX_ALLOW_EXPENSIVE:e.allowExpensiveRebuild===!1?"0":"1",SCIP_REINDEX_PROCESS_GROUP_LEADER:"1",SCIP_REINDEX_PARENT_IDENTITY:JSON.stringify(Ce)}}}var Fn={now:$,wallNow:()=>Date.now(),setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Wn=(e,t)=>Mn(e,t),Gn=15*6e4,Jn=1e3,Bn=64*1024;function Un(){return{stdoutTail:"",stderrTail:"",stdoutTruncated:!1,stderrTruncated:!1}}function pt(e,t){let n=e instanceof Error?e.message:String(e),i=t.stderrTail.trim()||t.stdoutTail.trim();return i?`${n}
3
- ${i}`:n}function wt(e={}){let t=e.timeoutMs??Gn,n=e.terminationGraceMs??Jn,i=e.maxOutputBytes??Bn,r=e.resolveLaunch??Et;return{start(o){let s=r(o),c=new AbortController,a=Un(),d=!1,l=Ve({command:process.execPath,args:[...process.execArgv,s.workerPath],label:"watch reindex worker",env:s.env,timeoutMs:t,terminationGraceMs:n,maxStdoutBytes:i,maxStderrBytes:i,outputLimitBehavior:"truncate-tail",signal:c.signal,detached:!0}).then(p=>{if(a={stdoutTail:p.stdout,stderrTail:p.stderr,stdoutTruncated:p.stdoutTruncated,stderrTruncated:p.stderrTruncated},p.status!==0)throw new Error(pt(new Error(`Reindex worker exited with ${p.signal?`signal ${p.signal}`:`code ${p.status}`}`),a));return p.durationMs}).catch(p=>{throw p instanceof Me&&(a={stdoutTail:p.stdout,stderrTail:p.stderr,stdoutTruncated:p.stdoutTruncated,stderrTruncated:p.stderrTruncated}),new Error(pt(p,a),{cause:p})}).finally(()=>{d=!0});return{completion:l,async cancel(){d||c.abort();try{await l}catch{}return{state:"exited",diagnostics:a}},diagnostics:()=>a}}}}function ft(e,t){return e?e.kind===t.kind?e.detail===t.detail?e:{kind:e.kind,detail:"multiple changes"}:{kind:"watch-git-state",detail:`${e.kind}, ${t.kind}`}:t}function Hn(e){if(e==="add")return"add";if(e==="change")return"change";if(e==="unlink")return"delete"}function qn(e,t){return e?e==="add"?t==="delete"?null:"add":e==="delete"&&t==="add"?"change":t:t}function Yn(e){return e instanceof Error&&"code"in e&&e.code==="EMFILE"||String(e).includes("EMFILE: too many open files")}var pe=/^[0-9a-f]{40,64}$/i;function ht(e,t){return e===".git"||e.startsWith(".git/")||e==="node_modules"||e.startsWith("node_modules/")||e.endsWith("/node_modules")||e.includes("/node_modules/")?!0:t!==void 0&&(e===t||e.startsWith(`${t}/`))}function Kn(e){let t=b(e,".git");try{let n=Tn(t),i;if(n.isDirectory())i=t;else if(n.isFile()){let r=/^gitdir:\s*(.+)\s*$/m.exec(w(t,"Git directory marker"));if(!r?.[1])return null;let o=r[1].trim();i=le(o)?o:St(e,o)}else return null;return vt(i)?{gitDir:i,indexPath:b(i,"index")}:null}catch{return null}}function Qn(e){let t;try{t=w(b(e,"HEAD"),"Git HEAD").trim()}catch{return}if(pe.test(t))return t.toLowerCase();let n=/^ref:\s*(.+)$/.exec(t)?.[1]?.trim();if(!n)return;let i=zn(e);return mt(e,n)??mt(i,n)??Xn(i,n)}function zn(e){try{let t=w(b(e,"commondir"),"Git common-directory marker").trim();return t?le(t)?t:St(e,t):e}catch{return e}}function mt(e,t){try{let n=w(b(e,t),"Git reference").trim();return pe.test(n)?n.toLowerCase():void 0}catch{return}}function Xn(e,t){try{for(let n of w(b(e,"packed-refs"),"Git packed references").split(`
4
- `)){if(n.startsWith("#")||n.startsWith("^"))continue;let i=n.indexOf(" ");if(i===-1)continue;let r=n.slice(0,i);if(n.slice(i+1).trim()===t&&pe.test(r))return r.toLowerCase()}}catch{return}}function gt(e,t){let n={head:e,indexPath:t};try{let i=An(t);n.indexMtimeMs=i.mtimeMs,n.indexSize=i.size}catch{n.indexMtimeMs=void 0,n.indexSize=void 0}return n}function Zn(e,t){let n=Rt(e,t).replaceAll("\\","/");if(!(!n||n===".."||n.startsWith("../")))return n}function ei(e,t){if(!Number.isSafeInteger(e)||e<=0)throw new Error(`${t} must be a positive integer.`);return e}function kt(e){return e&&e.length>0?[...e]:j}function yt(e,t){try{O(e).languages=kt(H(t).languages)}catch{O(e).languages=j}}function Ct(e,t){return be(t,O(e).languages)!=="other"}function ti(e,t,n,i,r,o,s,c){let a=new Set;if(s){if(!n.head||!i.head)return null;let d=t.runResult(e,["diff","--name-only","-z","--no-renames","--relative",n.head,i.head,"--"]);if(d.kind!=="success")return null;for(let l of ni(d.output))a.add(l)}if(c){if(r===null||o===null)return null;for(let d of ri(r,o))a.add(d)}return[...a].sort()}function bt(e,t){let n=t.runResult(e,["diff","--cached","--raw","-z","--no-renames","--relative","--"]);return n.kind==="success"?ii(n.output):null}function ni(e){return e.split("\0").filter(t=>t.length>0)}function ii(e){let t=e.split("\0");if(t.at(-1)===""&&t.pop(),t.length%2!==0)return null;let n=new Map;for(let i=0;i<t.length;i+=2){let r=t[i],o=t[i+1];if(!r.startsWith(":")||!o)return null;n.set(o,r)}return n}function ri(e,t){return[...new Set([...e.keys(),...t.keys()])].filter(i=>e.get(i)!==t.get(i))}function de(e,t){return t===null?`${e}; changed paths unavailable`:t.length===0?e:t.length===1?t[0]:`${t.length} compiler inputs changed`}import{existsSync as fe,mkdirSync as oi,symlinkSync as si,readlinkSync as _t,unlinkSync as Pt,readdirSync as ai}from"fs";import{join as _,dirname as he,resolve as P,relative as ci,isAbsolute as di}from"path";import{homedir as ui,platform as li}from"os";import{fileURLToPath as pi}from"url";var fi=li()==="win32";var Tt=["scip-query","scip-plan","scip-setup","scip-integrity-audit","scip-explore","concrete-plan"];function hi(e={}){let t=e.quiet?()=>{}:console.log,n=pi(import.meta.url),i=P(he(n),"..","skills"),r=e.homeDir??process.env.SCIP_QUERY_SKILLS_HOME??ui(),o=[_(r,".claude","skills"),_(r,".codex","skills"),_(r,".agents","skills")],s={installed:[],skipped:[],alreadyLinked:[],pruned:[]};for(let c of o){let a=he(c);if(!fe(a))continue;oi(c,{recursive:!0});let d=yi(c);mi(c,i,d,s,t);for(let l of Tt){let p=_(i,l),f=_(c,l);if(!fe(p)){s.skipped.push(`${d}/${l}`);continue}if(fe(f)){try{let x=_t(f);if(P(x)===P(p)){s.alreadyLinked.push(`${d}/${l}`),t(` ok: ${l} \u2192 ${d} (already linked)`);continue}}catch{s.skipped.push(`${d}/${l}`),t(` skip: ${l} \u2192 ${d} (exists, not a symlink)`);continue}Pt(f)}si(p,f,fi?"junction":"dir"),s.installed.push(`${d}/${l}`),t(` done: ${l} \u2192 ${d}`)}}return s}function mi(e,t,n,i,r){let o=new Set(Tt);for(let s of ai(e)){if(o.has(s))continue;let c=_(e,s),a;try{a=P(he(c),_t(c))}catch{continue}gi(a,t)&&(Pt(c),i.pruned.push(`${n}/${s}`),r(` prune: ${s} \u2192 ${n} (removed stale scip-query skill link)`))}}function gi(e,t){let n=ci(P(t),P(e));return n===""||!n.startsWith("..")&&!di(n)}function yi(e){return e.includes(".codex")?"Codex":e.includes(".agents")?"Agents":"Claude"}var At=["repository-observation","repository-preview","mutation","composite","environment-observation","tool-information"];function Ci(e,t=[]){return{defaultRole:e,...t.length>0?{rules:t}:{}}}function bi(e,t){for(let n of e.rules??[]){if(n.when.kind==="option-present"){let r=t.options[n.when.name];if(r!==void 0&&r!==!1)return n.role;continue}if((n.when.kind==="argument"?t.args[n.when.index]:t.options[n.when.name])===n.when.equals)return n.role}return e.defaultRole}function vi(e){return[...new Set([e.defaultRole,...(e.rules??[]).map(t=>t.role)])]}function Y(e){return At.includes(e)}function Ri(e){return e==="repository-observation"||e==="repository-preview"||e==="composite"}var me=1,ge=1,K=["compiler-graph","semantic-analysis","repository-source","change-history","runtime-measurement","heuristic","mixed","unknown"],Nt=["complete","partial","unknown"],jt=["validated","failed","not-evaluated","not-applicable"],Mt=["observe","advise","require-adjudication","block","not-established"],Vt={policyId:"scip-query:unresolved-repository-policy",policyVersion:ge,permission:"not-established",reasons:["No repository action policy was supplied for this claim."]};function Si(e){return{schemaVersion:me,origin:e.contract.origin,coverage:Dt(e.coverage),producerValidation:e.contract.producerValidation,stateAuthority:J(e.receipt,e.receipt),repositoryPolicy:e.repositoryPolicy??Vt,...e.contract.families?{families:e.contract.families}:{}}}function Dt(e){return e?e.complete===!0?{state:"complete",returned:e.returned,totalKnown:!0,total:e.total??e.returned,omitted:0}:e.totalKnown?{state:"partial",returned:e.returned,totalKnown:!0,...e.total===void 0?{}:{total:e.total},...e.omitted===void 0?{}:{omitted:e.omitted}}:{state:"unknown",returned:e.returned,totalKnown:!1}:{state:"unknown",returned:0,totalKnown:!1}}function Ii(e,t){let n=[];return L(n,"origin",t.origins,e.origin),L(n,"coverage",t.coverage,e.coverage.state),L(n,"producer-validation",t.producerValidation,e.producerValidation.status),L(n,"state-authority",t.stateAuthority,e.stateAuthority.authority),L(n,"action-permission",t.actionPermission,e.repositoryPolicy.permission),{satisfied:n.every(i=>i.satisfied),predicates:n}}function L(e,t,n,i){n&&e.push({predicate:t,satisfied:n.includes(i),required:n,actual:i})}function ye(e){return!u(e)||e.schemaVersion!==me||!T(e.origin,K)||!Oi(e.coverage)||!xi(e.producerValidation)||!Ei(e.stateAuthority)||!wi(e.repositoryPolicy)?!1:e.families===void 0||ki(e.families)}function Oi(e){return!u(e)||!T(e.state,Nt)||!E(e.returned)||typeof e.totalKnown!="boolean"||e.total!==void 0&&!E(e.total)||e.omitted!==void 0&&!E(e.omitted)?!1:e.state==="complete"?e.totalKnown===!0&&e.total===e.returned&&e.omitted===0:e.state==="partial"?e.totalKnown===!0&&E(e.total)&&E(e.omitted)&&e.total===Number(e.returned)+Number(e.omitted):e.totalKnown===!1}function xi(e){if(!u(e)||!T(e.status,jt))return!1;let t=e.certification;return e.status==="validated"||e.status==="failed"?u(t)&&g(t.id)&&Number.isSafeInteger(t.version)&&Number(t.version)>0&&g(t.corpus):t===void 0}function Ei(e){return u(e)&&Number.isSafeInteger(e.policyVersion)&&(e.authority==="completion"||e.authority==="advisory"||e.authority==="none")&&Array.isArray(e.requiredRelationships)&&e.requiredRelationships.every(g)&&Array.isArray(e.reasons)&&e.reasons.every(g)}function wi(e){return u(e)&&g(e.policyId)&&e.policyVersion===ge&&T(e.permission,Mt)&&Array.isArray(e.reasons)&&e.reasons.every(g)}function ki(e){return Array.isArray(e)&&e.every(t=>u(t)&&g(t.id)&&g(t.selector)&&_i(t.origin))}function _i(e){return u(e)?e.kind==="fixed"?T(e.origin,K)&&e.origin!=="mixed":e.kind!=="result-field"||!g(e.field)||!u(e.values)?!1:Object.values(e.values).every(t=>T(t,K)&&t!=="mixed"):!1}function T(e,t){return typeof e=="string"&&t.includes(e)}var Ft="scip-query-result",Wt=0,A=1,Pi=1,Gt=1,Jt=1;function Bt(e){if(!u(e))return{kind:"malformed",reason:"CLI JSON output must be an object."};let t=Object.hasOwn(e,"kind"),n=Object.hasOwn(e,"schemaVersion");if(!t&&!n){let s=Lt(e);return s?{kind:"malformed",reason:`Legacy CLI JSON envelope: ${s}`}:{kind:"legacy",schemaVersion:Wt,envelope:e}}if(!t||!n)return{kind:"malformed",reason:"CLI JSON envelope must contain both kind and schemaVersion."};if(e.kind!==Ft)return{kind:"malformed",reason:`Unsupported CLI JSON envelope kind: ${ji(e.kind)}.`};let i=e.schemaVersion;if(!Number.isSafeInteger(i)||Number(i)<1)return{kind:"malformed",reason:"CLI JSON envelope schemaVersion must be a positive safe integer."};if(i!==A)return{kind:"unsupported",schemaVersion:Number(i),direction:Number(i)<A?"older":"future",...$t(e.producer)?{producer:e.producer}:{}};let r=Lt(e);if(r)return{kind:"malformed",reason:`CLI JSON envelope v1: ${r}`};if(!$t(e.producer))return{kind:"malformed",reason:"CLI JSON envelope v1: producer must identify scip-query and its non-empty version."};if(!N(e.resultSchemaVersion))return{kind:"malformed",reason:"CLI JSON envelope v1: resultSchemaVersion must be a positive safe integer."};if(e.resultProjection!==void 0&&e.resultProjection!=="agent")return{kind:"malformed",reason:'CLI JSON envelope v1: resultProjection must be "agent" when present.'};let o=Ut(e.command);return o.includes(e.resultSchemaVersion)?e.evidenceContext!==void 0&&!Ni(e.evidenceContext)?{kind:"malformed",reason:"CLI JSON envelope v1: evidenceContext must contain a supported receipt and analysis manifest."}:e.operationRole!==void 0&&!Y(e.operationRole)?{kind:"malformed",reason:"CLI JSON envelope v1: operationRole must be a supported command operation role."}:u(e.evidenceContext)&&e.operationRole!==void 0&&e.evidenceContext.operationRole!==void 0&&e.operationRole!==e.evidenceContext.operationRole?{kind:"malformed",reason:"CLI JSON envelope v1: top-level and evidence-context operation roles must agree."}:{kind:"supported",schemaVersion:A,envelope:e}:{kind:"unsupported-result",schemaVersion:A,command:e.command,resultSchemaVersion:e.resultSchemaVersion,supportedResultSchemaVersions:o}}function Ti(e){let t=Bt(e);if(t.kind==="legacy"||t.kind==="supported")return t;if(t.kind==="unsupported"){let n=t.producer?` from ${t.producer.name}@${t.producer.version}`:"";throw new Error(`Unsupported scip-query CLI JSON schemaVersion ${t.schemaVersion}${n}; this consumer supports the legacy unversioned envelope and schemaVersion ${A}.`)}throw t.kind==="unsupported-result"?new Error(`Unsupported resultSchemaVersion ${t.resultSchemaVersion} for scip-query command ${JSON.stringify(t.command)}; this consumer supports ${t.supportedResultSchemaVersions.join(", ")}.`):new Error(`Malformed scip-query CLI JSON envelope: ${t.reason}`)}function Ut(e){return Ai[e]??[Pi]}var Ai={};function Lt(e){return typeof e.command!="string"||e.command.length===0?"command must be a non-empty string.":Array.isArray(e.args)?u(e.options)?Object.hasOwn(e,"result")?null:"result is required.":"options must be an object.":"args must be an array."}function $t(e){return u(e)&&e.name==="scip-query"&&typeof e.version=="string"&&e.version.length>0}function Ni(e){if(!u(e)||e.schemaVersion!==Gt||e.operationRole!==void 0&&!Y(e.operationRole)||!G(e.receipt))return!1;let t=e.analysisManifest;return u(t)&&t.schemaVersion===Jt&&(t.evidence===void 0||t.evidence==="graph-fact"||t.evidence==="heuristic"||t.evidence==="mixed")&&(t.claimQualification===void 0||ye(t.claimQualification))}function ji(e){return typeof e=="string"?JSON.stringify(e):String(e)}export{Mt as CLAIM_ACTION_PERMISSIONS,ge as CLAIM_ACTION_POLICY_VERSION,Nt as CLAIM_COVERAGE_STATES,K as CLAIM_ORIGINS,me as CLAIM_QUALIFICATION_SCHEMA_VERSION,Jt as CLI_ANALYSIS_MANIFEST_SCHEMA_VERSION,Gt as CLI_EVIDENCE_CONTEXT_SCHEMA_VERSION,Ft as CLI_JSON_ENVELOPE_KIND,At as COMMAND_OPERATION_ROLES,A as CURRENT_CLI_JSON_ENVELOPE_SCHEMA_VERSION,Vt as DEFAULT_REPOSITORY_POLICY_ACTION,Wt as LEGACY_CLI_JSON_ENVELOPE_SCHEMA_VERSION,h as LEGACY_OBSERVATION_RECEIPT_SCHEMA_VERSION,V as OBSERVATION_IDENTITY_CANONICALIZATION_VERSION,M as OBSERVATION_IDENTITY_HASH_ALGORITHM,W as OBSERVATION_IDENTITY_SCHEMA_VERSION,R as OBSERVATION_RECEIPT_SCHEMA_VERSION,ne as OBSERVATION_STATE_AUTHORITY_POLICY_VERSION,jt as PRODUCER_VALIDATION_STATUSES,ue as Watcher,Ci as commandOperation,vi as commandOperationRoles,re as compareObservationReceipts,Be as createObservationIdentity,wt as createReindexRunner,Bt as decodeCliJsonEnvelope,ie as decodeObservationReceipt,Dt as deriveClaimCoverage,Si as deriveClaimQualification,J as deriveObservationStateAuthority,Ii as evaluateClaimQualification,Yt as getScipVersion,wn as initProjectConfig,hi as installSkills,ye as isClaimQualificationV1,Y as isCommandOperationRole,G as isObservationReceipt,qt as isScipInstalled,H as loadProjectConfig,Ue as observationReceiptGenerationIdentity,qe as observationReceiptStabilityLabel,He as observationReceiptWorkspaceIdentity,Ri as operationObservesRepository,Kt as printScipInstallInstructions,Ti as requireCompatibleCliJsonEnvelope,bi as resolveCommandOperationRole,X as resolveIndexStoragePaths,Et as resolveReindexWorkerLaunch,Ut as supportedCliResultSchemaVersions};
1
+ import{b as Ke,c as qe,e as sn,f as an,g as cn,l as Ye,o as Qe}from"./chunk-AMIMMNA4.js";import{c as Me,t as We,w as He}from"./chunk-ISIQLPJ2.js";import{c as je,e as G,g as De,h as Le}from"./chunk-HG722PO7.js";import"./chunk-DHEQMPLW.js";import{$ as Fe,C as _e,D as Te,Fa as Ue,I as Ae,J as O,L as Ne,T as Ve,X as $e,_ as ne,da as Ge,g as te,ga as Je,i as we,ja as Be,n as p,oa as J,p as g,q as w,r as j,s as Pe,t as m,v as M,x as ke}from"./chunk-GH5YSGZL.js";import{existsSync as Vn}from"fs";import{randomUUID as Dn}from"crypto";import{isAbsolute as br,join as ft,relative as vr,resolve as Rr}from"path";var x=1,P=2,dn="./node_modules/scip-query/docs/schemas/project-config.schema.json";function ie(e){let t=e;if(typeof e=="string")try{t=JSON.parse(e)}catch(a){return{kind:"malformed",reason:`invalid JSON: ${a instanceof Error?a.message:String(a)}`}}if(!p(t))return{kind:"malformed",reason:"project config must be a JSON object"};let n=t.schemaVersion;if(n!==void 0&&!Number.isInteger(n))return{kind:"malformed",reason:"schemaVersion must be an integer"};let i=n===void 0?x:n;if(i!==x&&i!==P)return{kind:"unsupported",schemaVersion:i,direction:i<x?"older":"future"};let r=t.$schema;if(r!==void 0&&(typeof r!="string"||r.trim()===""))return{kind:"malformed",reason:"$schema must be a non-empty string when present"};let o=B(t),s=i!==P||typeof t.$schema!="string";return i===x?{kind:"legacy",sourceVersion:x,config:o,needsMigration:s}:{kind:"supported",sourceVersion:P,config:o,needsMigration:s}}function B(e){let t=e,{$schema:n,schemaVersion:i,...r}=t;return{$schema:typeof n=="string"&&n.trim()!==""?n:dn,schemaVersion:P,...r}}function re(e){return`${JSON.stringify(B(e),null,2)}
2
+ `}import{createHash as un}from"crypto";var f=1,I=2,U=1,D=1,V="sha256",ae=1;function tt(e,t,n){if(!m(e)||!j(t))throw new Error("Observation identity requires a bounded projection name and positive projection version.");return{schemaVersion:U,canonicalizationVersion:D,hashAlgorithm:V,projection:{name:e,version:t},digest:un(V).update(ln(e,t,n)).digest("hex")}}function ln(e,t,n){return`{"canonicalizationVersion":${D},"projection":${JSON.stringify(e)},"projectionVersion":${t},"value":${JSON.stringify(n)}}`}function ce(e){if(!p(e))return{kind:"malformed",reason:"observation receipt must be an object"};let t=e.schemaVersion;if(!Number.isInteger(t))return{kind:"malformed",reason:"observation receipt schemaVersion must be an integer"};if(t===f)return yn(e)?{kind:"legacy",schemaVersion:f,receipt:e}:{kind:"malformed",reason:"observation receipt v1 fields are malformed or contradictory"};if(t===I)return Cn(e)?{kind:"supported",schemaVersion:I,receipt:e}:{kind:"malformed",reason:"observation receipt v2 facts are malformed or contradictory"};let n=t;return{kind:"unsupported",schemaVersion:n,direction:n<f?"older":"future"}}function H(e){let t=ce(e);return t.kind==="legacy"||t.kind==="supported"}function de(e,t){return{collaborationDomain:E(y(e,n=>n.facts.collaborationDomain),y(t,n=>n.facts.collaborationDomain)),repositoryLineage:E(y(e,n=>n.facts.repositoryLineage),y(t,n=>n.facts.repositoryLineage)),workspaceInstance:E(y(e,n=>n.facts.workspaceInstance),y(t,n=>n.facts.workspaceInstance)),wholeContent:E(y(e,n=>n.facts.wholeContent),y(t,n=>n.facts.wholeContent)),relevantInputs:pn(e,t),indexInput:E(y(e,n=>n.facts.index?.inputs),y(t,n=>n.facts.index?.inputs)),indexGeneration:hn(e,t),observationStability:mn(e,t)}}function K(e,t,n=de(e,t)){let i=[["collaborationDomain",n.collaborationDomain],["wholeContent",n.wholeContent],["observationStability",n.observationStability]],r=[];for(let[s,a]of i)a.state!=="established"&&r.push(`${s}:${a.state}`);for(let[s,a]of[["left",e],["right",t]]){let c=gn(a);c!=="not-applicable"&&c!=="established"&&r.push(`${s}IndexAlignment:${c}`)}let o=i.some(([,s])=>s.state==="disproven")||r.some(s=>s.endsWith(":disproven"));return{policyVersion:ae,authority:r.length===0?"completion":o?"none":"advisory",requiredRelationships:["collaborationDomain","wholeContent","observationStability"],reasons:r}}function nt(e){return e.schemaVersion===f?e.index?.generationIdentity:e.facts.index?.generation.digest}function it(e){return e.schemaVersion===f?void 0:e.facts.workspaceInstance?.digest}function rt(e){if(e.schemaVersion===f)return e.index?.alignment??"not-established";let t=e.stabilityProofs.filter(n=>n.source!=="process");return t.some(n=>n.kind==="invalidated")?"invalidated":t.length>0&&t.every(n=>n.kind==="immutable"||n.kind==="fixed-snapshot")?"fixed":t.some(n=>n.kind==="bracketed")?"bracketed":"not-established"}function pn(e,t){let n=Xe(e),i=Xe(t);return[...new Set([...n.keys(),...i.keys()])].sort().map(o=>{let s=n.get(o),a=i.get(o),c=s?.subject??a?.subject??o,d=s?.identity.projection.name??a?.identity.projection.name??o;return{subject:c,projection:d,judgment:E(s?.identity,a?.identity)}})}function Xe(e){return e.schemaVersion!==I?new Map:new Map((e.facts.relevantInputs??[]).map(t=>[`${t.subject}\0${t.identity.projection.name}`,t]))}function hn(e,t){return e.schemaVersion===f&&t.schemaVersion===f?fn(e.index?.generationIdentity,t.index?.generationIdentity):e.schemaVersion===f||t.schemaVersion===f?b("unknown",["legacy-fact-not-comparable"],Ze(e),Ze(t)):E(e.facts.index?.generation,t.facts.index?.generation)}function fn(e,t){let n=e?[{kind:"legacy-index-generation",value:e}]:[],i=t?[{kind:"legacy-index-generation",value:t}]:[];return e===void 0||t===void 0?ot(n,i):b(e===t?"established":"disproven",[e===t?"identities-equal":"identities-different"],n,i)}function E(e,t){let n=e?[{kind:"identity",identity:e}]:[],i=t?[{kind:"identity",identity:t}]:[];return!e||!t?ot(n,i):ue(e,t)?b(e.digest===t.digest?"established":"disproven",[e.digest===t.digest?"identities-equal":"identities-different"],n,i):b("unknown",["identity-projections-not-comparable"],n,i)}function mn(e,t){if(e.schemaVersion===f||t.schemaVersion===f)return b("unknown",["legacy-fact-not-comparable"],[],[]);let n=et(e),i=et(t),r=ze(e),o=ze(t);return r==="invalidated"||o==="invalidated"?b("disproven",[...r==="invalidated"?["left-observation-invalidated"]:[],...o==="invalidated"?["right-observation-invalidated"]:[]],n,i):r!=="fixed"||o!=="fixed"?b("unknown",[...r==="no-repository-source"?["left-observation-has-no-repository-source"]:r!=="fixed"?["left-observation-not-fixed"]:[],...o==="no-repository-source"?["right-observation-has-no-repository-source"]:o!=="fixed"?["right-observation-not-fixed"]:[]],n,i):b("established",["all-observed-sources-fixed"],n,i)}function ze(e){let t=e.observedSources.filter(i=>i.kind!=="process");if(t.length===0)return"no-repository-source";let n=new Map(e.stabilityProofs.map(i=>[i.source,i.kind]));return t.some(i=>n.get(i.kind)==="invalidated")?"invalidated":t.every(i=>{let r=n.get(i.kind);return r==="immutable"||r==="fixed-snapshot"})?"fixed":"unknown"}function gn(e){if(e.schemaVersion!==I)return e.index?"unknown":"not-applicable";if(!e.observedSources.some(i=>i.kind==="index-generation"))return"not-applicable";let t=e.facts.index?.inputs;if(!t)return"unknown";let n=(e.facts.relevantInputs??[]).find(i=>ue(i.identity,t))?.identity;return n?n.digest===t.digest?"established":"disproven":"unknown"}function y(e,t){return e.schemaVersion===I?t(e):void 0}function Ze(e){return e.schemaVersion===f&&e.index?[{kind:"legacy-index-generation",value:e.index.generationIdentity}]:e.schemaVersion===I&&e.facts.index?[{kind:"identity",identity:e.facts.index.generation}]:[]}function et(e){return e.stabilityProofs.map(t=>({kind:"stability",proof:t}))}function ot(e,t){let n=e.length===0&&t.length===0?"both-facts-missing":e.length===0?"left-fact-missing":"right-fact-missing";return b("unknown",[n],e,t)}function b(e,t,n,i){return{state:e,reasons:t,facts:{left:n,right:i}}}function ue(e,t){return e.schemaVersion===t.schemaVersion&&e.canonicalizationVersion===t.canonicalizationVersion&&e.hashAlgorithm===t.hashAlgorithm&&e.projection.name===t.projection.name&&e.projection.version===t.projection.version}function yn(e){if(!p(e))return!1;let t=e.index,n=e.worktree;return at(e.observedAt)&&m(e.projectIdentity)&&xn(e.authorityKind)&&(t===void 0||p(t)&&m(t.generationIdentity)&&(t.source==="immutable"||t.source==="legacy")&&(t.alignment==="not-certified"||t.alignment==="leased"))&&(n===void 0||p(n)&&m(n.identity)&&typeof n.clean=="boolean"&&(n.headCommit===void 0||m(n.headCommit))&&(n.treeOid===void 0||m(n.treeOid)))&&On(e.authorityKind,t,n)}function Cn(e){if(!p(e))return!1;let t=e.facts,n=e.observedSources,i=e.stabilityProofs;if(!at(e.observedAt)||!p(t)||!Array.isArray(n)||n.length===0||!n.every(vn)||!se(n,c=>c.kind)||!Array.isArray(i)||!i.every(Rn)||!se(i,c=>c.source)||i.some(c=>!n.some(d=>d.kind===c.source))||!i.every(c=>In(c,t))||["collaborationDomain","repositoryLineage","workspaceInstance","wholeContent"].some(c=>t[c]!==void 0&&!S(t[c])))return!1;let o=t.relevantInputs;if(o!==void 0&&(!Array.isArray(o)||!o.every(bn)||!se(o,c=>`${c.subject}\0${c.identity.projection.name}`)))return!1;let s=t.index;if(s!==void 0&&(!p(s)||!S(s.generation)||s.inputs!==void 0&&!S(s.inputs)||s.source!=="immutable"&&s.source!=="legacy"))return!1;let a=e.diagnostics;return(a===void 0||p(a)&&(a.clean===void 0||typeof a.clean=="boolean")&&(a.headCommit===void 0||m(a.headCommit))&&(a.treeOid===void 0||m(a.treeOid)))&&Sn(t,n)}function S(e){return!p(e)||!p(e.projection)?!1:e.schemaVersion===U&&e.canonicalizationVersion===D&&e.hashAlgorithm===V&&m(e.projection.name)&&j(e.projection.version)&&Pe(e.digest)}function bn(e){return p(e)&&m(e.subject)&&S(e.identity)}function vn(e){return p(e)&&st(e.kind)&&(e.identity===void 0||S(e.identity))}function Rn(e){return p(e)&&st(e.source)&&(e.kind==="immutable"||e.kind==="fixed-snapshot"||e.kind==="bracketed"||e.kind==="not-established"||e.kind==="invalidated")}function Sn(e,t){let n=e.index,i=t.find(c=>c.kind==="index-generation");if(i){if(!p(n)||!S(n.generation)||i.identity&&!oe(i.identity,n.generation))return!1}else if(n!==void 0)return!1;let r=e.workspaceInstance,o=t.find(c=>c.kind==="live-workspace");if(o?.identity&&(!S(r)||!oe(o.identity,r)))return!1;let s=e.wholeContent,a=t.find(c=>c.kind==="repository-snapshot");return!(a?.identity&&(!S(s)||!oe(a.identity,s)))}function In(e,t){return e.kind==="not-established"||e.kind==="invalidated"?!0:e.source==="index-generation"?e.kind==="immutable"&&p(t.index)&&t.index.source==="immutable":e.source==="repository-snapshot"?e.kind==="fixed-snapshot":e.source==="live-workspace"?e.kind==="bracketed":!1}function oe(e,t){return ue(e,t)&&e.digest===t.digest}function On(e,t,n){return e==="index-worktree"?t!==void 0&&n!==void 0:e==="index-only"?t!==void 0&&n===void 0:e==="worktree-only"?t===void 0&&n!==void 0:e==="process-local"&&t===void 0&&n===void 0}function xn(e){return e==="index-worktree"||e==="index-only"||e==="worktree-only"||e==="process-local"}function st(e){return e==="index-generation"||e==="repository-snapshot"||e==="live-workspace"||e==="process"}function at(e){return typeof e=="string"&&!Number.isNaN(Date.parse(e))}function se(e,t){return new Set(e.map(t)).size===e.length}import{createHash as ct}from"crypto";import{closeSync as En,fstatSync as dt,openSync as wn,rmSync as Pn}from"fs";import{dirname as kn}from"path";var _n=2e3,Tn=10,An=3,Y=class extends Error{constructor(n,i,r){super(`Concurrent edit detected for ${n}; expected revision ${lt(i)}, but found ${lt(r)}. The latest file was left untouched.`);this.path=n;this.original=i;this.latest=r;this.name="FileRevisionConflictError"}path;original;latest};function pt(e,t,n={}){let i=Nn(e,n.lockTimeoutMs??_n,n.monotonicNow??G);try{let r=Math.max(0,Math.floor(n.maxRetries??An));for(let o=0;;o+=1){let s=q(e),a=t(s,o);if(a.kind==="unchanged")return{changed:!1,attempts:o+1,previous:s,current:s};n.onBeforeCommit?.({attempt:o,snapshot:s,mutation:a});let c=q(e);if(!Mn(s.revision,c.revision)){if(o<r)continue;throw new Y(e,s.revision,c.revision)}try{jn(e,a,s.revision)}catch(d){if(d.code==="EEXIST"){let l=q(e);if(o<r)continue;throw new Y(e,s.revision,l.revision)}throw d}return{changed:!0,attempts:o+1,previous:s,current:q(e)}}}finally{i.release()}}function q(e){for(let t=0;t<4;t+=1){let n;try{n=wn(e,"r");let i=ut(dt(n)),r=Ne(n,{maxBytes:Te,inputKind:"revisioned text file"}),o=ut(dt(n));if(!ht(i,o))continue;return{path:e,text:r,revision:{exists:!0,hash:ct("sha256").update(r).digest("hex"),identity:o}}}catch(i){if(i.code==="ENOENT")return{path:e,text:"",revision:{exists:!1,hash:ct("sha256").update("").digest("hex")}};throw i}finally{n!==void 0&&En(n)}}throw new Error(`Could not read a stable revision of ${e}; the file is changing continuously.`)}function Nn(e,t,n){let i=`${e}.scip-query-write.lock`,r=n()+Math.max(0,t);for(;;){let o=Me(i,{kind:"revisioned-file-mutation",detail:{target:e}});if(o.kind==="acquired")return o.lock;if(n()>=r)throw new Error(`Timed out after ${t}ms waiting to update ${e}; the file was left untouched.`);Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,Tn)}}function jn(e,t,n){if(t.kind==="delete"){if(!n.exists)return;Pn(e),Ve(kn(e));return}let i=t.mode??n.identity?.mode;n.exists?De(e,t.text,{durability:"durable",mode:i}):Le(e,t.text,{durability:"durable",mode:i})}function Mn(e,t){return e.exists===t.exists&&e.hash===t.hash&&(e.identity===void 0?t.identity===void 0:t.identity!==void 0&&ht(e.identity,t.identity))}function ut(e){return{dev:e.dev,ino:e.ino,size:e.size,mtimeMs:e.mtimeMs,mode:e.mode&511}}function ht(e,t){return e.dev===t.dev&&e.ino===t.ino&&e.size===t.size&&e.mtimeMs===t.mtimeMs&&e.mode===t.mode}function lt(e){return e.exists?e.hash.slice(0,12):"<absent>"}var L=".scipquery.json",mt=2e3,gt=5e3,le=gt,yt=15*6e4,pe={enabled:!0,windowMs:15*6e4,maxRebuilds:2,maxEstimatedWriteBytes:1024*1024*1024},Ln={enabled:!1,autoStart:!1,allowExpensiveRebuild:!1,debounceMs:mt,cooldownMs:le,gitPollMs:2e3,idleTimeoutMs:yt,autoRefresh:!0,ignore:[],resourceBudget:pe};var Er=new Set(M);function Q(e){let t=ft(e,L);if(!Vn(t))return{};let n;try{n=Ae(t,{maxBytes:_e,inputKind:"scip-query project config"})}catch(i){let r=i instanceof Error?i.message:String(i);throw new Error(`unable to read ${L} at ${t}: ${r}`,{cause:i})}return bt(ie(n),t,"read").config}function Ct(e){return{...Ln,...e.watch,cooldownMs:Math.max(gt,e.watch?.cooldownMs??le),resourceBudget:{...pe,...e.watch?.resourceBudget}}}function Wn(e,t){return $n(e,t).configPath}function $n(e,t){let n=ft(e,L),i=Dn(),r={collaborationDomainId:i,languages:t,watch:{enabled:!0,debounceMs:mt,cooldownMs:le,gitPollMs:2e3,idleTimeoutMs:yt,autoRefresh:!0,resourceBudget:{...pe}}},o=pt(n,s=>{if(!s.revision.exists)return{kind:"write",text:re(r)};let a=Fn(s,r);return a.config.collaborationDomainId?{kind:"unchanged"}:{kind:"write",text:re({...a.config,collaborationDomainId:i})}});return{configPath:n,changed:o.changed}}function Fn(e,t){if(!e.revision.exists)return{config:B(t),needsMigration:!0};let n=bt(ie(e.text),e.path,"update");return{config:n.config,needsMigration:n.needsMigration}}function bt(e,t,n){if(e.kind==="legacy"||e.kind==="supported")return e;if(e.kind==="malformed"){let r=n==="read"?`invalid ${L} at ${t}: ${e.reason}`:`Cannot update ${t}: the latest project config is ${e.reason}.`;throw new Error(`${r} The file was left untouched.`)}let i=n==="read"?`invalid ${L} at ${t}`:`Cannot update ${t}: the latest project config is invalid`;throw new Error(`${i} (unsupported ${e.direction} schemaVersion ${e.schemaVersion}; this scip-query reads legacy v${x} and current v${P}). Upgrade scip-query before retrying; the file was left untouched.`)}import{existsSync as Ce,lstatSync as Jn,statSync as _t,watch as Bn}from"fs";import{EventEmitter as Un}from"events";import{basename as Hn,dirname as Kn,isAbsolute as be,join as C,relative as Tt,resolve as At}from"path";import{watch as qn}from"chokidar";import Yn from"ignore";function he(e){let t=JSON.stringify(e);return Buffer.byteLength(t)<=65536?t:void 0}var Nt=5e3,ge=class{projectRoot;config;watchConfig;outputDb;languages;pnpmWorkspaces;typescriptProjectMode;typescriptProjects;clojureConfigPath;indexerConcurrency;onStatus;onReindexComplete;onReindexError;onRefreshSuppressed;onError;reindexRunner;subscriptionFactory;budgetInspector;clock;activeOperation=null;stopPromise=null;stopInProgress=!1;status={state:"idle"};debounceTimer=null;cooldownTimer=null;budgetTimer=null;dirty=!1;changedFiles=0;pendingTrigger=null;pendingChanges=new Map;pendingChangesComplete=!0;pendingChangesIncompleteReason;reindexInFlight=!1;lastReindexEnd=0;fsWatchers=[];sourcePollingFallbackStarted=!1;gitPollTimer=null;lastGitState=null;preferFilesystemGitState=!0;watchGitLayout=null;localCacheWatchPath;gitignoreFilter;extraIgnore;stopped=!1;constructor(t){this.projectRoot=t.projectRoot,this.config=t.config,this.watchConfig=Ct(t.config),this.outputDb=t.outputDb??C(Be(this.projectRoot,t.config),"index.db"),this.preferFilesystemGitState=t.gitReader===void 0,this.localCacheWatchPath=yi(this.projectRoot,Kn(this.outputDb)),this.languages=t.languages,this.pnpmWorkspaces=t.config.indexer?.typescript?.pnpmWorkspaces??!1,this.typescriptProjectMode=t.config.indexer?.typescript?.projectMode,this.typescriptProjects=t.config.indexer?.typescript?.projects,this.clojureConfigPath=t.config.indexer?.clojure?.configPath,this.indexerConcurrency=t.config.indexerConcurrency,this.onStatus=t.onStatus??(()=>{}),this.onReindexComplete=t.onReindexComplete??(()=>{}),this.onReindexError=t.onReindexError??(()=>{}),this.onRefreshSuppressed=t.onRefreshSuppressed??(()=>{}),this.onError=t.onError??(n=>console.error(n.message)),this.clock=t.clock??Zn,jt.set(this,Ci(t.stopTimeoutMs??Nt,"watcher stop timeout")),this.reindexRunner=t.reindexRunner??Lt(),this.subscriptionFactory=t.subscriptionFactory??ei,this.budgetInspector=t.budgetInspector??Qe,Mt.set(this,{projectRoot:t.projectRoot,config:t.config,gitReader:t.gitReader??$e,languages:Wt(t.languages??t.config.languages),typeScriptInputPaths:null,stagedIndexEntries:null}),this.gitignoreFilter=He(t.projectRoot),this.extraIgnore=Yn(),this.watchConfig.ignore.length>0&&this.extraIgnore.add(this.watchConfig.ignore),Pt(this)}start(){if(this.stopInProgress)throw new Error("Cannot restart a watcher while its previous ownership is still draining.");this.stopped=!1,this.stopPromise=null,z(this).errors=[],this.sourcePollingFallbackStarted=!1,this.setStatus({state:"idle"}),this.startGitStatePolling();try{this.startSourceWatcher()}catch(t){this.onError(new Error(`Failed to watch ${this.projectRoot}: ${String(t)}`))}}stop(){if(this.stopPromise)return this.stopPromise;this.stopped=!0,this.stopInProgress=!0;let t=this.fsWatchers;this.fsWatchers=[],this.clearDebounceTimer(),this.clearCooldownTimer(),this.clearBudgetTimer(),this.clearGitPollTimer();let n=this.activeOperation;n&&this.setStatus({state:"draining",startedAt:this.wallNow(),reason:"waiting for the active reindex worker to exit"});let i=[...z(this).closures],r=Xn(this),o=this.clock.now()+r;return this.stopPromise=this.finishStop(t,i,n,o,r).catch(s=>{throw this.stopInProgress=!1,s}),this.stopPromise}requestRefresh(t,n={}){if(!this.stopped){if(this.markPendingChangesIncomplete(`unstructured-trigger:${t.kind}`),!n.immediate||this.reindexInFlight||this.status.state==="cooldown"||this.status.state==="budget-paused"){this.scheduleReindex(t);return}this.pendingTrigger=fe(this.pendingTrigger,t),this.changedFiles+=1,this.clearDebounceTimer(),this.triggerReindex()}}startSourceWatcher(t=!1){let n=this.subscriptionFactory(this.projectRoot,{ignoreInitial:!0,ignored:(i,r)=>this.isIgnoredWatchPath(i,r?.isDirectory()??!1),usePolling:t,ignorePermissionErrors:!0,...t?{interval:5e3,binaryInterval:1e4}:{}});n.on("all",(i,r)=>{!this.stopped&&i!=="addDir"&&i!=="unlinkDir"&&this.handleFileChange(i,r)}),n.on("error",i=>this.handleSourceWatcherError(n,i,t)),this.fsWatchers.push(n)}handleSourceWatcherError(t,n,i){if(this.markPendingChangesIncomplete("source-watcher-error"),i||this.sourcePollingFallbackStarted||!pi(n)||this.stopped){this.onError(new Error(`Failed to watch ${this.projectRoot}: ${String(n)}`));return}this.sourcePollingFallbackStarted=!0,this.fsWatchers=this.fsWatchers.filter(r=>r!==t),zn(z(this),t,r=>this.onError(r));try{this.startSourceWatcher(!0)}catch(r){this.onError(new Error(`Failed to watch ${this.projectRoot}: ${String(r)}`))}}isIgnoredWatchPath(t,n){let i=this.relativeWatchPath(t);if(!i)return!1;if(It(i,this.localCacheWatchPath))return!0;let r=n?`${i}/`:i;return this.gitignoreFilter.isIgnored(r)||this.extraIgnore.ignores(r)}handleFileChange(t,n){let i=this.relativeWatchPath(n);if(!i||i===".."||i.startsWith("../")||It(i,this.localCacheWatchPath)||this.gitignoreFilter.isIgnored(i)||this.extraIgnore.ignores(i)||i.endsWith("index.db")||i.endsWith("index.scip")||i.endsWith("index.db.tmp")||Hn(i).startsWith(Ye))return;i===".scipquery.json"&&Et(this,this.projectRoot);let r=wt(this,t,i);r!==null&&(r||this.markPendingChangesIncomplete(`unsupported-source-event:${t}`),this.scheduleReindex({kind:"watch-source",detail:i},r?[{path:i,kind:r}]:void 0,r!==void 0))}relativeWatchPath(t){let n=be(t)?t:C(this.projectRoot,t);return Tt(this.projectRoot,n).replaceAll("\\","/")}scheduleReindex(t,n,i=!1){this.pendingTrigger=fe(this.pendingTrigger,t),i||this.markPendingChangesIncomplete(`unstructured-trigger:${t.kind}`);for(let o of n??[])this.recordPendingChange(o);if(this.changedFiles++,this.reindexInFlight){this.dirty=!0,this.setStatus({state:"indexing",startedAt:this.status.startedAt});let o=this.activeOperation;o&&k.get(this)!==o&&(k.set(this,o),o.cancel().then(s=>{s.state==="degraded"&&!this.stopped&&this.onError(new Error(s.reason))},s=>{this.stopped||this.onError(s instanceof Error?s:new Error(String(s)))}));return}if(this.status.state==="cooldown"){this.dirty=!0,this.setStatus({state:"cooldown",until:this.status.until,dirty:!0});return}if(this.status.state==="budget-paused"){this.dirty=!0,this.setStatus({...this.status,dirty:!0});return}this.clearDebounceTimer();let r=this.wallNow()+this.watchConfig.debounceMs;this.setStatus({state:"waiting",changedFiles:this.changedFiles,reindexAt:r}),this.debounceTimer=this.clock.setTimeout(()=>{this.debounceTimer=null,this.triggerReindex()},this.watchConfig.debounceMs)}triggerReindex(){if(this.reindexInFlight||this.stopped)return;let t=this.inspectBudget(),n=this.watchConfig.allowExpensiveRebuild&&t.state!=="paused";if(t.state==="paused"&&t.reason!=="rebuild-count"){this.dirty=!0;let c=Math.max(this.wallNow()+1,t.until);this.setStatus({state:"budget-paused",until:c,dirty:!0,reason:t.detail,rebuilt:t.rebuilt,estimatedWriteBytes:t.estimatedWriteBytes}),this.clearBudgetTimer(),this.budgetTimer=this.clock.setTimeout(()=>{this.budgetTimer=null,this.dirty&&!this.stopped&&(this.dirty=!1,this.triggerReindex())},Math.min(2147483647,Math.max(1,c-this.wallNow())));return}let i=this.clock.now()-this.lastReindexEnd;if(this.lastReindexEnd>0&&i<this.watchConfig.cooldownMs){let c=this.watchConfig.cooldownMs-i;this.dirty=!0;let d=this.wallNow()+c;this.setStatus({state:"cooldown",until:d,dirty:!0}),this.cooldownTimer=this.clock.setTimeout(()=>{this.cooldownTimer=null,this.dirty&&!this.stopped&&(this.dirty=!1,this.triggerReindex())},c);return}this.reindexInFlight=!0,this.dirty=!1,this.changedFiles=0;let r=this.pendingTrigger??{kind:"watch-source"};this.pendingTrigger=null;let o=this.consumePendingChangeJournal(),s=this.wallNow();this.setStatus({state:"indexing",startedAt:s});let a=this.reindexRunner.start(this.reindexRequest(r,n,o));this.activeOperation=a,a.completion.then(c=>{if(this.reindexInFlight=!1,this.lastReindexEnd=this.clock.now(),X.set(this,0),this.stopped)return;if(k.get(this)===a){if(this.restorePendingChangeJournal(o),this.dirty){let l=this.wallNow()+this.watchConfig.cooldownMs;this.setStatus({state:"cooldown",until:l,dirty:!0}),this.clearCooldownTimer(),this.cooldownTimer=this.clock.setTimeout(()=>{this.cooldownTimer=null,this.dirty&&!this.stopped?(this.dirty=!1,this.triggerReindex()):this.setStatus({state:"idle"})},this.watchConfig.cooldownMs)}else this.setStatus({state:"idle"});return}Pt(this);let d=!1;try{d=this.onReindexComplete(c,r,{pendingChanges:this.dirty})===!0}catch(l){this.onError(l instanceof Error?l:new Error(String(l)))}if(this.dirty&&!this.stopped){if(d){let u=this.pendingTrigger??{kind:"unknown"};this.dirty=!1,this.changedFiles=0,this.pendingTrigger=null,this.resetPendingChanges(),this.onRefreshSuppressed(u),this.setStatus({state:"idle"});return}let l=this.wallNow()+this.watchConfig.cooldownMs;this.setStatus({state:"cooldown",until:l,dirty:!0}),this.clearCooldownTimer(),this.cooldownTimer=this.clock.setTimeout(()=>{this.cooldownTimer=null,this.dirty&&!this.stopped?(this.dirty=!1,this.triggerReindex()):this.setStatus({state:"idle"})},this.watchConfig.cooldownMs)}else this.setStatus({state:"idle"})}).catch(c=>{if(this.reindexInFlight=!1,this.lastReindexEnd=this.clock.now(),this.stopped)return;let d=c instanceof Error?c:new Error(String(c));this.restorePendingChangeJournal(o);let l=Dt(d),u=0;if(l?(u=(X.get(this)??0)+1,X.set(this,u),this.dirty=!0,this.pendingTrigger=fe(this.pendingTrigger,r)):X.set(this,0),!l&&k.get(this)!==a&&(this.onReindexError(d,r),this.onError(d)),this.dirty){let h=l?ci(this.watchConfig.cooldownMs,u):this.watchConfig.cooldownMs,R=this.wallNow()+h;this.setStatus({state:"cooldown",until:R,dirty:!0}),this.clearCooldownTimer(),this.cooldownTimer=this.clock.setTimeout(()=>{this.cooldownTimer=null,this.dirty&&!this.stopped?(this.dirty=!1,this.triggerReindex()):this.setStatus({state:"idle"})},h);return}this.setStatus({state:"idle"})}).finally(()=>{this.activeOperation===a&&(this.activeOperation=null),k.get(this)===a&&k.delete(this)})}async finishStop(t,n,i,r,o){let s=[],a=t.map(async h=>{try{await h.close()}catch(R){s.push(`watch subscription close failed: ${String(R)}`)}});a.push(...n),i&&a.push((async()=>{try{let h=await i.cancel();h.state==="degraded"&&s.push(h.reason)}catch(h){s.push(`reindex cancellation failed: ${h instanceof Error?h.message:String(h)}`)}})());let c=a.length,d=a.map(h=>h.finally(()=>{c-=1})),l=await Qn(d,r,this.clock),u=z(this);return s.push(...u.errors),u.errors=[],l?this.stopInProgress=!1:(s.push(`watch shutdown exceeded the ${o}ms deadline with ${c} operation(s) still pending`),Promise.all(d).then(()=>{this.stopInProgress=!1})),s.length>0?(this.setStatus({state:"draining",startedAt:this.wallNow(),reason:s.join("; ")}),{state:"degraded",reasons:s}):(this.setStatus({state:"idle"}),{state:"stopped"})}wallNow(){return this.clock.wallNow?.()??this.clock.now()}inspectBudget(){try{return this.budgetInspector(this.outputDb,this.watchConfig.resourceBudget,new Date(this.wallNow()))}catch(t){return{state:"paused",reason:"activity-evidence",until:this.wallNow()+this.watchConfig.resourceBudget.windowMs,rebuilt:0,estimatedWriteBytes:0,detail:`reindex activity evidence could not be read: ${t instanceof Error?t.message:String(t)}`}}}reindexRequest(t,n=!0,i){return{projectRoot:this.projectRoot,config:this.config,languages:this.languages,pnpmWorkspaces:this.pnpmWorkspaces,typescriptProjectMode:this.typescriptProjectMode,typescriptProjects:this.typescriptProjects,clojureConfigPath:this.clojureConfigPath,indexerConcurrency:this.indexerConcurrency,trigger:t,changeJournal:i,allowExpensiveRebuild:n}}setStatus(t){this.status=t,this.onStatus(t)}recordPendingChange(t){if(this.pendingChanges.size>=1024&&!this.pendingChanges.has(t.path)){this.pendingChanges.clear(),this.markPendingChangesIncomplete("change-entry-limit");return}let n=this.pendingChanges.get(t.path),i=ui(n,t.kind);i===null?this.pendingChanges.delete(t.path):this.pendingChanges.set(t.path,i)}markPendingChangesIncomplete(t){this.pendingChangesComplete=!1,this.pendingChangesIncompleteReason??=t}consumePendingChangeJournal(){let t=We(this.outputDb),n=[...this.pendingChanges.entries()].map(([s,a])=>({path:s,kind:a})).sort((s,a)=>s.path.localeCompare(a.path)),i=this.pendingChangesComplete,r=this.pendingChangesIncompleteReason;t||(i=!1,r??="accepted-generation-unavailable");let o={version:1,baseGeneration:t,complete:i,...r?{incompleteReason:r}:{},entries:n};return he(o)||(o={version:1,baseGeneration:t,complete:!1,incompleteReason:"change-journal-byte-limit",entries:[]}),this.resetPendingChanges(),o}restorePendingChangeJournal(t){let n=[...this.pendingChanges.entries()].map(([o,s])=>({path:o,kind:s})),i=this.pendingChangesComplete,r=this.pendingChangesIncompleteReason;this.resetPendingChanges(),t.complete||this.markPendingChangesIncomplete(t.incompleteReason??"failed-reindex");for(let o of t.entries)this.recordPendingChange(o);i||this.markPendingChangesIncomplete(r??"failed-reindex");for(let o of n)this.recordPendingChange(o)}resetPendingChanges(){this.pendingChanges.clear(),this.pendingChangesComplete=!0,this.pendingChangesIncompleteReason=void 0}clearDebounceTimer(){this.debounceTimer&&(this.clock.clearTimeout(this.debounceTimer),this.debounceTimer=null)}clearCooldownTimer(){this.cooldownTimer&&(this.clock.clearTimeout(this.cooldownTimer),this.cooldownTimer=null)}clearBudgetTimer(){this.budgetTimer&&(this.clock.clearTimeout(this.budgetTimer),this.budgetTimer=null)}startGitStatePolling(){this.lastGitState=this.readGitState(),this.lastGitState&&(v(this).stagedIndexEntries=kt(this.projectRoot,v(this).gitReader),this.gitPollTimer=this.clock.setInterval(()=>this.pollGitState(),this.watchConfig.gitPollMs),this.gitPollTimer.unref?.())}pollGitState(){if(this.reindexInFlight||this.stopped)return;let t=this.lastGitState,n=this.readGitState();if(!t||!n||this.stopped){this.lastGitState=n;return}this.lastGitState=n;let i=t.head!==n.head,r=t.indexPath!==n.indexPath||t.indexMtimeMs!==n.indexMtimeMs||t.indexSize!==n.indexSize;if(!i&&!r)return;let o=v(this),s=o.stagedIndexEntries,a=kt(this.projectRoot,o.gitReader);o.stagedIndexEntries=a;let c=Si(this.projectRoot,o.gitReader,t,n,s,a,i,r),d=null;if(c!==null&&(c.includes(".scipquery.json")&&Et(this,this.projectRoot),d=c.filter(u=>wt(this,"add",u)!==null),d.length===0))return;let l=d?.map(u=>({path:u,kind:Ce(C(this.projectRoot,u))?"change":"delete"}));i&&r?this.scheduleReindex({kind:"watch-git-state",detail:me("HEAD and index changed",d)},l,l!==void 0):i?this.scheduleReindex({kind:"watch-git-head",detail:me("HEAD changed",d)},l,l!==void 0):r&&this.scheduleReindex({kind:"watch-git-index",detail:me(n.indexPath??"index changed",d)},l,l!==void 0)}readGitState(){if(this.preferFilesystemGitState){let t=this.readFilesystemGitState();if(t)return t}return this.readGitStateFromGit()}readFilesystemGitState(){let t=this.watchGitLayout??hi(this.projectRoot);if(!t)return null;this.watchGitLayout=t;let n=fi(t.gitDir);return n?xt(n,t.indexPath):null}readGitStateFromGit(){let t=v(this).gitReader,n=ne(this.projectRoot,["rev-parse","--git-path","index"],t);if(!n)return null;let i=Fe(this.projectRoot,n);return xt(ne(this.projectRoot,["rev-parse","--verify","HEAD"],t),i)}clearGitPollTimer(){this.gitPollTimer&&(this.clock.clearInterval(this.gitPollTimer),this.gitPollTimer=null)}};async function Qn(e,t,n){if(e.length===0)return!0;let i=Promise.all(e).then(()=>!0),r=Math.max(0,t-n.now()),o=null,s=new Promise(c=>{o=n.setTimeout(()=>c(!1),r)}),a=await Promise.race([i,s]);return a&&o&&n.clearTimeout(o),a}var Rt=new WeakMap,jt=new WeakMap,Mt=new WeakMap,k=new WeakMap,X=new WeakMap;function z(e){let t=Rt.get(e);if(t)return t;let n={closures:new Set,errors:[]};return Rt.set(e,n),n}function Xn(e){return jt.get(e)??Nt}function v(e){let t=Mt.get(e);if(!t)throw new Error("Watcher input state was not initialized.");return t}function zn(e,t,n){let i=Promise.resolve().then(()=>t.close()).catch(r=>{let o=`watch subscription close failed during polling fallback: ${String(r)}`;e.errors.push(o),n(new Error(o))});e.closures.add(i),i.then(()=>e.closures.delete(i))}function Vt(e,t=je){let{projectRoot:n,config:i,languages:r,pnpmWorkspaces:o,typescriptProjectMode:s,typescriptProjects:a,clojureConfigPath:c,indexerConcurrency:d,trigger:l}=e,u=Q(n),h=Object.keys(u).length>0?u:i,R=J(n,h),F=h.indexer?.typescript,on=h.indexer?.clojure,Ee=t(process.pid);if(!Ee)throw new Error(`Could not establish watcher process identity for reindex worker ownership (pid ${process.pid}).`);return{workerPath:new URL("./reindex-worker.js",import.meta.url).pathname,env:{...process.env,SCIP_REINDEX_PROJECT_ROOT:n,SCIP_REINDEX_OUTPUT_SCIP:R.indexPath,SCIP_REINDEX_OUTPUT_DB:R.dbPath,SCIP_REINDEX_LANGUAGES:(h.languages??r)?.join(",")??"",SCIP_REINDEX_INDEXER_CONCURRENCY:String(h.indexerConcurrency??d??""),SCIP_REINDEX_PNPM_WORKSPACES:F?.pnpmWorkspaces??o?"1":"",SCIP_REINDEX_TYPESCRIPT_CONFIG:JSON.stringify({projectMode:F?.projectMode??s,projects:F?.projects??a??[],maxHeapMb:F?.maxHeapMb}),SCIP_REINDEX_CLOJURE_CONFIG_PATH:on?.configPath??c??"",SCIP_REINDEX_TRIGGER_KIND:l.kind,SCIP_REINDEX_TRIGGER_DETAIL:l.detail??"",SCIP_REINDEX_CHANGE_JOURNAL:e.changeJournal?he(e.changeJournal)??"":"",SCIP_REINDEX_ALLOW_EXPENSIVE:e.allowExpensiveRebuild===!1?"0":"1",SCIP_REINDEX_PROCESS_GROUP_LEADER:"1",SCIP_REINDEX_PARENT_IDENTITY:JSON.stringify(Ee)}}}var Zn={now:G,wallNow:()=>Date.now(),setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},ei=(e,t)=>ti(process.platform,t.usePolling)?new ye(e):qn(e,t);function ti(e,t){return e==="darwin"&&t!==!0}var W=class extends Error{constructor(t,n){super(t,n===void 0?void 0:{cause:n}),this.name="RecursiveSourceWatchError"}},ye=class{events=new Un;watcher;constructor(t){this.watcher=Bn(t,{recursive:!0},(n,i)=>{if(i===null){this.events.emit("error",new W("Recursive source watcher omitted the changed path."));return}let r=C(t,i.toString());this.events.emit("all",ni(n,r),r)}),this.watcher.on("error",n=>{this.events.emit("error",new W(`Recursive source watcher failed: ${n.message}`,n))})}on=(t,n)=>(this.events.on(t,n),this);close(){this.watcher.close()}};function ni(e,t){return e==="change"?"change":Ce(t)?_t(t).isDirectory()?"addDir":"add":"unlink"}var ii=15*6e4,ri=1e3,oi=64*1024;function si(){return{stdoutTail:"",stderrTail:"",stdoutTruncated:!1,stderrTruncated:!1}}function St(e,t){let n=e instanceof Error?e.message:String(e),i=t.stderrTail.trim()||t.stdoutTail.trim();return i?`${n}
3
+ ${i}`:n}function ai(e,t){return Object.assign(new Error(e,t===void 0?void 0:{cause:t}),{retryable:!0})}function Dt(e){return e instanceof Error&&"retryable"in e&&e.retryable===!0}function ci(e,t){let n=e*2**Math.min(5,Math.max(0,t-1));return Math.max(e,Math.min(3e4,n))}function Lt(e={}){let t=e.timeoutMs??ii,n=e.terminationGraceMs??ri,i=e.maxOutputBytes??oi,r=e.resolveLaunch??Vt;return{start(o){let s=r(o),a=new AbortController,c=si(),d=!1,l=qe({command:process.execPath,args:[...process.execArgv,s.workerPath],label:"watch reindex worker",env:s.env,timeoutMs:t,terminationGraceMs:n,maxStdoutBytes:i,maxStderrBytes:i,outputLimitBehavior:"truncate-tail",signal:a.signal,detached:!0}).then(u=>{if(c={stdoutTail:u.stdout,stderrTail:u.stderr,stdoutTruncated:u.stdoutTruncated,stderrTruncated:u.stderrTruncated},u.status!==0){let h=St(new Error(`Reindex worker exited with ${u.signal?`signal ${u.signal}`:`code ${u.status}`}`),c);throw u.status===75?ai(h):new Error(h)}return u.durationMs}).catch(u=>{throw Dt(u)?u:(u instanceof Ke&&(c={stdoutTail:u.stdout,stderrTail:u.stderr,stdoutTruncated:u.stdoutTruncated,stderrTruncated:u.stderrTruncated}),new Error(St(u,c),{cause:u}))}).finally(()=>{d=!0});return{completion:l,async cancel(){d||a.abort();try{await l}catch{}return{state:"exited",diagnostics:c}},diagnostics:()=>c}}}}function fe(e,t){return e?e.kind===t.kind?e.detail===t.detail?e:{kind:e.kind,detail:"multiple changes"}:{kind:"watch-git-state",detail:`${e.kind}, ${t.kind}`}:t}function di(e){if(e==="add")return"add";if(e==="change")return"change";if(e==="unlink")return"delete"}function ui(e,t){return e?e==="add"?t==="delete"?null:"add":e==="delete"&&t==="add"?"change":t:t}function li(e){return e instanceof Error&&"code"in e&&e.code==="EMFILE"||String(e).includes("EMFILE: too many open files")}function pi(e){return e instanceof W||li(e)}var ve=/^[0-9a-f]{40,64}$/i;function It(e,t){return e===".git"||e.startsWith(".git/")||e==="node_modules"||e.startsWith("node_modules/")||e.endsWith("/node_modules")||e.includes("/node_modules/")?!0:t!==void 0&&(e===t||e.startsWith(`${t}/`))}function hi(e){let t=C(e,".git");try{let n=Jn(t),i;if(n.isDirectory())i=t;else if(n.isFile()){let r=/^gitdir:\s*(.+)\s*$/m.exec(O(t,"Git directory marker"));if(!r?.[1])return null;let o=r[1].trim();i=be(o)?o:At(e,o)}else return null;return Ce(i)?{gitDir:i,indexPath:C(i,"index")}:null}catch{return null}}function fi(e){let t;try{t=O(C(e,"HEAD"),"Git HEAD").trim()}catch{return}if(ve.test(t))return t.toLowerCase();let n=/^ref:\s*(.+)$/.exec(t)?.[1]?.trim();if(!n)return;let i=mi(e);return Ot(e,n)??Ot(i,n)??gi(i,n)}function mi(e){try{let t=O(C(e,"commondir"),"Git common-directory marker").trim();return t?be(t)?t:At(e,t):e}catch{return e}}function Ot(e,t){try{let n=O(C(e,t),"Git reference").trim();return ve.test(n)?n.toLowerCase():void 0}catch{return}}function gi(e,t){try{for(let n of O(C(e,"packed-refs"),"Git packed references").split(`
4
+ `)){if(n.startsWith("#")||n.startsWith("^"))continue;let i=n.indexOf(" ");if(i===-1)continue;let r=n.slice(0,i);if(n.slice(i+1).trim()===t&&ve.test(r))return r.toLowerCase()}}catch{return}}function xt(e,t){let n={head:e,indexPath:t};try{let i=_t(t);n.indexMtimeMs=i.mtimeMs,n.indexSize=i.size}catch{n.indexMtimeMs=void 0,n.indexSize=void 0}return n}function yi(e,t){let n=Tt(e,t).replaceAll("\\","/");if(!(!n||n===".."||n.startsWith("../")))return n}function Ci(e,t){if(!Number.isSafeInteger(e)||e<=0)throw new Error(`${t} must be a positive integer.`);return e}function Wt(e){return e&&e.length>0?[...e]:M}function Et(e,t){try{let n=v(e);n.config=Q(t),n.languages=Wt(n.config.languages)}catch{v(e).languages=M}}function wt(e,t,n){let i=v(e);if(te(n,i.languages)==="other")return null;let o=di(t);if(n===".scipquery.json"||Ge(n))return i.typeScriptInputPaths=null,o;if(!bi(n,i.languages))return o;let s=i.typeScriptInputPaths;if(!s)return o;let a=s.has(n);if(o!=="add")return a?o:null;if(a)return"change";let c=$t(e);return c?c.has(n)?"add":null:o}function Pt(e){let t=v(e);if(!t.languages.includes("typescript")){t.typeScriptInputPaths=null;return}let n=vi(t.projectRoot,t.config,t.languages);t.typeScriptInputPaths=n??$t(e)}function $t(e){let t=v(e);if(!t.languages.includes("typescript"))return t.typeScriptInputPaths=null,null;try{let n=t.config.indexer?.typescript,i=Je(t.projectRoot,n?.projectMode,n?.projects);return t.typeScriptInputPaths=i,i}catch{return t.typeScriptInputPaths=null,null}}function bi(e,t){if(!t.includes("typescript"))return!1;let n=te(e,["typescript","javascript"]);return n==="source"||n==="ambient"}function vi(e,t,n){try{let i=ke(O(J(e,t).metaPath,"reindex metadata"));if(i.kind!=="supported"&&i.kind!=="legacy")return null;let r=we(i.metadata.fingerprint);return!r||!Ri(r,n,t)?null:new Set(r.files.map(o=>o.path))}catch{return null}}function Ri(e,t,n){let i=Ue(t,{pnpmWorkspaces:n.indexer?.typescript?.pnpmWorkspaces,typescriptProjectMode:n.indexer?.typescript?.projectMode,typescriptProjects:n.indexer?.typescript?.projects,clojureConfigPath:n.indexer?.clojure?.configPath});return e.version===i.version&&JSON.stringify([...e.languages].sort())===JSON.stringify(i.languages)&&e.pnpmWorkspaces===i.pnpmWorkspaces&&e.typescriptProjectMode===i.typescriptProjectMode&&JSON.stringify([...e.typescriptProjects].sort())===JSON.stringify(i.typescriptProjects)&&e.clojureConfigPath===i.clojureConfigPath}function Si(e,t,n,i,r,o,s,a){let c=new Set;if(s){if(!n.head||!i.head)return null;let d=t.runResult(e,["diff","--name-only","-z","--no-renames","--relative",n.head,i.head,"--"]);if(d.kind!=="success")return null;for(let l of Ii(d.output))c.add(l)}if(a){if(r===null||o===null)return null;for(let d of xi(r,o))c.add(d)}return[...c].sort()}function kt(e,t){let n=t.runResult(e,["diff","--cached","--raw","-z","--no-renames","--relative","--"]);return n.kind==="success"?Oi(n.output):null}function Ii(e){return e.split("\0").filter(t=>t.length>0)}function Oi(e){let t=e.split("\0");if(t.at(-1)===""&&t.pop(),t.length%2!==0)return null;let n=new Map;for(let i=0;i<t.length;i+=2){let r=t[i],o=t[i+1];if(!r.startsWith(":")||!o)return null;n.set(o,r)}return n}function xi(e,t){return[...new Set([...e.keys(),...t.keys()])].filter(i=>e.get(i)!==t.get(i))}function me(e,t){return t===null?`${e}; changed paths unavailable`:t.length===0?e:t.length===1?t[0]:`${t.length} compiler inputs changed`}import{existsSync as Re,mkdirSync as Ei,symlinkSync as wi,readlinkSync as Ft,unlinkSync as Gt,readdirSync as Pi}from"fs";import{join as _,dirname as Se,resolve as T,relative as ki,isAbsolute as _i}from"path";import{homedir as Ti,platform as Ai}from"os";import{fileURLToPath as Ni}from"url";var ji=Ai()==="win32";var Jt=["scip-query","scip-plan","scip-setup","scip-integrity-audit","scip-explore","concrete-plan"];function Mi(e={}){let t=e.quiet?()=>{}:console.log,n=Ni(import.meta.url),i=T(Se(n),"..","skills"),r=e.homeDir??process.env.SCIP_QUERY_SKILLS_HOME??Ti(),o=[_(r,".claude","skills"),_(r,".codex","skills"),_(r,".agents","skills")],s={installed:[],skipped:[],alreadyLinked:[],pruned:[]};for(let a of o){let c=Se(a);if(!Re(c))continue;Ei(a,{recursive:!0});let d=Li(a);Vi(a,i,d,s,t);for(let l of Jt){let u=_(i,l),h=_(a,l);if(!Re(u)){s.skipped.push(`${d}/${l}`);continue}if(Re(h)){try{let R=Ft(h);if(T(R)===T(u)){s.alreadyLinked.push(`${d}/${l}`),t(` ok: ${l} \u2192 ${d} (already linked)`);continue}}catch{s.skipped.push(`${d}/${l}`),t(` skip: ${l} \u2192 ${d} (exists, not a symlink)`);continue}Gt(h)}wi(u,h,ji?"junction":"dir"),s.installed.push(`${d}/${l}`),t(` done: ${l} \u2192 ${d}`)}}return s}function Vi(e,t,n,i,r){let o=new Set(Jt);for(let s of Pi(e)){if(o.has(s))continue;let a=_(e,s),c;try{c=T(Se(a),Ft(a))}catch{continue}Di(c,t)&&(Gt(a),i.pruned.push(`${n}/${s}`),r(` prune: ${s} \u2192 ${n} (removed stale scip-query skill link)`))}}function Di(e,t){let n=ki(T(t),T(e));return n===""||!n.startsWith("..")&&!_i(n)}function Li(e){return e.includes(".codex")?"Codex":e.includes(".agents")?"Agents":"Claude"}var Bt=["repository-observation","repository-preview","mutation","composite","environment-observation","tool-information"];function Wi(e,t=[]){return{defaultRole:e,...t.length>0?{rules:t}:{}}}function $i(e,t){for(let n of e.rules??[]){if(n.when.kind==="option-present"){let r=t.options[n.when.name];if(r!==void 0&&r!==!1)return n.role;continue}if((n.when.kind==="argument"?t.args[n.when.index]:t.options[n.when.name])===n.when.equals)return n.role}return e.defaultRole}function Fi(e){return[...new Set([e.defaultRole,...(e.rules??[]).map(t=>t.role)])]}function Z(e){return Bt.includes(e)}function Gi(e){return e==="repository-observation"||e==="repository-preview"||e==="composite"}var Ie=1,Oe=1,ee=["compiler-graph","semantic-analysis","repository-source","change-history","runtime-measurement","heuristic","mixed","unknown"],Ut=["complete","partial","unknown"],Ht=["validated","failed","not-evaluated","not-applicable"],Kt=["observe","advise","require-adjudication","block","not-established"],qt={policyId:"scip-query:unresolved-repository-policy",policyVersion:Oe,permission:"not-established",reasons:["No repository action policy was supplied for this claim."]};function Ji(e){return{schemaVersion:Ie,origin:e.contract.origin,coverage:Yt(e.coverage),producerValidation:e.contract.producerValidation,stateAuthority:K(e.receipt,e.receipt),repositoryPolicy:e.repositoryPolicy??qt,...e.contract.families?{families:e.contract.families}:{}}}function Yt(e){return e?e.complete===!0?{state:"complete",returned:e.returned,totalKnown:!0,total:e.total??e.returned,omitted:0}:e.totalKnown?{state:"partial",returned:e.returned,totalKnown:!0,...e.total===void 0?{}:{total:e.total},...e.omitted===void 0?{}:{omitted:e.omitted}}:{state:"unknown",returned:e.returned,totalKnown:!1}:{state:"unknown",returned:0,totalKnown:!1}}function Bi(e,t){let n=[];return $(n,"origin",t.origins,e.origin),$(n,"coverage",t.coverage,e.coverage.state),$(n,"producer-validation",t.producerValidation,e.producerValidation.status),$(n,"state-authority",t.stateAuthority,e.stateAuthority.authority),$(n,"action-permission",t.actionPermission,e.repositoryPolicy.permission),{satisfied:n.every(i=>i.satisfied),predicates:n}}function $(e,t,n,i){n&&e.push({predicate:t,satisfied:n.includes(i),required:n,actual:i})}function xe(e){return!p(e)||e.schemaVersion!==Ie||!A(e.origin,ee)||!Ui(e.coverage)||!Hi(e.producerValidation)||!Ki(e.stateAuthority)||!qi(e.repositoryPolicy)?!1:e.families===void 0||Yi(e.families)}function Ui(e){return!p(e)||!A(e.state,Ut)||!w(e.returned)||typeof e.totalKnown!="boolean"||e.total!==void 0&&!w(e.total)||e.omitted!==void 0&&!w(e.omitted)?!1:e.state==="complete"?e.totalKnown===!0&&e.total===e.returned&&e.omitted===0:e.state==="partial"?e.totalKnown===!0&&w(e.total)&&w(e.omitted)&&e.total===Number(e.returned)+Number(e.omitted):e.totalKnown===!1}function Hi(e){if(!p(e)||!A(e.status,Ht))return!1;let t=e.certification;return e.status==="validated"||e.status==="failed"?p(t)&&g(t.id)&&Number.isSafeInteger(t.version)&&Number(t.version)>0&&g(t.corpus):t===void 0}function Ki(e){return p(e)&&Number.isSafeInteger(e.policyVersion)&&(e.authority==="completion"||e.authority==="advisory"||e.authority==="none")&&Array.isArray(e.requiredRelationships)&&e.requiredRelationships.every(g)&&Array.isArray(e.reasons)&&e.reasons.every(g)}function qi(e){return p(e)&&g(e.policyId)&&e.policyVersion===Oe&&A(e.permission,Kt)&&Array.isArray(e.reasons)&&e.reasons.every(g)}function Yi(e){return Array.isArray(e)&&e.every(t=>p(t)&&g(t.id)&&g(t.selector)&&Qi(t.origin))}function Qi(e){return p(e)?e.kind==="fixed"?A(e.origin,ee)&&e.origin!=="mixed":e.kind!=="result-field"||!g(e.field)||!p(e.values)?!1:Object.values(e.values).every(t=>A(t,ee)&&t!=="mixed"):!1}function A(e,t){return typeof e=="string"&&t.includes(e)}var zt="scip-query-result",Zt=0,N=1,Xi=1,en=1,tn=1;function nn(e){if(!p(e))return{kind:"malformed",reason:"CLI JSON output must be an object."};let t=Object.hasOwn(e,"kind"),n=Object.hasOwn(e,"schemaVersion");if(!t&&!n){let s=Qt(e);return s?{kind:"malformed",reason:`Legacy CLI JSON envelope: ${s}`}:{kind:"legacy",schemaVersion:Zt,envelope:e}}if(!t||!n)return{kind:"malformed",reason:"CLI JSON envelope must contain both kind and schemaVersion."};if(e.kind!==zt)return{kind:"malformed",reason:`Unsupported CLI JSON envelope kind: ${tr(e.kind)}.`};let i=e.schemaVersion;if(!Number.isSafeInteger(i)||Number(i)<1)return{kind:"malformed",reason:"CLI JSON envelope schemaVersion must be a positive safe integer."};if(i!==N)return{kind:"unsupported",schemaVersion:Number(i),direction:Number(i)<N?"older":"future",...Xt(e.producer)?{producer:e.producer}:{}};let r=Qt(e);if(r)return{kind:"malformed",reason:`CLI JSON envelope v1: ${r}`};if(!Xt(e.producer))return{kind:"malformed",reason:"CLI JSON envelope v1: producer must identify scip-query and its non-empty version."};if(!j(e.resultSchemaVersion))return{kind:"malformed",reason:"CLI JSON envelope v1: resultSchemaVersion must be a positive safe integer."};if(e.resultProjection!==void 0&&e.resultProjection!=="agent")return{kind:"malformed",reason:'CLI JSON envelope v1: resultProjection must be "agent" when present.'};let o=rn(e.command);return o.includes(e.resultSchemaVersion)?e.evidenceContext!==void 0&&!er(e.evidenceContext)?{kind:"malformed",reason:"CLI JSON envelope v1: evidenceContext must contain a supported receipt and analysis manifest."}:e.operationRole!==void 0&&!Z(e.operationRole)?{kind:"malformed",reason:"CLI JSON envelope v1: operationRole must be a supported command operation role."}:p(e.evidenceContext)&&e.operationRole!==void 0&&e.evidenceContext.operationRole!==void 0&&e.operationRole!==e.evidenceContext.operationRole?{kind:"malformed",reason:"CLI JSON envelope v1: top-level and evidence-context operation roles must agree."}:{kind:"supported",schemaVersion:N,envelope:e}:{kind:"unsupported-result",schemaVersion:N,command:e.command,resultSchemaVersion:e.resultSchemaVersion,supportedResultSchemaVersions:o}}function zi(e){let t=nn(e);if(t.kind==="legacy"||t.kind==="supported")return t;if(t.kind==="unsupported"){let n=t.producer?` from ${t.producer.name}@${t.producer.version}`:"";throw new Error(`Unsupported scip-query CLI JSON schemaVersion ${t.schemaVersion}${n}; this consumer supports the legacy unversioned envelope and schemaVersion ${N}.`)}throw t.kind==="unsupported-result"?new Error(`Unsupported resultSchemaVersion ${t.resultSchemaVersion} for scip-query command ${JSON.stringify(t.command)}; this consumer supports ${t.supportedResultSchemaVersions.join(", ")}.`):new Error(`Malformed scip-query CLI JSON envelope: ${t.reason}`)}function rn(e){return Zi[e]??[Xi]}var Zi={};function Qt(e){return typeof e.command!="string"||e.command.length===0?"command must be a non-empty string.":Array.isArray(e.args)?p(e.options)?Object.hasOwn(e,"result")?null:"result is required.":"options must be an object.":"args must be an array."}function Xt(e){return p(e)&&e.name==="scip-query"&&typeof e.version=="string"&&e.version.length>0}function er(e){if(!p(e)||e.schemaVersion!==en||e.operationRole!==void 0&&!Z(e.operationRole)||!H(e.receipt))return!1;let t=e.analysisManifest;return p(t)&&t.schemaVersion===tn&&(t.evidence===void 0||t.evidence==="graph-fact"||t.evidence==="heuristic"||t.evidence==="mixed")&&(t.claimQualification===void 0||xe(t.claimQualification))}function tr(e){return typeof e=="string"?JSON.stringify(e):String(e)}export{Kt as CLAIM_ACTION_PERMISSIONS,Oe as CLAIM_ACTION_POLICY_VERSION,Ut as CLAIM_COVERAGE_STATES,ee as CLAIM_ORIGINS,Ie as CLAIM_QUALIFICATION_SCHEMA_VERSION,tn as CLI_ANALYSIS_MANIFEST_SCHEMA_VERSION,en as CLI_EVIDENCE_CONTEXT_SCHEMA_VERSION,zt as CLI_JSON_ENVELOPE_KIND,Bt as COMMAND_OPERATION_ROLES,N as CURRENT_CLI_JSON_ENVELOPE_SCHEMA_VERSION,qt as DEFAULT_REPOSITORY_POLICY_ACTION,Zt as LEGACY_CLI_JSON_ENVELOPE_SCHEMA_VERSION,f as LEGACY_OBSERVATION_RECEIPT_SCHEMA_VERSION,D as OBSERVATION_IDENTITY_CANONICALIZATION_VERSION,V as OBSERVATION_IDENTITY_HASH_ALGORITHM,U as OBSERVATION_IDENTITY_SCHEMA_VERSION,I as OBSERVATION_RECEIPT_SCHEMA_VERSION,ae as OBSERVATION_STATE_AUTHORITY_POLICY_VERSION,Ht as PRODUCER_VALIDATION_STATUSES,ge as Watcher,Wi as commandOperation,Fi as commandOperationRoles,de as compareObservationReceipts,tt as createObservationIdentity,Lt as createReindexRunner,nn as decodeCliJsonEnvelope,ce as decodeObservationReceipt,Yt as deriveClaimCoverage,Ji as deriveClaimQualification,K as deriveObservationStateAuthority,Bi as evaluateClaimQualification,an as getScipVersion,Wn as initProjectConfig,Mi as installSkills,xe as isClaimQualificationV1,Z as isCommandOperationRole,H as isObservationReceipt,sn as isScipInstalled,Q as loadProjectConfig,nt as observationReceiptGenerationIdentity,rt as observationReceiptStabilityLabel,it as observationReceiptWorkspaceIdentity,Gi as operationObservesRepository,cn as printScipInstallInstructions,zi as requireCompatibleCliJsonEnvelope,$i as resolveCommandOperationRole,J as resolveIndexStoragePaths,Vt as resolveReindexWorkerLaunch,rn as supportedCliResultSchemaVersions};
5
5
  //# sourceMappingURL=runtime.js.map
@@ -1,2 +1,2 @@
1
- import{j as U}from"./chunk-DHKBIOXF.js";import{e as E,f as A,g as O,h as C,m as V}from"./chunk-CT5SI2I4.js";import"./chunk-54EOGFBR.js";import"./chunk-F4FNK44D.js";import"./chunk-T6FRID7Y.js";import"./chunk-Q7HB7BFJ.js";import{a as v,c as h,g as x,h as q,l as _,m as N,q as T,r as g,s as k,t as P,v as B}from"./chunk-G6OGPXJW.js";import"./chunk-DRENNWRG.js";import"./chunk-H5EXS3HM.js";import"./chunk-HGFDYOVB.js";import{c as L,d as b}from"./chunk-3VLJ2DCA.js";import"./chunk-4DCKBY6T.js";import n from"process";import{randomUUID as H}from"crypto";import{rmSync as J}from"fs";import{resolve as S}from"path";import{pathToFileURL as W}from"url";var X=10*6e4,F=10,G=250,z=1e3;function Y(e,t,s={}){let M=_(e),d=s.now??(s.nowMs===void 0?Date.now:()=>s.nowMs),f=d(),y=A(e),w=T(M,{ownerId:s.ownerId??oe,nowMs:f,limits:s.limits,owner:re,liveness:ne}),R=0;for(let i of w){let o=null,c,m="handler-error";try{let u=g(i,s.limits),a;try{a=JSON.parse(u)}catch{throw m="malformed-request",new Error("Durable Rust semantic helper received malformed request JSON.")}let r=O(a,{claimRequestId:i.requestId,sessionIdentity:y,nowMs:d()});if(!r.ok)throw m=r.code,c=r.responseIdentity,new Error(r.error);o=r.value,c={id:o.id,sessionIdentity:o.sessionIdentity,deadlineAtMs:o.deadlineAtMs};let l=$(o.request,s.monotonicNowMs??b());s.beforeRequest?.(l);let p=t.handle(l),I=d();if(o.deadlineAtMs<I)throw m="expired-request",new Error("Durable Rust semantic request expired while the helper was processing it.");k(M,i,{ok:!0,protocolVersion:E,id:o.id,sessionIdentity:o.sessionIdentity,deadlineAtMs:o.deadlineAtMs,...p},{nowMs:I,limits:s.limits})}catch(u){let a=d(),r=c??(o?{id:o.id,sessionIdentity:o.sessionIdentity,deadlineAtMs:o.deadlineAtMs}:void 0),l=u instanceof Error?u.message:String(u);P(M,i,{ok:!1,protocolVersion:E,id:r?.id??i.requestId,...r?{sessionIdentity:r.sessionIdentity,deadlineAtMs:r.deadlineAtMs}:{},errorCode:m,error:l},l,{nowMs:a,limits:s.limits})}R+=1}return R}function $(e,t){let s=t+Math.max(1,e.timeoutMs-1e3);return{...e,request:{...e.request,readinessDeadlineMs:s}}}async function K(e,t){let s=_(e);N(s);let M=S(e,"server.lock"),d=ee(M);if(!d)return;let f=new C(()=>V({semanticWorkerPath:t,shareEnvironment:!0})),y=!1,w=b(),R=Number.NEGATIVE_INFINITY,i,o=0,c=L(n.pid),m=A(e),u=()=>{y=!0};n.once("SIGINT",u),n.once("SIGTERM",u);let a=(r=!1,l=r?"durable":"visibility")=>{let p=Date.now(),I=b();if(!r&&I-R<z)return;R=I;let D={protocolVersion:E,sessionIdentity:m,pid:n.pid,...c?{processIdentity:c}:{},heartbeatAtMs:p,...i===void 0?{}:{busyUntilMs:i},mailbox:B(s)};l==="durable"?q(S(e,"server.json"),D):x(S(e,"server.json"),D)};try{a(!0);let r=te();for(;!y&&b()-w<r;){let l=Y(e,f,{beforeRequest(p){i=Date.now()+p.timeoutMs+5e3,a(!0,"visibility")}});l>0?(o=0,w=b(),i=void 0,a(!0,"visibility")):(o+=1,a()),await U(Q(l,o))}}finally{f.shutdown(),J(S(e,"server.json"),{force:!0}),d.release()}}function Q(e,t=1){if(e>0)return F;let s=Math.max(0,Math.min(5,t-1));return Math.min(G,F*2**s)}var Z=e=>{let t=Number(e);return Number.isInteger(t)&&t>0?{pid:t}:null};function ee(e){let t=h(e,{kind:"rust-durable-session-server",parseLegacy:Z});return t.kind==="acquired"?t.lock:null}function te(){let e=Number(n.env.SCIP_RUST_SEMANTIC_DURABLE_IDLE_MS);return Number.isInteger(e)&&e>=0?e:X}var se=n.argv[1]?W(S(n.argv[1])).href:null;if(se===import.meta.url){let e=n.argv[2],t=n.argv[3];!e||!t?(console.error("durable-rust-session: expected <session-dir> <semantic-worker-path>"),n.exitCode=1):await K(e,t)}var oe=`rust-semantic-${n.pid}-${H()}`,j=L(n.pid),re={pid:n.pid,...j?{processIdentity:j}:{}},ne={isProcessAlive:v,readProcessIdentity:L};export{ee as acquireDurableRustSessionServerLock,Q as durableSessionLoopDelayMs,Y as processDurableRustSessionRequests};
1
+ import{j as O}from"./chunk-KQHJEU6V.js";import{e as E,f as A,g as C,h as V,m as F}from"./chunk-WSLEJSFR.js";import"./chunk-VUSKPCUB.js";import"./chunk-F4FNK44D.js";import"./chunk-HCVJR2V4.js";import"./chunk-DRENNWRG.js";import"./chunk-JHH5SCZ3.js";import{b as h}from"./chunk-57N6LN2A.js";import{a as x,c as q,d as N,i as _,j as T,n as g,o as k,p as P,q as B,s as U}from"./chunk-JT6XX7QY.js";import"./chunk-H5EXS3HM.js";import"./chunk-HGFDYOVB.js";import{c as L,d as b,e as v}from"./chunk-SB25YMEQ.js";import"./chunk-AK3PYTIK.js";import n from"process";import{randomUUID as J}from"crypto";import{rmSync as W}from"fs";import{resolve as S}from"path";import{pathToFileURL as X}from"url";var G=10*6e4,j=10,z=250,Y=1e3;function $(e,t,o={}){let M=_(e),d=o.now??(o.nowMs===void 0?Date.now:()=>o.nowMs),f=d(),y=A(e),w=g(M,{ownerId:o.ownerId??re,nowMs:f,limits:o.limits,owner:ne,liveness:ie}),p=0;for(let i of w){let s=null,c,m="handler-error";try{let a=k(i,o.limits),u;try{u=JSON.parse(a)}catch{throw m="malformed-request",new Error("Durable Rust semantic helper received malformed request JSON.")}let r=C(u,{claimRequestId:i.requestId,sessionIdentity:y,nowMs:d()});if(!r.ok)throw m=r.code,c=r.responseIdentity,new Error(r.error);s=r.value,c={id:s.id,sessionIdentity:s.sessionIdentity,deadlineAtMs:s.deadlineAtMs};let l=K(s.request,o.monotonicNowMs??b());o.beforeRequest?.(l);let R=t.handle(l),I=d();if(s.deadlineAtMs<I)throw m="expired-request",new Error("Durable Rust semantic request expired while the helper was processing it.");P(M,i,{ok:!0,protocolVersion:E,id:s.id,sessionIdentity:s.sessionIdentity,deadlineAtMs:s.deadlineAtMs,...R},{nowMs:I,limits:o.limits})}catch(a){let u=d(),r=c??(s?{id:s.id,sessionIdentity:s.sessionIdentity,deadlineAtMs:s.deadlineAtMs}:void 0),l=a instanceof Error?a.message:String(a);B(M,i,{ok:!1,protocolVersion:E,id:r?.id??i.requestId,...r?{sessionIdentity:r.sessionIdentity,deadlineAtMs:r.deadlineAtMs}:{},errorCode:m,error:l},l,{nowMs:u,limits:o.limits})}p+=1}return p}function K(e,t){let o=t+Math.max(1,e.timeoutMs-1e3);return{...e,request:{...e.request,readinessDeadlineMs:o}}}async function Q(e,t){let o=_(e);T(o);let M=S(e,"server.lock"),d=te(M);if(!d)return;let f=new V(()=>F({semanticWorkerPath:t,shareEnvironment:!0})),y=!1,w=b(),p=Number.NEGATIVE_INFINITY,i,s=0,c=L(n.pid),m=A(e),a=()=>{y=!0};n.once("SIGINT",a),n.once("SIGTERM",a);let u=(r=!1,l=r?"durable":"visibility")=>{let R=Date.now(),I=b();if(!r&&I-p<Y)return;p=I;let D={protocolVersion:E,sessionIdentity:m,pid:n.pid,...c?{processIdentity:c}:{},heartbeatAtMs:R,...i===void 0?{}:{busyUntilMs:i},mailbox:U(o)};l==="durable"?N(S(e,"server.json"),D):q(S(e,"server.json"),D)};try{u(!0);let r=se();for(;!y&&b()-w<r;){let l=$(e,f,{beforeRequest(R){i=Date.now()+R.timeoutMs+5e3,u(!0,"visibility")}});l>0?(s=0,w=b(),i=void 0,u(!0,"visibility")):(s+=1,u()),await O(Z(l,s))}}finally{f.shutdown(),W(S(e,"server.json"),{force:!0}),d.release()}}function Z(e,t=1){return v(e,t,j,j,z,5)}var ee=e=>{let t=Number(e);return Number.isInteger(t)&&t>0?{pid:t}:null};function te(e){let t=h(e,{kind:"rust-durable-session-server",parseLegacy:ee});return t.kind==="acquired"?t.lock:null}function se(){let e=Number(n.env.SCIP_RUST_SEMANTIC_DURABLE_IDLE_MS);return Number.isInteger(e)&&e>=0?e:G}var oe=n.argv[1]?X(S(n.argv[1])).href:null;if(oe===import.meta.url){let e=n.argv[2],t=n.argv[3];!e||!t?(console.error("durable-rust-session: expected <session-dir> <semantic-worker-path>"),n.exitCode=1):await Q(e,t)}var re=`rust-semantic-${n.pid}-${J()}`,H=L(n.pid),ne={pid:n.pid,...H?{processIdentity:H}:{}},ie={isProcessAlive:x,readProcessIdentity:L};export{te as acquireDurableRustSessionServerLock,Z as durableSessionLoopDelayMs,$ as processDurableRustSessionRequests};
2
2
  //# sourceMappingURL=rust-semantic-session-server.js.map
@@ -1,2 +1,2 @@
1
- import{b as H,c as U,d as K,e as W,f as le,i as ce,j as ue,k as de,l as fe,m as D,o as me,p as pe}from"./chunk-K5MZYZV7.js";import{a as P,b as ne}from"./chunk-ILMHV3KM.js";import{b as te,c as ie,d as C,e as N,f as G,h as E,i as B,j as S}from"./chunk-DHKBIOXF.js";import{d as F,e as se,f as re,g as oe,h as ae}from"./chunk-T6FRID7Y.js";import"./chunk-Q7HB7BFJ.js";import{a as j,f as d,g as M}from"./chunk-HGFDYOVB.js";import"./chunk-3VLJ2DCA.js";import{da as q,ea as ee}from"./chunk-4DCKBY6T.js";import k from"process";import{existsSync as Te,writeFileSync as ve}from"fs";import{dirname as Ae,isAbsolute as Ie,resolve as Ce}from"path";import{performance as L}from"perf_hooks";import{parentPort as Ee}from"worker_threads";import{resolve as he}from"path";var ze=4,x=class{constructor(n=ze){this.capacity=n;if(!Number.isSafeInteger(n)||n<=0)throw new Error("Rust analyzer session capacity must be a positive safe integer.")}capacity;entries=new Map;get(n){let i=this.entries.get(n);if(i)return this.entries.delete(n),this.entries.set(n,i),i}async acquire(n,i,t){let s=this.get(n);if(s)return s;if(this.entries.size>=this.capacity){let o=this.entries.entries().next().value;if(!o)throw new Error("Rust analyzer session registry capacity accounting is inconsistent.");this.entries.delete(o[0]);try{await t(o[1])}catch(l){throw this.restoreOldest(o),l}}let r=await i();if(r.key!==n){try{await t(r)}catch(o){throw new AggregateError([o],`Rust analyzer session factory returned '${r.key}' for reserved key '${n}', and the mismatched session could not be reaped.`,{cause:o})}throw new Error(`Rust analyzer session factory returned '${r.key}' for reserved key '${n}'.`)}return this.entries.set(n,r),r}deleteIfSame(n){return this.entries.get(n.key)!==n?!1:this.entries.delete(n.key)}async shutdownAll(n){let i=[...this.entries.values()];this.entries.clear();let t=await Promise.allSettled(i.map(n)),s=[];for(let r=0;r<t.length;r+=1){let o=t[r];if(o.status==="fulfilled")continue;let l=i[r];s.push({session:l,reason:o.reason}),this.entries.set(l.key,l)}if(s.length>0)throw new AggregateError(s.map(r=>r.reason),`Failed to shut down ${s.length} retained rust-analyzer session(s).`)}get size(){return this.entries.size}restoreOldest(n){let i=[...this.entries.entries()];this.entries.clear(),this.entries.set(n[0],n[1]);for(let[t,s]of i)this.entries.set(t,s)}};function Re(e,n){let i=he(e);return[...new Set(n.map(t=>he(i,t)))].sort((t,s)=>t<s?-1:t>s?1:0)}function ye(e,n,i){return JSON.stringify({binary:e,sessionRoot:n,linkedProjects:i})}var Fe="SCIP_RUST_SEMANTIC_REFERENCE_TASK_PROFILE_MS",We="SCIP_RUST_SEMANTIC_CALLEE_TASK_PROFILE_MS",_=new x,ge=Promise.resolve(),Me;Ee?.on("message",e=>{ge=ge.then(()=>xe(e)).catch(()=>{})});async function xe(e){if(Me??=Ae(e.responsePath),e.kind==="shutdown"){await He(),g(e.responsePath,{ok:!0},e.sharedBuffer);return}if(e.kind==="import-definitions"){try{let n=await Le(e.request);g(e.responsePath,{ok:!0,response:n},e.sharedBuffer)}catch(n){let i=B(n);if(i){g(e.responsePath,i,e.sharedBuffer);return}let t={available:!1,reason:n instanceof Error?n.message:String(n),sourcePaths:e.request.positions.map(s=>[s.id,null])};g(e.responsePath,{ok:!0,response:t},e.sharedBuffer)}return}try{let n=await _e(e.request);g(e.responsePath,{ok:!0,response:n},e.sharedBuffer)}catch(n){let i=B(n);if(i){g(e.responsePath,i,e.sharedBuffer);return}let t=De(e.request,n instanceof Error?n.message:String(n));g(e.responsePath,{ok:!0,response:t},e.sharedBuffer)}}async function Le(e){let n={timeoutMs:e.requestTimeoutMs,deadlineMs:e.readinessDeadlineMs},i=await d("rust.semantic.worker.session",()=>Pe(e.projectRoot,e.rustAnalyzerBinary,[e.file],{requestTimeoutMs:e.requestTimeoutMs,readinessDeadlineMs:e.readinessDeadlineMs}),()=>({kind:"import-definitions",files:1,positions:e.positions.length}));if(!i.capabilities.definitionProvider)return{available:!1,reason:"rust-analyzer initialized without textDocument/definition support.",sourcePaths:e.positions.map(o=>[o.id,null])};let t=0;await E(()=>d("rust.semantic.worker.open-source-documents",async()=>{t=await Ne(i,e.projectRoot,[e.file],{diagnosticsTimeoutMs:e.diagnosticsTimeoutMs,settleDelayMs:e.settleDelayMs,readinessDeadlineMs:e.readinessDeadlineMs})},()=>({files:1,openedDocuments:t,positions:e.positions.length})),()=>ke(_,i,e.readinessDeadlineMs));let s=0;return{available:!0,sourcePaths:await d("rust.semantic.worker.import-definitions",()=>P(e.positions,e.concurrency??8,async o=>{let l=await i.client.definition({textDocument:{uri:F(e.projectRoot,o.file)},position:{line:o.line,character:o.column}},n),u=Ge(e.projectRoot,l);return u&&(s+=1),[o.id,u]}),()=>({positions:e.positions.length,resolvedPositions:s,concurrency:e.concurrency??8}))}}async function _e(e){let n={timeoutMs:e.requestTimeoutMs,deadlineMs:e.readinessDeadlineMs},i=e.includeReferences!==!1,t=e.includeCallees===!0,s=e.includeSignatures===!0,r=H(e),o=U(e),l=K(e),u=W(e),c=await d("rust.semantic.worker.session",()=>Oe(e),()=>({kind:"semantic",definitions:u.length,referenceDefinitions:r.length,calleeDefinitions:o.length,signatureDefinitions:l.length,references:i,callees:t,signatures:s})),p=Be(c.capabilities,{references:i,callees:t,signatures:s});if(p)return De(e,p);let f=0;await E(()=>d("rust.semantic.worker.open-definition-documents",async()=>{f=await je(c,e)},()=>({definitions:u.length,openedDocuments:f})),()=>ke(_,c,e.readinessDeadlineMs));let m=0,b=0,y=j(),$=y?new Map:null,z=y?we(k.env[Fe]):null,J=()=>i?d("rust.semantic.worker.references",()=>P(r,e.concurrency??8,async a=>{let w=y?L.now():0,R=await me(c.client,re(e.projectRoot,a,!1),{requestTimeoutMs:e.requestTimeoutMs,retryTimeoutMs:e.referenceRetryTimeoutMs,deadlineMs:e.readinessDeadlineMs}),h=ae(oe(e.projectRoot,R.locations)),I=y?Math.round(L.now()-w):0;return Ue($,a.relativePath,{durationMs:I,references:h.length,hasReferences:h.length>0,slow:z!==null&&I>=z}),z!==null&&I>=z&&M({type:"span",name:"rust.semantic.worker.reference-task",durationMs:I,ok:!0,symbolId:a.symbolId,relativePath:a.relativePath,leaf:a.leaf,kind:a.kind,startLine:a.startLine,endLine:a.endLine,references:h.length,complete:R.complete}),h.length>0&&(b+=1),m+=h.length,{symbolId:a.symbolId,references:h,complete:R.complete}}),()=>({definitions:r.length,concurrency:e.concurrency??8,definitionsWithReferences:b,references:m})):Promise.resolve(r.map(a=>({symbolId:a.symbolId,references:[],complete:!0}))),V=0,Y=0,T=j(),Z=T?new Map:null,v=T?we(k.env[We]):null,Q=()=>t?d("rust.semantic.worker.callees",()=>P(o,e.concurrency??8,async a=>{let w=T?L.now():0,R=await pe(c.client,e.projectRoot,a,n),h=T?Math.round(L.now()-w):0;return Je(Z,a.relativePath,{durationMs:h,callees:R.length,hasCallees:R.length>0,slow:v!==null&&h>=v}),v!==null&&h>=v&&M({type:"span",name:"rust.semantic.worker.callee-task",durationMs:h,ok:!0,symbolId:a.symbolId,relativePath:a.relativePath,leaf:a.leaf,kind:a.kind,startLine:a.startLine,endLine:a.endLine,callees:R.length}),R.length>0&&(Y+=1),V+=R.length,{symbolId:a.symbolId,callees:R}}),()=>({definitions:o.length,concurrency:e.concurrency??8,definitionsWithCallees:Y,callees:V})):Promise.resolve([]),A,O;i&&t&&r.length>0&&o.length>0&&Ze()?[A,O]=await ne([J(),Q()]):(A=await J(),O=await Q()),Ke($),Ve(Z);let X=0,be=s?await d("rust.semantic.worker.signatures",()=>P(l,e.concurrency??8,async a=>{let w=await le(c.client,e.projectRoot,a,n);return w&&(X+=1),{symbolId:a.symbolId,signature:w}}),()=>({definitions:l.length,concurrency:e.concurrency??8,signaturesFound:X})):[];return{available:!0,references:A.filter(a=>a.complete).map(a=>[a.symbolId,a.references]),incompleteReferenceSymbolIds:A.filter(a=>!a.complete).map(a=>a.symbolId),...t?{callees:O.map(a=>[a.symbolId,a.callees])}:{},...s?{signatures:be.map(a=>[a.symbolId,a.signature])}:{}}}async function Oe(e){return Pe(e.projectRoot,e.rustAnalyzerBinary,W(e).map(n=>n.relativePath),{requestTimeoutMs:e.requestTimeoutMs,readinessDeadlineMs:e.readinessDeadlineMs})}async function Pe(e,n,i,t){let s=Re(e,de(e,i.map(l=>({relativePath:l})))),r=ue(e,s),o=ye(n,r,s);return _.acquire(o,async()=>{let l=ce(s),u=new te(ie(n,r,k.env,Me),{requestTimeoutMs:t.requestTimeoutMs,configuration:l}),c=t.readinessDeadlineMs===void 0?null:{afterGeneration:u.serverStatusGeneration(),deadlineMs:t.readinessDeadlineMs},p=await E(()=>d("rust.semantic.worker.initialize",()=>u.initialize({processId:k.pid,rootUri:F(r,"."),capabilities:{textDocument:{references:{dynamicRegistration:!1},definition:{dynamicRegistration:!1},callHierarchy:{dynamicRegistration:!1},hover:{dynamicRegistration:!1}}},initializationOptions:l},{timeoutMs:t.requestTimeoutMs,deadlineMs:t.readinessDeadlineMs}),()=>({linkedProjects:s.length,relativePaths:i.length})),()=>u.shutdownAndReap({deadlineMs:t.readinessDeadlineMs}));return{key:o,client:u,capabilities:p.capabilities,openedPaths:new Set,initializationReadiness:c}},l=>l.client.shutdownAndReap({deadlineMs:t.readinessDeadlineMs}))}async function je(e,n){let i=W(n).filter(c=>e.openedPaths.has(c.relativePath)?!1:Te(Ce(n.projectRoot,c.relativePath)));if(i.length===0)return await Se(e),0;let t=e.initializationReadiness,s=n.readinessDeadlineMs===void 0?null:{statusSnapshot:t?null:e.client.serverStatusSnapshot(),initializationGeneration:t?.afterGeneration,deadlineMs:n.readinessDeadlineMs},r=fe(e.client,n.projectRoot,i);for(let c of i)e.openedPaths.add(c.relativePath);let o=n.diagnosticsTimeoutMs??1e4,l=o;await d("rust.semantic.worker.diagnostics",()=>s?G(c=>(l=c,D(e.client,r,c)),o,s.deadlineMs):D(e.client,r,o),()=>({openedDocuments:r.length,timeoutMs:l}));let u=n.settleDelayMs??5e3;if(!s)await d("rust.semantic.worker.settle",()=>S(u),()=>({openedDocuments:r.length,settleDelayMs:u}));else{let c;await d("rust.semantic.worker.readiness",async()=>{let p=m=>d("rust.semantic.worker.settle",()=>S(m),()=>({openedDocuments:r.length,settleDelayMs:m})),f=s.initializationGeneration===void 0?await N(e.client,s.statusSnapshot,r.length,s.deadlineMs,u,Date.now,p):await C(e.client,s.initializationGeneration,r.length,s.deadlineMs,u,Date.now,p);s.initializationGeneration!==void 0&&(e.initializationReadiness=null),c=f?.health},()=>({phase:s.initializationGeneration===void 0?"didOpen":"initialize+didOpen",openedDocuments:r.length,health:c}))}return r.length}async function Ne(e,n,i,t){let s=i.filter(f=>!e.openedPaths.has(f));if(s.length===0)return await Se(e),0;let r=e.initializationReadiness,o=t.readinessDeadlineMs===void 0?null:{statusSnapshot:r?null:e.client.serverStatusSnapshot(),initializationGeneration:r?.afterGeneration,deadlineMs:t.readinessDeadlineMs},l=[];for(let f of s)try{let m=F(n,f);e.client.didOpenTextDocument({uri:m,languageId:"rust",version:1,text:q(n,f,{inputKind:"indexed Rust source file"})}),e.openedPaths.add(f),l.push(m)}catch(m){if(!ee(m))throw m}let u=t.diagnosticsTimeoutMs??1e4,c=u;await d("rust.semantic.worker.diagnostics",()=>o?G(f=>(c=f,D(e.client,l,f)),u,o.deadlineMs):D(e.client,l,u),()=>({openedDocuments:l.length,timeoutMs:c}));let p=t.settleDelayMs??5e3;if(!o)await d("rust.semantic.worker.settle",()=>S(p),()=>({openedDocuments:l.length,settleDelayMs:p}));else{let f;await d("rust.semantic.worker.readiness",async()=>{let m=y=>d("rust.semantic.worker.settle",()=>S(y),()=>({openedDocuments:l.length,settleDelayMs:y})),b=o.initializationGeneration===void 0?await N(e.client,o.statusSnapshot,l.length,o.deadlineMs,p,Date.now,m):await C(e.client,o.initializationGeneration,l.length,o.deadlineMs,p,Date.now,m);o.initializationGeneration!==void 0&&(e.initializationReadiness=null),f=b?.health},()=>({phase:o.initializationGeneration===void 0?"didOpen":"initialize+didOpen",openedDocuments:l.length,health:f}))}return l.length}async function Se(e){let n=e.initializationReadiness;if(!n)return;let i;await d("rust.semantic.worker.readiness",async()=>{i=(await C(e.client,n.afterGeneration,0,n.deadlineMs,0)).health,e.initializationReadiness=null},()=>({phase:"initialize",openedDocuments:0,health:i}))}function Ge(e,n){for(let i of n){let t=se(e,i.uri);if(!(!t||t===".."||t.startsWith("../")||Ie(t)))return t}return null}function Be(e,n){return n.references&&!e.referencesProvider?"rust-analyzer initialized without textDocument/references support.":n.callees&&!e.callHierarchyProvider?"rust-analyzer initialized without call hierarchy support.":n.signatures&&!e.hoverProvider?"rust-analyzer initialized without hover support.":null}function De(e,n){let i=H(e),t=U(e),s=K(e);return{available:!1,reason:n,references:i.map(r=>[r.symbolId,[]]),...e.includeCallees?{callees:t.map(r=>[r.symbolId,[]])}:{},...e.includeSignatures?{signatures:s.map(r=>[r.symbolId,null])}:{}}}async function He(){await _.shutdownAll(e=>e.client.shutdownAndReap())}async function ke(e,n,i){e.deleteIfSame(n),await n.client.shutdownAndReap({deadlineMs:i})}function Ue(e,n,i){if(!e)return;let t=$e(e,n);t.definitions+=1,i.hasReferences&&(t.definitionsWithReferences+=1),t.references+=i.references,t.durationMs+=i.durationMs,t.maxDurationMs=Math.max(t.maxDurationMs,i.durationMs),i.slow&&(t.slowTasks+=1)}function Ke(e){if(!e)return;let n=[...e.entries()].sort(([i,t],[s,r])=>r.durationMs-t.durationMs||i.localeCompare(s));for(let[i,t]of n)M({type:"span",name:"rust.semantic.worker.references.by-file",durationMs:t.durationMs,ok:!0,relativePath:i,definitions:t.definitions,definitionsWithReferences:t.definitionsWithReferences,references:t.references,maxDurationMs:t.maxDurationMs,slowTasks:t.slowTasks,aggregate:"sum-task-duration"})}function $e(e,n){let i=e.get(n);if(i)return i;let t={definitions:0,definitionsWithReferences:0,references:0,durationMs:0,maxDurationMs:0,slowTasks:0};return e.set(n,t),t}function Je(e,n,i){if(!e)return;let t=Ye(e,n);t.definitions+=1,i.hasCallees&&(t.definitionsWithCallees+=1),t.callees+=i.callees,t.durationMs+=i.durationMs,t.maxDurationMs=Math.max(t.maxDurationMs,i.durationMs),i.slow&&(t.slowTasks+=1)}function Ve(e){if(!e)return;let n=[...e.entries()].sort(([i,t],[s,r])=>r.durationMs-t.durationMs||i.localeCompare(s));for(let[i,t]of n)M({type:"span",name:"rust.semantic.worker.callees.by-file",durationMs:t.durationMs,ok:!0,relativePath:i,definitions:t.definitions,definitionsWithCallees:t.definitionsWithCallees,callees:t.callees,maxDurationMs:t.maxDurationMs,slowTasks:t.slowTasks,aggregate:"sum-task-duration"})}function Ye(e,n){let i=e.get(n);if(i)return i;let t={definitions:0,definitionsWithCallees:0,callees:0,durationMs:0,maxDurationMs:0,slowTasks:0};return e.set(n,t),t}function we(e){if(e===void 0||e==="")return null;let n=Number(e);return Number.isInteger(n)&&n>=0?n:null}function Ze(){let e=k.env.SCIP_RUST_SEMANTIC_PARALLEL_OPERATIONS;return e!=="0"&&e!=="false"}function g(e,n,i){ve(e,JSON.stringify(n));let t=new Int32Array(i);Atomics.store(t,0,1),Atomics.notify(t,0)}export{ke as discardRustAnalyzerSession};
1
+ import{b as H,c as U,d as K,e as W,f as le,i as ce,j as ue,k as de,l as fe,m as D,o as me,p as pe}from"./chunk-HXOU4XNH.js";import{a as P,b as ne}from"./chunk-ILMHV3KM.js";import{b as te,c as ie,d as C,e as N,f as G,h as E,i as B,j as S}from"./chunk-KQHJEU6V.js";import{d as F,e as se,f as re,g as oe,h as ae}from"./chunk-HCVJR2V4.js";import"./chunk-JHH5SCZ3.js";import{a as j,f as d,g as M}from"./chunk-HGFDYOVB.js";import"./chunk-SB25YMEQ.js";import{ma as q,na as ee}from"./chunk-AK3PYTIK.js";import k from"process";import{existsSync as Te,writeFileSync as ve}from"fs";import{dirname as Ae,isAbsolute as Ie,resolve as Ce}from"path";import{performance as L}from"perf_hooks";import{parentPort as Ee}from"worker_threads";import{resolve as he}from"path";var ze=4,x=class{constructor(n=ze){this.capacity=n;if(!Number.isSafeInteger(n)||n<=0)throw new Error("Rust analyzer session capacity must be a positive safe integer.")}capacity;entries=new Map;get(n){let i=this.entries.get(n);if(i)return this.entries.delete(n),this.entries.set(n,i),i}async acquire(n,i,t){let s=this.get(n);if(s)return s;if(this.entries.size>=this.capacity){let o=this.entries.entries().next().value;if(!o)throw new Error("Rust analyzer session registry capacity accounting is inconsistent.");this.entries.delete(o[0]);try{await t(o[1])}catch(l){throw this.restoreOldest(o),l}}let r=await i();if(r.key!==n){try{await t(r)}catch(o){throw new AggregateError([o],`Rust analyzer session factory returned '${r.key}' for reserved key '${n}', and the mismatched session could not be reaped.`,{cause:o})}throw new Error(`Rust analyzer session factory returned '${r.key}' for reserved key '${n}'.`)}return this.entries.set(n,r),r}deleteIfSame(n){return this.entries.get(n.key)!==n?!1:this.entries.delete(n.key)}async shutdownAll(n){let i=[...this.entries.values()];this.entries.clear();let t=await Promise.allSettled(i.map(n)),s=[];for(let r=0;r<t.length;r+=1){let o=t[r];if(o.status==="fulfilled")continue;let l=i[r];s.push({session:l,reason:o.reason}),this.entries.set(l.key,l)}if(s.length>0)throw new AggregateError(s.map(r=>r.reason),`Failed to shut down ${s.length} retained rust-analyzer session(s).`)}get size(){return this.entries.size}restoreOldest(n){let i=[...this.entries.entries()];this.entries.clear(),this.entries.set(n[0],n[1]);for(let[t,s]of i)this.entries.set(t,s)}};function Re(e,n){let i=he(e);return[...new Set(n.map(t=>he(i,t)))].sort((t,s)=>t<s?-1:t>s?1:0)}function ye(e,n,i){return JSON.stringify({binary:e,sessionRoot:n,linkedProjects:i})}var Fe="SCIP_RUST_SEMANTIC_REFERENCE_TASK_PROFILE_MS",We="SCIP_RUST_SEMANTIC_CALLEE_TASK_PROFILE_MS",_=new x,ge=Promise.resolve(),Me;Ee?.on("message",e=>{ge=ge.then(()=>xe(e)).catch(()=>{})});async function xe(e){if(Me??=Ae(e.responsePath),e.kind==="shutdown"){await He(),g(e.responsePath,{ok:!0},e.sharedBuffer);return}if(e.kind==="import-definitions"){try{let n=await Le(e.request);g(e.responsePath,{ok:!0,response:n},e.sharedBuffer)}catch(n){let i=B(n);if(i){g(e.responsePath,i,e.sharedBuffer);return}let t={available:!1,reason:n instanceof Error?n.message:String(n),sourcePaths:e.request.positions.map(s=>[s.id,null])};g(e.responsePath,{ok:!0,response:t},e.sharedBuffer)}return}try{let n=await _e(e.request);g(e.responsePath,{ok:!0,response:n},e.sharedBuffer)}catch(n){let i=B(n);if(i){g(e.responsePath,i,e.sharedBuffer);return}let t=De(e.request,n instanceof Error?n.message:String(n));g(e.responsePath,{ok:!0,response:t},e.sharedBuffer)}}async function Le(e){let n={timeoutMs:e.requestTimeoutMs,deadlineMs:e.readinessDeadlineMs},i=await d("rust.semantic.worker.session",()=>Pe(e.projectRoot,e.rustAnalyzerBinary,[e.file],{requestTimeoutMs:e.requestTimeoutMs,readinessDeadlineMs:e.readinessDeadlineMs}),()=>({kind:"import-definitions",files:1,positions:e.positions.length}));if(!i.capabilities.definitionProvider)return{available:!1,reason:"rust-analyzer initialized without textDocument/definition support.",sourcePaths:e.positions.map(o=>[o.id,null])};let t=0;await E(()=>d("rust.semantic.worker.open-source-documents",async()=>{t=await Ne(i,e.projectRoot,[e.file],{diagnosticsTimeoutMs:e.diagnosticsTimeoutMs,settleDelayMs:e.settleDelayMs,readinessDeadlineMs:e.readinessDeadlineMs})},()=>({files:1,openedDocuments:t,positions:e.positions.length})),()=>ke(_,i,e.readinessDeadlineMs));let s=0;return{available:!0,sourcePaths:await d("rust.semantic.worker.import-definitions",()=>P(e.positions,e.concurrency??8,async o=>{let l=await i.client.definition({textDocument:{uri:F(e.projectRoot,o.file)},position:{line:o.line,character:o.column}},n),u=Ge(e.projectRoot,l);return u&&(s+=1),[o.id,u]}),()=>({positions:e.positions.length,resolvedPositions:s,concurrency:e.concurrency??8}))}}async function _e(e){let n={timeoutMs:e.requestTimeoutMs,deadlineMs:e.readinessDeadlineMs},i=e.includeReferences!==!1,t=e.includeCallees===!0,s=e.includeSignatures===!0,r=H(e),o=U(e),l=K(e),u=W(e),c=await d("rust.semantic.worker.session",()=>Oe(e),()=>({kind:"semantic",definitions:u.length,referenceDefinitions:r.length,calleeDefinitions:o.length,signatureDefinitions:l.length,references:i,callees:t,signatures:s})),p=Be(c.capabilities,{references:i,callees:t,signatures:s});if(p)return De(e,p);let f=0;await E(()=>d("rust.semantic.worker.open-definition-documents",async()=>{f=await je(c,e)},()=>({definitions:u.length,openedDocuments:f})),()=>ke(_,c,e.readinessDeadlineMs));let m=0,b=0,y=j(),$=y?new Map:null,z=y?we(k.env[Fe]):null,J=()=>i?d("rust.semantic.worker.references",()=>P(r,e.concurrency??8,async a=>{let w=y?L.now():0,R=await me(c.client,re(e.projectRoot,a,!1),{requestTimeoutMs:e.requestTimeoutMs,retryTimeoutMs:e.referenceRetryTimeoutMs,deadlineMs:e.readinessDeadlineMs}),h=ae(oe(e.projectRoot,R.locations)),I=y?Math.round(L.now()-w):0;return Ue($,a.relativePath,{durationMs:I,references:h.length,hasReferences:h.length>0,slow:z!==null&&I>=z}),z!==null&&I>=z&&M({type:"span",name:"rust.semantic.worker.reference-task",durationMs:I,ok:!0,symbolId:a.symbolId,relativePath:a.relativePath,leaf:a.leaf,kind:a.kind,startLine:a.startLine,endLine:a.endLine,references:h.length,complete:R.complete}),h.length>0&&(b+=1),m+=h.length,{symbolId:a.symbolId,references:h,complete:R.complete}}),()=>({definitions:r.length,concurrency:e.concurrency??8,definitionsWithReferences:b,references:m})):Promise.resolve(r.map(a=>({symbolId:a.symbolId,references:[],complete:!0}))),V=0,Y=0,T=j(),Z=T?new Map:null,v=T?we(k.env[We]):null,Q=()=>t?d("rust.semantic.worker.callees",()=>P(o,e.concurrency??8,async a=>{let w=T?L.now():0,R=await pe(c.client,e.projectRoot,a,n),h=T?Math.round(L.now()-w):0;return Je(Z,a.relativePath,{durationMs:h,callees:R.length,hasCallees:R.length>0,slow:v!==null&&h>=v}),v!==null&&h>=v&&M({type:"span",name:"rust.semantic.worker.callee-task",durationMs:h,ok:!0,symbolId:a.symbolId,relativePath:a.relativePath,leaf:a.leaf,kind:a.kind,startLine:a.startLine,endLine:a.endLine,callees:R.length}),R.length>0&&(Y+=1),V+=R.length,{symbolId:a.symbolId,callees:R}}),()=>({definitions:o.length,concurrency:e.concurrency??8,definitionsWithCallees:Y,callees:V})):Promise.resolve([]),A,O;i&&t&&r.length>0&&o.length>0&&Ze()?[A,O]=await ne([J(),Q()]):(A=await J(),O=await Q()),Ke($),Ve(Z);let X=0,be=s?await d("rust.semantic.worker.signatures",()=>P(l,e.concurrency??8,async a=>{let w=await le(c.client,e.projectRoot,a,n);return w&&(X+=1),{symbolId:a.symbolId,signature:w}}),()=>({definitions:l.length,concurrency:e.concurrency??8,signaturesFound:X})):[];return{available:!0,references:A.filter(a=>a.complete).map(a=>[a.symbolId,a.references]),incompleteReferenceSymbolIds:A.filter(a=>!a.complete).map(a=>a.symbolId),...t?{callees:O.map(a=>[a.symbolId,a.callees])}:{},...s?{signatures:be.map(a=>[a.symbolId,a.signature])}:{}}}async function Oe(e){return Pe(e.projectRoot,e.rustAnalyzerBinary,W(e).map(n=>n.relativePath),{requestTimeoutMs:e.requestTimeoutMs,readinessDeadlineMs:e.readinessDeadlineMs})}async function Pe(e,n,i,t){let s=Re(e,de(e,i.map(l=>({relativePath:l})))),r=ue(e,s),o=ye(n,r,s);return _.acquire(o,async()=>{let l=ce(s),u=new te(ie(n,r,k.env,Me),{requestTimeoutMs:t.requestTimeoutMs,configuration:l}),c=t.readinessDeadlineMs===void 0?null:{afterGeneration:u.serverStatusGeneration(),deadlineMs:t.readinessDeadlineMs},p=await E(()=>d("rust.semantic.worker.initialize",()=>u.initialize({processId:k.pid,rootUri:F(r,"."),capabilities:{textDocument:{references:{dynamicRegistration:!1},definition:{dynamicRegistration:!1},callHierarchy:{dynamicRegistration:!1},hover:{dynamicRegistration:!1}}},initializationOptions:l},{timeoutMs:t.requestTimeoutMs,deadlineMs:t.readinessDeadlineMs}),()=>({linkedProjects:s.length,relativePaths:i.length})),()=>u.shutdownAndReap({deadlineMs:t.readinessDeadlineMs}));return{key:o,client:u,capabilities:p.capabilities,openedPaths:new Set,initializationReadiness:c}},l=>l.client.shutdownAndReap({deadlineMs:t.readinessDeadlineMs}))}async function je(e,n){let i=W(n).filter(c=>e.openedPaths.has(c.relativePath)?!1:Te(Ce(n.projectRoot,c.relativePath)));if(i.length===0)return await Se(e),0;let t=e.initializationReadiness,s=n.readinessDeadlineMs===void 0?null:{statusSnapshot:t?null:e.client.serverStatusSnapshot(),initializationGeneration:t?.afterGeneration,deadlineMs:n.readinessDeadlineMs},r=fe(e.client,n.projectRoot,i);for(let c of i)e.openedPaths.add(c.relativePath);let o=n.diagnosticsTimeoutMs??1e4,l=o;await d("rust.semantic.worker.diagnostics",()=>s?G(c=>(l=c,D(e.client,r,c)),o,s.deadlineMs):D(e.client,r,o),()=>({openedDocuments:r.length,timeoutMs:l}));let u=n.settleDelayMs??5e3;if(!s)await d("rust.semantic.worker.settle",()=>S(u),()=>({openedDocuments:r.length,settleDelayMs:u}));else{let c;await d("rust.semantic.worker.readiness",async()=>{let p=m=>d("rust.semantic.worker.settle",()=>S(m),()=>({openedDocuments:r.length,settleDelayMs:m})),f=s.initializationGeneration===void 0?await N(e.client,s.statusSnapshot,r.length,s.deadlineMs,u,Date.now,p):await C(e.client,s.initializationGeneration,r.length,s.deadlineMs,u,Date.now,p);s.initializationGeneration!==void 0&&(e.initializationReadiness=null),c=f?.health},()=>({phase:s.initializationGeneration===void 0?"didOpen":"initialize+didOpen",openedDocuments:r.length,health:c}))}return r.length}async function Ne(e,n,i,t){let s=i.filter(f=>!e.openedPaths.has(f));if(s.length===0)return await Se(e),0;let r=e.initializationReadiness,o=t.readinessDeadlineMs===void 0?null:{statusSnapshot:r?null:e.client.serverStatusSnapshot(),initializationGeneration:r?.afterGeneration,deadlineMs:t.readinessDeadlineMs},l=[];for(let f of s)try{let m=F(n,f);e.client.didOpenTextDocument({uri:m,languageId:"rust",version:1,text:q(n,f,{inputKind:"indexed Rust source file"})}),e.openedPaths.add(f),l.push(m)}catch(m){if(!ee(m))throw m}let u=t.diagnosticsTimeoutMs??1e4,c=u;await d("rust.semantic.worker.diagnostics",()=>o?G(f=>(c=f,D(e.client,l,f)),u,o.deadlineMs):D(e.client,l,u),()=>({openedDocuments:l.length,timeoutMs:c}));let p=t.settleDelayMs??5e3;if(!o)await d("rust.semantic.worker.settle",()=>S(p),()=>({openedDocuments:l.length,settleDelayMs:p}));else{let f;await d("rust.semantic.worker.readiness",async()=>{let m=y=>d("rust.semantic.worker.settle",()=>S(y),()=>({openedDocuments:l.length,settleDelayMs:y})),b=o.initializationGeneration===void 0?await N(e.client,o.statusSnapshot,l.length,o.deadlineMs,p,Date.now,m):await C(e.client,o.initializationGeneration,l.length,o.deadlineMs,p,Date.now,m);o.initializationGeneration!==void 0&&(e.initializationReadiness=null),f=b?.health},()=>({phase:o.initializationGeneration===void 0?"didOpen":"initialize+didOpen",openedDocuments:l.length,health:f}))}return l.length}async function Se(e){let n=e.initializationReadiness;if(!n)return;let i;await d("rust.semantic.worker.readiness",async()=>{i=(await C(e.client,n.afterGeneration,0,n.deadlineMs,0)).health,e.initializationReadiness=null},()=>({phase:"initialize",openedDocuments:0,health:i}))}function Ge(e,n){for(let i of n){let t=se(e,i.uri);if(!(!t||t===".."||t.startsWith("../")||Ie(t)))return t}return null}function Be(e,n){return n.references&&!e.referencesProvider?"rust-analyzer initialized without textDocument/references support.":n.callees&&!e.callHierarchyProvider?"rust-analyzer initialized without call hierarchy support.":n.signatures&&!e.hoverProvider?"rust-analyzer initialized without hover support.":null}function De(e,n){let i=H(e),t=U(e),s=K(e);return{available:!1,reason:n,references:i.map(r=>[r.symbolId,[]]),...e.includeCallees?{callees:t.map(r=>[r.symbolId,[]])}:{},...e.includeSignatures?{signatures:s.map(r=>[r.symbolId,null])}:{}}}async function He(){await _.shutdownAll(e=>e.client.shutdownAndReap())}async function ke(e,n,i){e.deleteIfSame(n),await n.client.shutdownAndReap({deadlineMs:i})}function Ue(e,n,i){if(!e)return;let t=$e(e,n);t.definitions+=1,i.hasReferences&&(t.definitionsWithReferences+=1),t.references+=i.references,t.durationMs+=i.durationMs,t.maxDurationMs=Math.max(t.maxDurationMs,i.durationMs),i.slow&&(t.slowTasks+=1)}function Ke(e){if(!e)return;let n=[...e.entries()].sort(([i,t],[s,r])=>r.durationMs-t.durationMs||i.localeCompare(s));for(let[i,t]of n)M({type:"span",name:"rust.semantic.worker.references.by-file",durationMs:t.durationMs,ok:!0,relativePath:i,definitions:t.definitions,definitionsWithReferences:t.definitionsWithReferences,references:t.references,maxDurationMs:t.maxDurationMs,slowTasks:t.slowTasks,aggregate:"sum-task-duration"})}function $e(e,n){let i=e.get(n);if(i)return i;let t={definitions:0,definitionsWithReferences:0,references:0,durationMs:0,maxDurationMs:0,slowTasks:0};return e.set(n,t),t}function Je(e,n,i){if(!e)return;let t=Ye(e,n);t.definitions+=1,i.hasCallees&&(t.definitionsWithCallees+=1),t.callees+=i.callees,t.durationMs+=i.durationMs,t.maxDurationMs=Math.max(t.maxDurationMs,i.durationMs),i.slow&&(t.slowTasks+=1)}function Ve(e){if(!e)return;let n=[...e.entries()].sort(([i,t],[s,r])=>r.durationMs-t.durationMs||i.localeCompare(s));for(let[i,t]of n)M({type:"span",name:"rust.semantic.worker.callees.by-file",durationMs:t.durationMs,ok:!0,relativePath:i,definitions:t.definitions,definitionsWithCallees:t.definitionsWithCallees,callees:t.callees,maxDurationMs:t.maxDurationMs,slowTasks:t.slowTasks,aggregate:"sum-task-duration"})}function Ye(e,n){let i=e.get(n);if(i)return i;let t={definitions:0,definitionsWithCallees:0,callees:0,durationMs:0,maxDurationMs:0,slowTasks:0};return e.set(n,t),t}function we(e){if(e===void 0||e==="")return null;let n=Number(e);return Number.isInteger(n)&&n>=0?n:null}function Ze(){let e=k.env.SCIP_RUST_SEMANTIC_PARALLEL_OPERATIONS;return e!=="0"&&e!=="false"}function g(e,n,i){ve(e,JSON.stringify(n));let t=new Int32Array(i);Atomics.store(t,0,1),Atomics.notify(t,0)}export{ke as discardRustAnalyzerSession};
2
2
  //# sourceMappingURL=rust-semantic-session-worker.js.map
@@ -1,2 +1,2 @@
1
- import{a as b,b as c,c as d,d as e,e as f,f as g,g as h,h as i,i as j,j as k,k as l,l as m,m as n,n as o,o as p,p as q}from"./chunk-K5MZYZV7.js";import{a}from"./chunk-ILMHV3KM.js";import"./chunk-DHKBIOXF.js";import"./chunk-T6FRID7Y.js";import"./chunk-Q7HB7BFJ.js";import"./chunk-3VLJ2DCA.js";import"./chunk-4DCKBY6T.js";export{q as calleesForDefinition,l as cargoManifestsForDefinitions,i as hoverToRustSignature,h as hoverWithRetry,m as openDefinitionDocuments,p as referencesWithCompletion,o as referencesWithRetry,b as runRustAnalyzerReferenceBatch,a as runWithConcurrency,j as rustAnalyzerInitializationOptions,k as rustAnalyzerSessionRoot,d as rustRequestCalleeDefinitions,c as rustRequestReferenceDefinitions,f as rustRequestSessionDefinitions,e as rustRequestSignatureDefinitions,g as signatureForDefinition,n as waitForOpenedDocuments};
1
+ import{a as b,b as c,c as d,d as e,e as f,f as g,g as h,h as i,i as j,j as k,k as l,l as m,m as n,n as o,o as p,p as q}from"./chunk-HXOU4XNH.js";import{a}from"./chunk-ILMHV3KM.js";import"./chunk-KQHJEU6V.js";import"./chunk-HCVJR2V4.js";import"./chunk-JHH5SCZ3.js";import"./chunk-SB25YMEQ.js";import"./chunk-AK3PYTIK.js";export{q as calleesForDefinition,l as cargoManifestsForDefinitions,i as hoverToRustSignature,h as hoverWithRetry,m as openDefinitionDocuments,p as referencesWithCompletion,o as referencesWithRetry,b as runRustAnalyzerReferenceBatch,a as runWithConcurrency,j as rustAnalyzerInitializationOptions,k as rustAnalyzerSessionRoot,d as rustRequestCalleeDefinitions,c as rustRequestReferenceDefinitions,f as rustRequestSessionDefinitions,e as rustRequestSignatureDefinitions,g as signatureForDefinition,n as waitForOpenedDocuments};
2
2
  //# sourceMappingURL=rust-semantic-worker.js.map
@@ -1,4 +1,4 @@
1
- import { a as SupportedLanguage } from './config-types-Cm-VSEBb.js';
1
+ import { a as SupportedLanguage } from './config-types-B9B60MiR.js';
2
2
 
3
3
  type WatcherStatus = {
4
4
  state: 'idle';
@@ -0,0 +1,2 @@
1
+ import{a,b}from"./chunk-XFMVKFSF.js";import"./chunk-SVHTMVA4.js";import"./chunk-BGBBVSH4.js";import"./chunk-6NC3YSPY.js";import"./chunk-MTDBHTSF.js";import"./chunk-IXESDH3J.js";import"./chunk-OXYAWIEA.js";import"./chunk-FKGQOTKD.js";import"./chunk-FELGD32K.js";import"./chunk-2XCGSDIT.js";import"./chunk-WRQXLNYE.js";import"./chunk-T6QD2ZQB.js";import"./chunk-EELPBR7E.js";import"./chunk-YUKYB54I.js";import"./chunk-BJT7LSPK.js";import"./chunk-WSLEJSFR.js";import"./chunk-VUSKPCUB.js";import"./chunk-F4FNK44D.js";import"./chunk-HCVJR2V4.js";import"./chunk-EETGXQY7.js";import"./chunk-TQZV7KV4.js";import"./chunk-C7IJMOFP.js";import"./chunk-YXPUP5G2.js";import"./chunk-DRENNWRG.js";import"./chunk-BVFYEEBH.js";import"./chunk-JHH5SCZ3.js";import"./chunk-DHEQMPLW.js";import"./chunk-ENWQWA2R.js";import"./chunk-DKM723YF.js";import"./chunk-K3XFWJI2.js";import"./chunk-IW5XQG5G.js";import"./chunk-JT6XX7QY.js";import"./chunk-H5EXS3HM.js";import"./chunk-HGFDYOVB.js";import"./chunk-SB25YMEQ.js";import"./chunk-AK3PYTIK.js";export{a as referenceReachability,b as slice};
2
+ //# sourceMappingURL=slice-YOB5YFAM.js.map
@@ -0,0 +1,2 @@
1
+ import{a,b}from"./chunk-DPWKKNKI.js";import"./chunk-56NQAEPJ.js";import"./chunk-SVHTMVA4.js";import"./chunk-BGBBVSH4.js";import"./chunk-6NC3YSPY.js";import"./chunk-MTDBHTSF.js";import"./chunk-IXESDH3J.js";import"./chunk-OXYAWIEA.js";import"./chunk-FKGQOTKD.js";import"./chunk-FELGD32K.js";import"./chunk-2XCGSDIT.js";import"./chunk-WRQXLNYE.js";import"./chunk-T6QD2ZQB.js";import"./chunk-EELPBR7E.js";import"./chunk-YUKYB54I.js";import"./chunk-BJT7LSPK.js";import"./chunk-WSLEJSFR.js";import"./chunk-VUSKPCUB.js";import"./chunk-F4FNK44D.js";import"./chunk-HCVJR2V4.js";import"./chunk-EETGXQY7.js";import"./chunk-TQZV7KV4.js";import"./chunk-C7IJMOFP.js";import"./chunk-YXPUP5G2.js";import"./chunk-DRENNWRG.js";import"./chunk-BVFYEEBH.js";import"./chunk-JHH5SCZ3.js";import"./chunk-DHEQMPLW.js";import"./chunk-ENWQWA2R.js";import"./chunk-DKM723YF.js";import"./chunk-K3XFWJI2.js";import"./chunk-IW5XQG5G.js";import"./chunk-JT6XX7QY.js";import"./chunk-H5EXS3HM.js";import"./chunk-HGFDYOVB.js";import"./chunk-SB25YMEQ.js";import"./chunk-AK3PYTIK.js";export{b as consumerSurface,a as surface};
2
+ //# sourceMappingURL=surface-VY5EFWTW.js.map
@@ -0,0 +1,2 @@
1
+ import{a}from"./chunk-CLG6DWVS.js";import{a as c}from"./chunk-26CT72HM.js";import{b as i,e as m}from"./chunk-EELPBR7E.js";import"./chunk-C7IJMOFP.js";import"./chunk-YXPUP5G2.js";import{c as l}from"./chunk-DRENNWRG.js";import"./chunk-MXNGIEPU.js";import"./chunk-DKM723YF.js";import"./chunk-K3XFWJI2.js";import"./chunk-IW5XQG5G.js";import"./chunk-H5EXS3HM.js";import"./chunk-HGFDYOVB.js";import"./chunk-AK3PYTIK.js";function g(o,t){let s=i(o,t),e=f(s);for(let n of e)console.log(n)}function R(o,t,s="No results found for resolved symbol."){return i(o,t).match?s:p(t,m(o,t,5))}function S(o,t,s,e){return{...a(o,t),[e]:s}}function p(o,t){let s=`No definition matched '${o}'.`;return t.length>0?`${s} Suggestions: ${t.join(", ")}`:s}function f(o){if(!o.match||o.total<=1)return[];let t=o.match,s=Math.max(0,o.total-1),e=[`Resolved: ${l(t.symbol)} (${t.relativePath}) -- ${s} other definition(s) share this name; qualify as <dir/leaf> to target another.`],n=o.candidates.slice(0,3);return n.length>0&&e.push(`Alternates: ${n.map(r=>`${r.shortName} (${r.relativePath}:${c(r.startLine)})`).join("; ")}`),e.push(""),e}export{p as noMatchMessage,g as symbolResolutionBefore,R as symbolResolutionEmptyMessage,a as symbolResolutionJson,S as withSymbolResolutionJson};
2
+ //# sourceMappingURL=symbol-resolution-DGQN4XIV.js.map
@@ -0,0 +1,2 @@
1
+ import{a,b}from"./chunk-F24QUEQP.js";import"./chunk-56NQAEPJ.js";import"./chunk-T6QD2ZQB.js";import"./chunk-EELPBR7E.js";import"./chunk-C7IJMOFP.js";import"./chunk-YXPUP5G2.js";import"./chunk-DRENNWRG.js";import"./chunk-DKM723YF.js";import"./chunk-K3XFWJI2.js";import"./chunk-IW5XQG5G.js";import"./chunk-H5EXS3HM.js";import"./chunk-HGFDYOVB.js";import"./chunk-AK3PYTIK.js";export{b as moduleMap,a as system};
2
+ //# sourceMappingURL=system-2KQ3QD2P.js.map
@@ -0,0 +1,2 @@
1
+ import{a,b,c}from"./chunk-Q55NF3ZG.js";import"./chunk-5YRQIE2B.js";import"./chunk-RNKPYYYE.js";import"./chunk-IXESDH3J.js";import"./chunk-OXYAWIEA.js";import"./chunk-FKGQOTKD.js";import"./chunk-FELGD32K.js";import"./chunk-2XCGSDIT.js";import"./chunk-WRQXLNYE.js";import"./chunk-T6QD2ZQB.js";import"./chunk-EELPBR7E.js";import"./chunk-BJT7LSPK.js";import"./chunk-WSLEJSFR.js";import"./chunk-VUSKPCUB.js";import"./chunk-F4FNK44D.js";import"./chunk-HCVJR2V4.js";import"./chunk-EETGXQY7.js";import"./chunk-TQZV7KV4.js";import"./chunk-C7IJMOFP.js";import"./chunk-YXPUP5G2.js";import"./chunk-DRENNWRG.js";import"./chunk-BVFYEEBH.js";import"./chunk-JHH5SCZ3.js";import"./chunk-ENWQWA2R.js";import"./chunk-DKM723YF.js";import"./chunk-K3XFWJI2.js";import"./chunk-IW5XQG5G.js";import"./chunk-JT6XX7QY.js";import"./chunk-H5EXS3HM.js";import"./chunk-HGFDYOVB.js";import"./chunk-SB25YMEQ.js";import"./chunk-AK3PYTIK.js";export{c as qualifiedTraceEvidence,a as trace,b as traceEvidence};
2
+ //# sourceMappingURL=trace-HTIPTXAE.js.map
@@ -1,2 +1,2 @@
1
- import{a as m}from"./chunk-CN2WGM7D.js";import"./chunk-BHE44MHT.js";import{a as u}from"./chunk-ZD3Z54IW.js";import{e as d,f as c}from"./chunk-5ZJH6DDE.js";import"./chunk-MEI3PTUK.js";import"./chunk-DHEQMPLW.js";import"./chunk-SEUJVWT2.js";import"./chunk-AUP6YI5M.js";import"./chunk-SF7X6QNW.js";import"./chunk-SDPA5DKN.js";import"./chunk-DOPCR5BY.js";import"./chunk-7IOAZRVL.js";import"./chunk-VWLIOEEF.js";import"./chunk-G6OGPXJW.js";import"./chunk-DRENNWRG.js";import"./chunk-H5EXS3HM.js";import{c as a,d as p}from"./chunk-HGFDYOVB.js";import"./chunk-3VLJ2DCA.js";import"./chunk-4DCKBY6T.js";import{parentPort as s,workerData as f}from"worker_threads";var o=b(f);if(!s)throw new Error("TypeScript mailbox worker requires a parent port.");if(o.kind==="index"){let t=new c({projectRoot:o.projectRoot,currentGeneration:()=>d(o.dbPath),...o.maxActiveSessions===void 0?{}:{maxActiveSessions:o.maxActiveSessions},...o.softMemoryLimitMb===void 0?{}:{softMemoryLimitMb:o.softMemoryLimitMb}});s.on("message",e=>{let r=S(e);y(r,()=>t.handle(r.payload.baseGeneration,r.payload.request),()=>t.status())})}else{let t=new u({openDb:()=>m(o.projectRoot)});s.on("message",e=>{let r=S(e),i=a();p(r.payload.profileEnvironment??{});try{y(r,()=>t.handle(r.payload.generation,r.payload.request),()=>t.status())}finally{p(i)}})}function y(t,e,r){let i;try{if(Date.now()>t.deadlineAtMs)throw new Error("TypeScript mailbox request expired before processing.");let n=e();if(Date.now()>t.deadlineAtMs)throw new Error("TypeScript mailbox request expired while the worker was processing it.");i={kind:"response",requestId:t.requestId,ok:!0,result:n,status:r()}}catch(n){i={kind:"response",requestId:t.requestId,ok:!1,error:n instanceof Error?n.message:String(n),status:r()}}s.postMessage(i)}function b(t){if(!t||typeof t!="object")throw new Error("TypeScript mailbox worker data is missing.");let e=t;if(e.kind==="index"&&typeof e.projectRoot=="string"&&typeof e.dbPath=="string"&&l(e.maxActiveSessions)&&l(e.softMemoryLimitMb))return{kind:"index",projectRoot:e.projectRoot,dbPath:e.dbPath,...e.maxActiveSessions===void 0?{}:{maxActiveSessions:e.maxActiveSessions},...e.softMemoryLimitMb===void 0?{}:{softMemoryLimitMb:e.softMemoryLimitMb}};if(e.kind==="semantic"&&typeof e.projectRoot=="string")return{kind:"semantic",projectRoot:e.projectRoot};throw new Error("TypeScript mailbox worker data is invalid.")}function l(t){return t===void 0||Number.isInteger(t)&&t>0}function S(t){if(!t||typeof t!="object")throw new Error("TypeScript mailbox worker request is missing.");let e=t;if(e.kind!=="request"||typeof e.requestId!="string"||!Number.isSafeInteger(e.deadlineAtMs)||typeof e.payload!="object"||e.payload===null)throw new Error("TypeScript mailbox worker request is invalid.");return e}
1
+ import{b as T}from"./chunk-GRX7JOXQ.js";import{a as M}from"./chunk-CBBHFNLX.js";import{a as P,c as j}from"./chunk-EETGXQY7.js";import"./chunk-C76O5MDS.js";import{c as b,e as v,f as l}from"./chunk-TQZV7KV4.js";import"./chunk-C7IJMOFP.js";import"./chunk-YXPUP5G2.js";import"./chunk-DRENNWRG.js";import{d as g}from"./chunk-7YQOCABQ.js";import"./chunk-QWKHW6VZ.js";import"./chunk-DHEQMPLW.js";import{a as w}from"./chunk-ENWQWA2R.js";import"./chunk-WN3TCGJ4.js";import"./chunk-DKM723YF.js";import{d as f}from"./chunk-K3XFWJI2.js";import"./chunk-NRBNAECH.js";import"./chunk-IW5XQG5G.js";import"./chunk-57N6LN2A.js";import"./chunk-JT6XX7QY.js";import"./chunk-H5EXS3HM.js";import{c as y,d}from"./chunk-HGFDYOVB.js";import{c as m}from"./chunk-SB25YMEQ.js";import{o as h,r as S}from"./chunk-AK3PYTIK.js";import{parentPort as c,workerData as O}from"worker_threads";import{randomUUID as C}from"crypto";import{resolve as R}from"path";var a=class{loadModule;discoverTsconfigs;createProjects;createProvider;db;module=null;projects=null;provider=null;stats={providerRequests:0,sessionsCreated:0,sessionsReused:0,sessionsRefreshed:0,sessionsReplaced:0,projectsCreated:0};constructor(e,t={}){this.db=e,this.loadModule=t.loadModule??b,this.discoverTsconfigs=t.discoverTsconfigs??P,this.createProjects=t.createProjects??v,this.createProvider=t.createProvider??((i,s,o)=>j(i,s,o,{reusedProjects:!0}))}semanticProvider(){return this.stats.providerRequests+=1,this.provider?(this.stats.sessionsReused+=1,this.provider):this.createSession()}advanceGeneration(e,t){let i=q(t);return this.provider?.dispose?.(),this.provider=null,this.db=e,this.projects?i.mode==="replace"?(this.projects=null,this.module=null,this.stats.sessionsReplaced+=1,i):(i.mode==="refresh"&&(D(this.projects,e.config.projectRoot,i),this.stats.sessionsRefreshed+=1),i):i}snapshotStats(){return{...this.stats}}dispose(){this.provider?.dispose?.(),this.provider=null,this.projects=null,this.module=null}createSession(){let e=this.module??this.loadModule();if(!e)return this.provider=l("ts-morph is not installed"),this.provider;if(this.module=e,!this.projects){let t=this.discoverTsconfigs(this.db);if(t.length===0)return this.provider=l("no tsconfig found"),this.provider;this.projects=this.createProjects(e,t),this.stats.projectsCreated+=this.projects.length}return this.provider=this.createProvider(this.db,e,this.projects),this.stats.sessionsCreated+=1,this.provider}};function q(r){let e=new Set;r.projectIdentityChanged&&e.add("project-identity-changed");for(let o of r.uncertainty)e.add(o);for(let o of r.changes)o.inputKind!=="source"&&e.add(`${o.inputKind}-input-changed`);if(e.size>0)return{mode:"replace",addedFiles:[],modifiedFiles:[],deletedFiles:[],reasons:[...e].sort()};let t=u(r.changes,"added"),i=u(r.changes,"modified"),s=u(r.changes,"deleted");return{mode:t.length+i.length+s.length===0?"reuse":"refresh",addedFiles:t,modifiedFiles:i,deletedFiles:s,reasons:[]}}function u(r,e){return r.filter(t=>t.kind===e).map(t=>t.path).sort()}function D(r,e,t){for(let i of r){for(let s of t.deletedFiles)i.project.getSourceFile(R(e,s))?.forget();for(let s of t.modifiedFiles){let o=i.project.getSourceFile(R(e,s));o&&o.refreshFromFileSystemSync()}t.addedFiles.length>0&&i.project.addSourceFilesFromTsConfig(i.tsconfigPath)}}var p=class{openDb;createHost;generationIdentity;readSnapshot;now;db=null;host=null;generation=null;snapshot=null;requests=0;lastRequestAtMs=null;lastError=null;available=null;constructor(e){this.openDb=e.openDb,this.createHost=e.createHost??(t=>new a(t)),this.generationIdentity=e.generationIdentity?t=>e.generationIdentity(t.config.dbPath):t=>t.generation.identity,this.readSnapshot=e.readSnapshot?t=>e.readSnapshot(t.config.dbPath):H,this.now=e.now??Date.now}handle(e,t){try{this.syncGeneration(e);let i=this.host.semanticProvider();switch(this.available=i.availability().available,this.requests+=1,this.lastRequestAtMs=this.now(),this.lastError=null,t.kind){case"availability":return i.availability();case"import-usage":return i.importUsage(t.file);case"references":return[...F(i,t.definitions,{exact:t.exact===!0})];case"reference-fragments":if(!i.referenceFragmentsForFiles)throw new Error("TypeScript provider does not support reference fragments.");return[...i.referenceFragmentsForFiles(t.files)];case"callees":return[...A(i,t.definitions)];case"signature":return i.signatureFor(t.definition);default:return B(t)}}catch(i){throw this.lastError=i instanceof Error?i.message:String(i),i}}status(e){let t=this.host?.snapshotStats();return{protocolVersion:w,state:this.lastError?"error":this.host?this.available?"ready":"unavailable":"idle",requests:this.requests,...this.lastRequestAtMs===null?{}:{lastRequestAt:new Date(this.lastRequestAtMs).toISOString()},...this.lastError?{lastError:this.lastError}:{},sessionsCreated:t?.sessionsCreated??0,sessionsReused:t?.sessionsReused??0,sessionsRefreshed:t?.sessionsRefreshed??0,sessionsReplaced:t?.sessionsReplaced??0,projectsCreated:t?.projectsCreated??0,...e?{mailbox:e}:{}}}closeTypeScriptService(){this.host?.dispose(),this.db?.close(),this.host=null,this.db=null,this.generation=null,this.snapshot=null,this.available=null}syncGeneration(e){if(this.generation===e&&this.host&&this.db)return;let t=this.openDb(),i=this.generationIdentity(t);if(!i||i!==e)throw t.close(),new Error("TypeScript semantic request does not match the currently published index generation.");let s=this.readSnapshot(t);if(!this.host||!this.db)this.db=t,this.host=this.createHost(t);else{let o=this.db;this.host.advanceGeneration(t,N(this.snapshot,s)),this.db=t,o.close()}this.generation=i,this.snapshot=s,this.available=null}};function F(r,e,t){return r.referencesForDefinitions?.(e,t)??new Map(e.map(i=>[i.symbolId,r.referencesFor(i)]))}function A(r,e){return r.calleesForDefinitions?.(e)??new Map(e.map(t=>[t.symbolId,r.calleesFor(t)]))}function H(r){if(!r.generation.metadataRaw)return null;let e=f(r.generation.metadataRaw);return e.kind!=="legacy"&&e.kind!=="supported"||!e.capabilities.usableForEvidenceCache?null:h(e.metadata.fingerprint)}function N(r,e){return e?S(r,e):{version:1,changes:[],projectIdentityChanged:!0,uncertainty:["prior-snapshot-unavailable"]}}function B(r){throw new Error(`Unhandled TypeScript semantic request: ${JSON.stringify(r)}`)}var Z=`typescript-semantic-${process.pid}-${C()}`,x=m(process.pid),ee={pid:process.pid,...x?{processIdentity:x}:{}};var n=L(O);if(!c)throw new Error("TypeScript mailbox worker requires a parent port.");if(n.kind==="index"){let r=new T({projectRoot:n.projectRoot,currentGeneration:()=>g(n.dbPath),...n.maxActiveSessions===void 0?{}:{maxActiveSessions:n.maxActiveSessions},...n.softMemoryLimitMb===void 0?{}:{softMemoryLimitMb:n.softMemoryLimitMb}});c.on("message",e=>{let t=k(e);I(t,()=>r.handle(t.payload.baseGeneration,t.payload.request),()=>r.status())})}else{let r=new p({openDb:()=>M(n.projectRoot)});c.on("message",e=>{let t=k(e),i=y();d(t.payload.profileEnvironment??{});try{I(t,()=>r.handle(t.payload.generation,t.payload.request),()=>r.status())}finally{d(i)}})}function I(r,e,t){let i;try{if(Date.now()>r.deadlineAtMs)throw new Error("TypeScript mailbox request expired before processing.");let s=e();if(Date.now()>r.deadlineAtMs)throw new Error("TypeScript mailbox request expired while the worker was processing it.");i={kind:"response",requestId:r.requestId,ok:!0,result:s,status:t()}}catch(s){i={kind:"response",requestId:r.requestId,ok:!1,error:s instanceof Error?s.message:String(s),status:t()}}c.postMessage(i)}function L(r){if(!r||typeof r!="object")throw new Error("TypeScript mailbox worker data is missing.");let e=r;if(e.kind==="index"&&typeof e.projectRoot=="string"&&typeof e.dbPath=="string"&&E(e.maxActiveSessions)&&E(e.softMemoryLimitMb))return{kind:"index",projectRoot:e.projectRoot,dbPath:e.dbPath,...e.maxActiveSessions===void 0?{}:{maxActiveSessions:e.maxActiveSessions},...e.softMemoryLimitMb===void 0?{}:{softMemoryLimitMb:e.softMemoryLimitMb}};if(e.kind==="semantic"&&typeof e.projectRoot=="string")return{kind:"semantic",projectRoot:e.projectRoot};throw new Error("TypeScript mailbox worker data is invalid.")}function E(r){return r===void 0||Number.isInteger(r)&&r>0}function k(r){if(!r||typeof r!="object")throw new Error("TypeScript mailbox worker request is missing.");let e=r;if(e.kind!=="request"||typeof e.requestId!="string"||!Number.isSafeInteger(e.deadlineAtMs)||typeof e.payload!="object"||e.payload===null)throw new Error("TypeScript mailbox worker request is invalid.");return e}
2
2
  //# sourceMappingURL=typescript-mailbox-worker.js.map
@@ -0,0 +1,2 @@
1
+ import{a}from"./chunk-GPGRZJ3R.js";import"./chunk-D2MVJSP4.js";import"./chunk-3TNRNKAT.js";import"./chunk-7KCZELVM.js";import"./chunk-XN22RGSR.js";import"./chunk-RNKPYYYE.js";import"./chunk-SVHTMVA4.js";import"./chunk-BGBBVSH4.js";import"./chunk-6NC3YSPY.js";import"./chunk-MTDBHTSF.js";import"./chunk-IXESDH3J.js";import"./chunk-OXYAWIEA.js";import"./chunk-BYDAFMSR.js";import"./chunk-RYOYJMGF.js";import"./chunk-FKGQOTKD.js";import"./chunk-FELGD32K.js";import"./chunk-2XCGSDIT.js";import"./chunk-WRQXLNYE.js";import"./chunk-T6QD2ZQB.js";import"./chunk-EELPBR7E.js";import"./chunk-YUKYB54I.js";import"./chunk-BJT7LSPK.js";import"./chunk-WSLEJSFR.js";import"./chunk-VUSKPCUB.js";import"./chunk-F4FNK44D.js";import"./chunk-HCVJR2V4.js";import"./chunk-EETGXQY7.js";import"./chunk-TQZV7KV4.js";import"./chunk-C7IJMOFP.js";import"./chunk-YXPUP5G2.js";import"./chunk-DRENNWRG.js";import"./chunk-BVFYEEBH.js";import"./chunk-JHH5SCZ3.js";import"./chunk-DHEQMPLW.js";import"./chunk-ENWQWA2R.js";import"./chunk-DKM723YF.js";import"./chunk-K3XFWJI2.js";import"./chunk-IW5XQG5G.js";import"./chunk-JT6XX7QY.js";import"./chunk-H5EXS3HM.js";import"./chunk-HGFDYOVB.js";import"./chunk-SB25YMEQ.js";import"./chunk-AK3PYTIK.js";export{a as valueFlow};
2
+ //# sourceMappingURL=value-flow-5FV3VQI7.js.map