scip-query 0.22.0 → 0.23.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 (386) hide show
  1. package/CHANGELOG.md +257 -0
  2. package/README.md +11 -0
  3. package/dist/augment-vue-worker.js +1 -1
  4. package/dist/by-kind-XI2CSWEY.js +2 -0
  5. package/dist/call-graph-UONR6JR5.js +2 -0
  6. package/dist/{chunk-FGNCOQUX.js → chunk-2E7CX53V.js} +2 -2
  7. package/dist/chunk-2GRUZAQF.js +43 -0
  8. package/dist/{chunk-DPWKKNKI.js → chunk-2LDBDR6J.js} +2 -2
  9. package/dist/{chunk-JHH5SCZ3.js → chunk-2OOY75BW.js} +2 -2
  10. package/dist/{chunk-XGGBK66W.js → chunk-2R3V3PSD.js} +2 -2
  11. package/dist/chunk-2WC2OEDO.js +4 -0
  12. package/dist/{chunk-57N6LN2A.js → chunk-3AF4TUFK.js} +2 -2
  13. package/dist/{chunk-2RE5OCHZ.js → chunk-3D3QG236.js} +2 -2
  14. package/dist/{chunk-D2MVJSP4.js → chunk-3FHOF22C.js} +2 -2
  15. package/dist/{chunk-7XZGZBSQ.js → chunk-3JKSW6LJ.js} +2 -2
  16. package/dist/chunk-3L2ZBPEX.js +133 -0
  17. package/dist/{chunk-NVSZNESQ.js → chunk-3PJABJSU.js} +2 -2
  18. package/dist/{chunk-WOOAY3PA.js → chunk-3SVF22I5.js} +2 -2
  19. package/dist/{chunk-YAGYMBEX.js → chunk-3WR4E3A3.js} +2 -2
  20. package/dist/chunk-4FTZ4P5G.js +2 -0
  21. package/dist/{chunk-F24G5NBE.js → chunk-4ILJCCXV.js} +2 -2
  22. package/dist/chunk-4UX2F3JX.js +2 -0
  23. package/dist/chunk-4WNW27SX.js +2 -0
  24. package/dist/chunk-5ENOG4VP.js +61 -0
  25. package/dist/{chunk-RHHCLWQ6.js → chunk-64BFSI5I.js} +2 -2
  26. package/dist/chunk-66DVSJQG.js +455 -0
  27. package/dist/{chunk-ISWFRGJ6.js → chunk-6HFCYNYE.js} +2 -2
  28. package/dist/{chunk-Y2VM4CJC.js → chunk-6I6L7Z62.js} +2 -2
  29. package/dist/{chunk-CKRWA452.js → chunk-6PQNKL3G.js} +2 -2
  30. package/dist/{chunk-GPGRZJ3R.js → chunk-6V5CNXL6.js} +2 -2
  31. package/dist/chunk-6VVV4WRR.js +4 -0
  32. package/dist/{chunk-BDGTPN27.js → chunk-7BWFZPPZ.js} +2 -2
  33. package/dist/{chunk-25GWKRUZ.js → chunk-7CYG22FH.js} +2 -2
  34. package/dist/chunk-7F45LJKI.js +2 -0
  35. package/dist/{chunk-4TQU4TX2.js → chunk-7IWV2EG3.js} +2 -2
  36. package/dist/{chunk-UDY7MIAW.js → chunk-AFHTBORT.js} +2 -2
  37. package/dist/chunk-AVRYW5OZ.js +2 -0
  38. package/dist/chunk-B3PYOSCX.js +2 -0
  39. package/dist/{chunk-RNKPYYYE.js → chunk-B5D7QPBE.js} +2 -2
  40. package/dist/{chunk-FFJQZG6J.js → chunk-BBCIS4DX.js} +2 -2
  41. package/dist/chunk-BDUVI7TO.js +3 -0
  42. package/dist/{chunk-BVFYEEBH.js → chunk-BE7ZZTMC.js} +2 -2
  43. package/dist/{chunk-NEIQPFBI.js → chunk-BHVUJOCQ.js} +2 -2
  44. package/dist/chunk-BKVWUP7Y.js +2 -0
  45. package/dist/{chunk-IJMD6BRI.js → chunk-BQGB4HBD.js} +2 -2
  46. package/dist/{chunk-ERCYGVAM.js → chunk-BRV7PIFF.js} +2 -2
  47. package/dist/chunk-CEEZJXEF.js +2 -0
  48. package/dist/{chunk-BTVKZGWT.js → chunk-CIYLO6SI.js} +2 -2
  49. package/dist/chunk-CJZXN4NU.js +2 -0
  50. package/dist/{chunk-VXJJTQYE.js → chunk-CNO7TOKL.js} +2 -2
  51. package/dist/{chunk-ZZ3Z7D56.js → chunk-COF23M5F.js} +2 -2
  52. package/dist/{chunk-ZGW4HLPD.js → chunk-CWFP7GM5.js} +2 -2
  53. package/dist/chunk-D2DHWI3D.js +2 -0
  54. package/dist/{chunk-Q55NF3ZG.js → chunk-D4N5SQ2M.js} +2 -2
  55. package/dist/{chunk-LXQUF2RP.js → chunk-DBRSYFXR.js} +2 -2
  56. package/dist/{chunk-PXXYQK55.js → chunk-DHUIOLDT.js} +2 -2
  57. package/dist/{chunk-KZYID5KV.js → chunk-DIRJWYBM.js} +2 -2
  58. package/dist/{chunk-IKVNEGTW.js → chunk-DIUFNHRJ.js} +2 -2
  59. package/dist/{chunk-CLG6DWVS.js → chunk-DTZCKZEU.js} +2 -2
  60. package/dist/{chunk-Z2PZVKPR.js → chunk-DULC3QFP.js} +2 -2
  61. package/dist/{chunk-AYPDH2LU.js → chunk-DYGHBZ2N.js} +2 -2
  62. package/dist/{chunk-JJ62MTQH.js → chunk-E5R6AQ73.js} +2 -2
  63. package/dist/{chunk-BWVQP3LB.js → chunk-E73UNJTF.js} +2 -2
  64. package/dist/{chunk-GVOMSPGL.js → chunk-EG2CPZMJ.js} +2 -2
  65. package/dist/{chunk-56NQAEPJ.js → chunk-EKV5HX33.js} +2 -2
  66. package/dist/{chunk-GDRJB3SB.js → chunk-EQHFIL6T.js} +2 -2
  67. package/dist/{chunk-EWWY2ZFL.js → chunk-ESIQ66Z7.js} +2 -2
  68. package/dist/chunk-EVFUMY4R.js +3 -0
  69. package/dist/{chunk-ZYM4HOFA.js → chunk-F7DY272B.js} +2 -2
  70. package/dist/chunk-FBN2FGXG.js +2 -0
  71. package/dist/{chunk-AZS7YPCB.js → chunk-FDLOBR6P.js} +2 -2
  72. package/dist/chunk-FESCRNVV.js +5 -0
  73. package/dist/{chunk-URSGGIZX.js → chunk-FFRKR4EQ.js} +2 -2
  74. package/dist/chunk-FGA2U4OR.js +8 -0
  75. package/dist/{chunk-7YQOCABQ.js → chunk-FIQRSHVM.js} +2 -2
  76. package/dist/{chunk-KFVSJX25.js → chunk-FPYLNQPT.js} +2 -2
  77. package/dist/{chunk-FELGD32K.js → chunk-FRUSVINH.js} +2 -2
  78. package/dist/chunk-GAS2LJMP.js +3 -0
  79. package/dist/{chunk-OTSPRVNW.js → chunk-GSP44ENC.js} +2 -2
  80. package/dist/{chunk-K3XFWJI2.js → chunk-GUFSG5TX.js} +2 -2
  81. package/dist/chunk-GYIZ4NXB.js +2 -0
  82. package/dist/{chunk-2OXVP5U5.js → chunk-GZIUDL6G.js} +2 -2
  83. package/dist/chunk-HCXEQRFF.js +18 -0
  84. package/dist/{chunk-LO5JSW2C.js → chunk-HEHOQQKH.js} +2 -2
  85. package/dist/{chunk-U2N2KE7A.js → chunk-HKGFPJ4T.js} +2 -2
  86. package/dist/chunk-HLZTEXRA.js +2 -0
  87. package/dist/{chunk-EELPBR7E.js → chunk-HOENASQM.js} +2 -2
  88. package/dist/{chunk-VTCIYFEK.js → chunk-HVF5VBG6.js} +2 -2
  89. package/dist/{chunk-TH6IC56G.js → chunk-HYO3NP5Q.js} +2 -2
  90. package/dist/{chunk-OPSAW5DT.js → chunk-I55I7XXP.js} +2 -2
  91. package/dist/{chunk-DEAB5TGT.js → chunk-IDFEUFKS.js} +2 -2
  92. package/dist/{chunk-DJAO2OZJ.js → chunk-IHGQTTVW.js} +2 -2
  93. package/dist/{chunk-XU75YQN4.js → chunk-IICPE7B2.js} +2 -2
  94. package/dist/{chunk-GY7CCCEZ.js → chunk-IL676XCC.js} +2 -2
  95. package/dist/{chunk-4HE7MVWD.js → chunk-ILTDAWEF.js} +2 -2
  96. package/dist/chunk-IZDPJ2QI.js +2 -0
  97. package/dist/{chunk-5YRQIE2B.js → chunk-J66VOFW6.js} +2 -2
  98. package/dist/{chunk-SB25YMEQ.js → chunk-JFMEXGFE.js} +2 -2
  99. package/dist/{chunk-QLBSG7U5.js → chunk-JGKUET5J.js} +2 -2
  100. package/dist/{chunk-VZ7NXSHV.js → chunk-JS4PGXMV.js} +2 -2
  101. package/dist/{chunk-ZAZGGSM3.js → chunk-JTQVMR42.js} +2 -2
  102. package/dist/chunk-JWTGMPIT.js +80 -0
  103. package/dist/{chunk-5ZMBRQFC.js → chunk-JYR66JN5.js} +2 -2
  104. package/dist/chunk-KLFEXGQA.js +2 -0
  105. package/dist/chunk-KYSDI3GE.js +5 -0
  106. package/dist/{chunk-MSR2QRUE.js → chunk-L6PJPETJ.js} +2 -2
  107. package/dist/{chunk-VU6LIWHT.js → chunk-LDVT66YM.js} +2 -2
  108. package/dist/chunk-LEECKFCJ.js +2 -0
  109. package/dist/{chunk-H7CG6LOE.js → chunk-LMZ5PRUV.js} +2 -2
  110. package/dist/{chunk-ZPASRBLF.js → chunk-LQRQN2XA.js} +2 -2
  111. package/dist/{chunk-HISEUIL2.js → chunk-LXABEJX3.js} +2 -2
  112. package/dist/{chunk-WHADK6OS.js → chunk-M2O5NY6W.js} +2 -2
  113. package/dist/{chunk-Y334QQU5.js → chunk-MNV5FSBW.js} +2 -2
  114. package/dist/{chunk-RYOYJMGF.js → chunk-MPQ4OTBM.js} +2 -2
  115. package/dist/{chunk-6NC3YSPY.js → chunk-MV3CDXPI.js} +2 -2
  116. package/dist/{chunk-NRBNAECH.js → chunk-MWN53KRN.js} +2 -2
  117. package/dist/chunk-N2ZSIIGR.js +117 -0
  118. package/dist/chunk-N5B2NILC.js +5 -0
  119. package/dist/{chunk-Q6T2CAJL.js → chunk-NJITK2GP.js} +2 -2
  120. package/dist/{chunk-ENWQWA2R.js → chunk-NOGJXYFO.js} +2 -2
  121. package/dist/{chunk-V4NG5OMS.js → chunk-NOYBFVJA.js} +106 -106
  122. package/dist/chunk-NWQXSFFU.js +3 -0
  123. package/dist/chunk-ODDUPDP7.js +13 -0
  124. package/dist/{chunk-A77SCPW2.js → chunk-OLIWTZI3.js} +2 -2
  125. package/dist/{chunk-XFMVKFSF.js → chunk-OLNV6I6U.js} +2 -2
  126. package/dist/{chunk-QKT4UI2Y.js → chunk-OR2E3AGZ.js} +2 -2
  127. package/dist/chunk-OSR2GEHQ.js +2 -0
  128. package/dist/{chunk-5H5WTJSD.js → chunk-OSSESPDX.js} +2 -2
  129. package/dist/{chunk-KQHJEU6V.js → chunk-OWOOWNJ5.js} +2 -2
  130. package/dist/{chunk-GRX7JOXQ.js → chunk-P42EIXTA.js} +2 -2
  131. package/dist/{chunk-AQ2PORIO.js → chunk-PJFGPYTU.js} +2 -2
  132. package/dist/{chunk-LRI5OMPE.js → chunk-PP7KNN7L.js} +2 -2
  133. package/dist/{chunk-PLJUQFQN.js → chunk-PU7T5QYQ.js} +2 -2
  134. package/dist/{chunk-JUN5DOAK.js → chunk-PWWAJSKV.js} +2 -2
  135. package/dist/{chunk-7IQXARSQ.js → chunk-PZL5T7SU.js} +2 -2
  136. package/dist/{chunk-UAQ4T73O.js → chunk-QBE3YX64.js} +2 -2
  137. package/dist/{chunk-3TJY6M3B.js → chunk-QGVTFRY2.js} +2 -2
  138. package/dist/chunk-QOJONDS7.js +2 -0
  139. package/dist/chunk-QU5XRYB5.js +4 -0
  140. package/dist/{chunk-2KVU55CW.js → chunk-QUU5OBVK.js} +2 -2
  141. package/dist/{chunk-Q5TA4OY4.js → chunk-RBLQNW26.js} +2 -2
  142. package/dist/chunk-RTQ7NEKG.js +81 -0
  143. package/dist/{chunk-F24QUEQP.js → chunk-SQXRS7BG.js} +2 -2
  144. package/dist/chunk-SSK6LDPC.js +2 -0
  145. package/dist/chunk-SZHGTCPP.js +7 -0
  146. package/dist/chunk-T4N4P2K5.js +16 -0
  147. package/dist/chunk-TA3QKLLU.js +2 -0
  148. package/dist/chunk-TEBQMNVI.js +43 -0
  149. package/dist/{chunk-NK3JMP22.js → chunk-TPFHAQ2G.js} +2 -2
  150. package/dist/chunk-TQPCBMWT.js +5 -0
  151. package/dist/{chunk-HG722PO7.js → chunk-TRNAEQ6P.js} +2 -2
  152. package/dist/chunk-TY7CRN3Z.js +2 -0
  153. package/dist/{chunk-7XA3OM44.js → chunk-UHFYCMZO.js} +2 -2
  154. package/dist/{chunk-ARVO6TTW.js → chunk-UICY4GTQ.js} +2 -2
  155. package/dist/{chunk-SWK4XPUS.js → chunk-UVGEWT4Y.js} +2 -2
  156. package/dist/{chunk-GIQ6CSL4.js → chunk-UXW33INU.js} +2 -2
  157. package/dist/{chunk-RDULNRSJ.js → chunk-VMPRET3I.js} +2 -2
  158. package/dist/{chunk-I6UTXNHU.js → chunk-VNLGKHS6.js} +2 -2
  159. package/dist/{chunk-44T4DUAA.js → chunk-VQILFTEH.js} +2 -2
  160. package/dist/{chunk-N7FP5H5U.js → chunk-VUPHCS7Y.js} +8 -8
  161. package/dist/{chunk-JAT6C3VX.js → chunk-VVZSBTSU.js} +2 -2
  162. package/dist/{chunk-FBCVASUG.js → chunk-VZRNID6A.js} +2 -2
  163. package/dist/{chunk-TUQIPUDS.js → chunk-W5OXRYGE.js} +2 -2
  164. package/dist/chunk-W6STWDQI.js +57 -0
  165. package/dist/chunk-W7CXK74K.js +2 -0
  166. package/dist/chunk-WB3WYIRE.js +4 -0
  167. package/dist/{chunk-C76O5MDS.js → chunk-WDNVY4E7.js} +2 -2
  168. package/dist/{chunk-TAYD3AE7.js → chunk-WIWY3CRX.js} +2 -2
  169. package/dist/chunk-WK46TNUM.js +3 -0
  170. package/dist/chunk-WNTFFKAX.js +12 -0
  171. package/dist/{chunk-JFQBRL3J.js → chunk-WOIKCX6A.js} +2 -2
  172. package/dist/{chunk-PIFTZEEM.js → chunk-WUN6KBHV.js} +2 -2
  173. package/dist/chunk-WYCTJDVR.js +2 -0
  174. package/dist/chunk-WYPL7GF7.js +2 -0
  175. package/dist/{chunk-XN22RGSR.js → chunk-XBGWL66K.js} +2 -2
  176. package/dist/{chunk-R6M456QG.js → chunk-XDQMU3BT.js} +2 -2
  177. package/dist/{chunk-XJX6LGHL.js → chunk-XFA4SSO3.js} +2 -2
  178. package/dist/{chunk-2YC7YNKT.js → chunk-XGZEP6GR.js} +2 -2
  179. package/dist/chunk-XPDPNWTQ.js +368 -0
  180. package/dist/chunk-XRYABF57.js +8 -0
  181. package/dist/{chunk-YIHNPKWD.js → chunk-YBGKCQIS.js} +2 -2
  182. package/dist/{chunk-2XCGSDIT.js → chunk-YEN6CYC7.js} +2 -2
  183. package/dist/{chunk-VMWUV6WB.js → chunk-YF5IB2LF.js} +2 -2
  184. package/dist/{chunk-TNG2FYS5.js → chunk-YI2AWIHC.js} +2 -2
  185. package/dist/{chunk-EELG7D3Q.js → chunk-YPWBKGFU.js} +2 -2
  186. package/dist/{chunk-GQIDEID3.js → chunk-YPWHBBIS.js} +2 -2
  187. package/dist/{chunk-TKDNDQA7.js → chunk-YSH6U3L4.js} +2 -2
  188. package/dist/{chunk-BUTEIZKP.js → chunk-YU5DZUZI.js} +2 -2
  189. package/dist/chunk-YWO5DDRC.js +16 -0
  190. package/dist/{chunk-6HRZQLOI.js → chunk-Z4CDXYNQ.js} +2 -2
  191. package/dist/{chunk-XSWYJCAK.js → chunk-ZF5KHH7C.js} +2 -2
  192. package/dist/chunk-ZOHS7AQV.js +21 -0
  193. package/dist/{chunk-7U2YQSDE.js → chunk-ZTI4SBFV.js} +2 -2
  194. package/dist/cli-main.js +2 -2
  195. package/dist/code-MI6F2TTU.js +2 -0
  196. package/dist/code-result-json-FXALY4HE.js +2 -0
  197. package/dist/{command-descriptors-ORNTVNYV.js → command-descriptors-P34VABY5.js} +136 -135
  198. package/dist/dataflow-4KEMJPC6.js +2 -0
  199. package/dist/dependence-slice-R7FPWD5M.js +2 -0
  200. package/dist/deps-7EMQUYUT.js +2 -0
  201. package/dist/direct-navigation-6YO234F2.js +3 -0
  202. package/dist/entry-map-KOOLR26E.js +2 -0
  203. package/dist/files-OPIPJIGZ.js +2 -0
  204. package/dist/hierarchy-QPD2CAER.js +2 -0
  205. package/dist/imports-M6HUXRXC.js +2 -0
  206. package/dist/index.js +1 -1
  207. package/dist/members-I5MEFOCT.js +2 -0
  208. package/dist/methods-5JYGGHXA.js +2 -0
  209. package/dist/output-continuation-command-UPQAAKBP.js +3 -0
  210. package/dist/postinstall.js +1 -1
  211. package/dist/project-reindex-UKKQ5PLS.js +3 -0
  212. package/dist/queries/affected.js +1 -1
  213. package/dist/queries/anchors.js +1 -1
  214. package/dist/queries/architecture.js +1 -1
  215. package/dist/queries/bottlenecks.js +1 -1
  216. package/dist/queries/by-kind.js +1 -1
  217. package/dist/queries/call-graph.js +1 -1
  218. package/dist/queries/change-surface.js +1 -1
  219. package/dist/queries/cleanup-plan.js +1 -1
  220. package/dist/queries/co-change.js +1 -1
  221. package/dist/queries/code.js +1 -1
  222. package/dist/queries/complexity-hotspots.js +1 -1
  223. package/dist/queries/complexity.js +1 -1
  224. package/dist/queries/context.js +1 -1
  225. package/dist/queries/convergence.js +1 -1
  226. package/dist/queries/coupling.js +1 -1
  227. package/dist/queries/cycles.js +1 -1
  228. package/dist/queries/dataflow.js +1 -1
  229. package/dist/queries/dead.js +1 -1
  230. package/dist/queries/decorative-checkers.js +1 -1
  231. package/dist/queries/deep-chains.js +1 -1
  232. package/dist/queries/dependence-slice.js +1 -1
  233. package/dist/queries/dependency-depth.js +1 -1
  234. package/dist/queries/deps.js +1 -1
  235. package/dist/queries/diff-impact.d.ts +9 -0
  236. package/dist/queries/diff-impact.js +1 -1
  237. package/dist/queries/doc-drift.js +1 -1
  238. package/dist/queries/drift.js +1 -1
  239. package/dist/queries/duplicate-bodies.js +1 -1
  240. package/dist/queries/entry-map.js +1 -1
  241. package/dist/queries/evidence.js +1 -1
  242. package/dist/queries/extract-candidates.js +1 -1
  243. package/dist/queries/fan.js +1 -1
  244. package/dist/queries/files.js +1 -1
  245. package/dist/queries/health.js +1 -1
  246. package/dist/queries/hierarchy.js +1 -1
  247. package/dist/queries/hotspots.js +1 -1
  248. package/dist/queries/imports.js +1 -1
  249. package/dist/queries/incomplete-migration.js +1 -1
  250. package/dist/queries/index.js +1 -1
  251. package/dist/queries/isolated.js +1 -1
  252. package/dist/queries/locality-candidates.js +1 -1
  253. package/dist/queries/members.js +1 -1
  254. package/dist/queries/methods.js +1 -1
  255. package/dist/queries/not-implemented.js +1 -1
  256. package/dist/queries/outline.js +1 -1
  257. package/dist/queries/passthrough-candidates.js +1 -1
  258. package/dist/queries/plan-context.js +1 -1
  259. package/dist/queries/react-component-duplicates.js +1 -1
  260. package/dist/queries/react-hook-candidates.js +1 -1
  261. package/dist/queries/react-large-component-pressure.js +1 -1
  262. package/dist/queries/recent-duplicates.js +1 -1
  263. package/dist/queries/redundant-reexports.js +1 -1
  264. package/dist/queries/reference-neighborhood.js +1 -1
  265. package/dist/queries/reference-reachability.js +1 -1
  266. package/dist/queries/refs.js +1 -1
  267. package/dist/queries/self-audit.js +1 -1
  268. package/dist/queries/similar-chains.js +1 -1
  269. package/dist/queries/similar-files.js +1 -1
  270. package/dist/queries/similar-signatures.js +1 -1
  271. package/dist/queries/similar.js +1 -1
  272. package/dist/queries/slice.js +1 -1
  273. package/dist/queries/source-inspection.js +1 -1
  274. package/dist/queries/source-search.js +1 -1
  275. package/dist/queries/stale-abstractions.js +1 -1
  276. package/dist/queries/surface.js +1 -1
  277. package/dist/queries/symbols.js +1 -1
  278. package/dist/queries/system-map.js +1 -1
  279. package/dist/queries/system.js +1 -1
  280. package/dist/queries/test-quality.js +1 -1
  281. package/dist/queries/trace.js +1 -1
  282. package/dist/queries/twin-ab.js +1 -1
  283. package/dist/queries/twin-drift.js +1 -1
  284. package/dist/queries/unused-imports.js +1 -1
  285. package/dist/queries/unused-params.js +1 -1
  286. package/dist/queries/value-flow.js +1 -1
  287. package/dist/queries/vue-component-duplicates.js +1 -1
  288. package/dist/queries/vue-composable-candidates.js +1 -1
  289. package/dist/queries/vue-large-view-pressure.js +1 -1
  290. package/dist/queries/wrapper-candidates.js +1 -1
  291. package/dist/query-service-server.js +3 -3
  292. package/dist/refs-PSU4JZZW.js +2 -0
  293. package/dist/refs-pagination-JG6CJMRC.js +2 -0
  294. package/dist/reindex-worker.js +25 -25
  295. package/dist/reindex.d.ts +3 -2
  296. package/dist/reindex.js +35 -35
  297. package/dist/runtime.d.ts +34 -2
  298. package/dist/runtime.js +4 -4
  299. package/dist/rust-semantic-session-server.js +1 -1
  300. package/dist/rust-semantic-session-worker.js +1 -1
  301. package/dist/rust-semantic-worker.js +1 -1
  302. package/dist/{scip-cli-H-n59izO.d.ts → scip-cli-DOerTq-R.d.ts} +42 -4
  303. package/dist/slice-HYRATV64.js +2 -0
  304. package/dist/surface-VTGDYWF5.js +2 -0
  305. package/dist/symbol-resolution-WD5EU5JE.js +2 -0
  306. package/dist/system-LRQNFOR2.js +2 -0
  307. package/dist/trace-F4B6OLL4.js +2 -0
  308. package/dist/typescript-mailbox-worker.js +1 -1
  309. package/dist/value-flow-VRPZY72V.js +2 -0
  310. package/dist/watch-server.js +3 -3
  311. package/package.json +1 -1
  312. package/dist/by-kind-4IYG2SKW.js +0 -2
  313. package/dist/call-graph-WQNXMNNN.js +0 -2
  314. package/dist/chunk-2BTJALUS.js +0 -454
  315. package/dist/chunk-3QXC54FQ.js +0 -3
  316. package/dist/chunk-42W3LFUK.js +0 -13
  317. package/dist/chunk-4GAQ6FI4.js +0 -43
  318. package/dist/chunk-6VEFRPTD.js +0 -5
  319. package/dist/chunk-7C26EKLZ.js +0 -4
  320. package/dist/chunk-7JYHQAH2.js +0 -22
  321. package/dist/chunk-7KSO2OAP.js +0 -2
  322. package/dist/chunk-AK3PYTIK.js +0 -5
  323. package/dist/chunk-AMIMMNA4.js +0 -11
  324. package/dist/chunk-AUY5BL74.js +0 -2
  325. package/dist/chunk-BDHFVH2M.js +0 -18
  326. package/dist/chunk-BECZLYNU.js +0 -8
  327. package/dist/chunk-BYDAFMSR.js +0 -57
  328. package/dist/chunk-BZYSGZRK.js +0 -2
  329. package/dist/chunk-C7IJMOFP.js +0 -134
  330. package/dist/chunk-CBBHFNLX.js +0 -2
  331. package/dist/chunk-D35XIZGN.js +0 -2
  332. package/dist/chunk-DKM723YF.js +0 -79
  333. package/dist/chunk-E44IVWIJ.js +0 -367
  334. package/dist/chunk-EDMB6SSO.js +0 -7
  335. package/dist/chunk-EETGXQY7.js +0 -3
  336. package/dist/chunk-FKGQOTKD.js +0 -2
  337. package/dist/chunk-GH5YSGZL.js +0 -5
  338. package/dist/chunk-HCVJR2V4.js +0 -3
  339. package/dist/chunk-HXOU4XNH.js +0 -3
  340. package/dist/chunk-IMKZEXZG.js +0 -2
  341. package/dist/chunk-ISIQLPJ2.js +0 -61
  342. package/dist/chunk-IXESDH3J.js +0 -2
  343. package/dist/chunk-JT6XX7QY.js +0 -8
  344. package/dist/chunk-MHIEP7EG.js +0 -4
  345. package/dist/chunk-OJNK5ALA.js +0 -2
  346. package/dist/chunk-OXYAWIEA.js +0 -2
  347. package/dist/chunk-OZETODHH.js +0 -2
  348. package/dist/chunk-PBUH2P5S.js +0 -3
  349. package/dist/chunk-PLYUVM4F.js +0 -2
  350. package/dist/chunk-Q7GBK5T7.js +0 -81
  351. package/dist/chunk-QWKHW6VZ.js +0 -2
  352. package/dist/chunk-RPL3ARU7.js +0 -16
  353. package/dist/chunk-SVHTMVA4.js +0 -4
  354. package/dist/chunk-T6QD2ZQB.js +0 -43
  355. package/dist/chunk-TD7VKJ2Y.js +0 -117
  356. package/dist/chunk-TUSPIVZ3.js +0 -4
  357. package/dist/chunk-UT7TADJX.js +0 -2
  358. package/dist/chunk-VUSKPCUB.js +0 -2
  359. package/dist/chunk-WN3TCGJ4.js +0 -2
  360. package/dist/chunk-WSLEJSFR.js +0 -2
  361. package/dist/chunk-WYZIHUPZ.js +0 -16
  362. package/dist/chunk-XE33FV5W.js +0 -2
  363. package/dist/chunk-Z2AWCTN6.js +0 -2
  364. package/dist/chunk-ZOXKSQQB.js +0 -2
  365. package/dist/code-EQJFDT6I.js +0 -2
  366. package/dist/code-result-json-7UWIWBOO.js +0 -2
  367. package/dist/dataflow-6VL54GX5.js +0 -2
  368. package/dist/dependence-slice-DT2NUHD2.js +0 -2
  369. package/dist/deps-DB7H5IKC.js +0 -2
  370. package/dist/direct-navigation-O3LUAYWQ.js +0 -3
  371. package/dist/entry-map-6K62RV3D.js +0 -2
  372. package/dist/files-MSLD7MO6.js +0 -2
  373. package/dist/hierarchy-IVBXAKFA.js +0 -2
  374. package/dist/imports-FRAVZ3Y2.js +0 -2
  375. package/dist/members-KJOJDYGO.js +0 -2
  376. package/dist/methods-2AYABBT3.js +0 -2
  377. package/dist/output-continuation-command-JHMPH6NC.js +0 -3
  378. package/dist/project-reindex-HYO4WD7Z.js +0 -3
  379. package/dist/refs-ARMA6XUJ.js +0 -2
  380. package/dist/refs-pagination-VUGIWN6U.js +0 -2
  381. package/dist/slice-YOB5YFAM.js +0 -2
  382. package/dist/surface-VY5EFWTW.js +0 -2
  383. package/dist/symbol-resolution-DGQN4XIV.js +0 -2
  384. package/dist/system-2KQ3QD2P.js +0 -2
  385. package/dist/trace-HTIPTXAE.js +0 -2
  386. package/dist/value-flow-5FV3VQI7.js +0 -2
package/dist/runtime.d.ts CHANGED
@@ -1,8 +1,9 @@
1
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
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-H-n59izO.js';
5
- export { g as getScipVersion, i as isScipInstalled, p as printScipInstallInstructions } from './scip-cli-H-n59izO.js';
4
+ import { R as RefreshTrigger, P as ProjectInputChangeJournal, W as WatcherStatus } from './scip-cli-DOerTq-R.js';
5
+ export { g as getScipVersion, i as isScipInstalled, p as printScipInstallInstructions } from './scip-cli-DOerTq-R.js';
6
+ import 'node:fs';
6
7
 
7
8
  /**
8
9
  * One operating-system process instance. A PID alone names a reusable slot;
@@ -64,6 +65,8 @@ type ReindexActivityBudgetDecision = {
64
65
  detail: string;
65
66
  };
66
67
 
68
+ type IndexFreshnessState = 'fresh' | 'stale' | 'missing' | 'unknown';
69
+
67
70
  interface WatcherOptions {
68
71
  projectRoot: string;
69
72
  config: ProjectConfig;
@@ -71,6 +74,10 @@ interface WatcherOptions {
71
74
  reindexRunner?: ReindexRunner;
72
75
  subscriptionFactory?: WatchSubscriptionFactory;
73
76
  budgetInspector?: WatchBudgetInspector;
77
+ /** Reads the identity of the currently published index generation; defaults to the SQLite generation state. */
78
+ publishedGeneration?: (outputDb: string) => string | null;
79
+ /** Reports whether the published index matches the working tree; defaults to the CLI freshness check. */
80
+ indexFreshness?: (projectRoot: string, config: ProjectConfig, outputDb: string) => IndexFreshnessState;
74
81
  gitReader?: GitReader;
75
82
  outputDb?: string;
76
83
  clock?: WatchClock;
@@ -202,9 +209,15 @@ declare class Watcher {
202
209
  private pendingChangesIncompleteReason;
203
210
  private reindexInFlight;
204
211
  private lastReindexEnd;
212
+ /** Generation identity the watcher last saw; a different published identity means someone else refreshed. */
213
+ private lastObservedGeneration;
214
+ private readonly publishedGeneration;
215
+ private readonly indexFreshness;
205
216
  private fsWatchers;
206
217
  private sourcePollingFallbackStarted;
207
218
  private gitPollTimer;
219
+ /** Polls for generations published outside the watcher while work is pending; runs even without Git. */
220
+ private reconcileTimer;
208
221
  private lastGitState;
209
222
  /** When unset, idle Git polls read HEAD/index from the filesystem instead of spawning git. */
210
223
  private preferFilesystemGitState;
@@ -244,6 +257,25 @@ declare class Watcher {
244
257
  private clearCooldownTimer;
245
258
  private clearBudgetTimer;
246
259
  private startGitStatePolling;
260
+ /**
261
+ * While a refresh waits out a cooldown or a budget pause, re-check on the
262
+ * Git poll cadence whether someone else already published a fresh
263
+ * generation. The timer exists only during those states and never outlives
264
+ * the wait it belongs to, so idle watchers hold no standing timer.
265
+ */
266
+ private armReconcileTimer;
267
+ private clearReconcileTimer;
268
+ private readPublishedGeneration;
269
+ /**
270
+ * A manual `reindex` or `setup` publishes a generation the watcher did not
271
+ * produce. When one appears while work is pending (dirty, cooldown, budget
272
+ * pause, or a debounce wait) and the published index matches the working
273
+ * tree, the pending refresh is already satisfied: drop it and report the
274
+ * suppression instead of holding "changes pending" until the budget window
275
+ * or cooldown expires and then re-running a refresh that would only be
276
+ * suppressed as fresh anyway. Returns true when pending work was cleared.
277
+ */
278
+ private reconcileExternalPublication;
247
279
  private pollGitState;
248
280
  private readGitState;
249
281
  private readFilesystemGitState;
package/dist/runtime.js CHANGED
@@ -1,5 +1,5 @@
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};
1
+ import{C as lt,D as pt,M as ht,O as ue,b as at,c as ct,i as On,j as En,k as wn,q as dt,z as ut}from"./chunk-WNTFFKAX.js";import{c as qe,u as ce,x as st}from"./chunk-5ENOG4VP.js";import{c as Ue,e as q,g as Ke,h as Ye}from"./chunk-TRNAEQ6P.js";import"./chunk-DHEQMPLW.js";import"./chunk-JWTGMPIT.js";import{$ as Xe,C as $e,D as Ge,Da as it,Fa as ot,I as Je,Ia as K,J as v,L as Be,T as He,X as Qe,_ as ze,aa as de,ba as Ze,f as Le,fa as et,g as ae,i as B,ia as tt,ja as nt,k as Fe,ma as rt,n as p,p as C,q as k,r as D,ra as H,s as We,t as g,v as L,x as U}from"./chunk-N5B2NILC.js";import{existsSync as or}from"fs";import{randomUUID as sr}from"crypto";import{isAbsolute as Ki,join as At,relative as Yi,resolve as Qi}from"path";var E=1,T=2,Pn="./node_modules/scip-query/docs/schemas/project-config.schema.json";function le(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 r=n===void 0?E:n;if(r!==E&&r!==T)return{kind:"unsupported",schemaVersion:r,direction:r<E?"older":"future"};let i=t.$schema;if(i!==void 0&&(typeof i!="string"||i.trim()===""))return{kind:"malformed",reason:"$schema must be a non-empty string when present"};let o=Y(t),s=r!==T||typeof t.$schema!="string";return r===E?{kind:"legacy",sourceVersion:E,config:o,needsMigration:s}:{kind:"supported",sourceVersion:T,config:o,needsMigration:s}}function Y(e){let t=e,{$schema:n,schemaVersion:r,...i}=t;return{$schema:typeof n=="string"&&n.trim()!==""?n:Pn,schemaVersion:T,...i}}function pe(e){return`${JSON.stringify(Y(e),null,2)}
2
+ `}import{createHash as kn}from"crypto";var f=1,I=2,Q=1,W=1,F="sha256",me=1;function Ct(e,t,n){if(!g(e)||!D(t))throw new Error("Observation identity requires a bounded projection name and positive projection version.");return{schemaVersion:Q,canonicalizationVersion:W,hashAlgorithm:F,projection:{name:e,version:t},digest:kn(F).update(Tn(e,t,n)).digest("hex")}}function Tn(e,t,n){return`{"canonicalizationVersion":${W},"projection":${JSON.stringify(e)},"projectionVersion":${t},"value":${JSON.stringify(n)}}`}function ge(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 Vn(e)?{kind:"legacy",schemaVersion:f,receipt:e}:{kind:"malformed",reason:"observation receipt v1 fields are malformed or contradictory"};if(t===I)return Dn(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 z(e){let t=ge(e);return t.kind==="legacy"||t.kind==="supported"}function ye(e,t){return{collaborationDomain:w(b(e,n=>n.facts.collaborationDomain),b(t,n=>n.facts.collaborationDomain)),repositoryLineage:w(b(e,n=>n.facts.repositoryLineage),b(t,n=>n.facts.repositoryLineage)),workspaceInstance:w(b(e,n=>n.facts.workspaceInstance),b(t,n=>n.facts.workspaceInstance)),wholeContent:w(b(e,n=>n.facts.wholeContent),b(t,n=>n.facts.wholeContent)),relevantInputs:_n(e,t),indexInput:w(b(e,n=>n.facts.index?.inputs),b(t,n=>n.facts.index?.inputs)),indexGeneration:An(e,t),observationStability:jn(e,t)}}function X(e,t,n=ye(e,t)){let r=[["collaborationDomain",n.collaborationDomain],["wholeContent",n.wholeContent],["observationStability",n.observationStability]],i=[];for(let[s,a]of r)a.state!=="established"&&i.push(`${s}:${a.state}`);for(let[s,a]of[["left",e],["right",t]]){let c=Mn(a);c!=="not-applicable"&&c!=="established"&&i.push(`${s}IndexAlignment:${c}`)}let o=r.some(([,s])=>s.state==="disproven")||i.some(s=>s.endsWith(":disproven"));return{policyVersion:me,authority:i.length===0?"completion":o?"none":"advisory",requiredRelationships:["collaborationDomain","wholeContent","observationStability"],reasons:i}}function bt(e){return e.schemaVersion===f?e.index?.generationIdentity:e.facts.index?.generation.digest}function vt(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 _n(e,t){let n=ft(e),r=ft(t);return[...new Set([...n.keys(),...r.keys()])].sort().map(o=>{let s=n.get(o),a=r.get(o),c=s?.subject??a?.subject??o,d=s?.identity.projection.name??a?.identity.projection.name??o;return{subject:c,projection:d,judgment:w(s?.identity,a?.identity)}})}function ft(e){return e.schemaVersion!==I?new Map:new Map((e.facts.relevantInputs??[]).map(t=>[`${t.subject}\0${t.identity.projection.name}`,t]))}function An(e,t){return e.schemaVersion===f&&t.schemaVersion===f?Nn(e.index?.generationIdentity,t.index?.generationIdentity):e.schemaVersion===f||t.schemaVersion===f?R("unknown",["legacy-fact-not-comparable"],gt(e),gt(t)):w(e.facts.index?.generation,t.facts.index?.generation)}function Nn(e,t){let n=e?[{kind:"legacy-index-generation",value:e}]:[],r=t?[{kind:"legacy-index-generation",value:t}]:[];return e===void 0||t===void 0?St(n,r):R(e===t?"established":"disproven",[e===t?"identities-equal":"identities-different"],n,r)}function w(e,t){let n=e?[{kind:"identity",identity:e}]:[],r=t?[{kind:"identity",identity:t}]:[];return!e||!t?St(n,r):Ce(e,t)?R(e.digest===t.digest?"established":"disproven",[e.digest===t.digest?"identities-equal":"identities-different"],n,r):R("unknown",["identity-projections-not-comparable"],n,r)}function jn(e,t){if(e.schemaVersion===f||t.schemaVersion===f)return R("unknown",["legacy-fact-not-comparable"],[],[]);let n=yt(e),r=yt(t),i=mt(e),o=mt(t);return i==="invalidated"||o==="invalidated"?R("disproven",[...i==="invalidated"?["left-observation-invalidated"]:[],...o==="invalidated"?["right-observation-invalidated"]:[]],n,r):i!=="fixed"||o!=="fixed"?R("unknown",[...i==="no-repository-source"?["left-observation-has-no-repository-source"]:i!=="fixed"?["left-observation-not-fixed"]:[],...o==="no-repository-source"?["right-observation-has-no-repository-source"]:o!=="fixed"?["right-observation-not-fixed"]:[]],n,r):R("established",["all-observed-sources-fixed"],n,r)}function mt(e){let t=e.observedSources.filter(r=>r.kind!=="process");if(t.length===0)return"no-repository-source";let n=new Map(e.stabilityProofs.map(r=>[r.source,r.kind]));return t.some(r=>n.get(r.kind)==="invalidated")?"invalidated":t.every(r=>{let i=n.get(r.kind);return i==="immutable"||i==="fixed-snapshot"})?"fixed":"unknown"}function Mn(e){if(e.schemaVersion!==I)return e.index?"unknown":"not-applicable";if(!e.observedSources.some(r=>r.kind==="index-generation"))return"not-applicable";let t=e.facts.index?.inputs;if(!t)return"unknown";let n=(e.facts.relevantInputs??[]).find(r=>Ce(r.identity,t))?.identity;return n?n.digest===t.digest?"established":"disproven":"unknown"}function b(e,t){return e.schemaVersion===I?t(e):void 0}function gt(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 yt(e){return e.stabilityProofs.map(t=>({kind:"stability",proof:t}))}function St(e,t){let n=e.length===0&&t.length===0?"both-facts-missing":e.length===0?"left-fact-missing":"right-fact-missing";return R("unknown",[n],e,t)}function R(e,t,n,r){return{state:e,reasons:t,facts:{left:n,right:r}}}function Ce(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 Vn(e){if(!p(e))return!1;let t=e.index,n=e.worktree;return It(e.observedAt)&&g(e.projectIdentity)&&Bn(e.authorityKind)&&(t===void 0||p(t)&&g(t.generationIdentity)&&(t.source==="immutable"||t.source==="legacy")&&(t.alignment==="not-certified"||t.alignment==="leased"))&&(n===void 0||p(n)&&g(n.identity)&&typeof n.clean=="boolean"&&(n.headCommit===void 0||g(n.headCommit))&&(n.treeOid===void 0||g(n.treeOid)))&&Jn(e.authorityKind,t,n)}function Dn(e){if(!p(e))return!1;let t=e.facts,n=e.observedSources,r=e.stabilityProofs;if(!It(e.observedAt)||!p(t)||!Array.isArray(n)||n.length===0||!n.every(Fn)||!fe(n,c=>c.kind)||!Array.isArray(r)||!r.every(Wn)||!fe(r,c=>c.source)||r.some(c=>!n.some(d=>d.kind===c.source))||!r.every(c=>Gn(c,t))||["collaborationDomain","repositoryLineage","workspaceInstance","wholeContent"].some(c=>t[c]!==void 0&&!x(t[c])))return!1;let o=t.relevantInputs;if(o!==void 0&&(!Array.isArray(o)||!o.every(Ln)||!fe(o,c=>`${c.subject}\0${c.identity.projection.name}`)))return!1;let s=t.index;if(s!==void 0&&(!p(s)||!x(s.generation)||s.inputs!==void 0&&!x(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||g(a.headCommit))&&(a.treeOid===void 0||g(a.treeOid)))&&$n(t,n)}function x(e){return!p(e)||!p(e.projection)?!1:e.schemaVersion===Q&&e.canonicalizationVersion===W&&e.hashAlgorithm===F&&g(e.projection.name)&&D(e.projection.version)&&We(e.digest)}function Ln(e){return p(e)&&g(e.subject)&&x(e.identity)}function Fn(e){return p(e)&&xt(e.kind)&&(e.identity===void 0||x(e.identity))}function Wn(e){return p(e)&&xt(e.source)&&(e.kind==="immutable"||e.kind==="fixed-snapshot"||e.kind==="bracketed"||e.kind==="not-established"||e.kind==="invalidated")}function $n(e,t){let n=e.index,r=t.find(c=>c.kind==="index-generation");if(r){if(!p(n)||!x(n.generation)||r.identity&&!he(r.identity,n.generation))return!1}else if(n!==void 0)return!1;let i=e.workspaceInstance,o=t.find(c=>c.kind==="live-workspace");if(o?.identity&&(!x(i)||!he(o.identity,i)))return!1;let s=e.wholeContent,a=t.find(c=>c.kind==="repository-snapshot");return!(a?.identity&&(!x(s)||!he(a.identity,s)))}function Gn(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 he(e,t){return Ce(e,t)&&e.digest===t.digest}function Jn(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 Bn(e){return e==="index-worktree"||e==="index-only"||e==="worktree-only"||e==="process-local"}function xt(e){return e==="index-generation"||e==="repository-snapshot"||e==="live-workspace"||e==="process"}function It(e){return typeof e=="string"&&!Number.isNaN(Date.parse(e))}function fe(e,t){return new Set(e.map(t)).size===e.length}import{createHash as Ot}from"crypto";import{closeSync as Un,fstatSync as Et,lstatSync as qn,openSync as Hn,readlinkSync as Kn,realpathSync as Yn,rmSync as Qn}from"fs";import{dirname as kt,resolve as zn}from"path";var Xn=2e3,Zn=10,er=3,ee=class extends Error{constructor(n,r,i){super(`Concurrent edit detected for ${n}; expected revision ${Pt(r)}, but found ${Pt(i)}. The latest file was left untouched.`);this.path=n;this.original=r;this.latest=i;this.name="FileRevisionConflictError"}path;original;latest};function Tt(e,t,n={}){let r=tr(e),i=nr(r,n.lockTimeoutMs??Xn,n.monotonicNow??q);try{let o=Math.max(0,Math.floor(n.maxRetries??er));for(let s=0;;s+=1){let a=Z(r),c=t(a,s);if(c.kind==="unchanged")return{changed:!1,attempts:s+1,previous:a,current:a};n.onBeforeCommit?.({attempt:s,snapshot:a,mutation:c});let d=Z(r);if(!ir(a.revision,d.revision)){if(s<o)continue;throw new ee(r,a.revision,d.revision)}try{rr(r,c,a.revision)}catch(l){if(l.code==="EEXIST"){let u=Z(r);if(s<o)continue;throw new ee(r,a.revision,u.revision)}throw l}return{changed:!0,attempts:s+1,previous:a,current:Z(r)}}}finally{i.release()}}function tr(e){let t;try{if(!qn(e).isSymbolicLink())return e;t=Kn(e)}catch{return e}try{return Yn(e)}catch{return zn(kt(e),t)}}function Z(e){for(let t=0;t<4;t+=1){let n;try{n=Hn(e,"r");let r=wt(Et(n)),i=Be(n,{maxBytes:Ge,inputKind:"revisioned text file"}),o=wt(Et(n));if(!_t(r,o))continue;return{path:e,text:i,revision:{exists:!0,hash:Ot("sha256").update(i).digest("hex"),identity:o}}}catch(r){if(r.code==="ENOENT")return{path:e,text:"",revision:{exists:!1,hash:Ot("sha256").update("").digest("hex")}};throw r}finally{n!==void 0&&Un(n)}}throw new Error(`Could not read a stable revision of ${e}; the file is changing continuously.`)}function nr(e,t,n){let r=`${e}.scip-query-write.lock`,i=n()+Math.max(0,t);for(;;){let o=qe(r,{kind:"revisioned-file-mutation",detail:{target:e}});if(o.kind==="acquired")return o.lock;if(n()>=i)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,Zn)}}function rr(e,t,n){if(t.kind==="delete"){if(!n.exists)return;Qn(e),He(kt(e));return}let r=t.mode??n.identity?.mode;n.exists?Ke(e,t.text,{durability:"durable",mode:r}):Ye(e,t.text,{durability:"durable",mode:r})}function ir(e,t){return e.exists===t.exists&&e.hash===t.hash&&(e.identity===void 0?t.identity===void 0:t.identity!==void 0&&_t(e.identity,t.identity))}function wt(e){return{dev:e.dev,ino:e.ino,size:e.size,mtimeMs:e.mtimeMs,mode:e.mode&511}}function _t(e,t){return e.dev===t.dev&&e.ino===t.ino&&e.size===t.size&&e.mtimeMs===t.mtimeMs&&e.mode===t.mode}function Pt(e){return e.exists?e.hash.slice(0,12):"<absent>"}var $=".scipquery.json",Nt=2e3,jt=5e3,be=jt,Mt=15*6e4,ve={enabled:!0,windowMs:15*6e4,maxRebuilds:2,maxEstimatedWriteBytes:1024*1024*1024},ar={enabled:!1,autoStart:!1,allowExpensiveRebuild:!1,debounceMs:Nt,cooldownMs:be,gitPollMs:2e3,idleTimeoutMs:Mt,autoRefresh:!0,ignore:[],resourceBudget:ve};var to=new Set(L);function te(e){let t=At(e,$);if(!or(t))return{};let n;try{n=Je(t,{maxBytes:$e,inputKind:"scip-query project config"})}catch(r){let i=r instanceof Error?r.message:String(r);throw new Error(`unable to read ${$} at ${t}: ${i}`,{cause:r})}return Dt(le(n),t,"read").config}function Vt(e){return{...ar,...e.watch,cooldownMs:Math.max(jt,e.watch?.cooldownMs??be),resourceBudget:{...ve,...e.watch?.resourceBudget}}}function cr(e,t){return dr(e,t).configPath}function dr(e,t){let n=At(e,$),r=sr(),i={collaborationDomainId:r,languages:t,watch:{enabled:!0,debounceMs:Nt,cooldownMs:be,gitPollMs:2e3,idleTimeoutMs:Mt,autoRefresh:!0,resourceBudget:{...ve}}},o=Tt(n,s=>{if(!s.revision.exists)return{kind:"write",text:pe(i)};let a=ur(s,i);return a.config.collaborationDomainId?{kind:"unchanged"}:{kind:"write",text:pe({...a.config,collaborationDomainId:r})}});return{configPath:n,changed:o.changed}}function ur(e,t){if(!e.revision.exists)return{config:Y(t),needsMigration:!0};let n=Dt(le(e.text),e.path,"update");return{config:n.config,needsMigration:n.needsMigration}}function Dt(e,t,n){if(e.kind==="legacy"||e.kind==="supported")return e;if(e.kind==="malformed"){let i=n==="read"?`invalid ${$} at ${t}: ${e.reason}`:`Cannot update ${t}: the latest project config is ${e.reason}.`;throw new Error(`${i} The file was left untouched.`)}let r=n==="read"?`invalid ${$} at ${t}`:`Cannot update ${t}: the latest project config is invalid`;throw new Error(`${r} (unsupported ${e.direction} schemaVersion ${e.schemaVersion}; this scip-query reads legacy v${E} and current v${T}). Upgrade scip-query before retrying; the file was left untouched.`)}import{existsSync as we,lstatSync as Cr,statSync as Yt,watch as br}from"fs";import{EventEmitter as vr}from"events";import{basename as Rr,dirname as Qt,isAbsolute as Pe,join as y,relative as zt,resolve as Xt}from"path";import{watch as Sr}from"chokidar";import xr from"ignore";function Re(e){let t=JSON.stringify(e);return Buffer.byteLength(t)<=65536?t:void 0}import{existsSync as Lt,lstatSync as lr}from"fs";import{resolve as pr}from"path";function Ft(e,t,n,r={}){let i=new Date().toISOString();if(!Lt(n.dbPath))return{state:"missing",checkedAt:i,metaPath:n.metaPath,reason:"No SQLite index database exists.",remedy:"Run: scip-query reindex"};if(!Lt(n.metaPath))return{state:"unknown",checkedAt:i,metaPath:n.metaPath,reason:"No reindex metadata file exists next to the SQLite index.",remedy:"Run: scip-query reindex"};try{let o=U(v(n.metaPath,"reindex metadata"));if(o.kind==="unsupported")return{state:"unknown",checkedAt:i,metaPath:n.metaPath,reason:`Reindex metadata version ${o.version} is unsupported by this scip-query build.`,remedy:"Upgrade scip-query or run: scip-query reindex"};if(o.kind==="malformed")return{state:"unknown",checkedAt:i,metaPath:n.metaPath,reason:`Could not decode reindex metadata: ${o.reason}`,remedy:"Run: scip-query reindex"};let s=o.metadata,a=t.languages??dt(e),c=s.fingerprint,d=n.cacheDir&&r.gitContext&&ue(r.gitContext,n.cacheDir,c)?c:void 0,l=n.cacheDir&&r.gitContext&&d&&fr(d,a,t)&&mr(e,d,t)?r.gitObservation?.context===r.gitContext?r.gitContext:ze(r.gitContext):void 0,u=r.gitObservation&&r.gitObservation.context===r.gitContext?r.gitObservation.projectFileInventorySequence:void 0,h=l?.clean&&Xe(e,void 0,{cachedInventoryAfterSequence:u})?l:void 0,m=n.cacheDir&&h&&d&&ue(h,n.cacheDir,d)?d:hr(e,a,t),O=[...s.indexedLanguages??[]].sort(),V=o.capabilities.publishableGeneration&&Fe(B(s.fingerprint),m)&&JSON.stringify(O)===JSON.stringify(m.languages),P=ht(n.dbPath,n.metaPath),Me=P.state==="invalid"||P.state==="drifted",se=V?pt(n.dbPath,m,O):void 0,Ve=se?.state==="incomplete",De=V&&!Me&&!Ve;return{state:De?"fresh":"stale",checkedAt:i,metaPath:n.metaPath,updatedAt:s.updatedAt,lastRefresh:s.lastRefresh,reason:Me?`SQLite generation requires repair: ${P.reason}`:Ve?`SQLite generation is missing ${se.missingDocumentCount} indexed source document(s): ${se.missingPaths.join(", ")}`:V?"Index metadata fingerprint matches current source files.":"Index metadata fingerprint differs from current source files.",remedy:De?void 0:"Run: scip-query reindex"}}catch(o){return{state:"unknown",checkedAt:i,metaPath:n.metaPath,reason:`Could not read reindex metadata: ${o instanceof Error?o.message:String(o)}`,remedy:"Run: scip-query reindex"}}}function hr(e,t,n){return ot(e,t,{pnpmWorkspaces:n.indexer?.typescript?.pnpmWorkspaces,typescriptProjectMode:n.indexer?.typescript?.projectMode,typescriptProjects:n.indexer?.typescript?.projects,clojureConfigPath:n.indexer?.clojure?.configPath})}function fr(e,t,n){let r=gr(t,n);return e.version===r.version&&JSON.stringify([...e.languages].sort())===JSON.stringify(r.languages)&&e.pnpmWorkspaces===r.pnpmWorkspaces&&e.typescriptProjectMode===r.typescriptProjectMode&&JSON.stringify([...e.typescriptProjects].sort())===JSON.stringify(r.typescriptProjects)&&e.clojureConfigPath===r.clojureConfigPath}function mr(e,t,n){if(!(t.languages.includes("typescript")||!!t.clojureConfigPath))return!0;let i=it(e);if(t.clojureConfigPath){let o=Le(t.clojureConfigPath);if(!i.includes(o))return!1;try{if(!lr(pr(e,o)).isFile())return!1}catch{return!1}}return!t.languages.includes("typescript")||nt(e,n.indexer?.typescript?.projectMode,n.indexer?.typescript?.projects??[],i)}function gr(e,t){return K(e,{pnpmWorkspaces:t.indexer?.typescript?.pnpmWorkspaces,typescriptProjectMode:t.indexer?.typescript?.projectMode,typescriptProjects:t.indexer?.typescript?.projects,clojureConfigPath:t.indexer?.clojure?.configPath})}var Zt=5e3,Oe=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;lastObservedGeneration=null;publishedGeneration;indexFreshness;fsWatchers=[];sourcePollingFallbackStarted=!1;gitPollTimer=null;reconcileTimer=null;lastGitState=null;preferFilesystemGitState=!0;watchGitLayout=null;localCacheWatchPath;gitignoreFilter;extraIgnore;stopped=!1;constructor(t){this.projectRoot=t.projectRoot,this.config=t.config,this.watchConfig=Vt(t.config),this.outputDb=t.outputDb??y(rt(this.projectRoot,t.config),"index.db"),this.preferFilesystemGitState=t.gitReader===void 0,this.localCacheWatchPath=qr(this.projectRoot,Qt(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??wr,en.set(this,Hr(t.stopTimeoutMs??Zt,"watcher stop timeout")),this.reindexRunner=t.reindexRunner??on(),this.subscriptionFactory=t.subscriptionFactory??Pr,this.budgetInspector=t.budgetInspector??lt,this.publishedGeneration=t.publishedGeneration??ce,this.indexFreshness=t.indexFreshness??Ur,this.lastObservedGeneration=this.readPublishedGeneration(),tn.set(this,{projectRoot:t.projectRoot,config:t.config,gitReader:t.gitReader??Qe,languages:sn(t.languages??t.config.languages),typeScriptInputPaths:null,stagedIndexEntries:null}),this.gitignoreFilter=st(t.projectRoot),this.extraIgnore=xr(),this.watchConfig.ignore.length>0&&this.extraIgnore.add(this.watchConfig.ignore),xe(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,re(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(),this.clearReconcileTimer();let n=this.activeOperation;n&&this.setStatus({state:"draining",startedAt:this.wallNow(),reason:"waiting for the active reindex worker to exit"});let r=[...re(this).closures],i=Or(this),o=this.clock.now()+i;return this.stopPromise=this.finishStop(t,r,n,o,i).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=Se(this.pendingTrigger,t),this.changedFiles+=1,this.clearDebounceTimer(),this.triggerReindex()}}startSourceWatcher(t=!1){let n=this.subscriptionFactory(this.projectRoot,{ignoreInitial:!0,ignored:(r,i)=>this.isIgnoredWatchPath(r,i?.isDirectory()??!1),usePolling:t,ignorePermissionErrors:!0,...t?{interval:5e3,binaryInterval:1e4}:{}});n.on("all",(r,i)=>{!this.stopped&&r!=="addDir"&&r!=="unlinkDir"&&this.handleFileChange(r,i)}),n.on("error",r=>this.handleSourceWatcherError(n,r,t)),this.fsWatchers.push(n)}handleSourceWatcherError(t,n,r){if(this.markPendingChangesIncomplete("source-watcher-error"),r||this.sourcePollingFallbackStarted||!Wr(n)||this.stopped){this.onError(new Error(`Failed to watch ${this.projectRoot}: ${String(n)}`));return}this.sourcePollingFallbackStarted=!0,this.fsWatchers=this.fsWatchers.filter(i=>i!==t),Er(re(this),t,i=>this.onError(i));try{this.startSourceWatcher(!0)}catch(i){this.onError(new Error(`Failed to watch ${this.projectRoot}: ${String(i)}`))}}isIgnoredWatchPath(t,n){let r=this.relativeWatchPath(t);if(!r)return!1;if(Jt(r,this.localCacheWatchPath))return!0;let i=n?`${r}/`:r;return this.gitignoreFilter.isIgnored(i)||this.extraIgnore.ignores(i)}handleFileChange(t,n){let r=this.relativeWatchPath(n);if(!r||r===".."||r.startsWith("../")||Jt(r,this.localCacheWatchPath)||this.gitignoreFilter.isIgnored(r)||this.extraIgnore.ignores(r)||r.endsWith("index.db")||r.endsWith("index.scip")||r.endsWith("index.db.tmp")||Rr(r).startsWith(ut))return;r===".scipquery.json"&&qt(this,this.projectRoot);let i=Ht(this,t,r);i!==null&&(i||this.markPendingChangesIncomplete(`unsupported-source-event:${t}`),this.scheduleReindex({kind:"watch-source",detail:r},i?[{path:r,kind:i}]:void 0,i!==void 0))}relativeWatchPath(t){let n=Pe(t)?t:y(this.projectRoot,t);return zt(this.projectRoot,n).replaceAll("\\","/")}scheduleReindex(t,n,r=!1){this.pendingTrigger=Se(this.pendingTrigger,t),r||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&&_.get(this)!==o&&(_.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 i=this.wallNow()+this.watchConfig.debounceMs;this.setStatus({state:"waiting",changedFiles:this.changedFiles,reindexAt:i}),this.debounceTimer=this.clock.setTimeout(()=>{this.debounceTimer=null,this.triggerReindex()},this.watchConfig.debounceMs)}triggerReindex(){if(this.reindexInFlight||this.stopped||this.reconcileExternalPublication())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 r=this.clock.now()-this.lastReindexEnd;if(this.lastReindexEnd>0&&r<this.watchConfig.cooldownMs){let c=this.watchConfig.cooldownMs-r;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 i=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(i,n,o));this.activeOperation=a,a.completion.then(c=>{if(this.reindexInFlight=!1,this.lastReindexEnd=this.clock.now(),ne.set(this,0),this.stopped)return;if(_.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}xe(this),this.lastObservedGeneration=this.readPublishedGeneration();let d=!1;try{d=this.onReindexComplete(c,i,{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=rn(d),u=0;if(l?(u=(ne.get(this)??0)+1,ne.set(this,u),this.dirty=!0,this.pendingTrigger=Se(this.pendingTrigger,i)):ne.set(this,0),!l&&_.get(this)!==a&&(this.onReindexError(d,i),this.onError(d)),this.dirty){let h=l?Vr(this.watchConfig.cooldownMs,u):this.watchConfig.cooldownMs,m=this.wallNow()+h;this.setStatus({state:"cooldown",until:m,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),_.get(this)===a&&_.delete(this)})}async finishStop(t,n,r,i,o){let s=[],a=t.map(async h=>{try{await h.close()}catch(m){s.push(`watch subscription close failed: ${String(m)}`)}});a.push(...n),r&&a.push((async()=>{try{let h=await r.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 Ir(d,i,this.clock),u=re(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,r){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:r,allowExpensiveRebuild:n}}setStatus(t){this.status=t,t.state==="cooldown"||t.state==="budget-paused"?this.armReconcileTimer(t.until):this.clearReconcileTimer(),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),r=Lr(n,t.kind);r===null?this.pendingChanges.delete(t.path):this.pendingChanges.set(t.path,r)}markPendingChangesIncomplete(t){this.pendingChangesComplete=!1,this.pendingChangesIncompleteReason??=t}consumePendingChangeJournal(){let t=ce(this.outputDb),n=[...this.pendingChanges.entries()].map(([s,a])=>({path:s,kind:a})).sort((s,a)=>s.path.localeCompare(a.path)),r=this.pendingChangesComplete,i=this.pendingChangesIncompleteReason;t||(r=!1,i??="accepted-generation-unavailable");let o={version:1,baseGeneration:t,complete:r,...i?{incompleteReason:i}:{},entries:n};return Re(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})),r=this.pendingChangesComplete,i=this.pendingChangesIncompleteReason;this.resetPendingChanges(),t.complete||this.markPendingChangesIncomplete(t.incompleteReason??"failed-reindex");for(let o of t.entries)this.recordPendingChange(o);r||this.markPendingChangesIncomplete(i??"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&&(S(this).stagedIndexEntries=Kt(this.projectRoot,S(this).gitReader),this.gitPollTimer=this.clock.setInterval(()=>this.pollGitState(),this.watchConfig.gitPollMs),this.gitPollTimer.unref?.())}armReconcileTimer(t){this.clearReconcileTimer();let n=t-this.wallNow();if(n<=0||!(this.watchConfig.gitPollMs>0))return;let r=Math.min(this.watchConfig.gitPollMs,n);this.reconcileTimer=this.clock.setTimeout(()=>{this.reconcileTimer=null,!(this.stopped||this.reconcileExternalPublication())&&(this.status.state==="cooldown"||this.status.state==="budget-paused")&&this.armReconcileTimer(this.status.until)},r),this.reconcileTimer.unref?.()}clearReconcileTimer(){this.reconcileTimer&&(this.clock.clearTimeout(this.reconcileTimer),this.reconcileTimer=null)}readPublishedGeneration(){try{return this.publishedGeneration(this.outputDb)}catch{return null}}reconcileExternalPublication(){if(this.stopped||this.reindexInFlight||!(this.dirty||this.status.state==="budget-paused"||this.status.state==="cooldown"||this.status.state==="waiting"))return!1;let n=this.readPublishedGeneration();if(n===null||n===this.lastObservedGeneration)return!1;this.lastObservedGeneration=n;let r;try{r=this.indexFreshness(this.projectRoot,this.config,this.outputDb)}catch{return!1}if(r!=="fresh")return!1;let i=this.pendingTrigger??{kind:"unknown"};return this.clearDebounceTimer(),this.clearCooldownTimer(),this.clearBudgetTimer(),this.dirty=!1,this.changedFiles=0,this.pendingTrigger=null,this.resetPendingChanges(),xe(this),this.onRefreshSuppressed({...i,detail:`a generation published outside the watcher is fresh${i.detail?` (${i.detail})`:""}`}),this.setStatus({state:"idle"}),!0}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 r=t.head!==n.head,i=t.indexPath!==n.indexPath||t.indexMtimeMs!==n.indexMtimeMs||t.indexSize!==n.indexSize;if(!r&&!i)return;let o=S(this),s=o.stagedIndexEntries,a=Kt(this.projectRoot,o.gitReader);o.stagedIndexEntries=a;let c=zr(this.projectRoot,o.gitReader,t,n,s,a,r,i),d=null;if(c!==null&&(c.includes(".scipquery.json")&&qt(this,this.projectRoot),d=c.filter(u=>Ht(this,"add",u)!==null),d.length===0))return;let l=d?.map(u=>({path:u,kind:we(y(this.projectRoot,u))?"change":"delete"}));r&&i?this.scheduleReindex({kind:"watch-git-state",detail:Ie("HEAD and index changed",d)},l,l!==void 0):r?this.scheduleReindex({kind:"watch-git-head",detail:Ie("HEAD changed",d)},l,l!==void 0):i&&this.scheduleReindex({kind:"watch-git-index",detail:Ie(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??$r(this.projectRoot);if(!t)return null;this.watchGitLayout=t;let n=Gr(t.gitDir);return n?Ut(n,t.indexPath):null}readGitStateFromGit(){let t=S(this).gitReader,n=de(this.projectRoot,["rev-parse","--git-path","index"],t);if(!n)return null;let r=Ze(this.projectRoot,n);return Ut(de(this.projectRoot,["rev-parse","--verify","HEAD"],t),r)}clearGitPollTimer(){this.gitPollTimer&&(this.clock.clearInterval(this.gitPollTimer),this.gitPollTimer=null)}};async function Ir(e,t,n){if(e.length===0)return!0;let r=Promise.all(e).then(()=>!0),i=Math.max(0,t-n.now()),o=null,s=new Promise(c=>{o=n.setTimeout(()=>c(!1),i)}),a=await Promise.race([r,s]);return a&&o&&n.clearTimeout(o),a}var $t=new WeakMap,en=new WeakMap,tn=new WeakMap,_=new WeakMap,ne=new WeakMap;function re(e){let t=$t.get(e);if(t)return t;let n={closures:new Set,errors:[]};return $t.set(e,n),n}function Or(e){return en.get(e)??Zt}function S(e){let t=tn.get(e);if(!t)throw new Error("Watcher input state was not initialized.");return t}function Er(e,t,n){let r=Promise.resolve().then(()=>t.close()).catch(i=>{let o=`watch subscription close failed during polling fallback: ${String(i)}`;e.errors.push(o),n(new Error(o))});e.closures.add(r),r.then(()=>e.closures.delete(r))}function nn(e,t=Ue){let{projectRoot:n,config:r,languages:i,pnpmWorkspaces:o,typescriptProjectMode:s,typescriptProjects:a,clojureConfigPath:c,indexerConcurrency:d,trigger:l}=e,u=te(n),h=Object.keys(u).length>0?u:r,m=H(n,h),O=h.indexer?.typescript,V=h.indexer?.clojure,P=t(process.pid);if(!P)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:m.indexPath,SCIP_REINDEX_OUTPUT_DB:m.dbPath,SCIP_REINDEX_LANGUAGES:(h.languages??i)?.join(",")??"",SCIP_REINDEX_INDEXER_CONCURRENCY:String(h.indexerConcurrency??d??""),SCIP_REINDEX_PNPM_WORKSPACES:O?.pnpmWorkspaces??o?"1":"",SCIP_REINDEX_TYPESCRIPT_CONFIG:JSON.stringify({projectMode:O?.projectMode??s,projects:O?.projects??a??[],maxHeapMb:O?.maxHeapMb}),SCIP_REINDEX_CLOJURE_CONFIG_PATH:V?.configPath??c??"",SCIP_REINDEX_TRIGGER_KIND:l.kind,SCIP_REINDEX_TRIGGER_DETAIL:l.detail??"",SCIP_REINDEX_CHANGE_JOURNAL:e.changeJournal?Re(e.changeJournal)??"":"",SCIP_REINDEX_ALLOW_EXPENSIVE:e.allowExpensiveRebuild===!1?"0":"1",SCIP_REINDEX_PROCESS_GROUP_LEADER:"1",SCIP_REINDEX_PARENT_IDENTITY:JSON.stringify(P)}}}var wr={now:q,wallNow:()=>Date.now(),setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Pr=(e,t)=>kr(process.platform,t.usePolling)?new Ee(e):Sr(e,t);function kr(e,t){return e==="darwin"&&t!==!0}var G=class extends Error{constructor(t,n){super(t,n===void 0?void 0:{cause:n}),this.name="RecursiveSourceWatchError"}},Ee=class{events=new vr;watcher;constructor(t){this.watcher=br(t,{recursive:!0},(n,r)=>{if(r===null){this.events.emit("error",new G("Recursive source watcher omitted the changed path."));return}let i=y(t,r.toString());this.events.emit("all",Tr(n,i),i)}),this.watcher.on("error",n=>{this.events.emit("error",new G(`Recursive source watcher failed: ${n.message}`,n))})}on=(t,n)=>(this.events.on(t,n),this);close(){this.watcher.close()}};function Tr(e,t){return e==="change"?"change":we(t)?Yt(t).isDirectory()?"addDir":"add":"unlink"}var _r=15*6e4,Ar=1e3,Nr=64*1024;function jr(){return{stdoutTail:"",stderrTail:"",stdoutTruncated:!1,stderrTruncated:!1}}function Gt(e,t){let n=e instanceof Error?e.message:String(e),r=t.stderrTail.trim()||t.stdoutTail.trim();return r?`${n}
3
+ ${r}`:n}function Mr(e,t){return Object.assign(new Error(e,t===void 0?void 0:{cause:t}),{retryable:!0})}function rn(e){return e instanceof Error&&"retryable"in e&&e.retryable===!0}function Vr(e,t){let n=e*2**Math.min(5,Math.max(0,t-1));return Math.max(e,Math.min(3e4,n))}function on(e={}){let t=e.timeoutMs??_r,n=e.terminationGraceMs??Ar,r=e.maxOutputBytes??Nr,i=e.resolveLaunch??nn;return{start(o){let s=i(o),a=new AbortController,c=jr(),d=!1,l=ct({command:process.execPath,args:[...process.execArgv,s.workerPath],label:"watch reindex worker",env:s.env,timeoutMs:t,terminationGraceMs:n,maxStdoutBytes:r,maxStderrBytes:r,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=Gt(new Error(`Reindex worker exited with ${u.signal?`signal ${u.signal}`:`code ${u.status}`}`),c);throw u.status===75?Mr(h):new Error(h)}return u.durationMs}).catch(u=>{throw rn(u)?u:(u instanceof at&&(c={stdoutTail:u.stdout,stderrTail:u.stderr,stdoutTruncated:u.stdoutTruncated,stderrTruncated:u.stderrTruncated}),new Error(Gt(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 Se(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 Dr(e){if(e==="add")return"add";if(e==="change")return"change";if(e==="unlink")return"delete"}function Lr(e,t){return e?e==="add"?t==="delete"?null:"add":e==="delete"&&t==="add"?"change":t:t}function Fr(e){return e instanceof Error&&"code"in e&&e.code==="EMFILE"||String(e).includes("EMFILE: too many open files")}function Wr(e){return e instanceof G||Fr(e)}var ke=/^[0-9a-f]{40,64}$/i;function Jt(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 $r(e){let t=y(e,".git");try{let n=Cr(t),r;if(n.isDirectory())r=t;else if(n.isFile()){let i=/^gitdir:\s*(.+)\s*$/m.exec(v(t,"Git directory marker"));if(!i?.[1])return null;let o=i[1].trim();r=Pe(o)?o:Xt(e,o)}else return null;return we(r)?{gitDir:r,indexPath:y(r,"index")}:null}catch{return null}}function Gr(e){let t;try{t=v(y(e,"HEAD"),"Git HEAD").trim()}catch{return}if(ke.test(t))return t.toLowerCase();let n=/^ref:\s*(.+)$/.exec(t)?.[1]?.trim();if(!n)return;let r=Jr(e);return Bt(e,n)??Bt(r,n)??Br(r,n)}function Jr(e){try{let t=v(y(e,"commondir"),"Git common-directory marker").trim();return t?Pe(t)?t:Xt(e,t):e}catch{return e}}function Bt(e,t){try{let n=v(y(e,t),"Git reference").trim();return ke.test(n)?n.toLowerCase():void 0}catch{return}}function Br(e,t){try{for(let n of v(y(e,"packed-refs"),"Git packed references").split(`
4
+ `)){if(n.startsWith("#")||n.startsWith("^"))continue;let r=n.indexOf(" ");if(r===-1)continue;let i=n.slice(0,r);if(n.slice(r+1).trim()===t&&ke.test(i))return i.toLowerCase()}}catch{return}}function Ur(e,t,n){let r=Qt(n);return Ft(e,t,{dbPath:n,metaPath:y(r,"meta.json"),cacheDir:r}).state}function Ut(e,t){let n={head:e,indexPath:t};try{let r=Yt(t);n.indexMtimeMs=r.mtimeMs,n.indexSize=r.size}catch{n.indexMtimeMs=void 0,n.indexSize=void 0}return n}function qr(e,t){let n=zt(e,t).replaceAll("\\","/");if(!(!n||n===".."||n.startsWith("../")))return n}function Hr(e,t){if(!Number.isSafeInteger(e)||e<=0)throw new Error(`${t} must be a positive integer.`);return e}function sn(e){return e&&e.length>0?[...e]:L}function qt(e,t){try{let n=S(e);n.config=te(t),n.languages=sn(n.config.languages)}catch{S(e).languages=L}}function Ht(e,t,n){let r=S(e);if(ae(n,r.languages)==="other")return null;let o=Dr(t);if(n===".scipquery.json"||et(n))return r.typeScriptInputPaths=null,o;if(!Kr(n,r.languages))return o;let s=r.typeScriptInputPaths;if(!s)return o;let a=s.has(n);if(o!=="add")return a?o:null;if(a)return"change";let c=an(e);return c?c.has(n)?"add":null:o}function xe(e){let t=S(e);if(!t.languages.includes("typescript")){t.typeScriptInputPaths=null;return}let n=Yr(t.projectRoot,t.config,t.languages);t.typeScriptInputPaths=n??an(e)}function an(e){let t=S(e);if(!t.languages.includes("typescript"))return t.typeScriptInputPaths=null,null;try{let n=t.config.indexer?.typescript,r=tt(t.projectRoot,n?.projectMode,n?.projects);return t.typeScriptInputPaths=r,r}catch{return t.typeScriptInputPaths=null,null}}function Kr(e,t){if(!t.includes("typescript"))return!1;let n=ae(e,["typescript","javascript"]);return n==="source"||n==="ambient"}function Yr(e,t,n){try{let r=U(v(H(e,t).metaPath,"reindex metadata"));if(r.kind!=="supported"&&r.kind!=="legacy")return null;let i=B(r.metadata.fingerprint);return!i||!Qr(i,n,t)?null:new Set(i.files.map(o=>o.path))}catch{return null}}function Qr(e,t,n){let r=K(t,{pnpmWorkspaces:n.indexer?.typescript?.pnpmWorkspaces,typescriptProjectMode:n.indexer?.typescript?.projectMode,typescriptProjects:n.indexer?.typescript?.projects,clojureConfigPath:n.indexer?.clojure?.configPath});return e.version===r.version&&JSON.stringify([...e.languages].sort())===JSON.stringify(r.languages)&&e.pnpmWorkspaces===r.pnpmWorkspaces&&e.typescriptProjectMode===r.typescriptProjectMode&&JSON.stringify([...e.typescriptProjects].sort())===JSON.stringify(r.typescriptProjects)&&e.clojureConfigPath===r.clojureConfigPath}function zr(e,t,n,r,i,o,s,a){let c=new Set;if(s){if(!n.head||!r.head)return null;let d=t.runResult(e,["diff","--name-only","-z","--no-renames","--relative",n.head,r.head,"--"]);if(d.kind!=="success")return null;for(let l of Xr(d.output))c.add(l)}if(a){if(i===null||o===null)return null;for(let d of ei(i,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"?Zr(n.output):null}function Xr(e){return e.split("\0").filter(t=>t.length>0)}function Zr(e){let t=e.split("\0");if(t.at(-1)===""&&t.pop(),t.length%2!==0)return null;let n=new Map;for(let r=0;r<t.length;r+=2){let i=t[r],o=t[r+1];if(!i.startsWith(":")||!o)return null;n.set(o,i)}return n}function ei(e,t){return[...new Set([...e.keys(),...t.keys()])].filter(r=>e.get(r)!==t.get(r))}function Ie(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 Te,mkdirSync as ti,symlinkSync as ni,readlinkSync as cn,unlinkSync as dn,readdirSync as ri}from"fs";import{join as A,dirname as _e,resolve as N,relative as ii,isAbsolute as oi}from"path";import{homedir as si,platform as ai}from"os";import{fileURLToPath as ci}from"url";var di=ai()==="win32";var un=["scip-query","scip-plan","scip-setup","scip-integrity-audit","scip-explore","concrete-plan"];function ui(e={}){let t=e.quiet?()=>{}:console.log,n=ci(import.meta.url),r=N(_e(n),"..","skills"),i=e.homeDir??process.env.SCIP_QUERY_SKILLS_HOME??si(),o=[A(i,".claude","skills"),A(i,".codex","skills"),A(i,".agents","skills")],s={installed:[],skipped:[],alreadyLinked:[],pruned:[]};for(let a of o){let c=_e(a);if(!Te(c))continue;ti(a,{recursive:!0});let d=hi(a);li(a,r,d,s,t);for(let l of un){let u=A(r,l),h=A(a,l);if(!Te(u)){s.skipped.push(`${d}/${l}`);continue}if(Te(h)){try{let m=cn(h);if(N(m)===N(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}dn(h)}ni(u,h,di?"junction":"dir"),s.installed.push(`${d}/${l}`),t(` done: ${l} \u2192 ${d}`)}}return s}function li(e,t,n,r,i){let o=new Set(un);for(let s of ri(e)){if(o.has(s))continue;let a=A(e,s),c;try{c=N(_e(a),cn(a))}catch{continue}pi(c,t)&&(dn(a),r.pruned.push(`${n}/${s}`),i(` prune: ${s} \u2192 ${n} (removed stale scip-query skill link)`))}}function pi(e,t){let n=ii(N(t),N(e));return n===""||!n.startsWith("..")&&!oi(n)}function hi(e){return e.includes(".codex")?"Codex":e.includes(".agents")?"Agents":"Claude"}var ln=["repository-observation","repository-preview","mutation","composite","environment-observation","tool-information"];function fi(e,t=[]){return{defaultRole:e,...t.length>0?{rules:t}:{}}}function mi(e,t){for(let n of e.rules??[]){if(n.when.kind==="option-present"){let i=t.options[n.when.name];if(i!==void 0&&i!==!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 gi(e){return[...new Set([e.defaultRole,...(e.rules??[]).map(t=>t.role)])]}function ie(e){return ln.includes(e)}function yi(e){return e==="repository-observation"||e==="repository-preview"||e==="composite"}var Ae=1,Ne=1,oe=["compiler-graph","semantic-analysis","repository-source","change-history","runtime-measurement","heuristic","mixed","unknown"],pn=["complete","partial","unknown"],hn=["validated","failed","not-evaluated","not-applicable"],fn=["observe","advise","require-adjudication","block","not-established"],mn={policyId:"scip-query:unresolved-repository-policy",policyVersion:Ne,permission:"not-established",reasons:["No repository action policy was supplied for this claim."]};function Ci(e){return{schemaVersion:Ae,origin:e.contract.origin,coverage:gn(e.coverage),producerValidation:e.contract.producerValidation,stateAuthority:X(e.receipt,e.receipt),repositoryPolicy:e.repositoryPolicy??mn,...e.contract.families?{families:e.contract.families}:{}}}function gn(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 J(n,"origin",t.origins,e.origin),J(n,"coverage",t.coverage,e.coverage.state),J(n,"producer-validation",t.producerValidation,e.producerValidation.status),J(n,"state-authority",t.stateAuthority,e.stateAuthority.authority),J(n,"action-permission",t.actionPermission,e.repositoryPolicy.permission),{satisfied:n.every(r=>r.satisfied),predicates:n}}function J(e,t,n,r){n&&e.push({predicate:t,satisfied:n.includes(r),required:n,actual:r})}function je(e){return!p(e)||e.schemaVersion!==Ae||!j(e.origin,oe)||!vi(e.coverage)||!Ri(e.producerValidation)||!Si(e.stateAuthority)||!xi(e.repositoryPolicy)?!1:e.families===void 0||Ii(e.families)}function vi(e){return!p(e)||!j(e.state,pn)||!k(e.returned)||typeof e.totalKnown!="boolean"||e.total!==void 0&&!k(e.total)||e.omitted!==void 0&&!k(e.omitted)?!1:e.state==="complete"?e.totalKnown===!0&&e.total===e.returned&&e.omitted===0:e.state==="partial"?e.totalKnown===!0&&k(e.total)&&k(e.omitted)&&e.total===Number(e.returned)+Number(e.omitted):e.totalKnown===!1}function Ri(e){if(!p(e)||!j(e.status,hn))return!1;let t=e.certification;return e.status==="validated"||e.status==="failed"?p(t)&&C(t.id)&&Number.isSafeInteger(t.version)&&Number(t.version)>0&&C(t.corpus):t===void 0}function Si(e){return p(e)&&Number.isSafeInteger(e.policyVersion)&&(e.authority==="completion"||e.authority==="advisory"||e.authority==="none")&&Array.isArray(e.requiredRelationships)&&e.requiredRelationships.every(C)&&Array.isArray(e.reasons)&&e.reasons.every(C)}function xi(e){return p(e)&&C(e.policyId)&&e.policyVersion===Ne&&j(e.permission,fn)&&Array.isArray(e.reasons)&&e.reasons.every(C)}function Ii(e){return Array.isArray(e)&&e.every(t=>p(t)&&C(t.id)&&C(t.selector)&&Oi(t.origin))}function Oi(e){return p(e)?e.kind==="fixed"?j(e.origin,oe)&&e.origin!=="mixed":e.kind!=="result-field"||!C(e.field)||!p(e.values)?!1:Object.values(e.values).every(t=>j(t,oe)&&t!=="mixed"):!1}function j(e,t){return typeof e=="string"&&t.includes(e)}var bn="scip-query-result",vn=0,M=1,Ei=1,Rn=1,Sn=1;function xn(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=yn(e);return s?{kind:"malformed",reason:`Legacy CLI JSON envelope: ${s}`}:{kind:"legacy",schemaVersion:vn,envelope:e}}if(!t||!n)return{kind:"malformed",reason:"CLI JSON envelope must contain both kind and schemaVersion."};if(e.kind!==bn)return{kind:"malformed",reason:`Unsupported CLI JSON envelope kind: ${Ti(e.kind)}.`};let r=e.schemaVersion;if(!Number.isSafeInteger(r)||Number(r)<1)return{kind:"malformed",reason:"CLI JSON envelope schemaVersion must be a positive safe integer."};if(r!==M)return{kind:"unsupported",schemaVersion:Number(r),direction:Number(r)<M?"older":"future",...Cn(e.producer)?{producer:e.producer}:{}};let i=yn(e);if(i)return{kind:"malformed",reason:`CLI JSON envelope v1: ${i}`};if(!Cn(e.producer))return{kind:"malformed",reason:"CLI JSON envelope v1: producer must identify scip-query and its non-empty version."};if(!D(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=In(e.command);return o.includes(e.resultSchemaVersion)?e.evidenceContext!==void 0&&!ki(e.evidenceContext)?{kind:"malformed",reason:"CLI JSON envelope v1: evidenceContext must contain a supported receipt and analysis manifest."}:e.operationRole!==void 0&&!ie(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:M,envelope:e}:{kind:"unsupported-result",schemaVersion:M,command:e.command,resultSchemaVersion:e.resultSchemaVersion,supportedResultSchemaVersions:o}}function wi(e){let t=xn(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 ${M}.`)}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 In(e){return Pi[e]??[Ei]}var Pi={};function yn(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 Cn(e){return p(e)&&e.name==="scip-query"&&typeof e.version=="string"&&e.version.length>0}function ki(e){if(!p(e)||e.schemaVersion!==Rn||e.operationRole!==void 0&&!ie(e.operationRole)||!z(e.receipt))return!1;let t=e.analysisManifest;return p(t)&&t.schemaVersion===Sn&&(t.evidence===void 0||t.evidence==="graph-fact"||t.evidence==="heuristic"||t.evidence==="mixed")&&(t.claimQualification===void 0||je(t.claimQualification))}function Ti(e){return typeof e=="string"?JSON.stringify(e):String(e)}export{fn as CLAIM_ACTION_PERMISSIONS,Ne as CLAIM_ACTION_POLICY_VERSION,pn as CLAIM_COVERAGE_STATES,oe as CLAIM_ORIGINS,Ae as CLAIM_QUALIFICATION_SCHEMA_VERSION,Sn as CLI_ANALYSIS_MANIFEST_SCHEMA_VERSION,Rn as CLI_EVIDENCE_CONTEXT_SCHEMA_VERSION,bn as CLI_JSON_ENVELOPE_KIND,ln as COMMAND_OPERATION_ROLES,M as CURRENT_CLI_JSON_ENVELOPE_SCHEMA_VERSION,mn as DEFAULT_REPOSITORY_POLICY_ACTION,vn as LEGACY_CLI_JSON_ENVELOPE_SCHEMA_VERSION,f as LEGACY_OBSERVATION_RECEIPT_SCHEMA_VERSION,W as OBSERVATION_IDENTITY_CANONICALIZATION_VERSION,F as OBSERVATION_IDENTITY_HASH_ALGORITHM,Q as OBSERVATION_IDENTITY_SCHEMA_VERSION,I as OBSERVATION_RECEIPT_SCHEMA_VERSION,me as OBSERVATION_STATE_AUTHORITY_POLICY_VERSION,hn as PRODUCER_VALIDATION_STATUSES,Oe as Watcher,fi as commandOperation,gi as commandOperationRoles,ye as compareObservationReceipts,Ct as createObservationIdentity,on as createReindexRunner,xn as decodeCliJsonEnvelope,ge as decodeObservationReceipt,gn as deriveClaimCoverage,Ci as deriveClaimQualification,X as deriveObservationStateAuthority,bi as evaluateClaimQualification,En as getScipVersion,cr as initProjectConfig,ui as installSkills,je as isClaimQualificationV1,ie as isCommandOperationRole,z as isObservationReceipt,On as isScipInstalled,te as loadProjectConfig,bt as observationReceiptGenerationIdentity,Rt as observationReceiptStabilityLabel,vt as observationReceiptWorkspaceIdentity,yi as operationObservesRepository,wn as printScipInstallInstructions,wi as requireCompatibleCliJsonEnvelope,mi as resolveCommandOperationRole,H as resolveIndexStoragePaths,nn as resolveReindexWorkerLaunch,In as supportedCliResultSchemaVersions};
5
5
  //# sourceMappingURL=runtime.js.map
@@ -1,2 +1,2 @@
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};
1
+ import{j as O}from"./chunk-OWOOWNJ5.js";import{e as E,f as A,g as C,h as V,m as F}from"./chunk-SSK6LDPC.js";import"./chunk-4WNW27SX.js";import"./chunk-F4FNK44D.js";import"./chunk-GAS2LJMP.js";import"./chunk-DRENNWRG.js";import"./chunk-2OOY75BW.js";import{b as h}from"./chunk-3AF4TUFK.js";import{b as q,c as N,h as _,i as T,m as g,n as k,o as P,p as B,r as U}from"./chunk-FGA2U4OR.js";import{a as x}from"./chunk-B3PYOSCX.js";import"./chunk-H5EXS3HM.js";import"./chunk-HGFDYOVB.js";import{c as L,d as b,e as v}from"./chunk-JFMEXGFE.js";import"./chunk-KYSDI3GE.js";import"./chunk-7F45LJKI.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-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};
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-BDUVI7TO.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-OWOOWNJ5.js";import{d as F,e as se,f as re,g as oe,h as ae}from"./chunk-GAS2LJMP.js";import"./chunk-2OOY75BW.js";import{a as j,f as d,g as M}from"./chunk-HGFDYOVB.js";import"./chunk-JFMEXGFE.js";import{$ as ee,_ as q}from"./chunk-KYSDI3GE.js";import"./chunk-7F45LJKI.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-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};
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-BDUVI7TO.js";import{a}from"./chunk-ILMHV3KM.js";import"./chunk-OWOOWNJ5.js";import"./chunk-GAS2LJMP.js";import"./chunk-2OOY75BW.js";import"./chunk-JFMEXGFE.js";import"./chunk-KYSDI3GE.js";import"./chunk-7F45LJKI.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,5 @@
1
1
  import { a as SupportedLanguage } from './config-types-B9B60MiR.js';
2
+ import { writeSync, renameSync, fsyncSync } from 'node:fs';
2
3
 
3
4
  type WatcherStatus = {
4
5
  state: 'idle';
@@ -69,6 +70,35 @@ interface ProjectInputChangeJournal {
69
70
  entries: ProjectInputChangeEntry[];
70
71
  }
71
72
 
73
+ interface VerifiedBinaryFetchOptions {
74
+ /** Absolute path to cache the downloaded bytes at (and to check first). */
75
+ cachePath: string;
76
+ url: string;
77
+ expectedSha256: string;
78
+ fetchImpl?: typeof fetch;
79
+ timeoutMs?: number;
80
+ maxBytes?: number;
81
+ lockWaitMs?: number;
82
+ signal?: AbortSignal;
83
+ /** Failure-injection seam; production uses node:fs.writeSync. */
84
+ writeImpl?: typeof writeSync;
85
+ /** Failure-injection seam for the durable promotion rename. */
86
+ renameImpl?: typeof renameSync;
87
+ /** Failure-injection seam for staged-file and directory flushes. */
88
+ syncImpl?: typeof fsyncSync;
89
+ }
90
+ interface VerifiedBinaryFetchResult {
91
+ status: 'cached' | 'downloaded';
92
+ path: string;
93
+ sha256: string;
94
+ }
95
+ /**
96
+ * Reuse a cache entry whose checksum matches, or serialize one bounded,
97
+ * streamed download for the target path. The accepted bytes become visible by
98
+ * atomic rename only after their declared/observed size and SHA-256 pass.
99
+ */
100
+ declare function fetchVerifiedBinary(opts: VerifiedBinaryFetchOptions): Promise<VerifiedBinaryFetchResult>;
101
+
72
102
  /**
73
103
  * Check if the `scip` CLI binary is available on PATH or packaged with scip-query.
74
104
  */
@@ -81,11 +111,19 @@ declare function getScipVersion(): string | null;
81
111
  * Print instructions for installing the scip CLI binary.
82
112
  */
83
113
  declare function printScipInstallInstructions(): void;
114
+ interface ScipReleaseInstallDeps {
115
+ fetch: typeof fetchVerifiedBinary;
116
+ extract: (archivePath: string, directory: string) => void;
117
+ markExecutable: (path: string) => void;
118
+ probeVersion: (binary: string) => string | null;
119
+ env: NodeJS.ProcessEnv;
120
+ }
84
121
  /**
85
- * Attempt to auto-install the `scip` CLI binary.
86
- * Uses an immutable Go module identity, then prints versioned manual instructions.
87
- * Returns true if installation succeeded.
122
+ * Attempt to auto-install the `scip` CLI binary: the reviewed release archive
123
+ * first (no toolchain required), then `go install` of the immutable module as
124
+ * a fallback for platforms without a published archive. Returns true if a
125
+ * binary reporting the pinned version is now resolvable.
88
126
  */
89
- declare function tryInstallScipCli(onStatus: (msg: string) => void): boolean;
127
+ declare function tryInstallScipCli(onStatus: (msg: string) => void, deps?: Partial<ScipReleaseInstallDeps>): Promise<boolean>;
90
128
 
91
129
  export { type LastRefreshMetadata as L, type ProjectInputChangeJournal as P, type RefreshTrigger as R, type WatcherStatus as W, getScipVersion as g, isScipInstalled as i, printScipInstallInstructions as p, tryInstallScipCli as t };
@@ -0,0 +1,2 @@
1
+ import{a,b}from"./chunk-OLNV6I6U.js";import"./chunk-2WC2OEDO.js";import"./chunk-BGBBVSH4.js";import"./chunk-MV3CDXPI.js";import"./chunk-MTDBHTSF.js";import"./chunk-WYCTJDVR.js";import"./chunk-CEEZJXEF.js";import"./chunk-OSR2GEHQ.js";import"./chunk-FRUSVINH.js";import"./chunk-YEN6CYC7.js";import"./chunk-WRQXLNYE.js";import"./chunk-2GRUZAQF.js";import"./chunk-HOENASQM.js";import"./chunk-YUKYB54I.js";import"./chunk-BJT7LSPK.js";import"./chunk-SSK6LDPC.js";import"./chunk-4WNW27SX.js";import"./chunk-F4FNK44D.js";import"./chunk-GAS2LJMP.js";import"./chunk-WK46TNUM.js";import"./chunk-TQZV7KV4.js";import"./chunk-3L2ZBPEX.js";import"./chunk-YXPUP5G2.js";import"./chunk-DRENNWRG.js";import"./chunk-BE7ZZTMC.js";import"./chunk-2OOY75BW.js";import"./chunk-DHEQMPLW.js";import"./chunk-NOGJXYFO.js";import"./chunk-RTQ7NEKG.js";import"./chunk-GUFSG5TX.js";import"./chunk-IW5XQG5G.js";import"./chunk-FGA2U4OR.js";import"./chunk-B3PYOSCX.js";import"./chunk-H5EXS3HM.js";import"./chunk-HGFDYOVB.js";import"./chunk-JFMEXGFE.js";import"./chunk-KYSDI3GE.js";import"./chunk-7F45LJKI.js";export{a as referenceReachability,b as slice};
2
+ //# sourceMappingURL=slice-HYRATV64.js.map
@@ -0,0 +1,2 @@
1
+ import{a,b}from"./chunk-UXW33INU.js";import"./chunk-EKV5HX33.js";import"./chunk-2WC2OEDO.js";import"./chunk-BGBBVSH4.js";import"./chunk-MV3CDXPI.js";import"./chunk-MTDBHTSF.js";import"./chunk-WYCTJDVR.js";import"./chunk-CEEZJXEF.js";import"./chunk-OSR2GEHQ.js";import"./chunk-FRUSVINH.js";import"./chunk-YEN6CYC7.js";import"./chunk-WRQXLNYE.js";import"./chunk-2GRUZAQF.js";import"./chunk-HOENASQM.js";import"./chunk-YUKYB54I.js";import"./chunk-BJT7LSPK.js";import"./chunk-SSK6LDPC.js";import"./chunk-4WNW27SX.js";import"./chunk-F4FNK44D.js";import"./chunk-GAS2LJMP.js";import"./chunk-WK46TNUM.js";import"./chunk-TQZV7KV4.js";import"./chunk-3L2ZBPEX.js";import"./chunk-YXPUP5G2.js";import"./chunk-DRENNWRG.js";import"./chunk-BE7ZZTMC.js";import"./chunk-2OOY75BW.js";import"./chunk-DHEQMPLW.js";import"./chunk-NOGJXYFO.js";import"./chunk-RTQ7NEKG.js";import"./chunk-GUFSG5TX.js";import"./chunk-IW5XQG5G.js";import"./chunk-FGA2U4OR.js";import"./chunk-B3PYOSCX.js";import"./chunk-H5EXS3HM.js";import"./chunk-HGFDYOVB.js";import"./chunk-JFMEXGFE.js";import"./chunk-KYSDI3GE.js";import"./chunk-7F45LJKI.js";export{b as consumerSurface,a as surface};
2
+ //# sourceMappingURL=surface-VTGDYWF5.js.map
@@ -0,0 +1,2 @@
1
+ import{a}from"./chunk-DTZCKZEU.js";import{a as c}from"./chunk-26CT72HM.js";import{b as i,e as m}from"./chunk-HOENASQM.js";import"./chunk-3L2ZBPEX.js";import"./chunk-YXPUP5G2.js";import{c as l}from"./chunk-DRENNWRG.js";import"./chunk-MXNGIEPU.js";import"./chunk-RTQ7NEKG.js";import"./chunk-GUFSG5TX.js";import"./chunk-IW5XQG5G.js";import"./chunk-H5EXS3HM.js";import"./chunk-HGFDYOVB.js";import"./chunk-KYSDI3GE.js";import"./chunk-7F45LJKI.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-WD5EU5JE.js.map
@@ -0,0 +1,2 @@
1
+ import{a,b}from"./chunk-SQXRS7BG.js";import"./chunk-EKV5HX33.js";import"./chunk-2GRUZAQF.js";import"./chunk-HOENASQM.js";import"./chunk-3L2ZBPEX.js";import"./chunk-YXPUP5G2.js";import"./chunk-DRENNWRG.js";import"./chunk-RTQ7NEKG.js";import"./chunk-GUFSG5TX.js";import"./chunk-IW5XQG5G.js";import"./chunk-H5EXS3HM.js";import"./chunk-HGFDYOVB.js";import"./chunk-KYSDI3GE.js";import"./chunk-7F45LJKI.js";export{b as moduleMap,a as system};
2
+ //# sourceMappingURL=system-LRQNFOR2.js.map
@@ -0,0 +1,2 @@
1
+ import{a,b,c}from"./chunk-D4N5SQ2M.js";import"./chunk-J66VOFW6.js";import"./chunk-B5D7QPBE.js";import"./chunk-WYCTJDVR.js";import"./chunk-CEEZJXEF.js";import"./chunk-OSR2GEHQ.js";import"./chunk-FRUSVINH.js";import"./chunk-YEN6CYC7.js";import"./chunk-WRQXLNYE.js";import"./chunk-2GRUZAQF.js";import"./chunk-HOENASQM.js";import"./chunk-BJT7LSPK.js";import"./chunk-SSK6LDPC.js";import"./chunk-4WNW27SX.js";import"./chunk-F4FNK44D.js";import"./chunk-GAS2LJMP.js";import"./chunk-WK46TNUM.js";import"./chunk-TQZV7KV4.js";import"./chunk-3L2ZBPEX.js";import"./chunk-YXPUP5G2.js";import"./chunk-DRENNWRG.js";import"./chunk-BE7ZZTMC.js";import"./chunk-2OOY75BW.js";import"./chunk-NOGJXYFO.js";import"./chunk-RTQ7NEKG.js";import"./chunk-GUFSG5TX.js";import"./chunk-IW5XQG5G.js";import"./chunk-FGA2U4OR.js";import"./chunk-B3PYOSCX.js";import"./chunk-H5EXS3HM.js";import"./chunk-HGFDYOVB.js";import"./chunk-JFMEXGFE.js";import"./chunk-KYSDI3GE.js";import"./chunk-7F45LJKI.js";export{c as qualifiedTraceEvidence,a as trace,b as traceEvidence};
2
+ //# sourceMappingURL=trace-F4B6OLL4.js.map