scip-query 0.22.0 → 0.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (386) hide show
  1. package/CHANGELOG.md +257 -0
  2. package/README.md +11 -0
  3. package/dist/augment-vue-worker.js +1 -1
  4. package/dist/by-kind-XI2CSWEY.js +2 -0
  5. package/dist/call-graph-UONR6JR5.js +2 -0
  6. package/dist/{chunk-FGNCOQUX.js → chunk-2E7CX53V.js} +2 -2
  7. package/dist/chunk-2GRUZAQF.js +43 -0
  8. package/dist/{chunk-DPWKKNKI.js → chunk-2LDBDR6J.js} +2 -2
  9. package/dist/{chunk-JHH5SCZ3.js → chunk-2OOY75BW.js} +2 -2
  10. package/dist/{chunk-XGGBK66W.js → chunk-2R3V3PSD.js} +2 -2
  11. package/dist/chunk-2WC2OEDO.js +4 -0
  12. package/dist/{chunk-57N6LN2A.js → chunk-3AF4TUFK.js} +2 -2
  13. package/dist/{chunk-2RE5OCHZ.js → chunk-3D3QG236.js} +2 -2
  14. package/dist/{chunk-D2MVJSP4.js → chunk-3FHOF22C.js} +2 -2
  15. package/dist/{chunk-7XZGZBSQ.js → chunk-3JKSW6LJ.js} +2 -2
  16. package/dist/chunk-3L2ZBPEX.js +133 -0
  17. package/dist/{chunk-NVSZNESQ.js → chunk-3PJABJSU.js} +2 -2
  18. package/dist/{chunk-WOOAY3PA.js → chunk-3SVF22I5.js} +2 -2
  19. package/dist/{chunk-YAGYMBEX.js → chunk-3WR4E3A3.js} +2 -2
  20. package/dist/chunk-4FTZ4P5G.js +2 -0
  21. package/dist/{chunk-F24G5NBE.js → chunk-4ILJCCXV.js} +2 -2
  22. package/dist/chunk-4UX2F3JX.js +2 -0
  23. package/dist/chunk-4WNW27SX.js +2 -0
  24. package/dist/chunk-5ENOG4VP.js +61 -0
  25. package/dist/{chunk-RHHCLWQ6.js → chunk-64BFSI5I.js} +2 -2
  26. package/dist/chunk-66DVSJQG.js +455 -0
  27. package/dist/{chunk-ISWFRGJ6.js → chunk-6HFCYNYE.js} +2 -2
  28. package/dist/{chunk-Y2VM4CJC.js → chunk-6I6L7Z62.js} +2 -2
  29. package/dist/{chunk-CKRWA452.js → chunk-6PQNKL3G.js} +2 -2
  30. package/dist/{chunk-GPGRZJ3R.js → chunk-6V5CNXL6.js} +2 -2
  31. package/dist/chunk-6VVV4WRR.js +4 -0
  32. package/dist/{chunk-BDGTPN27.js → chunk-7BWFZPPZ.js} +2 -2
  33. package/dist/{chunk-25GWKRUZ.js → chunk-7CYG22FH.js} +2 -2
  34. package/dist/chunk-7F45LJKI.js +2 -0
  35. package/dist/{chunk-4TQU4TX2.js → chunk-7IWV2EG3.js} +2 -2
  36. package/dist/{chunk-UDY7MIAW.js → chunk-AFHTBORT.js} +2 -2
  37. package/dist/chunk-AVRYW5OZ.js +2 -0
  38. package/dist/chunk-B3PYOSCX.js +2 -0
  39. package/dist/{chunk-RNKPYYYE.js → chunk-B5D7QPBE.js} +2 -2
  40. package/dist/{chunk-FFJQZG6J.js → chunk-BBCIS4DX.js} +2 -2
  41. package/dist/chunk-BDUVI7TO.js +3 -0
  42. package/dist/{chunk-BVFYEEBH.js → chunk-BE7ZZTMC.js} +2 -2
  43. package/dist/{chunk-NEIQPFBI.js → chunk-BHVUJOCQ.js} +2 -2
  44. package/dist/chunk-BKVWUP7Y.js +2 -0
  45. package/dist/{chunk-IJMD6BRI.js → chunk-BQGB4HBD.js} +2 -2
  46. package/dist/{chunk-ERCYGVAM.js → chunk-BRV7PIFF.js} +2 -2
  47. package/dist/chunk-CEEZJXEF.js +2 -0
  48. package/dist/{chunk-BTVKZGWT.js → chunk-CIYLO6SI.js} +2 -2
  49. package/dist/chunk-CJZXN4NU.js +2 -0
  50. package/dist/{chunk-VXJJTQYE.js → chunk-CNO7TOKL.js} +2 -2
  51. package/dist/{chunk-ZZ3Z7D56.js → chunk-COF23M5F.js} +2 -2
  52. package/dist/{chunk-ZGW4HLPD.js → chunk-CWFP7GM5.js} +2 -2
  53. package/dist/chunk-D2DHWI3D.js +2 -0
  54. package/dist/{chunk-Q55NF3ZG.js → chunk-D4N5SQ2M.js} +2 -2
  55. package/dist/{chunk-LXQUF2RP.js → chunk-DBRSYFXR.js} +2 -2
  56. package/dist/{chunk-PXXYQK55.js → chunk-DHUIOLDT.js} +2 -2
  57. package/dist/{chunk-KZYID5KV.js → chunk-DIRJWYBM.js} +2 -2
  58. package/dist/{chunk-IKVNEGTW.js → chunk-DIUFNHRJ.js} +2 -2
  59. package/dist/{chunk-CLG6DWVS.js → chunk-DTZCKZEU.js} +2 -2
  60. package/dist/{chunk-Z2PZVKPR.js → chunk-DULC3QFP.js} +2 -2
  61. package/dist/{chunk-AYPDH2LU.js → chunk-DYGHBZ2N.js} +2 -2
  62. package/dist/{chunk-JJ62MTQH.js → chunk-E5R6AQ73.js} +2 -2
  63. package/dist/{chunk-BWVQP3LB.js → chunk-E73UNJTF.js} +2 -2
  64. package/dist/{chunk-GVOMSPGL.js → chunk-EG2CPZMJ.js} +2 -2
  65. package/dist/{chunk-56NQAEPJ.js → chunk-EKV5HX33.js} +2 -2
  66. package/dist/{chunk-GDRJB3SB.js → chunk-EQHFIL6T.js} +2 -2
  67. package/dist/{chunk-EWWY2ZFL.js → chunk-ESIQ66Z7.js} +2 -2
  68. package/dist/chunk-EVFUMY4R.js +3 -0
  69. package/dist/{chunk-ZYM4HOFA.js → chunk-F7DY272B.js} +2 -2
  70. package/dist/chunk-FBN2FGXG.js +2 -0
  71. package/dist/{chunk-AZS7YPCB.js → chunk-FDLOBR6P.js} +2 -2
  72. package/dist/chunk-FESCRNVV.js +5 -0
  73. package/dist/{chunk-URSGGIZX.js → chunk-FFRKR4EQ.js} +2 -2
  74. package/dist/chunk-FGA2U4OR.js +8 -0
  75. package/dist/{chunk-7YQOCABQ.js → chunk-FIQRSHVM.js} +2 -2
  76. package/dist/{chunk-KFVSJX25.js → chunk-FPYLNQPT.js} +2 -2
  77. package/dist/{chunk-FELGD32K.js → chunk-FRUSVINH.js} +2 -2
  78. package/dist/chunk-GAS2LJMP.js +3 -0
  79. package/dist/{chunk-OTSPRVNW.js → chunk-GSP44ENC.js} +2 -2
  80. package/dist/{chunk-K3XFWJI2.js → chunk-GUFSG5TX.js} +2 -2
  81. package/dist/chunk-GYIZ4NXB.js +2 -0
  82. package/dist/{chunk-2OXVP5U5.js → chunk-GZIUDL6G.js} +2 -2
  83. package/dist/chunk-HCXEQRFF.js +18 -0
  84. package/dist/{chunk-LO5JSW2C.js → chunk-HEHOQQKH.js} +2 -2
  85. package/dist/{chunk-U2N2KE7A.js → chunk-HKGFPJ4T.js} +2 -2
  86. package/dist/chunk-HLZTEXRA.js +2 -0
  87. package/dist/{chunk-EELPBR7E.js → chunk-HOENASQM.js} +2 -2
  88. package/dist/{chunk-VTCIYFEK.js → chunk-HVF5VBG6.js} +2 -2
  89. package/dist/{chunk-TH6IC56G.js → chunk-HYO3NP5Q.js} +2 -2
  90. package/dist/{chunk-OPSAW5DT.js → chunk-I55I7XXP.js} +2 -2
  91. package/dist/{chunk-DEAB5TGT.js → chunk-IDFEUFKS.js} +2 -2
  92. package/dist/{chunk-DJAO2OZJ.js → chunk-IHGQTTVW.js} +2 -2
  93. package/dist/{chunk-XU75YQN4.js → chunk-IICPE7B2.js} +2 -2
  94. package/dist/{chunk-GY7CCCEZ.js → chunk-IL676XCC.js} +2 -2
  95. package/dist/{chunk-4HE7MVWD.js → chunk-ILTDAWEF.js} +2 -2
  96. package/dist/chunk-IZDPJ2QI.js +2 -0
  97. package/dist/{chunk-5YRQIE2B.js → chunk-J66VOFW6.js} +2 -2
  98. package/dist/{chunk-SB25YMEQ.js → chunk-JFMEXGFE.js} +2 -2
  99. package/dist/{chunk-QLBSG7U5.js → chunk-JGKUET5J.js} +2 -2
  100. package/dist/{chunk-VZ7NXSHV.js → chunk-JS4PGXMV.js} +2 -2
  101. package/dist/{chunk-ZAZGGSM3.js → chunk-JTQVMR42.js} +2 -2
  102. package/dist/chunk-JWTGMPIT.js +80 -0
  103. package/dist/{chunk-5ZMBRQFC.js → chunk-JYR66JN5.js} +2 -2
  104. package/dist/chunk-KLFEXGQA.js +2 -0
  105. package/dist/chunk-KYSDI3GE.js +5 -0
  106. package/dist/{chunk-MSR2QRUE.js → chunk-L6PJPETJ.js} +2 -2
  107. package/dist/{chunk-VU6LIWHT.js → chunk-LDVT66YM.js} +2 -2
  108. package/dist/chunk-LEECKFCJ.js +2 -0
  109. package/dist/{chunk-H7CG6LOE.js → chunk-LMZ5PRUV.js} +2 -2
  110. package/dist/{chunk-ZPASRBLF.js → chunk-LQRQN2XA.js} +2 -2
  111. package/dist/{chunk-HISEUIL2.js → chunk-LXABEJX3.js} +2 -2
  112. package/dist/{chunk-WHADK6OS.js → chunk-M2O5NY6W.js} +2 -2
  113. package/dist/{chunk-Y334QQU5.js → chunk-MNV5FSBW.js} +2 -2
  114. package/dist/{chunk-RYOYJMGF.js → chunk-MPQ4OTBM.js} +2 -2
  115. package/dist/{chunk-6NC3YSPY.js → chunk-MV3CDXPI.js} +2 -2
  116. package/dist/{chunk-NRBNAECH.js → chunk-MWN53KRN.js} +2 -2
  117. package/dist/chunk-N2ZSIIGR.js +117 -0
  118. package/dist/chunk-N5B2NILC.js +5 -0
  119. package/dist/{chunk-Q6T2CAJL.js → chunk-NJITK2GP.js} +2 -2
  120. package/dist/{chunk-ENWQWA2R.js → chunk-NOGJXYFO.js} +2 -2
  121. package/dist/{chunk-V4NG5OMS.js → chunk-NOYBFVJA.js} +106 -106
  122. package/dist/chunk-NWQXSFFU.js +3 -0
  123. package/dist/chunk-ODDUPDP7.js +13 -0
  124. package/dist/{chunk-A77SCPW2.js → chunk-OLIWTZI3.js} +2 -2
  125. package/dist/{chunk-XFMVKFSF.js → chunk-OLNV6I6U.js} +2 -2
  126. package/dist/{chunk-QKT4UI2Y.js → chunk-OR2E3AGZ.js} +2 -2
  127. package/dist/chunk-OSR2GEHQ.js +2 -0
  128. package/dist/{chunk-5H5WTJSD.js → chunk-OSSESPDX.js} +2 -2
  129. package/dist/{chunk-KQHJEU6V.js → chunk-OWOOWNJ5.js} +2 -2
  130. package/dist/{chunk-GRX7JOXQ.js → chunk-P42EIXTA.js} +2 -2
  131. package/dist/{chunk-AQ2PORIO.js → chunk-PJFGPYTU.js} +2 -2
  132. package/dist/{chunk-LRI5OMPE.js → chunk-PP7KNN7L.js} +2 -2
  133. package/dist/{chunk-PLJUQFQN.js → chunk-PU7T5QYQ.js} +2 -2
  134. package/dist/{chunk-JUN5DOAK.js → chunk-PWWAJSKV.js} +2 -2
  135. package/dist/{chunk-7IQXARSQ.js → chunk-PZL5T7SU.js} +2 -2
  136. package/dist/{chunk-UAQ4T73O.js → chunk-QBE3YX64.js} +2 -2
  137. package/dist/{chunk-3TJY6M3B.js → chunk-QGVTFRY2.js} +2 -2
  138. package/dist/chunk-QOJONDS7.js +2 -0
  139. package/dist/chunk-QU5XRYB5.js +4 -0
  140. package/dist/{chunk-2KVU55CW.js → chunk-QUU5OBVK.js} +2 -2
  141. package/dist/{chunk-Q5TA4OY4.js → chunk-RBLQNW26.js} +2 -2
  142. package/dist/chunk-RTQ7NEKG.js +81 -0
  143. package/dist/{chunk-F24QUEQP.js → chunk-SQXRS7BG.js} +2 -2
  144. package/dist/chunk-SSK6LDPC.js +2 -0
  145. package/dist/chunk-SZHGTCPP.js +7 -0
  146. package/dist/chunk-T4N4P2K5.js +16 -0
  147. package/dist/chunk-TA3QKLLU.js +2 -0
  148. package/dist/chunk-TEBQMNVI.js +43 -0
  149. package/dist/{chunk-NK3JMP22.js → chunk-TPFHAQ2G.js} +2 -2
  150. package/dist/chunk-TQPCBMWT.js +5 -0
  151. package/dist/{chunk-HG722PO7.js → chunk-TRNAEQ6P.js} +2 -2
  152. package/dist/chunk-TY7CRN3Z.js +2 -0
  153. package/dist/{chunk-7XA3OM44.js → chunk-UHFYCMZO.js} +2 -2
  154. package/dist/{chunk-ARVO6TTW.js → chunk-UICY4GTQ.js} +2 -2
  155. package/dist/{chunk-SWK4XPUS.js → chunk-UVGEWT4Y.js} +2 -2
  156. package/dist/{chunk-GIQ6CSL4.js → chunk-UXW33INU.js} +2 -2
  157. package/dist/{chunk-RDULNRSJ.js → chunk-VMPRET3I.js} +2 -2
  158. package/dist/{chunk-I6UTXNHU.js → chunk-VNLGKHS6.js} +2 -2
  159. package/dist/{chunk-44T4DUAA.js → chunk-VQILFTEH.js} +2 -2
  160. package/dist/{chunk-N7FP5H5U.js → chunk-VUPHCS7Y.js} +8 -8
  161. package/dist/{chunk-JAT6C3VX.js → chunk-VVZSBTSU.js} +2 -2
  162. package/dist/{chunk-FBCVASUG.js → chunk-VZRNID6A.js} +2 -2
  163. package/dist/{chunk-TUQIPUDS.js → chunk-W5OXRYGE.js} +2 -2
  164. package/dist/chunk-W6STWDQI.js +57 -0
  165. package/dist/chunk-W7CXK74K.js +2 -0
  166. package/dist/chunk-WB3WYIRE.js +4 -0
  167. package/dist/{chunk-C76O5MDS.js → chunk-WDNVY4E7.js} +2 -2
  168. package/dist/{chunk-TAYD3AE7.js → chunk-WIWY3CRX.js} +2 -2
  169. package/dist/chunk-WK46TNUM.js +3 -0
  170. package/dist/chunk-WNTFFKAX.js +12 -0
  171. package/dist/{chunk-JFQBRL3J.js → chunk-WOIKCX6A.js} +2 -2
  172. package/dist/{chunk-PIFTZEEM.js → chunk-WUN6KBHV.js} +2 -2
  173. package/dist/chunk-WYCTJDVR.js +2 -0
  174. package/dist/chunk-WYPL7GF7.js +2 -0
  175. package/dist/{chunk-XN22RGSR.js → chunk-XBGWL66K.js} +2 -2
  176. package/dist/{chunk-R6M456QG.js → chunk-XDQMU3BT.js} +2 -2
  177. package/dist/{chunk-XJX6LGHL.js → chunk-XFA4SSO3.js} +2 -2
  178. package/dist/{chunk-2YC7YNKT.js → chunk-XGZEP6GR.js} +2 -2
  179. package/dist/chunk-XPDPNWTQ.js +368 -0
  180. package/dist/chunk-XRYABF57.js +8 -0
  181. package/dist/{chunk-YIHNPKWD.js → chunk-YBGKCQIS.js} +2 -2
  182. package/dist/{chunk-2XCGSDIT.js → chunk-YEN6CYC7.js} +2 -2
  183. package/dist/{chunk-VMWUV6WB.js → chunk-YF5IB2LF.js} +2 -2
  184. package/dist/{chunk-TNG2FYS5.js → chunk-YI2AWIHC.js} +2 -2
  185. package/dist/{chunk-EELG7D3Q.js → chunk-YPWBKGFU.js} +2 -2
  186. package/dist/{chunk-GQIDEID3.js → chunk-YPWHBBIS.js} +2 -2
  187. package/dist/{chunk-TKDNDQA7.js → chunk-YSH6U3L4.js} +2 -2
  188. package/dist/{chunk-BUTEIZKP.js → chunk-YU5DZUZI.js} +2 -2
  189. package/dist/chunk-YWO5DDRC.js +16 -0
  190. package/dist/{chunk-6HRZQLOI.js → chunk-Z4CDXYNQ.js} +2 -2
  191. package/dist/{chunk-XSWYJCAK.js → chunk-ZF5KHH7C.js} +2 -2
  192. package/dist/chunk-ZOHS7AQV.js +21 -0
  193. package/dist/{chunk-7U2YQSDE.js → chunk-ZTI4SBFV.js} +2 -2
  194. package/dist/cli-main.js +2 -2
  195. package/dist/code-MI6F2TTU.js +2 -0
  196. package/dist/code-result-json-FXALY4HE.js +2 -0
  197. package/dist/{command-descriptors-ORNTVNYV.js → command-descriptors-P34VABY5.js} +136 -135
  198. package/dist/dataflow-4KEMJPC6.js +2 -0
  199. package/dist/dependence-slice-R7FPWD5M.js +2 -0
  200. package/dist/deps-7EMQUYUT.js +2 -0
  201. package/dist/direct-navigation-6YO234F2.js +3 -0
  202. package/dist/entry-map-KOOLR26E.js +2 -0
  203. package/dist/files-OPIPJIGZ.js +2 -0
  204. package/dist/hierarchy-QPD2CAER.js +2 -0
  205. package/dist/imports-M6HUXRXC.js +2 -0
  206. package/dist/index.js +1 -1
  207. package/dist/members-I5MEFOCT.js +2 -0
  208. package/dist/methods-5JYGGHXA.js +2 -0
  209. package/dist/output-continuation-command-UPQAAKBP.js +3 -0
  210. package/dist/postinstall.js +1 -1
  211. package/dist/project-reindex-UKKQ5PLS.js +3 -0
  212. package/dist/queries/affected.js +1 -1
  213. package/dist/queries/anchors.js +1 -1
  214. package/dist/queries/architecture.js +1 -1
  215. package/dist/queries/bottlenecks.js +1 -1
  216. package/dist/queries/by-kind.js +1 -1
  217. package/dist/queries/call-graph.js +1 -1
  218. package/dist/queries/change-surface.js +1 -1
  219. package/dist/queries/cleanup-plan.js +1 -1
  220. package/dist/queries/co-change.js +1 -1
  221. package/dist/queries/code.js +1 -1
  222. package/dist/queries/complexity-hotspots.js +1 -1
  223. package/dist/queries/complexity.js +1 -1
  224. package/dist/queries/context.js +1 -1
  225. package/dist/queries/convergence.js +1 -1
  226. package/dist/queries/coupling.js +1 -1
  227. package/dist/queries/cycles.js +1 -1
  228. package/dist/queries/dataflow.js +1 -1
  229. package/dist/queries/dead.js +1 -1
  230. package/dist/queries/decorative-checkers.js +1 -1
  231. package/dist/queries/deep-chains.js +1 -1
  232. package/dist/queries/dependence-slice.js +1 -1
  233. package/dist/queries/dependency-depth.js +1 -1
  234. package/dist/queries/deps.js +1 -1
  235. package/dist/queries/diff-impact.d.ts +9 -0
  236. package/dist/queries/diff-impact.js +1 -1
  237. package/dist/queries/doc-drift.js +1 -1
  238. package/dist/queries/drift.js +1 -1
  239. package/dist/queries/duplicate-bodies.js +1 -1
  240. package/dist/queries/entry-map.js +1 -1
  241. package/dist/queries/evidence.js +1 -1
  242. package/dist/queries/extract-candidates.js +1 -1
  243. package/dist/queries/fan.js +1 -1
  244. package/dist/queries/files.js +1 -1
  245. package/dist/queries/health.js +1 -1
  246. package/dist/queries/hierarchy.js +1 -1
  247. package/dist/queries/hotspots.js +1 -1
  248. package/dist/queries/imports.js +1 -1
  249. package/dist/queries/incomplete-migration.js +1 -1
  250. package/dist/queries/index.js +1 -1
  251. package/dist/queries/isolated.js +1 -1
  252. package/dist/queries/locality-candidates.js +1 -1
  253. package/dist/queries/members.js +1 -1
  254. package/dist/queries/methods.js +1 -1
  255. package/dist/queries/not-implemented.js +1 -1
  256. package/dist/queries/outline.js +1 -1
  257. package/dist/queries/passthrough-candidates.js +1 -1
  258. package/dist/queries/plan-context.js +1 -1
  259. package/dist/queries/react-component-duplicates.js +1 -1
  260. package/dist/queries/react-hook-candidates.js +1 -1
  261. package/dist/queries/react-large-component-pressure.js +1 -1
  262. package/dist/queries/recent-duplicates.js +1 -1
  263. package/dist/queries/redundant-reexports.js +1 -1
  264. package/dist/queries/reference-neighborhood.js +1 -1
  265. package/dist/queries/reference-reachability.js +1 -1
  266. package/dist/queries/refs.js +1 -1
  267. package/dist/queries/self-audit.js +1 -1
  268. package/dist/queries/similar-chains.js +1 -1
  269. package/dist/queries/similar-files.js +1 -1
  270. package/dist/queries/similar-signatures.js +1 -1
  271. package/dist/queries/similar.js +1 -1
  272. package/dist/queries/slice.js +1 -1
  273. package/dist/queries/source-inspection.js +1 -1
  274. package/dist/queries/source-search.js +1 -1
  275. package/dist/queries/stale-abstractions.js +1 -1
  276. package/dist/queries/surface.js +1 -1
  277. package/dist/queries/symbols.js +1 -1
  278. package/dist/queries/system-map.js +1 -1
  279. package/dist/queries/system.js +1 -1
  280. package/dist/queries/test-quality.js +1 -1
  281. package/dist/queries/trace.js +1 -1
  282. package/dist/queries/twin-ab.js +1 -1
  283. package/dist/queries/twin-drift.js +1 -1
  284. package/dist/queries/unused-imports.js +1 -1
  285. package/dist/queries/unused-params.js +1 -1
  286. package/dist/queries/value-flow.js +1 -1
  287. package/dist/queries/vue-component-duplicates.js +1 -1
  288. package/dist/queries/vue-composable-candidates.js +1 -1
  289. package/dist/queries/vue-large-view-pressure.js +1 -1
  290. package/dist/queries/wrapper-candidates.js +1 -1
  291. package/dist/query-service-server.js +3 -3
  292. package/dist/refs-PSU4JZZW.js +2 -0
  293. package/dist/refs-pagination-JG6CJMRC.js +2 -0
  294. package/dist/reindex-worker.js +25 -25
  295. package/dist/reindex.d.ts +3 -2
  296. package/dist/reindex.js +35 -35
  297. package/dist/runtime.d.ts +34 -2
  298. package/dist/runtime.js +4 -4
  299. package/dist/rust-semantic-session-server.js +1 -1
  300. package/dist/rust-semantic-session-worker.js +1 -1
  301. package/dist/rust-semantic-worker.js +1 -1
  302. package/dist/{scip-cli-H-n59izO.d.ts → scip-cli-DOerTq-R.d.ts} +42 -4
  303. package/dist/slice-HYRATV64.js +2 -0
  304. package/dist/surface-VTGDYWF5.js +2 -0
  305. package/dist/symbol-resolution-WD5EU5JE.js +2 -0
  306. package/dist/system-LRQNFOR2.js +2 -0
  307. package/dist/trace-F4B6OLL4.js +2 -0
  308. package/dist/typescript-mailbox-worker.js +1 -1
  309. package/dist/value-flow-VRPZY72V.js +2 -0
  310. package/dist/watch-server.js +3 -3
  311. package/package.json +1 -1
  312. package/dist/by-kind-4IYG2SKW.js +0 -2
  313. package/dist/call-graph-WQNXMNNN.js +0 -2
  314. package/dist/chunk-2BTJALUS.js +0 -454
  315. package/dist/chunk-3QXC54FQ.js +0 -3
  316. package/dist/chunk-42W3LFUK.js +0 -13
  317. package/dist/chunk-4GAQ6FI4.js +0 -43
  318. package/dist/chunk-6VEFRPTD.js +0 -5
  319. package/dist/chunk-7C26EKLZ.js +0 -4
  320. package/dist/chunk-7JYHQAH2.js +0 -22
  321. package/dist/chunk-7KSO2OAP.js +0 -2
  322. package/dist/chunk-AK3PYTIK.js +0 -5
  323. package/dist/chunk-AMIMMNA4.js +0 -11
  324. package/dist/chunk-AUY5BL74.js +0 -2
  325. package/dist/chunk-BDHFVH2M.js +0 -18
  326. package/dist/chunk-BECZLYNU.js +0 -8
  327. package/dist/chunk-BYDAFMSR.js +0 -57
  328. package/dist/chunk-BZYSGZRK.js +0 -2
  329. package/dist/chunk-C7IJMOFP.js +0 -134
  330. package/dist/chunk-CBBHFNLX.js +0 -2
  331. package/dist/chunk-D35XIZGN.js +0 -2
  332. package/dist/chunk-DKM723YF.js +0 -79
  333. package/dist/chunk-E44IVWIJ.js +0 -367
  334. package/dist/chunk-EDMB6SSO.js +0 -7
  335. package/dist/chunk-EETGXQY7.js +0 -3
  336. package/dist/chunk-FKGQOTKD.js +0 -2
  337. package/dist/chunk-GH5YSGZL.js +0 -5
  338. package/dist/chunk-HCVJR2V4.js +0 -3
  339. package/dist/chunk-HXOU4XNH.js +0 -3
  340. package/dist/chunk-IMKZEXZG.js +0 -2
  341. package/dist/chunk-ISIQLPJ2.js +0 -61
  342. package/dist/chunk-IXESDH3J.js +0 -2
  343. package/dist/chunk-JT6XX7QY.js +0 -8
  344. package/dist/chunk-MHIEP7EG.js +0 -4
  345. package/dist/chunk-OJNK5ALA.js +0 -2
  346. package/dist/chunk-OXYAWIEA.js +0 -2
  347. package/dist/chunk-OZETODHH.js +0 -2
  348. package/dist/chunk-PBUH2P5S.js +0 -3
  349. package/dist/chunk-PLYUVM4F.js +0 -2
  350. package/dist/chunk-Q7GBK5T7.js +0 -81
  351. package/dist/chunk-QWKHW6VZ.js +0 -2
  352. package/dist/chunk-RPL3ARU7.js +0 -16
  353. package/dist/chunk-SVHTMVA4.js +0 -4
  354. package/dist/chunk-T6QD2ZQB.js +0 -43
  355. package/dist/chunk-TD7VKJ2Y.js +0 -117
  356. package/dist/chunk-TUSPIVZ3.js +0 -4
  357. package/dist/chunk-UT7TADJX.js +0 -2
  358. package/dist/chunk-VUSKPCUB.js +0 -2
  359. package/dist/chunk-WN3TCGJ4.js +0 -2
  360. package/dist/chunk-WSLEJSFR.js +0 -2
  361. package/dist/chunk-WYZIHUPZ.js +0 -16
  362. package/dist/chunk-XE33FV5W.js +0 -2
  363. package/dist/chunk-Z2AWCTN6.js +0 -2
  364. package/dist/chunk-ZOXKSQQB.js +0 -2
  365. package/dist/code-EQJFDT6I.js +0 -2
  366. package/dist/code-result-json-7UWIWBOO.js +0 -2
  367. package/dist/dataflow-6VL54GX5.js +0 -2
  368. package/dist/dependence-slice-DT2NUHD2.js +0 -2
  369. package/dist/deps-DB7H5IKC.js +0 -2
  370. package/dist/direct-navigation-O3LUAYWQ.js +0 -3
  371. package/dist/entry-map-6K62RV3D.js +0 -2
  372. package/dist/files-MSLD7MO6.js +0 -2
  373. package/dist/hierarchy-IVBXAKFA.js +0 -2
  374. package/dist/imports-FRAVZ3Y2.js +0 -2
  375. package/dist/members-KJOJDYGO.js +0 -2
  376. package/dist/methods-2AYABBT3.js +0 -2
  377. package/dist/output-continuation-command-JHMPH6NC.js +0 -3
  378. package/dist/project-reindex-HYO4WD7Z.js +0 -3
  379. package/dist/refs-ARMA6XUJ.js +0 -2
  380. package/dist/refs-pagination-VUGIWN6U.js +0 -2
  381. package/dist/slice-YOB5YFAM.js +0 -2
  382. package/dist/surface-VY5EFWTW.js +0 -2
  383. package/dist/symbol-resolution-DGQN4XIV.js +0 -2
  384. package/dist/system-2KQ3QD2P.js +0 -2
  385. package/dist/trace-HTIPTXAE.js +0 -2
  386. package/dist/value-flow-5FV3VQI7.js +0 -2
@@ -1,2 +1,2 @@
1
- import{b as T}from"./chunk-GRX7JOXQ.js";import{a as M}from"./chunk-CBBHFNLX.js";import{a as P,c as j}from"./chunk-EETGXQY7.js";import"./chunk-C76O5MDS.js";import{c as b,e as v,f as l}from"./chunk-TQZV7KV4.js";import"./chunk-C7IJMOFP.js";import"./chunk-YXPUP5G2.js";import"./chunk-DRENNWRG.js";import{d as g}from"./chunk-7YQOCABQ.js";import"./chunk-QWKHW6VZ.js";import"./chunk-DHEQMPLW.js";import{a as w}from"./chunk-ENWQWA2R.js";import"./chunk-WN3TCGJ4.js";import"./chunk-DKM723YF.js";import{d as f}from"./chunk-K3XFWJI2.js";import"./chunk-NRBNAECH.js";import"./chunk-IW5XQG5G.js";import"./chunk-57N6LN2A.js";import"./chunk-JT6XX7QY.js";import"./chunk-H5EXS3HM.js";import{c as y,d}from"./chunk-HGFDYOVB.js";import{c as m}from"./chunk-SB25YMEQ.js";import{o as h,r as S}from"./chunk-AK3PYTIK.js";import{parentPort as c,workerData as O}from"worker_threads";import{randomUUID as C}from"crypto";import{resolve as R}from"path";var a=class{loadModule;discoverTsconfigs;createProjects;createProvider;db;module=null;projects=null;provider=null;stats={providerRequests:0,sessionsCreated:0,sessionsReused:0,sessionsRefreshed:0,sessionsReplaced:0,projectsCreated:0};constructor(e,t={}){this.db=e,this.loadModule=t.loadModule??b,this.discoverTsconfigs=t.discoverTsconfigs??P,this.createProjects=t.createProjects??v,this.createProvider=t.createProvider??((i,s,o)=>j(i,s,o,{reusedProjects:!0}))}semanticProvider(){return this.stats.providerRequests+=1,this.provider?(this.stats.sessionsReused+=1,this.provider):this.createSession()}advanceGeneration(e,t){let i=q(t);return this.provider?.dispose?.(),this.provider=null,this.db=e,this.projects?i.mode==="replace"?(this.projects=null,this.module=null,this.stats.sessionsReplaced+=1,i):(i.mode==="refresh"&&(D(this.projects,e.config.projectRoot,i),this.stats.sessionsRefreshed+=1),i):i}snapshotStats(){return{...this.stats}}dispose(){this.provider?.dispose?.(),this.provider=null,this.projects=null,this.module=null}createSession(){let e=this.module??this.loadModule();if(!e)return this.provider=l("ts-morph is not installed"),this.provider;if(this.module=e,!this.projects){let t=this.discoverTsconfigs(this.db);if(t.length===0)return this.provider=l("no tsconfig found"),this.provider;this.projects=this.createProjects(e,t),this.stats.projectsCreated+=this.projects.length}return this.provider=this.createProvider(this.db,e,this.projects),this.stats.sessionsCreated+=1,this.provider}};function q(r){let e=new Set;r.projectIdentityChanged&&e.add("project-identity-changed");for(let o of r.uncertainty)e.add(o);for(let o of r.changes)o.inputKind!=="source"&&e.add(`${o.inputKind}-input-changed`);if(e.size>0)return{mode:"replace",addedFiles:[],modifiedFiles:[],deletedFiles:[],reasons:[...e].sort()};let t=u(r.changes,"added"),i=u(r.changes,"modified"),s=u(r.changes,"deleted");return{mode:t.length+i.length+s.length===0?"reuse":"refresh",addedFiles:t,modifiedFiles:i,deletedFiles:s,reasons:[]}}function u(r,e){return r.filter(t=>t.kind===e).map(t=>t.path).sort()}function D(r,e,t){for(let i of r){for(let s of t.deletedFiles)i.project.getSourceFile(R(e,s))?.forget();for(let s of t.modifiedFiles){let o=i.project.getSourceFile(R(e,s));o&&o.refreshFromFileSystemSync()}t.addedFiles.length>0&&i.project.addSourceFilesFromTsConfig(i.tsconfigPath)}}var p=class{openDb;createHost;generationIdentity;readSnapshot;now;db=null;host=null;generation=null;snapshot=null;requests=0;lastRequestAtMs=null;lastError=null;available=null;constructor(e){this.openDb=e.openDb,this.createHost=e.createHost??(t=>new a(t)),this.generationIdentity=e.generationIdentity?t=>e.generationIdentity(t.config.dbPath):t=>t.generation.identity,this.readSnapshot=e.readSnapshot?t=>e.readSnapshot(t.config.dbPath):H,this.now=e.now??Date.now}handle(e,t){try{this.syncGeneration(e);let i=this.host.semanticProvider();switch(this.available=i.availability().available,this.requests+=1,this.lastRequestAtMs=this.now(),this.lastError=null,t.kind){case"availability":return i.availability();case"import-usage":return i.importUsage(t.file);case"references":return[...F(i,t.definitions,{exact:t.exact===!0})];case"reference-fragments":if(!i.referenceFragmentsForFiles)throw new Error("TypeScript provider does not support reference fragments.");return[...i.referenceFragmentsForFiles(t.files)];case"callees":return[...A(i,t.definitions)];case"signature":return i.signatureFor(t.definition);default:return B(t)}}catch(i){throw this.lastError=i instanceof Error?i.message:String(i),i}}status(e){let t=this.host?.snapshotStats();return{protocolVersion:w,state:this.lastError?"error":this.host?this.available?"ready":"unavailable":"idle",requests:this.requests,...this.lastRequestAtMs===null?{}:{lastRequestAt:new Date(this.lastRequestAtMs).toISOString()},...this.lastError?{lastError:this.lastError}:{},sessionsCreated:t?.sessionsCreated??0,sessionsReused:t?.sessionsReused??0,sessionsRefreshed:t?.sessionsRefreshed??0,sessionsReplaced:t?.sessionsReplaced??0,projectsCreated:t?.projectsCreated??0,...e?{mailbox:e}:{}}}closeTypeScriptService(){this.host?.dispose(),this.db?.close(),this.host=null,this.db=null,this.generation=null,this.snapshot=null,this.available=null}syncGeneration(e){if(this.generation===e&&this.host&&this.db)return;let t=this.openDb(),i=this.generationIdentity(t);if(!i||i!==e)throw t.close(),new Error("TypeScript semantic request does not match the currently published index generation.");let s=this.readSnapshot(t);if(!this.host||!this.db)this.db=t,this.host=this.createHost(t);else{let o=this.db;this.host.advanceGeneration(t,N(this.snapshot,s)),this.db=t,o.close()}this.generation=i,this.snapshot=s,this.available=null}};function F(r,e,t){return r.referencesForDefinitions?.(e,t)??new Map(e.map(i=>[i.symbolId,r.referencesFor(i)]))}function A(r,e){return r.calleesForDefinitions?.(e)??new Map(e.map(t=>[t.symbolId,r.calleesFor(t)]))}function H(r){if(!r.generation.metadataRaw)return null;let e=f(r.generation.metadataRaw);return e.kind!=="legacy"&&e.kind!=="supported"||!e.capabilities.usableForEvidenceCache?null:h(e.metadata.fingerprint)}function N(r,e){return e?S(r,e):{version:1,changes:[],projectIdentityChanged:!0,uncertainty:["prior-snapshot-unavailable"]}}function B(r){throw new Error(`Unhandled TypeScript semantic request: ${JSON.stringify(r)}`)}var Z=`typescript-semantic-${process.pid}-${C()}`,x=m(process.pid),ee={pid:process.pid,...x?{processIdentity:x}:{}};var n=L(O);if(!c)throw new Error("TypeScript mailbox worker requires a parent port.");if(n.kind==="index"){let r=new T({projectRoot:n.projectRoot,currentGeneration:()=>g(n.dbPath),...n.maxActiveSessions===void 0?{}:{maxActiveSessions:n.maxActiveSessions},...n.softMemoryLimitMb===void 0?{}:{softMemoryLimitMb:n.softMemoryLimitMb}});c.on("message",e=>{let t=k(e);I(t,()=>r.handle(t.payload.baseGeneration,t.payload.request),()=>r.status())})}else{let r=new p({openDb:()=>M(n.projectRoot)});c.on("message",e=>{let t=k(e),i=y();d(t.payload.profileEnvironment??{});try{I(t,()=>r.handle(t.payload.generation,t.payload.request),()=>r.status())}finally{d(i)}})}function I(r,e,t){let i;try{if(Date.now()>r.deadlineAtMs)throw new Error("TypeScript mailbox request expired before processing.");let s=e();if(Date.now()>r.deadlineAtMs)throw new Error("TypeScript mailbox request expired while the worker was processing it.");i={kind:"response",requestId:r.requestId,ok:!0,result:s,status:t()}}catch(s){i={kind:"response",requestId:r.requestId,ok:!1,error:s instanceof Error?s.message:String(s),status:t()}}c.postMessage(i)}function L(r){if(!r||typeof r!="object")throw new Error("TypeScript mailbox worker data is missing.");let e=r;if(e.kind==="index"&&typeof e.projectRoot=="string"&&typeof e.dbPath=="string"&&E(e.maxActiveSessions)&&E(e.softMemoryLimitMb))return{kind:"index",projectRoot:e.projectRoot,dbPath:e.dbPath,...e.maxActiveSessions===void 0?{}:{maxActiveSessions:e.maxActiveSessions},...e.softMemoryLimitMb===void 0?{}:{softMemoryLimitMb:e.softMemoryLimitMb}};if(e.kind==="semantic"&&typeof e.projectRoot=="string")return{kind:"semantic",projectRoot:e.projectRoot};throw new Error("TypeScript mailbox worker data is invalid.")}function E(r){return r===void 0||Number.isInteger(r)&&r>0}function k(r){if(!r||typeof r!="object")throw new Error("TypeScript mailbox worker request is missing.");let e=r;if(e.kind!=="request"||typeof e.requestId!="string"||!Number.isSafeInteger(e.deadlineAtMs)||typeof e.payload!="object"||e.payload===null)throw new Error("TypeScript mailbox worker request is invalid.");return e}
1
+ import{b as T}from"./chunk-P42EIXTA.js";import{a as M}from"./chunk-KLFEXGQA.js";import{a as P,c as j}from"./chunk-WK46TNUM.js";import"./chunk-IICPE7B2.js";import{c as b,e as v,f as l}from"./chunk-TQZV7KV4.js";import"./chunk-3L2ZBPEX.js";import"./chunk-YXPUP5G2.js";import"./chunk-DRENNWRG.js";import{d as g}from"./chunk-FIQRSHVM.js";import"./chunk-TY7CRN3Z.js";import"./chunk-DHEQMPLW.js";import{a as w}from"./chunk-NOGJXYFO.js";import"./chunk-IZDPJ2QI.js";import"./chunk-WYPL7GF7.js";import"./chunk-RTQ7NEKG.js";import{d as f}from"./chunk-GUFSG5TX.js";import"./chunk-MWN53KRN.js";import"./chunk-IW5XQG5G.js";import"./chunk-3AF4TUFK.js";import"./chunk-FGA2U4OR.js";import"./chunk-B3PYOSCX.js";import"./chunk-H5EXS3HM.js";import{c as y,d}from"./chunk-HGFDYOVB.js";import{c as m}from"./chunk-JFMEXGFE.js";import{c as h,f as S}from"./chunk-KYSDI3GE.js";import"./chunk-7F45LJKI.js";import{parentPort as c,workerData as O}from"worker_threads";import{randomUUID as C}from"crypto";import{resolve as R}from"path";var a=class{loadModule;discoverTsconfigs;createProjects;createProvider;db;module=null;projects=null;provider=null;stats={providerRequests:0,sessionsCreated:0,sessionsReused:0,sessionsRefreshed:0,sessionsReplaced:0,projectsCreated:0};constructor(e,t={}){this.db=e,this.loadModule=t.loadModule??b,this.discoverTsconfigs=t.discoverTsconfigs??P,this.createProjects=t.createProjects??v,this.createProvider=t.createProvider??((i,s,o)=>j(i,s,o,{reusedProjects:!0}))}semanticProvider(){return this.stats.providerRequests+=1,this.provider?(this.stats.sessionsReused+=1,this.provider):this.createSession()}advanceGeneration(e,t){let i=q(t);return this.provider?.dispose?.(),this.provider=null,this.db=e,this.projects?i.mode==="replace"?(this.projects=null,this.module=null,this.stats.sessionsReplaced+=1,i):(i.mode==="refresh"&&(D(this.projects,e.config.projectRoot,i),this.stats.sessionsRefreshed+=1),i):i}snapshotStats(){return{...this.stats}}dispose(){this.provider?.dispose?.(),this.provider=null,this.projects=null,this.module=null}createSession(){let e=this.module??this.loadModule();if(!e)return this.provider=l("ts-morph is not installed"),this.provider;if(this.module=e,!this.projects){let t=this.discoverTsconfigs(this.db);if(t.length===0)return this.provider=l("no tsconfig found"),this.provider;this.projects=this.createProjects(e,t),this.stats.projectsCreated+=this.projects.length}return this.provider=this.createProvider(this.db,e,this.projects),this.stats.sessionsCreated+=1,this.provider}};function q(r){let e=new Set;r.projectIdentityChanged&&e.add("project-identity-changed");for(let o of r.uncertainty)e.add(o);for(let o of r.changes)o.inputKind!=="source"&&e.add(`${o.inputKind}-input-changed`);if(e.size>0)return{mode:"replace",addedFiles:[],modifiedFiles:[],deletedFiles:[],reasons:[...e].sort()};let t=u(r.changes,"added"),i=u(r.changes,"modified"),s=u(r.changes,"deleted");return{mode:t.length+i.length+s.length===0?"reuse":"refresh",addedFiles:t,modifiedFiles:i,deletedFiles:s,reasons:[]}}function u(r,e){return r.filter(t=>t.kind===e).map(t=>t.path).sort()}function D(r,e,t){for(let i of r){for(let s of t.deletedFiles)i.project.getSourceFile(R(e,s))?.forget();for(let s of t.modifiedFiles){let o=i.project.getSourceFile(R(e,s));o&&o.refreshFromFileSystemSync()}t.addedFiles.length>0&&i.project.addSourceFilesFromTsConfig(i.tsconfigPath)}}var p=class{openDb;createHost;generationIdentity;readSnapshot;now;db=null;host=null;generation=null;snapshot=null;requests=0;lastRequestAtMs=null;lastError=null;available=null;constructor(e){this.openDb=e.openDb,this.createHost=e.createHost??(t=>new a(t)),this.generationIdentity=e.generationIdentity?t=>e.generationIdentity(t.config.dbPath):t=>t.generation.identity,this.readSnapshot=e.readSnapshot?t=>e.readSnapshot(t.config.dbPath):H,this.now=e.now??Date.now}handle(e,t){try{this.syncGeneration(e);let i=this.host.semanticProvider();switch(this.available=i.availability().available,this.requests+=1,this.lastRequestAtMs=this.now(),this.lastError=null,t.kind){case"availability":return i.availability();case"import-usage":return i.importUsage(t.file);case"references":return[...F(i,t.definitions,{exact:t.exact===!0})];case"reference-fragments":if(!i.referenceFragmentsForFiles)throw new Error("TypeScript provider does not support reference fragments.");return[...i.referenceFragmentsForFiles(t.files)];case"callees":return[...A(i,t.definitions)];case"signature":return i.signatureFor(t.definition);default:return B(t)}}catch(i){throw this.lastError=i instanceof Error?i.message:String(i),i}}status(e){let t=this.host?.snapshotStats();return{protocolVersion:w,state:this.lastError?"error":this.host?this.available?"ready":"unavailable":"idle",requests:this.requests,...this.lastRequestAtMs===null?{}:{lastRequestAt:new Date(this.lastRequestAtMs).toISOString()},...this.lastError?{lastError:this.lastError}:{},sessionsCreated:t?.sessionsCreated??0,sessionsReused:t?.sessionsReused??0,sessionsRefreshed:t?.sessionsRefreshed??0,sessionsReplaced:t?.sessionsReplaced??0,projectsCreated:t?.projectsCreated??0,...e?{mailbox:e}:{}}}closeTypeScriptService(){this.host?.dispose(),this.db?.close(),this.host=null,this.db=null,this.generation=null,this.snapshot=null,this.available=null}syncGeneration(e){if(this.generation===e&&this.host&&this.db)return;let t=this.openDb(),i=this.generationIdentity(t);if(!i||i!==e)throw t.close(),new Error("TypeScript semantic request does not match the currently published index generation.");let s=this.readSnapshot(t);if(!this.host||!this.db)this.db=t,this.host=this.createHost(t);else{let o=this.db;this.host.advanceGeneration(t,N(this.snapshot,s)),this.db=t,o.close()}this.generation=i,this.snapshot=s,this.available=null}};function F(r,e,t){return r.referencesForDefinitions?.(e,t)??new Map(e.map(i=>[i.symbolId,r.referencesFor(i)]))}function A(r,e){return r.calleesForDefinitions?.(e)??new Map(e.map(t=>[t.symbolId,r.calleesFor(t)]))}function H(r){if(!r.generation.metadataRaw)return null;let e=f(r.generation.metadataRaw);return e.kind!=="legacy"&&e.kind!=="supported"||!e.capabilities.usableForEvidenceCache?null:h(e.metadata.fingerprint)}function N(r,e){return e?S(r,e):{version:1,changes:[],projectIdentityChanged:!0,uncertainty:["prior-snapshot-unavailable"]}}function B(r){throw new Error(`Unhandled TypeScript semantic request: ${JSON.stringify(r)}`)}var Z=`typescript-semantic-${process.pid}-${C()}`,x=m(process.pid),ee={pid:process.pid,...x?{processIdentity:x}:{}};var n=L(O);if(!c)throw new Error("TypeScript mailbox worker requires a parent port.");if(n.kind==="index"){let r=new T({projectRoot:n.projectRoot,currentGeneration:()=>g(n.dbPath),...n.maxActiveSessions===void 0?{}:{maxActiveSessions:n.maxActiveSessions},...n.softMemoryLimitMb===void 0?{}:{softMemoryLimitMb:n.softMemoryLimitMb}});c.on("message",e=>{let t=k(e);I(t,()=>r.handle(t.payload.baseGeneration,t.payload.request),()=>r.status())})}else{let r=new p({openDb:()=>M(n.projectRoot)});c.on("message",e=>{let t=k(e),i=y();d(t.payload.profileEnvironment??{});try{I(t,()=>r.handle(t.payload.generation,t.payload.request),()=>r.status())}finally{d(i)}})}function I(r,e,t){let i;try{if(Date.now()>r.deadlineAtMs)throw new Error("TypeScript mailbox request expired before processing.");let s=e();if(Date.now()>r.deadlineAtMs)throw new Error("TypeScript mailbox request expired while the worker was processing it.");i={kind:"response",requestId:r.requestId,ok:!0,result:s,status:t()}}catch(s){i={kind:"response",requestId:r.requestId,ok:!1,error:s instanceof Error?s.message:String(s),status:t()}}c.postMessage(i)}function L(r){if(!r||typeof r!="object")throw new Error("TypeScript mailbox worker data is missing.");let e=r;if(e.kind==="index"&&typeof e.projectRoot=="string"&&typeof e.dbPath=="string"&&E(e.maxActiveSessions)&&E(e.softMemoryLimitMb))return{kind:"index",projectRoot:e.projectRoot,dbPath:e.dbPath,...e.maxActiveSessions===void 0?{}:{maxActiveSessions:e.maxActiveSessions},...e.softMemoryLimitMb===void 0?{}:{softMemoryLimitMb:e.softMemoryLimitMb}};if(e.kind==="semantic"&&typeof e.projectRoot=="string")return{kind:"semantic",projectRoot:e.projectRoot};throw new Error("TypeScript mailbox worker data is invalid.")}function E(r){return r===void 0||Number.isInteger(r)&&r>0}function k(r){if(!r||typeof r!="object")throw new Error("TypeScript mailbox worker request is missing.");let e=r;if(e.kind!=="request"||typeof e.requestId!="string"||!Number.isSafeInteger(e.deadlineAtMs)||typeof e.payload!="object"||e.payload===null)throw new Error("TypeScript mailbox worker request is invalid.");return e}
2
2
  //# sourceMappingURL=typescript-mailbox-worker.js.map
@@ -0,0 +1,2 @@
1
+ import{a}from"./chunk-6V5CNXL6.js";import"./chunk-3FHOF22C.js";import"./chunk-3TNRNKAT.js";import"./chunk-7KCZELVM.js";import"./chunk-XBGWL66K.js";import"./chunk-B5D7QPBE.js";import"./chunk-2WC2OEDO.js";import"./chunk-BGBBVSH4.js";import"./chunk-MV3CDXPI.js";import"./chunk-MTDBHTSF.js";import"./chunk-WYCTJDVR.js";import"./chunk-CEEZJXEF.js";import"./chunk-W6STWDQI.js";import"./chunk-MPQ4OTBM.js";import"./chunk-OSR2GEHQ.js";import"./chunk-FRUSVINH.js";import"./chunk-YEN6CYC7.js";import"./chunk-WRQXLNYE.js";import"./chunk-2GRUZAQF.js";import"./chunk-HOENASQM.js";import"./chunk-YUKYB54I.js";import"./chunk-BJT7LSPK.js";import"./chunk-SSK6LDPC.js";import"./chunk-4WNW27SX.js";import"./chunk-F4FNK44D.js";import"./chunk-GAS2LJMP.js";import"./chunk-WK46TNUM.js";import"./chunk-TQZV7KV4.js";import"./chunk-3L2ZBPEX.js";import"./chunk-YXPUP5G2.js";import"./chunk-DRENNWRG.js";import"./chunk-BE7ZZTMC.js";import"./chunk-2OOY75BW.js";import"./chunk-DHEQMPLW.js";import"./chunk-NOGJXYFO.js";import"./chunk-RTQ7NEKG.js";import"./chunk-GUFSG5TX.js";import"./chunk-IW5XQG5G.js";import"./chunk-FGA2U4OR.js";import"./chunk-B3PYOSCX.js";import"./chunk-H5EXS3HM.js";import"./chunk-HGFDYOVB.js";import"./chunk-JFMEXGFE.js";import"./chunk-KYSDI3GE.js";import"./chunk-7F45LJKI.js";export{a as valueFlow};
2
+ //# sourceMappingURL=value-flow-VRPZY72V.js.map
@@ -1,4 +1,4 @@
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};
1
+ import{b as Ve,c as He,g as ht,j as pt,k as K,l as ft,m as ke}from"./chunk-SZHGTCPP.js";import{a as Y,b as vt,c as Rt}from"./chunk-FIQRSHVM.js";import{a as Pe,b as Pt,c as Tt,d as Ct,e as Te,f as Et,g as Ce,h as Wt,i as Mt,j as At,k as Lt,l as jt,m as _t,n as Gt}from"./chunk-GYIZ4NXB.js";import{a as wt}from"./chunk-MXNGIEPU.js";import{a as bt,c as Q}from"./chunk-BE7ZZTMC.js";import"./chunk-2OOY75BW.js";import{d as B,e as Z,f as $,g as xt}from"./chunk-TY7CRN3Z.js";import"./chunk-DHEQMPLW.js";import{a as ee,b as It,c as kt}from"./chunk-NOGJXYFO.js";import{H as gt,c as j}from"./chunk-IZDPJ2QI.js";import{c as tt,d as ye}from"./chunk-WYPL7GF7.js";import{e as dt}from"./chunk-RTQ7NEKG.js";import{a as me,d as Ke}from"./chunk-GUFSG5TX.js";import{a as ut}from"./chunk-MWN53KRN.js";import"./chunk-IW5XQG5G.js";import"./chunk-3AF4TUFK.js";import{b as ve,g as Re,i as be,m as mt,n as yt,o as we,p as xe,q as Ie,r as St}from"./chunk-FGA2U4OR.js";import{a as M}from"./chunk-B3PYOSCX.js";import"./chunk-H5EXS3HM.js";import"./chunk-HGFDYOVB.js";import{c as T,d as C,e as Ye}from"./chunk-JFMEXGFE.js";import{A as q,E as rt,F as it,I as nt,J as st,K as Se,L as ot,P as at,S as ct,a as ge,c as Xe,ga as lt,t as Qe,u as O,v as Ze,x as et,y as N}from"./chunk-KYSDI3GE.js";import{h as R}from"./chunk-7F45LJKI.js";import v from"process";import{rmSync as yr}from"fs";import{resolve as Li}from"path";import{pathToFileURL as ji}from"url";import{lstatSync as wr}from"fs";function Ft(t,e){let r=te(t);if(r.kind!=="directory")throw new Error(`Watcher root is not a directory: ${t}`);if(!e)return{projectRoot:t,projectDirectory:r};let i=te(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 Ot(t){try{if(!Dt(t.projectDirectory,te(t.projectRoot)))return!1;let e=t.gitControlDirectory;return!e||Dt(e.identity,te(e.path))}catch{return!1}}function te(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 Dt(t,e){return t.device===e.device&&t.inode===e.inode&&t.birthtimeNs===e.birthtimeNs&&t.kind===e.kind}import{existsSync as Le,lstatSync as Ir,statSync as Xt,watch as kr}from"fs";import{EventEmitter as Pr}from"events";import{basename as Tr,dirname as Kt,isAbsolute as je,join as b,relative as Yt,resolve as Qt}from"path";import{watch as Cr}from"chokidar";import Er from"ignore";var Zt=5e3,ne=class{projectRoot;config;watchConfig;outputDb;languages;pnpmWorkspaces;typescriptProjectMode;typescriptProjects;clojureConfigPath;indexerConcurrency;onStatus;onReindexComplete;onReindexError;onRefreshSuppressed;onError;reindexRunner;subscriptionFactory;budgetInspector;clock;activeOperation=null;stopPromise=null;stopInProgress=!1;status={state:"idle"};debounceTimer=null;cooldownTimer=null;budgetTimer=null;dirty=!1;changedFiles=0;pendingTrigger=null;pendingChanges=new Map;pendingChangesComplete=!0;pendingChangesIncompleteReason;reindexInFlight=!1;lastReindexEnd=0;lastObservedGeneration=null;publishedGeneration;indexFreshness;fsWatchers=[];sourcePollingFallbackStarted=!1;gitPollTimer=null;reconcileTimer=null;lastGitState=null;preferFilesystemGitState=!0;watchGitLayout=null;localCacheWatchPath;gitignoreFilter;extraIgnore;stopped=!1;constructor(e){this.projectRoot=e.projectRoot,this.config=e.config,this.watchConfig=Z(e.config),this.outputDb=e.outputDb??b(Qe(this.projectRoot,e.config),"index.db"),this.preferFilesystemGitState=e.gitReader===void 0,this.localCacheWatchPath=ei(this.projectRoot,Kt(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??jr,er.set(this,ti(e.stopTimeoutMs??Zt,"watcher stop timeout")),this.reindexRunner=e.reindexRunner??Ur(),this.subscriptionFactory=e.subscriptionFactory??_r,this.budgetInspector=e.budgetInspector??ft,this.publishedGeneration=e.publishedGeneration??j,this.indexFreshness=e.indexFreshness??Zr,this.lastObservedGeneration=this.readPublishedGeneration(),tr.set(this,{projectRoot:e.projectRoot,config:e.config,gitReader:e.gitReader??rt,languages:ir(e.languages??e.config.languages),typeScriptInputPaths:null,stagedIndexEntries:null}),this.gitignoreFilter=ut(e.projectRoot),this.extraIgnore=Er(),this.watchConfig.ignore.length>0&&this.extraIgnore.add(this.watchConfig.ignore),We(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,ie(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(),this.clearReconcileTimer();let r=this.activeOperation;r&&this.setStatus({state:"draining",startedAt:this.wallNow(),reason:"waiting for the active reindex worker to exit"});let i=[...ie(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=Ee(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(ie(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($t(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("../")||$t(i,this.localCacheWatchPath)||this.gitignoreFilter.isIgnored(i)||this.extraIgnore.ignores(i)||i.endsWith("index.db")||i.endsWith("index.scip")||i.endsWith("index.db.tmp")||Tr(i).startsWith(ht))return;i===".scipquery.json"&&Jt(this,this.projectRoot);let n=Vt(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=je(e)?e:b(this.projectRoot,e);return Yt(this.projectRoot,r).replaceAll("\\","/")}scheduleReindex(e,r,i=!1){this.pendingTrigger=Ee(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||this.reconcileExternalPublication())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(),re.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}We(this),this.lastObservedGeneration=this.readPublishedGeneration();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=rr(l),d=0;if(u?(d=(re.get(this)??0)+1,re.set(this,d),this.dirty=!0,this.pendingTrigger=Ee(this.pendingTrigger,n)):re.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 Wr(l,n,this.clock),d=ie(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,e.state==="cooldown"||e.state==="budget-paused"?this.armReconcileTimer(e.until):this.clearReconcileTimer(),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=j(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 ke(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&&(x(this).stagedIndexEntries=Ht(this.projectRoot,x(this).gitReader),this.gitPollTimer=this.clock.setInterval(()=>this.pollGitState(),this.watchConfig.gitPollMs),this.gitPollTimer.unref?.())}armReconcileTimer(e){this.clearReconcileTimer();let r=e-this.wallNow();if(r<=0||!(this.watchConfig.gitPollMs>0))return;let i=Math.min(this.watchConfig.gitPollMs,r);this.reconcileTimer=this.clock.setTimeout(()=>{this.reconcileTimer=null,!(this.stopped||this.reconcileExternalPublication())&&(this.status.state==="cooldown"||this.status.state==="budget-paused")&&this.armReconcileTimer(this.status.until)},i),this.reconcileTimer.unref?.()}clearReconcileTimer(){this.reconcileTimer&&(this.clock.clearTimeout(this.reconcileTimer),this.reconcileTimer=null)}readPublishedGeneration(){try{return this.publishedGeneration(this.outputDb)}catch{return null}}reconcileExternalPublication(){if(this.stopped||this.reindexInFlight||!(this.dirty||this.status.state==="budget-paused"||this.status.state==="cooldown"||this.status.state==="waiting"))return!1;let r=this.readPublishedGeneration();if(r===null||r===this.lastObservedGeneration)return!1;this.lastObservedGeneration=r;let i;try{i=this.indexFreshness(this.projectRoot,this.config,this.outputDb)}catch{return!1}if(i!=="fresh")return!1;let n=this.pendingTrigger??{kind:"unknown"};return this.clearDebounceTimer(),this.clearCooldownTimer(),this.clearBudgetTimer(),this.dirty=!1,this.changedFiles=0,this.pendingTrigger=null,this.resetPendingChanges(),We(this),this.onRefreshSuppressed({...n,detail:`a generation published outside the watcher is fresh${n.detail?` (${n.detail})`:""}`}),this.setStatus({state:"idle"}),!0}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=x(this),a=s.stagedIndexEntries,o=Ht(this.projectRoot,s.gitReader);s.stagedIndexEntries=o;let c=si(this.projectRoot,s.gitReader,e,r,a,o,i,n),l=null;if(c!==null&&(c.includes(".scipquery.json")&&Jt(this,this.projectRoot),l=c.filter(d=>Vt(this,"add",d)!==null),l.length===0))return;let u=l?.map(d=>({path:d,kind:Le(b(this.projectRoot,d))?"change":"delete"}));i&&n?this.scheduleReindex({kind:"watch-git-state",detail:Me("HEAD and index changed",l)},u,u!==void 0):i?this.scheduleReindex({kind:"watch-git-head",detail:Me("HEAD changed",l)},u,u!==void 0):n&&this.scheduleReindex({kind:"watch-git-index",detail:Me(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?zt(r,e.indexPath):null}readGitStateFromGit(){let e=x(this).gitReader,r=Se(this.projectRoot,["rev-parse","--git-path","index"],e);if(!r)return null;let i=ot(this.projectRoot,r);return zt(Se(this.projectRoot,["rev-parse","--verify","HEAD"],e),i)}clearGitPollTimer(){this.gitPollTimer&&(this.clock.clearInterval(this.gitPollTimer),this.gitPollTimer=null)}};async function Wr(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 qt=new WeakMap,er=new WeakMap,tr=new WeakMap,_=new WeakMap,re=new WeakMap;function ie(t){let e=qt.get(t);if(e)return e;let r={closures:new Set,errors:[]};return qt.set(t,r),r}function Mr(t){return er.get(t)??Zt}function x(t){let e=tr.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=N(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?ke(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 jr={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)},_r=(t,e)=>Gr(process.platform,e.usePolling)?new Ae(t):Cr(t,e);function Gr(t,e){return t==="darwin"&&e!==!0}var U=class extends Error{constructor(e,r){super(e,r===void 0?void 0:{cause:r}),this.name="RecursiveSourceWatchError"}},Ae=class{events=new Pr;watcher;constructor(e){this.watcher=kr(e,{recursive:!0},(r,i)=>{if(i===null){this.events.emit("error",new U("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 U(`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":Le(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 Bt(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 rr(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=He({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=Bt(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 rr(d)?d:(d instanceof Ve&&(c={stdoutTail:d.stdout,stderrTail:d.stderr,stdoutTruncated:d.stdoutTruncated,stderrTruncated:d.stderrTruncated}),new Error(Bt(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 Ee(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 U||Vr(t)}var _e=/^[0-9a-f]{40,64}$/i;function $t(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=je(s)?s:Qt(t,s)}else return null;return Le(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 Ut(t,r)??Ut(i,r)??Qr(i,r)}function Yr(t){try{let e=R(b(t,"commondir"),"Git common-directory marker").trim();return e?je(e)?e:Qt(t,e):t}catch{return t}}function Ut(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 Zr(t,e,r){let i=Kt(r);return $(t,e,{dbPath:r,metaPath:b(i,"meta.json"),cacheDir:i}).state}function zt(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 ei(t,e){let r=Yt(t,e).replaceAll("\\","/");if(!(!r||r===".."||r.startsWith("../")))return r}function ti(t,e){if(!Number.isSafeInteger(t)||t<=0)throw new Error(`${e} must be a positive integer.`);return t}function ir(t){return t&&t.length>0?[...t]:me}function Jt(t,e){try{let r=x(t);r.config=B(e),r.languages=ir(r.config.languages)}catch{x(t).languages=me}}function Vt(t,e,r){let i=x(t);if(ge(r,i.languages)==="other")return null;let s=zr(e);if(r===".scipquery.json"||at(r))return i.typeScriptInputPaths=null,s;if(!ri(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=nr(t);return c?c.has(r)?"add":null:s}function We(t){let e=x(t);if(!e.languages.includes("typescript")){e.typeScriptInputPaths=null;return}let r=ii(e.projectRoot,e.config,e.languages);e.typeScriptInputPaths=r??nr(t)}function nr(t){let e=x(t);if(!e.languages.includes("typescript"))return e.typeScriptInputPaths=null,null;try{let r=e.config.indexer?.typescript,i=ct(e.projectRoot,r?.projectMode,r?.projects);return e.typeScriptInputPaths=i,i}catch{return e.typeScriptInputPaths=null,null}}function ri(t,e){if(!e.includes("typescript"))return!1;let r=ge(t,["typescript","javascript"]);return r==="source"||r==="ambient"}function ii(t,e,r){try{let i=Ke(R(N(t,e).metaPath,"reindex metadata"));if(i.kind!=="supported"&&i.kind!=="legacy")return null;let n=Xe(i.metadata.fingerprint);return!n||!ni(n,r,e)?null:new Set(n.files.map(s=>s.path))}catch{return null}}function ni(t,e,r){let i=lt(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 si(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 oi(l.output))c.add(u)}if(o){if(n===null||s===null)return null;for(let l of ci(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"?ai(r.output):null}function oi(t){return t.split("\0").filter(e=>e.length>0)}function ai(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 ci(t,e){return[...new Set([...t.keys(),...e.keys()])].filter(i=>t.get(i)!==e.get(i))}function Me(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 se,lstatSync as z,readdirSync as ar,realpathSync as sr,rmSync as G,statSync as li}from"fs";import{join as S,resolve as J,sep as cr}from"path";var di=3600*1e3,ui=2*1024*1024*1024,oe=300*1e3,hi="gc-state.json",pi="gc.lock";function fi(t){let e=t.leases.filter(o=>o.managed&&!o.live&&!o.busy),r=gi(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 gi(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(!et())return{kind:"disabled"};let i=r.repositoryId===void 0?it(t)?.repositoryId:r.repositoryId;if(!i)return{kind:"unavailable"};let n=S(O(),"repositories",i),s=(r.now??Date.now)(),a=se(n)?dr(t,n,i,e,s,r):{kind:"unavailable"};return mi(t,i,e,s,r),a}function dr(t,e,r,i,n,s){let a=S(e,"gc-state.json"),o=Ri(a);if(!s.force&&o&&n-Date.parse(o.lastSweepAt)<oe)return{kind:"throttled",sweptAt:o.lastSweepAt};let c=tt(e,{now:()=>n});if(!c)return{kind:"busy"};try{let l=yi(t,e,r,o?.unreferencedSince??{}),u=fi({nowMs:n,...l,policy:{generationTtlMs:s.policy?.generationTtlMs??di,budgetBytes:s.policy?.budgetBytes??ui}}),d=0,h=0;for(let f of u.deleteWorktrees){if(!Fe(f.lease))continue;if(!se(f.lease.localCacheDir)){G(f.leasePath,{force:!0}),h+=1;continue}if(!Si(f.lease))continue;let y=ye(S(f.lease.localCacheDir,"cache-lifecycle.lock"));if(y)try{if(Ge(f.lease,!0))continue;try{At({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}),h+=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 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 ve(a,m,{spacing:2,trailingNewline:!0}),p}catch(l){return{kind:"failed",error:l instanceof Error?l.message:String(l)}}finally{c.release()}}function mi(t,e,r,i,n){let s=S(O(),"repositories");if(!se(s))return;let a=S(s,hi),o=bi(a);if(!n.force&&o!==void 0&&i-o<oe)return;let c=ye(S(s,pi));if(c)try{for(let l of V(s)){if(l===e||!/^[a-f0-9]{24}$/.test(l))continue;let u=S(s,l),d;try{d=z(u)}catch{continue}if(!d.isDirectory()||d.isSymbolicLink())continue;let h=vi(u)??t;dr(h,u,l,r,i,n)}ve(a,{version:1,lastSweepAt:new Date(i).toISOString()},{spacing:2,trailingNewline:!0})}finally{c.release()}}function yi(t,e,r,i){let n=new Set(st(t).map(l=>J(l.path))),s=[];for(let l of V(S(e,"worktrees"))){if(!l.endsWith(".json"))continue;let u=S(e,"worktrees",l),d=ur(u);if(!d)continue;let h=J(d.projectRoot);s.push({leasePath:u,lease:d,managed:d.repositoryId===r&&Fe(d),live:n.has(h)||se(h),busy:Ge(d)})}let a=[];for(let l of V(S(e,"locks"))){let u=/^([a-f0-9]{64})\.lock$/.exec(l);if(!u)continue;let d=S(e,"locks",l),h=De(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 V(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:or(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=z(d)}catch{continue}!h.isDirectory()||h.isSymbolicLink()||o.push({generationId:l,path:d,size:or(d),...i[l]===void 0?{}:{unreferencedAt:i[l]}})}return{leases:s,generations:o,locks:a,temporaries:c}}function Fe(t){if(t.ownershipChecksum!==gt(t)||q(t.localCacheDir)!==q(Ze(t.projectRoot)))return!1;let e=q(S(O(),"projects"));return q(t.localCacheDir).startsWith(`${e}${cr}`)}function Si(t){if(!Fe(t))return!1;let e=J(O()),r=J(S(e,"projects")),i=J(t.localCacheDir);try{let n=z(e),s=z(r),a=z(i);if(!n.isDirectory()||n.isSymbolicLink()||!s.isDirectory()||s.isSymbolicLink()||!a.isDirectory()||a.isSymbolicLink())return!1;let o=sr(r);return sr(i).startsWith(`${o}${cr}`)}catch{return!1}}function vi(t){for(let e of V(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(Q(t.localCacheDir).lockPath);return r!==void 0&&M(r)}function ur(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 De(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 Ri(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 bi(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 V(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 s=S(i,n.name);n.isDirectory()?r.push(s):n.isFile()&&(e+=li(s).size)}}return e}var ae=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=Et(this.root),r=Wt(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=Tt(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?(Ct(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 ki}from"fs";import{Worker as Pi}from"worker_threads";var ce=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(Ne(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=xi(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(Oe(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: ${Ne(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(Oe(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: ${Ne(i)}`,{cause:i})),!1}finally{r===this.workerGeneration&&(this.terminating=null)}})(),this.terminating}};function xi(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 Ne(t){return t instanceof Error?t.message:String(t)}var Ti=6e4,Ci=10*6e4;function hr(t){let e=t.maxActiveSessions??8,r=t.workerSoftMemoryMb??Wi(t.workerHeapMb),i=()=>({protocolVersion:Y,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:()=>mr(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:Y,id:s.id,baseGeneration:s.baseGeneration,response:a},{nowMs:o,limits:t.limits})},reject(n,s,a,o){xe(t.paths,n,{ok:!1,protocolVersion:Y,id:s,error:a},a,{nowMs:o,limits:t.limits})},idleTtlMs:t.workerIdleMs??Ci,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:ee,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:kt,createWorker:()=>mr(t,{kind:"semantic",projectRoot:t.projectRoot}),complete(r,i,n,s){we(t.paths,r,{ok:!0,protocolVersion:ee,id:i.id,generation:i.generation,response:n},{nowMs:s,limits:t.limits})},reject(r,i,n,s){xe(t.paths,r,{ok:!1,protocolVersion:ee,id:i,error:n},n,{nowMs:s,limits:t.limits})},idleTtlMs:Ti,onBusy:t.onBusy,onFatal:t.onFatal})}function fr(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 ce({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 I=e();try{t.complete(y.claim,y.envelope,m,I)}catch(k){if(!(k instanceof Re))throw k;try{t.reject(y.claim,y.envelope.id,k.message,I)}catch(P){if(!(P instanceof Re))throw P;ki(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=mt(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(yt(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=Ai(f);try{t.reject(p,m,y,e()),a?.claim===p&&h(a)}catch(I){l(Mi(I))}}return 1},status(){return{...u.hasWorker()||!t.statusWhenWorkerAbsent?o:t.statusWhenWorkerAbsent(o),mailbox:St(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 Ei=6144;function gr(){let t=Number.parseInt(process.env.SCIP_TS_WORKER_HEAP_MB??"",10);return Number.isFinite(t)&&t>0?t:Ei}function Wi(t){return Math.max(1,Math.floor((t??gr())*.9))}function mr(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:t.workerHeapMb??gr()}})}function Mi(t){return t instanceof Error?t:new Error(String(t))}function Ai(t){return t instanceof Error?t.message:String(t)}var Sr=2e3,_i=5e3,Gi=5e3,Di=6e4,Fi=10,Oi=50,Ni=1e4;function qi(t,e=1){return Ye(t,e,Fi,Oi,Ni,8)}function Bi(t,e){let r;return{begin(){return r||(e.requestStop(),e.closeWake(),r=t.stop(),r.catch(()=>{})),r}}}async function $i(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=qi(n,s);return await e.wait(a),{indexRequests:r,semanticRequests:i,processedRequests:n,consecutiveIdlePolls:s,stopped:!1,delayMs:a}}function Ui(t){return t==="fresh"?null:{kind:"watch-startup",detail:`index ${t} when watch service started`}}function zi(t){Lt(t.statePath,{version:1,protocolVersion:bt,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 Ji(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>=Gi&&(i=o,!Ot(t.worktreeLiveness))){t.requestStop();return}if(o-s>=Di&&(s=o,Ie(t.indexMailboxPaths),Ie(t.semanticMailboxPaths)),o-n>=oe&&(n=o,lr(t.projectRoot,t.cliVersion)),o-r>=_i){r=o;let c=jt(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 Vi(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(),Sr),e.unref?.(),o&&t.requestRefresh(o);!t.stopRequested();){let c=await $i(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 Hi(t){let e=pr({paths:t.semanticPaths,projectRoot:t.projectRoot,onBusy:t.onSemanticBusy,onFatal:t.onFatal}),r=t.config.indexer?.typescript,i=hr({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 Xi(t,e,r={}){let i=Mt(t,e),n=i.projectRoot,s=i.worktreeKind==="git"?Ki(n,i.worktreeId):void 0,a=Ft(n,s),o=B(n);o.watch={...o.watch,...r};let c=Z(o);if(!c.enabled)throw new Error('watch mode is disabled; set "watch.enabled": true before starting the service');let l=N(n,o),u=Q(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 ae(u.refreshRequestsPath,{retryDelayMs:Math.max(1e3,c.cooldownMs)});p.initializeAfterOwnershipAcquired();let m=Date.now(),f=C(),y=m,I=f,k={state:"idle"},P,le,E,de,ue=K(l.dbPath),H=!1,qe=!1,Be=Number.NEGATIVE_INFINITY,$e,Ue,D=It(l.cacheDir),F=vt(l.cacheDir);be(D),be(F);let ze=Pe([F.pendingDir,F.legacyRequestDir,D.pendingDir,D.legacyRequestDir,u.refreshRequestsPath]),w=(g=!1,W=g?"durable":"visibility")=>{if(!qe)return;let fe=Date.now(),L=C();!g&&L-Be<Sr||(Be=L,zi({statePath:u.statePath,durability:W,processIdentity:d,projectRoot:n,worktreeId:i.worktreeId,cliVersion:e,startedAtMs:m,nowMs:fe,lastActivityAtMs:y,idleTimeoutMs:c.idleTimeoutMs,watcherStatus:k,indexGeneration:P,lastRefresh:le,lastError:E,reindexActivity:ue,refreshCoordinator:p,semanticLane:he,indexLane:pe,semanticBusyUntilMs:$e,indexBusyUntilMs:Ue}))},A=()=>{y=Date.now(),I=C()},vr=g=>{A(),de??=g,E={at:new Date().toISOString(),message:g.message},w(!0,"visibility")},{semanticLane:he,indexLane:pe}=Hi({semanticPaths:D,indexPaths:F,projectRoot:n,dbPath:l.dbPath,config:o,onSemanticBusy(g){$e=g===void 0?void 0:g+5e3,w(!0,"visibility")},onIndexBusy(g){Ue=g===void 0?void 0:g+5e3,w(!0,"visibility")},onFatal:vr}),X=new ne({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,W,fe){A();let L=fe?.pendingChanges!==!1?$(n,o,l):xt(l);return le=L.lastRefresh,P=L.state==="fresh"?j(l.dbPath)??void 0:void 0,ue=K(l.dbPath),p.completeActive(),E=void 0,w(!0),L.state==="fresh"},onReindexError(){p.failActive()},onRefreshSuppressed(g){let W=pt(l.dbPath,g);W.state==="failed"&&(E={at:new Date().toISOString(),message:`Suppressed-refresh telemetry was not recorded: ${W.reason}`},w(!0,"visibility")),ue=K(l.dbPath)},onError(g){A(),P=void 0,E={at:new Date().toISOString(),message:g.message},w(!0)}}),Je=Bi(X,{requestStop(){H=!0},closeWake(){ze.close()}}),Rr=()=>{Je.begin()},br=Ji({worktreeLiveness:a,indexMailboxPaths:F,semanticMailboxPaths:D,projectRoot:n,cliVersion:e,activityPath:u.activityPath,refreshCoordinator:p,watcherStatus:()=>k,requestRefresh:g=>X.requestRefresh({kind:"watch-demand",detail:g},{immediate:!0}),requestStop:()=>{H=!0},recordActivity:A,updateObservedActivity(g,W){g<=y||(y=g,I=W)},persistState:w});await Vi({watcher:X,shutdown:Je,stopSignal:Rr,initializeFreshness(){let g=$(n,o,l);return le=g.lastRefresh,P=g.state==="fresh"?j(l.dbPath)??void 0:void 0,Ui(g.state)},markReady:()=>{qe=!0},recordActivity:A,persistState:w,requestRefresh:g=>X.requestRefresh(g,{immediate:!0}),stopRequested:()=>H,processIndexRequests:()=>pe.poll(),processSemanticRequests:()=>he.poll(),afterMailboxPoll:br,shouldStop:()=>H||de!==void 0||Gt({watcher:k,lastActivityAtMs:I,nowMs:C(),idleTimeoutMs:c.idleTimeoutMs}),wait:g=>ze.wait(g),closeLanes:()=>Promise.all([he.close("TypeScript semantic service stopped before completing the request."),pe.close("TypeScript index service stopped before completing the request.")]).then(()=>{}),mailboxFatalError:()=>de,finalizeStopped(){yr(u.statePath,{force:!0}),yr(u.activityPath,{force:!0}),h.release()},finalizeDegraded(g){return E={at:new Date().toISOString(),message:`Watch service shutdown is degraded: ${g.join("; ")}`},w(!0),new Error(E.message)}})}function Ki(t,e){let r=nt(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 Yi(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 Qi=v.argv[1]?ji(Li(v.argv[1])).href:null;if(Qi===import.meta.url){let t=v.argv[2],e=v.argv[3],r=Zi(v.argv[4]);if(!t||!e)console.error("watch-service: expected <project-root> <cli-version>"),v.exitCode=1;else try{await Xi(t,e,r)}catch(i){Yi(i)}}function Zi(t){if(!t)return{};try{let e=JSON.parse(t);return e&&typeof e=="object"?e:{}}catch{return{}}}export{Pe as createPathChangeWake,Bi as createWatchServiceShutdown,$i as runWatchServiceLoopIteration,Xi as runWatchServiceServer,Ui as startupRefreshTrigger,Yi as terminateWatchServiceProcess,qi as watchServiceLoopDelayMs};
4
4
  //# sourceMappingURL=watch-server.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scip-query",
3
- "version": "0.22.0",
3
+ "version": "0.23.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",
@@ -1,2 +0,0 @@
1
- import{a,b}from"./chunk-JAT6C3VX.js";import"./chunk-MTDBHTSF.js";import"./chunk-C7IJMOFP.js";import"./chunk-YXPUP5G2.js";import"./chunk-DRENNWRG.js";import"./chunk-DKM723YF.js";import"./chunk-K3XFWJI2.js";import"./chunk-IW5XQG5G.js";import"./chunk-H5EXS3HM.js";import"./chunk-HGFDYOVB.js";import"./chunk-AK3PYTIK.js";export{a as byKind,b as kindCounts};
2
- //# sourceMappingURL=by-kind-4IYG2SKW.js.map
@@ -1,2 +0,0 @@
1
- import{a}from"./chunk-GQIDEID3.js";import"./chunk-7KCZELVM.js";import"./chunk-BGBBVSH4.js";import"./chunk-6NC3YSPY.js";import"./chunk-MTDBHTSF.js";import"./chunk-IXESDH3J.js";import"./chunk-OXYAWIEA.js";import"./chunk-FKGQOTKD.js";import"./chunk-2XCGSDIT.js";import"./chunk-WRQXLNYE.js";import"./chunk-T6QD2ZQB.js";import"./chunk-EELPBR7E.js";import"./chunk-BJT7LSPK.js";import"./chunk-WSLEJSFR.js";import"./chunk-VUSKPCUB.js";import"./chunk-F4FNK44D.js";import"./chunk-HCVJR2V4.js";import"./chunk-EETGXQY7.js";import"./chunk-TQZV7KV4.js";import"./chunk-C7IJMOFP.js";import"./chunk-YXPUP5G2.js";import"./chunk-DRENNWRG.js";import"./chunk-BVFYEEBH.js";import"./chunk-JHH5SCZ3.js";import"./chunk-ENWQWA2R.js";import"./chunk-DKM723YF.js";import"./chunk-K3XFWJI2.js";import"./chunk-IW5XQG5G.js";import"./chunk-JT6XX7QY.js";import"./chunk-H5EXS3HM.js";import"./chunk-HGFDYOVB.js";import"./chunk-SB25YMEQ.js";import"./chunk-AK3PYTIK.js";export{a as callGraph};
2
- //# sourceMappingURL=call-graph-WQNXMNNN.js.map