scip-query 0.21.0 → 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (496) hide show
  1. package/CHANGELOG.md +72 -0
  2. package/dist/augment-vue-worker.js +1 -1
  3. package/dist/by-kind-4IYG2SKW.js +2 -0
  4. package/dist/call-graph-WQNXMNNN.js +2 -0
  5. package/dist/{chunk-AQDWTCDC.js → chunk-25GWKRUZ.js} +2 -2
  6. package/dist/chunk-2BTJALUS.js +454 -0
  7. package/dist/chunk-2KVU55CW.js +11 -0
  8. package/dist/{chunk-BBWPOMGU.js → chunk-2OXVP5U5.js} +2 -2
  9. package/dist/{chunk-D5W4UZY5.js → chunk-2RE5OCHZ.js} +2 -2
  10. package/dist/{chunk-2I3RSUWX.js → chunk-2XCGSDIT.js} +2 -2
  11. package/dist/{chunk-V7LQZTTZ.js → chunk-2YC7YNKT.js} +2 -2
  12. package/dist/chunk-3QXC54FQ.js +3 -0
  13. package/dist/{chunk-32A42O5B.js → chunk-3TJY6M3B.js} +2 -2
  14. package/dist/chunk-42W3LFUK.js +13 -0
  15. package/dist/chunk-44T4DUAA.js +2 -0
  16. package/dist/chunk-4GAQ6FI4.js +43 -0
  17. package/dist/{chunk-4S4DF62J.js → chunk-4HE7MVWD.js} +2 -2
  18. package/dist/{chunk-TGWNNMPF.js → chunk-4TQU4TX2.js} +2 -2
  19. package/dist/{chunk-SKUMCCC5.js → chunk-56NQAEPJ.js} +2 -2
  20. package/dist/chunk-57N6LN2A.js +3 -0
  21. package/dist/{chunk-LPGDO2XA.js → chunk-5H5WTJSD.js} +2 -2
  22. package/dist/{chunk-EA4SH4U5.js → chunk-5YRQIE2B.js} +2 -2
  23. package/dist/{chunk-O2RM7E7L.js → chunk-5ZMBRQFC.js} +4 -4
  24. package/dist/{chunk-ICHBVITH.js → chunk-6HRZQLOI.js} +2 -2
  25. package/dist/{chunk-WULAPQUD.js → chunk-6NC3YSPY.js} +2 -2
  26. package/dist/{chunk-IDPLC3FI.js → chunk-6VEFRPTD.js} +2 -2
  27. package/dist/{chunk-IOKWFRFQ.js → chunk-7C26EKLZ.js} +2 -2
  28. package/dist/{chunk-S3RTPPLQ.js → chunk-7IQXARSQ.js} +2 -2
  29. package/dist/chunk-7JYHQAH2.js +22 -0
  30. package/dist/chunk-7KSO2OAP.js +2 -0
  31. package/dist/{chunk-2ZBMOQGG.js → chunk-7U2YQSDE.js} +2 -2
  32. package/dist/{chunk-EKZRF57O.js → chunk-7XA3OM44.js} +2 -2
  33. package/dist/{chunk-4EXFZP6H.js → chunk-7XZGZBSQ.js} +2 -2
  34. package/dist/chunk-7YQOCABQ.js +2 -0
  35. package/dist/chunk-A77SCPW2.js +3 -0
  36. package/dist/chunk-AK3PYTIK.js +5 -0
  37. package/dist/chunk-AMIMMNA4.js +11 -0
  38. package/dist/{chunk-MOBF2GH6.js → chunk-AQ2PORIO.js} +2 -2
  39. package/dist/{chunk-YUFWLWIC.js → chunk-ARVO6TTW.js} +2 -2
  40. package/dist/chunk-AUY5BL74.js +2 -0
  41. package/dist/{chunk-RGCJ4646.js → chunk-AYPDH2LU.js} +2 -2
  42. package/dist/{chunk-73Z33VFI.js → chunk-AZS7YPCB.js} +2 -2
  43. package/dist/{chunk-SYUNTKO2.js → chunk-BDGTPN27.js} +2 -2
  44. package/dist/{chunk-BATIVRU2.js → chunk-BDHFVH2M.js} +2 -2
  45. package/dist/chunk-BECZLYNU.js +8 -0
  46. package/dist/chunk-BJT7LSPK.js +3 -0
  47. package/dist/{chunk-6SWA6B24.js → chunk-BTVKZGWT.js} +2 -2
  48. package/dist/{chunk-QD7IFBCR.js → chunk-BUTEIZKP.js} +2 -2
  49. package/dist/{chunk-UZFCZ7SJ.js → chunk-BVFYEEBH.js} +2 -2
  50. package/dist/{chunk-ICUQONOG.js → chunk-BWVQP3LB.js} +2 -2
  51. package/dist/chunk-BYDAFMSR.js +57 -0
  52. package/dist/{chunk-BHE44MHT.js → chunk-C76O5MDS.js} +2 -2
  53. package/dist/chunk-C7IJMOFP.js +134 -0
  54. package/dist/{chunk-CN2WGM7D.js → chunk-CBBHFNLX.js} +2 -2
  55. package/dist/{chunk-COTMS5KM.js → chunk-CKRWA452.js} +2 -2
  56. package/dist/{chunk-ANWGXPPN.js → chunk-CLG6DWVS.js} +2 -2
  57. package/dist/chunk-D2MVJSP4.js +21 -0
  58. package/dist/chunk-D35XIZGN.js +2 -0
  59. package/dist/{chunk-U7DR7MJD.js → chunk-DEAB5TGT.js} +2 -2
  60. package/dist/{chunk-6GJAP4OE.js → chunk-DJAO2OZJ.js} +2 -2
  61. package/dist/chunk-DKM723YF.js +79 -0
  62. package/dist/{chunk-4IIMPWMR.js → chunk-DPWKKNKI.js} +2 -2
  63. package/dist/chunk-E44IVWIJ.js +367 -0
  64. package/dist/chunk-EDMB6SSO.js +7 -0
  65. package/dist/{chunk-KWARB5FZ.js → chunk-EELG7D3Q.js} +2 -2
  66. package/dist/chunk-EELPBR7E.js +3 -0
  67. package/dist/chunk-EETGXQY7.js +3 -0
  68. package/dist/chunk-ENWQWA2R.js +2 -0
  69. package/dist/{chunk-HUZNZ3H2.js → chunk-ERCYGVAM.js} +2 -2
  70. package/dist/{chunk-WSG3DK5H.js → chunk-EWWY2ZFL.js} +2 -2
  71. package/dist/chunk-F24G5NBE.js +3 -0
  72. package/dist/{chunk-XRXCANFQ.js → chunk-F24QUEQP.js} +2 -2
  73. package/dist/{chunk-KFK7GF5C.js → chunk-FBCVASUG.js} +2 -2
  74. package/dist/{chunk-35IW3P4H.js → chunk-FELGD32K.js} +2 -2
  75. package/dist/{chunk-UNORWZIJ.js → chunk-FFJQZG6J.js} +5 -5
  76. package/dist/{chunk-5SE323LF.js → chunk-FGNCOQUX.js} +2 -2
  77. package/dist/chunk-FKGQOTKD.js +2 -0
  78. package/dist/chunk-GDRJB3SB.js +3 -0
  79. package/dist/chunk-GH5YSGZL.js +5 -0
  80. package/dist/{chunk-X7PJJYKX.js → chunk-GIQ6CSL4.js} +2 -2
  81. package/dist/{chunk-2RP27XLR.js → chunk-GPGRZJ3R.js} +2 -2
  82. package/dist/{chunk-IYV2YBHM.js → chunk-GQIDEID3.js} +2 -2
  83. package/dist/chunk-GRX7JOXQ.js +2 -0
  84. package/dist/{chunk-H46QMB7E.js → chunk-GVOMSPGL.js} +2 -2
  85. package/dist/{chunk-KTRGJLY7.js → chunk-GY7CCCEZ.js} +2 -2
  86. package/dist/{chunk-VNKYRJKN.js → chunk-H7CG6LOE.js} +2 -2
  87. package/dist/chunk-HCVJR2V4.js +3 -0
  88. package/dist/chunk-HG722PO7.js +3 -0
  89. package/dist/{chunk-LHTT5C3Z.js → chunk-HISEUIL2.js} +2 -2
  90. package/dist/{chunk-K5MZYZV7.js → chunk-HXOU4XNH.js} +2 -2
  91. package/dist/chunk-I6UTXNHU.js +6 -0
  92. package/dist/{chunk-I7PFL5P3.js → chunk-IJMD6BRI.js} +2 -2
  93. package/dist/{chunk-XXJ7WL3F.js → chunk-IKVNEGTW.js} +2 -2
  94. package/dist/chunk-IMKZEXZG.js +2 -0
  95. package/dist/chunk-ISIQLPJ2.js +61 -0
  96. package/dist/{chunk-DEUGHURX.js → chunk-ISWFRGJ6.js} +2 -2
  97. package/dist/chunk-IW5XQG5G.js +2 -0
  98. package/dist/chunk-IXESDH3J.js +2 -0
  99. package/dist/{chunk-FGB567HK.js → chunk-JAT6C3VX.js} +2 -2
  100. package/dist/{chunk-7TWP3MCP.js → chunk-JFQBRL3J.js} +2 -2
  101. package/dist/{chunk-Q7HB7BFJ.js → chunk-JHH5SCZ3.js} +2 -2
  102. package/dist/{chunk-ZHSARYVS.js → chunk-JJ62MTQH.js} +2 -2
  103. package/dist/chunk-JT6XX7QY.js +8 -0
  104. package/dist/{chunk-5H7IWVXJ.js → chunk-JUN5DOAK.js} +2 -2
  105. package/dist/{chunk-DOPCR5BY.js → chunk-K3XFWJI2.js} +2 -2
  106. package/dist/{chunk-Y4XQ7LES.js → chunk-KFOYCQAJ.js} +1 -1
  107. package/dist/{chunk-N5C65OFK.js → chunk-KFVSJX25.js} +2 -2
  108. package/dist/chunk-KK7GPALL.js +28 -0
  109. package/dist/{chunk-DHKBIOXF.js → chunk-KQHJEU6V.js} +2 -2
  110. package/dist/{chunk-WB6LGCFB.js → chunk-KZYID5KV.js} +2 -2
  111. package/dist/{chunk-KW6B5OL4.js → chunk-LO5JSW2C.js} +2 -2
  112. package/dist/{chunk-ZW44MCJM.js → chunk-LRI5OMPE.js} +2 -2
  113. package/dist/{chunk-HG5YI7PV.js → chunk-LXQUF2RP.js} +2 -2
  114. package/dist/{chunk-TM5XEDDR.js → chunk-MHIEP7EG.js} +2 -2
  115. package/dist/{chunk-FHV7NMFU.js → chunk-MSR2QRUE.js} +2 -2
  116. package/dist/chunk-N7FP5H5U.js +57 -0
  117. package/dist/{chunk-3653GTR7.js → chunk-NEIQPFBI.js} +2 -2
  118. package/dist/chunk-NK3JMP22.js +2 -0
  119. package/dist/{chunk-7IOAZRVL.js → chunk-NRBNAECH.js} +2 -2
  120. package/dist/{chunk-HGKEAP7F.js → chunk-NVSZNESQ.js} +2 -2
  121. package/dist/{chunk-R2MOKIVO.js → chunk-OJNK5ALA.js} +2 -2
  122. package/dist/{chunk-RFWAUHVW.js → chunk-OPSAW5DT.js} +2 -2
  123. package/dist/chunk-OTSPRVNW.js +2 -0
  124. package/dist/chunk-OXYAWIEA.js +2 -0
  125. package/dist/chunk-OZETODHH.js +2 -0
  126. package/dist/chunk-PBUH2P5S.js +3 -0
  127. package/dist/{chunk-QBANU5BQ.js → chunk-PIFTZEEM.js} +2 -2
  128. package/dist/{chunk-CKDOY6JA.js → chunk-PLJUQFQN.js} +2 -2
  129. package/dist/{chunk-JVZNWJBH.js → chunk-PLYUVM4F.js} +2 -2
  130. package/dist/chunk-PXXYQK55.js +2 -0
  131. package/dist/{chunk-WZQFY5S7.js → chunk-Q55NF3ZG.js} +2 -2
  132. package/dist/{chunk-OVPS2ILI.js → chunk-Q5TA4OY4.js} +2 -2
  133. package/dist/{chunk-OUB4J26T.js → chunk-Q6T2CAJL.js} +2 -2
  134. package/dist/chunk-Q7GBK5T7.js +81 -0
  135. package/dist/chunk-QKT4UI2Y.js +2 -0
  136. package/dist/{chunk-PIZY2GX6.js → chunk-QLBSG7U5.js} +2 -2
  137. package/dist/chunk-QWKHW6VZ.js +2 -0
  138. package/dist/{chunk-E7BJXRNV.js → chunk-R6M456QG.js} +2 -2
  139. package/dist/{chunk-MJNV7OCG.js → chunk-RDULNRSJ.js} +2 -2
  140. package/dist/{chunk-SSSJO4RG.js → chunk-RHHCLWQ6.js} +2 -2
  141. package/dist/chunk-RNKPYYYE.js +4 -0
  142. package/dist/{chunk-IXJ26KJJ.js → chunk-RPL3ARU7.js} +2 -2
  143. package/dist/{chunk-3EX7DNBC.js → chunk-RYOYJMGF.js} +2 -2
  144. package/dist/chunk-SB25YMEQ.js +2 -0
  145. package/dist/chunk-SV2LEFVM.js +2 -0
  146. package/dist/{chunk-ZBNL3QCY.js → chunk-SVHTMVA4.js} +3 -3
  147. package/dist/{chunk-6IEVHGWG.js → chunk-SWK4XPUS.js} +2 -2
  148. package/dist/chunk-T6QD2ZQB.js +43 -0
  149. package/dist/{chunk-VETXXOYU.js → chunk-TAYD3AE7.js} +2 -2
  150. package/dist/chunk-TD7VKJ2Y.js +117 -0
  151. package/dist/{chunk-UQ7XPRWU.js → chunk-TH6IC56G.js} +2 -2
  152. package/dist/{chunk-XVDMJMES.js → chunk-TKDNDQA7.js} +2 -2
  153. package/dist/{chunk-CSDDOUA4.js → chunk-TNG2FYS5.js} +2 -2
  154. package/dist/chunk-TQZV7KV4.js +2 -0
  155. package/dist/{chunk-AJVMVE7X.js → chunk-TUQIPUDS.js} +2 -2
  156. package/dist/chunk-TUSPIVZ3.js +4 -0
  157. package/dist/{chunk-ORBKAUCH.js → chunk-U2N2KE7A.js} +2 -2
  158. package/dist/{chunk-3PII3JI5.js → chunk-UAQ4T73O.js} +2 -2
  159. package/dist/{chunk-OFY4HTMI.js → chunk-UDY7MIAW.js} +2 -2
  160. package/dist/{chunk-WKPZCQLI.js → chunk-URSGGIZX.js} +2 -2
  161. package/dist/{chunk-UL4VJUMD.js → chunk-UT7TADJX.js} +2 -2
  162. package/dist/chunk-V4NG5OMS.js +554 -0
  163. package/dist/{chunk-2H4IAJHO.js → chunk-VMWUV6WB.js} +2 -2
  164. package/dist/{chunk-46JLFIGA.js → chunk-VTCIYFEK.js} +2 -2
  165. package/dist/chunk-VU6LIWHT.js +2 -0
  166. package/dist/chunk-VUSKPCUB.js +2 -0
  167. package/dist/{chunk-URMZLV2N.js → chunk-VXJJTQYE.js} +2 -2
  168. package/dist/{chunk-IPAL6DP2.js → chunk-VZ7NXSHV.js} +2 -2
  169. package/dist/{chunk-FUG6RPYY.js → chunk-WHADK6OS.js} +2 -2
  170. package/dist/chunk-WN3TCGJ4.js +2 -0
  171. package/dist/{chunk-B7ECWJAZ.js → chunk-WOOAY3PA.js} +2 -2
  172. package/dist/chunk-WRQXLNYE.js +9 -0
  173. package/dist/chunk-WSLEJSFR.js +2 -0
  174. package/dist/chunk-WYZIHUPZ.js +16 -0
  175. package/dist/{chunk-ZYREOING.js → chunk-XE33FV5W.js} +2 -2
  176. package/dist/chunk-XFMVKFSF.js +2 -0
  177. package/dist/{chunk-BBEDPVPB.js → chunk-XGGBK66W.js} +2 -2
  178. package/dist/{chunk-OFUBXBYX.js → chunk-XJX6LGHL.js} +2 -2
  179. package/dist/{chunk-Z3GCK3PD.js → chunk-XN22RGSR.js} +2 -2
  180. package/dist/{chunk-HWLCBKFE.js → chunk-XSWYJCAK.js} +2 -2
  181. package/dist/{chunk-IGKKTHJR.js → chunk-XU75YQN4.js} +2 -2
  182. package/dist/{chunk-E4EJBGDZ.js → chunk-Y2VM4CJC.js} +2 -2
  183. package/dist/{chunk-U7LRSQG6.js → chunk-Y334QQU5.js} +2 -2
  184. package/dist/{chunk-APLKXICZ.js → chunk-YAGYMBEX.js} +2 -2
  185. package/dist/{chunk-XITQLISP.js → chunk-YIHNPKWD.js} +2 -2
  186. package/dist/chunk-YXPUP5G2.js +11 -0
  187. package/dist/{chunk-6BJ7SOY7.js → chunk-Z2AWCTN6.js} +2 -2
  188. package/dist/{chunk-PHSPBQM6.js → chunk-Z2PZVKPR.js} +2 -2
  189. package/dist/{chunk-QXR5QPSF.js → chunk-ZAZGGSM3.js} +2 -2
  190. package/dist/{chunk-5236NQV3.js → chunk-ZGW4HLPD.js} +2 -2
  191. package/dist/chunk-ZOXKSQQB.js +2 -0
  192. package/dist/{chunk-BD6CV7PN.js → chunk-ZPASRBLF.js} +2 -2
  193. package/dist/{chunk-DMUGTKMD.js → chunk-ZYM4HOFA.js} +2 -2
  194. package/dist/{chunk-4ILHWBYF.js → chunk-ZZ3Z7D56.js} +2 -2
  195. package/dist/cli-main.js +4 -4
  196. package/dist/{code-CczEvHui.d.ts → code-B17qEMbt.d.ts} +1 -1
  197. package/dist/code-EQJFDT6I.js +2 -0
  198. package/dist/code-result-json-7UWIWBOO.js +2 -0
  199. package/dist/command-descriptors-ORNTVNYV.js +342 -0
  200. package/dist/{config-types-Cm-VSEBb.d.ts → config-types-B9B60MiR.d.ts} +10 -0
  201. package/dist/dataflow-6VL54GX5.js +2 -0
  202. package/dist/{db-LKJXAlNS.d.ts → db-BwIVAYNB.d.ts} +1 -1
  203. package/dist/dependence-slice-DT2NUHD2.js +2 -0
  204. package/dist/deps-DB7H5IKC.js +2 -0
  205. package/dist/direct-navigation-O3LUAYWQ.js +3 -0
  206. package/dist/entry-map-6K62RV3D.js +2 -0
  207. package/dist/files-MSLD7MO6.js +2 -0
  208. package/dist/{graph-evidence-CbUPCSKV.d.ts → graph-evidence-Bjyky2V4.d.ts} +1 -1
  209. package/dist/{health-Wl5G_LRt.d.ts → health-CPp2Jf1Z.d.ts} +1 -1
  210. package/dist/hierarchy-IVBXAKFA.js +2 -0
  211. package/dist/imports-FRAVZ3Y2.js +2 -0
  212. package/dist/index.d.ts +2 -2
  213. package/dist/index.js +1 -1
  214. package/dist/members-KJOJDYGO.js +2 -0
  215. package/dist/methods-2AYABBT3.js +2 -0
  216. package/dist/output-continuation-command-JHMPH6NC.js +3 -0
  217. package/dist/{output-pagination-VAWOGX4R.js → output-pagination-3OFL2MJV.js} +2 -2
  218. package/dist/project-reindex-HYO4WD7Z.js +3 -0
  219. package/dist/queries/affected.d.ts +2 -2
  220. package/dist/queries/affected.js +1 -1
  221. package/dist/queries/anchors.d.ts +2 -2
  222. package/dist/queries/anchors.js +1 -1
  223. package/dist/queries/architecture.d.ts +2 -2
  224. package/dist/queries/architecture.js +1 -1
  225. package/dist/queries/bottlenecks.d.ts +2 -2
  226. package/dist/queries/bottlenecks.js +1 -1
  227. package/dist/queries/by-kind.d.ts +2 -2
  228. package/dist/queries/by-kind.js +1 -1
  229. package/dist/queries/call-graph.d.ts +2 -2
  230. package/dist/queries/call-graph.js +1 -1
  231. package/dist/queries/change-surface.d.ts +2 -2
  232. package/dist/queries/change-surface.js +1 -1
  233. package/dist/queries/cleanup-plan.d.ts +2 -2
  234. package/dist/queries/cleanup-plan.js +1 -1
  235. package/dist/queries/co-change.d.ts +2 -2
  236. package/dist/queries/co-change.js +1 -1
  237. package/dist/queries/code.d.ts +3 -3
  238. package/dist/queries/code.js +1 -1
  239. package/dist/queries/complexity-hotspots.d.ts +2 -2
  240. package/dist/queries/complexity-hotspots.js +1 -1
  241. package/dist/queries/complexity.d.ts +13 -2
  242. package/dist/queries/complexity.js +1 -1
  243. package/dist/queries/context.d.ts +2 -2
  244. package/dist/queries/context.js +1 -1
  245. package/dist/queries/convergence.d.ts +2 -2
  246. package/dist/queries/convergence.js +1 -1
  247. package/dist/queries/coupling.d.ts +2 -2
  248. package/dist/queries/coupling.js +1 -1
  249. package/dist/queries/cycles.d.ts +2 -2
  250. package/dist/queries/cycles.js +1 -1
  251. package/dist/queries/dataflow.d.ts +2 -2
  252. package/dist/queries/dataflow.js +1 -1
  253. package/dist/queries/dead.d.ts +2 -2
  254. package/dist/queries/dead.js +1 -1
  255. package/dist/queries/decorative-checkers.d.ts +2 -2
  256. package/dist/queries/decorative-checkers.js +1 -1
  257. package/dist/queries/deep-chains.d.ts +2 -2
  258. package/dist/queries/deep-chains.js +1 -1
  259. package/dist/queries/dependence-slice.d.ts +3 -3
  260. package/dist/queries/dependence-slice.js +1 -1
  261. package/dist/queries/dependency-depth.d.ts +2 -2
  262. package/dist/queries/dependency-depth.js +1 -1
  263. package/dist/queries/deps.d.ts +2 -2
  264. package/dist/queries/deps.js +1 -1
  265. package/dist/queries/diff-impact.d.ts +2 -2
  266. package/dist/queries/diff-impact.js +1 -1
  267. package/dist/queries/doc-drift.d.ts +2 -2
  268. package/dist/queries/doc-drift.js +1 -1
  269. package/dist/queries/drift.d.ts +2 -2
  270. package/dist/queries/drift.js +1 -1
  271. package/dist/queries/duplicate-bodies.d.ts +2 -2
  272. package/dist/queries/duplicate-bodies.js +1 -1
  273. package/dist/queries/entry-map.d.ts +2 -2
  274. package/dist/queries/entry-map.js +1 -1
  275. package/dist/queries/evidence.d.ts +3 -3
  276. package/dist/queries/evidence.js +1 -1
  277. package/dist/queries/extract-candidates.d.ts +2 -2
  278. package/dist/queries/extract-candidates.js +1 -1
  279. package/dist/queries/fan.d.ts +2 -2
  280. package/dist/queries/fan.js +1 -1
  281. package/dist/queries/files.d.ts +2 -2
  282. package/dist/queries/files.js +1 -1
  283. package/dist/queries/health.d.ts +3 -3
  284. package/dist/queries/health.js +1 -1
  285. package/dist/queries/hierarchy.d.ts +2 -2
  286. package/dist/queries/hierarchy.js +1 -1
  287. package/dist/queries/hotspots.d.ts +2 -2
  288. package/dist/queries/hotspots.js +1 -1
  289. package/dist/queries/imports.d.ts +2 -2
  290. package/dist/queries/imports.js +1 -1
  291. package/dist/queries/incomplete-migration.d.ts +2 -2
  292. package/dist/queries/incomplete-migration.js +1 -1
  293. package/dist/queries/index.d.ts +5 -5
  294. package/dist/queries/index.js +1 -1
  295. package/dist/queries/isolated.d.ts +2 -2
  296. package/dist/queries/isolated.js +1 -1
  297. package/dist/queries/locality-candidates.d.ts +2 -2
  298. package/dist/queries/locality-candidates.js +1 -1
  299. package/dist/queries/members.d.ts +2 -2
  300. package/dist/queries/members.js +1 -1
  301. package/dist/queries/methods.d.ts +2 -2
  302. package/dist/queries/methods.js +1 -1
  303. package/dist/queries/not-implemented.d.ts +2 -2
  304. package/dist/queries/not-implemented.js +1 -1
  305. package/dist/queries/outline.d.ts +2 -2
  306. package/dist/queries/outline.js +1 -1
  307. package/dist/queries/passthrough-candidates.d.ts +2 -2
  308. package/dist/queries/passthrough-candidates.js +1 -1
  309. package/dist/queries/plan-context.d.ts +2 -2
  310. package/dist/queries/plan-context.js +1 -1
  311. package/dist/queries/react-component-duplicates.d.ts +2 -2
  312. package/dist/queries/react-component-duplicates.js +1 -1
  313. package/dist/queries/react-hook-candidates.d.ts +2 -2
  314. package/dist/queries/react-hook-candidates.js +1 -1
  315. package/dist/queries/react-large-component-pressure.d.ts +2 -2
  316. package/dist/queries/react-large-component-pressure.js +1 -1
  317. package/dist/queries/recent-duplicates.d.ts +2 -2
  318. package/dist/queries/recent-duplicates.js +1 -1
  319. package/dist/queries/redundant-reexports.d.ts +2 -2
  320. package/dist/queries/redundant-reexports.js +1 -1
  321. package/dist/queries/reference-neighborhood.d.ts +2 -2
  322. package/dist/queries/reference-neighborhood.js +1 -1
  323. package/dist/queries/reference-reachability.d.ts +2 -2
  324. package/dist/queries/reference-reachability.js +1 -1
  325. package/dist/queries/refs.d.ts +2 -2
  326. package/dist/queries/refs.js +1 -1
  327. package/dist/queries/self-audit.d.ts +2 -2
  328. package/dist/queries/self-audit.js +1 -1
  329. package/dist/queries/similar-chains.d.ts +2 -2
  330. package/dist/queries/similar-chains.js +1 -1
  331. package/dist/queries/similar-files.d.ts +2 -2
  332. package/dist/queries/similar-files.js +1 -1
  333. package/dist/queries/similar-signatures.d.ts +2 -2
  334. package/dist/queries/similar-signatures.js +1 -1
  335. package/dist/queries/similar.d.ts +2 -2
  336. package/dist/queries/similar.js +1 -1
  337. package/dist/queries/slice.d.ts +2 -2
  338. package/dist/queries/slice.js +1 -1
  339. package/dist/queries/source-inspection.d.ts +4 -4
  340. package/dist/queries/source-inspection.js +1 -1
  341. package/dist/queries/source-search.d.ts +2 -2
  342. package/dist/queries/source-search.js +1 -1
  343. package/dist/queries/stale-abstractions.d.ts +2 -2
  344. package/dist/queries/stale-abstractions.js +1 -1
  345. package/dist/queries/stats.d.ts +2 -2
  346. package/dist/queries/surface.d.ts +2 -2
  347. package/dist/queries/surface.js +1 -1
  348. package/dist/queries/symbols.d.ts +2 -2
  349. package/dist/queries/symbols.js +1 -1
  350. package/dist/queries/system-map.d.ts +2 -2
  351. package/dist/queries/system-map.js +1 -1
  352. package/dist/queries/system.d.ts +2 -2
  353. package/dist/queries/system.js +1 -1
  354. package/dist/queries/test-quality.d.ts +2 -2
  355. package/dist/queries/test-quality.js +1 -1
  356. package/dist/queries/trace.d.ts +2 -2
  357. package/dist/queries/trace.js +1 -1
  358. package/dist/queries/twin-ab.d.ts +2 -2
  359. package/dist/queries/twin-ab.js +1 -1
  360. package/dist/queries/twin-drift.d.ts +2 -2
  361. package/dist/queries/twin-drift.js +1 -1
  362. package/dist/queries/unused-imports.d.ts +2 -2
  363. package/dist/queries/unused-imports.js +1 -1
  364. package/dist/queries/unused-params.d.ts +2 -2
  365. package/dist/queries/unused-params.js +1 -1
  366. package/dist/queries/value-flow.d.ts +3 -3
  367. package/dist/queries/value-flow.js +1 -1
  368. package/dist/queries/vue-component-duplicates.d.ts +2 -2
  369. package/dist/queries/vue-component-duplicates.js +1 -1
  370. package/dist/queries/vue-composable-candidates.d.ts +2 -2
  371. package/dist/queries/vue-composable-candidates.js +1 -1
  372. package/dist/queries/vue-large-view-pressure.d.ts +2 -2
  373. package/dist/queries/vue-large-view-pressure.js +1 -1
  374. package/dist/queries/wrapper-candidates.d.ts +2 -2
  375. package/dist/queries/wrapper-candidates.js +1 -1
  376. package/dist/query-service-fastpath.js +5 -5
  377. package/dist/query-service-server.js +2 -2
  378. package/dist/refs-ARMA6XUJ.js +2 -0
  379. package/dist/refs-pagination-VUGIWN6U.js +2 -0
  380. package/dist/reindex-worker.js +125 -66
  381. package/dist/reindex.d.ts +5 -3
  382. package/dist/reindex.js +135 -76
  383. package/dist/runtime.d.ts +5 -5
  384. package/dist/runtime.js +4 -4
  385. package/dist/rust-semantic-session-server.js +1 -1
  386. package/dist/rust-semantic-session-worker.js +1 -1
  387. package/dist/rust-semantic-worker.js +1 -1
  388. package/dist/{scip-cli-CppzF5MK.d.ts → scip-cli-H-n59izO.d.ts} +1 -1
  389. package/dist/slice-YOB5YFAM.js +2 -0
  390. package/dist/surface-VY5EFWTW.js +2 -0
  391. package/dist/symbol-resolution-DGQN4XIV.js +2 -0
  392. package/dist/system-2KQ3QD2P.js +2 -0
  393. package/dist/trace-HTIPTXAE.js +2 -0
  394. package/dist/typescript-mailbox-worker.js +1 -1
  395. package/dist/value-flow-5FV3VQI7.js +2 -0
  396. package/dist/watch-server.js +3 -3
  397. package/docs/CLI_JSON_OUTPUT.md +2 -2
  398. package/docs/COMMAND_REFERENCE.md +2 -2
  399. package/docs/schemas/project-config.schema.json +11 -1
  400. package/package.json +6 -5
  401. package/skills/scip-explore/SKILL.md +73 -3
  402. package/skills/scip-explore/agents/openai.yaml +3 -3
  403. package/skills/scip-explore/references/delegated-exploration.md +51 -0
  404. package/skills/scip-explore/references/external-evidence.md +72 -0
  405. package/skills/scip-explore/references/information-model.md +51 -0
  406. package/skills/scip-explore/scripts/capture-evidence.mjs +666 -0
  407. package/skills/scip-query/SKILL.md +22 -1
  408. package/dist/by-kind-CI3O6PQG.js +0 -2
  409. package/dist/call-graph-6QTUTXH7.js +0 -2
  410. package/dist/chunk-2COFMIVK.js +0 -60
  411. package/dist/chunk-35ELD3RM.js +0 -2
  412. package/dist/chunk-3FQ3KMCD.js +0 -2
  413. package/dist/chunk-3VLJ2DCA.js +0 -2
  414. package/dist/chunk-4DCKBY6T.js +0 -5
  415. package/dist/chunk-4N6QSEMZ.js +0 -10
  416. package/dist/chunk-4OE2JO6I.js +0 -2
  417. package/dist/chunk-4UUCUASK.js +0 -554
  418. package/dist/chunk-54EOGFBR.js +0 -2
  419. package/dist/chunk-5IZTXSOL.js +0 -117
  420. package/dist/chunk-5ZJH6DDE.js +0 -2
  421. package/dist/chunk-63MBA7EG.js +0 -3
  422. package/dist/chunk-6T7H2AFY.js +0 -3
  423. package/dist/chunk-7COHFNJK.js +0 -38
  424. package/dist/chunk-7HU2IJ2T.js +0 -3
  425. package/dist/chunk-7PPYXENX.js +0 -2
  426. package/dist/chunk-AA7K3XLM.js +0 -21
  427. package/dist/chunk-AUP6YI5M.js +0 -2
  428. package/dist/chunk-CA5RE6H7.js +0 -2
  429. package/dist/chunk-CT5SI2I4.js +0 -2
  430. package/dist/chunk-D5EKVZPI.js +0 -2
  431. package/dist/chunk-DMQ7ZKJG.js +0 -81
  432. package/dist/chunk-ELNRLMC5.js +0 -29
  433. package/dist/chunk-F7WQ337U.js +0 -308
  434. package/dist/chunk-FEQIQ26E.js +0 -2
  435. package/dist/chunk-FN6EJM6Q.js +0 -2
  436. package/dist/chunk-FTSQNONX.js +0 -2
  437. package/dist/chunk-G2F6T5BV.js +0 -2
  438. package/dist/chunk-G6OGPXJW.js +0 -9
  439. package/dist/chunk-GFLTPNWV.js +0 -3
  440. package/dist/chunk-GTDP2SKQ.js +0 -2
  441. package/dist/chunk-HEOMG7IM.js +0 -8
  442. package/dist/chunk-I3U2FN2T.js +0 -13
  443. package/dist/chunk-IUJ3ZFEE.js +0 -7
  444. package/dist/chunk-LXLD46LH.js +0 -21
  445. package/dist/chunk-MEI3PTUK.js +0 -2
  446. package/dist/chunk-MO226P4Q.js +0 -4
  447. package/dist/chunk-MYUKI5VN.js +0 -4
  448. package/dist/chunk-OIRWZIYL.js +0 -38
  449. package/dist/chunk-OIVZ7PW6.js +0 -438
  450. package/dist/chunk-PNISDVYC.js +0 -3
  451. package/dist/chunk-PQOL42AW.js +0 -2
  452. package/dist/chunk-PUVZNFVY.js +0 -11
  453. package/dist/chunk-PZEI2TVL.js +0 -4
  454. package/dist/chunk-Q2J2VZZT.js +0 -2
  455. package/dist/chunk-QDCCHMVZ.js +0 -2
  456. package/dist/chunk-QLQBZOJH.js +0 -3
  457. package/dist/chunk-S73HBCGI.js +0 -11
  458. package/dist/chunk-SDPA5DKN.js +0 -210
  459. package/dist/chunk-SEUJVWT2.js +0 -3
  460. package/dist/chunk-SF7X6QNW.js +0 -2
  461. package/dist/chunk-SWFAFA4G.js +0 -49
  462. package/dist/chunk-T6FRID7Y.js +0 -3
  463. package/dist/chunk-TNOHGHZQ.js +0 -2
  464. package/dist/chunk-U2GPTA5U.js +0 -3
  465. package/dist/chunk-URTX2BEA.js +0 -6
  466. package/dist/chunk-VGRUM7JI.js +0 -3
  467. package/dist/chunk-VWLIOEEF.js +0 -11
  468. package/dist/chunk-WK4FD4PG.js +0 -2
  469. package/dist/chunk-X434XZAI.js +0 -2
  470. package/dist/chunk-YIEFEPG6.js +0 -16
  471. package/dist/chunk-YRVERHJR.js +0 -49
  472. package/dist/chunk-ZD3Z54IW.js +0 -2
  473. package/dist/chunk-ZDVDSDFG.js +0 -4
  474. package/dist/code-EQL6ZBLH.js +0 -2
  475. package/dist/code-result-json-6E4J6LGZ.js +0 -2
  476. package/dist/command-descriptors-QH3G2OVD.js +0 -346
  477. package/dist/dataflow-2BLMUZBP.js +0 -2
  478. package/dist/dependence-slice-MGAJDZXB.js +0 -2
  479. package/dist/deps-GQMUYVKW.js +0 -2
  480. package/dist/direct-navigation-6RUJKLAV.js +0 -3
  481. package/dist/entry-map-V2NQP5JU.js +0 -2
  482. package/dist/files-VM53I4IU.js +0 -2
  483. package/dist/hierarchy-D553WRSZ.js +0 -2
  484. package/dist/imports-DOZAJWLW.js +0 -2
  485. package/dist/members-HE67475K.js +0 -2
  486. package/dist/methods-K5JK4PPH.js +0 -2
  487. package/dist/output-continuation-command-LKBUTNRL.js +0 -3
  488. package/dist/project-reindex-4ARU6QCM.js +0 -3
  489. package/dist/refs-NBHKL4UQ.js +0 -2
  490. package/dist/refs-pagination-BBVTIHMH.js +0 -2
  491. package/dist/slice-U6S6LBSB.js +0 -2
  492. package/dist/surface-C7SS5CDQ.js +0 -2
  493. package/dist/symbol-resolution-3FVEKDTJ.js +0 -2
  494. package/dist/system-6K2NOO5C.js +0 -2
  495. package/dist/trace-II5K2TMH.js +0 -2
  496. package/dist/value-flow-MKFUUE5B.js +0 -2
@@ -1,4 +1,4 @@
1
- import{b as Ke,c as Qe,f as ht,i as pt,j as re,k as ft,l as Te}from"./chunk-IUJ3ZFEE.js";import{b as Ct}from"./chunk-ZD3Z54IW.js";import{b as ie,c as vt,d as Rt,g as bt}from"./chunk-5ZJH6DDE.js";import{a as We,b as Pt,c as Wt,d as Et,e as Ee,f as Mt,g as Me,h as At,i as Lt,j as _t,k as Gt,l as Dt,m as jt,n as Ot}from"./chunk-G2F6T5BV.js";import{a as It}from"./chunk-MXNGIEPU.js";import{a as wt,c as ne}from"./chunk-UZFCZ7SJ.js";import"./chunk-Q7HB7BFJ.js";import{d as U,e as se,f as Ce,g as xt}from"./chunk-MEI3PTUK.js";import"./chunk-DHEQMPLW.js";import{a as oe,b as kt,c as Pe,d as Tt}from"./chunk-SEUJVWT2.js";import{z as mt}from"./chunk-AUP6YI5M.js";import{c as ct,d as we,q as lt}from"./chunk-SF7X6QNW.js";import{d as dt}from"./chunk-SDPA5DKN.js";import{a as ve}from"./chunk-DOPCR5BY.js";import{a as ut}from"./chunk-7IOAZRVL.js";import"./chunk-VWLIOEEF.js";import{a as M,g as be,q as gt,r as yt,s as Ie,t as xe,u as ke,v as St}from"./chunk-G6OGPXJW.js";import"./chunk-DRENNWRG.js";import"./chunk-H5EXS3HM.js";import"./chunk-HGFDYOVB.js";import{c as P,d as W}from"./chunk-3VLJ2DCA.js";import{E as et,F as B,G as tt,I as rt,J as te,L as $,O as it,P as nt,S as st,T as ot,U as Re,V as at,h as b,l as Ze}from"./chunk-4DCKBY6T.js";import v from"process";import{rmSync as yr}from"fs";import{resolve as Ri}from"path";import{pathToFileURL as wi}from"url";import{lstatSync as vr}from"fs";function Nt(t,e){let r=ae(t);if(r.kind!=="directory")throw new Error(`Watcher root is not a directory: ${t}`);if(!e)return{projectRoot:t,projectDirectory:r};let i=ae(e);if(i.kind!=="directory")throw new Error(`Git control path is not a directory: ${e}`);return{projectRoot:t,projectDirectory:r,gitControlDirectory:{path:e,identity:i}}}function qt(t){try{if(!Ft(t.projectDirectory,ae(t.projectRoot)))return!1;let e=t.gitControlDirectory;return!e||Ft(e.identity,ae(e.path))}catch{return!1}}function ae(t){let e=vr(t,{bigint:!0}),r=e.isDirectory()?"directory":e.isFile()?"file":void 0;if(!r||e.isSymbolicLink())throw new Error(`Unsupported watcher identity path: ${t}`);return{device:e.dev,inode:e.ino,birthtimeNs:e.birthtimeNs,kind:r}}function Ft(t,e){return t.device===e.device&&t.inode===e.inode&&t.birthtimeNs===e.birthtimeNs&&t.kind===e.kind}import{existsSync as Qt,lstatSync as wr,statSync as br}from"fs";import{basename as Ir,dirname as xr,isAbsolute as Le,join as T,relative as Zt,resolve as er}from"path";import{watch as kr}from"chokidar";import Tr from"ignore";var tr=5e3,le=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(e){this.projectRoot=e.projectRoot,this.config=e.config,this.watchConfig=se(e.config),this.outputDb=e.outputDb??T(et(this.projectRoot,e.config),"index.db"),this.preferFilesystemGitState=e.gitReader===void 0,this.localCacheWatchPath=Jr(this.projectRoot,xr(this.outputDb)),this.languages=e.languages,this.pnpmWorkspaces=e.config.indexer?.typescript?.pnpmWorkspaces??!1,this.typescriptProjectMode=e.config.indexer?.typescript?.projectMode,this.typescriptProjects=e.config.indexer?.typescript?.projects,this.clojureConfigPath=e.config.indexer?.clojure?.configPath,this.indexerConcurrency=e.config.indexerConcurrency,this.onStatus=e.onStatus??(()=>{}),this.onReindexComplete=e.onReindexComplete??(()=>{}),this.onReindexError=e.onReindexError??(()=>{}),this.onRefreshSuppressed=e.onRefreshSuppressed??(()=>{}),this.onError=e.onError??(r=>console.error(r.message)),this.clock=e.clock??Mr,rr.set(this,Vr(e.stopTimeoutMs??tr,"watcher stop timeout")),this.reindexRunner=e.reindexRunner??jr(),this.subscriptionFactory=e.subscriptionFactory??Ar,this.budgetInspector=e.budgetInspector??ft,ir.set(this,{gitReader:e.gitReader??it,languages:nr(e.languages??e.config.languages),stagedIndexEntries:null}),this.gitignoreFilter=ut(e.projectRoot),this.extraIgnore=Tr(),this.watchConfig.ignore.length>0&&this.extraIgnore.add(this.watchConfig.ignore)}start(){if(this.stopInProgress)throw new Error("Cannot restart a watcher while its previous ownership is still draining.");this.stopped=!1,this.stopPromise=null,ce(this).errors=[],this.sourcePollingFallbackStarted=!1,this.setStatus({state:"idle"}),this.startGitStatePolling();try{this.startSourceWatcher()}catch(e){this.onError(new Error(`Failed to watch ${this.projectRoot}: ${String(e)}`))}}stop(){if(this.stopPromise)return this.stopPromise;this.stopped=!0,this.stopInProgress=!0;let e=this.fsWatchers;this.fsWatchers=[],this.clearDebounceTimer(),this.clearCooldownTimer(),this.clearBudgetTimer(),this.clearGitPollTimer();let r=this.activeOperation;r&&this.setStatus({state:"draining",startedAt:this.wallNow(),reason:"waiting for the active reindex worker to exit"});let i=[...ce(this).closures],n=Pr(this),o=this.clock.now()+n;return this.stopPromise=this.finishStop(e,i,r,o,n).catch(c=>{throw this.stopInProgress=!1,c}),this.stopPromise}requestRefresh(e,r={}){if(!this.stopped){if(this.markPendingChangesIncomplete(`unstructured-trigger:${e.kind}`),!r.immediate||this.reindexInFlight||this.status.state==="cooldown"||this.status.state==="budget-paused"){this.scheduleReindex(e);return}this.pendingTrigger=Jt(this.pendingTrigger,e),this.changedFiles+=1,this.clearDebounceTimer(),this.triggerReindex()}}startSourceWatcher(e=!1){let r=this.subscriptionFactory(this.projectRoot,{ignoreInitial:!0,ignored:(i,n)=>this.isIgnoredWatchPath(i,n?.isDirectory()??!1),usePolling:e,ignorePermissionErrors:!0,...e?{interval:5e3,binaryInterval:1e4}:{}});r.on("all",(i,n)=>{!this.stopped&&i!=="addDir"&&i!=="unlinkDir"&&this.handleFileChange(i,n)}),r.on("error",i=>this.handleSourceWatcherError(r,i,e)),this.fsWatchers.push(r)}handleSourceWatcherError(e,r,i){if(this.markPendingChangesIncomplete("source-watcher-error"),i||this.sourcePollingFallbackStarted||!Nr(r)||this.stopped){this.onError(new Error(`Failed to watch ${this.projectRoot}: ${String(r)}`));return}this.sourcePollingFallbackStarted=!0,this.fsWatchers=this.fsWatchers.filter(n=>n!==e),Wr(ce(this),e,n=>this.onError(n));try{this.startSourceWatcher(!0)}catch(n){this.onError(new Error(`Failed to watch ${this.projectRoot}: ${String(n)}`))}}isIgnoredWatchPath(e,r){let i=this.relativeWatchPath(e);if(!i)return!1;if(Vt(i,this.localCacheWatchPath))return!0;let n=r?`${i}/`:i;return this.gitignoreFilter.isIgnored(n)||this.extraIgnore.ignores(n)}handleFileChange(e,r){let i=this.relativeWatchPath(r);if(!i||i===".."||i.startsWith("../")||Vt(i,this.localCacheWatchPath)||this.gitignoreFilter.isIgnored(i)||this.extraIgnore.ignores(i)||i.endsWith("index.db")||i.endsWith("index.scip")||i.endsWith("index.db.tmp")||Ir(i).startsWith(ht)||(i===".scipquery.json"&&Xt(this,this.projectRoot),!Yt(this,i)))return;let n=Or(e);n||this.markPendingChangesIncomplete(`unsupported-source-event:${e}`),this.scheduleReindex({kind:"watch-source",detail:i},n?[{path:i,kind:n}]:void 0,n!==void 0)}relativeWatchPath(e){let r=Le(e)?e:T(this.projectRoot,e);return Zt(this.projectRoot,r).replaceAll("\\","/")}scheduleReindex(e,r,i=!1){this.pendingTrigger=Jt(this.pendingTrigger,e),i||this.markPendingChangesIncomplete(`unstructured-trigger:${e.kind}`);for(let o of r??[])this.recordPendingChange(o);if(this.changedFiles++,this.reindexInFlight){this.dirty=!0,this.setStatus({state:"indexing",startedAt:this.status.startedAt});return}if(this.status.state==="cooldown"){this.dirty=!0,this.setStatus({state:"cooldown",until:this.status.until,dirty:!0});return}if(this.status.state==="budget-paused"){this.dirty=!0,this.setStatus({...this.status,dirty:!0});return}this.clearDebounceTimer();let n=this.wallNow()+this.watchConfig.debounceMs;this.setStatus({state:"waiting",changedFiles:this.changedFiles,reindexAt:n}),this.debounceTimer=this.clock.setTimeout(()=>{this.debounceTimer=null,this.triggerReindex()},this.watchConfig.debounceMs)}triggerReindex(){if(this.reindexInFlight||this.stopped)return;let e=this.inspectBudget(),r=e.state!=="paused";if(e.state==="paused"&&e.reason!=="rebuild-count"){this.dirty=!0;let l=Math.max(this.wallNow()+1,e.until);this.setStatus({state:"budget-paused",until:l,dirty:!0,reason:e.detail,rebuilt:e.rebuilt,estimatedWriteBytes:e.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,l-this.wallNow())));return}let i=this.clock.now()-this.lastReindexEnd;if(this.lastReindexEnd>0&&i<this.watchConfig.cooldownMs){let l=this.watchConfig.cooldownMs-i;this.dirty=!0;let a=this.wallNow()+l;this.setStatus({state:"cooldown",until:a,dirty:!0}),this.cooldownTimer=this.clock.setTimeout(()=>{this.cooldownTimer=null,this.dirty&&!this.stopped&&(this.dirty=!1,this.triggerReindex())},l);return}this.reindexInFlight=!0,this.dirty=!1,this.changedFiles=0;let n=this.pendingTrigger??{kind:"watch-source"};this.pendingTrigger=null;let o=this.consumePendingChangeJournal(),c=this.wallNow();this.setStatus({state:"indexing",startedAt:c});let s=this.reindexRunner.start(this.reindexRequest(n,r,o));this.activeOperation=s,s.completion.then(l=>{if(this.reindexInFlight=!1,this.lastReindexEnd=this.clock.now(),this.stopped)return;let a=!1;try{a=this.onReindexComplete(l,n,{pendingChanges:this.dirty})===!0}catch(u){this.onError(u instanceof Error?u:new Error(String(u)))}if(this.dirty&&!this.stopped){if(a){let d=this.pendingTrigger??{kind:"unknown"};this.dirty=!1,this.changedFiles=0,this.pendingTrigger=null,this.resetPendingChanges(),this.onRefreshSuppressed(d),this.setStatus({state:"idle"});return}let u=this.wallNow()+this.watchConfig.cooldownMs;this.setStatus({state:"cooldown",until:u,dirty:!0}),this.cooldownTimer=this.clock.setTimeout(()=>{this.cooldownTimer=null,this.dirty&&!this.stopped?(this.dirty=!1,this.triggerReindex()):this.setStatus({state:"idle"})},this.watchConfig.cooldownMs)}else this.setStatus({state:"idle"})}).catch(l=>{if(this.reindexInFlight=!1,this.lastReindexEnd=this.clock.now(),this.stopped)return;let a=l instanceof Error?l:new Error(String(l));this.restorePendingChangeJournal(o),this.onReindexError(a,n),this.onError(a),this.setStatus({state:"idle"})}).finally(()=>{this.activeOperation===s&&(this.activeOperation=null)})}async finishStop(e,r,i,n,o){let c=[],s=e.map(async p=>{try{await p.close()}catch(h){c.push(`watch subscription close failed: ${String(h)}`)}});s.push(...r),i&&s.push((async()=>{try{let p=await i.cancel();p.state==="degraded"&&c.push(p.reason)}catch(p){c.push(`reindex cancellation failed: ${p instanceof Error?p.message:String(p)}`)}})());let l=s.length,a=s.map(p=>p.finally(()=>{l-=1})),u=await Cr(a,n,this.clock),d=ce(this);return c.push(...d.errors),d.errors=[],u?this.stopInProgress=!1:(c.push(`watch shutdown exceeded the ${o}ms deadline with ${l} operation(s) still pending`),Promise.all(a).then(()=>{this.stopInProgress=!1})),c.length>0?(this.setStatus({state:"draining",startedAt:this.wallNow(),reason:c.join("; ")}),{state:"degraded",reasons:c}):(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(e){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: ${e instanceof Error?e.message:String(e)}`}}}reindexRequest(e,r=!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:e,changeJournal:i,allowExpensiveRebuild:r}}setStatus(e){this.status=e,this.onStatus(e)}recordPendingChange(e){if(this.pendingChanges.size>=1024&&!this.pendingChanges.has(e.path)){this.pendingChanges.clear(),this.markPendingChangesIncomplete("change-entry-limit");return}let r=this.pendingChanges.get(e.path),i=Fr(r,e.kind);i===null?this.pendingChanges.delete(e.path):this.pendingChanges.set(e.path,i)}markPendingChangesIncomplete(e){this.pendingChangesComplete=!1,this.pendingChangesIncompleteReason??=e}consumePendingChangeJournal(){let e=lt(this.outputDb),r=[...this.pendingChanges.entries()].map(([c,s])=>({path:c,kind:s})).sort((c,s)=>c.path.localeCompare(s.path)),i=this.pendingChangesComplete,n=this.pendingChangesIncompleteReason;e||(i=!1,n??="accepted-generation-unavailable");let o={version:1,baseGeneration:e,complete:i,...n?{incompleteReason:n}:{},entries:r};return Te(o)||(o={version:1,baseGeneration:e,complete:!1,incompleteReason:"change-journal-byte-limit",entries:[]}),this.resetPendingChanges(),o}restorePendingChangeJournal(e){let r=[...this.pendingChanges.entries()].map(([o,c])=>({path:o,kind:c})),i=this.pendingChangesComplete,n=this.pendingChangesIncompleteReason;this.resetPendingChanges(),e.complete||this.markPendingChangesIncomplete(e.incompleteReason??"failed-reindex");for(let o of e.entries)this.recordPendingChange(o);i||this.markPendingChangesIncomplete(n??"failed-reindex");for(let o of r)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&&(A(this).stagedIndexEntries=Kt(this.projectRoot,A(this).gitReader),this.gitPollTimer=this.clock.setInterval(()=>this.pollGitState(),this.watchConfig.gitPollMs),this.gitPollTimer.unref?.())}pollGitState(){if(this.reindexInFlight||this.stopped)return;let e=this.lastGitState,r=this.readGitState();if(!e||!r||this.stopped){this.lastGitState=r;return}this.lastGitState=r;let i=e.head!==r.head,n=e.indexPath!==r.indexPath||e.indexMtimeMs!==r.indexMtimeMs||e.indexSize!==r.indexSize;if(!i&&!n)return;let o=A(this),c=o.stagedIndexEntries,s=Kt(this.projectRoot,o.gitReader);o.stagedIndexEntries=s;let l=zr(this.projectRoot,o.gitReader,e,r,c,s,i,n),a=null;if(l!==null&&(l.includes(".scipquery.json")&&Xt(this,this.projectRoot),a=l.filter(d=>Yt(this,d)),a.length===0))return;let u=a?.map(d=>({path:d,kind:Qt(T(this.projectRoot,d))?"change":"delete"}));i&&n?this.scheduleReindex({kind:"watch-git-state",detail:Ae("HEAD and index changed",a)},u,u!==void 0):i?this.scheduleReindex({kind:"watch-git-head",detail:Ae("HEAD changed",a)},u,u!==void 0):n&&this.scheduleReindex({kind:"watch-git-index",detail:Ae(r.indexPath??"index changed",a)},u,u!==void 0)}readGitState(){if(this.preferFilesystemGitState){let e=this.readFilesystemGitState();if(e)return e}return this.readGitStateFromGit()}readFilesystemGitState(){let e=this.watchGitLayout??qr(this.projectRoot);if(!e)return null;this.watchGitLayout=e;let r=Br(e.gitDir);return r?Ht(r,e.indexPath):null}readGitStateFromGit(){let e=A(this).gitReader,r=Re(this.projectRoot,["rev-parse","--git-path","index"],e);if(!r)return null;let i=at(this.projectRoot,r);return Ht(Re(this.projectRoot,["rev-parse","--verify","HEAD"],e),i)}clearGitPollTimer(){this.gitPollTimer&&(this.clock.clearInterval(this.gitPollTimer),this.gitPollTimer=null)}};async function Cr(t,e,r){if(t.length===0)return!0;let i=Promise.all(t).then(()=>!0),n=Math.max(0,e-r.now()),o=null,c=new Promise(l=>{o=r.setTimeout(()=>l(!1),n)}),s=await Promise.race([i,c]);return s&&o&&r.clearTimeout(o),s}var $t=new WeakMap,rr=new WeakMap,ir=new WeakMap;function ce(t){let e=$t.get(t);if(e)return e;let r={closures:new Set,errors:[]};return $t.set(t,r),r}function Pr(t){return rr.get(t)??tr}function A(t){let e=ir.get(t);if(!e)throw new Error("Watcher input state was not initialized.");return e}function Wr(t,e,r){let i=Promise.resolve().then(()=>e.close()).catch(n=>{let o=`watch subscription close failed during polling fallback: ${String(n)}`;t.errors.push(o),r(new Error(o))});t.closures.add(i),i.then(()=>t.closures.delete(i))}function Er(t,e=P){let{projectRoot:r,config:i,languages:n,pnpmWorkspaces:o,typescriptProjectMode:c,typescriptProjects:s,clojureConfigPath:l,indexerConcurrency:a,trigger:u}=t,d=U(r),p=Object.keys(d).length>0?d:i,h=te(r,p),g=p.indexer?.typescript,f=p.indexer?.clojure,y=e(process.pid);if(!y)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:r,SCIP_REINDEX_OUTPUT_SCIP:h.indexPath,SCIP_REINDEX_OUTPUT_DB:h.dbPath,SCIP_REINDEX_LANGUAGES:(p.languages??n)?.join(",")??"",SCIP_REINDEX_INDEXER_CONCURRENCY:String(p.indexerConcurrency??a??""),SCIP_REINDEX_PNPM_WORKSPACES:g?.pnpmWorkspaces??o?"1":"",SCIP_REINDEX_TYPESCRIPT_CONFIG:JSON.stringify({projectMode:g?.projectMode??c,projects:g?.projects??s??[]}),SCIP_REINDEX_CLOJURE_CONFIG_PATH:f?.configPath??l??"",SCIP_REINDEX_TRIGGER_KIND:u.kind,SCIP_REINDEX_TRIGGER_DETAIL:u.detail??"",SCIP_REINDEX_CHANGE_JOURNAL:t.changeJournal?Te(t.changeJournal)??"":"",SCIP_REINDEX_ALLOW_EXPENSIVE:t.allowExpensiveRebuild===!1?"0":"1",SCIP_REINDEX_PROCESS_GROUP_LEADER:"1",SCIP_REINDEX_PARENT_IDENTITY:JSON.stringify(y)}}}var Mr={now:W,wallNow:()=>Date.now(),setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)},Ar=(t,e)=>kr(t,e),Lr=15*6e4,_r=1e3,Gr=64*1024;function Dr(){return{stdoutTail:"",stderrTail:"",stdoutTruncated:!1,stderrTruncated:!1}}function Ut(t,e){let r=t instanceof Error?t.message:String(t),i=e.stderrTail.trim()||e.stdoutTail.trim();return i?`${r}
2
- ${i}`:r}function jr(t={}){let e=t.timeoutMs??Lr,r=t.terminationGraceMs??_r,i=t.maxOutputBytes??Gr,n=t.resolveLaunch??Er;return{start(o){let c=n(o),s=new AbortController,l=Dr(),a=!1,u=Qe({command:process.execPath,args:[...process.execArgv,c.workerPath],label:"watch reindex worker",env:c.env,timeoutMs:e,terminationGraceMs:r,maxStdoutBytes:i,maxStderrBytes:i,outputLimitBehavior:"truncate-tail",signal:s.signal,detached:!0}).then(d=>{if(l={stdoutTail:d.stdout,stderrTail:d.stderr,stdoutTruncated:d.stdoutTruncated,stderrTruncated:d.stderrTruncated},d.status!==0)throw new Error(Ut(new Error(`Reindex worker exited with ${d.signal?`signal ${d.signal}`:`code ${d.status}`}`),l));return d.durationMs}).catch(d=>{throw d instanceof Ke&&(l={stdoutTail:d.stdout,stderrTail:d.stderr,stdoutTruncated:d.stdoutTruncated,stderrTruncated:d.stderrTruncated}),new Error(Ut(d,l),{cause:d})}).finally(()=>{a=!0});return{completion:u,async cancel(){a||s.abort();try{await u}catch{}return{state:"exited",diagnostics:l}},diagnostics:()=>l}}}}function Jt(t,e){return t?t.kind===e.kind?t.detail===e.detail?t:{kind:t.kind,detail:"multiple changes"}:{kind:"watch-git-state",detail:`${t.kind}, ${e.kind}`}:e}function Or(t){if(t==="add")return"add";if(t==="change")return"change";if(t==="unlink")return"delete"}function Fr(t,e){return t?t==="add"?e==="delete"?null:"add":t==="delete"&&e==="add"?"change":e:e}function Nr(t){return t instanceof Error&&"code"in t&&t.code==="EMFILE"||String(t).includes("EMFILE: too many open files")}var _e=/^[0-9a-f]{40,64}$/i;function Vt(t,e){return t===".git"||t.startsWith(".git/")||t==="node_modules"||t.startsWith("node_modules/")||t.endsWith("/node_modules")||t.includes("/node_modules/")?!0:e!==void 0&&(t===e||t.startsWith(`${e}/`))}function qr(t){let e=T(t,".git");try{let r=wr(e),i;if(r.isDirectory())i=e;else if(r.isFile()){let n=/^gitdir:\s*(.+)\s*$/m.exec(b(e,"Git directory marker"));if(!n?.[1])return null;let o=n[1].trim();i=Le(o)?o:er(t,o)}else return null;return Qt(i)?{gitDir:i,indexPath:T(i,"index")}:null}catch{return null}}function Br(t){let e;try{e=b(T(t,"HEAD"),"Git HEAD").trim()}catch{return}if(_e.test(e))return e.toLowerCase();let r=/^ref:\s*(.+)$/.exec(e)?.[1]?.trim();if(!r)return;let i=$r(t);return zt(t,r)??zt(i,r)??Ur(i,r)}function $r(t){try{let e=b(T(t,"commondir"),"Git common-directory marker").trim();return e?Le(e)?e:er(t,e):t}catch{return t}}function zt(t,e){try{let r=b(T(t,e),"Git reference").trim();return _e.test(r)?r.toLowerCase():void 0}catch{return}}function Ur(t,e){try{for(let r of b(T(t,"packed-refs"),"Git packed references").split(`
3
- `)){if(r.startsWith("#")||r.startsWith("^"))continue;let i=r.indexOf(" ");if(i===-1)continue;let n=r.slice(0,i);if(r.slice(i+1).trim()===e&&_e.test(n))return n.toLowerCase()}}catch{return}}function Ht(t,e){let r={head:t,indexPath:e};try{let i=br(e);r.indexMtimeMs=i.mtimeMs,r.indexSize=i.size}catch{r.indexMtimeMs=void 0,r.indexSize=void 0}return r}function Jr(t,e){let r=Zt(t,e).replaceAll("\\","/");if(!(!r||r===".."||r.startsWith("../")))return r}function Vr(t,e){if(!Number.isSafeInteger(t)||t<=0)throw new Error(`${e} must be a positive integer.`);return t}function nr(t){return t&&t.length>0?[...t]:ve}function Xt(t,e){try{A(t).languages=nr(U(e).languages)}catch{A(t).languages=ve}}function Yt(t,e){return Ze(e,A(t).languages)!=="other"}function zr(t,e,r,i,n,o,c,s){let l=new Set;if(c){if(!r.head||!i.head)return null;let a=e.runResult(t,["diff","--name-only","-z","--no-renames","--relative",r.head,i.head,"--"]);if(a.kind!=="success")return null;for(let u of Hr(a.output))l.add(u)}if(s){if(n===null||o===null)return null;for(let a of Yr(n,o))l.add(a)}return[...l].sort()}function Kt(t,e){let r=e.runResult(t,["diff","--cached","--raw","-z","--no-renames","--relative","--"]);return r.kind==="success"?Xr(r.output):null}function Hr(t){return t.split("\0").filter(e=>e.length>0)}function Xr(t){let e=t.split("\0");if(e.at(-1)===""&&e.pop(),e.length%2!==0)return null;let r=new Map;for(let i=0;i<e.length;i+=2){let n=e[i],o=e[i+1];if(!n.startsWith(":")||!o)return null;r.set(o,n)}return r}function Yr(t,e){return[...new Set([...t.keys(),...e.keys()])].filter(i=>t.get(i)!==e.get(i))}function Ae(t,e){return e===null?`${t}; changed paths unavailable`:e.length===0?t:e.length===1?e[0]:`${e.length} compiler inputs changed`}import{existsSync as de,lstatSync as J,readdirSync as ar,realpathSync as sr,rmSync as G,statSync as Kr}from"fs";import{join as S,resolve as V,sep as cr}from"path";var Qr=3600*1e3,Zr=2*1024*1024*1024,ue=300*1e3,ei="gc-state.json",ti="gc.lock";function ri(t){let e=t.leases.filter(s=>s.managed&&!s.live&&!s.busy),r=ii(t.leases,t.locks),i={};for(let s of t.generations)r.has(s.generationId)||(i[s.generationId]=s.unreferencedAt??t.nowMs);let n=t.generations.filter(s=>!r.has(s.generationId)).sort((s,l)=>i[s.generationId]-i[l.generationId]||s.generationId.localeCompare(l.generationId)),o=new Set;for(let s of n)t.nowMs-i[s.generationId]>=t.policy.generationTtlMs&&o.add(s.generationId);let c=t.generations.filter(s=>!o.has(s.generationId)).reduce((s,l)=>s+l.size,0);for(let s of n){if(c<=t.policy.budgetBytes)break;o.has(s.generationId)||(o.add(s.generationId),c-=s.size)}for(let s of o)delete i[s];return{deleteWorktrees:e,deleteGenerations:t.generations.filter(s=>o.has(s.generationId)),deleteLocks:t.locks.filter(s=>!s.live),deleteTemporaries:t.temporaries.filter(s=>!s.live),protectedGenerationIds:[...r].sort(),unreferencedSince:i}}function ii(t,e){let r=new Set(t.filter(i=>i.managed&&(i.live||i.busy)).flatMap(i=>[i.lease.baseGenerationId,i.lease.activeGenerationId]).filter(i=>i!==void 0));for(let i of e)i.live&&r.add(i.generationId);return r}function lr(t,e,r={}){if(!rt())return{kind:"disabled"};let i=r.repositoryId===void 0?nt(t)?.repositoryId:r.repositoryId;if(!i)return{kind:"unavailable"};let n=S(B(),"repositories",i),o=(r.now??Date.now)(),c=de(n)?dr(t,n,i,e,o,r):{kind:"unavailable"};return ni(t,i,e,o,r),c}function dr(t,e,r,i,n,o){let c=S(e,"gc-state.json"),s=ci(c);if(!o.force&&s&&n-Date.parse(s.lastSweepAt)<ue)return{kind:"throttled",sweptAt:s.lastSweepAt};let l=ct(e,{now:()=>n});if(!l)return{kind:"busy"};try{let a=si(t,e,r,s?.unreferencedSince??{}),u=ri({nowMs:n,...a,policy:{generationTtlMs:o.policy?.generationTtlMs??Qr,budgetBytes:o.policy?.budgetBytes??Zr}}),d=0,p=0;for(let f of u.deleteWorktrees){if(!je(f.lease))continue;if(!de(f.lease.localCacheDir)){G(f.leasePath,{force:!0}),p+=1;continue}if(!oi(f.lease))continue;let y=we(S(f.lease.localCacheDir,"cache-lifecycle.lock"));if(y)try{if(Ge(f.lease,!0))continue;try{_t({projectRoot:f.lease.projectRoot,cacheDir:f.lease.localCacheDir,cliVersion:i})}catch{continue}if(Ge(f.lease,!0))continue;G(f.lease.localCacheDir,{recursive:!0,force:!0}),G(f.leasePath,{force:!0}),p+=1}finally{y.release()}}for(let f of u.deleteLocks)G(f.path,{force:!0});for(let f of u.deleteTemporaries)G(f.path,{recursive:!0,force:!0});for(let f of u.deleteGenerations)G(f.path,{recursive:!0,force:!0}),d+=f.size;dt(S(e,"evidence.db"));let h={kind:"swept",sweptAt:new Date(n).toISOString(),deletedWorktrees:p,deletedGenerations:u.deleteGenerations.length,deletedBytes:d,protectedGenerations:u.protectedGenerationIds.length},g={version:1,lastSweepAt:h.sweptAt,unreferencedSince:u.unreferencedSince,lastResult:h};return be(c,g,{spacing:2,trailingNewline:!0}),h}catch(a){return{kind:"failed",error:a instanceof Error?a.message:String(a)}}finally{l.release()}}function ni(t,e,r,i,n){let o=S(B(),"repositories");if(!de(o))return;let c=S(o,ei),s=li(c);if(!n.force&&s!==void 0&&i-s<ue)return;let l=we(S(o,ti));if(l)try{for(let a of z(o)){if(a===e||!/^[a-f0-9]{24}$/.test(a))continue;let u=S(o,a),d;try{d=J(u)}catch{continue}if(!d.isDirectory()||d.isSymbolicLink())continue;let p=ai(u)??t;dr(p,u,a,r,i,n)}be(c,{version:1,lastSweepAt:new Date(i).toISOString()},{spacing:2,trailingNewline:!0})}finally{l.release()}}function si(t,e,r,i){let n=new Set(ot(t).map(a=>V(a.path))),o=[];for(let a of z(S(e,"worktrees"))){if(!a.endsWith(".json"))continue;let u=S(e,"worktrees",a),d=ur(u);if(!d)continue;let p=V(d.projectRoot);o.push({leasePath:u,lease:d,managed:d.repositoryId===r&&je(d),live:n.has(p)||de(p),busy:Ge(d)})}let c=[];for(let a of z(S(e,"locks"))){let u=/^([a-f0-9]{64})\.lock$/.exec(a);if(!u)continue;let d=S(e,"locks",a),p=De(d),h=p!==void 0&&M(p),g=u[1];c.push({generationId:g,path:d,live:h})}let s=[],l=[];for(let a of z(S(e,"generations"))){let u=/^\.tmp-(\d+)-/.exec(a);if(u){let h=S(e,"generations",a),g=Number(u[1]);try{l.push({path:h,size:or(h),live:Number.isSafeInteger(g)&&M(g)})}catch{}continue}if(!/^[a-f0-9]{64}$/.test(a))continue;let d=S(e,"generations",a),p;try{p=J(d)}catch{continue}!p.isDirectory()||p.isSymbolicLink()||s.push({generationId:a,path:d,size:or(d),...i[a]===void 0?{}:{unreferencedAt:i[a]}})}return{leases:o,generations:s,locks:c,temporaries:l}}function je(t){if(t.ownershipChecksum!==mt(t)||$(t.localCacheDir)!==$(tt(t.projectRoot)))return!1;let e=$(S(B(),"projects"));return $(t.localCacheDir).startsWith(`${e}${cr}`)}function oi(t){if(!je(t))return!1;let e=V(B()),r=V(S(e,"projects")),i=V(t.localCacheDir);try{let n=J(e),o=J(r),c=J(i);if(!n.isDirectory()||n.isSymbolicLink()||!o.isDirectory()||o.isSymbolicLink()||!c.isDirectory()||c.isSymbolicLink())return!1;let s=sr(r);return sr(i).startsWith(`${s}${cr}`)}catch{return!1}}function ai(t){for(let e of z(S(t,"worktrees"))){if(!e.endsWith(".json"))continue;let r=ur(S(t,"worktrees",e));if(r)return r.projectRoot}}function Ge(t,e=!1){for(let i of e?["index.lock"]:["index.lock","cache-lifecycle.lock"]){let n=De(S(t.localCacheDir,i));if(n!==void 0&&M(n))return!0}let r=De(ne(t.localCacheDir).lockPath);return r!==void 0&&M(r)}function ur(t){try{let e=JSON.parse(b(t,"worktree cache lease"));return e.version!==1||typeof e.repositoryId!="string"||typeof e.worktreeId!="string"||typeof e.projectRoot!="string"||e.treeOid!==void 0&&typeof e.treeOid!="string"||typeof e.localCacheDir!="string"||e.baseGenerationId!==void 0&&typeof e.baseGenerationId!="string"||e.activeGenerationId!==void 0&&typeof e.activeGenerationId!="string"||typeof e.ownershipChecksum!="string"||!/^[a-f0-9]{64}$/.test(e.ownershipChecksum)||typeof e.lastAction!="string"||e.lastReason!==void 0&&typeof e.lastReason!="string"||typeof e.lastSeenAt!="string"?null:e}catch{return null}}function De(t){try{let e=JSON.parse(b(t,"watch lock record"));return typeof e.pid=="number"&&Number.isSafeInteger(e.pid)&&e.pid>0?e.pid:void 0}catch{return}}function ci(t){try{let e=JSON.parse(b(t,"repository cache GC state"));return e.version!==1||typeof e.lastSweepAt!="string"||!Number.isFinite(Date.parse(e.lastSweepAt))||!e.unreferencedSince||typeof e.unreferencedSince!="object"||!e.lastResult?null:e}catch{return null}}function li(t){try{let e=JSON.parse(b(t,"global repository cache GC state"));if(e.version!==1||typeof e.lastSweepAt!="string")return;let r=Date.parse(e.lastSweepAt);return Number.isFinite(r)?r:void 0}catch{return}}function z(t){try{return ar(t)}catch{return[]}}function or(t){let e=0,r=[t];for(;r.length>0;){let i=r.pop();for(let n of ar(i,{withFileTypes:!0})){let o=S(i,n.name);n.isDirectory()?r.push(o):n.isFile()&&(e+=Kr(o).size)}}return e}var he=class{root;now;randomId;retryDelayMs;active;retryNotBeforeMs=0;currentStatus;constructor(e,r={}){this.root=e,this.now=r.now??Date.now,this.randomId=r.randomId,this.retryDelayMs=Math.max(1,Math.floor(r.retryDelayMs??1e3)),this.currentStatus=Me(e)}initializeAfterOwnershipAcquired(){let e=Mt(this.root),r=At(this.root,{now:()=>new Date(this.now())});return this.refreshStatus(),{recoveredClaims:e,prunedHistory:r}}observeLegacyRequest(e,r){Pt(this.root,r??"stale index observed by a legacy command",{idempotencyKey:`legacy-activity:${e}`,now:()=>new Date(e)}),this.refreshStatus()}poll(e,r){if(this.active||e.state!=="idle"||this.now()<this.retryNotBeforeMs)return!1;let i=Wt(this.root,{now:()=>new Date(this.now()),...this.randomId?{randomId:this.randomId}:{}});if(this.refreshStatus(),i.requests.length===0)return!1;this.active=i;try{return r(di(i)),!0}catch(n){throw Ee(this.root,i),this.active=void 0,this.retryNotBeforeMs=this.now()+this.retryDelayMs,this.refreshStatus(),n}}completeActive(){return this.active?(Et(this.root,this.active,()=>new Date(this.now())),this.active=void 0,this.retryNotBeforeMs=0,this.refreshStatus(),!0):!1}failActive(){return this.active?(Ee(this.root,this.active),this.active=void 0,this.retryNotBeforeMs=this.now()+this.retryDelayMs,this.refreshStatus(),!0):!1}status(){return{...this.currentStatus}}refreshStatus(){this.currentStatus=Me(this.root)}};function di(t){if(t.requests.length===1)return t.requests[0].detail;let r=[...new Set(t.requests.map(i=>i.detail))].slice(0,3).join("; ");return`${t.requests.length} coalesced refresh requests${r?`: ${r}`:""}`.slice(0,2048)}import{randomUUID as hi}from"crypto";import{Worker as pi}from"worker_threads";var pe=class{constructor(e){this.options=e;if(this.now=e.now??Date.now,this.setTimer=e.setTimer??setTimeout,this.clearTimer=e.clearTimer??clearTimeout,e.maxWorkerFailureRetries!==void 0&&(!Number.isInteger(e.maxWorkerFailureRetries)||e.maxWorkerFailureRetries<0))throw new Error("Worker maxWorkerFailureRetries must be a non-negative integer.")}options;now;setTimer;clearTimer;worker=null;active=null;activeFailure=null;terminating=null;closed=!1;workerGeneration=0;idleTimer=null;canAccept(){return!this.closed&&this.active===null&&this.terminating===null}hasWorker(){return this.worker!==null}start(e){if(!this.canAccept())return!1;if(this.clearIdleTimer(),e.deadlineAtMs<this.now()){try{this.options.onReject(e,`${this.options.name} request expired before processing.`)}catch(n){this.closed=!0,this.options.onFatal(Oe(n))}return!0}let r=this.ensureWorker(),i=this.deadlineTimer(e);this.active={request:e,timer:i,workerFailureRetries:0,workerFailureReasons:[]};try{r.postMessage({kind:"request",...e})}catch(n){this.failActiveAfterTermination(Fe(n),!0)}return!0}async close(e=`${this.options.name} service is shutting down.`){if(this.closed=!0,this.clearIdleTimer(),this.active){await this.failActiveAfterTermination(e);return}await this.terminateWorker()}ensureWorker(){if(this.worker)return this.worker;let e=this.options.createWorker(),r=++this.workerGeneration;return e.on("message",i=>this.handleMessage(r,i)),e.on("error",i=>{r===this.workerGeneration&&this.failActiveAfterTermination(`${this.options.name} worker failed: ${i.message}`,!0)}),e.on("exit",i=>{r!==this.workerGeneration||this.terminating||(this.worker=null,this.active&&this.failActiveAfterTermination(`${this.options.name} worker exited unexpectedly with code ${i}.`,!0))}),this.worker=e,e}handleMessage(e,r){if(e!==this.workerGeneration||this.closed||!this.active)return;let i=ui(r);if(!i){this.failActiveAfterTermination(`${this.options.name} worker returned an invalid response.`);return}if(i.requestId!==this.active.request.requestId){this.failActiveAfterTermination(`${this.options.name} worker returned a mismatched request identity.`);return}if(this.now()>this.active.request.deadlineAtMs){this.failActiveAfterTermination(`${this.options.name} request expired while it was processing.`);return}let n=this.active,o;try{this.options.onStatus(i.status),i.ok?this.options.onComplete(n.request,i.result,i.status):this.options.onReject(n.request,i.error,i.status),o=this.options.retireAfterResponse?.(i.status)??!1}catch(c){this.closed=!0,this.clearTimer(n.timer),this.options.onFatal(Oe(c));return}this.releaseActive(n),o?this.terminateWorker():this.scheduleIdleTermination()}async failActiveAfterTermination(e,r=!1){if(this.activeFailure){await this.activeFailure;return}let i=this.active;if(!i){await this.terminateWorker();return}this.clearTimer(i.timer),r&&i.workerFailureReasons.push(e);let n=(async()=>{if(!await this.terminateWorker())return;let c=this.options.maxWorkerFailureRetries??0;if(r&&!this.closed&&i.workerFailureRetries<c&&this.now()<=i.request.deadlineAtMs){i.workerFailureRetries+=1;try{let l=this.ensureWorker();i.timer=this.deadlineTimer(i.request),l.postMessage({kind:"request",...i.request});return}catch(l){let a=`Cold Worker retry failed: ${Fe(l)}`;if(i.workerFailureReasons.push(a),e=`${e} ${a}`,!await this.terminateWorker())return}}let s=i.workerFailureReasons.length===0?e:[...new Set([...i.workerFailureReasons,e])].join(" Cold Worker retry: ");try{this.options.onReject(i.request,s)}catch(l){this.closed=!0,this.options.onFatal(Oe(l));return}this.releaseActive(i)})();this.activeFailure=n;try{await n}finally{this.activeFailure===n&&(this.activeFailure=null)}}deadlineTimer(e){let r=Math.max(1,Math.min(2147483647,e.deadlineAtMs-this.now()));return this.setTimer(()=>{this.failActiveAfterTermination(`${this.options.name} request exceeded its deadline.`)},r)}releaseActive(e){this.active===e&&(this.active=null,this.clearTimer(e.timer))}scheduleIdleTermination(){let e=this.options.idleTtlMs;!e||e<=0||this.closed||this.active||!this.worker||(this.clearIdleTimer(),this.idleTimer=this.setTimer(()=>{this.idleTimer=null,!(this.closed||this.active||!this.worker)&&this.terminateWorker()},e))}clearIdleTimer(){this.idleTimer&&(this.clearTimer(this.idleTimer),this.idleTimer=null)}async terminateWorker(){if(this.clearIdleTimer(),this.terminating)return this.terminating;let e=this.worker;if(!e)return!0;this.worker=null;let r=++this.workerGeneration;return this.terminating=(async()=>{try{return await e.terminate(),!0}catch(i){return this.closed=!0,this.options.onFatal(new Error(`${this.options.name} worker termination failed: ${Fe(i)}`,{cause:i})),!1}finally{r===this.workerGeneration&&(this.terminating=null)}})(),this.terminating}};function ui(t){if(!t||typeof t!="object")return null;let e=t;if(e.kind!=="response"||typeof e.requestId!="string"||!("status"in e))return null;if(e.ok===!0){if(!("result"in e)||"error"in e)return null}else if(e.ok===!1){if("result"in e||typeof e.error!="string")return null}else return null;return e}function Oe(t){return t instanceof Error?t:new Error(String(t))}function Fe(t){return t instanceof Error?t.message:String(t)}var fi=6e4,mi=10*6e4;function hr(t){let e=t.maxActiveSessions??8,r=t.workerSoftMemoryMb??yi(),i=()=>({protocolVersion:ie,state:"idle",requests:0,sessionsCreated:0,sessionsReplaced:0,sessionsEvicted:0,activeSessions:0,maxActiveSessions:e,softMemoryLimitBytes:r*1024*1024,retireRequested:!1,initializations:0,programUpdates:0,documentsEmitted:0,documentsRemoved:0});return fr({name:"TypeScript index",paths:t.paths,now:t.now,limits:t.limits,initialStatus:i,parseEnvelope:Rt,createWorker:()=>gr(t,{kind:"index",projectRoot:t.projectRoot,dbPath:t.dbPath,maxActiveSessions:e,softMemoryLimitMb:r}),complete(n,o,c,s){Ie(t.paths,n,{ok:!0,protocolVersion:ie,id:o.id,baseGeneration:o.baseGeneration,response:c},{nowMs:s,limits:t.limits})},reject(n,o,c,s){xe(t.paths,n,{ok:!1,protocolVersion:ie,id:o,error:c},c,{nowMs:s,limits:t.limits})},idleTtlMs:t.workerIdleMs??mi,maxWorkerFailureRetries:1,retireAfterResponse:n=>n.retireRequested===!0,statusWhenWorkerAbsent:n=>({...n,state:"idle",activeSessions:0,heapUsedBytes:0,retireRequested:!1}),onBusy:t.onBusy,onFatal:t.onFatal})}function pr(t){let e=()=>({protocolVersion:oe,state:"idle",requests:0,sessionsCreated:0,sessionsReused:0,sessionsRefreshed:0,sessionsReplaced:0,projectsCreated:0});return fr({name:"TypeScript semantic",paths:t.paths,now:t.now,limits:t.limits,initialStatus:e,parseEnvelope:Tt,createWorker:()=>gr(t,{kind:"semantic",projectRoot:t.projectRoot}),complete(r,i,n,o){Ie(t.paths,r,{ok:!0,protocolVersion:oe,id:i.id,generation:i.generation,response:n},{nowMs:o,limits:t.limits})},reject(r,i,n,o){xe(t.paths,r,{ok:!1,protocolVersion:oe,id:i,error:n},n,{nowMs:o,limits:t.limits})},idleTtlMs:fi,onBusy:t.onBusy,onFatal:t.onFatal})}function fr(t){let e=t.now??Date.now,r=P(process.pid),i={pid:process.pid,...r?{processIdentity:r}:{}},n=`${t.name.toLowerCase().replaceAll(" ","-")}-${process.pid}-${hi()}`,o={...t.limits,maxBatch:1},c=null,s=t.initialStatus(),l=!1,a=h=>{l=!0,t.onFatal(h)},u=new pe({name:t.name,createWorker:t.createWorker,now:e,idleTtlMs:t.idleTtlMs,maxWorkerFailureRetries:t.maxWorkerFailureRetries,retireAfterResponse:t.retireAfterResponse,onComplete(h,g,f){let y=d(h.requestId);s=f,t.complete(y.claim,y.envelope,g,e()),p(y)},onReject(h,g,f){let y=d(h.requestId);f!==void 0&&(s=f),t.reject(y.claim,y.envelope.id,g,e()),p(y)},onStatus(h){s=h},onFatal:a});return{poll(){if(l||!u.canAccept())return 0;let h=gt(t.paths,{ownerId:n,nowMs:e(),limits:o,owner:i,liveness:{isProcessAlive:M,readProcessIdentity:P}})[0];if(!h)return 0;let g=h.requestId;try{let f=t.parseEnvelope(yt(h,o));if(g=f.id,f.id!==h.requestId)throw new Error(`${t.name} request identity does not match its mailbox path.`);if(f.deadlineAtMs<e())throw new Error(`${t.name} request expired before processing.`);if(c={claim:h,envelope:f},t.onBusy?.(f.deadlineAtMs),!u.start({requestId:f.id,deadlineAtMs:f.deadlineAtMs,payload:f}))throw new Error(`${t.name} worker lane closed admission after claiming a request.`)}catch(f){let y=vi(f);try{t.reject(h,g,y,e()),c?.claim===h&&p(c)}catch(D){a(Si(D))}}return 1},status(){return{...u.hasWorker()||!t.statusWhenWorkerAbsent?s:t.statusWhenWorkerAbsent(s),mailbox:St(t.paths)}},async close(h){await u.close(h)}};function d(h){let g=c;if(!g||g.envelope.id!==h)throw new Error(`${t.name} parent lost the active mailbox claim.`);return g}function p(h){c===h&&(c=null,t.onBusy?.(void 0))}}var gi=8192;function mr(){let t=Number.parseInt(process.env.SCIP_TS_WORKER_HEAP_MB??"",10);return Number.isFinite(t)&&t>0?t:gi}function yi(){return Math.max(1,Math.floor(mr()*.7))}function gr(t,e){if(t.createWorker)return t.createWorker(e);let r=t.workerUrl??new URL("./typescript-mailbox-worker.js",import.meta.url);return new pi(r,{workerData:e,resourceLimits:{maxOldGenerationSizeMb:mr()}})}function Si(t){return t instanceof Error?t:new Error(String(t))}function vi(t){return t instanceof Error?t.message:String(t)}var Sr=2e3,bi=5e3,Ii=5e3,xi=6e4,ki=10,Ti=50,Ci=1e4;function Pi(t,e=1){if(t>0)return ki;let r=Math.max(0,Math.min(8,e-1));return Math.min(Ci,Ti*2**r)}function Wi(t,e){let r;return{begin(){return r||(e.requestStop(),e.closeWake(),r=t.stop(),r.catch(()=>{})),r}}}async function Ei(t,e){let r=e.processIndexRequests(),i=e.processSemanticRequests(),n=r+i,o=n>0?0:t+1;if(e.afterMailboxPoll({indexRequests:r,semanticRequests:i,processedRequests:n}),e.shouldStop())return{indexRequests:r,semanticRequests:i,processedRequests:n,consecutiveIdlePolls:o,stopped:!0};let c=Pi(n,o);return await e.wait(c),{indexRequests:r,semanticRequests:i,processedRequests:n,consecutiveIdlePolls:o,stopped:!1,delayMs:c}}function Mi(t){return t==="fresh"?null:{kind:"watch-startup",detail:`index ${t} when watch service started`}}async function Ai(t,e,r={}){let i=Lt(t,e),n=i.projectRoot,o=i.worktreeKind==="git"?Li(n,i.worktreeId):void 0,c=Nt(n,o),s=U(n);s.watch={...s.watch,...r};let l=se(s);if(!l.enabled)throw new Error('watch mode is disabled; set "watch.enabled": true before starting the service');let a=te(n,s),u=ne(a.cacheDir),d=P(v.pid),p=jt(u.lockPath,n,{readProcessIdentity:m=>m===v.pid?d:P(m)});if(!p.acquired)return;let h=new he(u.refreshRequestsPath,{retryDelayMs:Math.max(1e3,l.cooldownMs)});h.initializeAfterOwnershipAcquired();let g=Date.now(),f=W(),y=g,D=f,j={state:"idle"},L,H,C,X,fe=re(a.dbPath),Y=!1,Ne=!1,qe=0,Be=Number.NEGATIVE_INFINITY,$e=Number.NEGATIVE_INFINITY,Ue=Number.NEGATIVE_INFINITY,Je=Number.NEGATIVE_INFINITY,Ve=Number.NEGATIVE_INFINITY,me,ge,ze=0,O=kt(a.cacheDir),F=vt(a.cacheDir);Ct(O),bt(F);let He=We([F.pendingDir,F.legacyRequestDir,O.pendingDir,O.legacyRequestDir,u.refreshRequestsPath]),K,R=(m=!1,w=m?"durable":"visibility")=>{if(!Ne)return;let _=Date.now(),I=W();!m&&I-Be<Sr||(Be=I,Gt(u.statePath,{version:1,protocolVersion:wt,pid:v.pid,...d?{processIdentity:d}:{},projectRoot:n,...i.worktreeId?{worktreeId:i.worktreeId}:{},cliVersion:e,startedAt:new Date(g).toISOString(),heartbeatAt:new Date(_).toISOString(),lastActivityAt:new Date(y).toISOString(),...l.idleTimeoutMs===0?{}:{idleDeadlineAt:new Date(y+l.idleTimeoutMs).toISOString()},watcher:j,...j.state==="idle"&&L?{indexGeneration:L}:{},...H?{lastRefresh:H}:{},...C?{lastError:C}:{},reindexActivity:fe,refreshRequests:h.status(),typescriptSemantic:{...ye.status(),...me===void 0?{}:{busyUntil:new Date(me).toISOString()}},typescriptIndex:{...Se.status(),...ge===void 0?{}:{busyUntil:new Date(ge).toISOString()}}},{durability:w}))},E=()=>{y=Date.now(),D=W()},Xe=m=>{E(),X??=m,C={at:new Date().toISOString(),message:m.message},R(!0,"visibility")},ye=pr({paths:O,projectRoot:n,onBusy(m){me=m===void 0?void 0:m+5e3,R(!0,"visibility")},onFatal:Xe}),Se=hr({paths:F,projectRoot:n,dbPath:a.dbPath,...s.indexer?.typescript?.maxWarmSessions===void 0?{}:{maxActiveSessions:s.indexer.typescript.maxWarmSessions},...s.indexer?.typescript?.workerIdleMs===void 0?{}:{workerIdleMs:s.indexer.typescript.workerIdleMs},...s.indexer?.typescript?.workerSoftMemoryMb===void 0?{}:{workerSoftMemoryMb:s.indexer.typescript.workerSoftMemoryMb},onBusy(m){ge=m===void 0?void 0:m+5e3,R(!0,"visibility")},onFatal:Xe}),Q=new le({projectRoot:n,config:{...s,watch:l},outputDb:a.dbPath,languages:s.languages,onStatus(m){j=m,m.state!=="idle"&&(L=void 0),m.state!=="idle"&&E(),R(!0)},onReindexComplete(m,w,_){E();let I=_?.pendingChanges!==!1?Ce(n,s,a):xt(a);return H=I.lastRefresh,L=I.state==="fresh"?Pe(a.dbPath)??void 0:void 0,fe=re(a.dbPath),h.completeActive(),C=void 0,R(!0),I.state==="fresh"},onReindexError(){h.failActive()},onRefreshSuppressed(m){let w=pt(a.dbPath,m);w.state==="failed"&&(C={at:new Date().toISOString(),message:`Suppressed-refresh telemetry was not recorded: ${w.reason}`},R(!0,"visibility")),fe=re(a.dbPath)},onError(m){E(),L=void 0,C={at:new Date().toISOString(),message:m.message},R(!0)}}),Ye=Wi(Q,{requestStop(){Y=!0},closeWake(){He.close()}}),Z=()=>{Ye.begin()};v.once("SIGINT",Z),v.once("SIGTERM",Z);let N=!1,ee,q;try{Q.start();let m=Ce(n,s,a);H=m.lastRefresh,L=m.state==="fresh"?Pe(a.dbPath)??void 0:void 0;let w=Mi(m.state);for(E(),Ne=!0,R(!0),K=setInterval(()=>R(),Sr),K.unref?.(),w&&Q.requestRefresh(w,{immediate:!0});!Y;){let _=await Ei(ze,{processIndexRequests:()=>Se.poll(),processSemanticRequests:()=>ye.poll(),afterMailboxPoll:({processedRequests:I})=>{let k=W();if(k-Ue>=Ii&&(Ue=k,!qt(c))){Y=!0;return}if(k-Ve>=xi&&(Ve=k,ke(F),ke(O)),k-Je>=ue&&(Je=k,lr(n,e)),k-$e>=bi){$e=k;let x=Dt(u.activityPath);x&&x.atMs>y&&(y=x.atMs,D=k),x?.refreshRequestedAtMs!==void 0&&x.refreshRequestedAtMs>qe&&(qe=x.refreshRequestedAtMs,h.observeLegacyRequest(x.refreshRequestedAtMs,x.refreshDetail??"stale index observed by a legacy command"))}h.poll(j,x=>{E(),Q.requestRefresh({kind:"watch-demand",detail:x},{immediate:!0})}),I>0&&(E(),R(!0,"visibility")),R()},shouldStop:()=>Y||X!==void 0||Ot({watcher:j,lastActivityAtMs:D,nowMs:W(),idleTimeoutMs:l.idleTimeoutMs}),wait:I=>He.wait(I)});if(ze=_.consecutiveIdlePolls,_.stopped)break}}catch(m){N=!0,ee=m}finally{v.off("SIGINT",Z),v.off("SIGTERM",Z),K!==void 0&&clearInterval(K);let m=Ye.begin();await Promise.all([ye.close("TypeScript semantic service stopped before completing the request."),Se.close("TypeScript index service stopped before completing the request.")]);let w=await m;w.state==="stopped"?(yr(u.statePath,{force:!0}),yr(u.activityPath,{force:!0}),p.release()):(C={at:new Date().toISOString(),message:`Watch service shutdown is degraded: ${w.reasons.join("; ")}`},R(!0),q=new Error(C.message))}if(!N&&X&&(N=!0,ee=X),N&&q)throw new AggregateError([ee,q],"Watch service execution and shutdown both failed.");if(N)throw ee;if(q)throw q}function Li(t,e){let r=st(t);if(r.kind!=="worktree"||r.identity.worktreeId!==e)throw new Error(`Git worktree identity changed while starting the watch service for ${t}.`);return r.identity.gitDir}function _i(t,e={report:r=>console.error(r),exit:r=>v.exit(r)}){return e.report(`watch-service: ${It(t instanceof Error?t.message:String(t))}`),e.exit(1)}var Gi=v.argv[1]?wi(Ri(v.argv[1])).href:null;if(Gi===import.meta.url){let t=v.argv[2],e=v.argv[3],r=Di(v.argv[4]);if(!t||!e)console.error("watch-service: expected <project-root> <cli-version>"),v.exitCode=1;else try{await Ai(t,e,r)}catch(i){_i(i)}}function Di(t){if(!t)return{};try{let e=JSON.parse(t);return e&&typeof e=="object"?e:{}}catch{return{}}}export{We as createPathChangeWake,Wi as createWatchServiceShutdown,Ei as runWatchServiceLoopIteration,Ai as runWatchServiceServer,Mi as startupRefreshTrigger,_i as terminateWatchServiceProcess,Pi as watchServiceLoopDelayMs};
1
+ import{b as Je,c as Ve,g as ut,j as ht,k as X,l as pt,m as xe}from"./chunk-EDMB6SSO.js";import{a as K,b as St,c as vt}from"./chunk-7YQOCABQ.js";import{a as Pe,b as kt,c as Pt,d as Tt,e as Te,f as Ct,g as Ce,h as Wt,i as Et,j as Mt,k as At,l as Lt,m as _t,n as jt}from"./chunk-AUY5BL74.js";import{a as wt}from"./chunk-MXNGIEPU.js";import{a as Rt,c as Y}from"./chunk-BVFYEEBH.js";import"./chunk-JHH5SCZ3.js";import{d as B,e as Q,f as ke,g as bt}from"./chunk-QWKHW6VZ.js";import"./chunk-DHEQMPLW.js";import{a as Z,b as It,c as xt}from"./chunk-ENWQWA2R.js";import{L as ft,c as st,d as ye,g as q}from"./chunk-WN3TCGJ4.js";import{e as lt}from"./chunk-DKM723YF.js";import{a as ge,d as Xe}from"./chunk-K3XFWJI2.js";import{a as dt}from"./chunk-NRBNAECH.js";import"./chunk-IW5XQG5G.js";import"./chunk-57N6LN2A.js";import{a as M,c as Se,h as ve,j as Re,n as gt,o as mt,p as we,q as be,r as Ie,s as yt}from"./chunk-JT6XX7QY.js";import"./chunk-H5EXS3HM.js";import"./chunk-HGFDYOVB.js";import{c as T,d as C,e as Ke}from"./chunk-SB25YMEQ.js";import{H as Ye,I as F,J as Qe,L as Ze,M as O,O as N,S as et,T as tt,W as rt,X as it,Y as me,Z as nt,ba as ot,ea as at,h as R,m as fe,o as He,ua as ct}from"./chunk-AK3PYTIK.js";import v from"process";import{rmSync as mr}from"fs";import{resolve as Ai}from"path";import{pathToFileURL as Li}from"url";import{lstatSync as wr}from"fs";function Dt(t,e){let r=ee(t);if(r.kind!=="directory")throw new Error(`Watcher root is not a directory: ${t}`);if(!e)return{projectRoot:t,projectDirectory:r};let i=ee(e);if(i.kind!=="directory")throw new Error(`Git control path is not a directory: ${e}`);return{projectRoot:t,projectDirectory:r,gitControlDirectory:{path:e,identity:i}}}function Ft(t){try{if(!Gt(t.projectDirectory,ee(t.projectRoot)))return!1;let e=t.gitControlDirectory;return!e||Gt(e.identity,ee(e.path))}catch{return!1}}function ee(t){let e=wr(t,{bigint:!0}),r=e.isDirectory()?"directory":e.isFile()?"file":void 0;if(!r||e.isSymbolicLink())throw new Error(`Unsupported watcher identity path: ${t}`);return{device:e.dev,inode:e.ino,birthtimeNs:e.birthtimeNs,kind:r}}function Gt(t,e){return t.device===e.device&&t.inode===e.inode&&t.birthtimeNs===e.birthtimeNs&&t.kind===e.kind}import{existsSync as Ae,lstatSync as Ir,statSync as Xt,watch as xr}from"fs";import{EventEmitter as kr}from"events";import{basename as Pr,dirname as Tr,isAbsolute as Le,join as b,relative as Kt,resolve as Yt}from"path";import{watch as Cr}from"chokidar";import Wr from"ignore";var Qt=5e3,ie=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(e){this.projectRoot=e.projectRoot,this.config=e.config,this.watchConfig=Q(e.config),this.outputDb=e.outputDb??b(Ye(this.projectRoot,e.config),"index.db"),this.preferFilesystemGitState=e.gitReader===void 0,this.localCacheWatchPath=Zr(this.projectRoot,Tr(this.outputDb)),this.languages=e.languages,this.pnpmWorkspaces=e.config.indexer?.typescript?.pnpmWorkspaces??!1,this.typescriptProjectMode=e.config.indexer?.typescript?.projectMode,this.typescriptProjects=e.config.indexer?.typescript?.projects,this.clojureConfigPath=e.config.indexer?.clojure?.configPath,this.indexerConcurrency=e.config.indexerConcurrency,this.onStatus=e.onStatus??(()=>{}),this.onReindexComplete=e.onReindexComplete??(()=>{}),this.onReindexError=e.onReindexError??(()=>{}),this.onRefreshSuppressed=e.onRefreshSuppressed??(()=>{}),this.onError=e.onError??(r=>console.error(r.message)),this.clock=e.clock??_r,Zt.set(this,ei(e.stopTimeoutMs??Qt,"watcher stop timeout")),this.reindexRunner=e.reindexRunner??Ur(),this.subscriptionFactory=e.subscriptionFactory??jr,this.budgetInspector=e.budgetInspector??pt,er.set(this,{projectRoot:e.projectRoot,config:e.config,gitReader:e.gitReader??et,languages:rr(e.languages??e.config.languages),typeScriptInputPaths:null,stagedIndexEntries:null}),this.gitignoreFilter=dt(e.projectRoot),this.extraIgnore=Wr(),this.watchConfig.ignore.length>0&&this.extraIgnore.add(this.watchConfig.ignore),Vt(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(e){this.onError(new Error(`Failed to watch ${this.projectRoot}: ${String(e)}`))}}stop(){if(this.stopPromise)return this.stopPromise;this.stopped=!0,this.stopInProgress=!0;let e=this.fsWatchers;this.fsWatchers=[],this.clearDebounceTimer(),this.clearCooldownTimer(),this.clearBudgetTimer(),this.clearGitPollTimer();let r=this.activeOperation;r&&this.setStatus({state:"draining",startedAt:this.wallNow(),reason:"waiting for the active reindex worker to exit"});let i=[...re(this).closures],n=Mr(this),s=this.clock.now()+n;return this.stopPromise=this.finishStop(e,i,r,s,n).catch(a=>{throw this.stopInProgress=!1,a}),this.stopPromise}requestRefresh(e,r={}){if(!this.stopped){if(this.markPendingChangesIncomplete(`unstructured-trigger:${e.kind}`),!r.immediate||this.reindexInFlight||this.status.state==="cooldown"||this.status.state==="budget-paused"){this.scheduleReindex(e);return}this.pendingTrigger=We(this.pendingTrigger,e),this.changedFiles+=1,this.clearDebounceTimer(),this.triggerReindex()}}startSourceWatcher(e=!1){let r=this.subscriptionFactory(this.projectRoot,{ignoreInitial:!0,ignored:(i,n)=>this.isIgnoredWatchPath(i,n?.isDirectory()??!1),usePolling:e,ignorePermissionErrors:!0,...e?{interval:5e3,binaryInterval:1e4}:{}});r.on("all",(i,n)=>{!this.stopped&&i!=="addDir"&&i!=="unlinkDir"&&this.handleFileChange(i,n)}),r.on("error",i=>this.handleSourceWatcherError(r,i,e)),this.fsWatchers.push(r)}handleSourceWatcherError(e,r,i){if(this.markPendingChangesIncomplete("source-watcher-error"),i||this.sourcePollingFallbackStarted||!Hr(r)||this.stopped){this.onError(new Error(`Failed to watch ${this.projectRoot}: ${String(r)}`));return}this.sourcePollingFallbackStarted=!0,this.fsWatchers=this.fsWatchers.filter(n=>n!==e),Ar(re(this),e,n=>this.onError(n));try{this.startSourceWatcher(!0)}catch(n){this.onError(new Error(`Failed to watch ${this.projectRoot}: ${String(n)}`))}}isIgnoredWatchPath(e,r){let i=this.relativeWatchPath(e);if(!i)return!1;if(Bt(i,this.localCacheWatchPath))return!0;let n=r?`${i}/`:i;return this.gitignoreFilter.isIgnored(n)||this.extraIgnore.ignores(n)}handleFileChange(e,r){let i=this.relativeWatchPath(r);if(!i||i===".."||i.startsWith("../")||Bt(i,this.localCacheWatchPath)||this.gitignoreFilter.isIgnored(i)||this.extraIgnore.ignores(i)||i.endsWith("index.db")||i.endsWith("index.scip")||i.endsWith("index.db.tmp")||Pr(i).startsWith(ut))return;i===".scipquery.json"&&zt(this,this.projectRoot);let n=Jt(this,e,i);n!==null&&(n||this.markPendingChangesIncomplete(`unsupported-source-event:${e}`),this.scheduleReindex({kind:"watch-source",detail:i},n?[{path:i,kind:n}]:void 0,n!==void 0))}relativeWatchPath(e){let r=Le(e)?e:b(this.projectRoot,e);return Kt(this.projectRoot,r).replaceAll("\\","/")}scheduleReindex(e,r,i=!1){this.pendingTrigger=We(this.pendingTrigger,e),i||this.markPendingChangesIncomplete(`unstructured-trigger:${e.kind}`);for(let s of r??[])this.recordPendingChange(s);if(this.changedFiles++,this.reindexInFlight){this.dirty=!0,this.setStatus({state:"indexing",startedAt:this.status.startedAt});let s=this.activeOperation;s&&_.get(this)!==s&&(_.set(this,s),s.cancel().then(a=>{a.state==="degraded"&&!this.stopped&&this.onError(new Error(a.reason))},a=>{this.stopped||this.onError(a instanceof Error?a:new Error(String(a)))}));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 n=this.wallNow()+this.watchConfig.debounceMs;this.setStatus({state:"waiting",changedFiles:this.changedFiles,reindexAt:n}),this.debounceTimer=this.clock.setTimeout(()=>{this.debounceTimer=null,this.triggerReindex()},this.watchConfig.debounceMs)}triggerReindex(){if(this.reindexInFlight||this.stopped)return;let e=this.inspectBudget(),r=this.watchConfig.allowExpensiveRebuild&&e.state!=="paused";if(e.state==="paused"&&e.reason!=="rebuild-count"){this.dirty=!0;let c=Math.max(this.wallNow()+1,e.until);this.setStatus({state:"budget-paused",until:c,dirty:!0,reason:e.detail,rebuilt:e.rebuilt,estimatedWriteBytes:e.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 l=this.wallNow()+c;this.setStatus({state:"cooldown",until:l,dirty:!0}),this.cooldownTimer=this.clock.setTimeout(()=>{this.cooldownTimer=null,this.dirty&&!this.stopped&&(this.dirty=!1,this.triggerReindex())},c);return}this.reindexInFlight=!0,this.dirty=!1,this.changedFiles=0;let n=this.pendingTrigger??{kind:"watch-source"};this.pendingTrigger=null;let s=this.consumePendingChangeJournal(),a=this.wallNow();this.setStatus({state:"indexing",startedAt:a});let o=this.reindexRunner.start(this.reindexRequest(n,r,s));this.activeOperation=o,o.completion.then(c=>{if(this.reindexInFlight=!1,this.lastReindexEnd=this.clock.now(),te.set(this,0),this.stopped)return;if(_.get(this)===o){if(this.restorePendingChangeJournal(s),this.dirty){let u=this.wallNow()+this.watchConfig.cooldownMs;this.setStatus({state:"cooldown",until:u,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}Vt(this);let l=!1;try{l=this.onReindexComplete(c,n,{pendingChanges:this.dirty})===!0}catch(u){this.onError(u instanceof Error?u:new Error(String(u)))}if(this.dirty&&!this.stopped){if(l){let d=this.pendingTrigger??{kind:"unknown"};this.dirty=!1,this.changedFiles=0,this.pendingTrigger=null,this.resetPendingChanges(),this.onRefreshSuppressed(d),this.setStatus({state:"idle"});return}let u=this.wallNow()+this.watchConfig.cooldownMs;this.setStatus({state:"cooldown",until:u,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 l=c instanceof Error?c:new Error(String(c));this.restorePendingChangeJournal(s);let u=tr(l),d=0;if(u?(d=(te.get(this)??0)+1,te.set(this,d),this.dirty=!0,this.pendingTrigger=We(this.pendingTrigger,n)):te.set(this,0),!u&&_.get(this)!==o&&(this.onReindexError(l,n),this.onError(l)),this.dirty){let h=u?$r(this.watchConfig.cooldownMs,d):this.watchConfig.cooldownMs,p=this.wallNow()+h;this.setStatus({state:"cooldown",until:p,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===o&&(this.activeOperation=null),_.get(this)===o&&_.delete(this)})}async finishStop(e,r,i,n,s){let a=[],o=e.map(async h=>{try{await h.close()}catch(p){a.push(`watch subscription close failed: ${String(p)}`)}});o.push(...r),i&&o.push((async()=>{try{let h=await i.cancel();h.state==="degraded"&&a.push(h.reason)}catch(h){a.push(`reindex cancellation failed: ${h instanceof Error?h.message:String(h)}`)}})());let c=o.length,l=o.map(h=>h.finally(()=>{c-=1})),u=await Er(l,n,this.clock),d=re(this);return a.push(...d.errors),d.errors=[],u?this.stopInProgress=!1:(a.push(`watch shutdown exceeded the ${s}ms deadline with ${c} operation(s) still pending`),Promise.all(l).then(()=>{this.stopInProgress=!1})),a.length>0?(this.setStatus({state:"draining",startedAt:this.wallNow(),reason:a.join("; ")}),{state:"degraded",reasons:a}):(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(e){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: ${e instanceof Error?e.message:String(e)}`}}}reindexRequest(e,r=!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:e,changeJournal:i,allowExpensiveRebuild:r}}setStatus(e){this.status=e,this.onStatus(e)}recordPendingChange(e){if(this.pendingChanges.size>=1024&&!this.pendingChanges.has(e.path)){this.pendingChanges.clear(),this.markPendingChangesIncomplete("change-entry-limit");return}let r=this.pendingChanges.get(e.path),i=Jr(r,e.kind);i===null?this.pendingChanges.delete(e.path):this.pendingChanges.set(e.path,i)}markPendingChangesIncomplete(e){this.pendingChangesComplete=!1,this.pendingChangesIncompleteReason??=e}consumePendingChangeJournal(){let e=q(this.outputDb),r=[...this.pendingChanges.entries()].map(([a,o])=>({path:a,kind:o})).sort((a,o)=>a.path.localeCompare(o.path)),i=this.pendingChangesComplete,n=this.pendingChangesIncompleteReason;e||(i=!1,n??="accepted-generation-unavailable");let s={version:1,baseGeneration:e,complete:i,...n?{incompleteReason:n}:{},entries:r};return xe(s)||(s={version:1,baseGeneration:e,complete:!1,incompleteReason:"change-journal-byte-limit",entries:[]}),this.resetPendingChanges(),s}restorePendingChangeJournal(e){let r=[...this.pendingChanges.entries()].map(([s,a])=>({path:s,kind:a})),i=this.pendingChangesComplete,n=this.pendingChangesIncompleteReason;this.resetPendingChanges(),e.complete||this.markPendingChangesIncomplete(e.incompleteReason??"failed-reindex");for(let s of e.entries)this.recordPendingChange(s);i||this.markPendingChangesIncomplete(n??"failed-reindex");for(let s of r)this.recordPendingChange(s)}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&&(I(this).stagedIndexEntries=Ht(this.projectRoot,I(this).gitReader),this.gitPollTimer=this.clock.setInterval(()=>this.pollGitState(),this.watchConfig.gitPollMs),this.gitPollTimer.unref?.())}pollGitState(){if(this.reindexInFlight||this.stopped)return;let e=this.lastGitState,r=this.readGitState();if(!e||!r||this.stopped){this.lastGitState=r;return}this.lastGitState=r;let i=e.head!==r.head,n=e.indexPath!==r.indexPath||e.indexMtimeMs!==r.indexMtimeMs||e.indexSize!==r.indexSize;if(!i&&!n)return;let s=I(this),a=s.stagedIndexEntries,o=Ht(this.projectRoot,s.gitReader);s.stagedIndexEntries=o;let c=ni(this.projectRoot,s.gitReader,e,r,a,o,i,n),l=null;if(c!==null&&(c.includes(".scipquery.json")&&zt(this,this.projectRoot),l=c.filter(d=>Jt(this,"add",d)!==null),l.length===0))return;let u=l?.map(d=>({path:d,kind:Ae(b(this.projectRoot,d))?"change":"delete"}));i&&n?this.scheduleReindex({kind:"watch-git-state",detail:Ee("HEAD and index changed",l)},u,u!==void 0):i?this.scheduleReindex({kind:"watch-git-head",detail:Ee("HEAD changed",l)},u,u!==void 0):n&&this.scheduleReindex({kind:"watch-git-index",detail:Ee(r.indexPath??"index changed",l)},u,u!==void 0)}readGitState(){if(this.preferFilesystemGitState){let e=this.readFilesystemGitState();if(e)return e}return this.readGitStateFromGit()}readFilesystemGitState(){let e=this.watchGitLayout??Xr(this.projectRoot);if(!e)return null;this.watchGitLayout=e;let r=Kr(e.gitDir);return r?Ut(r,e.indexPath):null}readGitStateFromGit(){let e=I(this).gitReader,r=me(this.projectRoot,["rev-parse","--git-path","index"],e);if(!r)return null;let i=nt(this.projectRoot,r);return Ut(me(this.projectRoot,["rev-parse","--verify","HEAD"],e),i)}clearGitPollTimer(){this.gitPollTimer&&(this.clock.clearInterval(this.gitPollTimer),this.gitPollTimer=null)}};async function Er(t,e,r){if(t.length===0)return!0;let i=Promise.all(t).then(()=>!0),n=Math.max(0,e-r.now()),s=null,a=new Promise(c=>{s=r.setTimeout(()=>c(!1),n)}),o=await Promise.race([i,a]);return o&&s&&r.clearTimeout(s),o}var Nt=new WeakMap,Zt=new WeakMap,er=new WeakMap,_=new WeakMap,te=new WeakMap;function re(t){let e=Nt.get(t);if(e)return e;let r={closures:new Set,errors:[]};return Nt.set(t,r),r}function Mr(t){return Zt.get(t)??Qt}function I(t){let e=er.get(t);if(!e)throw new Error("Watcher input state was not initialized.");return e}function Ar(t,e,r){let i=Promise.resolve().then(()=>e.close()).catch(n=>{let s=`watch subscription close failed during polling fallback: ${String(n)}`;t.errors.push(s),r(new Error(s))});t.closures.add(i),i.then(()=>t.closures.delete(i))}function Lr(t,e=T){let{projectRoot:r,config:i,languages:n,pnpmWorkspaces:s,typescriptProjectMode:a,typescriptProjects:o,clojureConfigPath:c,indexerConcurrency:l,trigger:u}=t,d=B(r),h=Object.keys(d).length>0?d:i,p=O(r,h),m=h.indexer?.typescript,f=h.indexer?.clojure,y=e(process.pid);if(!y)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:r,SCIP_REINDEX_OUTPUT_SCIP:p.indexPath,SCIP_REINDEX_OUTPUT_DB:p.dbPath,SCIP_REINDEX_LANGUAGES:(h.languages??n)?.join(",")??"",SCIP_REINDEX_INDEXER_CONCURRENCY:String(h.indexerConcurrency??l??""),SCIP_REINDEX_PNPM_WORKSPACES:m?.pnpmWorkspaces??s?"1":"",SCIP_REINDEX_TYPESCRIPT_CONFIG:JSON.stringify({projectMode:m?.projectMode??a,projects:m?.projects??o??[],maxHeapMb:m?.maxHeapMb}),SCIP_REINDEX_CLOJURE_CONFIG_PATH:f?.configPath??c??"",SCIP_REINDEX_TRIGGER_KIND:u.kind,SCIP_REINDEX_TRIGGER_DETAIL:u.detail??"",SCIP_REINDEX_CHANGE_JOURNAL:t.changeJournal?xe(t.changeJournal)??"":"",SCIP_REINDEX_ALLOW_EXPENSIVE:t.allowExpensiveRebuild===!1?"0":"1",SCIP_REINDEX_PROCESS_GROUP_LEADER:"1",SCIP_REINDEX_PARENT_IDENTITY:JSON.stringify(y)}}}var _r={now:C,wallNow:()=>Date.now(),setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)},jr=(t,e)=>Gr(process.platform,e.usePolling)?new Me(t):Cr(t,e);function Gr(t,e){return t==="darwin"&&e!==!0}var $=class extends Error{constructor(e,r){super(e,r===void 0?void 0:{cause:r}),this.name="RecursiveSourceWatchError"}},Me=class{events=new kr;watcher;constructor(e){this.watcher=xr(e,{recursive:!0},(r,i)=>{if(i===null){this.events.emit("error",new $("Recursive source watcher omitted the changed path."));return}let n=b(e,i.toString());this.events.emit("all",Dr(r,n),n)}),this.watcher.on("error",r=>{this.events.emit("error",new $(`Recursive source watcher failed: ${r.message}`,r))})}on=(e,r)=>(this.events.on(e,r),this);close(){this.watcher.close()}};function Dr(t,e){return t==="change"?"change":Ae(e)?Xt(e).isDirectory()?"addDir":"add":"unlink"}var Fr=15*6e4,Or=1e3,Nr=64*1024;function qr(){return{stdoutTail:"",stderrTail:"",stdoutTruncated:!1,stderrTruncated:!1}}function qt(t,e){let r=t instanceof Error?t.message:String(t),i=e.stderrTail.trim()||e.stdoutTail.trim();return i?`${r}
2
+ ${i}`:r}function Br(t,e){return Object.assign(new Error(t,e===void 0?void 0:{cause:e}),{retryable:!0})}function tr(t){return t instanceof Error&&"retryable"in t&&t.retryable===!0}function $r(t,e){let r=t*2**Math.min(5,Math.max(0,e-1));return Math.max(t,Math.min(3e4,r))}function Ur(t={}){let e=t.timeoutMs??Fr,r=t.terminationGraceMs??Or,i=t.maxOutputBytes??Nr,n=t.resolveLaunch??Lr;return{start(s){let a=n(s),o=new AbortController,c=qr(),l=!1,u=Ve({command:process.execPath,args:[...process.execArgv,a.workerPath],label:"watch reindex worker",env:a.env,timeoutMs:e,terminationGraceMs:r,maxStdoutBytes:i,maxStderrBytes:i,outputLimitBehavior:"truncate-tail",signal:o.signal,detached:!0}).then(d=>{if(c={stdoutTail:d.stdout,stderrTail:d.stderr,stdoutTruncated:d.stdoutTruncated,stderrTruncated:d.stderrTruncated},d.status!==0){let h=qt(new Error(`Reindex worker exited with ${d.signal?`signal ${d.signal}`:`code ${d.status}`}`),c);throw d.status===75?Br(h):new Error(h)}return d.durationMs}).catch(d=>{throw tr(d)?d:(d instanceof Je&&(c={stdoutTail:d.stdout,stderrTail:d.stderr,stdoutTruncated:d.stdoutTruncated,stderrTruncated:d.stderrTruncated}),new Error(qt(d,c),{cause:d}))}).finally(()=>{l=!0});return{completion:u,async cancel(){l||o.abort();try{await u}catch{}return{state:"exited",diagnostics:c}},diagnostics:()=>c}}}}function We(t,e){return t?t.kind===e.kind?t.detail===e.detail?t:{kind:t.kind,detail:"multiple changes"}:{kind:"watch-git-state",detail:`${t.kind}, ${e.kind}`}:e}function zr(t){if(t==="add")return"add";if(t==="change")return"change";if(t==="unlink")return"delete"}function Jr(t,e){return t?t==="add"?e==="delete"?null:"add":t==="delete"&&e==="add"?"change":e:e}function Vr(t){return t instanceof Error&&"code"in t&&t.code==="EMFILE"||String(t).includes("EMFILE: too many open files")}function Hr(t){return t instanceof $||Vr(t)}var _e=/^[0-9a-f]{40,64}$/i;function Bt(t,e){return t===".git"||t.startsWith(".git/")||t==="node_modules"||t.startsWith("node_modules/")||t.endsWith("/node_modules")||t.includes("/node_modules/")?!0:e!==void 0&&(t===e||t.startsWith(`${e}/`))}function Xr(t){let e=b(t,".git");try{let r=Ir(e),i;if(r.isDirectory())i=e;else if(r.isFile()){let n=/^gitdir:\s*(.+)\s*$/m.exec(R(e,"Git directory marker"));if(!n?.[1])return null;let s=n[1].trim();i=Le(s)?s:Yt(t,s)}else return null;return Ae(i)?{gitDir:i,indexPath:b(i,"index")}:null}catch{return null}}function Kr(t){let e;try{e=R(b(t,"HEAD"),"Git HEAD").trim()}catch{return}if(_e.test(e))return e.toLowerCase();let r=/^ref:\s*(.+)$/.exec(e)?.[1]?.trim();if(!r)return;let i=Yr(t);return $t(t,r)??$t(i,r)??Qr(i,r)}function Yr(t){try{let e=R(b(t,"commondir"),"Git common-directory marker").trim();return e?Le(e)?e:Yt(t,e):t}catch{return t}}function $t(t,e){try{let r=R(b(t,e),"Git reference").trim();return _e.test(r)?r.toLowerCase():void 0}catch{return}}function Qr(t,e){try{for(let r of R(b(t,"packed-refs"),"Git packed references").split(`
3
+ `)){if(r.startsWith("#")||r.startsWith("^"))continue;let i=r.indexOf(" ");if(i===-1)continue;let n=r.slice(0,i);if(r.slice(i+1).trim()===e&&_e.test(n))return n.toLowerCase()}}catch{return}}function Ut(t,e){let r={head:t,indexPath:e};try{let i=Xt(e);r.indexMtimeMs=i.mtimeMs,r.indexSize=i.size}catch{r.indexMtimeMs=void 0,r.indexSize=void 0}return r}function Zr(t,e){let r=Kt(t,e).replaceAll("\\","/");if(!(!r||r===".."||r.startsWith("../")))return r}function ei(t,e){if(!Number.isSafeInteger(t)||t<=0)throw new Error(`${e} must be a positive integer.`);return t}function rr(t){return t&&t.length>0?[...t]:ge}function zt(t,e){try{let r=I(t);r.config=B(e),r.languages=rr(r.config.languages)}catch{I(t).languages=ge}}function Jt(t,e,r){let i=I(t);if(fe(r,i.languages)==="other")return null;let s=zr(e);if(r===".scipquery.json"||ot(r))return i.typeScriptInputPaths=null,s;if(!ti(r,i.languages))return s;let a=i.typeScriptInputPaths;if(!a)return s;let o=a.has(r);if(s!=="add")return o?s:null;if(o)return"change";let c=ir(t);return c?c.has(r)?"add":null:s}function Vt(t){let e=I(t);if(!e.languages.includes("typescript")){e.typeScriptInputPaths=null;return}let r=ri(e.projectRoot,e.config,e.languages);e.typeScriptInputPaths=r??ir(t)}function ir(t){let e=I(t);if(!e.languages.includes("typescript"))return e.typeScriptInputPaths=null,null;try{let r=e.config.indexer?.typescript,i=at(e.projectRoot,r?.projectMode,r?.projects);return e.typeScriptInputPaths=i,i}catch{return e.typeScriptInputPaths=null,null}}function ti(t,e){if(!e.includes("typescript"))return!1;let r=fe(t,["typescript","javascript"]);return r==="source"||r==="ambient"}function ri(t,e,r){try{let i=Xe(R(O(t,e).metaPath,"reindex metadata"));if(i.kind!=="supported"&&i.kind!=="legacy")return null;let n=He(i.metadata.fingerprint);return!n||!ii(n,r,e)?null:new Set(n.files.map(s=>s.path))}catch{return null}}function ii(t,e,r){let i=ct(e,{pnpmWorkspaces:r.indexer?.typescript?.pnpmWorkspaces,typescriptProjectMode:r.indexer?.typescript?.projectMode,typescriptProjects:r.indexer?.typescript?.projects,clojureConfigPath:r.indexer?.clojure?.configPath});return t.version===i.version&&JSON.stringify([...t.languages].sort())===JSON.stringify(i.languages)&&t.pnpmWorkspaces===i.pnpmWorkspaces&&t.typescriptProjectMode===i.typescriptProjectMode&&JSON.stringify([...t.typescriptProjects].sort())===JSON.stringify(i.typescriptProjects)&&t.clojureConfigPath===i.clojureConfigPath}function ni(t,e,r,i,n,s,a,o){let c=new Set;if(a){if(!r.head||!i.head)return null;let l=e.runResult(t,["diff","--name-only","-z","--no-renames","--relative",r.head,i.head,"--"]);if(l.kind!=="success")return null;for(let u of si(l.output))c.add(u)}if(o){if(n===null||s===null)return null;for(let l of ai(n,s))c.add(l)}return[...c].sort()}function Ht(t,e){let r=e.runResult(t,["diff","--cached","--raw","-z","--no-renames","--relative","--"]);return r.kind==="success"?oi(r.output):null}function si(t){return t.split("\0").filter(e=>e.length>0)}function oi(t){let e=t.split("\0");if(e.at(-1)===""&&e.pop(),e.length%2!==0)return null;let r=new Map;for(let i=0;i<e.length;i+=2){let n=e[i],s=e[i+1];if(!n.startsWith(":")||!s)return null;r.set(s,n)}return r}function ai(t,e){return[...new Set([...t.keys(),...e.keys()])].filter(i=>t.get(i)!==e.get(i))}function Ee(t,e){return e===null?`${t}; changed paths unavailable`:e.length===0?t:e.length===1?e[0]:`${e.length} compiler inputs changed`}import{existsSync as ne,lstatSync as U,readdirSync as or,realpathSync as nr,rmSync as j,statSync as ci}from"fs";import{join as S,resolve as z,sep as ar}from"path";var li=3600*1e3,di=2*1024*1024*1024,se=300*1e3,ui="gc-state.json",hi="gc.lock";function pi(t){let e=t.leases.filter(o=>o.managed&&!o.live&&!o.busy),r=fi(t.leases,t.locks),i={};for(let o of t.generations)r.has(o.generationId)||(i[o.generationId]=o.unreferencedAt??t.nowMs);let n=t.generations.filter(o=>!r.has(o.generationId)).sort((o,c)=>i[o.generationId]-i[c.generationId]||o.generationId.localeCompare(c.generationId)),s=new Set;for(let o of n)t.nowMs-i[o.generationId]>=t.policy.generationTtlMs&&s.add(o.generationId);let a=t.generations.filter(o=>!s.has(o.generationId)).reduce((o,c)=>o+c.size,0);for(let o of n){if(a<=t.policy.budgetBytes)break;s.has(o.generationId)||(s.add(o.generationId),a-=o.size)}for(let o of s)delete i[o];return{deleteWorktrees:e,deleteGenerations:t.generations.filter(o=>s.has(o.generationId)),deleteLocks:t.locks.filter(o=>!o.live),deleteTemporaries:t.temporaries.filter(o=>!o.live),protectedGenerationIds:[...r].sort(),unreferencedSince:i}}function fi(t,e){let r=new Set(t.filter(i=>i.managed&&(i.live||i.busy)).flatMap(i=>[i.lease.baseGenerationId,i.lease.activeGenerationId]).filter(i=>i!==void 0));for(let i of e)i.live&&r.add(i.generationId);return r}function cr(t,e,r={}){if(!Ze())return{kind:"disabled"};let i=r.repositoryId===void 0?tt(t)?.repositoryId:r.repositoryId;if(!i)return{kind:"unavailable"};let n=S(F(),"repositories",i),s=(r.now??Date.now)(),a=ne(n)?lr(t,n,i,e,s,r):{kind:"unavailable"};return gi(t,i,e,s,r),a}function lr(t,e,r,i,n,s){let a=S(e,"gc-state.json"),o=vi(a);if(!s.force&&o&&n-Date.parse(o.lastSweepAt)<se)return{kind:"throttled",sweptAt:o.lastSweepAt};let c=st(e,{now:()=>n});if(!c)return{kind:"busy"};try{let l=mi(t,e,r,o?.unreferencedSince??{}),u=pi({nowMs:n,...l,policy:{generationTtlMs:s.policy?.generationTtlMs??li,budgetBytes:s.policy?.budgetBytes??di}}),d=0,h=0;for(let f of u.deleteWorktrees){if(!De(f.lease))continue;if(!ne(f.lease.localCacheDir)){j(f.leasePath,{force:!0}),h+=1;continue}if(!yi(f.lease))continue;let y=ye(S(f.lease.localCacheDir,"cache-lifecycle.lock"));if(y)try{if(je(f.lease,!0))continue;try{Mt({projectRoot:f.lease.projectRoot,cacheDir:f.lease.localCacheDir,cliVersion:i})}catch{continue}if(je(f.lease,!0))continue;j(f.lease.localCacheDir,{recursive:!0,force:!0}),j(f.leasePath,{force:!0}),h+=1}finally{y.release()}}for(let f of u.deleteLocks)j(f.path,{force:!0});for(let f of u.deleteTemporaries)j(f.path,{recursive:!0,force:!0});for(let f of u.deleteGenerations)j(f.path,{recursive:!0,force:!0}),d+=f.size;lt(S(e,"evidence.db"));let p={kind:"swept",sweptAt:new Date(n).toISOString(),deletedWorktrees:h,deletedGenerations:u.deleteGenerations.length,deletedBytes:d,protectedGenerations:u.protectedGenerationIds.length},m={version:1,lastSweepAt:p.sweptAt,unreferencedSince:u.unreferencedSince,lastResult:p};return Se(a,m,{spacing:2,trailingNewline:!0}),p}catch(l){return{kind:"failed",error:l instanceof Error?l.message:String(l)}}finally{c.release()}}function gi(t,e,r,i,n){let s=S(F(),"repositories");if(!ne(s))return;let a=S(s,ui),o=Ri(a);if(!n.force&&o!==void 0&&i-o<se)return;let c=ye(S(s,hi));if(c)try{for(let l of J(s)){if(l===e||!/^[a-f0-9]{24}$/.test(l))continue;let u=S(s,l),d;try{d=U(u)}catch{continue}if(!d.isDirectory()||d.isSymbolicLink())continue;let h=Si(u)??t;lr(h,u,l,r,i,n)}Se(a,{version:1,lastSweepAt:new Date(i).toISOString()},{spacing:2,trailingNewline:!0})}finally{c.release()}}function mi(t,e,r,i){let n=new Set(it(t).map(l=>z(l.path))),s=[];for(let l of J(S(e,"worktrees"))){if(!l.endsWith(".json"))continue;let u=S(e,"worktrees",l),d=dr(u);if(!d)continue;let h=z(d.projectRoot);s.push({leasePath:u,lease:d,managed:d.repositoryId===r&&De(d),live:n.has(h)||ne(h),busy:je(d)})}let a=[];for(let l of J(S(e,"locks"))){let u=/^([a-f0-9]{64})\.lock$/.exec(l);if(!u)continue;let d=S(e,"locks",l),h=Ge(d),p=h!==void 0&&M(h),m=u[1];a.push({generationId:m,path:d,live:p})}let o=[],c=[];for(let l of J(S(e,"generations"))){let u=/^\.tmp-(\d+)-/.exec(l);if(u){let p=S(e,"generations",l),m=Number(u[1]);try{c.push({path:p,size:sr(p),live:Number.isSafeInteger(m)&&M(m)})}catch{}continue}if(!/^[a-f0-9]{64}$/.test(l))continue;let d=S(e,"generations",l),h;try{h=U(d)}catch{continue}!h.isDirectory()||h.isSymbolicLink()||o.push({generationId:l,path:d,size:sr(d),...i[l]===void 0?{}:{unreferencedAt:i[l]}})}return{leases:s,generations:o,locks:a,temporaries:c}}function De(t){if(t.ownershipChecksum!==ft(t)||N(t.localCacheDir)!==N(Qe(t.projectRoot)))return!1;let e=N(S(F(),"projects"));return N(t.localCacheDir).startsWith(`${e}${ar}`)}function yi(t){if(!De(t))return!1;let e=z(F()),r=z(S(e,"projects")),i=z(t.localCacheDir);try{let n=U(e),s=U(r),a=U(i);if(!n.isDirectory()||n.isSymbolicLink()||!s.isDirectory()||s.isSymbolicLink()||!a.isDirectory()||a.isSymbolicLink())return!1;let o=nr(r);return nr(i).startsWith(`${o}${ar}`)}catch{return!1}}function Si(t){for(let e of J(S(t,"worktrees"))){if(!e.endsWith(".json"))continue;let r=dr(S(t,"worktrees",e));if(r)return r.projectRoot}}function je(t,e=!1){for(let i of e?["index.lock"]:["index.lock","cache-lifecycle.lock"]){let n=Ge(S(t.localCacheDir,i));if(n!==void 0&&M(n))return!0}let r=Ge(Y(t.localCacheDir).lockPath);return r!==void 0&&M(r)}function dr(t){try{let e=JSON.parse(R(t,"worktree cache lease"));return e.version!==1||typeof e.repositoryId!="string"||typeof e.worktreeId!="string"||typeof e.projectRoot!="string"||e.treeOid!==void 0&&typeof e.treeOid!="string"||typeof e.localCacheDir!="string"||e.baseGenerationId!==void 0&&typeof e.baseGenerationId!="string"||e.activeGenerationId!==void 0&&typeof e.activeGenerationId!="string"||typeof e.ownershipChecksum!="string"||!/^[a-f0-9]{64}$/.test(e.ownershipChecksum)||typeof e.lastAction!="string"||e.lastReason!==void 0&&typeof e.lastReason!="string"||typeof e.lastSeenAt!="string"?null:e}catch{return null}}function Ge(t){try{let e=JSON.parse(R(t,"watch lock record"));return typeof e.pid=="number"&&Number.isSafeInteger(e.pid)&&e.pid>0?e.pid:void 0}catch{return}}function vi(t){try{let e=JSON.parse(R(t,"repository cache GC state"));return e.version!==1||typeof e.lastSweepAt!="string"||!Number.isFinite(Date.parse(e.lastSweepAt))||!e.unreferencedSince||typeof e.unreferencedSince!="object"||!e.lastResult?null:e}catch{return null}}function Ri(t){try{let e=JSON.parse(R(t,"global repository cache GC state"));if(e.version!==1||typeof e.lastSweepAt!="string")return;let r=Date.parse(e.lastSweepAt);return Number.isFinite(r)?r:void 0}catch{return}}function J(t){try{return or(t)}catch{return[]}}function sr(t){let e=0,r=[t];for(;r.length>0;){let i=r.pop();for(let n of or(i,{withFileTypes:!0})){let s=S(i,n.name);n.isDirectory()?r.push(s):n.isFile()&&(e+=ci(s).size)}}return e}var oe=class{root;now;randomId;retryDelayMs;active;retryNotBeforeMs=0;currentStatus;constructor(e,r={}){this.root=e,this.now=r.now??Date.now,this.randomId=r.randomId,this.retryDelayMs=Math.max(1,Math.floor(r.retryDelayMs??1e3)),this.currentStatus=Ce(e)}initializeAfterOwnershipAcquired(){let e=Ct(this.root),r=Wt(this.root,{now:()=>new Date(this.now())});return this.refreshStatus(),{recoveredClaims:e,prunedHistory:r}}observeLegacyRequest(e,r){kt(this.root,r??"stale index observed by a legacy command",{idempotencyKey:`legacy-activity:${e}`,now:()=>new Date(e)}),this.refreshStatus()}poll(e,r){if(this.active||e.state!=="idle"||this.now()<this.retryNotBeforeMs)return!1;let i=Pt(this.root,{now:()=>new Date(this.now()),...this.randomId?{randomId:this.randomId}:{}});if(this.refreshStatus(),i.requests.length===0)return!1;this.active=i;try{return r(wi(i)),!0}catch(n){throw Te(this.root,i),this.active=void 0,this.retryNotBeforeMs=this.now()+this.retryDelayMs,this.refreshStatus(),n}}completeActive(){return this.active?(Tt(this.root,this.active,()=>new Date(this.now())),this.active=void 0,this.retryNotBeforeMs=0,this.refreshStatus(),!0):!1}failActive(){return this.active?(Te(this.root,this.active),this.active=void 0,this.retryNotBeforeMs=this.now()+this.retryDelayMs,this.refreshStatus(),!0):!1}status(){return{...this.currentStatus}}refreshStatus(){this.currentStatus=Ce(this.root)}};function wi(t){if(t.requests.length===1)return t.requests[0].detail;let r=[...new Set(t.requests.map(i=>i.detail))].slice(0,3).join("; ");return`${t.requests.length} coalesced refresh requests${r?`: ${r}`:""}`.slice(0,2048)}import{randomUUID as Ii}from"crypto";import{rmSync as xi}from"fs";import{Worker as ki}from"worker_threads";var ae=class{constructor(e){this.options=e;if(this.now=e.now??Date.now,this.setTimer=e.setTimer??setTimeout,this.clearTimer=e.clearTimer??clearTimeout,e.maxWorkerFailureRetries!==void 0&&(!Number.isInteger(e.maxWorkerFailureRetries)||e.maxWorkerFailureRetries<0))throw new Error("Worker maxWorkerFailureRetries must be a non-negative integer.")}options;now;setTimer;clearTimer;worker=null;active=null;activeFailure=null;terminating=null;closed=!1;workerGeneration=0;idleTimer=null;canAccept(){return!this.closed&&this.active===null&&this.terminating===null}hasWorker(){return this.worker!==null}start(e){if(!this.canAccept())return!1;if(this.clearIdleTimer(),e.deadlineAtMs<this.now()){try{this.options.onReject(e,`${this.options.name} request expired before processing.`)}catch(n){this.closed=!0,this.options.onFatal(Fe(n))}return!0}let r=this.ensureWorker(),i=this.deadlineTimer(e);this.active={request:e,timer:i,workerFailureRetries:0,workerFailureReasons:[]};try{r.postMessage({kind:"request",...e})}catch(n){this.failActiveAfterTermination(Oe(n),!0)}return!0}async close(e=`${this.options.name} service is shutting down.`){if(this.closed=!0,this.clearIdleTimer(),this.active){await this.failActiveAfterTermination(e);return}await this.terminateWorker()}ensureWorker(){if(this.worker)return this.worker;let e=this.options.createWorker(),r=++this.workerGeneration;return e.on("message",i=>this.handleMessage(r,i)),e.on("error",i=>{r===this.workerGeneration&&this.failActiveAfterTermination(`${this.options.name} worker failed: ${i.message}`,!0)}),e.on("exit",i=>{r!==this.workerGeneration||this.terminating||(this.worker=null,this.active&&this.failActiveAfterTermination(`${this.options.name} worker exited unexpectedly with code ${i}.`,!0))}),this.worker=e,e}handleMessage(e,r){if(e!==this.workerGeneration||this.closed||!this.active)return;let i=bi(r);if(!i){this.failActiveAfterTermination(`${this.options.name} worker returned an invalid response.`);return}if(i.requestId!==this.active.request.requestId){this.failActiveAfterTermination(`${this.options.name} worker returned a mismatched request identity.`);return}if(this.now()>this.active.request.deadlineAtMs){this.failActiveAfterTermination(`${this.options.name} request expired while it was processing.`);return}let n=this.active,s;try{this.options.onStatus(i.status),i.ok?this.options.onComplete(n.request,i.result,i.status):this.options.onReject(n.request,i.error,i.status),s=this.options.retireAfterResponse?.(i.status)??!1}catch(a){this.closed=!0,this.clearTimer(n.timer),this.options.onFatal(Fe(a));return}this.releaseActive(n),s?this.terminateWorker():this.scheduleIdleTermination()}async failActiveAfterTermination(e,r=!1){if(this.activeFailure){await this.activeFailure;return}let i=this.active;if(!i){await this.terminateWorker();return}this.clearTimer(i.timer),r&&i.workerFailureReasons.push(e);let n=(async()=>{if(!await this.terminateWorker())return;let a=this.options.maxWorkerFailureRetries??0;if(r&&!this.closed&&i.workerFailureRetries<a&&this.now()<=i.request.deadlineAtMs){i.workerFailureRetries+=1;try{let c=this.ensureWorker();i.timer=this.deadlineTimer(i.request),c.postMessage({kind:"request",...i.request});return}catch(c){let l=`Cold Worker retry failed: ${Oe(c)}`;if(i.workerFailureReasons.push(l),e=`${e} ${l}`,!await this.terminateWorker())return}}let o=i.workerFailureReasons.length===0?e:[...new Set([...i.workerFailureReasons,e])].join(" Cold Worker retry: ");try{this.options.onReject(i.request,o)}catch(c){this.closed=!0,this.options.onFatal(Fe(c));return}this.releaseActive(i)})();this.activeFailure=n;try{await n}finally{this.activeFailure===n&&(this.activeFailure=null)}}deadlineTimer(e){let r=Math.max(1,Math.min(2147483647,e.deadlineAtMs-this.now()));return this.setTimer(()=>{this.failActiveAfterTermination(`${this.options.name} request exceeded its deadline.`)},r)}releaseActive(e){this.active===e&&(this.active=null,this.clearTimer(e.timer))}scheduleIdleTermination(){let e=this.options.idleTtlMs;!e||e<=0||this.closed||this.active||!this.worker||(this.clearIdleTimer(),this.idleTimer=this.setTimer(()=>{this.idleTimer=null,!(this.closed||this.active||!this.worker)&&this.terminateWorker()},e))}clearIdleTimer(){this.idleTimer&&(this.clearTimer(this.idleTimer),this.idleTimer=null)}async terminateWorker(){if(this.clearIdleTimer(),this.terminating)return this.terminating;let e=this.worker;if(!e)return!0;this.worker=null;let r=++this.workerGeneration;return this.terminating=(async()=>{try{return await e.terminate(),!0}catch(i){return this.closed=!0,this.options.onFatal(new Error(`${this.options.name} worker termination failed: ${Oe(i)}`,{cause:i})),!1}finally{r===this.workerGeneration&&(this.terminating=null)}})(),this.terminating}};function bi(t){if(!t||typeof t!="object")return null;let e=t;if(e.kind!=="response"||typeof e.requestId!="string"||!("status"in e))return null;if(e.ok===!0){if(!("result"in e)||"error"in e)return null}else if(e.ok===!1){if("result"in e||typeof e.error!="string")return null}else return null;return e}function Fe(t){return t instanceof Error?t:new Error(String(t))}function Oe(t){return t instanceof Error?t.message:String(t)}var Pi=6e4,Ti=10*6e4;function ur(t){let e=t.maxActiveSessions??8,r=t.workerSoftMemoryMb??Wi(t.workerHeapMb),i=()=>({protocolVersion:K,state:"idle",requests:0,sessionsCreated:0,sessionsReplaced:0,sessionsEvicted:0,activeSessions:0,maxActiveSessions:e,softMemoryLimitBytes:r*1024*1024,retireRequested:!1,initializations:0,programUpdates:0,documentsEmitted:0,documentsRemoved:0});return pr({name:"TypeScript index",paths:t.paths,now:t.now,limits:t.limits,initialStatus:i,parseEnvelope:vt,createWorker:()=>gr(t,{kind:"index",projectRoot:t.projectRoot,dbPath:t.dbPath,maxActiveSessions:e,softMemoryLimitMb:r}),complete(n,s,a,o){we(t.paths,n,{ok:!0,protocolVersion:K,id:s.id,baseGeneration:s.baseGeneration,response:a},{nowMs:o,limits:t.limits})},reject(n,s,a,o){be(t.paths,n,{ok:!1,protocolVersion:K,id:s,error:a},a,{nowMs:o,limits:t.limits})},idleTtlMs:t.workerIdleMs??Ti,maxWorkerFailureRetries:1,retireAfterResponse:n=>n.retireRequested===!0,statusWhenWorkerAbsent:n=>({...n,state:"idle",activeSessions:0,heapUsedBytes:0,retireRequested:!1}),onBusy:t.onBusy,onFatal:t.onFatal})}function hr(t){let e=()=>({protocolVersion:Z,state:"idle",requests:0,sessionsCreated:0,sessionsReused:0,sessionsRefreshed:0,sessionsReplaced:0,projectsCreated:0});return pr({name:"TypeScript semantic",paths:t.paths,now:t.now,limits:t.limits,initialStatus:e,parseEnvelope:xt,createWorker:()=>gr(t,{kind:"semantic",projectRoot:t.projectRoot}),complete(r,i,n,s){we(t.paths,r,{ok:!0,protocolVersion:Z,id:i.id,generation:i.generation,response:n},{nowMs:s,limits:t.limits})},reject(r,i,n,s){be(t.paths,r,{ok:!1,protocolVersion:Z,id:i,error:n},n,{nowMs:s,limits:t.limits})},idleTtlMs:Pi,onBusy:t.onBusy,onFatal:t.onFatal})}function pr(t){let e=t.now??Date.now,r=T(process.pid),i={pid:process.pid,...r?{processIdentity:r}:{}},n=`${t.name.toLowerCase().replaceAll(" ","-")}-${process.pid}-${Ii()}`,s={...t.limits,maxBatch:1},a=null,o=t.initialStatus(),c=!1,l=p=>{c=!0,t.onFatal(p)},u=new ae({name:t.name,createWorker:t.createWorker,now:e,idleTtlMs:t.idleTtlMs,maxWorkerFailureRetries:t.maxWorkerFailureRetries,retireAfterResponse:t.retireAfterResponse,onComplete(p,m,f){let y=d(p.requestId);o=f;let x=e();try{t.complete(y.claim,y.envelope,m,x)}catch(k){if(!(k instanceof ve))throw k;try{t.reject(y.claim,y.envelope.id,k.message,x)}catch(P){if(!(P instanceof ve))throw P;xi(y.claim.path,{force:!0})}}h(y)},onReject(p,m,f){let y=d(p.requestId);f!==void 0&&(o=f),t.reject(y.claim,y.envelope.id,m,e()),h(y)},onStatus(p){o=p},onFatal:l});return{poll(){if(c||!u.canAccept())return 0;let p=gt(t.paths,{ownerId:n,nowMs:e(),limits:s,owner:i,liveness:{isProcessAlive:M,readProcessIdentity:T}})[0];if(!p)return 0;let m=p.requestId;try{let f=t.parseEnvelope(mt(p,s));if(m=f.id,f.id!==p.requestId)throw new Error(`${t.name} request identity does not match its mailbox path.`);if(f.deadlineAtMs<e())throw new Error(`${t.name} request expired before processing.`);if(a={claim:p,envelope:f},t.onBusy?.(f.deadlineAtMs),!u.start({requestId:f.id,deadlineAtMs:f.deadlineAtMs,payload:f}))throw new Error(`${t.name} worker lane closed admission after claiming a request.`)}catch(f){let y=Mi(f);try{t.reject(p,m,y,e()),a?.claim===p&&h(a)}catch(x){l(Ei(x))}}return 1},status(){return{...u.hasWorker()||!t.statusWhenWorkerAbsent?o:t.statusWhenWorkerAbsent(o),mailbox:yt(t.paths)}},async close(p){await u.close(p)}};function d(p){let m=a;if(!m||m.envelope.id!==p)throw new Error(`${t.name} parent lost the active mailbox claim.`);return m}function h(p){a===p&&(a=null,t.onBusy?.(void 0))}}var Ci=6144;function fr(){let t=Number.parseInt(process.env.SCIP_TS_WORKER_HEAP_MB??"",10);return Number.isFinite(t)&&t>0?t:Ci}function Wi(t){return Math.max(1,Math.floor((t??fr())*.9))}function gr(t,e){if(t.createWorker)return t.createWorker(e);let r=t.workerUrl??new URL("./typescript-mailbox-worker.js",import.meta.url);return new ki(r,{workerData:e,resourceLimits:{maxOldGenerationSizeMb:t.workerHeapMb??fr()}})}function Ei(t){return t instanceof Error?t:new Error(String(t))}function Mi(t){return t instanceof Error?t.message:String(t)}var yr=2e3,_i=5e3,ji=5e3,Gi=6e4,Di=10,Fi=50,Oi=1e4;function Ni(t,e=1){return Ke(t,e,Di,Fi,Oi,8)}function qi(t,e){let r;return{begin(){return r||(e.requestStop(),e.closeWake(),r=t.stop(),r.catch(()=>{})),r}}}async function Bi(t,e){let r=e.processIndexRequests(),i=e.processSemanticRequests(),n=r+i,s=n>0?0:t+1;if(e.afterMailboxPoll({indexRequests:r,semanticRequests:i,processedRequests:n}),e.shouldStop())return{indexRequests:r,semanticRequests:i,processedRequests:n,consecutiveIdlePolls:s,stopped:!0};let a=Ni(n,s);return await e.wait(a),{indexRequests:r,semanticRequests:i,processedRequests:n,consecutiveIdlePolls:s,stopped:!1,delayMs:a}}function $i(t){return t==="fresh"?null:{kind:"watch-startup",detail:`index ${t} when watch service started`}}function Ui(t){At(t.statePath,{version:1,protocolVersion:Rt,pid:v.pid,...t.processIdentity?{processIdentity:t.processIdentity}:{},projectRoot:t.projectRoot,...t.worktreeId?{worktreeId:t.worktreeId}:{},cliVersion:t.cliVersion,startedAt:new Date(t.startedAtMs).toISOString(),heartbeatAt:new Date(t.nowMs).toISOString(),lastActivityAt:new Date(t.lastActivityAtMs).toISOString(),...t.idleTimeoutMs===0?{}:{idleDeadlineAt:new Date(t.lastActivityAtMs+t.idleTimeoutMs).toISOString()},watcher:t.watcherStatus,...t.watcherStatus.state==="idle"&&t.indexGeneration?{indexGeneration:t.indexGeneration}:{},...t.lastRefresh?{lastRefresh:t.lastRefresh}:{},...t.lastError?{lastError:t.lastError}:{},reindexActivity:t.reindexActivity,refreshRequests:t.refreshCoordinator.status(),typescriptSemantic:{...t.semanticLane.status(),...t.semanticBusyUntilMs===void 0?{}:{busyUntil:new Date(t.semanticBusyUntilMs).toISOString()}},typescriptIndex:{...t.indexLane.status(),...t.indexBusyUntilMs===void 0?{}:{busyUntil:new Date(t.indexBusyUntilMs).toISOString()}}},{durability:t.durability})}function zi(t){let e=0,r=Number.NEGATIVE_INFINITY,i=Number.NEGATIVE_INFINITY,n=Number.NEGATIVE_INFINITY,s=Number.NEGATIVE_INFINITY;return({processedRequests:a})=>{let o=C();if(o-i>=ji&&(i=o,!Ft(t.worktreeLiveness))){t.requestStop();return}if(o-s>=Gi&&(s=o,Ie(t.indexMailboxPaths),Ie(t.semanticMailboxPaths)),o-n>=se&&(n=o,cr(t.projectRoot,t.cliVersion)),o-r>=_i){r=o;let c=Lt(t.activityPath);c&&t.updateObservedActivity(c.atMs,o),c?.refreshRequestedAtMs!==void 0&&c.refreshRequestedAtMs>e&&(e=c.refreshRequestedAtMs,t.refreshCoordinator.observeLegacyRequest(c.refreshRequestedAtMs,c.refreshDetail??"stale index observed by a legacy command"))}t.refreshCoordinator.poll(t.watcherStatus(),c=>{t.recordActivity(),t.requestRefresh(c)}),a>0&&(t.recordActivity(),t.persistState(!0,"visibility")),t.persistState()}}async function Ji(t){let e,r=0,i=!1,n,s;v.once("SIGINT",t.stopSignal),v.once("SIGTERM",t.stopSignal);try{t.watcher.start();let o=t.initializeFreshness();for(t.recordActivity(),t.markReady(),t.persistState(!0),e=setInterval(()=>t.persistState(),yr),e.unref?.(),o&&t.requestRefresh(o);!t.stopRequested();){let c=await Bi(r,{processIndexRequests:t.processIndexRequests,processSemanticRequests:t.processSemanticRequests,afterMailboxPoll:t.afterMailboxPoll,shouldStop:t.shouldStop,wait:t.wait});if(r=c.consecutiveIdlePolls,c.stopped)break}}catch(o){i=!0,n=o}finally{v.off("SIGINT",t.stopSignal),v.off("SIGTERM",t.stopSignal),e!==void 0&&clearInterval(e);let o=t.shutdown.begin();await t.closeLanes();let c=await o;c.state==="stopped"?t.finalizeStopped():s=t.finalizeDegraded(c.reasons)}let a=t.mailboxFatalError();if(!i&&a&&(i=!0,n=a),i&&s)throw new AggregateError([n,s],"Watch service execution and shutdown both failed.");if(i)throw n;if(s)throw s}function Vi(t){let e=hr({paths:t.semanticPaths,projectRoot:t.projectRoot,onBusy:t.onSemanticBusy,onFatal:t.onFatal}),r=t.config.indexer?.typescript,i=ur({paths:t.indexPaths,projectRoot:t.projectRoot,dbPath:t.dbPath,...r?.maxWarmSessions===void 0?{}:{maxActiveSessions:r.maxWarmSessions},...r?.workerIdleMs===void 0?{}:{workerIdleMs:r.workerIdleMs},...r?.workerSoftMemoryMb===void 0?{}:{workerSoftMemoryMb:r.workerSoftMemoryMb},...r?.workerHeapMb===void 0?{}:{workerHeapMb:r.workerHeapMb},onBusy:t.onIndexBusy,onFatal:t.onFatal});return{semanticLane:e,indexLane:i}}async function Hi(t,e,r={}){let i=Et(t,e),n=i.projectRoot,s=i.worktreeKind==="git"?Xi(n,i.worktreeId):void 0,a=Dt(n,s),o=B(n);o.watch={...o.watch,...r};let c=Q(o);if(!c.enabled)throw new Error('watch mode is disabled; set "watch.enabled": true before starting the service');let l=O(n,o),u=Y(l.cacheDir),d=T(v.pid),h=_t(u.lockPath,n,{readProcessIdentity:g=>g===v.pid?d:T(g)});if(!h.acquired)return;let p=new oe(u.refreshRequestsPath,{retryDelayMs:Math.max(1e3,c.cooldownMs)});p.initializeAfterOwnershipAcquired();let m=Date.now(),f=C(),y=m,x=f,k={state:"idle"},P,ce,W,le,de=X(l.dbPath),V=!1,Ne=!1,qe=Number.NEGATIVE_INFINITY,Be,$e,G=It(l.cacheDir),D=St(l.cacheDir);Re(G),Re(D);let Ue=Pe([D.pendingDir,D.legacyRequestDir,G.pendingDir,G.legacyRequestDir,u.refreshRequestsPath]),w=(g=!1,E=g?"durable":"visibility")=>{if(!Ne)return;let pe=Date.now(),L=C();!g&&L-qe<yr||(qe=L,Ui({statePath:u.statePath,durability:E,processIdentity:d,projectRoot:n,worktreeId:i.worktreeId,cliVersion:e,startedAtMs:m,nowMs:pe,lastActivityAtMs:y,idleTimeoutMs:c.idleTimeoutMs,watcherStatus:k,indexGeneration:P,lastRefresh:ce,lastError:W,reindexActivity:de,refreshCoordinator:p,semanticLane:ue,indexLane:he,semanticBusyUntilMs:Be,indexBusyUntilMs:$e}))},A=()=>{y=Date.now(),x=C()},Sr=g=>{A(),le??=g,W={at:new Date().toISOString(),message:g.message},w(!0,"visibility")},{semanticLane:ue,indexLane:he}=Vi({semanticPaths:G,indexPaths:D,projectRoot:n,dbPath:l.dbPath,config:o,onSemanticBusy(g){Be=g===void 0?void 0:g+5e3,w(!0,"visibility")},onIndexBusy(g){$e=g===void 0?void 0:g+5e3,w(!0,"visibility")},onFatal:Sr}),H=new ie({projectRoot:n,config:{...o,watch:c},outputDb:l.dbPath,languages:o.languages,onStatus(g){k=g,g.state!=="idle"&&(P=void 0),g.state!=="idle"&&A(),w(!0)},onReindexComplete(g,E,pe){A();let L=pe?.pendingChanges!==!1?ke(n,o,l):bt(l);return ce=L.lastRefresh,P=L.state==="fresh"?q(l.dbPath)??void 0:void 0,de=X(l.dbPath),p.completeActive(),W=void 0,w(!0),L.state==="fresh"},onReindexError(){p.failActive()},onRefreshSuppressed(g){let E=ht(l.dbPath,g);E.state==="failed"&&(W={at:new Date().toISOString(),message:`Suppressed-refresh telemetry was not recorded: ${E.reason}`},w(!0,"visibility")),de=X(l.dbPath)},onError(g){A(),P=void 0,W={at:new Date().toISOString(),message:g.message},w(!0)}}),ze=qi(H,{requestStop(){V=!0},closeWake(){Ue.close()}}),vr=()=>{ze.begin()},Rr=zi({worktreeLiveness:a,indexMailboxPaths:D,semanticMailboxPaths:G,projectRoot:n,cliVersion:e,activityPath:u.activityPath,refreshCoordinator:p,watcherStatus:()=>k,requestRefresh:g=>H.requestRefresh({kind:"watch-demand",detail:g},{immediate:!0}),requestStop:()=>{V=!0},recordActivity:A,updateObservedActivity(g,E){g<=y||(y=g,x=E)},persistState:w});await Ji({watcher:H,shutdown:ze,stopSignal:vr,initializeFreshness(){let g=ke(n,o,l);return ce=g.lastRefresh,P=g.state==="fresh"?q(l.dbPath)??void 0:void 0,$i(g.state)},markReady:()=>{Ne=!0},recordActivity:A,persistState:w,requestRefresh:g=>H.requestRefresh(g,{immediate:!0}),stopRequested:()=>V,processIndexRequests:()=>he.poll(),processSemanticRequests:()=>ue.poll(),afterMailboxPoll:Rr,shouldStop:()=>V||le!==void 0||jt({watcher:k,lastActivityAtMs:x,nowMs:C(),idleTimeoutMs:c.idleTimeoutMs}),wait:g=>Ue.wait(g),closeLanes:()=>Promise.all([ue.close("TypeScript semantic service stopped before completing the request."),he.close("TypeScript index service stopped before completing the request.")]).then(()=>{}),mailboxFatalError:()=>le,finalizeStopped(){mr(u.statePath,{force:!0}),mr(u.activityPath,{force:!0}),h.release()},finalizeDegraded(g){return W={at:new Date().toISOString(),message:`Watch service shutdown is degraded: ${g.join("; ")}`},w(!0),new Error(W.message)}})}function Xi(t,e){let r=rt(t);if(r.kind!=="worktree"||r.identity.worktreeId!==e)throw new Error(`Git worktree identity changed while starting the watch service for ${t}.`);return r.identity.gitDir}function Ki(t,e={report:r=>console.error(r),exit:r=>v.exit(r)}){return e.report(`watch-service: ${wt(t instanceof Error?t.message:String(t))}`),e.exit(1)}var Yi=v.argv[1]?Li(Ai(v.argv[1])).href:null;if(Yi===import.meta.url){let t=v.argv[2],e=v.argv[3],r=Qi(v.argv[4]);if(!t||!e)console.error("watch-service: expected <project-root> <cli-version>"),v.exitCode=1;else try{await Hi(t,e,r)}catch(i){Ki(i)}}function Qi(t){if(!t)return{};try{let e=JSON.parse(t);return e&&typeof e=="object"?e:{}}catch{return{}}}export{Pe as createPathChangeWake,qi as createWatchServiceShutdown,Bi as runWatchServiceLoopIteration,Hi as runWatchServiceServer,$i as startupRefreshTrigger,Ki as terminateWatchServiceProcess,Ni as watchServiceLoopDelayMs};
4
4
  //# sourceMappingURL=watch-server.js.map
@@ -77,7 +77,7 @@ The current envelope is schema version 1:
77
77
  {
78
78
  "kind": "scip-query-result",
79
79
  "schemaVersion": 1,
80
- "producer": { "name": "scip-query", "version": "0.21.0" },
80
+ "producer": { "name": "scip-query", "version": "0.21.1" },
81
81
  "command": "refs",
82
82
  "operationRole": "repository-observation",
83
83
  "resultSchemaVersion": 1,
@@ -268,7 +268,7 @@ exact command that opts into output pages. The paged command returns:
268
268
  {
269
269
  "kind": "scip-query-output-page",
270
270
  "schemaVersion": 1,
271
- "producer": { "name": "scip-query", "version": "0.21.0" },
271
+ "producer": { "name": "scip-query", "version": "0.21.1" },
272
272
  "command": "architecture",
273
273
  "contentType": "application/json",
274
274
  "agentInstruction": "INCOMPLETE EVIDENCE: do not draw conclusions or report completion from this partial page. Run page.continuation.command exactly, then repeat until page.complete is true.",
@@ -153,7 +153,7 @@ An unavailable frontier is a relationship class for which no registered analyzer
153
153
 
154
154
  | Command | Description | Cost | Closes disclosed gaps with | Options |
155
155
  |---|---|---|---|---|
156
- | `reindex` | Index the codebase and convert to SQLite | variable | - | `-l, --language <lang>`<br>`--pnpm-workspaces`<br>`--force`<br>`--allow-partial`<br>`--trust-project-tools`<br>`--install-missing`<br>`--indexer-concurrency <n>`<br>`--json`<br>`--result-only`<br>`--compact` |
156
+ | `reindex` | Index the codebase and convert to SQLite | variable | - | `-l, --language <lang>`<br>`--pnpm-workspaces`<br>`--force`<br>`--allow-partial`<br>`--allow-expensive-rebuild`<br>`--trust-project-tools`<br>`--install-missing`<br>`--indexer-concurrency <n>`<br>`--json`<br>`--result-only`<br>`--compact` |
157
157
  | `augment-sources` | Add source files skipped by upstream SCIP indexers to the SQLite documents table | variable | - | - |
158
158
  | `augment-vue` | Add compiler-resolved Vue SFC references to the SQLite index using Volar | variable | - | `--project <tsconfig>` |
159
159
 
@@ -278,7 +278,7 @@ An unavailable frontier is a relationship class for which no registered analyzer
278
278
 
279
279
  | Command | Description | Cost | Closes disclosed gaps with | Options |
280
280
  |---|---|---|---|---|
281
- | `install-skills` | Install skills (scip-query, scip-plan, scip-setup, scip-integrity-audit) into Claude Code, Codex, and shared agent roots | variable | - | - |
281
+ | `install-skills` | Install skills (scip-query, scip-explore, scip-plan, scip-setup, scip-integrity-audit) into Claude Code, Codex, and shared agent roots | variable | - | - |
282
282
  | `check-deps` | Check whether scip-query and the detected language indexers are runnable | bounded | `inspect`, `code` | - |
283
283
  | `capabilities` | Report which mapping and analysis capabilities are available in this project | bounded | `inspect`, `code` | `--matrix`<br>`--json`<br>`--result-only`<br>`--compact` |
284
284
  | `init` | Create a .scipquery.json configuration file for this project | variable | - | - |
@@ -82,6 +82,14 @@
82
82
  "additionalProperties": true,
83
83
  "properties": {
84
84
  "enabled": { "type": "boolean" },
85
+ "autoStart": {
86
+ "type": "boolean",
87
+ "description": "Whether ordinary commands may automatically start the background watch service. Explicit watch commands remain available when false."
88
+ },
89
+ "allowExpensiveRebuild": {
90
+ "type": "boolean",
91
+ "description": "Permit watcher-triggered whole-project indexers after an incremental miss. Defaults to false so a watcher cannot silently start an expensive fallback."
92
+ },
85
93
  "debounceMs": { "type": "integer", "exclusiveMinimum": 0 },
86
94
  "cooldownMs": {
87
95
  "type": "integer",
@@ -114,7 +122,9 @@
114
122
  "configPath": { "type": "string", "minLength": 1 },
115
123
  "maxWarmSessions": { "type": "integer", "exclusiveMinimum": 0 },
116
124
  "workerIdleMs": { "type": "integer", "minimum": 0 },
117
- "workerSoftMemoryMb": { "type": "integer", "exclusiveMinimum": 0 }
125
+ "workerSoftMemoryMb": { "type": "integer", "exclusiveMinimum": 0 },
126
+ "workerHeapMb": { "type": "integer", "exclusiveMinimum": 0 },
127
+ "maxHeapMb": { "type": "integer", "exclusiveMinimum": 0 }
118
128
  }
119
129
  },
120
130
  "entryRoots": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scip-query",
3
- "version": "0.21.0",
3
+ "version": "0.22.0",
4
4
  "description": "Evidence and verification for AI coding agents: map code, reuse concepts, finish migrations, and gate diffs.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -20,7 +20,8 @@
20
20
  "scripts/scip-windows-provenance.mjs",
21
21
  "scripts/verify-scip-windows.mjs",
22
22
  "skills/**/*.md",
23
- "skills/**/agents/*.yaml"
23
+ "skills/**/agents/*.yaml",
24
+ "skills/**/scripts/*.mjs"
24
25
  ],
25
26
  "sideEffects": false,
26
27
  "exports": {
@@ -360,8 +361,8 @@
360
361
  "scripts": {
361
362
  "build": "node --max-old-space-size=16384 ./node_modules/tsup/dist/cli-default.js",
362
363
  "dev": "tsup --watch",
363
- "format": "prettier --write \"{src,tests,scripts}/**/*.{ts,tsx,js,mjs,json}\" \"*.{ts,js,json}\"",
364
- "format:check": "prettier --check \"{src,tests,scripts}/**/*.{ts,tsx,js,mjs,json}\" \"*.{ts,js,json}\"",
364
+ "format": "prettier --write \"{src,tests,scripts}/**/*.{ts,tsx,js,mjs,json}\" \"skills/**/scripts/*.{js,mjs}\" \"*.{ts,js,json}\"",
365
+ "format:check": "prettier --check \"{src,tests,scripts}/**/*.{ts,tsx,js,mjs,json}\" \"skills/**/scripts/*.{js,mjs}\" \"*.{ts,js,json}\"",
365
366
  "test": "vitest run --maxWorkers=2",
366
367
  "soak:cache-lifecycle": "npm run build && vite-node scripts/cache-lifecycle-soak.ts",
367
368
  "test:watch": "vitest",
@@ -370,7 +371,7 @@
370
371
  "api:report": "node scripts/api-surface-contract.mjs report",
371
372
  "api:check": "npm run build && node scripts/api-surface-contract.mjs check && tsc -p tests/fixtures/public-api-consumer/tsconfig.json",
372
373
  "api:update": "npm run build && node scripts/api-surface-contract.mjs update",
373
- "lint": "npm run format:check && eslint src tests tsup.config.ts scripts/api-surface-contract.mjs scripts/audit-production-dependencies.mjs scripts/benchmark-cold-reindex.ts scripts/benchmark-graph-literal.ts scripts/benchmark-query-service.ts scripts/benchmark-reindex-accounting.ts scripts/benchmark-source-search.ts scripts/build-scip-windows.mjs scripts/cache-lifecycle-soak.ts scripts/codex-exploration-sandbox.mjs scripts/codex-exploration-trial-core.mjs scripts/codex-exploration-trial.mjs scripts/compare-exploration-trials.mjs scripts/exploration-benchmark-core.mjs scripts/exploration-benchmark.mjs scripts/npm-release-state.ts scripts/npm-release.ts scripts/publish-scip-windows.ts scripts/release-npm-guard.ts scripts/release-npm.ts scripts/scip-windows-package-identity.ts scripts/scip-windows-provenance.mjs scripts/scip-windows-release.ts scripts/verify-identity-collision-cli.mjs scripts/verify-scip-windows.mjs scripts/verify-scip-windows-registry.ts && npm run api:check && node scripts/check-skill-links.mjs",
374
+ "lint": "npm run format:check && eslint src tests tsup.config.ts scripts/api-surface-contract.mjs scripts/audit-production-dependencies.mjs scripts/benchmark-cold-reindex.ts scripts/benchmark-graph-literal.ts scripts/benchmark-query-service.ts scripts/benchmark-reindex-accounting.ts scripts/benchmark-source-search.ts scripts/build-scip-windows.mjs scripts/cache-lifecycle-soak.ts scripts/codex-exploration-sandbox.mjs scripts/codex-exploration-trial-core.mjs scripts/codex-exploration-trial.mjs scripts/compare-exploration-trials.mjs scripts/exploration-benchmark-core.mjs scripts/exploration-benchmark.mjs scripts/npm-release-state.ts scripts/npm-release.ts scripts/publish-scip-windows.ts scripts/release-npm-guard.ts scripts/release-npm.ts scripts/scip-windows-package-identity.ts scripts/scip-windows-provenance.mjs scripts/scip-windows-release.ts scripts/verify-identity-collision-cli.mjs scripts/verify-scip-windows.mjs scripts/verify-scip-windows-registry.ts skills/scip-explore/scripts/capture-evidence.mjs && npm run api:check && node scripts/check-skill-links.mjs",
374
375
  "build:scip-windows": "node scripts/build-scip-windows.mjs",
375
376
  "verify:scip-windows": "node scripts/verify-scip-windows.mjs",
376
377
  "verify:identity-collision-cli": "node scripts/verify-identity-collision-cli.mjs",
@@ -1,8 +1,78 @@
1
1
  ---
2
2
  name: scip-explore
3
- description: Compatibility alias for the canonical scip-query exploration skill. Use only when an existing prompt explicitly requests scip-explore.
3
+ description: Understand a repository system end to end before explaining, planning, changing, or reviewing it. Use when the task depends on how behavior enters the system, branches, transforms data, crosses runtimes, changes state, reaches consumers, or recovers from failure across multiple symbols or files. Apply scip-query as the evidence instrument; this skill owns the system model, evidence ledger, synthesis, and stopping test. Skip it for a single exact source lookup whose answer is already local.
4
4
  ---
5
5
 
6
- # SCIP Explore compatibility alias
6
+ # SCIP Explore
7
7
 
8
- This name remains for a transition period so existing agent prompts do not fail. Apply `$scip-query`; it contains the canonical command/question manual, typed-relationship controls, source-reading controls, and coverage semantics. Do not combine the two skills or treat this alias as a separate exploration phase.
8
+ A repository system is the set of cooperating code, runtime mechanisms, and state resources whose coordinated behavior turns an initiating input into observable consequences. To understand one end to end is to reconstruct that behavior from its initiating boundary through every material decision, transformation, handoff, state change, result, and recovery path within the user's scope.
9
+
10
+ `$scip-query` is the sensing skill: it locates exact referents, projects typed relationships, reads implementation, and reports evidence strength and coverage. Load it before querying. This skill is the investigation skill: it decides which facts the answer must establish, integrates the observations, and decides when the system is understood well enough to answer. Do not duplicate the command manual here or treat either skill as a fixed command sequence.
11
+
12
+ ## Build the proof target
13
+
14
+ Before querying, restate the user's question as a checkable capability or decision. Then create a small private evidence ledger. An evidence ledger is a working record whose rows bind each material claim to the evidence needed to settle it. A material claim is a repository fact whose truth could change the requested explanation, decision, plan, or edit.
15
+
16
+ Start with three to seven rows, normally one for each distinct clause in the user's question. A row must be atomic enough that one status applies to every part of it. Split a row when different predicates, outcomes, fields, bounds, or failure paths require different evidence. Do not add rows merely because an unrelated implementation exposes more behavior.
17
+
18
+ Give each row one status:
19
+
20
+ - `unresolved`: no sufficient evidence yet;
21
+ - `established`: exact or adequately calibrated evidence supports the claim within stated coverage;
22
+ - `unsupported`: a named provider or source limitation prevents the claim;
23
+ - `excluded`: the claim cannot change the requested answer, with the reason recorded.
24
+
25
+ Derive rows from the question, not from a generic checklist. For an end-to-end behavior, test whether the answer depends on these five parts of the causal spine:
26
+
27
+ 1. origin and ownership — what initiates the behavior, which entry surface receives it, and which long-lived or per-invocation owner controls it;
28
+ 2. decisions and transformations — which predicates, authorization checks, precedence rules, bounds, defaults, sibling outcomes, extension hooks, and data reshaping alter what happens;
29
+ 3. crossings and effects — which runtime mechanisms carry the work, which state or external resources are observed or changed, and in what order;
30
+ 4. observation — which return value, emitted event, notification, durable record, or downstream consumer makes the result visible;
31
+ 5. failure and recovery — which retry, rejection, rollback, cleanup, interruption rule, later repair, or post-loop maintenance follows an incomplete or completed path.
32
+
33
+ These are possible fact classes, not assumptions that every system contains all five. Mark an absent class `excluded` only when evidence shows it cannot alter the answer. For comparisons, keep separate rows for both paths and for each discriminator between them.
34
+
35
+ Read [references/information-model.md](references/information-model.md) only when the user asks for the capability inventory, a ledger row needs a specialized analysis beyond the ordinary relationship families, or provider support is uncertain. It maps the complete kinds of information scip-query can expose to the system claims they can and cannot establish. Do not load it for routine end-to-end exploration.
36
+
37
+ When collaboration tools are available and authorized, and the main agent will continue from the investigation into planning, editing, or review, prefer a fresh delegated explorer for a multi-symbol causal spine. Read [references/delegated-exploration.md](references/delegated-exploration.md) before the main context performs repository exploration. The explorer owns read-only acquisition; the main agent receives only a claim-complete ledger, retains all mutation and user-facing authority, and revalidates affected claims after edits. Do not delegate a single exact lookup whose result is already local.
38
+
39
+ When `SCIP_EXPLORE_EVIDENCE_DIR` and `SCIP_EXPLORE_LEDGER` are set, read [references/external-evidence.md](references/external-evidence.md) before querying. That runner has requested external evidence mode: complete packets stay outside model context, bounded receipts support the investigation, and a claim-complete ledger becomes the only input to a fresh synthesis phase.
40
+
41
+ ## Establish the causal spine
42
+
43
+ Start from the most discriminating exact referent already present in the request. Locate one only when needed. Reuse returned symbols and `file:line` identities as graph roots; do not rediscover the same unit through synonyms.
44
+
45
+ Treat all exact text already visible in a locator, inspect slice, or code receipt as located. Do not search for a function, call expression, constant, or message that is already present in delivered source. Do not run `outline` after exact source has already exposed the relevant unit boundaries. If a root has produced two failed or non-settling locator/outline attempts, use the best exact `file:line` already known with one bounded `inspect` and reassess the claim; do not alternate among more locators. A claim is not unsupported or excludable while a delivered exact identity or recovery command can settle a material clause.
46
+
47
+ When a locator returns competing implementations, make authoritative scope the first ledger row. Before reading either implementation body, compare only the evidence that can identify which path answers the question: external entry surfaces, incoming execution, ownership, consumers, or runtime handoffs. A core type, newer package, first search result, or public export is not ingress. Treat one path as authoritative only when exact evidence connects it to the scope named by the question. If one bounded comparison plus its exact relevant recovery cannot do that, preserve every plausibly live implementation as a separate scope; an ambiguous general question requires each live scope to be explained to the requested depth or explicitly left unresolved. Do not silently choose one, and do not exclude another without evidence that it cannot answer the question.
48
+
49
+ For a lifecycle, distinguish scheduling from execution and completion from later maintenance. If work is queued, establish both the event that creates the pending work and the later owner that observes and processes it, including their ordering. If plugins or other extension points can inject, replace, or transform material input, treat those operations as behavior rather than incidental calls. Include later filtering, reconstruction, pruning, or cleanup when it changes what a future consumer observes.
50
+
51
+ Select relationships because they can settle named ledger rows. Include the initiating owner as a root or request incoming execution when an end-to-end account needs ingress. Batch independent roots and related families when their evidence belongs to the same open question. When the interface supports concurrent tool calls, issue independent observations in one wave while preserving one complete result and cursor chain per command. Never combine results through a shortening pipe or abandon a printed `Continue exactly:` cursor; transport completion is required before coverage can be evaluated. Do not request every family to see what appears. Use graph evidence for relationships between units and behavior/source evidence for predicates inside a selected unit; neither substitutes for the other.
52
+
53
+ After each packet:
54
+
55
+ - record its normalized request and every delivered exact source interval; before another query, reject an exact duplicate and subtract already covered ranges locally;
56
+ - update only the ledger rows that its evidence actually establishes;
57
+ - preserve evidence strength, coverage, exact bounds, defaults, branch predicates, separately handled fields, ownership scope, state identity, ordering, and cleanup effects;
58
+ - mark a row `established` only when the selected behavior supports every clause in that row; an accurate high-level sentence does not settle omitted guards, markers, fields, stop conditions, or sibling outcomes;
59
+ - treat the exact formula of any configurable threshold, budget, or bound that changes selection as material; treat a durable reduction marker as unresolved until its later consumer and exact model-facing substitution are established or the provider reports that frontier unsupported;
60
+ - name the remaining gap before another query;
61
+ - follow a printed fold, recovery command, or adjacent identity only when it can close that gap;
62
+ - use `inspect --view behavior` for a named behavioral gap and `code` only when exact syntax can change the conclusion.
63
+
64
+ If two consecutive packets neither establish a row nor split one using a newly discovered behavior-changing fact, stop expanding that root and reassess the selected authority, relationship family, or ledger. Do not compensate for a weak root with more source.
65
+
66
+ At an input boundary, keep decoding or parsing separate from validation even when source nests them in one expression. Establish both failure paths before assigning a response: a validator that returns a failure result does not catch an exception or rejected promise raised while its argument is being produced. Preserve which enclosing handler catches that earlier failure.
67
+
68
+ Calls and exact runtime handoffs establish executable reachability within their stated coverage. Dataflow, state, temporal, contract, identity, ownership, reference, and dependency evidence establish only the relationship they name. A candidate is a lead requiring confirmation. A bounded or unsupported result cannot establish absence. If scip-query reports a specific unsupported frontier, use a native read only for that frontier and record why the exception was necessary.
69
+
70
+ ## Synthesize the system
71
+
72
+ Condense observations into one causal account: when the initiating condition holds, the identified owner evaluates the material decisions, transforms or transfers the identified data, changes the identified state in the established order, and exposes the established result; on the relevant failure path, the established recovery behavior follows.
73
+
74
+ This causal account is not a chronology of files read. Organize it by what makes the behavior occur. Keep structurally different operations separate: a returned default is not a thrown rejection; a cache invalidation is not a generic state update; an enqueue is not successful consumption; local source order is not cross-process completion.
75
+
76
+ Before answering or editing, audit the draft against the ledger and every selected statement-complete behavior packet. Repair answer-side omissions from evidence already delivered instead of querying again. Preserve every material predicate, hard bound, default, separately merged field, durable effect, externally visible ordering, and cleanup action. If an unsupported row limits the conclusion, state that limit in the answer.
77
+
78
+ Stop when every material row is `established`, `unsupported`, or `excluded`, no contradiction remains among the rows, and no exact in-scope recovery command could change the answer. Packet completion, a plausible narrative, elapsed time, query count, and token cost are not stopping conditions.
@@ -1,4 +1,4 @@
1
1
  interface:
2
- display_name: 'SCIP Explore (compatibility)'
3
- short_description: 'Forward old exploration prompts to SCIP Query'
4
- default_prompt: 'Use $scip-query for this repository exploration. $scip-explore is only a compatibility alias.'
2
+ display_name: 'SCIP Explore'
3
+ short_description: 'Understand repository systems end to end'
4
+ default_prompt: 'Use $scip-explore to understand this repository system end to end before explaining or changing it.'
@@ -0,0 +1,51 @@
1
+ # Delegated live exploration
2
+
3
+ A delegated explorer is a read-only subagent that turns one fixed repository question into a claim-complete evidence ledger for a separate coding agent. Its defining boundary is that it may observe and record the system but cannot change the repository, choose the implementation, grade its own work, or answer the user. The separation keeps acquisition transcripts outside the main coding context while leaving decisions and effects with the agent responsible for them.
4
+
5
+ Use this mode only when the active environment permits subagents and the investigation spans enough owners, branches, crossings, or effects that direct exploration would materially enlarge the main context. The main agent remains responsible for the user's objective, permissions, edits, checks, commits, and final answer.
6
+
7
+ ## Create the checkpoint
8
+
9
+ Before spawning, the main agent:
10
+
11
+ 1. states the exact question and initial material claims without exploring their answers;
12
+ 2. creates one private temporary root outside the repository, containing an evidence directory and ledger path;
13
+ 3. records the current repository root, commit, dirty paths, and intended scope;
14
+ 4. refrains from tracked-source edits until acquisition returns.
15
+
16
+ Start one fresh explorer with no inherited conversation turns. When the collaboration surface supports explicit profiles, request `gpt-5.6-terra` with `xhigh` reasoning for a terminal ledger unless the user selected another profile or broader fixed evaluation has established a better one. Do not silently substitute a different model or reasoning level.
17
+
18
+ Treat `gpt-5.6-sol` with `low` reasoning as an experimental balanced profile, not yet the default. On one frozen OpenCode external-ledger run it recovered 6/7 strict compound facts in 338 seconds for about 43.10 Codex credits, versus Terra-xhigh's 5/7 in 630 seconds for 33.20 credits. It has not been repeated across seeds or task shapes. Use it when the user accepts the measured credit premium for faster turnaround and stronger observed clause retention; disclose that the evidence is one run.
19
+
20
+ Use `gpt-5.6-sol` with `medium` reasoning as an accuracy escalation when a decision-critical compound claim remains unresolved after Terra, or when the user explicitly prioritizes accuracy over credits. On one frozen OpenCode external-ledger run it recovered 7/7 strict compound facts versus Terra-xhigh's 5/7, but cost about 2.5 times as many Codex credits, used 60 semantic queries instead of 23, and has not been repeated across task shapes or seeds. Give Sol the unresolved claim ids and accepted ledger for an audit or targeted delta; do not repeat a complete acquisition unless the earlier ledger is unusable.
21
+
22
+ Treat `gpt-5.6-luna` with `max` reasoning as an experimental economy pre-pass, not as a terminal-ledger replacement. Use it only when the user explicitly prioritizes cost or the result is a preliminary map. Before relying on its ledger for an implementation or compound system claim, give the question and ledger—not its receipts or transcript—to a fresh Terra-xhigh auditor; turn every missing or weakened material clause into a targeted Terra delta. Do not claim that this hybrid saves cost until its complete acquisition, audit, and delta path has been measured.
23
+
24
+ Give the explorer only the question, material-claim seed, repository and temporary paths, observed baseline, and these instructions. Require it to load `$scip-explore` and `$scip-query`, read [external-evidence.md](external-evidence.md), and run each scip-query observation through the capture wrapper with the assigned evidence directory. The explorer may prepare or refresh scip-query's private index when required; it may not edit, stage, commit, run tests, mutate external systems, inspect an evaluation rubric, or broaden the user's scope.
25
+
26
+ The explorer writes either a complete base ledger or a blocked ledger. Its visible response is exactly `LEDGER_READY <absolute-ledger-path>` or `LEDGER_BLOCKED <absolute-ledger-path>`; it does not paste the ledger, receipts, raw packets, or a user-facing explanation into the subagent response.
27
+
28
+ ## Accept the handoff
29
+
30
+ The main agent reads only the ledger. Accept `LEDGER_READY` only when:
31
+
32
+ - the path is the assigned path and the file is nonempty and bounded;
33
+ - the header names the exact task, scope, baseline, receipts, and observation identities;
34
+ - the scope manifest accounts for every plausibly live production scope from complete locator evidence; a named but unexplored live scope rejects the handoff unless exact routing evidence excludes it;
35
+ - the ledger state is `complete` and no material row remains `unresolved`;
36
+ - every established row has exact citations, evidence strength, and coverage;
37
+ - receipts combined within a claim describe compatible, adequately stable observations.
38
+
39
+ If the explorer returns `LEDGER_BLOCKED`, the signal is malformed, the snapshot changed, or a required identity is unknown, do not silently explore in the main context or downgrade the explorer. Retry a fresh explorer only when a named recoverable gap can be corrected; otherwise tell the user which evidence boundary prevented the handoff.
40
+
41
+ A Sol-low base ledger that fails the scope-manifest or clause-transfer check is not accepted because it is cheaper. Give only the missing scope or claim ids to the configured accuracy escalation as a targeted delta; do not repeat already accepted acquisition.
42
+
43
+ After acceptance, the main agent synthesizes the system and may read only the exact implementation surfaces needed to edit. It never reads raw packets merely to gain confidence. Keep the temporary evidence until the task's verification is complete, then remove only the exact temporary root created for this handoff.
44
+
45
+ ## Revalidate after edits
46
+
47
+ An edit changes the repository snapshot and therefore ends the original ledger's authority over current state. Run `scip-query diff-impact` after a nontrivial change and identify which relied-on claim ids intersect changed or affected symbols and files.
48
+
49
+ A ledger delta is a new read-only handoff that binds an earlier ledger to a later repository snapshot while replacing only claims whose truth or evidence may have changed. Spawn a fresh explorer with the original question, base-ledger checksum, affected claim ids, diff-impact result, and new temporary paths. The delta explorer first ensures scip-query's index reflects the changed tracked sources; an unchanged index-generation identity after an indexed source change cannot authorize the new snapshot. The delta must name the new observation identities, invalidated or superseded ids, replacement terminal rows, and any unchanged rows whose continued applicability it establishes. Do not make the main agent carry the earlier exploration transcript into this pass.
50
+
51
+ The main agent may retain an old claim only when the delta establishes that the change cannot affect it. A moved commit, changed content or index identity, invalidated stability proof, incompatible receipt, or unknown relationship blocks reuse rather than producing a warning.