codebaseiq 0.3.1 → 0.4.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 (321) hide show
  1. package/CHANGELOG.md +65 -0
  2. package/dist/augment-vue-worker.js +1 -1
  3. package/dist/{chunk-7GAK2F3H.js → chunk-23AD24QZ.js} +12 -12
  4. package/dist/chunk-24TEZJST.js +2 -0
  5. package/dist/{chunk-356EZBIP.js → chunk-26EDDGAX.js} +2 -2
  6. package/dist/{chunk-O2M3VNDY.js → chunk-26EZWQ24.js} +2 -2
  7. package/dist/{chunk-U33PMPNW.js → chunk-2L3NCI52.js} +2 -2
  8. package/dist/{chunk-MSI3K7PJ.js → chunk-2QJAVISG.js} +2 -2
  9. package/dist/{chunk-4LK5OIPW.js → chunk-2ZBZRYX4.js} +2 -2
  10. package/dist/{chunk-JYRJYXUV.js → chunk-33AXWMO2.js} +2 -2
  11. package/dist/{chunk-EQNMD62X.js → chunk-37K55EG3.js} +2 -2
  12. package/dist/{chunk-LCW3PSGL.js → chunk-3EFZ5KQ4.js} +2 -2
  13. package/dist/{chunk-D7DOB27N.js → chunk-3F23W57G.js} +2 -2
  14. package/dist/{chunk-BGGB5N53.js → chunk-3GKKCVKK.js} +2 -2
  15. package/dist/{chunk-MQW6SJ4P.js → chunk-3SYRGMCL.js} +2 -2
  16. package/dist/{chunk-DWBAESVW.js → chunk-3VDL7GTY.js} +2 -2
  17. package/dist/{chunk-BFANZRQ5.js → chunk-3XBZ5PKL.js} +2 -2
  18. package/dist/{chunk-K6FNTQQW.js → chunk-42PXSE74.js} +2 -2
  19. package/dist/{chunk-ALOEHWJS.js → chunk-4GIERC2P.js} +2 -2
  20. package/dist/{chunk-W7YLRXZE.js → chunk-4UXDBRIF.js} +2 -2
  21. package/dist/chunk-4XMZYLW5.js +2 -0
  22. package/dist/{chunk-JSB43EX6.js → chunk-55NUXP2V.js} +2 -2
  23. package/dist/chunk-5AJQCOZZ.js +21 -0
  24. package/dist/{chunk-L37EQYAX.js → chunk-5NUPFZFA.js} +2 -2
  25. package/dist/{chunk-PIFYOWS4.js → chunk-65QIFIF6.js} +2 -2
  26. package/dist/{chunk-SUE7SHZL.js → chunk-66Q5VLH6.js} +2 -2
  27. package/dist/{chunk-KFTHI2R6.js → chunk-6CQPIIS7.js} +2 -2
  28. package/dist/{chunk-GV2CEZCW.js → chunk-6CTSFS7R.js} +2 -2
  29. package/dist/{chunk-SB53KPWA.js → chunk-6EBUAKJT.js} +2 -2
  30. package/dist/chunk-6I55VYFG.js +4 -0
  31. package/dist/chunk-6NUURWPF.js +3 -0
  32. package/dist/{chunk-TEMM2FEL.js → chunk-6P5QMOM7.js} +2 -2
  33. package/dist/{chunk-3LQJRS4I.js → chunk-6S5FE4ZF.js} +2 -2
  34. package/dist/chunk-74LRKLNC.js +22 -0
  35. package/dist/{chunk-NNG6M6XD.js → chunk-75A23IID.js} +2 -2
  36. package/dist/chunk-75VNTSO6.js +7 -0
  37. package/dist/chunk-7HBBVZJ6.js +3 -0
  38. package/dist/{chunk-AGGR2BKS.js → chunk-7PPBMBH6.js} +2 -2
  39. package/dist/{chunk-DECN422G.js → chunk-7WG57A5X.js} +2 -2
  40. package/dist/{chunk-ILGTMRMZ.js → chunk-7XHZX6FX.js} +2 -2
  41. package/dist/{chunk-OKAF4OQS.js → chunk-A5HJ3CJW.js} +2 -2
  42. package/dist/{chunk-JNXI6NQ7.js → chunk-AJ5HVC5Z.js} +2 -2
  43. package/dist/{chunk-SZ4P7MF7.js → chunk-AYRHOFLV.js} +2 -2
  44. package/dist/chunk-AZDY3EKD.js +93 -0
  45. package/dist/{chunk-SA7G6GJX.js → chunk-AZZNG5Z2.js} +2 -2
  46. package/dist/chunk-BEKCTUPY.js +3 -0
  47. package/dist/{chunk-PTR3EOXC.js → chunk-BKKX2OU5.js} +2 -2
  48. package/dist/{chunk-5LL4KEHO.js → chunk-BQKRYKDD.js} +2 -2
  49. package/dist/{chunk-UIAUPFBJ.js → chunk-BVDQU2XJ.js} +2 -2
  50. package/dist/chunk-C3PPB2T5.js +5 -0
  51. package/dist/chunk-CABIZQXQ.js +21 -0
  52. package/dist/{chunk-M2Y6PCFE.js → chunk-CAH322MC.js} +2 -2
  53. package/dist/{chunk-EIBGSU2R.js → chunk-CBOOHUK4.js} +2 -2
  54. package/dist/chunk-CFIICAOM.js +2 -0
  55. package/dist/{chunk-UMEPSVKT.js → chunk-CPWYEPWQ.js} +2 -2
  56. package/dist/{chunk-LQHYYIOB.js → chunk-CRT7I7RJ.js} +2 -2
  57. package/dist/{chunk-IZDPGOZR.js → chunk-CZVSQQDU.js} +2 -2
  58. package/dist/{chunk-TNJGTQWO.js → chunk-D3KE26FS.js} +2 -2
  59. package/dist/{chunk-CB5AVJMM.js → chunk-DNRHRVKS.js} +2 -2
  60. package/dist/{chunk-SGMNWYTH.js → chunk-DOQLO74K.js} +2 -2
  61. package/dist/{chunk-DDRA3QKN.js → chunk-DP3EJ6XL.js} +2 -2
  62. package/dist/{chunk-OWJWOEDU.js → chunk-DQZF7MP6.js} +2 -2
  63. package/dist/{chunk-VSGOIZMQ.js → chunk-DTM4EHD2.js} +2 -2
  64. package/dist/{chunk-YRKP7PM7.js → chunk-DUM7GR6B.js} +2 -2
  65. package/dist/{chunk-HNXRVGMY.js → chunk-DZ4QOIRY.js} +2 -2
  66. package/dist/{chunk-CSPDQLLU.js → chunk-E3R6TJ5T.js} +2 -2
  67. package/dist/chunk-E4DP45YU.js +3 -0
  68. package/dist/{chunk-PUVNH4PO.js → chunk-E5U6N5WI.js} +2 -2
  69. package/dist/chunk-E7T22WET.js +21 -0
  70. package/dist/{chunk-QEOWONKY.js → chunk-ED7ZAZ5V.js} +2 -2
  71. package/dist/{chunk-RCIGX23V.js → chunk-EDMG5CSO.js} +2 -2
  72. package/dist/{chunk-IHSLIIL3.js → chunk-EOSUV7H5.js} +2 -2
  73. package/dist/{chunk-EHPOTEQX.js → chunk-ESWVTSHU.js} +2 -2
  74. package/dist/{chunk-57OPIQFM.js → chunk-ETZBIG6K.js} +2 -2
  75. package/dist/chunk-EYSJHKX6.js +3 -0
  76. package/dist/{chunk-MC46AL7B.js → chunk-F4AGM7ZE.js} +37 -37
  77. package/dist/{chunk-EOKVZXNF.js → chunk-FPUJRBHL.js} +55 -55
  78. package/dist/{chunk-CCIYWXX6.js → chunk-G2UU6PQP.js} +2 -2
  79. package/dist/{chunk-C6WKPKCF.js → chunk-G3KRXNNT.js} +2 -2
  80. package/dist/{chunk-TEANKHUU.js → chunk-G3ZBP72R.js} +2 -2
  81. package/dist/{chunk-ELYMY5S2.js → chunk-GC4I33OD.js} +2 -2
  82. package/dist/{chunk-NDKOVQFG.js → chunk-GLXEWYQY.js} +2 -2
  83. package/dist/{chunk-CYJS33YX.js → chunk-GRHNPFHT.js} +2 -2
  84. package/dist/{chunk-QY7QB7I6.js → chunk-GWESWURK.js} +2 -2
  85. package/dist/{chunk-R4OJGTMP.js → chunk-GXOFPAIR.js} +2 -2
  86. package/dist/{chunk-OBC7HSSO.js → chunk-H4FGIFEU.js} +2 -2
  87. package/dist/{chunk-LKUTSP4G.js → chunk-HOGS6JFP.js} +2 -2
  88. package/dist/{chunk-RIO3JXHM.js → chunk-HSJLK5MC.js} +2 -2
  89. package/dist/{chunk-BWL3PMPT.js → chunk-HTPEUJ42.js} +2 -2
  90. package/dist/{chunk-DJKOXMNG.js → chunk-IBPXUGJV.js} +2 -2
  91. package/dist/{chunk-2XBJRZEM.js → chunk-ITA3N7G6.js} +2 -2
  92. package/dist/chunk-JG5OWAEB.js +22 -0
  93. package/dist/{chunk-LSZYMN2A.js → chunk-JGJKRTTB.js} +2 -2
  94. package/dist/{chunk-TJWVT4DO.js → chunk-JGXLB7PR.js} +2 -2
  95. package/dist/{chunk-5TZNHP4T.js → chunk-JKUF2UG6.js} +2 -2
  96. package/dist/{chunk-CIYA2KZN.js → chunk-JOYASZRF.js} +2 -2
  97. package/dist/{chunk-U7NUXDQO.js → chunk-K3PFL5QQ.js} +2 -2
  98. package/dist/{chunk-WK2IQJPK.js → chunk-KAXBWTSX.js} +2 -2
  99. package/dist/{chunk-5ZI2PPI7.js → chunk-KHHAGHAW.js} +2 -2
  100. package/dist/{chunk-UW6KD57C.js → chunk-KJLUQVBG.js} +2 -2
  101. package/dist/{chunk-WWCV4E6J.js → chunk-KOVUXHIZ.js} +2 -2
  102. package/dist/chunk-KPMMOAV5.js +4 -0
  103. package/dist/{chunk-2Z7K66D7.js → chunk-LKJZNGMA.js} +2 -2
  104. package/dist/{chunk-3VJ3OCRE.js → chunk-LMPOC372.js} +2 -2
  105. package/dist/{chunk-F3QSL4W2.js → chunk-LTPNP6D5.js} +2 -2
  106. package/dist/{chunk-O2KWU34K.js → chunk-M3IBH6C3.js} +9 -9
  107. package/dist/{chunk-UJIXCI3L.js → chunk-MAGBSB6E.js} +2 -2
  108. package/dist/{chunk-QMOZZ2VX.js → chunk-MFMHD36E.js} +2 -2
  109. package/dist/{chunk-LMTSB3TB.js → chunk-MJX2J5QE.js} +2 -2
  110. package/dist/{chunk-WO6OFKUC.js → chunk-N26LGGSF.js} +2 -2
  111. package/dist/{chunk-J7AMBVWF.js → chunk-NB2DAVPP.js} +2 -2
  112. package/dist/{chunk-MDFT325O.js → chunk-NJDXNYLG.js} +2 -2
  113. package/dist/{chunk-BRQL7AFJ.js → chunk-NMKQOIYZ.js} +2 -2
  114. package/dist/{chunk-ICUL7XRT.js → chunk-NRNVMB2R.js} +2 -2
  115. package/dist/{chunk-JAFDMV5I.js → chunk-O5BWFNIH.js} +2 -2
  116. package/dist/{chunk-3H2H5ODK.js → chunk-O7PCDZ5B.js} +2 -2
  117. package/dist/{chunk-KPZGTB2O.js → chunk-OAJYNPRU.js} +2 -2
  118. package/dist/{chunk-KUKWHP4R.js → chunk-OFUC6R46.js} +2 -2
  119. package/dist/chunk-OSZ7PW5K.js +5 -0
  120. package/dist/{chunk-B3UYV66Z.js → chunk-OZ2M2X7A.js} +2 -2
  121. package/dist/{chunk-6O3KXIDL.js → chunk-OZI44VCR.js} +2 -2
  122. package/dist/{chunk-XN3EKMLI.js → chunk-PCKIKOUA.js} +2 -2
  123. package/dist/{chunk-I3OK27P7.js → chunk-PFMQRHC6.js} +2 -2
  124. package/dist/{chunk-K4S2VH42.js → chunk-PVKSZBX5.js} +2 -2
  125. package/dist/{chunk-NEWHKGVD.js → chunk-QANCT4MO.js} +2 -2
  126. package/dist/{chunk-ZNH33XIB.js → chunk-QEWN7BLP.js} +2 -2
  127. package/dist/{chunk-OQUCBKOI.js → chunk-QFJ46F6F.js} +2 -2
  128. package/dist/{chunk-2E6OUPCF.js → chunk-QPQWR6CW.js} +2 -2
  129. package/dist/{chunk-YTJHCGYB.js → chunk-QX4HDF2I.js} +2 -2
  130. package/dist/{chunk-KLX6NSWT.js → chunk-R2F2CTBA.js} +2 -2
  131. package/dist/{chunk-2OMXFE64.js → chunk-R7PXHYMY.js} +2 -2
  132. package/dist/{chunk-F74LZWCE.js → chunk-RGBZDOUO.js} +2 -2
  133. package/dist/{chunk-362QOSFD.js → chunk-RNPG5P4P.js} +2 -2
  134. package/dist/{chunk-D62CTZX6.js → chunk-RS6UYNEP.js} +2 -2
  135. package/dist/{chunk-VGWZ4MOY.js → chunk-RVBRPBLQ.js} +2 -2
  136. package/dist/{chunk-BGYRF5YX.js → chunk-RWAZCEJD.js} +2 -2
  137. package/dist/{chunk-Z66XYVLZ.js → chunk-RWDIONS7.js} +2 -2
  138. package/dist/{chunk-CJTKGAGH.js → chunk-S3CJYDXP.js} +2 -2
  139. package/dist/{chunk-53ELMZRF.js → chunk-S6UTKCBT.js} +2 -2
  140. package/dist/chunk-SLLFJXTW.js +27 -0
  141. package/dist/{chunk-TOTWJZIX.js → chunk-T3KTMLQT.js} +2 -2
  142. package/dist/{chunk-HJTM3C4Y.js → chunk-TB575ZGO.js} +2 -2
  143. package/dist/{chunk-YHPG3S2U.js → chunk-TG4GMU73.js} +2 -2
  144. package/dist/{chunk-N2XDMNVI.js → chunk-THKM7OXM.js} +2 -2
  145. package/dist/{chunk-GVAF222T.js → chunk-TNLOX4TN.js} +2 -2
  146. package/dist/{chunk-BPKNP3KZ.js → chunk-UHFZDQZJ.js} +2 -2
  147. package/dist/{chunk-YT4DVWUV.js → chunk-UUMAM5LM.js} +2 -2
  148. package/dist/{chunk-TLTSESB4.js → chunk-UUT5P3V7.js} +2 -2
  149. package/dist/{chunk-W7QDASTN.js → chunk-VEPK6M5C.js} +2 -2
  150. package/dist/{chunk-XJBK3QDV.js → chunk-VPCHKZ3I.js} +2 -2
  151. package/dist/{chunk-3ON3A2QV.js → chunk-VZY3XOBU.js} +2 -2
  152. package/dist/{chunk-XQAVQVIL.js → chunk-W6E6ME7G.js} +2 -2
  153. package/dist/{chunk-KEJ2HLRW.js → chunk-WGYZBS5S.js} +2 -2
  154. package/dist/{chunk-5MPBSFZH.js → chunk-WUP24Q4U.js} +2 -2
  155. package/dist/chunk-WXUHXSLN.js +2 -0
  156. package/dist/{chunk-F5CJO5JN.js → chunk-X4YZD2MP.js} +2 -2
  157. package/dist/chunk-XARPGCTL.js +2 -0
  158. package/dist/{chunk-5FWR5HLG.js → chunk-XDQ6QJF5.js} +20 -20
  159. package/dist/{chunk-JCMFBF4Z.js → chunk-XRH7R5SX.js} +2 -2
  160. package/dist/{chunk-T2M5HWBQ.js → chunk-XVJ2E7W7.js} +2 -2
  161. package/dist/{chunk-AXQCHG77.js → chunk-Y7GFAU5N.js} +2 -2
  162. package/dist/{chunk-T6MQNNAC.js → chunk-YBDLHFZZ.js} +2 -2
  163. package/dist/{chunk-ZB4C5TTR.js → chunk-YI3CJPOY.js} +2 -2
  164. package/dist/chunk-YMAGXBLT.js +3 -0
  165. package/dist/{chunk-MZNMASFM.js → chunk-YRAGNEBZ.js} +2 -2
  166. package/dist/chunk-YXZAAQHZ.js +3 -0
  167. package/dist/chunk-Z2L5H2HF.js +3 -0
  168. package/dist/{chunk-5CR4U5X2.js → chunk-ZHK7TVAJ.js} +2 -2
  169. package/dist/chunk-ZJNV27DZ.js +4 -0
  170. package/dist/{chunk-GQLDYCWS.js → chunk-ZQ6GAIUV.js} +2 -2
  171. package/dist/{chunk-4GWN76B2.js → chunk-ZQE2QYAC.js} +2 -2
  172. package/dist/chunk-ZUQ2MDFT.js +2 -0
  173. package/dist/cli-context-4R2LREXQ.js +3 -0
  174. package/dist/cli-context-6X7JYARX.js +2 -0
  175. package/dist/cli-failure-RECEHOM2.js +3 -0
  176. package/dist/cli-program-MXA3WTAO.js +7 -0
  177. package/dist/cli.js +1 -1
  178. package/dist/{code-viewer-AMRXV444.js → code-viewer-C6HE4DFC.js} +2 -2
  179. package/dist/{code-viewer-EXI5SFFR.js → code-viewer-XHSSAMBX.js} +2 -2
  180. package/dist/{command-descriptors-ROIOTCCW.js → command-descriptors-NWW34Z54.js} +171 -171
  181. package/dist/{command-descriptors-H6A4UY72.js → command-descriptors-XHK3PK2I.js} +116 -116
  182. package/dist/{command-panels-SZONPMLJ.js → command-panels-OXMCJ2QZ.js} +2 -2
  183. package/dist/direct-navigation-236VXYBZ.js +3 -0
  184. package/dist/direct-navigation-36YSILY6.js +2 -0
  185. package/dist/index.js +1 -1
  186. package/dist/invocation-command-descriptors-35JULLNR.js +3 -0
  187. package/dist/invocation-command-descriptors-FEWSFUO2.js +2 -0
  188. package/dist/output-continuation-command-MJBVH3A5.js +2 -0
  189. package/dist/output-continuation-command-TBXIOPHQ.js +3 -0
  190. package/dist/project-reindex-5TCGOVSK.js +2 -0
  191. package/dist/project-reindex-BUNTSYKM.js +3 -0
  192. package/dist/queries/affected.js +1 -1
  193. package/dist/queries/anchors.js +1 -1
  194. package/dist/queries/architecture.js +1 -1
  195. package/dist/queries/bottlenecks.js +1 -1
  196. package/dist/queries/by-kind.js +1 -1
  197. package/dist/queries/call-graph.js +1 -1
  198. package/dist/queries/change-surface.js +1 -1
  199. package/dist/queries/cleanup-plan.js +1 -1
  200. package/dist/queries/co-change.js +1 -1
  201. package/dist/queries/code.js +1 -1
  202. package/dist/queries/complexity-hotspots.js +1 -1
  203. package/dist/queries/complexity.js +1 -1
  204. package/dist/queries/context.js +1 -1
  205. package/dist/queries/convergence.js +1 -1
  206. package/dist/queries/coupling.js +1 -1
  207. package/dist/queries/cycles.js +1 -1
  208. package/dist/queries/dataflow.js +1 -1
  209. package/dist/queries/dead.js +1 -1
  210. package/dist/queries/decorative-checkers.js +1 -1
  211. package/dist/queries/deep-chains.js +1 -1
  212. package/dist/queries/dependence-slice.js +1 -1
  213. package/dist/queries/dependency-depth.js +1 -1
  214. package/dist/queries/deps.js +1 -1
  215. package/dist/queries/diff-impact.js +1 -1
  216. package/dist/queries/doc-drift.js +1 -1
  217. package/dist/queries/drift.js +1 -1
  218. package/dist/queries/duplicate-bodies.js +1 -1
  219. package/dist/queries/entry-map.js +1 -1
  220. package/dist/queries/evidence.js +1 -1
  221. package/dist/queries/extract-candidates.js +1 -1
  222. package/dist/queries/fan.js +1 -1
  223. package/dist/queries/files.js +1 -1
  224. package/dist/queries/health.js +1 -1
  225. package/dist/queries/hierarchy.js +1 -1
  226. package/dist/queries/hotspots.js +1 -1
  227. package/dist/queries/imports.js +1 -1
  228. package/dist/queries/incomplete-migration.js +1 -1
  229. package/dist/queries/index.js +1 -1
  230. package/dist/queries/isolated.js +1 -1
  231. package/dist/queries/locality-candidates.js +1 -1
  232. package/dist/queries/members.js +1 -1
  233. package/dist/queries/methods.js +1 -1
  234. package/dist/queries/not-implemented.js +1 -1
  235. package/dist/queries/outline.js +1 -1
  236. package/dist/queries/passthrough-candidates.js +1 -1
  237. package/dist/queries/plan-context.js +1 -1
  238. package/dist/queries/react-component-duplicates.js +1 -1
  239. package/dist/queries/react-hook-candidates.js +1 -1
  240. package/dist/queries/react-large-component-pressure.js +1 -1
  241. package/dist/queries/recent-duplicates.js +1 -1
  242. package/dist/queries/redundant-reexports.js +1 -1
  243. package/dist/queries/reference-neighborhood.js +1 -1
  244. package/dist/queries/reference-reachability.js +1 -1
  245. package/dist/queries/refs.js +1 -1
  246. package/dist/queries/self-audit.js +1 -1
  247. package/dist/queries/similar-chains.js +1 -1
  248. package/dist/queries/similar-files.js +1 -1
  249. package/dist/queries/similar-signatures.js +1 -1
  250. package/dist/queries/similar.js +1 -1
  251. package/dist/queries/slice.js +1 -1
  252. package/dist/queries/source-inspection.js +1 -1
  253. package/dist/queries/source-search.js +1 -1
  254. package/dist/queries/stale-abstractions.js +1 -1
  255. package/dist/queries/surface.js +1 -1
  256. package/dist/queries/symbols.js +1 -1
  257. package/dist/queries/system-map.js +1 -1
  258. package/dist/queries/system.js +1 -1
  259. package/dist/queries/test-quality.js +1 -1
  260. package/dist/queries/trace.js +1 -1
  261. package/dist/queries/twin-ab.js +1 -1
  262. package/dist/queries/twin-drift.js +1 -1
  263. package/dist/queries/unused-imports.js +1 -1
  264. package/dist/queries/unused-params.js +1 -1
  265. package/dist/queries/value-flow.js +1 -1
  266. package/dist/queries/vue-component-duplicates.js +1 -1
  267. package/dist/queries/vue-composable-candidates.js +1 -1
  268. package/dist/queries/vue-large-view-pressure.js +1 -1
  269. package/dist/queries/wrapper-candidates.js +1 -1
  270. package/dist/reindex-worker.js +1 -1
  271. package/dist/reindex.js +30 -30
  272. package/dist/runtime.js +1 -1
  273. package/dist/rust-semantic-session-server.js +1 -1
  274. package/dist/rust-semantic-session-worker.js +1 -1
  275. package/dist/rust-semantic-worker.js +1 -1
  276. package/dist/sentinel-ensure-command-3MZCLPQY.js +2 -0
  277. package/dist/sentinel-ensure-command-LEWHIRLL.js +3 -0
  278. package/dist/sentinel-worker.js +1 -1
  279. package/dist/typescript-mailbox-worker.js +1 -1
  280. package/dist/watch-server.js +6 -6
  281. package/docs/COMMAND_REFERENCE.md +2 -2
  282. package/docs/SECURITY_MODEL.md +3 -0
  283. package/package.json +1 -1
  284. package/skills/codebaseiq/SKILL.md +15 -3
  285. package/dist/chunk-2I2UHZET.js +0 -2
  286. package/dist/chunk-5T44HG5Y.js +0 -88
  287. package/dist/chunk-5YBDBY5L.js +0 -2
  288. package/dist/chunk-6EYESTJM.js +0 -3
  289. package/dist/chunk-6FXXYYQM.js +0 -22
  290. package/dist/chunk-7UCDGXRW.js +0 -8
  291. package/dist/chunk-BIADXGC3.js +0 -22
  292. package/dist/chunk-CLPCFGRT.js +0 -3
  293. package/dist/chunk-DUKHVPU5.js +0 -4
  294. package/dist/chunk-G7GVV2TV.js +0 -27
  295. package/dist/chunk-KUKKLWJD.js +0 -3
  296. package/dist/chunk-KWRQVLPX.js +0 -3
  297. package/dist/chunk-MEUHIDI3.js +0 -7
  298. package/dist/chunk-OP6BUIV6.js +0 -2
  299. package/dist/chunk-OQ3DK7FW.js +0 -2
  300. package/dist/chunk-OT5ISJSR.js +0 -2
  301. package/dist/chunk-SX72EVMY.js +0 -3
  302. package/dist/chunk-T75DS2E6.js +0 -21
  303. package/dist/chunk-UC2FD2PS.js +0 -4
  304. package/dist/chunk-UQYQBLJX.js +0 -5
  305. package/dist/chunk-V4NGDIEA.js +0 -21
  306. package/dist/chunk-XUPFA6GH.js +0 -2
  307. package/dist/chunk-YPBKBYPS.js +0 -21
  308. package/dist/chunk-ZMA5HWXY.js +0 -3
  309. package/dist/cli-context-FJL2JHOE.js +0 -3
  310. package/dist/cli-context-PQNWHMCQ.js +0 -2
  311. package/dist/cli-program-SCHOHOQE.js +0 -7
  312. package/dist/direct-navigation-3JOYP2MO.js +0 -3
  313. package/dist/direct-navigation-SJMJLBY7.js +0 -2
  314. package/dist/invocation-command-descriptors-GMZX3UAD.js +0 -2
  315. package/dist/invocation-command-descriptors-HNMKDEF6.js +0 -3
  316. package/dist/output-continuation-command-5NWVDQT7.js +0 -2
  317. package/dist/output-continuation-command-RNEHNYPU.js +0 -3
  318. package/dist/project-reindex-MIW5CYEG.js +0 -3
  319. package/dist/project-reindex-VQ23LWDA.js +0 -2
  320. package/dist/sentinel-ensure-command-H66AZ3VE.js +0 -2
  321. package/dist/sentinel-ensure-command-R4YAUCJB.js +0 -3
@@ -1,4 +1,4 @@
1
- import{a as ne,c as re}from"./chunk-YTJHCGYB.js";import{a as jn}from"./chunk-ILMHV3KM.js";import{a as Qt,b as Kt,d as qe,e as nn}from"./chunk-O2M3VNDY.js";import{I as zt,J as Xt,K as Yt,M as Vt,Q as wn,R as Xe,T as Dn,U as Fn,V as kn,a as me,b as Ht,d as Jt}from"./chunk-K4S2VH42.js";import{b as Ot,c as Lt,e as X,f as ge,g as te,h as Ct,i as $t,j as Ut,k as Gt,l as Bt,r as he,s as rn}from"./chunk-EQNMD62X.js";import{a as ze,c as Se,d as _n,f as Tn}from"./chunk-4LK5OIPW.js";import{s as Be}from"./chunk-C6WKPKCF.js";import{A as ln,B as un,C as pn,D as gn,E as fn,F as mn,G as He,I as $,J as ye,K as hn,M as Je,N as yn,O as bn,P as be,S as Sn,T as Rn,U as xn,c as K,d as le,e as Ae,g as Me,h as Ce,i as Dt,j as D,l as jt,o as F,p as M,q as C,r as We,s as Zt,t as en,u as tn,v as an,w as on,x as sn,y as cn,z as dn}from"./chunk-T75DS2E6.js";import{e as fe}from"./chunk-YT4DVWUV.js";import{a as j,b as _t}from"./chunk-RCIGX23V.js";import{i as q,j as J,l as Ft,m as Ge,n as kt,r as Wt,s as qt,u as Pn,x as En,y as In,z as vn}from"./chunk-D7DOB27N.js";import{i as ue,j as Z}from"./chunk-R2NOK63J.js";import{a as S,c as Tt,d as ee,e as H}from"./chunk-6O3KXIDL.js";import{$ as Nt,E as $e,O as Ue,T as pe,Y as wt,Z as z,a as Pt,c as Q,f as A,g as se,ga as At,h as ce,ha as Mt,i as Et,n as It,o as vt,p as de,r as I}from"./chunk-UQYQBLJX.js";import{createHash as fo}from"crypto";import{existsSync as T,mkdirSync as je,readdirSync as Cr,renameSync as $r,rmSync as Y,statSync as mo}from"fs";import{basename as ke,dirname as h,extname as ho,join as v,resolve as Fr}from"path";import{execFileSync as Kr}from"child_process";import{constants as Zr,copyFileSync as On,statSync as ei}from"fs";import{platform as ti}from"os";var ni=Object.freeze({size:e=>ei(e).size,clone:ii,copy:(e,t)=>On(e,t)}),ri=new Set(["ENOSYS","ENOTSUP","EOPNOTSUPP","EINVAL","EXDEV","ENOTTY"]);function U(e,t,n=ni){let r=n.size(e);try{return n.clone(e,t),{method:"reflink",bytes:r}}catch(i){if(!oi(i))throw i}return n.copy(e,t),{method:"copy",bytes:r}}function ii(e,t){if(ti()!=="darwin"){On(e,t,Zr.COPYFILE_FICLONE_FORCE);return}try{Kr("/bin/cp",["-c",e,t],{timeout:6e4,maxBuffer:64*1024,stdio:["ignore","ignore","pipe"],windowsHide:!0})}catch(n){throw ai(n)}}function ai(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 oi(e){let t=e?.code;return t!==void 0&&ri.has(t)}function Ln(){return{reflinkedBytes:0,fallbackCopiedBytes:0}}function G(e,t){t.method==="reflink"?e.reflinkedBytes+=t.bytes:e.fallbackCopiedBytes+=t.bytes}import{dirname as si,join as ci}from"path";function Nn(e={}){return{id:"runtime-boundaries",facts:["runtime-boundary-observation","runtime-boundary-link"],run:({projectRoot:t,dbPath:n,onStatus:r})=>{let i=new F({projectRoot:t,dbPath:n,indexPath:e.indexPath??ci(si(n),"index.scip")}),a,o=!1,s=!1;try{let l=e.reuseExisting||e.affectedFiles?Vt(i):null;e.reuseExisting&&l?.extractorVersion===zt?(a=l,o=!0):(a=Xt(i,{...l?{previousGraph:l}:{},...e.affectedFiles?{affectedFiles:e.affectedFiles}:{}}),s=(a.coverage.filesReused??0)>0)}finally{i.close()}o||Yt(n,a);let c={reused:o,incrementallyUpdated:s,observations:a.observations.length,links:a.links.length,frontiers:a.frontiers.length,filesScanned:a.coverage.filesScanned,errors:a.coverage.extractionErrors.length,phases:a.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-(a.coverage.filesReused??0)} file(s) extracted, ${a.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).`),!o&&a.coverage.phases&&r?.(`Runtime-boundary phases: ${a.coverage.phases.map(l=>`${l.id} ${l.durationMs.toFixed(0)}ms`).join(", ")}.`),c}}}import{createHash as li}from"crypto";import{existsSync as ui}from"fs";import{dirname as pi,join as Mn}from"path";function Ye(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 Re(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),a=Ye(e),o=new Set(a.reasons);return r.some(s=>!i.has(s))&&o.add("changed-file-outside-project"),t===null?(o.add("dependency-graph-unavailable"),An(r,i,o)):o.size>0?An(r,i,o):{mode:"closure",changedFiles:r,affectedFiles:di(r,t,i),reasons:[]}}function An(e,t,n){return{mode:"full-project",changedFiles:e,affectedFiles:[...t].sort(),reasons:[...n].sort()}}function di(e,t,n){let r=new Map;for(let[o,s]of t)if(n.has(o))for(let c of s){if(!n.has(c))continue;let l=r.get(c)??new Set;l.add(o),r.set(c,l)}let i=new Set(e),a=[...e];for(let o=0;o<a.length;o+=1){let s=a[o];if(s!==void 0)for(let c of r.get(s)??[])i.has(c)||(i.add(c),a.push(c))}return[...i].sort()}var gi="<global-symbols>";function fi(e){let t=[];for(let n of e.all(`
1
+ import{a as ne,c as re}from"./chunk-QX4HDF2I.js";import{a as kn}from"./chunk-ILMHV3KM.js";import{a as Qt,b as Kt,d as qe,e as nn}from"./chunk-26EZWQ24.js";import{I as zt,J as Xt,K as Yt,M as Vt,Q as wn,R as Xe,T as Dn,U as Fn,V as jn,a as me,b as Ht,d as Jt}from"./chunk-PVKSZBX5.js";import{b as Ot,c as Lt,e as X,f as ge,g as te,h as Ct,i as $t,j as Ut,k as Gt,l as Bt,r as he,s as rn}from"./chunk-37K55EG3.js";import{a as ze,c as Se,d as _n,f as Tn}from"./chunk-2ZBZRYX4.js";import{s as Be}from"./chunk-G3KRXNNT.js";import{A as ln,B as un,C as pn,D as gn,E as fn,F as mn,G as He,I as $,J as ye,K as hn,M as Je,N as yn,O as bn,P as be,S as Sn,T as Rn,U as xn,c as K,d as le,e as Ae,g as Me,h as Ce,i as Dt,j as D,l as kt,o as F,p as M,q as C,r as We,s as Zt,t as en,u as tn,v as an,w as on,x as sn,y as cn,z as dn}from"./chunk-E7T22WET.js";import{e as fe}from"./chunk-UUMAM5LM.js";import{a as k,b as _t}from"./chunk-EDMG5CSO.js";import{i as q,j as J,l as Ft,m as Ge,n as jt,r as Wt,s as qt,u as Pn,x as En,y as In,z as vn}from"./chunk-3F23W57G.js";import{i as ue,j as Z}from"./chunk-R2NOK63J.js";import{a as S,c as Tt,d as ee,e as H}from"./chunk-OZI44VCR.js";import{E as $e,R as Ue,X as pe,a as Pt,aa as wt,ba as z,c as Q,da as Nt,f as A,g as se,h as ce,i as Et,ka as At,la as Mt,n as It,o as vt,p as de,r as I}from"./chunk-C3PPB2T5.js";import{createHash as mo}from"crypto";import{existsSync as T,mkdirSync as ke,readdirSync as Cr,renameSync as $r,rmSync as Y,statSync as ho}from"fs";import{basename as je,dirname as h,extname as yo,join as v,resolve as Fr}from"path";import{execFileSync as Kr}from"child_process";import{constants as Zr,copyFileSync as On,statSync as ei}from"fs";import{platform as ti}from"os";var ni=Object.freeze({size:e=>ei(e).size,clone:ii,copy:(e,t)=>On(e,t)}),ri=new Set(["ENOSYS","ENOTSUP","EOPNOTSUPP","EINVAL","EXDEV","ENOTTY"]);function U(e,t,n=ni){let r=n.size(e);try{return n.clone(e,t),{method:"reflink",bytes:r}}catch(i){if(!oi(i))throw i}return n.copy(e,t),{method:"copy",bytes:r}}function ii(e,t){if(ti()!=="darwin"){On(e,t,Zr.COPYFILE_FICLONE_FORCE);return}try{Kr("/bin/cp",["-c",e,t],{timeout:6e4,maxBuffer:64*1024,stdio:["ignore","ignore","pipe"],windowsHide:!0})}catch(n){throw ai(n)}}function ai(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 oi(e){let t=e?.code;return t!==void 0&&ri.has(t)}function Ln(){return{reflinkedBytes:0,fallbackCopiedBytes:0}}function G(e,t){t.method==="reflink"?e.reflinkedBytes+=t.bytes:e.fallbackCopiedBytes+=t.bytes}import{dirname as si,join as ci}from"path";function Nn(e={}){return{id:"runtime-boundaries",facts:["runtime-boundary-observation","runtime-boundary-link"],run:({projectRoot:t,dbPath:n,onStatus:r})=>{let i=new F({projectRoot:t,dbPath:n,indexPath:e.indexPath??ci(si(n),"index.scip")}),a,o=!1,s=!1;try{let l=e.reuseExisting||e.affectedFiles?Vt(i):null;e.reuseExisting&&l?.extractorVersion===zt?(a=l,o=!0):(a=Xt(i,{...l?{previousGraph:l}:{},...e.affectedFiles?{affectedFiles:e.affectedFiles}:{}}),s=(a.coverage.filesReused??0)>0)}finally{i.close()}o||Yt(n,a);let c={reused:o,incrementallyUpdated:s,observations:a.observations.length,links:a.links.length,frontiers:a.frontiers.length,filesScanned:a.coverage.filesScanned,errors:a.coverage.extractionErrors.length,phases:a.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-(a.coverage.filesReused??0)} file(s) extracted, ${a.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).`),!o&&a.coverage.phases&&r?.(`Runtime-boundary phases: ${a.coverage.phases.map(l=>`${l.id} ${l.durationMs.toFixed(0)}ms`).join(", ")}.`),c}}}import{createHash as li}from"crypto";import{existsSync as ui}from"fs";import{dirname as pi,join as Mn}from"path";function Ye(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 Re(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),a=Ye(e),o=new Set(a.reasons);return r.some(s=>!i.has(s))&&o.add("changed-file-outside-project"),t===null?(o.add("dependency-graph-unavailable"),An(r,i,o)):o.size>0?An(r,i,o):{mode:"closure",changedFiles:r,affectedFiles:di(r,t,i),reasons:[]}}function An(e,t,n){return{mode:"full-project",changedFiles:e,affectedFiles:[...t].sort(),reasons:[...n].sort()}}function di(e,t,n){let r=new Map;for(let[o,s]of t)if(n.has(o))for(let c of s){if(!n.has(c))continue;let l=r.get(c)??new Set;l.add(o),r.set(c,l)}let i=new Set(e),a=[...e];for(let o=0;o<a.length;o+=1){let s=a[o];if(s!==void 0)for(let c of r.get(s)??[])i.has(c)||(i.add(c),a.push(c))}return[...i].sort()}var gi="<global-symbols>";function fi(e){let t=[];for(let n of e.all(`
2
2
  SELECT relative_path, language, position_encoding, text
3
3
  FROM documents
4
4
  `))t.push({relativePath:n.relative_path,kind:"document",values:[n.language,n.position_encoding,n.text]});for(let n of e.all(`
@@ -55,7 +55,7 @@ import{a as ne,c as re}from"./chunk-YTJHCGYB.js";import{a as jn}from"./chunk-ILM
55
55
  SELECT 1 FROM mentions m WHERE m.symbol_id = g.id
56
56
  )
57
57
  `))t.push({relativePath:gi,kind:"global-symbol",values:Ve(n)});return mi(t)}function mi(e){let t=new Map;for(let r of e){let i=JSON.stringify([r.kind,r.values]),a=t.get(r.relativePath)??[];a.push(i),t.set(r.relativePath,a)}let n=new Map;for(let[r,i]of[...t].sort(([a],[o])=>a.localeCompare(o))){let a=li("sha256");for(let o of i.sort())a.update(String(Buffer.byteLength(o))),a.update(":"),a.update(o),a.update(`
58
- `);n.set(r,a.digest("hex"))}return n}function hi(e,t){let n=[],r=[],i=[],a=[],o=new Set([...e.keys(),...t.keys()]);for(let s of[...o].sort()){let c=e.get(s),l=t.get(s);c===void 0?n.push(s):l===void 0?i.push(s):c!==l?r.push(s):a.push(s)}return{addedFiles:n,modifiedFiles:r,deletedFiles:i,changedFiles:[...n,...r,...i].sort(),unchangedFiles:a}}function Qe(e,t,n){let r=new Set(e.affectedFiles),i=new Set(t.changedFiles),a=e.mode==="full-project"?[]:t.changedFiles.filter(c=>!r.has(c)),o=e.affectedFiles.filter(c=>!i.has(c)).sort(),s=t.changedFiles.length-a.length;return{passed:a.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:a,extraFiles:o}}function Ke(e,t=xi){let n=t.wallNow===void 0&&t.monotonicNow===void 0,r=t.monotonicNow??t.now,i=t.wallNow??t.now,a=r(),o=(l,d)=>{let p=r();return qn(e.refreshResult,l,n?p:i(),Math.max(0,p-a),d)};if(!t.databaseExists(e.previousDbPath))return o("prior-index-unavailable");if(!t.databaseExists(e.candidateDbPath))return o("candidate-index-unavailable");let s=null,c=null;try{s=t.openDatabase(e.projectRoot,e.previousDbPath,e.previousIndexPath),c=t.openDatabase(e.projectRoot,e.candidateDbPath,e.candidateIndexPath);let l=[...new Set([...t.indexedPaths(s),...t.indexedPaths(c)])].sort(),d=de(e.previousSnapshot,e.currentSnapshot),p=new Set(l),u=d.changes.length>0&&!Ye(d).fullProject&&d.changes.every(_=>p.has(_.path)),g=Re(d,u?t.dependencyGraph(s):new Map,l),m=hi(t.factDigests(s),t.factDigests(c)),x=r();return{version:1,status:"evaluated",refreshResult:e.refreshResult,recordedAt:new Date(n?x:i()).toISOString(),durationMs:Math.max(0,x-a),manifest:d,plan:g,comparison:m,evaluation:Qe(g,m,l.length)}}catch(l){return o("oracle-error",l instanceof Error?l.message:String(l))}finally{Cn(s),Cn(c)}}function Gn(e,t,n,r=Date.now()){return qn(e,t,r,0,n)}function Bn(e){let t=pi(e);return{latestPath:Mn(t,"affected-shadow-latest.json"),historyPath:Mn(t,"affected-shadow.jsonl")}}function xs(e,t=n=>Et(n,"affected-shadow source file")){let n=Bn(e),r;try{r=JSON.parse(t(n.latestPath))}catch(f){let y=_i(f),R=y?"telemetry-missing":vi(f);return O(n,R,y?void 0:f instanceof Error?f.message:String(f))}if(M(r)&&typeof r.version=="number"&&r.version!==1)return O(n,"unsupported-record-version",`Unsupported version ${r.version}.`);if(!Ei(r))return O(n,"telemetry-malformed");if(r.status==="unavailable")return Ii(r.reason)?{state:"unavailable",...n,reason:r.reason,recordedAt:r.recordedAt,refreshResult:r.refreshResult,durationMs:r.durationMs,...typeof r.error=="string"?{error:r.error}:{}}:O(n,"telemetry-malformed");if(r.status!=="evaluated")return O(n,"telemetry-malformed");let i=r.plan,a=r.comparison,o=r.evaluation;if(!M(r.manifest)||!M(i)||!M(a)||!M(o))return O(n,"telemetry-malformed");let s=i.mode,c=C(i.affectedFiles),l=C(i.reasons),d=C(a.changedFiles),p=C(o.predictedFiles),u=C(o.actualFiles),g=C(o.missingFiles),m=o.recall,x=o.affectedRatio;if(s!=="none"&&s!=="closure"&&s!=="full-project"||c===null||l===null||d===null||p===null||u===null||g===null||typeof o.passed!="boolean"||!$n(m)||!$n(x))return O(n,"telemetry-malformed");let _=u.length===0?1:(u.length-g.length)/u.length;return!Un(c,p)||!Un(d,u)||o.passed!==(g.length===0)||Math.abs(m-_)>Number.EPSILON||g.some(f=>!u.includes(f)||p.includes(f))?O(n,"telemetry-malformed"):{state:o.passed?"passing":"failing",...n,recordedAt:r.recordedAt,refreshResult:r.refreshResult,durationMs:r.durationMs,mode:s,recall:m,affectedRatio:x,predictedFiles:p,actualFiles:u,missingFiles:g,fallbackReasons:l}}function Ps(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 Wn(e,t,n=Pi){let r=Bn(e);return n.appendHistory(r.historyPath,t),n.writeLatest(r.latestPath,t),r}var yi=8*1024*1024,bi=Qt;function Si(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 Ri(e,t,n=yi){Kt(e,Si(t),{maxSegmentBytes:n,previousSuffix:bi})}function Ve(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 xi={now:()=>Date.now(),wallNow:()=>Date.now(),monotonicNow:S,databaseExists:e=>ui(e),openDatabase:(e,t,n)=>new F({projectRoot:e,dbPath:t,indexPath:n}),indexedPaths:e=>fe(e),dependencyGraph:e=>me(e),factDigests:e=>fi(e)},Pi={appendHistory:Ri,writeLatest:(e,t)=>Wt(e,t,{spacing:2,trailingNewline:!0})};function qn(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 Cn(e){try{e?.close()}catch{}}function Ei(e){return M(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 Ii(e){return e==="prior-index-unavailable"||e==="candidate-index-unavailable"||e==="oracle-error"}function $n(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0&&e<=1}function Un(e,t){return e.length===t.length&&e.every((n,r)=>n===t[r])}function O(e,t,n){return{state:"unavailable",...e,reason:t,...n?{error:n}:{}}}function vi(e){return e instanceof SyntaxError?"telemetry-malformed":"telemetry-unreadable"}function _i(e){return e instanceof Error&&e.code==="ENOENT"}import{readdirSync as Ti}from"fs";import{isAbsolute as Hn,join as wi,resolve as Di}from"path";var xe="@sourcegraph/scip-typescript@0.4.0",Jn="scip-python-plus@0.7.5",zn="github.com/sourcegraph/scip-go@v0.2.7",Xn="scip-dotnet@0.2.14",Fi="scip_dart@1.6.2",ki=3,ji=new Set(["bin","obj","node_modules"]),Oi={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:[...I.typescript],installMethods:[{label:"npm",identity:xe,destination:"npm global prefix",prerequisite:"npm",binary:"npm",args:["install","-g",xe]}],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:[...I.javascript],installMethods:[{label:"npm",identity:xe,destination:"npm global prefix",prerequisite:"npm",binary:"npm",args:["install","-g",xe]}],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:[...I.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:[...I.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:[...I.kotlin],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-java/releases"},rust:{language:X.language,indexerBinary:X.indexerBinary,checkCommand:`${X.indexerBinary} --version`,indexArgs:({outputPath:e})=>({binary:X.indexerBinary,args:["scip",".","--output",e]}),markerFiles:[...I.rust],installMethods:[],installUrl:X.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:[...I.python],installMethods:[{label:"npm",identity:Jn,destination:"npm global prefix",prerequisite:"npm",binary:"npm",args:["install","-g",Jn]}],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",Hn(r)?r:Di(e,r)),{binary:n,args:i}},markerFiles:[...I.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:[...I.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:[...I.go],installMethods:[{label:"go install",identity:zn,destination:"Go bin directory (GOBIN or GOPATH/bin)",prerequisite:"go",binary:"go",args:["install",zn]}],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:[...I.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:[...I.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",Yn(e,[".sln",".slnx",".csproj"])??e,"--output",t,"--working-directory",e]}),markerFiles:[...I.csharp],installMethods:[{label:"dotnet",identity:Xn,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",Yn(e,[".sln",".slnx",".vbproj"])??e,"--output",t,"--working-directory",e]}),markerFiles:[...I.vb],installMethods:[{label:"dotnet",identity:Xn,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:[...I.dart],installMethods:[{label:"dart pub",identity:Fi,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})=>Hn(e)?{binary:"php",args:["-d","error_reporting=E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED",e]}:{binary:e,args:[]},defaultOutputPath:"index.scip",markerFiles:[...I.php],installMethods:[],installUrl:"https://github.com/davidrjenni/scip-php/releases"}};function Vn(e){if(!(e.projectPath||e.pnpmWorkspaces)){if(e.language==="typescript")return"{}";if(e.language==="javascript")return'{"compilerOptions":{"allowJs":true}}'}}function Ze(e){return Oi[e]}function Yn(e,t){let n=[e];for(let r=0;r<=ki&&n.length>0;r++){let i=[],a=[];for(let o of n){let s;try{s=Ti(o,{withFileTypes:!0})}catch{continue}for(let c of s){let l=wi(o,c.name);c.isDirectory()?!c.name.startsWith(".")&&!ji.has(c.name)&&a.push(l):i.push(l)}}for(let o of t){let s=i.filter(c=>c.endsWith(o)).sort()[0];if(s)return s}n=a.sort()}return null}import{createHash as Li}from"crypto";import{existsSync as Qn,rmSync as Kn}from"fs";import{resolve as Ni}from"path";import tr from"better-sqlite3";var Ai={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}]},Mi={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 nr(e){let t=S(),n=Ci(e.affectedFiles);if($i(e.previousDbPath,e.miniDbPath,e.candidateDbPath),Kn(e.candidateDbPath,{force:!0}),!Qn(e.previousDbPath))throw new Error("previous SQLite generation is unavailable");if(!Qn(e.miniDbPath))throw new Error("incremental SQLite mini database is unavailable");Zn(e.previousDbPath,"previous SQLite generation",!1),Zn(e.miniDbPath,"incremental SQLite mini database");let r=U(e.previousDbPath,e.candidateDbPath);e.writeTelemetry&&G(e.writeTelemetry,r);let i=null;try{i=new tr(j(e.candidateDbPath),{fileMustExist:!0}),i.pragma("busy_timeout = 5000"),i.pragma("foreign_keys = ON"),i.prepare("ATTACH DATABASE ? AS incremental").run(j(e.miniDbPath)),et(i,"main","candidate SQLite generation"),et(i,"incremental","incremental SQLite mini database"),Ui(i,n),Gi(i,n.length);let a=tt(i,"main",!0),o=L(i,"SELECT COUNT(*) AS value FROM main.documents");i.transaction(()=>{Bi(i),Wi(i),qi(i),e.onStage?.("after-delete"),Hi(i),e.onStage?.("after-symbol-reconciliation"),Ji(i),e.onStage?.("after-insert"),zi(i),Xi(i,n.length,o),e.onStage?.("before-commit")}).immediate(),rr(i,"main","candidate SQLite generation");let l=[...Yi(i)].filter(([d,p])=>a.get(d)!==p).map(([d])=>d).sort();return i.exec("DETACH DATABASE incremental"),i.close(),i=null,{candidateDbPath:e.candidateDbPath,affectedDocumentCount:n.length,changedDocumentPaths:l,durationMs:S()-t}}catch(a){try{i?.close()}finally{Kn(e.candidateDbPath,{force:!0})}throw new Error(`Incremental SQLite publication rejected: ${a instanceof Error?a.message:String(a)}`,{cause:a})}}function Ci(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 $i(e,t,n){let r=[e,t,n].map(i=>Ni(i));if(new Set(r).size!==r.length)throw new Error("previous, mini, and candidate SQLite paths must be distinct")}function Zn(e,t,n=!0){let r=new tr(j(e),{readonly:!0,fileMustExist:!0});try{et(r,"main",t),n&&rr(r,"main",t)}finally{r.close()}}function et(e,t,n){for(let[r,i]of Object.entries(Ai)){let o=e.prepare(`PRAGMA ${t}.table_info('${r}')`).all().map(({name:s,type:c,notnull:l,pk:d})=>({name:s,type:c.toUpperCase(),notnull:l,pk:d}));if(JSON.stringify(o)!==JSON.stringify(i))throw new Error(`${n} schema changed for table ${r}`)}for(let[r,i]of Object.entries(Mi)){let a=e.prepare(`SELECT tbl_name FROM ${t}.sqlite_master WHERE type = 'index' AND name = ?`).get(r),o=e.prepare(`PRAGMA ${t}.index_info('${r}')`).all().map(s=>s.name);if(a?.tbl_name!==i.table||JSON.stringify(o)!==JSON.stringify(i.columns))throw new Error(`${n} schema changed for index ${r}`)}er(e,t,"documents",["relative_path"],n),er(e,t,"global_symbols",["symbol"],n)}function er(e,t,n,r,i){if(!e.prepare(`PRAGMA ${t}.index_list('${n}')`).all().some(s=>{if(s.unique!==1)return!1;let c=e.prepare(`PRAGMA ${t}.index_info('${s.name}')`).all().map(l=>l.name);return JSON.stringify(c)===JSON.stringify(r)}))throw new Error(`${i} lost the unique ${n}(${r.join(", ")}) constraint`)}function rr(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 Ui(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 a of i)n.run(a)})(t)}function Gi(e,t){let n=L(e,"SELECT COUNT(*) AS value FROM incremental.documents"),r=L(e,`SELECT COUNT(*) AS value
58
+ `);n.set(r,a.digest("hex"))}return n}function hi(e,t){let n=[],r=[],i=[],a=[],o=new Set([...e.keys(),...t.keys()]);for(let s of[...o].sort()){let c=e.get(s),l=t.get(s);c===void 0?n.push(s):l===void 0?i.push(s):c!==l?r.push(s):a.push(s)}return{addedFiles:n,modifiedFiles:r,deletedFiles:i,changedFiles:[...n,...r,...i].sort(),unchangedFiles:a}}function Qe(e,t,n){let r=new Set(e.affectedFiles),i=new Set(t.changedFiles),a=e.mode==="full-project"?[]:t.changedFiles.filter(c=>!r.has(c)),o=e.affectedFiles.filter(c=>!i.has(c)).sort(),s=t.changedFiles.length-a.length;return{passed:a.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:a,extraFiles:o}}function Ke(e,t=xi){let n=t.wallNow===void 0&&t.monotonicNow===void 0,r=t.monotonicNow??t.now,i=t.wallNow??t.now,a=r(),o=(l,d)=>{let p=r();return qn(e.refreshResult,l,n?p:i(),Math.max(0,p-a),d)};if(!t.databaseExists(e.previousDbPath))return o("prior-index-unavailable");if(!t.databaseExists(e.candidateDbPath))return o("candidate-index-unavailable");let s=null,c=null;try{s=t.openDatabase(e.projectRoot,e.previousDbPath,e.previousIndexPath),c=t.openDatabase(e.projectRoot,e.candidateDbPath,e.candidateIndexPath);let l=[...new Set([...t.indexedPaths(s),...t.indexedPaths(c)])].sort(),d=de(e.previousSnapshot,e.currentSnapshot),p=new Set(l),u=d.changes.length>0&&!Ye(d).fullProject&&d.changes.every(_=>p.has(_.path)),g=Re(d,u?t.dependencyGraph(s):new Map,l),m=hi(t.factDigests(s),t.factDigests(c)),x=r();return{version:1,status:"evaluated",refreshResult:e.refreshResult,recordedAt:new Date(n?x:i()).toISOString(),durationMs:Math.max(0,x-a),manifest:d,plan:g,comparison:m,evaluation:Qe(g,m,l.length)}}catch(l){return o("oracle-error",l instanceof Error?l.message:String(l))}finally{Cn(s),Cn(c)}}function Gn(e,t,n,r=Date.now()){return qn(e,t,r,0,n)}function Bn(e){let t=pi(e);return{latestPath:Mn(t,"affected-shadow-latest.json"),historyPath:Mn(t,"affected-shadow.jsonl")}}function Ps(e,t=n=>Et(n,"affected-shadow source file")){let n=Bn(e),r;try{r=JSON.parse(t(n.latestPath))}catch(f){let y=_i(f),R=y?"telemetry-missing":vi(f);return O(n,R,y?void 0:f instanceof Error?f.message:String(f))}if(M(r)&&typeof r.version=="number"&&r.version!==1)return O(n,"unsupported-record-version",`Unsupported version ${r.version}.`);if(!Ei(r))return O(n,"telemetry-malformed");if(r.status==="unavailable")return Ii(r.reason)?{state:"unavailable",...n,reason:r.reason,recordedAt:r.recordedAt,refreshResult:r.refreshResult,durationMs:r.durationMs,...typeof r.error=="string"?{error:r.error}:{}}:O(n,"telemetry-malformed");if(r.status!=="evaluated")return O(n,"telemetry-malformed");let i=r.plan,a=r.comparison,o=r.evaluation;if(!M(r.manifest)||!M(i)||!M(a)||!M(o))return O(n,"telemetry-malformed");let s=i.mode,c=C(i.affectedFiles),l=C(i.reasons),d=C(a.changedFiles),p=C(o.predictedFiles),u=C(o.actualFiles),g=C(o.missingFiles),m=o.recall,x=o.affectedRatio;if(s!=="none"&&s!=="closure"&&s!=="full-project"||c===null||l===null||d===null||p===null||u===null||g===null||typeof o.passed!="boolean"||!$n(m)||!$n(x))return O(n,"telemetry-malformed");let _=u.length===0?1:(u.length-g.length)/u.length;return!Un(c,p)||!Un(d,u)||o.passed!==(g.length===0)||Math.abs(m-_)>Number.EPSILON||g.some(f=>!u.includes(f)||p.includes(f))?O(n,"telemetry-malformed"):{state:o.passed?"passing":"failing",...n,recordedAt:r.recordedAt,refreshResult:r.refreshResult,durationMs:r.durationMs,mode:s,recall:m,affectedRatio:x,predictedFiles:p,actualFiles:u,missingFiles:g,fallbackReasons:l}}function Es(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 Wn(e,t,n=Pi){let r=Bn(e);return n.appendHistory(r.historyPath,t),n.writeLatest(r.latestPath,t),r}var yi=8*1024*1024,bi=Qt;function Si(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 Ri(e,t,n=yi){Kt(e,Si(t),{maxSegmentBytes:n,previousSuffix:bi})}function Ve(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 xi={now:()=>Date.now(),wallNow:()=>Date.now(),monotonicNow:S,databaseExists:e=>ui(e),openDatabase:(e,t,n)=>new F({projectRoot:e,dbPath:t,indexPath:n}),indexedPaths:e=>fe(e),dependencyGraph:e=>me(e),factDigests:e=>fi(e)},Pi={appendHistory:Ri,writeLatest:(e,t)=>Wt(e,t,{spacing:2,trailingNewline:!0})};function qn(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 Cn(e){try{e?.close()}catch{}}function Ei(e){return M(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 Ii(e){return e==="prior-index-unavailable"||e==="candidate-index-unavailable"||e==="oracle-error"}function $n(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0&&e<=1}function Un(e,t){return e.length===t.length&&e.every((n,r)=>n===t[r])}function O(e,t,n){return{state:"unavailable",...e,reason:t,...n?{error:n}:{}}}function vi(e){return e instanceof SyntaxError?"telemetry-malformed":"telemetry-unreadable"}function _i(e){return e instanceof Error&&e.code==="ENOENT"}import{readdirSync as Ti}from"fs";import{isAbsolute as Hn,join as wi,resolve as Di}from"path";var xe="@sourcegraph/scip-typescript@0.4.0",Jn="scip-python-plus@0.7.5",zn="github.com/sourcegraph/scip-go@v0.2.7",Xn="scip-dotnet@0.2.14",Fi="scip_dart@1.6.2",ji=3,ki=new Set(["bin","obj","node_modules"]),Oi={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:[...I.typescript],installMethods:[{label:"npm",identity:xe,destination:"npm global prefix",prerequisite:"npm",binary:"npm",args:["install","-g",xe]}],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:[...I.javascript],installMethods:[{label:"npm",identity:xe,destination:"npm global prefix",prerequisite:"npm",binary:"npm",args:["install","-g",xe]}],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:[...I.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:[...I.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:[...I.kotlin],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-java/releases"},rust:{language:X.language,indexerBinary:X.indexerBinary,checkCommand:`${X.indexerBinary} --version`,indexArgs:({outputPath:e})=>({binary:X.indexerBinary,args:["scip",".","--output",e]}),markerFiles:[...I.rust],installMethods:[],installUrl:X.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","--project-version","0"]}),markerFiles:[...I.python],installMethods:[{label:"npm",identity:Jn,destination:"npm global prefix",prerequisite:"npm",binary:"npm",args:["install","-g",Jn]}],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",Hn(r)?r:Di(e,r)),{binary:n,args:i}},markerFiles:[...I.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:[...I.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:[...I.go],installMethods:[{label:"go install",identity:zn,destination:"Go bin directory (GOBIN or GOPATH/bin)",prerequisite:"go",binary:"go",args:["install",zn]}],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:[...I.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:[...I.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",Yn(e,[".sln",".slnx",".csproj"])??e,"--output",t,"--working-directory",e]}),markerFiles:[...I.csharp],installMethods:[{label:"dotnet",identity:Xn,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",Yn(e,[".sln",".slnx",".vbproj"])??e,"--output",t,"--working-directory",e]}),markerFiles:[...I.vb],installMethods:[{label:"dotnet",identity:Xn,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:[...I.dart],installMethods:[{label:"dart pub",identity:Fi,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})=>Hn(e)?{binary:"php",args:["-d","error_reporting=E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED",e]}:{binary:e,args:[]},defaultOutputPath:"index.scip",markerFiles:[...I.php],installMethods:[],installUrl:"https://github.com/davidrjenni/scip-php/releases"}};function Vn(e){if(!(e.projectPath||e.pnpmWorkspaces)){if(e.language==="typescript")return"{}";if(e.language==="javascript")return'{"compilerOptions":{"allowJs":true}}'}}function Ze(e){return Oi[e]}function Yn(e,t){let n=[e];for(let r=0;r<=ji&&n.length>0;r++){let i=[],a=[];for(let o of n){let s;try{s=Ti(o,{withFileTypes:!0})}catch{continue}for(let c of s){let l=wi(o,c.name);c.isDirectory()?!c.name.startsWith(".")&&!ki.has(c.name)&&a.push(l):i.push(l)}}for(let o of t){let s=i.filter(c=>c.endsWith(o)).sort()[0];if(s)return s}n=a.sort()}return null}import{createHash as Li}from"crypto";import{existsSync as Qn,rmSync as Kn}from"fs";import{resolve as Ni}from"path";import tr from"better-sqlite3";var Ai={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}]},Mi={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 nr(e){let t=S(),n=Ci(e.affectedFiles);if($i(e.previousDbPath,e.miniDbPath,e.candidateDbPath),Kn(e.candidateDbPath,{force:!0}),!Qn(e.previousDbPath))throw new Error("previous SQLite generation is unavailable");if(!Qn(e.miniDbPath))throw new Error("incremental SQLite mini database is unavailable");Zn(e.previousDbPath,"previous SQLite generation",!1),Zn(e.miniDbPath,"incremental SQLite mini database");let r=U(e.previousDbPath,e.candidateDbPath);e.writeTelemetry&&G(e.writeTelemetry,r);let i=null;try{i=new tr(k(e.candidateDbPath),{fileMustExist:!0}),i.pragma("busy_timeout = 5000"),i.pragma("foreign_keys = ON"),i.prepare("ATTACH DATABASE ? AS incremental").run(k(e.miniDbPath)),et(i,"main","candidate SQLite generation"),et(i,"incremental","incremental SQLite mini database"),Ui(i,n),Gi(i,n.length);let a=tt(i,"main",!0),o=L(i,"SELECT COUNT(*) AS value FROM main.documents");i.transaction(()=>{Bi(i),Wi(i),qi(i),e.onStage?.("after-delete"),Hi(i),e.onStage?.("after-symbol-reconciliation"),Ji(i),e.onStage?.("after-insert"),zi(i),Xi(i,n.length,o),e.onStage?.("before-commit")}).immediate(),rr(i,"main","candidate SQLite generation");let l=[...Yi(i)].filter(([d,p])=>a.get(d)!==p).map(([d])=>d).sort();return i.exec("DETACH DATABASE incremental"),i.close(),i=null,{candidateDbPath:e.candidateDbPath,affectedDocumentCount:n.length,changedDocumentPaths:l,durationMs:S()-t}}catch(a){try{i?.close()}finally{Kn(e.candidateDbPath,{force:!0})}throw new Error(`Incremental SQLite publication rejected: ${a instanceof Error?a.message:String(a)}`,{cause:a})}}function Ci(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 $i(e,t,n){let r=[e,t,n].map(i=>Ni(i));if(new Set(r).size!==r.length)throw new Error("previous, mini, and candidate SQLite paths must be distinct")}function Zn(e,t,n=!0){let r=new tr(k(e),{readonly:!0,fileMustExist:!0});try{et(r,"main",t),n&&rr(r,"main",t)}finally{r.close()}}function et(e,t,n){for(let[r,i]of Object.entries(Ai)){let o=e.prepare(`PRAGMA ${t}.table_info('${r}')`).all().map(({name:s,type:c,notnull:l,pk:d})=>({name:s,type:c.toUpperCase(),notnull:l,pk:d}));if(JSON.stringify(o)!==JSON.stringify(i))throw new Error(`${n} schema changed for table ${r}`)}for(let[r,i]of Object.entries(Mi)){let a=e.prepare(`SELECT tbl_name FROM ${t}.sqlite_master WHERE type = 'index' AND name = ?`).get(r),o=e.prepare(`PRAGMA ${t}.index_info('${r}')`).all().map(s=>s.name);if(a?.tbl_name!==i.table||JSON.stringify(o)!==JSON.stringify(i.columns))throw new Error(`${n} schema changed for index ${r}`)}er(e,t,"documents",["relative_path"],n),er(e,t,"global_symbols",["symbol"],n)}function er(e,t,n,r,i){if(!e.prepare(`PRAGMA ${t}.index_list('${n}')`).all().some(s=>{if(s.unique!==1)return!1;let c=e.prepare(`PRAGMA ${t}.index_info('${s.name}')`).all().map(l=>l.name);return JSON.stringify(c)===JSON.stringify(r)}))throw new Error(`${i} lost the unique ${n}(${r.join(", ")}) constraint`)}function rr(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 Ui(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 a of i)n.run(a)})(t)}function Gi(e,t){let n=L(e,"SELECT COUNT(*) AS value FROM incremental.documents"),r=L(e,`SELECT COUNT(*) AS value
59
59
  FROM main.documents d
60
60
  JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path`),i=e.prepare(`SELECT p.relative_path
61
61
  FROM temp.incremental_affected_paths p
@@ -225,7 +225,7 @@ import{a as ne,c as re}from"./chunk-YTJHCGYB.js";import{a as jn}from"./chunk-ILM
225
225
  JOIN ${t}.global_symbols g ON g.id = m.symbol_id
226
226
  ${r}
227
227
  ORDER BY d.relative_path, c.chunk_index, m.role, g.symbol`).all(),c=new Map;for(let[d,p]of Object.entries({documents:i,chunks:a,definitions:o,mentions:s}))for(let u of p){let g=JSON.stringify([d,u]),m=c.get(u.relative_path)??[];m.push(g),c.set(u.relative_path,m)}let l=new Map;for(let[d,p]of[...c].sort(([u],[g])=>u.localeCompare(g))){let u=Li("sha256");for(let g of p.sort())u.update(g).update(`
228
- `);l.set(d,u.digest("hex"))}return l}function L(e,t){return e.prepare(t).get().value}import Vi from"better-sqlite3";var Pe="idx_mentions_definitions",Qi=["symbol_id","chunk_id"];function nt(e){let t=new Vi(j(e)),n=[],r=[],i=[];try{return t.transaction(()=>{Ki(t,n),Ee(t,"idx_global_symbols_symbol")?.join("\0")==="symbol"&&ir(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")):Ee(t,"idx_global_symbols_symbol")&&i.push("idx_global_symbols_symbol");let a=Ee(t,"idx_chunks_doc_id"),o=ir(t,"chunks").some(s=>s.name!=="idx_chunks_doc_id"&&s.columns.length>1&&s.columns[0]==="document_id");a?.join("\0")==="document_id"&&o?(t.exec('DROP INDEX "idx_chunks_doc_id"'),r.push("idx_chunks_doc_id")):a&&i.push("idx_chunks_doc_id"),t.exec("ANALYZE")})(),{added:n,removed:r,retained:i,analyzed:!0}}catch(a){if(a.code==="SQLITE_NOTADB")return{added:[],removed:[],retained:[],analyzed:!1,skippedReason:"not-a-sqlite-database"};throw a}finally{t.close()}}function Ki(e,t){let n=ar(e,Pe);if(n){let r=n.columns.join("\0")===Qi.join("\0"),i=/\bWHERE\s+role\s*=\s*1\b/iu.test(n.sql??"");if(!r||!i||n.table!=="mentions")throw new Error(`${Pe} exists with an incompatible definition`);return}e.exec(`CREATE INDEX "${Pe}" ON mentions(symbol_id, chunk_id) WHERE role = 1`),t.push(Pe)}function ir(e,t){return e.prepare(`PRAGMA index_list('${t.replaceAll("'","''")}')`).all().map(n=>({name:n.name,unique:n.unique===1,columns:Ee(e,n.name)??[]}))}function Ee(e,t){return ar(e,t)?.columns??null}function ar(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{createHash as Zi}from"crypto";import{existsSync as rt,readdirSync as ea}from"fs";import{dirname as it,join as Ie,relative as ta,resolve as at,sep as or}from"path";function sr(e,t){let n=t.includes("."),r={};for(let a of t)r[a]=[];let i=[];for(let a of e){let o=ur(a.path,t);o?r[o].push(a):n?r["."].push(a):i.push(a)}return{files:r,shared:i}}function cr(e,t){let n=new Map;for(let i of e){let a=t[i]?.packageName;a&&n.set(a,i)}let r=new Map;for(let i of e)r.set(i,new Set);for(let i of e){let a=t[i],o=r.get(i);if(!a||a.parseFailed){for(let s of e)s!==i&&o.add(s);continue}for(let s of a.dependencyNames){let c=n.get(s);c&&c!==i&&o.add(c)}for(let s of[...a.pathsTargets,...a.referencesPaths]){let c=ur(s,e);c&&c!==i&&o.add(c)}}return na(e,r)}function dr(e,t,n){let r={};for(let i of e){let a=new Map;for(let o of t.files[i]??[])a.set(o.path,o);for(let o of n[i]??[])for(let s of t.files[o]??[])a.set(s.path,s);for(let o of t.shared)a.set(o.path,o);r[i]={files:[...a.values()].sort((o,s)=>o.path.localeCompare(s.path))}}return r}function ot(e){if(e===".")return"root";let t=Zi("sha256").update(e).digest("hex").slice(0,8);return`${e.split("/").join("__")}-${t}`}function lr(e,t){let n=at(e),r={};for(let i of t)r[i]=ra(n,i);return r}function ur(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 na(e,t){let n={};for(let r of e){let i=new Set,a=[...t.get(r)??[]];for(;a.length>0;){let o=a.pop();if(!(o===r||i.has(o))){i.add(o);for(let s of t.get(o)??[])s!==r&&!i.has(s)&&a.push(s)}}n[r]=[...i].sort((o,s)=>o.localeCompare(s))}return n}function ra(e,t){let n=t==="."?e:Ie(e,t),r=ia(n),i=aa(n),a=i?oa(i,e):{pathsTargets:[],referencesPaths:[],failed:!1};return{packageName:r.name,dependencyNames:r.dependencyNames,pathsTargets:a.pathsTargets,referencesPaths:a.referencesPaths,parseFailed:r.failed||a.failed}}function ia(e){let t=Ie(e,"package.json");if(!rt(t))return{name:void 0,dependencyNames:[],failed:!1};let n=st(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 a of["dependencies","devDependencies","peerDependencies"]){let o=n.value[a];if(o&&typeof o=="object"&&!Array.isArray(o))for(let s of Object.keys(o))i.add(s)}return{name:r,dependencyNames:[...i],failed:!1}}function aa(e){let t=Ie(e,"tsconfig.json");if(rt(t))return t;let n;try{n=ea(e).filter(r=>/^tsconfig.*\.json$/.test(r))}catch{return}return n.sort((r,i)=>r.localeCompare(i)),n.length>0?Ie(e,n[0]):void 0}function oa(e,t){let n=st(e);if(!n.ok)return{pathsTargets:[],referencesPaths:[],failed:!0};let r=sa(n.value,e,t),i=pr(e,n.value,t,0);return{pathsTargets:i.pathsTargets,referencesPaths:r,failed:i.failed}}function sa(e,t,n){let r=e.references;if(!Array.isArray(r))return[];let i=it(t),a=new Set;for(let o of r){if(!o||typeof o!="object")continue;let s=o.path;if(typeof s!="string"||s.trim()==="")continue;let c=gr(s,i,n);c&&a.add(c)}return[...a]}function pr(e,t,n,r){let i=ca(t);if(i)return{pathsTargets:da(i,it(e),n),failed:!1};if(r>=5)return{pathsTargets:[],failed:!1};let a=la(t.extends,e,n);if(!a)return{pathsTargets:[],failed:!1};let o=st(a);return o.ok?pr(a,o.value,n,r+1):{pathsTargets:[],failed:!0}}function ca(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 da(e,t,n){let r=new Set;for(let i of Object.values(e))if(Array.isArray(i))for(let a of i){if(typeof a!="string")continue;let o=gr(a,t,n);o&&r.add(o)}return[...r]}function la(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=at(it(t),r);if(i.endsWith(".json")||(i=`${i}.json`),!i.split(or).includes("node_modules")&&$e(n,i)&&rt(i))return i}function gr(e,t,n){let r=e.replace(/\/?\*+$/,""),i=at(t,r===""?".":r);if(!$e(n,i))return;let o=ta(n,i).split(or).join("/");return o===""?".":o}function ua(e){let t="",n=0,r=!1,i=e.length;for(;n<i;){let a=e[n];if(r){if(t+=a,a==="\\"&&n+1<i){t+=e[n+1],n+=2;continue}a==='"'&&(r=!1),n+=1;continue}if(a==='"'){r=!0,t+=a,n+=1;continue}if(a==="/"&&e[n+1]==="/"){for(n+=2;n<i&&e[n]!==`
228
+ `);l.set(d,u.digest("hex"))}return l}function L(e,t){return e.prepare(t).get().value}import Vi from"better-sqlite3";var Pe="idx_mentions_definitions",Qi=["symbol_id","chunk_id"];function nt(e){let t=new Vi(k(e)),n=[],r=[],i=[];try{return t.transaction(()=>{Ki(t,n),Ee(t,"idx_global_symbols_symbol")?.join("\0")==="symbol"&&ir(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")):Ee(t,"idx_global_symbols_symbol")&&i.push("idx_global_symbols_symbol");let a=Ee(t,"idx_chunks_doc_id"),o=ir(t,"chunks").some(s=>s.name!=="idx_chunks_doc_id"&&s.columns.length>1&&s.columns[0]==="document_id");a?.join("\0")==="document_id"&&o?(t.exec('DROP INDEX "idx_chunks_doc_id"'),r.push("idx_chunks_doc_id")):a&&i.push("idx_chunks_doc_id"),t.exec("ANALYZE")})(),{added:n,removed:r,retained:i,analyzed:!0}}catch(a){if(a.code==="SQLITE_NOTADB")return{added:[],removed:[],retained:[],analyzed:!1,skippedReason:"not-a-sqlite-database"};throw a}finally{t.close()}}function Ki(e,t){let n=ar(e,Pe);if(n){let r=n.columns.join("\0")===Qi.join("\0"),i=/\bWHERE\s+role\s*=\s*1\b/iu.test(n.sql??"");if(!r||!i||n.table!=="mentions")throw new Error(`${Pe} exists with an incompatible definition`);return}e.exec(`CREATE INDEX "${Pe}" ON mentions(symbol_id, chunk_id) WHERE role = 1`),t.push(Pe)}function ir(e,t){return e.prepare(`PRAGMA index_list('${t.replaceAll("'","''")}')`).all().map(n=>({name:n.name,unique:n.unique===1,columns:Ee(e,n.name)??[]}))}function Ee(e,t){return ar(e,t)?.columns??null}function ar(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{createHash as Zi}from"crypto";import{existsSync as rt,readdirSync as ea}from"fs";import{dirname as it,join as Ie,relative as ta,resolve as at,sep as or}from"path";function sr(e,t){let n=t.includes("."),r={};for(let a of t)r[a]=[];let i=[];for(let a of e){let o=ur(a.path,t);o?r[o].push(a):n?r["."].push(a):i.push(a)}return{files:r,shared:i}}function cr(e,t){let n=new Map;for(let i of e){let a=t[i]?.packageName;a&&n.set(a,i)}let r=new Map;for(let i of e)r.set(i,new Set);for(let i of e){let a=t[i],o=r.get(i);if(!a||a.parseFailed){for(let s of e)s!==i&&o.add(s);continue}for(let s of a.dependencyNames){let c=n.get(s);c&&c!==i&&o.add(c)}for(let s of[...a.pathsTargets,...a.referencesPaths]){let c=ur(s,e);c&&c!==i&&o.add(c)}}return na(e,r)}function dr(e,t,n){let r={};for(let i of e){let a=new Map;for(let o of t.files[i]??[])a.set(o.path,o);for(let o of n[i]??[])for(let s of t.files[o]??[])a.set(s.path,s);for(let o of t.shared)a.set(o.path,o);r[i]={files:[...a.values()].sort((o,s)=>o.path.localeCompare(s.path))}}return r}function ot(e){if(e===".")return"root";let t=Zi("sha256").update(e).digest("hex").slice(0,8);return`${e.split("/").join("__")}-${t}`}function lr(e,t){let n=at(e),r={};for(let i of t)r[i]=ra(n,i);return r}function ur(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 na(e,t){let n={};for(let r of e){let i=new Set,a=[...t.get(r)??[]];for(;a.length>0;){let o=a.pop();if(!(o===r||i.has(o))){i.add(o);for(let s of t.get(o)??[])s!==r&&!i.has(s)&&a.push(s)}}n[r]=[...i].sort((o,s)=>o.localeCompare(s))}return n}function ra(e,t){let n=t==="."?e:Ie(e,t),r=ia(n),i=aa(n),a=i?oa(i,e):{pathsTargets:[],referencesPaths:[],failed:!1};return{packageName:r.name,dependencyNames:r.dependencyNames,pathsTargets:a.pathsTargets,referencesPaths:a.referencesPaths,parseFailed:r.failed||a.failed}}function ia(e){let t=Ie(e,"package.json");if(!rt(t))return{name:void 0,dependencyNames:[],failed:!1};let n=st(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 a of["dependencies","devDependencies","peerDependencies"]){let o=n.value[a];if(o&&typeof o=="object"&&!Array.isArray(o))for(let s of Object.keys(o))i.add(s)}return{name:r,dependencyNames:[...i],failed:!1}}function aa(e){let t=Ie(e,"tsconfig.json");if(rt(t))return t;let n;try{n=ea(e).filter(r=>/^tsconfig.*\.json$/.test(r))}catch{return}return n.sort((r,i)=>r.localeCompare(i)),n.length>0?Ie(e,n[0]):void 0}function oa(e,t){let n=st(e);if(!n.ok)return{pathsTargets:[],referencesPaths:[],failed:!0};let r=sa(n.value,e,t),i=pr(e,n.value,t,0);return{pathsTargets:i.pathsTargets,referencesPaths:r,failed:i.failed}}function sa(e,t,n){let r=e.references;if(!Array.isArray(r))return[];let i=it(t),a=new Set;for(let o of r){if(!o||typeof o!="object")continue;let s=o.path;if(typeof s!="string"||s.trim()==="")continue;let c=gr(s,i,n);c&&a.add(c)}return[...a]}function pr(e,t,n,r){let i=ca(t);if(i)return{pathsTargets:da(i,it(e),n),failed:!1};if(r>=5)return{pathsTargets:[],failed:!1};let a=la(t.extends,e,n);if(!a)return{pathsTargets:[],failed:!1};let o=st(a);return o.ok?pr(a,o.value,n,r+1):{pathsTargets:[],failed:!0}}function ca(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 da(e,t,n){let r=new Set;for(let i of Object.values(e))if(Array.isArray(i))for(let a of i){if(typeof a!="string")continue;let o=gr(a,t,n);o&&r.add(o)}return[...r]}function la(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=at(it(t),r);if(i.endsWith(".json")||(i=`${i}.json`),!i.split(or).includes("node_modules")&&$e(n,i)&&rt(i))return i}function gr(e,t,n){let r=e.replace(/\/?\*+$/,""),i=at(t,r===""?".":r);if(!$e(n,i))return;let o=ta(n,i).split(or).join("/");return o===""?".":o}function ua(e){let t="",n=0,r=!1,i=e.length;for(;n<i;){let a=e[n];if(r){if(t+=a,a==="\\"&&n+1<i){t+=e[n+1],n+=2;continue}a==='"'&&(r=!1),n+=1;continue}if(a==='"'){r=!0,t+=a,n+=1;continue}if(a==="/"&&e[n+1]==="/"){for(n+=2;n<i&&e[n]!==`
229
229
  `;)n+=1;continue}if(a==="/"&&e[n+1]==="*"){for(n+=2;n<i&&!(e[n]==="*"&&e[n+1]==="/");)n+=1;n+=2;continue}t+=a,n+=1}return t}function st(e){try{let t=se(e,{maxBytes:Pt,inputKind:"TypeScript project manifest"}),n=JSON.parse(ua(t));return n&&typeof n=="object"&&!Array.isArray(n)?{ok:!0,value:n}:{ok:!1}}catch{return{ok:!1}}}import{writeFileSync as Ta}from"fs";import{deserializeSCIP as wa,PositionEncoding as ve,serializeSCIP as Da}from"@c4312/scip";import{rmSync as ga}from"fs";import fa from"better-sqlite3";var ma=200,ha=[`CREATE TABLE documents (
230
230
  id INTEGER PRIMARY KEY,
231
231
  language TEXT,
@@ -266,13 +266,13 @@ import{a as ne,c as re}from"./chunk-YTJHCGYB.js";import{a as jn}from"./chunk-ILM
266
266
  end_char INTEGER NOT NULL,
267
267
  FOREIGN KEY (document_id) REFERENCES documents(id),
268
268
  FOREIGN KEY (symbol_id) REFERENCES global_symbols(id)
269
- )`],ya=["CREATE INDEX idx_chunks_line_range ON chunks(document_id, start_line, end_line)","CREATE INDEX idx_mentions_symbol_id_role ON mentions(symbol_id, role)","CREATE INDEX idx_defn_enclosing_ranges_symbol_id ON defn_enclosing_ranges(symbol_id)","CREATE INDEX idx_defn_enclosing_ranges_document ON defn_enclosing_ranges(document_id, start_line, end_line)","CREATE INDEX idx_chunks_doc_id ON chunks(document_id)","CREATE INDEX idx_global_symbols_symbol ON global_symbols(symbol)"];function mr(e,t){ga(e,{force:!0});let n=new fa(j(e));try{n.pragma("journal_mode = WAL"),n.pragma("synchronous = NORMAL"),n.pragma("temp_store = MEMORY"),n.pragma("foreign_keys = ON");for(let r of ha)n.exec(r);n.transaction(()=>ba(n,t)).immediate(),n.transaction(()=>{for(let r of ya)n.exec(r)}).immediate()}finally{n.close()}}function ba(e,t){let n=Sa(e);for(let r of Ra(e,n,t))xa(e,n,r),Pa(e,n,r)}function Sa(e){let t=e.prepare("INSERT INTO global_symbols (symbol, display_name, kind, documentation, enclosing_symbol) VALUES (?, ?, ?, ?, ?)"),n=new Map,r=i=>{let a=n.get(i.symbol);if(a!==void 0)return a;let o=Number(t.run(i.symbol,i.displayName||null,i.kind||null,i.documentation.join(`
269
+ )`],ya=["CREATE INDEX idx_chunks_line_range ON chunks(document_id, start_line, end_line)","CREATE INDEX idx_mentions_symbol_id_role ON mentions(symbol_id, role)","CREATE INDEX idx_defn_enclosing_ranges_symbol_id ON defn_enclosing_ranges(symbol_id)","CREATE INDEX idx_defn_enclosing_ranges_document ON defn_enclosing_ranges(document_id, start_line, end_line)","CREATE INDEX idx_chunks_doc_id ON chunks(document_id)","CREATE INDEX idx_global_symbols_symbol ON global_symbols(symbol)"];function mr(e,t){ga(e,{force:!0});let n=new fa(k(e));try{n.pragma("journal_mode = WAL"),n.pragma("synchronous = NORMAL"),n.pragma("temp_store = MEMORY"),n.pragma("foreign_keys = ON");for(let r of ha)n.exec(r);n.transaction(()=>ba(n,t)).immediate(),n.transaction(()=>{for(let r of ya)n.exec(r)}).immediate()}finally{n.close()}}function ba(e,t){let n=Sa(e);for(let r of Ra(e,n,t))xa(e,n,r),Pa(e,n,r)}function Sa(e){let t=e.prepare("INSERT INTO global_symbols (symbol, display_name, kind, documentation, enclosing_symbol) VALUES (?, ?, ?, ?, ?)"),n=new Map,r=i=>{let a=n.get(i.symbol);if(a!==void 0)return a;let o=Number(t.run(i.symbol,i.displayName||null,i.kind||null,i.documentation.join(`
270
270
  `)||null,i.enclosingSymbol||null).lastInsertRowid);return n.set(i.symbol,o),o};return{declared:r,referenced:i=>r({symbol:i,displayName:null,kind:null,documentation:[],enclosingSymbol:null})}}function Ra(e,t,n){let r=e.prepare("INSERT INTO documents (language, relative_path, position_encoding, text) VALUES (?, ?, ?, ?)"),i=[],a=new Set;for(let o of n){if(!o.relativePath)throw new Error("document relative path must not be empty");if(a.has(o.relativePath))continue;a.add(o.relativePath);let s=Number(r.run(o.language||null,o.relativePath,o.positionEncoding,o.text||null).lastInsertRowid);for(let c of Ea(o.symbols)){if(!c.symbol)throw new Error(`empty symbol in symbol information for document ${o.relativePath}`);he(c.symbol)||t.declared(c)}i.push({id:s,relativePath:o.relativePath,occurrences:Ia(o.occurrences)})}return i}function xa(e,t,n){let r=e.prepare(`INSERT INTO defn_enclosing_ranges (document_id, symbol_id, start_line, start_char, end_line, end_char)
271
- VALUES (?, ?, ?, ?, ?, ?)`);for(let i of n.occurrences){if((i.roles&1)===0||he(i.symbol)||!i.enclosingRange)continue;let[a,o,s,c]=_a(i,n.relativePath);r.run(n.id,t.referenced(i.symbol),a,o,s,c)}}function Pa(e,t,n){let r=e.prepare("INSERT INTO chunks (document_id, chunk_index, start_line, end_line, occurrences) VALUES (?, ?, ?, ?, ?)"),i=e.prepare("INSERT INTO mentions (chunk_id, symbol_id, role) VALUES (?, ?, ?)");va(n.occurrences).forEach((a,o)=>{let s=Number(r.run(n.id,o,a.startLine,a.endLine,rn(a.occurrences)).lastInsertRowid),c=new Map;for(let l of a.occurrences){if(he(l.symbol))continue;let d=c.get(l.symbol)??new Set;d.add(l.roles),c.set(l.symbol,d)}for(let[l,d]of c){let p=t.referenced(l);for(let u of d)i.run(s,p,u)}})}function Ea(e){let t=new Map;for(let n of e){let r=t.get(n.symbol);if(!r){t.set(n.symbol,n);continue}t.set(n.symbol,{...r,documentation:[...r.documentation,...n.documentation.filter(i=>!r.documentation.includes(i))]})}return[...t.values()].sort((n,r)=>hr(n.symbol,r.symbol))}function Ia(e){let t=[...e].sort((r,i)=>fr(r.range,i.range)||hr(r.symbol,i.symbol)),n=[];for(let r of t){let i=n.at(-1);i&&i.symbol===r.symbol&&fr(i.range,r.range)===0?n[n.length-1]={...i,roles:i.roles|r.roles}:n.push(r)}return n}function va(e){let t=[],n=0;for(;n<e.length;){let r=Math.min(e.length,n+ma);for(;r<e.length&&e[r-1].range[0]===e[r].range[0];)r+=1;t.push({startLine:e[n].range[0],endLine:e[r-1].range[0],occurrences:e.slice(n,r)}),n=r}return t}function _a(e,t){let n=e.enclosingRange,[r,i,a,o]=n;if(!(r>=0&&i>=0&&(a>r&&o>=0||a===r&&o>=i)))throw new Error(`bad enclosing range ${JSON.stringify(n)} for symbol ${e.symbol} in document ${t}`);return n}function fr(e,t){return e[0]-t[0]||e[1]-t[1]||e[2]-t[2]||e[3]-t[3]}function hr(e,t){return e<t?-1:e>t?1:0}var Fa={[ve.UnspecifiedPositionEncoding]:null,[ve.UTF8CodeUnitOffsetFromLineStart]:"UTF-8",[ve.UTF16CodeUnitOffsetFromLineStart]:"UTF-16",[ve.UTF32CodeUnitOffsetFromLineStart]:"UTF-32"};function br(e,t,n){let r=wa(A(e,{inputKind:"SCIP index store input",maxBytes:Q})),i={removedDefinitionOccurrences:0,touchedDocuments:0};if(n.sanitize){let a=Zt(r);a.touchedDocuments>0&&(Ta(e,Buffer.from(Da(a.index))),r=a.index),i={removedDefinitionOccurrences:a.removedDefinitionOccurrences,touchedDocuments:a.touchedDocuments}}return mr(t,r.documents.map(ka)),i}function ka(e){let t=Fa[e.positionEncoding];if(t===void 0)throw new Error(`unknown position encoding ${e.positionEncoding} in ${e.relativePath}`);return{relativePath:e.relativePath,language:e.language||null,positionEncoding:t,text:e.text||null,symbols:e.symbols.map(n=>({symbol:n.symbol,displayName:n.displayName||null,kind:n.kind||null,documentation:n.documentation,enclosingSymbol:n.enclosingSymbol||null})),occurrences:e.occurrences.flatMap(n=>{let r=yr(n.range);return r?[{symbol:n.symbol,roles:n.symbolRoles,range:r,enclosingRange:yr(n.enclosingRange)}]:[]})}}function yr(e){return e.length===3?[e[0],e[1],e[0],e[2]]:e.length===4?[e[0],e[1],e[2],e[3]]:null}import{createHash as Ba}from"crypto";import{existsSync as ct,statSync as Wa,writeFileSync as dt}from"fs";import{join as qa}from"path";import{randomUUID as ja}from"crypto";import{existsSync as Oa}from"fs";var La=12e4,Na=5,_e=class{projectRoot;cacheDir;baseGeneration;timeoutMs;runtime;mailboxLimits;constructor(t,n={}){this.projectRoot=wt(t.projectRoot),this.cacheDir=t.cacheDir,this.baseGeneration=t.baseGeneration,this.timeoutMs=n.timeoutMs??Ua(),this.runtime=n.runtime??Ga,this.mailboxLimits=n.mailboxLimits??{}}request(t){let n=wn(this.cacheDir),r=_n(this.cacheDir),i=Xe(n.statePath);if(!Sr(i,this.projectRoot,this.runtime))throw new Error("Compatible TypeScript index service is not running.");let a=this.runtime.now(),o=a+this.timeoutMs,s=(this.runtime.monotonicNow??S)()+this.timeoutMs,c=En("typescript-index-v4",{baseGeneration:this.baseGeneration,request:t}),l=In(c),d=vn(r,{mailboxVersion:Pn,operationKey:c,clientId:this.runtime.randomId(),enqueuedAtMs:a,deadlineAtMs:o,protocolVersion:Se,id:l,baseGeneration:this.baseGeneration,request:t},{nowMs:a,limits:this.mailboxLimits});for(;(this.runtime.monotonicNow??S)()<=s;){if(Oa(d.responsePath))return Aa(se(d.responsePath,{maxBytes:this.mailboxLimits.maxItemBytes??64*1024*1024,inputKind:"TypeScript index mailbox response"}),l,c,this.baseGeneration,t.producerIdentity,t.affectedFiles);let p=Xe(n.statePath);if(!Sr(p,this.projectRoot,this.runtime))throw new Error("TypeScript index service stopped while processing a request.");this.runtime.sleep(Na)}throw new Error(`TypeScript index service timed out after ${this.timeoutMs}ms.`)}};function Sr(e,t,n){let r=e?.processIdentity?n.readProcessIdentity?.(e.pid):null;return e!==null&&e.projectRoot===t&&e.typescriptIndex?.protocolVersion===Se&&n.isProcessAlive(e.pid)&&(!e.processIdentity||r!=null&&ee(e.processIdentity,r))}function Aa(e,t,n,r,i,a){let o=JSON.parse(e);if(o.protocolVersion!==Se||o.id!==t||o.operationKey!==n||o.ok===!0&&o.baseGeneration!==r)throw new Error("TypeScript index service wrote an incompatible response.");if(o.ok!==!0)throw new Error(typeof o.error=="string"?o.error:"TypeScript index service request failed.");let s=Ma(o.response,i),c=[...new Set(a)].sort(),l=s.fragments.map(d=>d.relativePath).sort();if(JSON.stringify(l)!==JSON.stringify(c))throw new Error("TypeScript index service omitted or added an affected document.");return s}function Ma(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(a=>{if(!a||typeof a.relativePath!="string"||a.bytesBase64!==null&&typeof a.bytesBase64!="string"||typeof a.occurrences!="number"||!Number.isInteger(a.occurrences)||a.occurrences<0||typeof a.symbols!="number"||!Number.isInteger(a.symbols)||a.symbols<0||!Array.isArray(a.referenceFragments)||!a.referenceFragments.every(Ca)||r.has(a.relativePath))throw new Error("TypeScript index service wrote an invalid fragment.");r.add(a.relativePath);let o=a.bytesBase64===null?null:$a(a.bytesBase64);return{relativePath:a.relativePath,bytes:o,occurrences:a.occurrences,symbols:a.symbols,referenceFragments:a.referenceFragments}});return{producerIdentity:n.producerIdentity,cold:n.cold,durationMs:n.durationMs,fragments:i}}function Ca(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 $a(e){let t=Buffer.from(e,"base64");if(t.toString("base64")!==e)throw new Error("TypeScript index service wrote invalid base64.");return t}function Ua(){let e=Number(process.env.SCIP_TYPESCRIPT_INDEX_TIMEOUT_MS);return Number.isInteger(e)&&e>0?e:La}var Ga={now:Date.now,monotonicNow:S,randomId:ja,sleep(e){let t=new Int32Array(new SharedArrayBuffer(4));Atomics.wait(t,0,0,e)},isProcessAlive:J,readProcessIdentity:H};function Ha(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=de(e.previousSnapshot,e.currentSnapshot);if(n.changes.length===0)return{eligible:!1,reason:"no changed project inputs"};if(n.changes.some(d=>d.kind!=="modified"||d.inputKind!=="source"||!Be(d.path)))return{eligible:!1,reason:"change is not a modified TypeScript source file"};let r=Re(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=Ja(r,t,e.graph);if(!i)return{eligible:!1,reason:"affected files cross or ambiguously match TypeScript projects"};let a=Rr(e.currentSnapshot,e.projectFiles,e.producerIdentity),o=Rr(e.previousSnapshot,e.projectFiles,e.producerIdentity);if(a!==o)return{eligible:!1,reason:"TypeScript fragment project identity changed"};let s=Pr(e.previousSnapshot,e.projectFiles,e.graph,e.producerIdentity,e.projectFiles);if(!s)return{eligible:!1,reason:"prior document identity unavailable"};let c=Pr(e.currentSnapshot,e.projectFiles,e.graph,e.producerIdentity,r.affectedFiles);if(!c)return{eligible:!1,reason:"next document identity unavailable"};let l=i.length===1?i[0]:void 0;return{eligible:!0,manifest:n,plan:r,projectIdentity:a,previousFragmentGeneration:xr(e.previousSnapshot,e.producerIdentity),nextFragmentGeneration:xr(e.currentSnapshot,e.producerIdentity),previousDocumentIdentities:s,nextDocumentIdentities:c,projects:i,...l?{tsconfigPath:l.tsconfigPath,projectArgument:l.projectArgument}:{}}}function Ja(e,t,n){let r=new Map;for(let a of e.affectedFiles){let o=za(a,t);if(!o)return null;let s=r.get(o)??[];s.push(a),r.set(o,s)}let i=[];for(let[a,o]of[...r].sort(([s],[c])=>s.localeCompare(c))){let s=new Set(o),c=e.changedFiles.filter(l=>s.has(l)||o.some(d=>Xa(d,l,n)));if(c.length===0)return null;i.push({projectArgument:a,tsconfigPath:a==="."?"tsconfig.json":`${a}/tsconfig.json`,modifiedFiles:c,affectedFiles:[...o].sort()})}return i}function za(e,t){let n=t.filter(a=>a==="."||e===a||e.startsWith(`${a}/`));if(n.length===0)return null;let r=[...new Set(n)].sort((a,o)=>Te(o)-Te(a)||a.localeCompare(o)),i=r[0];return r[1]&&Te(r[1])===Te(i)?null:i}function Te(e){return e==="."?0:e.split("/").filter(Boolean).length}function Xa(e,t,n){let r=new Set,i=[e];for(let a=0;a<i.length;a+=1){let o=i[a];if(!(!o||r.has(o))){r.add(o);for(let s of n.get(o)??[]){if(s===t)return!0;r.has(s)||i.push(s)}}}return!1}function Er(e){let t=S();try{if(!ct(e.previousDbPath)||!ct(e.previousShardPath))throw new Error("prior TypeScript graph or language shard unavailable");let n=performance.now(),r=ze();if(!r.available)throw new Error(r.reason);let i=performance.now()-n;n=performance.now();let a=new F({projectRoot:e.projectRoot,dbPath:e.previousDbPath,indexPath:e.previousIndexPath}),o,s;try{o=fe(a,{includeIgnored:!1}).filter(Be).sort(),s=me(a)}finally{a.close()}let c=performance.now()-n,l=Ha({projectMode:e.projectMode,workspaceProjects:e.projectMode==="workspace"?z(e.projectRoot,e.currentSnapshot.typescriptProjects):void 0,previousSnapshot:e.previousSnapshot,currentSnapshot:e.currentSnapshot,projectFiles:o,graph:s,producerIdentity:r.producerIdentity,rootTsconfigExists:ct(qa(e.projectRoot,"tsconfig.json"))});if(!l.eligible)throw new Error(l.reason);let d=Tn(e.previousDbPath);if(!d)throw new Error("published TypeScript base generation unavailable");n=performance.now();let p=new _e({projectRoot:e.projectRoot,cacheDir:e.cacheDir,baseGeneration:d}),u=l.projects.map(b=>p.request({kind:"emit-documents",tsconfigPath:b.tsconfigPath,projectArgument:b.projectArgument,projectIdentity:l.projectIdentity,producerIdentity:r.producerIdentity,modifiedFiles:b.modifiedFiles,affectedFiles:b.affectedFiles})),g=u.flatMap(b=>b.fragments),m=performance.now()-n,x=Wa(e.previousShardPath).size>=ln;n=performance.now();let _=x?null:A(e.previousShardPath,{inputKind:"TypeScript base SCIP shard",maxBytes:Q}),f=x?{completeIndexBytes:null,affectedIndexBytes:an(g)}:cn({packageVersion:r.packageVersion,baseIndexBytes:_,fragments:g}),y=performance.now()-n;n=performance.now(),x?un({cacheDir:e.cacheDir,previousGenerationIdentity:l.previousFragmentGeneration,nextGenerationIdentity:l.nextFragmentGeneration,producerIdentity:r.producerIdentity,projectIdentity:l.projectIdentity,baseShardCurrent:e.baseShardCurrent,fragments:g}):(on({cacheDir:e.cacheDir,packageVersion:r.packageVersion,indexBytes:_,producerIdentity:r.producerIdentity,projectIdentity:l.projectIdentity,generationIdentity:l.previousFragmentGeneration,documentIdentities:l.previousDocumentIdentities,allowUntrackedDocuments:!0}),sn({cacheDir:e.cacheDir,previousGenerationIdentity:l.previousFragmentGeneration,producerIdentity:r.producerIdentity,projectIdentity:l.projectIdentity,generationIdentity:l.nextFragmentGeneration,fragments:g,documentIdentities:l.nextDocumentIdentities}));let R=performance.now()-n;n=performance.now(),f.completeIndexBytes&&dt(e.candidateShardPath,f.completeIndexBytes),dt(e.candidateAffectedScipPath,f.affectedIndexBytes);let E=performance.now()-n,P={scipPath:x?e.previousShardPath:e.candidateShardPath,candidateScipPath:e.candidateShardPath,affectedScipPath:e.candidateAffectedScipPath,completeScipUpdated:!x,durationMs:S()-t,cold:u.some(b=>b.cold),changedFiles:l.plan.changedFiles,affectedFiles:l.plan.affectedFiles,producerIdentity:r.producerIdentity,previousFragmentGeneration:l.previousFragmentGeneration,nextFragmentGeneration:l.nextFragmentGeneration,manifest:l.manifest,plan:l.plan,projectFileCount:o.length,referenceFragmentsByFile:new Map(g.map(b=>[b.relativePath,b.referenceFragments])),timings:{runtimeMs:i,graphMs:c,requestMs:m,serviceMs:u.reduce((b,B)=>b+B.durationMs,0),assemblyMs:y,fragmentStoreMs:R,writeMs:E}};return e.onStatus(`Incremental TypeScript index emitted ${P.affectedFiles.length} affected document(s) across ${l.projects.length} project(s) in ${(P.durationMs/1e3).toFixed(3)}s (${P.cold?"cold":"warm"} service; ${x?"whole SCIP deferred":"whole SCIP current"}; runtime ${i.toFixed(0)}ms, graph ${c.toFixed(0)}ms, request ${m.toFixed(0)}ms, assembly ${y.toFixed(0)}ms, fragments ${R.toFixed(0)}ms, write ${E.toFixed(0)}ms).`),P}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 Ir(e){let t=ze();if(!t.available)throw new Error(t.reason);let n=pn({cacheDir:e.cacheDir,generationIdentity:e.generationIdentity,baseIndexBytes:A(e.baseShardPath,{inputKind:"TypeScript base SCIP shard",maxBytes:Q}),packageVersion:t.packageVersion});dt(e.candidateShardPath,n)}function Rr(e,t,n){let r=e.files.filter(i=>It(i.path,e.languages)!=="source").map(i=>({path:i.path,size:i.size,hash:i.hash})).sort((i,a)=>i.path.localeCompare(a.path));return lt(JSON.stringify({version:1,producerIdentity:n,pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:[...e.typescriptProjects].sort(),projectFiles:[...t].sort(),nonSourceInputs:r}))}function xr(e,t){return lt(JSON.stringify({version:1,producerIdentity:t,snapshot:e}))}function Pr(e,t,n,r,i){let a=new Set(e.files.map(c=>c.path)),o=Ht({projectFiles:t.filter(c=>a.has(c)),snapshot:e,graph:n,engineIdentity:r}),s=new Map;for(let c of i){let l=o.identityFor(c,"typescript-scip-document-v1");if(l.key){s.set(c,l.key);continue}if(a.has(c))return null;s.set(c,lt(JSON.stringify({version:1,producerIdentity:r,generatedDocument:c})))}return s}function lt(e){return Ba("sha256").update(e).digest("hex")}import{closeSync as Ya,existsSync as we,fstatSync as Va,lstatSync as Qa,openSync as Ka,renameSync as pt,rmSync as De,statSync as Za,writeSync as eo}from"fs";import{cpus as to}from"os";import{join as gt}from"path";function no(e,t){if(e.temporaryRootConfigContent===void 0)return null;let n=gt(t,"tsconfig.json"),r=Buffer.from(e.temporaryRootConfigContent,"utf8"),i;try{i=Ka(n,"wx",384)}catch(a){if(a.code==="EEXIST")return null;throw a}try{eo(i,r);let a=Va(i);return{path:n,content:r,device:a.dev,inode:a.ino}}finally{Ya(i)}}function ro(e){if(e)try{let t=Qa(e.path);if(!t.isFile()||t.dev!==e.device||t.ino!==e.inode||t.size!==e.content.byteLength)return;let n;try{n=A(e.path,{maxBytes:e.content.byteLength,inputKind:"temporary TypeScript index configuration"})}catch{return}if(!n.equals(e.content))return;De(e.path)}catch(t){if(t.code!=="ENOENT")throw t}}function io(e,t,n){if(!e.defaultOutputPath)return;let r=gt(t,e.defaultOutputPath);n!==r&&we(r)&&pt(r,n)}function ao(e,t,n){if(!e.defaultOutputPath)return null;let r=gt(t,e.defaultOutputPath);if(r===n)return null;let i=`${n}.default-output-backup`;return De(i,{force:!0}),we(r)?(pt(r,i),{defaultOutputPath:r,backupPath:i}):{defaultOutputPath:r,backupPath:null}}function oo(e){e&&(De(e.defaultOutputPath,{force:!0}),e.backupPath&&we(e.backupPath)&&pt(e.backupPath,e.defaultOutputPath))}function so(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,to().length));return Math.max(1,Math.min(e,Math.floor(r)))}async function _r(e,t,n,r,i){D(i,"Reindex cancelled by its owner.");let a=e.filter(d=>d.config.defaultOutputPath),o=e.filter(d=>!d.config.defaultOutputPath),s=[],c=so(o.length,r),l=await jn(o,c,d=>ut(d,t,n,i));if(c>1){let d=new Map;for(let p of l.filter(u=>u.result.skipped&&u.retryable)){let u=o.find(g=>g.id===p.result.id);u&&(n(`Retrying ${u.label} indexer serially after parallel failure...`),D(i,"Reindex cancelled by its owner."),d.set(u.id,(await ut(u,t,n,i)).result))}s.push(...l.map(({result:p})=>d.get(p.id)??p))}else s.push(...l.map(({result:d})=>d));for(let d of a)D(i,"Reindex cancelled by its owner."),s.push((await ut(d,t,n,i)).result);return s.sort((d,p)=>e.findIndex(u=>u.id===d.id)-e.findIndex(u=>u.id===p.id))}async function ut(e,t,n,r){D(r,"Reindex cancelled by its owner."),n(`Indexing ${e.label} with ${e.resolvedBinary}...`),De(e.scipPath,{force:!0});let i=ao(e.config,t,e.scipPath),a=no(e,t),o=[e.binary,...e.args].join(" "),s=S();try{e.trustedProjectTool&&Gt(t,e.trustedProjectTool);let l=Lt(e.binary,e.args),d=await kn({command:l.binary,args:l.args,label:`${e.label} indexer`,cwd:t,env:e.env,timeoutMs:co(),maxStdoutBytes:50*1024*1024,maxStderrBytes:50*1024*1024,signal:r});if(d.status!==0){let p=d.stderr.trim();throw new Error(`${e.resolvedBinary} exited with status ${d.status}${p?`:
272
- ${p}`:""}`)}io(e.config,t,e.scipPath)}catch(l){if(r?.aborted)throw Dt(r,"Reindex cancelled by its owner.");let d=l instanceof Error?l.message:String(l),p=`${e.resolvedBinary} indexer failed: ${d.split(`
273
- `)[0]}`,u=e.label===e.language?p:`${e.label}: ${p}`;return n(`Skipping ${e.label}: ${p}`),{result:{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,durationMs:S()-s,command:o,skipped:{language:e.language,reason:u}},retryable:lo(l)}}finally{oo(i),ro(a)}if(!we(e.scipPath)){let l=`${e.resolvedBinary} indexer completed but did not produce ${e.scipPath}`,d=e.label===e.language?l:`${e.label}: ${l}`;return n(`Skipping ${e.label}: ${l}`),{result:{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,durationMs:S()-s,command:o,skipped:{language:e.language,reason:d}},retryable:!1}}let c;try{c=Za(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:S()-s,command:o,outputBytes:c},retryable:!1}}function co(){let e=Number(process.env.CODEBASEIQ_INDEXER_TIMEOUT_MS);return Number.isFinite(e)&&e>0?Math.floor(e):Dn.indexer}function lo(e){return e instanceof Fn?e.kind==="spawn"&&vr(e.cause):vr(e)}function vr(e){let t=e?.code;return t==="EAGAIN"||t==="ENOMEM"||t==="EMFILE"||t==="ENFILE"||t==="ETXTBSY"}import{execFileSync as wr}from"child_process";import{homedir as Tr,platform as uo}from"os";import{delimiter as po,join as Fe}from"path";function Dr(e,t){let n=e.installMethods,r=ge(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(!Ot(i.prerequisite))continue;let a=go(i);t(`Installing immutable ${i.identity} via ${i.label} into ${a}; expected executable: ${r}.`);try{wr(i.binary,i.args,{stdio:"inherit",windowsHide:!0,timeout:3e5,env:process.env,shell:uo()==="win32"});let o=te(e);if(o){let s=o===e.indexerBinary?"":` (using ${o})`;return t(`Successfully installed ${i.identity} via ${i.label}${s}; resolved executable: ${o}.`),!0}t(`${i.label} command completed but ${r} was not found on PATH`)}catch(o){let s=o instanceof Error?o.message:String(o);t(`${i.label} install failed: ${s}`)}}return t(`Could not auto-install ${r}.`),e.installUrl&&t(`Install manually from: ${e.installUrl}`),!1}function go(e){if(e.binary==="npm")return ft("npm",["root","-g"])??e.destination;if(e.binary==="go"){let t=ft("go",["env","GOBIN"]);if(t)return t;let n=ft("go",["env","GOPATH"]);if(n)return Fe(n.split(po)[0],"bin")}return e.binary==="dotnet"?Fe(process.env.DOTNET_CLI_HOME??Tr(),".dotnet","tools"):e.binary==="dart"?Fe(process.env.PUB_CACHE??Fe(Tr(),".pub-cache"),"bin"):e.destination}function ft(e,t){try{return wr(e,t,{stdio:["ignore","pipe","ignore"],windowsHide:!0,encoding:"utf8",timeout:1e4,killSignal:"SIGKILL",env:process.env}).trim()||null}catch{return null}}async function zd(e){let{projectRoot:t,maxHeapMb:n=8192,onStatus:r=console.log}=e,i=e.skipAutoInstall===!0||e.installMissing!==!0,a=So(e),o=Date.now(),s=S();je(h(a.outputScip),{recursive:!0}),je(h(a.outputDb),{recursive:!0});let c=e.languages??We(t);if(c.length===0)throw new Error("No supported languages detected in this project. Looked for: tsconfig.json, Cargo.toml, go.mod, pyproject.toml, etc.");r(`Detected languages: ${c.join(", ")}`);let l=ue("reindex.fingerprint",()=>Mt(t,c,{pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:e.typescriptProjects,clojureConfigPath:e.clojureConfigPath}),{languages:c.length}),d,p;if(e.skipIfUnchanged!==!1&&!hn(t,a.outputDb)&&Fr(a.outputScip)===Fr(v(h(a.outputDb),"index.scip"))){let f=pe(t);if(d=f?.clean?ye(f,l):void 0,f&&!f.clean&&!bo(a)){let y=yn(f,c,{pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:e.typescriptProjects,clojureConfigPath:e.clojureConfigPath});if(y)try{be({snapshot:y.snapshot,manifest:y.manifest,targetCacheDir:h(a.outputDb),targetProjectRoot:t,persistLease:!1}),xn(y.snapshot,h(a.outputDb)),r(`Forked shared baseline ${y.snapshot.generationId.slice(0,12)} for dirty worktree reindex`)}catch(R){r(`Shared baseline fork failed; continuing locally: ${N(R)}`)}}else if(d){let y=Je(d);if(y){if(!yo(a,l))try{be({snapshot:d,manifest:y,targetCacheDir:h(a.outputDb),targetProjectRoot:t}),r(`Attached shared generation ${d.generationId.slice(0,12)}`)}catch(R){r(`Shared generation attach failed; continuing locally: ${N(R)}`)}}else{let R=await Sn(d);if(R.kind==="owner")p=R.release;else if(R.kind==="generation-ready"){let E=Je(d);if(E)try{be({snapshot:d,manifest:E,targetCacheDir:h(a.outputDb),targetProjectRoot:t,action:"waited"}),r(`Attached shared generation ${d.generationId.slice(0,12)} after waiting`)}catch(P){r(`Shared generation attach failed after waiting; continuing locally: ${N(P)}`)}}else r("Shared generation build lock timed out; continuing with an isolated local reindex")}}}let g=jt(v(h(a.outputDb),"cache-lifecycle.lock"),{waitMs:3e4});if(!g)throw p?.(),new Error(`Could not acquire codebaseiq cache lifecycle lock for ${h(a.outputDb)}.`);let m;try{m=await Z("reindex.lock",()=>Ho(v(h(a.outputDb),"index.lock"),{projectRoot:t,trigger:e.trigger,onStatus:r}),{languages:c.length})}catch(f){throw g.release(),p?.(),f}let x=null,_=Ln();try{mn(a.outputDb,a.outputScip,a.metaPath);let f=Eo(h(a.outputDb));f.removed>0&&r(`Removed ${f.removed} abandoned reindex workspace(s)`);for(let W of f.errors)r(`Could not remove abandoned reindex workspace: ${W}`);let y=null,R=ue("reindex.reuse-check",()=>(y=Ro({opts:e,paths:a,languages:c,fingerprint:l,start:o,monotonicStart:s,onStatus:r}),y),()=>({languages:c.length,reused:y!==null}));if(R){kr({snapshot:d,paths:a,projectRoot:t,fingerprint:l,onStatus:r});let W=qe(a.outputDb,R);return W.state==="failed"&&r(`Warning: reindex succeeded, but activity telemetry was not recorded: ${W.reason}`),Ue(t,h(a.outputDb)),R}let E=Po(a);x=E.runDir;let P,b=await Z("reindex.fresh",async()=>(P=await Io({opts:e,languages:c,projectRoot:t,paths:a,tempPaths:E,fingerprint:l,start:o,monotonicStart:s,maxHeapMb:n,skipAutoInstall:i,onStatus:r,writeTelemetry:_}),P),()=>({languages:c.length,reused:P?.reused,skipped:P?.skipped.length}));kr({snapshot:d,paths:a,projectRoot:t,fingerprint:l,onStatus:r});let B=qe(a.outputDb,b);return B.state==="failed"&&r(`Warning: reindex succeeded, but activity telemetry was not recorded: ${B.reason}`),Ue(t,h(a.outputDb)),b}catch(f){let y=Ne({trigger:e.trigger,result:"failed",start:o,monotonicStart:s,error:f instanceof Error?f.message:String(f)});Qr(a.metaPath,y);let R=nn(a.outputDb,y);throw R.state==="failed"&&r(`Warning: failed reindex activity telemetry was not recorded: ${R.reason}`),f}finally{if(x){let f=x;try{q(()=>Y(f,{recursive:!0,force:!0}))}catch(y){r(`Warning: temporary reindex workspace was left behind: ${N(y)}`)}}m(),g.release(),p?.()}}function kr(e){if(e.snapshot)try{let t=pe(e.projectRoot),n=t?ye(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:h(e.paths.outputDb),sourceProjectRoot:e.projectRoot,sourceStillValid:()=>{let i=pe(e.projectRoot);return(i?ye(i,e.fingerprint):void 0)?.generationId===e.snapshot?.generationId}});Rn(e.snapshot,h(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: ${N(t)}`)}}function yo(e,t){if(!T(e.outputScip)||!T(e.outputDb)||!Vr(e.metaPath,t))return!1;let n=$(e.outputDb,e.metaPath);return n.state!=="invalid"&&n.state!=="drifted"}function bo(e){if(!T(e.outputScip)||!T(e.outputDb)||!V(e.metaPath))return!1;let t=$(e.outputDb,e.metaPath);return t.state!=="invalid"&&t.state!=="drifted"}function N(e){return e instanceof Error?e.message:String(e)}function yt(e,t,n,r,i,a){try{re(Nn({indexPath:n,reuseExisting:i,affectedFiles:a}),{projectRoot:e,dbPath:t,onStatus:r})}catch(o){r(`Runtime-boundary extraction unavailable: ${o instanceof Error?o.message:String(o)}.`)}}function So(e){let t=e.outputScip??v(e.projectRoot,"index.scip"),n=e.outputDb??v(e.projectRoot,"index.db");return{outputScip:t,outputDb:n,metaPath:v(h(n),"meta.json")}}function Ro(e){let t=$(e.paths.outputDb,e.paths.metaPath);if(e.opts.skipIfUnchanged===!1||!T(e.paths.outputScip)||!T(e.paths.outputDb)||!Vr(e.paths.metaPath,e.fingerprint)||t.state==="invalid"||t.state==="drifted")return null;re(ne(),{projectRoot:e.opts.projectRoot,dbPath:e.paths.outputDb,onStatus:e.onStatus}),yt(e.opts.projectRoot,e.paths.outputDb,e.paths.outputScip,e.onStatus,!0),$(e.paths.outputDb,e.paths.metaPath).state==="drifted"&&(He(e.paths.outputDb,e.paths.metaPath),e.onStatus("Published refreshed SQLite generation after post-index augmentation"));let n=S()-e.monotonicStart,r=Ne({trigger:e.opts.trigger,result:"reused",start:e.start,monotonicStart:e.monotonicStart,languages:e.languages,skipped:[]});return Qr(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:xo(e.paths,e.opts.projectRoot,e.languages,e.opts)}}function xo(e,t,n,r){let i=Xr(t,n,r);return n.map(a=>({id:a,language:a,reused:!0,fingerprint:ie(i[a]),outputBytes:ae(St(e.outputDb,a)),durationMs:0}))}function Po(e){let t=_t(v(h(e.outputDb),"reindex-"));return{runDir:t,tempOutputScip:v(t,ke(e.outputScip)),tempOutputDb:v(t,ke(e.outputDb)),tempMetaPath:v(t,ke(e.metaPath))}}function Eo(e){let t=[],n;try{n=Cr(e,{withFileTypes:!0})}catch(i){return{removed:0,errors:[N(i)]}}let r=0;for(let i of n)if(!(!i.name.startsWith("reindex-")||!i.isDirectory()))try{Y(v(e,i.name),{recursive:!0,force:!0}),r+=1}catch(a){t.push(`${i.name}: ${N(a)}`)}return{removed:r,errors:t}}async function Io(e){let t={...process.env,NODE_OPTIONS:`--max-old-space-size=${e.maxHeapMb}`},n,r=await Z("reindex.language-indexers",async()=>(n=await _o(e,t),n),()=>({languages:e.languages.length,indexed:n?.indexedOutputs.length,reused:n?.reusedLanguages.length,skipped:n?.skippedLanguages.length})),{indexedOutputs:i,skippedLanguages:a,reusedLanguages:o,languageFingerprints:s,shards:c,typescriptProjectShardContext:l,incrementalTypeScript:d}=r;if(o.length>0&&e.onStatus(`Reused ${o.length} cached language shard(s): ${o.join(", ")}`),vo({run:e,indexedOutputs:i,skippedLanguages:a,reusedLanguages:o})){let g=ue("reindex.publish",()=>No(e,i,a,o,s,l),{mode:"metadata-only",languages:i.length,reused:o.length}),m=g.durationMs;return e.onStatus(`All language shards unchanged; reused existing SQLite index in ${(m/1e3).toFixed(1)}s`),{languages:i.map(x=>x.language),indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:m,reused:!0,skipped:a,lastRefresh:g,shards:c,writeTelemetry:e.writeTelemetry}}let p=await Z("reindex.publish",()=>Lo(e,t,i,a,o,s,l,d),{mode:d?"incremental-or-fallback":"full",languages:i.length,reused:o.length,skipped:a.length}),u=p.durationMs;return e.onStatus(`Done in ${(u/1e3).toFixed(1)}s`),{languages:i.map(g=>g.language),indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:u,reused:!1,skipped:a,lastRefresh:p,shards:c,writeTelemetry:e.writeTelemetry}}function vo(e){if(e.run.opts.skipIfUnchanged===!1||e.skippedLanguages.length>0||!T(e.run.paths.outputScip)||!T(e.run.paths.outputDb))return!1;let t=$(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 _o(e,t){let n=ko({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[w,xt]of n)xt.reused&&(r.push({language:w,scipPath:xt.scipPath}),i.add(w));for(let w of i)e.onStatus(`Reusing cached ${w} SCIP shard (language inputs unchanged).`);let a=n.get("typescript"),o=$(e.paths.outputDb,e.paths.metaPath),s=V(e.paths.metaPath),c=(o.state==="legacy"||o.state==="current")&&s!==null&&Ce(s),l=s?.scipCompanion!=="deferred"&&(o.state!=="current"||o.generation.publication?.scipCompanion!=="deferred"),d=a&&!a.reused&&c?Er({projectRoot:e.projectRoot,cacheDir:h(e.paths.outputDb),previousDbPath:e.paths.outputDb,previousIndexPath:e.paths.outputScip,previousShardPath:a.scipPath,candidateShardPath:oe(e.tempPaths.tempOutputScip,"typescript-incremental",0),candidateAffectedScipPath:oe(e.tempPaths.tempOutputScip,"typescript-affected",0),baseShardCurrent:l,previousSnapshot:bt(e.paths.metaPath),currentSnapshot:e.fingerprint,projectMode:e.opts.typescriptProjectMode,onStatus:e.onStatus}):null,p=new Set(d?["typescript"]:[]),u=d?void 0:To(e,n),{preparedRuns:g,skippedLanguages:m,languageOutputScipPaths:x}=Co({languages:e.languages.filter(w=>!i.has(w)&&!p.has(w)),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:u?.allProjects,clojureConfigPath:e.opts.clojureConfigPath,onStatus:e.onStatus}),_=u?g.filter(w=>w.language!=="typescript"||u.missedProjectIds.has(w.id)):g,f=await _r(_,e.projectRoot,e.onStatus,e.opts.indexerConcurrency,e.opts.signal),y=[];if(u){Do(e.paths.outputDb,f,e.writeTelemetry);let w=x.typescript??e.tempPaths.tempOutputScip;y=Fo({outputDb:e.paths.outputDb,tempOutputScip:e.tempPaths.tempOutputScip,outputScipPath:w,reusedProjects:u.reusedProjects,writeTelemetry:e.writeTelemetry})}let R=[...f,...y],{indexedOutputs:E}=Uo(R,m),P=d?[{language:"typescript",scipPath:d.scipPath}]:[],b=[...r,...P,...E];Go(b,m,e.languages,e.opts.allowPartial,e.onStatus);let B=d?[{id:"typescript",language:"typescript",label:"typescript (incremental documents)",scipPath:d.scipPath,outputScipPath:d.scipPath,durationMs:d.durationMs,command:"watch-service:typescript-index",outputBytes:ae(d.scipPath)??void 0}]:[],W=jo(n,[...f,...B],u?{outputDb:e.paths.outputDb,classification:u.classification}:void 0);return{indexedOutputs:b,skippedLanguages:m,reusedLanguages:[...i],languageFingerprints:Oo(n,e.languages),shards:W,typescriptProjectShardContext:u?{projects:u.allProjects,fingerprints:u.fingerprints}:void 0,incrementalTypeScript:d??void 0}}function To(e,t){let n=t.get("typescript");if(!n||n.reused||e.opts.typescriptProjectMode!=="workspace")return;let r=z(e.projectRoot,e.opts.typescriptProjects);if(r.length===0)return;let i=lr(e.projectRoot,r),a=sr(n.fingerprint.files,r),o=cr(r,i),s=dr(r,a,o),c=V(e.paths.metaPath),d=wo(c,s,m=>T(Le(e.paths.outputDb,m))),p=[...d.entries()].filter(([,m])=>m.reused).map(([m])=>m),u=new Set(p),g=new Set(r.filter(m=>!u.has(m)).map(m=>`typescript:${m}`));return{allProjects:r,fingerprints:s,classification:d,reusedProjects:p,missedProjectIds:g}}function wo(e,t,n){let r=new Map;for(let i of Object.keys(t)){let a=t[i];if(!e){r.set(i,{reused:!1,reason:"no reindex metadata found",fingerprint:a});continue}let o=e.version===K&&Me(e).typescriptProjectShardReuse?e.typescriptProjectShards?.[i]:void 0;if(!o){r.set(i,{reused:!1,reason:"no cached fingerprint for this project",fingerprint:a});continue}if(!n(i)){r.set(i,{reused:!1,reason:"cached shard file missing on disk",fingerprint:a});continue}if(k(o)!==k(a)){r.set(i,{reused:!1,reason:"project inputs changed since last index",fingerprint:a});continue}r.set(i,{reused:!0,fingerprint:a})}return r}function Do(e,t,n){for(let r of t){if(r.skipped||!r.id.startsWith("typescript:"))continue;let i=r.id.slice(11),a=Le(e,i);je(h(a),{recursive:!0}),G(n,U(r.scipPath,a))}}function Fo(e){return e.reusedProjects.map((t,n)=>{let r=Le(e.outputDb,t),i=oe(e.tempOutputScip,"typescript-project-cached",n);return G(e.writeTelemetry,U(r,i)),{id:`typescript:${t}`,language:"typescript",label:`typescript (${t})`,scipPath:i,outputScipPath:e.outputScipPath,durationMs:0,command:"cached",outputBytes:ae(i)??void 0}})}function ko(e){let t=V(e.paths.metaPath),n=Xr(e.projectRoot,e.languages,e),r=new Map;for(let i of e.languages){let a=St(e.paths.outputDb,i),o=n[i];if(!t){r.set(i,{reused:!1,reason:"no reindex metadata found",fingerprint:o,scipPath:a});continue}if(t.version!==K){r.set(i,{reused:!1,reason:`metadata version ${String(t.version??"unknown")} predates per-language shard caching`,fingerprint:o,scipPath:a});continue}if(i==="typescript"&&t.scipCompanion==="deferred"){r.set(i,{reused:!1,reason:"whole TypeScript SCIP companion is deferred behind changed-document overlays",fingerprint:o,scipPath:a});continue}if(!Me(t).languageShardReuse||!t.languageFingerprints){r.set(i,{reused:!1,reason:"no per-language fingerprints recorded in metadata",fingerprint:o,scipPath:a});continue}let s=t.languageFingerprints[i];if(!s){r.set(i,{reused:!1,reason:"no cached fingerprint for this language",fingerprint:o,scipPath:a});continue}if(!T(a)){r.set(i,{reused:!1,reason:"cached shard file missing on disk",fingerprint:o,scipPath:a});continue}if(k(s)!==k(o)){r.set(i,{reused:!1,reason:"language inputs changed since last index",fingerprint:o,scipPath:a});continue}r.set(i,{reused:!0,fingerprint:o,scipPath:a})}return r}function jo(e,t,n){let r=[];for(let[i,a]of e)a.reused&&r.push({id:i,language:i,reused:!0,fingerprint:ie(a.fingerprint),outputBytes:ae(a.scipPath),durationMs:0});for(let i of t){let a=e.get(i.language),o=n&&i.id.startsWith("typescript:")?i.id.slice(11):null,s=o?n.classification.get(o):void 0;r.push({id:i.id,language:i.language,reused:!1,missReason:s?.reason??a?.reason??i.skipped?.reason,fingerprint:s?ie(s.fingerprint):a?ie(a.fingerprint):"unknown",outputBytes:i.outputBytes??null,durationMs:i.durationMs,command:i.command})}if(n)for(let[i,a]of n.classification)a.reused&&r.push({id:`typescript:${i}`,language:"typescript",reused:!0,fingerprint:ie(a.fingerprint),outputBytes:ae(Le(n.outputDb,i)),durationMs:0});return r}function ie(e){return fo("sha256").update(k(e)).digest("hex").slice(0,16)}function ae(e){try{return mo(e).size}catch{return null}}function Oo(e,t){let n={};for(let r of t){let i=e.get(r);i&&(n[r]=i.fingerprint)}return n}async function Lo(e,t,n,r,i,a,o,s){D(e.opts.signal,"Reindex cancelled by its owner.");let c=!s||s.completeScipUpdated,l=!1;c&&(jr(e.paths.outputDb,n,e.writeTelemetry),l=Or(n,e.tempPaths.tempOutputScip,e.onStatus));let d=await Bo({run:e,indexedOutputs:n,skippedLanguages:r,reusedLanguages:i,incrementalTypeScript:s,completeScipAvailable:c,completeScipSanitized:l,materializeFullFallback:async()=>{if(D(e.opts.signal,"Reindex cancelled by its owner."),!s||s.completeScipUpdated)return l;e.onStatus("Materializing the deferred whole TypeScript SCIP companion for full conversion..."),Ir({cacheDir:h(e.paths.outputDb),generationIdentity:s.nextFragmentGeneration,baseShardPath:s.scipPath,candidateShardPath:s.candidateScipPath});let E=n.map(P=>P.language==="typescript"?{language:P.language,scipPath:s.candidateScipPath}:P);return jr(e.paths.outputDb,E,e.writeTelemetry),l=Or(E,e.tempPaths.tempOutputScip,e.onStatus),l}});D(e.opts.signal,"Reindex cancelled by its owner."),re(ne(),{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 p=nt(e.tempPaths.tempOutputDb);if(p.added.length>0&&e.onStatus(`Added SQLite query indexes: ${p.added.join(", ")}`),p.removed.length>0&&e.onStatus(`Removed redundant SQLite indexes: ${p.removed.join(", ")}`),d.mode==="incremental"&&s){let E=null,P=null;try{E=new F({projectRoot:e.projectRoot,dbPath:e.tempPaths.tempOutputDb,indexPath:e.tempPaths.tempOutputScip}),P=new F({projectRoot:e.projectRoot,dbPath:e.paths.outputDb,indexPath:e.paths.outputScip});let b=Jt(E,e.fingerprint,s.referenceFragmentsByFile,P);e.onStatus(`Cached exact TypeScript reference fragments for ${b} affected document(s).`)}catch(b){e.onStatus(`Exact TypeScript reference fragment prefill unavailable: ${b instanceof Error?b.message:String(b)}.`)}finally{E?.close(),P?.close()}}let u=bt(e.paths.metaPath),g=d.mode==="incremental"&&s?qo(s,d.changedDocumentPaths):Ke({projectRoot:e.projectRoot,previousDbPath:e.paths.outputDb,previousIndexPath:e.paths.outputScip,candidateDbPath:e.tempPaths.tempOutputDb,candidateIndexPath:e.tempPaths.tempOutputScip,previousSnapshot:u,currentSnapshot:e.fingerprint,refreshResult:"rebuilt"}),m=Ne({trigger:e.opts.trigger,result:"rebuilt",start:e.start,monotonicStart:e.monotonicStart,languages:n.map(E=>E.language),skipped:[...r]}),x=d.mode==="incremental"&&d.scipCompanion==="deferred",_={...a};x&&delete _.typescript;let{metadata:f,pruneProjects:y}=Gr({run:e,indexedOutputs:n,skippedLanguages:r,reusedLanguages:i,languageFingerprints:_,typescriptProjectShardContext:o,lastRefresh:m});f.scipCompanion=x?"deferred":"current",Br(e.paths.outputDb,y),Rt(e.tempPaths.tempMetaPath,f);let R=fn({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:d.mode==="incremental"&&d.scipCompanion==="deferred",publication:d.mode==="incremental"?{mode:"incremental",validation:"passed",converterDurationMs:d.converterDurationMs,affectedDocumentCount:s?.affectedFiles.length,changedDocumentCount:d.changedDocumentPaths.length,producerDurationMs:s?.timings.serviceMs,materializationDurationMs:s?.durationMs,patchDurationMs:d.patchDurationMs,scipCompanion:d.scipCompanion,...d.scipCompanion==="deferred"&&s?{typescriptOverlayGeneration:s.nextFragmentGeneration}:{}}:{mode:"full",validation:"passed",converterDurationMs:d.converterDurationMs,scipCompanion:"current",...d.fallbackReason?{fallbackReason:d.fallbackReason}:{}}});return R.achievedDurability==="file-flushed"&&e.onStatus(`Published local generation ${R.currentGeneration.slice(0,12)} (file-flushed; directory sync unsupported)`),gn(h(e.paths.outputDb),d.mode==="incremental"&&d.scipCompanion==="deferred"?[s.nextFragmentGeneration]:[]),dn(h(e.paths.outputDb),s?.completeScipUpdated?[s.nextFragmentGeneration]:[]),Ur(e.paths.outputDb,g,e.onStatus),m}function No(e,t,n,r,i,a){let o=bt(e.paths.metaPath),s=null;try{G(e.writeTelemetry,U(e.paths.outputDb,e.tempPaths.tempOutputDb))}catch(u){s=Gn("reused","oracle-error",`Could not snapshot the prior database: ${u instanceof Error?u.message:String(u)}`)}re(ne(),{projectRoot:e.projectRoot,dbPath:e.paths.outputDb,onStatus:e.onStatus}),yt(e.projectRoot,e.paths.outputDb,e.paths.outputScip,e.onStatus,!0);let c=nt(e.paths.outputDb);c.added.length>0&&e.onStatus(`Added SQLite query indexes: ${c.added.join(", ")}`),c.removed.length>0&&e.onStatus(`Removed redundant SQLite indexes: ${c.removed.join(", ")}`),s??=Ke({projectRoot:e.projectRoot,previousDbPath:e.tempPaths.tempOutputDb,previousIndexPath:e.paths.outputScip,candidateDbPath:e.paths.outputDb,candidateIndexPath:e.paths.outputScip,previousSnapshot:o,currentSnapshot:e.fingerprint,refreshResult:"reused"});let l=Ne({trigger:e.opts.trigger,result:"reused",start:e.start,monotonicStart:e.monotonicStart,languages:t.map(u=>u.language),skipped:[...n]}),{metadata:d,pruneProjects:p}=Gr({run:e,indexedOutputs:t,skippedLanguages:n,reusedLanguages:r,languageFingerprints:i,typescriptProjectShardContext:a,lastRefresh:l});return Br(e.paths.outputDb,p),Rt(e.paths.metaPath,d),He(e.paths.outputDb,e.paths.metaPath),Ur(e.paths.outputDb,s,e.onStatus),l}function bt(e){return vt(V(e)?.fingerprint)}function Ur(e,t,n){try{Wn(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 Gr(e){let t=Ao({mode:e.run.opts.typescriptProjectMode,skippedLanguages:e.skippedLanguages,reusedLanguages:e.reusedLanguages,context:e.typescriptProjectShardContext,metaPath:e.run.paths.metaPath});return{metadata:{version:K,status:e.skippedLanguages.length===0?"complete":"partial",updatedAt:new Date().toISOString(),fingerprint:e.run.fingerprint,sqliteLayoutVersion:2,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 Ao(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=V(e.metaPath),n=t?.version===K?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 Br(e,t){let n=Yr(e);if(t===null){q(()=>Y(n,{recursive:!0,force:!0}));return}let r;try{r=Cr(n)}catch{return}for(let i of Mo(r,t))q(()=>Y(v(n,i),{force:!0}))}function Mo(e,t){let n=new Set(t.map(r=>`${ot(r)}.scip`));return e.filter(r=>!n.has(r))}function jr(e,t,n){for(let r of t){let i=St(e,r.language);je(h(i),{recursive:!0}),r.scipPath!==i&&G(n,U(r.scipPath,i))}}function Co(e){let t=[],n=[],r=e.languages.map((a,o)=>({language:a,scipPath:e.languages.length>1?oe(e.tempOutputScip,a,o):e.tempOutputScip})),i=Object.fromEntries(r.map(({language:a,scipPath:o})=>[a,o]));for(let{language:a,scipPath:o}of r){let s=$o({...e,language:a,scipPath:o});for(let c of s)"skipped"in c?Wr(n,c.skipped):t.push(c.prepared)}return{preparedRuns:t,skippedLanguages:n,languageOutputScipPaths:i}}function $o(e){if(e.language!=="typescript"||e.typescriptProjectMode!=="workspace")return[mt({...e,id:e.language,label:e.language,outputScipPath:e.scipPath})];let t=e.preDiscoveredTypeScriptProjects??z(e.projectRoot,e.typescriptProjects);return t.length===0?[mt({...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)=>mt({...e,id:`typescript:${n}`,label:`typescript (${n})`,scipPath:oe(e.tempOutputScip,"typescript-project",r),outputScipPath:e.scipPath,pnpmWorkspaces:!1,projectPath:n})))}function mt(e){let t=Ze(e.language),n=ge(t),r=$t(t,e.projectRoot),i=e.trustProjectTools&&r?Ut(t,e.projectRoot):null,a=te(t);if(!i&&!a&&r){let d=`${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}: ${d}`),{skipped:{language:e.language,reason:d}}}if(!i&&!a&&!Ct(t)){if(e.skipAutoInstall){let d=`${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}: ${d}`),{skipped:{language:e.language,reason:d}}}if(e.onStatus(`${n} not found. Attempting auto-install...`),!Dr(t,e.onStatus)){let d=`${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}: ${d}`),{skipped:{language:e.language,reason:d}}}}let o=i?.canonicalPath??te(t);if(!o){let d=`${n} was not found after installation checks.`;return e.onStatus(`Skipping ${e.language}: ${d}`),{skipped:{language:e.language,reason:d}}}let{binary:s,args:c}=t.indexArgs({projectRoot:e.projectRoot,outputPath:e.scipPath,pnpmWorkspaces:e.pnpmWorkspaces,indexerBinary:o,projectPath:e.projectPath,configPath:e.language==="clojure"?e.clojureConfigPath:void 0}),l=Vn({language:e.language,projectPath:e.projectPath,pnpmWorkspaces:e.pnpmWorkspaces});if(i&&!i.executable){let d=`${i.relativePath} is not executable; refusing project-local indexer.`;return e.onStatus(`Skipping ${e.language}: ${d}`),{skipped:{language:e.language,reason:d}}}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:o,binary:s,args:c,env:Bt(t,e.env,o),...l===void 0?{}:{temporaryRootConfigContent:l},...i?{trustedProjectTool:i}:{}}}}function Uo(e,t){let n=new Map;for(let i of e)if(i.skipped)Wr(t,i.skipped);else{let a=`${i.language}\0${i.outputScipPath}`,o=n.get(a)??{language:i.language,outputScipPath:i.outputScipPath,scipPaths:[]};o.scipPaths.push(i.scipPath),n.set(a,o)}let r=[];for(let i of n.values())if(i.scipPaths.length>1)en(i.scipPaths,i.outputScipPath),r.push({language:i.language,scipPath:i.outputScipPath});else{let a=i.scipPaths[0];a!==i.outputScipPath&&$r(a,i.outputScipPath),r.push({language:i.language,scipPath:i.outputScipPath})}return{indexedOutputs:r}}function Wr(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 Go(e,t,n,r,i){if(e.length===0){let a=t.map(o=>` - ${o.language}: ${o.reason}`).join(`
271
+ VALUES (?, ?, ?, ?, ?, ?)`);for(let i of n.occurrences){if((i.roles&1)===0||he(i.symbol)||!i.enclosingRange)continue;let[a,o,s,c]=_a(i,n.relativePath);r.run(n.id,t.referenced(i.symbol),a,o,s,c)}}function Pa(e,t,n){let r=e.prepare("INSERT INTO chunks (document_id, chunk_index, start_line, end_line, occurrences) VALUES (?, ?, ?, ?, ?)"),i=e.prepare("INSERT INTO mentions (chunk_id, symbol_id, role) VALUES (?, ?, ?)");va(n.occurrences).forEach((a,o)=>{let s=Number(r.run(n.id,o,a.startLine,a.endLine,rn(a.occurrences)).lastInsertRowid),c=new Map;for(let l of a.occurrences){if(he(l.symbol))continue;let d=c.get(l.symbol)??new Set;d.add(l.roles),c.set(l.symbol,d)}for(let[l,d]of c){let p=t.referenced(l);for(let u of d)i.run(s,p,u)}})}function Ea(e){let t=new Map;for(let n of e){let r=t.get(n.symbol);if(!r){t.set(n.symbol,n);continue}t.set(n.symbol,{...r,documentation:[...r.documentation,...n.documentation.filter(i=>!r.documentation.includes(i))]})}return[...t.values()].sort((n,r)=>hr(n.symbol,r.symbol))}function Ia(e){let t=[...e].sort((r,i)=>fr(r.range,i.range)||hr(r.symbol,i.symbol)),n=[];for(let r of t){let i=n.at(-1);i&&i.symbol===r.symbol&&fr(i.range,r.range)===0?n[n.length-1]={...i,roles:i.roles|r.roles}:n.push(r)}return n}function va(e){let t=[],n=0;for(;n<e.length;){let r=Math.min(e.length,n+ma);for(;r<e.length&&e[r-1].range[0]===e[r].range[0];)r+=1;t.push({startLine:e[n].range[0],endLine:e[r-1].range[0],occurrences:e.slice(n,r)}),n=r}return t}function _a(e,t){let n=e.enclosingRange,[r,i,a,o]=n;if(!(r>=0&&i>=0&&(a>r&&o>=0||a===r&&o>=i)))throw new Error(`bad enclosing range ${JSON.stringify(n)} for symbol ${e.symbol} in document ${t}`);return n}function fr(e,t){return e[0]-t[0]||e[1]-t[1]||e[2]-t[2]||e[3]-t[3]}function hr(e,t){return e<t?-1:e>t?1:0}var Fa={[ve.UnspecifiedPositionEncoding]:null,[ve.UTF8CodeUnitOffsetFromLineStart]:"UTF-8",[ve.UTF16CodeUnitOffsetFromLineStart]:"UTF-16",[ve.UTF32CodeUnitOffsetFromLineStart]:"UTF-32"};function br(e,t,n){let r=wa(A(e,{inputKind:"SCIP index store input",maxBytes:Q})),i={removedDefinitionOccurrences:0,touchedDocuments:0};if(n.sanitize){let a=Zt(r);a.touchedDocuments>0&&(Ta(e,Buffer.from(Da(a.index))),r=a.index),i={removedDefinitionOccurrences:a.removedDefinitionOccurrences,touchedDocuments:a.touchedDocuments}}return mr(t,r.documents.map(ja)),i}function ja(e){let t=Fa[e.positionEncoding];if(t===void 0)throw new Error(`unknown position encoding ${e.positionEncoding} in ${e.relativePath}`);return{relativePath:e.relativePath,language:e.language||null,positionEncoding:t,text:e.text||null,symbols:e.symbols.map(n=>({symbol:n.symbol,displayName:n.displayName||null,kind:n.kind||null,documentation:n.documentation,enclosingSymbol:n.enclosingSymbol||null})),occurrences:e.occurrences.flatMap(n=>{let r=yr(n.range);return r?[{symbol:n.symbol,roles:n.symbolRoles,range:r,enclosingRange:yr(n.enclosingRange)}]:[]})}}function yr(e){return e.length===3?[e[0],e[1],e[0],e[2]]:e.length===4?[e[0],e[1],e[2],e[3]]:null}import{createHash as Ba}from"crypto";import{existsSync as ct,statSync as Wa,writeFileSync as dt}from"fs";import{join as qa}from"path";import{randomUUID as ka}from"crypto";import{existsSync as Oa}from"fs";var La=12e4,Na=5,_e=class{projectRoot;cacheDir;baseGeneration;timeoutMs;runtime;mailboxLimits;constructor(t,n={}){this.projectRoot=wt(t.projectRoot),this.cacheDir=t.cacheDir,this.baseGeneration=t.baseGeneration,this.timeoutMs=n.timeoutMs??Ua(),this.runtime=n.runtime??Ga,this.mailboxLimits=n.mailboxLimits??{}}request(t){let n=wn(this.cacheDir),r=_n(this.cacheDir),i=Xe(n.statePath);if(!Sr(i,this.projectRoot,this.runtime))throw new Error("Compatible TypeScript index service is not running.");let a=this.runtime.now(),o=a+this.timeoutMs,s=(this.runtime.monotonicNow??S)()+this.timeoutMs,c=En("typescript-index-v4",{baseGeneration:this.baseGeneration,request:t}),l=In(c),d=vn(r,{mailboxVersion:Pn,operationKey:c,clientId:this.runtime.randomId(),enqueuedAtMs:a,deadlineAtMs:o,protocolVersion:Se,id:l,baseGeneration:this.baseGeneration,request:t},{nowMs:a,limits:this.mailboxLimits});for(;(this.runtime.monotonicNow??S)()<=s;){if(Oa(d.responsePath))return Aa(se(d.responsePath,{maxBytes:this.mailboxLimits.maxItemBytes??64*1024*1024,inputKind:"TypeScript index mailbox response"}),l,c,this.baseGeneration,t.producerIdentity,t.affectedFiles);let p=Xe(n.statePath);if(!Sr(p,this.projectRoot,this.runtime))throw new Error("TypeScript index service stopped while processing a request.");this.runtime.sleep(Na)}throw new Error(`TypeScript index service timed out after ${this.timeoutMs}ms.`)}};function Sr(e,t,n){let r=e?.processIdentity?n.readProcessIdentity?.(e.pid):null;return e!==null&&e.projectRoot===t&&e.typescriptIndex?.protocolVersion===Se&&n.isProcessAlive(e.pid)&&(!e.processIdentity||r!=null&&ee(e.processIdentity,r))}function Aa(e,t,n,r,i,a){let o=JSON.parse(e);if(o.protocolVersion!==Se||o.id!==t||o.operationKey!==n||o.ok===!0&&o.baseGeneration!==r)throw new Error("TypeScript index service wrote an incompatible response.");if(o.ok!==!0)throw new Error(typeof o.error=="string"?o.error:"TypeScript index service request failed.");let s=Ma(o.response,i),c=[...new Set(a)].sort(),l=s.fragments.map(d=>d.relativePath).sort();if(JSON.stringify(l)!==JSON.stringify(c))throw new Error("TypeScript index service omitted or added an affected document.");return s}function Ma(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(a=>{if(!a||typeof a.relativePath!="string"||a.bytesBase64!==null&&typeof a.bytesBase64!="string"||typeof a.occurrences!="number"||!Number.isInteger(a.occurrences)||a.occurrences<0||typeof a.symbols!="number"||!Number.isInteger(a.symbols)||a.symbols<0||!Array.isArray(a.referenceFragments)||!a.referenceFragments.every(Ca)||r.has(a.relativePath))throw new Error("TypeScript index service wrote an invalid fragment.");r.add(a.relativePath);let o=a.bytesBase64===null?null:$a(a.bytesBase64);return{relativePath:a.relativePath,bytes:o,occurrences:a.occurrences,symbols:a.symbols,referenceFragments:a.referenceFragments}});return{producerIdentity:n.producerIdentity,cold:n.cold,durationMs:n.durationMs,fragments:i}}function Ca(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 $a(e){let t=Buffer.from(e,"base64");if(t.toString("base64")!==e)throw new Error("TypeScript index service wrote invalid base64.");return t}function Ua(){let e=Number(process.env.SCIP_TYPESCRIPT_INDEX_TIMEOUT_MS);return Number.isInteger(e)&&e>0?e:La}var Ga={now:Date.now,monotonicNow:S,randomId:ka,sleep(e){let t=new Int32Array(new SharedArrayBuffer(4));Atomics.wait(t,0,0,e)},isProcessAlive:J,readProcessIdentity:H};function Ha(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=de(e.previousSnapshot,e.currentSnapshot);if(n.changes.length===0)return{eligible:!1,reason:"no changed project inputs"};if(n.changes.some(d=>d.kind!=="modified"||d.inputKind!=="source"||!Be(d.path)))return{eligible:!1,reason:"change is not a modified TypeScript source file"};let r=Re(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=Ja(r,t,e.graph);if(!i)return{eligible:!1,reason:"affected files cross or ambiguously match TypeScript projects"};let a=Rr(e.currentSnapshot,e.projectFiles,e.producerIdentity),o=Rr(e.previousSnapshot,e.projectFiles,e.producerIdentity);if(a!==o)return{eligible:!1,reason:"TypeScript fragment project identity changed"};let s=Pr(e.previousSnapshot,e.projectFiles,e.graph,e.producerIdentity,e.projectFiles);if(!s)return{eligible:!1,reason:"prior document identity unavailable"};let c=Pr(e.currentSnapshot,e.projectFiles,e.graph,e.producerIdentity,r.affectedFiles);if(!c)return{eligible:!1,reason:"next document identity unavailable"};let l=i.length===1?i[0]:void 0;return{eligible:!0,manifest:n,plan:r,projectIdentity:a,previousFragmentGeneration:xr(e.previousSnapshot,e.producerIdentity),nextFragmentGeneration:xr(e.currentSnapshot,e.producerIdentity),previousDocumentIdentities:s,nextDocumentIdentities:c,projects:i,...l?{tsconfigPath:l.tsconfigPath,projectArgument:l.projectArgument}:{}}}function Ja(e,t,n){let r=new Map;for(let a of e.affectedFiles){let o=za(a,t);if(!o)return null;let s=r.get(o)??[];s.push(a),r.set(o,s)}let i=[];for(let[a,o]of[...r].sort(([s],[c])=>s.localeCompare(c))){let s=new Set(o),c=e.changedFiles.filter(l=>s.has(l)||o.some(d=>Xa(d,l,n)));if(c.length===0)return null;i.push({projectArgument:a,tsconfigPath:a==="."?"tsconfig.json":`${a}/tsconfig.json`,modifiedFiles:c,affectedFiles:[...o].sort()})}return i}function za(e,t){let n=t.filter(a=>a==="."||e===a||e.startsWith(`${a}/`));if(n.length===0)return null;let r=[...new Set(n)].sort((a,o)=>Te(o)-Te(a)||a.localeCompare(o)),i=r[0];return r[1]&&Te(r[1])===Te(i)?null:i}function Te(e){return e==="."?0:e.split("/").filter(Boolean).length}function Xa(e,t,n){let r=new Set,i=[e];for(let a=0;a<i.length;a+=1){let o=i[a];if(!(!o||r.has(o))){r.add(o);for(let s of n.get(o)??[]){if(s===t)return!0;r.has(s)||i.push(s)}}}return!1}function Er(e){let t=S();try{if(!ct(e.previousDbPath)||!ct(e.previousShardPath))throw new Error("prior TypeScript graph or language shard unavailable");let n=performance.now(),r=ze();if(!r.available)throw new Error(r.reason);let i=performance.now()-n;n=performance.now();let a=new F({projectRoot:e.projectRoot,dbPath:e.previousDbPath,indexPath:e.previousIndexPath}),o,s;try{o=fe(a,{includeIgnored:!1}).filter(Be).sort(),s=me(a)}finally{a.close()}let c=performance.now()-n,l=Ha({projectMode:e.projectMode,workspaceProjects:e.projectMode==="workspace"?z(e.projectRoot,e.currentSnapshot.typescriptProjects):void 0,previousSnapshot:e.previousSnapshot,currentSnapshot:e.currentSnapshot,projectFiles:o,graph:s,producerIdentity:r.producerIdentity,rootTsconfigExists:ct(qa(e.projectRoot,"tsconfig.json"))});if(!l.eligible)throw new Error(l.reason);let d=Tn(e.previousDbPath);if(!d)throw new Error("published TypeScript base generation unavailable");n=performance.now();let p=new _e({projectRoot:e.projectRoot,cacheDir:e.cacheDir,baseGeneration:d}),u=l.projects.map(b=>p.request({kind:"emit-documents",tsconfigPath:b.tsconfigPath,projectArgument:b.projectArgument,projectIdentity:l.projectIdentity,producerIdentity:r.producerIdentity,modifiedFiles:b.modifiedFiles,affectedFiles:b.affectedFiles})),g=u.flatMap(b=>b.fragments),m=performance.now()-n,x=Wa(e.previousShardPath).size>=ln;n=performance.now();let _=x?null:A(e.previousShardPath,{inputKind:"TypeScript base SCIP shard",maxBytes:Q}),f=x?{completeIndexBytes:null,affectedIndexBytes:an(g)}:cn({packageVersion:r.packageVersion,baseIndexBytes:_,fragments:g}),y=performance.now()-n;n=performance.now(),x?un({cacheDir:e.cacheDir,previousGenerationIdentity:l.previousFragmentGeneration,nextGenerationIdentity:l.nextFragmentGeneration,producerIdentity:r.producerIdentity,projectIdentity:l.projectIdentity,baseShardCurrent:e.baseShardCurrent,fragments:g}):(on({cacheDir:e.cacheDir,packageVersion:r.packageVersion,indexBytes:_,producerIdentity:r.producerIdentity,projectIdentity:l.projectIdentity,generationIdentity:l.previousFragmentGeneration,documentIdentities:l.previousDocumentIdentities,allowUntrackedDocuments:!0}),sn({cacheDir:e.cacheDir,previousGenerationIdentity:l.previousFragmentGeneration,producerIdentity:r.producerIdentity,projectIdentity:l.projectIdentity,generationIdentity:l.nextFragmentGeneration,fragments:g,documentIdentities:l.nextDocumentIdentities}));let R=performance.now()-n;n=performance.now(),f.completeIndexBytes&&dt(e.candidateShardPath,f.completeIndexBytes),dt(e.candidateAffectedScipPath,f.affectedIndexBytes);let E=performance.now()-n,P={scipPath:x?e.previousShardPath:e.candidateShardPath,candidateScipPath:e.candidateShardPath,affectedScipPath:e.candidateAffectedScipPath,completeScipUpdated:!x,durationMs:S()-t,cold:u.some(b=>b.cold),changedFiles:l.plan.changedFiles,affectedFiles:l.plan.affectedFiles,producerIdentity:r.producerIdentity,previousFragmentGeneration:l.previousFragmentGeneration,nextFragmentGeneration:l.nextFragmentGeneration,manifest:l.manifest,plan:l.plan,projectFileCount:o.length,referenceFragmentsByFile:new Map(g.map(b=>[b.relativePath,b.referenceFragments])),timings:{runtimeMs:i,graphMs:c,requestMs:m,serviceMs:u.reduce((b,B)=>b+B.durationMs,0),assemblyMs:y,fragmentStoreMs:R,writeMs:E}};return e.onStatus(`Incremental TypeScript index emitted ${P.affectedFiles.length} affected document(s) across ${l.projects.length} project(s) in ${(P.durationMs/1e3).toFixed(3)}s (${P.cold?"cold":"warm"} service; ${x?"whole SCIP deferred":"whole SCIP current"}; runtime ${i.toFixed(0)}ms, graph ${c.toFixed(0)}ms, request ${m.toFixed(0)}ms, assembly ${y.toFixed(0)}ms, fragments ${R.toFixed(0)}ms, write ${E.toFixed(0)}ms).`),P}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 Ir(e){let t=ze();if(!t.available)throw new Error(t.reason);let n=pn({cacheDir:e.cacheDir,generationIdentity:e.generationIdentity,baseIndexBytes:A(e.baseShardPath,{inputKind:"TypeScript base SCIP shard",maxBytes:Q}),packageVersion:t.packageVersion});dt(e.candidateShardPath,n)}function Rr(e,t,n){let r=e.files.filter(i=>It(i.path,e.languages)!=="source").map(i=>({path:i.path,size:i.size,hash:i.hash})).sort((i,a)=>i.path.localeCompare(a.path));return lt(JSON.stringify({version:1,producerIdentity:n,pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:[...e.typescriptProjects].sort(),projectFiles:[...t].sort(),nonSourceInputs:r}))}function xr(e,t){return lt(JSON.stringify({version:1,producerIdentity:t,snapshot:e}))}function Pr(e,t,n,r,i){let a=new Set(e.files.map(c=>c.path)),o=Ht({projectFiles:t.filter(c=>a.has(c)),snapshot:e,graph:n,engineIdentity:r}),s=new Map;for(let c of i){let l=o.identityFor(c,"typescript-scip-document-v1");if(l.key){s.set(c,l.key);continue}if(a.has(c))return null;s.set(c,lt(JSON.stringify({version:1,producerIdentity:r,generatedDocument:c})))}return s}function lt(e){return Ba("sha256").update(e).digest("hex")}import{closeSync as Ya,existsSync as we,fstatSync as Va,lstatSync as Qa,openSync as Ka,renameSync as pt,rmSync as De,statSync as Za,writeSync as eo}from"fs";import{cpus as to}from"os";import{join as gt}from"path";function no(e,t){if(e.temporaryRootConfigContent===void 0)return null;let n=gt(t,"tsconfig.json"),r=Buffer.from(e.temporaryRootConfigContent,"utf8"),i;try{i=Ka(n,"wx",384)}catch(a){if(a.code==="EEXIST")return null;throw a}try{eo(i,r);let a=Va(i);return{path:n,content:r,device:a.dev,inode:a.ino}}finally{Ya(i)}}function ro(e){if(e)try{let t=Qa(e.path);if(!t.isFile()||t.dev!==e.device||t.ino!==e.inode||t.size!==e.content.byteLength)return;let n;try{n=A(e.path,{maxBytes:e.content.byteLength,inputKind:"temporary TypeScript index configuration"})}catch{return}if(!n.equals(e.content))return;De(e.path)}catch(t){if(t.code!=="ENOENT")throw t}}function io(e,t,n){if(!e.defaultOutputPath)return;let r=gt(t,e.defaultOutputPath);n!==r&&we(r)&&pt(r,n)}function ao(e,t,n){if(!e.defaultOutputPath)return null;let r=gt(t,e.defaultOutputPath);if(r===n)return null;let i=`${n}.default-output-backup`;return De(i,{force:!0}),we(r)?(pt(r,i),{defaultOutputPath:r,backupPath:i}):{defaultOutputPath:r,backupPath:null}}function oo(e){e&&(De(e.defaultOutputPath,{force:!0}),e.backupPath&&we(e.backupPath)&&pt(e.backupPath,e.defaultOutputPath))}function so(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,to().length));return Math.max(1,Math.min(e,Math.floor(r)))}async function _r(e,t,n,r,i){D(i,"Reindex cancelled by its owner.");let a=e.filter(d=>d.config.defaultOutputPath),o=e.filter(d=>!d.config.defaultOutputPath),s=[],c=so(o.length,r),l=await kn(o,c,d=>ut(d,t,n,i));if(c>1){let d=new Map;for(let p of l.filter(u=>u.result.skipped&&u.retryable)){let u=o.find(g=>g.id===p.result.id);u&&(n(`Retrying ${u.label} indexer serially after parallel failure...`),D(i,"Reindex cancelled by its owner."),d.set(u.id,(await ut(u,t,n,i)).result))}s.push(...l.map(({result:p})=>d.get(p.id)??p))}else s.push(...l.map(({result:d})=>d));for(let d of a)D(i,"Reindex cancelled by its owner."),s.push((await ut(d,t,n,i)).result);return s.sort((d,p)=>e.findIndex(u=>u.id===d.id)-e.findIndex(u=>u.id===p.id))}async function ut(e,t,n,r){D(r,"Reindex cancelled by its owner."),n(`Indexing ${e.label} with ${e.resolvedBinary}...`),De(e.scipPath,{force:!0});let i=ao(e.config,t,e.scipPath),a=no(e,t),o=[e.binary,...e.args].join(" "),s=S();try{e.trustedProjectTool&&Gt(t,e.trustedProjectTool);let l=Lt(e.binary,e.args),d=await jn({command:l.binary,args:l.args,label:`${e.label} indexer`,cwd:t,env:e.env,timeoutMs:lo(),maxStdoutBytes:50*1024*1024,maxStderrBytes:50*1024*1024,signal:r});if(d.status!==0){let p=d.stderr.trim();throw new Error(`${e.resolvedBinary} exited with status ${d.status}${p?`:
272
+ ${p}`:""}`)}io(e.config,t,e.scipPath)}catch(l){if(r?.aborted)throw Dt(r,"Reindex cancelled by its owner.");let d=l instanceof Error?l.message:String(l),p=`${e.resolvedBinary} indexer failed: ${co(d)}`,u=e.label===e.language?p:`${e.label}: ${p}`;return n(`Skipping ${e.label}: ${p}`),{result:{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,durationMs:S()-s,command:o,skipped:{language:e.language,reason:u}},retryable:uo(l)}}finally{oo(i),ro(a)}if(!we(e.scipPath)){let l=`${e.resolvedBinary} indexer completed but did not produce ${e.scipPath}`,d=e.label===e.language?l:`${e.label}: ${l}`;return n(`Skipping ${e.label}: ${l}`),{result:{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,durationMs:S()-s,command:o,skipped:{language:e.language,reason:d}},retryable:!1}}let c;try{c=Za(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:S()-s,command:o,outputBytes:c},retryable:!1}}function co(e){let[t="",...n]=e.split(`
273
+ `),r=n.map(a=>a.trim()).filter(Boolean);if(r.length===0)return t;let i=r.find(a=>/^(?:error:\s*)?[A-Z]\w*Error\b/.test(a))??r[r.length-1];return`${t} ${i}`}function lo(){let e=Number(process.env.CODEBASEIQ_INDEXER_TIMEOUT_MS);return Number.isFinite(e)&&e>0?Math.floor(e):Dn.indexer}function uo(e){return e instanceof Fn?e.kind==="spawn"&&vr(e.cause):vr(e)}function vr(e){let t=e?.code;return t==="EAGAIN"||t==="ENOMEM"||t==="EMFILE"||t==="ENFILE"||t==="ETXTBSY"}import{execFileSync as wr}from"child_process";import{homedir as Tr,platform as po}from"os";import{delimiter as go,join as Fe}from"path";function Dr(e,t){let n=e.installMethods,r=ge(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(!Ot(i.prerequisite))continue;let a=fo(i);t(`Installing immutable ${i.identity} via ${i.label} into ${a}; expected executable: ${r}.`);try{wr(i.binary,i.args,{stdio:"inherit",windowsHide:!0,timeout:3e5,env:process.env,shell:po()==="win32"});let o=te(e);if(o){let s=o===e.indexerBinary?"":` (using ${o})`;return t(`Successfully installed ${i.identity} via ${i.label}${s}; resolved executable: ${o}.`),!0}t(`${i.label} command completed but ${r} was not found on PATH`)}catch(o){let s=o instanceof Error?o.message:String(o);t(`${i.label} install failed: ${s}`)}}return t(`Could not auto-install ${r}.`),e.installUrl&&t(`Install manually from: ${e.installUrl}`),!1}function fo(e){if(e.binary==="npm")return ft("npm",["root","-g"])??e.destination;if(e.binary==="go"){let t=ft("go",["env","GOBIN"]);if(t)return t;let n=ft("go",["env","GOPATH"]);if(n)return Fe(n.split(go)[0],"bin")}return e.binary==="dotnet"?Fe(process.env.DOTNET_CLI_HOME??Tr(),".dotnet","tools"):e.binary==="dart"?Fe(process.env.PUB_CACHE??Fe(Tr(),".pub-cache"),"bin"):e.destination}function ft(e,t){try{return wr(e,t,{stdio:["ignore","pipe","ignore"],windowsHide:!0,encoding:"utf8",timeout:1e4,killSignal:"SIGKILL",env:process.env}).trim()||null}catch{return null}}async function Xd(e){let{projectRoot:t,maxHeapMb:n=8192,onStatus:r=console.log}=e,i=e.skipAutoInstall===!0||e.installMissing!==!0,a=Ro(e),o=Date.now(),s=S();ke(h(a.outputScip),{recursive:!0}),ke(h(a.outputDb),{recursive:!0});let c=e.languages??We(t);if(c.length===0)throw new Error("No supported languages detected in this project. Looked for: tsconfig.json, Cargo.toml, go.mod, pyproject.toml, etc.");r(`Detected languages: ${c.join(", ")}`);let l=ue("reindex.fingerprint",()=>Mt(t,c,{pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:e.typescriptProjects,clojureConfigPath:e.clojureConfigPath}),{languages:c.length}),d,p;if(e.skipIfUnchanged!==!1&&!hn(t,a.outputDb)&&Fr(a.outputScip)===Fr(v(h(a.outputDb),"index.scip"))){let f=pe(t);if(d=f?.clean?ye(f,l):void 0,f&&!f.clean&&!So(a)){let y=yn(f,c,{pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:e.typescriptProjects,clojureConfigPath:e.clojureConfigPath});if(y)try{be({snapshot:y.snapshot,manifest:y.manifest,targetCacheDir:h(a.outputDb),targetProjectRoot:t,persistLease:!1}),xn(y.snapshot,h(a.outputDb)),r(`Forked shared baseline ${y.snapshot.generationId.slice(0,12)} for dirty worktree reindex`)}catch(R){r(`Shared baseline fork failed; continuing locally: ${N(R)}`)}}else if(d){let y=Je(d);if(y){if(!bo(a,l))try{be({snapshot:d,manifest:y,targetCacheDir:h(a.outputDb),targetProjectRoot:t}),r(`Attached shared generation ${d.generationId.slice(0,12)}`)}catch(R){r(`Shared generation attach failed; continuing locally: ${N(R)}`)}}else{let R=await Sn(d);if(R.kind==="owner")p=R.release;else if(R.kind==="generation-ready"){let E=Je(d);if(E)try{be({snapshot:d,manifest:E,targetCacheDir:h(a.outputDb),targetProjectRoot:t,action:"waited"}),r(`Attached shared generation ${d.generationId.slice(0,12)} after waiting`)}catch(P){r(`Shared generation attach failed after waiting; continuing locally: ${N(P)}`)}}else r("Shared generation build lock timed out; continuing with an isolated local reindex")}}}let g=kt(v(h(a.outputDb),"cache-lifecycle.lock"),{waitMs:3e4});if(!g)throw p?.(),new Error(`Could not acquire codebaseiq cache lifecycle lock for ${h(a.outputDb)}.`);let m;try{m=await Z("reindex.lock",()=>Jo(v(h(a.outputDb),"index.lock"),{projectRoot:t,trigger:e.trigger,onStatus:r}),{languages:c.length})}catch(f){throw g.release(),p?.(),f}let x=null,_=Ln();try{mn(a.outputDb,a.outputScip,a.metaPath);let f=Io(h(a.outputDb));f.removed>0&&r(`Removed ${f.removed} abandoned reindex workspace(s)`);for(let W of f.errors)r(`Could not remove abandoned reindex workspace: ${W}`);let y=null,R=ue("reindex.reuse-check",()=>(y=xo({opts:e,paths:a,languages:c,fingerprint:l,start:o,monotonicStart:s,onStatus:r}),y),()=>({languages:c.length,reused:y!==null}));if(R){jr({snapshot:d,paths:a,projectRoot:t,fingerprint:l,onStatus:r});let W=qe(a.outputDb,R);return W.state==="failed"&&r(`Warning: reindex succeeded, but activity telemetry was not recorded: ${W.reason}`),Ue(t,h(a.outputDb)),R}let E=Eo(a);x=E.runDir;let P,b=await Z("reindex.fresh",async()=>(P=await vo({opts:e,languages:c,projectRoot:t,paths:a,tempPaths:E,fingerprint:l,start:o,monotonicStart:s,maxHeapMb:n,skipAutoInstall:i,onStatus:r,writeTelemetry:_}),P),()=>({languages:c.length,reused:P?.reused,skipped:P?.skipped.length}));jr({snapshot:d,paths:a,projectRoot:t,fingerprint:l,onStatus:r});let B=qe(a.outputDb,b);return B.state==="failed"&&r(`Warning: reindex succeeded, but activity telemetry was not recorded: ${B.reason}`),Ue(t,h(a.outputDb)),b}catch(f){let y=Ne({trigger:e.trigger,result:"failed",start:o,monotonicStart:s,error:f instanceof Error?f.message:String(f)});Qr(a.metaPath,y);let R=nn(a.outputDb,y);throw R.state==="failed"&&r(`Warning: failed reindex activity telemetry was not recorded: ${R.reason}`),f}finally{if(x){let f=x;try{q(()=>Y(f,{recursive:!0,force:!0}))}catch(y){r(`Warning: temporary reindex workspace was left behind: ${N(y)}`)}}m(),g.release(),p?.()}}function jr(e){if(e.snapshot)try{let t=pe(e.projectRoot),n=t?ye(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:h(e.paths.outputDb),sourceProjectRoot:e.projectRoot,sourceStillValid:()=>{let i=pe(e.projectRoot);return(i?ye(i,e.fingerprint):void 0)?.generationId===e.snapshot?.generationId}});Rn(e.snapshot,h(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: ${N(t)}`)}}function bo(e,t){if(!T(e.outputScip)||!T(e.outputDb)||!Vr(e.metaPath,t))return!1;let n=$(e.outputDb,e.metaPath);return n.state!=="invalid"&&n.state!=="drifted"}function So(e){if(!T(e.outputScip)||!T(e.outputDb)||!V(e.metaPath))return!1;let t=$(e.outputDb,e.metaPath);return t.state!=="invalid"&&t.state!=="drifted"}function N(e){return e instanceof Error?e.message:String(e)}function yt(e,t,n,r,i,a){try{re(Nn({indexPath:n,reuseExisting:i,affectedFiles:a}),{projectRoot:e,dbPath:t,onStatus:r})}catch(o){r(`Runtime-boundary extraction unavailable: ${o instanceof Error?o.message:String(o)}.`)}}function Ro(e){let t=e.outputScip??v(e.projectRoot,"index.scip"),n=e.outputDb??v(e.projectRoot,"index.db");return{outputScip:t,outputDb:n,metaPath:v(h(n),"meta.json")}}function xo(e){let t=$(e.paths.outputDb,e.paths.metaPath);if(e.opts.skipIfUnchanged===!1||!T(e.paths.outputScip)||!T(e.paths.outputDb)||!Vr(e.paths.metaPath,e.fingerprint)||t.state==="invalid"||t.state==="drifted")return null;re(ne(),{projectRoot:e.opts.projectRoot,dbPath:e.paths.outputDb,onStatus:e.onStatus}),yt(e.opts.projectRoot,e.paths.outputDb,e.paths.outputScip,e.onStatus,!0),$(e.paths.outputDb,e.paths.metaPath).state==="drifted"&&(He(e.paths.outputDb,e.paths.metaPath),e.onStatus("Published refreshed SQLite generation after post-index augmentation"));let n=S()-e.monotonicStart,r=Ne({trigger:e.opts.trigger,result:"reused",start:e.start,monotonicStart:e.monotonicStart,languages:e.languages,skipped:[]});return Qr(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:Po(e.paths,e.opts.projectRoot,e.languages,e.opts)}}function Po(e,t,n,r){let i=Xr(t,n,r);return n.map(a=>({id:a,language:a,reused:!0,fingerprint:ie(i[a]),outputBytes:ae(St(e.outputDb,a)),durationMs:0}))}function Eo(e){let t=_t(v(h(e.outputDb),"reindex-"));return{runDir:t,tempOutputScip:v(t,je(e.outputScip)),tempOutputDb:v(t,je(e.outputDb)),tempMetaPath:v(t,je(e.metaPath))}}function Io(e){let t=[],n;try{n=Cr(e,{withFileTypes:!0})}catch(i){return{removed:0,errors:[N(i)]}}let r=0;for(let i of n)if(!(!i.name.startsWith("reindex-")||!i.isDirectory()))try{Y(v(e,i.name),{recursive:!0,force:!0}),r+=1}catch(a){t.push(`${i.name}: ${N(a)}`)}return{removed:r,errors:t}}async function vo(e){let t={...process.env,NODE_OPTIONS:`--max-old-space-size=${e.maxHeapMb}`},n,r=await Z("reindex.language-indexers",async()=>(n=await To(e,t),n),()=>({languages:e.languages.length,indexed:n?.indexedOutputs.length,reused:n?.reusedLanguages.length,skipped:n?.skippedLanguages.length})),{indexedOutputs:i,skippedLanguages:a,reusedLanguages:o,languageFingerprints:s,shards:c,typescriptProjectShardContext:l,incrementalTypeScript:d}=r;if(o.length>0&&e.onStatus(`Reused ${o.length} cached language shard(s): ${o.join(", ")}`),_o({run:e,indexedOutputs:i,skippedLanguages:a,reusedLanguages:o})){let g=ue("reindex.publish",()=>Ao(e,i,a,o,s,l),{mode:"metadata-only",languages:i.length,reused:o.length}),m=g.durationMs;return e.onStatus(`All language shards unchanged; reused existing SQLite index in ${(m/1e3).toFixed(1)}s`),{languages:i.map(x=>x.language),indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:m,reused:!0,skipped:a,lastRefresh:g,shards:c,writeTelemetry:e.writeTelemetry}}let p=await Z("reindex.publish",()=>No(e,t,i,a,o,s,l,d),{mode:d?"incremental-or-fallback":"full",languages:i.length,reused:o.length,skipped:a.length}),u=p.durationMs;return e.onStatus(`Done in ${(u/1e3).toFixed(1)}s`),{languages:i.map(g=>g.language),indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:u,reused:!1,skipped:a,lastRefresh:p,shards:c,writeTelemetry:e.writeTelemetry}}function _o(e){if(e.run.opts.skipIfUnchanged===!1||e.skippedLanguages.length>0||!T(e.run.paths.outputScip)||!T(e.run.paths.outputDb))return!1;let t=$(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 To(e,t){let n=ko({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[w,xt]of n)xt.reused&&(r.push({language:w,scipPath:xt.scipPath}),i.add(w));for(let w of i)e.onStatus(`Reusing cached ${w} SCIP shard (language inputs unchanged).`);let a=n.get("typescript"),o=$(e.paths.outputDb,e.paths.metaPath),s=V(e.paths.metaPath),c=(o.state==="legacy"||o.state==="current")&&s!==null&&Ce(s),l=s?.scipCompanion!=="deferred"&&(o.state!=="current"||o.generation.publication?.scipCompanion!=="deferred"),d=a&&!a.reused&&c?Er({projectRoot:e.projectRoot,cacheDir:h(e.paths.outputDb),previousDbPath:e.paths.outputDb,previousIndexPath:e.paths.outputScip,previousShardPath:a.scipPath,candidateShardPath:oe(e.tempPaths.tempOutputScip,"typescript-incremental",0),candidateAffectedScipPath:oe(e.tempPaths.tempOutputScip,"typescript-affected",0),baseShardCurrent:l,previousSnapshot:bt(e.paths.metaPath),currentSnapshot:e.fingerprint,projectMode:e.opts.typescriptProjectMode,onStatus:e.onStatus}):null,p=new Set(d?["typescript"]:[]),u=d?void 0:wo(e,n),{preparedRuns:g,skippedLanguages:m,languageOutputScipPaths:x}=$o({languages:e.languages.filter(w=>!i.has(w)&&!p.has(w)),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:u?.allProjects,clojureConfigPath:e.opts.clojureConfigPath,onStatus:e.onStatus}),_=u?g.filter(w=>w.language!=="typescript"||u.missedProjectIds.has(w.id)):g,f=await _r(_,e.projectRoot,e.onStatus,e.opts.indexerConcurrency,e.opts.signal),y=[];if(u){Fo(e.paths.outputDb,f,e.writeTelemetry);let w=x.typescript??e.tempPaths.tempOutputScip;y=jo({outputDb:e.paths.outputDb,tempOutputScip:e.tempPaths.tempOutputScip,outputScipPath:w,reusedProjects:u.reusedProjects,writeTelemetry:e.writeTelemetry})}let R=[...f,...y],{indexedOutputs:E}=Go(R,m),P=d?[{language:"typescript",scipPath:d.scipPath}]:[],b=[...r,...P,...E];Bo(b,m,e.languages,e.opts.allowPartial,e.onStatus);let B=d?[{id:"typescript",language:"typescript",label:"typescript (incremental documents)",scipPath:d.scipPath,outputScipPath:d.scipPath,durationMs:d.durationMs,command:"watch-service:typescript-index",outputBytes:ae(d.scipPath)??void 0}]:[],W=Oo(n,[...f,...B],u?{outputDb:e.paths.outputDb,classification:u.classification}:void 0);return{indexedOutputs:b,skippedLanguages:m,reusedLanguages:[...i],languageFingerprints:Lo(n,e.languages),shards:W,typescriptProjectShardContext:u?{projects:u.allProjects,fingerprints:u.fingerprints}:void 0,incrementalTypeScript:d??void 0}}function wo(e,t){let n=t.get("typescript");if(!n||n.reused||e.opts.typescriptProjectMode!=="workspace")return;let r=z(e.projectRoot,e.opts.typescriptProjects);if(r.length===0)return;let i=lr(e.projectRoot,r),a=sr(n.fingerprint.files,r),o=cr(r,i),s=dr(r,a,o),c=V(e.paths.metaPath),d=Do(c,s,m=>T(Le(e.paths.outputDb,m))),p=[...d.entries()].filter(([,m])=>m.reused).map(([m])=>m),u=new Set(p),g=new Set(r.filter(m=>!u.has(m)).map(m=>`typescript:${m}`));return{allProjects:r,fingerprints:s,classification:d,reusedProjects:p,missedProjectIds:g}}function Do(e,t,n){let r=new Map;for(let i of Object.keys(t)){let a=t[i];if(!e){r.set(i,{reused:!1,reason:"no reindex metadata found",fingerprint:a});continue}let o=e.version===K&&Me(e).typescriptProjectShardReuse?e.typescriptProjectShards?.[i]:void 0;if(!o){r.set(i,{reused:!1,reason:"no cached fingerprint for this project",fingerprint:a});continue}if(!n(i)){r.set(i,{reused:!1,reason:"cached shard file missing on disk",fingerprint:a});continue}if(j(o)!==j(a)){r.set(i,{reused:!1,reason:"project inputs changed since last index",fingerprint:a});continue}r.set(i,{reused:!0,fingerprint:a})}return r}function Fo(e,t,n){for(let r of t){if(r.skipped||!r.id.startsWith("typescript:"))continue;let i=r.id.slice(11),a=Le(e,i);ke(h(a),{recursive:!0}),G(n,U(r.scipPath,a))}}function jo(e){return e.reusedProjects.map((t,n)=>{let r=Le(e.outputDb,t),i=oe(e.tempOutputScip,"typescript-project-cached",n);return G(e.writeTelemetry,U(r,i)),{id:`typescript:${t}`,language:"typescript",label:`typescript (${t})`,scipPath:i,outputScipPath:e.outputScipPath,durationMs:0,command:"cached",outputBytes:ae(i)??void 0}})}function ko(e){let t=V(e.paths.metaPath),n=Xr(e.projectRoot,e.languages,e),r=new Map;for(let i of e.languages){let a=St(e.paths.outputDb,i),o=n[i];if(!t){r.set(i,{reused:!1,reason:"no reindex metadata found",fingerprint:o,scipPath:a});continue}if(t.version!==K){r.set(i,{reused:!1,reason:`metadata version ${String(t.version??"unknown")} predates per-language shard caching`,fingerprint:o,scipPath:a});continue}if(i==="typescript"&&t.scipCompanion==="deferred"){r.set(i,{reused:!1,reason:"whole TypeScript SCIP companion is deferred behind changed-document overlays",fingerprint:o,scipPath:a});continue}if(!Me(t).languageShardReuse||!t.languageFingerprints){r.set(i,{reused:!1,reason:"no per-language fingerprints recorded in metadata",fingerprint:o,scipPath:a});continue}let s=t.languageFingerprints[i];if(!s){r.set(i,{reused:!1,reason:"no cached fingerprint for this language",fingerprint:o,scipPath:a});continue}if(!T(a)){r.set(i,{reused:!1,reason:"cached shard file missing on disk",fingerprint:o,scipPath:a});continue}if(j(s)!==j(o)){r.set(i,{reused:!1,reason:"language inputs changed since last index",fingerprint:o,scipPath:a});continue}r.set(i,{reused:!0,fingerprint:o,scipPath:a})}return r}function Oo(e,t,n){let r=[];for(let[i,a]of e)a.reused&&r.push({id:i,language:i,reused:!0,fingerprint:ie(a.fingerprint),outputBytes:ae(a.scipPath),durationMs:0});for(let i of t){let a=e.get(i.language),o=n&&i.id.startsWith("typescript:")?i.id.slice(11):null,s=o?n.classification.get(o):void 0;r.push({id:i.id,language:i.language,reused:!1,missReason:s?.reason??a?.reason??i.skipped?.reason,fingerprint:s?ie(s.fingerprint):a?ie(a.fingerprint):"unknown",outputBytes:i.outputBytes??null,durationMs:i.durationMs,command:i.command})}if(n)for(let[i,a]of n.classification)a.reused&&r.push({id:`typescript:${i}`,language:"typescript",reused:!0,fingerprint:ie(a.fingerprint),outputBytes:ae(Le(n.outputDb,i)),durationMs:0});return r}function ie(e){return mo("sha256").update(j(e)).digest("hex").slice(0,16)}function ae(e){try{return ho(e).size}catch{return null}}function Lo(e,t){let n={};for(let r of t){let i=e.get(r);i&&(n[r]=i.fingerprint)}return n}async function No(e,t,n,r,i,a,o,s){D(e.opts.signal,"Reindex cancelled by its owner.");let c=!s||s.completeScipUpdated,l=!1;c&&(kr(e.paths.outputDb,n,e.writeTelemetry),l=Or(n,e.tempPaths.tempOutputScip,e.onStatus));let d=await Wo({run:e,indexedOutputs:n,skippedLanguages:r,reusedLanguages:i,incrementalTypeScript:s,completeScipAvailable:c,completeScipSanitized:l,materializeFullFallback:async()=>{if(D(e.opts.signal,"Reindex cancelled by its owner."),!s||s.completeScipUpdated)return l;e.onStatus("Materializing the deferred whole TypeScript SCIP companion for full conversion..."),Ir({cacheDir:h(e.paths.outputDb),generationIdentity:s.nextFragmentGeneration,baseShardPath:s.scipPath,candidateShardPath:s.candidateScipPath});let E=n.map(P=>P.language==="typescript"?{language:P.language,scipPath:s.candidateScipPath}:P);return kr(e.paths.outputDb,E,e.writeTelemetry),l=Or(E,e.tempPaths.tempOutputScip,e.onStatus),l}});D(e.opts.signal,"Reindex cancelled by its owner."),re(ne(),{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 p=nt(e.tempPaths.tempOutputDb);if(p.added.length>0&&e.onStatus(`Added SQLite query indexes: ${p.added.join(", ")}`),p.removed.length>0&&e.onStatus(`Removed redundant SQLite indexes: ${p.removed.join(", ")}`),d.mode==="incremental"&&s){let E=null,P=null;try{E=new F({projectRoot:e.projectRoot,dbPath:e.tempPaths.tempOutputDb,indexPath:e.tempPaths.tempOutputScip}),P=new F({projectRoot:e.projectRoot,dbPath:e.paths.outputDb,indexPath:e.paths.outputScip});let b=Jt(E,e.fingerprint,s.referenceFragmentsByFile,P);e.onStatus(`Cached exact TypeScript reference fragments for ${b} affected document(s).`)}catch(b){e.onStatus(`Exact TypeScript reference fragment prefill unavailable: ${b instanceof Error?b.message:String(b)}.`)}finally{E?.close(),P?.close()}}let u=bt(e.paths.metaPath),g=d.mode==="incremental"&&s?Ho(s,d.changedDocumentPaths):Ke({projectRoot:e.projectRoot,previousDbPath:e.paths.outputDb,previousIndexPath:e.paths.outputScip,candidateDbPath:e.tempPaths.tempOutputDb,candidateIndexPath:e.tempPaths.tempOutputScip,previousSnapshot:u,currentSnapshot:e.fingerprint,refreshResult:"rebuilt"}),m=Ne({trigger:e.opts.trigger,result:"rebuilt",start:e.start,monotonicStart:e.monotonicStart,languages:n.map(E=>E.language),skipped:[...r]}),x=d.mode==="incremental"&&d.scipCompanion==="deferred",_={...a};x&&delete _.typescript;let{metadata:f,pruneProjects:y}=Gr({run:e,indexedOutputs:n,skippedLanguages:r,reusedLanguages:i,languageFingerprints:_,typescriptProjectShardContext:o,lastRefresh:m});f.scipCompanion=x?"deferred":"current",Br(e.paths.outputDb,y),Rt(e.tempPaths.tempMetaPath,f);let R=fn({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:d.mode==="incremental"&&d.scipCompanion==="deferred",publication:d.mode==="incremental"?{mode:"incremental",validation:"passed",converterDurationMs:d.converterDurationMs,affectedDocumentCount:s?.affectedFiles.length,changedDocumentCount:d.changedDocumentPaths.length,producerDurationMs:s?.timings.serviceMs,materializationDurationMs:s?.durationMs,patchDurationMs:d.patchDurationMs,scipCompanion:d.scipCompanion,...d.scipCompanion==="deferred"&&s?{typescriptOverlayGeneration:s.nextFragmentGeneration}:{}}:{mode:"full",validation:"passed",converterDurationMs:d.converterDurationMs,scipCompanion:"current",...d.fallbackReason?{fallbackReason:d.fallbackReason}:{}}});return R.achievedDurability==="file-flushed"&&e.onStatus(`Published local generation ${R.currentGeneration.slice(0,12)} (file-flushed; directory sync unsupported)`),gn(h(e.paths.outputDb),d.mode==="incremental"&&d.scipCompanion==="deferred"?[s.nextFragmentGeneration]:[]),dn(h(e.paths.outputDb),s?.completeScipUpdated?[s.nextFragmentGeneration]:[]),Ur(e.paths.outputDb,g,e.onStatus),m}function Ao(e,t,n,r,i,a){let o=bt(e.paths.metaPath),s=null;try{G(e.writeTelemetry,U(e.paths.outputDb,e.tempPaths.tempOutputDb))}catch(u){s=Gn("reused","oracle-error",`Could not snapshot the prior database: ${u instanceof Error?u.message:String(u)}`)}re(ne(),{projectRoot:e.projectRoot,dbPath:e.paths.outputDb,onStatus:e.onStatus}),yt(e.projectRoot,e.paths.outputDb,e.paths.outputScip,e.onStatus,!0);let c=nt(e.paths.outputDb);c.added.length>0&&e.onStatus(`Added SQLite query indexes: ${c.added.join(", ")}`),c.removed.length>0&&e.onStatus(`Removed redundant SQLite indexes: ${c.removed.join(", ")}`),s??=Ke({projectRoot:e.projectRoot,previousDbPath:e.tempPaths.tempOutputDb,previousIndexPath:e.paths.outputScip,candidateDbPath:e.paths.outputDb,candidateIndexPath:e.paths.outputScip,previousSnapshot:o,currentSnapshot:e.fingerprint,refreshResult:"reused"});let l=Ne({trigger:e.opts.trigger,result:"reused",start:e.start,monotonicStart:e.monotonicStart,languages:t.map(u=>u.language),skipped:[...n]}),{metadata:d,pruneProjects:p}=Gr({run:e,indexedOutputs:t,skippedLanguages:n,reusedLanguages:r,languageFingerprints:i,typescriptProjectShardContext:a,lastRefresh:l});return Br(e.paths.outputDb,p),Rt(e.paths.metaPath,d),He(e.paths.outputDb,e.paths.metaPath),Ur(e.paths.outputDb,s,e.onStatus),l}function bt(e){return vt(V(e)?.fingerprint)}function Ur(e,t,n){try{Wn(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 Gr(e){let t=Mo({mode:e.run.opts.typescriptProjectMode,skippedLanguages:e.skippedLanguages,reusedLanguages:e.reusedLanguages,context:e.typescriptProjectShardContext,metaPath:e.run.paths.metaPath});return{metadata:{version:K,status:e.skippedLanguages.length===0?"complete":"partial",updatedAt:new Date().toISOString(),fingerprint:e.run.fingerprint,sqliteLayoutVersion:2,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 Mo(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=V(e.metaPath),n=t?.version===K?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 Br(e,t){let n=Yr(e);if(t===null){q(()=>Y(n,{recursive:!0,force:!0}));return}let r;try{r=Cr(n)}catch{return}for(let i of Co(r,t))q(()=>Y(v(n,i),{force:!0}))}function Co(e,t){let n=new Set(t.map(r=>`${ot(r)}.scip`));return e.filter(r=>!n.has(r))}function kr(e,t,n){for(let r of t){let i=St(e,r.language);ke(h(i),{recursive:!0}),r.scipPath!==i&&G(n,U(r.scipPath,i))}}function $o(e){let t=[],n=[],r=e.languages.map((a,o)=>({language:a,scipPath:e.languages.length>1?oe(e.tempOutputScip,a,o):e.tempOutputScip})),i=Object.fromEntries(r.map(({language:a,scipPath:o})=>[a,o]));for(let{language:a,scipPath:o}of r){let s=Uo({...e,language:a,scipPath:o});for(let c of s)"skipped"in c?Wr(n,c.skipped):t.push(c.prepared)}return{preparedRuns:t,skippedLanguages:n,languageOutputScipPaths:i}}function Uo(e){if(e.language!=="typescript"||e.typescriptProjectMode!=="workspace")return[mt({...e,id:e.language,label:e.language,outputScipPath:e.scipPath})];let t=e.preDiscoveredTypeScriptProjects??z(e.projectRoot,e.typescriptProjects);return t.length===0?[mt({...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)=>mt({...e,id:`typescript:${n}`,label:`typescript (${n})`,scipPath:oe(e.tempOutputScip,"typescript-project",r),outputScipPath:e.scipPath,pnpmWorkspaces:!1,projectPath:n})))}function mt(e){let t=Ze(e.language),n=ge(t),r=$t(t,e.projectRoot),i=e.trustProjectTools&&r?Ut(t,e.projectRoot):null,a=te(t);if(!i&&!a&&r){let d=`${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}: ${d}`),{skipped:{language:e.language,reason:d}}}if(!i&&!a&&!Ct(t)){if(e.skipAutoInstall){let d=`${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}: ${d}`),{skipped:{language:e.language,reason:d}}}if(e.onStatus(`${n} not found. Attempting auto-install...`),!Dr(t,e.onStatus)){let d=`${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}: ${d}`),{skipped:{language:e.language,reason:d}}}}let o=i?.canonicalPath??te(t);if(!o){let d=`${n} was not found after installation checks.`;return e.onStatus(`Skipping ${e.language}: ${d}`),{skipped:{language:e.language,reason:d}}}let{binary:s,args:c}=t.indexArgs({projectRoot:e.projectRoot,outputPath:e.scipPath,pnpmWorkspaces:e.pnpmWorkspaces,indexerBinary:o,projectPath:e.projectPath,configPath:e.language==="clojure"?e.clojureConfigPath:void 0}),l=Vn({language:e.language,projectPath:e.projectPath,pnpmWorkspaces:e.pnpmWorkspaces});if(i&&!i.executable){let d=`${i.relativePath} is not executable; refusing project-local indexer.`;return e.onStatus(`Skipping ${e.language}: ${d}`),{skipped:{language:e.language,reason:d}}}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:o,binary:s,args:c,env:Bt(t,e.env,o),...l===void 0?{}:{temporaryRootConfigContent:l},...i?{trustedProjectTool:i}:{}}}}function Go(e,t){let n=new Map;for(let i of e)if(i.skipped)Wr(t,i.skipped);else{let a=`${i.language}\0${i.outputScipPath}`,o=n.get(a)??{language:i.language,outputScipPath:i.outputScipPath,scipPaths:[]};o.scipPaths.push(i.scipPath),n.set(a,o)}let r=[];for(let i of n.values())if(i.scipPaths.length>1)en(i.scipPaths,i.outputScipPath),r.push({language:i.language,scipPath:i.outputScipPath});else{let a=i.scipPaths[0];a!==i.outputScipPath&&$r(a,i.outputScipPath),r.push({language:i.language,scipPath:i.outputScipPath})}return{indexedOutputs:r}}function Wr(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 Bo(e,t,n,r,i){if(e.length===0){let a=t.map(o=>` - ${o.language}: ${o.reason}`).join(`
274
274
  `);throw new Error(`No language indexers ran successfully. Install at least one indexer for the languages in this project.
275
275
  `+a)}if(t.length!==0&&(i(`Indexed ${e.length} language output(s); skipped or incomplete: ${t.map(a=>a.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.
276
276
  `+t.map(a=>` - ${a.language}: ${a.reason}`).join(`
277
- `))}function Or(e,t,n){if(e.length>1){n(`Merging ${e.length} language indexes...`);let r=performance.now(),i=tn(e.map(a=>a.scipPath),t);return qr(i,n),n(`Merged and sanitized SCIP indexes in ${(performance.now()-r).toFixed(0)}ms.`),!0}else e[0].scipPath!==t&&$r(e[0].scipPath,t);return!1}async function Bo(e){let t;if(Wo(e)){let i=v(e.run.tempPaths.runDir,"typescript-affected.db");try{e.run.onStatus(`Converting ${e.incrementalTypeScript.affectedFiles.length} affected TypeScript document(s) to SQLite...`);let a=performance.now();Lr(e.incrementalTypeScript.affectedScipPath,i,e.run.onStatus,!1,e.run.opts.signal),e.run.onStatus(`Converted affected SCIP documents in ${(performance.now()-a).toFixed(0)}ms.`);let o=nr({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 ${o.affectedDocumentCount} SQLite document(s) in ${(o.durationMs/1e3).toFixed(3)}s.`),{mode:"incremental",changedDocumentPaths:o.changedDocumentPaths,patchDurationMs:o.durationMs,converterDurationMs:performance.now()-a,scipCompanion:e.incrementalTypeScript.completeScipUpdated?"current":"deferred"}}catch(a){D(e.run.opts.signal,"Reindex cancelled by its owner."),t=a instanceof Error?a.message:String(a),q(()=>Y(i,{force:!0})),q(()=>Y(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 Lr(e.run.tempPaths.tempOutputScip,e.run.tempPaths.tempOutputDb,e.run.onStatus,n,e.run.opts.signal),{mode:"full",converterDurationMs:performance.now()-r,...t?{fallbackReason:t}:{}}}function Wo(e){if(!e.incrementalTypeScript||e.skippedLanguages.length>0||!T(e.run.paths.outputDb)||!T(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 qo(e,t){let n=S(),r=[...t].sort(),i=new Set(r),a={addedFiles:[],modifiedFiles:r,deletedFiles:[],changedFiles:r,unchangedFiles:e.affectedFiles.filter(o=>!i.has(o)).sort()};return{version:1,status:"evaluated",refreshResult:"rebuilt",recordedAt:new Date().toISOString(),durationMs:S()-n,manifest:e.manifest,plan:e.plan,comparison:a,evaluation:Qe(e.plan,a,e.projectFileCount)}}function Lr(e,t,n,r,i){if(D(i,"Reindex cancelled by its owner."),n("Writing the SQLite index..."),!T(e))throw new Error(`SCIP index not found at ${e} after indexing`);try{qr(br(e,t,{sanitize:!r}),n)}catch(a){let o=a instanceof Error?a.message:String(a);throw new Error(`Failed to write the SQLite index: ${o}`,{cause:a})}}function qr(e,t){e.removedDefinitionOccurrences!==0&&t(`Sanitized ${e.removedDefinitionOccurrences} invalid definition occurrences across ${e.touchedDocuments} documents before SQLite conversion.`)}function oe(e,t,n){let r=ho(e)||".scip",i=ke(e,r);return v(h(e),`${i}.${n+1}.${t}${r}`)}async function Ho(e,t){for(let n=0;n<2;n++){let r=Jo(e,t);if(r)return r;let i=zo(e);if(i&&zr(t.trigger,i)){t.onStatus(`Manual reindex preempting watcher refresh started at ${i.startedAt}.`);let a;try{a=await Yo(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: ${N(s)}`,{cause:s})}if(!a)throw new Error(`Could not confirm the watcher's in-progress reindex (pid ${i.pid}) terminated for ${h(e)}; refusing to steal an active lock.`);let o=Ge(e,{parseLegacy:Oe});if(!kt(e,o,{parseLegacy:Oe}))throw new Error(`Reindex lock ownership changed before preemption completed for ${h(e)}.`);continue}throw new Error(`Another codebaseiq reindex is already running for ${h(e)}.`)}throw new Error(`Could not acquire codebaseiq reindex lock for ${h(e)}.`)}function Jo(e,t){let n=H(process.pid),r=Ft(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:Oe});if(r.kind==="acquired"&&r.reclaimed){let i=Hr(r.reclaimed,e);i&&zr(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 ${h(e)}.`)}return r.kind==="acquired"?()=>{r.lock.release()}:null}function zo(e){return Hr(Ge(e,{parseLegacy:Oe}),e)}var Oe=e=>{let t=Jr(e,"");return t?{pid:t.pid,...t.processIdentity?{processIdentity:t.processIdentity}:{}}:null};function Hr(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:h(t),startedAt:e.record.startedAt,trigger:n.trigger}}return Jr(e.parsed,t)}function Jr(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=Tt(n.processIdentity);return r?.pid===n.pid?{processIdentity:r}:{}})(),...n.processGroupLeader===!0?{processGroupLeader:!0}:{},projectRoot:typeof n.projectRoot=="string"?n.projectRoot:h(t),startedAt:typeof n.startedAt=="string"?n.startedAt:"unknown",trigger:n.trigger}}catch{return null}}function zr(e,t){return e?.kind==="manual-cli"&&Xo(t?.trigger)}function Xo(e){return e?.kind==="watch-source"||e?.kind==="watch-git-head"||e?.kind==="watch-git-index"||e?.kind==="watch-git-state"}async function Yo(e){return!J(e.pid)||(ht(e),Nr(e,"SIGTERM"),await Ar(e,2e3))?!0:(ht(e),Nr(e,"SIGKILL"),Ar(e,1e3))}function Nr(e,t){if(e.processGroupLeader)try{process.kill(-e.pid,t);return}catch{if(!J(e.pid))return;ht(e)}try{process.kill(e.pid,t)}catch{}}async function Ar(e,t){let n=S()+t;for(;S()<n;){if(Mr(e))return!0;await Vo(50)}return Mr(e)}function ht(e){if(!e.processIdentity)throw new Error(`Refusing to signal reindex pid ${e.pid}: its ownership record has no process identity.`);let t=H(e.pid);if(!t)throw new Error(`Refusing to signal reindex pid ${e.pid}: its process identity is unavailable.`);if(!ee(e.processIdentity,t))throw new Error(`Refusing to signal reindex pid ${e.pid}: its process identity does not match the ownership record.`)}function Mr(e){if(!J(e.pid))return!0;if(!e.processIdentity)return!1;let t=H(e.pid);return t!==null&&!ee(e.processIdentity,t)}function Vo(e){return new Promise(t=>setTimeout(t,e))}function Xr(e,t,n){return Object.fromEntries(t.map(r=>{let i=r==="typescript"?Nt(n.typescriptProjects):[],a=r==="clojure"?Qo(n.clojureConfigPath):void 0,o=[...Ze(r).markerFiles,...i,...a?[a]:[]],s=r==="typescript"?{typescriptProjectMode:n.typescriptProjectMode??"single",typescriptProjects:i}:{typescriptProjectMode:"single",typescriptProjects:[]};return[r,{version:2,languages:[r],pnpmWorkspaces:r==="typescript"&&Ko(n),...s,clojureConfigPath:a,files:At(e,{language:r,markerFiles:o})}]}))}function Qo(e){return e?.trim()||void 0}function Ko(e){return e.typescriptProjectMode!=="workspace"&&e.pnpmWorkspaces===!0}function St(e,t){return v(h(e),"language-indexes",`${t}.scip`)}function Yr(e){return v(h(e),"language-indexes","typescript-projects")}function Le(e,t){return v(Yr(e),`${ot(t)}.scip`)}function V(e){try{return Ae(le(ce(e,"reindex metadata")))}catch{return null}}function Vr(e,t){try{let n=le(ce(e,"reindex metadata"));if(n.kind!=="legacy"&&n.kind!=="supported")return!1;let r=n.metadata;return n.capabilities.publishableGeneration&&Ce(r)&&k(r.fingerprint)===k(t)&&k([...r.indexedLanguages??[]].sort())===k(t.languages)}catch{return!1}}function Rt(e,t){qt(e,t,{spacing:2,trailingNewline:!0})}function Qr(e,t){try{let n=Ae(le(ce(e,"reindex metadata")));if(!n)return;Rt(e,{...n,lastRefresh:t})}catch{}}function Ne(e){return{trigger:e.trigger??{kind:"unknown"},result:e.result,startedAt:new Date(e.start).toISOString(),completedAt:new Date().toISOString(),durationMs:S()-e.monotonicStart,indexedLanguages:e.languages?[...e.languages]:void 0,skipped:e.skipped?[...e.skipped]:void 0,error:e.error}}function k(e){return JSON.stringify(e)}export{xs as a,Ps as b,Ze as c,Dr as d,zd as e};
278
- //# sourceMappingURL=chunk-O2KWU34K.js.map
277
+ `))}function Or(e,t,n){if(e.length>1){n(`Merging ${e.length} language indexes...`);let r=performance.now(),i=tn(e.map(a=>a.scipPath),t);return qr(i,n),n(`Merged and sanitized SCIP indexes in ${(performance.now()-r).toFixed(0)}ms.`),!0}else e[0].scipPath!==t&&$r(e[0].scipPath,t);return!1}async function Wo(e){let t;if(qo(e)){let i=v(e.run.tempPaths.runDir,"typescript-affected.db");try{e.run.onStatus(`Converting ${e.incrementalTypeScript.affectedFiles.length} affected TypeScript document(s) to SQLite...`);let a=performance.now();Lr(e.incrementalTypeScript.affectedScipPath,i,e.run.onStatus,!1,e.run.opts.signal),e.run.onStatus(`Converted affected SCIP documents in ${(performance.now()-a).toFixed(0)}ms.`);let o=nr({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 ${o.affectedDocumentCount} SQLite document(s) in ${(o.durationMs/1e3).toFixed(3)}s.`),{mode:"incremental",changedDocumentPaths:o.changedDocumentPaths,patchDurationMs:o.durationMs,converterDurationMs:performance.now()-a,scipCompanion:e.incrementalTypeScript.completeScipUpdated?"current":"deferred"}}catch(a){D(e.run.opts.signal,"Reindex cancelled by its owner."),t=a instanceof Error?a.message:String(a),q(()=>Y(i,{force:!0})),q(()=>Y(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 Lr(e.run.tempPaths.tempOutputScip,e.run.tempPaths.tempOutputDb,e.run.onStatus,n,e.run.opts.signal),{mode:"full",converterDurationMs:performance.now()-r,...t?{fallbackReason:t}:{}}}function qo(e){if(!e.incrementalTypeScript||e.skippedLanguages.length>0||!T(e.run.paths.outputDb)||!T(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 Ho(e,t){let n=S(),r=[...t].sort(),i=new Set(r),a={addedFiles:[],modifiedFiles:r,deletedFiles:[],changedFiles:r,unchangedFiles:e.affectedFiles.filter(o=>!i.has(o)).sort()};return{version:1,status:"evaluated",refreshResult:"rebuilt",recordedAt:new Date().toISOString(),durationMs:S()-n,manifest:e.manifest,plan:e.plan,comparison:a,evaluation:Qe(e.plan,a,e.projectFileCount)}}function Lr(e,t,n,r,i){if(D(i,"Reindex cancelled by its owner."),n("Writing the SQLite index..."),!T(e))throw new Error(`SCIP index not found at ${e} after indexing`);try{qr(br(e,t,{sanitize:!r}),n)}catch(a){let o=a instanceof Error?a.message:String(a);throw new Error(`Failed to write the SQLite index: ${o}`,{cause:a})}}function qr(e,t){e.removedDefinitionOccurrences!==0&&t(`Sanitized ${e.removedDefinitionOccurrences} invalid definition occurrences across ${e.touchedDocuments} documents before SQLite conversion.`)}function oe(e,t,n){let r=yo(e)||".scip",i=je(e,r);return v(h(e),`${i}.${n+1}.${t}${r}`)}async function Jo(e,t){for(let n=0;n<2;n++){let r=zo(e,t);if(r)return r;let i=Xo(e);if(i&&zr(t.trigger,i)){t.onStatus(`Manual reindex preempting watcher refresh started at ${i.startedAt}.`);let a;try{a=await Vo(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: ${N(s)}`,{cause:s})}if(!a)throw new Error(`Could not confirm the watcher's in-progress reindex (pid ${i.pid}) terminated for ${h(e)}; refusing to steal an active lock.`);let o=Ge(e,{parseLegacy:Oe});if(!jt(e,o,{parseLegacy:Oe}))throw new Error(`Reindex lock ownership changed before preemption completed for ${h(e)}.`);continue}throw new Error(`Another codebaseiq reindex is already running for ${h(e)}.`)}throw new Error(`Could not acquire codebaseiq reindex lock for ${h(e)}.`)}function zo(e,t){let n=H(process.pid),r=Ft(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:Oe});if(r.kind==="acquired"&&r.reclaimed){let i=Hr(r.reclaimed,e);i&&zr(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 ${h(e)}.`)}return r.kind==="acquired"?()=>{r.lock.release()}:null}function Xo(e){return Hr(Ge(e,{parseLegacy:Oe}),e)}var Oe=e=>{let t=Jr(e,"");return t?{pid:t.pid,...t.processIdentity?{processIdentity:t.processIdentity}:{}}:null};function Hr(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:h(t),startedAt:e.record.startedAt,trigger:n.trigger}}return Jr(e.parsed,t)}function Jr(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=Tt(n.processIdentity);return r?.pid===n.pid?{processIdentity:r}:{}})(),...n.processGroupLeader===!0?{processGroupLeader:!0}:{},projectRoot:typeof n.projectRoot=="string"?n.projectRoot:h(t),startedAt:typeof n.startedAt=="string"?n.startedAt:"unknown",trigger:n.trigger}}catch{return null}}function zr(e,t){return e?.kind==="manual-cli"&&Yo(t?.trigger)}function Yo(e){return e?.kind==="watch-source"||e?.kind==="watch-git-head"||e?.kind==="watch-git-index"||e?.kind==="watch-git-state"}async function Vo(e){return!J(e.pid)||(ht(e),Nr(e,"SIGTERM"),await Ar(e,2e3))?!0:(ht(e),Nr(e,"SIGKILL"),Ar(e,1e3))}function Nr(e,t){if(e.processGroupLeader)try{process.kill(-e.pid,t);return}catch{if(!J(e.pid))return;ht(e)}try{process.kill(e.pid,t)}catch{}}async function Ar(e,t){let n=S()+t;for(;S()<n;){if(Mr(e))return!0;await Qo(50)}return Mr(e)}function ht(e){if(!e.processIdentity)throw new Error(`Refusing to signal reindex pid ${e.pid}: its ownership record has no process identity.`);let t=H(e.pid);if(!t)throw new Error(`Refusing to signal reindex pid ${e.pid}: its process identity is unavailable.`);if(!ee(e.processIdentity,t))throw new Error(`Refusing to signal reindex pid ${e.pid}: its process identity does not match the ownership record.`)}function Mr(e){if(!J(e.pid))return!0;if(!e.processIdentity)return!1;let t=H(e.pid);return t!==null&&!ee(e.processIdentity,t)}function Qo(e){return new Promise(t=>setTimeout(t,e))}function Xr(e,t,n){return Object.fromEntries(t.map(r=>{let i=r==="typescript"?Nt(n.typescriptProjects):[],a=r==="clojure"?Ko(n.clojureConfigPath):void 0,o=[...Ze(r).markerFiles,...i,...a?[a]:[]],s=r==="typescript"?{typescriptProjectMode:n.typescriptProjectMode??"single",typescriptProjects:i}:{typescriptProjectMode:"single",typescriptProjects:[]};return[r,{version:2,languages:[r],pnpmWorkspaces:r==="typescript"&&Zo(n),...s,clojureConfigPath:a,files:At(e,{language:r,markerFiles:o})}]}))}function Ko(e){return e?.trim()||void 0}function Zo(e){return e.typescriptProjectMode!=="workspace"&&e.pnpmWorkspaces===!0}function St(e,t){return v(h(e),"language-indexes",`${t}.scip`)}function Yr(e){return v(h(e),"language-indexes","typescript-projects")}function Le(e,t){return v(Yr(e),`${ot(t)}.scip`)}function V(e){try{return Ae(le(ce(e,"reindex metadata")))}catch{return null}}function Vr(e,t){try{let n=le(ce(e,"reindex metadata"));if(n.kind!=="legacy"&&n.kind!=="supported")return!1;let r=n.metadata;return n.capabilities.publishableGeneration&&Ce(r)&&j(r.fingerprint)===j(t)&&j([...r.indexedLanguages??[]].sort())===j(t.languages)}catch{return!1}}function Rt(e,t){qt(e,t,{spacing:2,trailingNewline:!0})}function Qr(e,t){try{let n=Ae(le(ce(e,"reindex metadata")));if(!n)return;Rt(e,{...n,lastRefresh:t})}catch{}}function Ne(e){return{trigger:e.trigger??{kind:"unknown"},result:e.result,startedAt:new Date(e.start).toISOString(),completedAt:new Date().toISOString(),durationMs:S()-e.monotonicStart,indexedLanguages:e.languages?[...e.languages]:void 0,skipped:e.skipped?[...e.skipped]:void 0,error:e.error}}function j(e){return JSON.stringify(e)}export{Ps as a,Es as b,Ze as c,Dr as d,Xd as e};
278
+ //# sourceMappingURL=chunk-M3IBH6C3.js.map
@@ -1,5 +1,5 @@
1
- import{a as Q,b as ee,c as ne}from"./chunk-IHSLIIL3.js";import{a as Z}from"./chunk-DDRA3QKN.js";import{c as Y}from"./chunk-BGYRF5YX.js";import{a as X,b as z,c as W}from"./chunk-JCMFBF4Z.js";import{a as J,d as w}from"./chunk-VGWZ4MOY.js";import{a as K}from"./chunk-LMTSB3TB.js";import{a as H,d as V}from"./chunk-BGGB5N53.js";import{h as G}from"./chunk-GQLDYCWS.js";import{a as x}from"./chunk-BRQL7AFJ.js";import{p as q}from"./chunk-F74LZWCE.js";import{x as U}from"./chunk-7GAK2F3H.js";import{createHash as ue}from"crypto";var le=6,ve=12,be=48,Ce=2e4,te=12,L=Number.MAX_SAFE_INTEGER,ye=["definition","callers","callees"],_={search:12,"exact-source":24,definition:24,caller:8,callee:8,"production-reference":6,"test-reference":2,dependency:6,consumer:6};function tn(e,t){if(t.cursor)throw new Error("Inspect no longer accepts semantic packet cursors. Run the original inspect selectors again.");let n=xe(t),r=we(e,n),i=r.candidates.sort((c,p)=>M(c,p));n.view==="behavior"&&Pe(e,i),Re(e,i),n.view==="behavior"&&Ee(e,i);let o=Q(i.map(c=>O(c,n.view)),n.evidenceBudgets,(c,p)=>M(c.candidate,p.candidate)),{selected:u,omitted:a}=ee(o.selected,n.maxUnits,n.maxCharacters,(c,p)=>M(c.candidate,p.candidate),n.view==="source"),d=u.map(c=>c.candidate),s=[...o.omitted,...a].map(c=>c.candidate),l=d.map(Ae),m=z(d.map(c=>c.kind==="source"?c.bindingClosure:void 0),d.filter(c=>c.kind==="source").map(c=>({relativePath:c.relativePath,startLine:c.startLine,endLine:c.endLine}))),h=l.reduce((c,p)=>c+(p.kind==="source"?qe(p.source):0),0),g=l.reduce((c,p)=>c+(p.kind==="source"?p.source.length:0),0),y=l.reduce((c,p)=>c+he(p,n.view),0),v=l.filter(c=>c.kind==="source"&&(c.roles.includes("search")||c.roles.includes("location"))).map(De),b=i.filter(c=>c.kind==="source"&&(c.roles.includes("search")||c.roles.includes("location"))).length,fe=l.filter(c=>c.kind==="source"&&(c.roles.includes("search")||c.roles.includes("location"))).length,P=r.searches.map(c=>Me(c,i,d)),ge=Fe(s),N=r.locations.every(c=>c.matched)&&r.evidence.every(c=>c.kind==="matched")&&r.searches.every(c=>Te(c.textCoverage))&&s.every(c=>!c.roles.some(p=>p==="location"||p==="definition")),A=P.reduce((c,p)=>c+p.omittedMatches,0),R=s.length===0&&A===0,$=R?void 0:me(n,!0),D=$e(n,s),Se=Le(R,N,s.length+A,D,P,$),j=i.filter(c=>n.view==="behavior"&&c.kind==="source"&&c.roles.some(p=>p==="location"||p==="definition"||p==="search")).map(c=>({id:`inspect:${c.relativePath}:${c.startLine}-${c.endLine}`,label:c.ownerShort??`${c.relativePath}:${c.startLine+1}`,file:c.relativePath,startLine:c.startLine,endLine:c.endLine})),B=j.length>0?Y(e,j):void 0;return{searches:P,evidence:r.evidence,locations:r.locations,slices:v,candidateSlices:b,omittedSlices:b-fe,maxSlices:b,maxTotalLines:h,units:l,candidateUnits:i.length,omittedUnits:s.length,maxUnits:n.maxUnits,maxCharacters:n.maxCharacters,returnedLines:h,returnedCharacters:g,returnedViewCharacters:y,view:n.view,omissionGroups:D,packetCoverage:{mode:R?"complete":"bounded",candidateUnits:i.length,returnedUnits:l.length,omittedUnits:s.length,omittedByRole:ge,exactSelectorsComplete:N,maxUnits:n.maxUnits,maxCharacters:n.maxCharacters,channels:Oe(i,d,n.evidenceBudgets,n.view),...$?{expansionCommand:$}:{}},stoppingSummary:Se,...B&&B.candidateAnchors>0?{causalFrontier:B}:{},bindingClosure:m,continuation:null}}function Le(e,t,n,r,i,o){let u=f([...r.map(a=>a.drillCommand),...i.flatMap(a=>a.exactFollowup?[a.exactFollowup]:[]),...o?[o]:[]]);return e&&t?{queryStatus:"selection-complete",status:"stop-ready",openEvidence:0,guidance:"All evidence requested by this inspect query was materialized.",drillCommands:[]}:t?{queryStatus:"frontier-accounted",status:"relevance-check-required",openEvidence:n,guidance:"Withheld evidence is accounted for by recoverable groups; drill the groups relevant to the current decision.",drillCommands:u}:{queryStatus:"coverage-incomplete",status:"exact-evidence-withheld",openEvidence:n,guidance:"A requested identity, exact source unit, or current-text coverage requirement is unresolved; drill before relying on it.",drillCommands:u}}function xe(e){let t=F(e.searches),n=F(e.symbols),r=F(e.locations),i=t.length+n.length+r.length;if(i===0)throw new Error("inspect requires at least one --search, --symbol, or --at selector.");if(i>24)throw new RangeError(`inspect accepts at most ${24} selectors; received ${i}.`);let o=e.evidence??{};if(e.unitLines!==void 0&&C(e.unitLines,"unitLines"),e.totalLines!==void 0&&C(e.totalLines,"totalLines"),e.sliceLimit!==void 0&&C(e.sliceLimit,"sliceLimit"),e.maxCharacters!==void 0&&C(e.maxCharacters,"maxCharacters"),e.maxUnits!==void 0&&C(e.maxUnits,"maxUnits"),e.view!==void 0&&e.view!=="source"&&e.view!=="behavior")throw new Error(`Unknown inspect view: ${String(e.view)}. Use source or behavior.`);if(e.full&&(e.searchLimit!==void 0||e.maxUnits!==void 0||e.maxCharacters!==void 0||e.evidenceBudgets!==void 0))throw new Error("full inspect cannot be combined with searchLimit, maxUnits, maxCharacters, or evidenceBudgets.");let u=e.full??!1;return{searches:t,symbols:n,locations:r,...e.scope?.trim()?{scope:e.scope.trim()}:{},context:ae(e.context??le,"context"),searchLimit:C(e.searchLimit??(u?L:ve),"searchLimit"),maxUnits:C(u?L:e.maxUnits??be,"maxUnits"),maxCharacters:C(u?L:e.maxCharacters??Ce,"maxCharacters"),evidenceBudgets:u?Ue():Ie(e.evidenceBudgets??_),view:e.view??"source",evidence:{...o.parts?{parts:[...o.parts]}:n.length>0?{parts:[...ye]}:{},...o.referenceContext!==void 0?{referenceContext:ae(o.referenceContext,"referenceContext")}:{},relatedSourceLines:o.relatedSourceLines??60,...o.semantic!==void 0?{semantic:o.semantic}:{}}}}function Ie(e){let t={..._};for(let[n,r]of Object.entries(e)){if(!(n in t))throw new Error(`Unknown inspect evidence channel: ${n}.`);if(!Number.isSafeInteger(r)||(r??-1)<0)throw new RangeError(`Evidence budget ${n} must be a non-negative safe integer; received ${r}.`);t[n]=r}return t}function Ue(){return Object.fromEntries(Object.keys(_).map(e=>[e,L]))}function we(e,t){let n=[],r=0,i=t.searches.map(s=>{let l=ne(e,s,{scope:t.scope,context:0,limit:t.searchLimit,ranking:"structural"});return{pattern:s,result:l,matches:l.matches}}),o=Math.max(0,...i.map(s=>s.matches.length));for(let s=0;s<o;s+=1)for(let l of i){let m=l.matches[s];if(!m)continue;let h=w(e,m.relativePath,m.focusLine,L,t.context);h&&I(e,n,h,"search",`search:${l.pattern}`,m.ownerSymbol,m.ownerShort,1,r++)}let u=i.map(({pattern:s,result:l})=>{let m=l.omittedMatches>0?de(s,t.scope):void 0,h=l.fileCoverage??[],g=_e(s,h,t.scope);return{pattern:s,matchingLines:l.matchingLines,returnedMatches:l.matches.length,omittedMatches:l.omittedMatches,matchingFiles:h.length,returnedFiles:h.filter(y=>y.returnedMatches>0).length,omittedFiles:h.filter(y=>y.returnedMatches===0).length,candidateUnits:0,selectedUnits:0,omittedUnits:0,scopeHints:g.slice(0,te),omittedScopeHints:Math.max(0,g.length-te),textCoverage:l.textCoverage,...m?{exactFollowup:m}:{}}}),a=t.locations.map(s=>{let l=je(s),m=l?K(e,l.path):null,h=m?w(e,m,l.line-1,L,t.context):null;return h&&I(e,n,h,"location",`at:${s}`,null,null,0,r++),{target:s,matched:h!==null}}),d=t.symbols.map(s=>Z(e,s,t.evidence));for(let s of d)if(s.kind==="matched"){if(s.definition){let l=w(e,s.definition.relativePath,s.definition.startLine,L,t.context);l&&I(e,n,l,"definition",`definition:${s.shortName}`,s.symbol,s.shortName,0,r++)}for(let l of s.referenceWindows){let m=l.references[0];I(e,n,{...l,focusLine:m?.line??l.startLine,unitType:null,unitStartLine:l.startLine,unitEndLine:l.endLine,omittedLines:0},"reference",`reference:${s.shortName}`,m?.enclosingSymbol??null,m?.enclosingShort??null,x(l.relativePath)==="test"?5:4,r++,l.references.map(h=>h.line),s.symbol)}for(let l of s.callers)re(e,n,l,"caller",s,2,r++);for(let l of s.callees)re(e,n,l,"callee",s,3,r++);for(let l of s.dependencies)oe(e,n,"dependency",s.file,l.relativePath,s.symbol,t.context,6,r++);for(let l of s.consumers)oe(e,n,"consumer",l.relativePath,s.file,s.symbol,t.context,7,r++)}return{searches:u,evidence:d,locations:a,candidates:n}}function M(e,t){return e.priority-t.priority||t.roles.length-e.roles.length||t.reasons.length-e.reasons.length||ie(x(e.relativePath))-ie(x(t.relativePath))||e.sequence-t.sequence}function ie(e){switch(e){case"entry":case"source":case"worker":return 0;case"barrel":return 1;case"test":return 2}}function O(e,t){return{candidate:e,priority:e.priority,sequence:e.sequence,relativePath:e.relativePath,fileKind:x(e.relativePath),evidenceCharacters:he(e,t),roles:e.roles,reasons:e.reasons,symbols:e.symbols,behaviorSignals:e.kind==="source"?e.behavior?.signals??[]:[],channel:T(e)}}function T(e){let t=e.roles;return t.includes("location")?"exact-source":t.includes("definition")?"definition":t.includes("caller")?"caller":t.includes("callee")?"callee":t.includes("reference")?x(e.relativePath)==="test"?"test-reference":"production-reference":t.includes("dependency")?"dependency":t.includes("consumer")?"consumer":"search"}function Ee(e,t){let n=t.filter(i=>i.kind==="source"),r=G(e,{files:f(n.map(i=>i.relativePath))});for(let i of n){i.behavior=H(e,i.relativePath,i.startLine,i.endLine,i.focusLines)??void 0;let o=r.filter(a=>a.source.file===i.relativePath&&a.source.startLine<=i.endLine&&a.source.endLine>=i.startLine),u=o.filter(a=>!ke(a,o)).map(a=>({observationId:a.id,protocol:a.protocol,action:a.action,role:a.role,strength:a.strength,resolution:a.resolution,line:a.source.startLine,endLine:a.source.endLine,keyParts:a.keyParts.map(d=>({name:d.name,value:d.value,evidence:d.evidence})),derivation:{kind:a.derivation.kind,rule:a.derivation.rule,sourceSpans:a.derivation.sourceSpans.length}}));i.runtimeFacts=u.length>0?u:void 0}}function ke(e,t){if(e.strength!=="candidate"||e.protocol!=="http")return!1;let n=e.keyParts.find(i=>i.name==="path")?.value,r=e.keyParts.find(i=>i.name==="method")?.value;return n?t.some(i=>{if(i===e||i.action!==e.action||i.role!==e.role||i.source.startLine!==e.source.startLine||i.derivation.rule!=="http.mount-prefix")return!1;let o=i.keyParts.find(a=>a.name==="path")?.value,u=i.keyParts.find(a=>a.name==="method")?.value;return!!(o&&o!==n&&o.endsWith(n)&&(!r||r===u))}):!1}function Pe(e,t){for(let n of t){if(n.kind!=="source")continue;let r=V(e,n.relativePath,n.startLine,n.endLine,n.focusLines);r.startLine===n.startLine&&r.endLine===n.endLine||(n.startLine=r.startLine,n.endLine=r.endLine,n.source=U(e,n.relativePath).slice(r.startLine,r.endLine+1).join(`
1
+ import{a as Q,b as ee,c as ne}from"./chunk-EOSUV7H5.js";import{a as Z}from"./chunk-DP3EJ6XL.js";import{c as Y}from"./chunk-RWAZCEJD.js";import{a as X,b as z,c as W}from"./chunk-XRH7R5SX.js";import{a as J,d as w}from"./chunk-RVBRPBLQ.js";import{a as K}from"./chunk-MJX2J5QE.js";import{a as H,d as V}from"./chunk-3GKKCVKK.js";import{h as G}from"./chunk-ZQ6GAIUV.js";import{a as x}from"./chunk-NMKQOIYZ.js";import{p as q}from"./chunk-RGBZDOUO.js";import{x as U}from"./chunk-23AD24QZ.js";import{createHash as ue}from"crypto";var le=6,ve=12,be=48,Ce=2e4,te=12,L=Number.MAX_SAFE_INTEGER,ye=["definition","callers","callees"],_={search:12,"exact-source":24,definition:24,caller:8,callee:8,"production-reference":6,"test-reference":2,dependency:6,consumer:6};function tn(e,t){if(t.cursor)throw new Error("Inspect no longer accepts semantic packet cursors. Run the original inspect selectors again.");let n=xe(t),r=we(e,n),i=r.candidates.sort((c,p)=>M(c,p));n.view==="behavior"&&Pe(e,i),Re(e,i),n.view==="behavior"&&Ee(e,i);let o=Q(i.map(c=>O(c,n.view)),n.evidenceBudgets,(c,p)=>M(c.candidate,p.candidate)),{selected:u,omitted:a}=ee(o.selected,n.maxUnits,n.maxCharacters,(c,p)=>M(c.candidate,p.candidate),n.view==="source"),d=u.map(c=>c.candidate),s=[...o.omitted,...a].map(c=>c.candidate),l=d.map(Ae),m=z(d.map(c=>c.kind==="source"?c.bindingClosure:void 0),d.filter(c=>c.kind==="source").map(c=>({relativePath:c.relativePath,startLine:c.startLine,endLine:c.endLine}))),h=l.reduce((c,p)=>c+(p.kind==="source"?qe(p.source):0),0),g=l.reduce((c,p)=>c+(p.kind==="source"?p.source.length:0),0),y=l.reduce((c,p)=>c+he(p,n.view),0),v=l.filter(c=>c.kind==="source"&&(c.roles.includes("search")||c.roles.includes("location"))).map(De),b=i.filter(c=>c.kind==="source"&&(c.roles.includes("search")||c.roles.includes("location"))).length,fe=l.filter(c=>c.kind==="source"&&(c.roles.includes("search")||c.roles.includes("location"))).length,P=r.searches.map(c=>Me(c,i,d)),ge=Fe(s),N=r.locations.every(c=>c.matched)&&r.evidence.every(c=>c.kind==="matched")&&r.searches.every(c=>Te(c.textCoverage))&&s.every(c=>!c.roles.some(p=>p==="location"||p==="definition")),A=P.reduce((c,p)=>c+p.omittedMatches,0),R=s.length===0&&A===0,$=R?void 0:me(n,!0),D=$e(n,s),Se=Le(R,N,s.length+A,D,P,$),j=i.filter(c=>n.view==="behavior"&&c.kind==="source"&&c.roles.some(p=>p==="location"||p==="definition"||p==="search")).map(c=>({id:`inspect:${c.relativePath}:${c.startLine}-${c.endLine}`,label:c.ownerShort??`${c.relativePath}:${c.startLine+1}`,file:c.relativePath,startLine:c.startLine,endLine:c.endLine})),B=j.length>0?Y(e,j):void 0;return{searches:P,evidence:r.evidence,locations:r.locations,slices:v,candidateSlices:b,omittedSlices:b-fe,maxSlices:b,maxTotalLines:h,units:l,candidateUnits:i.length,omittedUnits:s.length,maxUnits:n.maxUnits,maxCharacters:n.maxCharacters,returnedLines:h,returnedCharacters:g,returnedViewCharacters:y,view:n.view,omissionGroups:D,packetCoverage:{mode:R?"complete":"bounded",candidateUnits:i.length,returnedUnits:l.length,omittedUnits:s.length,omittedByRole:ge,exactSelectorsComplete:N,maxUnits:n.maxUnits,maxCharacters:n.maxCharacters,channels:Oe(i,d,n.evidenceBudgets,n.view),...$?{expansionCommand:$}:{}},stoppingSummary:Se,...B&&B.candidateAnchors>0?{causalFrontier:B}:{},bindingClosure:m,continuation:null}}function Le(e,t,n,r,i,o){let u=f([...r.map(a=>a.drillCommand),...i.flatMap(a=>a.exactFollowup?[a.exactFollowup]:[]),...o?[o]:[]]);return e&&t?{queryStatus:"selection-complete",status:"stop-ready",openEvidence:0,guidance:"All evidence requested by this inspect query was materialized.",drillCommands:[]}:t?{queryStatus:"frontier-accounted",status:"relevance-check-required",openEvidence:n,guidance:"Withheld evidence is accounted for by recoverable groups; drill the groups relevant to the current decision.",drillCommands:u}:{queryStatus:"coverage-incomplete",status:"exact-evidence-withheld",openEvidence:n,guidance:"A requested identity, exact source unit, or current-text coverage requirement is unresolved; drill before relying on it.",drillCommands:u}}function xe(e){let t=F(e.searches),n=F(e.symbols),r=F(e.locations),i=t.length+n.length+r.length;if(i===0)throw new Error("inspect requires at least one --search, --symbol, or --at selector.");if(i>24)throw new RangeError(`inspect accepts at most ${24} selectors; received ${i}.`);let o=e.evidence??{};if(e.unitLines!==void 0&&C(e.unitLines,"unitLines"),e.totalLines!==void 0&&C(e.totalLines,"totalLines"),e.sliceLimit!==void 0&&C(e.sliceLimit,"sliceLimit"),e.maxCharacters!==void 0&&C(e.maxCharacters,"maxCharacters"),e.maxUnits!==void 0&&C(e.maxUnits,"maxUnits"),e.view!==void 0&&e.view!=="source"&&e.view!=="behavior")throw new Error(`Unknown inspect view: ${String(e.view)}. Use source or behavior.`);if(e.full&&(e.searchLimit!==void 0||e.maxUnits!==void 0||e.maxCharacters!==void 0||e.evidenceBudgets!==void 0))throw new Error("full inspect cannot be combined with searchLimit, maxUnits, maxCharacters, or evidenceBudgets.");let u=e.full??!1;return{searches:t,symbols:n,locations:r,...e.scope?.trim()?{scope:e.scope.trim()}:{},context:ae(e.context??le,"context"),searchLimit:C(e.searchLimit??(u?L:ve),"searchLimit"),maxUnits:C(u?L:e.maxUnits??be,"maxUnits"),maxCharacters:C(u?L:e.maxCharacters??Ce,"maxCharacters"),evidenceBudgets:u?Ue():Ie(e.evidenceBudgets??_),view:e.view??"source",evidence:{...o.parts?{parts:[...o.parts]}:n.length>0?{parts:[...ye]}:{},...o.referenceContext!==void 0?{referenceContext:ae(o.referenceContext,"referenceContext")}:{},relatedSourceLines:o.relatedSourceLines??60,...o.semantic!==void 0?{semantic:o.semantic}:{}}}}function Ie(e){let t={..._};for(let[n,r]of Object.entries(e)){if(!(n in t))throw new Error(`Unknown inspect evidence channel: ${n}.`);if(!Number.isSafeInteger(r)||(r??-1)<0)throw new RangeError(`Evidence budget ${n} must be a non-negative safe integer; received ${r}.`);t[n]=r}return t}function Ue(){return Object.fromEntries(Object.keys(_).map(e=>[e,L]))}function we(e,t){let n=[],r=0,i=t.searches.map(s=>{let l=ne(e,s,{scope:t.scope,context:0,limit:t.searchLimit,ranking:"structural"});return{pattern:s,result:l,matches:l.matches}}),o=Math.max(0,...i.map(s=>s.matches.length));for(let s=0;s<o;s+=1)for(let l of i){let m=l.matches[s];if(!m)continue;let h=w(e,m.relativePath,m.focusLine,L,t.context);h&&I(e,n,h,"search",`search:${l.pattern}`,m.ownerSymbol,m.ownerShort,1,r++)}let u=i.map(({pattern:s,result:l})=>{let m=l.omittedMatches>0?de(s,t.scope):void 0,h=l.fileCoverage??[],g=_e(s,h,t.scope);return{pattern:s,matchingLines:l.matchingLines,returnedMatches:l.matches.length,omittedMatches:l.omittedMatches,matchingFiles:h.length,returnedFiles:h.filter(y=>y.returnedMatches>0).length,omittedFiles:h.filter(y=>y.returnedMatches===0).length,candidateUnits:0,selectedUnits:0,omittedUnits:0,scopeHints:g.slice(0,te),omittedScopeHints:Math.max(0,g.length-te),textCoverage:l.textCoverage,...m?{exactFollowup:m}:{}}}),a=t.locations.map(s=>{let l=je(s),m=l?K(e,l.path):null,h=m?w(e,m,l.line-1,L,t.context):null;return h&&I(e,n,h,"location",`at:${s}`,null,null,0,r++),{target:s,matched:h!==null}}),d=t.symbols.map(s=>Z(e,s,t.evidence));for(let s of d)if(s.kind==="matched"){if(s.definition){let l=w(e,s.definition.relativePath,s.definition.startLine,L,t.context);l&&I(e,n,l,"definition",`definition:${s.shortName}`,s.symbol,s.shortName,0,r++)}for(let l of s.referenceWindows){let m=l.references[0];I(e,n,{...l,focusLine:m?.line??l.startLine,unitType:null,unitStartLine:l.startLine,unitEndLine:l.endLine,omittedLines:0},"reference",`reference:${s.shortName}`,m?.enclosingSymbol??null,m?.enclosingShort??null,x(l.relativePath)==="test"?5:4,r++,l.references.map(h=>h.line),s.symbol)}for(let l of s.callers)re(e,n,l,"caller",s,2,r++);for(let l of s.callees)re(e,n,l,"callee",s,3,r++);for(let l of s.dependencies)oe(e,n,"dependency",s.file,l.relativePath,s.symbol,t.context,6,r++);for(let l of s.consumers)oe(e,n,"consumer",l.relativePath,s.file,s.symbol,t.context,7,r++)}return{searches:u,evidence:d,locations:a,candidates:n}}function M(e,t){return e.priority-t.priority||t.roles.length-e.roles.length||t.reasons.length-e.reasons.length||ie(x(e.relativePath))-ie(x(t.relativePath))||e.sequence-t.sequence}function ie(e){switch(e){case"entry":case"source":case"worker":return 0;case"barrel":return 1;case"test":return 2}}function O(e,t){return{candidate:e,priority:e.priority,sequence:e.sequence,relativePath:e.relativePath,fileKind:x(e.relativePath),evidenceCharacters:he(e,t),roles:e.roles,reasons:e.reasons,symbols:e.symbols,behaviorSignals:e.kind==="source"?e.behavior?.signals??[]:[],channel:T(e)}}function T(e){let t=e.roles;return t.includes("location")?"exact-source":t.includes("definition")?"definition":t.includes("caller")?"caller":t.includes("callee")?"callee":t.includes("reference")?x(e.relativePath)==="test"?"test-reference":"production-reference":t.includes("dependency")?"dependency":t.includes("consumer")?"consumer":"search"}function Ee(e,t){let n=t.filter(i=>i.kind==="source"),r=G(e,{files:f(n.map(i=>i.relativePath))});for(let i of n){i.behavior=H(e,i.relativePath,i.startLine,i.endLine,i.focusLines)??void 0;let o=r.filter(a=>a.source.file===i.relativePath&&a.source.startLine<=i.endLine&&a.source.endLine>=i.startLine),u=o.filter(a=>!ke(a,o)).map(a=>({observationId:a.id,protocol:a.protocol,action:a.action,role:a.role,strength:a.strength,resolution:a.resolution,line:a.source.startLine,endLine:a.source.endLine,keyParts:a.keyParts.map(d=>({name:d.name,value:d.value,evidence:d.evidence})),derivation:{kind:a.derivation.kind,rule:a.derivation.rule,sourceSpans:a.derivation.sourceSpans.length}}));i.runtimeFacts=u.length>0?u:void 0}}function ke(e,t){if(e.strength!=="candidate"||e.protocol!=="http")return!1;let n=e.keyParts.find(i=>i.name==="path")?.value,r=e.keyParts.find(i=>i.name==="method")?.value;return n?t.some(i=>{if(i===e||i.action!==e.action||i.role!==e.role||i.source.startLine!==e.source.startLine||i.derivation.rule!=="http.mount-prefix")return!1;let o=i.keyParts.find(a=>a.name==="path")?.value,u=i.keyParts.find(a=>a.name==="method")?.value;return!!(o&&o!==n&&o.endsWith(n)&&(!r||r===u))}):!1}function Pe(e,t){for(let n of t){if(n.kind!=="source")continue;let r=V(e,n.relativePath,n.startLine,n.endLine,n.focusLines);r.startLine===n.startLine&&r.endLine===n.endLine||(n.startLine=r.startLine,n.endLine=r.endLine,n.source=U(e,n.relativePath).slice(r.startLine,r.endLine+1).join(`
2
2
  `),n.unitStartLine=r.startLine,n.unitEndLine=r.endLine,n.omittedLines=0)}}function Re(e,t){for(let n of t)n.kind==="source"&&(n.bindingClosure=X(e,n.relativePath,n.startLine,n.endLine))}function $e(e,t){let n=new Map;for(let r of t){let i=k(r.relativePath),o=T(r),u=[...r.roles].sort().join(","),a=r.kind==="path"?r.relationship:"",d=`${i}|${o}|${u}|${a}`,s=n.get(d)??[];s.push(r),n.set(d,s)}return[...n.entries()].map(([r,i])=>{let o=i[0],u=f(i.flatMap(d=>[...d.roles])).sort(),a=f(i.flatMap(d=>d.kind==="source"?d.behavior?.signals??[]:[])).sort();return{id:`g-${ue("sha256").update(r).digest("hex").slice(0,8)}`,scope:k(o.relativePath),channel:T(o),roles:u,behaviorSignals:a,candidateUnits:i.length,sourceCharacters:i.reduce((d,s)=>d+(s.kind==="source"?s.source.length:0),0),anchors:i.map(d=>({relativePath:d.relativePath,line:d.kind==="source"?d.focusLine:0,ownerShort:d.kind==="source"?d.ownerShort:null,roles:[...d.roles],behaviorSignals:d.kind==="source"?[...d.behavior?.signals??[]]:[]})),drillCommand:Be(e,i)}}).sort((r,i)=>i.candidateUnits-r.candidateUnits||i.sourceCharacters-r.sourceCharacters||r.scope.localeCompare(i.scope)||r.id.localeCompare(i.id))}function Be(e,t){let n=f(t.flatMap(o=>o.reasons.filter(u=>u.startsWith("search:")).map(u=>u.slice(7)))),r=k(t[0].relativePath);if(n.length>0&&t.every(o=>o.kind==="source"&&o.roles.includes("search"))){let o=["codebaseiq inspect"];for(let u of n)o.push(`--search ${S(u)}`);return o.push(`--scope ${S(r)}`,"--full"),e.view==="behavior"&&o.push("--view behavior"),o.join(" ")}let i=t.filter(o=>o.kind==="source");if(i.length>0&&i.length<=24){let o=["codebaseiq inspect"];for(let u of i)o.push(`--at ${S(`${u.relativePath}:${u.focusLine+1}`)}`);return e.view==="behavior"&&o.push("--view behavior"),o.join(" ")}return t.length===1&&t[0].kind==="path"?t[0].exactFollowup:me(e,!0)}function Me(e,t,n){let r=`search:${e.pattern}`,i=t.filter(a=>a.reasons.includes(r)).length,o=new Set(n),u=t.filter(a=>a.reasons.includes(r)&&o.has(a)).length;return{...e,candidateUnits:i,selectedUnits:u,omittedUnits:i-u}}function Fe(e){let t={};for(let n of e)for(let r of n.roles)t[r]=(t[r]??0)+1;return t}function Oe(e,t,n,r){let i=e.map(u=>O(u,r).channel),o=t.map(u=>O(u,r).channel);return Object.fromEntries(Object.keys(n).map(u=>{let a=i.filter(s=>s===u).length,d=o.filter(s=>s===u).length;return[u,{candidateUnits:a,returnedUnits:d,omittedUnits:a-d,maxUnits:n[u]}]}))}function Te(e){return!!(e&&e.skippedUnreadablePaths.length===0&&e.skippedOversizedPaths.length===0)}function _e(e,t,n){let r=new Map;for(let i of t){let o=k(i.relativePath),u=r.get(o)??{matchingLines:0,returnedMatches:0};u.matchingLines+=i.matchingLines,u.returnedMatches+=i.returnedMatches,r.set(o,u)}return[...r.entries()].map(([i,o])=>({scope:i,...o,exactFollowup:de(e,i||n)})).sort((i,o)=>o.matchingLines-i.matchingLines||o.returnedMatches-i.returnedMatches||i.scope.localeCompare(o.scope))}function k(e){let t=e.lastIndexOf("/");return t<0?e:e.slice(0,t)}function de(e,t){return`codebaseiq inspect --search ${S(e)}${t?` --scope ${S(t)}`:""} --full`}function me(e,t){let n=["codebaseiq inspect"];for(let r of e.searches)n.push(`--search ${S(r)}`);for(let r of e.symbols)n.push(`--symbol ${S(r)}`);for(let r of e.locations)n.push(`--at ${S(r)}`);return e.scope&&n.push(`--scope ${S(e.scope)}`),e.context!==le&&n.push(`--context ${e.context}`),e.evidence.parts&&n.push(`--include ${S(e.evidence.parts.join(","))}`),t&&n.push("--full"),e.view==="behavior"&&n.push("--view behavior"),n.join(" ")}function re(e,t,n,r,i,o,u){I(e,t,{...n,unitType:null,unitStartLine:n.startLine,unitEndLine:n.endLine+n.omittedLines},r,`${r}:${i.shortName}`,n.symbol,n.shortName,o,u,[n.focusLine],i.symbol)}function oe(e,t,n,r,i,o,u,a,d){let s=`${r} -> ${i}`,l=q(e,r).filter(b=>b.sourcePath===i),m=U(e,r),h=Ne(m,l,i),g=h===null?null:J(e,r,h,Math.min(u,4));if(g){I(e,t,{...g,unitType:null,unitStartLine:g.startLine,unitEndLine:g.endLine,omittedLines:0},n,`${n}:${s}`,null,null,a,d,[g.focusLine],o);return}let y=`codebaseiq inspect --search ${S(pe(i))} --scope ${S(r)}`,v=t.find(b=>b.kind==="path"&&b.relativePath===r&&b.relationship===s);if(v){v.roles=f([...v.roles,n]),v.reasons=f([...v.reasons,`${n}:${s}`]),v.symbols=f([...v.symbols,o]),v.priority=Math.min(v.priority,a);return}t.push({kind:"path",roles:[n],relativePath:r,relationship:s,reasons:[`${n}:${s}`],symbols:[o],exactFollowup:y,priority:a,sequence:d})}function Ne(e,t,n){let r=f(t.flatMap(d=>[d.importedName,d.localName??""]).filter(d=>d.length>1)),i=pe(n).replace(/\.[^.]+$/u,""),o=f([...r,i]).filter(Boolean),u=/\b(?:from|import|include|require|use)\b/u,a=e.findIndex(d=>u.test(d)&&o.some(s=>d.includes(s)));return a>=0?a:null}function I(e,t,n,r,i,o,u,a,d,s=[n.focusLine],l){let m=t.find(h=>h.kind==="source"&&h.relativePath===n.relativePath&&h.startLine<=n.endLine&&n.startLine<=h.endLine);if(m){let h=Math.min(m.startLine,n.startLine),g=Math.max(m.endLine,n.endLine);m.startLine=h,m.endLine=g,m.source=U(e,n.relativePath).slice(h,g+1).join(`
3
3
  `),m.focusLine=Math.min(m.focusLine,n.focusLine),m.focusLines=ce([...m.focusLines,...s]),m.unitStartLine=Math.min(m.unitStartLine,n.unitStartLine),m.unitEndLine=Math.max(m.unitEndLine,n.unitEndLine),m.omittedLines=Math.max(m.omittedLines,n.omittedLines),m.reasons=f([...m.reasons,i]),m.roles=f([...m.roles,r]),m.symbols=f([...m.symbols,...l?[l]:[]]),!m.ownerSymbol&&o&&(m.ownerSymbol=o),!m.ownerShort&&u&&(m.ownerShort=u),m.priority=Math.min(m.priority,a);return}t.push({kind:"source",...n,reasons:[i],focusLines:ce(s),ownerSymbol:o,ownerShort:u,roles:[r],symbols:l?[l]:[],priority:a,sequence:d})}function Ae(e){if(e.kind==="path"){let{priority:o,sequence:u,...a}=e;return{...a,id:se(a)}}let{priority:t,sequence:n,bindingClosure:r,...i}=e;return{...i,id:se(i),omittedCharacters:0}}function De(e){let{kind:t,id:n,roles:r,symbols:i,omittedCharacters:o,behavior:u,runtimeFacts:a,...d}=e;return d}function se(e){return ue("sha256").update(JSON.stringify(e)).digest("hex").slice(0,16)}function je(e){let t=e.match(/^(.+\.\w+):(\d+)$/u);if(!t)return null;let n=Number(t[2]);return Number.isSafeInteger(n)&&n>0?{path:t[1],line:n}:null}function F(e){return f((e??[]).map(t=>t.trim()).filter(Boolean))}function f(e){return[...new Set(e)]}function ce(e){return f(e).sort((t,n)=>t-n)}function qe(e){return e.length===0?0:e.split(`
4
4
  `).length}function he(e,t){if(e.kind==="path")return e.relationship.length+e.exactFollowup.length;let n="bindingClosure"in e?W(e.bindingClosure):0,r=(e.runtimeFacts??[]).reduce((i,o)=>i+o.action.length+o.derivation.rule.length+o.keyParts.reduce((u,a)=>u+a.name.length+a.value.length+4,0)+24,0);return t!=="behavior"?e.source.length+n:e.behavior?e.behavior.lines.reduce((i,o)=>i+o.text.length+o.signals.join(",").length+12,0)+e.behavior.testCases.reduce((i,o)=>i+o.length+2,0)+r+n:e.source.length+n+r}function pe(e){return e.split("/").at(-1)??e}function S(e){return`'${e.replaceAll("'","'\\''")}'`}function C(e,t){if(!Number.isSafeInteger(e)||e<=0)throw new RangeError(`${t} must be a positive safe integer; received ${e}`);return e}function ae(e,t){if(!Number.isSafeInteger(e)||e<0)throw new RangeError(`${t} must be a non-negative safe integer; received ${e}`);return e}export{tn as a};
5
- //# sourceMappingURL=chunk-UJIXCI3L.js.map
5
+ //# sourceMappingURL=chunk-MAGBSB6E.js.map