scip-query 0.21.0 → 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (496) hide show
  1. package/CHANGELOG.md +72 -0
  2. package/dist/augment-vue-worker.js +1 -1
  3. package/dist/by-kind-4IYG2SKW.js +2 -0
  4. package/dist/call-graph-WQNXMNNN.js +2 -0
  5. package/dist/{chunk-AQDWTCDC.js → chunk-25GWKRUZ.js} +2 -2
  6. package/dist/chunk-2BTJALUS.js +454 -0
  7. package/dist/chunk-2KVU55CW.js +11 -0
  8. package/dist/{chunk-BBWPOMGU.js → chunk-2OXVP5U5.js} +2 -2
  9. package/dist/{chunk-D5W4UZY5.js → chunk-2RE5OCHZ.js} +2 -2
  10. package/dist/{chunk-2I3RSUWX.js → chunk-2XCGSDIT.js} +2 -2
  11. package/dist/{chunk-V7LQZTTZ.js → chunk-2YC7YNKT.js} +2 -2
  12. package/dist/chunk-3QXC54FQ.js +3 -0
  13. package/dist/{chunk-32A42O5B.js → chunk-3TJY6M3B.js} +2 -2
  14. package/dist/chunk-42W3LFUK.js +13 -0
  15. package/dist/chunk-44T4DUAA.js +2 -0
  16. package/dist/chunk-4GAQ6FI4.js +43 -0
  17. package/dist/{chunk-4S4DF62J.js → chunk-4HE7MVWD.js} +2 -2
  18. package/dist/{chunk-TGWNNMPF.js → chunk-4TQU4TX2.js} +2 -2
  19. package/dist/{chunk-SKUMCCC5.js → chunk-56NQAEPJ.js} +2 -2
  20. package/dist/chunk-57N6LN2A.js +3 -0
  21. package/dist/{chunk-LPGDO2XA.js → chunk-5H5WTJSD.js} +2 -2
  22. package/dist/{chunk-EA4SH4U5.js → chunk-5YRQIE2B.js} +2 -2
  23. package/dist/{chunk-O2RM7E7L.js → chunk-5ZMBRQFC.js} +4 -4
  24. package/dist/{chunk-ICHBVITH.js → chunk-6HRZQLOI.js} +2 -2
  25. package/dist/{chunk-WULAPQUD.js → chunk-6NC3YSPY.js} +2 -2
  26. package/dist/{chunk-IDPLC3FI.js → chunk-6VEFRPTD.js} +2 -2
  27. package/dist/{chunk-IOKWFRFQ.js → chunk-7C26EKLZ.js} +2 -2
  28. package/dist/{chunk-S3RTPPLQ.js → chunk-7IQXARSQ.js} +2 -2
  29. package/dist/chunk-7JYHQAH2.js +22 -0
  30. package/dist/chunk-7KSO2OAP.js +2 -0
  31. package/dist/{chunk-2ZBMOQGG.js → chunk-7U2YQSDE.js} +2 -2
  32. package/dist/{chunk-EKZRF57O.js → chunk-7XA3OM44.js} +2 -2
  33. package/dist/{chunk-4EXFZP6H.js → chunk-7XZGZBSQ.js} +2 -2
  34. package/dist/chunk-7YQOCABQ.js +2 -0
  35. package/dist/chunk-A77SCPW2.js +3 -0
  36. package/dist/chunk-AK3PYTIK.js +5 -0
  37. package/dist/chunk-AMIMMNA4.js +11 -0
  38. package/dist/{chunk-MOBF2GH6.js → chunk-AQ2PORIO.js} +2 -2
  39. package/dist/{chunk-YUFWLWIC.js → chunk-ARVO6TTW.js} +2 -2
  40. package/dist/chunk-AUY5BL74.js +2 -0
  41. package/dist/{chunk-RGCJ4646.js → chunk-AYPDH2LU.js} +2 -2
  42. package/dist/{chunk-73Z33VFI.js → chunk-AZS7YPCB.js} +2 -2
  43. package/dist/{chunk-SYUNTKO2.js → chunk-BDGTPN27.js} +2 -2
  44. package/dist/{chunk-BATIVRU2.js → chunk-BDHFVH2M.js} +2 -2
  45. package/dist/chunk-BECZLYNU.js +8 -0
  46. package/dist/chunk-BJT7LSPK.js +3 -0
  47. package/dist/{chunk-6SWA6B24.js → chunk-BTVKZGWT.js} +2 -2
  48. package/dist/{chunk-QD7IFBCR.js → chunk-BUTEIZKP.js} +2 -2
  49. package/dist/{chunk-UZFCZ7SJ.js → chunk-BVFYEEBH.js} +2 -2
  50. package/dist/{chunk-ICUQONOG.js → chunk-BWVQP3LB.js} +2 -2
  51. package/dist/chunk-BYDAFMSR.js +57 -0
  52. package/dist/{chunk-BHE44MHT.js → chunk-C76O5MDS.js} +2 -2
  53. package/dist/chunk-C7IJMOFP.js +134 -0
  54. package/dist/{chunk-CN2WGM7D.js → chunk-CBBHFNLX.js} +2 -2
  55. package/dist/{chunk-COTMS5KM.js → chunk-CKRWA452.js} +2 -2
  56. package/dist/{chunk-ANWGXPPN.js → chunk-CLG6DWVS.js} +2 -2
  57. package/dist/chunk-D2MVJSP4.js +21 -0
  58. package/dist/chunk-D35XIZGN.js +2 -0
  59. package/dist/{chunk-U7DR7MJD.js → chunk-DEAB5TGT.js} +2 -2
  60. package/dist/{chunk-6GJAP4OE.js → chunk-DJAO2OZJ.js} +2 -2
  61. package/dist/chunk-DKM723YF.js +79 -0
  62. package/dist/{chunk-4IIMPWMR.js → chunk-DPWKKNKI.js} +2 -2
  63. package/dist/chunk-E44IVWIJ.js +367 -0
  64. package/dist/chunk-EDMB6SSO.js +7 -0
  65. package/dist/{chunk-KWARB5FZ.js → chunk-EELG7D3Q.js} +2 -2
  66. package/dist/chunk-EELPBR7E.js +3 -0
  67. package/dist/chunk-EETGXQY7.js +3 -0
  68. package/dist/chunk-ENWQWA2R.js +2 -0
  69. package/dist/{chunk-HUZNZ3H2.js → chunk-ERCYGVAM.js} +2 -2
  70. package/dist/{chunk-WSG3DK5H.js → chunk-EWWY2ZFL.js} +2 -2
  71. package/dist/chunk-F24G5NBE.js +3 -0
  72. package/dist/{chunk-XRXCANFQ.js → chunk-F24QUEQP.js} +2 -2
  73. package/dist/{chunk-KFK7GF5C.js → chunk-FBCVASUG.js} +2 -2
  74. package/dist/{chunk-35IW3P4H.js → chunk-FELGD32K.js} +2 -2
  75. package/dist/{chunk-UNORWZIJ.js → chunk-FFJQZG6J.js} +5 -5
  76. package/dist/{chunk-5SE323LF.js → chunk-FGNCOQUX.js} +2 -2
  77. package/dist/chunk-FKGQOTKD.js +2 -0
  78. package/dist/chunk-GDRJB3SB.js +3 -0
  79. package/dist/chunk-GH5YSGZL.js +5 -0
  80. package/dist/{chunk-X7PJJYKX.js → chunk-GIQ6CSL4.js} +2 -2
  81. package/dist/{chunk-2RP27XLR.js → chunk-GPGRZJ3R.js} +2 -2
  82. package/dist/{chunk-IYV2YBHM.js → chunk-GQIDEID3.js} +2 -2
  83. package/dist/chunk-GRX7JOXQ.js +2 -0
  84. package/dist/{chunk-H46QMB7E.js → chunk-GVOMSPGL.js} +2 -2
  85. package/dist/{chunk-KTRGJLY7.js → chunk-GY7CCCEZ.js} +2 -2
  86. package/dist/{chunk-VNKYRJKN.js → chunk-H7CG6LOE.js} +2 -2
  87. package/dist/chunk-HCVJR2V4.js +3 -0
  88. package/dist/chunk-HG722PO7.js +3 -0
  89. package/dist/{chunk-LHTT5C3Z.js → chunk-HISEUIL2.js} +2 -2
  90. package/dist/{chunk-K5MZYZV7.js → chunk-HXOU4XNH.js} +2 -2
  91. package/dist/chunk-I6UTXNHU.js +6 -0
  92. package/dist/{chunk-I7PFL5P3.js → chunk-IJMD6BRI.js} +2 -2
  93. package/dist/{chunk-XXJ7WL3F.js → chunk-IKVNEGTW.js} +2 -2
  94. package/dist/chunk-IMKZEXZG.js +2 -0
  95. package/dist/chunk-ISIQLPJ2.js +61 -0
  96. package/dist/{chunk-DEUGHURX.js → chunk-ISWFRGJ6.js} +2 -2
  97. package/dist/chunk-IW5XQG5G.js +2 -0
  98. package/dist/chunk-IXESDH3J.js +2 -0
  99. package/dist/{chunk-FGB567HK.js → chunk-JAT6C3VX.js} +2 -2
  100. package/dist/{chunk-7TWP3MCP.js → chunk-JFQBRL3J.js} +2 -2
  101. package/dist/{chunk-Q7HB7BFJ.js → chunk-JHH5SCZ3.js} +2 -2
  102. package/dist/{chunk-ZHSARYVS.js → chunk-JJ62MTQH.js} +2 -2
  103. package/dist/chunk-JT6XX7QY.js +8 -0
  104. package/dist/{chunk-5H7IWVXJ.js → chunk-JUN5DOAK.js} +2 -2
  105. package/dist/{chunk-DOPCR5BY.js → chunk-K3XFWJI2.js} +2 -2
  106. package/dist/{chunk-Y4XQ7LES.js → chunk-KFOYCQAJ.js} +1 -1
  107. package/dist/{chunk-N5C65OFK.js → chunk-KFVSJX25.js} +2 -2
  108. package/dist/chunk-KK7GPALL.js +28 -0
  109. package/dist/{chunk-DHKBIOXF.js → chunk-KQHJEU6V.js} +2 -2
  110. package/dist/{chunk-WB6LGCFB.js → chunk-KZYID5KV.js} +2 -2
  111. package/dist/{chunk-KW6B5OL4.js → chunk-LO5JSW2C.js} +2 -2
  112. package/dist/{chunk-ZW44MCJM.js → chunk-LRI5OMPE.js} +2 -2
  113. package/dist/{chunk-HG5YI7PV.js → chunk-LXQUF2RP.js} +2 -2
  114. package/dist/{chunk-TM5XEDDR.js → chunk-MHIEP7EG.js} +2 -2
  115. package/dist/{chunk-FHV7NMFU.js → chunk-MSR2QRUE.js} +2 -2
  116. package/dist/chunk-N7FP5H5U.js +57 -0
  117. package/dist/{chunk-3653GTR7.js → chunk-NEIQPFBI.js} +2 -2
  118. package/dist/chunk-NK3JMP22.js +2 -0
  119. package/dist/{chunk-7IOAZRVL.js → chunk-NRBNAECH.js} +2 -2
  120. package/dist/{chunk-HGKEAP7F.js → chunk-NVSZNESQ.js} +2 -2
  121. package/dist/{chunk-R2MOKIVO.js → chunk-OJNK5ALA.js} +2 -2
  122. package/dist/{chunk-RFWAUHVW.js → chunk-OPSAW5DT.js} +2 -2
  123. package/dist/chunk-OTSPRVNW.js +2 -0
  124. package/dist/chunk-OXYAWIEA.js +2 -0
  125. package/dist/chunk-OZETODHH.js +2 -0
  126. package/dist/chunk-PBUH2P5S.js +3 -0
  127. package/dist/{chunk-QBANU5BQ.js → chunk-PIFTZEEM.js} +2 -2
  128. package/dist/{chunk-CKDOY6JA.js → chunk-PLJUQFQN.js} +2 -2
  129. package/dist/{chunk-JVZNWJBH.js → chunk-PLYUVM4F.js} +2 -2
  130. package/dist/chunk-PXXYQK55.js +2 -0
  131. package/dist/{chunk-WZQFY5S7.js → chunk-Q55NF3ZG.js} +2 -2
  132. package/dist/{chunk-OVPS2ILI.js → chunk-Q5TA4OY4.js} +2 -2
  133. package/dist/{chunk-OUB4J26T.js → chunk-Q6T2CAJL.js} +2 -2
  134. package/dist/chunk-Q7GBK5T7.js +81 -0
  135. package/dist/chunk-QKT4UI2Y.js +2 -0
  136. package/dist/{chunk-PIZY2GX6.js → chunk-QLBSG7U5.js} +2 -2
  137. package/dist/chunk-QWKHW6VZ.js +2 -0
  138. package/dist/{chunk-E7BJXRNV.js → chunk-R6M456QG.js} +2 -2
  139. package/dist/{chunk-MJNV7OCG.js → chunk-RDULNRSJ.js} +2 -2
  140. package/dist/{chunk-SSSJO4RG.js → chunk-RHHCLWQ6.js} +2 -2
  141. package/dist/chunk-RNKPYYYE.js +4 -0
  142. package/dist/{chunk-IXJ26KJJ.js → chunk-RPL3ARU7.js} +2 -2
  143. package/dist/{chunk-3EX7DNBC.js → chunk-RYOYJMGF.js} +2 -2
  144. package/dist/chunk-SB25YMEQ.js +2 -0
  145. package/dist/chunk-SV2LEFVM.js +2 -0
  146. package/dist/{chunk-ZBNL3QCY.js → chunk-SVHTMVA4.js} +3 -3
  147. package/dist/{chunk-6IEVHGWG.js → chunk-SWK4XPUS.js} +2 -2
  148. package/dist/chunk-T6QD2ZQB.js +43 -0
  149. package/dist/{chunk-VETXXOYU.js → chunk-TAYD3AE7.js} +2 -2
  150. package/dist/chunk-TD7VKJ2Y.js +117 -0
  151. package/dist/{chunk-UQ7XPRWU.js → chunk-TH6IC56G.js} +2 -2
  152. package/dist/{chunk-XVDMJMES.js → chunk-TKDNDQA7.js} +2 -2
  153. package/dist/{chunk-CSDDOUA4.js → chunk-TNG2FYS5.js} +2 -2
  154. package/dist/chunk-TQZV7KV4.js +2 -0
  155. package/dist/{chunk-AJVMVE7X.js → chunk-TUQIPUDS.js} +2 -2
  156. package/dist/chunk-TUSPIVZ3.js +4 -0
  157. package/dist/{chunk-ORBKAUCH.js → chunk-U2N2KE7A.js} +2 -2
  158. package/dist/{chunk-3PII3JI5.js → chunk-UAQ4T73O.js} +2 -2
  159. package/dist/{chunk-OFY4HTMI.js → chunk-UDY7MIAW.js} +2 -2
  160. package/dist/{chunk-WKPZCQLI.js → chunk-URSGGIZX.js} +2 -2
  161. package/dist/{chunk-UL4VJUMD.js → chunk-UT7TADJX.js} +2 -2
  162. package/dist/chunk-V4NG5OMS.js +554 -0
  163. package/dist/{chunk-2H4IAJHO.js → chunk-VMWUV6WB.js} +2 -2
  164. package/dist/{chunk-46JLFIGA.js → chunk-VTCIYFEK.js} +2 -2
  165. package/dist/chunk-VU6LIWHT.js +2 -0
  166. package/dist/chunk-VUSKPCUB.js +2 -0
  167. package/dist/{chunk-URMZLV2N.js → chunk-VXJJTQYE.js} +2 -2
  168. package/dist/{chunk-IPAL6DP2.js → chunk-VZ7NXSHV.js} +2 -2
  169. package/dist/{chunk-FUG6RPYY.js → chunk-WHADK6OS.js} +2 -2
  170. package/dist/chunk-WN3TCGJ4.js +2 -0
  171. package/dist/{chunk-B7ECWJAZ.js → chunk-WOOAY3PA.js} +2 -2
  172. package/dist/chunk-WRQXLNYE.js +9 -0
  173. package/dist/chunk-WSLEJSFR.js +2 -0
  174. package/dist/chunk-WYZIHUPZ.js +16 -0
  175. package/dist/{chunk-ZYREOING.js → chunk-XE33FV5W.js} +2 -2
  176. package/dist/chunk-XFMVKFSF.js +2 -0
  177. package/dist/{chunk-BBEDPVPB.js → chunk-XGGBK66W.js} +2 -2
  178. package/dist/{chunk-OFUBXBYX.js → chunk-XJX6LGHL.js} +2 -2
  179. package/dist/{chunk-Z3GCK3PD.js → chunk-XN22RGSR.js} +2 -2
  180. package/dist/{chunk-HWLCBKFE.js → chunk-XSWYJCAK.js} +2 -2
  181. package/dist/{chunk-IGKKTHJR.js → chunk-XU75YQN4.js} +2 -2
  182. package/dist/{chunk-E4EJBGDZ.js → chunk-Y2VM4CJC.js} +2 -2
  183. package/dist/{chunk-U7LRSQG6.js → chunk-Y334QQU5.js} +2 -2
  184. package/dist/{chunk-APLKXICZ.js → chunk-YAGYMBEX.js} +2 -2
  185. package/dist/{chunk-XITQLISP.js → chunk-YIHNPKWD.js} +2 -2
  186. package/dist/chunk-YXPUP5G2.js +11 -0
  187. package/dist/{chunk-6BJ7SOY7.js → chunk-Z2AWCTN6.js} +2 -2
  188. package/dist/{chunk-PHSPBQM6.js → chunk-Z2PZVKPR.js} +2 -2
  189. package/dist/{chunk-QXR5QPSF.js → chunk-ZAZGGSM3.js} +2 -2
  190. package/dist/{chunk-5236NQV3.js → chunk-ZGW4HLPD.js} +2 -2
  191. package/dist/chunk-ZOXKSQQB.js +2 -0
  192. package/dist/{chunk-BD6CV7PN.js → chunk-ZPASRBLF.js} +2 -2
  193. package/dist/{chunk-DMUGTKMD.js → chunk-ZYM4HOFA.js} +2 -2
  194. package/dist/{chunk-4ILHWBYF.js → chunk-ZZ3Z7D56.js} +2 -2
  195. package/dist/cli-main.js +4 -4
  196. package/dist/{code-CczEvHui.d.ts → code-B17qEMbt.d.ts} +1 -1
  197. package/dist/code-EQJFDT6I.js +2 -0
  198. package/dist/code-result-json-7UWIWBOO.js +2 -0
  199. package/dist/command-descriptors-ORNTVNYV.js +342 -0
  200. package/dist/{config-types-Cm-VSEBb.d.ts → config-types-B9B60MiR.d.ts} +10 -0
  201. package/dist/dataflow-6VL54GX5.js +2 -0
  202. package/dist/{db-LKJXAlNS.d.ts → db-BwIVAYNB.d.ts} +1 -1
  203. package/dist/dependence-slice-DT2NUHD2.js +2 -0
  204. package/dist/deps-DB7H5IKC.js +2 -0
  205. package/dist/direct-navigation-O3LUAYWQ.js +3 -0
  206. package/dist/entry-map-6K62RV3D.js +2 -0
  207. package/dist/files-MSLD7MO6.js +2 -0
  208. package/dist/{graph-evidence-CbUPCSKV.d.ts → graph-evidence-Bjyky2V4.d.ts} +1 -1
  209. package/dist/{health-Wl5G_LRt.d.ts → health-CPp2Jf1Z.d.ts} +1 -1
  210. package/dist/hierarchy-IVBXAKFA.js +2 -0
  211. package/dist/imports-FRAVZ3Y2.js +2 -0
  212. package/dist/index.d.ts +2 -2
  213. package/dist/index.js +1 -1
  214. package/dist/members-KJOJDYGO.js +2 -0
  215. package/dist/methods-2AYABBT3.js +2 -0
  216. package/dist/output-continuation-command-JHMPH6NC.js +3 -0
  217. package/dist/{output-pagination-VAWOGX4R.js → output-pagination-3OFL2MJV.js} +2 -2
  218. package/dist/project-reindex-HYO4WD7Z.js +3 -0
  219. package/dist/queries/affected.d.ts +2 -2
  220. package/dist/queries/affected.js +1 -1
  221. package/dist/queries/anchors.d.ts +2 -2
  222. package/dist/queries/anchors.js +1 -1
  223. package/dist/queries/architecture.d.ts +2 -2
  224. package/dist/queries/architecture.js +1 -1
  225. package/dist/queries/bottlenecks.d.ts +2 -2
  226. package/dist/queries/bottlenecks.js +1 -1
  227. package/dist/queries/by-kind.d.ts +2 -2
  228. package/dist/queries/by-kind.js +1 -1
  229. package/dist/queries/call-graph.d.ts +2 -2
  230. package/dist/queries/call-graph.js +1 -1
  231. package/dist/queries/change-surface.d.ts +2 -2
  232. package/dist/queries/change-surface.js +1 -1
  233. package/dist/queries/cleanup-plan.d.ts +2 -2
  234. package/dist/queries/cleanup-plan.js +1 -1
  235. package/dist/queries/co-change.d.ts +2 -2
  236. package/dist/queries/co-change.js +1 -1
  237. package/dist/queries/code.d.ts +3 -3
  238. package/dist/queries/code.js +1 -1
  239. package/dist/queries/complexity-hotspots.d.ts +2 -2
  240. package/dist/queries/complexity-hotspots.js +1 -1
  241. package/dist/queries/complexity.d.ts +13 -2
  242. package/dist/queries/complexity.js +1 -1
  243. package/dist/queries/context.d.ts +2 -2
  244. package/dist/queries/context.js +1 -1
  245. package/dist/queries/convergence.d.ts +2 -2
  246. package/dist/queries/convergence.js +1 -1
  247. package/dist/queries/coupling.d.ts +2 -2
  248. package/dist/queries/coupling.js +1 -1
  249. package/dist/queries/cycles.d.ts +2 -2
  250. package/dist/queries/cycles.js +1 -1
  251. package/dist/queries/dataflow.d.ts +2 -2
  252. package/dist/queries/dataflow.js +1 -1
  253. package/dist/queries/dead.d.ts +2 -2
  254. package/dist/queries/dead.js +1 -1
  255. package/dist/queries/decorative-checkers.d.ts +2 -2
  256. package/dist/queries/decorative-checkers.js +1 -1
  257. package/dist/queries/deep-chains.d.ts +2 -2
  258. package/dist/queries/deep-chains.js +1 -1
  259. package/dist/queries/dependence-slice.d.ts +3 -3
  260. package/dist/queries/dependence-slice.js +1 -1
  261. package/dist/queries/dependency-depth.d.ts +2 -2
  262. package/dist/queries/dependency-depth.js +1 -1
  263. package/dist/queries/deps.d.ts +2 -2
  264. package/dist/queries/deps.js +1 -1
  265. package/dist/queries/diff-impact.d.ts +2 -2
  266. package/dist/queries/diff-impact.js +1 -1
  267. package/dist/queries/doc-drift.d.ts +2 -2
  268. package/dist/queries/doc-drift.js +1 -1
  269. package/dist/queries/drift.d.ts +2 -2
  270. package/dist/queries/drift.js +1 -1
  271. package/dist/queries/duplicate-bodies.d.ts +2 -2
  272. package/dist/queries/duplicate-bodies.js +1 -1
  273. package/dist/queries/entry-map.d.ts +2 -2
  274. package/dist/queries/entry-map.js +1 -1
  275. package/dist/queries/evidence.d.ts +3 -3
  276. package/dist/queries/evidence.js +1 -1
  277. package/dist/queries/extract-candidates.d.ts +2 -2
  278. package/dist/queries/extract-candidates.js +1 -1
  279. package/dist/queries/fan.d.ts +2 -2
  280. package/dist/queries/fan.js +1 -1
  281. package/dist/queries/files.d.ts +2 -2
  282. package/dist/queries/files.js +1 -1
  283. package/dist/queries/health.d.ts +3 -3
  284. package/dist/queries/health.js +1 -1
  285. package/dist/queries/hierarchy.d.ts +2 -2
  286. package/dist/queries/hierarchy.js +1 -1
  287. package/dist/queries/hotspots.d.ts +2 -2
  288. package/dist/queries/hotspots.js +1 -1
  289. package/dist/queries/imports.d.ts +2 -2
  290. package/dist/queries/imports.js +1 -1
  291. package/dist/queries/incomplete-migration.d.ts +2 -2
  292. package/dist/queries/incomplete-migration.js +1 -1
  293. package/dist/queries/index.d.ts +5 -5
  294. package/dist/queries/index.js +1 -1
  295. package/dist/queries/isolated.d.ts +2 -2
  296. package/dist/queries/isolated.js +1 -1
  297. package/dist/queries/locality-candidates.d.ts +2 -2
  298. package/dist/queries/locality-candidates.js +1 -1
  299. package/dist/queries/members.d.ts +2 -2
  300. package/dist/queries/members.js +1 -1
  301. package/dist/queries/methods.d.ts +2 -2
  302. package/dist/queries/methods.js +1 -1
  303. package/dist/queries/not-implemented.d.ts +2 -2
  304. package/dist/queries/not-implemented.js +1 -1
  305. package/dist/queries/outline.d.ts +2 -2
  306. package/dist/queries/outline.js +1 -1
  307. package/dist/queries/passthrough-candidates.d.ts +2 -2
  308. package/dist/queries/passthrough-candidates.js +1 -1
  309. package/dist/queries/plan-context.d.ts +2 -2
  310. package/dist/queries/plan-context.js +1 -1
  311. package/dist/queries/react-component-duplicates.d.ts +2 -2
  312. package/dist/queries/react-component-duplicates.js +1 -1
  313. package/dist/queries/react-hook-candidates.d.ts +2 -2
  314. package/dist/queries/react-hook-candidates.js +1 -1
  315. package/dist/queries/react-large-component-pressure.d.ts +2 -2
  316. package/dist/queries/react-large-component-pressure.js +1 -1
  317. package/dist/queries/recent-duplicates.d.ts +2 -2
  318. package/dist/queries/recent-duplicates.js +1 -1
  319. package/dist/queries/redundant-reexports.d.ts +2 -2
  320. package/dist/queries/redundant-reexports.js +1 -1
  321. package/dist/queries/reference-neighborhood.d.ts +2 -2
  322. package/dist/queries/reference-neighborhood.js +1 -1
  323. package/dist/queries/reference-reachability.d.ts +2 -2
  324. package/dist/queries/reference-reachability.js +1 -1
  325. package/dist/queries/refs.d.ts +2 -2
  326. package/dist/queries/refs.js +1 -1
  327. package/dist/queries/self-audit.d.ts +2 -2
  328. package/dist/queries/self-audit.js +1 -1
  329. package/dist/queries/similar-chains.d.ts +2 -2
  330. package/dist/queries/similar-chains.js +1 -1
  331. package/dist/queries/similar-files.d.ts +2 -2
  332. package/dist/queries/similar-files.js +1 -1
  333. package/dist/queries/similar-signatures.d.ts +2 -2
  334. package/dist/queries/similar-signatures.js +1 -1
  335. package/dist/queries/similar.d.ts +2 -2
  336. package/dist/queries/similar.js +1 -1
  337. package/dist/queries/slice.d.ts +2 -2
  338. package/dist/queries/slice.js +1 -1
  339. package/dist/queries/source-inspection.d.ts +4 -4
  340. package/dist/queries/source-inspection.js +1 -1
  341. package/dist/queries/source-search.d.ts +2 -2
  342. package/dist/queries/source-search.js +1 -1
  343. package/dist/queries/stale-abstractions.d.ts +2 -2
  344. package/dist/queries/stale-abstractions.js +1 -1
  345. package/dist/queries/stats.d.ts +2 -2
  346. package/dist/queries/surface.d.ts +2 -2
  347. package/dist/queries/surface.js +1 -1
  348. package/dist/queries/symbols.d.ts +2 -2
  349. package/dist/queries/symbols.js +1 -1
  350. package/dist/queries/system-map.d.ts +2 -2
  351. package/dist/queries/system-map.js +1 -1
  352. package/dist/queries/system.d.ts +2 -2
  353. package/dist/queries/system.js +1 -1
  354. package/dist/queries/test-quality.d.ts +2 -2
  355. package/dist/queries/test-quality.js +1 -1
  356. package/dist/queries/trace.d.ts +2 -2
  357. package/dist/queries/trace.js +1 -1
  358. package/dist/queries/twin-ab.d.ts +2 -2
  359. package/dist/queries/twin-ab.js +1 -1
  360. package/dist/queries/twin-drift.d.ts +2 -2
  361. package/dist/queries/twin-drift.js +1 -1
  362. package/dist/queries/unused-imports.d.ts +2 -2
  363. package/dist/queries/unused-imports.js +1 -1
  364. package/dist/queries/unused-params.d.ts +2 -2
  365. package/dist/queries/unused-params.js +1 -1
  366. package/dist/queries/value-flow.d.ts +3 -3
  367. package/dist/queries/value-flow.js +1 -1
  368. package/dist/queries/vue-component-duplicates.d.ts +2 -2
  369. package/dist/queries/vue-component-duplicates.js +1 -1
  370. package/dist/queries/vue-composable-candidates.d.ts +2 -2
  371. package/dist/queries/vue-composable-candidates.js +1 -1
  372. package/dist/queries/vue-large-view-pressure.d.ts +2 -2
  373. package/dist/queries/vue-large-view-pressure.js +1 -1
  374. package/dist/queries/wrapper-candidates.d.ts +2 -2
  375. package/dist/queries/wrapper-candidates.js +1 -1
  376. package/dist/query-service-fastpath.js +5 -5
  377. package/dist/query-service-server.js +2 -2
  378. package/dist/refs-ARMA6XUJ.js +2 -0
  379. package/dist/refs-pagination-VUGIWN6U.js +2 -0
  380. package/dist/reindex-worker.js +125 -66
  381. package/dist/reindex.d.ts +5 -3
  382. package/dist/reindex.js +135 -76
  383. package/dist/runtime.d.ts +5 -5
  384. package/dist/runtime.js +4 -4
  385. package/dist/rust-semantic-session-server.js +1 -1
  386. package/dist/rust-semantic-session-worker.js +1 -1
  387. package/dist/rust-semantic-worker.js +1 -1
  388. package/dist/{scip-cli-CppzF5MK.d.ts → scip-cli-H-n59izO.d.ts} +1 -1
  389. package/dist/slice-YOB5YFAM.js +2 -0
  390. package/dist/surface-VY5EFWTW.js +2 -0
  391. package/dist/symbol-resolution-DGQN4XIV.js +2 -0
  392. package/dist/system-2KQ3QD2P.js +2 -0
  393. package/dist/trace-HTIPTXAE.js +2 -0
  394. package/dist/typescript-mailbox-worker.js +1 -1
  395. package/dist/value-flow-5FV3VQI7.js +2 -0
  396. package/dist/watch-server.js +3 -3
  397. package/docs/CLI_JSON_OUTPUT.md +2 -2
  398. package/docs/COMMAND_REFERENCE.md +2 -2
  399. package/docs/schemas/project-config.schema.json +11 -1
  400. package/package.json +6 -5
  401. package/skills/scip-explore/SKILL.md +73 -3
  402. package/skills/scip-explore/agents/openai.yaml +3 -3
  403. package/skills/scip-explore/references/delegated-exploration.md +51 -0
  404. package/skills/scip-explore/references/external-evidence.md +72 -0
  405. package/skills/scip-explore/references/information-model.md +51 -0
  406. package/skills/scip-explore/scripts/capture-evidence.mjs +666 -0
  407. package/skills/scip-query/SKILL.md +22 -1
  408. package/dist/by-kind-CI3O6PQG.js +0 -2
  409. package/dist/call-graph-6QTUTXH7.js +0 -2
  410. package/dist/chunk-2COFMIVK.js +0 -60
  411. package/dist/chunk-35ELD3RM.js +0 -2
  412. package/dist/chunk-3FQ3KMCD.js +0 -2
  413. package/dist/chunk-3VLJ2DCA.js +0 -2
  414. package/dist/chunk-4DCKBY6T.js +0 -5
  415. package/dist/chunk-4N6QSEMZ.js +0 -10
  416. package/dist/chunk-4OE2JO6I.js +0 -2
  417. package/dist/chunk-4UUCUASK.js +0 -554
  418. package/dist/chunk-54EOGFBR.js +0 -2
  419. package/dist/chunk-5IZTXSOL.js +0 -117
  420. package/dist/chunk-5ZJH6DDE.js +0 -2
  421. package/dist/chunk-63MBA7EG.js +0 -3
  422. package/dist/chunk-6T7H2AFY.js +0 -3
  423. package/dist/chunk-7COHFNJK.js +0 -38
  424. package/dist/chunk-7HU2IJ2T.js +0 -3
  425. package/dist/chunk-7PPYXENX.js +0 -2
  426. package/dist/chunk-AA7K3XLM.js +0 -21
  427. package/dist/chunk-AUP6YI5M.js +0 -2
  428. package/dist/chunk-CA5RE6H7.js +0 -2
  429. package/dist/chunk-CT5SI2I4.js +0 -2
  430. package/dist/chunk-D5EKVZPI.js +0 -2
  431. package/dist/chunk-DMQ7ZKJG.js +0 -81
  432. package/dist/chunk-ELNRLMC5.js +0 -29
  433. package/dist/chunk-F7WQ337U.js +0 -308
  434. package/dist/chunk-FEQIQ26E.js +0 -2
  435. package/dist/chunk-FN6EJM6Q.js +0 -2
  436. package/dist/chunk-FTSQNONX.js +0 -2
  437. package/dist/chunk-G2F6T5BV.js +0 -2
  438. package/dist/chunk-G6OGPXJW.js +0 -9
  439. package/dist/chunk-GFLTPNWV.js +0 -3
  440. package/dist/chunk-GTDP2SKQ.js +0 -2
  441. package/dist/chunk-HEOMG7IM.js +0 -8
  442. package/dist/chunk-I3U2FN2T.js +0 -13
  443. package/dist/chunk-IUJ3ZFEE.js +0 -7
  444. package/dist/chunk-LXLD46LH.js +0 -21
  445. package/dist/chunk-MEI3PTUK.js +0 -2
  446. package/dist/chunk-MO226P4Q.js +0 -4
  447. package/dist/chunk-MYUKI5VN.js +0 -4
  448. package/dist/chunk-OIRWZIYL.js +0 -38
  449. package/dist/chunk-OIVZ7PW6.js +0 -438
  450. package/dist/chunk-PNISDVYC.js +0 -3
  451. package/dist/chunk-PQOL42AW.js +0 -2
  452. package/dist/chunk-PUVZNFVY.js +0 -11
  453. package/dist/chunk-PZEI2TVL.js +0 -4
  454. package/dist/chunk-Q2J2VZZT.js +0 -2
  455. package/dist/chunk-QDCCHMVZ.js +0 -2
  456. package/dist/chunk-QLQBZOJH.js +0 -3
  457. package/dist/chunk-S73HBCGI.js +0 -11
  458. package/dist/chunk-SDPA5DKN.js +0 -210
  459. package/dist/chunk-SEUJVWT2.js +0 -3
  460. package/dist/chunk-SF7X6QNW.js +0 -2
  461. package/dist/chunk-SWFAFA4G.js +0 -49
  462. package/dist/chunk-T6FRID7Y.js +0 -3
  463. package/dist/chunk-TNOHGHZQ.js +0 -2
  464. package/dist/chunk-U2GPTA5U.js +0 -3
  465. package/dist/chunk-URTX2BEA.js +0 -6
  466. package/dist/chunk-VGRUM7JI.js +0 -3
  467. package/dist/chunk-VWLIOEEF.js +0 -11
  468. package/dist/chunk-WK4FD4PG.js +0 -2
  469. package/dist/chunk-X434XZAI.js +0 -2
  470. package/dist/chunk-YIEFEPG6.js +0 -16
  471. package/dist/chunk-YRVERHJR.js +0 -49
  472. package/dist/chunk-ZD3Z54IW.js +0 -2
  473. package/dist/chunk-ZDVDSDFG.js +0 -4
  474. package/dist/code-EQL6ZBLH.js +0 -2
  475. package/dist/code-result-json-6E4J6LGZ.js +0 -2
  476. package/dist/command-descriptors-QH3G2OVD.js +0 -346
  477. package/dist/dataflow-2BLMUZBP.js +0 -2
  478. package/dist/dependence-slice-MGAJDZXB.js +0 -2
  479. package/dist/deps-GQMUYVKW.js +0 -2
  480. package/dist/direct-navigation-6RUJKLAV.js +0 -3
  481. package/dist/entry-map-V2NQP5JU.js +0 -2
  482. package/dist/files-VM53I4IU.js +0 -2
  483. package/dist/hierarchy-D553WRSZ.js +0 -2
  484. package/dist/imports-DOZAJWLW.js +0 -2
  485. package/dist/members-HE67475K.js +0 -2
  486. package/dist/methods-K5JK4PPH.js +0 -2
  487. package/dist/output-continuation-command-LKBUTNRL.js +0 -3
  488. package/dist/project-reindex-4ARU6QCM.js +0 -3
  489. package/dist/refs-NBHKL4UQ.js +0 -2
  490. package/dist/refs-pagination-BBVTIHMH.js +0 -2
  491. package/dist/slice-U6S6LBSB.js +0 -2
  492. package/dist/surface-C7SS5CDQ.js +0 -2
  493. package/dist/symbol-resolution-3FVEKDTJ.js +0 -2
  494. package/dist/system-6K2NOO5C.js +0 -2
  495. package/dist/trace-II5K2TMH.js +0 -2
  496. package/dist/value-flow-MKFUUE5B.js +0 -2
@@ -1,308 +0,0 @@
1
- #!/usr/bin/env node
2
- import{$c as ce,Ad as Qn,Be as Rr,Cd as Zn,Dd as xt,De as Et,Ea as An,Ee as xr,Fa as ae,Fe as vr,Gd as vt,Ge as Me,H as Fe,Ib as jn,Jb as Mn,Je as Pr,Ke as Ir,Ld as er,Le as wr,Md as A,N as gt,Ne as kr,Od as Le,Oe as Er,P as ie,Pd as Pt,Pe as Ce,Q as ft,Qd as tr,R as kn,S as Ae,Sd as nr,T as mt,U as oe,Ua as ht,Ud as It,V as _,Vb as Cn,Vd as rr,W as D,Wb as Nn,X as En,Xa as _n,Xb as $n,Xd as ir,Yc as se,Zc as Bn,_c as Vn,a as Rn,ab as Dn,ad as De,b as xn,bd as Re,c as vn,ca as z,cd as Un,d as Te,da as X,dd as Wn,de as or,e as E,ea as Tn,eb as Ln,ed as Gn,ee as ar,fb as yt,fd as qn,fe as sr,g as Pn,gb as On,gd as Jn,h as ut,he as cr,id as ue,ie as j,jd as Hn,je as ur,ka as O,kd as xe,ke as wt,l as H,la as Y,ld as B,le as Oe,m as lt,ma as Fn,md as R,me as lr,ne as dr,o as be,oe as pr,p as re,pe as gr,q as dt,qe as fr,r as In,rd as zn,re as mr,s as pt,sd as Xn,se as hr,t as wn,td as St,te as yr,ua as _e,ud as Yn,ue as Sr,vd as bt,ve as br,wd as Rt,we as kt,xd as Kn,ye as V,ze as je}from"./chunk-OIVZ7PW6.js";import{createHash as fl}from"crypto";import{existsSync as F,mkdirSync as it,mkdtempSync as ml,readdirSync as Do,renameSync as Lo,rmSync as he,statSync as hl}from"fs";import{basename as rt,dirname as y,extname as yl,join as T,resolve as Io}from"path";import{platform as Sl}from"os";import{execFileSync as Tr}from"child_process";import{createRequire as Yo}from"module";import{existsSync as Ko}from"fs";import{platform as ve,arch as Fr}from"os";var Pe="v0.8.1",Tt="https://github.com/sourcegraph/scip",Ne=`github.com/sourcegraph/scip/cmd/scip@${Pe}`,Ar=Yo(import.meta.url),_r="SCIP_QUERY_SCIP_BIN";function Qo(e){if(e.isOnPath("scip"))return{source:"path",path:"scip"};let t=e.env[_r];if(t&&e.fileExists(t))return{source:"env",path:t};if(e.platform==="win32"){let n=e.resolveSidecar(e.arch);if(n&&e.fileExists(n))return{source:"sidecar",path:n}}return null}function Zo(e){for(let t of e==="arm64"?["arm64","x64"]:[e])try{return Ar.resolve(`scip-query-scip-windows/scip-win32-${t}.exe`)}catch{}return null}function le(e=process.env){let t=Qo({platform:ve(),arch:Fr(),env:e,isOnPath:se,fileExists:Ko,resolveSidecar:Zo});return t?.source==="path"?Vn("scip")??t.path:t?.path??null}function cd(){return le()!==null}function ea(){let e=le();if(!e)return null;try{return Tr(e,["--version"],{stdio:"pipe",timeout:1e4,killSignal:"SIGKILL"}).toString().trim()}catch{return null}}function ta(){let e=ve(),t=Fr(),n,r,i;switch(e){case"darwin":n="darwin",i="tar.gz";break;case"linux":n="linux",i="tar.gz";break;default:return null}switch(t){case"arm64":r="arm64";break;case"x64":r="amd64";break;default:return null}let o=`scip-${n}-${r}.${i}`;return{url:`${Tt}/releases/download/${Pe}/${o}`,filename:o}}function ud(){let e=ta();if(console.log("\nThe `scip` CLI is required but not found on PATH.\n"),ve()==="darwin"||ve()==="linux")console.log("Install the reviewed version with Go:"),console.log(` go install ${Ne}
3
- `),console.log("Or download that exact release manually:");else if(ve()==="win32"){let t=na();console.log("On Windows the scip binary ships via the npm sidecar package scip-query-scip-windows,"),console.log("installed automatically with scip-query. If it is missing:"),console.log(` npm install -g ${t}`),console.log(`Or set ${_r} to a local scip.exe path.
4
- `),console.log("Upstream release page:")}else console.log("Download from:");console.log(e?` ${e.url}
5
- `:` ${Tt}/releases/tag/${Pe}
6
- `),console.log("After installing, ensure `scip` is on your PATH and run `scip-query reindex`.")}function na(){let t=Ar("../../package.json").optionalDependencies?.["scip-query-scip-windows"];if(!t||!/^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$/.test(t))throw new Error("scip-query package metadata does not declare an exact Windows sidecar version.");return`scip-query-scip-windows@${t}`}function Dr(e){if(se("go")){e(`Installing immutable ${Ne} via go install into the Go bin directory (GOBIN or GOPATH/bin); expected executable: scip.`);try{if(Tr("go",["install",Ne],{stdio:"inherit",timeout:3e5,env:process.env}),se("scip")){let t=le(),n=ea();if(t&&n&&n.includes(Pe))return e(`Successfully installed ${Ne}; resolved executable: ${t}; reported version: ${n}.`),!0;e(`go install completed, but the resolved scip executable did not report ${Pe} (executable: ${t??"unresolved"}; version: ${n??"unavailable"}).`)}}catch(t){let n=t instanceof Error?t.message:String(t);e(`go install failed: ${n}`)}}return e("Could not auto-install scip CLI."),e(`Install manually from: ${Tt}/releases`),!1}import{execFileSync as ra}from"child_process";import{constants as ia,copyFileSync as Lr,statSync as oa}from"fs";import{platform as aa}from"os";var sa=Object.freeze({size:e=>oa(e).size,clone:ua,copy:(e,t)=>Lr(e,t)}),ca=new Set(["ENOSYS","ENOTSUP","EOPNOTSUPP","EINVAL","EXDEV","ENOTTY"]);function K(e,t,n=sa){let r=n.size(e);try{return n.clone(e,t),{method:"reflink",bytes:r}}catch(i){if(!da(i))throw i}return n.copy(e,t),{method:"copy",bytes:r}}function ua(e,t){if(aa()!=="darwin"){Lr(e,t,ia.COPYFILE_FICLONE_FORCE);return}try{ra("/bin/cp",["-c",e,t],{timeout:6e4,maxBuffer:64*1024,stdio:["ignore","ignore","pipe"]})}catch(n){throw la(n)}}function la(e){let t=e?.stderr,n=Buffer.isBuffer(t)?t.toString("utf8"):t??"";return/operation not supported|not supported/i.test(n)?Object.assign(e instanceof Error?e:new Error(String(e)),{code:"ENOTSUP"}):/cross-device link/i.test(n)?Object.assign(e instanceof Error?e:new Error(String(e)),{code:"EXDEV"}):e}function da(e){let t=e?.code;return t!==void 0&&ca.has(t)}function Or(){return{reflinkedBytes:0,fallbackCopiedBytes:0}}function Q(e,t){t.method==="reflink"?e.reflinkedBytes+=t.bytes:e.fallbackCopiedBytes+=t.bytes}import pa from"better-sqlite3";import{execFileSync as ga}from"child_process";import{existsSync as fa,readdirSync as ma}from"fs";import{extname as $e,join as ha}from"path";function Z(e={}){return{id:"auxiliary-documents",facts:["auxiliary-document"],run:t=>jr({projectRoot:t.projectRoot,dbPath:t.dbPath,extensions:e.extensions,onStatus:t.onStatus})}}function jr(e){let t=new Set((e.extensions??jn).map(o=>o.toLowerCase()));if(t.size===0)return{scanned:0,inserted:0,existing:0};if(!fa(e.dbPath))throw new Error(`SCIP SQLite database not found at ${e.dbPath}`);let n=ur(e.projectRoot),r=ya(e.projectRoot,t).filter(o=>!n.isIgnored(o)),i=new pa(e.dbPath);try{let o=ba(i,r),a=i.prepare(`INSERT OR IGNORE INTO documents (language, relative_path, position_encoding, text)
7
- VALUES (?, ?, NULL, ?)`),c=i.transaction(u=>{let d=0;for(let p of u){if(o.has(p))continue;let f=Dn(e.projectRoot,p,{inputKind:"auxiliary source file"}),g=a.run(Ra(p),p,f);d+=Number(g.changes)}return d})(r),l={scanned:r.length,inserted:c,existing:r.length-c};return e.onStatus?.(`Augmented SQLite documents with ${c} auxiliary source file${c===1?"":"s"} (${l.existing} already present).`),l}finally{i.close()}}function ya(e,t){let n=Sa(e,t);if(n)return n;let r=[],i=o=>{let a=o?ha(e,o):e,s;try{s=ma(a,{withFileTypes:!0})}catch{return}for(let c of s){if(Mn.has(c.name))continue;let l=o?`${o}/${c.name}`:c.name;if(c.isDirectory()){i(l);continue}t.has($e(c.name).toLowerCase())&&r.push(l)}};return i(""),r.sort()}function Sa(e,t){try{return ga("git",["-C",e,"ls-files","-co","--exclude-standard","--","."],{encoding:"utf-8",maxBuffer:26214400,stdio:["ignore","pipe","ignore"],timeout:3e4,killSignal:"SIGKILL"}).split(`
8
- `).filter(r=>r&&t.has($e(r).toLowerCase())).sort()}catch{return null}}function ba(e,t){let n=new Set,r=500;for(let i=0;i<t.length;i+=r){let o=t.slice(i,i+r),a=e.prepare(`SELECT relative_path FROM documents WHERE relative_path IN (${o.map(()=>"?").join(",")})`).all(...o);for(let s of a)n.add(s.relative_path)}return n}function Ra(e){return $e(e).toLowerCase()===".vue"?"vue":$e(e).replace(/^\./,"").toLowerCase()||"source"}import{dirname as xa,join as va}from"path";function Mr(e={}){return{id:"runtime-boundaries",facts:["runtime-boundary-observation","runtime-boundary-link"],run:({projectRoot:t,dbPath:n,onStatus:r})=>{let i=new j({projectRoot:t,dbPath:n,indexPath:e.indexPath??va(xa(n),"index.scip")}),o,a=!1,s=!1;try{let l=e.reuseExisting||e.affectedFiles?cr(i):null;e.reuseExisting&&l?.extractorVersion===or?(o=l,a=!0):(o=ar(i,{...l?{previousGraph:l}:{},...e.affectedFiles?{affectedFiles:e.affectedFiles}:{},profileSpan:O}),s=(o.coverage.filesReused??0)>0)}finally{i.close()}a||sr(n,o);let c={reused:a,incrementallyUpdated:s,observations:o.observations.length,links:o.links.length,frontiers:o.frontiers.length,filesScanned:o.coverage.filesScanned,errors:o.coverage.extractionErrors.length,phases:o.coverage.phases};return r?.(c.reused?`Reused ${c.observations} cached runtime-boundary observation(s) and ${c.links} link(s).`:c.incrementallyUpdated?`Incrementally refreshed runtime-boundary observations (${c.filesScanned-(o.coverage.filesReused??0)} file(s) extracted, ${o.coverage.filesReused??0} reused) and rebuilt ${c.links} link(s).`:`Extracted ${c.observations} runtime-boundary observation(s), ${c.links} link(s), and ${c.frontiers} unresolved frontier(s).`),!a&&o.coverage.phases&&r?.(`Runtime-boundary phases: ${o.coverage.phases.map(l=>`${l.id} ${l.durationMs.toFixed(0)}ms`).join(", ")}.`),c}}}import{createHash as Na}from"crypto";import{existsSync as $a}from"fs";import{dirname as Ba,join as Ur}from"path";function Ft(e){let t=new Set;for(let n of e.uncertainty)t.add(n);e.projectIdentityChanged&&t.add("project-identity-changed");for(let n of e.changes)n.kind==="added"&&t.add("file-added"),n.kind==="deleted"&&t.add("file-deleted"),n.inputKind==="config"&&t.add("configuration-changed"),n.inputKind==="ambient"&&t.add("ambient-declaration-changed"),n.inputKind==="other"&&t.add("unclassified-input");return{fullProject:t.size>0,reasons:[...t].sort()}}function Be(e,t,n){let r=e.changes.map(s=>s.path).sort();if(r.length===0&&!e.projectIdentityChanged&&e.uncertainty.length===0)return{mode:"none",changedFiles:r,affectedFiles:[],reasons:[]};let i=new Set(n),o=Ft(e),a=new Set(o.reasons);return r.some(s=>!i.has(s))&&a.add("changed-file-outside-project"),t===null?(a.add("dependency-graph-unavailable"),Cr(r,i,a)):a.size>0?Cr(r,i,a):{mode:"closure",changedFiles:r,affectedFiles:Pa(r,t,i),reasons:[]}}function Cr(e,t,n){return{mode:"full-project",changedFiles:e,affectedFiles:[...t].sort(),reasons:[...n].sort()}}function Pa(e,t,n){let r=new Map;for(let[a,s]of t)if(n.has(a))for(let c of s){if(!n.has(c))continue;let l=r.get(c)??new Set;l.add(a),r.set(c,l)}let i=new Set(e),o=[...e];for(let a=0;a<o.length;a+=1){let s=o[a];if(s!==void 0)for(let c of r.get(s)??[])i.has(c)||(i.add(c),o.push(c))}return[...i].sort()}import{appendFileSync as Ia,existsSync as wa,mkdirSync as ka,renameSync as Ea,rmSync as Ta,statSync as Fa,truncateSync as Aa}from"fs";import{basename as _a,dirname as Da}from"path";var de=".previous",La=".rotation.lock",Oa=2e3,At=class extends Error{constructor(n,r){super(`Timed out after ${r}ms waiting for rotating JSONL lock: ${n}`);this.lockPath=n;this.timeoutMs=r;this.name="RotatingJsonlLockTimeoutError"}lockPath;timeoutMs;code="ROTATING_JSONL_LOCK_TIMEOUT"},_t=class extends Error{constructor(n){super(`Rotating JSONL lock ownership changed before release: ${n}`);this.lockPath=n;this.name="RotatingJsonlLockReleaseError"}lockPath;code="ROTATING_JSONL_LOCK_RELEASE_FAILED"},Nr=Object.freeze({monotonicNow:R,wait(e){Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,e)},tryAcquireLock(e,t){let n=Le(e,{kind:"rotating-jsonl",detail:{target:_a(t)}});return n.kind==="acquired"?{kind:"acquired",lock:n.lock}:{kind:"contended"}},makeDirectory(e){ka(e,{recursive:!0})},exists:wa,readBytes(e){return oe(e,{maxBytes:Ae,inputKind:"rotating JSONL segment"})},size(e){return Fa(e).size},truncate:Aa,remove(e){Ta(e,{force:!0})},rename:Ea,append:Ia});function Ve(e,t,n){let r=n.runtime??Nr,i=JSON.stringify(t);if(i===void 0)throw new TypeError("Rotating JSONL records must be JSON-serializable values.");let o=Buffer.from(`${i}
9
- `),a=Math.max(1,Math.floor(n.maxSegmentBytes),o.length);return Br(e,n.lockTimeoutMs,r,()=>{r.makeDirectory(Da(e));let s=ja(e,Ae,r);n.onPhase?.("tail-repaired");let c=`${e}${n.previousSuffix??de}`,l=!1,u=!1;return r.exists(e)&&r.size(e)+o.length>a&&(r.exists(c)&&(r.remove(c),u=!0),n.onPhase?.("previous-pruned"),r.rename(e,c),l=!0,n.onPhase?.("current-rotated")),r.append(e,o),n.onPhase?.("record-appended"),{lineBytes:o.length,segmentLimitBytes:a,repairedTailBytes:s,rotated:l,prunedPrevious:u}})}function $r(e,t={}){let n=t.runtime??Nr,r=Ma(t.maxSegmentBytes);return Br(e,t.lockTimeoutMs,n,()=>{let i=[],o=0,a=`${e}${t.previousSuffix??de}`;for(let s of[a,e]){if(!n.exists(s))continue;let c=Ca(Vr(s,r,n));i.push(...c.lines),o+=c.partialTailBytes}return{lines:i,ignoredPartialTailBytes:o}})}function Br(e,t,n,r){let i=`${e}${La}`,o=Math.max(0,t??Oa),a=n.monotonicNow()+o,s;for(;;){let p=n.tryAcquireLock(i,e);if(p.kind==="acquired"){s=p.lock;break}let f=a-n.monotonicNow();if(f<=0)throw new At(i,o);n.wait(Math.min(5,f))}let c=!1,l,u;try{u=r()}catch(p){c=!0,l=p}let d=!1;try{d=s.release()}catch(p){if(!c)throw p}if(c)throw l;if(!d)throw new _t(i);return u}function ja(e,t,n){if(!n.exists(e))return 0;let r=Vr(e,t,n);if(r.length===0||r[r.length-1]===10)return 0;let i=r.lastIndexOf(10),o=i<0?0:i+1;return n.truncate(e,o),r.length-o}function Ma(e){let t=e??Ae;if(!Number.isSafeInteger(t)||t<=0)throw new RangeError(`maxSegmentBytes must be a positive safe integer; received ${t}`);return t}function Vr(e,t,n){let r=n.size(e);if(r>t)throw new mt("rotating JSONL segment",e,"too-large",r,t);let i=n.readBytes(e),o=n.size(e);if(o!==r||i.byteLength!==r)throw new mt("rotating JSONL segment",e,"changed-during-read",o,t);return i}function Ca(e){let t=e.lastIndexOf(10),n=t<0?0:t+1;return{lines:e.subarray(0,n).toString("utf8").split(`
10
- `).filter(i=>i.length>0),partialTailBytes:e.length-n}}var Va="<global-symbols>";function Ua(e){let t=[];for(let n of e.all(`
11
- SELECT relative_path, language, position_encoding, text
12
- FROM documents
13
- `))t.push({relativePath:n.relative_path,kind:"document",values:[n.language,n.position_encoding,n.text]});for(let n of e.all(`
14
- SELECT d.relative_path,
15
- c.chunk_index,
16
- c.start_line,
17
- c.end_line,
18
- hex(c.occurrences) AS occurrences_hex
19
- FROM chunks c
20
- JOIN documents d ON d.id = c.document_id
21
- `))t.push({relativePath:n.relative_path,kind:"chunk",values:[n.chunk_index,n.start_line,n.end_line,n.occurrences_hex]});for(let n of e.all(`
22
- SELECT d.relative_path,
23
- r.start_line,
24
- r.start_char,
25
- r.end_line,
26
- r.end_char,
27
- g.symbol,
28
- g.display_name,
29
- g.kind,
30
- g.documentation,
31
- CASE WHEN g.signature IS NULL THEN NULL ELSE hex(g.signature) END AS signature_hex,
32
- g.enclosing_symbol,
33
- CASE WHEN g.relationships IS NULL THEN NULL ELSE hex(g.relationships) END AS relationships_hex
34
- FROM defn_enclosing_ranges r
35
- JOIN documents d ON d.id = r.document_id
36
- JOIN global_symbols g ON g.id = r.symbol_id
37
- `))t.push({relativePath:n.relative_path,kind:"definition",values:Dt(n,[n.start_line,n.start_char,n.end_line,n.end_char])});for(let n of e.all(`
38
- SELECT d.relative_path,
39
- c.chunk_index,
40
- m.role,
41
- g.symbol,
42
- g.display_name,
43
- g.kind,
44
- g.documentation,
45
- CASE WHEN g.signature IS NULL THEN NULL ELSE hex(g.signature) END AS signature_hex,
46
- g.enclosing_symbol,
47
- CASE WHEN g.relationships IS NULL THEN NULL ELSE hex(g.relationships) END AS relationships_hex
48
- FROM mentions m
49
- JOIN chunks c ON c.id = m.chunk_id
50
- JOIN documents d ON d.id = c.document_id
51
- JOIN global_symbols g ON g.id = m.symbol_id
52
- `))t.push({relativePath:n.relative_path,kind:"mention",values:Dt(n,[n.chunk_index,n.role])});for(let n of e.all(`
53
- SELECT g.symbol,
54
- g.display_name,
55
- g.kind,
56
- g.documentation,
57
- CASE WHEN g.signature IS NULL THEN NULL ELSE hex(g.signature) END AS signature_hex,
58
- g.enclosing_symbol,
59
- CASE WHEN g.relationships IS NULL THEN NULL ELSE hex(g.relationships) END AS relationships_hex
60
- FROM global_symbols g
61
- WHERE NOT EXISTS (
62
- SELECT 1 FROM defn_enclosing_ranges r WHERE r.symbol_id = g.id
63
- ) AND NOT EXISTS (
64
- SELECT 1 FROM mentions m WHERE m.symbol_id = g.id
65
- )
66
- `))t.push({relativePath:Va,kind:"global-symbol",values:Dt(n)});return Wa(t)}function Wa(e){let t=new Map;for(let r of e){let i=JSON.stringify([r.kind,r.values]),o=t.get(r.relativePath)??[];o.push(i),t.set(r.relativePath,o)}let n=new Map;for(let[r,i]of[...t].sort(([o],[a])=>o.localeCompare(a))){let o=Na("sha256");for(let a of i.sort())o.update(String(Buffer.byteLength(a))),o.update(":"),o.update(a),o.update(`
67
- `);n.set(r,o.digest("hex"))}return n}function Ga(e,t){let n=[],r=[],i=[],o=[],a=new Set([...e.keys(),...t.keys()]);for(let s of[...a].sort()){let c=e.get(s),l=t.get(s);c===void 0?n.push(s):l===void 0?i.push(s):c!==l?r.push(s):o.push(s)}return{addedFiles:n,modifiedFiles:r,deletedFiles:i,changedFiles:[...n,...r,...i].sort(),unchangedFiles:o}}function Lt(e,t,n){let r=new Set(e.affectedFiles),i=new Set(t.changedFiles),o=e.mode==="full-project"?[]:t.changedFiles.filter(c=>!r.has(c)),a=e.affectedFiles.filter(c=>!i.has(c)).sort(),s=t.changedFiles.length-o.length;return{passed:o.length===0,recall:t.changedFiles.length===0?1:s/t.changedFiles.length,affectedRatio:n===0?0:e.affectedFiles.length/n,predictedFiles:[...e.affectedFiles].sort(),actualFiles:[...t.changedFiles],missingFiles:o,extraFiles:a}}function Ot(e,t=Xa){let n=t.wallNow===void 0&&t.monotonicNow===void 0,r=t.monotonicNow??t.now,i=t.wallNow??t.now,o=r(),a=(l,u)=>{let d=r();return Xr(e.refreshResult,l,n?d:i(),Math.max(0,d-o),u)};if(!t.databaseExists(e.previousDbPath))return a("prior-index-unavailable");if(!t.databaseExists(e.candidateDbPath))return a("candidate-index-unavailable");let s=null,c=null;try{s=t.openDatabase(e.projectRoot,e.previousDbPath,e.previousIndexPath),c=t.openDatabase(e.projectRoot,e.candidateDbPath,e.candidateIndexPath);let l=[...new Set([...t.indexedPaths(s),...t.indexedPaths(c)])].sort(),u=Te(e.previousSnapshot,e.currentSnapshot),d=new Set(l),p=u.changes.length>0&&!Ft(u).fullProject&&u.changes.every(w=>d.has(w.path)),f=Be(u,p?t.dependencyGraph(s):new Map,l),g=Ga(t.factDigests(s),t.factDigests(c)),m=r();return{version:1,status:"evaluated",refreshResult:e.refreshResult,recordedAt:new Date(n?m:i()).toISOString(),durationMs:Math.max(0,m-o),manifest:u,plan:f,comparison:g,evaluation:Lt(f,g,l.length)}}catch(l){return a("oracle-error",l instanceof Error?l.message:String(l))}finally{Wr(s),Wr(c)}}function Jr(e,t,n,r=Date.now()){return Xr(e,t,r,0,n)}function Hr(e){let t=Ba(e);return{latestPath:Ur(t,"affected-shadow-latest.json"),historyPath:Ur(t,"affected-shadow.jsonl")}}function zd(e,t=n=>En(n,"affected-shadow source file")){let n=Hr(e),r;try{r=JSON.parse(t(n.latestPath))}catch(v){let P=es(v),S=P?"telemetry-missing":Za(v);return U(n,S,P?void 0:v instanceof Error?v.message:String(v))}if(z(r)&&typeof r.version=="number"&&r.version!==1)return U(n,"unsupported-record-version",`Unsupported version ${r.version}.`);if(!Ka(r))return U(n,"telemetry-malformed");if(r.status==="unavailable")return Qa(r.reason)?{state:"unavailable",...n,reason:r.reason,recordedAt:r.recordedAt,refreshResult:r.refreshResult,durationMs:r.durationMs,...typeof r.error=="string"?{error:r.error}:{}}:U(n,"telemetry-malformed");if(r.status!=="evaluated")return U(n,"telemetry-malformed");let i=r.plan,o=r.comparison,a=r.evaluation;if(!z(r.manifest)||!z(i)||!z(o)||!z(a))return U(n,"telemetry-malformed");let s=i.mode,c=X(i.affectedFiles),l=X(i.reasons),u=X(o.changedFiles),d=X(a.predictedFiles),p=X(a.actualFiles),f=X(a.missingFiles),g=a.recall,m=a.affectedRatio;if(s!=="none"&&s!=="closure"&&s!=="full-project"||c===null||l===null||u===null||d===null||p===null||f===null||typeof a.passed!="boolean"||!Gr(g)||!Gr(m))return U(n,"telemetry-malformed");let w=p.length===0?1:(p.length-f.length)/p.length;return!qr(c,d)||!qr(u,p)||a.passed!==(f.length===0)||Math.abs(g-w)>Number.EPSILON||f.some(v=>!p.includes(v)||d.includes(v))?U(n,"telemetry-malformed"):{state:a.passed?"passing":"failing",...n,recordedAt:r.recordedAt,refreshResult:r.refreshResult,durationMs:r.durationMs,mode:s,recall:g,affectedRatio:m,predictedFiles:d,actualFiles:p,missingFiles:f,fallbackReasons:l}}function Xd(e){if(e.state==="unavailable")return`unavailable (${e.reason})`;let t=e.missingFiles.length>0?`, ${e.missingFiles.length} missed`:"",n=e.fallbackReasons.length>0?`; fallback: ${e.fallbackReasons.join(", ")}`:"";return`${e.state}, ${(e.recall*100).toFixed(1)}% recall, ${e.predictedFiles.length} predicted / ${e.actualFiles.length} changed, ${(e.affectedRatio*100).toFixed(1)}% of project${t}${n}`}function zr(e,t,n=Ya){let r=Hr(e);return n.appendHistory(r.historyPath,t),n.writeLatest(r.latestPath,t),r}var qa=8*1024*1024,Ja=de;function Ha(e){let t={historyVersion:1,sourceVersion:e.version,refreshResult:e.refreshResult,recordedAt:e.recordedAt,durationMs:e.durationMs};return e.status==="unavailable"?{...t,status:"unavailable",reason:e.reason,...e.error?{error:e.error}:{}}:{...t,status:"evaluated",mode:e.plan.mode,passed:e.evaluation.passed,recall:e.evaluation.recall,affectedRatio:e.evaluation.affectedRatio,predictedFileCount:e.evaluation.predictedFiles.length,actualFileCount:e.evaluation.actualFiles.length,missingFileCount:e.evaluation.missingFiles.length,fallbackReasons:[...e.plan.reasons]}}function za(e,t,n=qa){Ve(e,Ha(t),{maxSegmentBytes:n,previousSuffix:Ja})}function Dt(e,t=[]){let n=[];for(let r of t)n.push(r);return n.push(e.symbol,e.display_name,e.kind,e.documentation,e.signature_hex,e.enclosing_symbol,e.relationships_hex),n}var Xa={now:()=>Date.now(),wallNow:()=>Date.now(),monotonicNow:R,databaseExists:e=>$a(e),openDatabase:(e,t,n)=>new j({projectRoot:e,dbPath:t,indexPath:n}),indexedPaths:e=>Fe(e),dependencyGraph:e=>Cn(e),factDigests:e=>Ua(e)},Ya={appendHistory:za,writeLatest:(e,t)=>zn(e,t,{spacing:2,trailingNewline:!0})};function Xr(e,t,n,r,i){return{version:1,status:"unavailable",refreshResult:e,recordedAt:new Date(n).toISOString(),durationMs:r,reason:t,...i?{error:i}:{}}}function Wr(e){try{e?.close()}catch{}}function Ka(e){return z(e)&&e.version===1&&typeof e.recordedAt=="string"&&(e.refreshResult==="rebuilt"||e.refreshResult==="reused")&&typeof e.durationMs=="number"&&Number.isFinite(e.durationMs)&&e.durationMs>=0}function Qa(e){return e==="prior-index-unavailable"||e==="candidate-index-unavailable"||e==="oracle-error"}function Gr(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0&&e<=1}function qr(e,t){return e.length===t.length&&e.every((n,r)=>n===t[r])}function U(e,t,n){return{state:"unavailable",...e,reason:t,...n?{error:n}:{}}}function Za(e){return e instanceof SyntaxError?"telemetry-malformed":"telemetry-unreadable"}function es(e){return e instanceof Error&&e.code==="ENOENT"}import{readdirSync as ts}from"fs";import{isAbsolute as Yr,join as ns,resolve as rs}from"path";var Ue="@sourcegraph/scip-typescript@0.4.0",Kr="scip-python-plus@0.7.5",Qr="github.com/sourcegraph/scip-go@v0.2.7",Zr="scip-dotnet@0.2.14",is="scip_dart@1.6.2",os={typescript:{language:"typescript",indexerBinary:"scip-typescript",checkCommand:"npx scip-typescript --version",indexArgs:({outputPath:e,pnpmWorkspaces:t,indexerBinary:n,projectPath:r})=>r?{binary:n,args:["index","--output",e,"--no-progress-bar",r]}:t?{binary:n,args:["index","--pnpm-workspaces","--output",e,"--no-progress-bar"]}:{binary:n,args:["index","--output",e,"--no-progress-bar"]},markerFiles:[...E.typescript],installMethods:[{label:"npm",identity:Ue,destination:"npm global prefix",prerequisite:"npm",binary:"npm",args:["install","-g",Ue]}],installUrl:"https://github.com/sourcegraph/scip-typescript",bundledNpmPackage:"@sourcegraph/scip-typescript"},javascript:{language:"javascript",indexerBinary:"scip-typescript",checkCommand:"npx scip-typescript --version",indexArgs:({outputPath:e,indexerBinary:t})=>({binary:t,args:["index","--output",e,"--no-progress-bar"]}),markerFiles:[...E.javascript],installMethods:[{label:"npm",identity:Ue,destination:"npm global prefix",prerequisite:"npm",binary:"npm",args:["install","-g",Ue]}],installUrl:"https://github.com/sourcegraph/scip-typescript",bundledNpmPackage:"@sourcegraph/scip-typescript"},java:{language:"java",indexerBinary:"scip-java",checkCommand:"scip-java --version",indexArgs:({outputPath:e})=>({binary:"scip-java",args:["index","--output",e]}),markerFiles:[...E.java],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-java/releases"},scala:{language:"scala",indexerBinary:"scip-java",checkCommand:"scip-java --version",indexArgs:({outputPath:e})=>({binary:"scip-java",args:["index","--output",e]}),markerFiles:[...E.scala],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-java/releases"},kotlin:{language:"kotlin",indexerBinary:"scip-java",checkCommand:"scip-java --version",indexArgs:({outputPath:e})=>({binary:"scip-java",args:["index","--output",e]}),markerFiles:[...E.kotlin],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-java/releases"},rust:{language:ce.language,indexerBinary:ce.indexerBinary,checkCommand:`${ce.indexerBinary} --version`,indexArgs:({outputPath:e})=>({binary:ce.indexerBinary,args:["scip",".","--output",e]}),markerFiles:[...E.rust],installMethods:[],installUrl:ce.installUrl},python:{language:"python",indexerBinary:"scip-python-plus",binaryAliases:["scip-python"],checkCommand:"scip-python-plus --version",indexArgs:({outputPath:e,indexerBinary:t})=>({binary:t,args:["index","--output",e,"--project-name","project"]}),markerFiles:[...E.python],installMethods:[{label:"npm",identity:Kr,destination:"npm global prefix",prerequisite:"npm",binary:"npm",args:["install","-g",Kr]}],installUrl:"https://github.com/PlunderStruck/scip-python",bundledNpmPackage:"scip-python-plus"},clojure:{language:"clojure",indexerBinary:"scip-clojure",projectLocalBinaries:["node_modules/.bin/scip-clojure"],checkCommand:"scip-clojure -h",indexArgs:({projectRoot:e,outputPath:t,indexerBinary:n,configPath:r})=>{let i=["-root",e,"-output",t];return r&&i.push("-config",Yr(r)?r:rs(e,r)),{binary:n,args:i}},markerFiles:[...E.clojure],installMethods:[],installUrl:"https://github.com/PlunderStruck/scip-clojure"},ruby:{language:"ruby",indexerBinary:"scip-ruby",checkCommand:"scip-ruby --version",indexArgs:({indexerBinary:e})=>({binary:e,args:["--dir","."]}),defaultOutputPath:"index.scip",markerFiles:[...E.ruby],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-ruby/releases"},go:{language:"go",indexerBinary:"scip-go",checkCommand:"scip-go --version",indexArgs:({outputPath:e})=>({binary:"scip-go",args:["--output",e]}),markerFiles:[...E.go],installMethods:[{label:"go install",identity:Qr,destination:"Go bin directory (GOBIN or GOPATH/bin)",prerequisite:"go",binary:"go",args:["install",Qr]}],installUrl:"https://github.com/sourcegraph/scip-go"},cpp:{language:"cpp",indexerBinary:"scip-clang",checkCommand:"scip-clang --version",indexArgs:({outputPath:e})=>({binary:"scip-clang",args:["--compdb-path","compile_commands.json","--index-output-path",e]}),markerFiles:[...E.cpp],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-clang/releases"},c:{language:"c",indexerBinary:"scip-clang",checkCommand:"scip-clang --version",indexArgs:({outputPath:e})=>({binary:"scip-clang",args:["--compdb-path","compile_commands.json","--index-output-path",e]}),markerFiles:[...E.c],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-clang/releases"},csharp:{language:"csharp",indexerBinary:"scip-dotnet",checkCommand:"scip-dotnet --version",indexArgs:({projectRoot:e,outputPath:t})=>({binary:"scip-dotnet",args:["index",ei(e,[".sln",".csproj"])??e,"--output",t,"--working-directory",e]}),markerFiles:[...E.csharp],installMethods:[{label:"dotnet",identity:Zr,destination:"dotnet global tool directory",prerequisite:"dotnet",binary:"dotnet",args:["tool","install","--global","scip-dotnet","--version","0.2.14"]}],installUrl:"https://github.com/sourcegraph/scip-dotnet/releases"},vb:{language:"vb",indexerBinary:"scip-dotnet",checkCommand:"scip-dotnet --version",indexArgs:({projectRoot:e,outputPath:t})=>({binary:"scip-dotnet",args:["index",ei(e,[".sln",".vbproj"])??e,"--output",t,"--working-directory",e]}),markerFiles:[...E.vb],installMethods:[{label:"dotnet",identity:Zr,destination:"dotnet global tool directory",prerequisite:"dotnet",binary:"dotnet",args:["tool","install","--global","scip-dotnet","--version","0.2.14"]}],installUrl:"https://github.com/sourcegraph/scip-dotnet/releases"},dart:{language:"dart",indexerBinary:"scip-dart",checkCommand:"scip-dart --version",indexArgs:({indexerBinary:e,outputPath:t})=>({binary:e,args:["--output",t]}),markerFiles:[...E.dart],installMethods:[{label:"dart pub",identity:is,destination:"Dart pub global cache",prerequisite:"dart",binary:"dart",args:["pub","global","activate","scip_dart","1.6.2"]}],installUrl:"https://github.com/Workiva/scip-dart/releases"},php:{language:"php",indexerBinary:"scip-php",projectLocalBinaries:["vendor/davidrjenni/scip-php/bin/scip-php","vendor/bin/scip-php"],checkCommand:"scip-php --version",indexArgs:({indexerBinary:e})=>Yr(e)?{binary:"php",args:["-d","error_reporting=E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED",e]}:{binary:e,args:[]},defaultOutputPath:"index.scip",markerFiles:[...E.php],installMethods:[],installUrl:"https://github.com/davidrjenni/scip-php/releases"}};function ti(e){if(!(e.projectPath||e.pnpmWorkspaces)){if(e.language==="typescript")return"{}";if(e.language==="javascript")return'{"compilerOptions":{"allowJs":true}}'}}function jt(e){return os[e]}function ei(e,t){let n;try{n=ts(e)}catch{return null}for(let r of t)for(let i of n)if(i.endsWith(r))return ns(e,i);return null}import{createHash as as}from"crypto";import{existsSync as ni,rmSync as ri}from"fs";import{resolve as ss}from"path";import ai from"better-sqlite3";var cs={documents:[{name:"id",type:"INTEGER",notnull:0,pk:1},{name:"language",type:"TEXT",notnull:0,pk:0},{name:"relative_path",type:"TEXT",notnull:1,pk:0},{name:"position_encoding",type:"TEXT",notnull:0,pk:0},{name:"text",type:"TEXT",notnull:0,pk:0}],chunks:[{name:"id",type:"INTEGER",notnull:0,pk:1},{name:"document_id",type:"INTEGER",notnull:1,pk:0},{name:"chunk_index",type:"INTEGER",notnull:1,pk:0},{name:"start_line",type:"INTEGER",notnull:1,pk:0},{name:"end_line",type:"INTEGER",notnull:1,pk:0},{name:"occurrences",type:"BLOB",notnull:1,pk:0}],global_symbols:[{name:"id",type:"INTEGER",notnull:0,pk:1},{name:"symbol",type:"TEXT",notnull:1,pk:0},{name:"display_name",type:"TEXT",notnull:0,pk:0},{name:"kind",type:"INTEGER",notnull:0,pk:0},{name:"documentation",type:"TEXT",notnull:0,pk:0},{name:"signature",type:"BLOB",notnull:0,pk:0},{name:"enclosing_symbol",type:"TEXT",notnull:0,pk:0},{name:"relationships",type:"BLOB",notnull:0,pk:0}],mentions:[{name:"chunk_id",type:"INTEGER",notnull:1,pk:1},{name:"symbol_id",type:"INTEGER",notnull:1,pk:2},{name:"role",type:"INTEGER",notnull:1,pk:3}],defn_enclosing_ranges:[{name:"id",type:"INTEGER",notnull:0,pk:1},{name:"document_id",type:"INTEGER",notnull:1,pk:0},{name:"symbol_id",type:"INTEGER",notnull:1,pk:0},{name:"start_line",type:"INTEGER",notnull:1,pk:0},{name:"start_char",type:"INTEGER",notnull:1,pk:0},{name:"end_line",type:"INTEGER",notnull:1,pk:0},{name:"end_char",type:"INTEGER",notnull:1,pk:0}]},us={idx_chunks_line_range:{table:"chunks",columns:["document_id","start_line","end_line"]},idx_defn_enclosing_ranges_document:{table:"defn_enclosing_ranges",columns:["document_id","start_line","end_line"]},idx_defn_enclosing_ranges_symbol_id:{table:"defn_enclosing_ranges",columns:["symbol_id"]},idx_mentions_symbol_id_role:{table:"mentions",columns:["symbol_id","role"]}};function si(e){let t=R(),n=ls(e.affectedFiles);if(ds(e.previousDbPath,e.miniDbPath,e.candidateDbPath),ri(e.candidateDbPath,{force:!0}),!ni(e.previousDbPath))throw new Error("previous SQLite generation is unavailable");if(!ni(e.miniDbPath))throw new Error("incremental SQLite mini database is unavailable");ii(e.previousDbPath,"previous SQLite generation",!1),ii(e.miniDbPath,"incremental SQLite mini database");let r=K(e.previousDbPath,e.candidateDbPath);e.writeTelemetry&&Q(e.writeTelemetry,r);let i=null;try{i=new ai(e.candidateDbPath,{fileMustExist:!0}),i.pragma("busy_timeout = 5000"),i.pragma("foreign_keys = ON"),i.prepare("ATTACH DATABASE ? AS incremental").run(e.miniDbPath),Mt(i,"main","candidate SQLite generation"),Mt(i,"incremental","incremental SQLite mini database"),ps(i,n);let{priorAffectedCount:o}=gs(i,n.length),a=Ct(i,"main",!0),s=W(i,"SELECT COUNT(*) AS value FROM main.documents");i.transaction(()=>{fs(i),ms(i),hs(i),e.onStage?.("after-delete"),ys(i),e.onStage?.("after-symbol-reconciliation"),Ss(i),e.onStage?.("after-insert"),bs(i),Rs(i,n.length,s,o),e.onStage?.("before-commit")}).immediate(),ci(i,"main","candidate SQLite generation");let u=[...xs(i)].filter(([d,p])=>a.get(d)!==p).map(([d])=>d).sort();return i.exec("DETACH DATABASE incremental"),i.close(),i=null,{candidateDbPath:e.candidateDbPath,affectedDocumentCount:n.length,changedDocumentPaths:u,durationMs:R()-t}}catch(o){try{i?.close()}finally{ri(e.candidateDbPath,{force:!0})}throw new Error(`Incremental SQLite publication rejected: ${o instanceof Error?o.message:String(o)}`,{cause:o})}}function ls(e){if(e.length===0)throw new Error("incremental SQLite publication requires affected documents");let t=[...e].sort();for(let n of t)if(!n||n.startsWith("/")||n.includes("\\")||n.split("/").includes(".."))throw new Error(`invalid affected document path: ${n}`);if(new Set(t).size!==t.length)throw new Error("incremental SQLite publication contains duplicate affected documents");return t}function ds(e,t,n){let r=[e,t,n].map(i=>ss(i));if(new Set(r).size!==r.length)throw new Error("previous, mini, and candidate SQLite paths must be distinct")}function ii(e,t,n=!0){let r=new ai(e,{readonly:!0,fileMustExist:!0});try{Mt(r,"main",t),n&&ci(r,"main",t)}finally{r.close()}}function Mt(e,t,n){for(let[r,i]of Object.entries(cs)){let a=e.prepare(`PRAGMA ${t}.table_info('${r}')`).all().map(({name:s,type:c,notnull:l,pk:u})=>({name:s,type:c.toUpperCase(),notnull:l,pk:u}));if(JSON.stringify(a)!==JSON.stringify(i))throw new Error(`${n} schema changed for table ${r}`)}for(let[r,i]of Object.entries(us)){let o=e.prepare(`SELECT tbl_name FROM ${t}.sqlite_master WHERE type = 'index' AND name = ?`).get(r),a=e.prepare(`PRAGMA ${t}.index_info('${r}')`).all().map(s=>s.name);if(o?.tbl_name!==i.table||JSON.stringify(a)!==JSON.stringify(i.columns))throw new Error(`${n} schema changed for index ${r}`)}oi(e,t,"documents",["relative_path"],n),oi(e,t,"global_symbols",["symbol"],n)}function oi(e,t,n,r,i){if(!e.prepare(`PRAGMA ${t}.index_list('${n}')`).all().some(s=>{if(s.unique!==1)return!1;let c=e.prepare(`PRAGMA ${t}.index_info('${s.name}')`).all().map(l=>l.name);return JSON.stringify(c)===JSON.stringify(r)}))throw new Error(`${i} lost the unique ${n}(${r.join(", ")}) constraint`)}function ci(e,t,n){let r=e.prepare(`PRAGMA ${t}.integrity_check`).pluck().get();if(r!=="ok")throw new Error(`${n} failed integrity_check: ${String(r)}`);if(e.prepare(`PRAGMA ${t}.foreign_key_check`).all().length>0)throw new Error(`${n} failed foreign_key_check`)}function ps(e,t){e.exec("CREATE TEMP TABLE incremental_affected_paths (relative_path TEXT PRIMARY KEY) WITHOUT ROWID");let n=e.prepare("INSERT INTO temp.incremental_affected_paths(relative_path) VALUES (?)");e.transaction(i=>{for(let o of i)n.run(o)})(t)}function gs(e,t){let n=W(e,"SELECT COUNT(*) AS value FROM incremental.documents"),r=W(e,`SELECT COUNT(*) AS value
68
- FROM main.documents d
69
- JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path`),i=e.prepare(`SELECT p.relative_path
70
- FROM temp.incremental_affected_paths p
71
- LEFT JOIN incremental.documents d ON d.relative_path = p.relative_path
72
- WHERE d.id IS NULL
73
- LIMIT 1`).pluck().get(),o=e.prepare(`SELECT d.relative_path
74
- FROM incremental.documents d
75
- LEFT JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path
76
- WHERE p.relative_path IS NULL
77
- LIMIT 1`).pluck().get();if(n!==t||i!==void 0||o!==void 0)throw new Error("incremental SQLite mini database does not exactly match the affected document set");return{priorAffectedCount:r}}function fs(e){e.exec(`
78
- CREATE TEMP TABLE incremental_old_defined_symbols (symbol TEXT PRIMARY KEY) WITHOUT ROWID;
79
- INSERT OR IGNORE INTO temp.incremental_old_defined_symbols(symbol)
80
- SELECT g.symbol
81
- FROM main.defn_enclosing_ranges r
82
- JOIN main.documents d ON d.id = r.document_id
83
- JOIN main.global_symbols g ON g.id = r.symbol_id
84
- JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path;
85
- INSERT OR IGNORE INTO temp.incremental_old_defined_symbols(symbol)
86
- SELECT g.symbol
87
- FROM main.mentions m
88
- JOIN main.chunks c ON c.id = m.chunk_id
89
- JOIN main.documents d ON d.id = c.document_id
90
- JOIN main.global_symbols g ON g.id = m.symbol_id
91
- JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path
92
- WHERE m.role = 1;
93
-
94
- CREATE TEMP TABLE incremental_new_defined_symbols (symbol TEXT PRIMARY KEY) WITHOUT ROWID;
95
- INSERT OR IGNORE INTO temp.incremental_new_defined_symbols(symbol)
96
- SELECT g.symbol
97
- FROM incremental.defn_enclosing_ranges r
98
- JOIN incremental.global_symbols g ON g.id = r.symbol_id;
99
- INSERT OR IGNORE INTO temp.incremental_new_defined_symbols(symbol)
100
- SELECT g.symbol
101
- FROM incremental.mentions m
102
- JOIN incremental.global_symbols g ON g.id = m.symbol_id
103
- WHERE m.role = 1;
104
- `)}function ms(e){let t=e.prepare(`WITH changed_symbols AS (
105
- SELECT symbol FROM temp.incremental_old_defined_symbols
106
- UNION
107
- SELECT symbol FROM temp.incremental_new_defined_symbols
108
- ), unaffected_definitions AS (
109
- SELECT g.symbol
110
- FROM main.defn_enclosing_ranges r
111
- JOIN main.documents d ON d.id = r.document_id
112
- JOIN main.global_symbols g ON g.id = r.symbol_id
113
- LEFT JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path
114
- WHERE p.relative_path IS NULL
115
- UNION
116
- SELECT g.symbol
117
- FROM main.mentions m
118
- JOIN main.chunks c ON c.id = m.chunk_id
119
- JOIN main.documents d ON d.id = c.document_id
120
- JOIN main.global_symbols g ON g.id = m.symbol_id
121
- LEFT JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path
122
- WHERE m.role = 1 AND p.relative_path IS NULL
123
- )
124
- SELECT u.symbol
125
- FROM unaffected_definitions u
126
- JOIN changed_symbols c ON c.symbol = u.symbol
127
- LIMIT 1`).pluck().get();if(typeof t=="string")throw new Error(`symbol definition is shared by affected and unaffected documents: ${t}`)}function hs(e){e.exec(`
128
- DELETE FROM main.mentions
129
- WHERE chunk_id IN (
130
- SELECT c.id
131
- FROM main.chunks c
132
- JOIN main.documents d ON d.id = c.document_id
133
- JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path
134
- );
135
- DELETE FROM main.chunks
136
- WHERE document_id IN (
137
- SELECT d.id
138
- FROM main.documents d
139
- JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path
140
- );
141
- DELETE FROM main.defn_enclosing_ranges
142
- WHERE document_id IN (
143
- SELECT d.id
144
- FROM main.documents d
145
- JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path
146
- );
147
- DELETE FROM main.documents
148
- WHERE relative_path IN (SELECT relative_path FROM temp.incremental_affected_paths);
149
- `)}function ys(e){e.exec(`
150
- UPDATE main.global_symbols
151
- SET display_name = NULL,
152
- kind = NULL,
153
- documentation = NULL,
154
- signature = NULL,
155
- enclosing_symbol = NULL,
156
- relationships = NULL
157
- WHERE symbol IN (SELECT symbol FROM temp.incremental_old_defined_symbols);
158
-
159
- INSERT OR IGNORE INTO main.global_symbols(
160
- symbol, display_name, kind, documentation, signature, enclosing_symbol, relationships
161
- )
162
- SELECT symbol, display_name, kind, documentation, signature, enclosing_symbol, relationships
163
- FROM incremental.global_symbols;
164
-
165
- UPDATE main.global_symbols
166
- SET display_name = (
167
- SELECT source.display_name FROM incremental.global_symbols source
168
- WHERE source.symbol = main.global_symbols.symbol
169
- ),
170
- kind = (
171
- SELECT source.kind FROM incremental.global_symbols source
172
- WHERE source.symbol = main.global_symbols.symbol
173
- ),
174
- documentation = (
175
- SELECT source.documentation FROM incremental.global_symbols source
176
- WHERE source.symbol = main.global_symbols.symbol
177
- ),
178
- signature = (
179
- SELECT source.signature FROM incremental.global_symbols source
180
- WHERE source.symbol = main.global_symbols.symbol
181
- ),
182
- enclosing_symbol = (
183
- SELECT source.enclosing_symbol FROM incremental.global_symbols source
184
- WHERE source.symbol = main.global_symbols.symbol
185
- ),
186
- relationships = (
187
- SELECT source.relationships FROM incremental.global_symbols source
188
- WHERE source.symbol = main.global_symbols.symbol
189
- )
190
- WHERE symbol IN (SELECT symbol FROM temp.incremental_new_defined_symbols);
191
- `)}function Ss(e){let t=W(e,"SELECT COALESCE(MAX(id), 0) AS value FROM main.documents"),n=W(e,"SELECT COALESCE(MAX(id), 0) AS value FROM main.chunks"),r=W(e,"SELECT COALESCE(MAX(id), 0) AS value FROM main.defn_enclosing_ranges");e.prepare(`INSERT INTO main.documents(id, language, relative_path, position_encoding, text)
192
- SELECT id + ?, language, relative_path, position_encoding, text
193
- FROM incremental.documents`).run(t),e.prepare(`INSERT INTO main.chunks(id, document_id, chunk_index, start_line, end_line, occurrences)
194
- SELECT id + ?, document_id + ?, chunk_index, start_line, end_line, occurrences
195
- FROM incremental.chunks`).run(n,t),e.prepare(`INSERT INTO main.mentions(chunk_id, symbol_id, role)
196
- SELECT m.chunk_id + ?, target.id, m.role
197
- FROM incremental.mentions m
198
- JOIN incremental.global_symbols source ON source.id = m.symbol_id
199
- JOIN main.global_symbols target ON target.symbol = source.symbol`).run(n),e.prepare(`INSERT INTO main.defn_enclosing_ranges(
200
- id, document_id, symbol_id, start_line, start_char, end_line, end_char
201
- )
202
- SELECT r.id + ?, r.document_id + ?, target.id,
203
- r.start_line, r.start_char, r.end_line, r.end_char
204
- FROM incremental.defn_enclosing_ranges r
205
- JOIN incremental.global_symbols source ON source.id = r.symbol_id
206
- JOIN main.global_symbols target ON target.symbol = source.symbol`).run(r,t)}function bs(e){e.exec(`
207
- DELETE FROM main.global_symbols
208
- WHERE NOT EXISTS (SELECT 1 FROM main.mentions m WHERE m.symbol_id = main.global_symbols.id)
209
- AND NOT EXISTS (
210
- SELECT 1 FROM main.defn_enclosing_ranges r WHERE r.symbol_id = main.global_symbols.id
211
- );
212
- `)}function Rs(e,t,n,r){let i=W(e,"SELECT COUNT(*) AS value FROM main.documents"),o=W(e,`SELECT COUNT(*) AS value
213
- FROM main.documents d
214
- JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path`),a=n-r+t;if(i!==a||o!==t)throw new Error("candidate SQLite document counts changed unexpectedly");let s=e.prepare("SELECT relative_path FROM main.documents GROUP BY relative_path HAVING COUNT(*) > 1 LIMIT 1").pluck().get(),c=e.prepare("SELECT symbol FROM main.global_symbols GROUP BY symbol HAVING COUNT(*) > 1 LIMIT 1").pluck().get();if(s!==void 0||c!==void 0)throw new Error("candidate SQLite generation contains duplicate document paths or symbols")}function xs(e){let t=Ct(e,"main",!0),n=Ct(e,"incremental",!1);if(JSON.stringify([...t])!==JSON.stringify([...n]))throw new Error("candidate SQLite affected document facts differ from the mini database");return t}function Ct(e,t,n){let r=n?"JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path":"",i=e.prepare(`SELECT d.relative_path, d.language, d.position_encoding, d.text
215
- FROM ${t}.documents d
216
- ${r}
217
- ORDER BY d.relative_path`).all(),o=e.prepare(`SELECT d.relative_path, c.chunk_index, c.start_line, c.end_line, hex(c.occurrences) AS occurrences
218
- FROM ${t}.chunks c
219
- JOIN ${t}.documents d ON d.id = c.document_id
220
- ${r}
221
- ORDER BY d.relative_path, c.chunk_index, c.start_line, c.end_line, c.id`).all(),a=e.prepare(`SELECT d.relative_path, r.start_line, r.start_char, r.end_line, r.end_char,
222
- g.symbol, g.display_name, g.kind, g.documentation,
223
- CASE WHEN g.signature IS NULL THEN NULL ELSE hex(g.signature) END AS signature,
224
- g.enclosing_symbol,
225
- CASE WHEN g.relationships IS NULL THEN NULL ELSE hex(g.relationships) END AS relationships
226
- FROM ${t}.defn_enclosing_ranges r
227
- JOIN ${t}.documents d ON d.id = r.document_id
228
- JOIN ${t}.global_symbols g ON g.id = r.symbol_id
229
- ${r}
230
- ORDER BY d.relative_path, r.start_line, r.start_char, r.end_line, r.end_char, g.symbol`).all(),s=e.prepare(`SELECT d.relative_path, c.chunk_index, m.role, g.symbol
231
- FROM ${t}.mentions m
232
- JOIN ${t}.chunks c ON c.id = m.chunk_id
233
- JOIN ${t}.documents d ON d.id = c.document_id
234
- JOIN ${t}.global_symbols g ON g.id = m.symbol_id
235
- ${r}
236
- ORDER BY d.relative_path, c.chunk_index, m.role, g.symbol`).all(),c=new Map;for(let[u,d]of Object.entries({documents:i,chunks:o,definitions:a,mentions:s}))for(let p of d){let f=JSON.stringify([u,p]),g=c.get(p.relative_path)??[];g.push(f),c.set(p.relative_path,g)}let l=new Map;for(let[u,d]of[...c].sort(([p],[f])=>p.localeCompare(f))){let p=as("sha256");for(let f of d.sort())p.update(f).update(`
237
- `);l.set(u,p.digest("hex"))}return l}function W(e,t){return e.prepare(t).get().value}import vs from"better-sqlite3";var We="idx_mentions_definitions",Ps=["symbol_id","chunk_id"];function Nt(e){let t=new vs(e),n=[],r=[],i=[];try{return t.transaction(()=>{Is(t,n),Ge(t,"idx_global_symbols_symbol")?.join("\0")==="symbol"&&ui(t,"global_symbols").some(s=>s.name!=="idx_global_symbols_symbol"&&s.unique&&s.columns.join("\0")==="symbol")?(t.exec('DROP INDEX "idx_global_symbols_symbol"'),r.push("idx_global_symbols_symbol")):Ge(t,"idx_global_symbols_symbol")&&i.push("idx_global_symbols_symbol");let o=Ge(t,"idx_chunks_doc_id"),a=ui(t,"chunks").some(s=>s.name!=="idx_chunks_doc_id"&&s.columns.length>1&&s.columns[0]==="document_id");o?.join("\0")==="document_id"&&a?(t.exec('DROP INDEX "idx_chunks_doc_id"'),r.push("idx_chunks_doc_id")):o&&i.push("idx_chunks_doc_id"),t.exec("ANALYZE")})(),{added:n,removed:r,retained:i,analyzed:!0}}catch(o){if(o.code==="SQLITE_NOTADB")return{added:[],removed:[],retained:[],analyzed:!1,skippedReason:"not-a-sqlite-database"};throw o}finally{t.close()}}function Is(e,t){let n=li(e,We);if(n){let r=n.columns.join("\0")===Ps.join("\0"),i=/\bWHERE\s+role\s*=\s*1\b/iu.test(n.sql??"");if(!r||!i||n.table!=="mentions")throw new Error(`${We} exists with an incompatible definition`);return}e.exec(`CREATE INDEX "${We}" ON mentions(symbol_id, chunk_id) WHERE role = 1`),t.push(We)}function ui(e,t){return e.prepare(`PRAGMA index_list('${t.replaceAll("'","''")}')`).all().map(n=>({name:n.name,unique:n.unique===1,columns:Ge(e,n.name)??[]}))}function Ge(e,t){return li(e,t)?.columns??null}function li(e,t){let n=e.prepare("SELECT tbl_name, sql FROM sqlite_master WHERE type = 'index' AND name = ?").get(t);if(!n)return null;let r=e.prepare(`PRAGMA index_info('${t.replaceAll("'","''")}')`).all().map(i=>i.name);return{table:n.tbl_name,sql:n.sql,columns:r}}import{writeFileSync as ws}from"fs";function ee(e,t){let n=performance.now(),r=e.run(t);return{stageId:e.id,facts:e.facts,durationMs:performance.now()-n,result:r}}async function pi(e){let t=e.readFingerprint(),n=ks(e.cachePath,t);if(n)return e.onCacheHit?.(n.result),n.result;let r=await e.compute();return Es(e.cachePath,e.readFingerprint(),r),r}function ks(e,t){try{let n=JSON.parse(_(e,{maxBytes:ie,inputKind:"post-index augmentation cache"}));return di(n.fingerprint)===di(t)?{result:n.result}:null}catch{return null}}function Es(e,t,n){ws(e,`${JSON.stringify({updatedAt:new Date().toISOString(),fingerprint:t,result:n},null,2)}
238
- `)}function di(e){return JSON.stringify(e)}import{existsSync as gi,statSync as Ts}from"fs";import{dirname as yi,join as Si}from"path";var Fs="reindex-activity.jsonl",qe=de,As=1024*1024,_s=1440*60*1e3,fi=e=>D(e,"reindex activity segment");function Je(e){return Si(yi(e),Fs)}function Ds(e){if(e.reused)return 0;let n=(e.shards?.some(r=>!r.reused&&r.strategy==="incremental")??!1?0:$t(e.indexPath))+$t(e.dbPath);for(let r of e.shards??[]){if(r.reused)continue;let i=r.producedOutputBytes??r.outputBytes;i!==null&&(n+=i)}return n}function Bt(e,t){let n=t.lastRefresh;if(!n)return{state:"failed",reason:"reindex result has no refresh metadata"};let r=Ds(t);return Vt(Je(e),{version:1,event:"run",recordedAt:n.completedAt,trigger:n.trigger,result:n.result,durationMs:n.durationMs,estimatedLogicalOutputBytes:r,estimatedWriteBytes:r+(t.writeTelemetry?.fallbackCopiedBytes??0),reflinkedBytes:t.writeTelemetry?.reflinkedBytes??0,fallbackCopiedBytes:t.writeTelemetry?.fallbackCopiedBytes??0,byLanguage:Ns(t)})}function bi(e,t){return Vt(Je(e),{version:1,event:"run",recordedAt:t.completedAt,trigger:t.trigger,result:"failed",durationMs:t.durationMs,estimatedLogicalOutputBytes:0})}function Rp(e,t,n=new Date){return Vt(Je(e),{version:1,event:"suppressed",recordedAt:n.toISOString(),trigger:t,reason:"completed-index-is-fresh"})}function Ls(e,t,n=As,r){Ve(e,t,{maxSegmentBytes:n,previousSuffix:qe,...r?{runtime:r}:{}})}function Os(e,t=new Date,n=_s,r=fi){let i=t.getTime(),o=i-n,a={confidence:"complete",recordsRead:0,invalidRecords:0,skippedRecords:0,readErrors:0,ignoredPartialTailBytes:0,windowStartedAt:new Date(o).toISOString(),windowEndedAt:t.toISOString(),runs:0,rebuilt:0,fullRebuilds:0,reused:0,failed:0,suppressed:0,estimatedLogicalOutputBytes:0,estimatedWriteBytes:0,reflinkedBytes:0,fallbackCopiedBytes:0,languageAttribution:"complete",attributedRuns:0,unattributedRuns:0,invalidLanguageDetails:0,byLanguage:{},byTrigger:{}},s=Je(e),c=[];if(r===fi){if(!gi(s)&&!gi(`${s}${qe}`))return a;try{let l=$r(s,{previousSuffix:qe});c=l.lines,a.ignoredPartialTailBytes=l.ignoredPartialTailBytes}catch{a.readErrors+=1,a.confidence="unavailable"}}else{let l=0;for(let u of[`${s}${qe}`,s])try{c.push(...Gs(r(u))),l+=1}catch{a.readErrors+=1}l===0?a.confidence="unavailable":a.readErrors>0&&(a.confidence="partial")}for(let l of c){a.recordsRead+=1;let u=js(l);if(!u){a.invalidRecords+=1,a.confidence!=="unavailable"&&(a.confidence="partial");continue}let{record:d}=u,p=Date.parse(d.recordedAt);if(p<o||p>i){a.skippedRecords+=1;continue}if(a.invalidLanguageDetails=(a.invalidLanguageDetails??0)+u.invalidLanguageDetails,a.byTrigger[d.trigger.kind]=(a.byTrigger[d.trigger.kind]??0)+1,d.event==="suppressed"){a.suppressed+=1;continue}a.runs+=1,a[d.result]+=1,a.estimatedLogicalOutputBytes+=d.estimatedLogicalOutputBytes,a.estimatedWriteBytes=(a.estimatedWriteBytes??0)+(d.estimatedWriteBytes??d.estimatedLogicalOutputBytes),a.reflinkedBytes=(a.reflinkedBytes??0)+(d.reflinkedBytes??0),a.fallbackCopiedBytes=(a.fallbackCopiedBytes??0)+(d.fallbackCopiedBytes??0),d.result!=="failed"&&(u.hasLanguageDetails?a.attributedRuns=(a.attributedRuns??0)+1:a.unattributedRuns=(a.unattributedRuns??0)+1);for(let[f,g]of Ri(d.byLanguage)){let m=(a.byLanguage??={})[f]??=Us();m.runs+=1,m[g.result]+=1,m.producedOutputBytes+=g.producedOutputBytes,m.durationMs+=g.durationMs}mi(d)&&a.oldestRebuildAt===void 0&&(a.oldestRebuildAt=d.recordedAt),mi(d)&&(a.fullRebuilds=(a.fullRebuilds??0)+1),(d.estimatedWriteBytes??d.estimatedLogicalOutputBytes)>0&&a.oldestWriteAt===void 0&&(a.oldestWriteAt=d.recordedAt)}return a.ignoredPartialTailBytes>0&&a.confidence!=="unavailable"&&(a.confidence="partial"),a.languageAttribution=Ws(a),a}function Vt(e,t){try{return Ls(e,t),{state:"recorded"}}catch(n){return{state:"failed",reason:n instanceof Error?n.message:String(n)}}}function js(e){try{let t=JSON.parse(e);if(!t||typeof t!="object")return null;let n=t;if(n.version!==1||!Pn(n.recordedAt)||!n.trigger||!Cs(n.trigger.kind))return null;if(n.event==="suppressed")return n.reason==="completed-index-is-fresh"?{record:n,hasLanguageDetails:!1,invalidLanguageDetails:0}:null;if(n.event!=="run"||n.result!=="rebuilt"&&n.result!=="reused"&&n.result!=="failed"||!H(n.durationMs)||!H(n.estimatedLogicalOutputBytes)||n.estimatedWriteBytes!==void 0&&!H(n.estimatedWriteBytes)||n.reflinkedBytes!==void 0&&!H(n.reflinkedBytes)||n.fallbackCopiedBytes!==void 0&&!H(n.fallbackCopiedBytes))return null;let r=n,{byLanguage:i,...o}=r,a=$s(i);return{record:{...o,...a.byLanguage?{byLanguage:a.byLanguage}:{}},hasLanguageDetails:a.hasLanguageDetails,invalidLanguageDetails:a.invalidLanguageDetails}}catch{return null}}function xp(e,t,n=new Date){return t.enabled?Ms(Os(e,n,t.windowMs),t,n.getTime()):{state:"allowed",rebuilt:0,estimatedWriteBytes:0}}function Ms(e,t,n){let r=e.estimatedWriteBytes??e.estimatedLogicalOutputBytes,i=e.fullRebuilds??e.rebuilt,o={rebuilt:i,estimatedWriteBytes:r};return t.enabled?e.confidence!==void 0&&e.confidence!=="complete"?{state:"paused",reason:"activity-evidence",until:n+t.windowMs,...o,detail:`reindex activity evidence is ${e.confidence}`}:i>=t.maxRebuilds?{state:"paused",reason:"rebuild-count",until:hi(e.oldestRebuildAt,t.windowMs,n),...o,detail:`${i}/${t.maxRebuilds} expensive full rebuild slots consumed`}:r>=t.maxEstimatedWriteBytes?{state:"paused",reason:"estimated-write-bytes",until:hi(e.oldestWriteAt,t.windowMs,n),...o,detail:`${r}/${t.maxEstimatedWriteBytes} estimated write bytes consumed`}:{state:"allowed",...o}:{state:"allowed",...o}}function mi(e){if(e.result!=="rebuilt")return!1;let t=Ri(e.byLanguage);return t.length===0?!0:t.some(([,n])=>n.result==="rebuilt"&&n.strategy!=="incremental"&&n.strategy!=="reused")}function hi(e,t,n){let r=e?Date.parse(e):Number.NaN;return Number.isFinite(r)&&r+t>n?r+t:n+t}function Cs(e){return e==="manual-cli"||e==="setup"||e==="watch-source"||e==="watch-startup"||e==="watch-demand"||e==="watch-git-head"||e==="watch-git-index"||e==="watch-git-state"||e==="unknown"}function $t(e){try{return Ts(e).size}catch{return 0}}function Ns(e){let t={};for(let n of e.languages){let r=(e.shards??[]).filter(l=>l.language===n),i=r.find(l=>l.id===n),o=e.reused||(i?i.reused:r.length>0&&r.every(l=>l.reused)),a=$t(Si(yi(e.dbPath),"language-indexes",`${n}.scip`)),s=a>0?a:i?.outputBytes??a,c=o?0:i?.durationMs??r.filter(l=>!l.reused).reduce((l,u)=>l+u.durationMs,0);t[n]={result:o?"reused":"rebuilt",strategy:o?"reused":i?.strategy??"full",...i?.strategy==="full"&&(i.fallbackReason??i.missReason)?{fallbackReason:i.fallbackReason??i.missReason}:{},outputBytes:s,producedOutputBytes:o?0:i?.producedOutputBytes??s,durationMs:c}}return t}function $s(e){if(e===void 0)return{hasLanguageDetails:!1,invalidLanguageDetails:0};if(!e||typeof e!="object"||Array.isArray(e))return{hasLanguageDetails:!1,invalidLanguageDetails:1};let t={},n=0;for(let[i,o]of Object.entries(e)){if(!Vs(i)||!Bs(o)){n+=1;continue}t[i]=o}let r=Object.keys(t).length>0;return{...r?{byLanguage:t}:{},hasLanguageDetails:r,invalidLanguageDetails:n}}function Bs(e){if(!e||typeof e!="object")return!1;let t=e;return(t.result==="rebuilt"||t.result==="reused")&&(t.strategy===void 0||t.strategy==="reused"||t.strategy==="incremental"||t.strategy==="full")&&(t.fallbackReason===void 0||typeof t.fallbackReason=="string")&&ut(t.outputBytes)&&ut(t.producedOutputBytes)&&H(t.durationMs)&&(t.result!=="reused"||t.producedOutputBytes===0&&t.durationMs===0)&&t.producedOutputBytes<=t.outputBytes}function Vs(e){return lt.includes(e)}function Ri(e){return e?lt.flatMap(t=>{let n=e[t];return n?[[t,n]]:[]}):[]}function Us(){return{runs:0,rebuilt:0,reused:0,producedOutputBytes:0,durationMs:0}}function Ws(e){let t=e.invalidLanguageDetails??0,n=e.attributedRuns??0;return(e.unattributedRuns??0)===0&&t===0?"complete":n===0?"unavailable":"partial"}function Gs(e){return e.endsWith(`
239
- `)||(e=e.slice(0,Math.max(0,e.lastIndexOf(`
240
- `)+1))),e.split(`
241
- `).filter(t=>t.length>0)}import{createHash as qs}from"crypto";import{existsSync as Ut,readdirSync as Js}from"fs";import{dirname as Wt,join as He,relative as Hs,resolve as Gt,sep as xi}from"path";function vi(e,t){let n=t.includes("."),r={};for(let o of t)r[o]=[];let i=[];for(let o of e){let a=ki(o.path,t);a?r[a].push(o):n?r["."].push(o):i.push(o)}return{files:r,shared:i}}function Pi(e,t){let n=new Map;for(let i of e){let o=t[i]?.packageName;o&&n.set(o,i)}let r=new Map;for(let i of e)r.set(i,new Set);for(let i of e){let o=t[i],a=r.get(i);if(!o||o.parseFailed){for(let s of e)s!==i&&a.add(s);continue}for(let s of o.dependencyNames){let c=n.get(s);c&&c!==i&&a.add(c)}for(let s of[...o.pathsTargets,...o.referencesPaths]){let c=ki(s,e);c&&c!==i&&a.add(c)}}return zs(e,r)}function Ii(e,t,n){let r={};for(let i of e){let o=new Map;for(let a of t.files[i]??[])o.set(a.path,a);for(let a of n[i]??[])for(let s of t.files[a]??[])o.set(s.path,s);for(let a of t.shared)o.set(a.path,a);r[i]={files:[...o.values()].sort((a,s)=>a.path.localeCompare(s.path))}}return r}function qt(e){if(e===".")return"root";let t=qs("sha256").update(e).digest("hex").slice(0,8);return`${e.split("/").join("__")}-${t}`}function wi(e,t){let n=Gt(e),r={};for(let i of t)r[i]=Xs(n,i);return r}function ki(e,t){let n;for(let r of t)r!=="."&&(e===r||e.startsWith(`${r}/`))&&(!n||r.length>n.length)&&(n=r);return n}function zs(e,t){let n={};for(let r of e){let i=new Set,o=[...t.get(r)??[]];for(;o.length>0;){let a=o.pop();if(!(a===r||i.has(a))){i.add(a);for(let s of t.get(a)??[])s!==r&&!i.has(s)&&o.push(s)}}n[r]=[...i].sort((a,s)=>a.localeCompare(s))}return n}function Xs(e,t){let n=t==="."?e:He(e,t),r=Ys(n),i=Ks(n),o=i?Qs(i,e):{pathsTargets:[],referencesPaths:[],failed:!1};return{packageName:r.name,dependencyNames:r.dependencyNames,pathsTargets:o.pathsTargets,referencesPaths:o.referencesPaths,parseFailed:r.failed||o.failed}}function Ys(e){let t=He(e,"package.json");if(!Ut(t))return{name:void 0,dependencyNames:[],failed:!1};let n=Jt(t);if(!n.ok)return{name:void 0,dependencyNames:[],failed:!0};let r=typeof n.value.name=="string"?n.value.name:void 0,i=new Set;for(let o of["dependencies","devDependencies","peerDependencies"]){let a=n.value[o];if(a&&typeof a=="object"&&!Array.isArray(a))for(let s of Object.keys(a))i.add(s)}return{name:r,dependencyNames:[...i],failed:!1}}function Ks(e){let t=He(e,"tsconfig.json");if(Ut(t))return t;let n;try{n=Js(e).filter(r=>/^tsconfig.*\.json$/.test(r))}catch{return}return n.sort((r,i)=>r.localeCompare(i)),n.length>0?He(e,n[0]):void 0}function Qs(e,t){let n=Jt(e);if(!n.ok)return{pathsTargets:[],referencesPaths:[],failed:!0};let r=Zs(n.value,e,t),i=Ei(e,n.value,t,0);return{pathsTargets:i.pathsTargets,referencesPaths:r,failed:i.failed}}function Zs(e,t,n){let r=e.references;if(!Array.isArray(r))return[];let i=Wt(t),o=new Set;for(let a of r){if(!a||typeof a!="object")continue;let s=a.path;if(typeof s!="string"||s.trim()==="")continue;let c=Ti(s,i,n);c&&o.add(c)}return[...o]}function Ei(e,t,n,r){let i=ec(t);if(i)return{pathsTargets:tc(i,Wt(e),n),failed:!1};if(r>=5)return{pathsTargets:[],failed:!1};let o=nc(t.extends,e,n);if(!o)return{pathsTargets:[],failed:!1};let a=Jt(o);return a.ok?Ei(o,a.value,n,r+1):{pathsTargets:[],failed:!0}}function ec(e){let t=e.compilerOptions;if(!t||typeof t!="object"||Array.isArray(t))return;let n=t.paths;return n&&typeof n=="object"&&!Array.isArray(n)?n:void 0}function tc(e,t,n){let r=new Set;for(let i of Object.values(e))if(Array.isArray(i))for(let o of i){if(typeof o!="string")continue;let a=Ti(o,t,n);a&&r.add(a)}return[...r]}function nc(e,t,n){let r=Array.isArray(e)?e.at(-1):e;if(typeof r!="string"||r.trim()===""||!r.startsWith(".")&&!r.startsWith("/"))return;let i=Gt(Wt(t),r);if(i.endsWith(".json")||(i=`${i}.json`),!i.split(xi).includes("node_modules")&&gt(n,i)&&Ut(i))return i}function Ti(e,t,n){let r=e.replace(/\/?\*+$/,""),i=Gt(t,r===""?".":r);if(!gt(n,i))return;let a=Hs(n,i).split(xi).join("/");return a===""?".":a}function rc(e){let t="",n=0,r=!1,i=e.length;for(;n<i;){let o=e[n];if(r){if(t+=o,o==="\\"&&n+1<i){t+=e[n+1],n+=2;continue}o==='"'&&(r=!1),n+=1;continue}if(o==='"'){r=!0,t+=o,n+=1;continue}if(o==="/"&&e[n+1]==="/"){for(n+=2;n<i&&e[n]!==`
242
- `;)n+=1;continue}if(o==="/"&&e[n+1]==="*"){for(n+=2;n<i&&!(e[n]==="*"&&e[n+1]==="/");)n+=1;n+=2;continue}t+=o,n+=1}return t}function Jt(e){try{let t=_(e,{maxBytes:ie,inputKind:"TypeScript project manifest"}),n=JSON.parse(rc(t));return n&&typeof n=="object"&&!Array.isArray(n)?{ok:!0,value:n}:{ok:!1}}catch{return{ok:!1}}}import{createHash as Ec}from"crypto";import{existsSync as tn,writeFileSync as Gi}from"fs";import{join as Tc}from"path";import{createRequire as ic}from"module";import{dirname as Kt,isAbsolute as oc,relative as _i,resolve as q,sep as zt}from"path";var G=ic(import.meta.url),ac=1,Fi="0.4.0";function sc(){try{let e=Di();if(!e.available)return e;let{packageRoot:t}=e,n=G.resolve("typescript",{paths:[t]}),r=G(n),{FileIndexer:i}=G(q(t,"dist/src/FileIndexer.js")),{Input:o}=G(q(t,"dist/src/Input.js")),{Packages:a}=G(q(t,"dist/src/Packages.js")),s=G(q(t,"dist/src/scip.js"));if(!i||!o||!a||!s.scip?.Document||!s.scip.Index)return{available:!1,reason:"scip-typescript document runtime has an unsupported module shape"};let c={packageVersion:e.packageVersion,typescript:r,Document:s.scip.Document,Index:s.scip.Index,FileIndexer:i,Input:o,Packages:a};return{available:!0,runtime:c,producerIdentity:Zt(c)}}catch(e){return{available:!1,reason:`scip-typescript document runtime unavailable: ${e instanceof Error?e.message:String(e)}`}}}function Qt(){let e=Di();return e.available?{available:!0,packageVersion:e.packageVersion,typescriptVersion:e.typescriptVersion,producerIdentity:e.producerIdentity}:e}function Di(){try{let e=G.resolve("@sourcegraph/scip-typescript/package.json"),t=JSON.parse(D(e,"scip-typescript package manifest"));if(t.version!==Fi)return{available:!1,reason:`unsupported scip-typescript version ${String(t.version??"unknown")}; expected ${Fi}`};let n=Kt(e),r=G.resolve("typescript/package.json",{paths:[n]}),i=JSON.parse(D(r,"TypeScript package manifest"));return typeof i.version!="string"||!i.version?{available:!1,reason:"scip-typescript TypeScript compiler version is unavailable"}:{available:!0,packageRoot:n,packageVersion:t.version,typescriptVersion:i.version,producerIdentity:Oi(t.version,i.version)}}catch(e){return{available:!1,reason:`scip-typescript document producer unavailable: ${e instanceof Error?e.message:String(e)}`}}}function Li(e){let t=e.runtime===void 0?sc():e.runtime===null?{available:!1,reason:"scip-typescript document runtime unavailable"}:{available:!0,runtime:e.runtime,producerIdentity:Zt(e.runtime)};return t.available?{available:!0,emitter:new Xt(e,t.runtime)}:t}var Xt=class{producerIdentity;workspaceRoot;tsconfigPath;projectRoot;maxFileByteSize;runtime;host;config=null;includedFiles=new Set;program=null;checker=null;symbolTable=new Map;constructorTable=new Map;packages;fragments=new Map;stats={initializations:0,programUpdates:0,documentsEmitted:0,documentsRemoved:0,sourceNodesReused:0,sourceNodesReplaced:0,symbolEntriesPruned:0};constructor(t,n){this.workspaceRoot=q(t.workspaceRoot),this.tsconfigPath=q(this.workspaceRoot,t.tsconfigPath),this.projectRoot=t.projectRoot??uc(this.workspaceRoot,Kt(this.tsconfigPath)),this.maxFileByteSize=t.maxFileByteSize??1024*1024,this.runtime=n,this.producerIdentity=Zt(n);let r=Ht(n.typescript,this.tsconfigPath);this.config=r,this.host=new Yt(n.typescript,r.options,this.workspaceRoot),this.packages=new n.Packages(this.projectRoot)}initialize(){let t=performance.now();this.initializeProgram();let n=[];for(let r of this.program.getSourceFiles())this.includedFiles.has(ge(r.fileName))&&n.push(this.emitSourceFile(r));return this.result(n,t)}advance(t){if(!this.program||!this.checker||!this.config)return this.initializeAndAdvance(t);let n=performance.now(),r=ze(t.modifiedFiles),i=ze(t.affectedFiles),o=Ht(this.runtime.typescript,this.tsconfigPath);this.config=o,this.includedFiles=new Set(o.fileNames.map(ge));let a=this.program,s=new Map;for(let l of r){let u=pe(this.workspaceRoot,l),d=a.getSourceFile(u);d&&(s.set(l,d),this.stats.symbolEntriesPruned+=Ai(this.symbolTable,d),this.stats.symbolEntriesPruned+=Ai(this.constructorTable,d)),this.host.invalidate(u)}this.program=this.runtime.typescript.createProgram(o.fileNames,o.options,this.host.compilerHost,a),this.checker=this.program.getTypeChecker(),this.stats.programUpdates+=1,this.validateIncrementalPaths(r,i);for(let[l,u]of s)this.program.getSourceFile(pe(this.workspaceRoot,l))===u?this.stats.sourceNodesReused+=1:this.stats.sourceNodesReplaced+=1;let c=i.map(l=>{let u=pe(this.workspaceRoot,l),d=this.program.getSourceFile(u);if(!d)throw new Error(`affected TypeScript source is unavailable: ${l}`);return this.emitSourceFile(d)});return this.result(c,n)}fragment(t){return this.fragments.get(Xe(t))??null}snapshotStats(){return{...this.stats}}initializeAndAdvance(t){let n=performance.now();this.initializeProgram();let r=ze(t.modifiedFiles),i=ze(t.affectedFiles);this.validateIncrementalPaths(r,i);let o=i.map(a=>{let s=this.program.getSourceFile(pe(this.workspaceRoot,a));if(!s)throw new Error(`affected TypeScript source is unavailable: ${a}`);return this.emitSourceFile(s)});return this.result(o,n)}initializeProgram(){let t=this.config??Ht(this.runtime.typescript,this.tsconfigPath);this.includedFiles=new Set(t.fileNames.map(ge)),this.program=this.runtime.typescript.createProgram(t.fileNames,t.options,this.host.compilerHost),this.checker=this.program.getTypeChecker(),this.stats.initializations+=1}validateIncrementalPaths(t,n){if(t.length===0)throw new Error("incremental TypeScript document update requires a modified file");if(n.length===0)throw new Error("incremental TypeScript document update requires an affected file");for(let r of t){let i=pe(this.workspaceRoot,r);if(!this.program?.getSourceFile(i))throw new Error(`modified TypeScript dependency is unavailable to the configured project: ${r}`)}for(let r of n){let i=pe(this.workspaceRoot,r);if(!this.includedFiles.has(ge(i)))throw new Error(`affected TypeScript file is outside the configured project: ${r}`)}}emitSourceFile(t){if(!this.checker)throw new Error("TypeScript document emitter is not initialized");let n=Xe(_i(this.workspaceRoot,t.fileName)),r=new this.runtime.Document({relative_path:n,occurrences:[]});if(new this.runtime.FileIndexer(this.checker,{cwd:this.workspaceRoot,projectRoot:this.projectRoot,projectDisplayName:this.projectRoot,maxFileByteSizeNumber:this.maxFileByteSize},new this.runtime.Input(t.fileName,t.getText()),r,this.symbolTable,this.constructorTable,this.packages,t).index(),this.stats.documentsEmitted+=1,r.occurrences.length===0)return this.fragments.delete(n),this.stats.documentsRemoved+=1,{relativePath:n,bytes:null,occurrences:0,symbols:r.symbols.length,referenceFragments:[]};let o=r.serializeBinary();return this.fragments.set(n,o),{relativePath:n,bytes:o,occurrences:r.occurrences.length,symbols:r.symbols.length,referenceFragments:cc(n,r)}}result(t,n){return{producerIdentity:this.producerIdentity,fragments:t,durationMs:performance.now()-n,stats:this.snapshotStats()}}};function cc(e,t){let n=new Map;for(let r of t.occurrences){if(!r.symbol||(r.symbol_roles&1)!==0||r.range.length<3)continue;let i=r.range[0],o=r.range[1];if(!Number.isInteger(i)||!Number.isInteger(o))continue;let a={targetSymbol:r.symbol,location:{file:e,line:i,column:o}};n.set(`${r.symbol}\0${i}\0${o}`,a)}return[...n.values()].sort((r,i)=>r.targetSymbol.localeCompare(i.targetSymbol)||r.location.line-i.location.line||r.location.column-i.location.column)}var Yt=class{compilerHost;sourceFiles=new Map;constructor(t,n,r){let i=t.createCompilerHost(n),o=i.getSourceFile.bind(i);this.compilerHost={...i,getCurrentDirectory:()=>r,getSourceFile:(a,s,c,l)=>{let u=ge(a);if(this.sourceFiles.has(u))return this.sourceFiles.get(u);let d=o(a,s,c,l);return this.sourceFiles.set(u,d),d}}}invalidate(t){this.sourceFiles.delete(ge(t))}};function Ht(e,t){let n=e.readConfigFile(t,e.sys.readFile);if(n.error)throw new Error(e.formatDiagnostics([n.error],e.createCompilerHost({})));let r=e.parseJsonConfigFileContent(n.config,e.sys,Kt(t)),i=r.errors.filter(o=>o.code!==18003);if(i.length>0)throw new Error(e.formatDiagnostics(i,e.createCompilerHost({})));return r}function Zt(e){return Oi(e.packageVersion,e.typescript.version)}function Oi(e,t){return`scip-typescript:${e}:typescript:${t}:document-adapter:${ac}`}function uc(e,t){return Xe(_i(e,t))||"."}function pe(e,t){if(oc(t))throw new Error(`expected a project-relative path: ${t}`);let n=q(e,t),r=e.endsWith(zt)?e:`${e}${zt}`;if(n!==e&&!n.startsWith(r))throw new Error(`path escapes the project root: ${t}`);return n}function ze(e){return[...new Set(e.map(Xe))].sort()}function Xe(e){return e.split(zt).join("/").replace(/^\.\//,"")}function ge(e){return q(e)}function Ai(e,t){let n=0;for(let r of e.keys())if(lc(r)){try{if(r.getSourceFile()!==t)continue}catch{continue}e.delete(r),n+=1}return n}function lc(e){return!!(e&&typeof e=="object"&&"kind"in e&&"getSourceFile"in e)}import{createHash as dc}from"crypto";import{dirname as pc,join as ji}from"path";var fe=4;var gc="typescript-index";function Mi(e){let t=ji(e,gc),n=Yn(t);return{...n,requestDir:n.legacyRequestDir}}function Ci(e){try{let t=In(re(D(ji(pc(e),"meta.json"),"reindex metadata")));return t?dc("sha256").update(t).digest("hex"):null}catch{return null}}import{randomUUID as yc}from"crypto";import{existsSync as Sc}from"fs";import{randomUUID as fc}from"crypto";import{getHeapStatistics as mc}from"v8";import{resolve as hc}from"path";var Ye=class{projectRoot;currentGeneration;createEmitter;wallNow;monotonicNow;maxActiveSessions;softMemoryLimitBytes;memoryUsage;active=new Map;requests=0;sessionsCreated=0;sessionsReplaced=0;sessionsEvicted=0;lastRequestAtMs=null;lastDurationMs=null;lastError=null;unavailable=!1;constructor(t){if(this.projectRoot=hc(t.projectRoot),this.currentGeneration=t.currentGeneration,this.createEmitter=t.createEmitter??Li,this.wallNow=t.wallNow??t.now??Date.now,this.monotonicNow=t.monotonicNow??t.now??R,t.maxActiveSessions!==void 0&&(!Number.isInteger(t.maxActiveSessions)||t.maxActiveSessions<1))throw new Error("TypeScript index maxActiveSessions must be a positive integer.");if(this.maxActiveSessions=t.maxActiveSessions??8,t.softMemoryLimitMb!==void 0&&(!Number.isInteger(t.softMemoryLimitMb)||t.softMemoryLimitMb<1))throw new Error("TypeScript index softMemoryLimitMb must be a positive integer.");this.softMemoryLimitBytes=t.softMemoryLimitMb===void 0?null:t.softMemoryLimitMb*1024*1024,this.memoryUsage=t.memoryUsage??(()=>({heapUsedBytes:process.memoryUsage().heapUsed,heapLimitBytes:mc().heap_size_limit}))}handle(t,n){let r=this.monotonicNow();try{if(this.currentGeneration()!==t)throw new Error("TypeScript index request does not match the currently published generation.");let i=this.emitterFor(n);if(i.emitter.producerIdentity!==n.producerIdentity)throw new Error("TypeScript index producer identity changed.");let o=i.emitter.snapshotStats(),a=i.emitter.advance({modifiedFiles:n.modifiedFiles,affectedFiles:n.affectedFiles}),s=this.monotonicNow()-r;return this.requests+=1,this.lastRequestAtMs=this.wallNow(),this.lastDurationMs=s,this.lastError=null,this.unavailable=!1,{producerIdentity:a.producerIdentity,cold:a.stats.initializations>o.initializations,durationMs:s,fragments:a.fragments.map(c=>({relativePath:c.relativePath,bytesBase64:c.bytes===null?null:Buffer.from(c.bytes).toString("base64"),occurrences:c.occurrences,symbols:c.symbols,referenceFragments:c.referenceFragments}))}}catch(i){throw this.lastError=i instanceof Error?i.message:String(i),i}}status(t){let n=[...this.active.values()].map(a=>a.emitter.snapshotStats()),r=a=>n.reduce((s,c)=>s+c[a],0),i=this.memoryUsage(),o=this.softMemoryLimitBytes!==null&&i.heapUsedBytes>=this.softMemoryLimitBytes;return{protocolVersion:fe,state:this.unavailable?"unavailable":this.lastError?"error":this.active.size>0?"ready":"idle",requests:this.requests,sessionsCreated:this.sessionsCreated,sessionsReplaced:this.sessionsReplaced,sessionsEvicted:this.sessionsEvicted,activeSessions:this.active.size,maxActiveSessions:this.maxActiveSessions,heapUsedBytes:i.heapUsedBytes,heapLimitBytes:i.heapLimitBytes,...this.softMemoryLimitBytes===null?{}:{softMemoryLimitBytes:this.softMemoryLimitBytes},retireRequested:o,initializations:r("initializations"),programUpdates:r("programUpdates"),documentsEmitted:r("documentsEmitted"),documentsRemoved:r("documentsRemoved"),...this.lastRequestAtMs===null?{}:{lastRequestAt:new Date(this.lastRequestAtMs).toISOString()},...this.lastDurationMs===null?{}:{lastDurationMs:this.lastDurationMs},...this.lastError?{lastError:this.lastError}:{},...t?{mailbox:t}:{}}}close(){this.active.clear()}emitterFor(t){let n=`${t.tsconfigPath}\0${t.projectArgument}`,r=this.active.get(n);if(r?.projectIdentity===t.projectIdentity)return this.active.delete(n),this.active.set(n,r),r;if(r)this.active.delete(n);else if(this.active.size>=this.maxActiveSessions){let a=this.active.keys().next().value;a!==void 0&&(this.active.delete(a),this.sessionsEvicted+=1)}let i=this.createEmitter({workspaceRoot:this.projectRoot,tsconfigPath:t.tsconfigPath,projectRoot:t.projectArgument});if(!i.available)throw this.unavailable=!0,new Error(i.reason);r&&(this.sessionsReplaced+=1);let o={projectIdentity:t.projectIdentity,emitter:i.emitter};return this.active.set(n,o),this.sessionsCreated+=1,o}};var Xp=`typescript-index-${process.pid}-${fc()}`,Ni=B(process.pid),Yp={pid:process.pid,...Ni?{processIdentity:Ni}:{}};var bc=12e4,Rc=5,Ie=class extends Error{name="TypeScriptIndexMemoryPressureError"},Ke=class{projectRoot;cacheDir;baseGeneration;timeoutMs;runtime;mailboxLimits;emitLocally;localHost=null;constructor(t,n={}){this.projectRoot=An(t.projectRoot),this.cacheDir=t.cacheDir,this.baseGeneration=t.baseGeneration,this.timeoutMs=n.timeoutMs??wc(),this.runtime=n.runtime??kc,this.mailboxLimits=n.mailboxLimits??{},this.emitLocally=n.emitLocally}request(t){let n=Zn(this.cacheDir),r=Mi(this.cacheDir),i=xt(n.statePath);if(!$i(i,this.projectRoot,this.runtime))return this.requestLocally(t);let o=this.runtime.now(),a=o+this.timeoutMs,s=(this.runtime.monotonicNow??R)()+this.timeoutMs,c=bt("typescript-index-v4",{baseGeneration:this.baseGeneration,request:t}),l=Rt(c),u=Kn(r,{mailboxVersion:St,operationKey:c,clientId:this.runtime.randomId(),enqueuedAtMs:o,deadlineAtMs:a,protocolVersion:fe,id:l,baseGeneration:this.baseGeneration,request:t},{nowMs:o,limits:this.mailboxLimits});for(;(this.runtime.monotonicNow??R)()<=s;){if(Sc(u.responsePath))return xc(_(u.responsePath,{maxBytes:this.mailboxLimits.maxItemBytes??64*1024*1024,inputKind:"TypeScript index mailbox response"}),l,c,this.baseGeneration,t.producerIdentity,t.affectedFiles);let d=xt(n.statePath);if(!$i(d,this.projectRoot,this.runtime))return this.requestLocally(t);this.runtime.sleep(Rc)}return this.requestLocally(t)}requestLocally(t){return this.emitLocally?en(this.emitLocally(t),t.producerIdentity,t.affectedFiles):(this.localHost??=new Ye({projectRoot:this.projectRoot,currentGeneration:()=>this.baseGeneration}),en(Bi(this.localHost.handle(this.baseGeneration,t),t.producerIdentity),t.producerIdentity,t.affectedFiles))}};function $i(e,t,n){let r=e?.processIdentity?n.readProcessIdentity?.(e.pid):null,i=e?Date.parse(e.heartbeatAt):Number.NaN;return e!==null&&e.projectRoot===t&&e.typescriptIndex?.protocolVersion===fe&&n.isProcessAlive(e.pid)&&Number.isFinite(i)&&n.now()-i<=Qn&&(!e.processIdentity||r!=null&&xe(e.processIdentity,r))}function xc(e,t,n,r,i,o){let a=JSON.parse(e);if(a.protocolVersion!==fe||a.id!==t||a.operationKey!==n||a.ok===!0&&a.baseGeneration!==r)throw new Error("TypeScript index service wrote an incompatible response.");if(a.ok!==!0){let s=typeof a.error=="string"?a.error:"TypeScript index service request failed.";throw vc(s)?new Ie(s):new Error(s)}return en(Bi(a.response,i),i,o)}function vc(e){let t=e.toLowerCase();return t.includes("out of memory")||t.includes("memory limit")||t.includes("allocation failed")||t.includes("err_worker_out_of_memory")}function en(e,t,n){if(e.producerIdentity!==t)throw new Error("TypeScript index service wrote an invalid response.");let r=[...new Set(n)].sort(),i=e.fragments.map(o=>o.relativePath).sort();if(JSON.stringify(i)!==JSON.stringify(r))throw new Error("TypeScript index service omitted or added an affected document.");return e}function Bi(e,t){if(!e||typeof e!="object")throw new Error("TypeScript index service wrote an invalid response.");let n=e;if(n.producerIdentity!==t||typeof n.cold!="boolean"||typeof n.durationMs!="number"||!Number.isFinite(n.durationMs)||!Array.isArray(n.fragments))throw new Error("TypeScript index service wrote an invalid response.");let r=new Set,i=n.fragments.map(o=>{if(!o||typeof o.relativePath!="string"||o.bytesBase64!==null&&typeof o.bytesBase64!="string"||typeof o.occurrences!="number"||!Number.isInteger(o.occurrences)||o.occurrences<0||typeof o.symbols!="number"||!Number.isInteger(o.symbols)||o.symbols<0||!Array.isArray(o.referenceFragments)||!o.referenceFragments.every(Pc)||r.has(o.relativePath))throw new Error("TypeScript index service wrote an invalid fragment.");r.add(o.relativePath);let a=o.bytesBase64===null?null:Ic(o.bytesBase64);return{relativePath:o.relativePath,bytes:a,occurrences:o.occurrences,symbols:o.symbols,referenceFragments:o.referenceFragments}});return{producerIdentity:n.producerIdentity,cold:n.cold,durationMs:n.durationMs,fragments:i}}function Pc(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.targetSymbol=="string"&&!!t.location&&typeof t.location.file=="string"&&Number.isInteger(t.location.line)&&Number.isInteger(t.location.column)}function Ic(e){let t=Buffer.from(e,"base64");if(t.toString("base64")!==e)throw new Error("TypeScript index service wrote invalid base64.");return t}function wc(){let e=Number(process.env.SCIP_TYPESCRIPT_INDEX_TIMEOUT_MS);return Number.isInteger(e)&&e>0?e:bc}var kc={now:Date.now,monotonicNow:R,randomId:yc,sleep(e){let t=new Int32Array(new SharedArrayBuffer(4));Atomics.wait(t,0,0,e)},isProcessAlive:ue,readProcessIdentity:B};function Fc(e){let t=e.projectMode==="workspace"?e.workspaceProjects??[]:["."];if(t.length===0)return{eligible:!1,reason:"workspace project roots unavailable"};if(t.length===1&&t[0]==="."&&!e.rootTsconfigExists)return{eligible:!1,reason:"root tsconfig unavailable"};if(!e.previousSnapshot)return{eligible:!1,reason:"prior project snapshot unavailable"};if(e.graph===null)return{eligible:!1,reason:"dependency graph unavailable"};if(e.projectFiles.length===0)return{eligible:!1,reason:"prior TypeScript documents unavailable"};let n=Te(e.previousSnapshot,e.currentSnapshot);if(n.changes.length===0)return{eligible:!1,reason:"no changed project inputs"};let r=n.changes.filter(m=>m.inputKind==="source"&&vt(m.path));if(r.some(m=>m.kind!=="modified"&&m.kind!=="added"))return{eligible:!1,reason:"TypeScript project membership changed"};if(r.length===0)return{eligible:!1,reason:"change is not a modified TypeScript source file"};let i=r.filter(m=>m.kind==="added").map(m=>m.path),o=r.filter(m=>m.kind==="modified"),a={...n,changes:r},s=Ac(o,i,e.graph,e.projectFiles);if(!s.eligible)return s;let c=s.plan,l=_c(c,t,e.graph);if(!l)return{eligible:!1,reason:"affected files cross or ambiguously match TypeScript projects"};let u=Vi(e.currentSnapshot,e.projectFiles,e.producerIdentity),d=Vi(e.previousSnapshot,e.projectFiles,e.producerIdentity);if(u!==d)return{eligible:!1,reason:"TypeScript fragment project identity changed"};let p=Wi(e.previousSnapshot,e.projectFiles,e.graph,e.producerIdentity,e.projectFiles);if(!p)return{eligible:!1,reason:"prior document identity unavailable"};let f=Wi(e.currentSnapshot,[...new Set([...e.projectFiles,...i])],e.graph,e.producerIdentity,c.affectedFiles);if(!f)return{eligible:!1,reason:"next document identity unavailable"};let g=l.length===1?l[0]:void 0;return{eligible:!0,manifest:a,plan:c,projectIdentity:u,previousFragmentGeneration:Ui(e.previousSnapshot,e.producerIdentity),nextFragmentGeneration:Ui(e.currentSnapshot,e.producerIdentity),previousDocumentIdentities:p,nextDocumentIdentities:f,projects:l,...g?{tsconfigPath:g.tsconfigPath,projectArgument:g.projectArgument}:{}}}function Ac(e,t,n,r){if(e.length===0)return t.length===0?{eligible:!1,reason:"empty affected set"}:{eligible:!0,plan:{mode:"closure",changedFiles:[...t].sort(),affectedFiles:[...t].sort(),reasons:[]}};let i=Be({version:1,changes:[...e],projectIdentityChanged:!1,uncertainty:[]},n,r);return i.mode!=="closure"||i.affectedFiles.length===0?{eligible:!1,reason:i.reasons.length>0?`affected set widened: ${i.reasons.join(", ")}`:"empty affected set"}:{eligible:!0,plan:{mode:"closure",changedFiles:[...new Set([...i.changedFiles,...t])].sort(),affectedFiles:[...new Set([...i.affectedFiles,...t])].sort(),reasons:[]}}}function _c(e,t,n){let r=new Map;for(let o of e.affectedFiles){let a=Dc(o,t);if(!a)return null;let s=r.get(a)??[];s.push(o),r.set(a,s)}let i=[];for(let[o,a]of[...r].sort(([s],[c])=>s.localeCompare(c))){let s=new Set(a),c=e.changedFiles.filter(l=>s.has(l)||a.some(u=>Lc(u,l,n)));if(c.length===0)return null;i.push({projectArgument:o,tsconfigPath:o==="."?"tsconfig.json":`${o}/tsconfig.json`,modifiedFiles:c,affectedFiles:[...a].sort()})}return i}function Dc(e,t){let n=t.filter(o=>o==="."||e===o||e.startsWith(`${o}/`));if(n.length===0)return null;let r=[...new Set(n)].sort((o,a)=>Qe(a)-Qe(o)||o.localeCompare(a)),i=r[0];return r[1]&&Qe(r[1])===Qe(i)?null:i}function Qe(e){return e==="."?0:e.split("/").filter(Boolean).length}function Lc(e,t,n){let r=new Set,i=[e];for(let o=0;o<i.length;o+=1){let a=i[o];if(!(!a||r.has(a))){r.add(a);for(let s of n.get(a)??[]){if(s===t)return!0;r.has(s)||i.push(s)}}}return!1}function qi(e){let t=R();try{if(!tn(e.previousDbPath)||!tn(e.previousShardPath))throw new Error("prior TypeScript graph or language shard unavailable");let n=performance.now(),r=Qt();if(!r.available)throw new Error(r.reason);let i=performance.now()-n;n=performance.now();let o=new j({projectRoot:e.projectRoot,dbPath:e.previousDbPath,indexPath:e.previousIndexPath}),a,s,c;try{a=Fe(o,{includeIgnored:!1}).filter(vt).sort(),c=Nn(o),s=c.graph}finally{o.close()}let l=performance.now()-n,u=Fc({projectMode:e.projectMode,workspaceProjects:e.projectMode==="workspace"?ae(e.projectRoot,e.currentSnapshot.typescriptProjects):void 0,previousSnapshot:e.previousSnapshot,currentSnapshot:e.currentSnapshot,projectFiles:a,graph:s,producerIdentity:r.producerIdentity,rootTsconfigExists:tn(Tc(e.projectRoot,"tsconfig.json"))});if(!u.eligible)throw new Error(u.reason);let d=Ci(e.previousDbPath);if(!d)throw new Error("published TypeScript base generation unavailable");n=performance.now();let p=new Ke({projectRoot:e.projectRoot,cacheDir:e.cacheDir,baseGeneration:d}),f=u.projects.map(h=>p.request({kind:"emit-documents",tsconfigPath:h.tsconfigPath,projectArgument:h.projectArgument,projectIdentity:u.projectIdentity,producerIdentity:r.producerIdentity,modifiedFiles:h.modifiedFiles,affectedFiles:h.affectedFiles})),g=f.flatMap(h=>h.fragments),m=performance.now()-n;n=performance.now();let w=lr(g),v=performance.now()-n;n=performance.now(),pr({cacheDir:e.cacheDir,previousGenerationIdentity:u.previousFragmentGeneration,nextGenerationIdentity:u.nextFragmentGeneration,producerIdentity:r.producerIdentity,projectIdentity:u.projectIdentity,baseShardCurrent:e.baseShardCurrent,fragments:g});let P=performance.now()-n;n=performance.now(),Gi(e.candidateAffectedScipPath,w);let S=performance.now()-n,x={scipPath:e.previousShardPath,candidateScipPath:e.candidateShardPath,affectedScipPath:e.candidateAffectedScipPath,completeScipUpdated:!1,durationMs:R()-t,cold:f.some(h=>h.cold),changedFiles:u.plan.changedFiles,affectedFiles:u.plan.affectedFiles,producerIdentity:r.producerIdentity,previousFragmentGeneration:u.previousFragmentGeneration,nextFragmentGeneration:u.nextFragmentGeneration,manifest:u.manifest,plan:u.plan,projectFileCount:a.length,dependencyGraphSnapshot:c,referenceFragmentsByFile:new Map(g.map(h=>[h.relativePath,h.referenceFragments])),timings:{runtimeMs:i,graphMs:l,requestMs:m,serviceMs:f.reduce((h,I)=>h+I.durationMs,0),assemblyMs:v,fragmentStoreMs:P,writeMs:S}};return e.onStatus(`Incremental TypeScript index emitted ${x.affectedFiles.length} affected document(s) across ${u.projects.length} project(s) in ${(x.durationMs/1e3).toFixed(3)}s (${x.cold?"cold":"warm"} service; whole SCIP deferred; runtime ${i.toFixed(0)}ms, graph ${l.toFixed(0)}ms, request ${m.toFixed(0)}ms, assembly ${v.toFixed(0)}ms, fragments ${P.toFixed(0)}ms, write ${S.toFixed(0)}ms).`),x}catch(n){let r=n instanceof Error?n.message:String(n);if(e.onUnavailable?.(r),n instanceof Ie)throw e.onStatus(`Incremental TypeScript index stopped after memory pressure survived one cold Worker retry: ${r}. Preserving the accepted index instead of starting a memory-heavier whole-project rebuild.`),n;return e.onStatus(`Incremental TypeScript index unavailable: ${r}. Falling back to the whole-project indexer.`),null}}function nn(e){let t=Qt();if(!t.available)throw new Error(t.reason);let n=gr({cacheDir:e.cacheDir,generationIdentity:e.generationIdentity,baseIndexBytes:oe(e.baseShardPath,{inputKind:"TypeScript base SCIP shard",maxBytes:kn}),packageVersion:t.packageVersion});Gi(e.candidateShardPath,n)}function Vi(e,t,n){let r=e.files.filter(i=>{let o=Rn(i.path,e.languages);return o==="config"||o==="ambient"}).map(i=>({path:i.path,size:i.size,hash:i.hash})).sort((i,o)=>i.path.localeCompare(o.path));return rn(JSON.stringify({version:1,producerIdentity:n,pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:[...e.typescriptProjects].sort(),projectFiles:[...t].sort(),nonSourceInputs:r}))}function Ui(e,t){return rn(JSON.stringify({version:1,producerIdentity:t,snapshot:e}))}function Wi(e,t,n,r,i){let o=new Set(e.files.map(c=>c.path)),a=rr({projectFiles:t.filter(c=>o.has(c)),snapshot:e,graph:n,engineIdentity:r}),s=new Map;for(let c of i){let l=a.identityFor(c,"typescript-scip-document-v1");if(l.key){s.set(c,l.key);continue}if(o.has(c))return null;s.set(c,rn(JSON.stringify({version:1,producerIdentity:r,generatedDocument:c})))}return s}function rn(e){return Ec("sha256").update(e).digest("hex")}import{closeSync as Oc,existsSync as Ze,fstatSync as jc,lstatSync as Mc,openSync as Cc,renameSync as sn,rmSync as et,statSync as Nc,writeSync as $c}from"fs";import{cpus as Bc}from"os";import{join as cn}from"path";var on=Symbol("no-error");async function Ji(e,t,n){if(e.length===0)return[];let r=new Array(e.length),i=Number.isFinite(t)?Math.max(1,Math.floor(t)):1,o=Math.min(e.length,i),a=0,s=on,c=!0,l=Array.from({length:o},async()=>{for(;c&&a<e.length;){let u=a++;try{r[u]=await n(e[u])}catch(d){s===on&&(s=d),c=!1}}});if(await Promise.all(l),s!==on)throw s;return r}function Vc(e,t){if(e.temporaryRootConfigContent===void 0)return null;let n=cn(t,"tsconfig.json"),r=Buffer.from(e.temporaryRootConfigContent,"utf8"),i;try{i=Cc(n,"wx",384)}catch(o){if(o.code==="EEXIST")return null;throw o}try{$c(i,r);let o=jc(i);return{path:n,content:r,device:o.dev,inode:o.ino}}finally{Oc(i)}}function Uc(e){if(e)try{let t=Mc(e.path);if(!t.isFile()||t.dev!==e.device||t.ino!==e.inode||t.size!==e.content.byteLength)return;let n;try{n=oe(e.path,{maxBytes:e.content.byteLength,inputKind:"temporary TypeScript index configuration"})}catch{return}if(!n.equals(e.content))return;et(e.path)}catch(t){if(t.code!=="ENOENT")throw t}}function Wc(e,t,n){if(!e.defaultOutputPath)return;let r=cn(t,e.defaultOutputPath);n!==r&&Ze(r)&&sn(r,n)}function Gc(e,t,n){if(!e.defaultOutputPath)return null;let r=cn(t,e.defaultOutputPath);if(r===n)return null;let i=`${n}.default-output-backup`;return et(i,{force:!0}),Ze(r)?(sn(r,i),{defaultOutputPath:r,backupPath:i}):{defaultOutputPath:r,backupPath:null}}function qc(e){e&&(et(e.defaultOutputPath,{force:!0}),e.backupPath&&Ze(e.backupPath)&&sn(e.backupPath,e.defaultOutputPath))}function Jc(e,t){if(e<=1)return 1;let n=Number(process.env.SCIP_QUERY_INDEXER_CONCURRENCY??0),r=Number.isFinite(t)&&t&&t>0?t:Number.isFinite(n)&&n>0?n:Math.min(8,Math.max(1,Bc().length));return Math.max(1,Math.min(e,Math.floor(r)))}async function zi(e,t,n,r,i){A(i,"Reindex cancelled by its owner.");let o=e.filter(u=>u.config.defaultOutputPath),a=e.filter(u=>!u.config.defaultOutputPath),s=[],c=Jc(a.length,r),l=await Ji(a,c,u=>an(u,t,n,i));if(c>1){let u=new Map;for(let d of l.filter(p=>p.result.skipped&&p.retryable)){let p=a.find(f=>f.id===d.result.id);p&&(n(`Retrying ${p.label} indexer serially after parallel failure...`),A(i,"Reindex cancelled by its owner."),u.set(p.id,(await an(p,t,n,i)).result))}s.push(...l.map(({result:d})=>u.get(d.id)??d))}else s.push(...l.map(({result:u})=>u));for(let u of o)A(i,"Reindex cancelled by its owner."),s.push((await an(u,t,n,i)).result);return s.sort((u,d)=>e.findIndex(p=>p.id===u.id)-e.findIndex(p=>p.id===d.id))}async function an(e,t,n,r){A(r,"Reindex cancelled by its owner."),n(`Indexing ${e.label} with ${e.resolvedBinary}...`),et(e.scipPath,{force:!0});let i=Gc(e.config,t,e.scipPath),o=Vc(e,t),a=[e.binary,...e.args].join(" "),s=R();try{e.trustedProjectTool&&qn(t,e.trustedProjectTool);let l=Bn(e.binary,e.args),u=await Ce({command:l.binary,args:l.args,label:`${e.label} indexer`,cwd:t,env:e.env,timeoutMs:Hc(),maxStdoutBytes:50*1024*1024,maxStderrBytes:50*1024*1024,signal:r});if(u.status!==0){let d=u.stderr.trim();throw new Error(`${e.resolvedBinary} exited with status ${u.status}${d?`:
243
- ${d}`:""}`)}Wc(e.config,t,e.scipPath)}catch(l){if(r?.aborted)throw er(r,"Reindex cancelled by its owner.");let u=l instanceof Error?l.message:String(l),d=`${e.resolvedBinary} indexer failed: ${u.split(`
244
- `)[0]}`,p=e.label===e.language?d:`${e.label}: ${d}`;return n(`Skipping ${e.label}: ${d}`),{result:{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,durationMs:R()-s,command:a,skipped:{language:e.language,reason:p}},retryable:zc(l)}}finally{qc(i),Uc(o)}if(!Ze(e.scipPath)){let l=`${e.resolvedBinary} indexer completed but did not produce ${e.scipPath}`,u=e.label===e.language?l:`${e.label}: ${l}`;return n(`Skipping ${e.label}: ${l}`),{result:{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,durationMs:R()-s,command:a,skipped:{language:e.language,reason:u}},retryable:!1}}let c;try{c=Nc(e.scipPath).size}catch{c=void 0}return{result:{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,durationMs:R()-s,command:a,outputBytes:c},retryable:!1}}function Hc(){let e=Number(process.env.SCIP_QUERY_INDEXER_TIMEOUT_MS);return Number.isFinite(e)&&e>0?Math.floor(e):kr.indexer}function zc(e){return e instanceof Er?e.kind==="spawn"&&Hi(e.cause):Hi(e)}function Hi(e){let t=e?.code;return t==="EAGAIN"||t==="ENOMEM"||t==="EMFILE"||t==="ENFILE"||t==="ETXTBSY"}import{execFileSync as Yi}from"child_process";import{homedir as Xi,platform as Xc}from"os";import{delimiter as Yc,join as tt}from"path";function Ki(e,t){let n=e.installMethods,r=De(e);if(!n?.length)return t(`No auto-install method available for ${r}.`),e.installUrl&&t(`Install manually from: ${e.installUrl}`),!1;for(let i of n){if(!i.identity||!i.destination){t(`Refusing ${i.label} installation for ${r}: the installer descriptor lacks an immutable identity or destination.`);continue}if(!se(i.prerequisite))continue;let o=Kc(i);t(`Installing immutable ${i.identity} via ${i.label} into ${o}; expected executable: ${r}.`);try{Yi(i.binary,i.args,{stdio:"inherit",timeout:3e5,env:process.env,shell:Xc()==="win32"});let a=Re(e);if(a){let s=a===e.indexerBinary?"":` (using ${a})`;return t(`Successfully installed ${i.identity} via ${i.label}${s}; resolved executable: ${a}.`),!0}t(`${i.label} command completed but ${r} was not found on PATH`)}catch(a){let s=a instanceof Error?a.message:String(a);t(`${i.label} install failed: ${s}`)}}return t(`Could not auto-install ${r}.`),e.installUrl&&t(`Install manually from: ${e.installUrl}`),!1}function Kc(e){if(e.binary==="npm")return un("npm",["root","-g"])??e.destination;if(e.binary==="go"){let t=un("go",["env","GOBIN"]);if(t)return t;let n=un("go",["env","GOPATH"]);if(n)return tt(n.split(Yc)[0],"bin")}return e.binary==="dotnet"?tt(process.env.DOTNET_CLI_HOME??Xi(),".dotnet","tools"):e.binary==="dart"?tt(process.env.PUB_CACHE??tt(Xi(),".pub-cache"),"bin"):e.destination}function un(e,t){try{return Yi(e,t,{stdio:["ignore","pipe","ignore"],encoding:"utf8",timeout:1e4,killSignal:"SIGKILL",env:process.env}).trim()||null}catch{return null}}import Gu from"better-sqlite3";import{existsSync as qu}from"fs";import{dirname as Ju,join as Hu,resolve as zu}from"path";import{randomUUID as Zc}from"crypto";import{mkdtempSync as eu,rmSync as tu,statSync as Zi}from"fs";import{tmpdir as nu}from"os";import{join as eo}from"path";import{Worker as ru}from"worker_threads";function Qc(){return{"missing-source-file":0,"missing-service-script":0,"no-definition":0,"same-file-definition":0,"unindexed-definition":0}}function me(){return{skippedReferences:0,skippedReferenceReasons:Qc(),skippedReferenceSamples:[]}}function nt(e,t){e.skippedReferences+=t.skippedReferences;for(let n of Object.keys(e.skippedReferenceReasons)){e.skippedReferenceReasons[n]+=t.skippedReferenceReasons[n];for(let r of t.skippedReferenceSamples.filter(i=>i.reason===n))e.skippedReferenceSamples.filter(o=>o.reason===n&&o.sourceFile===r.sourceFile).length<2&&e.skippedReferenceSamples.push(r)}}var iu=3e5,to=64*1024*1024,ou={createResultDirectory:()=>eu(eo(nu(),"scip-query-vue-workers-")),spawn:(e,t)=>new ru(e,{workerData:t}),resultSize:e=>Zi(e).size,readResult:e=>_(e,{maxBytes:to,inputKind:"Vue worker result"}),removeResultDirectory:e=>tu(e,{recursive:!0,force:!0})};function no(e){return e.length>=8&&io(e.length)>1}async function ro(e,t=ou){let n=io(e.vueFiles.length),r=Su(e.vueFiles),i=Ru(r,n),o=new URL("./augment-vue-worker.js",import.meta.url),a=e.timeoutMs??hu(),s=e.maxResultBytes??yu();Qi("timeoutMs",a),Qi("maxResultBytes",s);let c=Zc(),l=t.createResultDirectory(),u=[],d,p,f;try{for(let m=0;m<i.length;m++){let w=m,v=i[m]??[],P=v.map(h=>h.taskId),S=eo(l,`${w}.json`),x=t.spawn(o,{projectRoot:e.projectRoot,dbPath:e.dbPath,tsconfig:e.tsconfig,tasks:v,resultPath:S,runId:c,workerId:w,taskIds:P});u.push({workerId:w,taskIds:P,resultPath:S,handle:x,completion:au(x,w)})}await su(u,a);let g=u.sort((m,w)=>m.workerId-w.workerId).map(m=>uu(m,c,s,t));f={occurrences:g.flatMap(m=>m.occurrences),...me()};for(let m of g)nt(f,m)}catch(g){d=g}finally{let g=await cu(u);if(g.length===0)try{t.removeResultDirectory(l)}catch(m){g.push(m)}if(g.length>0){let m=d===void 0?g:[d,...g];p=new AggregateError(m,`Vue worker cleanup failed: ${mu(m[0])}`)}}if(p)throw p;if(d!==void 0)throw d;if(!f)throw new Error("Vue workers completed without producing a merged result.");return f}function au(e,t){return new Promise((n,r)=>{let i=!1,o=c=>{i||(i=!0,e.off("error",a),e.off("exit",s),c?r(c):n())},a=c=>{o(new Error(`Vue reference worker ${t} failed: ${c.message}`,{cause:c}))},s=c=>{o(c===0?void 0:new Error(`Vue reference worker ${t} exited with code ${c}`))};e.once("error",a),e.once("exit",s)})}async function su(e,t){let n;try{await Promise.race([Promise.all(e.map(r=>r.completion)),new Promise((r,i)=>{n=setTimeout(()=>i(new Error(`Vue reference workers timed out after ${(t/1e3).toFixed(3)}s`)),t),n.unref()})])}finally{n&&clearTimeout(n)}}async function cu(e){return(await Promise.allSettled(e.map(async n=>n.handle.terminate()))).flatMap(n=>n.status==="rejected"?[n.reason]:[])}function uu(e,t,n,r){let i=r.resultSize(e.resultPath);if(!Number.isSafeInteger(i)||i<0||i>n)throw new Error(`Vue reference worker ${e.workerId} result is ${i} bytes; limit is ${n} bytes`);let o;try{o=JSON.parse(r.readResult(e.resultPath))}catch(a){throw new Error(`Vue reference worker ${e.workerId} produced invalid JSON`,{cause:a})}if(!we(o)||o.version!==1||o.runId!==t||o.workerId!==e.workerId)throw new Error(`Vue reference worker ${e.workerId} result identity does not match its assignment`);if(!fu(o.taskIds,e.taskIds))throw new Error(`Vue reference worker ${e.workerId} result task identities do not match its assignment`);if(o.ok===!1)throw typeof o.error!="string"?new Error(`Vue reference worker ${e.workerId} failure payload is malformed`):new Error(`Vue reference worker ${e.workerId} failed: ${o.error}`);if(o.ok!==!0||!lu(o.result))throw new Error(`Vue reference worker ${e.workerId} success payload is malformed`);return o.result}function lu(e){if(!we(e)||!Array.isArray(e.occurrences)||!e.occurrences.every(du)||!C(e.skippedReferences)||!we(e.skippedReferenceReasons))return!1;for(let t of["missing-source-file","missing-service-script","no-definition","same-file-definition","unindexed-definition"])if(!C(e.skippedReferenceReasons[t]))return!1;return Array.isArray(e.skippedReferenceSamples)&&e.skippedReferenceSamples.every(pu)}function du(e){return we(e)&&typeof e.sourceFile=="string"&&C(e.sourceLine)&&C(e.sourceStartChar)&&C(e.sourceEndChar)&&typeof e.sourceToken=="string"&&typeof e.definitionFile=="string"&&C(e.symbolId)}function pu(e){return we(e)&&typeof e.sourceFile=="string"&&C(e.sourceLine)&&C(e.sourceStartChar)&&C(e.sourceEndChar)&&typeof e.token=="string"&&gu(e.reason)}function gu(e){return e==="missing-source-file"||e==="missing-service-script"||e==="no-definition"||e==="same-file-definition"||e==="unindexed-definition"}function C(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>=0}function we(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function fu(e,t){return Array.isArray(e)&&e.length===t.length&&e.every((n,r)=>typeof n=="string"&&n===t[r])}function Qi(e,t){if(!Number.isSafeInteger(t)||t<=0)throw new TypeError(`${e} must be a positive safe integer.`)}function mu(e){return e instanceof Error?e.message:String(e)}function io(e){let t=Number(process.env.SCIP_QUERY_AUGMENT_VUE_WORKERS??0),n=Number.isFinite(t)&&t>0?t:1;return Math.max(1,Math.min(e,n))}function hu(){let e=Number(process.env.SCIP_QUERY_AUGMENT_VUE_WORKER_TIMEOUT_MS??0);return Number.isFinite(e)&&e>0?e:iu}function yu(){let e=Number(process.env.SCIP_QUERY_AUGMENT_VUE_WORKER_RESULT_MAX_BYTES??0);return Number.isSafeInteger(e)&&e>0?e:to}function Su(e){let t=bu(),n=[];for(let r of e){let i=oo(r),o=Math.max(1,Math.ceil(i/t));for(let a=0;a<o;a++)n.push({taskId:`${n.length}:${r}:${a}`,fileName:r,startOffset:Math.floor(i*a/o),endOffset:a===o-1?Number.POSITIVE_INFINITY:Math.floor(i*(a+1)/o),countFileSkip:a===0})}return n}function bu(){return Number.POSITIVE_INFINITY}function Ru(e,t){let n=Array.from({length:t},()=>({tasks:[],weight:0})),r=e.map(i=>({task:i,weight:xu(i)})).sort((i,o)=>o.weight-i.weight);for(let i of r){let o=n.reduce((a,s)=>s.weight<a.weight?s:a);o.tasks.push(i.task),o.weight+=i.weight}return n.map(i=>i.tasks).filter(i=>i.length>0)}function xu(e){return Number.isFinite(e.endOffset)?Math.max(1,e.endOffset-e.startOffset):Math.max(1,oo(e.fileName)-e.startOffset)}function oo(e){try{return Zi(e).size}catch{return 1}}import{createRequire as vu}from"module";import{existsSync as Pu}from"fs";import{dirname as ao,extname as Iu,join as so,relative as wu,resolve as ku}from"path";import{pathToFileURL as Eu}from"url";function Tu(e){e.transaction(()=>{e.prepare(`
245
- DELETE FROM mentions
246
- WHERE chunk_id IN (
247
- SELECT c.id
248
- FROM chunks c
249
- JOIN documents d ON d.id = c.document_id
250
- WHERE d.language = 'vue' OR d.relative_path LIKE '%.vue'
251
- )
252
- `).run(),e.prepare(`
253
- DELETE FROM chunks
254
- WHERE document_id IN (
255
- SELECT id
256
- FROM documents
257
- WHERE language = 'vue' OR relative_path LIKE '%.vue'
258
- )
259
- `).run()})()}function co(e,t){return e.prepare(`
260
- SELECT relative_path AS relativePath
261
- FROM documents
262
- WHERE language = 'vue' OR relative_path LIKE '%.vue'
263
- ORDER BY relative_path
264
- `).all().map(r=>ku(t,r.relativePath))}function uo(e,t){let{vueCore:n,ts:r,volarTs:i}=Fu(e),{parsed:o,vueOptions:a}=Au(n,r,t),s=ao(t),c=n.createVueLanguagePlugin(r,o.options,a,f=>f),l=_u(n,r,c),u=Du(s,o),{languageServiceHost:d}=i.createLanguageServiceHost(r,r.sys,l,f=>f,u),p=r.createLanguageService(d);return{ts:r,language:l,languageService:p,fileNames:o.fileNames,configDir:s}}function Fu(e){let t=vu(Eu(so(e,"package.json")).href);return{vueCore:ln(t,"@vue/language-core",e),ts:ln(t,"typescript",e),volarTs:ln(t,"@volar/typescript",e)}}function Au(e,t,n){let r=t.readConfigFile(n,t.sys.readFile);if(r.error||!r.config)throw new Error(`Failed to read ${n}`);let o=e.createParsedCommandLine(t,t.sys,n).vueOptions;return typeof e.createGlobalTypesWriter=="function"&&(o.globalTypesPath=e.createGlobalTypesWriter(o,t.sys.writeFile)),{parsed:t.parseJsonConfigFileContent(r.config,t.sys,ao(n),void 0,n,void 0,e.getAllExtensions(o).map(a=>({extension:a.slice(1),isMixedContent:!0,scriptKind:t.ScriptKind.Deferred}))),vueOptions:o}}function _u(e,t,n){let r={},i=e.createLanguage([n],new Map,o=>{if(!Pu(o))return;let a=_(o,{maxBytes:ft,inputKind:"Vue language-service source file"});r.current?.scripts.set(o,t.ScriptSnapshot.fromString(a),n.getLanguageId(o)??Nu(o))});return r.current=i,i}function Du(e,t){return{getCurrentDirectory:()=>e,getCompilationSettings:()=>t.options,getScriptFileNames:()=>t.fileNames,getProjectReferences:()=>t.projectReferences,getProjectVersion:()=>"0"}}function ln(e,t,n){try{return e(t)}catch(r){throw(typeof r=="object"&&r!==null&&"code"in r?r.code:null)==="MODULE_NOT_FOUND"?new Error(`Vue augmentation requires ${t} to be installed in ${n}. Install Vue/Volar dependencies for that project, then rerun augment-vue.`,{cause:r}):r}}function lo(e,t,n){let r=Lu(e);return i=>{if(!i.name)return null;let o=N(t,i.fileName),a=n.get(i.fileName);if(!a)return null;let s=n.positionAt(a,i.textSpan.start),c=r.get(o);if(!c)return null;let l=c.starts.find(d=>d.line===s.line&&d.displayName===i.name);if(l)return l.symbolId;let u=c.containingByLine.get(s.line);return u&&u.displayName===i.name?u.symbolId:Ou(c.starts,s.line,2,i.name)}}function Lu(e){let t=e.prepare(`
265
- SELECT
266
- d.relative_path AS relativePath,
267
- der.start_line AS startLine,
268
- der.end_line AS endLine,
269
- der.symbol_id AS symbolId,
270
- gs.display_name AS displayName
271
- FROM defn_enclosing_ranges der
272
- JOIN documents d ON d.id = der.document_id
273
- JOIN global_symbols gs ON gs.id = der.symbol_id
274
- ORDER BY d.relative_path, (der.end_line - der.start_line) DESC
275
- `).all(),n=new Map;for(let r of t){let i=n.get(r.relativePath);i||(i={containingByLine:new Map,starts:[]},n.set(r.relativePath,i)),i.starts.push({line:r.startLine,symbolId:r.symbolId,displayName:r.displayName});for(let o=r.startLine;o<=r.endLine;o++)i.containingByLine.set(o,{symbolId:r.symbolId,displayName:r.displayName})}for(let r of n.values())r.starts.sort((i,o)=>i.line-o.line);return n}function Ou(e,t,n,r){let i=0,o=e.length-1;for(;i<=o;){let s=Math.floor((i+o)/2);e[s].line<t?i=s+1:o=s-1}let a=null;for(let s of[o,i]){let c=e[s];if(!c||c.displayName!==r)continue;let l=Math.abs(c.line-t);l>n||(!a||l<a.distance)&&(a={distance:l,symbolId:c.symbolId})}return a?.symbolId??null}function po(e,t,n){let r=Vu(t),i=e.prepare("SELECT id FROM global_symbols WHERE symbol = ?"),o=e.prepare(`
276
- INSERT OR IGNORE INTO global_symbols (symbol, display_name, kind, documentation)
277
- VALUES (?, ?, ?, ?)
278
- `),a=0,s=new Map;return e.transaction(()=>{for(let l of n){let u=N(t,l),d=xo(r.name,r.version,u);o.run(d,"default",7,`Vue component|${u}`);let p=Uu(i,r,t,l);p&&(a++,s.set(l,p))}})(),{get(l){return s.get(l)??null},syntheticSymbols:a}}function go(e,t,n,r,i){return e.transaction(()=>(Tu(e),ju(e,t,n,r),Mu(e,i)))()}function ju(e,t,n,r){let i=e.prepare("SELECT id FROM documents WHERE relative_path = ?"),o=e.prepare(`
279
- INSERT INTO chunks (document_id, chunk_index, start_line, end_line, occurrences)
280
- VALUES (?, ?, ?, ?, X'00')
281
- `),a=e.prepare(`
282
- INSERT OR IGNORE INTO mentions (chunk_id, symbol_id, role)
283
- VALUES (?, ?, 1)
284
- `);for(let s of n){let c=r.get(s);if(!c)continue;let l=N(t,s),u=i.get(l);if(!u)continue;let d=o.run(u.id,-1,0,0);a.run(Number(d.lastInsertRowid),c)}}function fo(e,t,n,r,i){if(e.fileName.endsWith(".vue")){let o=r.language.scripts.get(e.fileName),a=o?.generated?.languagePlugin.typescript?.getServiceScript(o.generated.root)?.code;if(o&&a){let s=r.language.maps.get(a,o);if(dn(s,e.textSpan.start)!==null)return n.get(e.fileName)}return e.fileName.startsWith(i)?n.get(e.fileName):null}return t(e)}function mo(e){let t=new Set,n=[];for(let r of e){let i=ho(r);t.has(i)||(t.add(i),n.push(r))}return n}function ho(e){return[e.sourceFile,e.sourceLine,e.sourceStartChar,e.sourceEndChar,e.symbolId].join(":")}function Mu(e,t){let n=Bu(e,[...new Set(t.map(c=>c.sourceFile))]),r=e.prepare(`
285
- INSERT INTO chunks (document_id, chunk_index, start_line, end_line, occurrences)
286
- VALUES (?, ?, ?, ?, X'00')
287
- `),i=e.prepare(`
288
- INSERT OR IGNORE INTO mentions (chunk_id, symbol_id, role)
289
- VALUES (?, ?, 0)
290
- `),o=new Set,a=0,s=0;for(let c of t){let l=ho(c);if(o.has(l))continue;o.add(l);let u=n.get(c.sourceFile);if(!u)continue;let d=r.run(u,s++,c.sourceLine,c.sourceLine),p=i.run(Number(d.lastInsertRowid),c.symbolId);a+=Number(p.changes)}return a}function*yo(e){let t=/\b[A-Za-z_$][A-Za-z0-9_$]*\b/g,n=new Set(["script","setup","template","style","lang","scoped","true","false","null","undefined","const","let","var","import","from","export","return","if","else","for","while","function","class","type","interface","as","await","async"]),r;for(;r=t.exec(e);){let i=r[0];n.has(i)||(yield{text:i,start:r.index,end:r.index+i.length})}}function So(e,t){for(let[n]of e.toGeneratedLocation(t,r=>!!r.navigation))return n;return null}function dn(e,t){let n=e;for(let[r]of n.toSourceLocation(t,i=>!!i.navigation))return r;return null}function Cu(e,t){let n=0,r=e.lineStarts.length-1;for(;n<=r;){let o=Math.floor((n+r)/2);e.lineStarts[o]<=t?n=o+1:r=o-1}let i=Math.max(0,r);return{line:i,character:t-e.lineStarts[i]}}function bo(e,t){return N(e,t).startsWith("node_modules/")}function N(e,t){return wu(e,t).replaceAll("\\","/")}function Nu(e){switch(Iu(e)){case".vue":return"vue";case".tsx":return"typescriptreact";case".ts":case".mts":case".cts":return"typescript";case".jsx":return"javascriptreact";case".js":case".mjs":case".cjs":return"javascript";case".json":return"json";default:return"typescript"}}function Ro(){let e=new Map;return{get(t){if(e.has(t))return e.get(t)??null;try{let n=_(t,{maxBytes:ft,inputKind:"Vue source file"}),r={text:n,lineStarts:$u(n)};return e.set(t,r),r}catch{return e.set(t,null),null}},positionAt:Cu}}function $u(e){let t=[0];for(let n=0;n<e.length;n++)e.charCodeAt(n)===10&&t.push(n+1);return t}function Bu(e,t){let n=new Map,r=500;for(let i=0;i<t.length;i+=r){let o=t.slice(i,i+r),a=e.prepare(`SELECT id, relative_path AS relativePath FROM documents WHERE relative_path IN (${o.map(()=>"?").join(",")})`).all(...o);for(let s of a)n.set(s.relativePath,s.id)}return n}function Vu(e){try{let t=JSON.parse(_(so(e,"package.json"),{maxBytes:ie,inputKind:"project package manifest"}));return{name:t.name??"workspace",version:t.version??"0.0.0"}}catch{return{name:"workspace",version:"0.0.0"}}}function Uu(e,t,n,r){let i=N(n,r),o=xo(t.name,t.version,i);return e.get(o)?.id??null}function xo(e,t,n){let r=n.split("/").map(i=>`\`${i.replaceAll("`","")}\``).join("/");return`scip-vue npm ${e} ${t} ${r}/default.`}async function Xu(e){return ee(Z(),{projectRoot:e.projectRoot,dbPath:e.dbPath}),Yu(e)}async function Yu(e){let t=zu(e.projectRoot,e.tsconfig);if(!qu(t))throw new Error(`Vue tsconfig not found at ${t}`);let n=new Gu(e.dbPath);try{let r=co(n,e.projectRoot),i=Hu(Ju(e.dbPath),"augment-vue-meta.json");return await pi({cachePath:i,readFingerprint:()=>el(n,e.projectRoot,e.tsconfig),compute:()=>Ku({db:n,projectRoot:e.projectRoot,dbPath:e.dbPath,tsconfig:e.tsconfig,configPath:t,vueFiles:r,onStatus:e.onStatus}),onCacheHit:o=>e.onStatus?.(`Vue references unchanged; reused ${o.resolvedReferences} cached resolved references.`)})}finally{n.close()}}async function Ku(e){let t=po(e.db,e.projectRoot,e.vueFiles),n=no(e.vueFiles)?await ro({projectRoot:e.projectRoot,dbPath:e.dbPath,tsconfig:e.tsconfig,vueFiles:e.vueFiles}):Zu(e,t);return Qu(e,t,n)}function Qu(e,t,n){let r=mo(n.occurrences),i=go(e.db,e.projectRoot,e.vueFiles,t,r),o={vueFiles:e.vueFiles.length,resolvedReferences:r.length,resolvedReferenceSamples:ul(e.db,r,20),insertedMentions:i,skippedReferences:n.skippedReferences,skippedReferenceReasons:n.skippedReferenceReasons,skippedReferenceSamples:cl(n.skippedReferenceSamples,20),syntheticSymbols:t.syntheticSymbols};return e.onStatus?.(`Resolved ${o.resolvedReferences} Vue references with Volar; inserted ${o.insertedMentions} mentions.`),o}function Zu(e,t){let n=tl({db:e.db,projectRoot:e.projectRoot,configPath:e.configPath,vueSymbolLookup:t});return nl({...n,vueFiles:n.context.fileNames.filter(r=>r.endsWith(".vue"))})}function el(e,t,n){let r=e.prepare(`
291
- SELECT
292
- (SELECT COUNT(*) FROM documents) AS documents,
293
- (SELECT COUNT(*) FROM global_symbols) AS symbols,
294
- (SELECT COUNT(*) FROM chunks) AS chunks,
295
- (SELECT COUNT(*) FROM mentions) AS mentions,
296
- (SELECT COUNT(*) FROM defn_enclosing_ranges) AS ranges,
297
- (SELECT MAX(id) FROM chunks) AS maxChunkId,
298
- (SELECT MAX(id) FROM global_symbols) AS maxSymbolId
299
- `).get();return{version:3,tsconfig:n,files:Ln(t),db:r}}function tl(e){let t=Ro();return{projectRoot:e.projectRoot,context:uo(e.projectRoot,e.configPath),symbolLookup:lo(e.db,e.projectRoot,t),vueSymbolLookup:e.vueSymbolLookup,sourceReader:t}}function nl(e){let t=[],n=me(),r=e.tasks??e.vueFiles.map(i=>({fileName:i,startOffset:0,endOffset:Number.POSITIVE_INFINITY,countFileSkip:!0}));for(let i of r){let o=rl(e,i);t.push(...o.occurrences),nt(n,o)}return{occurrences:t,...n}}function rl(e,t){let n=e.sourceReader.get(t.fileName);if(!n)return vo(e.projectRoot,t,"missing-source-file");let r=e.context.language.scripts.get(t.fileName),i=r?.generated?.languagePlugin.typescript?.getServiceScript(r.generated.root)?.code;if(!r||!i)return vo(e.projectRoot,t,"missing-service-script");let o=e.context.language.maps.get(i,r),a=N(e.projectRoot,t.fileName),s=[...yo(n.text)],c={tokens:s.filter(l=>l.start>=t.startOffset&&l.start<t.endOffset),tokenByStart:new Map(s.map(l=>[l.start,l])),tokenTextCounts:dl(s),processedStarts:new Set};return il({...e,fileName:t.fileName,sourceInfo:n,sourceFile:a,map:o,tokenContext:c})}function il(e){let t=[],n=me();for(let r of e.tokenContext.tokens){if(e.tokenContext.processedStarts.has(r.start)||ol(e.sourceInfo.text,r.start))continue;let i=So(e.map,r.start);if(i===null)continue;let a=(e.context.languageService.getDefinitionAtPosition(e.fileName,i+1)??[]).find(u=>!bo(e.projectRoot,u.fileName));if(!a){pn(n,e.sourceReader,e.sourceInfo,e.sourceFile,r,"no-definition");continue}let s=N(e.projectRoot,a.fileName),c=al(e.sourceFile,r.text,s);if(c){pn(n,e.sourceReader,e.sourceInfo,e.sourceFile,r,c);continue}let l=fo(a,e.symbolLookup,e.vueSymbolLookup,e.context,e.projectRoot);if(l===null){pn(n,e.sourceReader,e.sourceInfo,e.sourceFile,r,"unindexed-definition");continue}Po(t,e.sourceReader,e.sourceInfo,e.sourceFile,r,s,l),e.tokenContext.processedStarts.add(r.start),ll(t,e,r,i,s,l)}return{occurrences:t,...n}}function ol(e,t){let n=e.lastIndexOf(`
300
- `,t-1)+1,r=e.slice(n,t);return/\bfrom\s+['"][^'"]*$/.test(r)||/\bimport\s*\(\s*['"][^'"]*$/.test(r)}function al(e,t,n){return n===e?"same-file-definition":n.endsWith(".vue")&&t!==n.split("/").at(-1)?.replace(/\.vue$/,"")?"unindexed-definition":null}function vo(e,t,n){let r=me();return t.countFileSkip&&(r.skippedReferences=1,r.skippedReferenceReasons[n]=1,r.skippedReferenceSamples.push({sourceFile:N(e,t.fileName),sourceLine:0,sourceStartChar:0,sourceEndChar:0,token:"",reason:n})),{occurrences:[],...r}}function pn(e,t,n,r,i,o){if(e.skippedReferences++,e.skippedReferenceReasons[o]++,e.skippedReferenceSamples.filter(s=>s.reason===o&&s.sourceFile===r).length>=2)return;let a=t.positionAt(n,i.start);e.skippedReferenceSamples.push({sourceFile:r,sourceLine:a.line,sourceStartChar:a.character,sourceEndChar:a.character+i.text.length,token:i.text,reason:o})}function gn(e,t){let n=new Map;for(let o of e){let a=n.get(o.sourceFile)??[];a.push(o),n.set(o.sourceFile,a)}let r=[...n.keys()].sort(),i=[];for(let o=0;i.length<t;o++){let a=!1;for(let s of r){let c=n.get(s)?.[o];if(c&&(i.push(c),a=!0,i.length===t))break}if(!a)break}return i}function sl(e,t){let n=gn(e.filter(o=>o.sourceFile!==o.definitionFile),Math.ceil(t/2)),r=new Set(n.map(o=>`${o.sourceFile}:${o.sourceLine}:${o.sourceStartChar}:${o.sourceEndChar}:${o.symbolId}`)),i=gn(e.filter(o=>!r.has(`${o.sourceFile}:${o.sourceLine}:${o.sourceStartChar}:${o.sourceEndChar}:${o.symbolId}`)),t-n.length);return[...n,...i]}function cl(e,t){let n=[...new Set(e.map(i=>i.reason))].sort(),r=[];for(let[i,o]of n.entries()){let a=n.length-i,s=Math.ceil((t-r.length)/a);r.push(...gn(e.filter(c=>c.reason===o),s))}return r.slice(0,t)}function ul(e,t,n){let r=e.prepare("SELECT symbol FROM global_symbols WHERE id = ?");return sl(t,n).map(({symbolId:i,...o})=>({...o,definitionSymbol:r.get(i)?.symbol??`symbol-id:${i}`}))}function ll(e,t,n,r,i,o){if(!((t.tokenContext.tokenTextCounts.get(n.text)??0)<=1))for(let a of pl(t.context.languageService,t.fileName,r+1,t.map,n,t.tokenContext.tokenByStart)){if(t.tokenContext.processedStarts.has(a))continue;let s=t.tokenContext.tokenByStart.get(a);s&&(Po(e,t.sourceReader,t.sourceInfo,t.sourceFile,s,i,o),t.tokenContext.processedStarts.add(a))}}function Po(e,t,n,r,i,o,a){let s=t.positionAt(n,i.start);e.push({sourceFile:r,sourceLine:s.line,sourceStartChar:s.character,sourceEndChar:s.character+i.text.length,sourceToken:i.text,definitionFile:o,symbolId:a})}function dl(e){let t=new Map;for(let n of e)t.set(n.text,(t.get(n.text)??0)+1);return t}function pl(e,t,n,r,i,o){let a=e.getDocumentHighlights?.(t,n,[t])??[],s=[];for(let c of a)if(c.fileName===t)for(let l of c.highlightSpans){let u=gl(r,l.textSpan.start,o,i.text);u!==null&&s.push(u)}return s}function gl(e,t,n,r){let i=n.get(t);if(i?.text===r)return i.start;let o=dn(e,t);if(o===null)return null;let a=n.get(o);return a?.text===r?a.start:null}async function Oo(e){let{projectRoot:t,maxHeapMb:n=8192,onStatus:r=console.log}=e,i=e.skipAutoInstall===!0||e.installMissing!==!0,o=xl(e),a=Date.now(),s=R();it(y(o.outputScip),{recursive:!0}),it(y(o.outputDb),{recursive:!0});let c=e.languages??wt(t);if(c.length===0)throw new Error("No supported languages detected in this project. Looked for: tsconfig.json, Cargo.toml, go.mod, pyproject.toml, etc.");r(`Detected languages: ${c.join(", ")}`);let l=at(o.metaPath),u=O("reindex.fingerprint",()=>On(t,c,{pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:e.typescriptProjects,clojureConfigPath:e.clojureConfigPath},l,e.changeJournal,It(o.outputDb)),{languages:c.length}),d=u.fingerprint,p=u.mode==="delta"?e.changeJournal?.entries.filter(h=>h.kind!=="add").length??0:0,f=Math.max(0,(l?.files.length??0)-p);r(u.mode==="delta"?`Project fingerprint revalidated ${u.changedPaths.length} changed path(s), reused ${f} accepted file fingerprint(s), and accepted ${d.files.length} input(s)`:`Project fingerprint used full scan: ${u.reason}`);let g,m;if(e.skipIfUnchanged!==!1&&!Rr(t,o.outputDb)&&Io(o.outputScip)===Io(T(y(o.outputDb),"index.scip"))){let h=_e(t);if(g=h?.clean?je(h,d):void 0,h&&!h.clean&&!Rl(o)){let I=xr(h,c,{pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:e.typescriptProjects,clojureConfigPath:e.clojureConfigPath});if(I)try{Me({snapshot:I.snapshot,manifest:I.manifest,targetCacheDir:y(o.outputDb),targetProjectRoot:t,persistLease:!1}),wr(I.snapshot,y(o.outputDb)),r(`Forked shared baseline ${I.snapshot.generationId.slice(0,12)} for dirty worktree reindex`)}catch(k){r(`Shared baseline fork failed; continuing locally: ${te(k)}`)}}else if(g){let I=Et(g);if(I){if(!bl(o,d))try{Me({snapshot:g,manifest:I,targetCacheDir:y(o.outputDb),targetProjectRoot:t}),r(`Attached shared generation ${g.generationId.slice(0,12)}`)}catch(k){r(`Shared generation attach failed; continuing locally: ${te(k)}`)}}else{let k=await Pr(g);if(k.kind==="owner")m=k.release;else if(k.kind==="generation-ready"){let J=Et(g);if(J)try{Me({snapshot:g,manifest:J,targetCacheDir:y(o.outputDb),targetProjectRoot:t,action:"waited"}),r(`Attached shared generation ${g.generationId.slice(0,12)} after waiting`)}catch($){r(`Shared generation attach failed after waiting; continuing locally: ${te($)}`)}}else r("Shared generation build lock timed out; continuing with an isolated local reindex")}}}let v=nr(T(y(o.outputDb),"cache-lifecycle.lock"),{waitMs:3e4});if(!v)throw m?.(),new Error(`Could not acquire scip-query cache lifecycle lock for ${y(o.outputDb)}. A watch daemon or another reindex may hold it. Run "scip-query watch --stop", retry the reindex, then restart with "scip-query watch --daemon".`);let P;try{P=await Y("reindex.lock",()=>Xl(T(y(o.outputDb),"index.lock"),{projectRoot:t,trigger:e.trigger,onStatus:r}),{languages:c.length})}catch(h){throw v.release(),m?.(),h}let S=null,x=Or();try{u.mode==="delta"&&It(o.outputDb)!==e.changeJournal?.baseGeneration&&(d=yt(t,c,{pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:e.typescriptProjects,clojureConfigPath:e.clojureConfigPath}),u={mode:"full",fingerprint:d,reason:"accepted-generation-changed-before-lock"},g=void 0,m?.(),m=void 0,r("Project fingerprint used full scan: accepted-generation-changed-before-lock")),br(o.outputDb,o.outputScip,o.metaPath);let h=wl(y(o.outputDb));h.removed>0&&r(`Removed ${h.removed} abandoned reindex workspace(s)`);for(let Ee of h.errors)r(`Could not remove abandoned reindex workspace: ${Ee}`);let I=null,k=O("reindex.reuse-check",()=>(I=vl({opts:e,paths:o,languages:c,fingerprint:d,start:a,monotonicStart:s,onStatus:r}),I),()=>({languages:c.length,reused:I!==null}));if(k){wo({snapshot:g,paths:o,projectRoot:t,fingerprint:d,onStatus:r});let Ee=Bt(o.outputDb,k);return Ee.state==="failed"&&r(`Warning: reindex succeeded, but activity telemetry was not recorded: ${Ee.reason}`),ht(t,y(o.outputDb)),k}await Y("reindex.scip-cli-ready",()=>Vl(i,r));let J=Il(o);S=J.runDir;let $,b=await Y("reindex.fresh",async()=>($=await kl({opts:e,languages:c,projectRoot:t,paths:o,tempPaths:J,fingerprint:d,start:a,monotonicStart:s,maxHeapMb:n,skipAutoInstall:i,onStatus:r,writeTelemetry:x}),$),()=>({languages:c.length,reused:$?.reused,skipped:$?.skipped.length}));wo({snapshot:g,paths:o,projectRoot:t,fingerprint:d,onStatus:r});let M=Bt(o.outputDb,b);return M.state==="failed"&&r(`Warning: reindex succeeded, but activity telemetry was not recorded: ${M.reason}`),ht(t,y(o.outputDb)),b}catch(h){let I=ct({trigger:e.trigger,result:"failed",start:a,monotonicStart:s,error:h instanceof Error?h.message:String(h)});Xo(o.metaPath,I);let k=bi(o.outputDb,I);throw k.state==="failed"&&r(`Warning: failed reindex activity telemetry was not recorded: ${k.reason}`),h}finally{S&&he(S,{recursive:!0,force:!0}),P(),v.release(),m?.()}}function wo(e){if(e.snapshot)try{let t=_e(e.projectRoot),n=t?je(t,e.fingerprint):void 0;if(!n||n.generationId!==e.snapshot.generationId){e.onStatus("Skipped shared generation publication because the worktree changed during indexing");return}let r=vr({snapshot:e.snapshot,sourceCacheDir:y(e.paths.outputDb),sourceProjectRoot:e.projectRoot,sourceStillValid:()=>{let i=_e(e.projectRoot);return(i?je(i,e.fingerprint):void 0)?.generationId===e.snapshot?.generationId}});Ir(e.snapshot,y(e.paths.outputDb),"built"),e.onStatus(r.kind==="published"?`Published shared generation ${e.snapshot.generationId.slice(0,12)} (${r.achievedDurability})`:`Shared generation ${e.snapshot.generationId.slice(0,12)} was already available (${r.achievedDurability})`)}catch(t){e.onStatus(`Shared generation publication failed; local index remains valid: ${te(t)}`)}}function bl(e,t){if(!F(e.outputScip)||!F(e.outputDb)||!zo(e.metaPath,t))return!1;let n=V(e.outputDb,e.metaPath);return n.state!=="invalid"&&n.state!=="drifted"}function Rl(e){if(!F(e.outputScip)||!F(e.outputDb)||!ne(e.metaPath))return!1;let t=V(e.outputDb,e.metaPath);return t.state!=="invalid"&&t.state!=="drifted"}function te(e){return e instanceof Error?e.message:String(e)}function hn(e,t,n,r,i,o){try{ee(Mr({indexPath:n,reuseExisting:i,affectedFiles:o}),{projectRoot:e,dbPath:t,onStatus:r})}catch(a){r(`Runtime-boundary extraction unavailable: ${a instanceof Error?a.message:String(a)}.`)}}function xl(e){let t=e.outputScip??T(e.projectRoot,"index.scip"),n=e.outputDb??T(e.projectRoot,"index.db");return{outputScip:t,outputDb:n,metaPath:T(y(n),"meta.json")}}function vl(e){let t=V(e.paths.outputDb,e.paths.metaPath);if(e.opts.skipIfUnchanged===!1||!F(e.paths.outputScip)||!F(e.paths.outputDb)||!zo(e.paths.metaPath,e.fingerprint)||t.state==="invalid"||t.state==="drifted")return null;let n=Oe(e.paths.outputDb,e.fingerprint,e.languages);if(n.state!=="complete")return e.onStatus(yn("Accepted SQLite index",n)),null;ee(Z(),{projectRoot:e.opts.projectRoot,dbPath:e.paths.outputDb,onStatus:e.onStatus}),hn(e.opts.projectRoot,e.paths.outputDb,e.paths.outputScip,e.onStatus,!0),V(e.paths.outputDb,e.paths.metaPath).state==="drifted"&&(kt(e.paths.outputDb,e.paths.metaPath),e.onStatus("Published refreshed SQLite generation after post-index augmentation"));let r=R()-e.monotonicStart,i=ct({trigger:e.opts.trigger,result:"reused",start:e.start,monotonicStart:e.monotonicStart,languages:e.languages,skipped:[]});return Xo(e.paths.metaPath,i),e.onStatus(`Index unchanged; reused existing SQLite index in ${(r/1e3).toFixed(1)}s`),{languages:e.languages,indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:r,reused:!0,skipped:[],lastRefresh:i,shards:Pl(e.paths,e.languages,e.opts,e.fingerprint)}}function Pl(e,t,n,r){let i=Jo(r,t,n);return t.map(o=>({id:o,language:o,reused:!0,strategy:"reused",fingerprint:ke(i[o]),outputBytes:ye(Sn(e.outputDb,o)),durationMs:0}))}function Il(e){let t=ml(T(y(e.outputDb),"reindex-"));return{runDir:t,tempOutputScip:T(t,rt(e.outputScip)),tempOutputDb:T(t,rt(e.outputDb)),tempMetaPath:T(t,rt(e.metaPath))}}function wl(e){let t=[],n;try{n=Do(e,{withFileTypes:!0})}catch(i){return{removed:0,errors:[te(i)]}}let r=0;for(let i of n)if(!(!i.name.startsWith("reindex-")||!i.isDirectory()))try{he(T(e,i.name),{recursive:!0,force:!0}),r+=1}catch(o){t.push(`${i.name}: ${te(o)}`)}return{removed:r,errors:t}}async function kl(e){let t={...process.env,NODE_OPTIONS:`--max-old-space-size=${e.maxHeapMb}`},n,r=await Y("reindex.language-indexers",async()=>(n=await Tl(e,t),n),()=>({languages:e.languages.length,indexed:n?.indexedOutputs.length,reused:n?.reusedLanguages.length,skipped:n?.skippedLanguages.length})),{indexedOutputs:i,skippedLanguages:o,reusedLanguages:a,languageFingerprints:s,shards:c,typescriptProjectShardContext:l,incrementalTypeScript:u}=r;if(a.length>0&&e.onStatus(`Reused ${a.length} cached language shard(s): ${a.join(", ")}`),El({run:e,indexedOutputs:i,skippedLanguages:o,reusedLanguages:a})){let f=O("reindex.publish",()=>Cl(e,i,o,a,s,l),{mode:"metadata-only",languages:i.length,reused:a.length}),g=f.durationMs;return e.onStatus(`All language shards unchanged; reused existing SQLite index in ${(g/1e3).toFixed(1)}s`),{languages:i.map(m=>m.language),indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:g,reused:!0,skipped:o,lastRefresh:f,shards:c,writeTelemetry:e.writeTelemetry}}let d=await Y("reindex.publish",()=>Ml(e,t,i,o,a,s,l,u),{mode:u?"incremental-or-fallback":"full",languages:i.length,reused:a.length,skipped:o.length}),p=d.durationMs;return e.onStatus(`Done in ${(p/1e3).toFixed(1)}s`),{languages:i.map(f=>f.language),indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:p,reused:!1,skipped:o,lastRefresh:d,shards:c,writeTelemetry:e.writeTelemetry}}function El(e){if(e.run.opts.skipIfUnchanged===!1||e.skippedLanguages.length>0||!F(e.run.paths.outputScip)||!F(e.run.paths.outputDb))return!1;let t=V(e.run.paths.outputDb,e.run.paths.metaPath);if(t.state==="invalid"||t.state==="drifted")return!1;let n=new Set(e.reusedLanguages),r=new Set(e.indexedOutputs.map(i=>i.language));return e.run.languages.length>0&&r.size===e.run.languages.length&&e.indexedOutputs.length===e.run.languages.length&&e.run.languages.every(i=>n.has(i)&&r.has(i))}async function Tl(e,t){let n=Ll({paths:e.paths,projectRoot:e.projectRoot,languages:e.languages,pnpmWorkspaces:e.opts.pnpmWorkspaces,typescriptProjectMode:e.opts.typescriptProjectMode,typescriptProjects:e.opts.typescriptProjects,clojureConfigPath:e.opts.clojureConfigPath,projectFingerprint:e.fingerprint}),r=[],i=new Set;for(let[b,M]of n)M.reused&&(r.push({language:b,scipPath:M.scipPath}),i.add(b));for(let b of i)e.onStatus(`Reusing cached ${b} SCIP shard (language inputs unchanged).`);let o=n.get("typescript"),a=V(e.paths.outputDb,e.paths.metaPath),s=ne(e.paths.metaPath),c=a.state==="legacy"||a.state==="current",l=s?.scipCompanion!=="deferred"&&(a.state!=="current"||a.generation.publication?.scipCompanion!=="deferred"),u,d=o&&!o.reused&&c?qi({projectRoot:e.projectRoot,cacheDir:y(e.paths.outputDb),previousDbPath:e.paths.outputDb,previousIndexPath:e.paths.outputScip,previousShardPath:o.scipPath,candidateShardPath:Se(e.tempPaths.tempOutputScip,"typescript-incremental",0),candidateAffectedScipPath:Se(e.tempPaths.tempOutputScip,"typescript-affected",0),baseShardCurrent:l,previousSnapshot:at(e.paths.metaPath),currentSnapshot:e.fingerprint,projectMode:e.opts.typescriptProjectMode,onStatus:e.onStatus,onUnavailable:b=>{u=b}}):null,p=new Set(d?["typescript"]:[]);if(e.opts.allowExpensiveRebuild===!1)for(let b of e.languages){if(i.has(b)||p.has(b))continue;let M=n.get(b);M&&F(M.scipPath)&&(r.push({language:b,scipPath:M.scipPath}),i.add(b),e.onStatus(`Skipping expensive ${b} full rebuild because the watch full-rebuild budget is exhausted.`))}let f=d||i.has("typescript")?void 0:Fl(e,n),{preparedRuns:g,skippedLanguages:m,languageOutputScipPaths:w}=Ul({languages:e.languages.filter(b=>!i.has(b)&&!p.has(b)),tempOutputScip:e.tempPaths.tempOutputScip,projectRoot:e.projectRoot,env:t,skipAutoInstall:e.skipAutoInstall,trustProjectTools:e.opts.trustProjectTools===!0,pnpmWorkspaces:e.opts.pnpmWorkspaces,typescriptProjectMode:e.opts.typescriptProjectMode,typescriptProjects:e.opts.typescriptProjects,preDiscoveredTypeScriptProjects:f?.allProjects,clojureConfigPath:e.opts.clojureConfigPath,onStatus:e.onStatus}),v=f?g.filter(b=>b.language!=="typescript"||f.missedProjectIds.has(b.id)):g,P=await zi(v,e.projectRoot,e.onStatus,e.opts.indexerConcurrency,e.opts.signal);if(Tn())for(let b of P)Fn({type:"span",name:`reindex.language-indexer.${b.id}`,durationMs:Math.round(b.durationMs),ok:!b.skipped,language:b.language,indexerCommand:b.command,outputBytes:b.outputBytes,measurement:"indexer-run-result"});let S=[];if(f){_l(e.paths.outputDb,P,e.writeTelemetry);let b=w.typescript??e.tempPaths.tempOutputScip;S=Dl({outputDb:e.paths.outputDb,tempOutputScip:e.tempPaths.tempOutputScip,outputScipPath:b,reusedProjects:f.reusedProjects,writeTelemetry:e.writeTelemetry})}let x=[...P,...S],{indexedOutputs:h}=Gl(x,m),I=d?[{language:"typescript",scipPath:d.scipPath}]:[],k=[...r,...I,...h];ql(k,m,e.languages,e.opts.allowPartial,e.onStatus);let J=d?[{id:"typescript",language:"typescript",label:"typescript (incremental documents)",scipPath:d.scipPath,outputScipPath:d.scipPath,durationMs:d.durationMs,command:"watch-service:typescript-index",outputBytes:ye(d.scipPath)??void 0,producedOutputBytes:ye(d.affectedScipPath)??void 0}]:[],$=Ol(n,[...P,...J],f?{outputDb:e.paths.outputDb,classification:f.classification}:void 0,u);return{indexedOutputs:k,skippedLanguages:m,reusedLanguages:[...i],languageFingerprints:jl(n,e.languages),shards:$,typescriptProjectShardContext:f?{projects:f.allProjects,fingerprints:f.fingerprints}:void 0,incrementalTypeScript:d??void 0}}function Fl(e,t){let n=t.get("typescript");if(!n||n.reused||n.cacheIntegrityFailed||e.opts.typescriptProjectMode!=="workspace")return;let r=ae(e.projectRoot,e.opts.typescriptProjects);if(r.length===0)return;let i=wi(e.projectRoot,r),o=vi(n.fingerprint.files,r),a=Pi(r,i),s=Ii(r,o,a),c=ne(e.paths.metaPath),u=Al(c,s,g=>F(st(e.paths.outputDb,g))),d=[...u.entries()].filter(([,g])=>g.reused).map(([g])=>g),p=new Set(d),f=new Set(r.filter(g=>!p.has(g)).map(g=>`typescript:${g}`));return{allProjects:r,fingerprints:s,classification:u,reusedProjects:d,missedProjectIds:f}}function Al(e,t,n){let r=new Map;for(let i of Object.keys(t)){let o=t[i];if(!e){r.set(i,{reused:!1,reason:"no reindex metadata found",fingerprint:o});continue}let a=e.version===be&&pt(e).typescriptProjectShardReuse?e.typescriptProjectShards?.[i]:void 0;if(!a){r.set(i,{reused:!1,reason:"no cached fingerprint for this project",fingerprint:o});continue}if(!n(i)){r.set(i,{reused:!1,reason:"cached shard file missing on disk",fingerprint:o});continue}if(L(a)!==L(o)){r.set(i,{reused:!1,reason:"project inputs changed since last index",fingerprint:o});continue}r.set(i,{reused:!0,fingerprint:o})}return r}function _l(e,t,n){for(let r of t){if(r.skipped||!r.id.startsWith("typescript:"))continue;let i=r.id.slice(11),o=st(e,i);it(y(o),{recursive:!0}),Q(n,K(r.scipPath,o))}}function Dl(e){return e.reusedProjects.map((t,n)=>{let r=st(e.outputDb,t),i=Se(e.tempOutputScip,"typescript-project-cached",n);return Q(e.writeTelemetry,K(r,i)),{id:`typescript:${t}`,language:"typescript",label:`typescript (${t})`,scipPath:i,outputScipPath:e.outputScipPath,durationMs:0,command:"cached",outputBytes:ye(i)??void 0}})}function Ll(e){let t=ne(e.paths.metaPath),n=Jo(e.projectFingerprint,e.languages,e),r=t&&F(e.paths.outputDb)?Oe(e.paths.outputDb,e.projectFingerprint,e.languages):null,i=new Map;for(let o of e.languages){let a=Sn(e.paths.outputDb,o),s=n[o];if(!t){i.set(o,{reused:!1,reason:"no reindex metadata found",fingerprint:s,scipPath:a});continue}if(t.version!==be){i.set(o,{reused:!1,reason:`metadata version ${String(t.version??"unknown")} predates per-language shard caching`,fingerprint:s,scipPath:a});continue}if(!pt(t).languageShardReuse||!t.languageFingerprints){i.set(o,{reused:!1,reason:"no per-language fingerprints recorded in metadata",fingerprint:s,scipPath:a});continue}let c=t.languageFingerprints[o];if(!c){i.set(o,{reused:!1,reason:"no cached fingerprint for this language",fingerprint:s,scipPath:a});continue}if(!F(a)){i.set(o,{reused:!1,reason:"cached shard file missing on disk",fingerprint:s,scipPath:a});continue}if(L(c)!==L(s)){i.set(o,{reused:!1,reason:"language inputs changed since last index",fingerprint:s,scipPath:a});continue}if(r?.state==="unavailable"||r?.state==="incomplete"&&r.affectedLanguages.includes(o)){i.set(o,{reused:!1,reason:yn("accepted SQLite index",r),cacheIntegrityFailed:!0,fingerprint:s,scipPath:a});continue}i.set(o,{reused:!0,fingerprint:s,scipPath:a})}return i}function Ol(e,t,n,r){let i=[];for(let[o,a]of e)a.reused&&i.push({id:o,language:o,reused:!0,strategy:"reused",fingerprint:ke(a.fingerprint),outputBytes:ye(a.scipPath),durationMs:0});for(let o of t){let a=e.get(o.language),s=n&&o.id.startsWith("typescript:")?o.id.slice(11):null,c=s?n.classification.get(s):void 0;i.push({id:o.id,language:o.language,reused:!1,strategy:o.command==="watch-service:typescript-index"?"incremental":"full",missReason:c?.reason??a?.reason??o.skipped?.reason,fallbackReason:o.language==="typescript"?r:void 0,fingerprint:c?ke(c.fingerprint):a?ke(a.fingerprint):"unknown",outputBytes:o.outputBytes??null,producedOutputBytes:o.producedOutputBytes,durationMs:o.durationMs,command:o.command})}if(n)for(let[o,a]of n.classification)a.reused&&i.push({id:`typescript:${o}`,language:"typescript",reused:!0,strategy:"reused",fingerprint:ke(a.fingerprint),outputBytes:ye(st(n.outputDb,o)),durationMs:0});return i}function ke(e){return fl("sha256").update(L(e)).digest("hex").slice(0,16)}function ye(e){try{return hl(e).size}catch{return null}}function jl(e,t){let n={};for(let r of t){let i=e.get(r);i&&(n[r]=i.fingerprint)}return n}async function Ml(e,t,n,r,i,o,a,s){A(e.opts.signal,"Reindex cancelled by its owner.");let c=!s||s.completeScipUpdated,l=!1;c&&(l=O("reindex.publish.scip-output",()=>{let S=Bl({run:e,indexedOutputs:n,incrementalTypeScript:s});return ko(e.paths.outputDb,S,e.writeTelemetry),Eo(S,e.tempPaths.tempOutputScip,e.onStatus)}));let u=await Y("reindex.publish.sqlite-output",()=>Jl({run:e,env:t,indexedOutputs:n,skippedLanguages:r,reusedLanguages:i,incrementalTypeScript:s,completeScipAvailable:c,completeScipSanitized:l,materializeFullFallback:async()=>{if(A(e.opts.signal,"Reindex cancelled by its owner."),!s||s.completeScipUpdated)return l;e.onStatus("Materializing the deferred whole TypeScript SCIP companion for full conversion..."),nn({cacheDir:y(e.paths.outputDb),generationIdentity:s.nextFragmentGeneration,baseShardPath:s.scipPath,candidateShardPath:s.candidateScipPath});let S=n.map(x=>x.language==="typescript"?{language:x.language,scipPath:s.candidateScipPath}:x);return ko(e.paths.outputDb,S,e.writeTelemetry),l=Eo(S,e.tempPaths.tempOutputScip,e.onStatus),l}}));A(e.opts.signal,"Reindex cancelled by its owner."),O("reindex.publish.auxiliary-documents",()=>{ee(Z(),{projectRoot:e.projectRoot,dbPath:e.tempPaths.tempOutputDb,onStatus:e.onStatus})}),O("reindex.publish.runtime-boundaries",()=>hn(e.projectRoot,e.tempPaths.tempOutputDb,e.tempPaths.tempOutputScip,e.onStatus,!1,s?.affectedFiles));let d=O("reindex.publish.sqlite-layout",()=>Nt(e.tempPaths.tempOutputDb));if(d.added.length>0&&e.onStatus(`Added SQLite query indexes: ${d.added.join(", ")}`),d.removed.length>0&&e.onStatus(`Removed redundant SQLite indexes: ${d.removed.join(", ")}`),No(e,e.tempPaths.tempOutputDb,n.map(S=>S.language)),u.mode==="incremental"&&s){let S=null,x=null;try{S=new j({projectRoot:e.projectRoot,dbPath:e.tempPaths.tempOutputDb,indexPath:e.tempPaths.tempOutputScip}),x=new j({projectRoot:e.projectRoot,dbPath:e.paths.outputDb,indexPath:e.paths.outputScip});let h=ir(S,e.fingerprint,s.referenceFragmentsByFile,x);e.onStatus(`Cached exact TypeScript reference fragments for ${h} affected document(s).`)}catch(h){e.onStatus(`Exact TypeScript reference fragment prefill unavailable: ${h instanceof Error?h.message:String(h)}.`)}finally{S?.close(),x?.close()}}let p=at(e.paths.metaPath),f=u.mode==="incremental"&&s?zl(s,u.changedDocumentPaths):Ot({projectRoot:e.projectRoot,previousDbPath:e.paths.outputDb,previousIndexPath:e.paths.outputScip,candidateDbPath:e.tempPaths.tempOutputDb,candidateIndexPath:e.tempPaths.tempOutputScip,previousSnapshot:p,currentSnapshot:e.fingerprint,refreshResult:"rebuilt"}),g=ct({trigger:e.opts.trigger,result:"rebuilt",start:e.start,monotonicStart:e.monotonicStart,languages:n.map(S=>S.language),skipped:[...r]}),m=u.mode==="incremental"&&u.scipCompanion==="deferred",{metadata:w,pruneProjects:v}=Mo({run:e,indexedOutputs:n,skippedLanguages:r,reusedLanguages:i,languageFingerprints:o,typescriptProjectShardContext:a,lastRefresh:g});w.scipCompanion=m?"deferred":"current",Co(e),$o(e.paths.outputDb,v),bn(e.tempPaths.tempMetaPath,w);let P=Sr({tempOutputScip:e.tempPaths.tempOutputScip,tempOutputDb:e.tempPaths.tempOutputDb,tempMetaPath:e.tempPaths.tempMetaPath,outputScip:e.paths.outputScip,outputDb:e.paths.outputDb,metaPath:e.paths.metaPath,preserveOutputScip:u.mode==="incremental"&&u.scipCompanion==="deferred",publication:u.mode==="incremental"?{mode:"incremental",validation:"passed",converterDurationMs:u.converterDurationMs,affectedDocumentCount:s?.affectedFiles.length,changedDocumentCount:u.changedDocumentPaths.length,producerDurationMs:s?.timings.serviceMs,materializationDurationMs:s?.durationMs,patchDurationMs:u.patchDurationMs,scipCompanion:u.scipCompanion,...u.scipCompanion==="deferred"&&s?{typescriptOverlayGeneration:s.nextFragmentGeneration}:{}}:{mode:"full",validation:"passed",converterDurationMs:u.converterDurationMs,scipCompanion:"current",...u.fallbackReason?{fallbackReason:u.fallbackReason}:{}}});if(P.achievedDurability==="file-flushed"&&e.onStatus(`Published local generation ${P.currentGeneration.slice(0,12)} (file-flushed; directory sync unsupported)`),u.mode==="incremental"&&s){let S=null;try{S=new j({projectRoot:e.projectRoot,dbPath:e.paths.outputDb,indexPath:e.paths.outputScip});let x=$n(S,s.dependencyGraphSnapshot,s.affectedFiles);e.onStatus(x?`Carried the dependency graph forward by replacing ${s.affectedFiles.length} affected document(s).`:"Dependency graph carry-forward was ineligible; the next graph consumer will rebuild it.")}catch(x){e.onStatus(`Dependency graph carry-forward unavailable: ${x instanceof Error?x.message:String(x)}. The next graph consumer will rebuild it.`)}finally{S?.close()}}return fr(y(e.paths.outputDb),u.mode==="incremental"&&u.scipCompanion==="deferred"?[s.nextFragmentGeneration]:[]),dr(y(e.paths.outputDb),s?.completeScipUpdated?[s.nextFragmentGeneration]:[]),jo(e.paths.outputDb,f,e.onStatus),g}function Cl(e,t,n,r,i,o){let a=at(e.paths.metaPath),s=null;try{Q(e.writeTelemetry,K(e.paths.outputDb,e.tempPaths.tempOutputDb))}catch(p){s=Jr("reused","oracle-error",`Could not snapshot the prior database: ${p instanceof Error?p.message:String(p)}`)}ee(Z(),{projectRoot:e.projectRoot,dbPath:e.paths.outputDb,onStatus:e.onStatus}),hn(e.projectRoot,e.paths.outputDb,e.paths.outputScip,e.onStatus,!0);let c=Nt(e.paths.outputDb);c.added.length>0&&e.onStatus(`Added SQLite query indexes: ${c.added.join(", ")}`),c.removed.length>0&&e.onStatus(`Removed redundant SQLite indexes: ${c.removed.join(", ")}`),No(e,e.paths.outputDb,t.map(p=>p.language)),s??=Ot({projectRoot:e.projectRoot,previousDbPath:e.tempPaths.tempOutputDb,previousIndexPath:e.paths.outputScip,candidateDbPath:e.paths.outputDb,candidateIndexPath:e.paths.outputScip,previousSnapshot:a,currentSnapshot:e.fingerprint,refreshResult:"reused"});let l=ct({trigger:e.opts.trigger,result:"reused",start:e.start,monotonicStart:e.monotonicStart,languages:t.map(p=>p.language),skipped:[...n]}),{metadata:u,pruneProjects:d}=Mo({run:e,indexedOutputs:t,skippedLanguages:n,reusedLanguages:r,languageFingerprints:i,typescriptProjectShardContext:o,lastRefresh:l});return Co(e),$o(e.paths.outputDb,d),bn(e.paths.metaPath,u),kt(e.paths.outputDb,e.paths.metaPath),jo(e.paths.outputDb,s,e.onStatus),l}function at(e){return vn(ne(e)?.fingerprint)}function jo(e,t,n){try{zr(e,t),t.status==="evaluated"?n(`Affected-set shadow: ${(t.evaluation.recall*100).toFixed(1)}% recall; ${t.plan.affectedFiles.length} predicted, ${t.comparison.changedFiles.length} changed.`):n(`Affected-set shadow unavailable: ${t.reason}.`)}catch(r){n(`Affected-set shadow telemetry unavailable: ${r instanceof Error?r.message:String(r)}`)}}function Mo(e){let t=Nl({mode:e.run.opts.typescriptProjectMode,skippedLanguages:e.skippedLanguages,reusedLanguages:e.reusedLanguages,context:e.typescriptProjectShardContext,metaPath:e.run.paths.metaPath});return{metadata:{version:be,status:e.skippedLanguages.length===0?"complete":"partial",updatedAt:new Date().toISOString(),fingerprint:e.run.fingerprint,sqliteLayoutVersion:1,languageFingerprints:e.languageFingerprints,typescriptProjectShards:t.field,requestedLanguages:e.run.languages,indexedLanguages:e.indexedOutputs.map(n=>n.language),skipped:[...e.skippedLanguages],lastRefresh:e.lastRefresh},pruneProjects:t.pruneProjects}}function Co(e){A(e.opts.signal,"Reindex cancelled by its owner.");let t=yt(e.projectRoot,e.languages,{pnpmWorkspaces:e.opts.pnpmWorkspaces,typescriptProjectMode:e.opts.typescriptProjectMode,typescriptProjects:e.opts.typescriptProjects,clojureConfigPath:e.opts.clojureConfigPath});if(L(t)!==L(e.fingerprint))throw new Error("Project inputs changed during reindex; refusing to publish artifacts built from a different filesystem snapshot.")}function No(e,t,n){let r=Oe(t,e.fingerprint,n);if(r.state!=="complete")throw new Error(`${yn("Candidate SQLite index",r)} Refusing to publish it.`)}function yn(e,t){if(t.state==="unavailable")return`${e} document coverage could not be verified (${t.reason}); rebuilding cached language shards.`;let n=t.missingPaths.length>0?` First missing path: ${t.missingPaths[0]}.`:"";return`${e} is missing ${t.missingDocumentCount} fingerprinted source document${t.missingDocumentCount===1?"":"s"}; rebuilding affected language shards.${n}`}function Nl(e){if(e.mode!=="workspace")return{field:void 0,pruneProjects:null};if(e.skippedLanguages.some(t=>t.language==="typescript"))return{field:void 0,pruneProjects:null};if(e.reusedLanguages.includes("typescript")){let t=ne(e.metaPath),n=t?.version===be?t.typescriptProjectShards:void 0;return{field:n,pruneProjects:n?Object.keys(n):[]}}return e.context?{field:e.context.fingerprints,pruneProjects:e.context.projects}:{field:void 0,pruneProjects:[]}}function $o(e,t){let n=Ho(e);if(t===null){he(n,{recursive:!0,force:!0});return}let r;try{r=Do(n)}catch{return}for(let i of $l(r,t))he(T(n,i),{force:!0})}function $l(e,t){let n=new Set(t.map(r=>`${qt(r)}.scip`));return e.filter(r=>!n.has(r))}function Bl(e){if(e.incrementalTypeScript?.completeScipUpdated)return[...e.indexedOutputs];let t=e.indexedOutputs.find(a=>a.language==="typescript");if(!t)return[...e.indexedOutputs];let n=V(e.run.paths.outputDb,e.run.paths.metaPath),r=n.state==="current"?n.generation.publication?.typescriptOverlayGeneration:void 0;if(!(n.state==="current"?n.generation.publication?.scipCompanion==="deferred":ne(e.run.paths.metaPath)?.scipCompanion==="deferred")||!r)return[...e.indexedOutputs];let o=Se(e.run.tempPaths.tempOutputScip,"typescript-deferred",0);return e.run.onStatus("Materializing the deferred whole TypeScript SCIP companion for complete publication..."),nn({cacheDir:y(e.run.paths.outputDb),generationIdentity:r,baseShardPath:t.scipPath,candidateShardPath:o}),e.indexedOutputs.map(a=>a.language==="typescript"?{language:a.language,scipPath:o}:a)}function ko(e,t,n){for(let r of t){let i=Sn(e,r.language);it(y(i),{recursive:!0}),r.scipPath!==i&&Q(n,K(r.scipPath,i))}}async function Vl(e,t){if(!le()){if(Sl()==="win32")throw new Error("The scip CLI was not found. On Windows it ships via the npm sidecar package scip-query-scip-windows (installed automatically with scip-query). Reinstall scip-query with optional dependencies enabled, or follow 'scip-query setup' guidance for the exact sidecar package version, or set SCIP_QUERY_SCIP_BIN to a local scip.exe path.");if(e)throw new Error(`The scip CLI is required but not found on PATH.
301
- To install the reviewed version, run: scip-query reindex --install-missing
302
- Or install manually from: https://github.com/sourcegraph/scip/releases`);if(t("scip CLI not found on PATH. Attempting auto-install..."),!Dr(t))throw new Error(`The scip CLI is required but could not be installed.
303
- Install manually from: https://github.com/sourcegraph/scip/releases`)}}function Ul(e){let t=[],n=[],r=e.languages.map((o,a)=>({language:o,scipPath:e.languages.length>1?Se(e.tempOutputScip,o,a):e.tempOutputScip})),i=Object.fromEntries(r.map(({language:o,scipPath:a})=>[o,a]));for(let{language:o,scipPath:a}of r){let s=Wl({...e,language:o,scipPath:a});for(let c of s)"skipped"in c?Bo(n,c.skipped):t.push(c.prepared)}return{preparedRuns:t,skippedLanguages:n,languageOutputScipPaths:i}}function Wl(e){if(e.language!=="typescript"||e.typescriptProjectMode!=="workspace")return[fn({...e,id:e.language,label:e.language,outputScipPath:e.scipPath})];let t=e.preDiscoveredTypeScriptProjects??ae(e.projectRoot,e.typescriptProjects);return t.length===0?[fn({...e,id:e.language,label:e.language,outputScipPath:e.scipPath})]:(e.onStatus(`Indexing TypeScript workspace as ${t.length} project shard(s).`),t.map((n,r)=>fn({...e,id:`typescript:${n}`,label:`typescript (${n})`,scipPath:Se(e.tempOutputScip,"typescript-project",r),outputScipPath:e.scipPath,pnpmWorkspaces:!1,projectPath:n})))}function fn(e){let t=jt(e.language),n=De(t),r=Wn(t,e.projectRoot),i=e.trustProjectTools&&r?Gn(t,e.projectRoot):null,o=Re(t);if(!i&&!o&&r){let u=`${n} is available only as repository-local code at ${r}. Review that exact tool and rerun with --trust-project-tools.`;return e.onStatus(`Skipping ${e.language}: ${u}`),{skipped:{language:e.language,reason:u}}}if(!i&&!o&&!Un(t)){if(e.skipAutoInstall){let u=`${n} not found on PATH. To install the reviewed version, run: scip-query reindex --install-missing${t.installUrl?` (manual source: ${t.installUrl})`:""}`;return e.onStatus(`Skipping ${e.language}: ${u}`),{skipped:{language:e.language,reason:u}}}if(e.onStatus(`${n} not found. Attempting auto-install...`),!Ki(t,e.onStatus)){let u=`${n} could not be auto-installed. ${t.installUrl?`Install manually from ${t.installUrl}`:`Install ${n} and put it on PATH.`}`;return e.onStatus(`Skipping ${e.language}: ${u}`),{skipped:{language:e.language,reason:u}}}}let a=i?.canonicalPath??Re(t);if(!a){let u=`${n} was not found after installation checks.`;return e.onStatus(`Skipping ${e.language}: ${u}`),{skipped:{language:e.language,reason:u}}}let{binary:s,args:c}=t.indexArgs({projectRoot:e.projectRoot,outputPath:e.scipPath,pnpmWorkspaces:e.pnpmWorkspaces,indexerBinary:a,projectPath:e.projectPath,configPath:e.language==="clojure"?e.clojureConfigPath:void 0}),l=ti({language:e.language,projectPath:e.projectPath,pnpmWorkspaces:e.pnpmWorkspaces});if(i&&!i.executable){let u=`${i.relativePath} is not executable; refusing project-local indexer.`;return e.onStatus(`Skipping ${e.language}: ${u}`),{skipped:{language:e.language,reason:u}}}return i&&e.onStatus(`Trusted project-local ${e.language} indexer ${i.relativePath} (${i.sha256.slice(0,12)}\u2026, ${i.canonicalPath}).`),{prepared:{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,config:t,resolvedBinary:a,binary:s,args:c,env:Jn(t,e.env,a),...l===void 0?{}:{temporaryRootConfigContent:l},...i?{trustedProjectTool:i}:{}}}}function Gl(e,t){let n=new Map;for(let i of e)if(i.skipped)Bo(t,i.skipped);else{let o=`${i.language}\0${i.outputScipPath}`,a=n.get(o)??{language:i.language,outputScipPath:i.outputScipPath,scipPaths:[]};a.scipPaths.push(i.scipPath),n.set(o,a)}let r=[];for(let i of n.values())if(i.scipPaths.length>1)hr(i.scipPaths,i.outputScipPath),r.push({language:i.language,scipPath:i.outputScipPath});else{let o=i.scipPaths[0];o!==i.outputScipPath&&Lo(o,i.outputScipPath),r.push({language:i.language,scipPath:i.outputScipPath})}return{indexedOutputs:r}}function Bo(e,t){let n=e.find(r=>r.language===t.language);if(!n){e.push(t);return}n.reason.includes(t.reason)||(n.reason=`${n.reason}; ${t.reason}`)}function ql(e,t,n,r,i){if(e.length===0){let o=t.map(a=>` - ${a.language}: ${a.reason}`).join(`
304
- `);throw new Error(`No language indexers ran successfully. Install at least one indexer for the languages in this project.
305
- `+o)}if(t.length!==0&&(i(`Indexed ${e.length} language output(s); skipped or incomplete: ${t.map(o=>o.language).join(", ")}.`),!r))throw new Error(`Failed to index all required languages; preserving the previous index. Pass --allow-partial to intentionally write an incomplete index.
306
- `+t.map(o=>` - ${o.language}: ${o.reason}`).join(`
307
- `))}function Eo(e,t,n){if(e.length>1){n(`Merging ${e.length} language indexes...`);let r=performance.now(),i=yr(e.map(o=>o.scipPath),t);return Uo(i,n),n(`Merged and sanitized SCIP indexes in ${(performance.now()-r).toFixed(0)}ms.`),!0}else e[0].scipPath!==t&&Lo(e[0].scipPath,t);return!1}async function Jl(e){let t;if(Hl(e)){let i=T(e.run.tempPaths.runDir,"typescript-affected.db");try{Vo(e.incrementalTypeScript.affectedScipPath,e.run.onStatus),e.run.onStatus(`Converting ${e.incrementalTypeScript.affectedFiles.length} affected TypeScript document(s) to SQLite...`);let o=performance.now();await To(e.incrementalTypeScript.affectedScipPath,i,e.env,e.run.onStatus,!0,e.run.opts.signal),e.run.onStatus(`Converted affected SCIP documents in ${(performance.now()-o).toFixed(0)}ms.`);let a=si({previousDbPath:e.run.paths.outputDb,miniDbPath:i,candidateDbPath:e.run.tempPaths.tempOutputDb,affectedFiles:e.incrementalTypeScript.affectedFiles,writeTelemetry:e.run.writeTelemetry});return e.run.onStatus(`Patched ${a.affectedDocumentCount} SQLite document(s) in ${(a.durationMs/1e3).toFixed(3)}s.`),{mode:"incremental",changedDocumentPaths:a.changedDocumentPaths,patchDurationMs:a.durationMs,converterDurationMs:performance.now()-o,scipCompanion:e.incrementalTypeScript.completeScipUpdated?"current":"deferred"}}catch(o){A(e.run.opts.signal,"Reindex cancelled by its owner."),t=o instanceof Error?o.message:String(o),he(i,{force:!0}),he(e.run.tempPaths.tempOutputDb,{force:!0}),e.run.onStatus(`Incremental SQLite publication unavailable: ${t}. Falling back to complete conversion.`)}}let n=e.completeScipSanitized;e.completeScipAvailable||(n=await e.materializeFullFallback());let r=performance.now();return await To(e.run.tempPaths.tempOutputScip,e.run.tempPaths.tempOutputDb,e.env,e.run.onStatus,n,e.run.opts.signal),{mode:"full",converterDurationMs:performance.now()-r,...t?{fallbackReason:t}:{}}}function Hl(e){if(!e.incrementalTypeScript||e.skippedLanguages.length>0||!F(e.run.paths.outputDb)||!F(e.run.paths.outputScip))return!1;let t=new Set(e.reusedLanguages);return e.indexedOutputs.length===e.run.languages.length&&e.run.languages.every(n=>n==="typescript"||t.has(n))}function zl(e,t){let n=R(),r=[...t].sort(),i=new Set(r),o={addedFiles:[],modifiedFiles:r,deletedFiles:[],changedFiles:r,unchangedFiles:e.affectedFiles.filter(a=>!i.has(a)).sort()};return{version:1,status:"evaluated",refreshResult:"rebuilt",recordedAt:new Date().toISOString(),durationMs:R()-n,manifest:e.manifest,plan:e.plan,comparison:o,evaluation:Lt(e.plan,o,e.projectFileCount)}}async function To(e,t,n,r,i=!1,o){if(A(o,"Reindex cancelled by its owner."),r("Converting to SQLite..."),!F(e))throw new Error(`SCIP index not found at ${e} after indexing`);try{i||Vo(e,r);let a=le();if(!a)throw new Error("scip CLI is not available");let s=await Ce({command:a,args:["expt-convert","--output",t,e],label:"SCIP SQLite conversion",env:n,maxStdoutBytes:50*1024*1024,maxStderrBytes:50*1024*1024,timeoutMs:3e5,signal:o});if(s.status!==0)throw new Error(`scip expt-convert exited with ${s.status}${s.stderr.trim()?`: ${s.stderr.trim()}`:""}`)}catch(a){A(o,"Reindex cancelled by its owner.");let s=a instanceof Error?a.message:String(a);throw new Error(`Failed to convert SCIP index to SQLite: ${s}`,{cause:a})}}function Vo(e,t){let n=mr(e);Uo(n,t)}function Uo(e,t){e.removedDefinitionOccurrences!==0&&t(`Sanitized ${e.removedDefinitionOccurrences} invalid definition occurrences across ${e.touchedDocuments} documents before SQLite conversion.`)}function Se(e,t,n){let r=yl(e)||".scip",i=rt(e,r);return T(y(e),`${i}.${n+1}.${t}${r}`)}async function Xl(e,t){for(let n=0;n<2;n++){let r=Yl(e,t);if(r)return r;let i=Kl(e);if(i&&qo(t.trigger,i)){t.onStatus(`Manual reindex preempting watcher refresh started at ${i.startedAt}.`);let o;try{o=await Zl(i)}catch(s){throw new Error(`Could not verify the watcher's in-progress reindex owner (pid ${i.pid}); refusing to steal an active lock: ${te(s)}`,{cause:s})}if(!o)throw new Error(`Could not confirm the watcher's in-progress reindex (pid ${i.pid}) terminated for ${y(e)}; refusing to steal an active lock.`);let a=Pt(e,{parseLegacy:ot});if(!tr(e,a,{parseLegacy:ot}))throw new Error(`Reindex lock ownership changed before preemption completed for ${y(e)}.`);continue}throw new Error(`Another scip-query reindex is already running for ${y(e)}.`)}throw new Error(`Could not acquire scip-query reindex lock for ${y(e)}.`)}function Yl(e,t){let n=B(process.pid),r=Le(e,{kind:"reindex",processIdentity:n,detail:{projectRoot:t.projectRoot,...process.env.SCIP_REINDEX_PROCESS_GROUP_LEADER==="1"?{processGroupLeader:!0}:{},...t.trigger?{trigger:t.trigger}:{}},parseLegacy:ot});if(r.kind==="acquired"&&r.reclaimed){let i=Wo(r.reclaimed,e);i&&qo(t.trigger,i)?t.onStatus(`Manual reindex preempting watcher refresh started at ${i.startedAt}; its prior owner was already stale.`):t.onStatus(`Recovered an abandoned or incomplete reindex lock for ${y(e)}.`)}return r.kind==="acquired"?()=>{r.lock.release()}:null}function Kl(e){return Wo(Pt(e,{parseLegacy:ot}),e)}var ot=e=>{let t=Go(e,"");return t?{pid:t.pid,...t.processIdentity?{processIdentity:t.processIdentity}:{}}:null};function Wo(e,t){if(e.state==="valid"&&e.record?.kind==="reindex"){let n=e.record.detail??{};return{version:2,pid:e.record.pid,...e.record.processIdentity?{processIdentity:e.record.processIdentity}:{},...n.processGroupLeader===!0?{processGroupLeader:!0}:{},projectRoot:typeof n.projectRoot=="string"?n.projectRoot:y(t),startedAt:e.record.startedAt,trigger:n.trigger}}return Go(e.parsed,t)}function Go(e,t){try{let n=e;return typeof n.pid!="number"||!Number.isInteger(n.pid)||n.pid<=0?null:{version:n.version===2?2:1,pid:n.pid,...n.processIdentity===void 0?{}:(()=>{let r=Hn(n.processIdentity);return r?.pid===n.pid?{processIdentity:r}:{}})(),...n.processGroupLeader===!0?{processGroupLeader:!0}:{},projectRoot:typeof n.projectRoot=="string"?n.projectRoot:y(t),startedAt:typeof n.startedAt=="string"?n.startedAt:"unknown",trigger:n.trigger}}catch{return null}}function qo(e,t){return e?.kind==="manual-cli"&&Ql(t?.trigger)}function Ql(e){return e?.kind==="watch-source"||e?.kind==="watch-git-head"||e?.kind==="watch-git-index"||e?.kind==="watch-git-state"}async function Zl(e){return!ue(e.pid)||(mn(e),Fo(e,"SIGTERM"),await Ao(e,2e3))?!0:(mn(e),Fo(e,"SIGKILL"),Ao(e,1e3))}function Fo(e,t){if(e.processGroupLeader)try{process.kill(-e.pid,t);return}catch{if(!ue(e.pid))return;mn(e)}try{process.kill(e.pid,t)}catch{}}async function Ao(e,t){let n=R()+t;for(;R()<n;){if(_o(e))return!0;await ed(50)}return _o(e)}function mn(e){if(!e.processIdentity)throw new Error(`Refusing to signal reindex pid ${e.pid}: its ownership record has no process identity.`);let t=B(e.pid);if(!t)throw new Error(`Refusing to signal reindex pid ${e.pid}: its process identity is unavailable.`);if(!xe(e.processIdentity,t))throw new Error(`Refusing to signal reindex pid ${e.pid}: its process identity does not match the ownership record.`)}function _o(e){if(!ue(e.pid))return!0;if(!e.processIdentity)return!1;let t=B(e.pid);return t!==null&&!xe(e.processIdentity,t)}function ed(e){return new Promise(t=>setTimeout(t,e))}function Jo(e,t,n){return Object.fromEntries(t.map(r=>{let i=r==="typescript"?_n(n.typescriptProjects):[],o=r==="clojure"?td(n.clojureConfigPath):void 0,a=[...jt(r).markerFiles,...i,...o?[o]:[]],s=r==="typescript"?{typescriptProjectMode:n.typescriptProjectMode??"single",typescriptProjects:i}:{typescriptProjectMode:"single",typescriptProjects:[]};return[r,{version:2,languages:[r],pnpmWorkspaces:r==="typescript"&&nd(n),...s,clojureConfigPath:o,files:e.files.filter(c=>xn(c.path,r,a))}]}))}function td(e){return e?.trim()||void 0}function nd(e){return e.typescriptProjectMode!=="workspace"&&e.pnpmWorkspaces===!0}function Sn(e,t){return T(y(e),"language-indexes",`${t}.scip`)}function Ho(e){return T(y(e),"language-indexes","typescript-projects")}function st(e,t){return T(Ho(e),`${qt(t)}.scip`)}function ne(e){try{return dt(re(D(e,"reindex metadata")))}catch{return null}}function zo(e,t){try{let n=re(D(e,"reindex metadata"));if(n.kind!=="legacy"&&n.kind!=="supported")return!1;let r=n.metadata;return n.capabilities.publishableGeneration&&wn(r)&&L(r.fingerprint)===L(t)&&L([...r.indexedLanguages??[]].sort())===L(t.languages)}catch{return!1}}function bn(e,t){Xn(e,t,{spacing:2,trailingNewline:!0})}function Xo(e,t){try{let n=dt(re(D(e,"reindex metadata")));if(!n)return;bn(e,{...n,lastRefresh:t})}catch{}}function ct(e){return{trigger:e.trigger??{kind:"unknown"},result:e.result,startedAt:new Date(e.start).toISOString(),completedAt:new Date().toISOString(),durationMs:R()-e.monotonicStart,indexedLanguages:e.languages?[...e.languages]:void 0,skipped:e.skipped?[...e.skipped]:void 0,error:e.error}}function L(e){return JSON.stringify(e)}function vm(e,t,n,r){return Oo({projectRoot:e,languages:r.languages?.length?r.languages:t.languages,outputScip:n.indexPath,outputDb:n.dbPath,pnpmWorkspaces:t.indexer?.typescript?.pnpmWorkspaces,typescriptProjectMode:t.indexer?.typescript?.projectMode,typescriptProjects:t.indexer?.typescript?.projects,clojureConfigPath:t.indexer?.clojure?.configPath,skipIfUnchanged:r.force!==!0,allowPartial:r.allowPartial===!0,skipAutoInstall:r.skipAutoInstall===!0,installMissing:r.installMissing===!0,trustProjectTools:r.trustProjectTools===!0,indexerConcurrency:r.indexerConcurrency??t.indexerConcurrency,trigger:r.trigger,...r.onStatus?{onStatus:r.onStatus}:{}})}export{cd as a,ud as b,jr as c,zd as d,Xd as e,jt as f,Fs as g,Rp as h,xp as i,Ki as j,Xu as k,Oo as l,vm as m};
308
- //# sourceMappingURL=chunk-F7WQ337U.js.map