codebaseiq 0.2.0 → 0.3.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 (402) hide show
  1. package/CHANGELOG.md +44 -2
  2. package/README.md +1 -1
  3. package/dist/augment-vue-worker.js +1 -1
  4. package/dist/{chunk-2DMVFAY7.js → chunk-23C5AD3B.js} +2 -2
  5. package/dist/{chunk-WH5SYOMD.js → chunk-2E6OUPCF.js} +2 -2
  6. package/dist/{chunk-RWKEXCHU.js → chunk-2EDX3JT5.js} +2 -2
  7. package/dist/chunk-2I2UHZET.js +2 -0
  8. package/dist/{chunk-CSZOQ7YO.js → chunk-2OMXFE64.js} +2 -2
  9. package/dist/{chunk-EXMVF3JR.js → chunk-2PRONPAS.js} +3 -3
  10. package/dist/{chunk-5WXOEJ4G.js → chunk-356EZBIP.js} +2 -2
  11. package/dist/{chunk-A7XQT7MH.js → chunk-36JC5BG2.js} +2 -2
  12. package/dist/{chunk-RRPK327J.js → chunk-3RR2K7EZ.js} +2 -2
  13. package/dist/{chunk-3NUZVLR7.js → chunk-3RSBGWGL.js} +2 -2
  14. package/dist/{chunk-MTMF4N7F.js → chunk-3VJ3OCRE.js} +2 -2
  15. package/dist/{chunk-IBM3F2BJ.js → chunk-4LK5OIPW.js} +2 -2
  16. package/dist/{chunk-FQA3KIFX.js → chunk-5DSL3NT2.js} +2 -2
  17. package/dist/{chunk-IYBIBMPF.js → chunk-5FWR5HLG.js} +2 -2
  18. package/dist/{chunk-CIVYHK7U.js → chunk-5IC2WZAL.js} +2 -2
  19. package/dist/{chunk-PARCKE3Q.js → chunk-5IZRKWTZ.js} +2 -2
  20. package/dist/{chunk-HHBBGWES.js → chunk-5LL4KEHO.js} +2 -2
  21. package/dist/chunk-5T44HG5Y.js +88 -0
  22. package/dist/{chunk-YFQPWKHR.js → chunk-5ZI2PPI7.js} +2 -2
  23. package/dist/{chunk-T3YFIJ5P.js → chunk-67VJAYVR.js} +2 -2
  24. package/dist/{chunk-DKJXK3HA.js → chunk-6BF3VYEF.js} +2 -2
  25. package/dist/chunk-6JMAVFL4.js +3 -0
  26. package/dist/chunk-6O3KXIDL.js +2 -0
  27. package/dist/{chunk-OJFLPVBP.js → chunk-6VREELBC.js} +2 -2
  28. package/dist/chunk-6WAPPQ5F.js +82 -0
  29. package/dist/{chunk-QLTFXVUI.js → chunk-75KJGYX7.js} +2 -2
  30. package/dist/{chunk-PLZXWZHY.js → chunk-7GAK2F3H.js} +2 -2
  31. package/dist/{chunk-X5I2BQGX.js → chunk-7JELP5YE.js} +2 -2
  32. package/dist/{chunk-W3FK73MD.js → chunk-7UCDGXRW.js} +2 -2
  33. package/dist/{chunk-CMXW7MFV.js → chunk-AEXQYQD7.js} +2 -2
  34. package/dist/{chunk-PHPQ24UG.js → chunk-AQI4N64O.js} +2 -2
  35. package/dist/{chunk-XUJM6474.js → chunk-AURCQHSG.js} +2 -2
  36. package/dist/{chunk-EM5UHLAM.js → chunk-BBP7HVBJ.js} +2 -2
  37. package/dist/{chunk-57KFVPVZ.js → chunk-BFBIMTCJ.js} +2 -2
  38. package/dist/{chunk-VVCBMH5O.js → chunk-BGGB5N53.js} +2 -2
  39. package/dist/{chunk-ZOEDRCR4.js → chunk-BRQL7AFJ.js} +2 -2
  40. package/dist/{chunk-KDYQQJ6X.js → chunk-BWL3PMPT.js} +2 -2
  41. package/dist/{chunk-M7LAIM77.js → chunk-C6WKPKCF.js} +2 -2
  42. package/dist/{chunk-2F5ERMNI.js → chunk-C7OUW52M.js} +2 -2
  43. package/dist/{chunk-N3Q3AWGW.js → chunk-C7QWUBR2.js} +96 -96
  44. package/dist/{chunk-BX2U3QQV.js → chunk-CCIYWXX6.js} +2 -2
  45. package/dist/{chunk-3AC56WAR.js → chunk-CIYA2KZN.js} +2 -2
  46. package/dist/{chunk-35YYZD3D.js → chunk-CR3OG6SQ.js} +2 -2
  47. package/dist/{chunk-VYZQZ4ZN.js → chunk-CVHOQONG.js} +2 -2
  48. package/dist/{chunk-4IFISPQW.js → chunk-CW6AXOLR.js} +2 -2
  49. package/dist/{chunk-NDGTJHQN.js → chunk-D53LWANR.js} +2 -2
  50. package/dist/{chunk-VCWAJPXQ.js → chunk-D7AZAOZX.js} +2 -2
  51. package/dist/{chunk-ACZDU5GK.js → chunk-D7DOB27N.js} +7 -7
  52. package/dist/{chunk-CDWSLAPN.js → chunk-DAKIGMIK.js} +2 -2
  53. package/dist/chunk-DDN2F6GB.js +2 -0
  54. package/dist/{chunk-L3YSDLNB.js → chunk-DVWO7RBC.js} +2 -2
  55. package/dist/{chunk-KNV5VFDV.js → chunk-E52K4L2W.js} +2 -2
  56. package/dist/chunk-EIBGSU2R.js +2 -0
  57. package/dist/chunk-EQNMD62X.js +51 -0
  58. package/dist/{chunk-LY2NB5XR.js → chunk-EXZ7VLRY.js} +2 -2
  59. package/dist/{chunk-YIOQJ45A.js → chunk-F3QSL4W2.js} +2 -2
  60. package/dist/{chunk-JOALNFY3.js → chunk-F74LZWCE.js} +2 -2
  61. package/dist/{chunk-ZB3V5QM7.js → chunk-FEIZXBLH.js} +2 -2
  62. package/dist/{chunk-NJA4MMBD.js → chunk-FH5WG4LE.js} +2 -2
  63. package/dist/{chunk-MRGTCMDK.js → chunk-FOZ74V56.js} +2 -2
  64. package/dist/{chunk-S5SKXCND.js → chunk-FQTIFWLR.js} +2 -2
  65. package/dist/chunk-FTTV7IRX.js +355 -0
  66. package/dist/chunk-FWQGH2N2.js +2 -0
  67. package/dist/{chunk-PFPHS4NO.js → chunk-GDHWOA57.js} +2 -2
  68. package/dist/{chunk-H3CKAL6P.js → chunk-GIDCP7KV.js} +2 -2
  69. package/dist/{chunk-6SDEQTVY.js → chunk-GL6UTNUB.js} +2 -2
  70. package/dist/{chunk-37TKC6MB.js → chunk-GP7C5VAE.js} +2 -2
  71. package/dist/{chunk-U24M5RQM.js → chunk-GQLDYCWS.js} +2 -2
  72. package/dist/{chunk-I5FCDTK2.js → chunk-GQXXOS55.js} +2 -2
  73. package/dist/{chunk-NTRW52UR.js → chunk-GUFPEFBG.js} +2 -2
  74. package/dist/{chunk-B2E3HZ2A.js → chunk-GV2CEZCW.js} +2 -2
  75. package/dist/{chunk-AM5SUGHF.js → chunk-GVAF222T.js} +2 -2
  76. package/dist/{chunk-TAJ6UGCO.js → chunk-GWYZVVKY.js} +3 -3
  77. package/dist/{chunk-NK76RSB6.js → chunk-HENP2O4A.js} +2 -2
  78. package/dist/{chunk-VG55NFXF.js → chunk-HINZQKSY.js} +2 -2
  79. package/dist/{chunk-6OVNYYY4.js → chunk-HQA7EBSK.js} +2 -2
  80. package/dist/{chunk-DLC6JDN7.js → chunk-HVFB3PME.js} +2 -2
  81. package/dist/{chunk-FY5V4V4F.js → chunk-I22IZYDI.js} +2 -2
  82. package/dist/{chunk-RVYLJDXC.js → chunk-ICUL7XRT.js} +2 -2
  83. package/dist/{chunk-QVHZB75Z.js → chunk-IHSLIIL3.js} +2 -2
  84. package/dist/{chunk-PNVZIJ57.js → chunk-ITSJMNUD.js} +2 -2
  85. package/dist/{chunk-XNUWRTYM.js → chunk-IZDPGOZR.js} +2 -2
  86. package/dist/chunk-J3GLP7Q5.js +3 -0
  87. package/dist/{chunk-BH5CE4LN.js → chunk-J7AMBVWF.js} +2 -2
  88. package/dist/{chunk-YXJ4IAHH.js → chunk-JCMFBF4Z.js} +2 -2
  89. package/dist/{chunk-ZJZQ7Q2Q.js → chunk-JFIA2JI3.js} +2 -2
  90. package/dist/{chunk-FIXYHQ3W.js → chunk-JLZLLLW5.js} +2 -2
  91. package/dist/{chunk-2E6BTWER.js → chunk-JSNTHRLQ.js} +2 -2
  92. package/dist/{chunk-77GHPR2R.js → chunk-JX6ZWDOS.js} +2 -2
  93. package/dist/{chunk-SRY26ITJ.js → chunk-JYI7CV25.js} +2 -2
  94. package/dist/chunk-K7JLSGCJ.js +8 -0
  95. package/dist/{chunk-DFPAZXLU.js → chunk-KPZGTB2O.js} +2 -2
  96. package/dist/{chunk-7Z7HCZ7J.js → chunk-LKUTSP4G.js} +2 -2
  97. package/dist/{chunk-HIEXRDJF.js → chunk-LMTSB3TB.js} +2 -2
  98. package/dist/{chunk-BLKYYQ7C.js → chunk-LONKINMJ.js} +95 -95
  99. package/dist/{chunk-SF34QLK2.js → chunk-LQHYYIOB.js} +2 -2
  100. package/dist/{chunk-HBQGKMM3.js → chunk-LZSQ6X7E.js} +2 -2
  101. package/dist/{chunk-RCPZOPV6.js → chunk-M2Y6PCFE.js} +2 -2
  102. package/dist/{chunk-WJOQC4P7.js → chunk-MEUHIDI3.js} +2 -2
  103. package/dist/{chunk-MT5W4DUG.js → chunk-MHWMEZDA.js} +2 -2
  104. package/dist/{chunk-FLLXYUOL.js → chunk-MQW6SJ4P.js} +2 -2
  105. package/dist/{chunk-57KEZDPT.js → chunk-MSI3K7PJ.js} +2 -2
  106. package/dist/chunk-MVRGB4KJ.js +278 -0
  107. package/dist/{chunk-27PHVDKL.js → chunk-MZNMASFM.js} +2 -2
  108. package/dist/{chunk-DVYG3JTA.js → chunk-NBCQZSGR.js} +2 -2
  109. package/dist/{chunk-NIO346UL.js → chunk-NBZKSTXP.js} +2 -2
  110. package/dist/{chunk-UWB5WMC2.js → chunk-NCJILOAK.js} +2 -2
  111. package/dist/{chunk-JN5LIBT3.js → chunk-NDKOVQFG.js} +2 -2
  112. package/dist/{chunk-W6C6QTXJ.js → chunk-NEWHKGVD.js} +2 -2
  113. package/dist/{chunk-HBXZAGY6.js → chunk-O2M3VNDY.js} +2 -2
  114. package/dist/chunk-OFGOOL6U.js +3 -0
  115. package/dist/{chunk-FEBLLMTL.js → chunk-OQUCBKOI.js} +2 -2
  116. package/dist/{chunk-5IO2APSS.js → chunk-P4NVCOM7.js} +2 -2
  117. package/dist/{chunk-SJZQ2PTZ.js → chunk-PFC44E6D.js} +2 -2
  118. package/dist/{chunk-LAGDJXFY.js → chunk-PHNCEUXX.js} +2 -2
  119. package/dist/{chunk-HYKSLTAR.js → chunk-PTQPPPG2.js} +2 -2
  120. package/dist/{chunk-5XEVXVTK.js → chunk-PUVNH4PO.js} +2 -2
  121. package/dist/chunk-Q23IMHXS.js +343 -0
  122. package/dist/{chunk-YYFV32WR.js → chunk-Q3ZCQY2Y.js} +2 -2
  123. package/dist/{chunk-OMBRP7BB.js → chunk-Q4XEU3UH.js} +2 -2
  124. package/dist/{chunk-I645ZF75.js → chunk-QEOWONKY.js} +2 -2
  125. package/dist/{chunk-JXHLB7TP.js → chunk-QMOZZ2VX.js} +2 -2
  126. package/dist/{chunk-2VKB5CMA.js → chunk-RCIGX23V.js} +2 -2
  127. package/dist/{chunk-J24VICI5.js → chunk-RIYJ4L33.js} +2 -2
  128. package/dist/{chunk-M4EVGA5S.js → chunk-RJVAPMHF.js} +3 -3
  129. package/dist/chunk-SB7NASHU.js +2 -0
  130. package/dist/{chunk-3XFJUWJE.js → chunk-SGMNWYTH.js} +2 -2
  131. package/dist/chunk-SMDIEDM4.js +27 -0
  132. package/dist/{chunk-IOVPAZWP.js → chunk-SX72EVMY.js} +2 -2
  133. package/dist/{chunk-WO47BIPY.js → chunk-T5X7DK6C.js} +2 -2
  134. package/dist/{chunk-CZEIHYMP.js → chunk-T6MQNNAC.js} +2 -2
  135. package/dist/chunk-T75DS2E6.js +21 -0
  136. package/dist/{chunk-57GCCPLS.js → chunk-TEANKHUU.js} +2 -2
  137. package/dist/{chunk-T55YPJGB.js → chunk-TJBOJUVN.js} +2 -2
  138. package/dist/{chunk-I2KP4AGR.js → chunk-TJWVT4DO.js} +2 -2
  139. package/dist/{chunk-KM4QRWI5.js → chunk-TNJGTQWO.js} +2 -2
  140. package/dist/{chunk-EFFMFK7C.js → chunk-TOTWJZIX.js} +2 -2
  141. package/dist/{chunk-QMGWSEPL.js → chunk-TPO7XC5Z.js} +2 -2
  142. package/dist/{chunk-54K6556S.js → chunk-U33PMPNW.js} +2 -2
  143. package/dist/{chunk-GXVDTHFC.js → chunk-U7NUXDQO.js} +2 -2
  144. package/dist/chunk-UC2FD2PS.js +4 -0
  145. package/dist/{chunk-TUTSO7UZ.js → chunk-UQE4XFSA.js} +2 -2
  146. package/dist/{chunk-4O52YNKL.js → chunk-UQYQBLJX.js} +2 -2
  147. package/dist/{chunk-FPDL2TUB.js → chunk-USOAJHY7.js} +2 -2
  148. package/dist/{chunk-JUO3Z644.js → chunk-UW6KD57C.js} +2 -2
  149. package/dist/{chunk-VLTUX4IF.js → chunk-VGWZ4MOY.js} +2 -2
  150. package/dist/{chunk-U2XX3BT4.js → chunk-VWYGCMV5.js} +2 -2
  151. package/dist/{chunk-IWAMYGPN.js → chunk-W7YLRXZE.js} +2 -2
  152. package/dist/{chunk-QKVTWODE.js → chunk-WK2IQJPK.js} +2 -2
  153. package/dist/{chunk-S64NCE2Z.js → chunk-WWCV4E6J.js} +2 -2
  154. package/dist/{chunk-IVJJNVSX.js → chunk-XMJ53WG4.js} +2 -2
  155. package/dist/{chunk-IGYAZPRX.js → chunk-XN3EKMLI.js} +2 -2
  156. package/dist/{chunk-FWY2PRIF.js → chunk-XQAVQVIL.js} +2 -2
  157. package/dist/{chunk-JYX5UZSZ.js → chunk-XQPPURLQ.js} +2 -2
  158. package/dist/{chunk-4AOOSCZ7.js → chunk-YHPG3S2U.js} +2 -2
  159. package/dist/{chunk-5BDK6QC3.js → chunk-YRKP7PM7.js} +2 -2
  160. package/dist/{chunk-4NHWNAWQ.js → chunk-YT4DVWUV.js} +2 -2
  161. package/dist/{chunk-5NJPH3QZ.js → chunk-YTJHCGYB.js} +2 -2
  162. package/dist/chunk-Z35GOVEH.js +2 -0
  163. package/dist/{chunk-K5G7SPAG.js → chunk-Z6RL7XOE.js} +4 -4
  164. package/dist/{chunk-OVKZM2XI.js → chunk-ZAFGY22Q.js} +2 -2
  165. package/dist/{chunk-A67HT5FR.js → chunk-ZB4C5TTR.js} +2 -2
  166. package/dist/{chunk-CWMHWD56.js → chunk-ZNH33XIB.js} +2 -2
  167. package/dist/{chunk-ZNQCR656.js → chunk-ZQ62NNKN.js} +2 -2
  168. package/dist/{cli-context-XEPPF4RX.js → cli-context-FJL2JHOE.js} +2 -2
  169. package/dist/{cli-context-TSADTXLB.js → cli-context-PQNWHMCQ.js} +2 -2
  170. package/dist/{cli-program-KJGQEM72.js → cli-program-UO7PZD6V.js} +2 -2
  171. package/dist/cli.js +1 -1
  172. package/dist/{code-CDe-mIjx.d.ts → code-DfX3xeWy.d.ts} +1 -1
  173. package/dist/{code-viewer-YGDON6SY.js → code-viewer-KIXEYQNJ.js} +2 -2
  174. package/dist/{code-viewer-ZCTHXQ5C.js → code-viewer-VHLBLIUM.js} +2 -2
  175. package/dist/{command-descriptors-5VAB2MZX.js → command-descriptors-F5P2V3NW.js} +129 -129
  176. package/dist/{command-descriptors-EAHKIRAG.js → command-descriptors-YCLATF5I.js} +130 -130
  177. package/dist/{db-DmRNdCtm.d.ts → db-BoG_PWYH.d.ts} +1 -1
  178. package/dist/direct-navigation-4XJTXIDT.js +2 -0
  179. package/dist/direct-navigation-J5MVYYAD.js +3 -0
  180. package/dist/{graph-evidence-Bs54NWws.d.ts → graph-evidence-D1jx1Cql.d.ts} +1 -1
  181. package/dist/{health-BnzbSLCE.d.ts → health-DkYBS5BI.d.ts} +1 -1
  182. package/dist/index.d.ts +1 -1
  183. package/dist/index.js +1 -1
  184. package/dist/invocation-command-descriptors-RWV4VAI4.js +2 -0
  185. package/dist/invocation-command-descriptors-U76PN7IY.js +3 -0
  186. package/dist/{scip-cli-BRFKkHQn.d.ts → maintenance-types-CdL5eQii.d.ts} +1 -20
  187. package/dist/output-continuation-command-BL25S26S.js +3 -0
  188. package/dist/output-continuation-command-BTETTXEC.js +2 -0
  189. package/dist/postinstall.js +1 -1
  190. package/dist/project-reindex-CRJU3IFG.js +2 -0
  191. package/dist/project-reindex-TQFCOA2O.js +3 -0
  192. package/dist/queries/affected.d.ts +1 -1
  193. package/dist/queries/affected.js +1 -1
  194. package/dist/queries/anchors.d.ts +1 -1
  195. package/dist/queries/anchors.js +1 -1
  196. package/dist/queries/architecture.d.ts +1 -1
  197. package/dist/queries/architecture.js +1 -1
  198. package/dist/queries/bottlenecks.d.ts +1 -1
  199. package/dist/queries/bottlenecks.js +1 -1
  200. package/dist/queries/by-kind.d.ts +1 -1
  201. package/dist/queries/by-kind.js +1 -1
  202. package/dist/queries/call-graph.d.ts +1 -1
  203. package/dist/queries/call-graph.js +1 -1
  204. package/dist/queries/change-surface.d.ts +1 -1
  205. package/dist/queries/change-surface.js +1 -1
  206. package/dist/queries/cleanup-plan.d.ts +1 -1
  207. package/dist/queries/cleanup-plan.js +1 -1
  208. package/dist/queries/co-change.d.ts +1 -1
  209. package/dist/queries/co-change.js +1 -1
  210. package/dist/queries/code.d.ts +2 -2
  211. package/dist/queries/code.js +1 -1
  212. package/dist/queries/complexity-hotspots.d.ts +1 -1
  213. package/dist/queries/complexity-hotspots.js +1 -1
  214. package/dist/queries/complexity.d.ts +1 -1
  215. package/dist/queries/complexity.js +1 -1
  216. package/dist/queries/context.d.ts +1 -1
  217. package/dist/queries/context.js +1 -1
  218. package/dist/queries/convergence.d.ts +1 -1
  219. package/dist/queries/convergence.js +1 -1
  220. package/dist/queries/coupling.d.ts +1 -1
  221. package/dist/queries/coupling.js +1 -1
  222. package/dist/queries/cycles.d.ts +1 -1
  223. package/dist/queries/cycles.js +1 -1
  224. package/dist/queries/dataflow.d.ts +1 -1
  225. package/dist/queries/dataflow.js +1 -1
  226. package/dist/queries/dead.d.ts +1 -1
  227. package/dist/queries/dead.js +1 -1
  228. package/dist/queries/decorative-checkers.d.ts +1 -1
  229. package/dist/queries/decorative-checkers.js +1 -1
  230. package/dist/queries/deep-chains.d.ts +1 -1
  231. package/dist/queries/deep-chains.js +1 -1
  232. package/dist/queries/dependence-slice.d.ts +2 -2
  233. package/dist/queries/dependence-slice.js +1 -1
  234. package/dist/queries/dependency-depth.d.ts +1 -1
  235. package/dist/queries/dependency-depth.js +1 -1
  236. package/dist/queries/deps.d.ts +1 -1
  237. package/dist/queries/deps.js +1 -1
  238. package/dist/queries/diff-impact.d.ts +1 -1
  239. package/dist/queries/diff-impact.js +1 -1
  240. package/dist/queries/doc-drift.d.ts +1 -1
  241. package/dist/queries/doc-drift.js +1 -1
  242. package/dist/queries/drift.d.ts +1 -1
  243. package/dist/queries/drift.js +1 -1
  244. package/dist/queries/duplicate-bodies.d.ts +1 -1
  245. package/dist/queries/duplicate-bodies.js +1 -1
  246. package/dist/queries/entry-map.d.ts +1 -1
  247. package/dist/queries/entry-map.js +1 -1
  248. package/dist/queries/evidence.d.ts +2 -2
  249. package/dist/queries/evidence.js +1 -1
  250. package/dist/queries/extract-candidates.d.ts +1 -1
  251. package/dist/queries/extract-candidates.js +1 -1
  252. package/dist/queries/fan.d.ts +1 -1
  253. package/dist/queries/fan.js +1 -1
  254. package/dist/queries/files.d.ts +1 -1
  255. package/dist/queries/files.js +1 -1
  256. package/dist/queries/health.d.ts +2 -2
  257. package/dist/queries/health.js +1 -1
  258. package/dist/queries/hierarchy.d.ts +1 -1
  259. package/dist/queries/hierarchy.js +1 -1
  260. package/dist/queries/hotspots.d.ts +1 -1
  261. package/dist/queries/hotspots.js +1 -1
  262. package/dist/queries/imports.d.ts +1 -1
  263. package/dist/queries/imports.js +1 -1
  264. package/dist/queries/incomplete-migration.d.ts +1 -1
  265. package/dist/queries/incomplete-migration.js +1 -1
  266. package/dist/queries/index.d.ts +4 -4
  267. package/dist/queries/index.js +1 -1
  268. package/dist/queries/isolated.d.ts +1 -1
  269. package/dist/queries/isolated.js +1 -1
  270. package/dist/queries/locality-candidates.d.ts +1 -1
  271. package/dist/queries/locality-candidates.js +1 -1
  272. package/dist/queries/members.d.ts +1 -1
  273. package/dist/queries/members.js +1 -1
  274. package/dist/queries/methods.d.ts +1 -1
  275. package/dist/queries/methods.js +1 -1
  276. package/dist/queries/not-implemented.d.ts +1 -1
  277. package/dist/queries/not-implemented.js +1 -1
  278. package/dist/queries/outline.d.ts +1 -1
  279. package/dist/queries/outline.js +1 -1
  280. package/dist/queries/passthrough-candidates.d.ts +1 -1
  281. package/dist/queries/passthrough-candidates.js +1 -1
  282. package/dist/queries/plan-context.d.ts +1 -1
  283. package/dist/queries/plan-context.js +1 -1
  284. package/dist/queries/react-component-duplicates.d.ts +1 -1
  285. package/dist/queries/react-component-duplicates.js +1 -1
  286. package/dist/queries/react-hook-candidates.d.ts +1 -1
  287. package/dist/queries/react-hook-candidates.js +1 -1
  288. package/dist/queries/react-large-component-pressure.d.ts +1 -1
  289. package/dist/queries/react-large-component-pressure.js +1 -1
  290. package/dist/queries/recent-duplicates.d.ts +1 -1
  291. package/dist/queries/recent-duplicates.js +1 -1
  292. package/dist/queries/redundant-reexports.d.ts +1 -1
  293. package/dist/queries/redundant-reexports.js +1 -1
  294. package/dist/queries/reference-neighborhood.d.ts +1 -1
  295. package/dist/queries/reference-neighborhood.js +1 -1
  296. package/dist/queries/reference-reachability.d.ts +1 -1
  297. package/dist/queries/reference-reachability.js +1 -1
  298. package/dist/queries/refs.d.ts +1 -1
  299. package/dist/queries/refs.js +1 -1
  300. package/dist/queries/self-audit.d.ts +1 -1
  301. package/dist/queries/self-audit.js +1 -1
  302. package/dist/queries/similar-chains.d.ts +1 -1
  303. package/dist/queries/similar-chains.js +1 -1
  304. package/dist/queries/similar-files.d.ts +1 -1
  305. package/dist/queries/similar-files.js +1 -1
  306. package/dist/queries/similar-signatures.d.ts +1 -1
  307. package/dist/queries/similar-signatures.js +1 -1
  308. package/dist/queries/similar.d.ts +1 -1
  309. package/dist/queries/similar.js +1 -1
  310. package/dist/queries/slice.d.ts +1 -1
  311. package/dist/queries/slice.js +1 -1
  312. package/dist/queries/source-inspection.d.ts +3 -3
  313. package/dist/queries/source-inspection.js +1 -1
  314. package/dist/queries/source-search.d.ts +1 -1
  315. package/dist/queries/source-search.js +1 -1
  316. package/dist/queries/stale-abstractions.d.ts +1 -1
  317. package/dist/queries/stale-abstractions.js +1 -1
  318. package/dist/queries/stats.d.ts +1 -1
  319. package/dist/queries/surface.d.ts +1 -1
  320. package/dist/queries/surface.js +1 -1
  321. package/dist/queries/symbols.d.ts +1 -1
  322. package/dist/queries/symbols.js +1 -1
  323. package/dist/queries/system-map.d.ts +1 -1
  324. package/dist/queries/system-map.js +1 -1
  325. package/dist/queries/system.d.ts +1 -1
  326. package/dist/queries/system.js +1 -1
  327. package/dist/queries/test-quality.d.ts +1 -1
  328. package/dist/queries/test-quality.js +1 -1
  329. package/dist/queries/trace.d.ts +1 -1
  330. package/dist/queries/trace.js +1 -1
  331. package/dist/queries/twin-ab.d.ts +1 -1
  332. package/dist/queries/twin-ab.js +1 -1
  333. package/dist/queries/twin-drift.d.ts +1 -1
  334. package/dist/queries/twin-drift.js +1 -1
  335. package/dist/queries/unused-imports.d.ts +1 -1
  336. package/dist/queries/unused-imports.js +1 -1
  337. package/dist/queries/unused-params.d.ts +1 -1
  338. package/dist/queries/unused-params.js +1 -1
  339. package/dist/queries/value-flow.d.ts +2 -2
  340. package/dist/queries/value-flow.js +1 -1
  341. package/dist/queries/vue-component-duplicates.d.ts +1 -1
  342. package/dist/queries/vue-component-duplicates.js +1 -1
  343. package/dist/queries/vue-composable-candidates.d.ts +1 -1
  344. package/dist/queries/vue-composable-candidates.js +1 -1
  345. package/dist/queries/vue-large-view-pressure.d.ts +1 -1
  346. package/dist/queries/vue-large-view-pressure.js +1 -1
  347. package/dist/queries/wrapper-candidates.d.ts +1 -1
  348. package/dist/queries/wrapper-candidates.js +1 -1
  349. package/dist/reindex-worker.js +2 -2
  350. package/dist/reindex.d.ts +2 -4
  351. package/dist/reindex.js +71 -32
  352. package/dist/runtime.d.ts +1 -2
  353. package/dist/runtime.js +3 -3
  354. package/dist/rust-semantic-session-server.js +1 -1
  355. package/dist/rust-semantic-session-worker.js +1 -1
  356. package/dist/rust-semantic-worker.js +1 -1
  357. package/dist/sentinel-ensure-command-OSWGCFFL.js +3 -0
  358. package/dist/sentinel-ensure-command-SPW7XQLB.js +2 -0
  359. package/dist/sentinel-worker.js +1 -1
  360. package/dist/typescript-mailbox-worker.js +1 -1
  361. package/dist/watch-server.js +2 -2
  362. package/docs/INDEX_GENERATIONS.md +2 -2
  363. package/docs/NPM_RELEASE.md +323 -0
  364. package/docs/schemas/npm-release-state.schema.json +4 -13
  365. package/package.json +3 -11
  366. package/dist/chunk-2Q2LW5JW.js +0 -14
  367. package/dist/chunk-327YK6TB.js +0 -4
  368. package/dist/chunk-347TXATM.js +0 -2
  369. package/dist/chunk-36WRYYTE.js +0 -3
  370. package/dist/chunk-6OAHRI2D.js +0 -6
  371. package/dist/chunk-6URCE5QY.js +0 -2
  372. package/dist/chunk-6ZV5EDUT.js +0 -5
  373. package/dist/chunk-7R64XY4Y.js +0 -12
  374. package/dist/chunk-CANBLFVQ.js +0 -15
  375. package/dist/chunk-CCRZLRWJ.js +0 -2
  376. package/dist/chunk-G2XUZCF2.js +0 -88
  377. package/dist/chunk-H5QXP63L.js +0 -2
  378. package/dist/chunk-HCMQZPEO.js +0 -2
  379. package/dist/chunk-IEL6Q5W3.js +0 -308
  380. package/dist/chunk-IGQQUENU.js +0 -109
  381. package/dist/chunk-K2O7SBAU.js +0 -2
  382. package/dist/chunk-QVWDQTMG.js +0 -2
  383. package/dist/chunk-RJWAB4VR.js +0 -345
  384. package/dist/chunk-VCL7FK3E.js +0 -3
  385. package/dist/chunk-WOOTEWQT.js +0 -239
  386. package/dist/chunk-XYLV727H.js +0 -21
  387. package/dist/chunk-YMGZZEW4.js +0 -2
  388. package/dist/direct-navigation-B3SGOOBW.js +0 -2
  389. package/dist/direct-navigation-ZL362KXF.js +0 -3
  390. package/dist/invocation-command-descriptors-CSUGUHTT.js +0 -2
  391. package/dist/invocation-command-descriptors-PPVZOIE5.js +0 -3
  392. package/dist/output-continuation-command-FTVVBVSN.js +0 -2
  393. package/dist/output-continuation-command-ITPRC3YV.js +0 -3
  394. package/dist/project-reindex-7HZSLLLY.js +0 -3
  395. package/dist/project-reindex-NGM3DYBN.js +0 -2
  396. package/dist/sentinel-ensure-command-KYYULCFU.js +0 -2
  397. package/dist/sentinel-ensure-command-RIZA3RY7.js +0 -3
  398. package/docs/WINDOWS_SIDECAR_RELEASE.md +0 -424
  399. package/docs/schemas/windows-sidecar-provenance.schema.json +0 -137
  400. package/scripts/build-codebaseiq-windows.mjs +0 -197
  401. package/scripts/codebaseiq-windows-provenance.mjs +0 -364
  402. package/scripts/verify-codebaseiq-windows.mjs +0 -29
@@ -1,308 +0,0 @@
1
- #!/usr/bin/env node
2
- import{a as sr}from"./chunk-EN4AHLL3.js";import{Fb as tr,Gb as nr,Hb as rr,Jb as ir,Kb as or,Lb as ar,Mb as _e,T as Gn,U as qn,ca as Fe,cb as ie,db as Jn,eb as Hn,fb as oe,gb as Ae,hb as ge,ib as zn,jb as Xn,k as Te,kb as Kn,lb as Yn,mb as Qn,qb as yt,vb as Zn,xb as er}from"./chunk-RJWAB4VR.js";import{d as sn,e as ot}from"./chunk-D62CTZX6.js";import{$ as Sn,$a as Ee,A as ln,Aa as U,B as ve,Ba as W,C as k,Ca as G,D as pe,E as ee,Ea as gt,F as ct,Fa as In,G as dn,Ga as ft,H as ut,Ha as mt,I as pn,Ia as kn,J as R,Ja as wn,Ka as En,L as gn,La as Tn,M as A,Ma as Fn,Na as An,O as Pe,Oa as _n,P as lt,Pa as Dn,Q as fn,Qa as Ln,Ra as On,S as mn,Sa as jn,Ta as Cn,U as te,Ua as Mn,Va as we,Wa as Nn,X as hn,Y as yn,Ya as ht,Za as $n,_ as L,_a as Bn,cb as Vn,db as Un,eb as Wn,ha as Ie,ia as ne,j as at,ka as re,ma as bn,pa as Rn,s as st,ta as ke,u as D,ua as xn,v as cn,va as dt,wa as vn,xa as Pn,ya as pt,z as un}from"./chunk-G2XUZCF2.js";import{C as an,D as it,F as V,d as Re,i as nn,j as Y,k as Q,l as et,m as tt,n as xe,o as nt,p as B,q as F,r as _,s as rn,w as on,x as de,y as Z,z as rt}from"./chunk-DUKHVPU5.js";import{createHash as Lu}from"crypto";import{existsSync as E,mkdirSync as Ke,readdirSync as no,renameSync as ro,rmSync as ue,statSync as Ou}from"fs";import{basename as Xe,dirname as y,extname as ju,join as w,resolve as zi}from"path";import{platform as Cu}from"os";import{execFileSync as cr}from"child_process";import{createRequire as bo}from"module";import{existsSync as Ro}from"fs";import{platform as fe,arch as ur}from"os";var me="v0.8.1",St="https://github.com/sourcegraph/scip",De=`github.com/sourcegraph/scip/cmd/scip@${me}`,lr=bo(import.meta.url),dr="CODEBASEIQ_SCIP_BIN";function xo(e){if(e.isOnPath("scip"))return{source:"path",path:"scip"};let t=e.env[dr];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 vo(e){for(let t of e==="arm64"?["arm64","x64"]:[e])try{return lr.resolve(`codebaseiq-windows/scip-win32-${t}.exe`)}catch{}return null}function ae(e=process.env){let t=xo({platform:fe(),arch:ur(),env:e,isOnPath:ie,fileExists:Ro,resolveSidecar:vo});return t?.source==="path"?Hn("scip")??t.path:t?.path??null}function kl(){return ae()!==null}function Po(){let e=ae();if(!e)return null;try{return cr(e,["--version"],{stdio:"pipe",windowsHide:!0,timeout:1e4,killSignal:"SIGKILL"}).toString().trim()}catch{return null}}function Io(){let e=fe(),t=ur(),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:`${St}/releases/download/${me}/${o}`,filename:o}}function wl(){let e=Io();if(console.log("\nThe `scip` CLI is required but not found on PATH.\n"),fe()==="darwin"||fe()==="linux")console.log("Install the reviewed version with Go:"),console.log(` go install ${De}
3
- `),console.log("Or download that exact release manually:");else if(fe()==="win32"){let t=ko();console.log("On Windows the scip binary ships via the npm sidecar package codebaseiq-windows,"),console.log("installed automatically with codebaseiq. If it is missing:"),console.log(` npm install -g ${t}`),console.log(`Or set ${dr} to a local scip.exe path.
4
- `),console.log("Upstream release page:")}else console.log("Download from:");console.log(e?` ${e.url}
5
- `:` ${St}/releases/tag/${me}
6
- `),console.log("After installing, ensure `scip` is on your PATH and run `codebaseiq reindex`.")}function ko(){let t=lr("../../package.json").optionalDependencies?.["codebaseiq-windows"];if(!t||!/^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$/.test(t))throw new Error("codebaseiq package metadata does not declare an exact Windows sidecar version.");return`codebaseiq-windows@${t}`}function pr(e){if(ie("go")){e(`Installing immutable ${De} via go install into the Go bin directory (GOBIN or GOPATH/bin); expected executable: scip.`);try{if(cr("go",["install",De],{stdio:"inherit",windowsHide:!0,timeout:3e5,env:process.env}),ie("scip")){let t=ae(),n=Po();if(t&&n&&n.includes(me))return e(`Successfully installed ${De}; resolved executable: ${t}; reported version: ${n}.`),!0;e(`go install completed, but the resolved scip executable did not report ${me} (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: ${St}/releases`),!1}import{execFileSync as wo}from"child_process";import{constants as Eo,copyFileSync as gr,statSync as To}from"fs";import{platform as Fo}from"os";var Ao=Object.freeze({size:e=>To(e).size,clone:Do,copy:(e,t)=>gr(e,t)}),_o=new Set(["ENOSYS","ENOTSUP","EOPNOTSUPP","EINVAL","EXDEV","ENOTTY"]);function q(e,t,n=Ao){let r=n.size(e);try{return n.clone(e,t),{method:"reflink",bytes:r}}catch(i){if(!Oo(i))throw i}return n.copy(e,t),{method:"copy",bytes:r}}function Do(e,t){if(Fo()!=="darwin"){gr(e,t,Eo.COPYFILE_FICLONE_FORCE);return}try{wo("/bin/cp",["-c",e,t],{timeout:6e4,maxBuffer:64*1024,stdio:["ignore","ignore","pipe"],windowsHide:!0})}catch(n){throw Lo(n)}}function Lo(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 Oo(e){let t=e?.code;return t!==void 0&&_o.has(t)}function fr(){return{reflinkedBytes:0,fallbackCopiedBytes:0}}function J(e,t){t.method==="reflink"?e.reflinkedBytes+=t.bytes:e.fallbackCopiedBytes+=t.bytes}import jo from"better-sqlite3";import{execFileSync as Co}from"child_process";import{existsSync as Mo,readdirSync as No}from"fs";import{extname as Le,join as $o}from"path";function H(e={}){return{id:"auxiliary-documents",facts:["auxiliary-document"],run:t=>mr({projectRoot:t.projectRoot,dbPath:t.dbPath,extensions:e.extensions,onStatus:t.onStatus})}}function mr(e){let t=new Set((e.extensions??Gn).map(o=>o.toLowerCase()));if(t.size===0)return{scanned:0,inserted:0,existing:0};if(!Mo(e.dbPath))throw new Error(`SCIP SQLite database not found at ${e.dbPath}`);let n=Sn(e.projectRoot),r=Bo(e.projectRoot,t).filter(o=>!n.isIgnored(o)),i=new jo(D(e.dbPath));try{let o=Uo(i,r),a=i.prepare(`INSERT OR IGNORE INTO documents (language, relative_path, position_encoding, text)
7
- VALUES (?, ?, NULL, ?)`),c=i.transaction(l=>{let d=0;for(let p of l){if(o.has(p))continue;let g=Rn(e.projectRoot,p,{inputKind:"auxiliary source file"}),f=a.run(Wo(p),p,g);d+=Number(f.changes)}return d})(r),u={scanned:r.length,inserted:c,existing:r.length-c};return e.onStatus?.(`Augmented SQLite documents with ${c} auxiliary source file${c===1?"":"s"} (${u.existing} already present).`),u}finally{i.close()}}function Bo(e,t){let n=Vo(e,t);if(n)return n;let r=[],i=o=>{let a=o?$o(e,o):e,s;try{s=No(a,{withFileTypes:!0})}catch{return}for(let c of s){if(qn.has(c.name))continue;let u=o?`${o}/${c.name}`:c.name;if(c.isDirectory()){i(u);continue}t.has(Le(c.name).toLowerCase())&&r.push(u)}};return i(""),r.sort()}function Vo(e,t){try{return Co("git",["-C",e,"ls-files","-co","--exclude-standard","--","."],{encoding:"utf-8",maxBuffer:26214400,stdio:["ignore","pipe","ignore"],windowsHide:!0,timeout:3e4,killSignal:"SIGKILL"}).split(`
8
- `).filter(r=>r&&t.has(Le(r).toLowerCase())).sort()}catch{return null}}function Uo(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 Wo(e){return Le(e).toLowerCase()===".vue"?"vue":Le(e).replace(/^\./,"").toLowerCase()||"source"}import{dirname as Go,join as qo}from"path";function hr(e={}){return{id:"runtime-boundaries",facts:["runtime-boundary-observation","runtime-boundary-link"],run:({projectRoot:t,dbPath:n,onStatus:r})=>{let i=new L({projectRoot:t,dbPath:n,indexPath:e.indexPath??qo(Go(n),"index.scip")}),o,a=!1,s=!1;try{let u=e.reuseExisting||e.affectedFiles?ir(i):null;e.reuseExisting&&u?.extractorVersion===tr?(o=u,a=!0):(o=nr(i,{...u?{previousGraph:u}:{},...e.affectedFiles?{affectedFiles:e.affectedFiles}:{}}),s=(o.coverage.filesReused??0)>0)}finally{i.close()}a||rr(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(u=>`${u.id} ${u.durationMs.toFixed(0)}ms`).join(", ")}.`),c}}}import{createHash as sa}from"crypto";import{existsSync as ca}from"fs";import{dirname as ua,join as vr}from"path";function bt(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 Oe(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=bt(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"),yr(r,i,a)):a.size>0?yr(r,i,a):{mode:"closure",changedFiles:r,affectedFiles:Jo(r,t,i),reasons:[]}}function yr(e,t,n){return{mode:"full-project",changedFiles:e,affectedFiles:[...t].sort(),reasons:[...n].sort()}}function Jo(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 u=r.get(c)??new Set;u.add(a),r.set(c,u)}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 Ho,existsSync as zo,mkdirSync as Xo,renameSync as Ko,rmSync as Yo,statSync as Qo,truncateSync as Zo}from"fs";import{basename as ea,dirname as ta}from"path";var se=".previous",na=".rotation.lock",ra=2e3,Rt=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"},xt=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"},Sr=Object.freeze({monotonicNow:R,wait(e){Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,e)},tryAcquireLock(e,t){let n=Pe(e,{kind:"rotating-jsonl",detail:{target:ea(t)}});return n.kind==="acquired"?{kind:"acquired",lock:n.lock}:{kind:"contended"}},makeDirectory(e){Xo(e,{recursive:!0})},exists:zo,readBytes(e){return B(e,{maxBytes:xe,inputKind:"rotating JSONL segment"})},size(e){return Qo(e).size},truncate:Zo,remove(e){Yo(e,{force:!0})},rename:Ko,append:Ho});function je(e,t,n){let r=n.runtime??Sr,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 Rr(e,n.lockTimeoutMs,r,()=>{r.makeDirectory(ta(e));let s=ia(e,xe,r);n.onPhase?.("tail-repaired");let c=`${e}${n.previousSuffix??se}`,u=!1,l=!1;return r.exists(e)&&r.size(e)+o.length>a&&(r.exists(c)&&(r.remove(c),l=!0),n.onPhase?.("previous-pruned"),r.rename(e,c),u=!0,n.onPhase?.("current-rotated")),r.append(e,o),n.onPhase?.("record-appended"),{lineBytes:o.length,segmentLimitBytes:a,repairedTailBytes:s,rotated:u,prunedPrevious:l}})}function br(e,t={}){let n=t.runtime??Sr,r=oa(t.maxSegmentBytes);return Rr(e,t.lockTimeoutMs,n,()=>{let i=[],o=0,a=`${e}${t.previousSuffix??se}`;for(let s of[a,e]){if(!n.exists(s))continue;let c=aa(xr(s,r,n));i.push(...c.lines),o+=c.partialTailBytes}return{lines:i,ignoredPartialTailBytes:o}})}function Rr(e,t,n,r){let i=`${e}${na}`,o=Math.max(0,t??ra),a=n.monotonicNow()+o,s;for(;;){let p=n.tryAcquireLock(i,e);if(p.kind==="acquired"){s=p.lock;break}let g=a-n.monotonicNow();if(g<=0)throw new Rt(i,o);n.wait(Math.min(5,g))}let c=!1,u,l;try{l=r()}catch(p){c=!0,u=p}let d=!1;try{d=s.release()}catch(p){if(!c)throw p}if(c)throw u;if(!d)throw new xt(i);return l}function ia(e,t,n){if(!n.exists(e))return 0;let r=xr(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 oa(e){let t=e??xe;if(!Number.isSafeInteger(t)||t<=0)throw new RangeError(`maxSegmentBytes must be a positive safe integer; received ${t}`);return t}function xr(e,t,n){let r=n.size(e);if(r>t)throw new nt("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 nt("rotating JSONL segment",e,"changed-during-read",o,t);return i}function aa(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 la="<global-symbols>";function da(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:vt(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:vt(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:la,kind:"global-symbol",values:vt(n)});return pa(t)}function pa(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=sa("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),u=t.get(s);c===void 0?n.push(s):u===void 0?i.push(s):c!==u?r.push(s):o.push(s)}return{addedFiles:n,modifiedFiles:r,deletedFiles:i,changedFiles:[...n,...r,...i].sort(),unchangedFiles:o}}function Pt(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 It(e,t=Sa){let n=t.wallNow===void 0&&t.monotonicNow===void 0,r=t.monotonicNow??t.now,i=t.wallNow??t.now,o=r(),a=(u,l)=>{let d=r();return Fr(e.refreshResult,u,n?d:i(),Math.max(0,d-o),l)};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 u=[...new Set([...t.indexedPaths(s),...t.indexedPaths(c)])].sort(),l=ve(e.previousSnapshot,e.currentSnapshot),d=new Set(u),p=l.changes.length>0&&!bt(l).fullProject&&l.changes.every(I=>d.has(I.path)),g=Oe(l,p?t.dependencyGraph(s):new Map,u),f=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:l,plan:g,comparison:f,evaluation:Pt(g,f,u.length)}}catch(u){return a("oracle-error",u instanceof Error?u.message:String(u))}finally{Pr(s),Pr(c)}}function wr(e,t,n,r=Date.now()){return Fr(e,t,r,0,n)}function Er(e){let t=ua(e);return{latestPath:vr(t,"affected-shadow-latest.json"),historyPath:vr(t,"affected-shadow.jsonl")}}function dd(e,t=n=>rn(n,"affected-shadow source file")){let n=Er(e),r;try{r=JSON.parse(t(n.latestPath))}catch(h){let S=Pa(h),b=S?"telemetry-missing":va(h);return M(n,b,S?void 0:h instanceof Error?h.message:String(h))}if(W(r)&&typeof r.version=="number"&&r.version!==1)return M(n,"unsupported-record-version",`Unsupported version ${r.version}.`);if(!Ra(r))return M(n,"telemetry-malformed");if(r.status==="unavailable")return xa(r.reason)?{state:"unavailable",...n,reason:r.reason,recordedAt:r.recordedAt,refreshResult:r.refreshResult,durationMs:r.durationMs,...typeof r.error=="string"?{error:r.error}:{}}:M(n,"telemetry-malformed");if(r.status!=="evaluated")return M(n,"telemetry-malformed");let i=r.plan,o=r.comparison,a=r.evaluation;if(!W(r.manifest)||!W(i)||!W(o)||!W(a))return M(n,"telemetry-malformed");let s=i.mode,c=G(i.affectedFiles),u=G(i.reasons),l=G(o.changedFiles),d=G(a.predictedFiles),p=G(a.actualFiles),g=G(a.missingFiles),f=a.recall,m=a.affectedRatio;if(s!=="none"&&s!=="closure"&&s!=="full-project"||c===null||u===null||l===null||d===null||p===null||g===null||typeof a.passed!="boolean"||!Ir(f)||!Ir(m))return M(n,"telemetry-malformed");let I=p.length===0?1:(p.length-g.length)/p.length;return!kr(c,d)||!kr(l,p)||a.passed!==(g.length===0)||Math.abs(f-I)>Number.EPSILON||g.some(h=>!p.includes(h)||d.includes(h))?M(n,"telemetry-malformed"):{state:a.passed?"passing":"failing",...n,recordedAt:r.recordedAt,refreshResult:r.refreshResult,durationMs:r.durationMs,mode:s,recall:f,affectedRatio:m,predictedFiles:d,actualFiles:p,missingFiles:g,fallbackReasons:u}}function pd(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 Tr(e,t,n=ba){let r=Er(e);return n.appendHistory(r.historyPath,t),n.writeLatest(r.latestPath,t),r}var fa=8*1024*1024,ma=se;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 ya(e,t,n=fa){je(e,ha(t),{maxSegmentBytes:n,previousSuffix:ma})}function vt(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 Sa={now:()=>Date.now(),wallNow:()=>Date.now(),monotonicNow:R,databaseExists:e=>ca(e),openDatabase:(e,t,n)=>new L({projectRoot:e,dbPath:t,indexPath:n}),indexedPaths:e=>Te(e),dependencyGraph:e=>Fe(e),factDigests:e=>da(e)},ba={appendHistory:ya,writeLatest:(e,t)=>hn(e,t,{spacing:2,trailingNewline:!0})};function Fr(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 Pr(e){try{e?.close()}catch{}}function Ra(e){return W(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 xa(e){return e==="prior-index-unavailable"||e==="candidate-index-unavailable"||e==="oracle-error"}function Ir(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0&&e<=1}function kr(e,t){return e.length===t.length&&e.every((n,r)=>n===t[r])}function M(e,t,n){return{state:"unavailable",...e,reason:t,...n?{error:n}:{}}}function va(e){return e instanceof SyntaxError?"telemetry-malformed":"telemetry-unreadable"}function Pa(e){return e instanceof Error&&e.code==="ENOENT"}import{readdirSync as Ia}from"fs";import{isAbsolute as Ar,join as ka,resolve as wa}from"path";var Ce="@sourcegraph/scip-typescript@0.4.0",_r="scip-python-plus@0.7.5",Dr="github.com/sourcegraph/scip-go@v0.2.7",Lr="scip-dotnet@0.2.14",Ea="scip_dart@1.6.2",Ta={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:[...k.typescript],installMethods:[{label:"npm",identity:Ce,destination:"npm global prefix",prerequisite:"npm",binary:"npm",args:["install","-g",Ce]}],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:[...k.javascript],installMethods:[{label:"npm",identity:Ce,destination:"npm global prefix",prerequisite:"npm",binary:"npm",args:["install","-g",Ce]}],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:[...k.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:[...k.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:[...k.kotlin],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-java/releases"},rust:{language:oe.language,indexerBinary:oe.indexerBinary,checkCommand:`${oe.indexerBinary} --version`,indexArgs:({outputPath:e})=>({binary:oe.indexerBinary,args:["scip",".","--output",e]}),markerFiles:[...k.rust],installMethods:[],installUrl:oe.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:[...k.python],installMethods:[{label:"npm",identity:_r,destination:"npm global prefix",prerequisite:"npm",binary:"npm",args:["install","-g",_r]}],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",Ar(r)?r:wa(e,r)),{binary:n,args:i}},markerFiles:[...k.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:[...k.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:[...k.go],installMethods:[{label:"go install",identity:Dr,destination:"Go bin directory (GOBIN or GOPATH/bin)",prerequisite:"go",binary:"go",args:["install",Dr]}],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:[...k.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:[...k.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",Or(e,[".sln",".csproj"])??e,"--output",t,"--working-directory",e]}),markerFiles:[...k.csharp],installMethods:[{label:"dotnet",identity:Lr,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",Or(e,[".sln",".vbproj"])??e,"--output",t,"--working-directory",e]}),markerFiles:[...k.vb],installMethods:[{label:"dotnet",identity:Lr,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:[...k.dart],installMethods:[{label:"dart pub",identity:Ea,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})=>Ar(e)?{binary:"php",args:["-d","error_reporting=E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED",e]}:{binary:e,args:[]},defaultOutputPath:"index.scip",markerFiles:[...k.php],installMethods:[],installUrl:"https://github.com/davidrjenni/scip-php/releases"}};function jr(e){if(!(e.projectPath||e.pnpmWorkspaces)){if(e.language==="typescript")return"{}";if(e.language==="javascript")return'{"compilerOptions":{"allowJs":true}}'}}function kt(e){return Ta[e]}function Or(e,t){let n;try{n=Ia(e)}catch{return null}for(let r of t)for(let i of n)if(i.endsWith(r))return ka(e,i);return null}import{createHash as Fa}from"crypto";import{existsSync as Cr,rmSync as Mr}from"fs";import{resolve as Aa}from"path";import Br from"better-sqlite3";var _a={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}]},Da={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 Vr(e){let t=R(),n=La(e.affectedFiles);if(Oa(e.previousDbPath,e.miniDbPath,e.candidateDbPath),Mr(e.candidateDbPath,{force:!0}),!Cr(e.previousDbPath))throw new Error("previous SQLite generation is unavailable");if(!Cr(e.miniDbPath))throw new Error("incremental SQLite mini database is unavailable");Nr(e.previousDbPath,"previous SQLite generation",!1),Nr(e.miniDbPath,"incremental SQLite mini database");let r=q(e.previousDbPath,e.candidateDbPath);e.writeTelemetry&&J(e.writeTelemetry,r);let i=null;try{i=new Br(D(e.candidateDbPath),{fileMustExist:!0}),i.pragma("busy_timeout = 5000"),i.pragma("foreign_keys = ON"),i.prepare("ATTACH DATABASE ? AS incremental").run(D(e.miniDbPath)),wt(i,"main","candidate SQLite generation"),wt(i,"incremental","incremental SQLite mini database"),ja(i,n),Ca(i,n.length);let o=Et(i,"main",!0),a=N(i,"SELECT COUNT(*) AS value FROM main.documents");i.transaction(()=>{Ma(i),Na(i),$a(i),e.onStage?.("after-delete"),Ba(i),e.onStage?.("after-symbol-reconciliation"),Va(i),e.onStage?.("after-insert"),Ua(i),Wa(i,n.length,a),e.onStage?.("before-commit")}).immediate(),Ur(i,"main","candidate SQLite generation");let u=[...Ga(i)].filter(([l,d])=>o.get(l)!==d).map(([l])=>l).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{Mr(e.candidateDbPath,{force:!0})}throw new Error(`Incremental SQLite publication rejected: ${o instanceof Error?o.message:String(o)}`,{cause:o})}}function La(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 Oa(e,t,n){let r=[e,t,n].map(i=>Aa(i));if(new Set(r).size!==r.length)throw new Error("previous, mini, and candidate SQLite paths must be distinct")}function Nr(e,t,n=!0){let r=new Br(D(e),{readonly:!0,fileMustExist:!0});try{wt(r,"main",t),n&&Ur(r,"main",t)}finally{r.close()}}function wt(e,t,n){for(let[r,i]of Object.entries(_a)){let a=e.prepare(`PRAGMA ${t}.table_info('${r}')`).all().map(({name:s,type:c,notnull:u,pk:l})=>({name:s,type:c.toUpperCase(),notnull:u,pk:l}));if(JSON.stringify(a)!==JSON.stringify(i))throw new Error(`${n} schema changed for table ${r}`)}for(let[r,i]of Object.entries(Da)){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}`)}$r(e,t,"documents",["relative_path"],n),$r(e,t,"global_symbols",["symbol"],n)}function $r(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(u=>u.name);return JSON.stringify(c)===JSON.stringify(r)}))throw new Error(`${i} lost the unique ${n}(${r.join(", ")}) constraint`)}function Ur(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 ja(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 Ca(e,t){let n=N(e,"SELECT COUNT(*) AS value FROM incremental.documents"),r=N(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||r!==t||i!==void 0||o!==void 0)throw new Error("incremental SQLite mini database does not exactly match the affected document set")}function Ma(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 Na(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 $a(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 Ba(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 Va(e){let t=N(e,"SELECT COALESCE(MAX(id), 0) AS value FROM main.documents"),n=N(e,"SELECT COALESCE(MAX(id), 0) AS value FROM main.chunks"),r=N(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 Ua(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 Wa(e,t,n){let r=N(e,"SELECT COUNT(*) AS value FROM main.documents"),i=N(e,`SELECT COUNT(*) AS value
213
- FROM main.documents d
214
- JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path`);if(r!==n||i!==t)throw new Error("candidate SQLite document counts changed unexpectedly");let o=e.prepare("SELECT relative_path FROM main.documents GROUP BY relative_path HAVING COUNT(*) > 1 LIMIT 1").pluck().get(),a=e.prepare("SELECT symbol FROM main.global_symbols GROUP BY symbol HAVING COUNT(*) > 1 LIMIT 1").pluck().get();if(o!==void 0||a!==void 0)throw new Error("candidate SQLite generation contains duplicate document paths or symbols")}function Ga(e){let t=Et(e,"main",!0),n=Et(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 Et(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[l,d]of Object.entries({documents:i,chunks:o,definitions:a,mentions:s}))for(let p of d){let g=JSON.stringify([l,p]),f=c.get(p.relative_path)??[];f.push(g),c.set(p.relative_path,f)}let u=new Map;for(let[l,d]of[...c].sort(([p],[g])=>p.localeCompare(g))){let p=Fa("sha256");for(let g of d.sort())p.update(g).update(`
237
- `);u.set(l,p.digest("hex"))}return u}function N(e,t){return e.prepare(t).get().value}import qa from"better-sqlite3";var Me="idx_mentions_definitions",Ja=["symbol_id","chunk_id"];function Tt(e){let t=new qa(D(e)),n=[],r=[],i=[];try{return t.transaction(()=>{Ha(t,n),Ne(t,"idx_global_symbols_symbol")?.join("\0")==="symbol"&&Wr(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")):Ne(t,"idx_global_symbols_symbol")&&i.push("idx_global_symbols_symbol");let o=Ne(t,"idx_chunks_doc_id"),a=Wr(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 Ha(e,t){let n=Gr(e,Me);if(n){let r=n.columns.join("\0")===Ja.join("\0"),i=/\bWHERE\s+role\s*=\s*1\b/iu.test(n.sql??"");if(!r||!i||n.table!=="mentions")throw new Error(`${Me} exists with an incompatible definition`);return}e.exec(`CREATE INDEX "${Me}" ON mentions(symbol_id, chunk_id) WHERE role = 1`),t.push(Me)}function Wr(e,t){return e.prepare(`PRAGMA index_list('${t.replaceAll("'","''")}')`).all().map(n=>({name:n.name,unique:n.unique===1,columns:Ne(e,n.name)??[]}))}function Ne(e,t){return Gr(e,t)?.columns??null}function Gr(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 za}from"fs";function z(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 Jr(e){let t=e.readFingerprint(),n=Xa(e.cachePath,t);if(n)return e.onCacheHit?.(n.result),n.result;let r=await e.compute();return Ka(e.cachePath,e.readFingerprint(),r),r}function Xa(e,t){try{let n=JSON.parse(F(e,{maxBytes:Q,inputKind:"post-index augmentation cache"}));return qr(n.fingerprint)===qr(t)?{result:n.result}:null}catch{return null}}function Ka(e,t,n){za(e,`${JSON.stringify({updatedAt:new Date().toISOString(),fingerprint:t,result:n},null,2)}
238
- `)}function qr(e){return JSON.stringify(e)}import{existsSync as Hr,statSync as Ya}from"fs";import{dirname as Kr,join as Yr}from"path";var Qa="reindex-activity.jsonl",$e=se,Za=1024*1024,es=1440*60*1e3,zr=e=>_(e,"reindex activity segment");function Be(e){return Yr(Kr(e),Qa)}function ts(e){if(e.reused)return 0;let t=Ft(e.indexPath)+Ft(e.dbPath);for(let n of e.shards??[])!n.reused&&n.outputBytes!==null&&(t+=n.outputBytes);return t}function At(e,t){let n=t.lastRefresh;if(!n)return{state:"failed",reason:"reindex result has no refresh metadata"};let r=ts(t);return _t(Be(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:ss(t)})}function Qr(e,t){return _t(Be(e),{version:1,event:"run",recordedAt:t.completedAt,trigger:t.trigger,result:"failed",durationMs:t.durationMs,estimatedLogicalOutputBytes:0})}function $d(e,t,n=new Date){return _t(Be(e),{version:1,event:"suppressed",recordedAt:n.toISOString(),trigger:t,reason:"completed-index-is-fresh"})}function ns(e,t,n=Za,r){je(e,t,{maxSegmentBytes:n,previousSuffix:$e,...r?{runtime:r}:{}})}function rs(e,t=new Date,n=es,r=zr){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,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=Be(e),c=[];if(r===zr){if(!Hr(s)&&!Hr(`${s}${$e}`))return a;try{let u=br(s,{previousSuffix:$e});c=u.lines,a.ignoredPartialTailBytes=u.ignoredPartialTailBytes}catch{a.readErrors+=1,a.confidence="unavailable"}}else{let u=0;for(let l of[`${s}${$e}`,s])try{c.push(...fs(r(l))),u+=1}catch{a.readErrors+=1}u===0?a.confidence="unavailable":a.readErrors>0&&(a.confidence="partial")}for(let u of c){a.recordsRead+=1;let l=is(u);if(!l){a.invalidRecords+=1,a.confidence!=="unavailable"&&(a.confidence="partial");continue}let{record:d}=l,p=Date.parse(d.recordedAt);if(p<o||p>i){a.skippedRecords+=1;continue}if(a.invalidLanguageDetails=(a.invalidLanguageDetails??0)+l.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"&&(l.hasLanguageDetails?a.attributedRuns=(a.attributedRuns??0)+1:a.unattributedRuns=(a.unattributedRuns??0)+1);for(let[g,f]of ds(d.byLanguage)){let m=(a.byLanguage??={})[g]??=ps();m.runs+=1,m[f.result]+=1,m.producedOutputBytes+=f.producedOutputBytes,m.durationMs+=f.durationMs}d.result==="rebuilt"&&a.oldestRebuildAt===void 0&&(a.oldestRebuildAt=d.recordedAt),(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=gs(a),a}function _t(e,t){try{return ns(e,t),{state:"recorded"}}catch(n){return{state:"failed",reason:n instanceof Error?n.message:String(n)}}}function is(e){try{let t=JSON.parse(e);if(!t||typeof t!="object")return null;let n=t;if(n.version!==1||!an(n.recordedAt)||!n.trigger||!as(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"||!V(n.durationMs)||!V(n.estimatedLogicalOutputBytes)||n.estimatedWriteBytes!==void 0&&!V(n.estimatedWriteBytes)||n.reflinkedBytes!==void 0&&!V(n.reflinkedBytes)||n.fallbackCopiedBytes!==void 0&&!V(n.fallbackCopiedBytes))return null;let r=n,{byLanguage:i,...o}=r,a=cs(i);return{record:{...o,...a.byLanguage?{byLanguage:a.byLanguage}:{}},hasLanguageDetails:a.hasLanguageDetails,invalidLanguageDetails:a.invalidLanguageDetails}}catch{return null}}function Bd(e,t,n=new Date){return t.enabled?os(rs(e,n,t.windowMs),t,n.getTime()):{state:"allowed",rebuilt:0,estimatedWriteBytes:0}}function os(e,t,n){let r=e.estimatedWriteBytes??e.estimatedLogicalOutputBytes,i={rebuilt:e.rebuilt,estimatedWriteBytes:r};return t.enabled?e.confidence!==void 0&&e.confidence!=="complete"?{state:"paused",reason:"activity-evidence",until:n+t.windowMs,...i,detail:`reindex activity evidence is ${e.confidence}`}:e.rebuilt>=t.maxRebuilds?{state:"paused",reason:"rebuild-count",until:Xr(e.oldestRebuildAt,t.windowMs,n),...i,detail:`${e.rebuilt}/${t.maxRebuilds} automatic rebuild slots consumed`}:r>=t.maxEstimatedWriteBytes?{state:"paused",reason:"estimated-write-bytes",until:Xr(e.oldestWriteAt,t.windowMs,n),...i,detail:`${r}/${t.maxEstimatedWriteBytes} estimated write bytes consumed`}:{state:"allowed",...i}:{state:"allowed",...i}}function Xr(e,t,n){let r=e?Date.parse(e):Number.NaN;return Number.isFinite(r)&&r+t>n?r+t:n+t}function as(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 Ft(e){try{return Ya(e).size}catch{return 0}}function ss(e){let t={};for(let n of e.languages){let r=(e.shards??[]).filter(u=>u.language===n),i=r.find(u=>u.id===n),o=e.reused||(i?i.reused:r.length>0&&r.every(u=>u.reused)),a=Ft(Yr(Kr(e.dbPath),"language-indexes",`${n}.scip`)),s=a>0?a:i?.outputBytes??a,c=o?0:i?.durationMs??r.filter(u=>!u.reused).reduce((u,l)=>u+l.durationMs,0);t[n]={result:o?"reused":"rebuilt",outputBytes:s,producedOutputBytes:o?0:s,durationMs:c}}return t}function cs(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(!ls(i)||!us(o)){n+=1;continue}t[i]=o}let r=Object.keys(t).length>0;return{...r?{byLanguage:t}:{},hasLanguageDetails:r,invalidLanguageDetails:n}}function us(e){if(!e||typeof e!="object")return!1;let t=e;return(t.result==="rebuilt"||t.result==="reused")&&it(t.outputBytes)&&it(t.producedOutputBytes)&&V(t.durationMs)&&(t.result!=="reused"||t.producedOutputBytes===0&&t.durationMs===0)&&t.producedOutputBytes<=t.outputBytes}function ls(e){return rt.includes(e)}function ds(e){return e?rt.flatMap(t=>{let n=e[t];return n?[[t,n]]:[]}):[]}function ps(){return{runs:0,rebuilt:0,reused:0,producedOutputBytes:0,durationMs:0}}function gs(e){let t=e.invalidLanguageDetails??0,n=e.attributedRuns??0;return(e.unattributedRuns??0)===0&&t===0?"complete":n===0?"unavailable":"partial"}function fs(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 ms}from"crypto";import{existsSync as Dt,readdirSync as hs}from"fs";import{dirname as Lt,join as Ve,relative as ys,resolve as Ot,sep as Zr}from"path";function ei(e,t){let n=t.includes("."),r={};for(let o of t)r[o]=[];let i=[];for(let o of e){let a=ii(o.path,t);a?r[a].push(o):n?r["."].push(o):i.push(o)}return{files:r,shared:i}}function ti(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=ii(s,e);c&&c!==i&&a.add(c)}}return Ss(e,r)}function ni(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 jt(e){if(e===".")return"root";let t=ms("sha256").update(e).digest("hex").slice(0,8);return`${e.split("/").join("__")}-${t}`}function ri(e,t){let n=Ot(e),r={};for(let i of t)r[i]=bs(n,i);return r}function ii(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 Ss(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 bs(e,t){let n=t==="."?e:Ve(e,t),r=Rs(n),i=xs(n),o=i?vs(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 Rs(e){let t=Ve(e,"package.json");if(!Dt(t))return{name:void 0,dependencyNames:[],failed:!1};let n=Ct(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 xs(e){let t=Ve(e,"tsconfig.json");if(Dt(t))return t;let n;try{n=hs(e).filter(r=>/^tsconfig.*\.json$/.test(r))}catch{return}return n.sort((r,i)=>r.localeCompare(i)),n.length>0?Ve(e,n[0]):void 0}function vs(e,t){let n=Ct(e);if(!n.ok)return{pathsTargets:[],referencesPaths:[],failed:!0};let r=Ps(n.value,e,t),i=oi(e,n.value,t,0);return{pathsTargets:i.pathsTargets,referencesPaths:r,failed:i.failed}}function Ps(e,t,n){let r=e.references;if(!Array.isArray(r))return[];let i=Lt(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=ai(s,i,n);c&&o.add(c)}return[...o]}function oi(e,t,n,r){let i=Is(t);if(i)return{pathsTargets:ks(i,Lt(e),n),failed:!1};if(r>=5)return{pathsTargets:[],failed:!1};let o=ws(t.extends,e,n);if(!o)return{pathsTargets:[],failed:!1};let a=Ct(o);return a.ok?oi(o,a.value,n,r+1):{pathsTargets:[],failed:!0}}function Is(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 ks(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=ai(o,t,n);a&&r.add(a)}return[...r]}function ws(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=Ot(Lt(t),r);if(i.endsWith(".json")||(i=`${i}.json`),!i.split(Zr).includes("node_modules")&&at(n,i)&&Dt(i))return i}function ai(e,t,n){let r=e.replace(/\/?\*+$/,""),i=Ot(t,r===""?".":r);if(!at(n,i))return;let a=ys(n,i).split(Zr).join("/");return a===""?".":a}function Es(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 Ct(e){try{let t=F(e,{maxBytes:Q,inputKind:"TypeScript project manifest"}),n=JSON.parse(Es(t));return n&&typeof n=="object"&&!Array.isArray(n)?{ok:!0,value:n}:{ok:!1}}catch{return{ok:!1}}}import{createHash as Js}from"crypto";import{existsSync as Nt,statSync as Hs,writeFileSync as $t}from"fs";import{join as zs}from"path";import{createRequire as Ts}from"module";import{dirname as Fs,isAbsolute as Qd,relative as Zd,resolve as ep,sep as tp}from"path";var si=Ts(import.meta.url),As=1,ci="0.4.0";function Mt(){let e=_s();return e.available?{available:!0,packageVersion:e.packageVersion,typescriptVersion:e.typescriptVersion,producerIdentity:e.producerIdentity}:e}function _s(){try{let e=si.resolve("@sourcegraph/scip-typescript/package.json"),t=JSON.parse(_(e,"scip-typescript package manifest"));if(t.version!==ci)return{available:!1,reason:`unsupported scip-typescript version ${String(t.version??"unknown")}; expected ${ci}`};let n=Fs(e),r=si.resolve("typescript/package.json",{paths:[n]}),i=JSON.parse(_(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:Ds(t.version,i.version)}}catch(e){return{available:!1,reason:`scip-typescript document producer unavailable: ${e instanceof Error?e.message:String(e)}`}}}function Ds(e,t){return`scip-typescript:${e}:typescript:${t}:document-adapter:${As}`}import{createHash as Ls}from"crypto";import{dirname as Os,join as ui}from"path";var Ue=4;var js="typescript-index";function li(e){let t=ui(e,js),n=In(t);return{...n,requestDir:n.legacyRequestDir}}function di(e){try{let t=dn(ee(_(ui(Os(e),"meta.json"),"reindex metadata")));return t?Ls("sha256").update(t).digest("hex"):null}catch{return null}}import{randomUUID as Cs}from"crypto";import{existsSync as Ms}from"fs";var Ns=12e4,$s=5,We=class{projectRoot;cacheDir;baseGeneration;timeoutMs;runtime;mailboxLimits;constructor(t,n={}){this.projectRoot=nn(t.projectRoot),this.cacheDir=t.cacheDir,this.baseGeneration=t.baseGeneration,this.timeoutMs=n.timeoutMs??Gs(),this.runtime=n.runtime??qs,this.mailboxLimits=n.mailboxLimits??{}}request(t){let n=sn(this.cacheDir),r=li(this.cacheDir),i=ot(n.statePath);if(!pi(i,this.projectRoot,this.runtime))throw new Error("Compatible TypeScript index service is not running.");let o=this.runtime.now(),a=o+this.timeoutMs,s=(this.runtime.monotonicNow??R)()+this.timeoutMs,c=ft("typescript-index-v4",{baseGeneration:this.baseGeneration,request:t}),u=mt(c),l=kn(r,{mailboxVersion:gt,operationKey:c,clientId:this.runtime.randomId(),enqueuedAtMs:o,deadlineAtMs:a,protocolVersion:Ue,id:u,baseGeneration:this.baseGeneration,request:t},{nowMs:o,limits:this.mailboxLimits});for(;(this.runtime.monotonicNow??R)()<=s;){if(Ms(l.responsePath))return Bs(F(l.responsePath,{maxBytes:this.mailboxLimits.maxItemBytes??64*1024*1024,inputKind:"TypeScript index mailbox response"}),u,c,this.baseGeneration,t.producerIdentity,t.affectedFiles);let d=ot(n.statePath);if(!pi(d,this.projectRoot,this.runtime))throw new Error("TypeScript index service stopped while processing a request.");this.runtime.sleep($s)}throw new Error(`TypeScript index service timed out after ${this.timeoutMs}ms.`)}};function pi(e,t,n){let r=e?.processIdentity?n.readProcessIdentity?.(e.pid):null;return e!==null&&e.projectRoot===t&&e.typescriptIndex?.protocolVersion===Ue&&n.isProcessAlive(e.pid)&&(!e.processIdentity||r!=null&&de(e.processIdentity,r))}function Bs(e,t,n,r,i,o){let a=JSON.parse(e);if(a.protocolVersion!==Ue||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)throw new Error(typeof a.error=="string"?a.error:"TypeScript index service request failed.");let s=Vs(a.response,i),c=[...new Set(o)].sort(),u=s.fragments.map(l=>l.relativePath).sort();if(JSON.stringify(u)!==JSON.stringify(c))throw new Error("TypeScript index service omitted or added an affected document.");return s}function Vs(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(Us)||r.has(o.relativePath))throw new Error("TypeScript index service wrote an invalid fragment.");r.add(o.relativePath);let a=o.bytesBase64===null?null:Ws(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 Us(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 Ws(e){let t=Buffer.from(e,"base64");if(t.toString("base64")!==e)throw new Error("TypeScript index service wrote invalid base64.");return t}function Gs(){let e=Number(process.env.SCIP_TYPESCRIPT_INDEX_TIMEOUT_MS);return Number.isInteger(e)&&e>0?e:Ns}var qs={now:Date.now,monotonicNow:R,randomId:Cs,sleep(e){let t=new Int32Array(new SharedArrayBuffer(4));Atomics.wait(t,0,0,e)},isProcessAlive:Y,readProcessIdentity:Z};function Xs(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=ve(e.previousSnapshot,e.currentSnapshot);if(n.changes.length===0)return{eligible:!1,reason:"no changed project inputs"};if(n.changes.some(l=>l.kind!=="modified"||l.inputKind!=="source"||!yt(l.path)))return{eligible:!1,reason:"change is not a modified TypeScript source file"};let r=Oe(n,e.graph,e.projectFiles);if(r.mode!=="closure"||r.affectedFiles.length===0)return{eligible:!1,reason:r.reasons.length>0?`affected set widened: ${r.reasons.join(", ")}`:"empty affected set"};let i=Ks(r,t,e.graph);if(!i)return{eligible:!1,reason:"affected files cross or ambiguously match TypeScript projects"};let o=gi(e.currentSnapshot,e.projectFiles,e.producerIdentity),a=gi(e.previousSnapshot,e.projectFiles,e.producerIdentity);if(o!==a)return{eligible:!1,reason:"TypeScript fragment project identity changed"};let s=mi(e.previousSnapshot,e.projectFiles,e.graph,e.producerIdentity,e.projectFiles);if(!s)return{eligible:!1,reason:"prior document identity unavailable"};let c=mi(e.currentSnapshot,e.projectFiles,e.graph,e.producerIdentity,r.affectedFiles);if(!c)return{eligible:!1,reason:"next document identity unavailable"};let u=i.length===1?i[0]:void 0;return{eligible:!0,manifest:n,plan:r,projectIdentity:o,previousFragmentGeneration:fi(e.previousSnapshot,e.producerIdentity),nextFragmentGeneration:fi(e.currentSnapshot,e.producerIdentity),previousDocumentIdentities:s,nextDocumentIdentities:c,projects:i,...u?{tsconfigPath:u.tsconfigPath,projectArgument:u.projectArgument}:{}}}function Ks(e,t,n){let r=new Map;for(let o of e.affectedFiles){let a=Ys(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(u=>s.has(u)||a.some(l=>Qs(l,u,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 Ys(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)=>Ge(a)-Ge(o)||o.localeCompare(a)),i=r[0];return r[1]&&Ge(r[1])===Ge(i)?null:i}function Ge(e){return e==="."?0:e.split("/").filter(Boolean).length}function Qs(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 hi(e){let t=R();try{if(!Nt(e.previousDbPath)||!Nt(e.previousShardPath))throw new Error("prior TypeScript graph or language shard unavailable");let n=performance.now(),r=Mt();if(!r.available)throw new Error(r.reason);let i=performance.now()-n;n=performance.now();let o=new L({projectRoot:e.projectRoot,dbPath:e.previousDbPath,indexPath:e.previousIndexPath}),a,s;try{a=Te(o,{includeIgnored:!1}).filter(yt).sort(),s=Fe(o)}finally{o.close()}let c=performance.now()-n,u=Xs({projectMode:e.projectMode,workspaceProjects:e.projectMode==="workspace"?re(e.projectRoot,e.currentSnapshot.typescriptProjects):void 0,previousSnapshot:e.previousSnapshot,currentSnapshot:e.currentSnapshot,projectFiles:a,graph:s,producerIdentity:r.producerIdentity,rootTsconfigExists:Nt(zs(e.projectRoot,"tsconfig.json"))});if(!u.eligible)throw new Error(u.reason);let l=di(e.previousDbPath);if(!l)throw new Error("published TypeScript base generation unavailable");n=performance.now();let d=new We({projectRoot:e.projectRoot,cacheDir:e.cacheDir,baseGeneration:l}),p=u.projects.map(x=>d.request({kind:"emit-documents",tsconfigPath:x.tsconfigPath,projectArgument:x.projectArgument,projectIdentity:u.projectIdentity,producerIdentity:r.producerIdentity,modifiedFiles:x.modifiedFiles,affectedFiles:x.affectedFiles})),g=p.flatMap(x=>x.fragments),f=performance.now()-n,m=Hs(e.previousShardPath).size>=_n;n=performance.now();let I=m?null:B(e.previousShardPath,{inputKind:"TypeScript base SCIP shard",maxBytes:tt}),h=m?{completeIndexBytes:null,affectedIndexBytes:wn(g)}:Fn({packageVersion:r.packageVersion,baseIndexBytes:I,fragments:g}),S=performance.now()-n;n=performance.now(),m?Dn({cacheDir:e.cacheDir,previousGenerationIdentity:u.previousFragmentGeneration,nextGenerationIdentity:u.nextFragmentGeneration,producerIdentity:r.producerIdentity,projectIdentity:u.projectIdentity,baseShardCurrent:e.baseShardCurrent,fragments:g}):(En({cacheDir:e.cacheDir,packageVersion:r.packageVersion,indexBytes:I,producerIdentity:r.producerIdentity,projectIdentity:u.projectIdentity,generationIdentity:u.previousFragmentGeneration,documentIdentities:u.previousDocumentIdentities,allowUntrackedDocuments:!0}),Tn({cacheDir:e.cacheDir,previousGenerationIdentity:u.previousFragmentGeneration,producerIdentity:r.producerIdentity,projectIdentity:u.projectIdentity,generationIdentity:u.nextFragmentGeneration,fragments:g,documentIdentities:u.nextDocumentIdentities}));let b=performance.now()-n;n=performance.now(),h.completeIndexBytes&&$t(e.candidateShardPath,h.completeIndexBytes),$t(e.candidateAffectedScipPath,h.affectedIndexBytes);let P=performance.now()-n,v={scipPath:m?e.previousShardPath:e.candidateShardPath,candidateScipPath:e.candidateShardPath,affectedScipPath:e.candidateAffectedScipPath,completeScipUpdated:!m,durationMs:R()-t,cold:p.some(x=>x.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,referenceFragmentsByFile:new Map(g.map(x=>[x.relativePath,x.referenceFragments])),timings:{runtimeMs:i,graphMs:c,requestMs:f,serviceMs:p.reduce((x,X)=>x+X.durationMs,0),assemblyMs:S,fragmentStoreMs:b,writeMs:P}};return e.onStatus(`Incremental TypeScript index emitted ${v.affectedFiles.length} affected document(s) across ${u.projects.length} project(s) in ${(v.durationMs/1e3).toFixed(3)}s (${v.cold?"cold":"warm"} service; ${m?"whole SCIP deferred":"whole SCIP current"}; runtime ${i.toFixed(0)}ms, graph ${c.toFixed(0)}ms, request ${f.toFixed(0)}ms, assembly ${S.toFixed(0)}ms, fragments ${b.toFixed(0)}ms, write ${P.toFixed(0)}ms).`),v}catch(n){return e.onStatus(`Incremental TypeScript index unavailable: ${n instanceof Error?n.message:String(n)}. Falling back to the whole-project indexer.`),null}}function yi(e){let t=Mt();if(!t.available)throw new Error(t.reason);let n=Ln({cacheDir:e.cacheDir,generationIdentity:e.generationIdentity,baseIndexBytes:B(e.baseShardPath,{inputKind:"TypeScript base SCIP shard",maxBytes:tt}),packageVersion:t.packageVersion});$t(e.candidateShardPath,n)}function gi(e,t,n){let r=e.files.filter(i=>un(i.path,e.languages)!=="source").map(i=>({path:i.path,size:i.size,hash:i.hash})).sort((i,o)=>i.path.localeCompare(o.path));return Bt(JSON.stringify({version:1,producerIdentity:n,pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:[...e.typescriptProjects].sort(),projectFiles:[...t].sort(),nonSourceInputs:r}))}function fi(e,t){return Bt(JSON.stringify({version:1,producerIdentity:t,snapshot:e}))}function mi(e,t,n,r,i){let o=new Set(e.files.map(c=>c.path)),a=Zn({projectFiles:t.filter(c=>o.has(c)),snapshot:e,graph:n,engineIdentity:r}),s=new Map;for(let c of i){let u=a.identityFor(c,"typescript-scip-document-v1");if(u.key){s.set(c,u.key);continue}if(o.has(c))return null;s.set(c,Bt(JSON.stringify({version:1,producerIdentity:r,generatedDocument:c})))}return s}function Bt(e){return Js("sha256").update(e).digest("hex")}import{closeSync as Zs,existsSync as qe,fstatSync as ec,lstatSync as tc,openSync as nc,renameSync as Ut,rmSync as Je,statSync as rc,writeSync as ic}from"fs";import{cpus as oc}from"os";import{join as Wt}from"path";function ac(e,t){if(e.temporaryRootConfigContent===void 0)return null;let n=Wt(t,"tsconfig.json"),r=Buffer.from(e.temporaryRootConfigContent,"utf8"),i;try{i=nc(n,"wx",384)}catch(o){if(o.code==="EEXIST")return null;throw o}try{ic(i,r);let o=ec(i);return{path:n,content:r,device:o.dev,inode:o.ino}}finally{Zs(i)}}function sc(e){if(e)try{let t=tc(e.path);if(!t.isFile()||t.dev!==e.device||t.ino!==e.inode||t.size!==e.content.byteLength)return;let n;try{n=B(e.path,{maxBytes:e.content.byteLength,inputKind:"temporary TypeScript index configuration"})}catch{return}if(!n.equals(e.content))return;Je(e.path)}catch(t){if(t.code!=="ENOENT")throw t}}function cc(e,t,n){if(!e.defaultOutputPath)return;let r=Wt(t,e.defaultOutputPath);n!==r&&qe(r)&&Ut(r,n)}function uc(e,t,n){if(!e.defaultOutputPath)return null;let r=Wt(t,e.defaultOutputPath);if(r===n)return null;let i=`${n}.default-output-backup`;return Je(i,{force:!0}),qe(r)?(Ut(r,i),{defaultOutputPath:r,backupPath:i}):{defaultOutputPath:r,backupPath:null}}function lc(e){e&&(Je(e.defaultOutputPath,{force:!0}),e.backupPath&&qe(e.backupPath)&&Ut(e.backupPath,e.defaultOutputPath))}function dc(e,t){if(e<=1)return 1;let n=Number(process.env.CODEBASEIQ_INDEXER_CONCURRENCY??0),r=Number.isFinite(t)&&t&&t>0?t:Number.isFinite(n)&&n>0?n:Math.min(8,Math.max(1,oc().length));return Math.max(1,Math.min(e,Math.floor(r)))}async function bi(e,t,n,r,i){A(i,"Reindex cancelled by its owner.");let o=e.filter(l=>l.config.defaultOutputPath),a=e.filter(l=>!l.config.defaultOutputPath),s=[],c=dc(a.length,r),u=await sr(a,c,l=>Vt(l,t,n,i));if(c>1){let l=new Map;for(let d of u.filter(p=>p.result.skipped&&p.retryable)){let p=a.find(g=>g.id===d.result.id);p&&(n(`Retrying ${p.label} indexer serially after parallel failure...`),A(i,"Reindex cancelled by its owner."),l.set(p.id,(await Vt(p,t,n,i)).result))}s.push(...u.map(({result:d})=>l.get(d.id)??d))}else s.push(...u.map(({result:l})=>l));for(let l of o)A(i,"Reindex cancelled by its owner."),s.push((await Vt(l,t,n,i)).result);return s.sort((l,d)=>e.findIndex(p=>p.id===l.id)-e.findIndex(p=>p.id===d.id))}async function Vt(e,t,n,r){A(r,"Reindex cancelled by its owner."),n(`Indexing ${e.label} with ${e.resolvedBinary}...`),Je(e.scipPath,{force:!0});let i=uc(e.config,t,e.scipPath),o=ac(e,t),a=[e.binary,...e.args].join(" "),s=R();try{e.trustedProjectTool&&Yn(t,e.trustedProjectTool);let u=Jn(e.binary,e.args),l=await _e({command:u.binary,args:u.args,label:`${e.label} indexer`,cwd:t,env:e.env,timeoutMs:pc(),maxStdoutBytes:50*1024*1024,maxStderrBytes:50*1024*1024,signal:r});if(l.status!==0){let d=l.stderr.trim();throw new Error(`${e.resolvedBinary} exited with status ${l.status}${d?`:
243
- ${d}`:""}`)}cc(e.config,t,e.scipPath)}catch(u){if(r?.aborted)throw gn(r,"Reindex cancelled by its owner.");let l=u instanceof Error?u.message:String(u),d=`${e.resolvedBinary} indexer failed: ${l.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:gc(u)}}finally{lc(i),sc(o)}if(!qe(e.scipPath)){let u=`${e.resolvedBinary} indexer completed but did not produce ${e.scipPath}`,l=e.label===e.language?u:`${e.label}: ${u}`;return n(`Skipping ${e.label}: ${u}`),{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:l}},retryable:!1}}let c;try{c=rc(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 pc(){let e=Number(process.env.CODEBASEIQ_INDEXER_TIMEOUT_MS);return Number.isFinite(e)&&e>0?Math.floor(e):or.indexer}function gc(e){return e instanceof ar?e.kind==="spawn"&&Si(e.cause):Si(e)}function Si(e){let t=e?.code;return t==="EAGAIN"||t==="ENOMEM"||t==="EMFILE"||t==="ENFILE"||t==="ETXTBSY"}import{execFileSync as xi}from"child_process";import{homedir as Ri,platform as fc}from"os";import{delimiter as mc,join as He}from"path";function vi(e,t){let n=e.installMethods,r=Ae(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(!ie(i.prerequisite))continue;let o=hc(i);t(`Installing immutable ${i.identity} via ${i.label} into ${o}; expected executable: ${r}.`);try{xi(i.binary,i.args,{stdio:"inherit",windowsHide:!0,timeout:3e5,env:process.env,shell:fc()==="win32"});let a=ge(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 hc(e){if(e.binary==="npm")return Gt("npm",["root","-g"])??e.destination;if(e.binary==="go"){let t=Gt("go",["env","GOBIN"]);if(t)return t;let n=Gt("go",["env","GOPATH"]);if(n)return He(n.split(mc)[0],"bin")}return e.binary==="dotnet"?He(process.env.DOTNET_CLI_HOME??Ri(),".dotnet","tools"):e.binary==="dart"?He(process.env.PUB_CACHE??He(Ri(),".pub-cache"),"bin"):e.destination}function Gt(e,t){try{return xi(e,t,{stdio:["ignore","pipe","ignore"],windowsHide:!0,encoding:"utf8",timeout:1e4,killSignal:"SIGKILL",env:process.env}).trim()||null}catch{return null}}import uu from"better-sqlite3";import{existsSync as lu}from"fs";import{dirname as du,join as pu,resolve as gu}from"path";import{randomUUID as Sc}from"crypto";import{mkdtempSync as bc,rmSync as Rc,statSync as Ii}from"fs";import{tmpdir as xc}from"os";import{join as ki}from"path";import{Worker as vc}from"worker_threads";function yc(){return{"missing-source-file":0,"missing-service-script":0,"no-definition":0,"same-file-definition":0,"unindexed-definition":0}}function ce(){return{skippedReferences:0,skippedReferenceReasons:yc(),skippedReferenceSamples:[]}}function ze(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 Pc=3e5,wi=64*1024*1024,Ic={createResultDirectory:()=>bc(ki(xc(),"codebaseiq-vue-workers-")),spawn:(e,t)=>new vc(e,{workerData:t}),resultSize:e=>Ii(e).size,readResult:e=>F(e,{maxBytes:wi,inputKind:"Vue worker result"}),removeResultDirectory:e=>Rc(e,{recursive:!0,force:!0})};function Ei(e){return e.length>=8&&Fi(e.length)>1}async function Ti(e,t=Ic){let n=Fi(e.vueFiles.length),r=Mc(e.vueFiles),i=$c(r,n),o=new URL("./augment-vue-worker.js",import.meta.url),a=e.timeoutMs??jc(),s=e.maxResultBytes??Cc();Pi("timeoutMs",a),Pi("maxResultBytes",s);let c=Sc(),u=t.createResultDirectory(),l=[],d,p,g;try{for(let m=0;m<i.length;m++){let I=m,h=i[m]??[],S=h.map(v=>v.taskId),b=ki(u,`${I}.json`),P=t.spawn(o,{projectRoot:e.projectRoot,dbPath:e.dbPath,tsconfig:e.tsconfig,tasks:h,resultPath:b,runId:c,workerId:I,taskIds:S});l.push({workerId:I,taskIds:S,resultPath:b,handle:P,completion:kc(P,I)})}await wc(l,a);let f=l.sort((m,I)=>m.workerId-I.workerId).map(m=>Tc(m,c,s,t));g={occurrences:f.flatMap(m=>m.occurrences),...ce()};for(let m of f)ze(g,m)}catch(f){d=f}finally{let f=await Ec(l);if(f.length===0)try{t.removeResultDirectory(u)}catch(m){f.push(m)}if(f.length>0){let m=d===void 0?f:[d,...f];p=new AggregateError(m,`Vue worker cleanup failed: ${Oc(m[0])}`)}}if(p)throw p;if(d!==void 0)throw d;if(!g)throw new Error("Vue workers completed without producing a merged result.");return g}function kc(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 wc(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 Ec(e){return(await Promise.allSettled(e.map(async n=>n.handle.terminate()))).flatMap(n=>n.status==="rejected"?[n.reason]:[])}function Tc(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(!he(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(!Lc(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||!Fc(o.result))throw new Error(`Vue reference worker ${e.workerId} success payload is malformed`);return o.result}function Fc(e){if(!he(e)||!Array.isArray(e.occurrences)||!e.occurrences.every(Ac)||!O(e.skippedReferences)||!he(e.skippedReferenceReasons))return!1;for(let t of["missing-source-file","missing-service-script","no-definition","same-file-definition","unindexed-definition"])if(!O(e.skippedReferenceReasons[t]))return!1;return Array.isArray(e.skippedReferenceSamples)&&e.skippedReferenceSamples.every(_c)}function Ac(e){return he(e)&&typeof e.sourceFile=="string"&&O(e.sourceLine)&&O(e.sourceStartChar)&&O(e.sourceEndChar)&&typeof e.sourceToken=="string"&&typeof e.definitionFile=="string"&&O(e.symbolId)}function _c(e){return he(e)&&typeof e.sourceFile=="string"&&O(e.sourceLine)&&O(e.sourceStartChar)&&O(e.sourceEndChar)&&typeof e.token=="string"&&Dc(e.reason)}function Dc(e){return e==="missing-source-file"||e==="missing-service-script"||e==="no-definition"||e==="same-file-definition"||e==="unindexed-definition"}function O(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>=0}function he(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Lc(e,t){return Array.isArray(e)&&e.length===t.length&&e.every((n,r)=>typeof n=="string"&&n===t[r])}function Pi(e,t){if(!Number.isSafeInteger(t)||t<=0)throw new TypeError(`${e} must be a positive safe integer.`)}function Oc(e){return e instanceof Error?e.message:String(e)}function Fi(e){let t=Number(process.env.CODEBASEIQ_AUGMENT_VUE_WORKERS??0),n=Number.isFinite(t)&&t>0?t:1;return Math.max(1,Math.min(e,n))}function jc(){let e=Number(process.env.CODEBASEIQ_AUGMENT_VUE_WORKER_TIMEOUT_MS??0);return Number.isFinite(e)&&e>0?e:Pc}function Cc(){let e=Number(process.env.CODEBASEIQ_AUGMENT_VUE_WORKER_RESULT_MAX_BYTES??0);return Number.isSafeInteger(e)&&e>0?e:wi}function Mc(e){let t=Nc(),n=[];for(let r of e){let i=Ai(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 Nc(){return Number.POSITIVE_INFINITY}function $c(e,t){let n=Array.from({length:t},()=>({tasks:[],weight:0})),r=e.map(i=>({task:i,weight:Bc(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 Bc(e){return Number.isFinite(e.endOffset)?Math.max(1,e.endOffset-e.startOffset):Math.max(1,Ai(e.fileName)-e.startOffset)}function Ai(e){try{return Ii(e).size}catch{return 1}}import{createRequire as Vc}from"module";import{existsSync as Uc}from"fs";import{dirname as _i,extname as Wc,join as Di,relative as Gc,resolve as qc}from"path";import{pathToFileURL as Jc}from"url";function Hc(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 Li(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=>qc(t,r.relativePath))}function Oi(e,t){let{vueCore:n,ts:r,volarTs:i}=zc(e),{parsed:o,vueOptions:a}=Xc(n,r,t),s=_i(t),c=n.createVueLanguagePlugin(r,o.options,a,g=>g),u=Kc(n,r,c),l=Yc(s,o),{languageServiceHost:d}=i.createLanguageServiceHost(r,r.sys,u,g=>g,l),p=r.createLanguageService(d);return{ts:r,language:u,languageService:p,fileNames:o.fileNames,configDir:s}}function zc(e){let t=Vc(Jc(Di(e,"package.json")).href);return{vueCore:qt(t,"@vue/language-core",e),ts:qt(t,"typescript",e),volarTs:qt(t,"@volar/typescript",e)}}function Xc(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,_i(n),void 0,n,void 0,e.getAllExtensions(o).map(a=>({extension:a.slice(1),isMixedContent:!0,scriptKind:t.ScriptKind.Deferred}))),vueOptions:o}}function Kc(e,t,n){let r={},i=e.createLanguage([n],new Map,o=>{if(!Uc(o))return;let a=F(o,{maxBytes:et,inputKind:"Vue language-service source file"});r.current?.scripts.set(o,t.ScriptSnapshot.fromString(a),n.getLanguageId(o)??ru(o))});return r.current=i,i}function Yc(e,t){return{getCurrentDirectory:()=>e,getCompilationSettings:()=>t.options,getScriptFileNames:()=>t.fileNames,getProjectReferences:()=>t.projectReferences,getProjectVersion:()=>"0"}}function qt(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 ji(e,t,n){let r=Qc(e);return i=>{if(!i.name)return null;let o=j(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 u=c.starts.find(d=>d.line===s.line&&d.displayName===i.name);if(u)return u.symbolId;let l=c.containingByLine.get(s.line);return l&&l.displayName===i.name?l.symbolId:Zc(c.starts,s.line,2,i.name)}}function Qc(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 Zc(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 u=Math.abs(c.line-t);u>n||(!a||u<a.distance)&&(a={distance:u,symbolId:c.symbolId})}return a?.symbolId??null}function Ci(e,t,n){let r=au(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 u of n){let l=j(t,u),d=qi(r.name,r.version,l);o.run(d,"default",7,`Vue component|${l}`);let p=su(i,r,t,u);p&&(a++,s.set(u,p))}})(),{get(u){return s.get(u)??null},syntheticSymbols:a}}function Mi(e,t,n,r,i){return e.transaction(()=>(Hc(e),eu(e,t,n,r),tu(e,i)))()}function eu(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 u=j(t,s),l=i.get(u);if(!l)continue;let d=o.run(l.id,-1,0,0);a.run(Number(d.lastInsertRowid),c)}}function Ni(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(Jt(s,e.textSpan.start)!==null)return n.get(e.fileName)}return e.fileName.startsWith(i)?n.get(e.fileName):null}return t(e)}function $i(e){let t=new Set,n=[];for(let r of e){let i=Bi(r);t.has(i)||(t.add(i),n.push(r))}return n}function Bi(e){return[e.sourceFile,e.sourceLine,e.sourceStartChar,e.sourceEndChar,e.symbolId].join(":")}function tu(e,t){let n=ou(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 u=Bi(c);if(o.has(u))continue;o.add(u);let l=n.get(c.sourceFile);if(!l)continue;let d=r.run(l,s++,c.sourceLine,c.sourceLine),p=i.run(Number(d.lastInsertRowid),c.symbolId);a+=Number(p.changes)}return a}function*Vi(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 Ui(e,t){for(let[n]of e.toGeneratedLocation(t,r=>!!r.navigation))return n;return null}function Jt(e,t){let n=e;for(let[r]of n.toSourceLocation(t,i=>!!i.navigation))return r;return null}function nu(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 Wi(e,t){return j(e,t).startsWith("node_modules/")}function j(e,t){return Gc(e,t).replaceAll("\\","/")}function ru(e){switch(Wc(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 Gi(){let e=new Map;return{get(t){if(e.has(t))return e.get(t)??null;try{let n=F(t,{maxBytes:et,inputKind:"Vue source file"}),r={text:n,lineStarts:iu(n)};return e.set(t,r),r}catch{return e.set(t,null),null}},positionAt:nu}}function iu(e){let t=[0];for(let n=0;n<e.length;n++)e.charCodeAt(n)===10&&t.push(n+1);return t}function ou(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 au(e){try{let t=JSON.parse(F(Di(e,"package.json"),{maxBytes:Q,inputKind:"project package manifest"}));return{name:t.name??"workspace",version:t.version??"0.0.0"}}catch{return{name:"workspace",version:"0.0.0"}}}function su(e,t,n,r){let i=j(n,r),o=qi(t.name,t.version,i);return e.get(o)?.id??null}function qi(e,t,n){let r=n.split("/").map(i=>`\`${i.replaceAll("`","")}\``).join("/");return`scip-vue npm ${e} ${t} ${r}/default.`}async function fu(e){return z(H(),{projectRoot:e.projectRoot,dbPath:e.dbPath}),mu(e)}async function mu(e){let t=gu(e.projectRoot,e.tsconfig);if(!lu(t))throw new Error(`Vue tsconfig not found at ${t}`);let n=new uu(D(e.dbPath));try{let r=Li(n,e.projectRoot),i=pu(du(e.dbPath),"augment-vue-meta.json");return await Jr({cachePath:i,readFingerprint:()=>bu(n,e.projectRoot,e.tsconfig),compute:()=>hu({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 hu(e){let t=Ci(e.db,e.projectRoot,e.vueFiles),n=Ei(e.vueFiles)?await Ti({projectRoot:e.projectRoot,dbPath:e.dbPath,tsconfig:e.tsconfig,vueFiles:e.vueFiles}):Su(e,t);return yu(e,t,n)}function yu(e,t,n){let r=$i(n.occurrences),i=Mi(e.db,e.projectRoot,e.vueFiles,t,r),o={vueFiles:e.vueFiles.length,resolvedReferences:r.length,resolvedReferenceSamples:Tu(e.db,r,20),insertedMentions:i,skippedReferences:n.skippedReferences,skippedReferenceReasons:n.skippedReferenceReasons,skippedReferenceSamples:Eu(n.skippedReferenceSamples,20),syntheticSymbols:t.syntheticSymbols};return e.onStatus?.(`Resolved ${o.resolvedReferences} Vue references with Volar; inserted ${o.insertedMentions} mentions.`),o}function Su(e,t){let n=Ru({db:e.db,projectRoot:e.projectRoot,configPath:e.configPath,vueSymbolLookup:t});return xu({...n,vueFiles:n.context.fileNames.filter(r=>r.endsWith(".vue"))})}function bu(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:ke(t),db:r}}function Ru(e){let t=Gi();return{projectRoot:e.projectRoot,context:Oi(e.projectRoot,e.configPath),symbolLookup:ji(e.db,e.projectRoot,t),vueSymbolLookup:e.vueSymbolLookup,sourceReader:t}}function xu(e){let t=[],n=ce(),r=e.tasks??e.vueFiles.map(i=>({fileName:i,startOffset:0,endOffset:Number.POSITIVE_INFINITY,countFileSkip:!0}));for(let i of r){let o=vu(e,i);t.push(...o.occurrences),ze(n,o)}return{occurrences:t,...n}}function vu(e,t){let n=e.sourceReader.get(t.fileName);if(!n)return Ji(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 Ji(e.projectRoot,t,"missing-service-script");let o=e.context.language.maps.get(i,r),a=j(e.projectRoot,t.fileName),s=[...Vi(n.text)],c={tokens:s.filter(u=>u.start>=t.startOffset&&u.start<t.endOffset),tokenByStart:new Map(s.map(u=>[u.start,u])),tokenTextCounts:Au(s),processedStarts:new Set};return Pu({...e,fileName:t.fileName,sourceInfo:n,sourceFile:a,map:o,tokenContext:c})}function Pu(e){let t=[],n=ce();for(let r of e.tokenContext.tokens){if(e.tokenContext.processedStarts.has(r.start)||Iu(e.sourceInfo.text,r.start))continue;let i=Ui(e.map,r.start);if(i===null)continue;let a=(e.context.languageService.getDefinitionAtPosition(e.fileName,i+1)??[]).find(l=>!Wi(e.projectRoot,l.fileName));if(!a){Ht(n,e.sourceReader,e.sourceInfo,e.sourceFile,r,"no-definition");continue}let s=j(e.projectRoot,a.fileName),c=ku(e.sourceFile,r.text,s);if(c){Ht(n,e.sourceReader,e.sourceInfo,e.sourceFile,r,c);continue}let u=Ni(a,e.symbolLookup,e.vueSymbolLookup,e.context,e.projectRoot);if(u===null){Ht(n,e.sourceReader,e.sourceInfo,e.sourceFile,r,"unindexed-definition");continue}Hi(t,e.sourceReader,e.sourceInfo,e.sourceFile,r,s,u),e.tokenContext.processedStarts.add(r.start),Fu(t,e,r,i,s,u)}return{occurrences:t,...n}}function Iu(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 ku(e,t,n){return n===e?"same-file-definition":n.endsWith(".vue")&&t!==n.split("/").at(-1)?.replace(/\.vue$/,"")?"unindexed-definition":null}function Ji(e,t,n){let r=ce();return t.countFileSkip&&(r.skippedReferences=1,r.skippedReferenceReasons[n]=1,r.skippedReferenceSamples.push({sourceFile:j(e,t.fileName),sourceLine:0,sourceStartChar:0,sourceEndChar:0,token:"",reason:n})),{occurrences:[],...r}}function Ht(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 zt(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 wu(e,t){let n=zt(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=zt(e.filter(o=>!r.has(`${o.sourceFile}:${o.sourceLine}:${o.sourceStartChar}:${o.sourceEndChar}:${o.symbolId}`)),t-n.length);return[...n,...i]}function Eu(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(...zt(e.filter(c=>c.reason===o),s))}return r.slice(0,t)}function Tu(e,t,n){let r=e.prepare("SELECT symbol FROM global_symbols WHERE id = ?");return wu(t,n).map(({symbolId:i,...o})=>({...o,definitionSymbol:r.get(i)?.symbol??`symbol-id:${i}`}))}function Fu(e,t,n,r,i,o){if(!((t.tokenContext.tokenTextCounts.get(n.text)??0)<=1))for(let a of _u(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&&(Hi(e,t.sourceReader,t.sourceInfo,t.sourceFile,s,i,o),t.tokenContext.processedStarts.add(a))}}function Hi(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 Au(e){let t=new Map;for(let n of e)t.set(n.text,(t.get(n.text)??0)+1);return t}function _u(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 u of c.highlightSpans){let l=Du(r,u.textSpan.start,o,i.text);l!==null&&s.push(l)}return s}function Du(e,t,n,r){let i=n.get(t);if(i?.text===r)return i.start;let o=Jt(e,t);if(o===null)return null;let a=n.get(o);return a?.text===r?a.start:null}async function io(e){let{projectRoot:t,maxHeapMb:n=8192,onStatus:r=console.log}=e,i=e.skipAutoInstall===!0||e.installMissing!==!0,o=$u(e),a=Date.now(),s=R();Ke(y(o.outputScip),{recursive:!0}),Ke(y(o.outputDb),{recursive:!0});let c=e.languages??dt(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 u=Ie("reindex.fingerprint",()=>xn(t,c,{pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:e.typescriptProjects,clojureConfigPath:e.clojureConfigPath}),{languages:c.length}),l,d;if(e.skipIfUnchanged!==!1&&!Nn(t,o.outputDb)&&zi(o.outputScip)===zi(w(y(o.outputDb),"index.scip"))){let h=Re(t);if(l=h?.clean?we(h,u):void 0,h&&!h.clean&&!Nu(o)){let S=$n(h,c,{pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:e.typescriptProjects,clojureConfigPath:e.clojureConfigPath});if(S)try{Ee({snapshot:S.snapshot,manifest:S.manifest,targetCacheDir:y(o.outputDb),targetProjectRoot:t,persistLease:!1}),Wn(S.snapshot,y(o.outputDb)),r(`Forked shared baseline ${S.snapshot.generationId.slice(0,12)} for dirty worktree reindex`)}catch(b){r(`Shared baseline fork failed; continuing locally: ${$(b)}`)}}else if(l){let S=ht(l);if(S){if(!Mu(o,u))try{Ee({snapshot:l,manifest:S,targetCacheDir:y(o.outputDb),targetProjectRoot:t}),r(`Attached shared generation ${l.generationId.slice(0,12)}`)}catch(b){r(`Shared generation attach failed; continuing locally: ${$(b)}`)}}else{let b=await Vn(l);if(b.kind==="owner")d=b.release;else if(b.kind==="generation-ready"){let P=ht(l);if(P)try{Ee({snapshot:l,manifest:P,targetCacheDir:y(o.outputDb),targetProjectRoot:t,action:"waited"}),r(`Attached shared generation ${l.generationId.slice(0,12)} after waiting`)}catch(v){r(`Shared generation attach failed after waiting; continuing locally: ${$(v)}`)}}else r("Shared generation build lock timed out; continuing with an isolated local reindex")}}}let g=mn(w(y(o.outputDb),"cache-lifecycle.lock"),{waitMs:3e4});if(!g)throw d?.(),new Error(`Could not acquire codebaseiq cache lifecycle lock for ${y(o.outputDb)}.`);let f;try{f=await ne("reindex.lock",()=>pl(w(y(o.outputDb),"index.lock"),{projectRoot:t,trigger:e.trigger,onStatus:r}),{languages:c.length})}catch(h){throw g.release(),d?.(),h}let m=null,I=fr();try{Pn(o.outputDb,o.outputScip,o.metaPath);let h=Wu(y(o.outputDb));h.removed>0&&r(`Removed ${h.removed} abandoned reindex workspace(s)`);for(let K of h.errors)r(`Could not remove abandoned reindex workspace: ${K}`);let S=null,b=Ie("reindex.reuse-check",()=>(S=Bu({opts:e,paths:o,languages:c,fingerprint:u,start:a,monotonicStart:s,onStatus:r}),S),()=>({languages:c.length,reused:S!==null}));if(b){Xi({snapshot:l,paths:o,projectRoot:t,fingerprint:u,onStatus:r});let K=At(o.outputDb,b);return K.state==="failed"&&r(`Warning: reindex succeeded, but activity telemetry was not recorded: ${K.reason}`),st(t,y(o.outputDb)),b}await ne("reindex.scip-cli-ready",()=>il(i,r));let P=Uu(o);m=P.runDir;let v,x=await ne("reindex.fresh",async()=>(v=await Gu({opts:e,languages:c,projectRoot:t,paths:o,tempPaths:P,fingerprint:u,start:a,monotonicStart:s,maxHeapMb:n,skipAutoInstall:i,onStatus:r,writeTelemetry:I}),v),()=>({languages:c.length,reused:v?.reused,skipped:v?.skipped.length}));Xi({snapshot:l,paths:o,projectRoot:t,fingerprint:u,onStatus:r});let X=At(o.outputDb,x);return X.state==="failed"&&r(`Warning: reindex succeeded, but activity telemetry was not recorded: ${X.reason}`),st(t,y(o.outputDb)),x}catch(h){let S=Ze({trigger:e.trigger,result:"failed",start:a,monotonicStart:s,error:h instanceof Error?h.message:String(h)});So(o.metaPath,S);let b=Qr(o.outputDb,S);throw b.state==="failed"&&r(`Warning: failed reindex activity telemetry was not recorded: ${b.reason}`),h}finally{if(m){let h=m;try{te(()=>ue(h,{recursive:!0,force:!0}))}catch(S){r(`Warning: temporary reindex workspace was left behind: ${$(S)}`)}}f(),g.release(),d?.()}}function Xi(e){if(e.snapshot)try{let t=Re(e.projectRoot),n=t?we(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=Bn({snapshot:e.snapshot,sourceCacheDir:y(e.paths.outputDb),sourceProjectRoot:e.projectRoot,sourceStillValid:()=>{let i=Re(e.projectRoot);return(i?we(i,e.fingerprint):void 0)?.generationId===e.snapshot?.generationId}});Un(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: ${$(t)}`)}}function Mu(e,t){if(!E(e.outputScip)||!E(e.outputDb)||!yo(e.metaPath,t))return!1;let n=U(e.outputDb,e.metaPath);return n.state!=="invalid"&&n.state!=="drifted"}function Nu(e){if(!E(e.outputScip)||!E(e.outputDb)||!le(e.metaPath))return!1;let t=U(e.outputDb,e.metaPath);return t.state!=="invalid"&&t.state!=="drifted"}function $(e){return e instanceof Error?e.message:String(e)}function Yt(e,t,n,r,i,o){try{z(hr({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 $u(e){let t=e.outputScip??w(e.projectRoot,"index.scip"),n=e.outputDb??w(e.projectRoot,"index.db");return{outputScip:t,outputDb:n,metaPath:w(y(n),"meta.json")}}function Bu(e){let t=U(e.paths.outputDb,e.paths.metaPath);if(e.opts.skipIfUnchanged===!1||!E(e.paths.outputScip)||!E(e.paths.outputDb)||!yo(e.paths.metaPath,e.fingerprint)||t.state==="invalid"||t.state==="drifted")return null;z(H(),{projectRoot:e.opts.projectRoot,dbPath:e.paths.outputDb,onStatus:e.onStatus}),Yt(e.opts.projectRoot,e.paths.outputDb,e.paths.outputScip,e.onStatus,!0),U(e.paths.outputDb,e.paths.metaPath).state==="drifted"&&(pt(e.paths.outputDb,e.paths.metaPath),e.onStatus("Published refreshed SQLite generation after post-index augmentation"));let n=R()-e.monotonicStart,r=Ze({trigger:e.opts.trigger,result:"reused",start:e.start,monotonicStart:e.monotonicStart,languages:e.languages,skipped:[]});return So(e.paths.metaPath,r),e.onStatus(`Index unchanged; reused existing SQLite index in ${(n/1e3).toFixed(1)}s`),{languages:e.languages,indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:n,reused:!0,skipped:[],lastRefresh:r,shards:Vu(e.paths,e.opts.projectRoot,e.languages,e.opts)}}function Vu(e,t,n,r){let i=mo(t,n,r);return n.map(o=>({id:o,language:o,reused:!0,fingerprint:ye(i[o]),outputBytes:Se(Zt(e.outputDb,o)),durationMs:0}))}function Uu(e){let t=cn(w(y(e.outputDb),"reindex-"));return{runDir:t,tempOutputScip:w(t,Xe(e.outputScip)),tempOutputDb:w(t,Xe(e.outputDb)),tempMetaPath:w(t,Xe(e.metaPath))}}function Wu(e){let t=[],n;try{n=no(e,{withFileTypes:!0})}catch(i){return{removed:0,errors:[$(i)]}}let r=0;for(let i of n)if(!(!i.name.startsWith("reindex-")||!i.isDirectory()))try{ue(w(e,i.name),{recursive:!0,force:!0}),r+=1}catch(o){t.push(`${i.name}: ${$(o)}`)}return{removed:r,errors:t}}async function Gu(e){let t={...process.env,NODE_OPTIONS:`--max-old-space-size=${e.maxHeapMb}`},n,r=await ne("reindex.language-indexers",async()=>(n=await Ju(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:u,incrementalTypeScript:l}=r;if(a.length>0&&e.onStatus(`Reused ${a.length} cached language shard(s): ${a.join(", ")}`),qu({run:e,indexedOutputs:i,skippedLanguages:o,reusedLanguages:a})){let g=Ie("reindex.publish",()=>tl(e,i,o,a,s,u),{mode:"metadata-only",languages:i.length,reused:a.length}),f=g.durationMs;return e.onStatus(`All language shards unchanged; reused existing SQLite index in ${(f/1e3).toFixed(1)}s`),{languages:i.map(m=>m.language),indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:f,reused:!0,skipped:o,lastRefresh:g,shards:c,writeTelemetry:e.writeTelemetry}}let d=await ne("reindex.publish",()=>el(e,t,i,o,a,s,u,l),{mode:l?"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(g=>g.language),indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:p,reused:!1,skipped:o,lastRefresh:d,shards:c,writeTelemetry:e.writeTelemetry}}function qu(e){if(e.run.opts.skipIfUnchanged===!1||e.skippedLanguages.length>0||!E(e.run.paths.outputScip)||!E(e.run.paths.outputDb))return!1;let t=U(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 Ju(e,t){let n=Yu({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}),r=[],i=new Set;for(let[T,tn]of n)tn.reused&&(r.push({language:T,scipPath:tn.scipPath}),i.add(T));for(let T of i)e.onStatus(`Reusing cached ${T} SCIP shard (language inputs unchanged).`);let o=n.get("typescript"),a=U(e.paths.outputDb,e.paths.metaPath),s=le(e.paths.metaPath),c=a.state==="legacy"||a.state==="current",u=s?.scipCompanion!=="deferred"&&(a.state!=="current"||a.generation.publication?.scipCompanion!=="deferred"),l=o&&!o.reused&&c?hi({projectRoot:e.projectRoot,cacheDir:y(e.paths.outputDb),previousDbPath:e.paths.outputDb,previousIndexPath:e.paths.outputScip,previousShardPath:o.scipPath,candidateShardPath:be(e.tempPaths.tempOutputScip,"typescript-incremental",0),candidateAffectedScipPath:be(e.tempPaths.tempOutputScip,"typescript-affected",0),baseShardCurrent:u,previousSnapshot:Qt(e.paths.metaPath),currentSnapshot:e.fingerprint,projectMode:e.opts.typescriptProjectMode,onStatus:e.onStatus}):null,d=new Set(l?["typescript"]:[]),p=l?void 0:Hu(e,n),{preparedRuns:g,skippedLanguages:f,languageOutputScipPaths:m}=ol({languages:e.languages.filter(T=>!i.has(T)&&!d.has(T)),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:p?.allProjects,clojureConfigPath:e.opts.clojureConfigPath,onStatus:e.onStatus}),I=p?g.filter(T=>T.language!=="typescript"||p.missedProjectIds.has(T.id)):g,h=await bi(I,e.projectRoot,e.onStatus,e.opts.indexerConcurrency,e.opts.signal),S=[];if(p){Xu(e.paths.outputDb,h,e.writeTelemetry);let T=m.typescript??e.tempPaths.tempOutputScip;S=Ku({outputDb:e.paths.outputDb,tempOutputScip:e.tempPaths.tempOutputScip,outputScipPath:T,reusedProjects:p.reusedProjects,writeTelemetry:e.writeTelemetry})}let b=[...h,...S],{indexedOutputs:P}=sl(b,f),v=l?[{language:"typescript",scipPath:l.scipPath}]:[],x=[...r,...v,...P];cl(x,f,e.languages,e.opts.allowPartial,e.onStatus);let X=l?[{id:"typescript",language:"typescript",label:"typescript (incremental documents)",scipPath:l.scipPath,outputScipPath:l.scipPath,durationMs:l.durationMs,command:"watch-service:typescript-index",outputBytes:Se(l.scipPath)??void 0}]:[],K=Qu(n,[...h,...X],p?{outputDb:e.paths.outputDb,classification:p.classification}:void 0);return{indexedOutputs:x,skippedLanguages:f,reusedLanguages:[...i],languageFingerprints:Zu(n,e.languages),shards:K,typescriptProjectShardContext:p?{projects:p.allProjects,fingerprints:p.fingerprints}:void 0,incrementalTypeScript:l??void 0}}function Hu(e,t){let n=t.get("typescript");if(!n||n.reused||e.opts.typescriptProjectMode!=="workspace")return;let r=re(e.projectRoot,e.opts.typescriptProjects);if(r.length===0)return;let i=ri(e.projectRoot,r),o=ei(n.fingerprint.files,r),a=ti(r,i),s=ni(r,o,a),c=le(e.paths.metaPath),l=zu(c,s,f=>E(Qe(e.paths.outputDb,f))),d=[...l.entries()].filter(([,f])=>f.reused).map(([f])=>f),p=new Set(d),g=new Set(r.filter(f=>!p.has(f)).map(f=>`typescript:${f}`));return{allProjects:r,fingerprints:s,classification:l,reusedProjects:d,missedProjectIds:g}}function zu(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===pe&&ut(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(C(a)!==C(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 Xu(e,t,n){for(let r of t){if(r.skipped||!r.id.startsWith("typescript:"))continue;let i=r.id.slice(11),o=Qe(e,i);Ke(y(o),{recursive:!0}),J(n,q(r.scipPath,o))}}function Ku(e){return e.reusedProjects.map((t,n)=>{let r=Qe(e.outputDb,t),i=be(e.tempOutputScip,"typescript-project-cached",n);return J(e.writeTelemetry,q(r,i)),{id:`typescript:${t}`,language:"typescript",label:`typescript (${t})`,scipPath:i,outputScipPath:e.outputScipPath,durationMs:0,command:"cached",outputBytes:Se(i)??void 0}})}function Yu(e){let t=le(e.paths.metaPath),n=mo(e.projectRoot,e.languages,e),r=new Map;for(let i of e.languages){let o=Zt(e.paths.outputDb,i),a=n[i];if(!t){r.set(i,{reused:!1,reason:"no reindex metadata found",fingerprint:a,scipPath:o});continue}if(t.version!==pe){r.set(i,{reused:!1,reason:`metadata version ${String(t.version??"unknown")} predates per-language shard caching`,fingerprint:a,scipPath:o});continue}if(i==="typescript"&&t.scipCompanion==="deferred"){r.set(i,{reused:!1,reason:"whole TypeScript SCIP companion is deferred behind changed-document overlays",fingerprint:a,scipPath:o});continue}if(!ut(t).languageShardReuse||!t.languageFingerprints){r.set(i,{reused:!1,reason:"no per-language fingerprints recorded in metadata",fingerprint:a,scipPath:o});continue}let s=t.languageFingerprints[i];if(!s){r.set(i,{reused:!1,reason:"no cached fingerprint for this language",fingerprint:a,scipPath:o});continue}if(!E(o)){r.set(i,{reused:!1,reason:"cached shard file missing on disk",fingerprint:a,scipPath:o});continue}if(C(s)!==C(a)){r.set(i,{reused:!1,reason:"language inputs changed since last index",fingerprint:a,scipPath:o});continue}r.set(i,{reused:!0,fingerprint:a,scipPath:o})}return r}function Qu(e,t,n){let r=[];for(let[i,o]of e)o.reused&&r.push({id:i,language:i,reused:!0,fingerprint:ye(o.fingerprint),outputBytes:Se(o.scipPath),durationMs:0});for(let i of t){let o=e.get(i.language),a=n&&i.id.startsWith("typescript:")?i.id.slice(11):null,s=a?n.classification.get(a):void 0;r.push({id:i.id,language:i.language,reused:!1,missReason:s?.reason??o?.reason??i.skipped?.reason,fingerprint:s?ye(s.fingerprint):o?ye(o.fingerprint):"unknown",outputBytes:i.outputBytes??null,durationMs:i.durationMs,command:i.command})}if(n)for(let[i,o]of n.classification)o.reused&&r.push({id:`typescript:${i}`,language:"typescript",reused:!0,fingerprint:ye(o.fingerprint),outputBytes:Se(Qe(n.outputDb,i)),durationMs:0});return r}function ye(e){return Lu("sha256").update(C(e)).digest("hex").slice(0,16)}function Se(e){try{return Ou(e).size}catch{return null}}function Zu(e,t){let n={};for(let r of t){let i=e.get(r);i&&(n[r]=i.fingerprint)}return n}async function el(e,t,n,r,i,o,a,s){A(e.opts.signal,"Reindex cancelled by its owner.");let c=!s||s.completeScipUpdated,u=!1;c&&(Ki(e.paths.outputDb,n,e.writeTelemetry),u=Yi(n,e.tempPaths.tempOutputScip,e.onStatus));let l=await ul({run:e,env:t,indexedOutputs:n,skippedLanguages:r,reusedLanguages:i,incrementalTypeScript:s,completeScipAvailable:c,completeScipSanitized:u,materializeFullFallback:async()=>{if(A(e.opts.signal,"Reindex cancelled by its owner."),!s||s.completeScipUpdated)return u;e.onStatus("Materializing the deferred whole TypeScript SCIP companion for full conversion..."),yi({cacheDir:y(e.paths.outputDb),generationIdentity:s.nextFragmentGeneration,baseShardPath:s.scipPath,candidateShardPath:s.candidateScipPath});let P=n.map(v=>v.language==="typescript"?{language:v.language,scipPath:s.candidateScipPath}:v);return Ki(e.paths.outputDb,P,e.writeTelemetry),u=Yi(P,e.tempPaths.tempOutputScip,e.onStatus),u}});A(e.opts.signal,"Reindex cancelled by its owner."),z(H(),{projectRoot:e.projectRoot,dbPath:e.tempPaths.tempOutputDb,onStatus:e.onStatus}),Yt(e.projectRoot,e.tempPaths.tempOutputDb,e.tempPaths.tempOutputScip,e.onStatus,!1,s?.affectedFiles);let d=Tt(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(", ")}`),l.mode==="incremental"&&s){let P=null,v=null;try{P=new L({projectRoot:e.projectRoot,dbPath:e.tempPaths.tempOutputDb,indexPath:e.tempPaths.tempOutputScip}),v=new L({projectRoot:e.projectRoot,dbPath:e.paths.outputDb,indexPath:e.paths.outputScip});let x=er(P,e.fingerprint,s.referenceFragmentsByFile,v);e.onStatus(`Cached exact TypeScript reference fragments for ${x} affected document(s).`)}catch(x){e.onStatus(`Exact TypeScript reference fragment prefill unavailable: ${x instanceof Error?x.message:String(x)}.`)}finally{P?.close(),v?.close()}}let p=Qt(e.paths.metaPath),g=l.mode==="incremental"&&s?dl(s,l.changedDocumentPaths):It({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"}),f=Ze({trigger:e.opts.trigger,result:"rebuilt",start:e.start,monotonicStart:e.monotonicStart,languages:n.map(P=>P.language),skipped:[...r]}),m=l.mode==="incremental"&&l.scipCompanion==="deferred",I={...o};m&&delete I.typescript;let{metadata:h,pruneProjects:S}=ao({run:e,indexedOutputs:n,skippedLanguages:r,reusedLanguages:i,languageFingerprints:I,typescriptProjectShardContext:a,lastRefresh:f});h.scipCompanion=m?"deferred":"current",so(e.paths.outputDb,S),en(e.tempPaths.tempMetaPath,h);let b=vn({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:l.mode==="incremental"&&l.scipCompanion==="deferred",publication:l.mode==="incremental"?{mode:"incremental",validation:"passed",converterDurationMs:l.converterDurationMs,affectedDocumentCount:s?.affectedFiles.length,changedDocumentCount:l.changedDocumentPaths.length,producerDurationMs:s?.timings.serviceMs,materializationDurationMs:s?.durationMs,patchDurationMs:l.patchDurationMs,scipCompanion:l.scipCompanion,...l.scipCompanion==="deferred"&&s?{typescriptOverlayGeneration:s.nextFragmentGeneration}:{}}:{mode:"full",validation:"passed",converterDurationMs:l.converterDurationMs,scipCompanion:"current",...l.fallbackReason?{fallbackReason:l.fallbackReason}:{}}});return b.achievedDurability==="file-flushed"&&e.onStatus(`Published local generation ${b.currentGeneration.slice(0,12)} (file-flushed; directory sync unsupported)`),On(y(e.paths.outputDb),l.mode==="incremental"&&l.scipCompanion==="deferred"?[s.nextFragmentGeneration]:[]),An(y(e.paths.outputDb),s?.completeScipUpdated?[s.nextFragmentGeneration]:[]),oo(e.paths.outputDb,g,e.onStatus),f}function tl(e,t,n,r,i,o){let a=Qt(e.paths.metaPath),s=null;try{J(e.writeTelemetry,q(e.paths.outputDb,e.tempPaths.tempOutputDb))}catch(p){s=wr("reused","oracle-error",`Could not snapshot the prior database: ${p instanceof Error?p.message:String(p)}`)}z(H(),{projectRoot:e.projectRoot,dbPath:e.paths.outputDb,onStatus:e.onStatus}),Yt(e.projectRoot,e.paths.outputDb,e.paths.outputScip,e.onStatus,!0);let c=Tt(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(", ")}`),s??=It({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 u=Ze({trigger:e.opts.trigger,result:"reused",start:e.start,monotonicStart:e.monotonicStart,languages:t.map(p=>p.language),skipped:[...n]}),{metadata:l,pruneProjects:d}=ao({run:e,indexedOutputs:t,skippedLanguages:n,reusedLanguages:r,languageFingerprints:i,typescriptProjectShardContext:o,lastRefresh:u});return so(e.paths.outputDb,d),en(e.paths.metaPath,l),pt(e.paths.outputDb,e.paths.metaPath),oo(e.paths.outputDb,s,e.onStatus),u}function Qt(e){return ln(le(e)?.fingerprint)}function oo(e,t,n){try{Tr(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 ao(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:pe,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 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=le(e.metaPath),n=t?.version===pe?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 so(e,t){let n=ho(e);if(t===null){te(()=>ue(n,{recursive:!0,force:!0}));return}let r;try{r=no(n)}catch{return}for(let i of rl(r,t))te(()=>ue(w(n,i),{force:!0}))}function rl(e,t){let n=new Set(t.map(r=>`${jt(r)}.scip`));return e.filter(r=>!n.has(r))}function Ki(e,t,n){for(let r of t){let i=Zt(e,r.language);Ke(y(i),{recursive:!0}),r.scipPath!==i&&J(n,q(r.scipPath,i))}}async function il(e,t){if(!ae()){if(Cu()==="win32")throw new Error("The scip CLI was not found. On Windows it ships via the npm sidecar package codebaseiq-windows (installed automatically with codebaseiq). Reinstall codebaseiq with optional dependencies enabled, or follow 'codebaseiq setup' guidance for the exact sidecar package version, or set CODEBASEIQ_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: codebaseiq 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..."),!pr(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 ol(e){let t=[],n=[],r=e.languages.map((o,a)=>({language:o,scipPath:e.languages.length>1?be(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=al({...e,language:o,scipPath:a});for(let c of s)"skipped"in c?co(n,c.skipped):t.push(c.prepared)}return{preparedRuns:t,skippedLanguages:n,languageOutputScipPaths:i}}function al(e){if(e.language!=="typescript"||e.typescriptProjectMode!=="workspace")return[Xt({...e,id:e.language,label:e.language,outputScipPath:e.scipPath})];let t=e.preDiscoveredTypeScriptProjects??re(e.projectRoot,e.typescriptProjects);return t.length===0?[Xt({...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)=>Xt({...e,id:`typescript:${n}`,label:`typescript (${n})`,scipPath:be(e.tempOutputScip,"typescript-project",r),outputScipPath:e.scipPath,pnpmWorkspaces:!1,projectPath:n})))}function Xt(e){let t=kt(e.language),n=Ae(t),r=Xn(t,e.projectRoot),i=e.trustProjectTools&&r?Kn(t,e.projectRoot):null,o=ge(t);if(!i&&!o&&r){let l=`${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}: ${l}`),{skipped:{language:e.language,reason:l}}}if(!i&&!o&&!zn(t)){if(e.skipAutoInstall){let l=`${n} not found on PATH. To install the reviewed version, run: codebaseiq reindex --install-missing${t.installUrl?` (manual source: ${t.installUrl})`:""}`;return e.onStatus(`Skipping ${e.language}: ${l}`),{skipped:{language:e.language,reason:l}}}if(e.onStatus(`${n} not found. Attempting auto-install...`),!vi(t,e.onStatus)){let l=`${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}: ${l}`),{skipped:{language:e.language,reason:l}}}}let a=i?.canonicalPath??ge(t);if(!a){let l=`${n} was not found after installation checks.`;return e.onStatus(`Skipping ${e.language}: ${l}`),{skipped:{language:e.language,reason:l}}}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}),u=jr({language:e.language,projectPath:e.projectPath,pnpmWorkspaces:e.pnpmWorkspaces});if(i&&!i.executable){let l=`${i.relativePath} is not executable; refusing project-local indexer.`;return e.onStatus(`Skipping ${e.language}: ${l}`),{skipped:{language:e.language,reason:l}}}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:Qn(t,e.env,a),...u===void 0?{}:{temporaryRootConfigContent:u},...i?{trustedProjectTool:i}:{}}}}function sl(e,t){let n=new Map;for(let i of e)if(i.skipped)co(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)Cn(i.scipPaths,i.outputScipPath),r.push({language:i.language,scipPath:i.outputScipPath});else{let o=i.scipPaths[0];o!==i.outputScipPath&&ro(o,i.outputScipPath),r.push({language:i.language,scipPath:i.outputScipPath})}return{indexedOutputs:r}}function co(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 cl(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 Yi(e,t,n){if(e.length>1){n(`Merging ${e.length} language indexes...`);let r=performance.now(),i=Mn(e.map(o=>o.scipPath),t);return lo(i,n),n(`Merged and sanitized SCIP indexes in ${(performance.now()-r).toFixed(0)}ms.`),!0}else e[0].scipPath!==t&&ro(e[0].scipPath,t);return!1}async function ul(e){let t;if(ll(e)){let i=w(e.run.tempPaths.runDir,"typescript-affected.db");try{uo(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 Qi(e.incrementalTypeScript.affectedScipPath,i,e.env,e.run.onStatus,!1,e.run.opts.signal),e.run.onStatus(`Converted affected SCIP documents in ${(performance.now()-o).toFixed(0)}ms.`);let a=Vr({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),te(()=>ue(i,{force:!0})),te(()=>ue(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 Qi(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 ll(e){if(!e.incrementalTypeScript||e.skippedLanguages.length>0||!E(e.run.paths.outputDb)||!E(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 dl(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:Pt(e.plan,o,e.projectFileCount)}}async function Qi(e,t,n,r,i=!1,o){if(A(o,"Reindex cancelled by its owner."),r("Converting to SQLite..."),!E(e))throw new Error(`SCIP index not found at ${e} after indexing`);try{i||uo(e,r);let a=ae();if(!a)throw new Error("scip CLI is not available");let s=await _e({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 uo(e,t){let n=jn(e);lo(n,t)}function lo(e,t){e.removedDefinitionOccurrences!==0&&t(`Sanitized ${e.removedDefinitionOccurrences} invalid definition occurrences across ${e.touchedDocuments} documents before SQLite conversion.`)}function be(e,t,n){let r=ju(e)||".scip",i=Xe(e,r);return w(y(e),`${i}.${n+1}.${t}${r}`)}async function pl(e,t){for(let n=0;n<2;n++){let r=gl(e,t);if(r)return r;let i=fl(e);if(i&&fo(t.trigger,i)){t.onStatus(`Manual reindex preempting watcher refresh started at ${i.startedAt}.`);let o;try{o=await hl(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: ${$(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=lt(e,{parseLegacy:Ye});if(!fn(e,a,{parseLegacy:Ye}))throw new Error(`Reindex lock ownership changed before preemption completed for ${y(e)}.`);continue}throw new Error(`Another codebaseiq reindex is already running for ${y(e)}.`)}throw new Error(`Could not acquire codebaseiq reindex lock for ${y(e)}.`)}function gl(e,t){let n=Z(process.pid),r=Pe(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:Ye});if(r.kind==="acquired"&&r.reclaimed){let i=po(r.reclaimed,e);i&&fo(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 fl(e){return po(lt(e,{parseLegacy:Ye}),e)}var Ye=e=>{let t=go(e,"");return t?{pid:t.pid,...t.processIdentity?{processIdentity:t.processIdentity}:{}}:null};function po(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=on(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 fo(e,t){return e?.kind==="manual-cli"&&ml(t?.trigger)}function ml(e){return e?.kind==="watch-source"||e?.kind==="watch-git-head"||e?.kind==="watch-git-index"||e?.kind==="watch-git-state"}async function hl(e){return!Y(e.pid)||(Kt(e),Zi(e,"SIGTERM"),await eo(e,2e3))?!0:(Kt(e),Zi(e,"SIGKILL"),eo(e,1e3))}function Zi(e,t){if(e.processGroupLeader)try{process.kill(-e.pid,t);return}catch{if(!Y(e.pid))return;Kt(e)}try{process.kill(e.pid,t)}catch{}}async function eo(e,t){let n=R()+t;for(;R()<n;){if(to(e))return!0;await yl(50)}return to(e)}function Kt(e){if(!e.processIdentity)throw new Error(`Refusing to signal reindex pid ${e.pid}: its ownership record has no process identity.`);let t=Z(e.pid);if(!t)throw new Error(`Refusing to signal reindex pid ${e.pid}: its process identity is unavailable.`);if(!de(e.processIdentity,t))throw new Error(`Refusing to signal reindex pid ${e.pid}: its process identity does not match the ownership record.`)}function to(e){if(!Y(e.pid))return!0;if(!e.processIdentity)return!1;let t=Z(e.pid);return t!==null&&!de(e.processIdentity,t)}function yl(e){return new Promise(t=>setTimeout(t,e))}function mo(e,t,n){return Object.fromEntries(t.map(r=>{let i=r==="typescript"?bn(n.typescriptProjects):[],o=r==="clojure"?Sl(n.clojureConfigPath):void 0,a=[...kt(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"&&bl(n),...s,clojureConfigPath:o,files:ke(e,{language:r,markerFiles:a})}]}))}function Sl(e){return e?.trim()||void 0}function bl(e){return e.typescriptProjectMode!=="workspace"&&e.pnpmWorkspaces===!0}function Zt(e,t){return w(y(e),"language-indexes",`${t}.scip`)}function ho(e){return w(y(e),"language-indexes","typescript-projects")}function Qe(e,t){return w(ho(e),`${jt(t)}.scip`)}function le(e){try{return ct(ee(_(e,"reindex metadata")))}catch{return null}}function yo(e,t){try{let n=ee(_(e,"reindex metadata"));if(n.kind!=="legacy"&&n.kind!=="supported")return!1;let r=n.metadata;return n.capabilities.publishableGeneration&&pn(r)&&C(r.fingerprint)===C(t)&&C([...r.indexedLanguages??[]].sort())===C(t.languages)}catch{return!1}}function en(e,t){yn(e,t,{spacing:2,trailingNewline:!0})}function So(e,t){try{let n=ct(ee(_(e,"reindex metadata")));if(!n)return;en(e,{...n,lastRefresh:t})}catch{}}function Ze(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 C(e){return JSON.stringify(e)}function Df(e,t,n,r){return io({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{kl as a,wl as b,mr as c,dd as d,pd as e,kt as f,Qa as g,$d as h,Bd as i,vi as j,fu as k,io as l,Df as m};
308
- //# sourceMappingURL=chunk-IEL6Q5W3.js.map