codebaseiq 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (324) hide show
  1. package/CHANGELOG.md +80 -0
  2. package/dist/augment-vue-worker.js +1 -1
  3. package/dist/{chunk-7GAK2F3H.js → chunk-23AD24QZ.js} +12 -12
  4. package/dist/chunk-24TEZJST.js +2 -0
  5. package/dist/{chunk-356EZBIP.js → chunk-26EDDGAX.js} +2 -2
  6. package/dist/{chunk-O2M3VNDY.js → chunk-26EZWQ24.js} +2 -2
  7. package/dist/{chunk-U33PMPNW.js → chunk-2L3NCI52.js} +2 -2
  8. package/dist/{chunk-MSI3K7PJ.js → chunk-2QJAVISG.js} +2 -2
  9. package/dist/{chunk-4LK5OIPW.js → chunk-2ZBZRYX4.js} +2 -2
  10. package/dist/chunk-33AXWMO2.js +2 -0
  11. package/dist/{chunk-EQNMD62X.js → chunk-37K55EG3.js} +2 -2
  12. package/dist/{chunk-ITSJMNUD.js → chunk-3EFZ5KQ4.js} +2 -2
  13. package/dist/{chunk-D7DOB27N.js → chunk-3F23W57G.js} +2 -2
  14. package/dist/{chunk-BGGB5N53.js → chunk-3GKKCVKK.js} +2 -2
  15. package/dist/{chunk-MQW6SJ4P.js → chunk-3SYRGMCL.js} +2 -2
  16. package/dist/{chunk-PFC44E6D.js → chunk-3VDL7GTY.js} +2 -2
  17. package/dist/{chunk-7JELP5YE.js → chunk-3XBZ5PKL.js} +2 -2
  18. package/dist/{chunk-75KJGYX7.js → chunk-42PXSE74.js} +2 -2
  19. package/dist/{chunk-FEIZXBLH.js → chunk-4GIERC2P.js} +2 -2
  20. package/dist/{chunk-W7YLRXZE.js → chunk-4UXDBRIF.js} +2 -2
  21. package/dist/chunk-4XMZYLW5.js +2 -0
  22. package/dist/{chunk-6BF3VYEF.js → chunk-55NUXP2V.js} +2 -2
  23. package/dist/chunk-5AJQCOZZ.js +21 -0
  24. package/dist/{chunk-5DSL3NT2.js → chunk-5NUPFZFA.js} +2 -2
  25. package/dist/{chunk-RJVAPMHF.js → chunk-65QIFIF6.js} +2 -2
  26. package/dist/{chunk-36JC5BG2.js → chunk-66Q5VLH6.js} +2 -2
  27. package/dist/{chunk-D7AZAOZX.js → chunk-6CQPIIS7.js} +2 -2
  28. package/dist/{chunk-GV2CEZCW.js → chunk-6CTSFS7R.js} +2 -2
  29. package/dist/{chunk-Q4XEU3UH.js → chunk-6EBUAKJT.js} +2 -2
  30. package/dist/chunk-6I55VYFG.js +4 -0
  31. package/dist/chunk-6NUURWPF.js +3 -0
  32. package/dist/{chunk-MHWMEZDA.js → chunk-6P5QMOM7.js} +2 -2
  33. package/dist/{chunk-LZSQ6X7E.js → chunk-6S5FE4ZF.js} +2 -2
  34. package/dist/chunk-74LRKLNC.js +22 -0
  35. package/dist/chunk-75A23IID.js +3 -0
  36. package/dist/chunk-75VNTSO6.js +7 -0
  37. package/dist/chunk-7HBBVZJ6.js +3 -0
  38. package/dist/{chunk-VWYGCMV5.js → chunk-7PPBMBH6.js} +2 -2
  39. package/dist/{chunk-3RSBGWGL.js → chunk-7WG57A5X.js} +2 -2
  40. package/dist/{chunk-FWQGH2N2.js → chunk-7XHZX6FX.js} +2 -2
  41. package/dist/{chunk-RIYJ4L33.js → chunk-A5HJ3CJW.js} +2 -2
  42. package/dist/{chunk-LONKINMJ.js → chunk-AJ5HVC5Z.js} +2 -2
  43. package/dist/{chunk-ZAFGY22Q.js → chunk-AYRHOFLV.js} +2 -2
  44. package/dist/chunk-AZDY3EKD.js +93 -0
  45. package/dist/{chunk-CW6AXOLR.js → chunk-AZZNG5Z2.js} +2 -2
  46. package/dist/chunk-BEKCTUPY.js +3 -0
  47. package/dist/{chunk-CR3OG6SQ.js → chunk-BKKX2OU5.js} +2 -2
  48. package/dist/{chunk-5LL4KEHO.js → chunk-BQKRYKDD.js} +2 -2
  49. package/dist/{chunk-FOZ74V56.js → chunk-BVDQU2XJ.js} +2 -2
  50. package/dist/chunk-C3PPB2T5.js +5 -0
  51. package/dist/chunk-CABIZQXQ.js +21 -0
  52. package/dist/{chunk-M2Y6PCFE.js → chunk-CAH322MC.js} +2 -2
  53. package/dist/{chunk-EIBGSU2R.js → chunk-CBOOHUK4.js} +2 -2
  54. package/dist/chunk-CFIICAOM.js +2 -0
  55. package/dist/{chunk-XMJ53WG4.js → chunk-CPWYEPWQ.js} +2 -2
  56. package/dist/{chunk-LQHYYIOB.js → chunk-CRT7I7RJ.js} +2 -2
  57. package/dist/{chunk-IZDPGOZR.js → chunk-CZVSQQDU.js} +2 -2
  58. package/dist/{chunk-TNJGTQWO.js → chunk-D3KE26FS.js} +2 -2
  59. package/dist/{chunk-GP7C5VAE.js → chunk-DNRHRVKS.js} +2 -2
  60. package/dist/{chunk-SGMNWYTH.js → chunk-DOQLO74K.js} +2 -2
  61. package/dist/{chunk-AURCQHSG.js → chunk-DP3EJ6XL.js} +2 -2
  62. package/dist/{chunk-C7QWUBR2.js → chunk-DQZF7MP6.js} +2 -2
  63. package/dist/{chunk-E52K4L2W.js → chunk-DTM4EHD2.js} +2 -2
  64. package/dist/{chunk-YRKP7PM7.js → chunk-DUM7GR6B.js} +2 -2
  65. package/dist/{chunk-I22IZYDI.js → chunk-DZ4QOIRY.js} +2 -2
  66. package/dist/{chunk-EXZ7VLRY.js → chunk-E3R6TJ5T.js} +2 -2
  67. package/dist/chunk-E4DP45YU.js +3 -0
  68. package/dist/{chunk-PUVNH4PO.js → chunk-E5U6N5WI.js} +2 -2
  69. package/dist/chunk-E7T22WET.js +21 -0
  70. package/dist/{chunk-QEOWONKY.js → chunk-ED7ZAZ5V.js} +2 -2
  71. package/dist/{chunk-RCIGX23V.js → chunk-EDMG5CSO.js} +2 -2
  72. package/dist/{chunk-IHSLIIL3.js → chunk-EOSUV7H5.js} +2 -2
  73. package/dist/{chunk-FQTIFWLR.js → chunk-ESWVTSHU.js} +2 -2
  74. package/dist/{chunk-6VREELBC.js → chunk-ETZBIG6K.js} +2 -2
  75. package/dist/chunk-EYSJHKX6.js +3 -0
  76. package/dist/{chunk-Q23IMHXS.js → chunk-F4AGM7ZE.js} +37 -37
  77. package/dist/{chunk-FTTV7IRX.js → chunk-FPUJRBHL.js} +50 -50
  78. package/dist/{chunk-CCIYWXX6.js → chunk-G2UU6PQP.js} +2 -2
  79. package/dist/{chunk-C6WKPKCF.js → chunk-G3KRXNNT.js} +2 -2
  80. package/dist/{chunk-TEANKHUU.js → chunk-G3ZBP72R.js} +2 -2
  81. package/dist/{chunk-NBCQZSGR.js → chunk-GC4I33OD.js} +2 -2
  82. package/dist/{chunk-NDKOVQFG.js → chunk-GLXEWYQY.js} +2 -2
  83. package/dist/{chunk-AEXQYQD7.js → chunk-GRHNPFHT.js} +2 -2
  84. package/dist/{chunk-NBZKSTXP.js → chunk-GWESWURK.js} +2 -2
  85. package/dist/{chunk-Q3ZCQY2Y.js → chunk-GXOFPAIR.js} +2 -2
  86. package/dist/{chunk-USOAJHY7.js → chunk-H4FGIFEU.js} +2 -2
  87. package/dist/{chunk-LKUTSP4G.js → chunk-HOGS6JFP.js} +2 -2
  88. package/dist/{chunk-UQE4XFSA.js → chunk-HSJLK5MC.js} +2 -2
  89. package/dist/{chunk-BWL3PMPT.js → chunk-HTPEUJ42.js} +2 -2
  90. package/dist/{chunk-3RR2K7EZ.js → chunk-IBPXUGJV.js} +2 -2
  91. package/dist/{chunk-BFBIMTCJ.js → chunk-ITA3N7G6.js} +2 -2
  92. package/dist/chunk-JG5OWAEB.js +22 -0
  93. package/dist/{chunk-2PRONPAS.js → chunk-JGJKRTTB.js} +2 -2
  94. package/dist/{chunk-TJWVT4DO.js → chunk-JGXLB7PR.js} +2 -2
  95. package/dist/{chunk-K7JLSGCJ.js → chunk-JKUF2UG6.js} +3 -3
  96. package/dist/{chunk-CIYA2KZN.js → chunk-JOYASZRF.js} +2 -2
  97. package/dist/{chunk-U7NUXDQO.js → chunk-K3PFL5QQ.js} +2 -2
  98. package/dist/{chunk-WK2IQJPK.js → chunk-KAXBWTSX.js} +2 -2
  99. package/dist/{chunk-5ZI2PPI7.js → chunk-KHHAGHAW.js} +2 -2
  100. package/dist/{chunk-UW6KD57C.js → chunk-KJLUQVBG.js} +2 -2
  101. package/dist/{chunk-WWCV4E6J.js → chunk-KOVUXHIZ.js} +2 -2
  102. package/dist/chunk-KPMMOAV5.js +4 -0
  103. package/dist/{chunk-GDHWOA57.js → chunk-LKJZNGMA.js} +2 -2
  104. package/dist/{chunk-3VJ3OCRE.js → chunk-LMPOC372.js} +2 -2
  105. package/dist/{chunk-F3QSL4W2.js → chunk-LTPNP6D5.js} +2 -2
  106. package/dist/{chunk-MVRGB4KJ.js → chunk-M3IBH6C3.js} +9 -9
  107. package/dist/{chunk-PHNCEUXX.js → chunk-MAGBSB6E.js} +2 -2
  108. package/dist/{chunk-QMOZZ2VX.js → chunk-MFMHD36E.js} +2 -2
  109. package/dist/{chunk-LMTSB3TB.js → chunk-MJX2J5QE.js} +2 -2
  110. package/dist/{chunk-PTQPPPG2.js → chunk-N26LGGSF.js} +2 -2
  111. package/dist/{chunk-J7AMBVWF.js → chunk-NB2DAVPP.js} +2 -2
  112. package/dist/{chunk-JYI7CV25.js → chunk-NJDXNYLG.js} +2 -2
  113. package/dist/{chunk-BRQL7AFJ.js → chunk-NMKQOIYZ.js} +2 -2
  114. package/dist/{chunk-ICUL7XRT.js → chunk-NRNVMB2R.js} +2 -2
  115. package/dist/{chunk-DDN2F6GB.js → chunk-O5BWFNIH.js} +2 -2
  116. package/dist/{chunk-HVFB3PME.js → chunk-O7PCDZ5B.js} +2 -2
  117. package/dist/{chunk-KPZGTB2O.js → chunk-OAJYNPRU.js} +2 -2
  118. package/dist/{chunk-2EDX3JT5.js → chunk-OFUC6R46.js} +2 -2
  119. package/dist/chunk-OSZ7PW5K.js +5 -0
  120. package/dist/{chunk-B3UYV66Z.js → chunk-OZ2M2X7A.js} +2 -2
  121. package/dist/{chunk-6O3KXIDL.js → chunk-OZI44VCR.js} +2 -2
  122. package/dist/{chunk-XN3EKMLI.js → chunk-PCKIKOUA.js} +2 -2
  123. package/dist/{chunk-NCJILOAK.js → chunk-PFMQRHC6.js} +2 -2
  124. package/dist/chunk-PVKSZBX5.js +82 -0
  125. package/dist/{chunk-NEWHKGVD.js → chunk-QANCT4MO.js} +2 -2
  126. package/dist/{chunk-ZNH33XIB.js → chunk-QEWN7BLP.js} +2 -2
  127. package/dist/{chunk-OQUCBKOI.js → chunk-QFJ46F6F.js} +2 -2
  128. package/dist/{chunk-2E6OUPCF.js → chunk-QPQWR6CW.js} +2 -2
  129. package/dist/{chunk-YTJHCGYB.js → chunk-QX4HDF2I.js} +2 -2
  130. package/dist/{chunk-J3GLP7Q5.js → chunk-R2F2CTBA.js} +2 -2
  131. package/dist/{chunk-2OMXFE64.js → chunk-R7PXHYMY.js} +2 -2
  132. package/dist/{chunk-F74LZWCE.js → chunk-RGBZDOUO.js} +2 -2
  133. package/dist/{chunk-362QOSFD.js → chunk-RNPG5P4P.js} +2 -2
  134. package/dist/{chunk-D62CTZX6.js → chunk-RS6UYNEP.js} +2 -2
  135. package/dist/{chunk-VGWZ4MOY.js → chunk-RVBRPBLQ.js} +2 -2
  136. package/dist/{chunk-5IZRKWTZ.js → chunk-RWAZCEJD.js} +2 -2
  137. package/dist/{chunk-ZQ62NNKN.js → chunk-RWDIONS7.js} +2 -2
  138. package/dist/{chunk-HQA7EBSK.js → chunk-S3CJYDXP.js} +2 -2
  139. package/dist/{chunk-GL6UTNUB.js → chunk-S6UTKCBT.js} +2 -2
  140. package/dist/chunk-SLLFJXTW.js +27 -0
  141. package/dist/{chunk-TOTWJZIX.js → chunk-T3KTMLQT.js} +2 -2
  142. package/dist/{chunk-67VJAYVR.js → chunk-TB575ZGO.js} +2 -2
  143. package/dist/{chunk-YHPG3S2U.js → chunk-TG4GMU73.js} +2 -2
  144. package/dist/{chunk-CVHOQONG.js → chunk-THKM7OXM.js} +2 -2
  145. package/dist/{chunk-GVAF222T.js → chunk-TNLOX4TN.js} +2 -2
  146. package/dist/{chunk-HENP2O4A.js → chunk-UHFZDQZJ.js} +2 -2
  147. package/dist/{chunk-YT4DVWUV.js → chunk-UUMAM5LM.js} +2 -2
  148. package/dist/{chunk-JX6ZWDOS.js → chunk-UUT5P3V7.js} +2 -2
  149. package/dist/{chunk-Z6RL7XOE.js → chunk-VEPK6M5C.js} +2 -2
  150. package/dist/{chunk-C7OUW52M.js → chunk-VPCHKZ3I.js} +2 -2
  151. package/dist/{chunk-GIDCP7KV.js → chunk-VZY3XOBU.js} +2 -2
  152. package/dist/{chunk-XQAVQVIL.js → chunk-W6E6ME7G.js} +2 -2
  153. package/dist/{chunk-XQPPURLQ.js → chunk-WGYZBS5S.js} +2 -2
  154. package/dist/{chunk-GUFPEFBG.js → chunk-WUP24Q4U.js} +2 -2
  155. package/dist/chunk-WXUHXSLN.js +2 -0
  156. package/dist/{chunk-HINZQKSY.js → chunk-X4YZD2MP.js} +2 -2
  157. package/dist/chunk-XARPGCTL.js +2 -0
  158. package/dist/{chunk-5FWR5HLG.js → chunk-XDQ6QJF5.js} +20 -20
  159. package/dist/{chunk-JCMFBF4Z.js → chunk-XRH7R5SX.js} +2 -2
  160. package/dist/{chunk-BBP7HVBJ.js → chunk-XVJ2E7W7.js} +2 -2
  161. package/dist/{chunk-D53LWANR.js → chunk-Y7GFAU5N.js} +2 -2
  162. package/dist/{chunk-T6MQNNAC.js → chunk-YBDLHFZZ.js} +2 -2
  163. package/dist/{chunk-ZB4C5TTR.js → chunk-YI3CJPOY.js} +2 -2
  164. package/dist/chunk-YMAGXBLT.js +3 -0
  165. package/dist/{chunk-MZNMASFM.js → chunk-YRAGNEBZ.js} +2 -2
  166. package/dist/chunk-YXZAAQHZ.js +3 -0
  167. package/dist/chunk-Z2L5H2HF.js +3 -0
  168. package/dist/{chunk-JSNTHRLQ.js → chunk-ZHK7TVAJ.js} +2 -2
  169. package/dist/chunk-ZJNV27DZ.js +4 -0
  170. package/dist/{chunk-GQLDYCWS.js → chunk-ZQ6GAIUV.js} +2 -2
  171. package/dist/{chunk-TPO7XC5Z.js → chunk-ZQE2QYAC.js} +2 -2
  172. package/dist/chunk-ZUQ2MDFT.js +2 -0
  173. package/dist/cli-context-4R2LREXQ.js +3 -0
  174. package/dist/cli-context-6X7JYARX.js +2 -0
  175. package/dist/cli-failure-RECEHOM2.js +3 -0
  176. package/dist/cli-program-MXA3WTAO.js +7 -0
  177. package/dist/cli.js +1 -1
  178. package/dist/{code-viewer-VHLBLIUM.js → code-viewer-C6HE4DFC.js} +2 -2
  179. package/dist/{code-viewer-KIXEYQNJ.js → code-viewer-XHSSAMBX.js} +2 -2
  180. package/dist/{command-descriptors-YCLATF5I.js → command-descriptors-NWW34Z54.js} +171 -171
  181. package/dist/{command-descriptors-F5P2V3NW.js → command-descriptors-XHK3PK2I.js} +116 -116
  182. package/dist/{command-panels-SZONPMLJ.js → command-panels-OXMCJ2QZ.js} +2 -2
  183. package/dist/direct-navigation-236VXYBZ.js +3 -0
  184. package/dist/direct-navigation-36YSILY6.js +2 -0
  185. package/dist/index.js +1 -1
  186. package/dist/invocation-command-descriptors-35JULLNR.js +3 -0
  187. package/dist/invocation-command-descriptors-FEWSFUO2.js +2 -0
  188. package/dist/output-continuation-command-MJBVH3A5.js +2 -0
  189. package/dist/output-continuation-command-TBXIOPHQ.js +3 -0
  190. package/dist/project-reindex-5TCGOVSK.js +2 -0
  191. package/dist/project-reindex-BUNTSYKM.js +3 -0
  192. package/dist/queries/affected.js +1 -1
  193. package/dist/queries/anchors.js +1 -1
  194. package/dist/queries/architecture.js +1 -1
  195. package/dist/queries/bottlenecks.js +1 -1
  196. package/dist/queries/by-kind.js +1 -1
  197. package/dist/queries/call-graph.js +1 -1
  198. package/dist/queries/change-surface.js +1 -1
  199. package/dist/queries/cleanup-plan.js +1 -1
  200. package/dist/queries/co-change.js +1 -1
  201. package/dist/queries/code.js +1 -1
  202. package/dist/queries/complexity-hotspots.js +1 -1
  203. package/dist/queries/complexity.js +1 -1
  204. package/dist/queries/context.js +1 -1
  205. package/dist/queries/convergence.js +1 -1
  206. package/dist/queries/coupling.js +1 -1
  207. package/dist/queries/cycles.js +1 -1
  208. package/dist/queries/dataflow.js +1 -1
  209. package/dist/queries/dead.js +1 -1
  210. package/dist/queries/decorative-checkers.js +1 -1
  211. package/dist/queries/deep-chains.js +1 -1
  212. package/dist/queries/dependence-slice.js +1 -1
  213. package/dist/queries/dependency-depth.js +1 -1
  214. package/dist/queries/deps.js +1 -1
  215. package/dist/queries/diff-impact.js +1 -1
  216. package/dist/queries/doc-drift.js +1 -1
  217. package/dist/queries/drift.js +1 -1
  218. package/dist/queries/duplicate-bodies.js +1 -1
  219. package/dist/queries/entry-map.js +1 -1
  220. package/dist/queries/evidence.js +1 -1
  221. package/dist/queries/extract-candidates.js +1 -1
  222. package/dist/queries/fan.js +1 -1
  223. package/dist/queries/files.js +1 -1
  224. package/dist/queries/health.js +1 -1
  225. package/dist/queries/hierarchy.js +1 -1
  226. package/dist/queries/hotspots.js +1 -1
  227. package/dist/queries/imports.js +1 -1
  228. package/dist/queries/incomplete-migration.js +1 -1
  229. package/dist/queries/index.js +1 -1
  230. package/dist/queries/isolated.js +1 -1
  231. package/dist/queries/locality-candidates.js +1 -1
  232. package/dist/queries/members.js +1 -1
  233. package/dist/queries/methods.js +1 -1
  234. package/dist/queries/not-implemented.js +1 -1
  235. package/dist/queries/outline.js +1 -1
  236. package/dist/queries/passthrough-candidates.js +1 -1
  237. package/dist/queries/plan-context.js +1 -1
  238. package/dist/queries/react-component-duplicates.js +1 -1
  239. package/dist/queries/react-hook-candidates.js +1 -1
  240. package/dist/queries/react-large-component-pressure.js +1 -1
  241. package/dist/queries/recent-duplicates.js +1 -1
  242. package/dist/queries/redundant-reexports.js +1 -1
  243. package/dist/queries/reference-neighborhood.js +1 -1
  244. package/dist/queries/reference-reachability.js +1 -1
  245. package/dist/queries/refs.js +1 -1
  246. package/dist/queries/self-audit.js +1 -1
  247. package/dist/queries/similar-chains.js +1 -1
  248. package/dist/queries/similar-files.js +1 -1
  249. package/dist/queries/similar-signatures.js +1 -1
  250. package/dist/queries/similar.js +1 -1
  251. package/dist/queries/slice.js +1 -1
  252. package/dist/queries/source-inspection.js +1 -1
  253. package/dist/queries/source-search.js +1 -1
  254. package/dist/queries/stale-abstractions.js +1 -1
  255. package/dist/queries/surface.js +1 -1
  256. package/dist/queries/symbols.js +1 -1
  257. package/dist/queries/system-map.js +1 -1
  258. package/dist/queries/system.js +1 -1
  259. package/dist/queries/test-quality.js +1 -1
  260. package/dist/queries/trace.js +1 -1
  261. package/dist/queries/twin-ab.js +1 -1
  262. package/dist/queries/twin-drift.js +1 -1
  263. package/dist/queries/unused-imports.js +1 -1
  264. package/dist/queries/unused-params.js +1 -1
  265. package/dist/queries/value-flow.js +1 -1
  266. package/dist/queries/vue-component-duplicates.js +1 -1
  267. package/dist/queries/vue-composable-candidates.js +1 -1
  268. package/dist/queries/vue-large-view-pressure.js +1 -1
  269. package/dist/queries/wrapper-candidates.js +1 -1
  270. package/dist/reindex-worker.js +1 -1
  271. package/dist/reindex.js +30 -30
  272. package/dist/runtime.js +1 -1
  273. package/dist/rust-semantic-session-server.js +1 -1
  274. package/dist/rust-semantic-session-worker.js +1 -1
  275. package/dist/rust-semantic-worker.js +1 -1
  276. package/dist/sentinel-ensure-command-3MZCLPQY.js +2 -0
  277. package/dist/sentinel-ensure-command-LEWHIRLL.js +3 -0
  278. package/dist/sentinel-worker.js +1 -1
  279. package/dist/typescript-mailbox-worker.js +1 -1
  280. package/dist/watch-server.js +6 -6
  281. package/docs/COMMAND_REFERENCE.md +2 -2
  282. package/docs/SECURITY_MODEL.md +3 -0
  283. package/package.json +1 -1
  284. package/skills/codebaseiq/SKILL.md +15 -3
  285. package/dist/chunk-23C5AD3B.js +0 -2
  286. package/dist/chunk-2I2UHZET.js +0 -2
  287. package/dist/chunk-5IC2WZAL.js +0 -22
  288. package/dist/chunk-5T44HG5Y.js +0 -88
  289. package/dist/chunk-6JMAVFL4.js +0 -3
  290. package/dist/chunk-6WAPPQ5F.js +0 -82
  291. package/dist/chunk-7UCDGXRW.js +0 -8
  292. package/dist/chunk-AQI4N64O.js +0 -22
  293. package/dist/chunk-DAKIGMIK.js +0 -21
  294. package/dist/chunk-DUKHVPU5.js +0 -4
  295. package/dist/chunk-DVWO7RBC.js +0 -2
  296. package/dist/chunk-FH5WG4LE.js +0 -2
  297. package/dist/chunk-GQXXOS55.js +0 -2
  298. package/dist/chunk-GWYZVVKY.js +0 -21
  299. package/dist/chunk-JFIA2JI3.js +0 -3
  300. package/dist/chunk-JLZLLLW5.js +0 -3
  301. package/dist/chunk-MEUHIDI3.js +0 -7
  302. package/dist/chunk-OFGOOL6U.js +0 -3
  303. package/dist/chunk-P4NVCOM7.js +0 -2
  304. package/dist/chunk-SMDIEDM4.js +0 -27
  305. package/dist/chunk-SX72EVMY.js +0 -3
  306. package/dist/chunk-T5X7DK6C.js +0 -3
  307. package/dist/chunk-T75DS2E6.js +0 -21
  308. package/dist/chunk-TJBOJUVN.js +0 -3
  309. package/dist/chunk-UC2FD2PS.js +0 -4
  310. package/dist/chunk-UQYQBLJX.js +0 -5
  311. package/dist/chunk-Z35GOVEH.js +0 -2
  312. package/dist/cli-context-FJL2JHOE.js +0 -3
  313. package/dist/cli-context-PQNWHMCQ.js +0 -2
  314. package/dist/cli-program-UO7PZD6V.js +0 -7
  315. package/dist/direct-navigation-4XJTXIDT.js +0 -2
  316. package/dist/direct-navigation-J5MVYYAD.js +0 -3
  317. package/dist/invocation-command-descriptors-RWV4VAI4.js +0 -2
  318. package/dist/invocation-command-descriptors-U76PN7IY.js +0 -3
  319. package/dist/output-continuation-command-BL25S26S.js +0 -3
  320. package/dist/output-continuation-command-BTETTXEC.js +0 -2
  321. package/dist/project-reindex-CRJU3IFG.js +0 -2
  322. package/dist/project-reindex-TQFCOA2O.js +0 -3
  323. package/dist/sentinel-ensure-command-OSWGCFFL.js +0 -3
  324. package/dist/sentinel-ensure-command-SPW7XQLB.js +0 -2
@@ -1,22 +0,0 @@
1
- #!/usr/bin/env node
2
- import{a as he,c as z}from"./chunk-C7QWUBR2.js";import{b as le}from"./chunk-XZEE23VG.js";import{O as P,X as v}from"./chunk-5T44HG5Y.js";import{j as de,r as b,w as pe,x as ge,y as D}from"./chunk-DUKHVPU5.js";import{AsyncLocalStorage as nt}from"async_hooks";import{createHash as V}from"crypto";import{existsSync as rt,mkdirSync as st}from"fs";import{tmpdir as it}from"os";import{isAbsolute as ot,join as ye,resolve as Se}from"path";var q=2,at="CODEBASEIQ_SESSION",me="CODEBASEIQ_SESSION_DIR",ut=128,I=new nt;function ve(e,t){let n=e.sessionEnabled===!1||e.json?void 0:It(),r={enabled:n!==void 0,reemit:e.reemit===!0,command:e.command,projectRoot:Se(e.cwd),sessionIdentity:n,staged:[],stagedEvidence:[],finalized:!1};return I.run(r,t)}function Dn(e){let t=I.getStore();!t||t.finalized||(t.generationIdentity=e)}function zn(){return I.getStore()?.staged.length??0}function qn(e){let t=I.getStore();!t||e<0||e>t.staged.length||(t.staged.length=e)}function W(e){let t=I.getStore();if(!t||t.finalized)return;t.finalized=!0;let n=t.state;if(!n){t.staged.length=0,t.stagedEvidence.length=0;return}try{if(e&&(t.staged.length>0||t.stagedEvidence.length>0)){let r=n.ledger.nextOrdinal,s=yt(t.staged).map(o=>({...o,ordinal:r,command:t.command})),i=vt(t.stagedEvidence).map(o=>({...o,ordinal:r,command:t.command}));n.ledger.ranges.push(...s),n.ledger.evidence.push(...i),n.ledger.nextOrdinal+=1,n.ledger.updatedAt=new Date().toISOString(),v(n.ledgerPath,n.ledger,{spacing:2,trailingNewline:!0})}}catch{}finally{n.lock.release(),t.state=null,t.staged.length=0,t.stagedEvidence.length=0}}function Vn(e){let t=e.source.split(`
3
- `);if(t.length===0)return"";let n=ct(e.relativePath,e.startLine,t,e.ownerSymbol,e.sessionPolicy??"exact-unit"),r=e.indent??" ",s=e.sourceIndent??" ",i=e.focusLines??new Set;return n.map(o=>{let a=z(e.relativePath,o.startLine,o.endLine);if(o.kind==="covered"){let p=o.ordinal===null?"this command":`session #${o.ordinal} via ${o.command}`;return[`${r}${a} [source previously emitted: ${p}; not repeated]`,...e.afterHeader??[]].join(`
4
- `)}let u=e.headerSuffix??"",d=o.lines.map((p,l)=>{let g=o.startLine+l,c=e.showFocusMarker===!1?"":i.has(g)?">":" ",m=e.lineNumberWidth??5;return`${s}${c}${String(he(g)).padStart(m)} ${p}`});return[`${r}${a}${u}`,...e.blankAfterHeader?[""]:[],...e.afterHeader??[],...d].join(`
5
- `)}).join(`
6
- `)}function Wn(e){let t=I.getStore();if(!t||!t.enabled)return e.content;let n=G(t);if(!n)return e.content;let r=Oe(e.content),s=R(n.ledger.evidence,i=>i.kind===e.kind&&i.identity===e.identity&&i.contentHash===r);if(s&&!t.reemit){let i=e.label?`; ${fe(e.label)}`:"";return`${e.indent??""}[${e.kind} evidence previously emitted: receipt ${s.receiptId}; session #${s.ordinal} via ${s.command}${i}; not repeated]`}return t.stagedEvidence.push({kind:e.kind,identity:e.identity,contentHash:r,receiptId:wt(e.kind,e.identity,r),...e.label?{label:fe(e.label)}:{}}),e.content}function Gn(e=!1){let t=I.getStore();if(!t?.enabled)return{enabled:!1,reason:"No explicit CODEBASEIQ_SESSION is active; source packets render independently.",uniqueLines:0,evidenceItems:0,emissions:0,rows:[]};let n=G(t);if(!n)return{enabled:!1,reason:"The exploration-session ledger was unavailable or contended; evidence output is fail-open for this command.",uniqueLines:0,evidenceItems:0,emissions:0,rows:[]};if(e){n.ledger.ranges=[],n.ledger.evidence=[],n.ledger.nextOrdinal=1,n.ledger.updatedAt=new Date().toISOString();try{v(n.ledgerPath,n.ledger,{spacing:2,trailingNewline:!0})}catch{return{enabled:!1,reason:"The exploration-session ledger could not be reset; evidence output remains fail-open.",uniqueLines:0,evidenceItems:0,emissions:0,rows:[]}}}let r=new Map;for(let a of n.ledger.ranges){let u=r.get(a.ordinal)??[];u.push(a),r.set(a.ordinal,u)}let s=new Map;for(let a of n.ledger.evidence){let u=s.get(a.ordinal)??[];u.push(a),s.set(a.ordinal,u)}let o=[...new Set([...r.keys(),...s.keys()])].sort((a,u)=>a-u).map(a=>{let u=r.get(a)??[],d=s.get(a)??[],p=u[0]?.command??d[0]?.command??"unknown",l=u.length===0?null:(()=>{let m=u.slice(0,8).map(h=>z(h.relativePath,h.startLine,h.endLine)).join(", "),f=u.length>8?`, ... ${u.length-8} more range(s)`:"";return` #${a} ${p}: ${m}${f}`})();if(d.length===0)return l;let g=d.slice(0,8).map(m=>`${m.receiptId} ${m.kind}${m.label?` ${m.label}`:""}`).join(", "),c=d.length>8?`, ... ${d.length-8} more item(s)`:"";return l?`${l}
7
- evidence: ${g}${c}`:` #${a} ${p}: ${g}${c}`});return{enabled:!0,uniqueLines:Ot(n.ledger.ranges),evidenceItems:n.ledger.evidence.length,emissions:new Set([...r.keys(),...s.keys()]).size,rows:o}}function ct(e,t,n,r,s){let i=I.getStore(),o=t+n.length-1;if(!i)return[{kind:"source",startLine:t,endLine:o,lines:[...n]}];let u=(i.enabled?G(i):null)?.ledger.ranges??[],d=n.map(Oe),p=s==="exact-unit"&&!i.reemit?R(u,h=>h.policy==="exact-unit"&&h.relativePath===e&&h.startLine===t&&h.endLine===o&&h.ownerSymbol===r&&Et(h.lineHashes,d)):void 0;if(p)return[{kind:"covered",startLine:t,endLine:o,ordinal:p.ordinal,command:p.command}];let l=s==="exact-unit"&&!i.reemit?pt(u,e,t,o,d):void 0;if(l)return[{kind:"covered",startLine:t,endLine:o,ordinal:l.ordinal,command:l.command}];let g=n.map((h,y)=>dt(u,e,t+y,d[y]));if(!(s==="preview"&&!i.reemit&&g.every(h=>h!==void 0)))return i.staged.push({relativePath:e,startLine:t,endLine:o,ownerSymbol:r,policy:s,lineHashes:d}),[{kind:"source",startLine:t,endLine:o,lines:[...n]}];let m=[],f=0;for(;f<n.length;){let h=g[f],y=f;for(;y+1<n.length&&gt(h,g[y+1]);)y+=1;let S=t+f,N=t+y;m.push({kind:"covered",startLine:S,endLine:N,ordinal:h.ordinal,command:h.command}),f=y+1}return m}function dt(e,t,n,r){let s=R(e,i=>i.relativePath===t&&i.startLine<=n&&n<=i.endLine&&i.lineHashes[n-i.startLine]===r);if(s)return{ordinal:s.ordinal,command:s.command}}function pt(e,t,n,r,s){let i=R(e,o=>o.policy==="exact-unit"&&o.relativePath===t&&o.startLine<=n&&o.endLine>=r&&s.every((a,u)=>o.lineHashes[n-o.startLine+u]===a));return i?{ordinal:i.ordinal,command:i.command}:void 0}function gt(e,t){return!e||!t?e===t:e.ordinal===t.ordinal&&e.command===t.command}function G(e){if(e.state!==void 0)return e.state;if(!e.sessionIdentity||!e.generationIdentity)return e.state=null,null;try{let t=bt();st(t,{recursive:!0,mode:448});let n=V("sha256").update(e.projectRoot).update("\0").update(e.generationIdentity).update("\0").update(e.sessionIdentity).digest("hex"),r=ye(t,`${n}.json`),s=P(`${r}.lock`,{kind:"source-emission-session",detail:{session:n.slice(0,12)}});if(s.kind!=="acquired")return e.state=null,null;let i;try{i=rt(r)?ht(JSON.parse(b(r,"source emission session ledger")),{projectRoot:e.projectRoot,generationIdentity:e.generationIdentity,sessionIdentity:e.sessionIdentity}):lt(e)}catch{return s.lock.release(),e.state=null,null}return e.state={ledgerPath:r,lock:s.lock,ledger:i},e.state}catch{return e.state=null,null}}function lt(e){return{version:q,projectRoot:e.projectRoot,generationIdentity:e.generationIdentity,sessionIdentity:e.sessionIdentity,nextOrdinal:1,updatedAt:new Date().toISOString(),ranges:[],evidence:[]}}function ht(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Invalid source emission ledger.");let n=e;if(e.version===1&&n.projectRoot===t.projectRoot&&n.generationIdentity===t.generationIdentity&&n.sessionIdentity===t.sessionIdentity&&Number.isSafeInteger(n.nextOrdinal)&&(n.nextOrdinal??0)>0)return{version:q,projectRoot:t.projectRoot,generationIdentity:t.generationIdentity,sessionIdentity:t.sessionIdentity,nextOrdinal:n.nextOrdinal,updatedAt:typeof n.updatedAt=="string"?n.updatedAt:new Date().toISOString(),ranges:[],evidence:[]};if(n.version!==q||n.projectRoot!==t.projectRoot||n.generationIdentity!==t.generationIdentity||n.sessionIdentity!==t.sessionIdentity||!Number.isSafeInteger(n.nextOrdinal)||(n.nextOrdinal??0)<=0||!Array.isArray(n.ranges)||!n.ranges.every(mt)||!Array.isArray(n.evidence)||!n.evidence.every(ft))throw new Error("Invalid source emission ledger.");return n}function mt(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e;return typeof t.relativePath=="string"&&t.relativePath!==""&&Number.isSafeInteger(t.startLine)&&(t.startLine??-1)>=0&&Number.isSafeInteger(t.endLine)&&(t.endLine??-1)>=(t.startLine??0)&&Number.isSafeInteger(t.ordinal)&&(t.ordinal??0)>0&&typeof t.command=="string"&&t.command!==""&&(t.policy==="exact-unit"||t.policy==="preview")&&Array.isArray(t.lineHashes)&&t.lineHashes.length===(t.endLine??0)-(t.startLine??0)+1&&t.lineHashes.every(be)&&(t.ownerSymbol===void 0||typeof t.ownerSymbol=="string")}function ft(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e;return(t.kind==="unit"||t.kind==="edge")&&typeof t.identity=="string"&&t.identity!==""&&typeof t.contentHash=="string"&&be(t.contentHash)&&typeof t.receiptId=="string"&&/^ev-[0-9a-f]{12}$/u.test(t.receiptId)&&Number.isSafeInteger(t.ordinal)&&(t.ordinal??0)>0&&typeof t.command=="string"&&t.command!==""&&(t.label===void 0||typeof t.label=="string")}function yt(e){let t=[...e].sort((r,s)=>r.relativePath.localeCompare(s.relativePath)||r.startLine-s.startLine||r.endLine-s.endLine),n=[];for(let r of t){let s=n[n.length-1];if(s&&s.relativePath===r.relativePath&&s.ownerSymbol===r.ownerSymbol&&s.policy===r.policy&&r.startLine<=s.endLine+1&&St(s,r)){let i=r.startLine-s.startLine;for(let o=0;o<r.lineHashes.length;o+=1)s.lineHashes[i+o]??=r.lineHashes[o];s.endLine=Math.max(s.endLine,r.endLine)}else n.push({...r,lineHashes:[...r.lineHashes]})}return n}function St(e,t){let n=Math.max(e.startLine,t.startLine),r=Math.min(e.endLine,t.endLine);for(let s=n;s<=r;s+=1)if(e.lineHashes[s-e.startLine]!==t.lineHashes[s-t.startLine])return!1;return!0}function vt(e){let t=new Set,n=[];for(let r of e){let s=`${r.kind}\0${r.identity}\0${r.contentHash}`;t.has(s)||(t.add(s),n.push(r))}return n}function Ot(e){let t=new Map;for(let r of e){let s=t.get(r.relativePath)??[];s.push(r),t.set(r.relativePath,s)}let n=0;for(let r of t.values()){r.sort((o,a)=>o.startLine-a.startLine||o.endLine-a.endLine);let s=-1,i=-1;for(let o of r)s<0?(s=o.startLine,i=o.endLine):o.startLine<=i+1?i=Math.max(i,o.endLine):(n+=i-s+1,s=o.startLine,i=o.endLine);s>=0&&(n+=i-s+1)}return n}function bt(){let e=process.env[me];if(!e)return ye(it(),`codebaseiq-source-sessions-${process.getuid?.()??"user"}`);if(!ot(e))throw new Error(`${me} must be an absolute path.`);return Se(e)}function It(){let e=process.env[at]?.trim();if(e&&!(e.length>ut||!/^[A-Za-z0-9._:-]+$/.test(e)))return`explicit:${e}`}function wt(e,t,n){return`ev-${V("sha256").update(e).update("\0").update(t).update("\0").update(n).digest("hex").slice(0,12)}`}function fe(e){let t=e.replace(/[\r\n\t]+/gu," ").replace(/\s+/gu," ").trim();return t.length<=160?t:`${t.slice(0,157)}...`}function Oe(e){return V("sha256").update(e).digest("hex")}function Et(e,t){return e.length===t.length&&e.every((n,r)=>n===t[r])}function R(e,t){for(let n=e.length-1;n>=0;n-=1){let r=e[n];if(t(r))return r}}function be(e){return typeof e=="string"&&/^[0-9a-f]{64}$/u.test(e)}import{createHash as Ct}from"crypto";import{existsSync as Q,mkdirSync as Pt,rmSync as xt}from"fs";import{tmpdir as At}from"os";import{isAbsolute as Nt,join as we,resolve as T}from"path";var Ee=1,Lt="CODEBASEIQ_SESSION",Ie="CODEBASEIQ_SESSION_DIR",_t=128,Ce=8,Pe=32768,k=new Map;function tr(e,t,n=!0){if(!n)return;let r=$();if(!r)return;let s=Y(e),i=t.map(a=>a.trim()).filter(a=>a.startsWith("codebaseiq system-map ")&&a.length<=Pe).slice(0,Ce),o=xe(s,r);i.length===0?k.delete(o):k.set(o,i)}function J(e,t,n,r=!0,s){if(!r||e!=="anchors"&&e!=="system-map")return;let i=$();if(!i)return;let o=Y(t),a=K(o,i);if(e==="system-map"){n?xt(a,{force:!0}):Q(a)&&s&&F(a,()=>{let u=Z(a,o,i);u&&v(a,{...u,pendingMapContinuation:s,mapExecution:void 0,updatedAt:new Date().toISOString()},{spacing:2,trailingNewline:!0})});return}F(a,()=>{let u=Rt(o,i),d={version:Ee,projectRoot:o,sessionIdentity:i,mapRequired:!0,...u.length>0?{recommendedMapCommands:u}:{},updatedAt:new Date().toISOString()};v(a,d,{spacing:2,trailingNewline:!0})})}function X(e,t=!0){if(!t)return;let n=$();if(!n)return;let r=Y(e),s=K(r,n);Q(s)&&F(s,()=>{let i=Z(s,r,n);if(i){if(i.pendingMapContinuation)throw new Error(["MAP TRANSPORT INCOMPLETE","The selected system map has already been computed. Restarting it would repeat the same repository work.",`Continue exactly: ${i.pendingMapContinuation}`].join(`
8
- `));if(i.mapExecution&&Tt(i.mapExecution.processId))throw new Error(["NAVIGATION MAP ALREADY RUNNING","A selected system map is already computing in this CODEBASEIQ_SESSION.","Poll the existing terminal execution. Do not launch a duplicate map or inspect in parallel."].join(`
9
- `));v(s,{...i,mapExecution:{processId:process.pid,startedAt:new Date().toISOString()},updatedAt:new Date().toISOString()},{spacing:2,trailingNewline:!0})}})}function nr(e,t,n=!0){if(!n)return;let r=$();if(!r)return;let s=K(T(e),r);if(!Q(s))return;let i=Z(s,T(e),r);if(!i?.mapRequired)return;let o=i.recommendedMapCommands?.length?["This refusal is a recoverable protocol step, not evidence that the requested code cannot be explored.","Run exactly one of the ranked map commands below, then finish every emitted continuation:",...i.recommendedMapCommands.map((a,u)=>` [${u+1}] ${a}`)]:[`Do not retry ${t}. Run one printed next-abstraction system-map command and finish every emitted continuation first.`];throw new Error(["NAVIGATION MAP REQUIRED","An anchors locator completed in this CODEBASEIQ_SESSION, but its selected system map has not reached transport completion.",`Do not retry ${t}.`,...o,"The map must complete before the agent can choose source detail; map and detail exploration cannot run concurrently."].join(`
10
- `))}function Z(e,t,n){try{let r=JSON.parse(b(e,"navigation session state"));return r.version===Ee&&r.projectRoot===t&&r.sessionIdentity===n&&r.mapRequired===!0&&(r.recommendedMapCommands===void 0||Array.isArray(r.recommendedMapCommands)&&r.recommendedMapCommands.length<=Ce&&r.recommendedMapCommands.every(s=>typeof s=="string"&&s.startsWith("codebaseiq system-map ")&&s.length<=Pe))&&(r.pendingMapContinuation===void 0||typeof r.pendingMapContinuation=="string")&&(r.mapExecution===void 0||typeof r.mapExecution=="object"&&r.mapExecution!==null&&Number.isSafeInteger(r.mapExecution.processId)&&typeof r.mapExecution.startedAt=="string")?r:null}catch{return null}}function Rt(e,t){let n=xe(e,t),r=k.get(n)??[];return k.delete(n),r}function xe(e,t){return`${e}\0${t}`}function Tt(e){try{return process.kill(e,0),!0}catch(t){return t.code==="EPERM"}}function K(e,t){let n=kt();Pt(n,{recursive:!0,mode:448});let r=Ct("sha256").update(e).update("\0").update(t).digest("hex");return we(n,`navigation-${r}.json`)}function kt(){let e=process.env[Ie];if(!e)return we(At(),`codebaseiq-source-sessions-${process.getuid?.()??"user"}`);if(!Nt(e))throw new Error(`${Ie} must be an absolute path.`);return T(e)}function Y(e){let t=process.env.CODEBASEIQ_PROJECT_ROOT?.trim();return T(t||e)}function $(){let e=process.env[Lt]?.trim();if(e&&!(e.length>_t||!/^[A-Za-z0-9._:-]+$/u.test(e)))return`explicit:${e}`}function F(e,t){let n=P(`${e}.lock`,{kind:"navigation-session",detail:{state:e.slice(-17,-5)}});if(n.kind!=="acquired")throw new Error("Navigation session state is busy. Retry the completed command.");try{t()}finally{n.lock.release()}}import{createHash as H,randomBytes as Mt}from"crypto";import{chmodSync as Ht,closeSync as te,fstatSync as Ne,lstatSync as Ut,mkdirSync as Bt,openSync as Te,readSync as jt,readdirSync as ke,renameSync as Dt,rmSync as $e,statSync as zt,writeSync as qt}from"fs";import{tmpdir as Vt}from"os";import{join as _}from"path";import{StringDecoder as Me}from"string_decoder";import{InvalidArgumentError as Le}from"commander";var $t=/^[A-Za-z0-9_@%+=:,./-]+$/u;function Ae(e,t={}){return t.omitSafeQuotes&&$t.test(e)?e:(t.platform??process.platform)==="win32"?`"${e.replaceAll("%","%%").replaceAll('"','\\"')}"`:`'${e.replaceAll("'",`'"'"'`)}'`}var Wt="codebaseiq-output-page",Gt=1,Ft="continue",M=32e3,x=256,A=1e5,U=4096,ne=32e6,Qt=64*1024*1024,Jt=256*1024*1024,Xt=32,re=32768,He=3600*1e3,Ue=3;function Be(){return _(Vt(),`codebaseiq-output-pages-${typeof process.getuid=="function"?process.getuid():"user"}`)}var ae=/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/u,je=/^[A-Za-z0-9_][A-Za-z0-9_-]{11}$/u,Zt=/^4\.([A-Za-z0-9_-]{22})\.([0-9a-z]{1,10})$/u,Kt=/^([A-Za-z0-9_][A-Za-z0-9_-]{11})(?:\.([0-9a-z]{1,10}))?$/u,De=1,Yt="quota.lock",en=2e3,tn=5,_e=1024*1024,nn=new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT)),ee,rn=Object.freeze({maxSnapshotBytes:Qt,maxAggregateBytes:Jt,maxSnapshotCount:Xt});var ze={writeStdout:e=>{process.stdout.write(e)},writeStderr:e=>{process.stderr.write(e)}};async function sn(e,t,n=ze){return ve({command:e.command,cwd:e.cwd,argv:e.argv,json:e.json,sessionEnabled:e.sourceSession,reemit:e.reemitSource},async()=>{try{await on(e,t,n)}finally{W(!1)}})}async function on(e,t,n){let r=e.pageSize??M,s=e.snapshotRoot??Be(),i=hn(e.snapshotLimits),o=e.maxOutputCharacters??ne;if(!Number.isSafeInteger(o)||o<=0)throw new Error("Output character safety limit must be a positive integer.");let a=Math.min(o,ne);if(qe(r),e.cursor!==void 0&&e.cursor.length>U)throw new Error(`Output cursor exceeds the ${U}-character limit. Run the command again without --output-cursor.`);if(e.json&&e.pageSize===void 0&&e.cursor===void 0){e.command==="system-map"&&X(e.cwd,e.sourceSession!==!1),await an(e,t,n);return}let u=Ze(e.argv),d=Ye(e.invocationPrefix),p=Xe(e.command,e.cwd,d,u),l=e.cursor===void 0?void 0:Cn(e.cursor,p);e.command==="system-map"&&!l&&X(e.cwd,e.sourceSession!==!1);let g=l?.snapshotId,c;if(l)try{c=dn(l,p,r,a,s,e.onSnapshotRead)}catch(S){let N=S instanceof Error?S.message:String(S);throw new Error(`${N} Restart with: ${Ke(d,u,r)}`,{cause:S})}else{let S=new ie(p,d,e.command,e.cwd,u,r,a,s,i,!e.json),N=un(j=>S.write(j)),ce=!1;try{await t(),ce=!0}finally{N(),ce||S.abort()}let C;try{C=S.complete()}catch(j){throw S.abort(),j}g=C.snapshotId,c={content:C.content,offset:0,pageIndex:0,pageCount:C.pageCount,totalCharacters:C.totalCharacters,outputHash:C.outputHash}}let m=c.offset+c.content.length,f=c.pageIndex+1>=c.pageCount,h=f?void 0:wn({invocationPrefix:d,nextPageIndex:c.pageIndex+1,snapshotId:On(g)});if(J(e.command,e.cwd,f,e.sourceSession!==!1,h?.command),c.offset===0&&f&&e.cursor===void 0){n.writeStdout(c.content),W(!0),g&&E(g,s);return}let y={kind:Wt,schemaVersion:Gt,producer:{name:"codebaseiq",version:e.producerVersion},command:e.command,contentType:e.json?"application/json":"text/plain",agentInstruction:h?"INCOMPLETE EVIDENCE: do not draw conclusions or report completion from this partial page. Run page.continuation.command exactly, then repeat until page.complete is true.":"OUTPUT COMPLETE: all rendered characters have been retrieved. Evaluate the command result's own coverage separately.",page:h?{offset:c.offset,returnedCharacters:c.content.length,totalCharacters:c.totalCharacters,omittedCharacters:c.totalCharacters-c.content.length,remainingCharacters:c.totalCharacters-m,complete:!1,outputHash:c.outputHash,continuation:h}:{offset:c.offset,returnedCharacters:c.content.length,totalCharacters:c.totalCharacters,omittedCharacters:c.totalCharacters-c.content.length,remainingCharacters:c.totalCharacters-m,complete:!0,outputHash:c.outputHash},content:c.content};if(e.json){n.writeStdout(`${JSON.stringify(y)}
11
- `),f&&g&&E(g,s);return}n.writeStdout(_n(y)),f&&g&&E(g,s)}async function Or(e,t,n=Be(),r=ze){if(e.length>U)throw new Error(`Output cursor exceeds the ${U}-character limit.`);let s=Je(e);if(!s)throw new Error("Invalid output cursor. Run the original command again.");let i=We(s.snapshotId,n);await sn({command:i.command,producerVersion:t,invocationPrefix:i.invocationPrefix,argv:[...i.argv,"--output-page-size",String(i.pageSize),"--output-cursor",e],cwd:i.cwd,json:i.argv.some(o=>o==="--json"||o.startsWith("--json=")),sourceSession:!i.argv.some(o=>o==="--no-session"),pageSize:i.pageSize,cursor:e,snapshotRoot:n},()=>{throw new Error("Output continuation attempted to rerun the original command.")},r)}function br(e){if(!/^\d+$/u.test(e))throw new Le(`Output page size must be an integer from ${x} through ${A}.`);let t=Number(e);try{qe(t)}catch{throw new Le(`Output page size must be an integer from ${x} through ${A}.`)}return t}function qe(e){if(!Number.isSafeInteger(e)||e<x||e>A)throw new Error(`Output page size must be an integer from ${x} through ${A}.`)}async function an(e,t,n){let r=new se(M,e.maxOutputCharacters??ne),s=process.stdout.write,i=!1,o=`${le(`codebaseiq: JSON output exceeds ${M} characters and may be truncated by the client. Do not use possibly partial client output as evidence. Read every page with: ${Ke(Ye(e.invocationPrefix),Ze(e.argv),M)}`)}
12
- `;process.stdout.write=((a,u,d)=>{let p=r.push(a,u);return p!==void 0&&(i||(i=!0,n.writeStderr(o)),s.call(process.stdout,p)),Ve(u,d),!0});try{await t();let a=r.finish();a.crossedPageBoundary&&!i&&(i=!0,n.writeStderr(o)),a.bytes.length>0&&s.call(process.stdout,a.bytes),i&&n.writeStderr(o),J(e.command,e.cwd,!0,e.sourceSession!==!1)}finally{process.stdout.write=s}}function un(e){let t=process.stdout.write;return process.stdout.write=((n,r,s)=>{let i=cn(n,r);return e(i),Ve(r,s),!0}),()=>{process.stdout.write=t}}function cn(e,t){return typeof e=="string"?Buffer.from(e,typeof t=="string"?t:"utf8"):Buffer.from(e)}function Ve(e,t){let n=typeof e=="function"?e:t;typeof n=="function"&&n()}var se=class{constructor(t,n){this.limit=t;this.maxOutputCharacters=n}limit;maxOutputCharacters;decoder=new Me("utf8");chunks=[];overflowed=!1;totalCharacters=0;push(t,n){let r=typeof t=="string"?Buffer.from(t,typeof n=="string"?n:"utf8"):Buffer.from(t);if(this.addCharacters(this.decoder.write(r)),this.overflowed)return r;if(this.chunks.push(r),this.totalCharacters<=this.limit)return;this.overflowed=!0;let s=Buffer.concat(this.chunks);return this.chunks.length=0,s}finish(){this.addCharacters(this.decoder.end());let t=this.totalCharacters>this.limit,n=Buffer.concat(this.chunks);return this.chunks.length=0,{bytes:n,crossedPageBoundary:t}}addCharacters(t){if(this.totalCharacters+=t.length,!Number.isSafeInteger(this.totalCharacters)||this.totalCharacters>this.maxOutputCharacters)throw new Error(`Command output exceeds the ${this.maxOutputCharacters}-character safety limit. Narrow the query before retrying.`)}},ie=class{constructor(t,n,r,s,i,o,a,u,d,p){this.invocationHash=t;this.invocationPrefix=n;this.command=r;this.cwd=s;this.argv=i;this.pageSize=o;this.maxOutputCharacters=a;this.snapshotRoot=u;this.limits=d;this.preferLineBoundaries=p;ue(u);do this.snapshotId=Mt(9).toString("base64url");while(this.snapshotId.startsWith("-"));this.temporaryPath=O(u,this.snapshotId,"tmp")}invocationHash;invocationPrefix;command;cwd;argv;pageSize;maxOutputCharacters;snapshotRoot;limits;preferLineBoundaries;snapshotId;temporaryPath;decoder=new Me("utf8");hash=H("sha256");pages=[];descriptor=null;pending="";firstPageContent="";totalCharacters=0;pageCharacterOffset=0;byteLength=0;reservedBytes=0;opened=!1;finished=!1;write(t){if(this.finished)throw new Error("Output snapshot writer is closed.");this.appendDecoded(this.decoder.write(t))}complete(){if(this.finished)throw new Error("Output snapshot writer is closed.");if(this.appendDecoded(this.decoder.end()),this.finished=!0,!this.opened){let s=this.pending,i=Buffer.from(s);return this.assertWithinByteLimit(i.length),this.hash.update(i),this.pending="",{content:s,totalCharacters:this.totalCharacters,outputHash:this.hash.digest("hex"),pageCount:1}}if((this.pending.length>0||this.pages.length===0)&&(this.flushPage(this.pending),this.pending=""),this.descriptor===null)throw new Error("Output snapshot writer is not open.");te(this.descriptor),this.descriptor=null;let t=this.hash.digest("hex"),n=O(this.snapshotRoot,this.snapshotId,"output"),r=O(this.snapshotRoot,this.snapshotId,"json");try{Dt(this.temporaryPath,n);let s={version:Ue,snapshotId:this.snapshotId,invocationHash:this.invocationHash,invocationPrefix:[...this.invocationPrefix],command:this.command,cwd:this.cwd,argv:[...this.argv],outputHash:t,pageSize:this.pageSize,pages:this.pages,totalCharacters:this.totalCharacters,byteLength:this.byteLength,createdAtMs:Date.now()};return v(r,s),Re(this.snapshotRoot,this.snapshotId,this.byteLength,"complete",this.limits),this.reservedBytes=this.byteLength,{content:this.firstPageContent,totalCharacters:this.totalCharacters,outputHash:t,pageCount:this.pages.length,snapshotId:this.snapshotId}}catch(s){throw E(this.snapshotId,this.snapshotRoot),s}}abort(){this.descriptor!==null&&(te(this.descriptor),this.descriptor=null),this.finished=!0,E(this.snapshotId,this.snapshotRoot)}appendDecoded(t){if(t.length===0)return;let n=this.totalCharacters+t.length;if(!Number.isSafeInteger(n)||n>this.maxOutputCharacters)throw new Error(`Command output exceeds the ${this.maxOutputCharacters}-character safety limit. Narrow the query before retrying.`);for(this.totalCharacters=n,this.pending+=t,this.assertWithinByteLimit(this.byteLength+Buffer.byteLength(this.pending));this.pending.length>this.pageSize;){this.open();let r=In(this.pending,this.pageSize,this.preferLineBoundaries),s=this.pending.slice(0,r);this.pending=this.pending.slice(r),this.flushPage(s)}}open(){if(!this.opened){mn(this.snapshotRoot,this.snapshotId,0,this.limits);try{this.descriptor=Te(this.temporaryPath,"wx",384),this.opened=!0}catch(t){throw fn(this.snapshotRoot,this.snapshotId),t}}}flushPage(t){if(this.descriptor===null)throw new Error("Output snapshot writer is not open.");if(this.pages.length>=re)throw new Error(`Command output requires more than ${re} snapshot pages. Retry with a larger --output-page-size or narrow the query.`);let n=Buffer.from(t),r=this.byteLength+n.length;if(this.assertWithinByteLimit(r),r>this.reservedBytes){let o=Math.min(this.limits.maxSnapshotBytes,Math.ceil(r/_e)*_e);Re(this.snapshotRoot,this.snapshotId,o,"active",this.limits),this.reservedBytes=o}let s=0;for(;s<n.length;){let o=qt(this.descriptor,n,s,n.length-s);if(o<=0)throw new Error("Output snapshot write made no progress.");s+=o}let i={characterOffset:this.pageCharacterOffset,characterLength:t.length,byteOffset:this.byteLength,byteLength:n.length,hash:H("sha256").update(n).digest("hex")};this.pages.length===0&&(this.firstPageContent=t),this.pages.push(i),this.hash.update(n),this.pageCharacterOffset+=t.length,this.byteLength=r}assertWithinByteLimit(t){if(!Number.isSafeInteger(t)||t>this.limits.maxSnapshotBytes)throw new Error(`Command output exceeds the ${this.limits.maxSnapshotBytes}-byte snapshot limit. Narrow the query before retrying.`)}};function dn(e,t,n,r,s,i){ue(s);let o=We(e.snapshotId,s);if(o.invocationHash!==t)throw new Error("This output cursor belongs to a different command, working directory, or argument set. Run again without --output-cursor.");if(o.snapshotId!==e.snapshotId||e.version===3&&(o.invocationHash!==e.invocationHash||o.outputHash!==e.outputHash))throw new Error("Output snapshot identity does not match this cursor.");if(o.pageSize!==n||e.version===3&&e.pageSize!==n)throw new Error(`Output page size changed after this cursor was issued; use ${o.pageSize}.`);let a=o.pages[e.pageIndex];if(!a)throw new Error("Output cursor points past the current result.");if(o.totalCharacters>r)throw new Error(`Output snapshot exceeds the ${r}-character safety limit.`);if(Date.now()-o.createdAtMs>He)throw E(e.snapshotId,s),new Error("Output snapshot expired before all pages were read.");let u=O(s,e.snapshotId,"output"),d=Te(u,"r");try{let p=Ne(d);if(!p.isFile()||p.size!==o.byteLength)throw new Error("Output snapshot size or type changed.");let l=Buffer.allocUnsafe(a.byteLength),g=0;for(;g<l.length;){let f=jt(d,l,g,l.length-g,a.byteOffset+g);if(f===0)break;g+=f,i?.(f)}let c=Ne(d);if(c.dev!==p.dev||c.ino!==p.ino||c.size!==p.size||g!==a.byteLength)throw new Error("Output snapshot changed while it was being read.");if(H("sha256").update(l).digest("hex")!==a.hash)throw new Error("Output snapshot page no longer matches its metadata.");let m=l.toString("utf8");if(m.length!==a.characterLength)throw new Error("Output snapshot page character count changed.");return{content:m,offset:a.characterOffset,pageIndex:e.pageIndex,pageCount:o.pages.length,totalCharacters:o.totalCharacters,outputHash:o.outputHash}}catch(p){throw E(e.snapshotId,s),p}finally{te(d)}}function We(e,t){if(!w(e))throw new Error("Output snapshot identifier is invalid.");let n;try{n=JSON.parse(b(O(t,e,"json"),"output snapshot metadata"))}catch(r){throw new Error("Output snapshot is unavailable.",{cause:r})}if(!pn(n))throw new Error("Output snapshot metadata is invalid.");return n}function pn(e){if(!e||typeof e!="object")return!1;let t=e;return t.version===Ue&&typeof t.snapshotId=="string"&&w(t.snapshotId)&&L(t.invocationHash)&&et(t.invocationPrefix)&&typeof t.command=="string"&&t.command.length>0&&t.command.length<=256&&typeof t.cwd=="string"&&t.cwd.length>0&&t.cwd.length<=8192&&Ln(t.argv)&&Xe(t.command,t.cwd,t.invocationPrefix,t.argv)===t.invocationHash&&L(t.outputHash)&&Number.isSafeInteger(t.pageSize)&&(t.pageSize??0)>=x&&(t.pageSize??0)<=A&&Array.isArray(t.pages)&&t.pages.length>1&&t.pages.length<=re&&t.pages.every(gn)&&ln(t.pages)&&Number.isSafeInteger(t.totalCharacters)&&(t.totalCharacters??-1)>=0&&t.pages.reduce((n,r)=>n+r.characterLength,0)===t.totalCharacters&&Number.isSafeInteger(t.byteLength)&&(t.byteLength??-1)>=0&&t.pages.reduce((n,r)=>n+r.byteLength,0)===t.byteLength&&Number.isSafeInteger(t.createdAtMs)&&(t.createdAtMs??-1)>=0}function gn(e){if(!e||typeof e!="object")return!1;let t=e;return Number.isSafeInteger(t.characterOffset)&&(t.characterOffset??-1)>=0&&Number.isSafeInteger(t.characterLength)&&(t.characterLength??0)>0&&Number.isSafeInteger(t.byteOffset)&&(t.byteOffset??-1)>=0&&Number.isSafeInteger(t.byteLength)&&(t.byteLength??0)>0&&L(t.hash)}function ln(e){let t=0,n=0;for(let r of e){if(r.characterOffset!==t||r.byteOffset!==n)return!1;t+=r.characterLength,n+=r.byteLength}return!0}function ue(e){Bt(e,{recursive:!0,mode:448});let t=Ut(e);if(!t.isDirectory()||t.isSymbolicLink())throw new Error(`Output snapshot root is not a private directory: ${e}`);if(typeof process.getuid=="function"&&t.uid!==process.getuid())throw new Error(`Output snapshot root is not owned by the current user: ${e}`);process.platform!=="win32"&&Ht(e,448)}function hn(e){let t={...rn,...e};for(let[n,r]of Object.entries(t))if(!Number.isSafeInteger(r)||r<=0)throw new Error(`Output snapshot ${n} must be a positive integer.`);if(t.maxSnapshotBytes>t.maxAggregateBytes)throw new Error("Output snapshot maxSnapshotBytes cannot exceed maxAggregateBytes.");return t}function mn(e,t,n,r){B(e,()=>{Sn(e),Ge(e,t,n,"active",r)})}function Re(e,t,n,r,s){if(!Number.isSafeInteger(n)||n<0||n>s.maxSnapshotBytes)throw new Error(`Command output exceeds the ${s.maxSnapshotBytes}-byte snapshot limit.`);B(e,()=>{Ge(e,t,n,r,s)})}function Ge(e,t,n,r,s){if(!Number.isSafeInteger(n)||n<0||n>s.maxSnapshotBytes)throw new Error(`Command output exceeds the ${s.maxSnapshotBytes}-byte snapshot limit.`);let i=yn(e),o=i.find(l=>l.snapshotId===t),a=i.reduce((l,g)=>l+g.reservedBytes,0)-(o?.reservedBytes??0)+n,u=i.length+(o?0:1);if(u>s.maxSnapshotCount||a>s.maxAggregateBytes)throw new Error(`Output snapshot capacity is full (${u}/${s.maxSnapshotCount} snapshots, ${a}/${s.maxAggregateBytes} bytes). Narrow the query or finish an existing pagination sequence before retrying.`);let d=Date.now(),p={version:De,snapshotId:t,pid:process.pid,...oe()?{processIdentity:oe()}:{},reservedBytes:n,state:r,createdAtMs:o?.createdAtMs??d,updatedAtMs:d};v(O(e,t,"reserve"),p)}function fn(e,t){B(e,()=>{$e(O(e,t,"reserve"),{force:!0})})}function yn(e){let t=[];for(let n of ke(e,{withFileTypes:!0})){if(!n.isFile()||!n.name.endsWith(".reserve"))continue;let r=n.name.slice(0,-8);if(w(r))try{let s=JSON.parse(b(_(e,n.name),"output snapshot reservation"));if(!Fe(s)||s.snapshotId!==r)throw new Error("reservation identity is invalid");t.push(s)}catch(s){throw new Error(`Output snapshot reservation ${n.name} is invalid; retry after its owning process or snapshot expires.`,{cause:s})}}return t}function Fe(e){if(!e||typeof e!="object")return!1;let t=e;return t.version===De&&typeof t.snapshotId=="string"&&w(t.snapshotId)&&Number.isSafeInteger(t.pid)&&(t.pid??0)>0&&(t.processIdentity===void 0||pe(t.processIdentity)!==null&&t.processIdentity.pid===t.pid)&&Number.isSafeInteger(t.reservedBytes)&&(t.reservedBytes??-1)>=0&&(t.state==="active"||t.state==="complete")&&Number.isSafeInteger(t.createdAtMs)&&Number.isSafeInteger(t.updatedAtMs)}function Sn(e){let t=Date.now();for(let n of ke(e,{withFileTypes:!0})){if(!n.isFile()||!n.name.endsWith(".reserve"))continue;let r=n.name.slice(0,-8);if(!w(r))continue;let s=null;try{let u=JSON.parse(b(_(e,n.name),"output snapshot reservation"));s=Fe(u)?u:null}catch{s=null}let i=vn(O(e,r,"json")),o=s?.state==="active"&&de(s.pid)&&(s.processIdentity===void 0||(()=>{let u=D(s.pid);return u!==null&&ge(s.processIdentity,u)})()),a=s?t-s.updatedAtMs>He:!1;o||i&&!a||!i&&s&&!a&&s.state==="complete"||Qe(r,e)}}function vn(e){try{return zt(e),!0}catch{return!1}}function B(e,t){ue(e);let n=_(e,Yt),r=Date.now()+en;for(;;){let s=P(n,{kind:"output-snapshot-quota",processIdentity:oe()});if(s.kind==="acquired")try{return t()}finally{s.lock.release()}if(Date.now()>=r)throw new Error("Output snapshot quota is busy. Retry the command.");Atomics.wait(nn,0,0,tn)}}function oe(){return ee===void 0&&(ee=D(process.pid)),ee}function E(e,t){w(e)&&B(t,()=>Qe(e,t))}function Qe(e,t){for(let n of["json","output","tmp","reserve"])$e(O(t,e,n),{force:!0})}function O(e,t,n){if(!w(t))throw new Error("Output snapshot identifier is invalid.");return _(e,`${t}.${n}`)}function On(e){if(!e)throw new Error("Incomplete output did not create a resumable snapshot.");return e}function bn(e){return e>=55296&&e<=56319}function In(e,t,n){if(n){let r=e.lastIndexOf(`
13
- `,t-1);if(r>=0)return r+1}return bn(e.charCodeAt(t-1))?t-1:t}function wn(e){let t=En({pageIndex:e.nextPageIndex,snapshotId:e.snapshotId});return{cursor:t,command:Nn(e.invocationPrefix,t)}}function En(e){return je.test(e.snapshotId)?e.pageIndex===1?e.snapshotId:`${e.snapshotId}.${e.pageIndex.toString(36)}`:`4.${xn(e.snapshotId)}.${e.pageIndex.toString(36)}`}function Cn(e,t){let n=Je(e);if(!n)throw new Error("Invalid output cursor. Run the command again without --output-cursor.");if(n.version===3&&n.invocationHash!==t)throw new Error("This output cursor belongs to a different command, working directory, or argument set. Run again without --output-cursor.");return n}function Je(e){let t=Kt.exec(e);if(t){let r=t[2]??"1",s=Number.parseInt(r,36);return Number.isSafeInteger(s)&&s>=1&&s.toString(36)===r?{version:4,pageIndex:s,snapshotId:t[1]}:null}let n=Zt.exec(e);if(n){let r=An(n[1]),s=Number.parseInt(n[2],36);return r&&Number.isSafeInteger(s)&&s>=1&&s.toString(36)===n[2]?{version:4,pageIndex:s,snapshotId:r}:null}try{let r=JSON.parse(Buffer.from(e,"base64url").toString("utf8"));return Pn(r)?r:null}catch{return null}}function Pn(e){if(!e||typeof e!="object")return!1;let t=e;return t.version===3&&L(t.invocationHash)&&Number.isSafeInteger(t.pageIndex)&&(t.pageIndex??-1)>=1&&Number.isSafeInteger(t.pageSize)&&(t.pageSize??0)>=x&&(t.pageSize??0)<=A&&L(t.outputHash)&&typeof t.snapshotId=="string"&&w(t.snapshotId)}function xn(e){if(!ae.test(e))throw new Error("Output snapshot identifier is invalid.");return Buffer.from(e.replaceAll("-",""),"hex").toString("base64url")}function An(e){let t=Buffer.from(e,"base64url");if(t.length!==16)return null;let n=t.toString("hex"),r=`${n.slice(0,8)}-${n.slice(8,12)}-${n.slice(12,16)}-${n.slice(16,20)}-${n.slice(20)}`;return ae.test(r)?r:null}function w(e){return typeof e=="string"&&(je.test(e)||ae.test(e))}function L(e){return typeof e=="string"&&/^[a-f0-9]{64}$/u.test(e)}function Xe(e,t,n,r){return H("sha256").update(JSON.stringify({command:e,cwd:t,invocationPrefix:n,argv:r})).digest("hex")}function Ze(e){let t=[];for(let n=0;n<e.length;n+=1){let r=e[n];if(r==="--output-page-size"||r==="--output-cursor"){n+=1;continue}r.startsWith("--output-page-size=")||r.startsWith("--output-cursor=")||t.push(r)}return t}function Ke(e,t,n){return tt([...e,...t,"--output-page-size",String(n)])}function Nn(e,t){return tt([...e,Ft,t])}function Ye(e){let t=e===void 0?["codebaseiq"]:[...e];if(!et(t))throw new Error("Output pagination invocation prefix must contain one to sixteen non-empty shell arguments.");return t}function et(e){return Array.isArray(e)&&e.length>0&&e.length<=16&&e.every(t=>typeof t=="string"&&t.length>0&&t.length<=2048&&!t.includes("\0")&&!t.includes("\r")&&!t.includes(`
14
- `))}function Ln(e){return Array.isArray(e)&&e.length>0&&e.length<=256&&e.every(t=>typeof t=="string"&&t.length<=8192&&!t.includes("\0")&&!t.includes("\r")&&!t.includes(`
15
- `))}function tt(e){return e.map(t=>Ae(t,{omitSafeQuotes:!0})).join(" ")}function _n(e){let t=e.page.continuation,n=Math.max(e.page.offset,e.page.offset+e.page.returnedCharacters-1),r=`[codebaseiq output page: characters ${e.page.offset}-${n} of ${e.page.totalCharacters}]
16
- `,s=t?`
17
- [Incomplete: ${e.page.remainingCharacters} characters remain. Continue exactly:
18
- ${t.command}]
19
- `:`
20
- [codebaseiq transport complete; evaluate command coverage separately]
21
- `;return`${r}${e.content}${s}`}export{Ae as a,Dn as b,zn as c,qn as d,Vn as e,Wn as f,Gn as g,tr as h,nr as i,Ft as j,M as k,sn as l,Or as m,br as n};
22
- //# sourceMappingURL=chunk-AQI4N64O.js.map
@@ -1,21 +0,0 @@
1
- import{eb as he,gb as z}from"./chunk-LONKINMJ.js";import{b as le}from"./chunk-ZZ3MWF33.js";import{j as ge,l as P,r as v}from"./chunk-D7DOB27N.js";import{c as de,d as pe,e as D}from"./chunk-6O3KXIDL.js";import{h as b}from"./chunk-UQYQBLJX.js";import{AsyncLocalStorage as nt}from"async_hooks";import{createHash as V}from"crypto";import{existsSync as rt,mkdirSync as st}from"fs";import{tmpdir as it}from"os";import{isAbsolute as ot,join as ye,resolve as Se}from"path";var q=2,at="CODEBASEIQ_SESSION",me="CODEBASEIQ_SESSION_DIR",ut=128,I=new nt;function ve(e,t){let n=e.sessionEnabled===!1||e.json?void 0:It(),r={enabled:n!==void 0,reemit:e.reemit===!0,command:e.command,projectRoot:Se(e.cwd),sessionIdentity:n,staged:[],stagedEvidence:[],finalized:!1};return I.run(r,t)}function Dn(e){let t=I.getStore();!t||t.finalized||(t.generationIdentity=e)}function zn(){return I.getStore()?.staged.length??0}function qn(e){let t=I.getStore();!t||e<0||e>t.staged.length||(t.staged.length=e)}function W(e){let t=I.getStore();if(!t||t.finalized)return;t.finalized=!0;let n=t.state;if(!n){t.staged.length=0,t.stagedEvidence.length=0;return}try{if(e&&(t.staged.length>0||t.stagedEvidence.length>0)){let r=n.ledger.nextOrdinal,s=yt(t.staged).map(o=>({...o,ordinal:r,command:t.command})),i=vt(t.stagedEvidence).map(o=>({...o,ordinal:r,command:t.command}));n.ledger.ranges.push(...s),n.ledger.evidence.push(...i),n.ledger.nextOrdinal+=1,n.ledger.updatedAt=new Date().toISOString(),v(n.ledgerPath,n.ledger,{spacing:2,trailingNewline:!0})}}catch{}finally{n.lock.release(),t.state=null,t.staged.length=0,t.stagedEvidence.length=0}}function Vn(e){let t=e.source.split(`
2
- `);if(t.length===0)return"";let n=ct(e.relativePath,e.startLine,t,e.ownerSymbol,e.sessionPolicy??"exact-unit"),r=e.indent??" ",s=e.sourceIndent??" ",i=e.focusLines??new Set;return n.map(o=>{let a=z(e.relativePath,o.startLine,o.endLine);if(o.kind==="covered"){let p=o.ordinal===null?"this command":`session #${o.ordinal} via ${o.command}`;return[`${r}${a} [source previously emitted: ${p}; not repeated]`,...e.afterHeader??[]].join(`
3
- `)}let u=e.headerSuffix??"",d=o.lines.map((p,l)=>{let g=o.startLine+l,c=e.showFocusMarker===!1?"":i.has(g)?">":" ",m=e.lineNumberWidth??5;return`${s}${c}${String(he(g)).padStart(m)} ${p}`});return[`${r}${a}${u}`,...e.blankAfterHeader?[""]:[],...e.afterHeader??[],...d].join(`
4
- `)}).join(`
5
- `)}function Wn(e){let t=I.getStore();if(!t||!t.enabled)return e.content;let n=G(t);if(!n)return e.content;let r=Oe(e.content),s=R(n.ledger.evidence,i=>i.kind===e.kind&&i.identity===e.identity&&i.contentHash===r);if(s&&!t.reemit){let i=e.label?`; ${fe(e.label)}`:"";return`${e.indent??""}[${e.kind} evidence previously emitted: receipt ${s.receiptId}; session #${s.ordinal} via ${s.command}${i}; not repeated]`}return t.stagedEvidence.push({kind:e.kind,identity:e.identity,contentHash:r,receiptId:wt(e.kind,e.identity,r),...e.label?{label:fe(e.label)}:{}}),e.content}function Gn(e=!1){let t=I.getStore();if(!t?.enabled)return{enabled:!1,reason:"No explicit CODEBASEIQ_SESSION is active; source packets render independently.",uniqueLines:0,evidenceItems:0,emissions:0,rows:[]};let n=G(t);if(!n)return{enabled:!1,reason:"The exploration-session ledger was unavailable or contended; evidence output is fail-open for this command.",uniqueLines:0,evidenceItems:0,emissions:0,rows:[]};if(e){n.ledger.ranges=[],n.ledger.evidence=[],n.ledger.nextOrdinal=1,n.ledger.updatedAt=new Date().toISOString();try{v(n.ledgerPath,n.ledger,{spacing:2,trailingNewline:!0})}catch{return{enabled:!1,reason:"The exploration-session ledger could not be reset; evidence output remains fail-open.",uniqueLines:0,evidenceItems:0,emissions:0,rows:[]}}}let r=new Map;for(let a of n.ledger.ranges){let u=r.get(a.ordinal)??[];u.push(a),r.set(a.ordinal,u)}let s=new Map;for(let a of n.ledger.evidence){let u=s.get(a.ordinal)??[];u.push(a),s.set(a.ordinal,u)}let o=[...new Set([...r.keys(),...s.keys()])].sort((a,u)=>a-u).map(a=>{let u=r.get(a)??[],d=s.get(a)??[],p=u[0]?.command??d[0]?.command??"unknown",l=u.length===0?null:(()=>{let m=u.slice(0,8).map(h=>z(h.relativePath,h.startLine,h.endLine)).join(", "),f=u.length>8?`, ... ${u.length-8} more range(s)`:"";return` #${a} ${p}: ${m}${f}`})();if(d.length===0)return l;let g=d.slice(0,8).map(m=>`${m.receiptId} ${m.kind}${m.label?` ${m.label}`:""}`).join(", "),c=d.length>8?`, ... ${d.length-8} more item(s)`:"";return l?`${l}
6
- evidence: ${g}${c}`:` #${a} ${p}: ${g}${c}`});return{enabled:!0,uniqueLines:Ot(n.ledger.ranges),evidenceItems:n.ledger.evidence.length,emissions:new Set([...r.keys(),...s.keys()]).size,rows:o}}function ct(e,t,n,r,s){let i=I.getStore(),o=t+n.length-1;if(!i)return[{kind:"source",startLine:t,endLine:o,lines:[...n]}];let u=(i.enabled?G(i):null)?.ledger.ranges??[],d=n.map(Oe),p=s==="exact-unit"&&!i.reemit?R(u,h=>h.policy==="exact-unit"&&h.relativePath===e&&h.startLine===t&&h.endLine===o&&h.ownerSymbol===r&&Et(h.lineHashes,d)):void 0;if(p)return[{kind:"covered",startLine:t,endLine:o,ordinal:p.ordinal,command:p.command}];let l=s==="exact-unit"&&!i.reemit?pt(u,e,t,o,d):void 0;if(l)return[{kind:"covered",startLine:t,endLine:o,ordinal:l.ordinal,command:l.command}];let g=n.map((h,y)=>dt(u,e,t+y,d[y]));if(!(s==="preview"&&!i.reemit&&g.every(h=>h!==void 0)))return i.staged.push({relativePath:e,startLine:t,endLine:o,ownerSymbol:r,policy:s,lineHashes:d}),[{kind:"source",startLine:t,endLine:o,lines:[...n]}];let m=[],f=0;for(;f<n.length;){let h=g[f],y=f;for(;y+1<n.length&&gt(h,g[y+1]);)y+=1;let S=t+f,N=t+y;m.push({kind:"covered",startLine:S,endLine:N,ordinal:h.ordinal,command:h.command}),f=y+1}return m}function dt(e,t,n,r){let s=R(e,i=>i.relativePath===t&&i.startLine<=n&&n<=i.endLine&&i.lineHashes[n-i.startLine]===r);if(s)return{ordinal:s.ordinal,command:s.command}}function pt(e,t,n,r,s){let i=R(e,o=>o.policy==="exact-unit"&&o.relativePath===t&&o.startLine<=n&&o.endLine>=r&&s.every((a,u)=>o.lineHashes[n-o.startLine+u]===a));return i?{ordinal:i.ordinal,command:i.command}:void 0}function gt(e,t){return!e||!t?e===t:e.ordinal===t.ordinal&&e.command===t.command}function G(e){if(e.state!==void 0)return e.state;if(!e.sessionIdentity||!e.generationIdentity)return e.state=null,null;try{let t=bt();st(t,{recursive:!0,mode:448});let n=V("sha256").update(e.projectRoot).update("\0").update(e.generationIdentity).update("\0").update(e.sessionIdentity).digest("hex"),r=ye(t,`${n}.json`),s=P(`${r}.lock`,{kind:"source-emission-session",detail:{session:n.slice(0,12)}});if(s.kind!=="acquired")return e.state=null,null;let i;try{i=rt(r)?ht(JSON.parse(b(r,"source emission session ledger")),{projectRoot:e.projectRoot,generationIdentity:e.generationIdentity,sessionIdentity:e.sessionIdentity}):lt(e)}catch{return s.lock.release(),e.state=null,null}return e.state={ledgerPath:r,lock:s.lock,ledger:i},e.state}catch{return e.state=null,null}}function lt(e){return{version:q,projectRoot:e.projectRoot,generationIdentity:e.generationIdentity,sessionIdentity:e.sessionIdentity,nextOrdinal:1,updatedAt:new Date().toISOString(),ranges:[],evidence:[]}}function ht(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Invalid source emission ledger.");let n=e;if(e.version===1&&n.projectRoot===t.projectRoot&&n.generationIdentity===t.generationIdentity&&n.sessionIdentity===t.sessionIdentity&&Number.isSafeInteger(n.nextOrdinal)&&(n.nextOrdinal??0)>0)return{version:q,projectRoot:t.projectRoot,generationIdentity:t.generationIdentity,sessionIdentity:t.sessionIdentity,nextOrdinal:n.nextOrdinal,updatedAt:typeof n.updatedAt=="string"?n.updatedAt:new Date().toISOString(),ranges:[],evidence:[]};if(n.version!==q||n.projectRoot!==t.projectRoot||n.generationIdentity!==t.generationIdentity||n.sessionIdentity!==t.sessionIdentity||!Number.isSafeInteger(n.nextOrdinal)||(n.nextOrdinal??0)<=0||!Array.isArray(n.ranges)||!n.ranges.every(mt)||!Array.isArray(n.evidence)||!n.evidence.every(ft))throw new Error("Invalid source emission ledger.");return n}function mt(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e;return typeof t.relativePath=="string"&&t.relativePath!==""&&Number.isSafeInteger(t.startLine)&&(t.startLine??-1)>=0&&Number.isSafeInteger(t.endLine)&&(t.endLine??-1)>=(t.startLine??0)&&Number.isSafeInteger(t.ordinal)&&(t.ordinal??0)>0&&typeof t.command=="string"&&t.command!==""&&(t.policy==="exact-unit"||t.policy==="preview")&&Array.isArray(t.lineHashes)&&t.lineHashes.length===(t.endLine??0)-(t.startLine??0)+1&&t.lineHashes.every(be)&&(t.ownerSymbol===void 0||typeof t.ownerSymbol=="string")}function ft(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=e;return(t.kind==="unit"||t.kind==="edge")&&typeof t.identity=="string"&&t.identity!==""&&typeof t.contentHash=="string"&&be(t.contentHash)&&typeof t.receiptId=="string"&&/^ev-[0-9a-f]{12}$/u.test(t.receiptId)&&Number.isSafeInteger(t.ordinal)&&(t.ordinal??0)>0&&typeof t.command=="string"&&t.command!==""&&(t.label===void 0||typeof t.label=="string")}function yt(e){let t=[...e].sort((r,s)=>r.relativePath.localeCompare(s.relativePath)||r.startLine-s.startLine||r.endLine-s.endLine),n=[];for(let r of t){let s=n[n.length-1];if(s&&s.relativePath===r.relativePath&&s.ownerSymbol===r.ownerSymbol&&s.policy===r.policy&&r.startLine<=s.endLine+1&&St(s,r)){let i=r.startLine-s.startLine;for(let o=0;o<r.lineHashes.length;o+=1)s.lineHashes[i+o]??=r.lineHashes[o];s.endLine=Math.max(s.endLine,r.endLine)}else n.push({...r,lineHashes:[...r.lineHashes]})}return n}function St(e,t){let n=Math.max(e.startLine,t.startLine),r=Math.min(e.endLine,t.endLine);for(let s=n;s<=r;s+=1)if(e.lineHashes[s-e.startLine]!==t.lineHashes[s-t.startLine])return!1;return!0}function vt(e){let t=new Set,n=[];for(let r of e){let s=`${r.kind}\0${r.identity}\0${r.contentHash}`;t.has(s)||(t.add(s),n.push(r))}return n}function Ot(e){let t=new Map;for(let r of e){let s=t.get(r.relativePath)??[];s.push(r),t.set(r.relativePath,s)}let n=0;for(let r of t.values()){r.sort((o,a)=>o.startLine-a.startLine||o.endLine-a.endLine);let s=-1,i=-1;for(let o of r)s<0?(s=o.startLine,i=o.endLine):o.startLine<=i+1?i=Math.max(i,o.endLine):(n+=i-s+1,s=o.startLine,i=o.endLine);s>=0&&(n+=i-s+1)}return n}function bt(){let e=process.env[me];if(!e)return ye(it(),`codebaseiq-source-sessions-${process.getuid?.()??"user"}`);if(!ot(e))throw new Error(`${me} must be an absolute path.`);return Se(e)}function It(){let e=process.env[at]?.trim();if(e&&!(e.length>ut||!/^[A-Za-z0-9._:-]+$/.test(e)))return`explicit:${e}`}function wt(e,t,n){return`ev-${V("sha256").update(e).update("\0").update(t).update("\0").update(n).digest("hex").slice(0,12)}`}function fe(e){let t=e.replace(/[\r\n\t]+/gu," ").replace(/\s+/gu," ").trim();return t.length<=160?t:`${t.slice(0,157)}...`}function Oe(e){return V("sha256").update(e).digest("hex")}function Et(e,t){return e.length===t.length&&e.every((n,r)=>n===t[r])}function R(e,t){for(let n=e.length-1;n>=0;n-=1){let r=e[n];if(t(r))return r}}function be(e){return typeof e=="string"&&/^[0-9a-f]{64}$/u.test(e)}import{createHash as Ct}from"crypto";import{existsSync as Q,mkdirSync as Pt,rmSync as xt}from"fs";import{tmpdir as At}from"os";import{isAbsolute as Nt,join as we,resolve as T}from"path";var Ee=1,Lt="CODEBASEIQ_SESSION",Ie="CODEBASEIQ_SESSION_DIR",_t=128,Ce=8,Pe=32768,k=new Map;function tr(e,t,n=!0){if(!n)return;let r=$();if(!r)return;let s=Y(e),i=t.map(a=>a.trim()).filter(a=>a.startsWith("codebaseiq system-map ")&&a.length<=Pe).slice(0,Ce),o=xe(s,r);i.length===0?k.delete(o):k.set(o,i)}function J(e,t,n,r=!0,s){if(!r||e!=="anchors"&&e!=="system-map")return;let i=$();if(!i)return;let o=Y(t),a=K(o,i);if(e==="system-map"){n?xt(a,{force:!0}):Q(a)&&s&&F(a,()=>{let u=Z(a,o,i);u&&v(a,{...u,pendingMapContinuation:s,mapExecution:void 0,updatedAt:new Date().toISOString()},{spacing:2,trailingNewline:!0})});return}F(a,()=>{let u=Rt(o,i),d={version:Ee,projectRoot:o,sessionIdentity:i,mapRequired:!0,...u.length>0?{recommendedMapCommands:u}:{},updatedAt:new Date().toISOString()};v(a,d,{spacing:2,trailingNewline:!0})})}function X(e,t=!0){if(!t)return;let n=$();if(!n)return;let r=Y(e),s=K(r,n);Q(s)&&F(s,()=>{let i=Z(s,r,n);if(i){if(i.pendingMapContinuation)throw new Error(["MAP TRANSPORT INCOMPLETE","The selected system map has already been computed. Restarting it would repeat the same repository work.",`Continue exactly: ${i.pendingMapContinuation}`].join(`
7
- `));if(i.mapExecution&&Tt(i.mapExecution.processId))throw new Error(["NAVIGATION MAP ALREADY RUNNING","A selected system map is already computing in this CODEBASEIQ_SESSION.","Poll the existing terminal execution. Do not launch a duplicate map or inspect in parallel."].join(`
8
- `));v(s,{...i,mapExecution:{processId:process.pid,startedAt:new Date().toISOString()},updatedAt:new Date().toISOString()},{spacing:2,trailingNewline:!0})}})}function nr(e,t,n=!0){if(!n)return;let r=$();if(!r)return;let s=K(T(e),r);if(!Q(s))return;let i=Z(s,T(e),r);if(!i?.mapRequired)return;let o=i.recommendedMapCommands?.length?["This refusal is a recoverable protocol step, not evidence that the requested code cannot be explored.","Run exactly one of the ranked map commands below, then finish every emitted continuation:",...i.recommendedMapCommands.map((a,u)=>` [${u+1}] ${a}`)]:[`Do not retry ${t}. Run one printed next-abstraction system-map command and finish every emitted continuation first.`];throw new Error(["NAVIGATION MAP REQUIRED","An anchors locator completed in this CODEBASEIQ_SESSION, but its selected system map has not reached transport completion.",`Do not retry ${t}.`,...o,"The map must complete before the agent can choose source detail; map and detail exploration cannot run concurrently."].join(`
9
- `))}function Z(e,t,n){try{let r=JSON.parse(b(e,"navigation session state"));return r.version===Ee&&r.projectRoot===t&&r.sessionIdentity===n&&r.mapRequired===!0&&(r.recommendedMapCommands===void 0||Array.isArray(r.recommendedMapCommands)&&r.recommendedMapCommands.length<=Ce&&r.recommendedMapCommands.every(s=>typeof s=="string"&&s.startsWith("codebaseiq system-map ")&&s.length<=Pe))&&(r.pendingMapContinuation===void 0||typeof r.pendingMapContinuation=="string")&&(r.mapExecution===void 0||typeof r.mapExecution=="object"&&r.mapExecution!==null&&Number.isSafeInteger(r.mapExecution.processId)&&typeof r.mapExecution.startedAt=="string")?r:null}catch{return null}}function Rt(e,t){let n=xe(e,t),r=k.get(n)??[];return k.delete(n),r}function xe(e,t){return`${e}\0${t}`}function Tt(e){try{return process.kill(e,0),!0}catch(t){return t.code==="EPERM"}}function K(e,t){let n=kt();Pt(n,{recursive:!0,mode:448});let r=Ct("sha256").update(e).update("\0").update(t).digest("hex");return we(n,`navigation-${r}.json`)}function kt(){let e=process.env[Ie];if(!e)return we(At(),`codebaseiq-source-sessions-${process.getuid?.()??"user"}`);if(!Nt(e))throw new Error(`${Ie} must be an absolute path.`);return T(e)}function Y(e){let t=process.env.CODEBASEIQ_PROJECT_ROOT?.trim();return T(t||e)}function $(){let e=process.env[Lt]?.trim();if(e&&!(e.length>_t||!/^[A-Za-z0-9._:-]+$/u.test(e)))return`explicit:${e}`}function F(e,t){let n=P(`${e}.lock`,{kind:"navigation-session",detail:{state:e.slice(-17,-5)}});if(n.kind!=="acquired")throw new Error("Navigation session state is busy. Retry the completed command.");try{t()}finally{n.lock.release()}}import{createHash as H,randomBytes as Mt}from"crypto";import{chmodSync as Ht,closeSync as te,fstatSync as Ne,lstatSync as Ut,mkdirSync as Bt,openSync as Te,readSync as jt,readdirSync as ke,renameSync as Dt,rmSync as $e,statSync as zt,writeSync as qt}from"fs";import{tmpdir as Vt}from"os";import{join as _}from"path";import{StringDecoder as Me}from"string_decoder";import{InvalidArgumentError as Le}from"commander";var $t=/^[A-Za-z0-9_@%+=:,./-]+$/u;function Ae(e,t={}){return t.omitSafeQuotes&&$t.test(e)?e:(t.platform??process.platform)==="win32"?`"${e.replaceAll("%","%%").replaceAll('"','\\"')}"`:`'${e.replaceAll("'",`'"'"'`)}'`}var Wt="codebaseiq-output-page",Gt=1,Ft="continue",M=32e3,x=256,A=1e5,U=4096,ne=32e6,Qt=64*1024*1024,Jt=256*1024*1024,Xt=32,re=32768,He=3600*1e3,Ue=3;function Be(){return _(Vt(),`codebaseiq-output-pages-${typeof process.getuid=="function"?process.getuid():"user"}`)}var ae=/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/u,je=/^[A-Za-z0-9_][A-Za-z0-9_-]{11}$/u,Zt=/^4\.([A-Za-z0-9_-]{22})\.([0-9a-z]{1,10})$/u,Kt=/^([A-Za-z0-9_][A-Za-z0-9_-]{11})(?:\.([0-9a-z]{1,10}))?$/u,De=1,Yt="quota.lock",en=2e3,tn=5,_e=1024*1024,nn=new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT)),ee,rn=Object.freeze({maxSnapshotBytes:Qt,maxAggregateBytes:Jt,maxSnapshotCount:Xt});var ze={writeStdout:e=>{process.stdout.write(e)},writeStderr:e=>{process.stderr.write(e)}};async function sn(e,t,n=ze){return ve({command:e.command,cwd:e.cwd,argv:e.argv,json:e.json,sessionEnabled:e.sourceSession,reemit:e.reemitSource},async()=>{try{await on(e,t,n)}finally{W(!1)}})}async function on(e,t,n){let r=e.pageSize??M,s=e.snapshotRoot??Be(),i=hn(e.snapshotLimits),o=e.maxOutputCharacters??ne;if(!Number.isSafeInteger(o)||o<=0)throw new Error("Output character safety limit must be a positive integer.");let a=Math.min(o,ne);if(qe(r),e.cursor!==void 0&&e.cursor.length>U)throw new Error(`Output cursor exceeds the ${U}-character limit. Run the command again without --output-cursor.`);if(e.json&&e.pageSize===void 0&&e.cursor===void 0){e.command==="system-map"&&X(e.cwd,e.sourceSession!==!1),await an(e,t,n);return}let u=Ze(e.argv),d=Ye(e.invocationPrefix),p=Xe(e.command,e.cwd,d,u),l=e.cursor===void 0?void 0:Cn(e.cursor,p);e.command==="system-map"&&!l&&X(e.cwd,e.sourceSession!==!1);let g=l?.snapshotId,c;if(l)try{c=dn(l,p,r,a,s,e.onSnapshotRead)}catch(S){let N=S instanceof Error?S.message:String(S);throw new Error(`${N} Restart with: ${Ke(d,u,r)}`,{cause:S})}else{let S=new ie(p,d,e.command,e.cwd,u,r,a,s,i,!e.json),N=un(j=>S.write(j)),ce=!1;try{await t(),ce=!0}finally{N(),ce||S.abort()}let C;try{C=S.complete()}catch(j){throw S.abort(),j}g=C.snapshotId,c={content:C.content,offset:0,pageIndex:0,pageCount:C.pageCount,totalCharacters:C.totalCharacters,outputHash:C.outputHash}}let m=c.offset+c.content.length,f=c.pageIndex+1>=c.pageCount,h=f?void 0:wn({invocationPrefix:d,nextPageIndex:c.pageIndex+1,snapshotId:On(g)});if(J(e.command,e.cwd,f,e.sourceSession!==!1,h?.command),c.offset===0&&f&&e.cursor===void 0){n.writeStdout(c.content),W(!0),g&&E(g,s);return}let y={kind:Wt,schemaVersion:Gt,producer:{name:"codebaseiq",version:e.producerVersion},command:e.command,contentType:e.json?"application/json":"text/plain",agentInstruction:h?"INCOMPLETE EVIDENCE: do not draw conclusions or report completion from this partial page. Run page.continuation.command exactly, then repeat until page.complete is true.":"OUTPUT COMPLETE: all rendered characters have been retrieved. Evaluate the command result's own coverage separately.",page:h?{offset:c.offset,returnedCharacters:c.content.length,totalCharacters:c.totalCharacters,omittedCharacters:c.totalCharacters-c.content.length,remainingCharacters:c.totalCharacters-m,complete:!1,outputHash:c.outputHash,continuation:h}:{offset:c.offset,returnedCharacters:c.content.length,totalCharacters:c.totalCharacters,omittedCharacters:c.totalCharacters-c.content.length,remainingCharacters:c.totalCharacters-m,complete:!0,outputHash:c.outputHash},content:c.content};if(e.json){n.writeStdout(`${JSON.stringify(y)}
10
- `),f&&g&&E(g,s);return}n.writeStdout(_n(y)),f&&g&&E(g,s)}async function Or(e,t,n=Be(),r=ze){if(e.length>U)throw new Error(`Output cursor exceeds the ${U}-character limit.`);let s=Je(e);if(!s)throw new Error("Invalid output cursor. Run the original command again.");let i=We(s.snapshotId,n);await sn({command:i.command,producerVersion:t,invocationPrefix:i.invocationPrefix,argv:[...i.argv,"--output-page-size",String(i.pageSize),"--output-cursor",e],cwd:i.cwd,json:i.argv.some(o=>o==="--json"||o.startsWith("--json=")),sourceSession:!i.argv.some(o=>o==="--no-session"),pageSize:i.pageSize,cursor:e,snapshotRoot:n},()=>{throw new Error("Output continuation attempted to rerun the original command.")},r)}function br(e){if(!/^\d+$/u.test(e))throw new Le(`Output page size must be an integer from ${x} through ${A}.`);let t=Number(e);try{qe(t)}catch{throw new Le(`Output page size must be an integer from ${x} through ${A}.`)}return t}function qe(e){if(!Number.isSafeInteger(e)||e<x||e>A)throw new Error(`Output page size must be an integer from ${x} through ${A}.`)}async function an(e,t,n){let r=new se(M,e.maxOutputCharacters??ne),s=process.stdout.write,i=!1,o=`${le(`codebaseiq: JSON output exceeds ${M} characters and may be truncated by the client. Do not use possibly partial client output as evidence. Read every page with: ${Ke(Ye(e.invocationPrefix),Ze(e.argv),M)}`)}
11
- `;process.stdout.write=((a,u,d)=>{let p=r.push(a,u);return p!==void 0&&(i||(i=!0,n.writeStderr(o)),s.call(process.stdout,p)),Ve(u,d),!0});try{await t();let a=r.finish();a.crossedPageBoundary&&!i&&(i=!0,n.writeStderr(o)),a.bytes.length>0&&s.call(process.stdout,a.bytes),i&&n.writeStderr(o),J(e.command,e.cwd,!0,e.sourceSession!==!1)}finally{process.stdout.write=s}}function un(e){let t=process.stdout.write;return process.stdout.write=((n,r,s)=>{let i=cn(n,r);return e(i),Ve(r,s),!0}),()=>{process.stdout.write=t}}function cn(e,t){return typeof e=="string"?Buffer.from(e,typeof t=="string"?t:"utf8"):Buffer.from(e)}function Ve(e,t){let n=typeof e=="function"?e:t;typeof n=="function"&&n()}var se=class{constructor(t,n){this.limit=t;this.maxOutputCharacters=n}limit;maxOutputCharacters;decoder=new Me("utf8");chunks=[];overflowed=!1;totalCharacters=0;push(t,n){let r=typeof t=="string"?Buffer.from(t,typeof n=="string"?n:"utf8"):Buffer.from(t);if(this.addCharacters(this.decoder.write(r)),this.overflowed)return r;if(this.chunks.push(r),this.totalCharacters<=this.limit)return;this.overflowed=!0;let s=Buffer.concat(this.chunks);return this.chunks.length=0,s}finish(){this.addCharacters(this.decoder.end());let t=this.totalCharacters>this.limit,n=Buffer.concat(this.chunks);return this.chunks.length=0,{bytes:n,crossedPageBoundary:t}}addCharacters(t){if(this.totalCharacters+=t.length,!Number.isSafeInteger(this.totalCharacters)||this.totalCharacters>this.maxOutputCharacters)throw new Error(`Command output exceeds the ${this.maxOutputCharacters}-character safety limit. Narrow the query before retrying.`)}},ie=class{constructor(t,n,r,s,i,o,a,u,d,p){this.invocationHash=t;this.invocationPrefix=n;this.command=r;this.cwd=s;this.argv=i;this.pageSize=o;this.maxOutputCharacters=a;this.snapshotRoot=u;this.limits=d;this.preferLineBoundaries=p;ue(u);do this.snapshotId=Mt(9).toString("base64url");while(this.snapshotId.startsWith("-"));this.temporaryPath=O(u,this.snapshotId,"tmp")}invocationHash;invocationPrefix;command;cwd;argv;pageSize;maxOutputCharacters;snapshotRoot;limits;preferLineBoundaries;snapshotId;temporaryPath;decoder=new Me("utf8");hash=H("sha256");pages=[];descriptor=null;pending="";firstPageContent="";totalCharacters=0;pageCharacterOffset=0;byteLength=0;reservedBytes=0;opened=!1;finished=!1;write(t){if(this.finished)throw new Error("Output snapshot writer is closed.");this.appendDecoded(this.decoder.write(t))}complete(){if(this.finished)throw new Error("Output snapshot writer is closed.");if(this.appendDecoded(this.decoder.end()),this.finished=!0,!this.opened){let s=this.pending,i=Buffer.from(s);return this.assertWithinByteLimit(i.length),this.hash.update(i),this.pending="",{content:s,totalCharacters:this.totalCharacters,outputHash:this.hash.digest("hex"),pageCount:1}}if((this.pending.length>0||this.pages.length===0)&&(this.flushPage(this.pending),this.pending=""),this.descriptor===null)throw new Error("Output snapshot writer is not open.");te(this.descriptor),this.descriptor=null;let t=this.hash.digest("hex"),n=O(this.snapshotRoot,this.snapshotId,"output"),r=O(this.snapshotRoot,this.snapshotId,"json");try{Dt(this.temporaryPath,n);let s={version:Ue,snapshotId:this.snapshotId,invocationHash:this.invocationHash,invocationPrefix:[...this.invocationPrefix],command:this.command,cwd:this.cwd,argv:[...this.argv],outputHash:t,pageSize:this.pageSize,pages:this.pages,totalCharacters:this.totalCharacters,byteLength:this.byteLength,createdAtMs:Date.now()};return v(r,s),Re(this.snapshotRoot,this.snapshotId,this.byteLength,"complete",this.limits),this.reservedBytes=this.byteLength,{content:this.firstPageContent,totalCharacters:this.totalCharacters,outputHash:t,pageCount:this.pages.length,snapshotId:this.snapshotId}}catch(s){throw E(this.snapshotId,this.snapshotRoot),s}}abort(){this.descriptor!==null&&(te(this.descriptor),this.descriptor=null),this.finished=!0,E(this.snapshotId,this.snapshotRoot)}appendDecoded(t){if(t.length===0)return;let n=this.totalCharacters+t.length;if(!Number.isSafeInteger(n)||n>this.maxOutputCharacters)throw new Error(`Command output exceeds the ${this.maxOutputCharacters}-character safety limit. Narrow the query before retrying.`);for(this.totalCharacters=n,this.pending+=t,this.assertWithinByteLimit(this.byteLength+Buffer.byteLength(this.pending));this.pending.length>this.pageSize;){this.open();let r=In(this.pending,this.pageSize,this.preferLineBoundaries),s=this.pending.slice(0,r);this.pending=this.pending.slice(r),this.flushPage(s)}}open(){if(!this.opened){mn(this.snapshotRoot,this.snapshotId,0,this.limits);try{this.descriptor=Te(this.temporaryPath,"wx",384),this.opened=!0}catch(t){throw fn(this.snapshotRoot,this.snapshotId),t}}}flushPage(t){if(this.descriptor===null)throw new Error("Output snapshot writer is not open.");if(this.pages.length>=re)throw new Error(`Command output requires more than ${re} snapshot pages. Retry with a larger --output-page-size or narrow the query.`);let n=Buffer.from(t),r=this.byteLength+n.length;if(this.assertWithinByteLimit(r),r>this.reservedBytes){let o=Math.min(this.limits.maxSnapshotBytes,Math.ceil(r/_e)*_e);Re(this.snapshotRoot,this.snapshotId,o,"active",this.limits),this.reservedBytes=o}let s=0;for(;s<n.length;){let o=qt(this.descriptor,n,s,n.length-s);if(o<=0)throw new Error("Output snapshot write made no progress.");s+=o}let i={characterOffset:this.pageCharacterOffset,characterLength:t.length,byteOffset:this.byteLength,byteLength:n.length,hash:H("sha256").update(n).digest("hex")};this.pages.length===0&&(this.firstPageContent=t),this.pages.push(i),this.hash.update(n),this.pageCharacterOffset+=t.length,this.byteLength=r}assertWithinByteLimit(t){if(!Number.isSafeInteger(t)||t>this.limits.maxSnapshotBytes)throw new Error(`Command output exceeds the ${this.limits.maxSnapshotBytes}-byte snapshot limit. Narrow the query before retrying.`)}};function dn(e,t,n,r,s,i){ue(s);let o=We(e.snapshotId,s);if(o.invocationHash!==t)throw new Error("This output cursor belongs to a different command, working directory, or argument set. Run again without --output-cursor.");if(o.snapshotId!==e.snapshotId||e.version===3&&(o.invocationHash!==e.invocationHash||o.outputHash!==e.outputHash))throw new Error("Output snapshot identity does not match this cursor.");if(o.pageSize!==n||e.version===3&&e.pageSize!==n)throw new Error(`Output page size changed after this cursor was issued; use ${o.pageSize}.`);let a=o.pages[e.pageIndex];if(!a)throw new Error("Output cursor points past the current result.");if(o.totalCharacters>r)throw new Error(`Output snapshot exceeds the ${r}-character safety limit.`);if(Date.now()-o.createdAtMs>He)throw E(e.snapshotId,s),new Error("Output snapshot expired before all pages were read.");let u=O(s,e.snapshotId,"output"),d=Te(u,"r");try{let p=Ne(d);if(!p.isFile()||p.size!==o.byteLength)throw new Error("Output snapshot size or type changed.");let l=Buffer.allocUnsafe(a.byteLength),g=0;for(;g<l.length;){let f=jt(d,l,g,l.length-g,a.byteOffset+g);if(f===0)break;g+=f,i?.(f)}let c=Ne(d);if(c.dev!==p.dev||c.ino!==p.ino||c.size!==p.size||g!==a.byteLength)throw new Error("Output snapshot changed while it was being read.");if(H("sha256").update(l).digest("hex")!==a.hash)throw new Error("Output snapshot page no longer matches its metadata.");let m=l.toString("utf8");if(m.length!==a.characterLength)throw new Error("Output snapshot page character count changed.");return{content:m,offset:a.characterOffset,pageIndex:e.pageIndex,pageCount:o.pages.length,totalCharacters:o.totalCharacters,outputHash:o.outputHash}}catch(p){throw E(e.snapshotId,s),p}finally{te(d)}}function We(e,t){if(!w(e))throw new Error("Output snapshot identifier is invalid.");let n;try{n=JSON.parse(b(O(t,e,"json"),"output snapshot metadata"))}catch(r){throw new Error("Output snapshot is unavailable.",{cause:r})}if(!pn(n))throw new Error("Output snapshot metadata is invalid.");return n}function pn(e){if(!e||typeof e!="object")return!1;let t=e;return t.version===Ue&&typeof t.snapshotId=="string"&&w(t.snapshotId)&&L(t.invocationHash)&&et(t.invocationPrefix)&&typeof t.command=="string"&&t.command.length>0&&t.command.length<=256&&typeof t.cwd=="string"&&t.cwd.length>0&&t.cwd.length<=8192&&Ln(t.argv)&&Xe(t.command,t.cwd,t.invocationPrefix,t.argv)===t.invocationHash&&L(t.outputHash)&&Number.isSafeInteger(t.pageSize)&&(t.pageSize??0)>=x&&(t.pageSize??0)<=A&&Array.isArray(t.pages)&&t.pages.length>1&&t.pages.length<=re&&t.pages.every(gn)&&ln(t.pages)&&Number.isSafeInteger(t.totalCharacters)&&(t.totalCharacters??-1)>=0&&t.pages.reduce((n,r)=>n+r.characterLength,0)===t.totalCharacters&&Number.isSafeInteger(t.byteLength)&&(t.byteLength??-1)>=0&&t.pages.reduce((n,r)=>n+r.byteLength,0)===t.byteLength&&Number.isSafeInteger(t.createdAtMs)&&(t.createdAtMs??-1)>=0}function gn(e){if(!e||typeof e!="object")return!1;let t=e;return Number.isSafeInteger(t.characterOffset)&&(t.characterOffset??-1)>=0&&Number.isSafeInteger(t.characterLength)&&(t.characterLength??0)>0&&Number.isSafeInteger(t.byteOffset)&&(t.byteOffset??-1)>=0&&Number.isSafeInteger(t.byteLength)&&(t.byteLength??0)>0&&L(t.hash)}function ln(e){let t=0,n=0;for(let r of e){if(r.characterOffset!==t||r.byteOffset!==n)return!1;t+=r.characterLength,n+=r.byteLength}return!0}function ue(e){Bt(e,{recursive:!0,mode:448});let t=Ut(e);if(!t.isDirectory()||t.isSymbolicLink())throw new Error(`Output snapshot root is not a private directory: ${e}`);if(typeof process.getuid=="function"&&t.uid!==process.getuid())throw new Error(`Output snapshot root is not owned by the current user: ${e}`);process.platform!=="win32"&&Ht(e,448)}function hn(e){let t={...rn,...e};for(let[n,r]of Object.entries(t))if(!Number.isSafeInteger(r)||r<=0)throw new Error(`Output snapshot ${n} must be a positive integer.`);if(t.maxSnapshotBytes>t.maxAggregateBytes)throw new Error("Output snapshot maxSnapshotBytes cannot exceed maxAggregateBytes.");return t}function mn(e,t,n,r){B(e,()=>{Sn(e),Ge(e,t,n,"active",r)})}function Re(e,t,n,r,s){if(!Number.isSafeInteger(n)||n<0||n>s.maxSnapshotBytes)throw new Error(`Command output exceeds the ${s.maxSnapshotBytes}-byte snapshot limit.`);B(e,()=>{Ge(e,t,n,r,s)})}function Ge(e,t,n,r,s){if(!Number.isSafeInteger(n)||n<0||n>s.maxSnapshotBytes)throw new Error(`Command output exceeds the ${s.maxSnapshotBytes}-byte snapshot limit.`);let i=yn(e),o=i.find(l=>l.snapshotId===t),a=i.reduce((l,g)=>l+g.reservedBytes,0)-(o?.reservedBytes??0)+n,u=i.length+(o?0:1);if(u>s.maxSnapshotCount||a>s.maxAggregateBytes)throw new Error(`Output snapshot capacity is full (${u}/${s.maxSnapshotCount} snapshots, ${a}/${s.maxAggregateBytes} bytes). Narrow the query or finish an existing pagination sequence before retrying.`);let d=Date.now(),p={version:De,snapshotId:t,pid:process.pid,...oe()?{processIdentity:oe()}:{},reservedBytes:n,state:r,createdAtMs:o?.createdAtMs??d,updatedAtMs:d};v(O(e,t,"reserve"),p)}function fn(e,t){B(e,()=>{$e(O(e,t,"reserve"),{force:!0})})}function yn(e){let t=[];for(let n of ke(e,{withFileTypes:!0})){if(!n.isFile()||!n.name.endsWith(".reserve"))continue;let r=n.name.slice(0,-8);if(w(r))try{let s=JSON.parse(b(_(e,n.name),"output snapshot reservation"));if(!Fe(s)||s.snapshotId!==r)throw new Error("reservation identity is invalid");t.push(s)}catch(s){throw new Error(`Output snapshot reservation ${n.name} is invalid; retry after its owning process or snapshot expires.`,{cause:s})}}return t}function Fe(e){if(!e||typeof e!="object")return!1;let t=e;return t.version===De&&typeof t.snapshotId=="string"&&w(t.snapshotId)&&Number.isSafeInteger(t.pid)&&(t.pid??0)>0&&(t.processIdentity===void 0||de(t.processIdentity)!==null&&t.processIdentity.pid===t.pid)&&Number.isSafeInteger(t.reservedBytes)&&(t.reservedBytes??-1)>=0&&(t.state==="active"||t.state==="complete")&&Number.isSafeInteger(t.createdAtMs)&&Number.isSafeInteger(t.updatedAtMs)}function Sn(e){let t=Date.now();for(let n of ke(e,{withFileTypes:!0})){if(!n.isFile()||!n.name.endsWith(".reserve"))continue;let r=n.name.slice(0,-8);if(!w(r))continue;let s=null;try{let u=JSON.parse(b(_(e,n.name),"output snapshot reservation"));s=Fe(u)?u:null}catch{s=null}let i=vn(O(e,r,"json")),o=s?.state==="active"&&ge(s.pid)&&(s.processIdentity===void 0||(()=>{let u=D(s.pid);return u!==null&&pe(s.processIdentity,u)})()),a=s?t-s.updatedAtMs>He:!1;o||i&&!a||!i&&s&&!a&&s.state==="complete"||Qe(r,e)}}function vn(e){try{return zt(e),!0}catch{return!1}}function B(e,t){ue(e);let n=_(e,Yt),r=Date.now()+en;for(;;){let s=P(n,{kind:"output-snapshot-quota",processIdentity:oe()});if(s.kind==="acquired")try{return t()}finally{s.lock.release()}if(Date.now()>=r)throw new Error("Output snapshot quota is busy. Retry the command.");Atomics.wait(nn,0,0,tn)}}function oe(){return ee===void 0&&(ee=D(process.pid)),ee}function E(e,t){w(e)&&B(t,()=>Qe(e,t))}function Qe(e,t){for(let n of["json","output","tmp","reserve"])$e(O(t,e,n),{force:!0})}function O(e,t,n){if(!w(t))throw new Error("Output snapshot identifier is invalid.");return _(e,`${t}.${n}`)}function On(e){if(!e)throw new Error("Incomplete output did not create a resumable snapshot.");return e}function bn(e){return e>=55296&&e<=56319}function In(e,t,n){if(n){let r=e.lastIndexOf(`
12
- `,t-1);if(r>=0)return r+1}return bn(e.charCodeAt(t-1))?t-1:t}function wn(e){let t=En({pageIndex:e.nextPageIndex,snapshotId:e.snapshotId});return{cursor:t,command:Nn(e.invocationPrefix,t)}}function En(e){return je.test(e.snapshotId)?e.pageIndex===1?e.snapshotId:`${e.snapshotId}.${e.pageIndex.toString(36)}`:`4.${xn(e.snapshotId)}.${e.pageIndex.toString(36)}`}function Cn(e,t){let n=Je(e);if(!n)throw new Error("Invalid output cursor. Run the command again without --output-cursor.");if(n.version===3&&n.invocationHash!==t)throw new Error("This output cursor belongs to a different command, working directory, or argument set. Run again without --output-cursor.");return n}function Je(e){let t=Kt.exec(e);if(t){let r=t[2]??"1",s=Number.parseInt(r,36);return Number.isSafeInteger(s)&&s>=1&&s.toString(36)===r?{version:4,pageIndex:s,snapshotId:t[1]}:null}let n=Zt.exec(e);if(n){let r=An(n[1]),s=Number.parseInt(n[2],36);return r&&Number.isSafeInteger(s)&&s>=1&&s.toString(36)===n[2]?{version:4,pageIndex:s,snapshotId:r}:null}try{let r=JSON.parse(Buffer.from(e,"base64url").toString("utf8"));return Pn(r)?r:null}catch{return null}}function Pn(e){if(!e||typeof e!="object")return!1;let t=e;return t.version===3&&L(t.invocationHash)&&Number.isSafeInteger(t.pageIndex)&&(t.pageIndex??-1)>=1&&Number.isSafeInteger(t.pageSize)&&(t.pageSize??0)>=x&&(t.pageSize??0)<=A&&L(t.outputHash)&&typeof t.snapshotId=="string"&&w(t.snapshotId)}function xn(e){if(!ae.test(e))throw new Error("Output snapshot identifier is invalid.");return Buffer.from(e.replaceAll("-",""),"hex").toString("base64url")}function An(e){let t=Buffer.from(e,"base64url");if(t.length!==16)return null;let n=t.toString("hex"),r=`${n.slice(0,8)}-${n.slice(8,12)}-${n.slice(12,16)}-${n.slice(16,20)}-${n.slice(20)}`;return ae.test(r)?r:null}function w(e){return typeof e=="string"&&(je.test(e)||ae.test(e))}function L(e){return typeof e=="string"&&/^[a-f0-9]{64}$/u.test(e)}function Xe(e,t,n,r){return H("sha256").update(JSON.stringify({command:e,cwd:t,invocationPrefix:n,argv:r})).digest("hex")}function Ze(e){let t=[];for(let n=0;n<e.length;n+=1){let r=e[n];if(r==="--output-page-size"||r==="--output-cursor"){n+=1;continue}r.startsWith("--output-page-size=")||r.startsWith("--output-cursor=")||t.push(r)}return t}function Ke(e,t,n){return tt([...e,...t,"--output-page-size",String(n)])}function Nn(e,t){return tt([...e,Ft,t])}function Ye(e){let t=e===void 0?["codebaseiq"]:[...e];if(!et(t))throw new Error("Output pagination invocation prefix must contain one to sixteen non-empty shell arguments.");return t}function et(e){return Array.isArray(e)&&e.length>0&&e.length<=16&&e.every(t=>typeof t=="string"&&t.length>0&&t.length<=2048&&!t.includes("\0")&&!t.includes("\r")&&!t.includes(`
13
- `))}function Ln(e){return Array.isArray(e)&&e.length>0&&e.length<=256&&e.every(t=>typeof t=="string"&&t.length<=8192&&!t.includes("\0")&&!t.includes("\r")&&!t.includes(`
14
- `))}function tt(e){return e.map(t=>Ae(t,{omitSafeQuotes:!0})).join(" ")}function _n(e){let t=e.page.continuation,n=Math.max(e.page.offset,e.page.offset+e.page.returnedCharacters-1),r=`[codebaseiq output page: characters ${e.page.offset}-${n} of ${e.page.totalCharacters}]
15
- `,s=t?`
16
- [Incomplete: ${e.page.remainingCharacters} characters remain. Continue exactly:
17
- ${t.command}]
18
- `:`
19
- [codebaseiq transport complete; evaluate command coverage separately]
20
- `;return`${r}${e.content}${s}`}export{Ae as a,Dn as b,zn as c,qn as d,Vn as e,Wn as f,Gn as g,tr as h,nr as i,Ft as j,M as k,sn as l,Or as m,br as n};
21
- //# sourceMappingURL=chunk-DAKIGMIK.js.map
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env node
2
- import{spawnSync as F}from"child_process";import{createHash as N}from"crypto";import{existsSync as W,lstatSync as M,realpathSync as j}from"fs";import{dirname as $,isAbsolute as z,join as U,resolve as g}from"path";function K(){return{...process.env,GIT_OPTIONAL_LOCKS:"0",LC_ALL:"C"}}var f={run(t,e){let r=I(t,e);return r.kind==="success"?r.output:void 0},runResult:I},J=["rev-parse","--show-toplevel","--absolute-git-dir","--git-common-dir","HEAD","HEAD^{tree}"],y=/^[0-9a-f]{40,64}$/;function Ce(t,e,r=f){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 Se(t,e=f){let r=e.runResult(t,J);if(r.kind==="success"){let n=Y(r.output);if(n)return H(n,e)}return X(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(p(a,n)),commonDir:u(p(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 X(t,e){let r=q(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(p(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 q(t,e=f){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(p(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=f){let r=e.run(t,["worktree","list","--porcelain","-z"]);return r===void 0?[]:V(r)}function V(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 Re(t,e,r=f){return h(r.run(t,e))}function p(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 N("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:K(),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"&&W(g(t)))&&!Q(t)?{kind:"not-repository"}:{kind:"error",message:i}}function Q(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 Ie(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 Z,readSync as E}from"fs";import{createHash as ee}from"crypto";var v=8*1024*1024,B=64*1024*1024,te=512*1024*1024,re=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 w(t,e){P(e.maxBytes);let r=String(t),n=C(t,"r");try{let i=m(n);D(i,e,r);let o=Z(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 S(t,e,r="utf8"){return w(t,e).toString(r)}function ne(t,e){return S(t,{maxBytes:v,inputKind:e})}function ie(t,e){return S(t,{maxBytes:B,inputKind:e})}function k(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 oe(t,e,r="utf8"){return k(t,e).toString(r)}function A(t,e){let r=C(t,"r");try{return k(r,e)}finally{b(r)}}function R(t,e,r="utf8"){return A(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 se(t,e){let r=ee("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 ae=new Set(["aix","android","darwin","freebsd","haiku","linux","openbsd","sunos","win32","cygwin","netbsd"]);function ce(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"||!ae.has(e.platform)||typeof e.startToken!="string"||e.startToken.trim()===""?null:{version:1,pid:e.pid,platform:e.platform,startToken:e.startToken}}function de(t,e){return t.version===e.version&&t.pid===e.pid&&t.platform===e.platform&&t.startToken===e.startToken}import{execFileSync as ue}from"child_process";import{platform as le}from"os";var L=new WeakMap,fe=1e3,G=16*1024;function Fe(t,e=me){if(!Number.isSafeInteger(t)||t<=0)return null;if(t===process.pid){let r=L.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&&L.set(e,n),n}catch{return null}}function pe(t,e){if(e.platform==="linux"||e.platform==="android")return ge(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 ge(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 me={platform:le(),readFile(t){return R(t,{maxBytes:G,inputKind:"process identity pseudo-file"})},run(t,e){return ue(t,[...e],{encoding:"utf8",timeout:fe,maxBuffer:G,env:{...process.env,LC_ALL:"C",LANG:"C"},stdio:["ignore","pipe","ignore"],windowsHide:!0})}};var Me=["typescript","javascript","java","scala","kotlin","rust","python","ruby","go","cpp","c","csharp","vb","dart","php","clojure"],je=["entry-surface","generated-code","compatibility-shim","reflection-or-registration","test-fixture","intentional-twin","historical-coupling-ended","detector-counterexample"];function ze(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Ue(t){return typeof t=="string"&&Number.isFinite(Date.parse(t))}function Ke(t){return typeof t=="number"&&Number.isSafeInteger(t)&&t>=0}function Je(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{K as a,f as b,Ce as c,Se as d,q as e,ke as f,Re as g,p as h,u as i,Ie as j,v as k,B as l,te as m,re as n,d as o,w as p,S as q,ne as r,ie as s,oe as t,O as u,se as v,ce as w,de as x,Fe as y,Me as z,je as A,ze as B,Ue as C,Ke as D,Je as E,Ye as F};
4
- //# sourceMappingURL=chunk-DUKHVPU5.js.map
@@ -1,2 +0,0 @@
1
- import{h as p,j as x,l,p as g,x as v}from"./chunk-GWYZVVKY.js";import{Q as d}from"./chunk-6WAPPQ5F.js";import{P as h,S as u,ia as f}from"./chunk-MEUHIDI3.js";import{G as m}from"./chunk-UQYQBLJX.js";import{existsSync as C}from"fs";var E=5e3,S=100,R={prepare:f,freshness:h,ensureService:x,inspectService:l,requestRefresh:g,async reindex(e,t,n,o){let{reindexConfiguredProject:a}=await import("./project-reindex-CRJU3IFG.js");return a(e,t,n,o)},indexExists:C,wait(e){return new Promise(t=>setTimeout(t,e))},now:Date.now};async function I(e,t=R,n={}){if(e.dbPathSource==="env")return{source:"explicit-index",service:{kind:"skipped",reason:"environment"}};if(v(e.commandName,e.config)&&t.indexExists(e.paths.dbPath))return{source:"published-generation",service:{kind:"skipped",reason:"excluded-command"}};let o=y(e,t),a=t.prepare(e.projectRoot,e.config,e.paths,{gitContext:e.gitContext,...o?{watcherGeneration:o}:{}}),r=t.freshness(e.projectRoot,e.config,e.paths),i=t.ensureService({commandName:e.commandName,projectRoot:e.projectRoot,cacheDir:e.paths.cacheDir,cliVersion:m,config:e.config,gitContext:e.gitContext});if(r.state==="fresh")return{source:a.kind==="local-fresh"?"existing":"shared-generation",service:i};if((i.kind==="started"||i.kind==="reused")&&(t.requestRefresh(d(e.paths.cacheDir).activityPath,`evidence command ${e.commandName} requires a fresh generation`),r=await F(e,r,t,n,i),r.state==="fresh"))return{source:"watcher",service:i};try{await t.reindex(e.projectRoot,e.config,e.paths,{allowPartial:!1,skipAutoInstall:!0,trigger:{kind:"watch-demand",detail:`codebaseiq ${e.commandName}`},onStatus:()=>{}})}catch(s){throw new Error(`Could not prepare fresh evidence for codebaseiq ${e.commandName}: ${s instanceof Error?s.message:String(s)}`,{cause:s})}if(r=t.freshness(e.projectRoot,e.config,e.paths),r.state!=="fresh")throw new Error(`Could not prepare fresh evidence for codebaseiq ${e.commandName}: index remained ${r.state} (${r.reason})`);return{source:"synchronous-reindex",service:i}}function y(e,t){if(e.config.watch?.enabled===!0)try{return p(t.inspectService({projectRoot:e.projectRoot,cacheDir:e.paths.cacheDir,cliVersion:m,gitContext:e.gitContext}))}catch{return}}async function F(e,t,n,o,a){if(a.state.watcher.state==="budget-paused")return t;let r=Math.max(0,o.waitMs??E),i=Math.max(1,o.pollMs??S),s=n.now()+r,c=t;for(;n.now()<s;)if(await n.wait(Math.min(i,Math.max(1,s-n.now()))),u(),c=n.freshness(e.projectRoot,e.config,e.paths),c.state==="fresh")return c;return c}export{I as a};
2
- //# sourceMappingURL=chunk-DVWO7RBC.js.map
@@ -1,2 +0,0 @@
1
- import{b as I}from"./chunk-DAKIGMIK.js";import{bb as v,ib as s,lb as E,mb as V}from"./chunk-LONKINMJ.js";import{c as y}from"./chunk-ZZ3MWF33.js";import{fa as h,pa as S,w}from"./chunk-MEUHIDI3.js";import{G as x}from"./chunk-UQYQBLJX.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=>{I(r.generation.identity),e({db:r,args:t,opts:o})})}}function R(e,n){return m(t=>{let o=V(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&&E(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?v({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};
2
- //# sourceMappingURL=chunk-FH5WG4LE.js.map
@@ -1,2 +0,0 @@
1
- import{m as g,n as h,z as S}from"./chunk-GWYZVVKY.js";import{c as u,d as m,h as p,k as f}from"./chunk-PUVNH4PO.js";import{B as d}from"./chunk-MEUHIDI3.js";import{G as c,N as a,Y as l}from"./chunk-UQYQBLJX.js";import{statSync as y}from"fs";import{join as R,resolve as C}from"path";var D=3e3,v=250,P={env:process.env,cliVersion:c,loadConfig:d,cacheDir:(e,r)=>a(e,r).cacheDir,registryRecord:e=>p(u(),m(e)),isProcessAlive:f,configChangedAtMs:e=>y(R(e,".codebaseiq.json")).mtimeMs,refreshHookBinary:e=>{S(e)},ensure:g,stop:h,sleep:e=>new Promise(r=>setTimeout(r,e))};async function _(e,r=P){let n=l(C(e)),t=r.loadConfig(n);if(t.sentinel?.enabled!==!0)return"sentinel-disabled";if(r.refreshHookBinary(r.cliVersion),t.watch?.enabled!==!0)return"watch-disabled";if(r.env.CODEBASEIQ_SKIP_WATCH_SERVICE==="1")return"environment";if(E(r,n))return"already-running";let i={projectRoot:n,cacheDir:r.cacheDir(n,t),cliVersion:r.cliVersion,spawnEnv:{CODEBASEIQ_SENTINEL_ENSURE:"1"}},o=r.ensure(i);if(o.disposition==="started")return"started";for(let s=0;s<D;s+=v)if(await r.sleep(v),E(r,n))return"reused";return Date.parse(o.state.startedAt)>=r.configChangedAtMs(n)?"reused-without-sentinel":(r.stop(i),r.ensure(i),"restarted")}function E(e,r){let n=e.registryRecord(r);return n!==void 0&&e.isProcessAlive(n.pid)&&n.serviceVersion===e.cliVersion}async function j(e){if(typeof e!="string"||e.length===0)throw new Error("A project root is required.");await _(e)}var k={id:"__sentinel-ensure-service",command:"__sentinel-ensure-service <projectRoot>",hidden:!0,description:"Internal: start the resident service that hosts the trailing sentinel",renderShape:"custom",handler:j};export{_ as a,k as b};
2
- //# sourceMappingURL=chunk-GQXXOS55.js.map
@@ -1,21 +0,0 @@
1
- import{V as Ue,W as Be}from"./chunk-LONKINMJ.js";import{N as ce,O as de,Q as C,R as M,S as N}from"./chunk-6WAPPQ5F.js";import{A as $e,B as je,K as L,P as Fe,l as le,m as Me,ma as Ge,n as I,p as Ne,q as Le,z as W}from"./chunk-MEUHIDI3.js";import{b as E,j as re,k as ie,l as He,m as se,n as _e,p as De,r as ae,s as D}from"./chunk-D7DOB27N.js";import{a as _,c as qe,d as te,e as ne}from"./chunk-6O3KXIDL.js";import{J as y,N as Te,U as Oe,W as oe,X as Pe,Y as k,a as Ie,f as Z,h as f,v as ee,w as x,x as We}from"./chunk-UQYQBLJX.js";import{spawn as Zt}from"child_process";import{existsSync as en,rmSync as rt}from"fs";import{dirname as tn,resolve as V}from"path";import{fileURLToPath as nn}from"url";import{createHash as Lt,randomUUID as ue}from"crypto";import{existsSync as $t,linkSync as jt,readdirSync as Ft,rmSync as w}from"fs";import{basename as Gt,dirname as Ut,join as h}from"path";var S=1,Bt=10*6e4,Vt=10080*6e4,j="requests",T="claims",$="completions",Ke="staging";function Je(e,t,n={}){let r=n.now?.()??new Date,o=zt(n.ttlMs),i=Qt(n.idempotencyKey),s=i?`key-${Lt("sha256").update(i).digest("hex")}`:`request-${(n.randomId??ue)()}`,a={version:S,requestId:s,...i?{idempotencyKey:i}:{},createdAt:r.toISOString(),deadlineAt:new Date(r.getTime()+o).toISOString(),detail:t.trim().slice(0,2048)||"stale index observed by a command"},c=et(e,s),d=he(e,c,a,n.onStage);if(d.published)return{disposition:"accepted",request:a,achievedDurability:d.achievedDurability,directorySync:d.directorySync};let p=pe(c);if(!p)throw new Error(`Watch refresh request identity ${s} exists but is malformed.`);return{disposition:"duplicate",request:p}}function er(e,t={}){let n=t.now?.()??new Date,r=`claim-${(t.randomId??ue)()}`,o=Math.max(1,Math.floor(t.limit??64)),i=Xe(e).sort(Xt),s=[];for(let a of i){if(s.length>=o)break;if(Ve(e,a.requestId))continue;if(Date.parse(a.deadlineAt)<=n.getTime()){Qe(e,{version:S,requestId:a.requestId,outcome:"expired",completedAt:n.toISOString()});continue}let c={version:S,requestId:a.requestId,claimId:r,claimedAt:n.toISOString()};if(he(e,tt(e,a.requestId),c).published){if(Ve(e,a.requestId)){Ye(e,a.requestId,r);continue}s.push(a)}}return{claimId:r,requests:s}}function tr(e,t,n=()=>new Date,r){let o=n().toISOString();for(let i of t.requests)Qe(e,{version:S,requestId:i.requestId,claimId:t.claimId,outcome:"completed",completedAt:o});r?.("after-completion"),Kt(e,t),r?.("after-claim-release")}function Kt(e,t){for(let n of t.requests)Ye(e,n.requestId,t.claimId)}function nr(e){let t=0;for(let n of b(h(e,T)))w(n,{force:!0}),t++;return t>0&&x(h(e,T)),Ze(e),t}function rr(e){let t=Xe(e),n=new Map,r=Jt(h(e,j),pe);for(let c of b(h(e,$))){let d=F(c);if(!d){r++;continue}n.set(d.requestId,d)}let o=new Set;for(let c of b(h(e,T))){let d=ze(c);if(!d){r++;continue}o.add(d.requestId)}let i=t.filter(c=>!n.has(c.requestId)&&!o.has(c.requestId)),s=[...n.values()].filter(c=>c.outcome==="completed").length,a=[...n.values()].filter(c=>c.outcome==="expired").length;return{pending:i.length,claimed:t.filter(c=>!n.has(c.requestId)&&o.has(c.requestId)).length,completed:s,expired:a,invalid:r,...i.length>0?{oldestPendingAt:i.map(c=>c.createdAt).reduce((c,d)=>Yt(c,d))}:{}}}function or(e,t={}){let n=(t.now?.()??new Date).getTime(),r=Math.max(0,t.retentionMs??Vt),o=0;for(let i of b(h(e,$))){let s=F(i);!s||n-Date.parse(s.completedAt)<r||(w(i,{force:!0}),w(et(e,s.requestId),{force:!0}),o++)}return o>0&&(x(h(e,$)),x(h(e,j))),Ze(e),o}function pe(e){return fe(e,t=>{let n=t;return n.version===S&&q(n.requestId)&&(n.idempotencyKey===void 0||typeof n.idempotencyKey=="string")&&E(n.createdAt)&&E(n.deadlineAt)&&Date.parse(n.deadlineAt)>=Date.parse(n.createdAt)&&typeof n.detail=="string"&&n.detail.length>0})}function ze(e){return fe(e,t=>{let n=t;return n.version===S&&q(n.requestId)&&q(n.claimId)&&E(n.claimedAt)})}function F(e){return fe(e,t=>{let n=t;return n.version===S&&q(n.requestId)&&(n.claimId===void 0||q(n.claimId))&&(n.outcome==="completed"||n.outcome==="expired")&&E(n.completedAt)})}function Qe(e,t){let n=nt(e,t.requestId);if(he(e,n,t).published)return;let r=F(n);if(!r||r.requestId!==t.requestId||r.outcome!==t.outcome)throw new Error(`Watch refresh completion ${t.requestId} conflicts with an existing record.`)}function he(e,t,n,r){let o=h(e,Ke),i=Ut(t),s=ee(o),a=ee(i),c=h(o,`${Gt(t)}.${process.pid}.${ue()}.tmp`);try{let d=D(c,n,{spacing:2,trailingNewline:!0});r?.("after-staged");try{jt(c,t)}catch(u){if(u.code==="EEXIST")return{published:!1};throw u}let p=We(s,a,d.directorySync,x(i));return r?.("after-published"),{published:!0,achievedDurability:p==="synced"?"directory-durable":"file-flushed",directorySync:p}}finally{w(c,{force:!0})}}function Xe(e){let t=[];for(let n of b(h(e,j))){let r=pe(n);r&&t.push(r)}return t}function Ye(e,t,n){let r=tt(e,t),o=ze(r);!o||o.claimId!==n||(w(r,{force:!0}),x(h(e,T)))}function Ze(e){for(let t of b(h(e,Ke),".tmp"))w(t,{force:!0})}function Jt(e,t){return b(e).filter(n=>!t(n)).length}function b(e,t=".json"){return $t(e)?Ft(e,{withFileTypes:!0}).filter(n=>n.isFile()&&n.name.endsWith(t)).map(n=>h(e,n.name)).sort():[]}function fe(e,t){try{let n=JSON.parse(f(e,"watch refresh request record"));return t(n)?n:null}catch{return null}}function et(e,t){return h(e,j,`${t}.json`)}function tt(e,t){return h(e,T,`${t}.json`)}function nt(e,t){return h(e,$,`${t}.json`)}function Ve(e,t){return F(nt(e,t))!==null}function zt(e){if(e===void 0)return Bt;if(!Number.isFinite(e)||e<=0)throw new Error("Watch refresh request ttlMs must be positive.");return Math.floor(e)}function Qt(e){let t=e?.trim();return t?t.slice(0,512):void 0}function q(e){return typeof e=="string"&&/^[a-z0-9][a-z0-9-]{0,127}$/i.test(e)}function Xt(e,t){return Date.parse(e.createdAt)-Date.parse(t.createdAt)||e.requestId.localeCompare(t.requestId)}function Yt(e,t){return Date.parse(t)<Date.parse(e)?t:e}var ot=5e3,rn=6e3,on=1e3,ge=10,sn=new Set(["capabilities","check-deps","config-validate","doctor","init","install-skills","reindex","setup","setup-agent","status","suppress","uninstall","watch"]);function Rr(e){let t=e.classification;if(t.kind!=="live")return;let{state:n}=t;return n.watcher.state==="idle"&&n.lastError===void 0?n.indexGeneration:void 0}function an(e,t=process.env){return t.CODEBASEIQ_SKIP_WATCH_SERVICE!=="1"&&!e.startsWith("__")&&!sn.has(e)}function Ar(e){let t=e.env??process.env;if(t.CODEBASEIQ_SKIP_WATCH_SERVICE==="1")return{kind:"skipped",reason:"environment"};if(!an(e.commandName,t))return{kind:"skipped",reason:"excluded-command"};if(e.config.watch?.enabled!==!0)return{kind:"skipped",reason:"disabled"};try{let n=cn({projectRoot:e.projectRoot,cacheDir:e.cacheDir,cliVersion:e.cliVersion,gitContext:e.gitContext,runtime:e.runtime});return{kind:n.disposition,state:n.state}}catch(n){return{kind:"failed",message:n instanceof Error?n.message:String(n)}}}function at(e,t,n){let r=k(V(e));if(n&&k(n.projectRoot)===r)return{projectRoot:r,worktreeKind:"git",worktreeId:n.worktreeId,cliVersion:t};let o=Oe(r);if(o.kind==="error")throw new Error(`Could not establish Git worktree identity for ${r}: ${o.message}`);return o.kind==="non-git"?{projectRoot:r,worktreeKind:"non-git",cliVersion:t}:{projectRoot:r,worktreeKind:"git",worktreeId:o.identity.worktreeId,cliVersion:t}}function Er(e){return U(e,at(e.projectRoot,e.cliVersion,e.gitContext))}function U(e,t){let n=e.runtime??Se,r=C(e.cacheDir),o=M(r.statePath),i=ke(r.lockPath);return{identity:t,classification:dn(o,t,n.now(),n.isProcessAlive),lock:i,lockIsLive:i!==null&&n.isProcessAlive(i.pid),paths:r}}function cn(e){let t=e.runtime??Se,n=at(e.projectRoot,e.cliVersion,e.gitContext),r=U(e,n),o=ye("ensure",r.classification);if(o.kind==="reuse")return G(r.paths.activityPath,t),{disposition:"reused",state:o.state};if(o.kind==="refuse-replace")throw new Error(`codebaseiq watch service pid ${o.state.pid} is still alive but its heartbeat is old. Refusing automatic replacement because civil-clock age alone cannot authorize a process signal.`);if(o.kind==="replace")ve(o.state,e,t),O(r.paths,o.state.pid,t);else if(o.kind==="start"){if(r.lockIsLive){let a=it(e,n,t,Math.min(e.startupTimeoutMs??1e3,1e3));if(a)return G(r.paths.activityPath,t),{disposition:"reused",state:a};throw new Error(`codebaseiq watch is already running for ${V(e.projectRoot)} (pid ${r.lock?.pid}; lock: ${r.paths.lockPath}) without compatible daemon state. Stop the foreground watcher before starting the service.`)}r.classification.kind==="stale"&&O(r.paths,r.classification.state.pid,t)}else throw new Error(`Unexpected ensure action: ${o.kind}`);if(r=U(e,n),o=ye("ensure",r.classification),o.kind==="reuse")return G(r.paths.activityPath,t),{disposition:"reused",state:o.state};if(o.kind==="refuse-replace")throw new Error(`codebaseiq watch service pid ${o.state.pid} remains alive with an old heartbeat; automatic replacement is not authorized.`);let i=e.serverPath??nn(new URL("./watch-server.js",import.meta.url));t.spawnServer(i,n.projectRoot,e.cliVersion,e.watchOverrides??{},e.spawnEnv);let s=it(e,n,t,e.startupTimeoutMs??ot);if(!s)throw new Error(`codebaseiq watch service did not become ready within ${e.startupTimeoutMs??ot}ms.`);return G(r.paths.activityPath,t),{disposition:"started",state:s}}function Cr(e){let t=e.runtime??Se,n=C(e.cacheDir),r=M(n.statePath),o=r?t.isProcessAlive(r.pid)?{kind:"live",state:r}:{kind:"stale",state:r,reason:"dead-process"}:{kind:"stopped"},i=ye("stop",o);if(i.kind==="signal-stop")return ve(i.state,e,t),O(n,i.state.pid,t),{disposition:"stopped",pid:i.state.pid};if(i.kind==="clean-stale")return O(n,i.state.pid,t),{disposition:"stopped",pid:i.state.pid};let s=ke(n.lockPath);return i.kind==="already-stopped"&&s&&t.isProcessAlive(s.pid)?(ve(s,e,t),O(n,s.pid,t),{disposition:"stopped",pid:s.pid}):{disposition:"already-stopped"}}function Ir(e,t,n={}){let{durability:r="durable",...o}=n;r==="durable"?D(e,t,o):ae(e,t,o)}function ct(e,t=Date.now()){ae(e,{version:1,at:new Date(t).toISOString()})}function Wr(e,t,n=Date.now(),r={}){Je(C(tn(e)).refreshRequestsPath,t,{...r,now:()=>new Date(n)}),ct(e,n)}function Tr(e){try{let t=JSON.parse(f(e,"watch activity record"));return t.version!==1||!N(t.at)||t.refreshRequestedAt!==void 0&&!N(t.refreshRequestedAt)||t.refreshDetail!==void 0&&typeof t.refreshDetail!="string"?null:{atMs:Date.parse(t.at),...t.refreshRequestedAt===void 0?{}:{refreshRequestedAtMs:Date.parse(t.refreshRequestedAt)},...t.refreshDetail===void 0?{}:{refreshDetail:t.refreshDetail}}}catch{return null}}function qr(e,t,n={}){let r=n.pid??process.pid,o=n.isProcessAlive??re,i=()=>{},s=n.readProcessIdentity??ne,a=n.now??(()=>new Date),c={...ie,wallNow:()=>a().getTime(),isProcessAlive:o,readProcessIdentity:s},d=He(e,{kind:"watch",pid:r,processIdentity:s(r),detail:{projectRoot:V(t)},parseLegacy:B,runtime:c});if(d.kind==="contended"){let p=dt(d.observation);return{acquired:!1,lockPath:e,message:ln(e,t,p),release:i}}return{acquired:!0,lockPath:e,message:"",release:()=>{d.lock.release()}}}function ke(e){return dt(se(e,{parseLegacy:B}))}var B=e=>{let t=lt(e);return t?{pid:t.pid,...t.processIdentity?{processIdentity:t.processIdentity}:{}}:null};function dt(e){if(e.state==="valid"&&e.record?.kind==="watch"){let t=e.record.detail?.projectRoot;return typeof t!="string"?null:{version:1,pid:e.record.pid,...e.record.processIdentity?{processIdentity:e.record.processIdentity}:{},projectRoot:t,startedAt:e.record.startedAt}}return lt(e.parsed)}function lt(e){try{let t=e;if(t.version!==1||typeof t.pid!="number"||!Number.isInteger(t.pid)||t.pid<=0||typeof t.projectRoot!="string"||!N(t.startedAt))return null;let n=t.processIdentity===void 0?null:qe(t.processIdentity);return t.processIdentity!==void 0&&(!n||n.pid!==t.pid)?null:{version:1,pid:t.pid,...n?{processIdentity:n}:{},projectRoot:t.projectRoot,startedAt:t.startedAt}}catch{return null}}function dn(e,t,n,r){if(!e)return{kind:"stopped"};if(e.protocolVersion!==ce)return{kind:"incompatible",state:e,reason:"protocol"};if(e.projectRoot!==t.projectRoot)return{kind:"incompatible",state:e,reason:"project"};let o=t.worktreeKind==="git"?t.worktreeId:void 0;if(e.worktreeId!==o)return{kind:"incompatible",state:e,reason:"worktree"};if(e.cliVersion!==t.cliVersion)return{kind:"incompatible",state:e,reason:"cli-version"};if(!r(e.pid))return{kind:"stale",state:e,reason:"dead-process"};let i=Date.parse(e.heartbeatAt);return n-i>de?{kind:"stale",state:e,reason:"old-heartbeat"}:{kind:"live",state:e}}function ye(e,t){switch(e){case"status":return{kind:"report",classification:t};case"ensure":switch(t.kind){case"stopped":return{kind:"start"};case"stale":return t.reason==="old-heartbeat"?{kind:"refuse-replace",state:t.state,reason:"old-heartbeat"}:{kind:"start"};case"live":return{kind:"reuse",state:t.state};case"incompatible":return{kind:"replace",state:t.state};default:return me(t)}case"stop":switch(t.kind){case"stopped":return{kind:"already-stopped"};case"stale":return t.reason==="old-heartbeat"?{kind:"signal-stop",state:t.state}:{kind:"clean-stale",state:t.state};case"live":case"incompatible":return{kind:"signal-stop",state:t.state};default:return me(t)}default:return me(e)}}function Or(e){return e.idleTimeoutMs===0||e.watcher.state!=="idle"||(e.liveSessions??0)>0?!1:e.nowMs-e.lastActivityAtMs>=e.idleTimeoutMs}function it(e,t,n,r){let o=n.monotonicNow??_,i=o()+r;for(;o()<=i;){let s=U(e,t).classification;if(s.kind==="live")return s.state;n.sleep(ge)}return null}function ve(e,t,n){let{pid:r}=e;if(!n.isProcessAlive(r))return;st(e,n),n.signalProcess(r);let o=t.stopTimeoutMs??rn,i=n.monotonicNow??_,s=i()+o;for(;i()<=s;){if(!n.isProcessAlive(r))return;n.sleep(ge)}if(!n.forceSignalProcess)throw new Error(`codebaseiq watch service pid ${r} did not stop within ${o}ms and forced termination is unavailable.`);st(e,n),n.forceSignalProcess(r);let a=t.forceStopTimeoutMs??on,c=i()+a;for(;i()<=c;){if(!n.isProcessAlive(r))return;let d=n.readProcessIdentity(r);if(e.processIdentity&&d&&!te(e.processIdentity,d))return;n.sleep(ge)}throw new Error(`codebaseiq watch service pid ${r} remained alive ${a}ms after forced termination.`)}function O(e,t,n){if(rt(e.statePath,{force:!0}),rt(e.activityPath,{force:!0}),ke(e.lockPath)?.pid===t&&!n.isProcessAlive(t)){let o={...ie,wallNow:n.now,isProcessAlive:n.isProcessAlive,readProcessIdentity:n.readProcessIdentity},i=se(e.lockPath,{parseLegacy:B,runtime:o});_e(e.lockPath,i,{parseLegacy:B,runtime:o})}}function ln(e,t,n){return`error: codebaseiq watch is already running for ${V(t)}${n?` (pid ${n.pid}, started ${n.startedAt}; lock: ${e})`:` (lock: ${e})`}. Stop that watcher before starting another.`}function G(e,t){try{(t.recordActivity??ct)(e,t.now())}catch(n){let r=un(n);if(r!=="EPERM"&&r!=="EACCES"&&r!=="EROFS")throw n}}function un(e){return e.code}var Se={now:Date.now,monotonicNow:_,isProcessAlive:re,readProcessIdentity:ne,spawnServer(e,t,n,r,o){if(!en(e))throw new Error(`Watch service helper was not found at ${e}. Run npm run build first.`);Zt(process.execPath,[e,t,n,JSON.stringify(r)],{detached:!0,stdio:"ignore",windowsHide:!0,env:{...process.env,...o,CODEBASEIQ_SKIP_WATCH_SERVICE:"1"}}).unref()},signalProcess(e){process.kill(e,"SIGTERM")},forceSignalProcess(e){process.kill(e,"SIGKILL")},sleep(e){let t=new Int32Array(new SharedArrayBuffer(4));Atomics.wait(t,0,0,e)}};function st(e,t){if(!e.processIdentity)throw new Error(`Refusing to signal codebaseiq watch pid ${e.pid}: its ownership record has no process identity.`);let n=t.readProcessIdentity(e.pid);if(!n)throw new Error(`Refusing to signal codebaseiq watch pid ${e.pid}: its process identity is unavailable.`);if(!te(e.processIdentity,n))throw new Error(`Refusing to signal codebaseiq watch pid ${e.pid}: its process identity does not match the ownership record.`)}function me(e){throw new Error(`Unhandled watch service value: ${JSON.stringify(e)}`)}import{existsSync as m,mkdirSync as pn,rmdirSync as hn,unlinkSync as fn}from"fs";import{homedir as mn}from"os";import{basename as vt,dirname as Q,isAbsolute as gn,join as l,resolve as xe}from"path";import{fileURLToPath as yn}from"url";var ut=["- `codebaseiq search <exact-text>` \u2014 Where does this exact text occur in current project text, and which aligned compiler symbol owns each line? Requires: One exact text literal or deliberately bounded regular expression; insert `--` before a literal that starts with a dash.","- `codebaseiq outline <file>` \u2014 What symbols and nesting exist in this file? Requires: One exact current project file path.","- `codebaseiq entrypoints [text]` \u2014 Which detected external roots or entry-surface candidates match this text? Requires: Optional exact text to filter candidates; otherwise the current indexed repository.","- `codebaseiq evidence` \u2014 Which exact execution, runtime, data, state, temporal, contract, identity, ownership, or dependency relationships surround these referents? Which related source must be read only when graph evidence leaves a named implementation gap? Requires: One or more exact symbol, file:line, or literal roots plus explicit family, direction, depth, and output bound.","- `codebaseiq inspect` \u2014 Which related source units across several known text, symbol, or location anchors should be read together? Requires: One or more exact text, symbol, or file:line selectors naming the unresolved behavior.","- `codebaseiq code <selectors...>` \u2014 What exact source defines these symbols, ranges, or file surfaces? Requires: One or more exact symbols, file:line ranges, or file paths.","- Choose graph controls explicitly: `execution incoming` \u2014 Who can call or reach this?; `execution outgoing` \u2014 What can this call or reach?; `dataflow incoming` \u2014 Where can this value come from?; `dataflow outgoing` \u2014 Where can this value go?; `runtime both` \u2014 Which producer and consumer rendezvous?; `state both` \u2014 What resource is observed or changed?; `temporal both` \u2014 What occurs before or after this?; `contract both` \u2014 What interface constrains this?; `identity both` \u2014 Are these observations the same entity?; `ownership both` \u2014 What contains or owns this?; `dependencies outgoing` \u2014 What does this statically rely on?. The CLI does not infer them from English intent.","- Calibration: exact is directly observed; derived is deterministically computed; candidate needs confirmation; mixed discloses its constituents; unknown cannot support a stronger claim. Read coverage and recovery before making absence claims.","- The controls above are complete for ordinary exploration. Run `codebaseiq capabilities --matrix` only when a named claim depends on uncertain provider support; do not run it for routine orientation."],_r=[{stage:"locate",id:"search",command:"search <exact-text>",question:"Where does this exact text occur in current project text, and which aligned compiler symbol owns each line?",requiredInput:"One exact text literal or deliberately bounded regular expression; insert `--` before a literal that starts with a dash.",returnedFact:"exact cardinality, bounded identities and source, and scope commands that recover withheld matches",evidenceCeiling:"Exact current-text cardinality and locations within reported text coverage; compiler ownership only where aligned.",nonClaim:"Structural source ranking orders exact matches but does not establish task relevance. A literal co-occurrence does not establish a graph relationship.",outputCost:"small",contrasts:["outline: search locates exact text across files; outline enumerates compiler-owned constructs in one known file."],gapClosingCommands:["evidence","inspect","code"]},{stage:"locate",id:"outline",command:"outline <file>",question:"What symbols and nesting exist in this file?",requiredInput:"One exact current project file path.",returnedFact:"symbol names, nesting, and line ranges",evidenceCeiling:"Exact compiler-owned constructs and ranges when the file is indexed; no invented semantic overlay.",nonClaim:"File ownership and nesting do not establish execution or task relevance.",outputCost:"small",contrasts:["search: outline enumerates constructs in one known file; search locates exact text across current project text.","code: outline returns identities and ranges; code materializes exact source for selected identities."],gapClosingCommands:["evidence","inspect","code"]},{stage:"locate",id:"entrypoints",command:"entrypoints [text]",question:"Which detected external roots or entry-surface candidates match this text?",requiredInput:"Optional exact text to filter candidates; otherwise the current indexed repository.",returnedFact:"entry symbols with files, confidence, evidence, and indexed caller counts",evidenceCeiling:"Source/compiler-grounded entry evidence and indexed caller counts; exported-only candidates remain candidates.",nonClaim:"A package-public export or zero indexed callers is an entry candidate, not proof of runtime ingress. Entry classification does not establish that the callable executes.",outputCost:"bounded",contrasts:["entry-map: entrypoints locates possible external roots; entry-map traverses static calls from one selected root.","search: entrypoints classifies callable roots; search only locates exact text and ownership."],gapClosingCommands:["evidence","inspect","code"]},{stage:"project",id:"evidence",command:"evidence",question:"Which exact execution, runtime, data, state, temporal, contract, identity, ownership, or dependency relationships surround these referents? Which related source must be read only when graph evidence leaves a named implementation gap?",requiredInput:"One or more exact symbol, file:line, or literal roots plus explicit family, direction, depth, and output bound.",returnedFact:"batched exact selectors and typed graph relationships; compact endpoints with exact locations and follow-up commands; coverage and recoverable omissions; exact source-recovery command when source was requested with a graph projection; explicit ambiguity failure with exact rerun commands",evidenceCeiling:"Typed edges only to each registered provider ceiling within the explicitly selected projection and reported coverage.",nonClaim:"The projection does not infer which relationships are relevant to the user task. Reference, dependency, data, state, temporal, contract, and identity edges do not become execution claims.",outputCost:"bounded",contrasts:["refs: refs enumerates direct reference sites; evidence traverses explicitly selected typed relationships.","call-graph: call-graph specializes in static calls; evidence can combine execution with other selected families.","value-flow: value-flow specializes in proved transfers; evidence projects bounded dataflow alongside other families.","dependence-slice: dependence-slice computes a program-dependence slice; evidence performs bounded graph projection."],gapClosingCommands:["inspect","code"]},{stage:"read",id:"inspect",command:"inspect",question:"Which related source units across several known text, symbol, or location anchors should be read together?",requiredInput:"One or more exact text, symbol, or file:line selectors naming the unresolved behavior.",returnedFact:"one ranked, deduplicated semantic packet plus exact selector cardinality and explicit expansion coverage",evidenceCeiling:"Complete current source for every materialized syntax unit; bounded selector and packet coverage remain explicit.",nonClaim:"A source packet does not choose which implementation details are relevant to the user task. A reference mention does not establish executable reachability.",outputCost:"potentially-large",contrasts:["code: inspect batches bounded behavior or source gaps; code materializes complete exact source.","evidence: inspect reads implementation units; evidence projects typed relationships without source."],gapClosingCommands:[]},{stage:"read",id:"code",command:"code <selectors...>",question:"What exact source defines these symbols, ranges, or file surfaces?",requiredInput:"One or more exact symbols, file:line ranges, or file paths.",returnedFact:"per-selector resolution, complete definition source, exact ranges with statically attributed same-file call closure, file export surfaces, omitted-local ledgers, and line ranges",evidenceCeiling:"Exact current source bytes for every resolved selector, with omitted file-local constructs disclosed.",nonClaim:"Source materialization does not establish callers, runtime reachability, or task relevance by itself.",outputCost:"potentially-large",contrasts:["inspect: code materializes complete exact source; inspect batches bounded behavior or source gaps.","outline: code reads selected implementations; outline enumerates file structure without reading every body."],gapClosingCommands:[]}];var g="<!-- codebaseiq:agent-setup:begin -->",R="<!-- codebaseiq:agent-setup:end -->",vn="# codebaseiq:agent-setup",X=[".codex/hooks.json",".claude/settings.local.json"],pt="# codebaseiq:local-agent-hooks:begin",ht="# codebaseiq:local-agent-hooks:end",we="hook-architecture-stop",kt=["claude","codex"],P={claude:".claude/settings.local.json",codex:".codex/hooks.json"},St="sentinel-hook.mjs",kn=l("dist","sentinel-hook.js"),Sn=l("dist","cli.js"),bn="cli-path",xn="installed-projects.json";function Yr(e){let t=e.written.length+e.unchanged.length,n=e.skipped.length;return{verdict:n===0?"ready":t===0?"blocked":"partial",ready:t,skipped:n}}function Zr(e,t={}){let n={written:[],unchanged:[],skipped:[]};return wn(e,n),t.architectureHook!==!1&&En(e,n,t.architectureHook),n}function eo(e,t={}){let n={removed:[],unchanged:[],skipped:[]};return mt(e,"AGENTS.md",t,n),mt(e,"CLAUDE.md",t,n),xt(e,t,n,r=>Ot(Wn(r))),qt(e,t,n),An(e,t,n),n}function wn(e,t){let n=[g,"## codebaseiq","","This repository uses codebaseiq as its primary code exploration surface.","","codebaseiq separates two responsibilities: the agent decides what repository fact it needs, while the tool locates exact referents and reports compiler, runtime, data, state, temporal, contract, identity, ownership, and dependency evidence without guessing task relevance. The ordinary loop is locate an exact root, project explicitly chosen relationships, read behavior only for a named remaining gap, then stop when the requested claims are established.","","- Use codebaseiq for repository exploration, including literal search and exact source reads. Native tools are for applying edits, running checks, binary content, or a specific unsupported gap that codebaseiq has explicitly reported\u2014not a parallel exploration workflow.","- Before exploring, state the few material repository facts the answer depends on. Include behavior-changing predicates, authorization checks, data reshaping, hard bounds, runtime crossings, durable state changes, emitted notifications, returned values, relevant sibling outcomes, and externally visible ordering only when the request depends on them.","- For end-to-end explanations, use the installed codebaseiq-explore guidance to maintain the evidence ledger and audit the final answer; codebaseiq supplies the repository observations.",...ut,"- Any exact symbol or `file:line` returned by a locator is immediately usable as a graph root. There is no required anchor-discovery phase and locator ordering never proves task relevance. For an end-to-end question, include the initiating owner as a root or request incoming execution capable of exposing it; do not assume a core type is the ingress. Locate independent roots together when the question already implies several participants.","- A materialized evidence projection requires repeated `--symbol`, `--at`, or `--search` selectors plus one or more repeated `--edge <family>` flags, explicit `--direction incoming|outgoing|both`, `--depth <n>`, and `--max-edges <n>`. The agent chooses the relationships capable of establishing its claim; the CLI resolves identity, direction, evidence strength, provider support, and coverage. Use optional exact `--subtype <subtype>` and `--connecting` only when the selected roots themselves must be connected. Never request `complete`, `all`, or every family merely to discover what exists; use `--inventory-only` when only counts can determine the next bounded projection.","- Treat execution calls and exact runtime handoffs as executable reachability. Dataflow, state, temporal, contract, identity, ownership, and dependency edges say what a path carries, changes, orders, constrains, identifies, contains, or relies on; they do not become call claims. Treat exact edges as facts only within their stated coverage and candidate edges as leads requiring source confirmation.","- Read every packet as a coverage contract. `accounted` means the requested bounded projection reports every omission; `bounded` means requested edges were placed in stable recoverable folds by the output budget; `incomplete` means a selector or provider could not be resolved. None proves the user task complete, and missing output is no evidence of absence.","- Prefer batched locators, projections, and gap reads. Query count measures exploration efficiency; it never makes a known recoverable material fact optional. Before drilling down, name the still-missing fact. Expand only a printed fold or exact adjacent identity that can establish it; batch independent roots and gaps instead of shuttling between abstraction levels, and repeat only while a named fact remains unresolved.","- Use `codebaseiq inspect --symbol <symbol> --symbol <symbol> --at <file:line> --view behavior` for several named behavioral gaps. Connected behavior is already source evidence; do not reread lines it rendered. Use `codebaseiq code <symbol-or-range>` only when exact implementation syntax can change the decision. Do not replace these reads with `rg`, `grep`, `sed`, or `nl`.","- For a multi-step mutation, preserve later compaction, rollback, and cleanup. For every event, log, or outbox write, preserve its operation and record identity. For coordination, state the lock scope and which checks and writes occur inside it. State whether interruption is prevented, atomic, rolled back, or repaired later. Resolve exact constant values when they can change the answer.","- For a tiered policy or dispatcher, preserve the precedence of its tiers and the exact scope of every bypass; never imply that a later bypass can skip an earlier hard rejection unless the rendered condition proves it.","- For a stateful owner, preserve its lifetime and sharing scope, including whether it is a singleton, shared registry, per-session instance, or per-invocation value.","- Use `codebaseiq diff-impact` to map changed symbols and downstream consumers after a nontrivial edit.","- Use `codebaseiq architecture` to inspect explicit structural rules.","- Use `codebaseiq health` to find React, Vue, duplication, complexity, drift, and cleanup candidates.","- Before claiming a complete relationship set or an absence, inspect coverage and use `--full` only when complete coverage can change the decision. A bounded or unsupported result cannot establish that no caller, route, branch, poller, or consumer exists.","- Before claiming what every callsite passes, read the `trace` or `evidence` claim-support section. Only an eligible callsite-argument claim is backed by complete syntactic invocations; bounded context is not proof.","- Prefer human output for agent reading. Use `--json --result-only` only for a programmatic consumer.","- Never rerun a successful human command as JSON. Before each drilldown, name the still-unanswered fact and check whether an earlier packet already establishes it; if so, update the ledger or draft without another query. Stop when no unanswered fact remains because every additional reasoning step pays again for the accumulated context.","- Before answering, compare the draft to selected statement-complete behavior. Preserve every material behavior-changing predicate, returned default, separately merged field, cache invalidation, and cleanup effect. Do not collapse fields with different operations into a generic summary, and do not re-query evidence already in context.","- With an explicit CODEBASEIQ_SESSION, a complete source unit, a byte-identical exact subset of a prior exact source read, or a graph unit/edge may be replaced by a visible receipt from the same index generation. Preview coverage never suppresses an exact unit; changed bytes, changed graph content, a new generation, or --reemit force full evidence.","- If output emits `Continue exactly:`, run that command unchanged until transport is complete.","- When architecture rules are configured and clean, setup installs one checkout-local Stop hook. It checks architecture only after indexed source changes.","- Commit relevant `.codebaseiq/suppressions/*.json` records with the change. Do not commit local agent-tool settings.",R].join(`
2
- `);ft(e,"AGENTS.md",n,t);let r=[g,"@AGENTS.md",R].join(`
3
- `);ft(e,"CLAUDE.md",r,t,o=>o.includes("@AGENTS.md")&&!o.includes(g))}function ft(e,t,n,r,o){let i=l(e,t),s=!1,a=Re(i,t,r,c=>{if(o?.(c.text))return s=!0,{kind:"unchanged"};let d=Rn(c.text,n);return d===c.text?{kind:"unchanged"}:{kind:"write",text:d,...c.revision.exists?{}:{mode:420}}});a&&(!a.changed||s?r.unchanged.push(t):r.written.push(t))}function mt(e,t,n,r){let o=l(e,t);if(n.dryRun){if(!m(o)){r.unchanged.push(t);return}try{let s=f(o,"agent instruction file");s.includes(g)?(gt(s),r.removed.push(t)):r.unchanged.push(t)}catch(s){r.skipped.push({target:t,reason:s instanceof Error?s.message:String(s)})}return}let i=Re(o,t,r,s=>{if(!s.revision.exists||!s.text.includes(g))return{kind:"unchanged"};let a=gt(s.text);return a.length===0?{kind:"delete"}:{kind:"write",text:a}});i&&(i.changed?r.removed.push(t):r.unchanged.push(t))}function Rn(e,t){if(bt(e)==="present"){let r=new RegExp(`${g}[\\s\\S]*?${R}`);return e.replace(r,t)}return e.length>0?`${e.replace(/\n*$/,`
4
-
5
- `)}${t}
6
- `:`${t}
7
- `}function gt(e){bt(e);let t=new RegExp(`${g}[\\s\\S]*?${R}`),n=e.replace(t,"").replace(/\n{3,}/g,`
8
-
9
- `).trim();return n.length===0?"":`${n}
10
- `}function bt(e){let t=e.split(g).length-1,n=e.split(R).length-1;if(t===0&&n===0)return"absent";if(t===1&&n===1&&e.indexOf(g)<e.indexOf(R))return"present";throw new Error("managed codebaseiq markers are incomplete, duplicated, or out of order")}function Re(e,t,n,r){try{return W(e,r,{maxRetries:0})}catch(o){n.skipped.push({target:t,reason:o instanceof Error?o.message:String(o)});return}}function An(e,t,n){let r=".git/hooks/pre-commit",o=l(e,r);if(!m(o)){n.unchanged.push(r);return}if(!f(o,"pre-commit hook").includes(vn)){n.skipped.push({target:r,reason:"pre-commit hook is not managed by codebaseiq"});return}if(t.dryRun){n.removed.push(r);return}Re(o,r,n,()=>({kind:"delete"}))?.changed&&n.removed.push(r)}function En(e,t,n={}){let r=(n.inspectReadiness??Cn)(e);if(r.state==="not-configured")return;if(r.state==="blocked"){t.skipped.push({target:"architecture Stop hook",reason:r.reason});return}let o=n.commandPrefix??"codebaseiq";for(let i of X){if(L(e,i)){t.skipped.push({target:i,reason:"tracked repository config; the checkout-local hook installer will not modify it"});continue}Ee(l(e,i),i,t,s=>In(s,o))}Ct(e,t)}function xt(e,t,n,r){for(let o of X){let i=l(e,o);if(m(i)){if(L(e,o)){n.skipped.push({target:o,reason:"tracked repository config; the checkout-local hook remover will not modify it"});continue}if(t.dryRun){try{let s=At(i);JSON.stringify(r(s))!==JSON.stringify(s)&&n.removed.push(o)}catch(s){n.skipped.push({target:o,reason:v(s)})}continue}Ee(i,o,n,r,!0)}}}function Cn(e){let t=je(e);if(!t.architecture||t.architecture.boundaries.length===0)return{state:"not-configured"};let n=Te(e,t),r=Fe(e,t,n);if(r.state!=="fresh")return{state:"blocked",reason:`the index is ${r.state}; refresh it before installing a persistent architecture grader`};let o;try{o=Ge(e);let i=Be(Ue(o));return i.length>0?{state:"blocked",reason:`the current architecture baseline has ${i.length} enforced violation(s); make the declared policy clean before installing the Stop hook`}:{state:"ready"}}catch(i){return{state:"blocked",reason:v(i)}}finally{o?.close()}}function In(e,t="codebaseiq"){let n=H(e.hooks),r=Array.isArray(n.Stop)?n.Stop:[],o={type:"command",command:`${t} ${we}`,timeout:120,statusMessage:"Checking architecture boundaries"};return{...e,hooks:{...n,Stop:wt(r,{hook:o},Rt)}}}function to(e,t){return e===we&&t.sentinel?.enabled===!0}function Wn(e){let t=H(e.hooks),n=Array.isArray(t.Stop)?t.Stop:[],r=Tn(n),o={...t};r.length>0?o.Stop=r:delete o.Stop;let i={...e};return Object.keys(o).length>0?i.hooks=o:delete i.hooks,i}function H(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}function Tn(e){return e.map(t=>({...t,hooks:Array.isArray(t.hooks)?t.hooks.filter(n=>!Rt(n)):[]})).filter(t=>t.hooks.length>0)}function Ae(e){return typeof e=="object"&&e!==null&&Array.isArray(e.hooks)}function wt(e,t,n){let r=!1,o=[];for(let i of e){if(!Ae(i)||!i.hooks.some(n)){o.push(i);continue}let s=i.hooks.every(n),a=[],c=!1;for(let d of i.hooks)n(d)?r||(a.push(t.hook),r=!0,c=!0):a.push(d);a.length!==0&&o.push(c&&s?qn({...i,hooks:a},t.matcher):{...i,hooks:a})}return r||o.push({...t.matcher!==void 0?{matcher:t.matcher}:{},hooks:[t.hook]}),o}function qn(e,t){let{matcher:n,...r}=e;return t===void 0?r:{matcher:t,...r}}function Rt(e){if(!e||typeof e!="object")return!1;let t=e.command;return typeof t=="string"&&new RegExp(`(?:^|\\s)${we}$`,"u").test(t)}function Ee(e,t,n,r,o=!1){try{W(e,s=>{let a=s.revision.exists?Et(s.text,e):{},c=r(a);return JSON.stringify(c)===JSON.stringify(a)?{kind:"unchanged"}:o&&Object.keys(c).length===0?{kind:"delete"}:{kind:"write",text:`${JSON.stringify(c,null,2)}
11
- `,mode:384}}).changed?"written"in n?n.written.push(t):n.removed.push(t):o||n.unchanged.push(t)}catch(i){n.skipped.push({target:t,reason:v(i)})}}function At(e){return Et(f(e,"agent hook settings"),e)}function Et(e,t){let n=JSON.parse(e);if(!n||typeof n!="object"||Array.isArray(n))throw new Error(`Cannot update ${t}: the hook config is not a JSON object.`);return n}function Ct(e,t){let n=oe(e,["rev-parse","--git-path","info/exclude"]),r=n?Pe(e,n):void 0;if(!r||!m(Q(r))){t.skipped.push({target:".git/info/exclude",reason:"Git metadata was not found; local hook files may appear as untracked"});return}let o=On(oe(e,["rev-parse","--show-prefix"])??"");try{W(r,i=>{let s=new RegExp(`${pt}([\\s\\S]*?)${ht}\\n?`,"gu"),a=[...i.text.matchAll(s)].flatMap(A=>A[1].split(`
12
- `).filter(Nt=>Nt!=="")),c=i.text.replace(s,"").replace(/\n*$/u,""),d=[...X,$e].map(A=>`/${o}${A}`),p=[pt,...new Set([...a,...d]),ht].join(`
13
- `),u=`${c}${c?`
14
-
15
- `:""}${p}
16
- `;return u===i.text?{kind:"unchanged"}:{kind:"write",text:u,mode:420}})}catch(i){t.skipped.push({target:".git/info/exclude",reason:v(i)})}}function On(e){return e.replace(/[\\*?[]/gu,"\\$&")}function v(e){return e instanceof Error?e.message:String(e)}var It={claude:[{event:"SessionStart",timeout:5},{event:"UserPromptSubmit",timeout:5},{event:"PostToolUse",matcher:"Edit|Write|MultiEdit",timeout:15,async:!0},{event:"Stop",timeout:30},{event:"SessionEnd",timeout:2}],codex:[{event:"SessionStart",timeout:5},{event:"UserPromptSubmit",timeout:5},{event:"PostToolUse",matcher:"apply_patch|Edit|Write",timeout:15},{event:"Stop",timeout:30}]};function Y(e){let t=l(e,"bin");return{directory:t,script:l(t,St),version:l(t,"sentinel-hook.version"),manifest:l(t,"package.json"),cliPath:l(t,bn)}}function Wt(e={}){let t=Pn(e.packageRoot??Q(yn(import.meta.url)));if(!t)return{state:"skipped",reason:"the codebaseiq package root was not found"};let n=l(t.root,kn);if(!m(n))return{state:"skipped",reason:"build the package first (dist/sentinel-hook.js was not found)"};let r=Y(e.cacheRoot??y());try{let o=`${JSON.stringify({name:"codebaseiq",version:t.version,private:!0},null,2)}
17
- `,i=[K(r.script,Z(n,Tt("sentinel hook bundle"))),K(r.version,Buffer.from(`${t.version}
18
- `)),K(r.manifest,Buffer.from(o)),K(r.cliPath,Buffer.from(`${xe(t.root,Sn)}
19
- `))];return{state:"installed",script:r.script,version:t.version,changed:i.some(Boolean)}}catch(o){return{state:"skipped",reason:`the hook binary could not be installed: ${v(o)}`}}}function no(e,t={}){let n=Y(t.cacheRoot??y());if(!(be(n.version,"sentinel hook version")===e&&m(n.cliPath)))return Wt(t)}function Pn(e){let t=e;for(;;){try{let r=JSON.parse(f(l(t,"package.json"),"package manifest"));if(r.name==="codebaseiq"&&typeof r.version=="string")return{root:t,version:r.version}}catch{}let n=Q(t);if(n===t)return;t=n}}function Tt(e){return{maxBytes:Ie,inputKind:e}}function K(e,t){try{if(Z(e,Tt("sentinel hook file")).equals(t))return!1}catch{}return De(e,t),!0}function ro(e,t={}){let n=t.hosts??kt,r=t.cacheRoot??y(),o=Wt({packageRoot:t.packageRoot,cacheRoot:r}),i={written:[],unchanged:[],skipped:[],binary:o,notices:[]};if(o.state==="skipped")return i.skipped.push({target:"sentinel hook binary",reason:o.reason}),i;for(let a of n){let c=P[a];if(L(e,c)){i.skipped.push({target:c,reason:"tracked repository config; the checkout-local hook installer will not modify it"});continue}let d=[];Ee(l(e,c),c,i,p=>{let u=Dn(p,Mn(a,o.script,t.nodeExecutable));return d=Hn(p,u),u}),a==="codex"&&d.length>0&&i.written.includes(c)&&i.notices.push(`Codex must re-approve the changed hooks (${d.join(", ")}): open Codex once in this project and approve them. The approval it recorded for the old command no longer applies, and codebaseiq can only see that an approval exists, not that it still matches.`)}if(Ct(e,i),n.map(a=>P[a]).some(a=>i.written.includes(a)||i.unchanged.includes(a)))try{Vn(r,e)}catch(a){i.skipped.push({target:"sentinel project registry",reason:v(a)})}return i}function Hn(e,t){let n=o=>`${o.event}:${o.group}:${o.index}:${JSON.stringify(o.hook)}`,r=new Set(z(t).map(n));return[...new Set(z(e).filter(o=>!r.has(n(o))).map(o=>o.event))]}function _n(e,t={}){let n={removed:[],unchanged:[],skipped:[]};return xt(e,t,n,Ot),qt(e,t,n),n}function oo(e={}){let t=e.cacheRoot??y(),n={removed:[],unchanged:[],skipped:[]};for(let o of Bn(t)){if(!m(o)){e.dryRun||Mt(t,o);continue}let i=_n(o,{dryRun:e.dryRun,cacheRoot:t});n.removed.push(...i.removed.map(s=>l(o,s))),n.skipped.push(...i.skipped.map(s=>({...s,target:l(o,s.target)})))}let r=Y(t);if(n.skipped.length>0)return m(r.script)&&n.skipped.push({target:r.script,reason:"kept: hooks that run it could not be removed from every project; run uninstall again once they can"}),n;for(let o of[r.script,r.version,r.manifest,r.cliPath])if(m(o)&&(n.removed.push(o),!e.dryRun))try{fn(o)}catch(i){n.skipped.push({target:o,reason:v(i)})}if(!e.dryRun)try{hn(r.directory)}catch{}return n}function qt(e,t,n){let r=X;if(!(t.dryRun||n.skipped.some(o=>r.includes(o.target))))try{Mt(t.cacheRoot??y(),e)}catch(o){n.skipped.push({target:"sentinel project registry",reason:v(o)})}}function J(e){if(!e||typeof e!="object")return!1;let{command:t,args:n}=e;return Array.isArray(n)&&n.includes(I)?!0:typeof t=="string"&&t.split(/\s+/u).includes(I)}function Dn(e,t){let n={...H(e.hooks)};for(let{event:r,...o}of t){let i=n[r];n[r]=wt(Array.isArray(i)?i:[],o,J)}return{...e,hooks:n}}function Ot(e){let t=H(e.hooks),n={},r=!1;for(let[i,s]of Object.entries(t)){if(!Array.isArray(s)){n[i]=s;continue}let a=[];for(let c of s){if(!Ae(c)||!c.hooks.some(J)){a.push(c);continue}r=!0;let d=c.hooks.filter(p=>!J(p));d.length>0&&a.push({...c,hooks:d})}(a.length>0||s.length===0)&&(n[i]=a)}if(!r)return e;let o={...e};return Object.keys(n).length>0?o.hooks=n:delete o.hooks,o}function Mn(e,t,n=process.execPath){return It[e].map(r=>({event:r.event,...r.matcher!==void 0?{matcher:r.matcher}:{},hook:e==="claude"?Nn(t,r):Ln(t,r,n)}))}function Nn(e,t){return{type:"command",command:"node",args:[e,"--host","claude",...t.async?["--async"]:[],I],...t.async?{async:!0,asyncRewake:!0}:{},timeout:t.timeout}}function Ln(e,t,n){let r=gn(n)&&/^node(?:\.exe)?$/iu.test(vt(n))?n:"node";return{type:"command",command:`${process.platform==="win32"?"& ":""}${yt(r)} ${yt(e)} --host codex ${I}`,timeout:t.timeout}}function yt(e){if((process.platform==="win32"?/["\r\n%$`]/u:/["\r\n$`]/u).test(e))throw new Error(`${JSON.stringify(e)} cannot be quoted in a Codex hook command`);return`"${e}"`}function z(e){let t=[];for(let[n,r]of Object.entries(H(e.hooks)))Array.isArray(r)&&r.forEach((o,i)=>{Ae(o)&&o.hooks.forEach((s,a)=>{J(s)&&t.push({event:n,group:i,index:a,hook:s})})});return t}function Pt(e){if(m(e))try{return At(e)}catch{return}}function io(e,t={}){let n=Y(t.cacheRoot??y()),r=be(n.version,"sentinel hook version"),o=be(n.cliPath,"sentinel hook CLI path");return{binary:{script:n.script,present:m(n.script),...r?{version:r}:{},...o?{cliTarget:o}:{}},hosts:kt.map(i=>{let s=P[i],a=Pt(l(e,s)),c=a?z(a):[],d=It[i].map(u=>u.event),p=new Set(c.map(u=>u.event));return{host:i,file:s,events:d.filter(u=>p.has(u)),missing:d.filter(u=>!p.has(u)),scripts:[...new Set(c.flatMap(u=>$n(u.hook)))]}})}}function be(e,t){try{return f(e,t).trim()||void 0}catch{return}}function $n(e){return(Array.isArray(e.args)?e.args.filter(n=>typeof n=="string"):[...e.command.matchAll(/"([^"]*)"|(\S+)/gu)].map(n=>n[1]??n[2]??"")).filter(n=>vt(n)===St)}function so(e,t={}){let n=l(e,P.codex),r=Pt(n),o=r?z(r):[];if(o.length===0)return;let i=l(t.codexHome??process.env.CODEX_HOME??l(mn(),".codex"),"config.toml"),s=Gn(i),a=[...new Set([n,l(k(e),P.codex)])];return{configPath:i,hooks:o.map(({event:c,group:d,index:p})=>{let u=`:${Un(c)}:${d}:${p}`;return{event:c,key:`${n}${u}`,trusted:a.some(A=>s.has(Ht(`${A}${u}`)))}})}}var jn=/^\s*\[hooks\.state\.(?:'([^']*)'|"((?:[^"\\]|\\.)*)")\]\s*(?:#.*)?$/u,Fn=/^\s*trusted_hash\s*=\s*"sha256:[0-9a-f]+"/u;function Gn(e){let t=new Set,n;try{n=f(e,"Codex config")}catch{return t}let r;for(let o of n.split(/\r?\n/u)){let i=jn.exec(o);i?r=Ht(i[1]??(i[2]??"").replace(/\\(["\\])/gu,"$1")):/^\s*\[/u.test(o)?r=void 0:r!==void 0&&Fn.test(o)&&t.add(r)}return t}function Un(e){return e.replace(/([a-z])([A-Z])/gu,"$1_$2").toLowerCase()}function Ht(e){return process.platform==="win32"?e.replaceAll("/","\\").toLowerCase():e}function ao(e){let t={...Le.delivery};try{let n=JSON.parse(f(l(e,le,Me),"sentinel settings")).delivery;for(let r of Ne){let o=n?.[r];(o==="shadow"||o==="live")&&(t[r]=o)}}catch{}return t}function Ce(e){return l(e,le,xn)}function Bn(e=y()){try{return _t(f(Ce(e),"sentinel project registry"))}catch{return[]}}function _t(e){try{let{projects:t}=JSON.parse(e);return Array.isArray(t)?t.filter(n=>typeof n=="string"):[]}catch{return[]}}function Dt(e,t){let n=Ce(e);pn(Q(n),{recursive:!0}),W(n,r=>{let o=t(r.revision.exists?_t(r.text):[]);return o===void 0?{kind:"unchanged"}:{kind:"write",text:`${JSON.stringify({projects:o},null,2)}
20
- `,mode:384}})}function Vn(e,t){let n=k(xe(t));Dt(e,r=>r.includes(n)?void 0:[...r,n].sort())}function Mt(e,t){if(!m(Ce(e)))return;let n=k(xe(t));Dt(e,r=>r.includes(n)?r.filter(o=>o!==n):void 0)}export{Je as a,er as b,tr as c,Kt as d,nr as e,rr as f,or as g,Rr as h,an as i,Ar as j,at as k,Er as l,cn as m,Cr as n,Ir as o,Wr as p,Tr as q,qr as r,Or as s,_r as t,Yr as u,Zr as v,eo as w,to as x,Ct as y,no as z,ro as A,_n as B,oo as C,io as D,so as E,ao as F};
21
- //# sourceMappingURL=chunk-GWYZVVKY.js.map
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
- import{d as R,e as k}from"./chunk-D62CTZX6.js";import{i as f,j as L,w as E,x as v}from"./chunk-DUKHVPU5.js";import{connect as D}from"net";import{performance as S}from"perf_hooks";import{createHash as b}from"crypto";import{tmpdir as V,userInfo as j}from"os";import{join as Q}from"path";var c=1,_=1*1024*1024,h=64*1024*1024,y=12e4,x=["NO_COLOR","FORCE_COLOR","CLICOLOR","CLICOLOR_FORCE","TERM","CODEBASEIQ_DEBUG"],O=1500;function P(t){let e=T(),r=b("sha256").update(`${e}\0${t}`).digest("hex");return process.platform==="win32"?`\\\\.\\pipe\\codebaseiq-lane-${r.slice(0,32)}`:Q(Y(),`lane-${r.slice(0,24)}.sock`)}function Y(){let t=T(),e=b("sha256").update(t).digest("hex").slice(0,16);return Q(V(),`codebaseiq-${e}`)}function T(){try{return j().username}catch{return`uid-${typeof process.getuid=="function"?process.getuid():"unknown"}`}}function A(t,e){let r=Buffer.from(JSON.stringify(t),"utf8");if(r.byteLength>e)throw new Error(`query-lane frame of ${r.byteLength} bytes exceeds the ${e}-byte limit`);let n=Buffer.allocUnsafe(4+r.byteLength);return n.writeUInt32LE(r.byteLength,0),r.copy(n,4),n}function w(t,e,r){let n=Buffer.alloc(0),u=!1,i=s=>{u||(u=!0,r(new Error(s)))};return{push(s){if(!u)for(n=n.byteLength===0?s:Buffer.concat([n,s]);n.byteLength>=4;){let a=n.readUInt32LE(0);if(a>t){i(`query-lane frame of ${a} bytes exceeds the ${t}-byte limit`);return}if(n.byteLength<4+a)return;let l=n.subarray(4,4+a);n=n.subarray(4+a);let o;try{o=JSON.parse(l.toString("utf8"))}catch{i("query-lane frame carried invalid JSON");return}if(e(o),u)return}}}}function N(t){if(!t||typeof t!="object")return null;let e=t;if(e.protocolVersion!==c)return null;if(e.ok===!1)return e.code!=="unsupported"&&e.code!=="invalid-request"&&e.code!=="wrong-project"&&e.code!=="busy"&&e.code!=="stale-index"&&e.code!=="ineligible-command"&&e.code!=="execution-error"||typeof e.message!="string"?null:{ok:!1,protocolVersion:c,code:e.code,message:e.message};if(e.ok!==!0)return null;if(e.kind==="accepted"){let n=e.serverPid;return typeof n!="number"||!Number.isInteger(n)||n<=0?null:{ok:!0,kind:"accepted",protocolVersion:c,serverPid:n}}if(e.kind==="executed"){let n=e;return typeof n.serverPid!="number"||!Number.isInteger(n.serverPid)||n.serverPid<=0||typeof n.exitCode!="number"||!Number.isInteger(n.exitCode)||typeof n.stdout!="string"||typeof n.stderr!="string"||typeof n.generation!="string"||!/^[a-f0-9]{64}$/.test(n.generation)||typeof n.durationMs!="number"||!Number.isFinite(n.durationMs)?null:{ok:!0,kind:"executed",protocolVersion:c,serverPid:n.serverPid,exitCode:n.exitCode,stdout:n.stdout,stderr:n.stderr,generation:n.generation,durationMs:n.durationMs}}if(e.kind!=="pong"||typeof e.serverPid!="number"||!Number.isInteger(e.serverPid)||e.serverPid<=0||typeof e.cliVersion!="string"||typeof e.projectRoot!="string"||e.indexGeneration!==void 0&&!/^[a-f0-9]{64}$/.test(e.indexGeneration))return null;let r;if(e.processIdentity!==void 0){let n=E(e.processIdentity);if(!n||n.pid!==e.serverPid)return null;r=n}return{ok:!0,kind:"pong",protocolVersion:c,serverPid:e.serverPid,...r?{processIdentity:r}:{},cliVersion:e.cliVersion,projectRoot:e.projectRoot,...e.indexGeneration!==void 0?{indexGeneration:e.indexGeneration}:{}}}var I=250,q=2e3,C="CODEBASEIQ_NO_DAEMON",$="CODEBASEIQ_DAEMON";async function se(t,e={}){let r=await M(t,{protocolVersion:c,kind:"ping",projectRoot:f(t.projectRoot)},e);if(r.kind!=="ok")return r;let n=r.response;return n.ok!==!0?{kind:"incompatible",reason:`query lane refused ping: ${n.code}: ${n.message}`}:n.kind!=="pong"?{kind:"incompatible",reason:"query lane answered ping with a non-pong response"}:n.serverPid!==r.state.pid?{kind:"incompatible",reason:"query lane responder is not the advertised watch service process"}:n.processIdentity&&r.state.processIdentity&&!v(n.processIdentity,r.state.processIdentity)?{kind:"incompatible",reason:"query lane responder identity differs from the advertised service"}:{kind:"ok",pong:n,roundTripMs:r.roundTripMs,state:r.state}}async function ie(t){let e=t[0];if(!e||e.startsWith("-"))return{served:!1,reason:"no eligible command was invoked"};if(process.env.CODEBASEIQ_INDEX_DB)return{served:!1,reason:"an explicit index database is pinned by the environment"};if(process.env.CODEBASEIQ_SESSION)return{served:!1,reason:"session-ledger evidence runs in-process"};let r;try{let{resolveProjectRoot:d,resolveCliProjectContext:p,residentQueryLaneEligible:U}=await import("./cli-context-FJL2JHOE.js");if(!U(e))return{served:!1,reason:`command ${e} always executes in-process`};let m=d(),g=p(m);r={projectRoot:m,cacheDir:g.paths.cacheDir,enabled:process.env[$]==="1"||g.config.daemon?.enabled===!0}}catch(d){return{served:!1,reason:`project resolution failed: ${d instanceof Error?d.message:d}`}}if(!r.enabled)return{served:!1,reason:"resident execution is not enabled for this project"};let{normalizeLegacyEvidenceInvocation:n}=await import("./invocation-command-descriptors-U76PN7IY.js"),u=["node","codebaseiq",...t];n(u);let i=u.slice(2),s={};for(let d of x){let p=process.env[d];p!==void 0&&(s[d]=p)}let a={protocolVersion:c,kind:"execute",projectRoot:f(r.projectRoot),argv:i,cwd:process.cwd(),envAllowlist:s,tty:{isTTY:process.stdout.isTTY===!0,...typeof process.stdout.columns=="number"?{columns:process.stdout.columns}:{}},deadlineMs:y,clientInvocation:{execPath:process.execPath,...process.argv[1]!==void 0?{scriptPath:process.argv[1]}:{}}},l=await M(r,a,{acceptTimeoutMs:O,responseTimeoutMs:y+5e3});if(l.kind!=="ok")return{served:!1,reason:l.reason};let o=l.response;return o.ok!==!0||o.kind!=="executed"?{served:!1,reason:o.ok===!1?`${o.code}: ${o.message}`:"the lane answered with a non-execution response"}:o.serverPid!==l.state.pid?{served:!1,reason:"the executing process is not the advertised watch service"}:(o.stdout.length>0&&process.stdout.write(o.stdout),o.stderr.length>0&&process.stderr.write(o.stderr),process.exitCode=o.exitCode,{served:!0,exitCode:o.exitCode})}async function M(t,e,r={}){if(process.env[C]==="1")return{kind:"unavailable",reason:`${C}=1 disables the query lane`};let n=B(t);if("reason"in n)return n;let u=r.socketPathOverride??P(t.cacheDir),i=S.now(),s=await W(u,e,r);if("reason"in s)return s;let a=N(s.value);return a?{kind:"ok",response:a,roundTripMs:S.now()-i,state:n.state}:{kind:"incompatible",reason:"query lane returned a response this client cannot validate"}}function F(t){return!!t&&typeof t=="object"&&t.kind==="accepted"&&t.ok===!0}function B(t){let e=k(R(t.cacheDir).statePath);return e?e.projectRoot!==f(t.projectRoot)?{kind:"unavailable",reason:"the published watch service serves a different project root"}:e.queryLane===void 0?{kind:"unavailable",reason:"the running watch service does not advertise a query lane"}:e.queryLane.protocolVersion!==c?{kind:"incompatible",reason:`query lane protocol ${e.queryLane.protocolVersion} does not match client protocol ${c}`}:L(e.pid)?{state:e}:{kind:"unavailable",reason:"the advertised watch service process is not alive"}:{kind:"unavailable",reason:"no watch service state is published for this cache"}}function W(t,e,r){return new Promise(n=>{let u=!1,i=o=>{u||(u=!0,clearTimeout(a),s.destroy(),n(o))},s=D({path:t,timeout:r.connectTimeoutMs??I}),a=setTimeout(()=>i({kind:"unavailable",reason:"query lane response timed out"}),(r.connectTimeoutMs??I)+(r.acceptTimeoutMs??r.responseTimeoutMs??q)),l=w(h,o=>{if(F(o)){clearTimeout(a),a=setTimeout(()=>i({kind:"unavailable",reason:"query lane response timed out after acknowledgement"}),r.responseTimeoutMs??q);return}i({value:o})},o=>i({kind:"unavailable",reason:`query lane response was malformed: ${o.message}`}));s.on("timeout",()=>i({kind:"unavailable",reason:"query lane connection timed out"})),s.on("error",o=>i({kind:"unavailable",reason:`query lane connection failed: ${o.message}`})),s.on("close",()=>i({kind:"unavailable",reason:"query lane closed before responding"})),s.on("data",o=>l.push(o)),s.on("connect",()=>{s.setTimeout(0);try{s.write(A(e,_))}catch(o){i({kind:"unavailable",reason:`query lane request could not be encoded: ${o instanceof Error?o.message:String(o)}`})}})})}export{se as a,ie as b};
3
- //# sourceMappingURL=chunk-JFIA2JI3.js.map
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
- import{b as v}from"./chunk-AQI4N64O.js";import{e as s,fb as E,kb as V,lb as I}from"./chunk-C7QWUBR2.js";import{c as y}from"./chunk-XZEE23VG.js";import{aa as h,ka as S,t as w}from"./chunk-7UCDGXRW.js";import{l as x}from"./chunk-5T44HG5Y.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-JLZLLLW5.js.map