codebaseiq 0.2.0 → 0.3.1

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 (403) hide show
  1. package/CHANGELOG.md +59 -2
  2. package/README.md +1 -1
  3. package/dist/augment-vue-worker.js +1 -1
  4. package/dist/{chunk-WH5SYOMD.js → chunk-2E6OUPCF.js} +2 -2
  5. package/dist/chunk-2I2UHZET.js +2 -0
  6. package/dist/{chunk-CSZOQ7YO.js → chunk-2OMXFE64.js} +2 -2
  7. package/dist/{chunk-57KFVPVZ.js → chunk-2XBJRZEM.js} +2 -2
  8. package/dist/{chunk-PFPHS4NO.js → chunk-2Z7K66D7.js} +2 -2
  9. package/dist/{chunk-5WXOEJ4G.js → chunk-356EZBIP.js} +2 -2
  10. package/dist/{chunk-DLC6JDN7.js → chunk-3H2H5ODK.js} +2 -2
  11. package/dist/{chunk-HBQGKMM3.js → chunk-3LQJRS4I.js} +2 -2
  12. package/dist/{chunk-H3CKAL6P.js → chunk-3ON3A2QV.js} +2 -2
  13. package/dist/{chunk-MTMF4N7F.js → chunk-3VJ3OCRE.js} +2 -2
  14. package/dist/{chunk-QMGWSEPL.js → chunk-4GWN76B2.js} +2 -2
  15. package/dist/{chunk-IBM3F2BJ.js → chunk-4LK5OIPW.js} +2 -2
  16. package/dist/{chunk-6SDEQTVY.js → chunk-53ELMZRF.js} +2 -2
  17. package/dist/{chunk-OJFLPVBP.js → chunk-57OPIQFM.js} +2 -2
  18. package/dist/{chunk-2E6BTWER.js → chunk-5CR4U5X2.js} +2 -2
  19. package/dist/{chunk-IYBIBMPF.js → chunk-5FWR5HLG.js} +2 -2
  20. package/dist/{chunk-HHBBGWES.js → chunk-5LL4KEHO.js} +2 -2
  21. package/dist/{chunk-NTRW52UR.js → chunk-5MPBSFZH.js} +2 -2
  22. package/dist/chunk-5T44HG5Y.js +88 -0
  23. package/dist/chunk-5TZNHP4T.js +8 -0
  24. package/dist/{chunk-L3YSDLNB.js → chunk-5YBDBY5L.js} +2 -2
  25. package/dist/{chunk-YFQPWKHR.js → chunk-5ZI2PPI7.js} +2 -2
  26. package/dist/{chunk-WO47BIPY.js → chunk-6EYESTJM.js} +2 -2
  27. package/dist/{chunk-PHPQ24UG.js → chunk-6FXXYYQM.js} +2 -2
  28. package/dist/chunk-6O3KXIDL.js +2 -0
  29. package/dist/{chunk-PLZXWZHY.js → chunk-7GAK2F3H.js} +2 -2
  30. package/dist/{chunk-W3FK73MD.js → chunk-7UCDGXRW.js} +2 -2
  31. package/dist/{chunk-U2XX3BT4.js → chunk-AGGR2BKS.js} +2 -2
  32. package/dist/{chunk-ZB3V5QM7.js → chunk-ALOEHWJS.js} +2 -2
  33. package/dist/{chunk-NDGTJHQN.js → chunk-AXQCHG77.js} +2 -2
  34. package/dist/{chunk-X5I2BQGX.js → chunk-BFANZRQ5.js} +2 -2
  35. package/dist/{chunk-VVCBMH5O.js → chunk-BGGB5N53.js} +2 -2
  36. package/dist/{chunk-PARCKE3Q.js → chunk-BGYRF5YX.js} +2 -2
  37. package/dist/{chunk-CIVYHK7U.js → chunk-BIADXGC3.js} +2 -2
  38. package/dist/{chunk-NK76RSB6.js → chunk-BPKNP3KZ.js} +2 -2
  39. package/dist/{chunk-ZOEDRCR4.js → chunk-BRQL7AFJ.js} +2 -2
  40. package/dist/{chunk-KDYQQJ6X.js → chunk-BWL3PMPT.js} +2 -2
  41. package/dist/{chunk-M7LAIM77.js → chunk-C6WKPKCF.js} +2 -2
  42. package/dist/{chunk-37TKC6MB.js → chunk-CB5AVJMM.js} +2 -2
  43. package/dist/{chunk-BX2U3QQV.js → chunk-CCIYWXX6.js} +2 -2
  44. package/dist/{chunk-3AC56WAR.js → chunk-CIYA2KZN.js} +2 -2
  45. package/dist/{chunk-6OVNYYY4.js → chunk-CJTKGAGH.js} +2 -2
  46. package/dist/{chunk-FIXYHQ3W.js → chunk-CLPCFGRT.js} +2 -2
  47. package/dist/{chunk-LY2NB5XR.js → chunk-CSPDQLLU.js} +2 -2
  48. package/dist/{chunk-CMXW7MFV.js → chunk-CYJS33YX.js} +2 -2
  49. package/dist/{chunk-ACZDU5GK.js → chunk-D7DOB27N.js} +7 -7
  50. package/dist/{chunk-XUJM6474.js → chunk-DDRA3QKN.js} +2 -2
  51. package/dist/{chunk-3NUZVLR7.js → chunk-DECN422G.js} +2 -2
  52. package/dist/{chunk-RRPK327J.js → chunk-DJKOXMNG.js} +2 -2
  53. package/dist/{chunk-SJZQ2PTZ.js → chunk-DWBAESVW.js} +2 -2
  54. package/dist/{chunk-S5SKXCND.js → chunk-EHPOTEQX.js} +2 -2
  55. package/dist/chunk-EIBGSU2R.js +2 -0
  56. package/dist/{chunk-DVYG3JTA.js → chunk-ELYMY5S2.js} +2 -2
  57. package/dist/chunk-EOKVZXNF.js +355 -0
  58. package/dist/chunk-EQNMD62X.js +51 -0
  59. package/dist/{chunk-YIOQJ45A.js → chunk-F3QSL4W2.js} +2 -2
  60. package/dist/{chunk-VG55NFXF.js → chunk-F5CJO5JN.js} +2 -2
  61. package/dist/{chunk-JOALNFY3.js → chunk-F74LZWCE.js} +2 -2
  62. package/dist/chunk-G7GVV2TV.js +27 -0
  63. package/dist/{chunk-U24M5RQM.js → chunk-GQLDYCWS.js} +2 -2
  64. package/dist/{chunk-B2E3HZ2A.js → chunk-GV2CEZCW.js} +2 -2
  65. package/dist/{chunk-AM5SUGHF.js → chunk-GVAF222T.js} +2 -2
  66. package/dist/{chunk-T3YFIJ5P.js → chunk-HJTM3C4Y.js} +2 -2
  67. package/dist/{chunk-FY5V4V4F.js → chunk-HNXRVGMY.js} +2 -2
  68. package/dist/{chunk-UWB5WMC2.js → chunk-I3OK27P7.js} +2 -2
  69. package/dist/{chunk-RVYLJDXC.js → chunk-ICUL7XRT.js} +2 -2
  70. package/dist/{chunk-QVHZB75Z.js → chunk-IHSLIIL3.js} +2 -2
  71. package/dist/chunk-ILGTMRMZ.js +2 -0
  72. package/dist/{chunk-XNUWRTYM.js → chunk-IZDPGOZR.js} +2 -2
  73. package/dist/{chunk-BH5CE4LN.js → chunk-J7AMBVWF.js} +2 -2
  74. package/dist/chunk-JAFDMV5I.js +2 -0
  75. package/dist/{chunk-YXJ4IAHH.js → chunk-JCMFBF4Z.js} +2 -2
  76. package/dist/{chunk-BLKYYQ7C.js → chunk-JNXI6NQ7.js} +95 -95
  77. package/dist/{chunk-DKJXK3HA.js → chunk-JSB43EX6.js} +2 -2
  78. package/dist/chunk-JYRJYXUV.js +2 -0
  79. package/dist/chunk-K4S2VH42.js +82 -0
  80. package/dist/{chunk-QLTFXVUI.js → chunk-K6FNTQQW.js} +2 -2
  81. package/dist/{chunk-JYX5UZSZ.js → chunk-KEJ2HLRW.js} +2 -2
  82. package/dist/{chunk-VCWAJPXQ.js → chunk-KFTHI2R6.js} +2 -2
  83. package/dist/chunk-KLX6NSWT.js +3 -0
  84. package/dist/{chunk-DFPAZXLU.js → chunk-KPZGTB2O.js} +2 -2
  85. package/dist/{chunk-T55YPJGB.js → chunk-KUKKLWJD.js} +2 -2
  86. package/dist/{chunk-RWKEXCHU.js → chunk-KUKWHP4R.js} +2 -2
  87. package/dist/{chunk-ZJZQ7Q2Q.js → chunk-KWRQVLPX.js} +2 -2
  88. package/dist/{chunk-FQA3KIFX.js → chunk-L37EQYAX.js} +2 -2
  89. package/dist/{chunk-PNVZIJ57.js → chunk-LCW3PSGL.js} +2 -2
  90. package/dist/{chunk-7Z7HCZ7J.js → chunk-LKUTSP4G.js} +2 -2
  91. package/dist/{chunk-HIEXRDJF.js → chunk-LMTSB3TB.js} +2 -2
  92. package/dist/{chunk-SF34QLK2.js → chunk-LQHYYIOB.js} +2 -2
  93. package/dist/{chunk-EXMVF3JR.js → chunk-LSZYMN2A.js} +3 -3
  94. package/dist/{chunk-RCPZOPV6.js → chunk-M2Y6PCFE.js} +2 -2
  95. package/dist/chunk-MC46AL7B.js +343 -0
  96. package/dist/{chunk-SRY26ITJ.js → chunk-MDFT325O.js} +2 -2
  97. package/dist/{chunk-WJOQC4P7.js → chunk-MEUHIDI3.js} +2 -2
  98. package/dist/{chunk-FLLXYUOL.js → chunk-MQW6SJ4P.js} +2 -2
  99. package/dist/{chunk-57KEZDPT.js → chunk-MSI3K7PJ.js} +2 -2
  100. package/dist/{chunk-27PHVDKL.js → chunk-MZNMASFM.js} +2 -2
  101. package/dist/{chunk-VYZQZ4ZN.js → chunk-N2XDMNVI.js} +2 -2
  102. package/dist/{chunk-JN5LIBT3.js → chunk-NDKOVQFG.js} +2 -2
  103. package/dist/{chunk-W6C6QTXJ.js → chunk-NEWHKGVD.js} +2 -2
  104. package/dist/chunk-NNG6M6XD.js +3 -0
  105. package/dist/chunk-O2KWU34K.js +278 -0
  106. package/dist/{chunk-HBXZAGY6.js → chunk-O2M3VNDY.js} +2 -2
  107. package/dist/{chunk-FPDL2TUB.js → chunk-OBC7HSSO.js} +2 -2
  108. package/dist/{chunk-J24VICI5.js → chunk-OKAF4OQS.js} +2 -2
  109. package/dist/{chunk-I5FCDTK2.js → chunk-OP6BUIV6.js} +2 -2
  110. package/dist/{chunk-2DMVFAY7.js → chunk-OQ3DK7FW.js} +2 -2
  111. package/dist/{chunk-FEBLLMTL.js → chunk-OQUCBKOI.js} +2 -2
  112. package/dist/chunk-OT5ISJSR.js +2 -0
  113. package/dist/{chunk-N3Q3AWGW.js → chunk-OWJWOEDU.js} +96 -96
  114. package/dist/{chunk-M4EVGA5S.js → chunk-PIFYOWS4.js} +3 -3
  115. package/dist/{chunk-35YYZD3D.js → chunk-PTR3EOXC.js} +2 -2
  116. package/dist/{chunk-5XEVXVTK.js → chunk-PUVNH4PO.js} +2 -2
  117. package/dist/{chunk-I645ZF75.js → chunk-QEOWONKY.js} +2 -2
  118. package/dist/{chunk-JXHLB7TP.js → chunk-QMOZZ2VX.js} +2 -2
  119. package/dist/{chunk-NIO346UL.js → chunk-QY7QB7I6.js} +2 -2
  120. package/dist/{chunk-YYFV32WR.js → chunk-R4OJGTMP.js} +2 -2
  121. package/dist/{chunk-2VKB5CMA.js → chunk-RCIGX23V.js} +2 -2
  122. package/dist/{chunk-TUTSO7UZ.js → chunk-RIO3JXHM.js} +2 -2
  123. package/dist/{chunk-4IFISPQW.js → chunk-SA7G6GJX.js} +2 -2
  124. package/dist/{chunk-OMBRP7BB.js → chunk-SB53KPWA.js} +2 -2
  125. package/dist/chunk-SB7NASHU.js +2 -0
  126. package/dist/{chunk-3XFJUWJE.js → chunk-SGMNWYTH.js} +2 -2
  127. package/dist/{chunk-A7XQT7MH.js → chunk-SUE7SHZL.js} +2 -2
  128. package/dist/{chunk-IOVPAZWP.js → chunk-SX72EVMY.js} +2 -2
  129. package/dist/{chunk-OVKZM2XI.js → chunk-SZ4P7MF7.js} +2 -2
  130. package/dist/{chunk-EM5UHLAM.js → chunk-T2M5HWBQ.js} +2 -2
  131. package/dist/{chunk-CZEIHYMP.js → chunk-T6MQNNAC.js} +2 -2
  132. package/dist/chunk-T75DS2E6.js +21 -0
  133. package/dist/{chunk-57GCCPLS.js → chunk-TEANKHUU.js} +2 -2
  134. package/dist/{chunk-MT5W4DUG.js → chunk-TEMM2FEL.js} +2 -2
  135. package/dist/{chunk-I2KP4AGR.js → chunk-TJWVT4DO.js} +2 -2
  136. package/dist/{chunk-77GHPR2R.js → chunk-TLTSESB4.js} +2 -2
  137. package/dist/{chunk-KM4QRWI5.js → chunk-TNJGTQWO.js} +2 -2
  138. package/dist/{chunk-EFFMFK7C.js → chunk-TOTWJZIX.js} +2 -2
  139. package/dist/{chunk-54K6556S.js → chunk-U33PMPNW.js} +2 -2
  140. package/dist/{chunk-GXVDTHFC.js → chunk-U7NUXDQO.js} +2 -2
  141. package/dist/chunk-UC2FD2PS.js +4 -0
  142. package/dist/{chunk-MRGTCMDK.js → chunk-UIAUPFBJ.js} +2 -2
  143. package/dist/{chunk-LAGDJXFY.js → chunk-UJIXCI3L.js} +2 -2
  144. package/dist/{chunk-IVJJNVSX.js → chunk-UMEPSVKT.js} +2 -2
  145. package/dist/{chunk-4O52YNKL.js → chunk-UQYQBLJX.js} +2 -2
  146. package/dist/{chunk-JUO3Z644.js → chunk-UW6KD57C.js} +2 -2
  147. package/dist/{chunk-TAJ6UGCO.js → chunk-V4NGDIEA.js} +3 -3
  148. package/dist/{chunk-VLTUX4IF.js → chunk-VGWZ4MOY.js} +2 -2
  149. package/dist/{chunk-KNV5VFDV.js → chunk-VSGOIZMQ.js} +2 -2
  150. package/dist/{chunk-K5G7SPAG.js → chunk-W7QDASTN.js} +4 -4
  151. package/dist/{chunk-IWAMYGPN.js → chunk-W7YLRXZE.js} +2 -2
  152. package/dist/{chunk-QKVTWODE.js → chunk-WK2IQJPK.js} +2 -2
  153. package/dist/{chunk-HYKSLTAR.js → chunk-WO6OFKUC.js} +2 -2
  154. package/dist/{chunk-S64NCE2Z.js → chunk-WWCV4E6J.js} +2 -2
  155. package/dist/{chunk-2F5ERMNI.js → chunk-XJBK3QDV.js} +2 -2
  156. package/dist/{chunk-IGYAZPRX.js → chunk-XN3EKMLI.js} +2 -2
  157. package/dist/{chunk-FWY2PRIF.js → chunk-XQAVQVIL.js} +2 -2
  158. package/dist/{chunk-NJA4MMBD.js → chunk-XUPFA6GH.js} +2 -2
  159. package/dist/{chunk-4AOOSCZ7.js → chunk-YHPG3S2U.js} +2 -2
  160. package/dist/{chunk-CDWSLAPN.js → chunk-YPBKBYPS.js} +2 -2
  161. package/dist/{chunk-5BDK6QC3.js → chunk-YRKP7PM7.js} +2 -2
  162. package/dist/{chunk-4NHWNAWQ.js → chunk-YT4DVWUV.js} +2 -2
  163. package/dist/{chunk-5NJPH3QZ.js → chunk-YTJHCGYB.js} +2 -2
  164. package/dist/{chunk-ZNQCR656.js → chunk-Z66XYVLZ.js} +2 -2
  165. package/dist/{chunk-A67HT5FR.js → chunk-ZB4C5TTR.js} +2 -2
  166. package/dist/chunk-ZMA5HWXY.js +3 -0
  167. package/dist/{chunk-CWMHWD56.js → chunk-ZNH33XIB.js} +2 -2
  168. package/dist/{cli-context-XEPPF4RX.js → cli-context-FJL2JHOE.js} +2 -2
  169. package/dist/{cli-context-TSADTXLB.js → cli-context-PQNWHMCQ.js} +2 -2
  170. package/dist/{cli-program-KJGQEM72.js → cli-program-SCHOHOQE.js} +2 -2
  171. package/dist/cli.js +1 -1
  172. package/dist/{code-CDe-mIjx.d.ts → code-DfX3xeWy.d.ts} +1 -1
  173. package/dist/{code-viewer-ZCTHXQ5C.js → code-viewer-AMRXV444.js} +2 -2
  174. package/dist/{code-viewer-YGDON6SY.js → code-viewer-EXI5SFFR.js} +2 -2
  175. package/dist/{command-descriptors-5VAB2MZX.js → command-descriptors-H6A4UY72.js} +129 -129
  176. package/dist/{command-descriptors-EAHKIRAG.js → command-descriptors-ROIOTCCW.js} +130 -130
  177. package/dist/{db-DmRNdCtm.d.ts → db-BoG_PWYH.d.ts} +1 -1
  178. package/dist/direct-navigation-3JOYP2MO.js +3 -0
  179. package/dist/direct-navigation-SJMJLBY7.js +2 -0
  180. package/dist/{graph-evidence-Bs54NWws.d.ts → graph-evidence-D1jx1Cql.d.ts} +1 -1
  181. package/dist/{health-BnzbSLCE.d.ts → health-DkYBS5BI.d.ts} +1 -1
  182. package/dist/index.d.ts +1 -1
  183. package/dist/index.js +1 -1
  184. package/dist/invocation-command-descriptors-GMZX3UAD.js +2 -0
  185. package/dist/invocation-command-descriptors-HNMKDEF6.js +3 -0
  186. package/dist/{scip-cli-BRFKkHQn.d.ts → maintenance-types-CdL5eQii.d.ts} +1 -20
  187. package/dist/output-continuation-command-5NWVDQT7.js +2 -0
  188. package/dist/output-continuation-command-RNEHNYPU.js +3 -0
  189. package/dist/postinstall.js +1 -1
  190. package/dist/project-reindex-MIW5CYEG.js +3 -0
  191. package/dist/project-reindex-VQ23LWDA.js +2 -0
  192. package/dist/queries/affected.d.ts +1 -1
  193. package/dist/queries/affected.js +1 -1
  194. package/dist/queries/anchors.d.ts +1 -1
  195. package/dist/queries/anchors.js +1 -1
  196. package/dist/queries/architecture.d.ts +1 -1
  197. package/dist/queries/architecture.js +1 -1
  198. package/dist/queries/bottlenecks.d.ts +1 -1
  199. package/dist/queries/bottlenecks.js +1 -1
  200. package/dist/queries/by-kind.d.ts +1 -1
  201. package/dist/queries/by-kind.js +1 -1
  202. package/dist/queries/call-graph.d.ts +1 -1
  203. package/dist/queries/call-graph.js +1 -1
  204. package/dist/queries/change-surface.d.ts +1 -1
  205. package/dist/queries/change-surface.js +1 -1
  206. package/dist/queries/cleanup-plan.d.ts +1 -1
  207. package/dist/queries/cleanup-plan.js +1 -1
  208. package/dist/queries/co-change.d.ts +1 -1
  209. package/dist/queries/co-change.js +1 -1
  210. package/dist/queries/code.d.ts +2 -2
  211. package/dist/queries/code.js +1 -1
  212. package/dist/queries/complexity-hotspots.d.ts +1 -1
  213. package/dist/queries/complexity-hotspots.js +1 -1
  214. package/dist/queries/complexity.d.ts +1 -1
  215. package/dist/queries/complexity.js +1 -1
  216. package/dist/queries/context.d.ts +1 -1
  217. package/dist/queries/context.js +1 -1
  218. package/dist/queries/convergence.d.ts +1 -1
  219. package/dist/queries/convergence.js +1 -1
  220. package/dist/queries/coupling.d.ts +1 -1
  221. package/dist/queries/coupling.js +1 -1
  222. package/dist/queries/cycles.d.ts +1 -1
  223. package/dist/queries/cycles.js +1 -1
  224. package/dist/queries/dataflow.d.ts +1 -1
  225. package/dist/queries/dataflow.js +1 -1
  226. package/dist/queries/dead.d.ts +1 -1
  227. package/dist/queries/dead.js +1 -1
  228. package/dist/queries/decorative-checkers.d.ts +1 -1
  229. package/dist/queries/decorative-checkers.js +1 -1
  230. package/dist/queries/deep-chains.d.ts +1 -1
  231. package/dist/queries/deep-chains.js +1 -1
  232. package/dist/queries/dependence-slice.d.ts +2 -2
  233. package/dist/queries/dependence-slice.js +1 -1
  234. package/dist/queries/dependency-depth.d.ts +1 -1
  235. package/dist/queries/dependency-depth.js +1 -1
  236. package/dist/queries/deps.d.ts +1 -1
  237. package/dist/queries/deps.js +1 -1
  238. package/dist/queries/diff-impact.d.ts +1 -1
  239. package/dist/queries/diff-impact.js +1 -1
  240. package/dist/queries/doc-drift.d.ts +1 -1
  241. package/dist/queries/doc-drift.js +1 -1
  242. package/dist/queries/drift.d.ts +1 -1
  243. package/dist/queries/drift.js +1 -1
  244. package/dist/queries/duplicate-bodies.d.ts +1 -1
  245. package/dist/queries/duplicate-bodies.js +1 -1
  246. package/dist/queries/entry-map.d.ts +1 -1
  247. package/dist/queries/entry-map.js +1 -1
  248. package/dist/queries/evidence.d.ts +2 -2
  249. package/dist/queries/evidence.js +1 -1
  250. package/dist/queries/extract-candidates.d.ts +1 -1
  251. package/dist/queries/extract-candidates.js +1 -1
  252. package/dist/queries/fan.d.ts +1 -1
  253. package/dist/queries/fan.js +1 -1
  254. package/dist/queries/files.d.ts +1 -1
  255. package/dist/queries/files.js +1 -1
  256. package/dist/queries/health.d.ts +2 -2
  257. package/dist/queries/health.js +1 -1
  258. package/dist/queries/hierarchy.d.ts +1 -1
  259. package/dist/queries/hierarchy.js +1 -1
  260. package/dist/queries/hotspots.d.ts +1 -1
  261. package/dist/queries/hotspots.js +1 -1
  262. package/dist/queries/imports.d.ts +1 -1
  263. package/dist/queries/imports.js +1 -1
  264. package/dist/queries/incomplete-migration.d.ts +1 -1
  265. package/dist/queries/incomplete-migration.js +1 -1
  266. package/dist/queries/index.d.ts +4 -4
  267. package/dist/queries/index.js +1 -1
  268. package/dist/queries/isolated.d.ts +1 -1
  269. package/dist/queries/isolated.js +1 -1
  270. package/dist/queries/locality-candidates.d.ts +1 -1
  271. package/dist/queries/locality-candidates.js +1 -1
  272. package/dist/queries/members.d.ts +1 -1
  273. package/dist/queries/members.js +1 -1
  274. package/dist/queries/methods.d.ts +1 -1
  275. package/dist/queries/methods.js +1 -1
  276. package/dist/queries/not-implemented.d.ts +1 -1
  277. package/dist/queries/not-implemented.js +1 -1
  278. package/dist/queries/outline.d.ts +1 -1
  279. package/dist/queries/outline.js +1 -1
  280. package/dist/queries/passthrough-candidates.d.ts +1 -1
  281. package/dist/queries/passthrough-candidates.js +1 -1
  282. package/dist/queries/plan-context.d.ts +1 -1
  283. package/dist/queries/plan-context.js +1 -1
  284. package/dist/queries/react-component-duplicates.d.ts +1 -1
  285. package/dist/queries/react-component-duplicates.js +1 -1
  286. package/dist/queries/react-hook-candidates.d.ts +1 -1
  287. package/dist/queries/react-hook-candidates.js +1 -1
  288. package/dist/queries/react-large-component-pressure.d.ts +1 -1
  289. package/dist/queries/react-large-component-pressure.js +1 -1
  290. package/dist/queries/recent-duplicates.d.ts +1 -1
  291. package/dist/queries/recent-duplicates.js +1 -1
  292. package/dist/queries/redundant-reexports.d.ts +1 -1
  293. package/dist/queries/redundant-reexports.js +1 -1
  294. package/dist/queries/reference-neighborhood.d.ts +1 -1
  295. package/dist/queries/reference-neighborhood.js +1 -1
  296. package/dist/queries/reference-reachability.d.ts +1 -1
  297. package/dist/queries/reference-reachability.js +1 -1
  298. package/dist/queries/refs.d.ts +1 -1
  299. package/dist/queries/refs.js +1 -1
  300. package/dist/queries/self-audit.d.ts +1 -1
  301. package/dist/queries/self-audit.js +1 -1
  302. package/dist/queries/similar-chains.d.ts +1 -1
  303. package/dist/queries/similar-chains.js +1 -1
  304. package/dist/queries/similar-files.d.ts +1 -1
  305. package/dist/queries/similar-files.js +1 -1
  306. package/dist/queries/similar-signatures.d.ts +1 -1
  307. package/dist/queries/similar-signatures.js +1 -1
  308. package/dist/queries/similar.d.ts +1 -1
  309. package/dist/queries/similar.js +1 -1
  310. package/dist/queries/slice.d.ts +1 -1
  311. package/dist/queries/slice.js +1 -1
  312. package/dist/queries/source-inspection.d.ts +3 -3
  313. package/dist/queries/source-inspection.js +1 -1
  314. package/dist/queries/source-search.d.ts +1 -1
  315. package/dist/queries/source-search.js +1 -1
  316. package/dist/queries/stale-abstractions.d.ts +1 -1
  317. package/dist/queries/stale-abstractions.js +1 -1
  318. package/dist/queries/stats.d.ts +1 -1
  319. package/dist/queries/surface.d.ts +1 -1
  320. package/dist/queries/surface.js +1 -1
  321. package/dist/queries/symbols.d.ts +1 -1
  322. package/dist/queries/symbols.js +1 -1
  323. package/dist/queries/system-map.d.ts +1 -1
  324. package/dist/queries/system-map.js +1 -1
  325. package/dist/queries/system.d.ts +1 -1
  326. package/dist/queries/system.js +1 -1
  327. package/dist/queries/test-quality.d.ts +1 -1
  328. package/dist/queries/test-quality.js +1 -1
  329. package/dist/queries/trace.d.ts +1 -1
  330. package/dist/queries/trace.js +1 -1
  331. package/dist/queries/twin-ab.d.ts +1 -1
  332. package/dist/queries/twin-ab.js +1 -1
  333. package/dist/queries/twin-drift.d.ts +1 -1
  334. package/dist/queries/twin-drift.js +1 -1
  335. package/dist/queries/unused-imports.d.ts +1 -1
  336. package/dist/queries/unused-imports.js +1 -1
  337. package/dist/queries/unused-params.d.ts +1 -1
  338. package/dist/queries/unused-params.js +1 -1
  339. package/dist/queries/value-flow.d.ts +2 -2
  340. package/dist/queries/value-flow.js +1 -1
  341. package/dist/queries/vue-component-duplicates.d.ts +1 -1
  342. package/dist/queries/vue-component-duplicates.js +1 -1
  343. package/dist/queries/vue-composable-candidates.d.ts +1 -1
  344. package/dist/queries/vue-composable-candidates.js +1 -1
  345. package/dist/queries/vue-large-view-pressure.d.ts +1 -1
  346. package/dist/queries/vue-large-view-pressure.js +1 -1
  347. package/dist/queries/wrapper-candidates.d.ts +1 -1
  348. package/dist/queries/wrapper-candidates.js +1 -1
  349. package/dist/reindex-worker.js +2 -2
  350. package/dist/reindex.d.ts +2 -4
  351. package/dist/reindex.js +71 -32
  352. package/dist/runtime.d.ts +1 -2
  353. package/dist/runtime.js +3 -3
  354. package/dist/rust-semantic-session-server.js +1 -1
  355. package/dist/rust-semantic-session-worker.js +1 -1
  356. package/dist/rust-semantic-worker.js +1 -1
  357. package/dist/sentinel-ensure-command-H66AZ3VE.js +2 -0
  358. package/dist/sentinel-ensure-command-R4YAUCJB.js +3 -0
  359. package/dist/sentinel-worker.js +1 -1
  360. package/dist/typescript-mailbox-worker.js +1 -1
  361. package/dist/watch-server.js +2 -2
  362. package/docs/INDEX_GENERATIONS.md +2 -2
  363. package/docs/NPM_RELEASE.md +323 -0
  364. package/docs/schemas/npm-release-state.schema.json +4 -13
  365. package/package.json +3 -11
  366. package/dist/chunk-2Q2LW5JW.js +0 -14
  367. package/dist/chunk-327YK6TB.js +0 -4
  368. package/dist/chunk-347TXATM.js +0 -2
  369. package/dist/chunk-36WRYYTE.js +0 -3
  370. package/dist/chunk-5IO2APSS.js +0 -2
  371. package/dist/chunk-6OAHRI2D.js +0 -6
  372. package/dist/chunk-6URCE5QY.js +0 -2
  373. package/dist/chunk-6ZV5EDUT.js +0 -5
  374. package/dist/chunk-7R64XY4Y.js +0 -12
  375. package/dist/chunk-CANBLFVQ.js +0 -15
  376. package/dist/chunk-CCRZLRWJ.js +0 -2
  377. package/dist/chunk-G2XUZCF2.js +0 -88
  378. package/dist/chunk-H5QXP63L.js +0 -2
  379. package/dist/chunk-HCMQZPEO.js +0 -2
  380. package/dist/chunk-IEL6Q5W3.js +0 -308
  381. package/dist/chunk-IGQQUENU.js +0 -109
  382. package/dist/chunk-K2O7SBAU.js +0 -2
  383. package/dist/chunk-QVWDQTMG.js +0 -2
  384. package/dist/chunk-RJWAB4VR.js +0 -345
  385. package/dist/chunk-VCL7FK3E.js +0 -3
  386. package/dist/chunk-WOOTEWQT.js +0 -239
  387. package/dist/chunk-XYLV727H.js +0 -21
  388. package/dist/chunk-YMGZZEW4.js +0 -2
  389. package/dist/direct-navigation-B3SGOOBW.js +0 -2
  390. package/dist/direct-navigation-ZL362KXF.js +0 -3
  391. package/dist/invocation-command-descriptors-CSUGUHTT.js +0 -2
  392. package/dist/invocation-command-descriptors-PPVZOIE5.js +0 -3
  393. package/dist/output-continuation-command-FTVVBVSN.js +0 -2
  394. package/dist/output-continuation-command-ITPRC3YV.js +0 -3
  395. package/dist/project-reindex-7HZSLLLY.js +0 -3
  396. package/dist/project-reindex-NGM3DYBN.js +0 -2
  397. package/dist/sentinel-ensure-command-KYYULCFU.js +0 -2
  398. package/dist/sentinel-ensure-command-RIZA3RY7.js +0 -3
  399. package/docs/WINDOWS_SIDECAR_RELEASE.md +0 -424
  400. package/docs/schemas/windows-sidecar-provenance.schema.json +0 -137
  401. package/scripts/build-codebaseiq-windows.mjs +0 -197
  402. package/scripts/codebaseiq-windows-provenance.mjs +0 -364
  403. package/scripts/verify-codebaseiq-windows.mjs +0 -29
@@ -1,88 +0,0 @@
1
- #!/usr/bin/env node
2
- import{B as J,C as Rn,a as In,d as Ae,f as xn,i as wn,j as te,k as A,l as me,m as L,o as Pn,p as D,q as R,r as S,u as it,v as ye,w as he,x as re,y as ne,z as En}from"./chunk-DUKHVPU5.js";import{createRequire as ls}from"module";var us=ls(import.meta.url),ot=ps().version;function ps(){for(let e of["../package.json","../../package.json"])try{return us(e)}catch{}return{version:"0.0.0"}}import{createHash as An,randomUUID as bs}from"crypto";import{chmodSync as Mn,existsSync as se,linkSync as Is,lstatSync as ct,readdirSync as zt,realpathSync as _,unlinkSync as xs,writeSync as ws}from"fs";import{homedir as Ps}from"os";import{basename as Es,dirname as dt,isAbsolute as Dn,join as T,resolve as lt}from"path";import{closeSync as fs,existsSync as gs,fsyncSync as ms,mkdirSync as ys,openSync as hs}from"fs";import{dirname as vn}from"path";function ie(e,t,r,n){let i=0;for(;i<t.length;){let o=r.writeFile(e,t,i,t.length-i);if(!Number.isSafeInteger(o)||o<=0||o>t.length-i)throw new Error(`${n} write did not make valid forward progress`);i+=o}}function Se(e,t){if(t!=="win32")return!1;let r=e.code;return r==="EACCES"||r==="EBADF"||r==="EINVAL"||r==="EISDIR"||r==="EPERM"}var oe=Object.freeze({platform:process.platform,pathExists:e=>gs(e),makeDirectory:e=>ys(e,{recursive:!0}),openFile:(e,t,r)=>hs(e,t,r),syncFile:e=>ms(e),closeFile:e=>fs(e)});function M(e,t=oe){let r=[],n=e;for(;!t.pathExists(n);){r.push(n);let o=vn(n);if(o===n)throw new Error(`Cannot establish a durable directory path without an existing ancestor: ${e}`);n=o}let i="synced";for(let o of r.reverse())t.makeDirectory(o),i=E(i,I(vn(o),t));return i}function I(e,t=oe){let r;try{r=t.openFile(e,"r")}catch(n){if(Se(n,t.platform))return"unsupported";throw n}try{t.syncFile(r)}catch(n){try{t.closeFile(r)}catch{}if(Se(n,t.platform))return"unsupported";throw n}return t.closeFile(r),"synced"}function E(...e){return e.every(t=>t==="not-requested")?"not-requested":e.includes("unsupported")?"unsupported":"synced"}import{isAbsolute as kn,relative as Ss}from"path";var v=class extends Error{constructor(r,n){super(`refusing unsafe project file path ${JSON.stringify(r)} (${n})`);this.relativePath=r;this.reason=n;this.name="UnsafeProjectPathError"}relativePath;reason;code="CODEBASEIQ_UNSAFE_PROJECT_PATH"};function qt(e){return e.replace(/\\/g,"/").replace(/^\.\//,"")}function su(e){return e.replace(/\\/g,"/")}function au(e,t){return qt(e)===qt(t)}function st(e){let t=e.trim();if(!/^file:/i.test(t))return t;let r;try{r=new URL(t)}catch{return t}if(r.protocol!=="file:")return t;let n;try{n=decodeURIComponent(r.pathname)}catch{return t}for(n=n.replace(/\\/g,"/");n.length>1&&n.endsWith("/");)n=n.slice(0,-1);let i=/^\/([A-Za-z]):(\/|$)/.exec(n);i&&(n=`/${i[1].toUpperCase()}:${n.slice(3)}`);let o=n.split("/").map(s=>encodeURIComponent(s).replace(/%3A/gi,":")).join("/");return`file://${r.host}${o}`}function be(e,t){return st(e)===st(t)}function O(e,t){let r=Ss(e,t);return r===""||!r.startsWith("..")&&!kn(r)}function j(e){if(!e)throw new v(e,"empty-path");if(e.includes("\0"))throw new v(e,"nul-byte");if(kn(e)||/^[A-Za-z]:/.test(e)||e.startsWith("//")||e.startsWith("\\\\"))throw new v(e,"absolute-path");let t=qt(e);if(t.split("/").some(n=>n===".."))throw new v(e,"parent-traversal");if(!t||t===".")throw new v(e,"empty-path");return t}var Cn=1,Ce=".codebaseiq-cache-owner.json",Rs=16*1024,Ln=Object.freeze({...oe,randomToken:()=>bs(),linkFile:(e,t)=>Is(e,t),removeFile:e=>xs(e),writeFile:(e,t,r,n)=>ws(e,t,r,n)});function at(e,t){return Object.assign(new Error(`refusing unsafe project dbPath ${JSON.stringify(e)} (${t}); use a repository-relative directory that remains inside the checkout`),{name:"UnsafeCachePathError",code:"CODEBASEIQ_UNSAFE_CACHE_PATH",configuredPath:e,reason:t})}function N(e,t){return Object.assign(new Error(`refusing unowned cache directory ${JSON.stringify(e)} (${t}); move unrelated data elsewhere or choose a new empty dbPath`),{name:"CacheOwnershipError",code:"CODEBASEIQ_CACHE_OWNERSHIP",cacheDir:e,reason:t})}function vs(e,t){let r=_(e);return ks(r,Wt(r,t))}function Wt(e,t){let r=_(e),n=process.env.CODEBASEIQ_CACHE_DIR;return n?lt(n):t?.dbPath?Fs(r,t.dbPath):pt(r)}function ut(){let e=process.env.XDG_CACHE_HOME;return T(e||T(Ps(),".cache"),"codebaseiq")}function pt(e){let t=lt(e);try{t=_(t)}catch{}let r=An("sha256").update(t).digest("hex").slice(0,12);return T(ut(),"projects",r)}function ft(e){if(!/^[a-f0-9]{24}$/.test(e))throw new Error(`invalid repository cache identity: ${e}`);let t=T(ut(),"repositories",e);return jn(t),_(t)}function Ht(e){return process.env.CODEBASEIQ_SHARED_CACHE!=="0"&&!process.env.CODEBASEIQ_CACHE_DIR&&!process.env.CODEBASEIQ_INDEX_DB&&!e?.dbPath}function Su(e,t){let r=vs(e,t);return{cacheDir:r,dbPath:T(r,"index.db"),indexPath:T(r,"index.scip"),metaPath:T(r,"meta.json")}}function ks(e,t,r=Ln){return Ds(e,t,r).cacheDir}function Ds(e,t,r=Ln){let n=_(e),i=se(t)?"synced":jn(t,r),o=_(t),s=T(o,Ce);if(se(s))return $t(n,o),Ut(s),Me(o),{kind:"existing",cacheDir:o};Fn(o),Ts(o),Fn(o);let c=`${JSON.stringify({schemaVersion:Cn,canonicalProjectRoot:n,canonicalCacheDir:o,creatorVersion:ot},null,2)}
3
- `;try{let d=Os(s,c,r),l=E(i,d);return{kind:"published",cacheDir:o,achievedDurability:l==="synced"?"directory-durable":"file-flushed",directorySync:l}}catch(d){if(_s(d))return $t(n,o),{kind:"existing",cacheDir:o};throw d}}function $t(e,t){let r=_(e),n=_(t);return Ms(n,r,n)}function bu(e,t){return se(T(t,Ce))?($t(e,t),Tn(t),!0):!1}function Fs(e,t){let r;try{r=j(t)}catch(s){throw s instanceof v?at(t,s.reason):s}let n=lt(e,...r.split("/"));if(n===e||!O(e,n))throw at(t,"outside-project");let i=As(n),o=_(i);if(!O(e,o)&&o!==e)throw at(t,"symlink-escape");return n}function As(e){let t=e;for(;!se(t);){let r=dt(t);if(r===t)throw at(e,"no-existing-ancestor");t=r}return t}function Ms(e,t,r){let n=T(e,Ce);if(!se(n)||ct(n).isSymbolicLink())throw N(e,"missing regular ownership record");let i=ct(n);if(!i.isFile()||i.size>Rs)throw N(e,"invalid ownership record file");let o=S(n,"cache ownership record"),s=Cs(o,e);if(s.canonicalProjectRoot!==t)throw N(e,"ownership record belongs to a different project");if(s.canonicalCacheDir!==r)throw N(e,"ownership record names a different cache directory");return{record:s,ownerSha256:An("sha256").update(o).digest("hex"),physicalCacheDir:e}}function Cs(e,t){try{let r=JSON.parse(e);if(r.schemaVersion!==Cn||typeof r.canonicalProjectRoot!="string"||typeof r.canonicalCacheDir!="string"||typeof r.creatorVersion!="string"||!Dn(r.canonicalProjectRoot)||!Dn(r.canonicalCacheDir))throw new Error("invalid fields");return r}catch(r){throw N(t,`malformed ownership record: ${r instanceof Error?r.message:String(r)}`)}}function Fn(e){let t=zt(e).filter(r=>r!==Ce&&!Ls(r));if(t.length>0)throw N(e,`unrecognized existing entries: ${t.slice(0,3).join(", ")}`)}function Ls(e){return e.startsWith(`${Ce}.tmp-`)||[".codebaseiq-generations","affected-shadow-latest.json","affected-shadow.jsonl","agent-hooks","augment-vue-meta.json","cache-lifecycle.lock","evidence.db","evidence.db-shm","evidence.db-wal","health-report-cache.json","index.db","index.db-shm","index.db-wal","index.lock","index.scip","language-indexes","meta.json","reindex-activity.jsonl","shared-cache.json","typescript-index","typescript-scip-fragments","typescript-scip-overlays","typescript-semantic","watch-activity.json","watch-refresh-requests","watch-state.json","watch.lock"].includes(e)?!0:/^(?:reindex-|rust-|typescript-)/.test(e)}function Ts(e){for(let t of zt(e)){let r=T(e,t);try{let n=ct(r);if(n.isSymbolicLink())throw N(e,`legacy cache entry ${t} is a symlink`);if(n.isDirectory())Me(r);else if(n.isFile())Ut(r);else throw N(e,`legacy cache entry ${t} is not a file or directory`)}catch(n){if(On(n))continue;throw n}}Me(e)}function Tn(e,t=!1){try{let r=ct(e);if(r.isSymbolicLink())throw N(e,"managed cache tree contains a symlink");if(r.isFile()){Ut(e);return}if(!r.isDirectory())throw N(e,"managed cache tree contains a special file");Me(e);for(let n of zt(e))Tn(T(e,n),!0)}catch(r){if(t&&On(r))return;throw r}}function On(e){let t=e?.code;return t==="ENOENT"||t==="ENOTDIR"}function jn(e,t=oe){let r=M(e,t);return Me(e),r}function Os(e,t,r){let n=`${e}.tmp-${process.pid}-${r.randomToken()}`,i,o=!1;try{i=r.openFile(n,"wx",384),o=!0,ie(i,Buffer.from(t),r,"cache ownership record"),r.syncFile(i),r.closeFile(i),i=void 0,r.linkFile(n,e);let s=I(dt(e),r);return r.removeFile(n),o=!1,E(s,I(dt(e),r))}finally{if(i!==void 0)try{r.closeFile(i)}catch{}if(o)try{r.removeFile(n)}catch{}}}function Me(e){process.platform!=="win32"&&Mn(e,448)}function Ut(e){process.platform!=="win32"&&Mn(e,384)}function js(e){if(se(e))return _(e);let t=[],r=e;for(;;){let n=dt(r);if(n===r)return e;if(t.unshift(Es(r)),se(n))return T(_(n),...t);r=n}}function Jt(e){return js(lt(e))}function _s(e){return typeof e=="object"&&e!==null&&"code"in e&&e.code==="EEXIST"}function Vt(e,t,r=[]){let n=Qt(e);if($n.has(n)||r.some(o=>gt(n,o))||t.some(o=>zn(n,o)))return"config";if(t.some(Hn)&&/\.d\.(?:ts|mts|cts)$/.test(n.toLowerCase()))return"ambient";let i=Wn(n);return t.some(o=>(Un[o]??[]).includes(i))?"source":"other"}function qn(e,t,r){let n=Qt(e);if($n.has(n)||r?.some(o=>gt(n,o))||zn(n,t)||Hn(t)&&/\.d\.(?:ts|mts|cts)$/.test(n.toLowerCase()))return!0;let i=Wn(n);return(Un[t]??[]).includes(i)}function xu(e){if(typeof e!="object"||e===null)return null;let t=e;return typeof t.version!="number"||!_n(t.languages)||typeof t.pnpmWorkspaces!="boolean"||typeof t.typescriptProjectMode!="string"||!_n(t.typescriptProjects)||t.clojureConfigPath!==void 0&&typeof t.clojureConfigPath!="string"||!Array.isArray(t.files)||!t.files.every(Kt)?null:t}function wu(e,t){let r=new Map((e?.files??[]).map(a=>[a.path,a])),n=new Map(t.files.map(a=>[a.path,a])),i=new Set([...r.keys(),...n.keys()]),o=[];for(let a of[...i].sort()){let c=r.get(a),d=n.get(a),l=Vt(a,t.languages);!c&&d?o.push({kind:"added",path:a,inputKind:l,after:d}):c&&!d?o.push({kind:"deleted",path:a,inputKind:l,before:c}):c&&d&&(c.hash!==d.hash||c.size!==d.size)&&o.push({kind:"modified",path:a,inputKind:l,before:c,after:d})}let s=new Set;return e||s.add("prior-snapshot-unavailable"),e&&e.version!==t.version&&s.add("snapshot-version-changed"),(Gn(e?.files??[])||Gn(t.files))&&s.add("duplicate-input-path"),[...e?.files??[],...t.files].some(Gs)&&s.add("unreadable-input"),{version:1,changes:o,projectIdentityChanged:e?!Ns(e,t):!0,uncertainty:[...s].sort()}}function _n(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function Gn(e){return new Set(e.map(t=>t.path)).size!==e.length}function Kt(e){if(typeof e!="object"||e===null)return!1;let t=e;return typeof t.path=="string"&&typeof t.size=="number"&&Number.isFinite(t.size)&&typeof t.hash=="string"}function Gs(e){return e.hash==="unreadable"||e.size<0}function Ns(e,t){return Nn(e.languages,t.languages)&&e.pnpmWorkspaces===t.pnpmWorkspaces&&e.typescriptProjectMode===t.typescriptProjectMode&&Nn(e.typescriptProjects,t.typescriptProjects)&&e.clojureConfigPath===t.clojureConfigPath}function Nn(e,t){if(e.length!==t.length)return!1;let r=[...e].sort(),n=[...t].sort();return r.every((i,o)=>i===n[o])}var $n=new Set([".codebaseiq.json"]),Bs={typescript:["tsconfig.json"],javascript:["package.json"],java:["pom.xml","build.gradle"],scala:["build.sbt"],kotlin:["build.gradle.kts"],rust:["Cargo.toml"],python:["pyproject.toml","setup.py"],ruby:["Gemfile"],go:["go.mod"],cpp:["CMakeLists.txt","Makefile"],c:["CMakeLists.txt","Makefile"],csharp:["*.csproj","*.sln"],vb:["*.vbproj","*.sln"],dart:["pubspec.yaml"],php:["composer.json"],clojure:["deps.edn","project.clj","bb.edn","shadow-cljs.edn"]},qs={typescript:["package.json","package-lock.json","pnpm-lock.yaml","yarn.lock","bun.lock","bun.lockb","tsconfig.*.json","jsconfig.json","jsconfig.*.json"],javascript:["package-lock.json","pnpm-lock.yaml","yarn.lock","bun.lock","bun.lockb","tsconfig.json","tsconfig.*.json","jsconfig.json","jsconfig.*.json"],java:["build.gradle.kts","settings.gradle","settings.gradle.kts","gradle.properties","gradle.lockfile","gradle-wrapper.properties"],scala:["plugins.sbt","build.properties"],kotlin:["pom.xml","build.gradle","settings.gradle","settings.gradle.kts","gradle.properties","gradle.lockfile","gradle-wrapper.properties"],rust:["Cargo.lock","rust-project.json","rust-toolchain","rust-toolchain.toml"],python:["setup.cfg","requirements*.txt","Pipfile","Pipfile.lock","poetry.lock","uv.lock"],ruby:["Gemfile.lock","gems.locked"],go:["go.sum","go.work","go.work.sum"],cpp:["compile_commands.json"],c:["compile_commands.json"],csharp:["Directory.Build.props","Directory.Build.targets","Directory.Packages.props","packages.lock.json","NuGet.Config","global.json"],vb:["Directory.Build.props","Directory.Build.targets","Directory.Packages.props","packages.lock.json","NuGet.Config","global.json"],dart:["pubspec.lock","analysis_options.yaml"],php:["composer.lock"],clojure:[]},Bn=new Map;function zn(e,t){return Bs[t].some(r=>gt(e,r))||qs[t].some(r=>gt(e,r))}function gt(e,t){let r=Qt(t).replace(/^\.\//,"");if(!r)return!1;let n=e.split("/").at(-1)??e,i=r.includes("/")?e:n;if(!r.includes("*")&&!r.includes("?"))return i===r;let o=Bn.get(r);if(!o){let s=r.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,"[^/]*").replace(/\?/g,"[^/]");o=new RegExp(`^${s}$`),Bn.set(r,o)}return o.test(i)}function Qt(e){return e.replaceAll("\\","/").replace(/^\.\//,"")}function Wn(e){return e.includes(".")?`.${e.split(".").at(-1).toLowerCase()}`:""}function Hn(e){return e==="typescript"||e==="javascript"}var Un={typescript:[".ts",".tsx",".mts",".cts"],javascript:[".js",".jsx",".mjs",".cjs",".vue"],java:[".java"],scala:[".scala"],kotlin:[".kt",".kts"],rust:[".rs"],python:[".py",".pyi"],ruby:[".rb"],go:[".go"],cpp:[".cc",".cpp",".cxx",".hpp",".hh",".hxx"],c:[".c",".h"],csharp:[".cs"],vb:[".vb"],dart:[".dart"],php:[".php"],clojure:[".clj",".cljs",".cljc"]};var Yt=2,ae=3;var Xt=new Set(En);function mt(e){let t=e;if(typeof e=="string")try{t=JSON.parse(e)}catch(s){return{kind:"malformed",reason:`invalid JSON: ${Vs(s)}`}}if(!J(t))return{kind:"malformed",reason:"metadata must be a JSON object"};let r=t.version;if(!Number.isInteger(r))return{kind:"malformed",reason:"version must be an integer"};if(r!==Yt&&r!==ae)return{kind:"unsupported",version:r,direction:r<Yt?"older":"future"};let n=zs(t,r);if(n)return{kind:"malformed",reason:n};let i=t,o={metadata:i,capabilities:$s(i)};return r===Yt?{kind:"legacy",...o,metadata:i}:{kind:"supported",...o,metadata:i}}function Du(e){return e.kind==="legacy"||e.kind==="supported"?e.metadata:null}function Jn(e){if(e.kind!=="legacy"&&e.kind!=="supported"||!e.capabilities.stableGenerationIdentity)return null;let t=e.metadata;return JSON.stringify({version:t.version,status:t.status,updatedAt:t.updatedAt,fingerprint:t.fingerprint,indexedLanguages:t.indexedLanguages,scipCompanion:t.scipCompanion,sqliteLayoutVersion:t.version===ae?t.sqliteLayoutVersion:void 0})}function $s(e){let t=e.fingerprint!==void 0,r=J(e.fingerprint),n=e.indexedLanguages!==void 0,i=e.status==="complete",o=e.version===ae?e:null;return{usableForQuery:n,usableForEvidenceCache:t,publishableGeneration:i&&r&&n,stableGenerationIdentity:i&&t&&typeof e.updatedAt=="string",languageShardReuse:!!o?.languageFingerprints,typescriptProjectShardReuse:!!o?.typescriptProjectShards}}function zs(e,t){if(e.status!=="complete"&&e.status!=="partial")return"status must be complete or partial";if(e.updatedAt!==void 0&&!Rn(e.updatedAt))return"updatedAt must be a valid timestamp";for(let r of["requestedLanguages","indexedLanguages"])if(e[r]!==void 0&&!Ws(e[r]))return`${r} must contain unique supported languages`;return e.skipped!==void 0&&!Hs(e.skipped)?"skipped must contain supported language/reason pairs":e.scipCompanion!==void 0&&e.scipCompanion!=="current"&&e.scipCompanion!=="deferred"?"scipCompanion must be current or deferred":t===ae&&e.sqliteLayoutVersion!==void 0&&(!Number.isSafeInteger(e.sqliteLayoutVersion)||e.sqliteLayoutVersion<1)?"sqliteLayoutVersion must be a positive safe integer":t===ae&&e.languageFingerprints!==void 0&&!Us(e.languageFingerprints)?"languageFingerprints must map supported languages to fingerprint objects":t===ae&&e.typescriptProjectShards!==void 0&&!Js(e.typescriptProjectShards)?"typescriptProjectShards must map project names to file fingerprints":null}function Fu(e){return e.version===ae&&e.sqliteLayoutVersion===1}function Ws(e){return!Array.isArray(e)||!e.every(t=>typeof t=="string"&&Xt.has(t))?!1:new Set(e).size===e.length}function Hs(e){return Array.isArray(e)&&e.every(t=>J(t)&&typeof t.language=="string"&&Xt.has(t.language)&&typeof t.reason=="string")}function Us(e){return J(e)&&Object.entries(e).every(([t,r])=>Xt.has(t)&&J(r))}function Js(e){return J(e)&&Object.values(e).every(t=>J(t)&&Array.isArray(t.files)&&t.files.every(Kt))}function Vs(e){return e instanceof Error?e.message:String(e)}import{randomUUID as ia}from"crypto";import{closeSync as oa,existsSync as sa,fsyncSync as aa,linkSync as ca,mkdirSync as da,openSync as la,renameSync as ua,unlinkSync as pa,writeSync as fa}from"fs";import{dirname as Kn}from"path";var Ks=Object.freeze(["EPERM","EACCES","EBUSY"]),Qs=Object.freeze([10,20,40,80,160,320,640,1e3,1e3,1e3]);function Ys(e){Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,e)}var Zt=Object.freeze({platform:process.platform,sleep:Ys});function Xs(e,t){if(t!=="win32")return!1;let r=e?.code;return typeof r=="string"&&Ks.includes(r)}function k(e,t={}){let r=t.runtime??Zt,n=t.delaysMs??Qs;for(let i of n)try{return e()}catch(o){if(!Xs(o,r.platform))throw o;r.sleep(i)}return e()}import{chmodSync as Zs,constants as ea,copyFileSync as ta}from"fs";import{dirname as ra}from"path";var Vn=Object.freeze({...oe,copyFile:(e,t)=>ta(e,t,ea.COPYFILE_FICLONE),chmodFile:(e,t)=>Zs(e,t)});function Le(e,t,r={}){let n=r.runtime??Vn,i=ra(t),o=M(i,n);if(n.copyFile(e,t),n.platform==="win32")na(t,r.mode,n);else{r.mode!==void 0&&n.chmodFile(t,r.mode);let s=n.openFile(t,"r");try{n.syncFile(s)}finally{n.closeFile(s)}}return E(o,I(i,n))}function na(e,t,r){let n=!1,i;try{i=r.openFile(e,"r+")}catch(o){let s=o.code;if(s!=="EACCES"&&s!=="EPERM")throw o;r.chmodFile(e,384),n=!0,i=r.openFile(e,"r+")}try{r.syncFile(i)}finally{r.closeFile(i)}t!==void 0?r.chmodFile(e,t):n&&r.chmodFile(e,292)}var Qn=Object.freeze({platform:process.platform,randomToken:()=>ia(),pathExists:e=>sa(e),makeDirectory:e=>da(e,{recursive:!0}),openFile:(e,t,r)=>la(e,t,r),writeFile:(e,t,r,n)=>fa(e,t,r,n),syncFile:e=>aa(e),closeFile:e=>oa(e),renameFile:(e,t)=>ua(e,t),linkFile:(e,t)=>ca(e,t),removeFile:e=>pa(e)});function er(e,t,r={}){let n=r.durability??"visibility",i=r.runtime??Qn,o=Kn(e),s=n==="durable"?M(o,i):(i.makeDirectory(o),"not-requested"),a=`${e}.tmp-${i.randomToken()}`,c=typeof t=="string"?Buffer.from(t):t,d,l=!1;try{d=i.openFile(a,"wx",r.mode??384),l=!0,ie(d,c,i,"atomic file"),n==="durable"&&i.syncFile(d),i.closeFile(d),d=void 0,k(()=>i.renameFile(a,e),{runtime:{platform:i.platform,sleep:i.sleep??Zt.sleep}}),l=!1;let u=n==="durable"?E(s,I(o,i)):"not-requested";return Yn(n,u)}finally{if(d!==void 0)try{i.closeFile(d)}catch{}if(l)try{i.removeFile(a)}catch{}}}function tr(e,t,r={}){let n=r.durability??"visibility",i=r.runtime??Qn;if(!i.linkFile)throw new Error("Exclusive atomic file publication requires hard-link support.");let o=Kn(e),s=n==="durable"?M(o,i):(i.makeDirectory(o),"not-requested"),a=`${e}.tmp-${i.randomToken()}`,c=typeof t=="string"?Buffer.from(t):t,d,l=!1;try{d=i.openFile(a,"wx",r.mode??384),l=!0,ie(d,c,i,"exclusive atomic file"),n==="durable"&&i.syncFile(d),i.closeFile(d),d=void 0,i.linkFile(a,e);let u=n==="durable"?I(o,i):"not-requested";i.removeFile(a),l=!1;let p=n==="durable"?E(s,u,I(o,i)):"not-requested";return Yn(n,p)}finally{if(d!==void 0)try{i.closeFile(d)}catch{}if(l)try{i.removeFile(a)}catch{}}}function Yn(e,t){return{requestedDurability:e,achievedDurability:e==="visibility"?"visibility":t==="synced"?"directory-durable":"file-flushed",directorySync:t}}function V(e,t,r={}){er(e,Xn(t,r),{durability:"visibility",runtime:r.runtime})}function B(e,t,r={}){return er(e,Xn(t,r),{durability:"durable",runtime:r.runtime})}function Xn(e,t){let r=JSON.stringify(e,null,t.spacing);return t.trailingNewline?`${r}
4
- `:r}import Qa from"better-sqlite3";import{mkdtempSync as Zn}from"fs";import{win32 as ga}from"path";var ma=259,ya=8,ha=6,yt="\\\\?\\",rr=`${yt}UNC\\`;function ei(e,t,r){if(r!=="win32"||e.startsWith(yt))return;let n=ga.resolve(e);if(!(n.length+t<=ma))return n.startsWith("\\\\")?`${rr}${n.slice(2)}`:`${yt}${n}`}function ht(e,t=process.platform){return e===""||e===":memory:"?e:ei(e,ya,t)??e}function nr(e,t=process.platform){let r=ei(e,ha,t);if(!r)return Zn(e);let n=Zn(r);return n.startsWith(rr)?`\\\\${n.slice(rr.length)}`:n.slice(yt.length)}var ti=[],ri=[];function Qu(e){e.groups.length>0&&ti.push(e)}function Yu(e){ri.push(e)}function ni(e){let t=[];for(let r of ri)try{r.close(e)}catch(n){t.push(n)}if(t.length===1)throw t[0];if(t.length>1)throw new AggregateError(t,"Multiple database-owned resources failed to close.")}function Xu(e,t){let r=new Set(t.groups);for(let n of ti)n.groups.some(i=>r.has(i))&&(t.file!==void 0&&n.clearFile?n.clearFile(e,t.file):n.clearAll(e))}import{createHash as Oa,randomUUID as ja}from"crypto";import{existsSync as de,mkdirSync as _a,readdirSync as Ga,rmSync as fi,statSync as gi}from"fs";import{basename as Na,dirname as Oe,join as C}from"path";import{join as Ma}from"path";function ce(){return performance.now()}function ep(){return Date.now()}function St(e,t){return e.reason instanceof Error?e.reason:new Error(t)}function ii(e,t){if(e?.aborted)throw St(e,t)}import{randomUUID as Sa}from"crypto";import{closeSync as ba,fsyncSync as Ia,linkSync as xa,mkdirSync as wa,openSync as Pa,statSync as Ea,unlinkSync as Ra,writeSync as va}from"fs";import{dirname as cr}from"path";var or="codebaseiq-process-lock",sr=1,bt=Object.freeze({wallNow:()=>Date.now(),isProcessAlive:te,readProcessIdentity:ne,randomToken:()=>Sa(),makeDirectory:e=>wa(e,{recursive:!0}),openFile:(e,t,r)=>Pa(e,t,r),writeFile:(e,t,r,n)=>va(e,t,r,n),syncFile:e=>Ia(e),closeFile:e=>ba(e),linkFile:(e,t)=>xa(e,t),readFile:e=>S(e,"process lock record"),statFile:e=>{let t=Ea(e);return{dev:t.dev,ino:t.ino,size:t.size,mtimeMs:t.mtimeMs}},removeFile:e=>Ra(e)});function It(e,t){let r=t.runtime??bt;r.makeDirectory(cr(e));let n;for(let i=0;i<2;i+=1)try{return{kind:"acquired",lock:si(e,t,r),...n?{reclaimed:n}:{}}}catch(o){if(o.code!=="EEXIST")throw o;let s=Ie(e,{parseLegacy:t.parseLegacy,runtime:r});if(i===0&&Da(e,s,{creationGraceMs:t.creationGraceMs,parseLegacy:t.parseLegacy,runtime:r})){n=s;continue}return{kind:"contended",observation:s}}return{kind:"contended",observation:Ie(e,{parseLegacy:t.parseLegacy,runtime:r})}}function Ie(e,t={}){let r=t.runtime??bt,n,i;try{n=r.statFile(e),i=r.readFile(e)}catch(c){return c.code==="ENOENT"?{state:"missing"}:{state:"malformed"}}let o;try{o=JSON.parse(i)}catch{return{state:"malformed",raw:i,identity:n}}let s=ka(o);if(s)return{state:"valid",raw:i,identity:n,record:s,owner:Aa(s),parsed:o};let a=t.parseLegacy?.(o)??null;return a?{state:"legacy",raw:i,identity:n,owner:a,parsed:o}:{state:"malformed",raw:i,identity:n,parsed:o}}function ka(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e;if(t.protocol!==or||t.version!==sr||typeof t.kind!="string"||t.kind.trim()===""||typeof t.pid!="number"||!Number.isSafeInteger(t.pid)||t.pid<=0||typeof t.token!="string"||t.token.trim()===""||typeof t.startedAt!="string"||!Number.isFinite(Date.parse(t.startedAt))||t.detail!==void 0&&(typeof t.detail!="object"||t.detail===null||Array.isArray(t.detail)))return null;let r=t.processIdentity===void 0?null:he(t.processIdentity);return t.processIdentity!==void 0&&(!r||r.pid!==t.pid)?null:{protocol:or,version:sr,kind:t.kind,pid:t.pid,token:t.token,...r?{processIdentity:r}:{},startedAt:t.startedAt,...t.detail?{detail:t.detail}:{}}}function Da(e,t,r={}){let n=r.runtime??bt;if(!ar(t,n))return!1;let i=Fa(`${e}.reclaim`,n);if(!i)return!1;try{let o=Ie(e,{parseLegacy:r.parseLegacy,runtime:n});return!ai(t,o)||!ar(o,n)?!1:dr(e,n)}finally{i.release()}}function si(e,t,r){let n=t.pid??process.pid,i=r.randomToken(),o=t.processIdentity===void 0?r.readProcessIdentity(n):t.processIdentity,s={protocol:or,version:sr,kind:t.kind,pid:n,token:i,...o?{processIdentity:o}:{},startedAt:new Date(r.wallNow()).toISOString(),...t.detail?{detail:t.detail}:{}},a=`${e}.${i}.candidate`,c=r.openFile(a,"wx",384),d;try{ie(c,Buffer.from(`${JSON.stringify(s)}
5
- `),r,"process lock"),r.syncFile(c)}catch(u){d=u}try{r.closeFile(c)}catch(u){d??=u}if(d!==void 0)throw ir(a,r),d;try{r.linkFile(a,e)}catch(u){throw ir(a,r),u}ir(a,r);try{ci(cr(e),r)}catch(u){throw oi(e,s,r),u}let l=!1;return{path:e,record:s,release:()=>l?!1:(l=!0,oi(e,s,r))}}function oi(e,t,r=bt){let n=Ie(e,{runtime:r});return n.state!=="valid"||!n.record||n.record.pid!==t.pid||n.record.token!==t.token||t.processIdentity&&(!n.record.processIdentity||!re(t.processIdentity,n.record.processIdentity))?!1:dr(e,r)}function Fa(e,t){for(let r=0;r<2;r+=1)try{return si(e,{kind:"reclaim-guard",runtime:t},t)}catch(n){if(n.code!=="EEXIST")return null;let i=Ie(e,{runtime:t});if(r>0||!ar(i,t))return null;let o=Ie(e,{runtime:t});if(!ai(i,o)||!dr(e,t))return null}return null}function ar(e,t){if(e.state==="missing")return!1;if(e.owner){if(!t.isProcessAlive(e.owner.pid))return!0;if(!e.owner.processIdentity)return!1;let r=t.readProcessIdentity(e.owner.pid);return r!==null&&!re(e.owner.processIdentity,r)}return!1}function ai(e,t){return e.state===t.state&&e.raw===t.raw&&e.identity!==void 0&&t.identity!==void 0&&e.identity.dev===t.identity.dev&&e.identity.ino===t.identity.ino&&e.identity.size===t.identity.size&&e.identity.mtimeMs===t.identity.mtimeMs}function Aa(e){return{pid:e.pid,...e.processIdentity?{processIdentity:e.processIdentity}:{}}}function ci(e,t){let r;try{r=t.openFile(e,"r")}catch(n){if(Se(n,process.platform))return;throw n}try{t.syncFile(r)}catch(n){if(!Se(n,process.platform))throw n}finally{t.closeFile(r)}}function dr(e,t){try{return t.removeFile(e),ci(cr(e),t),!0}catch{return!1}}function ir(e,t){try{t.removeFile(e)}catch{}}var Ca=e=>{if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e.pid;return typeof t=="number"&&Number.isSafeInteger(t)&&t>0?{pid:t}:null};function di(e,t={}){return q(Ma(e,"gc.lock"),t)}function q(e,t={}){let r=t.waitMs??0,n=t.pollMs??10,i=t.now??ce,o=i()+r;do{let s=li(e);if(s)return ui(s);let a=o-i();if(a<=0)return null;La(Math.min(n,a))}while(i()<=o);return null}async function mp(e,t={}){let r=t.waitMs??0,n=t.pollMs??10,i=t.now??ce,o=i()+r;do{ii(t.signal,"Lock acquisition was aborted.");let s=li(e);if(s)return ui(s);let a=o-i();if(a<=0)return null;await Ta(Math.min(n,a),t.signal)}while(i()<=o);return null}function li(e){let t=It(e,{kind:"generic",parseLegacy:Ca});return t.kind==="acquired"?t.lock:null}function ui(e){return{release:()=>{e.release()}}}function La(e){let t=new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));Atomics.wait(t,0,0,e)}function Ta(e,t){return t?.aborted?Promise.reject(St(t,"Lock acquisition was aborted.")):new Promise((r,n)=>{let i=setTimeout(()=>{t?.removeEventListener("abort",o),r()},e),o=()=>{clearTimeout(i),t?.removeEventListener("abort",o),n(t?St(t,"Lock acquisition was aborted."):new Error("Lock acquisition was aborted."))};t?.addEventListener("abort",o,{once:!0})})}var le=1,fr=1,je=".codebaseiq-generations",xt="manifest.json",mi="readers",Ba="gc.lock",qa=128,Te=new Map,yi={pid:process.pid,now:()=>new Date,randomToken:()=>ja(),isProcessAlive:te,readProcessIdentity:ne,resolveImmutableGeneration:Si};function P(e){return C(Oe(e),je)}function _e(e){return C(P(e),Ba)}function hi(e,t=yi){let r=q(_e(e.dbPath),{waitMs:5e3});if(!r)throw new Error("SQLite generation retention is busy; retry opening the index.");let n;try{let o=$(e.dbPath);if(!o||!Ge(e.dbPath,o.currentGeneration))return{generation:mr(e),release(){}};let s=t.randomToken();if(!/^[A-Za-z0-9._-]+$/.test(s))throw new Error("SQLite generation reader token is unsafe.");let a=C(P(e.dbPath),mi);_a(a,{recursive:!0});let c=C(a,`${t.pid}-${s}.json`),d=t.readProcessIdentity(t.pid);V(c,{version:1,token:s,generationIdentity:o.currentGeneration,pid:t.pid,...d?{processIdentity:d}:{},acquiredAt:t.now().toISOString()},{spacing:2,trailingNewline:!0});let l=!1;n={identity:o.currentGeneration,required:o.artifactSet==="immutable-v1",release(){l||(l=!0,fi(c,{force:!0}))}}}finally{r.release()}let i;try{i=t.resolveImmutableGeneration(e,n.identity)}catch(o){throw n.release(),o}if(i?.source==="immutable"&&i.identity===n.identity)return{generation:i,release:n.release};if(n.release(),n.required)throw new Error(`Published SQLite generation ${n.identity} is missing or invalid.`);return $a(e,n.identity)}function $a(e,t){let r=q(_e(e.dbPath),{waitMs:5e3});if(!r)throw new Error("SQLite generation retention is busy; retry opening the index.");try{let n=$(e.dbPath);if(n?.currentGeneration!==t)throw new Error("SQLite index publication changed while opening a legacy generation.");if(de(C(Oe(e.dbPath),"index.lock")))throw new Error("Legacy SQLite publication is in progress; retry after the reindex lock is released.");return{generation:bi(e,n.currentGeneration),release(){}}}finally{r.release()}}function gr(e,t,r=yi,n={}){let i=C(P(e),mi);if(!de(i))return{protectedGenerations:new Set,activeLeases:0,staleLeasesRemoved:0,malformedLeases:0};let o=new Set,s=0,a=0,c=0;for(let d of Ga(i,{withFileTypes:!0})){if(!d.isFile()||!d.name.endsWith(".json"))continue;let l=C(i,d.name),u;try{u=za(JSON.parse(S(l,"SQLite generation reader lease")))}catch{u=null}if(!u){c+=1;for(let p of t)o.add(p);continue}if(!Wa(u,r)){n.removeStale!==!1&&(fi(l,{force:!0}),a+=1);continue}s+=1,o.add(u.generationIdentity)}return{protectedGenerations:o,activeLeases:s,staleLeasesRemoved:a,malformedLeases:c}}function za(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e,r=t.processIdentity===void 0?null:he(t.processIdentity);return t.version!==1||typeof t.token!="string"||t.token.trim()===""||typeof t.generationIdentity!="string"||!/^[a-f0-9]{64}$/.test(t.generationIdentity)||typeof t.pid!="number"||!Number.isSafeInteger(t.pid)||t.pid<=0||typeof t.acquiredAt!="string"||!Number.isFinite(Date.parse(t.acquiredAt))||t.processIdentity!==void 0&&(!r||r.pid!==t.pid)?null:{version:1,token:t.token,generationIdentity:t.generationIdentity,pid:t.pid,...r?{processIdentity:r}:{},acquiredAt:t.acquiredAt}}function Wa(e,t){if(!t.isProcessAlive(e.pid))return!1;if(!e.processIdentity)return!0;let r=t.readProcessIdentity(e.pid);return r===null||re(e.processIdentity,r)}function $(e){try{let t=JSON.parse(S(C(P(e),"state.json"),"SQLite generation state"));return Ua(t)?t:null}catch{return null}}function Ge(e,t){return Ne(P(e),t)}function Ne(e,t){try{let r=JSON.parse(S(C(e,t,xt),"SQLite generation manifest"));return Ha(r,t)?r:null}catch{return null}}function mr(e){let t=$(e.dbPath);if(t){let r=Si(e,t.currentGeneration);if(r)return r;if(t.artifactSet==="immutable-v1")throw new Error(`Published SQLite generation ${t.currentGeneration} is missing or invalid.`)}if(de(C(Oe(e.dbPath),"index.lock")))throw new Error("Legacy SQLite publication is in progress; retry after the reindex lock is released.");return bi(e,t?.currentGeneration)}function kp(e){let t=$(e);if(t)return t.currentGeneration;try{let r=C(Oe(e),"meta.json"),n=de(r)?S(r,"reindex metadata"):void 0;return Ii(e,n)}catch{return null}}function K(e){return Jn(mt(e))??e}function Si(e,t){try{let r=C(P(e.dbPath),t),n=Ge(e.dbPath,t);if(!n)return null;let i=lr(r,n.database),o=n.index?lr(r,n.index):void 0,s=n.metadata?lr(r,n.metadata):void 0;return!ur(i,n.database)||n.index&&(!o||!ur(o,n.index))||n.metadata&&(!s||!ur(s,n.metadata))?null:{identity:t,databasePath:i,...o?{indexPath:o}:{},...s?{metadataPath:s,metadataRaw:S(s,"reindex metadata")}:{},source:"immutable"}}catch{return null}}function bi(e,t){let r=H(e.dbPath),n=C(Oe(e.dbPath),"meta.json"),i=de(n)?S(n,"reindex metadata"):void 0,o=de(e.indexPath)?e.indexPath:void 0;return{identity:t??Ii(e.dbPath,i),databasePath:e.dbPath,...o?{indexPath:o}:{},...i===void 0?{}:{metadataPath:n,metadataRaw:i},source:"legacy",databaseFileIdentity:r}}function Ii(e,t){let r=Oa("sha256").update("sqlite-generation-legacy-v1\0");return t!==void 0&&r.update(K(t)),r.update(`\0${H(e)}`),r.digest("hex")}function H(e){let t=gi(e);return`${t.dev}:${t.ino}:${t.size}:${t.mtimeMs}`}function lr(e,t){if(Na(t.file)!==t.file||t.file==="."||t.file==="..")throw new Error("SQLite generation manifest contains an unsafe artifact path");return C(e,t.file)}function ur(e,t){if(!de(e))return!1;let r=pi(e);if(!r||r.size!==t.size)return!1;let n=`${e}\0${t.sha256}\0${r.identity}`;if(Te.has(n))return!0;let i=ye(e,{inputKind:"immutable SQLite generation artifact",maxBytes:t.size}),o=pi(e);if(!o||o.identity!==r.identity||i!==t.sha256)return!1;for(Te.set(n,!0);Te.size>qa;){let s=Te.keys().next().value;if(s===void 0)break;Te.delete(s)}return!0}function pi(e){let t=gi(e,{bigint:!0});return t.isFile()?{identity:`${t.dev}:${t.ino}:${t.size}:${t.mtimeNs}:${t.ctimeNs}`,size:Number(t.size)}:null}function Ha(e,t){return e.version===fr&&e.identity===t&&pr(e.database)&&(e.index===void 0||pr(e.index))&&(e.metadata===void 0||pr(e.metadata))}function pr(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.file=="string"&&!!t.file&&Number.isSafeInteger(t.size)&&(t.size??-1)>=0&&typeof t.sha256=="string"&&/^[a-f0-9]{64}$/.test(t.sha256)}function Ua(e){return e.version===le&&typeof e.currentGeneration=="string"&&!!e.currentGeneration&&typeof e.publishedAt=="string"&&Number.isFinite(Date.parse(e.publishedAt))&&(e.artifactSet===void 0||e.artifactSet==="immutable-v1")&&Ja(e.stableMirrors)&&Va(e.previousGeneration)&&Ka(e.publication)}function Ja(e){if(e===void 0)return!0;if(!e||typeof e!="object")return!1;let t=e;return typeof t.databaseFileIdentity=="string"&&!!t.databaseFileIdentity&&(t.indexFileIdentity===void 0||typeof t.indexFileIdentity=="string"&&!!t.indexFileIdentity)}function Va(e){if(e===void 0)return!0;if(!e||typeof e!="object")return!1;let t=e;return typeof t.generationIdentity=="string"&&!!t.generationIdentity&&typeof t.databasePath=="string"&&!!t.databasePath&&(t.metadataPath===void 0||typeof t.metadataPath=="string"&&!!t.metadataPath)}function Ka(e){if(e===void 0)return!0;if(!e||typeof e!="object")return!1;let t=e,r=[t.converterDurationMs,t.affectedDocumentCount,t.changedDocumentCount,t.producerDurationMs,t.materializationDurationMs,t.patchDurationMs].filter(n=>n!==void 0);return(t.mode==="incremental"||t.mode==="full")&&t.validation==="passed"&&t.converterDurationMs!==void 0&&r.every(n=>typeof n=="number"&&Number.isFinite(n)&&n>=0)&&(t.scipCompanion===void 0||t.scipCompanion==="current"||t.scipCompanion==="deferred")&&(t.typescriptOverlayGeneration===void 0||typeof t.typescriptOverlayGeneration=="string"&&!!t.typescriptOverlayGeneration)&&(t.scipCompanion!=="deferred"||!!t.typescriptOverlayGeneration)&&(t.fallbackReason===void 0||typeof t.fallbackReason=="string")}var Ya=["busy_timeout = 5000","query_only = ON","temp_store = MEMORY","cache_size = -64000","mmap_size = 268435456"],yr=class{constructor(t,r){this.connection=t;this.releaseGenerationReader=r}connection;releaseGenerationReader;active=!0;initialize(t){try{for(let r of Ya)this.connection.pragma(r);t(this.connection)}catch(r){try{this.close()}catch(n){throw new AggregateError([r,n],"SQLite initialization and rollback both failed.",{cause:n})}throw r}}close(){if(!this.active)return;this.active=!1;let t,r;try{this.connection.close()}catch(n){t=n}try{this.releaseGenerationReader()}catch(n){r=n}if(t!==void 0&&r!==void 0)throw new AggregateError([t,r],"SQLite connection close and generation-reader release both failed.");if(t!==void 0)throw t;if(r!==void 0)throw r}},Xa=["node_modules",".git","dist","build","out","coverage","target",".next",".nuxt",".cache",".turbo",".nbb",".cpcache",".shadow-cljs",".codebaseiq-cache","__pycache__",".venv","venv"],xi=class{db;config;generation;pathFilter;connection;connectionOwnership;statementCache=new Map;closed=!1;constructor(t,r){this.config=t,this.pathFilter=r??null;let n=rc(t),i=new yr(n.db,n.release);try{i.initialize(tc),this.generation=n.generation,this.connection=n.db,this.connectionOwnership=i,this.db=Za(n.db)}catch(o){try{i.close()}catch(s){throw new AggregateError([o,s],"SQLite construction and rollback both failed.",{cause:s})}throw o}}isIgnored(t){return this.pathFilter?.isIgnored(t)??!1}get localSymbolPredicate(){return`(
6
- EXISTS (
7
- SELECT 1
8
- FROM defn_enclosing_ranges local_der
9
- JOIN documents local_d ON local_der.document_id = local_d.id
10
- WHERE local_der.symbol_id = gs.id
11
- ${this.pathExclusionsFor("local_d").trimStart()}
12
- )
13
- OR EXISTS (
14
- SELECT 1
15
- FROM mentions local_m
16
- JOIN chunks local_c ON local_m.chunk_id = local_c.id
17
- JOIN documents local_d ON local_c.document_id = local_d.id
18
- WHERE local_m.symbol_id = gs.id
19
- AND local_m.role = 1
20
- ${this.pathExclusionsFor("local_d").trimStart()}
21
- )
22
- )`}get pathExclusions(){return this.pathExclusionsFor("d")}get symbolNoise(){return this.symbolNoiseFor("gs")}pathExclusionsFor(...t){return t.flatMap(r=>Xa.flatMap(n=>[`AND ${r}.relative_path NOT LIKE '${n}/%'`,`AND ${r}.relative_path NOT LIKE '%/${n}/%'`])).join(`
23
- `)}symbolNoiseFor(t){return`AND ${t}.symbol NOT LIKE '%().(%' AND ${t}.symbol NOT LIKE '%typeLiteral%'`}all(t,...r){return this.statement(t).all(...r)}get(t,...r){return this.statement(t).get(...r)}close(){if(this.closed)return;this.closed=!0,this.statementCache.clear();let t,r;try{ni(this)}catch(n){t=n}try{this.connectionOwnership.close()}catch(n){r=n}if(t!==void 0&&r!==void 0)throw new AggregateError([t,r],"Database-owned resource and SQLite connection cleanup both failed.");if(t!==void 0)throw t;if(r!==void 0)throw r}statement(t){let r=this.statementCache.get(t);return r||(r=this.connection.prepare(t),this.statementCache.set(t,r)),r}};function Za(e){return Object.freeze({prepare(t){let r=e.prepare(t);if(!r.readonly||!r.reader)throw new Error("ScipDatabase.db only permits read-only statements that return rows.");return ec(r)}})}function ec(e){let t={get:(...r)=>e.get(...r),all:(...r)=>e.all(...r),iterate:(...r)=>e.iterate(...r),pluck(r){return r===void 0?e.pluck():e.pluck(r),t},expand(r){return r===void 0?e.expand():e.expand(r),t},raw(r){return r===void 0?e.raw():e.raw(r),t},bind(...r){return e.bind(...r),t},columns:()=>e.columns(),safeIntegers(r){return r===void 0?e.safeIntegers():e.safeIntegers(r),t}};return Object.freeze(t)}function tc(e){if(!e.prepare("SELECT 1 AS present FROM sqlite_master WHERE type = 'table' AND name = 'documents'").get())return;let r=e.prepare("SELECT relative_path FROM documents").iterate();for(let n of r)j(n.relative_path)}function rc(e){for(let t=0;t<4;t+=1){let r=hi(e),n=r.generation,i;try{i=new Qa(ht(n.databasePath),{readonly:!0,fileMustExist:!0})}catch(o){throw r.release(),o}if(n.source==="immutable")return{db:i,generation:n,release:r.release};try{let o=mr(e);if(n.databaseFileIdentity===H(n.databasePath)&&o.source==="legacy"&&o.identity===n.identity&&o.databaseFileIdentity===n.databaseFileIdentity&&o.metadataRaw===n.metadataRaw)return{db:i,generation:n,release:r.release}}catch(o){throw i.close(),r.release(),o}i.close(),r.release()}throw new Error("SQLite index publication changed repeatedly while opening a coherent generation.")}import nc from"ignore";import{existsSync as wi,readdirSync as ic}from"fs";import{dirname as hr,isAbsolute as Pi,join as wt,relative as oc,resolve as sc}from"path";function Np(e){let t=nc();return ac(e,t)||t.add(lc),{isIgnored:n=>Sr(t,e,n),filter:n=>n.filter(i=>!Sr(t,e,i))}}function ac(e,t){let r=new Set,n=(s,a)=>{if(!(r.has(s)||!wi(s)))try{let c=R(s,{maxBytes:A,inputKind:"gitignore file"});t.add(a?cc(c,a):c),r.add(s)}catch{}},i=hr(e),o=0;for(;i!==hr(i)&&o<5&&(n(wt(i,".gitignore"),""),!wi(wt(i,".git")));)i=hr(i),o++;return Ei(e,"",t,n),r.size>0}function Ei(e,t,r,n){let i=t?wt(e,t):e;n(wt(i,".gitignore"),t);let o;try{o=ic(i,{withFileTypes:!0})}catch{return}for(let s of o){if(!s.isDirectory()||s.name===".git")continue;let a=t?`${t}/${s.name}`:s.name;Sr(r,e,`${a}/`)||Ei(e,a,r,n)}}function cc(e,t){let r=t.replaceAll("\\","/").replace(/\/+$/,"");return e.split(/\r?\n/).map(n=>dc(n,r)).join(`
24
- `)}function dc(e,t){let r=e.trimStart();if(!r||r.startsWith("#"))return e;let n=e.slice(0,e.length-r.length),i=r.startsWith("!"),o=i?r.slice(1):r;if(!o||o.startsWith("#"))return e;let s=o.startsWith("/"),a=s?o.slice(1):o,l=(a.endsWith("/")?a.slice(0,-1):a).includes("/")||s?`${t}/${a}`:`${t}/**/${a}`;return`${n}${i?"!":""}${l}`}var lc=`
25
- # Dependencies
26
- node_modules/
27
- vendor/
28
- .bundle/
29
-
30
- # Build output
31
- dist/
32
- build/
33
- out/
34
- target/
35
- bin/
36
- obj/
37
-
38
- # Python
39
- __pycache__/
40
- *.pyc
41
- *.pyo
42
- .venv/
43
- venv/
44
- .env/
45
- env/
46
- *.egg-info/
47
-
48
- # Rust
49
- target/
50
-
51
- # Java / Kotlin / Scala
52
- *.class
53
- .gradle/
54
- .mvn/
55
-
56
- # C# / .NET
57
- bin/
58
- obj/
59
- packages/
60
-
61
- # Go
62
- vendor/
63
-
64
- # Dart
65
- .dart_tool/
66
- build/
67
-
68
- # PHP
69
- vendor/
70
-
71
- # IDE / OS
72
- .idea/
73
- .vscode/
74
- *.swp
75
- *.swo
76
- .DS_Store
77
- Thumbs.db
78
-
79
- # Type definitions (often noise in queries)
80
- *.d.ts
81
- `;function Sr(e,t,r){let n=uc(t,r);if(!n)return!1;try{return e.ignores(n)}catch{return!1}}function uc(e,t){if(!t||t===".")return null;if(!Pi(t)&&!t.startsWith(".."))return t.replaceAll("\\","/");let r=Pi(t)?t:sc(e,t),n=oc(e,r).replaceAll("\\","/");return!n||n==="."||n.startsWith("..")?null:n}import{appendFileSync as pc,mkdirSync as fc}from"fs";import{createHash as gc,randomUUID as mc}from"crypto";import{dirname as yc}from"path";import{performance as xe}from"perf_hooks";var Di="CODEBASEIQ_PROFILE",Fi="CODEBASEIQ_PROFILE_OUT",Ai="CODEBASEIQ_PROFILE_COMMAND",Mi="CODEBASEIQ_PROFILE_CACHE_STATE",br="CODEBASEIQ_PROFILE_RUN_ID",Ir="CODEBASEIQ_PROFILE_WORKLOAD_IDENTITY",xr="CODEBASEIQ_PROFILE_WORKLOAD_IDENTITY_KIND",Ci=[Di,Fi,Ai,Mi,br,Ir,xr],Hp=new Set(Ci),Ri=new Set,vi=new Map,ki=!1;function Be(){let e=process.env[Di];return e==="1"||e==="true"}function hc(){return process.env[Fi]}function Li(){return process.env[Ai]}function Sc(){return process.env[Mi]}function Ti(){let e=process.env[br];if(e)return e;if(!Be())return;let t=mc();return process.env[br]=t,t}function Oi(){return process.env[Ir]}function bc(e){let t=Oi();if(t)return t;if(!Be())return;let r=Ti();if(!r)return;let n=e.projectFingerprint?"published-project":"run-only",i=ji(["profile-workload-v1",e.toolVersion,e.command,e.projectFingerprint??r]);return process.env[Ir]=i,process.env[xr]=n,i}function ji(e){return gc("sha256").update(JSON.stringify(e)).digest("hex").slice(0,24)}function Up(){return Object.fromEntries(Ci.flatMap(e=>{let t=process.env[e];return t===void 0?[]:[[e,t]]}))}function Jp(e,t,r){if(!Be())return t();let n=xe.now();try{let i=t();return Pt({type:"span",name:e,durationMs:Math.round(xe.now()-n),ok:!0,...Et(r)??{}}),i}catch(i){throw Pt({type:"span",name:e,durationMs:Math.round(xe.now()-n),ok:!1,error:i instanceof Error?i.message:String(i),...Et(r)??{}}),i}}async function Vp(e,t,r){if(!Be())return t();let n=xe.now();try{let i=await t();return Pt({type:"span",name:e,durationMs:Math.round(xe.now()-n),ok:!0,...Et(r)??{}}),i}catch(i){throw Pt({type:"span",name:e,durationMs:Math.round(xe.now()-n),ok:!1,error:i instanceof Error?i.message:String(i),...Et(r)??{}}),i}}function Pt(e,t=hc()){let r=Ic(e),n={timestamp:new Date().toISOString(),pid:process.pid,runId:Ti(),command:Li(),cacheState:Sc(),...r,...e},i=`${JSON.stringify(n)}
82
- `;if(t)try{let o=yc(t);Ri.has(o)||(fc(o,{recursive:!0}),Ri.add(o)),pc(t,i);return}catch(o){ki||(ki=!0,process.stderr.write(`[profile] failed to write ${t}: ${o instanceof Error?o.message:String(o)}
83
- `));return}Be()&&process.stderr.write(i)}function Ic(e){let t=Oi()??bc({command:Li()??"unknown",toolVersion:"unknown",projectFingerprint:null});if(!t)return{};let r=process.env[xr],n=typeof e.name=="string"?e.name:void 0;if(!n)return{workloadIdentity:t,workloadIdentityKind:r};let i=n.split(/[.:]/,1)[0]??n,o=`${t}\0${n}`,s=vi.get(o);return s||(s=ji(["profile-subsystem-v1",t,n]),vi.set(o,s)),{workloadIdentity:t,workloadIdentityKind:r,subsystem:i,subsystemWorkIdentity:s}}function Et(e){return typeof e=="function"?e():e}import{createHash as Wo,randomUUID as xl}from"crypto";import{existsSync as Y,lstatSync as tn,mkdirSync as ve,readdirSync as Ho,realpathSync as Uo,renameSync as ge,rmSync as Q,statSync as Gt}from"fs";import{dirname as rn,join as f,resolve as Ze}from"path";import{setTimeout as wl}from"timers/promises";import{pathToFileURL as Bo}from"url";import{deserializeSCIP as Jo}from"@c4312/scip";import Pl from"better-sqlite3";import{execFileSync as Qc}from"child_process";import{createHash as Hi}from"crypto";import{closeSync as Yc,fstatSync as Ui,lstatSync as Rr,openSync as Xc,readdirSync as Zc,readFileSync as ed,readlinkSync as td,realpathSync as kt}from"fs";import{isAbsolute as rd,join as vr,relative as nd,resolve as id,sep as od}from"path";import{execFileSync as wr}from"child_process";import{createHash as xc}from"crypto";import{mkdirSync as wc,renameSync as Pc,writeFileSync as Ec}from"fs";import{basename as Rc,dirname as vc,join as kc}from"path";var Dc="git-content-hashes.json",Fc=32*1024*1024,Ac=2e5,Rt=3e4;function Pr(){return{env:In(),encoding:"utf8",maxBuffer:64*1024*1024,stdio:["ignore","pipe","ignore"],windowsHide:!0,timeout:Rt,killSignal:"SIGKILL"}}function _i(e){let t,r;try{t=wr("git",["-C",e,"ls-files","-s","-z","--","."],{...Pr(),timeout:Rt}),r=wr("git",["-C",e,"status","--porcelain=v1","-z","--untracked-files=all","--no-renames","--","."],{...Pr(),timeout:Rt})}catch{return null}let n=new Map,i=[];for(let l of t.split("\0")){if(!l)continue;let u=l.indexOf(" "),p=u>0?l.slice(0,u).split(" "):[];if(p.length!==3)continue;let[m,g,F]=p,x=l.slice(u+1);if(m!=="100644"&&m!=="100755"||F!=="0"){n.delete(x);continue}n.set(x,g),Rc(x)===".gitattributes"&&i.push(`${x}:${g}`)}let o=new Set;for(let l of r.split("\0"))l.length>=4&&l[2]===" "&&o.add(l.slice(3));let s=Mc(e,i),a=kc(Wt(e),Dc),c=Cc(a,s),d=new Map;return{lookup(l){if(o.has(l))return;let u=n.get(l);if(u)return d.get(u)??c.entries[u]},seed(l,u){if(o.has(l))return;let p=n.get(l);!p||c.entries[p]||d.has(p)||d.set(p,u)},persist(){if(d.size===0)return;let l=new Set(n.values()),u={};for(let[p,m]of Object.entries(c.entries))l.has(p)&&(u[p]=m);for(let[p,m]of d)u[p]=m;if(!(Object.keys(u).length>Ac))try{wc(vc(a),{recursive:!0});let p=`${a}.${process.pid}.tmp`;Ec(p,JSON.stringify({version:1,salt:s,entries:u})),Pc(p,a)}catch{}}}}function Mc(e,t){let r="";try{r=wr("git",["-C",e,"config","--get-regexp","^core\\.(autocrlf|eol|safecrlf)$"],{...Pr(),timeout:Rt})}catch{}return xc("sha256").update(JSON.stringify([r.trim(),t.sort()])).digest("hex")}function Cc(e,t){let r={version:1,salt:t,entries:{}};try{let n=R(e,{maxBytes:Fc,inputKind:"git-content-hash-store"}),i=JSON.parse(n);if(i.version!==1||i.salt!==t||!i.entries||typeof i.entries!="object")return r;let o={};for(let[s,a]of Object.entries(i.entries))/^[0-9a-f]{40,64}$/.test(s)&&a&&typeof a.size=="number"&&Number.isInteger(a.size)&&a.size>=0&&typeof a.hash=="string"&&/^[0-9a-f]{64}$/.test(a.hash)&&(o[s]={size:a.size,hash:a.hash});return{version:1,salt:t,entries:o}}catch{return r}}import{AsyncLocalStorage as Lc}from"async_hooks";var Tc=new Lc;function we(e,t){let r=vt(e);if(!r||r.missing.has(t))return;let n=r.files.get(t);if(n)return n;let i=r.readBaseFile?.(t);return i&&r.files.set(t,i),i}function Pe(e,t){let r=vt(e);if(r)return r.missing.has(t)?"missing":r.paths.includes(t)?"present":"missing"}function Gi(e,t){return vt(e)?.fingerprints.get(t)}function ue(e){return vt(e)?.paths}function vt(e){let t=Tc.getStore();if(t)return t.projectRoot===wn(e)?t:void 0}import{createRequire as Oc}from"module";import{existsSync as jc,readdirSync as _c,statSync as Gc}from"fs";import y from"path";var Nc=Oc(import.meta.url),Ni=new Set([".cache",".git",".next",".nuxt",".turbo",".nx","build","coverage","dist","node_modules","tmp","vendor"]);function Bc(e,t=[]){let r=y.resolve(e),n=t.flatMap(c=>$c(r,c));if(n.length>0)return Bi(r,$i(n));let i=qc(r),o=$i(i),s=zc(r,o)?[r,...o]:o,a=s.length>0?s:[r];return Bi(r,a)}function zi(e,t,r=[]){let n;try{n=Nc("ts-morph")}catch{return null}let i=y.resolve(e),o=t==="workspace"?Bc(i,r):["."],s=new Set;for(let a of o){let c=a==="."?i:y.join(i,a),d=y.join(c,"tsconfig.json"),l=Jc(n.ts,i);if(!l.fileExists(d))return null;let u=n.ts.readConfigFile(d,l.readFile);if(u.error)return null;let p=n.ts.parseJsonConfigFileContent(u.config,l,c);if(p.errors.length>0)return null;for(let m of p.fileNames){let g=y.resolve(m);O(i,g)&&s.add(y.relative(i,g).split(y.sep).join("/"))}}return s}function Bi(e,t){return[...new Set(t.map(r=>qe(e,r)))].sort((r,n)=>r.localeCompare(n))}function qc(e){let t=ue(e);if(t)return t.flatMap(i=>{if(i.split("/").some(s=>Ni.has(s)))return[];let o=y.join(e,...i.split("/"));return qi(e,o)?[y.dirname(o)]:[]});let r=[],n=[e];for(;n.length>0;){let i=n.pop(),o;try{o=_c(i,{withFileTypes:!0})}catch{continue}for(let s of o){let a=y.join(i,s.name);if(s.isDirectory()){!Ni.has(s.name)&&!s.name.startsWith(".")&&n.push(a);continue}s.isFile()&&qi(e,a)&&r.push(y.dirname(a))}}return r}function $c(e,t){let r=t.trim();if(!r)return[];let n=y.resolve(e,r);if(!O(e,n))return[];let i=ue(e);if(i){let o=qe(e,n);if(i.includes(o)&&Er(y.basename(n)))return[y.dirname(n)];let s=o==="."?"":`${o}/`;return i.some(a=>a.startsWith(s))?[n]:[]}try{let o=Gc(n);if(o.isDirectory())return[n];if(o.isFile()&&Er(y.basename(n)))return[y.dirname(n)]}catch{return[]}return[]}function qi(e,t){if(!Er(y.basename(t)))return!1;let r=Wi(e,t);return r?y.basename(t)==="tsconfig.json"||"include"in r||"files"in r||"references"in r:!1}function Er(e){return e.startsWith("tsconfig")&&e.endsWith(".json")}function $i(e){let t=[...new Set(e.map(r=>y.resolve(r)))].sort((r,n)=>r.localeCompare(n));return t.length<=1?t:t.filter(r=>!t.some(n=>n!==r&&Kc(r,n)))}function zc(e,t){if(t.length===0||t.some(n=>y.resolve(n)===e))return!1;let r=y.join(e,"tsconfig.json");return Hc(e,r)&&Wc(e,r)}function Wc(e,t){let n=Wi(e,t)?.include;return Array.isArray(n)?n.some(i=>typeof i=="string"&&i.trim()!==""&&!i.startsWith("!")&&(i.includes("/")||i.includes("**")||!y.extname(i))):!1}function Wi(e,t){try{let r=JSON.parse(Uc(e,t));return r&&typeof r=="object"&&!Array.isArray(r)?r:null}catch{return null}}function Hc(e,t){let r=qe(e,t),n=Pe(e,r);return n?n==="present":jc(t)}function Uc(e,t){let r=qe(e,t);if(ue(e)){let i=we(e,r);if(!i)throw Object.assign(new Error(`Snapshot file ${r} is missing.`),{code:"ENOENT"});return i.content.toString("utf8")}return S(t,"TypeScript project config")}function Jc(e,t){let r=ue(t);if(!r)return e.sys;let n=y.resolve(t),i=new Set(r),o=Vc(n,r),s=e,a=c=>{let d=y.resolve(c);return O(n,d)?qe(n,d):null};return{useCaseSensitiveFileNames:e.sys.useCaseSensitiveFileNames,fileExists(c){let d=a(c);return d===null?e.sys.fileExists(c):i.has(d)},readFile(c){let d=a(c);return d===null?e.sys.readFile(c):we(n,d)?.content.toString("utf8")},readDirectory(c,d,l,u,p){let m=y.resolve(c);return O(n,m)?s.matchFiles(m,d,l,u,e.sys.useCaseSensitiveFileNames,n,p,g=>o.get(y.resolve(g))??{files:[],directories:[]},g=>g):e.sys.readDirectory(c,d,l,u,p)}}}function Vc(e,t){let r=new Map,n=new Map,i=o=>{r.has(o)||r.set(o,new Set),n.has(o)||n.set(o,new Set)};i(e);for(let o of t){let s=o.split("/"),a=e;for(let c=0;c<s.length-1;c+=1){let d=s[c];i(a),n.get(a).add(d),a=y.join(a,d),i(a)}r.get(a).add(s.at(-1))}return new Map([...r].map(([o,s])=>[o,{files:[...s].sort(),directories:[...n.get(o)??[]].sort()}]))}function qe(e,t){let r=y.relative(e,t);return r?r.split(y.sep).join("/"):"."}function Kc(e,t){let r=y.relative(e,t);return!!r&&!r.startsWith("..")&&!y.isAbsolute(r)}var Dt=64*1024*1024,$e=class extends Error{constructor(r,n,i,o){super(`${r} ${JSON.stringify(n)} is ${i} bytes; the safety limit is ${o} bytes`);this.inputKind=r;this.inputPath=n;this.observedBytes=i;this.limitBytes=o;this.name="InputTooLargeError"}inputKind;inputPath;observedBytes;limitBytes;code="CODEBASEIQ_INPUT_TOO_LARGE"};function sd(e){return[...new Set((e??[]).map(t=>t.trim()).filter(Boolean))].sort((t,r)=>t.localeCompare(r))}function Ji(e,t,r={}){let n=j(t),i=kt(e),o=id(i,...n.split("/"));if(!O(i,o)||o===i)throw new v(t,"outside-project");let s=kt(o);if(!O(i,s)||s===i)throw new v(t,"outside-project");let a=Rr(s);if(!a.isFile())throw new v(t,"not-a-file");let c={projectRoot:i,relativePath:n,absolutePath:s,size:a.size,mtimeMs:a.mtimeMs,device:a.dev,inode:a.ino},d=r.maxBytes??Dt;if(Vi(d),c.size>d)throw new $e(r.inputKind??"project file",c.relativePath,c.size,d);return c}function ad(e,t,r={}){let n=j(t),i=Pe(e,n);if(i){if(i==="missing")throw Object.assign(new Error(`Snapshot project file ${JSON.stringify(n)} does not exist.`),{code:"ENOENT"});let c=we(e,n);if(!c)throw new v(n,"changed-during-read");let d=r.maxBytes??Dt;if(Vi(d),c.size>d)throw new $e(r.inputKind??"project file",n,c.size,d);return Buffer.from(c.content)}let o=Ji(e,t,r),s=r.maxBytes??Dt,a=Xc(o.absolutePath,"r");try{let c=Ui(a);if(!c.isFile()||c.dev!==o.device||c.ino!==o.inode||c.size!==o.size)throw new v(t,"changed-during-read");if(c.size>s)throw new $e(r.inputKind??"project file",o.relativePath,c.size,s);let d=ed(a),l=Ui(a);if(l.dev!==c.dev||l.ino!==c.ino||l.size!==c.size||d.byteLength!==c.size)throw new v(t,"changed-during-read");return d}finally{Yc(a)}}function Rf(e,t,r={}){return ad(e,t,r).toString("utf8")}function kr(e){return typeof e=="object"&&e!==null&&"code"in e&&(e.code==="ENOENT"||e.code==="ENOTDIR")}function vf(e,t){try{return Ji(e,t),!0}catch(r){if(kr(r))return!1;throw r}}function Vi(e){if(!Number.isSafeInteger(e)||e<0)throw new RangeError(`maxBytes must be a non-negative safe integer; received ${e}`)}function cd(e){return(ue(e)??fd(e)??gd(e)).filter(t=>t&&!Fr(t)).sort()}function dd(e,t={}){let r=(t.includePaths??[]).map(j),n=[...new Set([...cd(e),...r])].filter(c=>!Fr(c)).filter(c=>!t.language||qn(c,t.language,t.markerFiles)).filter(c=>!t.includePath||t.includePath(c)).sort(),i=kt(e),o,s=()=>o??=_i(i),a=n.flatMap(c=>{let d=Gi(e,c);if(d)return[{path:c,size:d.fingerprintSize??d.size,hash:d.sha256}];let l=Pe(e,c);if(l==="present"){let g=we(e,c);if(g)return[{path:c,size:g.fingerprintSize??g.size,hash:g.sha256}]}let u=l===void 0?s():null,p=u?.lookup(c);if(p)return[{path:c,size:p.size,hash:p.hash}];let m=vr(e,c);try{if(Rr(m).isSymbolicLink()){let ee=kt(m),Bt=nd(i,ee);if(Bt===".."||Bt.startsWith(`..${od}`)||rd(Bt))throw new Error("external symlink");let bn=td(m);return[{path:c,size:Buffer.byteLength(bn),hash:Hi("sha256").update("symlink\0").update(bn).digest("hex")}]}let g=Hi("sha256"),F=it(m,{inputKind:"project fingerprint input",maxBytes:Dt},ee=>g.update(ee)),x=g.digest("hex");return u?.seed(c,{size:F,hash:x}),[{path:c,size:F,hash:x}]}catch(g){return kr(g)?[]:[{path:c,size:-1,hash:"unreadable"}]}});return o?.persist(),a}function Dr(e,t,r){let n=Ft(t,r),i=[...n.typescriptProjects.filter(s=>ud(e,s)),...n.clojureConfigPath?[n.clojureConfigPath]:[]],o=n.languages.includes("typescript")?zi(e,n.typescriptProjectMode,n.typescriptProjects):null;return{...n,files:dd(e,{includePath:s=>{let a=Vt(s,t,i);return a==="other"?!1:a!=="source"||!ld(s)||!o?!0:o.has(s)},includePaths:i})}}function ld(e){return/\.(?:[cm]?[jt]sx?|vue)$/iu.test(e)}function ud(e,t){let r;try{r=j(t)}catch{return!1}let n=Pe(e,r);if(n)return n==="present";try{return Rr(vr(e,r)).isFile()}catch(i){if(kr(i))return!1;throw i}}function Ft(e,t){return{version:3,languages:[...e].sort(),pnpmWorkspaces:t.typescriptProjectMode!=="workspace"&&t.pnpmWorkspaces===!0,typescriptProjectMode:t.typescriptProjectMode??"single",typescriptProjects:sd(t.typescriptProjects),clojureConfigPath:pd(t.clojureConfigPath)}}function pd(e){return e?.trim()||void 0}function fd(e){try{return Qc("git",["-C",e,"ls-files","-co","--exclude-standard","--","."],{encoding:"utf-8",maxBuffer:50*1024*1024,stdio:["ignore","pipe","ignore"],windowsHide:!0,timeout:3e4,killSignal:"SIGKILL"}).split(`
84
- `).filter(Boolean)}catch{return null}}function gd(e){let t=[],r=[""];for(;r.length>0;){let n=r.pop(),i=n?vr(e,n):e,o;try{o=Zc(i,{withFileTypes:!0})}catch{continue}for(let s of o){let a=n?`${n}/${s.name}`:s.name;if(s.isDirectory()){Fr(a)||r.push(a);continue}t.push(a)}}return t}function Fr(e){let t=e.split("/");return e==="meta.json"||t[0]===".codebaseiq"&&(t[1]==="events"||t[1]==="ledger"||t[1]==="releases"||t[1]==="suppressions")||t.some(r=>md.has(r))||e.endsWith(".db")||e.endsWith(".db-wal")||e.endsWith(".db-shm")||e.endsWith(".scip")}var md=new Set([".git","node_modules",".codebaseiq-cache",".codebaseiq-generations",".stryker-tmp","dist","build","coverage",".next",".nuxt","target"]);import{execFileSync as yd}from"child_process";import{existsSync as hd,readdirSync as Qi}from"fs";import{extname as Yi,join as Xi}from"path";var Zi=new Set([".git",".hg",".svn",".idea",".vscode","node_modules","vendor","dist","build","target","bin","obj",".dart_tool",".gradle",".next",".venv","venv","__pycache__"]),Sd=[{language:"typescript",files:["tsconfig.json","tsconfig.base.json"],extensions:[".ts",".tsx",".mts",".cts"]},{language:"rust",files:["Cargo.toml"],extensions:[".rs"]},{language:"go",files:["go.mod"],extensions:[".go"]},{language:"java",files:["pom.xml","build.gradle","build.gradle.kts"],extensions:[".java"]},{language:"kotlin",files:["build.gradle.kts"],extensions:[".kt",".kts"]},{language:"scala",files:["build.sbt"],extensions:[".scala"]},{language:"clojure",files:["deps.edn","project.clj","bb.edn","shadow-cljs.edn"],extensions:[".clj",".cljs",".cljc"]},{language:"python",files:["pyproject.toml","setup.py","setup.cfg","Pipfile"],extensions:[".py",".pyi"]},{language:"ruby",files:["Gemfile"],extensions:[".rb"]},{language:"cpp",files:["compile_commands.json","CMakeLists.txt","Makefile"],extensions:[".cc",".cpp",".cxx",".hpp",".hh",".hxx"]},{language:"c",files:["compile_commands.json","CMakeLists.txt","Makefile"],extensions:[".c",".h"]},{language:"csharp",globs:["*.csproj","*.sln"],extensions:[".cs"]},{language:"vb",globs:["*.vbproj"],extensions:[".vb"]},{language:"dart",files:["pubspec.yaml"],extensions:[".dart"]},{language:"php",files:["composer.json"],extensions:[".php"]},{language:"javascript",files:["package.json"],extensions:[".js",".jsx",".mjs",".cjs"]}];function Ar(e){let t=[],r=bd(e),n=Pd(e);for(let i of Sd){if(Id(e,i.files)){t.push(i.language);continue}if(xd(r,i.globs)){t.push(i.language);continue}Rd(n,i.extensions)&&t.push(i.language)}return t.includes("typescript")&&Ki(t,"javascript"),t.includes("cpp")&&!n.has(".c")&&Ki(t,"c"),t}function bd(e){try{return Qi(e)}catch{return[]}}function Id(e,t){return t?.length?t.some(r=>hd(Xi(e,r))):!1}function xd(e,t){return t?.length?e.some(r=>t.some(n=>wd(r,n))):!1}function wd(e,t){if(t==="*")return!0;if(!t.includes("*"))return e===t;let[r,n]=t.split("*");return e.startsWith(r??"")&&e.endsWith(n??"")}function Pd(e){let t=Ed(e);if(t)return t;let r=new Set,n=[e];for(;n.length>0;){let i=n.pop();if(!i)continue;let o;try{o=Qi(i,{withFileTypes:!0})}catch{continue}for(let s of o){if(s.name.startsWith(".")&&!s.name.endsWith("proj")&&!s.name.endsWith("sln")&&s.isDirectory())continue;let a=Xi(i,s.name);if(s.isDirectory()){Zi.has(s.name)||n.push(a);continue}let c=Yi(s.name).toLowerCase();c&&r.add(c)}}return r}function Ed(e){try{let t=yd("git",["-C",e,"ls-files","-co","--exclude-standard","--","."],{encoding:"utf-8",maxBuffer:26214400,stdio:["ignore","pipe","ignore"],windowsHide:!0,timeout:3e4,killSignal:"SIGKILL"}),r=new Set;for(let n of t.split(`
85
- `)){if(!n||n.split("/").some(o=>Zi.has(o)))continue;let i=Yi(n).toLowerCase();i&&r.add(i)}return r}catch{return null}}function Rd(e,t){return t?.length?t.some(r=>e.has(r)):!1}function Ki(e,t){let r=e.indexOf(t);r!==-1&&e.splice(r,1)}import{lstatSync as Nd,readdirSync as Bd}from"fs";import{join as qd,relative as $d,resolve as Nr,sep as zd}from"path";import{createHash as vd}from"crypto";import{existsSync as ze,mkdirSync as kd,readdirSync as eo,renameSync as Dd,rmSync as to,writeFileSync as Fd}from"fs";import{join as U}from"path";import{create as no,fromBinary as io,toBinary as Ad}from"@bufbuild/protobuf";import{deserializeSCIP as At,DocumentSchema as Cr,IndexSchema as oo,serializeSCIP as so}from"@c4312/scip";var Mt=1,We="typescript-scip-fragments";function Nf(e){if(e.length===0)throw new Error("affected TypeScript mini index requires documents");let t=new Set,r=[];for(let o of e){let s=pe(o.relativePath);if(t.has(s))throw new Error(`duplicate TypeScript fragment replacement: ${s}`);if(t.add(s),o.bytes===null)throw new Error(`affected TypeScript mini index cannot contain a deleted document: ${s}`);let a=io(Cr,o.bytes);if(a.relativePath!==s)throw new Error(`TypeScript fragment path mismatch: expected ${s}, got ${a.relativePath}`);r.push(a)}let n=so(no(oo,{documents:r,externalSymbols:[]})),i=At(n);if(i.documents.length!==r.length||i.externalSymbols.length!==0)throw new Error("affected TypeScript SCIP index failed structural verification");return n}function He(e){let t=U(e,We);return{rootDir:t,blobDir:U(t,"blobs"),generationDir:U(t,"generations")}}function Md(e){let t=At(e.indexBytes);yo(t.metadata,ho(e)),mo(t.externalSymbols);let r=new Set,n=[];for(let o of t.documents){let s=pe(o.relativePath);if(r.has(s))throw new Error(`duplicate TypeScript SCIP document path: ${s}`);r.add(s);let a=Ad(Cr,o),c=e.documentIdentities.get(s)??(e.allowUntrackedDocuments?fe(JSON.stringify({version:1,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,untrackedDocument:s,contentHash:fe(a)})):null);if(!c)throw new Error(`missing TypeScript document identity: ${s}`);n.push(uo(e.cacheDir,{relativePath:s,bytes:a,occurrences:o.occurrences.length,symbols:o.symbols.length,referenceFragments:[]},c))}let i=po(e,n);return fo(e.cacheDir,i),i}function Bf(e){let t=He(e.cacheDir);if(!ze(Tr(t,e.generationIdentity)))return Md(e);let r=ao({cacheDir:e.cacheDir,generationIdentity:e.generationIdentity,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity});if(!e.allowUntrackedDocuments&&r.manifest.documents.length!==e.documentIdentities.size)throw new Error("TypeScript fragment generation document identities changed");for(let n of r.manifest.documents){let i=e.documentIdentities.get(n.relativePath);if(!(i===void 0&&e.allowUntrackedDocuments)&&i!==n.documentIdentity)throw new Error(`TypeScript fragment generation document identity changed: ${n.relativePath}`)}return r.manifest}function qf(e){let t=ao({cacheDir:e.cacheDir,generationIdentity:e.previousGenerationIdentity,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity}).manifest,r=new Map(t.documents.map(o=>[o.relativePath,o])),n=new Set;for(let o of e.fragments){let s=pe(o.relativePath);if(n.has(s))throw new Error(`duplicate TypeScript fragment replacement: ${s}`);if(n.add(s),!r.has(s))throw new Error(`TypeScript fragment replacement has no prior document: ${s}`);let a=e.documentIdentities.get(s);if(!a)throw new Error(`missing TypeScript document identity: ${s}`);o.bytes===null?r.delete(s):r.set(s,uo(e.cacheDir,o,a))}if(n.size===0)throw new Error("TypeScript fragment generation requires at least one replacement");let i=po(e,[...r.values()]);return fo(e.cacheDir,i),i}function ao(e){let t=He(e.cacheDir),r=Tr(t,e.generationIdentity),n;try{n=Lr(R(r,{maxBytes:A,inputKind:"TypeScript fragment manifest"}))}catch(o){throw new Error(`TypeScript fragment generation is unavailable: ${o instanceof Error?o.message:String(o)}`,{cause:o})}if(n.generationIdentity!==e.generationIdentity)throw new Error("TypeScript fragment generation identity does not match its manifest path");if(e.producerIdentity&&n.producerIdentity!==e.producerIdentity)throw new Error("TypeScript fragment producer identity changed");if(e.projectIdentity&&n.projectIdentity!==e.projectIdentity)throw new Error("TypeScript fragment project identity changed");let i=new Map;for(let o of n.documents){let s=U(t.blobDir,`${o.blobHash}.scipdoc`),a=D(s,{maxBytes:me,inputKind:"TypeScript fragment blob"});if(a.byteLength!==o.byteLength||fe(a)!==o.blobHash)throw new Error(`TypeScript fragment blob is corrupt: ${o.relativePath}`);i.set(o.relativePath,a)}return{manifest:n,fragments:i}}function co(e){let t=lo(e);return Mr(t.baseIndex,t.completeDocuments,"assembled")}function $f(e){let t=lo(e);return Cd(t.deletedAffectedPaths),{completeIndexBytes:Mr(t.baseIndex,t.completeDocuments,"assembled"),affectedIndexBytes:Mr(t.baseIndex,t.affectedDocuments,"affected")}}function lo(e){let t=At(e.baseIndexBytes);yo(t.metadata,ho(e)),mo(t.externalSymbols);let r=new Map;for(let a of e.fragments){let c=pe(a.relativePath);if(r.has(c))throw new Error(`duplicate TypeScript fragment replacement: ${c}`);r.set(c,a)}if(r.size===0)throw new Error("TypeScript index assembly requires at least one replacement");let n=new Set,i=[],o=[],s=[];for(let a of t.documents){let c=pe(a.relativePath);if(n.has(c))throw new Error(`duplicate TypeScript SCIP document path: ${c}`);n.add(c);let d=r.get(c);if(!d){i.push(a);continue}if(r.delete(c),d.bytes===null){s.push(c);continue}let l=io(Cr,d.bytes);if(l.relativePath!==c)throw new Error(`TypeScript fragment path mismatch: expected ${c}, got ${l.relativePath}`);i.push(l),o.push(l)}if(r.size>0)throw new Error(`TypeScript fragment replacement has no prior document: ${[...r.keys()].sort()[0]}`);return{baseIndex:t,completeDocuments:i,affectedDocuments:o,deletedAffectedPaths:s}}function Mr(e,t,r){let n=so(no(oo,{metadata:e.metadata,documents:t,externalSymbols:[]})),i=At(n);if(i.documents.length!==t.length||i.externalSymbols.length!==0)throw new Error(`${r} TypeScript SCIP index failed structural verification`);return n}function Cd(e){if(e.length>0)throw new Error(`affected TypeScript mini index cannot contain a deleted document: ${e[0]}`)}function zf(e,t){let r=He(e);if(!ze(r.generationDir))return;let n=new Set(t.map(s=>go(s))),i=eo(r.generationDir).filter(s=>s.endsWith(".json")),o=new Set;for(let s of i.filter(a=>n.has(a))){let a=Lr(R(U(r.generationDir,s),{maxBytes:A,inputKind:"TypeScript fragment manifest"}));for(let c of a.documents)o.add(`${c.blobHash}.scipdoc`)}for(let s of i)n.has(s)||to(U(r.generationDir,s),{force:!0});if(ze(r.blobDir))for(let s of eo(r.blobDir))o.has(s)||to(U(r.blobDir,s),{force:!0})}function uo(e,t,r){if(t.bytes===null)throw new Error(`cannot persist an empty TypeScript fragment: ${t.relativePath}`);let n=pe(t.relativePath),i=Buffer.from(t.bytes),o=fe(i),s=He(e);kd(s.blobDir,{recursive:!0});let a=U(s.blobDir,`${o}.scipdoc`);if(ze(a)){let c=D(a,{maxBytes:me,inputKind:"TypeScript fragment blob"});if(c.byteLength!==i.byteLength||fe(c)!==o)throw new Error(`existing TypeScript fragment blob is corrupt: ${n}`)}else{let c=`${a}.${process.pid}.${Date.now()}.tmp`;Fd(c,i),Dd(c,a)}return{relativePath:n,blobHash:o,byteLength:i.byteLength,documentIdentity:r}}function po(e,t){if(!e.producerIdentity||!e.projectIdentity||!e.generationIdentity)throw new Error("TypeScript fragment generation identities must be non-empty");let r=[...t].sort((n,i)=>n.relativePath.localeCompare(i.relativePath));if(new Set(r.map(n=>n.relativePath)).size!==r.length)throw new Error("TypeScript fragment generation contains duplicate document paths");return{version:Mt,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,generationIdentity:e.generationIdentity,createdAt:(e.now??(()=>new Date))().toISOString(),documents:r}}function fo(e,t){let r=He(e),n=Tr(r,t.generationIdentity);if(ze(n)){let i=Lr(R(n,{maxBytes:A,inputKind:"TypeScript fragment manifest"}));if(ro(i)!==ro(t))throw new Error(`TypeScript fragment generation is immutable: ${t.generationIdentity}`);return}V(n,t,{spacing:2,trailingNewline:!0})}function ro(e){return fe(JSON.stringify({version:e.version,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,generationIdentity:e.generationIdentity,documents:e.documents}))}function Lr(e){let t=JSON.parse(e);if(t.version!==Mt||typeof t.producerIdentity!="string"||typeof t.projectIdentity!="string"||typeof t.generationIdentity!="string"||typeof t.createdAt!="string"||!Number.isFinite(Date.parse(t.createdAt))||!Array.isArray(t.documents))throw new Error("invalid TypeScript fragment generation manifest");let r=new Set;for(let n of t.documents){if(!n||typeof n.relativePath!="string"||typeof n.blobHash!="string"||!/^[a-f0-9]{64}$/.test(n.blobHash)||typeof n.byteLength!="number"||!Number.isInteger(n.byteLength)||n.byteLength<0||typeof n.documentIdentity!="string"||!n.documentIdentity)throw new Error("invalid TypeScript fragment record");if(pe(n.relativePath),r.has(n.relativePath))throw new Error("duplicate TypeScript fragment record");r.add(n.relativePath)}return t}function Tr(e,t){return U(e.generationDir,go(t))}function go(e){if(!e)throw new Error("TypeScript fragment generation identity must be non-empty");return`${fe(e)}.json`}function mo(e){if(e.length>0)throw new Error("scip-typescript emitted external symbols; incremental document assembly is unsupported")}function yo(e,t){if(!e||typeof e!="object")throw new Error("TypeScript SCIP shard has no producer metadata");let r=e,n=r.toolInfo??r.tool_info;if(!n||typeof n!="object")throw new Error("TypeScript SCIP shard has no producer tool identity");let i=n;if(i.name!=="scip-typescript"||i.version!==t)throw new Error("TypeScript SCIP shard producer identity changed")}function ho(e){let t=e.packageVersion??e.runtime?.packageVersion;if(!t)throw new Error("scip-typescript package version is unavailable");return t}function pe(e){if(!e||e.startsWith("/")||e.startsWith("\\")||e.includes("\\"))throw new Error(`invalid TypeScript SCIP document path: ${e}`);let t=e.split("/");if(t.includes("")||t.includes(".")||t.includes(".."))throw new Error(`invalid TypeScript SCIP document path: ${e}`);return e}function fe(e){return vd("sha256").update(e).digest("hex")}import{createHash as Ld}from"crypto";import{existsSync as Ue,mkdirSync as Td,readdirSync as Or,renameSync as Od,rmSync as So,writeFileSync as jd}from"fs";import{join as G}from"path";var Ct=1,Yf=64*1024*1024,Ve="typescript-scip-overlays";function Xf(e){let t=Io(e.cacheDir,e.previousGenerationIdentity);if(!t&&!e.baseShardCurrent)throw new Error("deferred TypeScript SCIP base has no matching overlay generation");if(t&&(t.producerIdentity!==e.producerIdentity||t.projectIdentity!==e.projectIdentity))throw new Error("TypeScript overlay producer or project identity changed");let r=new Map((t?.overlays??[]).map(o=>[o.relativePath,o])),n=new Set;for(let o of e.fragments){let s=Gr(o.relativePath);if(n.has(s))throw new Error(`duplicate TypeScript overlay: ${s}`);n.add(s),r.set(s,_d(e.cacheDir,o))}if(n.size===0)throw new Error("TypeScript overlay generation requires affected documents");let i={version:Ct,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,baseGenerationIdentity:t?.baseGenerationIdentity??e.previousGenerationIdentity,generationIdentity:e.nextGenerationIdentity,createdAt:(e.now??(()=>new Date))().toISOString(),overlays:[...r.values()].sort((o,s)=>o.relativePath.localeCompare(s.relativePath))};return Gd(e.cacheDir,i),i}function Zf(e){let t=Io(e.cacheDir,e.generationIdentity);if(!t)throw new Error("TypeScript overlay generation is unavailable");let r=t.overlays.map(n=>{if(n.blobHash===null)return{relativePath:n.relativePath,bytes:null,occurrences:0,symbols:0,referenceFragments:[]};let i=D(G(Ke(e.cacheDir),"blobs",`${n.blobHash}.scipdoc`),{maxBytes:me,inputKind:"TypeScript overlay blob"});if(i.byteLength!==n.byteLength||Je(i)!==n.blobHash)throw new Error(`TypeScript overlay blob is corrupt: ${n.relativePath}`);return{relativePath:n.relativePath,bytes:i,occurrences:0,symbols:0,referenceFragments:[]}});return co({packageVersion:e.packageVersion,baseIndexBytes:e.baseIndexBytes,fragments:r})}function eg(e,t){let r=Ke(e),n=G(r,"generations");if(!Ue(n))return;let i=new Set(t.map(_r)),o=new Set;for(let a of Or(n).filter(c=>i.has(c))){let c=jr(R(G(n,a),{maxBytes:A,inputKind:"TypeScript overlay manifest"}));for(let d of c.overlays)d.blobHash&&o.add(`${d.blobHash}.scipdoc`)}for(let a of Or(n))i.has(a)||So(G(n,a),{force:!0});let s=G(r,"blobs");if(Ue(s))for(let a of Or(s))o.has(a)||So(G(s,a),{force:!0})}function Io(e,t){let r=G(Ke(e),"generations",_r(t));if(!Ue(r))return null;let n=jr(R(r,{maxBytes:A,inputKind:"TypeScript overlay manifest"}));if(n.generationIdentity!==t)throw new Error("TypeScript overlay generation identity does not match its path");return n}function _d(e,t){let r=Gr(t.relativePath);if(t.bytes===null)return{relativePath:r,blobHash:null,byteLength:0};let n=Buffer.from(t.bytes),i=Je(n),o=G(Ke(e),"blobs");Td(o,{recursive:!0});let s=G(o,`${i}.scipdoc`);if(Ue(s)){let a=D(s,{maxBytes:me,inputKind:"TypeScript overlay blob"});if(a.byteLength!==n.byteLength||Je(a)!==i)throw new Error(`existing TypeScript overlay blob is corrupt: ${r}`)}else{let a=`${s}.${process.pid}.${Date.now()}.tmp`;jd(a,n),Od(a,s)}return{relativePath:r,blobHash:i,byteLength:n.byteLength}}function Gd(e,t){let r=G(Ke(e),"generations",_r(t.generationIdentity));if(Ue(r)){let n=jr(R(r,{maxBytes:A,inputKind:"TypeScript overlay manifest"}));if(bo(n)!==bo(t))throw new Error(`TypeScript overlay generation is immutable: ${t.generationIdentity}`);return}V(r,t,{spacing:2,trailingNewline:!0})}function jr(e){let t=JSON.parse(e);if(t.version!==Ct||typeof t.producerIdentity!="string"||!t.producerIdentity||typeof t.projectIdentity!="string"||!t.projectIdentity||typeof t.baseGenerationIdentity!="string"||!t.baseGenerationIdentity||typeof t.generationIdentity!="string"||!t.generationIdentity||typeof t.createdAt!="string"||!Number.isFinite(Date.parse(t.createdAt))||!Array.isArray(t.overlays))throw new Error("invalid TypeScript overlay manifest");let r=new Set;for(let n of t.overlays){if(!n||typeof n.relativePath!="string"||n.blobHash!==null&&(typeof n.blobHash!="string"||!/^[a-f0-9]{64}$/.test(n.blobHash))||!Number.isInteger(n.byteLength)||n.byteLength<0||n.blobHash===null&&n.byteLength!==0)throw new Error("invalid TypeScript overlay record");if(Gr(n.relativePath),r.has(n.relativePath))throw new Error("duplicate TypeScript overlay record");r.add(n.relativePath)}return t}function Ke(e){return G(e,Ve)}function _r(e){if(!e)throw new Error("TypeScript overlay generation identity must be non-empty");return`${Je(e)}.json`}function bo(e){return Je(JSON.stringify({version:e.version,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,baseGenerationIdentity:e.baseGenerationIdentity,generationIdentity:e.generationIdentity,overlays:e.overlays}))}function Gr(e){if(!e||e.startsWith("/")||e.includes("\\")||e.split("/").some(t=>!t||t==="."))throw new Error(`invalid TypeScript overlay path: ${e}`);if(e.split("/").includes(".."))throw new Error(`invalid TypeScript overlay path: ${e}`);return e}function Je(e){return Ld("sha256").update(e).digest("hex")}var Qe=1,Br="language-indexes",xo=["index.db","index.scip","meta.json"],wo=[Br,We,Ve];function Lt(e){let t=[];for(let r of xo)Wd(e,r),t.push(r);for(let r of wo)Po(e,r,t);return{version:Qe,files:t.sort()}}function Tt(e){if(!e||e.includes("\0")||e.startsWith("/")||e.includes("\\"))throw new Error(`invalid index artifact path: ${e||"<empty>"}`);let t=e.split("/");if(t.some(n=>!n||n==="."||n===".."))throw new Error(`invalid index artifact path: ${e}`);let r=t[0];if(!xo.includes(e)&&!wo.includes(r))throw new Error(`index artifact path is not shareable: ${e}`);return e}function z(e,t){let r=Tt(t),n=Nr(e),i=Nr(n,...r.split("/"));if(i!==n&&!i.startsWith(`${n}${zd}`))throw new Error(`index artifact escapes cache: ${t}`);return i}function Po(e,t,r){let n=qd(e,t),i;try{i=Bd(n,{withFileTypes:!0,encoding:"utf8"})}catch{return}for(let o of i){let s=`${t}/${o.name}`;if(o.isSymbolicLink())throw new Error(`index artifact cannot be a symlink: ${s}`);o.isDirectory()?Po(e,s,r):o.isFile()&&r.push(Tt(s))}}function Wd(e,t){let r=z(e,t),n;try{n=Nd(r)}catch{throw new Error(`required index artifact is missing: ${t}`)}if(!n.isFile()||n.isSymbolicLink())throw new Error(`required index artifact is not a regular file: ${t}`);if($d(Nr(e),r).startsWith(".."))throw new Error(`index artifact escapes cache: ${t}`)}import{writeFileSync as $r}from"fs";import{create as Ee}from"@bufbuild/protobuf";import{deserializeSCIP as zr,serializeSCIP as Wr,DocumentSchema as Yd,IndexSchema as Ro,MetadataSchema as vo,SymbolInformationSchema as Xd}from"@c4312/scip";import{writeFileSync as Hd}from"fs";import{create as Eo}from"@bufbuild/protobuf";import{deserializeSCIP as Ud,DocumentSchema as Jd,IndexSchema as Vd,serializeSCIP as Kd,SymbolRole as Qd}from"@c4312/scip";function pg(e){let t;try{t=Ud(D(e,{inputKind:"SCIP sanitization input",maxBytes:L}))}catch{return{removedDefinitionOccurrences:0,touchedDocuments:0}}let r=qr(t);return r.touchedDocuments>0&&Hd(e,Buffer.from(Kd(r.index))),{removedDefinitionOccurrences:r.removedDefinitionOccurrences,touchedDocuments:r.touchedDocuments}}function qr(e){let t=new Set,r=new Map;for(let s of e.documents){r.set(s,j(s.relativePath));for(let a of s.symbols)a.symbol&&t.add(a.symbol)}for(let s of e.externalSymbols)s.symbol&&t.add(s.symbol);let n=0,i=0,o=[];for(let s of e.documents){let a=r.get(s),c=s.occurrences.filter(d=>(d.symbolRoles&Qd.Definition)===0||t.has(d.symbol)?!0:(n+=1,!1));if(a===s.relativePath&&c.length===s.occurrences.length){o.push(s);continue}i+=1,o.push(Eo(Jd,{language:s.language,relativePath:a,occurrences:c,symbols:s.symbols,text:s.text,positionEncoding:s.positionEncoding}))}return{index:i===0?e:Eo(Vd,{metadata:e.metadata,documents:o,externalSymbols:e.externalSymbols}),removedDefinitionOccurrences:n,touchedDocuments:i}}function ko(e){if(e.length===0)throw new Error("Cannot merge zero SCIP indexes");if(e.length===1)return e[0];let t=el(e),r=tl(e.flatMap(i=>i.documents??[])),n=Fo(e.flatMap(i=>i.externalSymbols??[]));return Ee(Ro,{metadata:t,documents:r,externalSymbols:n})}function Ig(e,t){if(e.length===0)throw new Error("Cannot merge zero SCIP files");let r=e.map(i=>zr(D(i,{inputKind:"SCIP merge input",maxBytes:L}))),n=ko(r);return $r(t,Buffer.from(Wr(n))),{documentCount:n.documents.length,externalSymbolCount:n.externalSymbols.length,inputCount:e.length}}function xg(e,t){if(e.length===0)throw new Error("Cannot merge zero SCIP files");let r=e.map(i=>zr(D(i,{inputKind:"SCIP merge input",maxBytes:L}))),n=qr(ko(r));return $r(t,Buffer.from(Wr(n.index))),{documentCount:n.index.documents.length,externalSymbolCount:n.index.externalSymbols.length,inputCount:e.length,removedDefinitionOccurrences:n.removedDefinitionOccurrences,touchedDocuments:n.touchedDocuments}}function Zd(e,t,r){let n=e.metadata;if(!n)throw new Error("Cannot rebase a SCIP index without metadata");if(!be(n.projectRoot,t))throw new Error(`Cannot rebase SCIP project root: expected ${t}, got ${n.projectRoot}`);return Ee(Ro,{metadata:Ee(vo,{...n,projectRoot:r}),documents:e.documents,externalSymbols:e.externalSymbols})}function Do(e,t,r){let n=zr(D(e,{inputKind:"SCIP normalization input",maxBytes:L})),i=Zd(n,t,r);$r(e,Buffer.from(Wr(i)))}function el(e){let t=e[0]?.metadata;if(!t)return;let r=t.projectRoot;for(let i of e.slice(1)){let o=i.metadata?.projectRoot;if(r&&o&&!be(o,r))throw new Error(`Cannot merge SCIP indexes with different project roots: ${r} vs ${o}`)}let n=r&&st(r);return n===r?t:Ee(vo,{...t,projectRoot:n})}function tl(e){let t=new Map;for(let r of e){let n=t.get(r.relativePath);if(!n){t.set(r.relativePath,r);continue}t.set(r.relativePath,Ee(Yd,{language:n.language||r.language,relativePath:n.relativePath||r.relativePath,occurrences:rl([...n.occurrences,...r.occurrences]),symbols:Fo([...n.symbols,...r.symbols]),text:il(n.text,r.text),positionEncoding:n.positionEncoding||r.positionEncoding}))}return[...t.values()]}function rl(e){let t=new Set,r=[];for(let n of e){let i=JSON.stringify(n);t.has(i)||(t.add(i),r.push(n))}return r}function Fo(e){let t=new Map;for(let r of e){let n=t.get(r.symbol);if(!n){t.set(r.symbol,r);continue}t.set(r.symbol,Ee(Xd,{symbol:n.symbol,documentation:ol([...n.documentation,...r.documentation]),relationships:nl([...n.relationships,...r.relationships]),kind:n.kind||r.kind,displayName:n.displayName||r.displayName,enclosingSymbol:n.enclosingSymbol||r.enclosingSymbol,signatureDocumentation:n.signatureDocumentation??r.signatureDocumentation}))}return[...t.values()]}function nl(e){let t=new Set,r=[];for(let n of e){let i=[n.symbol,n.isReference?"1":"0",n.isImplementation?"1":"0",n.isTypeDefinition?"1":"0",n.isDefinition?"1":"0"].join("|");t.has(i)||(t.add(i),r.push(n))}return r}function il(e,t){return e?t?e.length>=t.length?e:t:e:t}function ol(e){return[...new Set(e)]}import{createHash as Qr}from"crypto";import{closeSync as sl,existsSync as b,mkdirSync as al,openSync as cl,readSync as dl,readdirSync as Yr,renameSync as Vr,rmSync as Ye,statSync as Re}from"fs";import{basename as Lo,dirname as W,join as h,relative as Ao}from"path";var Kr=Object.freeze({maxGenerations:2,maxLogicalBytes:2*1024*1024*1024});function To(e){let t=P(e.outputDb),r=gl(e);e.onStage?.("after-recovery-retained");let n=e.preserveOutputScip?e.outputScip:e.tempOutputScip,i=en({generationRoot:t,databasePath:e.tempOutputDb,indexPath:b(n)?n:void 0,metadataPath:b(e.tempMetaPath)?e.tempMetaPath:void 0}),o=(e.now??(()=>new Date))().toISOString(),s={version:le,currentGeneration:i.identity,artifactSet:"immutable-v1",...r?{previousGeneration:r}:{},...e.publication?{publication:e.publication}:{},publishedAt:o},a=B(h(t,"state.json"),s,{spacing:2,trailingNewline:!0});e.onStage?.("after-pointer-handoff"),e.preserveOutputScip||Jr(e.tempOutputScip,e.outputScip),e.onStage?.("after-scip-handoff"),Jr(e.tempOutputDb,e.outputDb),e.onStage?.("after-database-handoff"),Jr(e.tempMetaPath,e.metaPath),e.onStage?.("after-metadata-handoff");let c=i.identity,d={...s,stableMirrors:Zr(e.outputDb,e.outputScip)};B(h(t,"state.json"),d,{spacing:2,trailingNewline:!0});let l=Oo(e.outputDb,{now:e.now}),u=E(i.directorySync,a.directorySync);return{currentGeneration:c,...r?{previousGeneration:r}:{},retention:l,achievedDurability:u==="synced"?"directory-durable":"file-flushed",directorySync:u}}function ll(e,t,r,n=()=>new Date){if(!b(e))return null;let i=$(e),o=h(P(e),"state.json");if(i?.artifactSet==="immutable-v1"&&Ge(e,i.currentGeneration))return i;let s=P(e),a=!i&&b(o)?yl(r,e,t):void 0;if(a&&!Ne(s,a))return null;let c=en({generationRoot:s,databasePath:e,indexPath:b(t)?t:void 0,metadataPath:b(r)?r:void 0,forcedIdentity:i?.currentGeneration??a}),d={version:le,currentGeneration:c.identity,artifactSet:"immutable-v1",stableMirrors:Zr(e,t),...i?.previousGeneration?{previousGeneration:i.previousGeneration}:{},...i?.publication?{publication:i.publication}:{},publishedAt:i?.publishedAt??n().toISOString()};return B(h(s,"state.json"),d,{spacing:2,trailingNewline:!0}),d}function Tg(e,t,r=()=>new Date){if(!b(e)||!b(t))throw new Error("metadata-only generation refresh requires stable database and metadata files");let n=$(e),i=P(e),o=en({generationRoot:i,databasePath:e,indexPath:b(h(W(e),"index.scip"))?h(W(e),"index.scip"):void 0,metadataPath:t}),s=n&&n.currentGeneration!==o.identity?Go(e,n.currentGeneration):void 0,a={version:le,currentGeneration:o.identity,artifactSet:"immutable-v1",stableMirrors:Zr(e,h(W(e),"index.scip")),...s?{previousGeneration:s}:{},...n?.publication?{publication:n.publication}:{},publishedAt:r().toISOString()};return B(h(P(e),"state.json"),a,{spacing:2,trailingNewline:!0}),Oo(e,{now:r}),a}function Oo(e,t={}){let r=ul(t.limits),i=(t.now??(()=>new Date))().toISOString(),o=q(_e(e),{waitMs:0});if(!o)return{state:"deferred",generationCount:0,logicalBytes:0,protectedGenerations:0,activeReaderLeases:0,staleReaderLeasesRemoved:0,malformedReaderLeases:0,removedGenerations:0,removedLogicalBytes:0,limits:r,at:i,reason:"another process owns local generation retention"};try{let s=$(e),a=jo(e),c=gr(e,a.map(x=>x.identity),{isProcessAlive:t.isProcessAlive??te,readProcessIdentity:t.readProcessIdentity??ne}),d=new Set(c.protectedGenerations);s?.currentGeneration&&d.add(s.currentGeneration),s?.previousGeneration?.generationIdentity&&d.add(s.previousGeneration.generationIdentity);let l=a.length,u=a.reduce((x,ee)=>x+ee.logicalBytes,0),p=0,m=0;for(let x of a){if(l<=r.maxGenerations&&u<=r.maxLogicalBytes)break;d.has(x.identity)||(t.onBeforeRemove?.(x.identity),Ye(x.path,{recursive:!0,force:!0}),l-=1,u-=x.logicalBytes,p+=1,m+=x.logicalBytes)}let g=l>r.maxGenerations||u>r.maxLogicalBytes,F={state:g?"protected":p>0?"collected":"within-bounds",generationCount:l,logicalBytes:u,protectedGenerations:d.size,activeReaderLeases:c.activeLeases,staleReaderLeasesRemoved:c.staleLeasesRemoved,malformedReaderLeases:c.malformedLeases,removedGenerations:p,removedLogicalBytes:m,limits:r,at:i,...g?{reason:c.malformedLeases>0?"malformed reader ownership evidence fails closed":"retention bounds cannot be met without deleting a protected generation"}:{}};return Mo(e,F),F}catch(s){let a={state:"error",generationCount:0,logicalBytes:0,protectedGenerations:0,activeReaderLeases:0,staleReaderLeasesRemoved:0,malformedReaderLeases:0,removedGenerations:0,removedLogicalBytes:0,limits:r,at:i,reason:s instanceof Error?s.message:String(s)};try{Mo(e,a)}catch{}return a}finally{o.release()}}function Og(e){let t=P(e);if(!b(t))return{state:"absent",generationCount:0,logicalBytes:0,protectedGenerations:0,activeReaderLeases:0,malformedReaderLeases:0,limits:{...Kr},reason:"local immutable generation store does not exist"};let r=pl(e),n=r?.limits??{...Kr},i=q(_e(e),{waitMs:0});if(!i)return{state:"deferred",generationCount:r?.generationCount??0,logicalBytes:r?.logicalBytes??0,protectedGenerations:r?.protectedGenerations??0,activeReaderLeases:r?.activeReaderLeases??0,malformedReaderLeases:r?.malformedReaderLeases??0,limits:n,...r?{lastCollection:r}:{},reason:"another process owns local generation retention"};try{let o=jo(e),s=$(e),a=gr(e,o.map(d=>d.identity),{isProcessAlive:te,readProcessIdentity:ne},{removeStale:!1}),c=new Set(a.protectedGenerations);return s?.currentGeneration&&c.add(s.currentGeneration),s?.previousGeneration?.generationIdentity&&c.add(s.previousGeneration.generationIdentity),{state:"managed",generationCount:o.length,logicalBytes:o.reduce((d,l)=>d+l.logicalBytes,0),...o[0]?{oldestGenerationAt:new Date(o[0].modifiedAtMs).toISOString()}:{},protectedGenerations:c.size,activeReaderLeases:a.activeLeases,malformedReaderLeases:a.malformedLeases,limits:n,...r?{lastCollection:r}:{},...a.malformedLeases>0?{reason:"malformed reader ownership evidence prevents unsafe collection"}:{}}}catch(o){return{state:"error",generationCount:0,logicalBytes:0,protectedGenerations:0,activeReaderLeases:0,malformedReaderLeases:0,limits:n,...r?{lastCollection:r}:{},reason:o instanceof Error?o.message:String(o)}}finally{i.release()}}function ul(e={}){let t={...Kr,...e};if(!Number.isSafeInteger(t.maxGenerations)||t.maxGenerations<2)throw new Error("Local SQLite generation retention must keep at least current and previous generations.");if(!Number.isSafeInteger(t.maxLogicalBytes)||t.maxLogicalBytes<=0)throw new Error("Local SQLite generation byte retention must be a positive safe integer.");return t}function jo(e){let t=P(e);return b(t)?Yr(t,{withFileTypes:!0}).filter(r=>r.isDirectory()&&/^[a-f0-9]{64}$/.test(r.name)).map(r=>{let n=h(t,r.name),i=Ne(t,r.name),o=i?i.database.size+(i.index?.size??0)+(i.metadata?.size??0):_o(n);return{identity:r.name,path:n,logicalBytes:o,modifiedAtMs:Re(n).mtimeMs}}).sort((r,n)=>r.modifiedAtMs-n.modifiedAtMs||r.identity.localeCompare(n.identity)):[]}function _o(e){let t=0;for(let r of Yr(e,{withFileTypes:!0})){let n=h(e,r.name);r.isDirectory()?t+=_o(n):r.isFile()&&(t+=Re(n).size)}return t}function Mo(e,t){V(h(P(e),"gc.json"),t,{spacing:2,trailingNewline:!0})}function pl(e){try{let t=JSON.parse(S(h(P(e),"gc.json"),"local SQLite generation GC status"));return!t||t.state!=="within-bounds"&&t.state!=="collected"&&t.state!=="protected"&&t.state!=="deferred"&&t.state!=="error"||!Number.isSafeInteger(t.generationCount)||t.generationCount<0||!Number.isFinite(t.logicalBytes)||t.logicalBytes<0||!Number.isFinite(Date.parse(t.at))?void 0:t}catch{return}}function Xr(e,t=h(W(e),"meta.json")){let r=h(P(e),"state.json");if(!b(r))return{state:"legacy",statePath:r};let n=$(e);if(!n)return{state:"invalid",statePath:r,reason:"generation state is malformed"};try{let i=Ge(e,n.currentGeneration),o=i!==null,s=i?fl(e,t,i,n):!1,a=n.previousGeneration?b(h(W(e),n.previousGeneration.databasePath)):!0;return!s||!o||!a?{state:"drifted",statePath:r,currentMatches:s,recoveryExists:a,generation:n,reason:o?s?"retained recovery database is missing":"stable database or metadata no longer matches the published generation":"published immutable generation is missing"}:{state:"current",statePath:r,currentMatches:s,recoveryExists:a,generation:n}}catch(i){return{state:"drifted",statePath:r,currentMatches:!1,recoveryExists:!1,generation:n,reason:i instanceof Error?i.message:String(i)}}}function fl(e,t,r,n){if(n.stableMirrors&&(n.stableMirrors.databaseFileIdentity!==H(e)||n.stableMirrors.indexFileIdentity!==void 0&&n.stableMirrors.indexFileIdentity!==H(h(W(e),"index.scip")))||!Co(e,r.database))return!1;let i=h(W(e),"index.scip");if(r.index&&!Co(i,r.index))return!1;if(!r.metadata)return!b(t);if(!b(t))return!1;let o=h(P(e),r.identity,r.metadata.file);return b(o)&&K(S(t,"reindex metadata"))===K(S(o,"immutable reindex metadata"))}function Co(e,t){return b(e)&&Re(e).isFile()&&Re(e).size===t.size}function gl(e){let t=ll(e.outputDb,e.outputScip,e.metaPath);return t?Go(e.outputDb,t.currentGeneration):void 0}function Zr(e,t){return{databaseFileIdentity:H(e),...b(t)?{indexFileIdentity:H(t)}:{}}}function Go(e,t){let r=h(P(e),t),n=h(r,Lo(e)),i=h(r,"meta.json");return{generationIdentity:t,databasePath:Ao(W(e),n),...b(i)?{metadataPath:Ao(W(e),i)}:{}}}function ml(e){if(b(e)){for(let t of Yr(e,{withFileTypes:!0}))if(t.isDirectory()&&t.name.endsWith(".tmp"))try{Ye(h(e,t.name),{recursive:!0,force:!0})}catch{}}}function yl(e,t,r=h(W(t),"index.scip")){let n=Qr("sha256").update("sqlite-generation-artifacts-v1\0");return n.update(Ot(t)),b(r)&&n.update(`\0${Ot(r)}`),b(e)&&n.update(`\0${K(S(e,"reindex metadata"))}`),n.digest("hex")}function en(e){let t=Hr(e.databasePath),r=e.indexPath?Hr(e.indexPath):void 0,n=e.metadataPath?Hr(e.metadataPath):void 0,i=e.forcedIdentity??hl(t,r,e.metadataPath),o=h(e.generationRoot,i),s=h(o,xt);if(b(s)){let d=Ne(e.generationRoot,i);if(d&&No(o,d.database,t)&&bl(o,d.index,r)&&Il(o,d.metadata,e.metadataPath))return{identity:i,directorySync:I(e.generationRoot)};throw new Error(`SQLite generation ${i} already exists with different or corrupt artifacts.`)}let a=[M(e.generationRoot)];ml(e.generationRoot);let c=`${o}.${process.pid}.${Date.now()}.tmp`;Ye(c,{recursive:!0,force:!0}),al(c,{recursive:!0});try{a.push(Ur(e.databasePath,h(c,t.file))),r&&e.indexPath&&a.push(Ur(e.indexPath,h(c,r.file))),n&&e.metadataPath&&a.push(Ur(e.metadataPath,h(c,n.file)));let d=B(h(c,xt),{version:fr,identity:i,database:t,...r?{index:r}:{},...n?{metadata:n}:{}},{spacing:2,trailingNewline:!0});d.directorySync!=="not-requested"&&a.push(d.directorySync),a.push(I(c)),k(()=>Vr(c,o)),a.push(I(e.generationRoot))}finally{try{Ye(c,{recursive:!0,force:!0})}catch{}}return{identity:i,directorySync:E(...a)}}function hl(e,t,r){let n=Qr("sha256").update("sqlite-generation-artifacts-v1\0");return n.update(e.sha256),t&&n.update(`\0${t.sha256}`),r&&n.update(`\0${K(S(r,"reindex metadata"))}`),n.digest("hex")}function Hr(e){return{file:Lo(e),size:Re(e).size,sha256:Ot(e)}}function Ot(e){let t=Qr("sha256"),r=cl(e,"r"),n=Buffer.allocUnsafe(1024*1024);try{for(;;){let i=Sl(r,n);if(i===0)break;t.update(n.subarray(0,i))}}finally{sl(r)}return t.digest("hex")}function Sl(e,t){let r=0;for(;r<t.length;){let n=dl(e,t,r,t.length-r,null);if(r+=n,n===0)break}return r}function Ur(e,t){return Le(e,t,{mode:292})}function No(e,t,r){let n=h(e,t.file);return t.file===r.file&&t.size===r.size&&t.sha256===r.sha256&&b(n)&&Re(n).size===t.size&&Ot(n)===t.sha256}function bl(e,t,r){return!t||!r?t===r:No(e,t,r)}function Il(e,t,r){if(!t||!r)return t===void 0&&r===void 0;let n=h(e,t.file);return b(n)&&K(S(n,"stored reindex metadata"))===K(S(r,"candidate reindex metadata"))}function Jr(e,t){k(()=>Ye(`${t}.tmp-replace`,{force:!0})),k(()=>Vr(e,`${t}.tmp-replace`)),k(()=>Vr(`${t}.tmp-replace`,t))}var an=1,qo="CODEBASEIQ_SHARED_CACHE",El=2,jt=JSON.stringify({cliVersion:ot,artifactCatalogVersion:Qe,postIndexAugmentationSchemaVersion:El,sqliteGenerationStoreVersion:le,typescriptFragmentStoreVersion:Mt,typescriptOverlayStoreVersion:Ct}),cn="manifest.json",Rl="shared-cache.json",dn=[Br,We,Ve];function nn(e,t){if(!e.clean||!e.treeOid)return;let r=Zo(JSON.stringify({version:an,repositoryId:e.repositoryId,treeOid:e.treeOid,fingerprint:t,producerIdentity:jt}));return{repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:e.projectRoot,treeOid:e.treeOid,fingerprint:t,producerIdentity:jt,generationId:r,repositoryCacheDir:ft(e.repositoryId)}}function Vo(e,t,r){if(process.env[qo]==="0")return`${qo}=0`;if(!Ht(r))return"explicit cache or database override";if(Jt(rn(t))!==Jt(pt(e))||t!==f(rn(t),"index.db"))return"index database is outside the managed worktree cache"}function lm(e,t,r){if(!Ht(t))return;let n=r??Ae(e);return n?f(ft(n.repositoryId),"evidence.db"):void 0}function X(e,t=!0){let r=pn(e),n;try{n=Qo(R(f(r,cn),{inputKind:"shared-generation manifest",maxBytes:A}))}catch{return null}if(n.generationId!==e.generationId||n.repositoryId!==e.repositoryId||n.treeOid!==e.treeOid||n.producerIdentity!==e.producerIdentity||JSON.stringify(n.fingerprint)!==JSON.stringify(e.fingerprint))return null;if(!t)return n;try{for(let i of n.artifacts){let o=z(r,i.path),s=Gt(o);if(!s.isFile()||s.size!==i.size||ye(o,{inputKind:"shared-generation artifact",maxBytes:L})!==i.sha256)return null}}catch{return null}return n}function um(e,t,r){if(!e.treeOid)return null;let n=Ft(t,r),i=f(ut(),"repositories",e.repositoryId),o;try{let c=tn(i);if(!c.isDirectory()||c.isSymbolicLink())return null;o=Uo(i)}catch{return null}let s=f(o,"generations"),a=[];try{for(let c of Ho(s)){if(!/^[a-f0-9]{64}$/.test(c))continue;let d=f(s,c),l;try{l=tn(d)}catch{continue}if(!(!l.isDirectory()||l.isSymbolicLink()))try{let u=Qo(R(f(d,cn),{inputKind:"shared-generation baseline manifest",maxBytes:A}));u.generationId===c&&u.repositoryId===e.repositoryId&&u.treeOid===e.treeOid&&u.producerIdentity===jt&&Fl(u.fingerprint,n)&&a.push(u)}catch{continue}}}catch{return null}a.sort((c,d)=>Date.parse(d.createdAt)-Date.parse(c.createdAt)||c.generationId.localeCompare(d.generationId));for(let c of a){let d={repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:e.projectRoot,treeOid:e.treeOid,fingerprint:c.fingerprint,producerIdentity:c.producerIdentity,generationId:c.generationId,repositoryCacheDir:o},l=X(d);if(l)return{snapshot:d,manifest:l}}return null}function Ko(e){let t=q(f(e.snapshot.repositoryCacheDir,"locks",`${e.snapshot.generationId}.publish.lock`));if(!t)throw new Error(`shared generation publication is already in progress for ${e.snapshot.generationId}`);try{return vl(e)}finally{t.release()}}function vl(e){let t=X(e.snapshot);if(t)return $o(e.snapshot,t);if(!et(e.sourceCacheDir,e.sourceProjectRoot,e.snapshot.fingerprint))throw new Error("source index is incomplete, incompatible, or corrupt");let r=zo(e.sourceCacheDir);if(!r)throw new Error("source index artifacts are incomplete");let n=Lt(e.sourceCacheDir),i=f(e.snapshot.repositoryCacheDir,"generations"),o=[M(i)],s=nr(f(i,`.tmp-${process.pid}-`));try{let a=[];for(let g of n.files){let F=z(e.sourceCacheDir,g),x=z(s,g);o.push(tt(F,x,292)),e.onPublicationStage?.("after-artifact-flushed",g);let ee=Gt(x).size;a.push({path:g,size:ee,sha256:ye(x,{inputKind:"staged shared-generation artifact",maxBytes:L})})}let c=Jo(D(f(s,"index.scip"),{inputKind:"staged shared SCIP index",maxBytes:L})).metadata?.projectRoot;if(!c)throw new Error("shared SCIP generation has no project root metadata");let d=gn(e.sourceProjectRoot);if(!be(c,d))throw new Error("shared SCIP generation root does not match its source worktree");if(zo(e.sourceCacheDir)!==r||e.sourceStillValid&&!e.sourceStillValid())throw new Error("source index changed while staging a shared generation");let l={version:an,artifactCatalogVersion:Qe,generationId:e.snapshot.generationId,repositoryId:e.snapshot.repositoryId,treeOid:e.snapshot.treeOid,fingerprint:e.snapshot.fingerprint,producerIdentity:e.snapshot.producerIdentity,sourceProjectRoot:e.sourceProjectRoot,scipProjectRoot:c,createdAt:(e.now??(()=>new Date))().toISOString(),artifacts:a.sort((g,F)=>g.path.localeCompare(F.path))},u=B(f(s,cn),l,{spacing:2,trailingNewline:!0});u.directorySync!=="not-requested"&&o.push(u.directorySync),e.onPublicationStage?.("after-manifest-flushed"),o.push(I(s)),e.onPublicationStage?.("after-staging-directory-synced");let p=pn(e.snapshot);try{if(Y(p)&&!X(e.snapshot)){let g=`${p}.corrupt-${process.pid}-${Date.now()}`;k(()=>ge(p,g)),Q(g,{recursive:!0,force:!0})}k(()=>ge(s,p))}catch(g){let F=X(e.snapshot);if(F)return $o(e.snapshot,F);throw g}e.onPublicationStage?.("after-generation-renamed"),o.push(I(i)),e.onPublicationStage?.("after-generations-directory-synced");let m=E(...o);return{kind:"published",manifest:l,achievedDurability:m==="synced"?"directory-durable":"file-flushed",directorySync:m}}finally{Q(s,{recursive:!0,force:!0})}}function $o(e,t){let r=I(f(e.repositoryCacheDir,"generations"));return{kind:"existing",manifest:t,achievedDurability:r==="synced"?"directory-durable":"file-flushed",directorySync:r}}function on(e){let t=pn(e.snapshot);ve(e.targetCacheDir,{recursive:!0});let r=q(f(e.targetCacheDir,"cache-lifecycle.lock"),{waitMs:3e4});if(!r)throw new Error("timed out waiting for another cache hydration");let n,i,o=!1;try{n=nr(f(e.targetCacheDir,".shared-hydrate-")),Ll(e.manifest,e.snapshot);for(let c of e.manifest.artifacts){let d=z(t,c.path),l=z(n,c.path);if(tt(d,l),Gt(l).size!==c.size||ye(l,{inputKind:"hydrated shared-generation artifact",maxBytes:L})!==c.sha256)throw new Error(`shared artifact is corrupt: ${c.path}`)}let s=gn(e.targetProjectRoot);if(s!==e.manifest.scipProjectRoot)for(let c of e.manifest.artifacts)c.path.endsWith(".scip")&&Do(z(n,c.path),e.manifest.scipProjectRoot,s);if(!et(n,e.targetProjectRoot,e.snapshot.fingerprint,!1))throw new Error("staged shared generation failed completeness or integrity validation");i=Al(e.targetCacheDir,n),o=!0,Ml(n,e.targetCacheDir,i),To({tempOutputScip:f(n,"index.scip"),tempOutputDb:f(n,"index.db"),tempMetaPath:f(n,"meta.json"),outputScip:f(e.targetCacheDir,"index.scip"),outputDb:f(e.targetCacheDir,"index.db"),metaPath:f(e.targetCacheDir,"meta.json"),now:e.now});let a=Xr(f(e.targetCacheDir,"index.db"),f(e.targetCacheDir,"meta.json"));if(a.state==="invalid"||a.state==="drifted")throw new Error(`hydrated SQLite generation failed validation: ${a.reason}`);e.persistLease!==!1&&sn(e.snapshot,e.targetCacheDir,e.action??"attached",e.now)}catch(s){throw o&&i&&Cl(e.targetCacheDir,i),s}finally{n&&Q(n,{recursive:!0,force:!0}),r.release()}}function pm(e,t,r,n){let i=Vo(e,r.dbPath,t);if(i)return{kind:"bypassed",reason:i};try{let o=n??Ae(e);if(!o)return{kind:"missed",reason:"Git worktree identity is unavailable"};if(!o.clean)return _t(o,r.cacheDir,"missed",void 0,"worktree has uncommitted changes"),{kind:"missed",reason:"worktree has uncommitted changes"};let s=t.languages??Ar(e),a=Dr(e,s,Yo(t)),c=nn(o,a);if(!c)return{kind:"missed",reason:"clean committed snapshot is unavailable"};let d=X(c);if(d)return on({snapshot:c,manifest:d,targetCacheDir:r.cacheDir,targetProjectRoot:e}),{kind:"attached",generationId:c.generationId};let l=kl(c,e);return l?(d=l.manifest,on({snapshot:c,manifest:d,targetCacheDir:r.cacheDir,targetProjectRoot:e,action:"peer-imported"}),{kind:"peer-imported",generationId:c.generationId,sourceProjectRoot:l.sourceProjectRoot}):(_t(o,r.cacheDir,"missed",void 0,"no exact shared or peer generation exists"),{kind:"missed",reason:"no exact shared or peer generation exists"})}catch(o){return{kind:"failed",reason:o instanceof Error?o.message:String(o)}}}function fm(e,t,r,n){let i=Vo(e,r.dbPath,t);if(i)return{kind:"bypassed",reason:i};try{let o=n??Ae(e);if(!o)return{kind:"missed",reason:"Git worktree identity is unavailable"};if(!o.clean)return _t(o,r.cacheDir,"missed",void 0,"worktree is not a clean committed snapshot"),{kind:"missed",reason:"worktree is not a clean committed snapshot"};let s=t.languages??Ar(e),a=Dr(e,s,Yo(t)),c=nn(o,a);if(!c)return _t(o,r.cacheDir,"missed",void 0,"worktree is not a clean committed snapshot"),{kind:"missed",reason:"worktree is not a clean committed snapshot"};let d=X(c);if(d)return et(r.cacheDir,e,a)?(sn(c,r.cacheDir,"local-fresh"),{kind:"local-fresh"}):(on({snapshot:c,manifest:d,targetCacheDir:r.cacheDir,targetProjectRoot:e}),{kind:"attached",generationId:c.generationId});let l=un(r.cacheDir);return!l||JSON.stringify(l.fingerprint)!==JSON.stringify(a)||JSON.stringify([...l.indexedLanguages??[]].sort())!==JSON.stringify([...s].sort())?{kind:"missed",reason:"local metadata does not match the clean worktree snapshot"}:et(r.cacheDir,e,a)?(Ko({snapshot:c,sourceCacheDir:r.cacheDir,sourceProjectRoot:e,sourceStillValid:()=>{let u=Ae(e);return(u?nn(u,a):void 0)?.generationId===c.generationId}}),sn(c,r.cacheDir,"built"),{kind:"built",generationId:c.generationId}):{kind:"missed",reason:"local index artifacts are incomplete or incompatible"}}catch(o){return{kind:"failed",reason:o instanceof Error?o.message:String(o)}}}async function gm(e,t={}){let r=t.timeoutMs??3e4,n=t.pollMs??100,i=t.now??ce,o=i()+r,s=f(e.repositoryCacheDir,"locks"),a=f(s,`${e.generationId}.lock`),c=d=>{if(!d||typeof d!="object"||Array.isArray(d))return null;let l=d.pid;return typeof l=="number"&&Number.isSafeInteger(l)&&l>0?{pid:l}:null};for(;i()<=o;){if(X(e))return{kind:"generation-ready"};let d=It(a,{kind:"shared-generation-build",detail:{generationId:e.generationId},parseLegacy:c});if(d.kind==="acquired")return{kind:"owner",release:()=>d.lock.release()};let l=o-i();if(l<=0)break;await wl(Math.min(n,l))}return X(e)?{kind:"generation-ready"}:{kind:"timeout"}}function sn(e,t,r,n=void 0){let i={version:1,repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:e.projectRoot,treeOid:e.treeOid,localCacheDir:t,baseGenerationId:e.generationId,activeGenerationId:e.generationId,lastAction:r,lastSeenAt:(n??(()=>new Date))().toISOString()},o={...i,ownershipChecksum:ln(i)};return fn(e.repositoryCacheDir,o,!0),o}function mm(e,t,r=void 0){let n={version:1,repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:e.projectRoot,treeOid:e.treeOid,localCacheDir:t,baseGenerationId:e.generationId,lastAction:"overlay",lastReason:`private cache forked from shared baseline ${e.generationId}`,lastSeenAt:(r??(()=>new Date))().toISOString()},i={...n,ownershipChecksum:ln(n)};return fn(e.repositoryCacheDir,i,!0),i}function _t(e,t,r,n=void 0,i=void 0){let o={version:1,repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:e.projectRoot,treeOid:e.treeOid,localCacheDir:t,lastAction:r,...i?{lastReason:i}:{},lastSeenAt:(n??(()=>new Date))().toISOString()},s={...o,ownershipChecksum:ln(o)};return fn(ft(e.repositoryId),s,!1),s}function ln(e){return Zo(JSON.stringify({version:1,repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:Ze(e.projectRoot),localCacheDir:Ze(e.localCacheDir)}))}function Qo(e){let t=JSON.parse(e);if(t.version!==an||t.artifactCatalogVersion!==Qe||typeof t.generationId!="string"||!/^[a-f0-9]{64}$/.test(t.generationId)||typeof t.repositoryId!="string"||!/^[a-f0-9]{24}$/.test(t.repositoryId)||typeof t.treeOid!="string"||!t.treeOid||typeof t.producerIdentity!="string"||t.producerIdentity!==jt||typeof t.sourceProjectRoot!="string"||typeof t.scipProjectRoot!="string"||typeof t.createdAt!="string"||!Number.isFinite(Date.parse(t.createdAt))||!t.fingerprint||!Array.isArray(t.artifacts))throw new Error("invalid shared generation manifest");let r=new Set;for(let n of t.artifacts){if(!n||typeof n.path!="string"||typeof n.size!="number"||n.size<0||typeof n.sha256!="string"||!/^[a-f0-9]{64}$/.test(n.sha256))throw new Error("invalid shared generation artifact");if(Tt(n.path),r.has(n.path))throw new Error(`duplicate shared generation artifact: ${n.path}`);r.add(n.path)}for(let n of["index.db","index.scip","meta.json"])if(!r.has(n))throw new Error(`shared generation is missing ${n}`);return t}function tt(e,t,r=384){return Le(e,t,{mode:r})}function kl(e,t){for(let r of xn(t)){if(Ze(r.path)===Ze(t))continue;let n=pt(r.path),i=un(n);if(!(!i||JSON.stringify(i.fingerprint)!==JSON.stringify(e.fingerprint)||JSON.stringify([...i.indexedLanguages??[]].sort())!==JSON.stringify([...e.fingerprint.languages].sort()))&&et(n,r.path,e.fingerprint))try{return{manifest:Ko({snapshot:e,sourceCacheDir:n,sourceProjectRoot:r.path}).manifest,sourceProjectRoot:r.path}}catch{continue}}return null}function Dl(e,t,r){ve(e,{recursive:!0}),B(f(e,Rl),{version:1,repositoryId:t,worktreeId:r},{spacing:2,trailingNewline:!0})}function zo(e){try{let t=Lt(e),r=Wo("sha256");for(let n of t.files){let i=z(e,n),o=Gt(i).size;r.update(n).update("\0").update(String(o)).update("\0"),it(i,{inputKind:"source-generation artifact",maxBytes:L},s=>r.update(s)),r.update("\0")}return r.digest("hex")}catch{return null}}function un(e){try{let t=mt(R(f(e,"meta.json"),{inputKind:"reindex metadata",maxBytes:A}));return(t.kind==="legacy"||t.kind==="supported")&&t.capabilities.publishableGeneration?t.metadata:void 0}catch{return}}function Yo(e){return{pnpmWorkspaces:e.indexer?.typescript?.pnpmWorkspaces,typescriptProjectMode:e.indexer?.typescript?.projectMode,typescriptProjects:e.indexer?.typescript?.projects,clojureConfigPath:e.indexer?.clojure?.configPath}}function Fl(e,t){let r=Ft(e.languages,e);return JSON.stringify(r)===JSON.stringify(t)}function pn(e){return f(e.repositoryCacheDir,"generations",e.generationId)}function fn(e,t,r){let n=di(e,{waitMs:5e3});if(!n)throw new Error("repository cache cleanup is busy");try{if(r){let o=t.activeGenerationId??t.baseGenerationId;if(!o||!Y(f(e,"generations",o)))throw new Error("shared generation disappeared before its lease was attached")}let i=f(e,"worktrees");ve(i,{recursive:!0}),B(f(i,`${t.worktreeId}.json`),t,{spacing:2,trailingNewline:!0}),Dl(t.localCacheDir,t.repositoryId,t.worktreeId)}finally{n.release()}}function Al(e,t){let r=f(t,".rollback"),n=new Map,i=new Map;ve(r,{recursive:!0});for(let a of["index.scip","index.db","meta.json"]){let c=f(e,a),d=Y(c);n.set(a,d),d&&tt(c,f(r,"stable",a))}for(let a of dn){let c=f(e,a),d=Y(c);if(d){let l=tn(c);if(!l.isDirectory()||l.isSymbolicLink())throw new Error(`managed artifact path is not a directory: ${a}`)}i.set(a,d)}let o=f(e,je),s=Y(o);return s&&Xo(o,f(r,"sqlite-generations")),{root:r,stableFiles:n,managedDirectories:i,generationStoreExisted:s}}function Ml(e,t,r){for(let n of dn){let i=f(t,n);if(r.managedDirectories.get(n)){let s=f(r.root,"managed",n);ve(rn(s),{recursive:!0}),k(()=>ge(i,s))}let o=f(e,n);Y(o)&&k(()=>ge(o,i))}}function Cl(e,t){for(let i of dn){let o=f(e,i),s=f(t.root,"managed",i);t.managedDirectories.get(i)?Y(s)&&(Q(o,{recursive:!0,force:!0}),k(()=>ge(s,o))):Q(o,{recursive:!0,force:!0})}for(let[i,o]of t.stableFiles){let s=f(e,i);if(!o){Q(s,{force:!0});continue}let a=`${s}.shared-restore-${xl()}`;tt(f(t.root,"stable",i),a),k(()=>Q(s,{force:!0})),k(()=>ge(a,s))}let r=f(e,je);Q(r,{recursive:!0,force:!0});let n=f(t.root,"sqlite-generations");t.generationStoreExisted&&Y(n)&&k(()=>ge(n,r))}function Xo(e,t){ve(t,{recursive:!0});for(let r of Ho(e,{withFileTypes:!0})){let n=f(e,r.name),i=f(t,r.name);if(r.isSymbolicLink())throw new Error(`managed cache backup cannot contain a symlink: ${n}`);r.isDirectory()?Xo(n,i):r.isFile()&&tt(n,i)}}function Ll(e,t){if(e.generationId!==t.generationId||e.repositoryId!==t.repositoryId||e.treeOid!==t.treeOid||e.producerIdentity!==t.producerIdentity||JSON.stringify(e.fingerprint)!==JSON.stringify(t.fingerprint))throw new Error("shared generation manifest does not match the requested snapshot")}function et(e,t,r,n=!0,i=!0){try{let o=un(e);if(!o||JSON.stringify(o.fingerprint)!==JSON.stringify(r)||JSON.stringify([...o.indexedLanguages??[]].sort())!==JSON.stringify([...r.languages].sort()))return Xe("source validation rejected metadata"),!1;let s=Lt(e),a=Xr(f(e,"index.db"),f(e,"meta.json"));if(n?a.state!=="current":a.state==="invalid"||a.state==="drifted")return Xe(`source validation rejected SQLite generation state ${a.state}`),!1;let c=new Pl(ht(f(e,"index.db")),{readonly:!0,fileMustExist:!0});try{if(i){if(c.pragma("quick_check(1)",{simple:!0})!=="ok")return!1}else c.pragma("schema_version",{simple:!0})}finally{c.close()}let d=gn(t),u=(i?s.files.filter(p=>p.endsWith(".scip")):["index.scip"]).every(p=>{let m=Jo(D(z(e,p),{inputKind:"shared SCIP validation artifact",maxBytes:L})).metadata?.projectRoot,g=m!==void 0&&be(m,d);return g||Xe(`source validation rejected SCIP root for ${p}: ${String(m)}`),g});return u||Xe("source validation rejected SCIP project roots"),u}catch(o){return Xe(`source validation failed: ${o instanceof Error?o.message:String(o)}`),!1}}function Xe(e){process.env.CODEBASEIQ_DEBUG&&console.error(`shared-cache: ${e}`)}function gn(e){try{return Bo(Uo(e)).href}catch{return Bo(Ze(e)).href}}function Zo(e){return Wo("sha256").update(e).digest("hex")}function hm(e){return typeof e=="object"&&e!==null}function Sm(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")?e:null}import{createHash as Tl,randomUUID as is}from"crypto";import{existsSync as Fe,lstatSync as nt,readdirSync as De,renameSync as os,rmSync as Z}from"fs";import{basename as mn,dirname as Ol,join as w}from"path";function Nt(e){return Array.isArray(e)?`[${e.map(Nt).join(",")}]`:e&&typeof e=="object"?`{${Object.entries(e).sort(([t],[r])=>t.localeCompare(r)).map(([t,r])=>`${JSON.stringify(t)}:${Nt(r)}`).join(",")}}`:JSON.stringify(e)}var jl=1,_l=Object.freeze({maxItems:1024,maxBytes:512*1024*1024,maxItemBytes:64*1024*1024,maxBatch:16,claimLeaseMs:5*6e4,responseRetentionMs:10*6e4,deadLetterRetentionMs:1440*6e4,temporaryRetentionMs:6e4,cleanupBatch:64}),ke=class extends Error{constructor(r,n,i,o){let s=r==="item-too-large"?`request is ${o} bytes; per-item limit is ${i.maxItemBytes}`:r==="item-capacity"?`mailbox has ${n.totalItems} retained items; limit is ${i.maxItems}`:r==="byte-capacity"?`mailbox retains ${n.totalBytes} bytes and the request adds ${o}; limit is ${i.maxBytes}`:"another writer held the admission coordinator through the bounded wait";super(`Mailbox backpressure: ${s}. Retry after the service drains or expires retained work.`);this.code=r;this.status=n;this.limits=i;this.attemptedBytes=o;this.name="MailboxBackpressureError"}code;status;limits;attemptedBytes},Gl=".owner.json",Nl={isProcessAlive:()=>!0,readProcessIdentity:()=>null};function Fm(e){return{rootDir:e,pendingDir:w(e,"pending"),inflightDir:w(e,"inflight"),responseDir:w(e,"responses"),deadLetterDir:w(e,"dead-letter"),legacyRequestDir:w(e,"requests")}}function Bl(e={}){let t={..._l,...e};for(let[r,n]of Object.entries(t))if(!Number.isFinite(n)||n<=0||!Number.isInteger(n))throw new Error(`Mailbox limit ${r} must be a positive integer.`);return t}function ss(e){let t=[e.pendingDir,e.inflightDir,e.responseDir,e.deadLetterDir,e.legacyRequestDir].map(r=>M(r));return E(...t)}function Am(e,t){return Tl("sha256").update(Nt({namespace:e,payload:t})).digest("hex")}function ql(e){if(!/^[a-f0-9]{64}$/.test(e))throw new Error("Mailbox operation keys must be lowercase SHA-256 identities.");return`op-${e}`}function Mm(e,t,r={}){let n=Bl(r.limits),i=r.nowMs??Date.now(),o=ss(e);return Kl(t),zl(e,n,r.admissionLockTimeoutMs??2e3,r.monotonicNow??ce,()=>{$l(e,i,n);let s=w(e.pendingDir,`${t.id}.json`),a=w(e.responseDir,`${t.id}.json`),c=es(e,t.id);if(c){let p=ts(c,t.operationKey,t.id);return{disposition:"duplicate",requestId:t.id,responsePath:a,authoritativeDeadlineAtMs:p.deadlineAtMs??t.deadlineAtMs}}let d=`${JSON.stringify(t)}
86
- `,l=Buffer.byteLength(d),u=as(e);if(l>n.maxItemBytes)throw new ke("item-too-large",u,n,l);if(u.totalItems+1>n.maxItems)throw new ke("item-capacity",u,n,l);if(u.totalBytes+l>n.maxBytes)throw new ke("byte-capacity",u,n,l);r.onBeforePublish?.();try{let p=tr(s,d,{durability:"durable"}),m=E(o,p.directorySync);return{disposition:"accepted",requestId:t.id,responsePath:a,authoritativeDeadlineAtMs:t.deadlineAtMs,achievedDurability:m==="synced"?"directory-durable":"file-flushed",directorySync:m}}catch(p){if(p.code!=="EEXIST")throw p;let m=es(e,t.id);if(!m)throw p;let g=ts(m,t.operationKey,t.id);return{disposition:"duplicate",requestId:t.id,responsePath:a,authoritativeDeadlineAtMs:g.deadlineAtMs??t.deadlineAtMs}}})}function $l(e,t,r,n=Nl){let i={reclaimed:0,completedClaimsRemoved:0,responsesRemoved:0,deadLettersRemoved:0,temporaryFilesRemoved:0},o=r.cleanupBatch;for(let s of hn(e.inflightDir)){if(o<=0)break;let a=w(e.responseDir,`${s.requestId}.json`);if(Fe(a)){Z(s.path,{force:!0}),i.completedClaimsRemoved++,o--;continue}if(s.claimExpiresAtMs>t||Jl(e,s.ownerId,n)!=="dead")continue;let c=w(e.pendingDir,s.originalFile);try{os(s.path,c),i.reclaimed++}catch(d){if(d.code!=="EEXIST")throw d;Z(s.path,{force:!0})}I(Ol(s.path)),I(e.pendingDir),o--}o=rs(e.responseDir,o,(s,a)=>a+r.responseRetentionMs,t,()=>{i.responsesRemoved++}),o=rs(e.deadLetterDir,o,(s,a)=>a+r.deadLetterRetentionMs,t,()=>{i.deadLettersRemoved++});for(let s of[e.pendingDir,e.inflightDir,e.responseDir,e.deadLetterDir,e.legacyRequestDir]){if(o<=0)break;for(let a of cs(s)){if(o<=0)break;mn(a).includes(".tmp-")&&(nt(a).mtimeMs+r.temporaryRetentionMs>t||(Z(a,{force:!0}),i.temporaryFilesRemoved++,o--))}}return Ql(e.inflightDir),i}function as(e){ss(e);let t=[...rt(e.pendingDir).map(c=>({path:c,pending:!0})),...rt(e.legacyRequestDir).map(c=>({path:c,pending:!0}))],r=hn(e.inflightDir).map(c=>({path:c.path,pending:!1})),n=rt(e.responseDir).map(c=>({path:c,pending:!1})),i=rt(e.deadLetterDir).map(c=>({path:c,pending:!1})),o=[...t,...r,...n,...i],s=0,a;for(let c of t){let d=Sn(c.path);if(!d){s++;continue}let l=d.enqueuedAtMs??nt(c.path).mtimeMs;a=a===void 0?l:Math.min(a,l)}return{pending:t.length,inflight:r.length,responses:n.length,deadLetters:i.length,invalid:s,totalItems:o.length,totalBytes:o.reduce((c,d)=>c+Yl(d.path),0),...a===void 0?{}:{oldestPendingAt:new Date(a).toISOString()}}}function zl(e,t,r,n,i){let o=w(e.rootDir,".admission.lock"),s=`${process.pid}-${is()}`,a=n()+Math.max(0,r);for(;!Wl(e.rootDir,o,s);){if(Hl(o),n()>=a)throw new ke("admission-busy",as(e),t,0);Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,5)}try{return i()}finally{try{yn(o).ownerToken===s&&(Z(o,{recursive:!0,force:!0}),I(e.rootDir))}catch{}}}function Wl(e,t,r){let n=`${JSON.stringify({ownerToken:r,pid:process.pid,acquiredAtMs:Date.now()})}
87
- `;try{return tr(t,n,{durability:"durable"}),!0}catch(i){if(i.code==="EEXIST")return!1;try{yn(t).ownerToken===r&&(Z(t,{force:!0}),I(e))}catch{}throw i}}function Hl(e){let t=null;try{let n=yn(e);typeof n.ownerToken=="string"&&Number.isSafeInteger(n.pid)&&Number(n.pid)>0&&(t=Number(n.pid))}catch{}if(t===null||Ul(t))return;let r=`${e}.stale-${is()}`;try{os(e,r)}catch(n){let i=n.code;if(i==="ENOENT"||i==="EEXIST")return;throw n}Z(r,{recursive:!0,force:!0})}function yn(e){try{return JSON.parse(S(e,"mailbox lock record"))}catch(t){if(t.code!=="EISDIR"&&!(t instanceof Pn&&t.reason==="not-regular"))throw t;return JSON.parse(S(w(e,"owner.json"),"mailbox lock owner record"))}}function Ul(e){try{return process.kill(e,0),!0}catch(t){let r=t.code;return r==="EPERM"||r!=="ESRCH"}}function Jl(e,t,r){let n=Vl(w(e.inflightDir,ds(t),Gl));if(!n)return"unknown";if(!r.isProcessAlive(n.pid))return"dead";if(!n.processIdentity)return"live";let i=r.readProcessIdentity(n.pid);return i?re(n.processIdentity,i)?"live":"dead":"unknown"}function Vl(e){try{let t=JSON.parse(S(e,"mailbox owner record"));if(t.version!==1||typeof t.ownerId!="string"||!t.ownerId||typeof t.pid!="number"||!Number.isSafeInteger(t.pid)||t.pid<=0)return null;let r=t.processIdentity===void 0?null:he(t.processIdentity);return t.processIdentity!==void 0&&(!r||r.pid!==t.pid)?null:{version:1,ownerId:t.ownerId,pid:t.pid,...r?{processIdentity:r}:{}}}catch{return null}}function es(e,t){for(let r of[w(e.pendingDir,`${t}.json`),w(e.legacyRequestDir,`${t}.json`),w(e.responseDir,`${t}.json`)])if(Fe(r))return r;for(let r of hn(e.inflightDir))if(r.requestId===t)return r.path;return null}function ts(e,t,r){let n=Sn(e);if(!n||n.operationKey!==t)throw new Error(`Mailbox operation ${r} conflicts with an existing retained record.`);return n}function Kl(e){if(e.mailboxVersion!==jl||e.id!==ql(e.operationKey)||!e.clientId.trim()||!Number.isFinite(e.enqueuedAtMs)||!Number.isFinite(e.deadlineAtMs)||e.deadlineAtMs<e.enqueuedAtMs)throw new Error("Mailbox request has an invalid lifecycle identity.")}function hn(e){if(!Fe(e))return[];let t=[];for(let r of De(e,{withFileTypes:!0})){if(!r.isDirectory())continue;let n=ns(r.name);if(n===null)continue;let i=w(e,r.name);for(let o of De(i,{withFileTypes:!0})){if(!o.isFile()||!o.name.endsWith(".claim"))continue;let s=/^(.*)\.(\d+)\.claim$/.exec(o.name);if(!s)continue;let a=ns(s[1]),c=Number(s[2]);if(a===null||mn(a)!==a||!a.endsWith(".json")||!Number.isSafeInteger(c))continue;let d=w(i,o.name),l=Sn(d)??{id:mn(a,".json")},u=nt(d);t.push({requestId:l.id,ownerId:n,path:d,originalFile:a,claimedAtMs:u.mtimeMs,claimExpiresAtMs:c,byteLength:u.size,...l.operationKey?{operationKey:l.operationKey}:{},...l.clientId?{clientId:l.clientId}:{},...l.enqueuedAtMs===void 0?{}:{enqueuedAtMs:l.enqueuedAtMs},...l.deadlineAtMs===void 0?{}:{deadlineAtMs:l.deadlineAtMs},legacy:l.operationKey===void 0})}}return t.sort((r,n)=>r.claimedAtMs-n.claimedAtMs||r.path.localeCompare(n.path))}function Sn(e){try{let t=JSON.parse(S(e,"mailbox record"));return typeof t.id!="string"||!t.id?null:{id:t.id,...typeof t.operationKey=="string"?{operationKey:t.operationKey}:{},...typeof t.clientId=="string"?{clientId:t.clientId}:{},...typeof t.enqueuedAtMs=="number"?{enqueuedAtMs:t.enqueuedAtMs}:{},...typeof t.deadlineAtMs=="number"?{deadlineAtMs:t.deadlineAtMs}:{}}}catch{return null}}function rs(e,t,r,n,i){for(let o of rt(e)){if(t<=0)break;let s=nt(o);r(o,s.mtimeMs)>n||(Z(o,{force:!0}),i(),t--)}return t}function rt(e){return Fe(e)?De(e,{withFileTypes:!0}).filter(t=>t.isFile()).map(t=>w(e,t.name)).sort():[]}function cs(e){if(!Fe(e))return[];let t=[];for(let r of De(e,{withFileTypes:!0})){let n=w(e,r.name);r.isFile()?t.push(n):r.isDirectory()&&t.push(...cs(n))}return t.sort()}function Ql(e){if(Fe(e))for(let t of De(e,{withFileTypes:!0})){if(!t.isDirectory())continue;let r=w(e,t.name);De(r).some(n=>n.endsWith(".claim"))||Z(r,{recursive:!0,force:!0})}}function Yl(e){try{return nt(e).size}catch{return 0}}function ds(e){return Buffer.from(e,"utf8").toString("base64url")}function ns(e){try{let t=Buffer.from(e,"base64url").toString("utf8");return ds(t)===e?t:null}catch{return null}}export{ie as a,Se as b,M as c,I as d,E as e,v as f,qt as g,su as h,au as i,O as j,j as k,ot as l,Ce as m,Wt as n,ut as o,pt as p,Ht as q,Su as r,bu as s,Jt as t,ht as u,nr as v,Qu as w,Yu as x,Xu as y,Vt as z,xu as A,wu as B,Bs as C,ae as D,mt as E,Du as F,Jn as G,$s as H,Fu as I,ce as J,ep as K,St as L,ii as M,bt as N,It as O,Ie as P,Da as Q,di as R,q as S,mp as T,k as U,er as V,tr as W,V as X,B as Y,kp as Z,xi as _,Np as $,Be as aa,Li as ba,Ti as ca,Oi as da,bc as ea,ji as fa,Up as ga,Jp as ha,Vp as ia,Pt as ja,Bc as ka,$e as la,sd as ma,Ji as na,ad as oa,Rf as pa,kr as qa,vf as ra,cd as sa,dd as ta,Dr as ua,Ar as va,To as wa,ll as xa,Tg as ya,Og as za,Xr as Aa,hm as Ba,Sm as Ca,Nt as Da,jl as Ea,Fm as Fa,Am as Ga,ql as Ha,Mm as Ia,Nf as Ja,Bf as Ka,qf as La,$f as Ma,zf as Na,Yf as Oa,Xf as Pa,Zf as Qa,eg as Ra,pg as Sa,Ig as Ta,xg as Ua,nn as Va,Vo as Wa,lm as Xa,X as Ya,um as Za,Ko as _a,on as $a,pm as ab,fm as bb,gm as cb,sn as db,mm as eb,ln as fb};
88
- //# sourceMappingURL=chunk-G2XUZCF2.js.map
@@ -1,2 +0,0 @@
1
- import{b as g,d as f}from"./chunk-2Q2LW5JW.js";import{aa as p,ba as x,h as d}from"./chunk-4O52YNKL.js";import{execFileSync as b}from"child_process";import{createHash as v}from"crypto";import{existsSync as s,statSync as j}from"fs";import{createRequire as B}from"module";import{platform as N}from"os";import{dirname as m,join as a}from"path";var S=B(import.meta.url),K={language:"rust",indexerBinary:"rust-analyzer",installUrl:"https://github.com/rust-lang/rust-analyzer"};function l(n){return[n.indexerBinary,...n.binaryAliases??[]]}function k(n){let e=l(n);return e.length===1?e[0]:e.join(" or ")}function u(n){for(let e of l(n)){let r=f(e);if(r)return r}return w(n)}function q(n){return u(n)!==null||L(n)}function L(n){return T(n)!==null}function w(n){let e=T(n);if(!e)return null;let t=JSON.parse(d(e,"indexer package manifest")).bin;if(!t)return null;if(typeof t=="string")return a(m(e),t);for(let o of l(n)){let i=t[o];if(i)return a(m(e),i)}return null}function T(n){if(!n.bundledNpmPackage)return null;try{return S.resolve(`${n.bundledNpmPackage}/package.json`)}catch{return null}}function O(n,e){for(let r of n.projectLocalBinaries??[]){let t=a(e,r);if(s(t))return t}return null}function E(n,e){for(let r of n.projectLocalBinaries??[]){let t=a(e,r);if(s(t))return I(e,r,t)}return null}function G(n,e){let r=D(n,e);if(!r||r.canonicalPath!==e.canonicalPath||r.sha256!==e.sha256||r.size!==e.size||r.mtimeMs!==e.mtimeMs||r.device!==e.device||r.inode!==e.inode||r.executable!==e.executable)throw new Error(`refusing changed project-local indexer ${e.relativePath}; review the current file and rerun with --trust-project-tools`)}function D(n,e){try{return I(n,e.relativePath,e.configuredPath)}catch{return null}}function I(n,e,r){let t={maxBytes:268435456,inputKind:"project-local indexer"},o=p(n,e,t),i=x(n,e,t),h=j(o.absolutePath);return{configuredPath:r,canonicalPath:o.absolutePath,relativePath:e,sha256:v("sha256").update(i).digest("hex"),size:o.size,mtimeMs:o.mtimeMs,device:o.device,inode:o.inode,executable:(h.mode&73)!==0}}function R(n,e,r={}){return(r.trustProjectTools?E(n,e)?.canonicalPath:null)??u(n)}function W(n,e=process.env,r=n.indexerBinary){if(n.indexerBinary!=="scip-dotnet"||c(r,e))return e;let t=P(r,e);return t?{...e,DOTNET_ROOT:t}:e}function Y(n,e,r={}){let t=k(n),o=e?R(n,e,r):u(n);if(!o)return{language:n.language,binaryLabel:t,installed:!1,runnable:!1,resolvedBinary:null,installUrl:n.installUrl,...e&&O(n,e)?{note:"project-local indexer available only with --trust-project-tools"}:{}};if(n.indexerBinary!=="scip-dotnet")return{language:n.language,binaryLabel:t,installed:!0,runnable:!0,resolvedBinary:o};let i=J(o);return{language:n.language,binaryLabel:t,installed:!0,runnable:i.runnable,resolvedBinary:o,installUrl:n.installUrl,note:i.note}}function J(n){if(c(n,process.env))return{runnable:!0};let e=P(n,process.env);if(e)return{runnable:!0,note:`using .NET 9 runtime from ${e}`};let r=y(process.env);return{runnable:!1,note:r.length>0?`.NET 9 runtime still unavailable after checking ${r.join(", ")}`:"binary is present, but scip-dotnet still needs a .NET 9 runtime"}}function P(n,e){for(let r of y(e))if(c(n,{...e,DOTNET_ROOT:r}))return r;return null}function y(n){let e=[],r=n.DOTNET_ROOT;if(r&&s(r)&&e.push(r),N()==="darwin"&&g("brew"))try{let t=b("brew",["--prefix","dotnet@9"],{stdio:"pipe",windowsHide:!0,env:n,timeout:1e4,killSignal:"SIGKILL"}).toString().trim(),o=a(t,"libexec");s(o)&&!e.includes(o)&&e.push(o)}catch{}return e}function c(n,e){try{return b(n,["--version"],{stdio:"pipe",windowsHide:!0,env:e,timeout:1e4,killSignal:"SIGKILL"}),!0}catch{return!1}}export{K as a,k as b,u as c,q as d,O as e,E as f,G as g,W as h,Y as i};
2
- //# sourceMappingURL=chunk-H5QXP63L.js.map
@@ -1,2 +0,0 @@
1
- import{a as z}from"./chunk-P5XHIJHI.js";import{a as De,i as Me}from"./chunk-H5QXP63L.js";import{c as xe,h as _e}from"./chunk-EXMVF3JR.js";import{a as he,e as Ee,i as ke}from"./chunk-DRENNWRG.js";import{a as S,c as be,d as M,e as f,f as X,h as ge,j,t as x,u as k,v as Ae,x as q,y as K,z as we}from"./chunk-ACZDU5GK.js";import{a as C,i as G,k as v}from"./chunk-R2NOK63J.js";import{a as ye,b as Se,c as L,d as w}from"./chunk-6URCE5QY.js";import{a as pe,b as E,c as Re,f as me,g as A,ga as Ie,m as J}from"./chunk-4O52YNKL.js";import{createHash as fn}from"crypto";import{resolve as pn}from"path";var b=3;function V(e){return fn("sha256").update(x({kind:"codebaseiq-durable-rust-mailbox",protocolVersion:b,sessionDir:pn(e)})).digest("hex")}function Rn(e,n){if(!S(e)||typeof e.id!="string"||!e.id)return T("Durable Rust semantic helper received an invalid mailbox request.");if(e.id!==n.claimRequestId)return T("Durable Rust semantic request identity does not match its mailbox path.");if(e.protocolVersion===void 0){if(e.mailboxVersion!==void 0||e.operationKey!==void 0||e.clientId!==void 0||e.enqueuedAtMs!==void 0||e.deadlineAtMs!==void 0||e.sessionIdentity!==void 0)return T("Durable Rust semantic helper received a partially versioned request without a protocol version.");let s=Ce(e.request);if(!s)return T("Durable Rust semantic helper received an invalid legacy request kind or payload.");let i=n.nowMs+Math.max(1,s.timeoutMs);return{ok:!0,compatibility:"legacy-v2",value:{mailboxVersion:k,protocolVersion:b,id:e.id,operationKey:q("rust-semantic-v2",{id:e.id,request:s}),clientId:"legacy-v2",enqueuedAtMs:n.nowMs,deadlineAtMs:i,sessionIdentity:n.sessionIdentity,request:s}}}let t=mn(e,n);if(!t.ok)return t;if(e.protocolVersion!==b)return{ok:!1,code:"unsupported-protocol",error:`Durable Rust semantic helper does not support mailbox protocol ${String(e.protocolVersion)}.`,responseIdentity:t.responseIdentity};let r=Ce(e.request);return r?t.operationKey!==q("rust-semantic-v3",r)?{ok:!1,code:"malformed-request",error:"Durable Rust semantic helper received a mismatched mailbox operation identity.",responseIdentity:t.responseIdentity}:t.deadlineAtMs-t.enqueuedAtMs!==r.timeoutMs?{ok:!1,code:"malformed-request",error:"Durable Rust semantic helper received a deadline that does not match the request timeout.",responseIdentity:t.responseIdentity}:t.deadlineAtMs<n.nowMs?{ok:!1,code:"expired-request",error:"Durable Rust semantic request expired before processing.",responseIdentity:t.responseIdentity}:{ok:!0,compatibility:t.priorSessionIdentity?"prior-v3":"current-v3",value:{mailboxVersion:k,protocolVersion:b,id:e.id,operationKey:t.operationKey,clientId:t.clientId,enqueuedAtMs:t.enqueuedAtMs,deadlineAtMs:t.deadlineAtMs,sessionIdentity:n.sessionIdentity,request:r}}:{ok:!1,code:"malformed-request",error:"Durable Rust semantic helper received an invalid request kind or payload.",responseIdentity:t.responseIdentity}}function te(e,n){return S(e)?e.protocolVersion!==b?qe(e.protocolVersion===void 0?"helper wrote a prior uncorrelated response protocol":`helper wrote unsupported response protocol ${String(e.protocolVersion)}`):e.mailboxVersion!==k||e.id!==n.requestId||e.operationKey!==n.operationKey||e.sessionIdentity!==n.sessionIdentity||e.deadlineAtMs!==n.deadlineAtMs?qe("helper wrote an incompatible response identity"):typeof e.completedAtMs!="number"||!Number.isFinite(e.completedAtMs)||e.completedAtMs>n.deadlineAtMs||n.nowMs>n.deadlineAtMs?{ok:!1,code:"expired-request",error:"helper response arrived after the durable request deadline"}:e.ok===!1?typeof e.error!="string"||!Mn(e.errorCode)?ee("helper wrote an invalid rejection response"):{ok:!1,code:e.errorCode,error:e.error}:e.ok!==!0||e.session!=="created"&&e.session!=="reused"&&e.session!=="invalidated"||!gn(e.response,n.requestKind)?ee("helper wrote an invalid success response"):{ok:!0,session:e.session,response:e.response}:ee("helper wrote an invalid response object")}function mn(e,n){if(e.mailboxVersion!==k||typeof e.protocolVersion!="number"||!Number.isInteger(e.protocolVersion)||typeof e.operationKey!="string"||!Te(e.operationKey)||e.id!==K(e.operationKey)||typeof e.clientId!="string"||!e.clientId||typeof e.enqueuedAtMs!="number"||!Number.isFinite(e.enqueuedAtMs)||typeof e.deadlineAtMs!="number"||!Number.isFinite(e.deadlineAtMs)||e.deadlineAtMs<e.enqueuedAtMs||e.sessionIdentity!==void 0&&(typeof e.sessionIdentity!="string"||!Te(e.sessionIdentity))||e.sessionIdentity===void 0&&e.protocolVersion!==b)return T("Durable Rust semantic helper received an invalid mailbox lifecycle.");let t={id:n.claimRequestId,sessionIdentity:n.sessionIdentity,deadlineAtMs:e.deadlineAtMs};return e.sessionIdentity!==void 0&&e.sessionIdentity!==n.sessionIdentity?{ok:!1,code:"malformed-request",error:"Durable Rust semantic request belongs to a different mailbox session.",responseIdentity:t}:{ok:!0,responseIdentity:t,operationKey:e.operationKey,clientId:e.clientId,enqueuedAtMs:e.enqueuedAtMs,deadlineAtMs:e.deadlineAtMs,priorSessionIdentity:e.sessionIdentity===void 0}}function Ce(e){return!S(e)||typeof e.identityKey!="string"||!e.identityKey||!X(e.timeoutMs)||e.workerEnvironment!==void 0&&!be(e.workerEnvironment)?null:e.kind==="semantic"&&yn(e.request)?{kind:"semantic",identityKey:e.identityKey,...e.workerEnvironment===void 0?{}:{workerEnvironment:e.workerEnvironment},request:e.request,timeoutMs:e.timeoutMs}:e.kind==="import-definitions"&&Sn(e.request)?{kind:"import-definitions",identityKey:e.identityKey,...e.workerEnvironment===void 0?{}:{workerEnvironment:e.workerEnvironment},request:e.request,timeoutMs:e.timeoutMs}:null}function yn(e){return!S(e)||!M(e.projectRoot)||!M(e.rustAnalyzerBinary)||!Be(e.definitions)?!1:Z(e.referenceDefinitions)&&Z(e.calleeDefinitions)&&Z(e.signatureDefinitions)&&I(e.requestTimeoutMs)&&I(e.readinessDeadlineMs)&&I(e.referenceRetryTimeoutMs)&&I(e.diagnosticsTimeoutMs)&&I(e.settleDelayMs)&&Oe(e.concurrency)&&ne(e.includeReferences)&&ne(e.includeCallees)&&ne(e.includeSignatures)}function Sn(e){return!S(e)||!M(e.projectRoot)||!M(e.rustAnalyzerBinary)||!M(e.file)||!Array.isArray(e.positions)||!e.positions.every(n=>S(n)&&M(n.id)&&M(n.file)&&f(n.line)&&f(n.column))?!1:I(e.requestTimeoutMs)&&I(e.readinessDeadlineMs)&&I(e.diagnosticsTimeoutMs)&&I(e.settleDelayMs)&&Oe(e.concurrency)}function Be(e){return Array.isArray(e)&&e.every(bn)}function Z(e){return e===void 0||Be(e)}function bn(e){return S(e)&&f(e.symbolId)&&f(e.documentId)&&f(e.startLine)&&Pe(e.startChar)&&f(e.endLine)&&Pe(e.endChar)&&typeof e.symbol=="string"&&typeof e.relativePath=="string"&&typeof e.leaf=="string"&&(e.parentTypeName===null||typeof e.parentTypeName=="string")&&typeof e.isFunctionLike=="boolean"&&typeof e.isTypeLike=="boolean"&&(e.kind===null||Number.isSafeInteger(e.kind))&&(e.documentation===null||typeof e.documentation=="string")&&(e.enclosingSymbol===null||typeof e.enclosingSymbol=="string")}function gn(e,n){return!S(e)||typeof e.available!="boolean"||e.available===!1&&(typeof e.reason!="string"||e.reason.length===0)||e.available===!0&&e.reason!==void 0?!1:n==="import-definitions"?Array.isArray(e.sourcePaths)&&e.sourcePaths.every(t=>Array.isArray(t)&&t.length===2&&typeof t[0]=="string"&&(t[1]===null||typeof t[1]=="string")):ve(e.references,In)&&(e.incompleteReferenceSymbolIds===void 0||Array.isArray(e.incompleteReferenceSymbolIds)&&e.incompleteReferenceSymbolIds.every(t=>Number.isSafeInteger(t)))&&(e.callees===void 0||ve(e.callees,Dn))&&(e.signatures===void 0||Array.isArray(e.signatures)&&e.signatures.every(t=>Array.isArray(t)&&t.length===2&&Number.isSafeInteger(t[0])&&(t[1]===null||typeof t[1]=="string")))}function ve(e,n){return Array.isArray(e)&&e.every(t=>Array.isArray(t)&&t.length===2&&Number.isSafeInteger(t[0])&&Array.isArray(t[1])&&t[1].every(n))}function In(e){return S(e)&&typeof e.file=="string"&&f(e.line)&&f(e.column)}function Dn(e){return S(e)&&typeof e.symbol=="string"&&typeof e.file=="string"&&f(e.line)&&(e.callsiteLine===void 0||f(e.callsiteLine))}function Mn(e){return e==="unsupported-protocol"||e==="malformed-request"||e==="expired-request"||e==="handler-error"}function T(e){return{ok:!1,code:"malformed-request",error:e}}function ee(e){return{ok:!1,code:"malformed-response",error:e}}function qe(e){return{ok:!1,code:"incompatible-response",error:e}}function Te(e){return/^[a-f0-9]{64}$/.test(e)}function Oe(e){return e===void 0||X(e)}function Pe(e){return e===void 0||f(e)}function I(e){return e===void 0||ge(e)}function ne(e){return e===void 0||typeof e=="boolean"}import{spawn as Bn}from"child_process";import{createHash as On,randomUUID as Nn}from"crypto";import{existsSync as Qe,realpathSync as Un,rmSync as Wn}from"fs";import{tmpdir as Fn}from"os";import{resolve as _}from"path";import{execFileSync as Cn}from"child_process";import{existsSync as hn}from"fs";import{deserializeSCIP as En,SymbolRole as kn}from"@c4312/scip";var re=new WeakMap,An="SCIP_RUST_SCIP_OCCURRENCE_REFERENCE_MODE";function kt(e,n){let t=new Map,r=H(),s=n.filter(u=>Ue(u,r));if(s.length===0)return t;let i=We(e);if(!i)return t;for(let u of s){let l=Ne(i,u);l!==null&&t.set(u.symbolId,l)}return t}function At(e,n){if(!Ue(n,H()))return null;let t=We(e);return t?Ne(t,n):null}function Ne(e,n){return e.referencesBySymbol.get(n.symbol)??[]}function Ue(e,n="safe"){if(!e.symbol.startsWith("rust-analyzer ")||!e.relativePath.endsWith(".rs")||ke(e.symbol)||/impl#\[[^\]]+\]\[Default\]default\(\)\.$/.test(e.symbol))return!1;if(n==="all")return!0;let t=Ee(e.symbol);if(t==="method")return!0;if(t!=="term")return!1;let r=he(e.symbol);return"kind"in r?!1:!wn(r)}function wn(e){for(let n=0;n<e.descriptors.length-1;n+=1)if(e.descriptors[n]?.suffix==="type")return!0;return!1}function We(e){if(re.has(e))return re.get(e)??null;let n=xn(e);return re.set(e,n),n}function xn(e){if(!e.generation.indexPath||!hn(e.generation.indexPath))return null;try{let n=En(me(e.generation.indexPath,{inputKind:"SCIP occurrence-reference index",maxBytes:Re})),t=new Map;for(let r of n.documents??[]){let s=r.relativePath;if(!(!s||e.isIgnored(s)))for(let i of r.occurrences??[]){if(!i.symbol||(i.symbolRoles&kn.Definition)!==0)continue;let u=_n(s,i.range);if(!u)continue;let l=t.get(i.symbol)??[];l.push(u),t.set(i.symbol,l)}}for(let[r,s]of t)t.set(r,_e(s));return{referencesBySymbol:t}}catch{return null}}function _n(e,n){if(n.length<3)return null;let t=n[0],r=n[1];return!Number.isInteger(t)||!Number.isInteger(r)?null:{file:e,line:t,column:r}}function H(){return process.env[An]==="all"?"all":"safe"}function Fe(e){let n=Me(De,e),t=n.runnable;return t?{available:!0,dependencyAvailable:t,resolvedBinary:n.resolvedBinary??void 0,note:"rust-analyzer semantic reference queries are enabled."}:{available:!1,dependencyAvailable:t,resolvedBinary:n.resolvedBinary??void 0,reason:"rust-analyzer is not runnable; Rust semantic checks will use SCIP/source evidence only."}}var Le=new Map;function se(e){let t=Fe(e).resolvedBinary??null;return{engine:"rust-analyzer",resolvedBinary:t,version:t?vn(e,t):"unavailable"}}function Tt(e){return{...se(e),scipOccurrenceReferenceMode:H()}}function vn(e,n){let t=`${e}\0${n}`,r=Le.get(t);if(r)return r;let s;try{s=Cn(n,["--version"],{cwd:e,encoding:"utf8",stdio:["ignore","pipe","ignore"],windowsHide:!0,timeout:2e3}).trim()}catch{s="unknown"}return Le.set(t,s),s}import{createHash as qn}from"crypto";var Tn=new Set(["Cargo.lock","Cargo.toml","rust-project.json","rust-toolchain","rust-toolchain.toml"]);function je(e){let n=Ie(e,{includePath:Pn});return qn("sha256").update(JSON.stringify(n)).digest("hex")}function Pn(e){let n=e.replaceAll("\\","/"),t=n.split("/").at(-1)??n;return n.endsWith(".rs")||Tn.has(t)?!0:n===".cargo/config"||n===".cargo/config.toml"||n.endsWith("/.cargo/config")||n.endsWith("/.cargo/config.toml")}var Ln=5e3,Je=10,jn=3e4;function Ke(e,n,t,r=nn){let s=r.engineIdentity(e),i={protocolVersion:b,projectRoot:r.canonicalProjectRoot(e),projectFingerprint:r.projectFingerprint(e),engine:{engine:s.engine,resolvedBinary:s.resolvedBinary,version:s.version},workerFingerprint:r.fileFingerprint(n),environment:Xe(r.environment())};return{key:oe(x(i)),...i}}var ze=class{constructor(n,t=Vn){this.createRequester=n;this.applyEnvironment=t}createRequester;applyEnvironment;requester=null;identityKey=null;semanticResponseCache=null;handle(n){this.applyEnvironment(n.workerEnvironment??{});let t;if(this.requester?this.identityKey!==n.identityKey?(this.semanticResponseCache=null,this.requester.shutdown(),this.requester=this.createRequester(),this.identityKey=n.identityKey,t="invalidated"):t="reused":(this.requester=this.createRequester(),this.identityKey=n.identityKey,t="created"),n.kind==="semantic"){let r=Kn(n.request),s=t==="reused"&&r!==null&&this.semanticResponseCache?.identityKey===n.identityKey&&this.semanticResponseCache.requestKey===r?this.semanticResponseCache.response:null;if(s)return Ve(!0,n.request.definitions.length),{session:t,response:s};let i=this.requester.requestSemantic(n.request,n.timeoutMs);return r!==null&&zn(i)&&(this.semanticResponseCache={identityKey:n.identityKey,requestKey:r,response:i}),Ve(!1,n.request.definitions.length),{session:t,response:i}}return{session:t,response:this.requester.requestImportDefinitions(n.request,n.timeoutMs)}}shutdown(){this.requester?.shutdown(),this.requester=null,this.identityKey=null,this.semanticResponseCache=null}};function Kn(e){if(e.includeReferences===!1||e.includeCallees!==!0||e.includeSignatures===!0||(e.referenceDefinitions?.length??0)===0||(e.calleeDefinitions?.length??0)===0)return null;let{readinessDeadlineMs:n,...t}=e;return oe(x(t))}function zn(e){return e.available&&Array.isArray(e.callees)&&(e.incompleteReferenceSymbolIds?.length??0)===0}function Ve(e,n){C()&&v({type:"span",name:"rust.semantic.durable-session.response-cache",durationMs:0,ok:!0,hit:e,definitions:n})}function P(e,n,t,r){if(e.protocolVersion!==b||!t(e.pid))return!1;if(!e.processIdentity)return!0;let s=r?.(e.pid);return s!=null&&Se(e.processIdentity,s)}function ie(e,n,t){let r;try{r=J(n,{maxBytes:E,inputKind:"Rust semantic engine artifact"})}catch{r="missing"}let s=oe(x({projectRoot:_(e),serverPath:_(n),serverFingerprint:r})).slice(0,20);return _(t,`codebaseiq-rust-session-${s}`)}function He(e){let n=e===void 0?Number.NaN:Number(e);return Number.isInteger(n)&&n>=0?n:0}function Xe(e){return Object.fromEntries(Object.entries(e).filter(([n])=>Ze(n)).sort(([n],[t])=>n.localeCompare(t)).map(([n,t])=>[n,t??null]))}function Ge(e,n){let t=n.runtime??Jn,r=n.identityRuntime??nn,s=ie(e,n.serverPath,n.tempRoot??Fn()),i=!1,u=(l,d)=>{if(i)throw new Error("Durable Rust semantic session was already disposed.");return $n(s,n.serverPath,n.semanticWorkerPath,l,d,t,n.mailboxLimits)};return{requestSemantic(l,d){let R=Ke(e,n.semanticWorkerPath,l,r),{readinessDeadlineMs:c,...o}=l;return u({kind:"semantic",identityKey:R.key,workerEnvironment:Ye(),request:{...o,referenceRetryTimeoutMs:Hn(process.env.SCIP_RUST_SEMANTIC_REFERENCE_RETRY_TIMEOUT_MS,l.referenceRetryTimeoutMs),settleDelayMs:process.env.SCIP_RUST_SEMANTIC_SETTLE_MS===void 0?l.settleDelayMs:He(process.env.SCIP_RUST_SEMANTIC_SETTLE_MS)},timeoutMs:d},d)},requestImportDefinitions(l,d){let R=Ke(e,n.semanticWorkerPath,l,r),{readinessDeadlineMs:c,...o}=l;return u({kind:"import-definitions",identityKey:R.key,workerEnvironment:Ye(),request:{...o,settleDelayMs:process.env.SCIP_RUST_SEMANTIC_SETTLE_MS===void 0?l.settleDelayMs:He(process.env.SCIP_RUST_SEMANTIC_SETTLE_MS)},timeoutMs:d},d)},shutdown(){i=!0}}}function Vn(e){for(let n of Object.keys(process.env))en(n)&&delete process.env[n];for(let[n,t]of Object.entries(e))t!==null&&(process.env[n]=t)}function Hn(e,n){return n!==void 0?n:e===void 0?jn:void 0}function $n(e,n,t,r,s,i,u={}){let l=i.now(),d=l+s,R=(i.monotonicNow??w)(),c=R+s,o=q("rust-semantic-v3",r),a=K(o),p=Ae(e),m=V(e),y=we(p,{mailboxVersion:k,protocolVersion:b,id:a,operationKey:o,clientId:i.randomId(),enqueuedAtMs:l,deadlineAtMs:d,sessionIdentity:m,request:r},{nowMs:l,limits:u});for($e(e,n,t,c,i);(i.monotonicNow??w)()<=c;){if(Qe(y.responsePath)){let D=Yn(A(y.responsePath,{maxBytes:u.maxItemBytes??E,inputKind:"durable Rust semantic mailbox response"}),{requestId:a,operationKey:o,sessionIdentity:m,deadlineAtMs:y.authoritativeDeadlineAtMs,requestKind:r.kind,nowMs:i.now()});if(!D.ok)throw new Error(D.error);return C()&&v({type:"span",name:"rust.semantic.durable-session.request",durationMs:(i.monotonicNow??w)()-R,ok:!0,session:D.session,kind:r.kind}),D.response}let h=B(e);(!h||!P(h,i.now(),i.isProcessAlive,i.readProcessIdentity))&&$e(e,n,t,c,i),i.sleep(Je)}throw new Error(`Durable Rust semantic session timed out after ${(s/1e3).toFixed(0)}s.`)}function $e(e,n,t,r,s){let i=B(e);if(i&&P(i,s.now(),s.isProcessAlive,s.readProcessIdentity))return;Wn(_(e,"server.json"),{force:!0}),s.spawnServer(n,e,t);let u=s.monotonicNow??w,l=Math.min(r,u()+Ln);for(;u()<=l;){let d=B(e);if(d&&P(d,s.now(),s.isProcessAlive,s.readProcessIdentity))return;s.sleep(Je)}throw new Error("Durable Rust semantic session helper did not become ready within 5s.")}function B(e){try{let n=JSON.parse(A(_(e,"server.json"),{maxBytes:pe,inputKind:"durable Rust session state"}));if(typeof n.protocolVersion!="number"||n.sessionIdentity!==void 0&&(typeof n.sessionIdentity!="string"||n.sessionIdentity!==V(e))||typeof n.pid!="number"||typeof n.heartbeatAtMs!="number"||n.busyUntilMs!==void 0&&typeof n.busyUntilMs!="number"||n.mailbox!==void 0&&!Qn(n.mailbox))return null;let t=n.processIdentity===void 0?null:ye(n.processIdentity);return n.processIdentity!==void 0&&(!t||t.pid!==n.pid)?null:{protocolVersion:n.protocolVersion,...n.sessionIdentity===void 0?{}:{sessionIdentity:n.sessionIdentity},pid:n.pid,...t?{processIdentity:t}:{},heartbeatAtMs:n.heartbeatAtMs,...n.busyUntilMs===void 0?{}:{busyUntilMs:n.busyUntilMs},...n.mailbox===void 0?{}:{mailbox:n.mailbox}}}catch{return null}}function Yn(e,n){try{return te(JSON.parse(e),n)}catch(t){return{ok:!1,code:"malformed-response",error:`helper wrote malformed JSON: ${t instanceof Error?t.message:String(t)}`}}}function Qn(e){if(!e||typeof e!="object")return!1;let n=e;return f(n.pending)&&f(n.inflight)&&f(n.responses)&&f(n.deadLetters)&&f(n.invalid)&&f(n.totalItems)&&typeof n.totalBytes=="number"&&Number.isFinite(n.totalBytes)&&n.totalBytes>=0&&(n.oldestPendingAt===void 0||Number.isFinite(Date.parse(n.oldestPendingAt)))}function Ye(){return Object.fromEntries(Object.entries(process.env).filter(([e])=>en(e)).sort(([e],[n])=>e.localeCompare(n)).map(([e,n])=>[e,n??null]))}function Ze(e){return e==="HOME"||e==="PATH"||e.startsWith("CARGO_")||e.startsWith("RA_")||e.startsWith("RUST")}function en(e){return Ze(e)||e.startsWith("SCIP_RUST_")||e==="CODEBASEIQ_PROFILE"||e==="CODEBASEIQ_PROFILE_CACHE_STATE"||e==="CODEBASEIQ_PROFILE_COMMAND"||e==="CODEBASEIQ_PROFILE_OUT"||e==="CODEBASEIQ_PROFILE_RUN_ID"||e==="CODEBASEIQ_PROFILE_WORKLOAD_IDENTITY"||e==="CODEBASEIQ_PROFILE_WORKLOAD_IDENTITY_KIND"||e==="CODEBASEIQ_PROFILE_MIN_MS"}var nn={canonicalProjectRoot(e){try{return Un(e)}catch{return _(e)}},projectFingerprint(e){return je(e)},engineIdentity:se,fileFingerprint(e){return J(e,{maxBytes:E,inputKind:"Rust semantic engine artifact"})},environment(){return Xe(process.env)}},Jn={now:Date.now,monotonicNow:w,randomId:Nn,isProcessAlive:j,readProcessIdentity:L,spawnServer(e,n,t){if(!Qe(e))throw new Error(`Durable Rust semantic session helper was not found at ${e}. Run npm run build first.`);Bn(process.execPath,[e,n,t],{detached:!0,stdio:"ignore",windowsHide:!0}).unref()},sleep(e){let n=new Int32Array(new SharedArrayBuffer(4));Atomics.wait(n,0,0,e)}};function oe(e){return On("sha256").update(e).digest("hex")}import{existsSync as Xn,mkdtempSync as tn,rmSync as ue}from"fs";import{tmpdir as de}from"os";import{join as le}from"path";import{fileURLToPath as F,pathToFileURL as Gn}from"url";import{SHARE_ENV as Zn,Worker as et}from"worker_threads";function $(e,n,t=new Set){let r=new Map;for(let s of e)t.has(s.symbolId)||r.set(s.symbolId,n.get(s.symbolId)??[]);return r}function ae(e,n,t){let r=z(process.env.SCIP_RUST_SEMANTIC_BATCH_TIMEOUT_MS)??0;if(r>0)return r;let s=Math.max(1,Math.ceil(e/Math.max(1,t)));return Math.max(12e4,3e4+s*n)}var rn=15e3,sn=8,an=5e3,nt=64,tt=96,fe=class{constructor(n,t,r={}){this.projectRoot=n;this.status=t;this.opts=r;this.requester=r.requester??ot(n,process.env.SCIP_RUST_SEMANTIC_DURABLE_SESSION)}projectRoot;status;opts;requester;referencesForDefinitions(n){let t=this.status(this.projectRoot);if(!t.available||!t.resolvedBinary)return{available:!1,resolvedBinary:t.resolvedBinary,reason:N(t),references:U(n)};try{let r=this.requestSession(t.resolvedBinary,n,{includeReferences:!0});return{...O(r),resolvedBinary:t.resolvedBinary,references:$(n,new Map(r.references),new Set(r.incompleteReferenceSymbolIds??[]))}}catch(r){return this.opts.fallbackReferenceResolver?.referencesForDefinitions(n)??{available:!1,resolvedBinary:t.resolvedBinary,reason:r instanceof Error?r.message:String(r),references:U(n)}}}calleesForDefinitions(n){let t=this.status(this.projectRoot);if(!t.available||!t.resolvedBinary)return{available:!1,resolvedBinary:t.resolvedBinary,reason:N(t),callees:W(n)};try{let r=this.requestSession(t.resolvedBinary,n,{includeReferences:!1,includeCallees:!0});return{...O(r),resolvedBinary:t.resolvedBinary,callees:ce(n,new Map(r.callees??[]))}}catch(r){return this.opts.fallbackCalleeResolver?.calleesForDefinitions(n)??{available:!1,resolvedBinary:t.resolvedBinary,reason:r instanceof Error?r.message:String(r),callees:W(n)}}}referencesAndCalleesForDefinitions(n,t){let r=this.status(this.projectRoot);if(!r.available||!r.resolvedBinary)return{available:!1,resolvedBinary:r.resolvedBinary,reason:N(r),references:U(n),callees:W(t)};let s=[...n,...t];try{let i=this.requestSession(r.resolvedBinary,s,{includeReferences:n.length>0,includeCallees:t.length>0,referenceDefinitions:n,calleeDefinitions:t});return{...O(i),resolvedBinary:r.resolvedBinary,references:$(n,new Map(i.references),new Set(i.incompleteReferenceSymbolIds??[])),callees:ce(t,new Map(i.callees??[]))}}catch(i){return this.fallbackReferencesAndCallees(r,n,t,i)}}signaturesForDefinitions(n){let t=this.status(this.projectRoot);if(!t.available||!t.resolvedBinary)return{available:!1,resolvedBinary:t.resolvedBinary,reason:N(t),signatures:on(n)};try{let r=this.requestSession(t.resolvedBinary,n,{includeReferences:!1,includeCallees:!1,includeSignatures:!0});return{...O(r),resolvedBinary:t.resolvedBinary,signatures:dt(n,new Map(r.signatures??[]))}}catch(r){return this.opts.fallbackSignatureResolver?.signaturesForDefinitions(n)??{available:!1,resolvedBinary:t.resolvedBinary,reason:r instanceof Error?r.message:String(r),signatures:on(n)}}}importDefinitionsForFile(n,t){let r=this.status(this.projectRoot);if(t.length===0)return r.available?{available:!0,resolvedBinary:r.resolvedBinary,sourcePaths:new Map}:{available:!1,reason:r.reason,resolvedBinary:r.resolvedBinary,sourcePaths:new Map};if(!r.available||!r.resolvedBinary)return{available:!1,resolvedBinary:r.resolvedBinary,reason:N(r),sourcePaths:new Map(t.map(s=>[s.id,null]))};try{let s=this.requestImportDefinitions(r.resolvedBinary,n,t);return{...O(s),resolvedBinary:r.resolvedBinary,sourcePaths:new Map(s.sourcePaths)}}catch(s){return{available:!1,resolvedBinary:r.resolvedBinary,reason:s instanceof Error?s.message:String(s),sourcePaths:new Map(t.map(i=>[i.id,null]))}}}dispose(){this.requester.shutdown()}requestSession(n,t,r){let s=Y(process.env.SCIP_RUST_SEMANTIC_REQUEST_TIMEOUT_MS,rn),i=Q(process.env.SCIP_RUST_SEMANTIC_REFERENCE_RETRY_TIMEOUT_MS,0),u=Y(process.env.SCIP_RUST_SEMANTIC_CONCURRENCY,sn),l=Q(process.env.SCIP_RUST_SEMANTIC_DIAGNOSTICS_TIMEOUT_MS,Math.min(s,1e4)),d=r.referenceDefinitions?[...r.referenceDefinitions]:void 0,R=r.calleeDefinitions?[...r.calleeDefinitions]:void 0,c=r.signatureDefinitions?[...r.signatureDefinitions]:void 0,o=rt(process.env.SCIP_RUST_SEMANTIC_SETTLE_MS,{definitionCount:t.length,...r}),a={projectRoot:this.projectRoot,rustAnalyzerBinary:n,definitions:[...t],...d?{referenceDefinitions:d}:{},...R?{calleeDefinitions:R}:{},...c?{signatureDefinitions:c}:{},requestTimeoutMs:s,...r.includeReferences!==!1&&i>0?{referenceRetryTimeoutMs:i}:{},diagnosticsTimeoutMs:l,settleDelayMs:o,concurrency:u,includeReferences:r.includeReferences,includeCallees:r.includeCallees,includeSignatures:r.includeSignatures},p=ft(a);return G("rust.semantic.session.request",()=>this.requester.requestSemantic(a,ae(p,pt(s,a.referenceRetryTimeoutMs),u)),()=>({definitions:t.length,operationDefinitions:p,referenceDefinitions:a.referenceDefinitions?.length,calleeDefinitions:a.calleeDefinitions?.length,signatureDefinitions:a.signatureDefinitions?.length,references:a.includeReferences!==!1,callees:a.includeCallees===!0,signatures:a.includeSignatures===!0,referenceRetryTimeoutMs:a.referenceRetryTimeoutMs}))}fallbackReferencesAndCallees(n,t,r,s){let i=t.length===0?{available:!0,resolvedBinary:n.resolvedBinary,references:U(t)}:this.opts.fallbackReferenceResolver?.referencesForDefinitions(t),u=r.length===0?{available:!0,resolvedBinary:n.resolvedBinary,callees:W(r)}:this.opts.fallbackCalleeResolver?.calleesForDefinitions(r);if(i&&u){let l={resolvedBinary:i.resolvedBinary??u.resolvedBinary??n.resolvedBinary,references:$(t,i.references),callees:ce(r,u.callees)};return i.available&&u.available?{available:!0,...l}:{available:!1,reason:(i.available?void 0:i.reason)??(u.available?void 0:u.reason)??"Rust semantic fallback was unavailable.",...l}}return{available:!1,resolvedBinary:n.resolvedBinary,reason:s instanceof Error?s.message:String(s),references:U(t),callees:W(r)}}requestImportDefinitions(n,t,r){let s=Y(process.env.SCIP_RUST_SEMANTIC_REQUEST_TIMEOUT_MS,rn),i=Y(process.env.SCIP_RUST_SEMANTIC_CONCURRENCY,sn),u=Q(process.env.SCIP_RUST_SEMANTIC_DIAGNOSTICS_TIMEOUT_MS,Math.min(s,1e4)),l=Q(process.env.SCIP_RUST_SEMANTIC_SETTLE_MS,an),d={projectRoot:this.projectRoot,rustAnalyzerBinary:n,file:t,positions:[...r],requestTimeoutMs:s,diagnosticsTimeoutMs:u,settleDelayMs:l,concurrency:i};return G("rust.semantic.import-definitions.session.request",()=>this.requester.requestImportDefinitions(d,ae(r.length,s,i)),()=>({file:t,positions:r.length}))}};function O(e){return e.available?{available:!0}:{available:!1,reason:e.reason}}function N(e){return e.available?"rust-analyzer binary path is unavailable.":e.reason}function Sr(e,n,t={}){return new fe(e,n,t)}function rt(e,n){let t=dn(e);if(t!==null)return t;let r=n.includeReferences!==!1;return r&&n.includeCallees!==!0&&n.includeSignatures!==!0&&n.definitionCount<=nt||r&&n.includeCallees===!0&&n.includeSignatures!==!0&&n.definitionCount<=tt?0:an}function un(e){let n=e?.trim().toLowerCase(),t=n==="0"||n==="false"||n==="off"||n==="worker",r=n==="1"||n==="true"||n==="on"||n==="durable",s=n===void 0||n==="";return{transport:t||!s&&!r?"worker":"durable",source:s?"default":"environment",fallback:"worker",valid:s||t||r,optOut:"SCIP_RUST_SEMANTIC_DURABLE_SESSION=0"}}function st(e){return un(e).transport}function br(e,n){let t=un(n);if(t.transport==="worker")return{...t,state:"per-command"};let r=F(cn()),s=ie(e,r,de()),i=B(s);return i?{...t,state:P(i,Date.now(),j,L)?"live":"stale",pid:i.pid,heartbeatAtMs:i.heartbeatAtMs,...i.busyUntilMs===void 0?{}:{busyUntilMs:i.busyUntilMs}}:{...t,state:"stopped"}}function it(e,n){let t=null,r=!1,s=!1,i=!1,u=()=>t??=n(),l=()=>{s||(e.shutdown(),s=!0)},d=(c,o,a)=>{let p=ct(c);r=!0;try{l()}catch{}C()&&v({type:"span",name:"rust.semantic.durable-session.request",durationMs:a,ok:!1,kind:o,session:"worker-fallback",reason:p})},R=(c,o,a)=>{if(i)throw new Error("Rust semantic failover session was already disposed.");if(r)return a(u());let p=performance.now();try{return o(e)}catch(m){d(m,c,performance.now()-p)}return a(u())};return{requestSemantic(c,o){return R("semantic",a=>a.requestSemantic(c,o),a=>a.requestSemantic(c,o))},requestImportDefinitions(c,o){return R("import-definitions",a=>a.requestImportDefinitions(c,o),a=>a.requestImportDefinitions(c,o))},shutdown(){if(i)return;i=!0;let c=[];try{l()}catch(o){c.push(o)}try{t?.shutdown()}catch(o){c.push(o)}if(c.length>0)throw c[0]}}}function ot(e,n,t={worker:()=>at(),durable:()=>Ge(e,{serverPath:F(cn()),semanticWorkerPath:F(ln())})}){return st(n)==="durable"?it(t.durable(),t.worker):t.worker()}function at(e={}){let n=null,t=null,r=1,s=!1,i=null,u=null,l=o=>{o&&ue(o,{recursive:!0,force:!0})},d=()=>{if(i)return;let o=n,a=t;n=null,t=null;let p=o?o.terminate():Promise.resolve(0);i=Promise.allSettled([p,xe(a,{gracefulMs:1e3,forceMs:1e3})]).then(([m,y])=>{let D=(y.status==="fulfilled"?y.value:[{reaped:!1,detail:String(y.reason)}]).filter(g=>!g.reaped);if(m.status==="rejected"||D.length>0){u=new Error(`Rust semantic worker cleanup did not complete; ownership evidence remains at ${a??"unknown"}.`);return}l(a)}).finally(()=>{i=null})},R=()=>{if(n)return n;if(i)throw new Error("The previous Rust semantic session worker is still terminating; retry the request.");if(u)throw u;let o=e.semanticWorkerPath?Gn(e.semanticWorkerPath):ln();if(!Xn(F(o)))throw new Error(`Rust semantic session worker was not found at ${F(o)}. Run npm run build before using built semantic Rust queries.`);return t=tn(le(de(),"codebaseiq-rust-session-")),n=new et(o,e.shareEnvironment?{env:Zn}:void 0),n.unref(),n},c=()=>{let o=t??tn(le(de(),"codebaseiq-rust-session-"));return t=o,le(o,`${r++}.json`)};return{requestSemantic(o,a){if(s)throw new Error("Rust semantic session was already disposed.");let p=R(),m=c(),y=new SharedArrayBuffer(4),h=new Int32Array(y);if(p.postMessage({kind:"semantic",request:o,responsePath:m,sharedBuffer:y}),Atomics.wait(h,0,0,a)==="timed-out")throw d(),new Error(`Rust semantic session worker timed out after ${(a/1e3).toFixed(0)}s`);try{let g=ut(A(m,{maxBytes:E,inputKind:"Rust semantic worker response"}));if(!g.ok)throw new Error(g.error);return g.response}finally{ue(m,{force:!0})}},requestImportDefinitions(o,a){if(s)throw new Error("Rust semantic session was already disposed.");let p=R(),m=c(),y=new SharedArrayBuffer(4),h=new Int32Array(y);if(p.postMessage({kind:"import-definitions",request:o,responsePath:m,sharedBuffer:y}),Atomics.wait(h,0,0,a)==="timed-out")throw d(),new Error(`Rust semantic import-definition session worker timed out after ${(a/1e3).toFixed(0)}s`);try{let g=lt(A(m,{maxBytes:E,inputKind:"Rust import-definition worker response"}));if(!g.ok)throw new Error(g.error);return g.response}finally{ue(m,{force:!0})}},shutdown(){if(s)return;if(s=!0,!n){l(t),t=null;return}let o=c(),a=new SharedArrayBuffer(4),p=new Int32Array(a);n.postMessage({kind:"shutdown",responsePath:o,sharedBuffer:a}),Atomics.wait(p,0,0,5e3),d()}}}function ut(e){let n=JSON.parse(e);if(!n||typeof n!="object")return{ok:!1,error:"Rust semantic session worker wrote a non-object response."};let t=n;return t.ok===!0&&"response"in t?{ok:!0,response:t.response}:{ok:!1,error:typeof n.error=="string"?n.error:"Rust semantic session worker failed."}}function lt(e){let n=JSON.parse(e);if(!n||typeof n!="object")return{ok:!1,error:"Rust semantic session worker wrote a non-object response."};let t=n;return t.ok===!0&&"response"in t?{ok:!0,response:t.response}:{ok:!1,error:typeof n.error=="string"?n.error:"Rust semantic session worker failed."}}function ct(e){let n=e instanceof Error?`${e.name} ${e.message}`.toLowerCase():String(e).toLowerCase();return n.includes("readiness")?"readiness":n.includes("timeout")||n.includes("timed out")?"timeout":n.includes("helper")?"helper":"request"}function U(e){return new Map(e.map(n=>[n.symbolId,[]]))}function W(e){return new Map(e.map(n=>[n.symbolId,[]]))}function on(e){return new Map(e.map(n=>[n.symbolId,null]))}function ce(e,n){return new Map(e.map(t=>[t.symbolId,n.get(t.symbolId)??[]]))}function dt(e,n){return new Map(e.map(t=>[t.symbolId,n.get(t.symbolId)??null]))}function ft(e){let n=0;return e.includeReferences!==!1&&(n+=(e.referenceDefinitions??e.definitions).length),e.includeCallees===!0&&(n+=(e.calleeDefinitions??e.definitions).length),e.includeSignatures===!0&&(n+=(e.signatureDefinitions??e.definitions).length),Math.max(1,n)}function pt(e,n){return n&&n>0?Math.max(e,n):e}function ln(){return new URL("./rust-semantic-session-worker.js",import.meta.url)}function cn(){return new URL("./rust-semantic-session-server.js",import.meta.url)}function Y(e,n){return z(e)??n}function Q(e,n){return dn(e)??n}function dn(e){if(!e)return null;let n=Number(e);return Number.isInteger(n)&&n>=0?n:null}export{kt as a,At as b,Fe as c,Tt as d,b as e,V as f,Rn as g,ze as h,$ as i,ae as j,Sr as k,rt as l,br as m,at as n,pt as o};
2
- //# sourceMappingURL=chunk-HCMQZPEO.js.map