codebaseiq 0.1.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (447) hide show
  1. package/CHANGELOG.md +89 -0
  2. package/README.md +1 -1
  3. package/dist/augment-vue-worker.js +1 -1
  4. package/dist/{chunk-ZMI2JSX2.js → chunk-23C5AD3B.js} +2 -2
  5. package/dist/chunk-2E6OUPCF.js +2 -0
  6. package/dist/chunk-2EDX3JT5.js +3 -0
  7. package/dist/chunk-2I2UHZET.js +2 -0
  8. package/dist/{chunk-T3DGWPXM.js → chunk-2OMXFE64.js} +2 -2
  9. package/dist/chunk-2PRONPAS.js +3 -0
  10. package/dist/{chunk-GW6Z3WGY.js → chunk-356EZBIP.js} +2 -2
  11. package/dist/{chunk-UDS562V4.js → chunk-36JC5BG2.js} +2 -2
  12. package/dist/chunk-3RR2K7EZ.js +20 -0
  13. package/dist/{chunk-JE3WZ6II.js → chunk-3RSBGWGL.js} +2 -2
  14. package/dist/{chunk-VE5AVNMP.js → chunk-3VJ3OCRE.js} +2 -2
  15. package/dist/{chunk-FDGD5AB5.js → chunk-4LK5OIPW.js} +2 -2
  16. package/dist/chunk-5DSL3NT2.js +17 -0
  17. package/dist/chunk-5FWR5HLG.js +90 -0
  18. package/dist/chunk-5IC2WZAL.js +22 -0
  19. package/dist/{chunk-MVB3DAEY.js → chunk-5IZRKWTZ.js} +2 -2
  20. package/dist/{chunk-Q65CQ4XL.js → chunk-5LL4KEHO.js} +2 -2
  21. package/dist/chunk-5T44HG5Y.js +88 -0
  22. package/dist/{chunk-TRRC4ZJ7.js → chunk-5ZI2PPI7.js} +2 -2
  23. package/dist/{chunk-7XAN6GKB.js → chunk-67VJAYVR.js} +2 -2
  24. package/dist/{chunk-MOVBWNIP.js → chunk-6BF3VYEF.js} +2 -2
  25. package/dist/chunk-6JMAVFL4.js +3 -0
  26. package/dist/chunk-6O3KXIDL.js +2 -0
  27. package/dist/{chunk-JOIRNPPY.js → chunk-6VREELBC.js} +2 -2
  28. package/dist/chunk-6WAPPQ5F.js +82 -0
  29. package/dist/{chunk-FW53T7EB.js → chunk-75KJGYX7.js} +2 -2
  30. package/dist/chunk-7GAK2F3H.js +77 -0
  31. package/dist/{chunk-UBGWN7I4.js → chunk-7JELP5YE.js} +2 -2
  32. package/dist/chunk-7UCDGXRW.js +8 -0
  33. package/dist/{chunk-L57ZKWVG.js → chunk-AEXQYQD7.js} +2 -2
  34. package/dist/chunk-AQI4N64O.js +22 -0
  35. package/dist/{chunk-ICFDQHAM.js → chunk-AURCQHSG.js} +2 -2
  36. package/dist/{chunk-I2T2LLK2.js → chunk-BBP7HVBJ.js} +2 -2
  37. package/dist/{chunk-OFBE4NGP.js → chunk-BFBIMTCJ.js} +2 -2
  38. package/dist/{chunk-JEJLSICM.js → chunk-BGGB5N53.js} +2 -2
  39. package/dist/{chunk-TIIC3ZE7.js → chunk-BRQL7AFJ.js} +2 -2
  40. package/dist/{chunk-YSNONTJ2.js → chunk-BWL3PMPT.js} +2 -2
  41. package/dist/chunk-C6WKPKCF.js +127 -0
  42. package/dist/{chunk-YESXMKX3.js → chunk-C7OUW52M.js} +2 -2
  43. package/dist/chunk-C7QWUBR2.js +545 -0
  44. package/dist/{chunk-4WKDMDEW.js → chunk-CCIYWXX6.js} +2 -2
  45. package/dist/{chunk-FAJQ7LWY.js → chunk-CIYA2KZN.js} +2 -2
  46. package/dist/{chunk-VEXUL62T.js → chunk-CR3OG6SQ.js} +2 -2
  47. package/dist/{chunk-JSOYNVWH.js → chunk-CVHOQONG.js} +2 -2
  48. package/dist/{chunk-LU3BMVH2.js → chunk-CW6AXOLR.js} +2 -2
  49. package/dist/{chunk-TXXOEMZJ.js → chunk-D53LWANR.js} +2 -2
  50. package/dist/{chunk-DO6WQD2T.js → chunk-D62CTZX6.js} +2 -2
  51. package/dist/{chunk-N3IQCBCF.js → chunk-D7AZAOZX.js} +2 -2
  52. package/dist/{chunk-RDBI2RXU.js → chunk-D7DOB27N.js} +7 -7
  53. package/dist/chunk-DAKIGMIK.js +21 -0
  54. package/dist/chunk-DDN2F6GB.js +2 -0
  55. package/dist/chunk-DUKHVPU5.js +4 -0
  56. package/dist/chunk-DVWO7RBC.js +2 -0
  57. package/dist/{chunk-HKQUXIFO.js → chunk-E52K4L2W.js} +2 -2
  58. package/dist/chunk-EIBGSU2R.js +2 -0
  59. package/dist/chunk-EN4AHLL3.js +3 -0
  60. package/dist/chunk-EQNMD62X.js +51 -0
  61. package/dist/{chunk-ENCCHKM6.js → chunk-EXZ7VLRY.js} +4 -4
  62. package/dist/{chunk-NEDP5RFQ.js → chunk-F3QSL4W2.js} +2 -2
  63. package/dist/{chunk-O6QTXQPJ.js → chunk-F74LZWCE.js} +2 -2
  64. package/dist/{chunk-BH5F2Q4O.js → chunk-FEIZXBLH.js} +2 -2
  65. package/dist/chunk-FH5WG4LE.js +2 -0
  66. package/dist/{chunk-BVAJLC5A.js → chunk-FOZ74V56.js} +2 -2
  67. package/dist/{chunk-L4NRUAGJ.js → chunk-FQTIFWLR.js} +2 -2
  68. package/dist/chunk-FTTV7IRX.js +355 -0
  69. package/dist/chunk-FWQGH2N2.js +2 -0
  70. package/dist/{chunk-CAUCPUOF.js → chunk-GDHWOA57.js} +2 -2
  71. package/dist/{chunk-6MUIJMVL.js → chunk-GIDCP7KV.js} +2 -2
  72. package/dist/{chunk-ZV3JV5G5.js → chunk-GL6UTNUB.js} +2 -2
  73. package/dist/chunk-GP7C5VAE.js +2 -0
  74. package/dist/{chunk-FQKZWM4L.js → chunk-GQLDYCWS.js} +5 -5
  75. package/dist/chunk-GQXXOS55.js +2 -0
  76. package/dist/{chunk-H3LGFZVK.js → chunk-GUFPEFBG.js} +2 -2
  77. package/dist/{chunk-NNOKTMZT.js → chunk-GV2CEZCW.js} +2 -2
  78. package/dist/{chunk-FETNQCFO.js → chunk-GVAF222T.js} +2 -2
  79. package/dist/chunk-GWYZVVKY.js +21 -0
  80. package/dist/{chunk-7FND7D7N.js → chunk-HENP2O4A.js} +2 -2
  81. package/dist/{chunk-LZYFLFEH.js → chunk-HINZQKSY.js} +2 -2
  82. package/dist/{chunk-RR7SX44N.js → chunk-HQA7EBSK.js} +2 -2
  83. package/dist/{chunk-XMQ23E27.js → chunk-HVFB3PME.js} +2 -2
  84. package/dist/chunk-I22IZYDI.js +2 -0
  85. package/dist/chunk-ICUL7XRT.js +21 -0
  86. package/dist/{chunk-CQP3THUZ.js → chunk-IHSLIIL3.js} +2 -2
  87. package/dist/{chunk-34WBMAYK.js → chunk-ITSJMNUD.js} +2 -2
  88. package/dist/{chunk-PX4RYAAK.js → chunk-IZDPGOZR.js} +2 -2
  89. package/dist/chunk-J3GLP7Q5.js +3 -0
  90. package/dist/{chunk-CVYSU6BX.js → chunk-J7AMBVWF.js} +2 -2
  91. package/dist/{chunk-Y6KHROC3.js → chunk-JCMFBF4Z.js} +2 -2
  92. package/dist/chunk-JFIA2JI3.js +3 -0
  93. package/dist/chunk-JLZLLLW5.js +3 -0
  94. package/dist/{chunk-5PUWMSDU.js → chunk-JSNTHRLQ.js} +2 -2
  95. package/dist/{chunk-C6SBF2WH.js → chunk-JX6ZWDOS.js} +2 -2
  96. package/dist/{chunk-4XTAUQFD.js → chunk-JYI7CV25.js} +2 -2
  97. package/dist/chunk-K7JLSGCJ.js +8 -0
  98. package/dist/{chunk-XWUOUWYI.js → chunk-KPZGTB2O.js} +2 -2
  99. package/dist/{chunk-VXYS3FZD.js → chunk-LKUTSP4G.js} +2 -2
  100. package/dist/{chunk-GTXSJDCO.js → chunk-LMTSB3TB.js} +2 -2
  101. package/dist/chunk-LONKINMJ.js +543 -0
  102. package/dist/{chunk-WMPRTGH2.js → chunk-LQHYYIOB.js} +2 -2
  103. package/dist/{chunk-VUIYB2V3.js → chunk-LZSQ6X7E.js} +2 -2
  104. package/dist/{chunk-ST7V3SKN.js → chunk-M2Y6PCFE.js} +2 -2
  105. package/dist/chunk-MEUHIDI3.js +7 -0
  106. package/dist/{chunk-OZYRSMSH.js → chunk-MHWMEZDA.js} +2 -2
  107. package/dist/{chunk-RKEJ6VTF.js → chunk-MQW6SJ4P.js} +2 -2
  108. package/dist/{chunk-J77SU6VA.js → chunk-MSI3K7PJ.js} +2 -2
  109. package/dist/chunk-MVRGB4KJ.js +278 -0
  110. package/dist/{chunk-DQMDCD24.js → chunk-MZNMASFM.js} +2 -2
  111. package/dist/{chunk-ID63777H.js → chunk-NBCQZSGR.js} +2 -2
  112. package/dist/chunk-NBZKSTXP.js +2 -0
  113. package/dist/{chunk-SZD2KF7Q.js → chunk-NCJILOAK.js} +2 -2
  114. package/dist/{chunk-C7QOQX32.js → chunk-NDKOVQFG.js} +2 -2
  115. package/dist/{chunk-UNBY47BC.js → chunk-NEWHKGVD.js} +2 -2
  116. package/dist/{chunk-PYAB5SM6.js → chunk-O2M3VNDY.js} +2 -2
  117. package/dist/chunk-OFGOOL6U.js +3 -0
  118. package/dist/{chunk-SWHMHUKF.js → chunk-OQUCBKOI.js} +2 -2
  119. package/dist/{chunk-7MGU3HPH.js → chunk-P4NVCOM7.js} +2 -2
  120. package/dist/{chunk-ANFVSJWQ.js → chunk-PFC44E6D.js} +2 -2
  121. package/dist/{chunk-EZNMUY67.js → chunk-PHNCEUXX.js} +2 -2
  122. package/dist/{chunk-4FC325IF.js → chunk-PTQPPPG2.js} +2 -2
  123. package/dist/chunk-PUVNH4PO.js +3 -0
  124. package/dist/chunk-Q23IMHXS.js +343 -0
  125. package/dist/chunk-Q3ZCQY2Y.js +3 -0
  126. package/dist/{chunk-KMITESMT.js → chunk-Q4XEU3UH.js} +2 -2
  127. package/dist/{chunk-QKPLA6IC.js → chunk-QEOWONKY.js} +2 -2
  128. package/dist/{chunk-BJ6SQAEN.js → chunk-QMOZZ2VX.js} +2 -2
  129. package/dist/chunk-RCIGX23V.js +60 -0
  130. package/dist/{chunk-IOP6FWIM.js → chunk-RIYJ4L33.js} +2 -2
  131. package/dist/chunk-RJVAPMHF.js +14 -0
  132. package/dist/chunk-SB7NASHU.js +2 -0
  133. package/dist/{chunk-UZGZB3VB.js → chunk-SGMNWYTH.js} +2 -2
  134. package/dist/chunk-SMDIEDM4.js +27 -0
  135. package/dist/chunk-SV2LEFVM.js +2 -0
  136. package/dist/chunk-SX72EVMY.js +3 -0
  137. package/dist/chunk-T5X7DK6C.js +3 -0
  138. package/dist/{chunk-6NW7MU72.js → chunk-T6MQNNAC.js} +2 -2
  139. package/dist/chunk-T75DS2E6.js +21 -0
  140. package/dist/{chunk-HRWGYWRJ.js → chunk-TEANKHUU.js} +2 -2
  141. package/dist/chunk-TJBOJUVN.js +3 -0
  142. package/dist/{chunk-XLQ3GLWZ.js → chunk-TJWVT4DO.js} +2 -2
  143. package/dist/{chunk-7NVGT435.js → chunk-TNJGTQWO.js} +2 -2
  144. package/dist/{chunk-NE6IU5ZD.js → chunk-TOTWJZIX.js} +2 -2
  145. package/dist/{chunk-PBI2LFKH.js → chunk-TPO7XC5Z.js} +2 -2
  146. package/dist/{chunk-HPJRBHVT.js → chunk-U33PMPNW.js} +2 -2
  147. package/dist/{chunk-QHRNXP3C.js → chunk-U7NUXDQO.js} +2 -2
  148. package/dist/chunk-UC2FD2PS.js +4 -0
  149. package/dist/{chunk-PIOMTC27.js → chunk-UQE4XFSA.js} +2 -2
  150. package/dist/chunk-UQYQBLJX.js +5 -0
  151. package/dist/{chunk-KWVHSKHK.js → chunk-USOAJHY7.js} +2 -2
  152. package/dist/{chunk-GCHRX4YW.js → chunk-UW6KD57C.js} +2 -2
  153. package/dist/{chunk-PTAWHLVJ.js → chunk-VGWZ4MOY.js} +2 -2
  154. package/dist/{chunk-XME3HPXZ.js → chunk-VWYGCMV5.js} +2 -2
  155. package/dist/{chunk-AKB7V7TV.js → chunk-W7YLRXZE.js} +2 -2
  156. package/dist/{chunk-SYDJMPES.js → chunk-WK2IQJPK.js} +2 -2
  157. package/dist/{chunk-RBAS5ZHI.js → chunk-WWCV4E6J.js} +2 -2
  158. package/dist/{chunk-OL6KJP3N.js → chunk-XMJ53WG4.js} +2 -2
  159. package/dist/chunk-XN3EKMLI.js +4 -0
  160. package/dist/chunk-XQAVQVIL.js +3 -0
  161. package/dist/{chunk-IJ4HMYBE.js → chunk-XQPPURLQ.js} +2 -2
  162. package/dist/{chunk-OVTS4DKB.js → chunk-YHPG3S2U.js} +2 -2
  163. package/dist/{chunk-WOQBZPIF.js → chunk-YRKP7PM7.js} +2 -2
  164. package/dist/chunk-YT4DVWUV.js +11 -0
  165. package/dist/chunk-YTJHCGYB.js +61 -0
  166. package/dist/chunk-Z35GOVEH.js +2 -0
  167. package/dist/{chunk-OLF4MA5W.js → chunk-Z6RL7XOE.js} +4 -4
  168. package/dist/{chunk-UP3BUZR5.js → chunk-ZAFGY22Q.js} +2 -2
  169. package/dist/{chunk-CO5R3UNA.js → chunk-ZB4C5TTR.js} +2 -2
  170. package/dist/{chunk-ZZXSWSN6.js → chunk-ZNH33XIB.js} +2 -2
  171. package/dist/{chunk-EMNIHCRB.js → chunk-ZQ62NNKN.js} +2 -2
  172. package/dist/cli-context-FJL2JHOE.js +3 -0
  173. package/dist/cli-context-PQNWHMCQ.js +2 -0
  174. package/dist/cli-program-UO7PZD6V.js +7 -0
  175. package/dist/cli.js +1 -1
  176. package/dist/{code-DlqpBDd0.d.ts → code-DfX3xeWy.d.ts} +1 -1
  177. package/dist/code-viewer-KIXEYQNJ.js +12 -0
  178. package/dist/code-viewer-VHLBLIUM.js +11 -0
  179. package/dist/command-descriptors-F5P2V3NW.js +335 -0
  180. package/dist/command-descriptors-YCLATF5I.js +337 -0
  181. package/dist/{config-types-BNoC96J3.d.ts → config-types-D6X5S68_.d.ts} +50 -0
  182. package/dist/{db-D7sauVFH.d.ts → db-BoG_PWYH.d.ts} +2 -2
  183. package/dist/direct-navigation-4XJTXIDT.js +2 -0
  184. package/dist/direct-navigation-J5MVYYAD.js +3 -0
  185. package/dist/{graph-evidence-BIFqyisO.d.ts → graph-evidence-D1jx1Cql.d.ts} +1 -1
  186. package/dist/{health-DJaZXg8I.d.ts → health-DkYBS5BI.d.ts} +1 -1
  187. package/dist/index.d.ts +2 -2
  188. package/dist/index.js +1 -1
  189. package/dist/invocation-command-descriptors-RWV4VAI4.js +2 -0
  190. package/dist/invocation-command-descriptors-U76PN7IY.js +3 -0
  191. package/dist/{scip-cli-B7N3haxa.d.ts → maintenance-types-CdL5eQii.d.ts} +2 -21
  192. package/dist/output-continuation-command-BL25S26S.js +3 -0
  193. package/dist/output-continuation-command-BTETTXEC.js +2 -0
  194. package/dist/postinstall.js +1 -1
  195. package/dist/project-reindex-CRJU3IFG.js +2 -0
  196. package/dist/project-reindex-TQFCOA2O.js +3 -0
  197. package/dist/queries/affected.d.ts +2 -2
  198. package/dist/queries/affected.js +1 -1
  199. package/dist/queries/anchors.d.ts +2 -2
  200. package/dist/queries/anchors.js +1 -1
  201. package/dist/queries/architecture.d.ts +2 -2
  202. package/dist/queries/architecture.js +1 -1
  203. package/dist/queries/bottlenecks.d.ts +2 -2
  204. package/dist/queries/bottlenecks.js +1 -1
  205. package/dist/queries/by-kind.d.ts +2 -2
  206. package/dist/queries/by-kind.js +1 -1
  207. package/dist/queries/call-graph.d.ts +2 -2
  208. package/dist/queries/call-graph.js +1 -1
  209. package/dist/queries/change-surface.d.ts +2 -2
  210. package/dist/queries/change-surface.js +1 -1
  211. package/dist/queries/cleanup-plan.d.ts +2 -2
  212. package/dist/queries/cleanup-plan.js +1 -1
  213. package/dist/queries/co-change.d.ts +2 -2
  214. package/dist/queries/co-change.js +1 -1
  215. package/dist/queries/code.d.ts +3 -3
  216. package/dist/queries/code.js +1 -1
  217. package/dist/queries/complexity-hotspots.d.ts +2 -2
  218. package/dist/queries/complexity-hotspots.js +1 -1
  219. package/dist/queries/complexity.d.ts +2 -2
  220. package/dist/queries/complexity.js +1 -1
  221. package/dist/queries/context.d.ts +2 -2
  222. package/dist/queries/context.js +1 -1
  223. package/dist/queries/convergence.d.ts +2 -2
  224. package/dist/queries/convergence.js +1 -1
  225. package/dist/queries/coupling.d.ts +2 -2
  226. package/dist/queries/coupling.js +1 -1
  227. package/dist/queries/cycles.d.ts +2 -2
  228. package/dist/queries/cycles.js +1 -1
  229. package/dist/queries/dataflow.d.ts +2 -2
  230. package/dist/queries/dataflow.js +1 -1
  231. package/dist/queries/dead.d.ts +2 -2
  232. package/dist/queries/dead.js +1 -1
  233. package/dist/queries/decorative-checkers.d.ts +2 -2
  234. package/dist/queries/decorative-checkers.js +1 -1
  235. package/dist/queries/deep-chains.d.ts +2 -2
  236. package/dist/queries/deep-chains.js +1 -1
  237. package/dist/queries/dependence-slice.d.ts +3 -3
  238. package/dist/queries/dependence-slice.js +1 -1
  239. package/dist/queries/dependency-depth.d.ts +2 -2
  240. package/dist/queries/dependency-depth.js +1 -1
  241. package/dist/queries/deps.d.ts +2 -2
  242. package/dist/queries/deps.js +1 -1
  243. package/dist/queries/diff-impact.d.ts +2 -2
  244. package/dist/queries/diff-impact.js +1 -1
  245. package/dist/queries/doc-drift.d.ts +2 -2
  246. package/dist/queries/doc-drift.js +1 -1
  247. package/dist/queries/drift.d.ts +2 -2
  248. package/dist/queries/drift.js +1 -1
  249. package/dist/queries/duplicate-bodies.d.ts +2 -2
  250. package/dist/queries/duplicate-bodies.js +1 -1
  251. package/dist/queries/entry-map.d.ts +2 -2
  252. package/dist/queries/entry-map.js +1 -1
  253. package/dist/queries/evidence.d.ts +3 -3
  254. package/dist/queries/evidence.js +1 -1
  255. package/dist/queries/extract-candidates.d.ts +2 -2
  256. package/dist/queries/extract-candidates.js +1 -1
  257. package/dist/queries/fan.d.ts +2 -2
  258. package/dist/queries/fan.js +1 -1
  259. package/dist/queries/files.d.ts +2 -2
  260. package/dist/queries/files.js +1 -1
  261. package/dist/queries/health.d.ts +3 -3
  262. package/dist/queries/health.js +1 -1
  263. package/dist/queries/hierarchy.d.ts +2 -2
  264. package/dist/queries/hierarchy.js +1 -1
  265. package/dist/queries/hotspots.d.ts +2 -2
  266. package/dist/queries/hotspots.js +1 -1
  267. package/dist/queries/imports.d.ts +2 -2
  268. package/dist/queries/imports.js +1 -1
  269. package/dist/queries/incomplete-migration.d.ts +2 -2
  270. package/dist/queries/incomplete-migration.js +1 -1
  271. package/dist/queries/index.d.ts +5 -5
  272. package/dist/queries/index.js +1 -1
  273. package/dist/queries/isolated.d.ts +2 -2
  274. package/dist/queries/isolated.js +1 -1
  275. package/dist/queries/locality-candidates.d.ts +2 -2
  276. package/dist/queries/locality-candidates.js +1 -1
  277. package/dist/queries/members.d.ts +2 -2
  278. package/dist/queries/members.js +1 -1
  279. package/dist/queries/methods.d.ts +2 -2
  280. package/dist/queries/methods.js +1 -1
  281. package/dist/queries/not-implemented.d.ts +2 -2
  282. package/dist/queries/not-implemented.js +1 -1
  283. package/dist/queries/outline.d.ts +2 -2
  284. package/dist/queries/outline.js +1 -1
  285. package/dist/queries/passthrough-candidates.d.ts +2 -2
  286. package/dist/queries/passthrough-candidates.js +1 -1
  287. package/dist/queries/plan-context.d.ts +2 -2
  288. package/dist/queries/plan-context.js +1 -1
  289. package/dist/queries/react-component-duplicates.d.ts +2 -2
  290. package/dist/queries/react-component-duplicates.js +1 -1
  291. package/dist/queries/react-hook-candidates.d.ts +2 -2
  292. package/dist/queries/react-hook-candidates.js +1 -1
  293. package/dist/queries/react-large-component-pressure.d.ts +2 -2
  294. package/dist/queries/react-large-component-pressure.js +1 -1
  295. package/dist/queries/recent-duplicates.d.ts +2 -2
  296. package/dist/queries/recent-duplicates.js +1 -1
  297. package/dist/queries/redundant-reexports.d.ts +2 -2
  298. package/dist/queries/redundant-reexports.js +1 -1
  299. package/dist/queries/reference-neighborhood.d.ts +2 -2
  300. package/dist/queries/reference-neighborhood.js +1 -1
  301. package/dist/queries/reference-reachability.d.ts +2 -2
  302. package/dist/queries/reference-reachability.js +1 -1
  303. package/dist/queries/refs.d.ts +2 -2
  304. package/dist/queries/refs.js +1 -1
  305. package/dist/queries/self-audit.d.ts +2 -2
  306. package/dist/queries/self-audit.js +1 -1
  307. package/dist/queries/similar-chains.d.ts +2 -2
  308. package/dist/queries/similar-chains.js +1 -1
  309. package/dist/queries/similar-files.d.ts +2 -2
  310. package/dist/queries/similar-files.js +1 -1
  311. package/dist/queries/similar-signatures.d.ts +2 -2
  312. package/dist/queries/similar-signatures.js +1 -1
  313. package/dist/queries/similar.d.ts +2 -2
  314. package/dist/queries/similar.js +1 -1
  315. package/dist/queries/slice.d.ts +2 -2
  316. package/dist/queries/slice.js +1 -1
  317. package/dist/queries/source-inspection.d.ts +4 -4
  318. package/dist/queries/source-inspection.js +1 -1
  319. package/dist/queries/source-search.d.ts +2 -2
  320. package/dist/queries/source-search.js +1 -1
  321. package/dist/queries/stale-abstractions.d.ts +2 -2
  322. package/dist/queries/stale-abstractions.js +1 -1
  323. package/dist/queries/stats.d.ts +2 -2
  324. package/dist/queries/surface.d.ts +2 -2
  325. package/dist/queries/surface.js +1 -1
  326. package/dist/queries/symbols.d.ts +2 -2
  327. package/dist/queries/symbols.js +1 -1
  328. package/dist/queries/system-map.d.ts +2 -2
  329. package/dist/queries/system-map.js +1 -1
  330. package/dist/queries/system.d.ts +2 -2
  331. package/dist/queries/system.js +1 -1
  332. package/dist/queries/test-quality.d.ts +2 -2
  333. package/dist/queries/test-quality.js +1 -1
  334. package/dist/queries/trace.d.ts +2 -2
  335. package/dist/queries/trace.js +1 -1
  336. package/dist/queries/twin-ab.d.ts +2 -2
  337. package/dist/queries/twin-ab.js +1 -1
  338. package/dist/queries/twin-drift.d.ts +2 -2
  339. package/dist/queries/twin-drift.js +1 -1
  340. package/dist/queries/unused-imports.d.ts +2 -2
  341. package/dist/queries/unused-imports.js +1 -1
  342. package/dist/queries/unused-params.d.ts +2 -2
  343. package/dist/queries/unused-params.js +1 -1
  344. package/dist/queries/value-flow.d.ts +3 -3
  345. package/dist/queries/value-flow.js +1 -1
  346. package/dist/queries/vue-component-duplicates.d.ts +2 -2
  347. package/dist/queries/vue-component-duplicates.js +1 -1
  348. package/dist/queries/vue-composable-candidates.d.ts +2 -2
  349. package/dist/queries/vue-composable-candidates.js +1 -1
  350. package/dist/queries/vue-large-view-pressure.d.ts +2 -2
  351. package/dist/queries/vue-large-view-pressure.js +1 -1
  352. package/dist/queries/wrapper-candidates.d.ts +2 -2
  353. package/dist/queries/wrapper-candidates.js +1 -1
  354. package/dist/reindex-worker.js +2 -2
  355. package/dist/reindex.d.ts +3 -5
  356. package/dist/reindex.js +72 -33
  357. package/dist/runtime.d.ts +23 -4
  358. package/dist/runtime.js +3 -3
  359. package/dist/rust-semantic-session-server.js +1 -1
  360. package/dist/rust-semantic-session-worker.js +1 -1
  361. package/dist/rust-semantic-worker.js +1 -1
  362. package/dist/sentinel-ensure-command-OSWGCFFL.js +3 -0
  363. package/dist/sentinel-ensure-command-SPW7XQLB.js +2 -0
  364. package/dist/sentinel-hook.js +39 -0
  365. package/dist/sentinel-worker.js +16 -0
  366. package/dist/typescript-mailbox-worker.js +1 -1
  367. package/dist/watch-server.js +6 -6
  368. package/docs/COMMAND_REFERENCE.md +5 -3
  369. package/docs/INDEX_GENERATIONS.md +2 -2
  370. package/docs/NPM_RELEASE.md +323 -0
  371. package/docs/schemas/npm-release-state.schema.json +4 -13
  372. package/docs/schemas/project-config.schema.json +159 -0
  373. package/package.json +10 -14
  374. package/skills/codebaseiq/SKILL.md +1 -1
  375. package/skills/concrete-plan/SKILL.md +1 -1
  376. package/ui/view/api.js +450 -0
  377. package/ui/view/app.js +394 -0
  378. package/ui/view/builder.js +323 -0
  379. package/ui/view/file-panel.js +170 -0
  380. package/ui/view/focus.js +379 -0
  381. package/ui/view/index.html +54 -0
  382. package/ui/view/map.js +424 -0
  383. package/ui/view/styles.css +1125 -0
  384. package/dist/chunk-2Q2LW5JW.js +0 -14
  385. package/dist/chunk-2X7V4HS4.js +0 -88
  386. package/dist/chunk-3IER7Q6H.js +0 -12
  387. package/dist/chunk-3JSXXYTZ.js +0 -345
  388. package/dist/chunk-476NR5B7.js +0 -2
  389. package/dist/chunk-5VKBFZZU.js +0 -3
  390. package/dist/chunk-6BQ3DSPK.js +0 -2
  391. package/dist/chunk-6CS3UQTN.js +0 -3
  392. package/dist/chunk-6OAHRI2D.js +0 -6
  393. package/dist/chunk-ADTBPVUZ.js +0 -21
  394. package/dist/chunk-BFFZDZQV.js +0 -2
  395. package/dist/chunk-BMYOV5GP.js +0 -77
  396. package/dist/chunk-C74PPYLA.js +0 -3
  397. package/dist/chunk-CWONGW6P.js +0 -3
  398. package/dist/chunk-DDZ7VHWV.js +0 -20
  399. package/dist/chunk-DR2LURYU.js +0 -3
  400. package/dist/chunk-ECQBG7PW.js +0 -564
  401. package/dist/chunk-EF2R3WNQ.js +0 -2
  402. package/dist/chunk-FM5BPL4V.js +0 -60
  403. package/dist/chunk-G6XFR4ZL.js +0 -4
  404. package/dist/chunk-GTIYTDRE.js +0 -562
  405. package/dist/chunk-HOA5YGOH.js +0 -3
  406. package/dist/chunk-KUW32IRO.js +0 -2
  407. package/dist/chunk-LTA3BRZX.js +0 -2
  408. package/dist/chunk-NAUD7LCA.js +0 -2
  409. package/dist/chunk-NCZUNH3E.js +0 -109
  410. package/dist/chunk-NNJ2KZZG.js +0 -4
  411. package/dist/chunk-NNO6A2PO.js +0 -2
  412. package/dist/chunk-OGTFJ3XD.js +0 -2
  413. package/dist/chunk-Q5ELPRKQ.js +0 -2
  414. package/dist/chunk-Q72QSKXC.js +0 -308
  415. package/dist/chunk-QCN62RTF.js +0 -3
  416. package/dist/chunk-QW7EP6WI.js +0 -21
  417. package/dist/chunk-RU65DDUP.js +0 -215
  418. package/dist/chunk-SELM5MER.js +0 -2
  419. package/dist/chunk-SMRBZ6EC.js +0 -2
  420. package/dist/chunk-SNNWPCN7.js +0 -4
  421. package/dist/chunk-TFZB6XTM.js +0 -239
  422. package/dist/chunk-UCD3H3UZ.js +0 -5
  423. package/dist/chunk-UXM43C7T.js +0 -3
  424. package/dist/chunk-VFY6Y2H6.js +0 -61
  425. package/dist/chunk-WE5RZHZ7.js +0 -5
  426. package/dist/chunk-YMGZZEW4.js +0 -2
  427. package/dist/chunk-YVCIMIOC.js +0 -12
  428. package/dist/chunk-Z54RD7VL.js +0 -3
  429. package/dist/chunk-ZKX2FRS6.js +0 -15
  430. package/dist/cli-context-3SNLDYBM.js +0 -3
  431. package/dist/cli-context-T3B7W6GG.js +0 -2
  432. package/dist/cli-program-YNOXO72B.js +0 -7
  433. package/dist/command-descriptors-6AOUKWW7.js +0 -346
  434. package/dist/command-descriptors-ZFKJSRUP.js +0 -344
  435. package/dist/direct-navigation-DP4LVMRX.js +0 -3
  436. package/dist/direct-navigation-FLUS3BT6.js +0 -2
  437. package/dist/invocation-command-descriptors-QT2JMY5J.js +0 -3
  438. package/dist/invocation-command-descriptors-YN4QJEAX.js +0 -2
  439. package/dist/output-continuation-command-2V2SL4TD.js +0 -2
  440. package/dist/output-continuation-command-65J5IP3O.js +0 -3
  441. package/dist/project-reindex-5JOKXAXT.js +0 -2
  442. package/dist/project-reindex-UQBIKO4M.js +0 -3
  443. package/docs/WINDOWS_SIDECAR_RELEASE.md +0 -424
  444. package/docs/schemas/windows-sidecar-provenance.schema.json +0 -137
  445. package/scripts/build-codebaseiq-windows.mjs +0 -197
  446. package/scripts/codebaseiq-windows-provenance.mjs +0 -364
  447. package/scripts/verify-codebaseiq-windows.mjs +0 -29
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env node
2
- import{spawnSync as F}from"child_process";import{createHash as W}from"crypto";import{existsSync as N,lstatSync as M,realpathSync as j}from"fs";import{dirname as $,isAbsolute as z,join as U,resolve as g}from"path";var p={run(t,e){let r=I(t,e);return r.kind==="success"?r.output:void 0},runResult:I},K=["rev-parse","--show-toplevel","--absolute-git-dir","--git-common-dir","HEAD","HEAD^{tree}"],y=/^[0-9a-f]{40,64}$/;function be(t,e,r=p){if(!e||e.startsWith("-")||/[\0\r\n]/.test(e))throw new Error(`Invalid Git revision ${JSON.stringify(e)}.`);let n=r.runResult(t,["rev-parse","--verify","--end-of-options",`${e}^{commit}`]);if(n.kind!=="success"||!y.test(n.output))throw new Error(`Git revision ${JSON.stringify(e)} does not resolve to exactly one commit.`);return n.output}function Ce(t,e=p){let r=e.runResult(t,K);if(r.kind==="success"){let n=Y(r.output);if(n)return H(n,e)}return J(t,e)}function Y(t){let e=t.split(`
3
- `).map(c=>c.trim());if(e.length!==5)return;let[r,n,i,o,s]=e;if(!r||!n||!i||!o||!s||!y.test(o)||!y.test(s))return;let a=u(r);return{root:a,gitDir:u(f(a,n)),commonDir:u(f(a,i)),headCommit:o,treeOid:s}}function H(t,e){let r=e.run(t.root,["status","--porcelain=v1","-z","--untracked-files=all"]);return r===void 0?void 0:{...T(t.root,t.gitDir),commonDir:t.commonDir,repositoryId:x("repository",t.commonDir),headCommit:t.headCommit,treeOid:t.treeOid,clean:r.length===0}}function J(t,e){let r=X(t,e);if(r.kind!=="worktree")return;let n=r.identity,i=n.projectRoot,o=e.run(i,["rev-parse","--git-common-dir"])?.trim();if(!o)return;let s=u(f(i,o)),a=h(e.run(i,["rev-parse","--verify","HEAD"])),c=h(e.run(i,["rev-parse","--verify","HEAD^{tree}"])),l=e.run(i,["status","--porcelain=v1","-z","--untracked-files=all"]);if(l!==void 0)return{...n,commonDir:s,repositoryId:x("repository",s),headCommit:a,treeOid:c,clean:l.length===0}}function X(t,e=p){let r=e.runResult(t,["rev-parse","--show-toplevel"]);if(r.kind==="not-repository")return{kind:"non-git"};if(r.kind==="error")return r;let n=r.output.trim();if(!n)return{kind:"error",message:"Git returned an empty worktree root."};let i=u(n),o=e.run(i,["rev-parse","--absolute-git-dir"])?.trim();if(!o)return{kind:"error",message:"Git did not return an absolute worktree directory."};let s=u(f(i,o));return{kind:"worktree",identity:T(i,s)}}function T(t,e){return{projectRoot:t,gitDir:e,worktreeId:x("worktree",`${t}\0${e}`)}}function ke(t,e=p){let r=e.run(t,["worktree","list","--porcelain","-z"]);return r===void 0?[]:q(r)}function q(t){let e=[],r;for(let n of t.split("\0")){if(n===""){r&&e.push(r),r=void 0;continue}let i=n.indexOf(" "),o=i<0?n:n.slice(0,i),s=i<0?"":n.slice(i+1);if(o==="worktree"){r&&e.push(r),r={path:u(s),detached:!1,bare:!1,prunable:!1,locked:!1};continue}r&&(o==="HEAD"?r.head=s:o==="branch"?r.branch=s:o==="detached"?r.detached=!0:o==="bare"?r.bare=!0:o==="prunable"?r.prunable=!0:o==="locked"&&(r.locked=!0))}return r&&e.push(r),e}function Se(t,e,r=p){return h(r.run(t,e))}function f(t,e){return z(e)?e:g(t,e)}function u(t){try{return j(t)}catch{return g(t)}}function x(t,e){return W("sha256").update(`${t}\0${e}`).digest("hex").slice(0,24)}function h(t){return t?.trim()||void 0}function I(t,e){let r=F("git",["-C",t,...e],{encoding:"utf-8",env:{...process.env,LC_ALL:"C"},maxBuffer:52428800,stdio:["ignore","pipe","pipe"],windowsHide:!0,timeout:3e4,killSignal:"SIGKILL"});if(r.status===0)return{kind:"success",output:r.stdout.trimEnd()};let i=(typeof r.stderr=="string"?r.stderr.trim():"")||r.error?.message||`git exited with status ${r.status??"unknown"}`,o=r.error?.code;return(/not a git repository/i.test(i)||o==="ENOENT"&&N(g(t)))&&!V(t)?{kind:"not-repository"}:{kind:"error",message:i}}function V(t){if(process.env.GIT_DIR||process.env.GIT_COMMON_DIR)return!0;let e=g(t);for(;;){try{return M(U(e,".git")),!0}catch(n){let i=n.code;if(i!=="ENOENT"&&i!=="ENOTDIR")return!0}let r=$(e);if(r===e)return!1;e=r}}function Pe(t){try{return process.kill(t,0),!0}catch(e){return typeof e=="object"&&e!==null&&"code"in e&&e.code==="EPERM"}}import{closeSync as b,fstatSync as m,openSync as C,readFileSync as Q,readSync as E}from"fs";import{createHash as Z}from"crypto";var v=8*1024*1024,w=64*1024*1024,ee=512*1024*1024,te=256*1024*1024,d=class extends Error{constructor(r,n,i,o,s){let a=i==="too-large"?`is ${o} bytes; the safety limit is ${s} bytes`:i==="not-regular"?"is not a regular file":"changed while it was being read";super(`${r} ${JSON.stringify(n)} ${a}`);this.inputKind=r;this.inputPath=n;this.reason=i;this.observedBytes=o;this.limitBytes=s;this.name="BoundedFileReadError"}inputKind;inputPath;reason;observedBytes;limitBytes;code="CODEBASEIQ_BOUNDED_FILE_READ"};function A(t,e){P(e.maxBytes);let r=String(t),n=C(t,"r");try{let i=m(n);D(i,e,r);let o=Q(n),s=m(n);if(s.dev!==i.dev||s.ino!==i.ino||s.size!==i.size||o.byteLength!==i.size)throw new d(e.inputKind,r,"changed-during-read",s.size,e.maxBytes);return o}finally{b(n)}}function k(t,e,r="utf8"){return A(t,e).toString(r)}function re(t,e){return k(t,{maxBytes:v,inputKind:e})}function ne(t,e){return k(t,{maxBytes:w,inputKind:e})}function S(t,e){P(e.maxBytes);let r=[],n=Buffer.allocUnsafe(64*1024),i=0;for(;;){let o=E(t,n,0,n.length,null);if(o===0)break;if(i+=o,!Number.isSafeInteger(i)||i>e.maxBytes)throw new d(e.inputKind,`file descriptor ${t}`,"too-large",i,e.maxBytes);r.push(Buffer.from(n.subarray(0,o)))}return Buffer.concat(r,i)}function ie(t,e,r="utf8"){return S(t,e).toString(r)}function B(t,e){let r=C(t,"r");try{return S(r,e)}finally{b(r)}}function R(t,e,r="utf8"){return B(t,e).toString(r)}function O(t,e,r){P(e.maxBytes);let n=String(t),i=C(t,"r");try{let o=m(i);D(o,e,n);let s=Buffer.allocUnsafe(Math.min(1024*1024,Math.max(1,o.size))),a=0;for(;a<o.size;){let l=E(i,s,0,Math.min(s.length,o.size-a),a);if(l===0)break;r(s.subarray(0,l)),a+=l}let c=m(i);if(c.dev!==o.dev||c.ino!==o.ino||c.size!==o.size||a!==o.size)throw new d(e.inputKind,n,"changed-during-read",c.size,e.maxBytes);return a}finally{b(i)}}function oe(t,e){let r=Z("sha256");return O(t,e,n=>r.update(n)),r.digest("hex")}function D(t,e,r){if(!t.isFile())throw new d(e.inputKind,r,"not-regular",Number(t.size),e.maxBytes);if(t.size>e.maxBytes)throw new d(e.inputKind,r,"too-large",Number(t.size),e.maxBytes)}function P(t){if(!Number.isSafeInteger(t)||t<0)throw new RangeError(`maxBytes must be a non-negative safe integer; received ${t}`)}var se=new Set(["aix","android","darwin","freebsd","haiku","linux","openbsd","sunos","win32","cygwin","netbsd"]);function ae(t){if(!t||typeof t!="object"||Array.isArray(t))return null;let e=t;return e.version!==1||typeof e.pid!="number"||!Number.isSafeInteger(e.pid)||e.pid<=0||typeof e.platform!="string"||!se.has(e.platform)||typeof e.startToken!="string"||e.startToken.trim()===""?null:{version:1,pid:e.pid,platform:e.platform,startToken:e.startToken}}function ce(t,e){return t.version===e.version&&t.pid===e.pid&&t.platform===e.platform&&t.startToken===e.startToken}import{execFileSync as de}from"child_process";import{platform as ue}from"os";var G=new WeakMap,le=1e3,L=16*1024;function _e(t,e=ge){if(!Number.isSafeInteger(t)||t<=0)return null;if(t===process.pid){let r=G.get(e);if(r)return r}try{let r=pe(t,e);if(!r)return null;let n={version:1,pid:t,platform:e.platform,startToken:r};return t===process.pid&&G.set(e,n),n}catch{return null}}function pe(t,e){if(e.platform==="linux"||e.platform==="android")return fe(e.readFile(`/proc/${t}/stat`));if(e.platform==="win32"){let r=`([DateTimeOffset](Get-Process -Id ${t} -ErrorAction Stop).StartTime).ToUnixTimeMilliseconds()`;return _(e.run("powershell.exe",["-NoProfile","-NonInteractive","-Command",r]))}return e.platform==="darwin"||e.platform==="freebsd"||e.platform==="openbsd"||e.platform==="netbsd"?_(e.run("ps",["-p",String(t),"-o","lstart="])):null}function fe(t){let e=t.lastIndexOf(")");if(e<0)return null;let n=t.slice(e+1).trim().split(/\s+/)[19];return n&&/^\d+$/.test(n)?n:null}function _(t){let e=t.trim();return e===""?null:e}var ge={platform:ue(),readFile(t){return R(t,{maxBytes:L,inputKind:"process identity pseudo-file"})},run(t,e){return de(t,[...e],{encoding:"utf8",timeout:le,maxBuffer:L,env:{...process.env,LC_ALL:"C",LANG:"C"},stdio:["ignore","pipe","ignore"],windowsHide:!0})}};var Ne=["typescript","javascript","java","scala","kotlin","rust","python","ruby","go","cpp","c","csharp","vb","dart","php","clojure"],Me=["entry-surface","generated-code","compatibility-shim","reflection-or-registration","test-fixture","intentional-twin","historical-coupling-ended","detector-counterexample"];function $e(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function ze(t){return typeof t=="string"&&Number.isFinite(Date.parse(t))}function Ue(t){return typeof t=="number"&&Number.isSafeInteger(t)&&t>=0}function Ke(t){return typeof t=="string"&&t.length>0&&t.length<=256&&!/[\0\r\n]/u.test(t)}function Ye(t){return typeof t=="number"&&Number.isFinite(t)&&t>=0}export{p as a,be as b,Ce as c,X as d,ke as e,Se as f,f as g,u as h,Pe as i,v as j,w as k,ee as l,te as m,d as n,A as o,k as p,re as q,ne as r,ie as s,O as t,oe as u,ae as v,ce as w,_e as x,Ne as y,Me as z,$e as A,ze as B,Ue as C,Ke as D,Ye as E};
4
- //# sourceMappingURL=chunk-SNNWPCN7.js.map
@@ -1,239 +0,0 @@
1
- import{a as ee,c as te}from"./chunk-VFY6Y2H6.js";import{a as Tn}from"./chunk-ILMHV3KM.js";import{a as Kt,b as Zt,d as Ue,e as rn}from"./chunk-PYAB5SM6.js";import{P as Qt,Q as Vt,R as Xt,T as Yt,X as jn,Y as Je,a as vt,b as It,c as se,d as fe,e as Jt,g as zt}from"./chunk-NCZUNH3E.js";import{a as z,b as pe,c as Z,d as $t,e as Bt,f as Gt,g as Ut,h as Wt}from"./chunk-KUW32IRO.js";import{a as He,c as ye,d as wn,f as _n}from"./chunk-FDGD5AB5.js";import{T as Be}from"./chunk-RU65DDUP.js";import{A as ln,B as un,C as pn,D as gn,E as fn,F as mn,G as We,I as N,J as me,K as hn,M as qe,N as yn,O as Sn,P as he,S as bn,T as Pn,U as xn,c as K,d as de,e as Ae,g as Le,h as _t,i as Dt,j as T,l as Lt,o as F,p as L,q as M,r as Ge,s as en,t as tn,u as nn,v as an,w as on,x as sn,y as cn,z as dn}from"./chunk-QW7EP6WI.js";import{e as ge}from"./chunk-3IER7Q6H.js";import{i as W,j as H,l as Ot,m as $e,n as At,r as qt,s as Ht,u as Rn,x as vn,y as In,z as En}from"./chunk-RDBI2RXU.js";import{i as le,j as q}from"./chunk-R2NOK63J.js";import{a as Rt,b as Y,c as U,d as b}from"./chunk-EF2R3WNQ.js";import{E as Me,O as Ne,S as ue,X as kt,Y as J,_ as Mt,a as Pt,c as Oe,f as X,fa as Nt,g as ie,ga as Ct,h as oe,i as xt,n as Et,o as wt,p as ce,r as I}from"./chunk-WE5RZHZ7.js";import{a as Ce,d as Ft}from"./chunk-6OAHRI2D.js";import{b as jt,c as Tt}from"./chunk-2Q2LW5JW.js";import{createHash as Ci}from"crypto";import{existsSync as _,mkdirSync as Te,mkdtempSync as $i,readdirSync as Fr,renameSync as kr,rmSync as Q,statSync as Bi}from"fs";import{basename as je,dirname as h,extname as Gi,join as E,resolve as Rr}from"path";import{platform as Ui}from"os";import{execFileSync as Hr}from"child_process";import{constants as Jr,copyFileSync as Fn,statSync as zr}from"fs";import{platform as Qr}from"os";var Vr=Object.freeze({size:e=>zr(e).size,clone:Yr,copy:(e,t)=>Fn(e,t)}),Xr=new Set(["ENOSYS","ENOTSUP","EOPNOTSUPP","EINVAL","EXDEV","ENOTTY"]);function C(e,t,n=Vr){let r=n.size(e);try{return n.clone(e,t),{method:"reflink",bytes:r}}catch(a){if(!Zr(a))throw a}return n.copy(e,t),{method:"copy",bytes:r}}function Yr(e,t){if(Qr()!=="darwin"){Fn(e,t,Jr.COPYFILE_FICLONE_FORCE);return}try{Hr("/bin/cp",["-c",e,t],{timeout:6e4,maxBuffer:64*1024,stdio:["ignore","ignore","pipe"],windowsHide:!0})}catch(n){throw Kr(n)}}function Kr(e){let t=e?.stderr,n=Buffer.isBuffer(t)?t.toString("utf8"):t??"";return/operation not supported|not supported/i.test(n)?Object.assign(e instanceof Error?e:new Error(String(e)),{code:"ENOTSUP"}):/cross-device link/i.test(n)?Object.assign(e instanceof Error?e:new Error(String(e)),{code:"EXDEV"}):e}function Zr(e){let t=e?.code;return t!==void 0&&Xr.has(t)}function kn(){return{reflinkedBytes:0,fallbackCopiedBytes:0}}function $(e,t){t.method==="reflink"?e.reflinkedBytes+=t.bytes:e.fallbackCopiedBytes+=t.bytes}import{dirname as ea,join as ta}from"path";function Dn(e={}){return{id:"runtime-boundaries",facts:["runtime-boundary-observation","runtime-boundary-link"],run:({projectRoot:t,dbPath:n,onStatus:r})=>{let a=new F({projectRoot:t,dbPath:n,indexPath:e.indexPath??ta(ea(n),"index.scip")}),i,o=!1,s=!1;try{let l=e.reuseExisting||e.affectedFiles?Yt(a):null;e.reuseExisting&&l?.extractorVersion===Qt?(i=l,o=!0):(i=Vt(a,{...l?{previousGraph:l}:{},...e.affectedFiles?{affectedFiles:e.affectedFiles}:{}}),s=(i.coverage.filesReused??0)>0)}finally{a.close()}o||Xt(n,i);let d={reused:o,incrementallyUpdated:s,observations:i.observations.length,links:i.links.length,frontiers:i.frontiers.length,filesScanned:i.coverage.filesScanned,errors:i.coverage.extractionErrors.length,phases:i.coverage.phases};return r?.(d.reused?`Reused ${d.observations} cached runtime-boundary observation(s) and ${d.links} link(s).`:d.incrementallyUpdated?`Incrementally refreshed runtime-boundary observations (${d.filesScanned-(i.coverage.filesReused??0)} file(s) extracted, ${i.coverage.filesReused??0} reused) and rebuilt ${d.links} link(s).`:`Extracted ${d.observations} runtime-boundary observation(s), ${d.links} link(s), and ${d.frontiers} unresolved frontier(s).`),!o&&i.coverage.phases&&r?.(`Runtime-boundary phases: ${i.coverage.phases.map(l=>`${l.id} ${l.durationMs.toFixed(0)}ms`).join(", ")}.`),d}}}import{createHash as ra}from"crypto";import{existsSync as aa}from"fs";import{dirname as ia,join as An}from"path";function ze(e){let t=new Set;for(let n of e.uncertainty)t.add(n);e.projectIdentityChanged&&t.add("project-identity-changed");for(let n of e.changes)n.kind==="added"&&t.add("file-added"),n.kind==="deleted"&&t.add("file-deleted"),n.inputKind==="config"&&t.add("configuration-changed"),n.inputKind==="ambient"&&t.add("ambient-declaration-changed"),n.inputKind==="other"&&t.add("unclassified-input");return{fullProject:t.size>0,reasons:[...t].sort()}}function Se(e,t,n){let r=e.changes.map(s=>s.path).sort();if(r.length===0&&!e.projectIdentityChanged&&e.uncertainty.length===0)return{mode:"none",changedFiles:r,affectedFiles:[],reasons:[]};let a=new Set(n),i=ze(e),o=new Set(i.reasons);return r.some(s=>!a.has(s))&&o.add("changed-file-outside-project"),t===null?(o.add("dependency-graph-unavailable"),On(r,a,o)):o.size>0?On(r,a,o):{mode:"closure",changedFiles:r,affectedFiles:na(r,t,a),reasons:[]}}function On(e,t,n){return{mode:"full-project",changedFiles:e,affectedFiles:[...t].sort(),reasons:[...n].sort()}}function na(e,t,n){let r=new Map;for(let[o,s]of t)if(n.has(o))for(let d of s){if(!n.has(d))continue;let l=r.get(d)??new Set;l.add(o),r.set(d,l)}let a=new Set(e),i=[...e];for(let o=0;o<i.length;o+=1){let s=i[o];if(s!==void 0)for(let d of r.get(s)??[])a.has(d)||(a.add(d),i.push(d))}return[...a].sort()}var oa="<global-symbols>";function sa(e){let t=[];for(let n of e.all(`
2
- SELECT relative_path, language, position_encoding, text
3
- FROM documents
4
- `))t.push({relativePath:n.relative_path,kind:"document",values:[n.language,n.position_encoding,n.text]});for(let n of e.all(`
5
- SELECT d.relative_path,
6
- c.chunk_index,
7
- c.start_line,
8
- c.end_line,
9
- hex(c.occurrences) AS occurrences_hex
10
- FROM chunks c
11
- JOIN documents d ON d.id = c.document_id
12
- `))t.push({relativePath:n.relative_path,kind:"chunk",values:[n.chunk_index,n.start_line,n.end_line,n.occurrences_hex]});for(let n of e.all(`
13
- SELECT d.relative_path,
14
- r.start_line,
15
- r.start_char,
16
- r.end_line,
17
- r.end_char,
18
- g.symbol,
19
- g.display_name,
20
- g.kind,
21
- g.documentation,
22
- CASE WHEN g.signature IS NULL THEN NULL ELSE hex(g.signature) END AS signature_hex,
23
- g.enclosing_symbol,
24
- CASE WHEN g.relationships IS NULL THEN NULL ELSE hex(g.relationships) END AS relationships_hex
25
- FROM defn_enclosing_ranges r
26
- JOIN documents d ON d.id = r.document_id
27
- JOIN global_symbols g ON g.id = r.symbol_id
28
- `))t.push({relativePath:n.relative_path,kind:"definition",values:Qe(n,[n.start_line,n.start_char,n.end_line,n.end_char])});for(let n of e.all(`
29
- SELECT d.relative_path,
30
- c.chunk_index,
31
- m.role,
32
- g.symbol,
33
- g.display_name,
34
- g.kind,
35
- g.documentation,
36
- CASE WHEN g.signature IS NULL THEN NULL ELSE hex(g.signature) END AS signature_hex,
37
- g.enclosing_symbol,
38
- CASE WHEN g.relationships IS NULL THEN NULL ELSE hex(g.relationships) END AS relationships_hex
39
- FROM mentions m
40
- JOIN chunks c ON c.id = m.chunk_id
41
- JOIN documents d ON d.id = c.document_id
42
- JOIN global_symbols g ON g.id = m.symbol_id
43
- `))t.push({relativePath:n.relative_path,kind:"mention",values:Qe(n,[n.chunk_index,n.role])});for(let n of e.all(`
44
- SELECT g.symbol,
45
- g.display_name,
46
- g.kind,
47
- g.documentation,
48
- CASE WHEN g.signature IS NULL THEN NULL ELSE hex(g.signature) END AS signature_hex,
49
- g.enclosing_symbol,
50
- CASE WHEN g.relationships IS NULL THEN NULL ELSE hex(g.relationships) END AS relationships_hex
51
- FROM global_symbols g
52
- WHERE NOT EXISTS (
53
- SELECT 1 FROM defn_enclosing_ranges r WHERE r.symbol_id = g.id
54
- ) AND NOT EXISTS (
55
- SELECT 1 FROM mentions m WHERE m.symbol_id = g.id
56
- )
57
- `))t.push({relativePath:oa,kind:"global-symbol",values:Qe(n)});return ca(t)}function ca(e){let t=new Map;for(let r of e){let a=JSON.stringify([r.kind,r.values]),i=t.get(r.relativePath)??[];i.push(a),t.set(r.relativePath,i)}let n=new Map;for(let[r,a]of[...t].sort(([i],[o])=>i.localeCompare(o))){let i=ra("sha256");for(let o of a.sort())i.update(String(Buffer.byteLength(o))),i.update(":"),i.update(o),i.update(`
58
- `);n.set(r,i.digest("hex"))}return n}function da(e,t){let n=[],r=[],a=[],i=[],o=new Set([...e.keys(),...t.keys()]);for(let s of[...o].sort()){let d=e.get(s),l=t.get(s);d===void 0?n.push(s):l===void 0?a.push(s):d!==l?r.push(s):i.push(s)}return{addedFiles:n,modifiedFiles:r,deletedFiles:a,changedFiles:[...n,...r,...a].sort(),unchangedFiles:i}}function Ve(e,t,n){let r=new Set(e.affectedFiles),a=new Set(t.changedFiles),i=e.mode==="full-project"?[]:t.changedFiles.filter(d=>!r.has(d)),o=e.affectedFiles.filter(d=>!a.has(d)).sort(),s=t.changedFiles.length-i.length;return{passed:i.length===0,recall:t.changedFiles.length===0?1:s/t.changedFiles.length,affectedRatio:n===0?0:e.affectedFiles.length/n,predictedFiles:[...e.affectedFiles].sort(),actualFiles:[...t.changedFiles],missingFiles:i,extraFiles:o}}function Xe(e,t=fa){let n=t.wallNow===void 0&&t.monotonicNow===void 0,r=t.monotonicNow??t.now,a=t.wallNow??t.now,i=r(),o=(l,c)=>{let p=r();return Gn(e.refreshResult,l,n?p:a(),Math.max(0,p-i),c)};if(!t.databaseExists(e.previousDbPath))return o("prior-index-unavailable");if(!t.databaseExists(e.candidateDbPath))return o("candidate-index-unavailable");let s=null,d=null;try{s=t.openDatabase(e.projectRoot,e.previousDbPath,e.previousIndexPath),d=t.openDatabase(e.projectRoot,e.candidateDbPath,e.candidateIndexPath);let l=[...new Set([...t.indexedPaths(s),...t.indexedPaths(d)])].sort(),c=ce(e.previousSnapshot,e.currentSnapshot),p=new Set(l),u=c.changes.length>0&&!ze(c).fullProject&&c.changes.every(w=>p.has(w.path)),g=Se(c,u?t.dependencyGraph(s):new Map,l),m=da(t.factDigests(s),t.factDigests(d)),x=r();return{version:1,status:"evaluated",refreshResult:e.refreshResult,recordedAt:new Date(n?x:a()).toISOString(),durationMs:Math.max(0,x-i),manifest:c,plan:g,comparison:m,evaluation:Ve(g,m,l.length)}}catch(l){return o("oracle-error",l instanceof Error?l.message:String(l))}finally{Ln(s),Ln(d)}}function Cn(e,t,n,r=Date.now()){return Gn(e,t,r,0,n)}function $n(e){let t=ia(e);return{latestPath:An(t,"affected-shadow-latest.json"),historyPath:An(t,"affected-shadow.jsonl")}}function Vo(e,t=n=>xt(n,"affected-shadow source file")){let n=$n(e),r;try{r=JSON.parse(t(n.latestPath))}catch(f){let y=ba(f),P=y?"telemetry-missing":Sa(f);return D(n,P,y?void 0:f instanceof Error?f.message:String(f))}if(L(r)&&typeof r.version=="number"&&r.version!==1)return D(n,"unsupported-record-version",`Unsupported version ${r.version}.`);if(!ha(r))return D(n,"telemetry-malformed");if(r.status==="unavailable")return ya(r.reason)?{state:"unavailable",...n,reason:r.reason,recordedAt:r.recordedAt,refreshResult:r.refreshResult,durationMs:r.durationMs,...typeof r.error=="string"?{error:r.error}:{}}:D(n,"telemetry-malformed");if(r.status!=="evaluated")return D(n,"telemetry-malformed");let a=r.plan,i=r.comparison,o=r.evaluation;if(!L(r.manifest)||!L(a)||!L(i)||!L(o))return D(n,"telemetry-malformed");let s=a.mode,d=M(a.affectedFiles),l=M(a.reasons),c=M(i.changedFiles),p=M(o.predictedFiles),u=M(o.actualFiles),g=M(o.missingFiles),m=o.recall,x=o.affectedRatio;if(s!=="none"&&s!=="closure"&&s!=="full-project"||d===null||l===null||c===null||p===null||u===null||g===null||typeof o.passed!="boolean"||!Mn(m)||!Mn(x))return D(n,"telemetry-malformed");let w=u.length===0?1:(u.length-g.length)/u.length;return!Nn(d,p)||!Nn(c,u)||o.passed!==(g.length===0)||Math.abs(m-w)>Number.EPSILON||g.some(f=>!u.includes(f)||p.includes(f))?D(n,"telemetry-malformed"):{state:o.passed?"passing":"failing",...n,recordedAt:r.recordedAt,refreshResult:r.refreshResult,durationMs:r.durationMs,mode:s,recall:m,affectedRatio:x,predictedFiles:p,actualFiles:u,missingFiles:g,fallbackReasons:l}}function Xo(e){if(e.state==="unavailable")return`unavailable (${e.reason})`;let t=e.missingFiles.length>0?`, ${e.missingFiles.length} missed`:"",n=e.fallbackReasons.length>0?`; fallback: ${e.fallbackReasons.join(", ")}`:"";return`${e.state}, ${(e.recall*100).toFixed(1)}% recall, ${e.predictedFiles.length} predicted / ${e.actualFiles.length} changed, ${(e.affectedRatio*100).toFixed(1)}% of project${t}${n}`}function Bn(e,t,n=ma){let r=$n(e);return n.appendHistory(r.historyPath,t),n.writeLatest(r.latestPath,t),r}var la=8*1024*1024,ua=Kt;function pa(e){let t={historyVersion:1,sourceVersion:e.version,refreshResult:e.refreshResult,recordedAt:e.recordedAt,durationMs:e.durationMs};return e.status==="unavailable"?{...t,status:"unavailable",reason:e.reason,...e.error?{error:e.error}:{}}:{...t,status:"evaluated",mode:e.plan.mode,passed:e.evaluation.passed,recall:e.evaluation.recall,affectedRatio:e.evaluation.affectedRatio,predictedFileCount:e.evaluation.predictedFiles.length,actualFileCount:e.evaluation.actualFiles.length,missingFileCount:e.evaluation.missingFiles.length,fallbackReasons:[...e.plan.reasons]}}function ga(e,t,n=la){Zt(e,pa(t),{maxSegmentBytes:n,previousSuffix:ua})}function Qe(e,t=[]){let n=[];for(let r of t)n.push(r);return n.push(e.symbol,e.display_name,e.kind,e.documentation,e.signature_hex,e.enclosing_symbol,e.relationships_hex),n}var fa={now:()=>Date.now(),wallNow:()=>Date.now(),monotonicNow:b,databaseExists:e=>aa(e),openDatabase:(e,t,n)=>new F({projectRoot:e,dbPath:t,indexPath:n}),indexedPaths:e=>ge(e),dependencyGraph:e=>fe(e),factDigests:e=>sa(e)},ma={appendHistory:ga,writeLatest:(e,t)=>qt(e,t,{spacing:2,trailingNewline:!0})};function Gn(e,t,n,r,a){return{version:1,status:"unavailable",refreshResult:e,recordedAt:new Date(n).toISOString(),durationMs:r,reason:t,...a?{error:a}:{}}}function Ln(e){try{e?.close()}catch{}}function ha(e){return L(e)&&e.version===1&&typeof e.recordedAt=="string"&&(e.refreshResult==="rebuilt"||e.refreshResult==="reused")&&typeof e.durationMs=="number"&&Number.isFinite(e.durationMs)&&e.durationMs>=0}function ya(e){return e==="prior-index-unavailable"||e==="candidate-index-unavailable"||e==="oracle-error"}function Mn(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0&&e<=1}function Nn(e,t){return e.length===t.length&&e.every((n,r)=>n===t[r])}function D(e,t,n){return{state:"unavailable",...e,reason:t,...n?{error:n}:{}}}function Sa(e){return e instanceof SyntaxError?"telemetry-malformed":"telemetry-unreadable"}function ba(e){return e instanceof Error&&e.code==="ENOENT"}import{readdirSync as Pa}from"fs";import{isAbsolute as Un,join as xa,resolve as Ra}from"path";var be="@sourcegraph/scip-typescript@0.4.0",Wn="scip-python-plus@0.7.5",qn="github.com/sourcegraph/scip-go@v0.2.7",Hn="scip-dotnet@0.2.14",va="scip_dart@1.6.2",Ia={typescript:{language:"typescript",indexerBinary:"scip-typescript",checkCommand:"npx scip-typescript --version",indexArgs:({outputPath:e,pnpmWorkspaces:t,indexerBinary:n,projectPath:r})=>r?{binary:n,args:["index","--output",e,"--no-progress-bar",r]}:t?{binary:n,args:["index","--pnpm-workspaces","--output",e,"--no-progress-bar"]}:{binary:n,args:["index","--output",e,"--no-progress-bar"]},markerFiles:[...I.typescript],installMethods:[{label:"npm",identity:be,destination:"npm global prefix",prerequisite:"npm",binary:"npm",args:["install","-g",be]}],installUrl:"https://github.com/sourcegraph/scip-typescript",bundledNpmPackage:"@sourcegraph/scip-typescript"},javascript:{language:"javascript",indexerBinary:"scip-typescript",checkCommand:"npx scip-typescript --version",indexArgs:({outputPath:e,indexerBinary:t})=>({binary:t,args:["index","--output",e,"--no-progress-bar"]}),markerFiles:[...I.javascript],installMethods:[{label:"npm",identity:be,destination:"npm global prefix",prerequisite:"npm",binary:"npm",args:["install","-g",be]}],installUrl:"https://github.com/sourcegraph/scip-typescript",bundledNpmPackage:"@sourcegraph/scip-typescript"},java:{language:"java",indexerBinary:"scip-java",checkCommand:"scip-java --version",indexArgs:({outputPath:e})=>({binary:"scip-java",args:["index","--output",e]}),markerFiles:[...I.java],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-java/releases"},scala:{language:"scala",indexerBinary:"scip-java",checkCommand:"scip-java --version",indexArgs:({outputPath:e})=>({binary:"scip-java",args:["index","--output",e]}),markerFiles:[...I.scala],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-java/releases"},kotlin:{language:"kotlin",indexerBinary:"scip-java",checkCommand:"scip-java --version",indexArgs:({outputPath:e})=>({binary:"scip-java",args:["index","--output",e]}),markerFiles:[...I.kotlin],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-java/releases"},rust:{language:z.language,indexerBinary:z.indexerBinary,checkCommand:`${z.indexerBinary} --version`,indexArgs:({outputPath:e})=>({binary:z.indexerBinary,args:["scip",".","--output",e]}),markerFiles:[...I.rust],installMethods:[],installUrl:z.installUrl},python:{language:"python",indexerBinary:"scip-python-plus",binaryAliases:["scip-python"],checkCommand:"scip-python-plus --version",indexArgs:({outputPath:e,indexerBinary:t})=>({binary:t,args:["index","--output",e,"--project-name","project"]}),markerFiles:[...I.python],installMethods:[{label:"npm",identity:Wn,destination:"npm global prefix",prerequisite:"npm",binary:"npm",args:["install","-g",Wn]}],installUrl:"https://github.com/PlunderStruck/scip-python",bundledNpmPackage:"scip-python-plus"},clojure:{language:"clojure",indexerBinary:"scip-clojure",projectLocalBinaries:["node_modules/.bin/scip-clojure"],checkCommand:"scip-clojure -h",indexArgs:({projectRoot:e,outputPath:t,indexerBinary:n,configPath:r})=>{let a=["-root",e,"-output",t];return r&&a.push("-config",Un(r)?r:Ra(e,r)),{binary:n,args:a}},markerFiles:[...I.clojure],installMethods:[],installUrl:"https://github.com/PlunderStruck/scip-clojure"},ruby:{language:"ruby",indexerBinary:"scip-ruby",checkCommand:"scip-ruby --version",indexArgs:({indexerBinary:e})=>({binary:e,args:["--dir","."]}),defaultOutputPath:"index.scip",markerFiles:[...I.ruby],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-ruby/releases"},go:{language:"go",indexerBinary:"scip-go",checkCommand:"scip-go --version",indexArgs:({outputPath:e})=>({binary:"scip-go",args:["--output",e]}),markerFiles:[...I.go],installMethods:[{label:"go install",identity:qn,destination:"Go bin directory (GOBIN or GOPATH/bin)",prerequisite:"go",binary:"go",args:["install",qn]}],installUrl:"https://github.com/sourcegraph/scip-go"},cpp:{language:"cpp",indexerBinary:"scip-clang",checkCommand:"scip-clang --version",indexArgs:({outputPath:e})=>({binary:"scip-clang",args:["--compdb-path","compile_commands.json","--index-output-path",e]}),markerFiles:[...I.cpp],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-clang/releases"},c:{language:"c",indexerBinary:"scip-clang",checkCommand:"scip-clang --version",indexArgs:({outputPath:e})=>({binary:"scip-clang",args:["--compdb-path","compile_commands.json","--index-output-path",e]}),markerFiles:[...I.c],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-clang/releases"},csharp:{language:"csharp",indexerBinary:"scip-dotnet",checkCommand:"scip-dotnet --version",indexArgs:({projectRoot:e,outputPath:t})=>({binary:"scip-dotnet",args:["index",Jn(e,[".sln",".csproj"])??e,"--output",t,"--working-directory",e]}),markerFiles:[...I.csharp],installMethods:[{label:"dotnet",identity:Hn,destination:"dotnet global tool directory",prerequisite:"dotnet",binary:"dotnet",args:["tool","install","--global","scip-dotnet","--version","0.2.14"]}],installUrl:"https://github.com/sourcegraph/scip-dotnet/releases"},vb:{language:"vb",indexerBinary:"scip-dotnet",checkCommand:"scip-dotnet --version",indexArgs:({projectRoot:e,outputPath:t})=>({binary:"scip-dotnet",args:["index",Jn(e,[".sln",".vbproj"])??e,"--output",t,"--working-directory",e]}),markerFiles:[...I.vb],installMethods:[{label:"dotnet",identity:Hn,destination:"dotnet global tool directory",prerequisite:"dotnet",binary:"dotnet",args:["tool","install","--global","scip-dotnet","--version","0.2.14"]}],installUrl:"https://github.com/sourcegraph/scip-dotnet/releases"},dart:{language:"dart",indexerBinary:"scip-dart",checkCommand:"scip-dart --version",indexArgs:({indexerBinary:e,outputPath:t})=>({binary:e,args:["--output",t]}),markerFiles:[...I.dart],installMethods:[{label:"dart pub",identity:va,destination:"Dart pub global cache",prerequisite:"dart",binary:"dart",args:["pub","global","activate","scip_dart","1.6.2"]}],installUrl:"https://github.com/Workiva/scip-dart/releases"},php:{language:"php",indexerBinary:"scip-php",projectLocalBinaries:["vendor/davidrjenni/scip-php/bin/scip-php","vendor/bin/scip-php"],checkCommand:"scip-php --version",indexArgs:({indexerBinary:e})=>Un(e)?{binary:"php",args:["-d","error_reporting=E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED",e]}:{binary:e,args:[]},defaultOutputPath:"index.scip",markerFiles:[...I.php],installMethods:[],installUrl:"https://github.com/davidrjenni/scip-php/releases"}};function zn(e){if(!(e.projectPath||e.pnpmWorkspaces)){if(e.language==="typescript")return"{}";if(e.language==="javascript")return'{"compilerOptions":{"allowJs":true}}'}}function Ye(e){return Ia[e]}function Jn(e,t){let n;try{n=Pa(e)}catch{return null}for(let r of t)for(let a of n)if(a.endsWith(r))return xa(e,a);return null}import{createHash as Ea}from"crypto";import{existsSync as Qn,rmSync as Vn}from"fs";import{resolve as wa}from"path";import Kn from"better-sqlite3";var _a={documents:[{name:"id",type:"INTEGER",notnull:0,pk:1},{name:"language",type:"TEXT",notnull:0,pk:0},{name:"relative_path",type:"TEXT",notnull:1,pk:0},{name:"position_encoding",type:"TEXT",notnull:0,pk:0},{name:"text",type:"TEXT",notnull:0,pk:0}],chunks:[{name:"id",type:"INTEGER",notnull:0,pk:1},{name:"document_id",type:"INTEGER",notnull:1,pk:0},{name:"chunk_index",type:"INTEGER",notnull:1,pk:0},{name:"start_line",type:"INTEGER",notnull:1,pk:0},{name:"end_line",type:"INTEGER",notnull:1,pk:0},{name:"occurrences",type:"BLOB",notnull:1,pk:0}],global_symbols:[{name:"id",type:"INTEGER",notnull:0,pk:1},{name:"symbol",type:"TEXT",notnull:1,pk:0},{name:"display_name",type:"TEXT",notnull:0,pk:0},{name:"kind",type:"INTEGER",notnull:0,pk:0},{name:"documentation",type:"TEXT",notnull:0,pk:0},{name:"signature",type:"BLOB",notnull:0,pk:0},{name:"enclosing_symbol",type:"TEXT",notnull:0,pk:0},{name:"relationships",type:"BLOB",notnull:0,pk:0}],mentions:[{name:"chunk_id",type:"INTEGER",notnull:1,pk:1},{name:"symbol_id",type:"INTEGER",notnull:1,pk:2},{name:"role",type:"INTEGER",notnull:1,pk:3}],defn_enclosing_ranges:[{name:"id",type:"INTEGER",notnull:0,pk:1},{name:"document_id",type:"INTEGER",notnull:1,pk:0},{name:"symbol_id",type:"INTEGER",notnull:1,pk:0},{name:"start_line",type:"INTEGER",notnull:1,pk:0},{name:"start_char",type:"INTEGER",notnull:1,pk:0},{name:"end_line",type:"INTEGER",notnull:1,pk:0},{name:"end_char",type:"INTEGER",notnull:1,pk:0}]},ja={idx_chunks_line_range:{table:"chunks",columns:["document_id","start_line","end_line"]},idx_defn_enclosing_ranges_document:{table:"defn_enclosing_ranges",columns:["document_id","start_line","end_line"]},idx_defn_enclosing_ranges_symbol_id:{table:"defn_enclosing_ranges",columns:["symbol_id"]},idx_mentions_symbol_id_role:{table:"mentions",columns:["symbol_id","role"]}};function Zn(e){let t=b(),n=Ta(e.affectedFiles);if(Fa(e.previousDbPath,e.miniDbPath,e.candidateDbPath),Vn(e.candidateDbPath,{force:!0}),!Qn(e.previousDbPath))throw new Error("previous SQLite generation is unavailable");if(!Qn(e.miniDbPath))throw new Error("incremental SQLite mini database is unavailable");Xn(e.previousDbPath,"previous SQLite generation",!1),Xn(e.miniDbPath,"incremental SQLite mini database");let r=C(e.previousDbPath,e.candidateDbPath);e.writeTelemetry&&$(e.writeTelemetry,r);let a=null;try{a=new Kn(e.candidateDbPath,{fileMustExist:!0}),a.pragma("busy_timeout = 5000"),a.pragma("foreign_keys = ON"),a.prepare("ATTACH DATABASE ? AS incremental").run(e.miniDbPath),Ke(a,"main","candidate SQLite generation"),Ke(a,"incremental","incremental SQLite mini database"),ka(a,n),Da(a,n.length);let i=Ze(a,"main",!0),o=O(a,"SELECT COUNT(*) AS value FROM main.documents");a.transaction(()=>{Oa(a),Aa(a),La(a),e.onStage?.("after-delete"),Ma(a),e.onStage?.("after-symbol-reconciliation"),Na(a),e.onStage?.("after-insert"),Ca(a),$a(a,n.length,o),e.onStage?.("before-commit")}).immediate(),er(a,"main","candidate SQLite generation");let l=[...Ba(a)].filter(([c,p])=>i.get(c)!==p).map(([c])=>c).sort();return a.exec("DETACH DATABASE incremental"),a.close(),a=null,{candidateDbPath:e.candidateDbPath,affectedDocumentCount:n.length,changedDocumentPaths:l,durationMs:b()-t}}catch(i){try{a?.close()}finally{Vn(e.candidateDbPath,{force:!0})}throw new Error(`Incremental SQLite publication rejected: ${i instanceof Error?i.message:String(i)}`,{cause:i})}}function Ta(e){if(e.length===0)throw new Error("incremental SQLite publication requires affected documents");let t=[...e].sort();for(let n of t)if(!n||n.startsWith("/")||n.includes("\\")||n.split("/").includes(".."))throw new Error(`invalid affected document path: ${n}`);if(new Set(t).size!==t.length)throw new Error("incremental SQLite publication contains duplicate affected documents");return t}function Fa(e,t,n){let r=[e,t,n].map(a=>wa(a));if(new Set(r).size!==r.length)throw new Error("previous, mini, and candidate SQLite paths must be distinct")}function Xn(e,t,n=!0){let r=new Kn(e,{readonly:!0,fileMustExist:!0});try{Ke(r,"main",t),n&&er(r,"main",t)}finally{r.close()}}function Ke(e,t,n){for(let[r,a]of Object.entries(_a)){let o=e.prepare(`PRAGMA ${t}.table_info('${r}')`).all().map(({name:s,type:d,notnull:l,pk:c})=>({name:s,type:d.toUpperCase(),notnull:l,pk:c}));if(JSON.stringify(o)!==JSON.stringify(a))throw new Error(`${n} schema changed for table ${r}`)}for(let[r,a]of Object.entries(ja)){let i=e.prepare(`SELECT tbl_name FROM ${t}.sqlite_master WHERE type = 'index' AND name = ?`).get(r),o=e.prepare(`PRAGMA ${t}.index_info('${r}')`).all().map(s=>s.name);if(i?.tbl_name!==a.table||JSON.stringify(o)!==JSON.stringify(a.columns))throw new Error(`${n} schema changed for index ${r}`)}Yn(e,t,"documents",["relative_path"],n),Yn(e,t,"global_symbols",["symbol"],n)}function Yn(e,t,n,r,a){if(!e.prepare(`PRAGMA ${t}.index_list('${n}')`).all().some(s=>{if(s.unique!==1)return!1;let d=e.prepare(`PRAGMA ${t}.index_info('${s.name}')`).all().map(l=>l.name);return JSON.stringify(d)===JSON.stringify(r)}))throw new Error(`${a} lost the unique ${n}(${r.join(", ")}) constraint`)}function er(e,t,n){let r=e.prepare(`PRAGMA ${t}.integrity_check`).pluck().get();if(r!=="ok")throw new Error(`${n} failed integrity_check: ${String(r)}`);if(e.prepare(`PRAGMA ${t}.foreign_key_check`).all().length>0)throw new Error(`${n} failed foreign_key_check`)}function ka(e,t){e.exec("CREATE TEMP TABLE incremental_affected_paths (relative_path TEXT PRIMARY KEY) WITHOUT ROWID");let n=e.prepare("INSERT INTO temp.incremental_affected_paths(relative_path) VALUES (?)");e.transaction(a=>{for(let i of a)n.run(i)})(t)}function Da(e,t){let n=O(e,"SELECT COUNT(*) AS value FROM incremental.documents"),r=O(e,`SELECT COUNT(*) AS value
59
- FROM main.documents d
60
- JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path`),a=e.prepare(`SELECT p.relative_path
61
- FROM temp.incremental_affected_paths p
62
- LEFT JOIN incremental.documents d ON d.relative_path = p.relative_path
63
- WHERE d.id IS NULL
64
- LIMIT 1`).pluck().get(),i=e.prepare(`SELECT d.relative_path
65
- FROM incremental.documents d
66
- LEFT JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path
67
- WHERE p.relative_path IS NULL
68
- LIMIT 1`).pluck().get();if(n!==t||r!==t||a!==void 0||i!==void 0)throw new Error("incremental SQLite mini database does not exactly match the affected document set")}function Oa(e){e.exec(`
69
- CREATE TEMP TABLE incremental_old_defined_symbols (symbol TEXT PRIMARY KEY) WITHOUT ROWID;
70
- INSERT OR IGNORE INTO temp.incremental_old_defined_symbols(symbol)
71
- SELECT g.symbol
72
- FROM main.defn_enclosing_ranges r
73
- JOIN main.documents d ON d.id = r.document_id
74
- JOIN main.global_symbols g ON g.id = r.symbol_id
75
- JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path;
76
- INSERT OR IGNORE INTO temp.incremental_old_defined_symbols(symbol)
77
- SELECT g.symbol
78
- FROM main.mentions m
79
- JOIN main.chunks c ON c.id = m.chunk_id
80
- JOIN main.documents d ON d.id = c.document_id
81
- JOIN main.global_symbols g ON g.id = m.symbol_id
82
- JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path
83
- WHERE m.role = 1;
84
-
85
- CREATE TEMP TABLE incremental_new_defined_symbols (symbol TEXT PRIMARY KEY) WITHOUT ROWID;
86
- INSERT OR IGNORE INTO temp.incremental_new_defined_symbols(symbol)
87
- SELECT g.symbol
88
- FROM incremental.defn_enclosing_ranges r
89
- JOIN incremental.global_symbols g ON g.id = r.symbol_id;
90
- INSERT OR IGNORE INTO temp.incremental_new_defined_symbols(symbol)
91
- SELECT g.symbol
92
- FROM incremental.mentions m
93
- JOIN incremental.global_symbols g ON g.id = m.symbol_id
94
- WHERE m.role = 1;
95
- `)}function Aa(e){let t=e.prepare(`WITH changed_symbols AS (
96
- SELECT symbol FROM temp.incremental_old_defined_symbols
97
- UNION
98
- SELECT symbol FROM temp.incremental_new_defined_symbols
99
- ), unaffected_definitions AS (
100
- SELECT g.symbol
101
- FROM main.defn_enclosing_ranges r
102
- JOIN main.documents d ON d.id = r.document_id
103
- JOIN main.global_symbols g ON g.id = r.symbol_id
104
- LEFT JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path
105
- WHERE p.relative_path IS NULL
106
- UNION
107
- SELECT g.symbol
108
- FROM main.mentions m
109
- JOIN main.chunks c ON c.id = m.chunk_id
110
- JOIN main.documents d ON d.id = c.document_id
111
- JOIN main.global_symbols g ON g.id = m.symbol_id
112
- LEFT JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path
113
- WHERE m.role = 1 AND p.relative_path IS NULL
114
- )
115
- SELECT u.symbol
116
- FROM unaffected_definitions u
117
- JOIN changed_symbols c ON c.symbol = u.symbol
118
- LIMIT 1`).pluck().get();if(typeof t=="string")throw new Error(`symbol definition is shared by affected and unaffected documents: ${t}`)}function La(e){e.exec(`
119
- DELETE FROM main.mentions
120
- WHERE chunk_id IN (
121
- SELECT c.id
122
- FROM main.chunks c
123
- JOIN main.documents d ON d.id = c.document_id
124
- JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path
125
- );
126
- DELETE FROM main.chunks
127
- WHERE document_id IN (
128
- SELECT d.id
129
- FROM main.documents d
130
- JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path
131
- );
132
- DELETE FROM main.defn_enclosing_ranges
133
- WHERE document_id IN (
134
- SELECT d.id
135
- FROM main.documents d
136
- JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path
137
- );
138
- DELETE FROM main.documents
139
- WHERE relative_path IN (SELECT relative_path FROM temp.incremental_affected_paths);
140
- `)}function Ma(e){e.exec(`
141
- UPDATE main.global_symbols
142
- SET display_name = NULL,
143
- kind = NULL,
144
- documentation = NULL,
145
- signature = NULL,
146
- enclosing_symbol = NULL,
147
- relationships = NULL
148
- WHERE symbol IN (SELECT symbol FROM temp.incremental_old_defined_symbols);
149
-
150
- INSERT OR IGNORE INTO main.global_symbols(
151
- symbol, display_name, kind, documentation, signature, enclosing_symbol, relationships
152
- )
153
- SELECT symbol, display_name, kind, documentation, signature, enclosing_symbol, relationships
154
- FROM incremental.global_symbols;
155
-
156
- UPDATE main.global_symbols
157
- SET display_name = (
158
- SELECT source.display_name FROM incremental.global_symbols source
159
- WHERE source.symbol = main.global_symbols.symbol
160
- ),
161
- kind = (
162
- SELECT source.kind FROM incremental.global_symbols source
163
- WHERE source.symbol = main.global_symbols.symbol
164
- ),
165
- documentation = (
166
- SELECT source.documentation FROM incremental.global_symbols source
167
- WHERE source.symbol = main.global_symbols.symbol
168
- ),
169
- signature = (
170
- SELECT source.signature FROM incremental.global_symbols source
171
- WHERE source.symbol = main.global_symbols.symbol
172
- ),
173
- enclosing_symbol = (
174
- SELECT source.enclosing_symbol FROM incremental.global_symbols source
175
- WHERE source.symbol = main.global_symbols.symbol
176
- ),
177
- relationships = (
178
- SELECT source.relationships FROM incremental.global_symbols source
179
- WHERE source.symbol = main.global_symbols.symbol
180
- )
181
- WHERE symbol IN (SELECT symbol FROM temp.incremental_new_defined_symbols);
182
- `)}function Na(e){let t=O(e,"SELECT COALESCE(MAX(id), 0) AS value FROM main.documents"),n=O(e,"SELECT COALESCE(MAX(id), 0) AS value FROM main.chunks"),r=O(e,"SELECT COALESCE(MAX(id), 0) AS value FROM main.defn_enclosing_ranges");e.prepare(`INSERT INTO main.documents(id, language, relative_path, position_encoding, text)
183
- SELECT id + ?, language, relative_path, position_encoding, text
184
- FROM incremental.documents`).run(t),e.prepare(`INSERT INTO main.chunks(id, document_id, chunk_index, start_line, end_line, occurrences)
185
- SELECT id + ?, document_id + ?, chunk_index, start_line, end_line, occurrences
186
- FROM incremental.chunks`).run(n,t),e.prepare(`INSERT INTO main.mentions(chunk_id, symbol_id, role)
187
- SELECT m.chunk_id + ?, target.id, m.role
188
- FROM incremental.mentions m
189
- JOIN incremental.global_symbols source ON source.id = m.symbol_id
190
- JOIN main.global_symbols target ON target.symbol = source.symbol`).run(n),e.prepare(`INSERT INTO main.defn_enclosing_ranges(
191
- id, document_id, symbol_id, start_line, start_char, end_line, end_char
192
- )
193
- SELECT r.id + ?, r.document_id + ?, target.id,
194
- r.start_line, r.start_char, r.end_line, r.end_char
195
- FROM incremental.defn_enclosing_ranges r
196
- JOIN incremental.global_symbols source ON source.id = r.symbol_id
197
- JOIN main.global_symbols target ON target.symbol = source.symbol`).run(r,t)}function Ca(e){e.exec(`
198
- DELETE FROM main.global_symbols
199
- WHERE NOT EXISTS (SELECT 1 FROM main.mentions m WHERE m.symbol_id = main.global_symbols.id)
200
- AND NOT EXISTS (
201
- SELECT 1 FROM main.defn_enclosing_ranges r WHERE r.symbol_id = main.global_symbols.id
202
- );
203
- `)}function $a(e,t,n){let r=O(e,"SELECT COUNT(*) AS value FROM main.documents"),a=O(e,`SELECT COUNT(*) AS value
204
- FROM main.documents d
205
- JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path`);if(r!==n||a!==t)throw new Error("candidate SQLite document counts changed unexpectedly");let i=e.prepare("SELECT relative_path FROM main.documents GROUP BY relative_path HAVING COUNT(*) > 1 LIMIT 1").pluck().get(),o=e.prepare("SELECT symbol FROM main.global_symbols GROUP BY symbol HAVING COUNT(*) > 1 LIMIT 1").pluck().get();if(i!==void 0||o!==void 0)throw new Error("candidate SQLite generation contains duplicate document paths or symbols")}function Ba(e){let t=Ze(e,"main",!0),n=Ze(e,"incremental",!1);if(JSON.stringify([...t])!==JSON.stringify([...n]))throw new Error("candidate SQLite affected document facts differ from the mini database");return t}function Ze(e,t,n){let r=n?"JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path":"",a=e.prepare(`SELECT d.relative_path, d.language, d.position_encoding, d.text
206
- FROM ${t}.documents d
207
- ${r}
208
- ORDER BY d.relative_path`).all(),i=e.prepare(`SELECT d.relative_path, c.chunk_index, c.start_line, c.end_line, hex(c.occurrences) AS occurrences
209
- FROM ${t}.chunks c
210
- JOIN ${t}.documents d ON d.id = c.document_id
211
- ${r}
212
- ORDER BY d.relative_path, c.chunk_index, c.start_line, c.end_line, c.id`).all(),o=e.prepare(`SELECT d.relative_path, r.start_line, r.start_char, r.end_line, r.end_char,
213
- g.symbol, g.display_name, g.kind, g.documentation,
214
- CASE WHEN g.signature IS NULL THEN NULL ELSE hex(g.signature) END AS signature,
215
- g.enclosing_symbol,
216
- CASE WHEN g.relationships IS NULL THEN NULL ELSE hex(g.relationships) END AS relationships
217
- FROM ${t}.defn_enclosing_ranges r
218
- JOIN ${t}.documents d ON d.id = r.document_id
219
- JOIN ${t}.global_symbols g ON g.id = r.symbol_id
220
- ${r}
221
- ORDER BY d.relative_path, r.start_line, r.start_char, r.end_line, r.end_char, g.symbol`).all(),s=e.prepare(`SELECT d.relative_path, c.chunk_index, m.role, g.symbol
222
- FROM ${t}.mentions m
223
- JOIN ${t}.chunks c ON c.id = m.chunk_id
224
- JOIN ${t}.documents d ON d.id = c.document_id
225
- JOIN ${t}.global_symbols g ON g.id = m.symbol_id
226
- ${r}
227
- ORDER BY d.relative_path, c.chunk_index, m.role, g.symbol`).all(),d=new Map;for(let[c,p]of Object.entries({documents:a,chunks:i,definitions:o,mentions:s}))for(let u of p){let g=JSON.stringify([c,u]),m=d.get(u.relative_path)??[];m.push(g),d.set(u.relative_path,m)}let l=new Map;for(let[c,p]of[...d].sort(([u],[g])=>u.localeCompare(g))){let u=Ea("sha256");for(let g of p.sort())u.update(g).update(`
228
- `);l.set(c,u.digest("hex"))}return l}function O(e,t){return e.prepare(t).get().value}import Ga from"better-sqlite3";var Pe="idx_mentions_definitions",Ua=["symbol_id","chunk_id"];function et(e){let t=new Ga(e),n=[],r=[],a=[];try{return t.transaction(()=>{Wa(t,n),xe(t,"idx_global_symbols_symbol")?.join("\0")==="symbol"&&tr(t,"global_symbols").some(s=>s.name!=="idx_global_symbols_symbol"&&s.unique&&s.columns.join("\0")==="symbol")?(t.exec('DROP INDEX "idx_global_symbols_symbol"'),r.push("idx_global_symbols_symbol")):xe(t,"idx_global_symbols_symbol")&&a.push("idx_global_symbols_symbol");let i=xe(t,"idx_chunks_doc_id"),o=tr(t,"chunks").some(s=>s.name!=="idx_chunks_doc_id"&&s.columns.length>1&&s.columns[0]==="document_id");i?.join("\0")==="document_id"&&o?(t.exec('DROP INDEX "idx_chunks_doc_id"'),r.push("idx_chunks_doc_id")):i&&a.push("idx_chunks_doc_id"),t.exec("ANALYZE")})(),{added:n,removed:r,retained:a,analyzed:!0}}catch(i){if(i.code==="SQLITE_NOTADB")return{added:[],removed:[],retained:[],analyzed:!1,skippedReason:"not-a-sqlite-database"};throw i}finally{t.close()}}function Wa(e,t){let n=nr(e,Pe);if(n){let r=n.columns.join("\0")===Ua.join("\0"),a=/\bWHERE\s+role\s*=\s*1\b/iu.test(n.sql??"");if(!r||!a||n.table!=="mentions")throw new Error(`${Pe} exists with an incompatible definition`);return}e.exec(`CREATE INDEX "${Pe}" ON mentions(symbol_id, chunk_id) WHERE role = 1`),t.push(Pe)}function tr(e,t){return e.prepare(`PRAGMA index_list('${t.replaceAll("'","''")}')`).all().map(n=>({name:n.name,unique:n.unique===1,columns:xe(e,n.name)??[]}))}function xe(e,t){return nr(e,t)?.columns??null}function nr(e,t){let n=e.prepare("SELECT tbl_name, sql FROM sqlite_master WHERE type = 'index' AND name = ?").get(t);if(!n)return null;let r=e.prepare(`PRAGMA index_info('${t.replaceAll("'","''")}')`).all().map(a=>a.name);return{table:n.tbl_name,sql:n.sql,columns:r}}import{createHash as qa}from"crypto";import{existsSync as tt,readdirSync as Ha}from"fs";import{dirname as nt,join as Re,relative as Ja,resolve as rt,sep as rr}from"path";function ar(e,t){let n=t.includes("."),r={};for(let i of t)r[i]=[];let a=[];for(let i of e){let o=cr(i.path,t);o?r[o].push(i):n?r["."].push(i):a.push(i)}return{files:r,shared:a}}function ir(e,t){let n=new Map;for(let a of e){let i=t[a]?.packageName;i&&n.set(i,a)}let r=new Map;for(let a of e)r.set(a,new Set);for(let a of e){let i=t[a],o=r.get(a);if(!i||i.parseFailed){for(let s of e)s!==a&&o.add(s);continue}for(let s of i.dependencyNames){let d=n.get(s);d&&d!==a&&o.add(d)}for(let s of[...i.pathsTargets,...i.referencesPaths]){let d=cr(s,e);d&&d!==a&&o.add(d)}}return za(e,r)}function or(e,t,n){let r={};for(let a of e){let i=new Map;for(let o of t.files[a]??[])i.set(o.path,o);for(let o of n[a]??[])for(let s of t.files[o]??[])i.set(s.path,s);for(let o of t.shared)i.set(o.path,o);r[a]={files:[...i.values()].sort((o,s)=>o.path.localeCompare(s.path))}}return r}function at(e){if(e===".")return"root";let t=qa("sha256").update(e).digest("hex").slice(0,8);return`${e.split("/").join("__")}-${t}`}function sr(e,t){let n=rt(e),r={};for(let a of t)r[a]=Qa(n,a);return r}function cr(e,t){let n;for(let r of t)r!=="."&&(e===r||e.startsWith(`${r}/`))&&(!n||r.length>n.length)&&(n=r);return n}function za(e,t){let n={};for(let r of e){let a=new Set,i=[...t.get(r)??[]];for(;i.length>0;){let o=i.pop();if(!(o===r||a.has(o))){a.add(o);for(let s of t.get(o)??[])s!==r&&!a.has(s)&&i.push(s)}}n[r]=[...a].sort((o,s)=>o.localeCompare(s))}return n}function Qa(e,t){let n=t==="."?e:Re(e,t),r=Va(n),a=Xa(n),i=a?Ya(a,e):{pathsTargets:[],referencesPaths:[],failed:!1};return{packageName:r.name,dependencyNames:r.dependencyNames,pathsTargets:i.pathsTargets,referencesPaths:i.referencesPaths,parseFailed:r.failed||i.failed}}function Va(e){let t=Re(e,"package.json");if(!tt(t))return{name:void 0,dependencyNames:[],failed:!1};let n=it(t);if(!n.ok)return{name:void 0,dependencyNames:[],failed:!0};let r=typeof n.value.name=="string"?n.value.name:void 0,a=new Set;for(let i of["dependencies","devDependencies","peerDependencies"]){let o=n.value[i];if(o&&typeof o=="object"&&!Array.isArray(o))for(let s of Object.keys(o))a.add(s)}return{name:r,dependencyNames:[...a],failed:!1}}function Xa(e){let t=Re(e,"tsconfig.json");if(tt(t))return t;let n;try{n=Ha(e).filter(r=>/^tsconfig.*\.json$/.test(r))}catch{return}return n.sort((r,a)=>r.localeCompare(a)),n.length>0?Re(e,n[0]):void 0}function Ya(e,t){let n=it(e);if(!n.ok)return{pathsTargets:[],referencesPaths:[],failed:!0};let r=Ka(n.value,e,t),a=dr(e,n.value,t,0);return{pathsTargets:a.pathsTargets,referencesPaths:r,failed:a.failed}}function Ka(e,t,n){let r=e.references;if(!Array.isArray(r))return[];let a=nt(t),i=new Set;for(let o of r){if(!o||typeof o!="object")continue;let s=o.path;if(typeof s!="string"||s.trim()==="")continue;let d=lr(s,a,n);d&&i.add(d)}return[...i]}function dr(e,t,n,r){let a=Za(t);if(a)return{pathsTargets:ei(a,nt(e),n),failed:!1};if(r>=5)return{pathsTargets:[],failed:!1};let i=ti(t.extends,e,n);if(!i)return{pathsTargets:[],failed:!1};let o=it(i);return o.ok?dr(i,o.value,n,r+1):{pathsTargets:[],failed:!0}}function Za(e){let t=e.compilerOptions;if(!t||typeof t!="object"||Array.isArray(t))return;let n=t.paths;return n&&typeof n=="object"&&!Array.isArray(n)?n:void 0}function ei(e,t,n){let r=new Set;for(let a of Object.values(e))if(Array.isArray(a))for(let i of a){if(typeof i!="string")continue;let o=lr(i,t,n);o&&r.add(o)}return[...r]}function ti(e,t,n){let r=Array.isArray(e)?e.at(-1):e;if(typeof r!="string"||r.trim()===""||!r.startsWith(".")&&!r.startsWith("/"))return;let a=rt(nt(t),r);if(a.endsWith(".json")||(a=`${a}.json`),!a.split(rr).includes("node_modules")&&Me(n,a)&&tt(a))return a}function lr(e,t,n){let r=e.replace(/\/?\*+$/,""),a=rt(t,r===""?".":r);if(!Me(n,a))return;let o=Ja(n,a).split(rr).join("/");return o===""?".":o}function ni(e){let t="",n=0,r=!1,a=e.length;for(;n<a;){let i=e[n];if(r){if(t+=i,i==="\\"&&n+1<a){t+=e[n+1],n+=2;continue}i==='"'&&(r=!1),n+=1;continue}if(i==='"'){r=!0,t+=i,n+=1;continue}if(i==="/"&&e[n+1]==="/"){for(n+=2;n<a&&e[n]!==`
229
- `;)n+=1;continue}if(i==="/"&&e[n+1]==="*"){for(n+=2;n<a&&!(e[n]==="*"&&e[n+1]==="/");)n+=1;n+=2;continue}t+=i,n+=1}return t}function it(e){try{let t=ie(e,{maxBytes:Pt,inputKind:"TypeScript project manifest"}),n=JSON.parse(ni(t));return n&&typeof n=="object"&&!Array.isArray(n)?{ok:!0,value:n}:{ok:!1}}catch{return{ok:!1}}}import{createHash as gi}from"crypto";import{existsSync as ot,statSync as fi,writeFileSync as st}from"fs";import{join as mi}from"path";import{randomUUID as ri}from"crypto";import{existsSync as ai}from"fs";var ii=12e4,oi=5,ve=class{projectRoot;cacheDir;baseGeneration;timeoutMs;runtime;mailboxLimits;constructor(t,n={}){this.projectRoot=kt(t.projectRoot),this.cacheDir=t.cacheDir,this.baseGeneration=t.baseGeneration,this.timeoutMs=n.timeoutMs??ui(),this.runtime=n.runtime??pi,this.mailboxLimits=n.mailboxLimits??{}}request(t){let n=jn(this.cacheDir),r=wn(this.cacheDir),a=Je(n.statePath);if(!ur(a,this.projectRoot,this.runtime))throw new Error("Compatible TypeScript index service is not running.");let i=this.runtime.now(),o=i+this.timeoutMs,s=(this.runtime.monotonicNow??b)()+this.timeoutMs,d=vn("typescript-index-v4",{baseGeneration:this.baseGeneration,request:t}),l=In(d),c=En(r,{mailboxVersion:Rn,operationKey:d,clientId:this.runtime.randomId(),enqueuedAtMs:i,deadlineAtMs:o,protocolVersion:ye,id:l,baseGeneration:this.baseGeneration,request:t},{nowMs:i,limits:this.mailboxLimits});for(;(this.runtime.monotonicNow??b)()<=s;){if(ai(c.responsePath))return si(ie(c.responsePath,{maxBytes:this.mailboxLimits.maxItemBytes??64*1024*1024,inputKind:"TypeScript index mailbox response"}),l,d,this.baseGeneration,t.producerIdentity,t.affectedFiles);let p=Je(n.statePath);if(!ur(p,this.projectRoot,this.runtime))throw new Error("TypeScript index service stopped while processing a request.");this.runtime.sleep(oi)}throw new Error(`TypeScript index service timed out after ${this.timeoutMs}ms.`)}};function ur(e,t,n){let r=e?.processIdentity?n.readProcessIdentity?.(e.pid):null;return e!==null&&e.projectRoot===t&&e.typescriptIndex?.protocolVersion===ye&&n.isProcessAlive(e.pid)&&(!e.processIdentity||r!=null&&Y(e.processIdentity,r))}function si(e,t,n,r,a,i){let o=JSON.parse(e);if(o.protocolVersion!==ye||o.id!==t||o.operationKey!==n||o.ok===!0&&o.baseGeneration!==r)throw new Error("TypeScript index service wrote an incompatible response.");if(o.ok!==!0)throw new Error(typeof o.error=="string"?o.error:"TypeScript index service request failed.");let s=ci(o.response,a),d=[...new Set(i)].sort(),l=s.fragments.map(c=>c.relativePath).sort();if(JSON.stringify(l)!==JSON.stringify(d))throw new Error("TypeScript index service omitted or added an affected document.");return s}function ci(e,t){if(!e||typeof e!="object")throw new Error("TypeScript index service wrote an invalid response.");let n=e;if(n.producerIdentity!==t||typeof n.cold!="boolean"||typeof n.durationMs!="number"||!Number.isFinite(n.durationMs)||!Array.isArray(n.fragments))throw new Error("TypeScript index service wrote an invalid response.");let r=new Set,a=n.fragments.map(i=>{if(!i||typeof i.relativePath!="string"||i.bytesBase64!==null&&typeof i.bytesBase64!="string"||typeof i.occurrences!="number"||!Number.isInteger(i.occurrences)||i.occurrences<0||typeof i.symbols!="number"||!Number.isInteger(i.symbols)||i.symbols<0||!Array.isArray(i.referenceFragments)||!i.referenceFragments.every(di)||r.has(i.relativePath))throw new Error("TypeScript index service wrote an invalid fragment.");r.add(i.relativePath);let o=i.bytesBase64===null?null:li(i.bytesBase64);return{relativePath:i.relativePath,bytes:o,occurrences:i.occurrences,symbols:i.symbols,referenceFragments:i.referenceFragments}});return{producerIdentity:n.producerIdentity,cold:n.cold,durationMs:n.durationMs,fragments:a}}function di(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.targetSymbol=="string"&&!!t.location&&typeof t.location.file=="string"&&Number.isInteger(t.location.line)&&Number.isInteger(t.location.column)}function li(e){let t=Buffer.from(e,"base64");if(t.toString("base64")!==e)throw new Error("TypeScript index service wrote invalid base64.");return t}function ui(){let e=Number(process.env.SCIP_TYPESCRIPT_INDEX_TIMEOUT_MS);return Number.isInteger(e)&&e>0?e:ii}var pi={now:Date.now,monotonicNow:b,randomId:ri,sleep(e){let t=new Int32Array(new SharedArrayBuffer(4));Atomics.wait(t,0,0,e)},isProcessAlive:H,readProcessIdentity:U};function hi(e){let t=e.projectMode==="workspace"?e.workspaceProjects??[]:["."];if(t.length===0)return{eligible:!1,reason:"workspace project roots unavailable"};if(t.length===1&&t[0]==="."&&!e.rootTsconfigExists)return{eligible:!1,reason:"root tsconfig unavailable"};if(!e.previousSnapshot)return{eligible:!1,reason:"prior project snapshot unavailable"};if(e.graph===null)return{eligible:!1,reason:"dependency graph unavailable"};if(e.projectFiles.length===0)return{eligible:!1,reason:"prior TypeScript documents unavailable"};let n=ce(e.previousSnapshot,e.currentSnapshot);if(n.changes.length===0)return{eligible:!1,reason:"no changed project inputs"};if(n.changes.some(c=>c.kind!=="modified"||c.inputKind!=="source"||!Be(c.path)))return{eligible:!1,reason:"change is not a modified TypeScript source file"};let r=Se(n,e.graph,e.projectFiles);if(r.mode!=="closure"||r.affectedFiles.length===0)return{eligible:!1,reason:r.reasons.length>0?`affected set widened: ${r.reasons.join(", ")}`:"empty affected set"};let a=yi(r,t,e.graph);if(!a)return{eligible:!1,reason:"affected files cross or ambiguously match TypeScript projects"};let i=pr(e.currentSnapshot,e.projectFiles,e.producerIdentity),o=pr(e.previousSnapshot,e.projectFiles,e.producerIdentity);if(i!==o)return{eligible:!1,reason:"TypeScript fragment project identity changed"};let s=fr(e.previousSnapshot,e.projectFiles,e.graph,e.producerIdentity,e.projectFiles);if(!s)return{eligible:!1,reason:"prior document identity unavailable"};let d=fr(e.currentSnapshot,e.projectFiles,e.graph,e.producerIdentity,r.affectedFiles);if(!d)return{eligible:!1,reason:"next document identity unavailable"};let l=a.length===1?a[0]:void 0;return{eligible:!0,manifest:n,plan:r,projectIdentity:i,previousFragmentGeneration:gr(e.previousSnapshot,e.producerIdentity),nextFragmentGeneration:gr(e.currentSnapshot,e.producerIdentity),previousDocumentIdentities:s,nextDocumentIdentities:d,projects:a,...l?{tsconfigPath:l.tsconfigPath,projectArgument:l.projectArgument}:{}}}function yi(e,t,n){let r=new Map;for(let i of e.affectedFiles){let o=Si(i,t);if(!o)return null;let s=r.get(o)??[];s.push(i),r.set(o,s)}let a=[];for(let[i,o]of[...r].sort(([s],[d])=>s.localeCompare(d))){let s=new Set(o),d=e.changedFiles.filter(l=>s.has(l)||o.some(c=>bi(c,l,n)));if(d.length===0)return null;a.push({projectArgument:i,tsconfigPath:i==="."?"tsconfig.json":`${i}/tsconfig.json`,modifiedFiles:d,affectedFiles:[...o].sort()})}return a}function Si(e,t){let n=t.filter(i=>i==="."||e===i||e.startsWith(`${i}/`));if(n.length===0)return null;let r=[...new Set(n)].sort((i,o)=>Ie(o)-Ie(i)||i.localeCompare(o)),a=r[0];return r[1]&&Ie(r[1])===Ie(a)?null:a}function Ie(e){return e==="."?0:e.split("/").filter(Boolean).length}function bi(e,t,n){let r=new Set,a=[e];for(let i=0;i<a.length;i+=1){let o=a[i];if(!(!o||r.has(o))){r.add(o);for(let s of n.get(o)??[]){if(s===t)return!0;r.has(s)||a.push(s)}}}return!1}function mr(e){let t=b();try{if(!ot(e.previousDbPath)||!ot(e.previousShardPath))throw new Error("prior TypeScript graph or language shard unavailable");let n=performance.now(),r=He();if(!r.available)throw new Error(r.reason);let a=performance.now()-n;n=performance.now();let i=new F({projectRoot:e.projectRoot,dbPath:e.previousDbPath,indexPath:e.previousIndexPath}),o,s;try{o=ge(i,{includeIgnored:!1}).filter(Be).sort(),s=fe(i)}finally{i.close()}let d=performance.now()-n,l=hi({projectMode:e.projectMode,workspaceProjects:e.projectMode==="workspace"?J(e.projectRoot,e.currentSnapshot.typescriptProjects):void 0,previousSnapshot:e.previousSnapshot,currentSnapshot:e.currentSnapshot,projectFiles:o,graph:s,producerIdentity:r.producerIdentity,rootTsconfigExists:ot(mi(e.projectRoot,"tsconfig.json"))});if(!l.eligible)throw new Error(l.reason);let c=_n(e.previousDbPath);if(!c)throw new Error("published TypeScript base generation unavailable");n=performance.now();let p=new ve({projectRoot:e.projectRoot,cacheDir:e.cacheDir,baseGeneration:c}),u=l.projects.map(S=>p.request({kind:"emit-documents",tsconfigPath:S.tsconfigPath,projectArgument:S.projectArgument,projectIdentity:l.projectIdentity,producerIdentity:r.producerIdentity,modifiedFiles:S.modifiedFiles,affectedFiles:S.affectedFiles})),g=u.flatMap(S=>S.fragments),m=performance.now()-n,x=fi(e.previousShardPath).size>=ln;n=performance.now();let w=x?null:X(e.previousShardPath,{inputKind:"TypeScript base SCIP shard",maxBytes:Oe}),f=x?{completeIndexBytes:null,affectedIndexBytes:an(g)}:cn({packageVersion:r.packageVersion,baseIndexBytes:w,fragments:g}),y=performance.now()-n;n=performance.now(),x?un({cacheDir:e.cacheDir,previousGenerationIdentity:l.previousFragmentGeneration,nextGenerationIdentity:l.nextFragmentGeneration,producerIdentity:r.producerIdentity,projectIdentity:l.projectIdentity,baseShardCurrent:e.baseShardCurrent,fragments:g}):(on({cacheDir:e.cacheDir,packageVersion:r.packageVersion,indexBytes:w,producerIdentity:r.producerIdentity,projectIdentity:l.projectIdentity,generationIdentity:l.previousFragmentGeneration,documentIdentities:l.previousDocumentIdentities,allowUntrackedDocuments:!0}),sn({cacheDir:e.cacheDir,previousGenerationIdentity:l.previousFragmentGeneration,producerIdentity:r.producerIdentity,projectIdentity:l.projectIdentity,generationIdentity:l.nextFragmentGeneration,fragments:g,documentIdentities:l.nextDocumentIdentities}));let P=performance.now()-n;n=performance.now(),f.completeIndexBytes&&st(e.candidateShardPath,f.completeIndexBytes),st(e.candidateAffectedScipPath,f.affectedIndexBytes);let v=performance.now()-n,R={scipPath:x?e.previousShardPath:e.candidateShardPath,candidateScipPath:e.candidateShardPath,affectedScipPath:e.candidateAffectedScipPath,completeScipUpdated:!x,durationMs:b()-t,cold:u.some(S=>S.cold),changedFiles:l.plan.changedFiles,affectedFiles:l.plan.affectedFiles,producerIdentity:r.producerIdentity,previousFragmentGeneration:l.previousFragmentGeneration,nextFragmentGeneration:l.nextFragmentGeneration,manifest:l.manifest,plan:l.plan,projectFileCount:o.length,referenceFragmentsByFile:new Map(g.map(S=>[S.relativePath,S.referenceFragments])),timings:{runtimeMs:a,graphMs:d,requestMs:m,serviceMs:u.reduce((S,B)=>S+B.durationMs,0),assemblyMs:y,fragmentStoreMs:P,writeMs:v}};return e.onStatus(`Incremental TypeScript index emitted ${R.affectedFiles.length} affected document(s) across ${l.projects.length} project(s) in ${(R.durationMs/1e3).toFixed(3)}s (${R.cold?"cold":"warm"} service; ${x?"whole SCIP deferred":"whole SCIP current"}; runtime ${a.toFixed(0)}ms, graph ${d.toFixed(0)}ms, request ${m.toFixed(0)}ms, assembly ${y.toFixed(0)}ms, fragments ${P.toFixed(0)}ms, write ${v.toFixed(0)}ms).`),R}catch(n){return e.onStatus(`Incremental TypeScript index unavailable: ${n instanceof Error?n.message:String(n)}. Falling back to the whole-project indexer.`),null}}function hr(e){let t=He();if(!t.available)throw new Error(t.reason);let n=pn({cacheDir:e.cacheDir,generationIdentity:e.generationIdentity,baseIndexBytes:X(e.baseShardPath,{inputKind:"TypeScript base SCIP shard",maxBytes:Oe}),packageVersion:t.packageVersion});st(e.candidateShardPath,n)}function pr(e,t,n){let r=e.files.filter(a=>Et(a.path,e.languages)!=="source").map(a=>({path:a.path,size:a.size,hash:a.hash})).sort((a,i)=>a.path.localeCompare(i.path));return ct(JSON.stringify({version:1,producerIdentity:n,pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:[...e.typescriptProjects].sort(),projectFiles:[...t].sort(),nonSourceInputs:r}))}function gr(e,t){return ct(JSON.stringify({version:1,producerIdentity:t,snapshot:e}))}function fr(e,t,n,r,a){let i=new Set(e.files.map(d=>d.path)),o=Jt({projectFiles:t.filter(d=>i.has(d)),snapshot:e,graph:n,engineIdentity:r}),s=new Map;for(let d of a){let l=o.identityFor(d,"typescript-scip-document-v1");if(l.key){s.set(d,l.key);continue}if(i.has(d))return null;s.set(d,ct(JSON.stringify({version:1,producerIdentity:r,generatedDocument:d})))}return s}function ct(e){return gi("sha256").update(e).digest("hex")}import{closeSync as Pi,existsSync as Ee,fstatSync as xi,lstatSync as Ri,openSync as vi,renameSync as lt,rmSync as we,statSync as Ii,writeSync as Ei}from"fs";import{cpus as wi}from"os";import{join as ut}from"path";function _i(e,t){if(e.temporaryRootConfigContent===void 0)return null;let n=ut(t,"tsconfig.json"),r=Buffer.from(e.temporaryRootConfigContent,"utf8"),a;try{a=vi(n,"wx",384)}catch(i){if(i.code==="EEXIST")return null;throw i}try{Ei(a,r);let i=xi(a);return{path:n,content:r,device:i.dev,inode:i.ino}}finally{Pi(a)}}function ji(e){if(e)try{let t=Ri(e.path);if(!t.isFile()||t.dev!==e.device||t.ino!==e.inode||t.size!==e.content.byteLength)return;let n;try{n=X(e.path,{maxBytes:e.content.byteLength,inputKind:"temporary TypeScript index configuration"})}catch{return}if(!n.equals(e.content))return;we(e.path)}catch(t){if(t.code!=="ENOENT")throw t}}function Ti(e,t,n){if(!e.defaultOutputPath)return;let r=ut(t,e.defaultOutputPath);n!==r&&Ee(r)&&lt(r,n)}function Fi(e,t,n){if(!e.defaultOutputPath)return null;let r=ut(t,e.defaultOutputPath);if(r===n)return null;let a=`${n}.default-output-backup`;return we(a,{force:!0}),Ee(r)?(lt(r,a),{defaultOutputPath:r,backupPath:a}):{defaultOutputPath:r,backupPath:null}}function ki(e){e&&(we(e.defaultOutputPath,{force:!0}),e.backupPath&&Ee(e.backupPath)&&lt(e.backupPath,e.defaultOutputPath))}function Di(e,t){if(e<=1)return 1;let n=Number(process.env.CODEBASEIQ_INDEXER_CONCURRENCY??0),r=Number.isFinite(t)&&t&&t>0?t:Number.isFinite(n)&&n>0?n:Math.min(8,Math.max(1,wi().length));return Math.max(1,Math.min(e,Math.floor(r)))}async function Sr(e,t,n,r,a){T(a,"Reindex cancelled by its owner.");let i=e.filter(c=>c.config.defaultOutputPath),o=e.filter(c=>!c.config.defaultOutputPath),s=[],d=Di(o.length,r),l=await Tn(o,d,c=>dt(c,t,n,a));if(d>1){let c=new Map;for(let p of l.filter(u=>u.result.skipped&&u.retryable)){let u=o.find(g=>g.id===p.result.id);u&&(n(`Retrying ${u.label} indexer serially after parallel failure...`),T(a,"Reindex cancelled by its owner."),c.set(u.id,(await dt(u,t,n,a)).result))}s.push(...l.map(({result:p})=>c.get(p.id)??p))}else s.push(...l.map(({result:c})=>c));for(let c of i)T(a,"Reindex cancelled by its owner."),s.push((await dt(c,t,n,a)).result);return s.sort((c,p)=>e.findIndex(u=>u.id===c.id)-e.findIndex(u=>u.id===p.id))}async function dt(e,t,n,r){T(r,"Reindex cancelled by its owner."),n(`Indexing ${e.label} with ${e.resolvedBinary}...`),we(e.scipPath,{force:!0});let a=Fi(e.config,t,e.scipPath),i=_i(e,t),o=[e.binary,...e.args].join(" "),s=b();try{e.trustedProjectTool&&Ut(t,e.trustedProjectTool);let l=Tt(e.binary,e.args),c=await se({command:l.binary,args:l.args,label:`${e.label} indexer`,cwd:t,env:e.env,timeoutMs:Oi(),maxStdoutBytes:50*1024*1024,maxStderrBytes:50*1024*1024,signal:r});if(c.status!==0){let p=c.stderr.trim();throw new Error(`${e.resolvedBinary} exited with status ${c.status}${p?`:
230
- ${p}`:""}`)}Ti(e.config,t,e.scipPath)}catch(l){if(r?.aborted)throw Dt(r,"Reindex cancelled by its owner.");let c=l instanceof Error?l.message:String(l),p=`${e.resolvedBinary} indexer failed: ${c.split(`
231
- `)[0]}`,u=e.label===e.language?p:`${e.label}: ${p}`;return n(`Skipping ${e.label}: ${p}`),{result:{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,durationMs:b()-s,command:o,skipped:{language:e.language,reason:u}},retryable:Ai(l)}}finally{ki(a),ji(i)}if(!Ee(e.scipPath)){let l=`${e.resolvedBinary} indexer completed but did not produce ${e.scipPath}`,c=e.label===e.language?l:`${e.label}: ${l}`;return n(`Skipping ${e.label}: ${l}`),{result:{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,durationMs:b()-s,command:o,skipped:{language:e.language,reason:c}},retryable:!1}}let d;try{d=Ii(e.scipPath).size}catch{d=void 0}return{result:{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,durationMs:b()-s,command:o,outputBytes:d},retryable:!1}}function Oi(){let e=Number(process.env.CODEBASEIQ_INDEXER_TIMEOUT_MS);return Number.isFinite(e)&&e>0?Math.floor(e):vt.indexer}function Ai(e){return e instanceof It?e.kind==="spawn"&&yr(e.cause):yr(e)}function yr(e){let t=e?.code;return t==="EAGAIN"||t==="ENOMEM"||t==="EMFILE"||t==="ENFILE"||t==="ETXTBSY"}import{execFileSync as Pr}from"child_process";import{homedir as br,platform as Li}from"os";import{delimiter as Mi,join as _e}from"path";function xr(e,t){let n=e.installMethods,r=pe(e);if(!n?.length)return t(`No auto-install method available for ${r}.`),e.installUrl&&t(`Install manually from: ${e.installUrl}`),!1;for(let a of n){if(!a.identity||!a.destination){t(`Refusing ${a.label} installation for ${r}: the installer descriptor lacks an immutable identity or destination.`);continue}if(!jt(a.prerequisite))continue;let i=Ni(a);t(`Installing immutable ${a.identity} via ${a.label} into ${i}; expected executable: ${r}.`);try{Pr(a.binary,a.args,{stdio:"inherit",windowsHide:!0,timeout:3e5,env:process.env,shell:Li()==="win32"});let o=Z(e);if(o){let s=o===e.indexerBinary?"":` (using ${o})`;return t(`Successfully installed ${a.identity} via ${a.label}${s}; resolved executable: ${o}.`),!0}t(`${a.label} command completed but ${r} was not found on PATH`)}catch(o){let s=o instanceof Error?o.message:String(o);t(`${a.label} install failed: ${s}`)}}return t(`Could not auto-install ${r}.`),e.installUrl&&t(`Install manually from: ${e.installUrl}`),!1}function Ni(e){if(e.binary==="npm")return pt("npm",["root","-g"])??e.destination;if(e.binary==="go"){let t=pt("go",["env","GOBIN"]);if(t)return t;let n=pt("go",["env","GOPATH"]);if(n)return _e(n.split(Mi)[0],"bin")}return e.binary==="dotnet"?_e(process.env.DOTNET_CLI_HOME??br(),".dotnet","tools"):e.binary==="dart"?_e(process.env.PUB_CACHE??_e(br(),".pub-cache"),"bin"):e.destination}function pt(e,t){try{return Pr(e,t,{stdio:["ignore","pipe","ignore"],windowsHide:!0,encoding:"utf8",timeout:1e4,killSignal:"SIGKILL",env:process.env}).trim()||null}catch{return null}}async function dd(e){let{projectRoot:t,maxHeapMb:n=8192,onStatus:r=console.log}=e,a=e.skipAutoInstall===!0||e.installMissing!==!0,i=Hi(e),o=Date.now(),s=b();Te(h(i.outputScip),{recursive:!0}),Te(h(i.outputDb),{recursive:!0});let d=e.languages??Ge(t);if(d.length===0)throw new Error("No supported languages detected in this project. Looked for: tsconfig.json, Cargo.toml, go.mod, pyproject.toml, etc.");r(`Detected languages: ${d.join(", ")}`);let l=le("reindex.fingerprint",()=>Ct(t,d,{pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:e.typescriptProjects,clojureConfigPath:e.clojureConfigPath}),{languages:d.length}),c,p;if(e.skipIfUnchanged!==!1&&!hn(t,i.outputDb)&&Rr(i.outputScip)===Rr(E(h(i.outputDb),"index.scip"))){let f=ue(t);if(c=f?.clean?me(f,l):void 0,f&&!f.clean&&!qi(i)){let y=yn(f,d,{pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:e.typescriptProjects,clojureConfigPath:e.clojureConfigPath});if(y)try{he({snapshot:y.snapshot,manifest:y.manifest,targetCacheDir:h(i.outputDb),targetProjectRoot:t,persistLease:!1}),xn(y.snapshot,h(i.outputDb)),r(`Forked shared baseline ${y.snapshot.generationId.slice(0,12)} for dirty worktree reindex`)}catch(P){r(`Shared baseline fork failed; continuing locally: ${A(P)}`)}}else if(c){let y=qe(c);if(y){if(!Wi(i,l))try{he({snapshot:c,manifest:y,targetCacheDir:h(i.outputDb),targetProjectRoot:t}),r(`Attached shared generation ${c.generationId.slice(0,12)}`)}catch(P){r(`Shared generation attach failed; continuing locally: ${A(P)}`)}}else{let P=await bn(c);if(P.kind==="owner")p=P.release;else if(P.kind==="generation-ready"){let v=qe(c);if(v)try{he({snapshot:c,manifest:v,targetCacheDir:h(i.outputDb),targetProjectRoot:t,action:"waited"}),r(`Attached shared generation ${c.generationId.slice(0,12)} after waiting`)}catch(R){r(`Shared generation attach failed after waiting; continuing locally: ${A(R)}`)}}else r("Shared generation build lock timed out; continuing with an isolated local reindex")}}}let g=Lt(E(h(i.outputDb),"cache-lifecycle.lock"),{waitMs:3e4});if(!g)throw p?.(),new Error(`Could not acquire codebaseiq cache lifecycle lock for ${h(i.outputDb)}.`);let m;try{m=await q("reindex.lock",()=>bo(E(h(i.outputDb),"index.lock"),{projectRoot:t,trigger:e.trigger,onStatus:r}),{languages:d.length})}catch(f){throw g.release(),p?.(),f}let x=null,w=kn();try{mn(i.outputDb,i.outputScip,i.metaPath);let f=Vi(h(i.outputDb));f.removed>0&&r(`Removed ${f.removed} abandoned reindex workspace(s)`);for(let G of f.errors)r(`Could not remove abandoned reindex workspace: ${G}`);let y=null,P=le("reindex.reuse-check",()=>(y=Ji({opts:e,paths:i,languages:d,fingerprint:l,start:o,monotonicStart:s,onStatus:r}),y),()=>({languages:d.length,reused:y!==null}));if(P){vr({snapshot:c,paths:i,projectRoot:t,fingerprint:l,onStatus:r});let G=Ue(i.outputDb,P);return G.state==="failed"&&r(`Warning: reindex succeeded, but activity telemetry was not recorded: ${G.reason}`),Ne(t,h(i.outputDb)),P}await q("reindex.scip-cli-ready",()=>uo(a,r));let v=Qi(i);x=v.runDir;let R,S=await q("reindex.fresh",async()=>(R=await Xi({opts:e,languages:d,projectRoot:t,paths:i,tempPaths:v,fingerprint:l,start:o,monotonicStart:s,maxHeapMb:n,skipAutoInstall:a,onStatus:r,writeTelemetry:w}),R),()=>({languages:d.length,reused:R?.reused,skipped:R?.skipped.length}));vr({snapshot:c,paths:i,projectRoot:t,fingerprint:l,onStatus:r});let B=Ue(i.outputDb,S);return B.state==="failed"&&r(`Warning: reindex succeeded, but activity telemetry was not recorded: ${B.reason}`),Ne(t,h(i.outputDb)),S}catch(f){let y=De({trigger:e.trigger,result:"failed",start:o,monotonicStart:s,error:f instanceof Error?f.message:String(f)});qr(i.metaPath,y);let P=rn(i.outputDb,y);throw P.state==="failed"&&r(`Warning: failed reindex activity telemetry was not recorded: ${P.reason}`),f}finally{if(x){let f=x;try{W(()=>Q(f,{recursive:!0,force:!0}))}catch(y){r(`Warning: temporary reindex workspace was left behind: ${A(y)}`)}}m(),g.release(),p?.()}}function vr(e){if(e.snapshot)try{let t=ue(e.projectRoot),n=t?me(t,e.fingerprint):void 0;if(!n||n.generationId!==e.snapshot.generationId){e.onStatus("Skipped shared generation publication because the worktree changed during indexing");return}let r=Sn({snapshot:e.snapshot,sourceCacheDir:h(e.paths.outputDb),sourceProjectRoot:e.projectRoot,sourceStillValid:()=>{let a=ue(e.projectRoot);return(a?me(a,e.fingerprint):void 0)?.generationId===e.snapshot?.generationId}});Pn(e.snapshot,h(e.paths.outputDb),"built"),e.onStatus(r.kind==="published"?`Published shared generation ${e.snapshot.generationId.slice(0,12)} (${r.achievedDurability})`:`Shared generation ${e.snapshot.generationId.slice(0,12)} was already available (${r.achievedDurability})`)}catch(t){e.onStatus(`Shared generation publication failed; local index remains valid: ${A(t)}`)}}function Wi(e,t){if(!_(e.outputScip)||!_(e.outputDb)||!Wr(e.metaPath,t))return!1;let n=N(e.outputDb,e.metaPath);return n.state!=="invalid"&&n.state!=="drifted"}function qi(e){if(!_(e.outputScip)||!_(e.outputDb)||!V(e.metaPath))return!1;let t=N(e.outputDb,e.metaPath);return t.state!=="invalid"&&t.state!=="drifted"}function A(e){return e instanceof Error?e.message:String(e)}function mt(e,t,n,r,a,i){try{te(Dn({indexPath:n,reuseExisting:a,affectedFiles:i}),{projectRoot:e,dbPath:t,onStatus:r})}catch(o){r(`Runtime-boundary extraction unavailable: ${o instanceof Error?o.message:String(o)}.`)}}function Hi(e){let t=e.outputScip??E(e.projectRoot,"index.scip"),n=e.outputDb??E(e.projectRoot,"index.db");return{outputScip:t,outputDb:n,metaPath:E(h(n),"meta.json")}}function Ji(e){let t=N(e.paths.outputDb,e.paths.metaPath);if(e.opts.skipIfUnchanged===!1||!_(e.paths.outputScip)||!_(e.paths.outputDb)||!Wr(e.paths.metaPath,e.fingerprint)||t.state==="invalid"||t.state==="drifted")return null;te(ee(),{projectRoot:e.opts.projectRoot,dbPath:e.paths.outputDb,onStatus:e.onStatus}),mt(e.opts.projectRoot,e.paths.outputDb,e.paths.outputScip,e.onStatus,!0),N(e.paths.outputDb,e.paths.metaPath).state==="drifted"&&(We(e.paths.outputDb,e.paths.metaPath),e.onStatus("Published refreshed SQLite generation after post-index augmentation"));let n=b()-e.monotonicStart,r=De({trigger:e.opts.trigger,result:"reused",start:e.start,monotonicStart:e.monotonicStart,languages:e.languages,skipped:[]});return qr(e.paths.metaPath,r),e.onStatus(`Index unchanged; reused existing SQLite index in ${(n/1e3).toFixed(1)}s`),{languages:e.languages,indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:n,reused:!0,skipped:[],lastRefresh:r,shards:zi(e.paths,e.opts.projectRoot,e.languages,e.opts)}}function zi(e,t,n,r){let a=Gr(t,n,r);return n.map(i=>({id:i,language:i,reused:!0,fingerprint:ne(a[i]),outputBytes:re(yt(e.outputDb,i)),durationMs:0}))}function Qi(e){let t=$i(E(h(e.outputDb),"reindex-"));return{runDir:t,tempOutputScip:E(t,je(e.outputScip)),tempOutputDb:E(t,je(e.outputDb)),tempMetaPath:E(t,je(e.metaPath))}}function Vi(e){let t=[],n;try{n=Fr(e,{withFileTypes:!0})}catch(a){return{removed:0,errors:[A(a)]}}let r=0;for(let a of n)if(!(!a.name.startsWith("reindex-")||!a.isDirectory()))try{Q(E(e,a.name),{recursive:!0,force:!0}),r+=1}catch(i){t.push(`${a.name}: ${A(i)}`)}return{removed:r,errors:t}}async function Xi(e){let t={...process.env,NODE_OPTIONS:`--max-old-space-size=${e.maxHeapMb}`},n,r=await q("reindex.language-indexers",async()=>(n=await Ki(e,t),n),()=>({languages:e.languages.length,indexed:n?.indexedOutputs.length,reused:n?.reusedLanguages.length,skipped:n?.skippedLanguages.length})),{indexedOutputs:a,skippedLanguages:i,reusedLanguages:o,languageFingerprints:s,shards:d,typescriptProjectShardContext:l,incrementalTypeScript:c}=r;if(o.length>0&&e.onStatus(`Reused ${o.length} cached language shard(s): ${o.join(", ")}`),Yi({run:e,indexedOutputs:a,skippedLanguages:i,reusedLanguages:o})){let g=le("reindex.publish",()=>so(e,a,i,o,s,l),{mode:"metadata-only",languages:a.length,reused:o.length}),m=g.durationMs;return e.onStatus(`All language shards unchanged; reused existing SQLite index in ${(m/1e3).toFixed(1)}s`),{languages:a.map(x=>x.language),indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:m,reused:!0,skipped:i,lastRefresh:g,shards:d,writeTelemetry:e.writeTelemetry}}let p=await q("reindex.publish",()=>oo(e,t,a,i,o,s,l,c),{mode:c?"incremental-or-fallback":"full",languages:a.length,reused:o.length,skipped:i.length}),u=p.durationMs;return e.onStatus(`Done in ${(u/1e3).toFixed(1)}s`),{languages:a.map(g=>g.language),indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:u,reused:!1,skipped:i,lastRefresh:p,shards:d,writeTelemetry:e.writeTelemetry}}function Yi(e){if(e.run.opts.skipIfUnchanged===!1||e.skippedLanguages.length>0||!_(e.run.paths.outputScip)||!_(e.run.paths.outputDb))return!1;let t=N(e.run.paths.outputDb,e.run.paths.metaPath);if(t.state==="invalid"||t.state==="drifted")return!1;let n=new Set(e.reusedLanguages),r=new Set(e.indexedOutputs.map(a=>a.language));return e.run.languages.length>0&&r.size===e.run.languages.length&&e.indexedOutputs.length===e.run.languages.length&&e.run.languages.every(a=>n.has(a)&&r.has(a))}async function Ki(e,t){let n=ro({paths:e.paths,projectRoot:e.projectRoot,languages:e.languages,pnpmWorkspaces:e.opts.pnpmWorkspaces,typescriptProjectMode:e.opts.typescriptProjectMode,typescriptProjects:e.opts.typescriptProjects,clojureConfigPath:e.opts.clojureConfigPath}),r=[],a=new Set;for(let[j,bt]of n)bt.reused&&(r.push({language:j,scipPath:bt.scipPath}),a.add(j));for(let j of a)e.onStatus(`Reusing cached ${j} SCIP shard (language inputs unchanged).`);let i=n.get("typescript"),o=N(e.paths.outputDb,e.paths.metaPath),s=V(e.paths.metaPath),d=o.state==="legacy"||o.state==="current",l=s?.scipCompanion!=="deferred"&&(o.state!=="current"||o.generation.publication?.scipCompanion!=="deferred"),c=i&&!i.reused&&d?mr({projectRoot:e.projectRoot,cacheDir:h(e.paths.outputDb),previousDbPath:e.paths.outputDb,previousIndexPath:e.paths.outputScip,previousShardPath:i.scipPath,candidateShardPath:ae(e.tempPaths.tempOutputScip,"typescript-incremental",0),candidateAffectedScipPath:ae(e.tempPaths.tempOutputScip,"typescript-affected",0),baseShardCurrent:l,previousSnapshot:ht(e.paths.metaPath),currentSnapshot:e.fingerprint,projectMode:e.opts.typescriptProjectMode,onStatus:e.onStatus}):null,p=new Set(c?["typescript"]:[]),u=c?void 0:Zi(e,n),{preparedRuns:g,skippedLanguages:m,languageOutputScipPaths:x}=po({languages:e.languages.filter(j=>!a.has(j)&&!p.has(j)),tempOutputScip:e.tempPaths.tempOutputScip,projectRoot:e.projectRoot,env:t,skipAutoInstall:e.skipAutoInstall,trustProjectTools:e.opts.trustProjectTools===!0,pnpmWorkspaces:e.opts.pnpmWorkspaces,typescriptProjectMode:e.opts.typescriptProjectMode,typescriptProjects:e.opts.typescriptProjects,preDiscoveredTypeScriptProjects:u?.allProjects,clojureConfigPath:e.opts.clojureConfigPath,onStatus:e.onStatus}),w=u?g.filter(j=>j.language!=="typescript"||u.missedProjectIds.has(j.id)):g,f=await Sr(w,e.projectRoot,e.onStatus,e.opts.indexerConcurrency,e.opts.signal),y=[];if(u){to(e.paths.outputDb,f,e.writeTelemetry);let j=x.typescript??e.tempPaths.tempOutputScip;y=no({outputDb:e.paths.outputDb,tempOutputScip:e.tempPaths.tempOutputScip,outputScipPath:j,reusedProjects:u.reusedProjects,writeTelemetry:e.writeTelemetry})}let P=[...f,...y],{indexedOutputs:v}=fo(P,m),R=c?[{language:"typescript",scipPath:c.scipPath}]:[],S=[...r,...R,...v];mo(S,m,e.languages,e.opts.allowPartial,e.onStatus);let B=c?[{id:"typescript",language:"typescript",label:"typescript (incremental documents)",scipPath:c.scipPath,outputScipPath:c.scipPath,durationMs:c.durationMs,command:"watch-service:typescript-index",outputBytes:re(c.scipPath)??void 0}]:[],G=ao(n,[...f,...B],u?{outputDb:e.paths.outputDb,classification:u.classification}:void 0);return{indexedOutputs:S,skippedLanguages:m,reusedLanguages:[...a],languageFingerprints:io(n,e.languages),shards:G,typescriptProjectShardContext:u?{projects:u.allProjects,fingerprints:u.fingerprints}:void 0,incrementalTypeScript:c??void 0}}function Zi(e,t){let n=t.get("typescript");if(!n||n.reused||e.opts.typescriptProjectMode!=="workspace")return;let r=J(e.projectRoot,e.opts.typescriptProjects);if(r.length===0)return;let a=sr(e.projectRoot,r),i=ar(n.fingerprint.files,r),o=ir(r,a),s=or(r,i,o),d=V(e.paths.metaPath),c=eo(d,s,m=>_(ke(e.paths.outputDb,m))),p=[...c.entries()].filter(([,m])=>m.reused).map(([m])=>m),u=new Set(p),g=new Set(r.filter(m=>!u.has(m)).map(m=>`typescript:${m}`));return{allProjects:r,fingerprints:s,classification:c,reusedProjects:p,missedProjectIds:g}}function eo(e,t,n){let r=new Map;for(let a of Object.keys(t)){let i=t[a];if(!e){r.set(a,{reused:!1,reason:"no reindex metadata found",fingerprint:i});continue}let o=e.version===K&&Le(e).typescriptProjectShardReuse?e.typescriptProjectShards?.[a]:void 0;if(!o){r.set(a,{reused:!1,reason:"no cached fingerprint for this project",fingerprint:i});continue}if(!n(a)){r.set(a,{reused:!1,reason:"cached shard file missing on disk",fingerprint:i});continue}if(k(o)!==k(i)){r.set(a,{reused:!1,reason:"project inputs changed since last index",fingerprint:i});continue}r.set(a,{reused:!0,fingerprint:i})}return r}function to(e,t,n){for(let r of t){if(r.skipped||!r.id.startsWith("typescript:"))continue;let a=r.id.slice(11),i=ke(e,a);Te(h(i),{recursive:!0}),$(n,C(r.scipPath,i))}}function no(e){return e.reusedProjects.map((t,n)=>{let r=ke(e.outputDb,t),a=ae(e.tempOutputScip,"typescript-project-cached",n);return $(e.writeTelemetry,C(r,a)),{id:`typescript:${t}`,language:"typescript",label:`typescript (${t})`,scipPath:a,outputScipPath:e.outputScipPath,durationMs:0,command:"cached",outputBytes:re(a)??void 0}})}function ro(e){let t=V(e.paths.metaPath),n=Gr(e.projectRoot,e.languages,e),r=new Map;for(let a of e.languages){let i=yt(e.paths.outputDb,a),o=n[a];if(!t){r.set(a,{reused:!1,reason:"no reindex metadata found",fingerprint:o,scipPath:i});continue}if(t.version!==K){r.set(a,{reused:!1,reason:`metadata version ${String(t.version??"unknown")} predates per-language shard caching`,fingerprint:o,scipPath:i});continue}if(a==="typescript"&&t.scipCompanion==="deferred"){r.set(a,{reused:!1,reason:"whole TypeScript SCIP companion is deferred behind changed-document overlays",fingerprint:o,scipPath:i});continue}if(!Le(t).languageShardReuse||!t.languageFingerprints){r.set(a,{reused:!1,reason:"no per-language fingerprints recorded in metadata",fingerprint:o,scipPath:i});continue}let s=t.languageFingerprints[a];if(!s){r.set(a,{reused:!1,reason:"no cached fingerprint for this language",fingerprint:o,scipPath:i});continue}if(!_(i)){r.set(a,{reused:!1,reason:"cached shard file missing on disk",fingerprint:o,scipPath:i});continue}if(k(s)!==k(o)){r.set(a,{reused:!1,reason:"language inputs changed since last index",fingerprint:o,scipPath:i});continue}r.set(a,{reused:!0,fingerprint:o,scipPath:i})}return r}function ao(e,t,n){let r=[];for(let[a,i]of e)i.reused&&r.push({id:a,language:a,reused:!0,fingerprint:ne(i.fingerprint),outputBytes:re(i.scipPath),durationMs:0});for(let a of t){let i=e.get(a.language),o=n&&a.id.startsWith("typescript:")?a.id.slice(11):null,s=o?n.classification.get(o):void 0;r.push({id:a.id,language:a.language,reused:!1,missReason:s?.reason??i?.reason??a.skipped?.reason,fingerprint:s?ne(s.fingerprint):i?ne(i.fingerprint):"unknown",outputBytes:a.outputBytes??null,durationMs:a.durationMs,command:a.command})}if(n)for(let[a,i]of n.classification)i.reused&&r.push({id:`typescript:${a}`,language:"typescript",reused:!0,fingerprint:ne(i.fingerprint),outputBytes:re(ke(n.outputDb,a)),durationMs:0});return r}function ne(e){return Ci("sha256").update(k(e)).digest("hex").slice(0,16)}function re(e){try{return Bi(e).size}catch{return null}}function io(e,t){let n={};for(let r of t){let a=e.get(r);a&&(n[r]=a.fingerprint)}return n}async function oo(e,t,n,r,a,i,o,s){T(e.opts.signal,"Reindex cancelled by its owner.");let d=!s||s.completeScipUpdated,l=!1;d&&(Ir(e.paths.outputDb,n,e.writeTelemetry),l=Er(n,e.tempPaths.tempOutputScip,e.onStatus));let c=await ho({run:e,env:t,indexedOutputs:n,skippedLanguages:r,reusedLanguages:a,incrementalTypeScript:s,completeScipAvailable:d,completeScipSanitized:l,materializeFullFallback:async()=>{if(T(e.opts.signal,"Reindex cancelled by its owner."),!s||s.completeScipUpdated)return l;e.onStatus("Materializing the deferred whole TypeScript SCIP companion for full conversion..."),hr({cacheDir:h(e.paths.outputDb),generationIdentity:s.nextFragmentGeneration,baseShardPath:s.scipPath,candidateShardPath:s.candidateScipPath});let v=n.map(R=>R.language==="typescript"?{language:R.language,scipPath:s.candidateScipPath}:R);return Ir(e.paths.outputDb,v,e.writeTelemetry),l=Er(v,e.tempPaths.tempOutputScip,e.onStatus),l}});T(e.opts.signal,"Reindex cancelled by its owner."),te(ee(),{projectRoot:e.projectRoot,dbPath:e.tempPaths.tempOutputDb,onStatus:e.onStatus}),mt(e.projectRoot,e.tempPaths.tempOutputDb,e.tempPaths.tempOutputScip,e.onStatus,!1,s?.affectedFiles);let p=et(e.tempPaths.tempOutputDb);if(p.added.length>0&&e.onStatus(`Added SQLite query indexes: ${p.added.join(", ")}`),p.removed.length>0&&e.onStatus(`Removed redundant SQLite indexes: ${p.removed.join(", ")}`),c.mode==="incremental"&&s){let v=null,R=null;try{v=new F({projectRoot:e.projectRoot,dbPath:e.tempPaths.tempOutputDb,indexPath:e.tempPaths.tempOutputScip}),R=new F({projectRoot:e.projectRoot,dbPath:e.paths.outputDb,indexPath:e.paths.outputScip});let S=zt(v,e.fingerprint,s.referenceFragmentsByFile,R);e.onStatus(`Cached exact TypeScript reference fragments for ${S} affected document(s).`)}catch(S){e.onStatus(`Exact TypeScript reference fragment prefill unavailable: ${S instanceof Error?S.message:String(S)}.`)}finally{v?.close(),R?.close()}}let u=ht(e.paths.metaPath),g=c.mode==="incremental"&&s?So(s,c.changedDocumentPaths):Xe({projectRoot:e.projectRoot,previousDbPath:e.paths.outputDb,previousIndexPath:e.paths.outputScip,candidateDbPath:e.tempPaths.tempOutputDb,candidateIndexPath:e.tempPaths.tempOutputScip,previousSnapshot:u,currentSnapshot:e.fingerprint,refreshResult:"rebuilt"}),m=De({trigger:e.opts.trigger,result:"rebuilt",start:e.start,monotonicStart:e.monotonicStart,languages:n.map(v=>v.language),skipped:[...r]}),x=c.mode==="incremental"&&c.scipCompanion==="deferred",w={...i};x&&delete w.typescript;let{metadata:f,pruneProjects:y}=Or({run:e,indexedOutputs:n,skippedLanguages:r,reusedLanguages:a,languageFingerprints:w,typescriptProjectShardContext:o,lastRefresh:m});f.scipCompanion=x?"deferred":"current",Ar(e.paths.outputDb,y),St(e.tempPaths.tempMetaPath,f);let P=fn({tempOutputScip:e.tempPaths.tempOutputScip,tempOutputDb:e.tempPaths.tempOutputDb,tempMetaPath:e.tempPaths.tempMetaPath,outputScip:e.paths.outputScip,outputDb:e.paths.outputDb,metaPath:e.paths.metaPath,preserveOutputScip:c.mode==="incremental"&&c.scipCompanion==="deferred",publication:c.mode==="incremental"?{mode:"incremental",validation:"passed",converterDurationMs:c.converterDurationMs,affectedDocumentCount:s?.affectedFiles.length,changedDocumentCount:c.changedDocumentPaths.length,producerDurationMs:s?.timings.serviceMs,materializationDurationMs:s?.durationMs,patchDurationMs:c.patchDurationMs,scipCompanion:c.scipCompanion,...c.scipCompanion==="deferred"&&s?{typescriptOverlayGeneration:s.nextFragmentGeneration}:{}}:{mode:"full",validation:"passed",converterDurationMs:c.converterDurationMs,scipCompanion:"current",...c.fallbackReason?{fallbackReason:c.fallbackReason}:{}}});return P.achievedDurability==="file-flushed"&&e.onStatus(`Published local generation ${P.currentGeneration.slice(0,12)} (file-flushed; directory sync unsupported)`),gn(h(e.paths.outputDb),c.mode==="incremental"&&c.scipCompanion==="deferred"?[s.nextFragmentGeneration]:[]),dn(h(e.paths.outputDb),s?.completeScipUpdated?[s.nextFragmentGeneration]:[]),Dr(e.paths.outputDb,g,e.onStatus),m}function so(e,t,n,r,a,i){let o=ht(e.paths.metaPath),s=null;try{$(e.writeTelemetry,C(e.paths.outputDb,e.tempPaths.tempOutputDb))}catch(u){s=Cn("reused","oracle-error",`Could not snapshot the prior database: ${u instanceof Error?u.message:String(u)}`)}te(ee(),{projectRoot:e.projectRoot,dbPath:e.paths.outputDb,onStatus:e.onStatus}),mt(e.projectRoot,e.paths.outputDb,e.paths.outputScip,e.onStatus,!0);let d=et(e.paths.outputDb);d.added.length>0&&e.onStatus(`Added SQLite query indexes: ${d.added.join(", ")}`),d.removed.length>0&&e.onStatus(`Removed redundant SQLite indexes: ${d.removed.join(", ")}`),s??=Xe({projectRoot:e.projectRoot,previousDbPath:e.tempPaths.tempOutputDb,previousIndexPath:e.paths.outputScip,candidateDbPath:e.paths.outputDb,candidateIndexPath:e.paths.outputScip,previousSnapshot:o,currentSnapshot:e.fingerprint,refreshResult:"reused"});let l=De({trigger:e.opts.trigger,result:"reused",start:e.start,monotonicStart:e.monotonicStart,languages:t.map(u=>u.language),skipped:[...n]}),{metadata:c,pruneProjects:p}=Or({run:e,indexedOutputs:t,skippedLanguages:n,reusedLanguages:r,languageFingerprints:a,typescriptProjectShardContext:i,lastRefresh:l});return Ar(e.paths.outputDb,p),St(e.paths.metaPath,c),We(e.paths.outputDb,e.paths.metaPath),Dr(e.paths.outputDb,s,e.onStatus),l}function ht(e){return wt(V(e)?.fingerprint)}function Dr(e,t,n){try{Bn(e,t),t.status==="evaluated"?n(`Affected-set shadow: ${(t.evaluation.recall*100).toFixed(1)}% recall; ${t.plan.affectedFiles.length} predicted, ${t.comparison.changedFiles.length} changed.`):n(`Affected-set shadow unavailable: ${t.reason}.`)}catch(r){n(`Affected-set shadow telemetry unavailable: ${r instanceof Error?r.message:String(r)}`)}}function Or(e){let t=co({mode:e.run.opts.typescriptProjectMode,skippedLanguages:e.skippedLanguages,reusedLanguages:e.reusedLanguages,context:e.typescriptProjectShardContext,metaPath:e.run.paths.metaPath});return{metadata:{version:K,status:e.skippedLanguages.length===0?"complete":"partial",updatedAt:new Date().toISOString(),fingerprint:e.run.fingerprint,sqliteLayoutVersion:1,languageFingerprints:e.languageFingerprints,typescriptProjectShards:t.field,requestedLanguages:e.run.languages,indexedLanguages:e.indexedOutputs.map(n=>n.language),skipped:[...e.skippedLanguages],lastRefresh:e.lastRefresh},pruneProjects:t.pruneProjects}}function co(e){if(e.mode!=="workspace")return{field:void 0,pruneProjects:null};if(e.skippedLanguages.some(t=>t.language==="typescript"))return{field:void 0,pruneProjects:null};if(e.reusedLanguages.includes("typescript")){let t=V(e.metaPath),n=t?.version===K?t.typescriptProjectShards:void 0;return{field:n,pruneProjects:n?Object.keys(n):[]}}return e.context?{field:e.context.fingerprints,pruneProjects:e.context.projects}:{field:void 0,pruneProjects:[]}}function Ar(e,t){let n=Ur(e);if(t===null){W(()=>Q(n,{recursive:!0,force:!0}));return}let r;try{r=Fr(n)}catch{return}for(let a of lo(r,t))W(()=>Q(E(n,a),{force:!0}))}function lo(e,t){let n=new Set(t.map(r=>`${at(r)}.scip`));return e.filter(r=>!n.has(r))}function Ir(e,t,n){for(let r of t){let a=yt(e,r.language);Te(h(a),{recursive:!0}),r.scipPath!==a&&$(n,C(r.scipPath,a))}}async function uo(e,t){if(!Ce()){if(Ui()==="win32")throw new Error("The scip CLI was not found. On Windows it ships via the npm sidecar package codebaseiq-windows (installed automatically with codebaseiq). Reinstall codebaseiq with optional dependencies enabled, or follow 'codebaseiq setup' guidance for the exact sidecar package version, or set CODEBASEIQ_SCIP_BIN to a local scip.exe path.");if(e)throw new Error(`The scip CLI is required but not found on PATH.
232
- To install the reviewed version, run: codebaseiq reindex --install-missing
233
- Or install manually from: https://github.com/sourcegraph/scip/releases`);if(t("scip CLI not found on PATH. Attempting auto-install..."),!Ft(t))throw new Error(`The scip CLI is required but could not be installed.
234
- Install manually from: https://github.com/sourcegraph/scip/releases`)}}function po(e){let t=[],n=[],r=e.languages.map((i,o)=>({language:i,scipPath:e.languages.length>1?ae(e.tempOutputScip,i,o):e.tempOutputScip})),a=Object.fromEntries(r.map(({language:i,scipPath:o})=>[i,o]));for(let{language:i,scipPath:o}of r){let s=go({...e,language:i,scipPath:o});for(let d of s)"skipped"in d?Lr(n,d.skipped):t.push(d.prepared)}return{preparedRuns:t,skippedLanguages:n,languageOutputScipPaths:a}}function go(e){if(e.language!=="typescript"||e.typescriptProjectMode!=="workspace")return[gt({...e,id:e.language,label:e.language,outputScipPath:e.scipPath})];let t=e.preDiscoveredTypeScriptProjects??J(e.projectRoot,e.typescriptProjects);return t.length===0?[gt({...e,id:e.language,label:e.language,outputScipPath:e.scipPath})]:(e.onStatus(`Indexing TypeScript workspace as ${t.length} project shard(s).`),t.map((n,r)=>gt({...e,id:`typescript:${n}`,label:`typescript (${n})`,scipPath:ae(e.tempOutputScip,"typescript-project",r),outputScipPath:e.scipPath,pnpmWorkspaces:!1,projectPath:n})))}function gt(e){let t=Ye(e.language),n=pe(t),r=Bt(t,e.projectRoot),a=e.trustProjectTools&&r?Gt(t,e.projectRoot):null,i=Z(t);if(!a&&!i&&r){let c=`${n} is available only as repository-local code at ${r}. Review that exact tool and rerun with --trust-project-tools.`;return e.onStatus(`Skipping ${e.language}: ${c}`),{skipped:{language:e.language,reason:c}}}if(!a&&!i&&!$t(t)){if(e.skipAutoInstall){let c=`${n} not found on PATH. To install the reviewed version, run: codebaseiq reindex --install-missing${t.installUrl?` (manual source: ${t.installUrl})`:""}`;return e.onStatus(`Skipping ${e.language}: ${c}`),{skipped:{language:e.language,reason:c}}}if(e.onStatus(`${n} not found. Attempting auto-install...`),!xr(t,e.onStatus)){let c=`${n} could not be auto-installed. ${t.installUrl?`Install manually from ${t.installUrl}`:`Install ${n} and put it on PATH.`}`;return e.onStatus(`Skipping ${e.language}: ${c}`),{skipped:{language:e.language,reason:c}}}}let o=a?.canonicalPath??Z(t);if(!o){let c=`${n} was not found after installation checks.`;return e.onStatus(`Skipping ${e.language}: ${c}`),{skipped:{language:e.language,reason:c}}}let{binary:s,args:d}=t.indexArgs({projectRoot:e.projectRoot,outputPath:e.scipPath,pnpmWorkspaces:e.pnpmWorkspaces,indexerBinary:o,projectPath:e.projectPath,configPath:e.language==="clojure"?e.clojureConfigPath:void 0}),l=zn({language:e.language,projectPath:e.projectPath,pnpmWorkspaces:e.pnpmWorkspaces});if(a&&!a.executable){let c=`${a.relativePath} is not executable; refusing project-local indexer.`;return e.onStatus(`Skipping ${e.language}: ${c}`),{skipped:{language:e.language,reason:c}}}return a&&e.onStatus(`Trusted project-local ${e.language} indexer ${a.relativePath} (${a.sha256.slice(0,12)}\u2026, ${a.canonicalPath}).`),{prepared:{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,config:t,resolvedBinary:o,binary:s,args:d,env:Wt(t,e.env,o),...l===void 0?{}:{temporaryRootConfigContent:l},...a?{trustedProjectTool:a}:{}}}}function fo(e,t){let n=new Map;for(let a of e)if(a.skipped)Lr(t,a.skipped);else{let i=`${a.language}\0${a.outputScipPath}`,o=n.get(i)??{language:a.language,outputScipPath:a.outputScipPath,scipPaths:[]};o.scipPaths.push(a.scipPath),n.set(i,o)}let r=[];for(let a of n.values())if(a.scipPaths.length>1)tn(a.scipPaths,a.outputScipPath),r.push({language:a.language,scipPath:a.outputScipPath});else{let i=a.scipPaths[0];i!==a.outputScipPath&&kr(i,a.outputScipPath),r.push({language:a.language,scipPath:a.outputScipPath})}return{indexedOutputs:r}}function Lr(e,t){let n=e.find(r=>r.language===t.language);if(!n){e.push(t);return}n.reason.includes(t.reason)||(n.reason=`${n.reason}; ${t.reason}`)}function mo(e,t,n,r,a){if(e.length===0){let i=t.map(o=>` - ${o.language}: ${o.reason}`).join(`
235
- `);throw new Error(`No language indexers ran successfully. Install at least one indexer for the languages in this project.
236
- `+i)}if(t.length!==0&&(a(`Indexed ${e.length} language output(s); skipped or incomplete: ${t.map(i=>i.language).join(", ")}.`),!r))throw new Error(`Failed to index all required languages; preserving the previous index. Pass --allow-partial to intentionally write an incomplete index.
237
- `+t.map(i=>` - ${i.language}: ${i.reason}`).join(`
238
- `))}function Er(e,t,n){if(e.length>1){n(`Merging ${e.length} language indexes...`);let r=performance.now(),a=nn(e.map(i=>i.scipPath),t);return Nr(a,n),n(`Merged and sanitized SCIP indexes in ${(performance.now()-r).toFixed(0)}ms.`),!0}else e[0].scipPath!==t&&kr(e[0].scipPath,t);return!1}async function ho(e){let t;if(yo(e)){let a=E(e.run.tempPaths.runDir,"typescript-affected.db");try{Mr(e.incrementalTypeScript.affectedScipPath,e.run.onStatus),e.run.onStatus(`Converting ${e.incrementalTypeScript.affectedFiles.length} affected TypeScript document(s) to SQLite...`);let i=performance.now();await wr(e.incrementalTypeScript.affectedScipPath,a,e.env,e.run.onStatus,!1,e.run.opts.signal),e.run.onStatus(`Converted affected SCIP documents in ${(performance.now()-i).toFixed(0)}ms.`);let o=Zn({previousDbPath:e.run.paths.outputDb,miniDbPath:a,candidateDbPath:e.run.tempPaths.tempOutputDb,affectedFiles:e.incrementalTypeScript.affectedFiles,writeTelemetry:e.run.writeTelemetry});return e.run.onStatus(`Patched ${o.affectedDocumentCount} SQLite document(s) in ${(o.durationMs/1e3).toFixed(3)}s.`),{mode:"incremental",changedDocumentPaths:o.changedDocumentPaths,patchDurationMs:o.durationMs,converterDurationMs:performance.now()-i,scipCompanion:e.incrementalTypeScript.completeScipUpdated?"current":"deferred"}}catch(i){T(e.run.opts.signal,"Reindex cancelled by its owner."),t=i instanceof Error?i.message:String(i),W(()=>Q(a,{force:!0})),W(()=>Q(e.run.tempPaths.tempOutputDb,{force:!0})),e.run.onStatus(`Incremental SQLite publication unavailable: ${t}. Falling back to complete conversion.`)}}let n=e.completeScipSanitized;e.completeScipAvailable||(n=await e.materializeFullFallback());let r=performance.now();return await wr(e.run.tempPaths.tempOutputScip,e.run.tempPaths.tempOutputDb,e.env,e.run.onStatus,n,e.run.opts.signal),{mode:"full",converterDurationMs:performance.now()-r,...t?{fallbackReason:t}:{}}}function yo(e){if(!e.incrementalTypeScript||e.skippedLanguages.length>0||!_(e.run.paths.outputDb)||!_(e.run.paths.outputScip))return!1;let t=new Set(e.reusedLanguages);return e.indexedOutputs.length===e.run.languages.length&&e.run.languages.every(n=>n==="typescript"||t.has(n))}function So(e,t){let n=b(),r=[...t].sort(),a=new Set(r),i={addedFiles:[],modifiedFiles:r,deletedFiles:[],changedFiles:r,unchangedFiles:e.affectedFiles.filter(o=>!a.has(o)).sort()};return{version:1,status:"evaluated",refreshResult:"rebuilt",recordedAt:new Date().toISOString(),durationMs:b()-n,manifest:e.manifest,plan:e.plan,comparison:i,evaluation:Ve(e.plan,i,e.projectFileCount)}}async function wr(e,t,n,r,a=!1,i){if(T(i,"Reindex cancelled by its owner."),r("Converting to SQLite..."),!_(e))throw new Error(`SCIP index not found at ${e} after indexing`);try{a||Mr(e,r);let o=Ce();if(!o)throw new Error("scip CLI is not available");let s=await se({command:o,args:["expt-convert","--output",t,e],label:"SCIP SQLite conversion",env:n,maxStdoutBytes:50*1024*1024,maxStderrBytes:50*1024*1024,timeoutMs:3e5,signal:i});if(s.status!==0)throw new Error(`scip expt-convert exited with ${s.status}${s.stderr.trim()?`: ${s.stderr.trim()}`:""}`)}catch(o){T(i,"Reindex cancelled by its owner.");let s=o instanceof Error?o.message:String(o);throw new Error(`Failed to convert SCIP index to SQLite: ${s}`,{cause:o})}}function Mr(e,t){let n=en(e);Nr(n,t)}function Nr(e,t){e.removedDefinitionOccurrences!==0&&t(`Sanitized ${e.removedDefinitionOccurrences} invalid definition occurrences across ${e.touchedDocuments} documents before SQLite conversion.`)}function ae(e,t,n){let r=Gi(e)||".scip",a=je(e,r);return E(h(e),`${a}.${n+1}.${t}${r}`)}async function bo(e,t){for(let n=0;n<2;n++){let r=Po(e,t);if(r)return r;let a=xo(e);if(a&&Br(t.trigger,a)){t.onStatus(`Manual reindex preempting watcher refresh started at ${a.startedAt}.`);let i;try{i=await vo(a)}catch(s){throw new Error(`Could not verify the watcher's in-progress reindex owner (pid ${a.pid}); refusing to steal an active lock: ${A(s)}`,{cause:s})}if(!i)throw new Error(`Could not confirm the watcher's in-progress reindex (pid ${a.pid}) terminated for ${h(e)}; refusing to steal an active lock.`);let o=$e(e,{parseLegacy:Fe});if(!At(e,o,{parseLegacy:Fe}))throw new Error(`Reindex lock ownership changed before preemption completed for ${h(e)}.`);continue}throw new Error(`Another codebaseiq reindex is already running for ${h(e)}.`)}throw new Error(`Could not acquire codebaseiq reindex lock for ${h(e)}.`)}function Po(e,t){let n=U(process.pid),r=Ot(e,{kind:"reindex",processIdentity:n,detail:{projectRoot:t.projectRoot,...process.env.SCIP_REINDEX_PROCESS_GROUP_LEADER==="1"?{processGroupLeader:!0}:{},...t.trigger?{trigger:t.trigger}:{}},parseLegacy:Fe});if(r.kind==="acquired"&&r.reclaimed){let a=Cr(r.reclaimed,e);a&&Br(t.trigger,a)?t.onStatus(`Manual reindex preempting watcher refresh started at ${a.startedAt}; its prior owner was already stale.`):t.onStatus(`Recovered an abandoned or incomplete reindex lock for ${h(e)}.`)}return r.kind==="acquired"?()=>{r.lock.release()}:null}function xo(e){return Cr($e(e,{parseLegacy:Fe}),e)}var Fe=e=>{let t=$r(e,"");return t?{pid:t.pid,...t.processIdentity?{processIdentity:t.processIdentity}:{}}:null};function Cr(e,t){if(e.state==="valid"&&e.record?.kind==="reindex"){let n=e.record.detail??{};return{version:2,pid:e.record.pid,...e.record.processIdentity?{processIdentity:e.record.processIdentity}:{},...n.processGroupLeader===!0?{processGroupLeader:!0}:{},projectRoot:typeof n.projectRoot=="string"?n.projectRoot:h(t),startedAt:e.record.startedAt,trigger:n.trigger}}return $r(e.parsed,t)}function $r(e,t){try{let n=e;return typeof n.pid!="number"||!Number.isInteger(n.pid)||n.pid<=0?null:{version:n.version===2?2:1,pid:n.pid,...n.processIdentity===void 0?{}:(()=>{let r=Rt(n.processIdentity);return r?.pid===n.pid?{processIdentity:r}:{}})(),...n.processGroupLeader===!0?{processGroupLeader:!0}:{},projectRoot:typeof n.projectRoot=="string"?n.projectRoot:h(t),startedAt:typeof n.startedAt=="string"?n.startedAt:"unknown",trigger:n.trigger}}catch{return null}}function Br(e,t){return e?.kind==="manual-cli"&&Ro(t?.trigger)}function Ro(e){return e?.kind==="watch-source"||e?.kind==="watch-git-head"||e?.kind==="watch-git-index"||e?.kind==="watch-git-state"}async function vo(e){return!H(e.pid)||(ft(e),_r(e,"SIGTERM"),await jr(e,2e3))?!0:(ft(e),_r(e,"SIGKILL"),jr(e,1e3))}function _r(e,t){if(e.processGroupLeader)try{process.kill(-e.pid,t);return}catch{if(!H(e.pid))return;ft(e)}try{process.kill(e.pid,t)}catch{}}async function jr(e,t){let n=b()+t;for(;b()<n;){if(Tr(e))return!0;await Io(50)}return Tr(e)}function ft(e){if(!e.processIdentity)throw new Error(`Refusing to signal reindex pid ${e.pid}: its ownership record has no process identity.`);let t=U(e.pid);if(!t)throw new Error(`Refusing to signal reindex pid ${e.pid}: its process identity is unavailable.`);if(!Y(e.processIdentity,t))throw new Error(`Refusing to signal reindex pid ${e.pid}: its process identity does not match the ownership record.`)}function Tr(e){if(!H(e.pid))return!0;if(!e.processIdentity)return!1;let t=U(e.pid);return t!==null&&!Y(e.processIdentity,t)}function Io(e){return new Promise(t=>setTimeout(t,e))}function Gr(e,t,n){return Object.fromEntries(t.map(r=>{let a=r==="typescript"?Mt(n.typescriptProjects):[],i=r==="clojure"?Eo(n.clojureConfigPath):void 0,o=[...Ye(r).markerFiles,...a,...i?[i]:[]],s=r==="typescript"?{typescriptProjectMode:n.typescriptProjectMode??"single",typescriptProjects:a}:{typescriptProjectMode:"single",typescriptProjects:[]};return[r,{version:2,languages:[r],pnpmWorkspaces:r==="typescript"&&wo(n),...s,clojureConfigPath:i,files:Nt(e,{language:r,markerFiles:o})}]}))}function Eo(e){return e?.trim()||void 0}function wo(e){return e.typescriptProjectMode!=="workspace"&&e.pnpmWorkspaces===!0}function yt(e,t){return E(h(e),"language-indexes",`${t}.scip`)}function Ur(e){return E(h(e),"language-indexes","typescript-projects")}function ke(e,t){return E(Ur(e),`${at(t)}.scip`)}function V(e){try{return Ae(de(oe(e,"reindex metadata")))}catch{return null}}function Wr(e,t){try{let n=de(oe(e,"reindex metadata"));if(n.kind!=="legacy"&&n.kind!=="supported")return!1;let r=n.metadata;return n.capabilities.publishableGeneration&&_t(r)&&k(r.fingerprint)===k(t)&&k([...r.indexedLanguages??[]].sort())===k(t.languages)}catch{return!1}}function St(e,t){Ht(e,t,{spacing:2,trailingNewline:!0})}function qr(e,t){try{let n=Ae(de(oe(e,"reindex metadata")));if(!n)return;St(e,{...n,lastRefresh:t})}catch{}}function De(e){return{trigger:e.trigger??{kind:"unknown"},result:e.result,startedAt:new Date(e.start).toISOString(),completedAt:new Date().toISOString(),durationMs:b()-e.monotonicStart,indexedLanguages:e.languages?[...e.languages]:void 0,skipped:e.skipped?[...e.skipped]:void 0,error:e.error}}function k(e){return JSON.stringify(e)}export{Vo as a,Xo as b,Ye as c,xr as d,dd as e};
239
- //# sourceMappingURL=chunk-TFZB6XTM.js.map
@@ -1,5 +0,0 @@
1
- import{a as R,b as _,c as Te,d as Fe,e as $,f as Le,k as ie,l as oe,m as Oe,o as Ge}from"./chunk-ZKX2FRS6.js";import{a as W}from"./chunk-NNOKTMZT.js";import{a as De}from"./chunk-ADTBPVUZ.js";import{f as ke,i as se,r as qe,t as je}from"./chunk-BMYOV5GP.js";import{d as Ne,e as Ce}from"./chunk-CWONGW6P.js";import{d as ae}from"./chunk-3LCDIREB.js";import{E as Ae,H as S,L as Ee,P as Be,Q as F,R as re,i as Ie,k as Me,o as Re,q as d,s as we,t as Pe,v as G,x as ve}from"./chunk-NNJ2KZZG.js";function Mt(t,e){return t.reason instanceof Error?t.reason:new Error(e)}function ir(t,e){if(t?.aborted)throw Mt(t,e)}import{join as Rt}from"path";var wt=t=>{if(!t||typeof t!="object"||Array.isArray(t))return null;let e=t.pid;return typeof e=="number"&&Number.isSafeInteger(e)&&e>0?{pid:e}:null};function dr(t,e={}){return z(Rt(t,"gc.lock"),e)}function z(t,e={}){let n=e.waitMs??0,r=e.pollMs??10,i=e.now??$,o=i()+n;do{let s=Pt(t);if(s)return vt(s);let a=o-i();if(a<=0)return null;At(Math.min(r,a))}while(i()<=o);return null}function Pt(t){let e=Le(t,{kind:"generic",parseLegacy:wt});return e.kind==="acquired"?e.lock:null}function vt(t){return{release:()=>{t.release()}}}function At(t){let e=new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));Atomics.wait(e,0,0,t)}function _e(t,e,n={}){ie(t,$e(e,n),{durability:"visibility",runtime:n.runtime})}function pr(t,e,n={}){return ie(t,$e(e,n),{durability:"durable",runtime:n.runtime})}function $e(t,e){let n=JSON.stringify(t,null,e.spacing);return e.trailingNewline?`${n}
2
- `:n}import{execFileSync as ze}from"child_process";import{createHash as Et}from"crypto";import{existsSync as J,statSync as Tt}from"fs";import{createRequire as Ft}from"module";import{platform as Lt}from"os";import{dirname as We,join as L}from"path";var Bt=Ft(import.meta.url),Rr={language:"rust",indexerBinary:"rust-analyzer",installUrl:"https://github.com/rust-lang/rust-analyzer"};function ce(t){return[t.indexerBinary,...t.binaryAliases??[]]}function kt(t){let e=ce(t);return e.length===1?e[0]:e.join(" or ")}function de(t){for(let e of ce(t)){let n=Ge(e);if(n)return n}return qt(t)}function wr(t){return de(t)!==null||Dt(t)}function Dt(t){return Je(t)!==null}function qt(t){let e=Je(t);if(!e)return null;let r=JSON.parse(S(e,"indexer package manifest")).bin;if(!r)return null;if(typeof r=="string")return L(We(e),r);for(let i of ce(t)){let o=r[i];if(o)return L(We(e),o)}return null}function Je(t){if(!t.bundledNpmPackage)return null;try{return Bt.resolve(`${t.bundledNpmPackage}/package.json`)}catch{return null}}function jt(t,e){for(let n of t.projectLocalBinaries??[]){let r=L(e,n);if(J(r))return r}return null}function Nt(t,e){for(let n of t.projectLocalBinaries??[]){let r=L(e,n);if(J(r))return He(e,n,r)}return null}function Pr(t,e){let n=Ct(t,e);if(!n||n.canonicalPath!==e.canonicalPath||n.sha256!==e.sha256||n.size!==e.size||n.mtimeMs!==e.mtimeMs||n.device!==e.device||n.inode!==e.inode||n.executable!==e.executable)throw new Error(`refusing changed project-local indexer ${e.relativePath}; review the current file and rerun with --trust-project-tools`)}function Ct(t,e){try{return He(t,e.relativePath,e.configuredPath)}catch{return null}}function He(t,e,n){let r={maxBytes:268435456,inputKind:"project-local indexer"},i=Ne(t,e,r),o=Ce(t,e,r),s=Tt(i.absolutePath);return{configuredPath:n,canonicalPath:i.absolutePath,relativePath:e,sha256:Et("sha256").update(o).digest("hex"),size:i.size,mtimeMs:i.mtimeMs,device:i.device,inode:i.inode,executable:(s.mode&73)!==0}}function Ot(t,e,n={}){return(n.trustProjectTools?Nt(t,e)?.canonicalPath:null)??de(t)}function vr(t,e=process.env,n=t.indexerBinary){if(t.indexerBinary!=="scip-dotnet"||le(n,e))return e;let r=Ue(n,e);return r?{...e,DOTNET_ROOT:r}:e}function Ar(t,e,n={}){let r=kt(t),i=e?Ot(t,e,n):de(t);if(!i)return{language:t.language,binaryLabel:r,installed:!1,runnable:!1,resolvedBinary:null,installUrl:t.installUrl,...e&&jt(t,e)?{note:"project-local indexer available only with --trust-project-tools"}:{}};if(t.indexerBinary!=="scip-dotnet")return{language:t.language,binaryLabel:r,installed:!0,runnable:!0,resolvedBinary:i};let o=Gt(i);return{language:t.language,binaryLabel:r,installed:!0,runnable:o.runnable,resolvedBinary:i,installUrl:t.installUrl,note:o.note}}function Gt(t){if(le(t,process.env))return{runnable:!0};let e=Ue(t,process.env);if(e)return{runnable:!0,note:`using .NET 9 runtime from ${e}`};let n=Ve(process.env);return{runnable:!1,note:n.length>0?`.NET 9 runtime still unavailable after checking ${n.join(", ")}`:"binary is present, but scip-dotnet still needs a .NET 9 runtime"}}function Ue(t,e){for(let n of Ve(e))if(le(t,{...e,DOTNET_ROOT:n}))return n;return null}function Ve(t){let e=[],n=t.DOTNET_ROOT;if(n&&J(n)&&e.push(n),Lt()==="darwin"&&Oe("brew"))try{let r=ze("brew",["--prefix","dotnet@9"],{stdio:"pipe",windowsHide:!0,env:t,timeout:1e4,killSignal:"SIGKILL"}).toString().trim(),i=L(r,"libexec");J(i)&&!e.includes(i)&&e.push(i)}catch{}return e}function le(t,e){try{return ze(t,["--version"],{stdio:"pipe",windowsHide:!0,env:e,timeout:1e4,killSignal:"SIGKILL"}),!0}catch{return!1}}var _t=[".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs"];function H(t){let e=t.toLowerCase();return _t.some(n=>e.endsWith(n))}function V(t){let e=U(t.projectFiles),n=new Set(e),r=new Map(t.snapshot.files.map(c=>[c.path,c])),i=t.snapshot.files.filter(c=>{let m=Ie(c.path,["typescript"]);return m==="config"||m==="ambient"}).map(c=>c.path),o=U([...e,...i]),s=o.find(c=>!r.has(c)),a=new Set(t.snapshot.files.map(c=>c.path)).size!==t.snapshot.files.length,l=!s&&o.some(c=>Qe(r.get(c))),p=se(JSON.stringify({pnpmWorkspaces:t.snapshot.pnpmWorkspaces,typescriptProjectMode:t.snapshot.typescriptProjectMode,typescriptProjects:U(t.snapshot.typescriptProjects),membership:e})),u=new Map;return{identityFor(c,m){if(!n.has(c))return w("target-outside-project");if(a)return w("duplicate-input-path");if(s)return w("missing-input-fingerprint");if(l)return w("unreadable-input");let g=[],f,I;if(t.graph===null)g.push("dependency-graph-unavailable"),I="whole-project",f=o;else{let O=Wt(c,t.graph,u);if(O.find(ne=>!r.has(ne)))return w("missing-input-fingerprint");if(f=U([...O,...i]),f.some(ne=>Qe(r.get(ne))))return w("unreadable-input");I="dependency-closure"}let C=f.map(O=>zt(r.get(O)));return{version:1,key:se(JSON.stringify({version:1,engineIdentity:t.engineIdentity,schemaVersion:m,projectIdentity:p,inputs:C})),mode:I,inputFiles:f,reasons:g}}}}function $t(t,e){let n=new Set,r=[t];for(let i=0;i<r.length;i+=1){let o=r[i];if(!(o===void 0||n.has(o))){n.add(o);for(let s of[...e.get(o)??[]].sort())n.has(s)||r.push(s)}}return[...n].sort()}function Wt(t,e,n){let r=n.get(t);if(r)return r;let i=$t(t,e);return n.set(t,i),i}function zt(t){return{path:t.path,size:t.size,hash:t.hash}}function Qe(t){return t.size<0||t.hash==="unreadable"}function w(t){return{version:1,key:null,mode:"unkeyed",inputFiles:[],reasons:[t]}}function U(t){return[...new Set(t)].sort()}import{createRequire as Jt}from"module";var Ke=Jt(import.meta.url),B,Q;function Ht(){if(B!==void 0)return B;try{B=Ke("ts-morph")}catch{B=null}return B}function K(){if(Q)return Q;let t=Ht();if(!t)return"ts-morph:unavailable";let e="unknown";try{e=Ke("ts-morph/package.json").version??"unknown"}catch{}return Q=`ts-morph:${e}:typescript:${t.ts.version}`,Q}function Dr(t,e){return e.map(n=>({tsconfigPath:n,project:new t.Project({tsConfigFilePath:n,skipFileDependencyResolution:!0})}))}function qr(t,e,n){return{language:"typescript",availability:()=>({available:!1,reason:t,tsconfigPath:e,tsconfigPaths:n}),importUsage:()=>[],referencesFor:()=>[],calleesFor:()=>[],signatureFor:()=>null}}var Ut=ke("typescript-semantic-identity-context",{clearGroups:["whole-project"]});function ue(t,e,n){let r=Ut.get(t,()=>Vt(t));if(!r)return null;let i=`${n}\0${e}`,o=r.identities.get(i);if(o)return o;let s=r.builder.identityFor(e,n);return r.identities.set(i,s),s}function k(t){return De(t,{includeIgnored:!1}).filter(H).sort()}function Vt(t){try{if(!t.generation.metadataRaw)return null;let e=G(t.generation.metadataRaw);if(e.kind!=="legacy"&&e.kind!=="supported"||!e.capabilities.usableForEvidenceCache)return null;let n=Me(e.metadata.fingerprint);return n?{builder:V({projectFiles:k(t),snapshot:n,graph:W(t),engineIdentity:K()}),identities:new Map}:null}catch{return null}}function X(t,e){let n=new Map(t.map(i=>[i.symbol,i])),r=new Map(t.map(i=>[i.symbolId,[]]));for(let i of e.values())for(let o of i){let s=n.get(o.targetSymbol);s&&r.get(s.symbolId).push(o.location)}for(let[i,o]of r)r.set(i,Qt(o));return r}function Ze(t,e,n){let r=Ye(t,e),i=Ye(t,n),o=[...r].filter(c=>!i.has(c)).sort(),s=[...i].filter(c=>!r.has(c)).sort(),a=Xe(t,e),l=Xe(t,n),p=[...a].filter(c=>!l.has(c)).sort(),u=[...l].filter(c=>!a.has(c)).sort();return{passed:o.length===0&&s.length===0,expectedCount:r.size,actualCount:i.size,missing:o,extra:s,callerFiles:{passed:p.length===0&&u.length===0,expectedCount:a.size,actualCount:l.size,missing:p,extra:u}}}function Xe(t,e){let n=new Set;for(let r of t)for(let i of e.get(r.symbolId)??[])i.file!==r.relativePath&&n.add(`${r.symbol}\0${i.file}`);return n}function Hr(t,e,n){let r=new Set(n),i=new Map(n.map(o=>[o,[]]));for(let o of t)for(let s of e.get(o.symbolId)??[])r.has(s.file)&&i.get(s.file).push({targetSymbol:o.symbol,location:s});for(let[o,s]of i)i.set(o,Kt(s));return i}function Ye(t,e){let n=new Set;for(let r of t)for(let i of e.get(r.symbolId)??[])n.add(`${r.symbol}\0${i.file}\0${i.line}\0${i.column}`);return n}function Qt(t){let e=new Map;for(let n of t)e.set(`${n.file}\0${n.line}\0${n.column}`,n);return[...e.values()].sort(et)}function Kt(t){let e=new Map;for(let n of t){let{location:r}=n;e.set(`${n.targetSymbol}\0${r.file}\0${r.line}\0${r.column}`,n)}return[...e.values()].sort((n,r)=>n.targetSymbol.localeCompare(r.targetSymbol)||et(n.location,r.location))}function et(t,e){return t.file.localeCompare(e.file)||t.line-e.line||t.column-e.column}var pe="typescript-reference-fragment-v3-incomplete-scan",Y=qe({kind:"typescript-reference-fragments",invalidation:je("typescript-reference-fragments"),serialize:t=>JSON.stringify(t),deserialize:Yt});function ni(t,e,n,r=t){let i=k(t),o=V({projectFiles:i,snapshot:e,graph:W(t),engineIdentity:K()}),s=[...n].map(([a,l])=>({relativePath:a,contentHash:o.identityFor(a,pe).key,value:[...l]}));if(s.some(a=>a.contentHash===null))throw new Error("TypeScript reference fragment identity is unavailable for an affected document.");return Y.writeBatch(r,s.map(a=>({...a,contentHash:a.contentHash}))),s.length}function ri(t,e,n,r){let i=e.filter(s=>H(s.relativePath));if(i.length===0)return D("no TypeScript definitions");let o=D("shadow did not run");return ae("typescript.reference-fragments.shadow",()=>{try{let s=r(i[0].relativePath);if(!s.availability().available||!s.referenceFragmentsForFiles)return o=D("TypeScript reference fragment provider is unavailable"),o;let a=k(t),l=new Set(a),p=s.referenceFragmentsForFiles(a),u=a.filter(f=>!p.has(f));if(u.length>0)return o=D(`TypeScript reference lookup was incomplete for ${u.length} file(s)`),o;let c=X(i,p),m=Ze(i,Xt(n,l),c);if(!m.passed)return o={state:"failing",files:a.length,keyedFiles:0,writtenFiles:0,...m},o;let g=[];for(let f of a){let I=ue(t,f,pe);I?.key&&g.push({relativePath:f,contentHash:I.key,value:p.get(f)??[]})}return Y.writeBatch(t,g),o={state:"passing",files:a.length,keyedFiles:g.length,writtenFiles:g.length,...m},o}catch(s){return o=D(s instanceof Error?s.message:String(s)),o}},()=>({...o}))}function Xt(t,e){return new Map([...t].map(([n,r])=>[n,r.filter(i=>e.has(i.file))]))}function ii(t,e,n){if(e.length===0)return{references:new Map,files:0,cacheHits:0,cacheMisses:0,computedFiles:0};let r="fallback",i=0,o=0,s=0,a=0;return ae("typescript.reference-fragments.materialize",()=>{try{let l=k(t);i=l.length;let p=new Map,u=new Map,c=[];for(let f of l){let I=ue(t,f,pe);if(!I?.key)return null;p.set(f,I.key);let C=Y.read(t,f,I.key);C===null?(s+=1,c.push(f)):(o+=1,u.set(f,C))}if(s===0)return r="hit",{references:X(e,u),files:i,cacheHits:o,cacheMisses:s,computedFiles:a};let m=n(e[0].relativePath);if(!m.availability().available||!m.referenceFragmentsForFiles)return null;let g=m.referenceFragmentsForFiles(c);if(c.some(f=>!g.has(f)))return null;a=g.size,Y.writeBatch(t,c.map(f=>({relativePath:f,contentHash:p.get(f),value:g.get(f)??[]})));for(let[f,I]of g)u.set(f,I);return r="computed",{references:X(e,u),files:i,cacheHits:o,cacheMisses:s,computedFiles:a}}catch{return null}},()=>({state:r,files:i,cacheHits:o,cacheMisses:s,computedFiles:a}))}function D(t){return{state:"unavailable",files:0,keyedFiles:0,writtenFiles:0,expectedCount:0,actualCount:0,missing:[],extra:[],reason:t}}function Yt(t){try{let e=JSON.parse(t);return!Array.isArray(e)||!e.every(Zt)?null:e}catch{return null}}function Zt(t){if(!t||typeof t!="object")return!1;let e=t,n=e.location;return typeof e.targetSymbol=="string"&&!!n&&typeof n.file=="string"&&typeof n.line=="number"&&typeof n.column=="number"}import{createHash as en,randomUUID as tn}from"crypto";import{existsSync as P,mkdirSync as nn,readdirSync as rn,rmSync as nt,statSync as rt}from"fs";import{basename as on,dirname as Z,join as x}from"path";var sn=1,an=1,cn=".codebaseiq-generations",dn="manifest.json",it="readers",ln="gc.lock",un=128,q=new Map,ot={pid:process.pid,now:()=>new Date,randomToken:()=>tn(),isProcessAlive:Fe,readProcessIdentity:Te,resolveImmutableGeneration:ct};function v(t){return x(Z(t),cn)}function st(t){return x(v(t),ln)}function gi(t,e=ot){let n=z(st(t.dbPath),{waitMs:5e3});if(!n)throw new Error("SQLite generation retention is busy; retry opening the index.");let r;try{let o=ge(t.dbPath);if(!o||!at(t.dbPath,o.currentGeneration))return{generation:gn(t),release(){}};let s=e.randomToken();if(!/^[A-Za-z0-9._-]+$/.test(s))throw new Error("SQLite generation reader token is unsafe.");let a=x(v(t.dbPath),it);nn(a,{recursive:!0});let l=x(a,`${e.pid}-${s}.json`),p=e.readProcessIdentity(e.pid);_e(l,{version:1,token:s,generationIdentity:o.currentGeneration,pid:e.pid,...p?{processIdentity:p}:{},acquiredAt:e.now().toISOString()},{spacing:2,trailingNewline:!0});let u=!1;r={identity:o.currentGeneration,required:o.artifactSet==="immutable-v1",release(){u||(u=!0,nt(l,{force:!0}))}}}finally{n.release()}let i;try{i=e.resolveImmutableGeneration(t,r.identity)}catch(o){throw r.release(),o}if(i?.source==="immutable"&&i.identity===r.identity)return{generation:i,release:r.release};if(r.release(),r.required)throw new Error(`Published SQLite generation ${r.identity} is missing or invalid.`);return pn(t,r.identity)}function pn(t,e){let n=z(st(t.dbPath),{waitMs:5e3});if(!n)throw new Error("SQLite generation retention is busy; retry opening the index.");try{let r=ge(t.dbPath);if(r?.currentGeneration!==e)throw new Error("SQLite index publication changed while opening a legacy generation.");if(P(x(Z(t.dbPath),"index.lock")))throw new Error("Legacy SQLite publication is in progress; retry after the reindex lock is released.");return{generation:dt(t,r.currentGeneration),release(){}}}finally{n.release()}}function bi(t,e,n=ot,r={}){let i=x(v(t),it);if(!P(i))return{protectedGenerations:new Set,activeLeases:0,staleLeasesRemoved:0,malformedLeases:0};let o=new Set,s=0,a=0,l=0;for(let p of rn(i,{withFileTypes:!0})){if(!p.isFile()||!p.name.endsWith(".json"))continue;let u=x(i,p.name),c;try{c=fn(JSON.parse(S(u,"SQLite generation reader lease")))}catch{c=null}if(!c){l+=1;for(let m of e)o.add(m);continue}if(!mn(c,n)){r.removeStale!==!1&&(nt(u,{force:!0}),a+=1);continue}s+=1,o.add(c.generationIdentity)}return{protectedGenerations:o,activeLeases:s,staleLeasesRemoved:a,malformedLeases:l}}function fn(t){if(!t||typeof t!="object"||Array.isArray(t))return null;let e=t,n=e.processIdentity===void 0?null:R(e.processIdentity);return e.version!==1||typeof e.token!="string"||e.token.trim()===""||typeof e.generationIdentity!="string"||!/^[a-f0-9]{64}$/.test(e.generationIdentity)||typeof e.pid!="number"||!Number.isSafeInteger(e.pid)||e.pid<=0||typeof e.acquiredAt!="string"||!Number.isFinite(Date.parse(e.acquiredAt))||e.processIdentity!==void 0&&(!n||n.pid!==e.pid)?null:{version:1,token:e.token,generationIdentity:e.generationIdentity,pid:e.pid,...n?{processIdentity:n}:{},acquiredAt:e.acquiredAt}}function mn(t,e){if(!e.isProcessAlive(t.pid))return!1;if(!t.processIdentity)return!0;let n=e.readProcessIdentity(t.pid);return n===null||_(t.processIdentity,n)}function ge(t){try{let e=JSON.parse(S(x(v(t),"state.json"),"SQLite generation state"));return xn(e)?e:null}catch{return null}}function at(t,e){return yn(v(t),e)}function yn(t,e){try{let n=JSON.parse(S(x(t,e,dn),"SQLite generation manifest"));return Sn(n,e)?n:null}catch{return null}}function gn(t){let e=ge(t.dbPath);if(e){let n=ct(t,e.currentGeneration);if(n)return n;if(e.artifactSet==="immutable-v1")throw new Error(`Published SQLite generation ${e.currentGeneration} is missing or invalid.`)}if(P(x(Z(t.dbPath),"index.lock")))throw new Error("Legacy SQLite publication is in progress; retry after the reindex lock is released.");return dt(t,e?.currentGeneration)}function bn(t){return ve(G(t))??t}function ct(t,e){try{let n=x(v(t.dbPath),e),r=at(t.dbPath,e);if(!r)return null;let i=fe(n,r.database),o=r.index?fe(n,r.index):void 0,s=r.metadata?fe(n,r.metadata):void 0;return!me(i,r.database)||r.index&&(!o||!me(o,r.index))||r.metadata&&(!s||!me(s,r.metadata))?null:{identity:e,databasePath:i,...o?{indexPath:o}:{},...s?{metadataPath:s,metadataRaw:S(s,"reindex metadata")}:{},source:"immutable"}}catch{return null}}function dt(t,e){let n=lt(t.dbPath),r=x(Z(t.dbPath),"meta.json"),i=P(r)?S(r,"reindex metadata"):void 0,o=P(t.indexPath)?t.indexPath:void 0;return{identity:e??hn(t.dbPath,i),databasePath:t.dbPath,...o?{indexPath:o}:{},...i===void 0?{}:{metadataPath:r,metadataRaw:i},source:"legacy",databaseFileIdentity:n}}function hn(t,e){let n=en("sha256").update("sqlite-generation-legacy-v1\0");return e!==void 0&&n.update(bn(e)),n.update(`\0${lt(t)}`),n.digest("hex")}function lt(t){let e=rt(t);return`${e.dev}:${e.ino}:${e.size}:${e.mtimeMs}`}function fe(t,e){if(on(e.file)!==e.file||e.file==="."||e.file==="..")throw new Error("SQLite generation manifest contains an unsafe artifact path");return x(t,e.file)}function me(t,e){if(!P(t))return!1;let n=tt(t);if(!n||n.size!==e.size)return!1;let r=`${t}\0${e.sha256}\0${n.identity}`;if(q.has(r))return!0;let i=Ee(t,{inputKind:"immutable SQLite generation artifact",maxBytes:e.size}),o=tt(t);if(!o||o.identity!==n.identity||i!==e.sha256)return!1;for(q.set(r,!0);q.size>un;){let s=q.keys().next().value;if(s===void 0)break;q.delete(s)}return!0}function tt(t){let e=rt(t,{bigint:!0});return e.isFile()?{identity:`${e.dev}:${e.ino}:${e.size}:${e.mtimeNs}:${e.ctimeNs}`,size:Number(e.size)}:null}function Sn(t,e){return t.version===an&&t.identity===e&&ye(t.database)&&(t.index===void 0||ye(t.index))&&(t.metadata===void 0||ye(t.metadata))}function ye(t){if(!t||typeof t!="object")return!1;let e=t;return typeof e.file=="string"&&!!e.file&&Number.isSafeInteger(e.size)&&(e.size??-1)>=0&&typeof e.sha256=="string"&&/^[a-f0-9]{64}$/.test(e.sha256)}function xn(t){return t.version===sn&&typeof t.currentGeneration=="string"&&!!t.currentGeneration&&typeof t.publishedAt=="string"&&Number.isFinite(Date.parse(t.publishedAt))&&(t.artifactSet===void 0||t.artifactSet==="immutable-v1")&&In(t.stableMirrors)&&Mn(t.previousGeneration)&&Rn(t.publication)}function In(t){if(t===void 0)return!0;if(!t||typeof t!="object")return!1;let e=t;return typeof e.databaseFileIdentity=="string"&&!!e.databaseFileIdentity&&(e.indexFileIdentity===void 0||typeof e.indexFileIdentity=="string"&&!!e.indexFileIdentity)}function Mn(t){if(t===void 0)return!0;if(!t||typeof t!="object")return!1;let e=t;return typeof e.generationIdentity=="string"&&!!e.generationIdentity&&typeof e.databasePath=="string"&&!!e.databasePath&&(e.metadataPath===void 0||typeof e.metadataPath=="string"&&!!e.metadataPath)}function Rn(t){if(t===void 0)return!0;if(!t||typeof t!="object")return!1;let e=t,n=[e.converterDurationMs,e.affectedDocumentCount,e.changedDocumentCount,e.producerDurationMs,e.materializationDurationMs,e.patchDurationMs].filter(r=>r!==void 0);return(e.mode==="incremental"||e.mode==="full")&&e.validation==="passed"&&e.converterDurationMs!==void 0&&n.every(r=>typeof r=="number"&&Number.isFinite(r)&&r>=0)&&(e.scipCompanion===void 0||e.scipCompanion==="current"||e.scipCompanion==="deferred")&&(e.typescriptOverlayGeneration===void 0||typeof e.typescriptOverlayGeneration=="string"&&!!e.typescriptOverlayGeneration)&&(e.scipCompanion!=="deferred"||!!e.typescriptOverlayGeneration)&&(e.fallbackReason===void 0||typeof e.fallbackReason=="string")}import{createHash as wn,randomUUID as yt}from"crypto";import{existsSync as T,lstatSync as N,readdirSync as E,renameSync as gt,rmSync as M}from"fs";import{basename as be,dirname as Pn,join as y}from"path";function ee(t){return Array.isArray(t)?`[${t.map(ee).join(",")}]`:t&&typeof t=="object"?`{${Object.entries(t).sort(([e],[n])=>e.localeCompare(n)).map(([e,n])=>`${JSON.stringify(e)}:${ee(n)}`).join(",")}}`:JSON.stringify(t)}var vn=1,An=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}),A=class extends Error{constructor(n,r,i,o){let s=n==="item-too-large"?`request is ${o} bytes; per-item limit is ${i.maxItemBytes}`:n==="item-capacity"?`mailbox has ${r.totalItems} retained items; limit is ${i.maxItems}`:n==="byte-capacity"?`mailbox retains ${r.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=n;this.status=r;this.limits=i;this.attemptedBytes=o;this.name="MailboxBackpressureError"}code;status;limits;attemptedBytes},En=".owner.json",Tn={isProcessAlive:()=>!0,readProcessIdentity:()=>null};function Ti(t){return{rootDir:t,pendingDir:y(t,"pending"),inflightDir:y(t,"inflight"),responseDir:y(t,"responses"),deadLetterDir:y(t,"dead-letter"),legacyRequestDir:y(t,"requests")}}function Fn(t={}){let e={...An,...t};for(let[n,r]of Object.entries(e))if(!Number.isFinite(r)||r<=0||!Number.isInteger(r))throw new Error(`Mailbox limit ${n} must be a positive integer.`);return e}function bt(t){let e=[t.pendingDir,t.inflightDir,t.responseDir,t.deadLetterDir,t.legacyRequestDir].map(n=>Be(n));return re(...e)}function Fi(t,e){return wn("sha256").update(ee({namespace:t,payload:e})).digest("hex")}function Ln(t){if(!/^[a-f0-9]{64}$/.test(t))throw new Error("Mailbox operation keys must be lowercase SHA-256 identities.");return`op-${t}`}function Li(t,e,n={}){let r=Fn(n.limits),i=n.nowMs??Date.now(),o=bt(t);return On(e),kn(t,r,n.admissionLockTimeoutMs??2e3,n.monotonicNow??$,()=>{Bn(t,i,r);let s=y(t.pendingDir,`${e.id}.json`),a=y(t.responseDir,`${e.id}.json`),l=ut(t,e.id);if(l){let m=pt(l,e.operationKey,e.id);return{disposition:"duplicate",requestId:e.id,responsePath:a,authoritativeDeadlineAtMs:m.deadlineAtMs??e.deadlineAtMs}}let p=`${JSON.stringify(e)}
3
- `,u=Buffer.byteLength(p),c=ht(t);if(u>r.maxItemBytes)throw new A("item-too-large",c,r,u);if(c.totalItems+1>r.maxItems)throw new A("item-capacity",c,r,u);if(c.totalBytes+u>r.maxBytes)throw new A("byte-capacity",c,r,u);n.onBeforePublish?.();try{let m=oe(s,p,{durability:"durable"}),g=re(o,m.directorySync);return{disposition:"accepted",requestId:e.id,responsePath:a,authoritativeDeadlineAtMs:e.deadlineAtMs,achievedDurability:g==="synced"?"directory-durable":"file-flushed",directorySync:g}}catch(m){if(m.code!=="EEXIST")throw m;let g=ut(t,e.id);if(!g)throw m;let f=pt(g,e.operationKey,e.id);return{disposition:"duplicate",requestId:e.id,responsePath:a,authoritativeDeadlineAtMs:f.deadlineAtMs??e.deadlineAtMs}}})}function Bn(t,e,n,r=Tn){let i={reclaimed:0,completedClaimsRemoved:0,responsesRemoved:0,deadLettersRemoved:0,temporaryFilesRemoved:0},o=n.cleanupBatch;for(let s of Se(t.inflightDir)){if(o<=0)break;let a=y(t.responseDir,`${s.requestId}.json`);if(T(a)){M(s.path,{force:!0}),i.completedClaimsRemoved++,o--;continue}if(s.claimExpiresAtMs>e||Nn(t,s.ownerId,r)!=="dead")continue;let l=y(t.pendingDir,s.originalFile);try{gt(s.path,l),i.reclaimed++}catch(p){if(p.code!=="EEXIST")throw p;M(s.path,{force:!0})}F(Pn(s.path)),F(t.pendingDir),o--}o=ft(t.responseDir,o,(s,a)=>a+n.responseRetentionMs,e,()=>{i.responsesRemoved++}),o=ft(t.deadLetterDir,o,(s,a)=>a+n.deadLetterRetentionMs,e,()=>{i.deadLettersRemoved++});for(let s of[t.pendingDir,t.inflightDir,t.responseDir,t.deadLetterDir,t.legacyRequestDir]){if(o<=0)break;for(let a of St(s)){if(o<=0)break;be(a).includes(".tmp-")&&(N(a).mtimeMs+n.temporaryRetentionMs>e||(M(a,{force:!0}),i.temporaryFilesRemoved++,o--))}}return Gn(t.inflightDir),i}function ht(t){bt(t);let e=[...j(t.pendingDir).map(l=>({path:l,pending:!0})),...j(t.legacyRequestDir).map(l=>({path:l,pending:!0}))],n=Se(t.inflightDir).map(l=>({path:l.path,pending:!1})),r=j(t.responseDir).map(l=>({path:l,pending:!1})),i=j(t.deadLetterDir).map(l=>({path:l,pending:!1})),o=[...e,...n,...r,...i],s=0,a;for(let l of e){let p=xe(l.path);if(!p){s++;continue}let u=p.enqueuedAtMs??N(l.path).mtimeMs;a=a===void 0?u:Math.min(a,u)}return{pending:e.length,inflight:n.length,responses:r.length,deadLetters:i.length,invalid:s,totalItems:o.length,totalBytes:o.reduce((l,p)=>l+_n(p.path),0),...a===void 0?{}:{oldestPendingAt:new Date(a).toISOString()}}}function kn(t,e,n,r,i){let o=y(t.rootDir,".admission.lock"),s=`${process.pid}-${yt()}`,a=r()+Math.max(0,n);for(;!Dn(t.rootDir,o,s);){if(qn(o),r()>=a)throw new A("admission-busy",ht(t),e,0);Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,5)}try{return i()}finally{try{he(o).ownerToken===s&&(M(o,{recursive:!0,force:!0}),F(t.rootDir))}catch{}}}function Dn(t,e,n){let r=`${JSON.stringify({ownerToken:n,pid:process.pid,acquiredAtMs:Date.now()})}
4
- `;try{return oe(e,r,{durability:"durable"}),!0}catch(i){if(i.code==="EEXIST")return!1;try{he(e).ownerToken===n&&(M(e,{force:!0}),F(t))}catch{}throw i}}function qn(t){let e=null;try{let r=he(t);typeof r.ownerToken=="string"&&Number.isSafeInteger(r.pid)&&Number(r.pid)>0&&(e=Number(r.pid))}catch{}if(e===null||jn(e))return;let n=`${t}.stale-${yt()}`;try{gt(t,n)}catch(r){let i=r.code;if(i==="ENOENT"||i==="EEXIST")return;throw r}M(n,{recursive:!0,force:!0})}function he(t){try{return JSON.parse(S(t,"mailbox lock record"))}catch(e){if(e.code!=="EISDIR"&&!(e instanceof Ae&&e.reason==="not-regular"))throw e;return JSON.parse(S(y(t,"owner.json"),"mailbox lock owner record"))}}function jn(t){try{return process.kill(t,0),!0}catch(e){let n=e.code;return n==="EPERM"||n!=="ESRCH"}}function Nn(t,e,n){let r=Cn(y(t.inflightDir,xt(e),En));if(!r)return"unknown";if(!n.isProcessAlive(r.pid))return"dead";if(!r.processIdentity)return"live";let i=n.readProcessIdentity(r.pid);return i?_(r.processIdentity,i)?"live":"dead":"unknown"}function Cn(t){try{let e=JSON.parse(S(t,"mailbox owner record"));if(e.version!==1||typeof e.ownerId!="string"||!e.ownerId||typeof e.pid!="number"||!Number.isSafeInteger(e.pid)||e.pid<=0)return null;let n=e.processIdentity===void 0?null:R(e.processIdentity);return e.processIdentity!==void 0&&(!n||n.pid!==e.pid)?null:{version:1,ownerId:e.ownerId,pid:e.pid,...n?{processIdentity:n}:{}}}catch{return null}}function ut(t,e){for(let n of[y(t.pendingDir,`${e}.json`),y(t.legacyRequestDir,`${e}.json`),y(t.responseDir,`${e}.json`)])if(T(n))return n;for(let n of Se(t.inflightDir))if(n.requestId===e)return n.path;return null}function pt(t,e,n){let r=xe(t);if(!r||r.operationKey!==e)throw new Error(`Mailbox operation ${n} conflicts with an existing retained record.`);return r}function On(t){if(t.mailboxVersion!==vn||t.id!==Ln(t.operationKey)||!t.clientId.trim()||!Number.isFinite(t.enqueuedAtMs)||!Number.isFinite(t.deadlineAtMs)||t.deadlineAtMs<t.enqueuedAtMs)throw new Error("Mailbox request has an invalid lifecycle identity.")}function Se(t){if(!T(t))return[];let e=[];for(let n of E(t,{withFileTypes:!0})){if(!n.isDirectory())continue;let r=mt(n.name);if(r===null)continue;let i=y(t,n.name);for(let o of E(i,{withFileTypes:!0})){if(!o.isFile()||!o.name.endsWith(".claim"))continue;let s=/^(.*)\.(\d+)\.claim$/.exec(o.name);if(!s)continue;let a=mt(s[1]),l=Number(s[2]);if(a===null||be(a)!==a||!a.endsWith(".json")||!Number.isSafeInteger(l))continue;let p=y(i,o.name),u=xe(p)??{id:be(a,".json")},c=N(p);e.push({requestId:u.id,ownerId:r,path:p,originalFile:a,claimedAtMs:c.mtimeMs,claimExpiresAtMs:l,byteLength:c.size,...u.operationKey?{operationKey:u.operationKey}:{},...u.clientId?{clientId:u.clientId}:{},...u.enqueuedAtMs===void 0?{}:{enqueuedAtMs:u.enqueuedAtMs},...u.deadlineAtMs===void 0?{}:{deadlineAtMs:u.deadlineAtMs},legacy:u.operationKey===void 0})}}return e.sort((n,r)=>n.claimedAtMs-r.claimedAtMs||n.path.localeCompare(r.path))}function xe(t){try{let e=JSON.parse(S(t,"mailbox record"));return typeof e.id!="string"||!e.id?null:{id:e.id,...typeof e.operationKey=="string"?{operationKey:e.operationKey}:{},...typeof e.clientId=="string"?{clientId:e.clientId}:{},...typeof e.enqueuedAtMs=="number"?{enqueuedAtMs:e.enqueuedAtMs}:{},...typeof e.deadlineAtMs=="number"?{deadlineAtMs:e.deadlineAtMs}:{}}}catch{return null}}function ft(t,e,n,r,i){for(let o of j(t)){if(e<=0)break;let s=N(o);n(o,s.mtimeMs)>r||(M(o,{force:!0}),i(),e--)}return e}function j(t){return T(t)?E(t,{withFileTypes:!0}).filter(e=>e.isFile()).map(e=>y(t,e.name)).sort():[]}function St(t){if(!T(t))return[];let e=[];for(let n of E(t,{withFileTypes:!0})){let r=y(t,n.name);n.isFile()?e.push(r):n.isDirectory()&&e.push(...St(r))}return e.sort()}function Gn(t){if(T(t))for(let e of E(t,{withFileTypes:!0})){if(!e.isDirectory())continue;let n=y(t,e.name);E(n).some(r=>r.endsWith(".claim"))||M(n,{recursive:!0,force:!0})}}function _n(t){try{return N(t).size}catch{return 0}}function xt(t){return Buffer.from(t,"utf8").toString("base64url")}function mt(t){try{let e=Buffer.from(t,"base64url").toString("utf8");return xt(e)===t?e:null}catch{return null}}import{join as te}from"path";var $n="watch.lock",Wn="watch-state.json",zn="watch-activity.json",Jn="watch-refresh-requests";function Ci(t){return{lockPath:te(t,$n),statePath:te(t,Wn),activityPath:te(t,zn),refreshRequestsPath:te(t,Jn)}}function Oi(t){try{return Hn(JSON.parse(S(t,"watch service state")))}catch{return null}}function Hn(t){if(!t||typeof t!="object")return null;let e=t;if(e.version!==1||typeof e.protocolVersion!="number"||typeof e.pid!="number"||!Number.isInteger(e.pid)||e.pid<=0||typeof e.projectRoot!="string"||e.worktreeId!==void 0&&(typeof e.worktreeId!="string"||e.worktreeId.length===0)||typeof e.cliVersion!="string"||!b(e.startedAt)||!b(e.heartbeatAt)||!b(e.lastActivityAt)||!Un(e.watcher)||e.idleDeadlineAt!==void 0&&!b(e.idleDeadlineAt))return null;if(e.processIdentity!==void 0){let n=R(e.processIdentity);if(!n||n.pid!==e.pid)return null;e.processIdentity=n}return e.indexGeneration!==void 0&&!/^[a-f0-9]{64}$/.test(e.indexGeneration)||e.lastError!==void 0&&!Vn(e.lastError)||e.lastRefresh!==void 0&&!Qn(e.lastRefresh)||e.reindexActivity!==void 0&&!Kn(e.reindexActivity)||e.refreshRequests!==void 0&&!Yn(e.refreshRequests)||e.typescriptSemantic!==void 0&&!Zn(e.typescriptSemantic)||e.typescriptIndex!==void 0&&!er(e.typescriptIndex)||e.queryLane!==void 0&&!tr(e.queryLane)?null:e}function b(t){return Re(t)}function Un(t){if(!t||typeof t!="object"||!("state"in t))return!1;let e=t;switch(e.state){case"idle":return!0;case"waiting":return h(e.changedFiles)&&h(e.reindexAt);case"indexing":return h(e.startedAt);case"cooldown":return h(e.until)&&typeof e.dirty=="boolean";case"budget-paused":return h(e.until)&&typeof e.dirty=="boolean"&&typeof e.reason=="string"&&d(e.rebuilt)&&d(e.estimatedWriteBytes);case"draining":return h(e.startedAt)&&typeof e.reason=="string";default:return!1}}function Vn(t){if(!t||typeof t!="object")return!1;let e=t;return b(e.at)&&typeof e.message=="string"}function Qn(t){if(!t||typeof t!="object")return!1;let e=t;return typeof e.trigger?.kind=="string"&&typeof e.result=="string"&&b(e.startedAt)&&b(e.completedAt)&&h(e.durationMs)}function Kn(t){if(!t||typeof t!="object")return!1;let e=t;return e.confidence!==void 0&&e.confidence!=="complete"&&e.confidence!=="partial"&&e.confidence!=="unavailable"||e.recordsRead!==void 0&&!d(e.recordsRead)||e.invalidRecords!==void 0&&!d(e.invalidRecords)||e.skippedRecords!==void 0&&!d(e.skippedRecords)||e.readErrors!==void 0&&!d(e.readErrors)||e.ignoredPartialTailBytes!==void 0&&!d(e.ignoredPartialTailBytes)||!b(e.windowStartedAt)||!b(e.windowEndedAt)||!d(e.runs)||!d(e.rebuilt)||!d(e.reused)||!d(e.failed)||!d(e.suppressed)||!h(e.estimatedLogicalOutputBytes)||e.estimatedWriteBytes!==void 0&&!d(e.estimatedWriteBytes)||e.reflinkedBytes!==void 0&&!d(e.reflinkedBytes)||e.fallbackCopiedBytes!==void 0&&!d(e.fallbackCopiedBytes)||e.oldestRebuildAt!==void 0&&!b(e.oldestRebuildAt)||e.oldestWriteAt!==void 0&&!b(e.oldestWriteAt)||e.languageAttribution!==void 0&&e.languageAttribution!=="complete"&&e.languageAttribution!=="partial"&&e.languageAttribution!=="unavailable"||e.attributedRuns!==void 0&&!d(e.attributedRuns)||e.unattributedRuns!==void 0&&!d(e.unattributedRuns)||e.invalidLanguageDetails!==void 0&&!d(e.invalidLanguageDetails)||e.estimatedLogicalOutputBytes<0||!e.byTrigger||typeof e.byTrigger!="object"||Array.isArray(e.byTrigger)||e.byLanguage!==void 0&&!Xn(e.byLanguage)?!1:Object.values(e.byTrigger).every(n=>n===void 0||d(n))}function Xn(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;for(let[e,n]of Object.entries(t)){if(!Pe.includes(e)||!n||typeof n!="object")return!1;let r=n;if(!d(r.runs)||!d(r.rebuilt)||!d(r.reused)||!d(r.producedOutputBytes)||!we(r.durationMs)||r.rebuilt+r.reused!==r.runs)return!1}return!0}function Yn(t){if(!t||typeof t!="object")return!1;let e=t;return d(e.pending)&&d(e.claimed)&&d(e.completed)&&d(e.expired)&&d(e.invalid)&&(e.oldestPendingAt===void 0||b(e.oldestPendingAt))}function Zn(t){if(!t||typeof t!="object")return!1;let e=t;return typeof e.protocolVersion=="number"&&(e.state==="idle"||e.state==="ready"||e.state==="unavailable"||e.state==="error")&&h(e.requests)&&h(e.sessionsCreated)&&h(e.sessionsReused)&&h(e.sessionsRefreshed)&&h(e.sessionsReplaced)&&h(e.projectsCreated)&&(e.lastRequestAt===void 0||b(e.lastRequestAt))&&(e.lastError===void 0||typeof e.lastError=="string")&&(e.busyUntil===void 0||b(e.busyUntil))&&(e.mailbox===void 0||It(e.mailbox))}function er(t){if(!t||typeof t!="object")return!1;let e=t;return typeof e.protocolVersion=="number"&&(e.state==="idle"||e.state==="ready"||e.state==="unavailable"||e.state==="error")&&d(e.requests)&&d(e.sessionsCreated)&&d(e.sessionsReplaced)&&d(e.initializations)&&d(e.programUpdates)&&d(e.documentsEmitted)&&d(e.documentsRemoved)&&(e.lastRequestAt===void 0||b(e.lastRequestAt))&&(e.lastDurationMs===void 0||h(e.lastDurationMs)&&e.lastDurationMs>=0)&&(e.lastError===void 0||typeof e.lastError=="string")&&(e.busyUntil===void 0||b(e.busyUntil))&&(e.mailbox===void 0||It(e.mailbox))}function tr(t){if(!t||typeof t!="object")return!1;let e=t;return typeof e.protocolVersion=="number"&&typeof e.socketPath=="string"&&e.socketPath.length>0&&d(e.requests)&&(e.lastRequestAt===void 0||b(e.lastRequestAt))&&(e.lastError===void 0||typeof e.lastError=="string")}function It(t){if(!t||typeof t!="object")return!1;let e=t;return d(e.pending)&&d(e.inflight)&&d(e.responses)&&d(e.deadLetters)&&d(e.invalid)&&d(e.totalItems)&&h(e.totalBytes)&&e.totalBytes>=0&&e.totalItems===e.pending+e.inflight+e.responses+e.deadLetters&&(e.oldestPendingAt===void 0||b(e.oldestPendingAt))}function h(t){return typeof t=="number"&&Number.isFinite(t)}export{Mt as a,ir as b,dr as c,z as d,_e as e,pr as f,sn as g,an as h,cn as i,dn as j,v as k,st as l,gi as m,bi as n,ge as o,at as p,yn as q,gn as r,bn as s,lt as t,Rr as u,kt as v,de as w,wr as x,jt as y,Nt as z,Pr as A,vr as B,Ar as C,ee as D,vn as E,Ti as F,Fi as G,Ln as H,Li as I,Ci as J,Oi as K,_t as L,H as M,Ht as N,Dr as O,qr as P,Hr as Q,V as R,ue as S,ni as T,ri as U,ii as V};
5
- //# sourceMappingURL=chunk-UCD3H3UZ.js.map
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
- import{e as s,f as v,lb as E,qb as V,rb as I}from"./chunk-ECQBG7PW.js";import{c as y}from"./chunk-XZEE23VG.js";import{E as h,N as S,d as w}from"./chunk-G6XFR4ZL.js";import{l as x}from"./chunk-2X7V4HS4.js";var ce={defaultRole:"repository-observation"};function pe(e,n=[]){return{defaultRole:e,...n.length>0?{rules:n}:{}}}function k(e,n){for(let t of e.rules??[]){if(t.when.kind==="option-present"){let r=n.options[t.when.name];if(r!==void 0&&r!==!1)return t.role;continue}if((t.when.kind==="argument"?n.args[t.when.index]:n.options[t.when.name])===t.when.equals)return t.role}return e.defaultRole}function fe(e){return[...new Set([e.defaultRole,...(e.rules??[]).map(n=>n.role)])]}function A(e){return e==="repository-observation"||e==="repository-preview"||e==="composite"}import{AsyncLocalStorage as z}from"async_hooks";var U=1,j=1;var F={policyId:"codebaseiq:unresolved-repository-policy",policyVersion:j,permission:"not-established",reasons:["No repository action policy was supplied for this claim."]};function N(e){return{schemaVersion:U,origin:e.contract.origin,coverage:$(e.coverage),producerValidation:e.contract.producerValidation,stateAuthority:w(e.receipt,e.receipt),repositoryPolicy:e.repositoryPolicy??F,...e.contract.families?{families:e.contract.families}:{}}}function $(e){return e?e.complete===!0?{state:"complete",returned:e.returned,totalKnown:!0,total:e.total??e.returned,omitted:0}:e.totalKnown?{state:"partial",returned:e.returned,totalKnown:!0,...e.total===void 0?{}:{total:e.total},...e.omitted===void 0?{}:{omitted:e.omitted}}:{state:"unknown",returned:e.returned,totalKnown:!1}:{state:"unknown",returned:0,totalKnown:!1}}var W="codebaseiq-result";var G=1,Y=1,_=1,L=1;function M(e){let n=e.resultSchemaVersion??Y;if(!X(n))throw new Error("CLI result schema version must be a positive safe integer.");let{producerVersion:t,...o}=e;return{kind:W,schemaVersion:G,producer:{name:"codebaseiq",version:t},resultSchemaVersion:n,...o}}function J(e,n){return JSON.stringify(e,null,n?0:2)}function X(e){return Number.isSafeInteger(e)&&Number(e)>0}var P=Symbol("option-value-source"),T=new Map,D=new Map,B=new Map,H=new z;function Ie(e,n){return H.run(e,n)}function ke(e){T=new Map(e)}function Ae(e){D=new Map(e)}function Ne(e){B=new Map(e)}function m(e){return(...n)=>{let{args:t,opts:o}=le(n);S(r=>{v(r.generation.identity),e({db:r,args:t,opts:o})})}}function R(e,n){return m(t=>{let o=I(t.db,e,d(t.opts,"full"),{quiet:d(t.opts,"json")});n({...t,budget:o})})}function _e(e){return m(n=>c(n,e,{kind:"list"}))}function Le(e){return m(n=>c(n,e,{kind:"table",headers:e.headers,dashWidths:e.dashWidths}))}function Me(e){return m(n=>c(n,e,{kind:"grouped",key:e.key}))}function Z(e){return m(n=>b(n,e))}function Je(e){return Z({commandName:e.commandName,query:e.query,emptyMessage:e.emptyMessage,heuristicLabel:e.heuristicLabel,before:e.before,render:(n,t)=>s.sectionedReport(e.sections(n,t)),toJson:e.toJson,coverage:e.coverage,agentResult:e.agentResult,after:e.after})}function ee(e,n){return R(e,t=>b(t,{...n,commandName:n.commandName??e}))}function Pe(e,n){return ee(e,{commandName:n.commandName??e,query:n.query,emptyMessage:n.emptyMessage,heuristicLabel:n.heuristicLabel,before:n.before,render:(t,o)=>s.sectionedReport(n.sections(t,o)),toJson:n.toJson,coverage:n.coverage,agentResult:n.agentResult,after:n.after})}function Te(e,n){return R(e,t=>c(t,{...n,commandName:e},{kind:"list"}))}function De(e,n){return R(e,t=>c(t,{...n,commandName:e},{kind:"grouped",key:n.key}))}function Be(e,n){return String(e[n])}function He(e,n){let t=e[n];return typeof t=="string"?[t]:Array.isArray(t)&&t.every(o=>typeof o=="string")?t:[]}function Qe(e,n){let t=e[n];return typeof t=="string"?t:void 0}function qe(e,n){let t=e[n];return typeof t=="string"?t:void 0}function Q(e,n){let t=e[n];return typeof t=="number"?t:void 0}function d(e,n){return!!e[n]}function Ke(e,n){let t=e[n];return Array.isArray(t)&&t.every(o=>typeof o=="string")?t:[]}function Ue(e,n,t){return Q(e,n)??t}function je(e,n,t){let o=Q(e,n),r=o!==void 0&&ne(e,n)!=="default";if(d(e,"full")){if(r)throw new Error("--full cannot be combined with --limit. Use --full for all findings, or --limit N for a capped report.");return Number.MAX_SAFE_INTEGER}return o??t}function ne(e,n){return e[P]?.(n)}function c(e,n,t){b(e,{commandName:n.commandName,query:n.query,emptyMessage:(o,r)=>o.length===0&&n.emptyMessage?n.emptyMessage(r):void 0,heuristicLabel:n.heuristicLabel,render:(o,r)=>{t.kind==="list"?s.list(o,i=>n.format(i,r)):t.kind==="table"?s.table(t.headers,o.map(i=>n.format(i,r)),t.dashWidths):s.groupedByFile(o,i=>n.format(i,r),t.key?i=>t.key(i,r):void 0)},toJson:n.toJson,coverage:n.coverage,agentResult:n.agentResult,before:n.before,after:n.after})}function b(e,n){let t=n.query(e);if(d(e.opts,"json")){if(!n.commandName)throw new Error("JSON output requires a command name so its result contract can be identified.");oe(n.commandName,e.args,e.opts,n.toJson?n.toJson(t,e):t,{analysisBudget:te(e),coverage:n.coverage?.(t,e),agentResult:n.agentResult?.(t,e),resultSchemaVersion:n.resultSchemaVersion});return}let o=n.emptyMessage?.(t,e);if(o){s.empty(o);return}n.heuristicLabel&&V(n.heuristicLabel),n.before?.(t,e),n.render(t,e),n.after?.(t,e)}function te(e){return e.budget?.analysisBudget}function oe(e,n,t,o,r={}){let i=T.get(e),a=D.get(e),u=B.get(e),p=a?k(a.operation,{args:n,options:t}):void 0,f=H.getStore();if(f!==void 0&&p!==void 0&&f!==p)throw new Error(`Command ${e} changed operation role during execution: selected ${f}, rendered ${p}.`);let g=f??p,O=de(o),C=r.coverage??ae(a,o,r.analysisBudget),l=C&&O&&!C.resolution?{...C,resolution:O}:C;if(l&&ie(l),d(t,"resultOnly")){let K=Object.hasOwn(r,"resultOnly")?r.resultOnly:o;y(JSON.stringify(K,null,d(t,"compact")?0:2));return}let q=M({producerVersion:x,command:e,...g?{operationRole:g}:{},...i?{evidence:i}:{},...r.analysisBudget?{analysisBudget:r.analysisBudget}:{},args:ue(n),options:t,result:o,...l?{coverage:l}:{},...r.agentResult!==void 0?{agentResult:r.agentResult}:{},...re(g,i,r.analysisBudget,l,u,r.observationReceipt),...r.resultSchemaVersion===void 0?{}:{resultSchemaVersion:r.resultSchemaVersion}});y(J(q,d(t,"compact")))}function re(e,n,t,o,r,i){if(!e||!A(e))return{};let a=h(),u=i??(a?E({projectRoot:a.config.projectRoot,db:a,...r?{observedSourceKinds:r.observedSources}:{}}):void 0);return u?{evidenceContext:{schemaVersion:_,operationRole:e,receipt:u,analysisManifest:{schemaVersion:L,...n?{evidence:n}:{},...t?{analysisBudget:t}:{},...o?{coverage:o}:{},...r?{claimQualification:N({contract:r,receipt:u,...o?{coverage:o}:{}})}:{}}}}:{}}function ie(e){if(!Number.isSafeInteger(e.returned)||e.returned<0)throw new Error("Invocation coverage returned count must be a non-negative safe integer.");if(e.complete!==!0&&e.complete!==!1&&e.complete!==null)throw new Error("Invocation coverage complete must be true, false, or null.");if(e.complete===!0){if(!e.totalKnown)throw new Error("Complete invocation coverage must know its total.");if(!Number.isSafeInteger(e.total)||e.total!==e.returned)throw new Error("Complete invocation coverage total must equal returned.");if(e.omitted!==0)throw new Error("Complete invocation coverage cannot omit results.");if(e.omittedIdentities!==void 0)throw new Error("Complete invocation coverage cannot name omitted identities.");if(e.continuation!==void 0)throw new Error("Complete invocation coverage cannot provide a continuation.")}else if(e.totalKnown){if(e.complete!==!1)throw new Error("Known incomplete invocation coverage must set complete to false.");if(!Number.isSafeInteger(e.total)||e.total<e.returned)throw new Error("Known invocation coverage total must be a safe integer at least as large as returned.");let n=e.total-e.returned;if(e.omitted!==n)throw new Error("Known invocation coverage omitted count must equal total minus returned.");if(n===0)throw new Error("Known incomplete invocation coverage must omit at least one result.");if(e.omittedIdentities&&e.omittedIdentities.length!==n)throw new Error("Omitted identity count must equal the disclosed omitted count.")}else{if(e.total!==void 0||e.omitted!==void 0)throw new Error("Unknown invocation coverage cannot claim a total or omitted count.");if(e.omittedIdentities!==void 0)throw new Error("Unknown invocation coverage cannot claim omitted identities.")}if(e.continuation&&(e.continuation.cursor.length===0||e.continuation.indexGeneration.length===0))throw new Error("Invocation coverage continuation requires a cursor and index generation.");if(e.resolution){if(!Number.isSafeInteger(e.resolution.totalCandidates)||e.resolution.totalCandidates<0)throw new Error("Invocation resolution candidate count must be a non-negative safe integer.");if(e.resolution.state==="exact"&&e.resolution.totalCandidates!==1)throw new Error("Exact invocation resolution must name exactly one candidate.");if(e.resolution.state==="missing"&&e.resolution.totalCandidates!==0)throw new Error("Missing invocation resolution cannot name candidates.");if(e.resolution.state==="ambiguous"&&e.resolution.totalCandidates<2)throw new Error("Ambiguous invocation resolution must name at least two candidates.")}}function ae(e,n,t){if(!e)return;let o=se(e,n);return e.coverage==="complete"?{complete:!0,totalKnown:!0,returned:o,total:o,omitted:0}:e.coverage==="sampled"?{complete:!1,totalKnown:!1,returned:o}:e.coverage==="bounded"&&t?{complete:!1,totalKnown:!1,returned:o}:{complete:null,totalKnown:!1,returned:o}}function se(e,n){let t=e.resultUnits??{kind:"report"};if(t.kind==="rows")return Array.isArray(n)?n.length:0;if(t.kind==="field"){if(!n||typeof n!="object")return 0;let o=n[t.field];return Array.isArray(o)?o.length:o==null?0:1}return n==null?0:1}function de(e){if(!e||typeof e!="object"||Array.isArray(e))return;let n=e;if(n.matched===!1)return{state:"missing",totalCandidates:0};if(n.matched!==!0||!Number.isSafeInteger(n.totalMatches))return;let t=n.totalMatches;return t<=0?{state:"missing",totalCandidates:0}:t===1?{state:"exact",totalCandidates:t}:{state:"ambiguous",totalCandidates:t}}function ue(e){return e.filter(n=>typeof n=="string"||typeof n=="number"||typeof n=="boolean")}function le(e){if(e.length===0)return{args:[],opts:{}};let n=e[e.length-1];return{args:e.slice(0,-1),opts:me(n)}}function me(e){if(!e||typeof e!="object")return{};let n=e,t=typeof n.optsWithGlobals=="function"?n.optsWithGlobals.bind(n):typeof n.opts=="function"?n.opts.bind(n):null;if(t){let o=t();return!o||typeof o!="object"?{}:(typeof n.getOptionValueSource=="function"&&Object.defineProperty(o,P,{value:r=>n.getOptionValueSource(r),enumerable:!1}),o)}return e}export{ce as a,pe as b,k as c,fe as d,Ie as e,ke as f,Ae as g,Ne as h,m as i,R as j,_e as k,Le as l,Me as m,Z as n,Je as o,ee as p,Pe as q,Te as r,De as s,Be as t,He as u,Qe as v,qe as w,Q as x,d as y,Ke as z,Ue as A,je as B,ne as C,oe as D,le as E,me as F};
3
- //# sourceMappingURL=chunk-UXM43C7T.js.map