@testmuai/kane-cli 0.8.11 → 0.8.12

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 (213) hide show
  1. package/dist/{ChatSurface-YFJDAXOG.js → ChatSurface-DALSIICW.js} +1 -1
  2. package/dist/{ChromeProfilePicker-PUCZN6WU.js → ChromeProfilePicker-ZMVZH3AK.js} +1 -1
  3. package/dist/{CliFeedbackPrompt-JAIB5MHS.js → CliFeedbackPrompt-K66H7YE6.js} +1 -1
  4. package/dist/{CliUploadProgress-53LQMQJD.js → CliUploadProgress-5DZHZY4M.js} +1 -1
  5. package/dist/{ConfigView-7HFP4OXS.js → ConfigView-S5KBV62S.js} +1 -1
  6. package/dist/EvidenceViewOffer-UACWB3YJ.js +2 -0
  7. package/dist/FolderPicker-YH5TKMX3.js +2 -0
  8. package/dist/{InfoBox-62YG3YNQ.js → InfoBox-7PAM2FQH.js} +1 -1
  9. package/dist/{LinksBox-6NS3GHWO.js → LinksBox-2NVZ3FHJ.js} +1 -1
  10. package/dist/{ProfilesView-HIKK2HPC.js → ProfilesView-SIUBF7IU.js} +1 -1
  11. package/dist/{ProjectPicker-2CJMO5TD.js → ProjectPicker-5NI554X3.js} +1 -1
  12. package/dist/{SaveSessionPrompt-4DTPZSXD.js → SaveSessionPrompt-5OULBV5N.js} +1 -1
  13. package/dist/SingleShotApp-LA3EMPUK.js +2 -0
  14. package/dist/{SummaryBox-A6LKKQXJ.js → SummaryBox-GTGF3CBO.js} +1 -1
  15. package/dist/TestMdRunView-5MNKJJMS.js +2 -0
  16. package/dist/{TestrunEvidenceTable-7SCCTZPH.js → TestrunEvidenceTable-7WBCOGYW.js} +1 -1
  17. package/dist/{WhoamiView-PDMQ6F5N.js → WhoamiView-E2SVBHLC.js} +1 -1
  18. package/dist/{app-download-K2ELUXWR.js → app-download-SAXSYXIV.js} +1 -1
  19. package/dist/{auth-5WJSFLCP.js → auth-3LLVDHOJ.js} +1 -1
  20. package/dist/{binary-QVQRWQFK.js → binary-WSMIRJNC.js} +1 -1
  21. package/dist/{bind-5WELCZ4S.js → bind-A3M4PV4V.js} +3 -3
  22. package/dist/{bootstrap-3LNHRDQH.js → bootstrap-QTVHGL45.js} +1 -1
  23. package/dist/bridge-E2C5VV3H.js +2 -0
  24. package/dist/{changelog-TK6DWFVW.js → changelog-CNYWOB2V.js} +1 -1
  25. package/dist/{chat-committer-MAW25ICC.js → chat-committer-RAOIL2T6.js} +1 -1
  26. package/dist/chat-controller-YJCNU76T.js +2 -0
  27. package/dist/{chunk-5LEO463W.js → chunk-24QPDHRD.js} +1 -1
  28. package/dist/{chunk-DLJIML73.js → chunk-2LXJ2ZM3.js} +1 -1
  29. package/dist/{chunk-GSNGC7HI.js → chunk-2MTAXT2U.js} +1 -1
  30. package/dist/{chunk-5NBT5IVT.js → chunk-3CCD434H.js} +1 -1
  31. package/dist/{chunk-K6BWPGBO.js → chunk-3G3LY6BM.js} +1 -1
  32. package/dist/{chunk-2E55VQYA.js → chunk-3N2YOHD6.js} +1 -1
  33. package/dist/{chunk-OC7TJTQG.js → chunk-3OU2F34I.js} +1 -1
  34. package/dist/{chunk-DHWS7SLT.js → chunk-3XWKKSIM.js} +2 -2
  35. package/dist/{chunk-TB2CCKL7.js → chunk-43DM2I6Q.js} +1 -1
  36. package/dist/{chunk-WRVDIZAI.js → chunk-4ASRA7CD.js} +2 -2
  37. package/dist/{chunk-ZMJD3CI7.js → chunk-4E4GJPEM.js} +1 -1
  38. package/dist/{chunk-CABRAZOL.js → chunk-4O6XBS5G.js} +1 -1
  39. package/dist/{chunk-DJJO4IHY.js → chunk-4T35SA2O.js} +1 -1
  40. package/dist/{chunk-YSNBXUM6.js → chunk-4TZSEC2C.js} +1 -1
  41. package/dist/{chunk-3D7VYEDP.js → chunk-54JZ6VEW.js} +1 -1
  42. package/dist/{chunk-FIODM24X.js → chunk-5A4QG7ZM.js} +1 -1
  43. package/dist/{chunk-A76UL3EN.js → chunk-5AHOVOWV.js} +1 -1
  44. package/dist/{chunk-6DOS5CJ5.js → chunk-5FYO3PFG.js} +1 -1
  45. package/dist/{chunk-QHSF2CXK.js → chunk-5G22NOZK.js} +1 -1
  46. package/dist/{chunk-47WY2637.js → chunk-5KLDW3ZW.js} +58 -57
  47. package/dist/{chunk-7P3JGF2X.js → chunk-6A47PRDS.js} +1 -1
  48. package/dist/{chunk-FYLMTZ3J.js → chunk-6FCPS2VT.js} +1 -1
  49. package/dist/{chunk-A4BDLZOD.js → chunk-75HF3GPO.js} +1 -1
  50. package/dist/{chunk-BE4FBVKY.js → chunk-7KAPHA56.js} +1 -1
  51. package/dist/{chunk-3FJNTRAS.js → chunk-7NXHVC7G.js} +1 -1
  52. package/dist/{chunk-Y4ODYIOP.js → chunk-7R5K4IGS.js} +1 -1
  53. package/dist/{chunk-JJJREAFQ.js → chunk-7RFGO3TH.js} +1 -1
  54. package/dist/{chunk-NVRXDLJN.js → chunk-AFNDJK2A.js} +1 -1
  55. package/dist/{chunk-X6WB2QTT.js → chunk-AHRL4E3M.js} +1 -1
  56. package/dist/{chunk-7KRCBN6X.js → chunk-APZCLVZD.js} +1 -1
  57. package/dist/{chunk-4VZRBBLF.js → chunk-ASYWKYTQ.js} +1 -1
  58. package/dist/{chunk-QIRZBOKA.js → chunk-COVIEKZN.js} +1 -1
  59. package/dist/{chunk-HJBORIFP.js → chunk-CQ3ZQ5UK.js} +3 -3
  60. package/dist/{chunk-4FXSDPQW.js → chunk-DYXYNH6X.js} +1 -1
  61. package/dist/{chunk-OKBEMFAW.js → chunk-EEFZXZTZ.js} +1 -1
  62. package/dist/{chunk-DP7GPS6S.js → chunk-EV64VI66.js} +1 -1
  63. package/dist/{chunk-7HUJVIMO.js → chunk-F2CET54H.js} +2 -2
  64. package/dist/{chunk-NYUMJDCE.js → chunk-FAREJ4P2.js} +1 -1
  65. package/dist/{chunk-CRPBARFG.js → chunk-FBYB3SRE.js} +1 -1
  66. package/dist/{chunk-TSW5A7W3.js → chunk-FHYG3QLL.js} +1 -1
  67. package/dist/{chunk-NLSR2IFN.js → chunk-G2Q2TP3O.js} +1 -1
  68. package/dist/{chunk-F7R6A6P5.js → chunk-G52YPXKT.js} +1 -1
  69. package/dist/{chunk-XB7EMX6J.js → chunk-GNAPBOAJ.js} +1 -1
  70. package/dist/chunk-GRDYYYIQ.js +2 -0
  71. package/dist/{chunk-2ZBY2GME.js → chunk-H6NHARB4.js} +1 -1
  72. package/dist/chunk-H6VS5RYO.js +11 -0
  73. package/dist/{chunk-3PMEHGH3.js → chunk-HPUQJRDX.js} +1 -1
  74. package/dist/{chunk-GV5BX2IQ.js → chunk-HWHLKBUT.js} +1 -1
  75. package/dist/{chunk-VGLY4HWA.js → chunk-I57TM22L.js} +1 -1
  76. package/dist/{chunk-OGJ6ZSLC.js → chunk-IE4BCGUE.js} +1 -1
  77. package/dist/{chunk-M3Q7IQMS.js → chunk-IGW77FMB.js} +1 -1
  78. package/dist/{chunk-B7K5WOOU.js → chunk-IVQX3AKL.js} +1 -1
  79. package/dist/{chunk-ZES42R57.js → chunk-IWVA37B6.js} +1 -1
  80. package/dist/{chunk-CQKKDIKA.js → chunk-JDGBRACP.js} +1 -1
  81. package/dist/{chunk-Z6GMZOVL.js → chunk-JOATASPP.js} +3 -3
  82. package/dist/{chunk-S63XGGBE.js → chunk-KAZGHWGK.js} +1 -1
  83. package/dist/{chunk-Z4QLCWLB.js → chunk-KGKJU27A.js} +1 -1
  84. package/dist/{chunk-JAO7TZBV.js → chunk-L2BCQQLJ.js} +1 -1
  85. package/dist/{chunk-OKCULEBD.js → chunk-L7GAZQYL.js} +1 -1
  86. package/dist/{chunk-7B7OSHPX.js → chunk-LLY7TQSI.js} +1 -1
  87. package/dist/{chunk-CBLUNSF4.js → chunk-M4WSRYRA.js} +1 -1
  88. package/dist/{chunk-FQRWYXFG.js → chunk-MMQLVGUJ.js} +1 -1
  89. package/dist/{chunk-6GH4DRKR.js → chunk-N7Z7BQYO.js} +1 -1
  90. package/dist/{chunk-DEUDRSU7.js → chunk-NJJQL54J.js} +1 -1
  91. package/dist/{chunk-GMXM4WHF.js → chunk-NSD2H67E.js} +1 -1
  92. package/dist/{chunk-YELGHSVH.js → chunk-O5U6EAL3.js} +1 -1
  93. package/dist/{chunk-4VYWTTT4.js → chunk-O7U5BVX5.js} +2 -2
  94. package/dist/{chunk-4AZ7IG2A.js → chunk-QZRHXGNI.js} +1 -1
  95. package/dist/{chunk-SNKFWPEM.js → chunk-RV7Q4RUV.js} +2 -2
  96. package/dist/{chunk-IX4FH5W6.js → chunk-SA6EDKUF.js} +1 -1
  97. package/dist/{chunk-O7RB4X6I.js → chunk-SACCB44S.js} +2 -2
  98. package/dist/{chunk-2QSG5ZG6.js → chunk-TLFNUXKS.js} +1 -1
  99. package/dist/chunk-U27OWZPW.js +368 -0
  100. package/dist/{chunk-HFRMJP2P.js → chunk-U2CIXGZR.js} +1 -1
  101. package/dist/{chunk-G5ZGEZCA.js → chunk-UDFDTFBL.js} +1 -1
  102. package/dist/{chunk-TYRTD5DD.js → chunk-UH2ZTX4E.js} +1 -1
  103. package/dist/{chunk-CL3AMEK6.js → chunk-UZXCCO7V.js} +1 -1
  104. package/dist/{chunk-YQ4MRF57.js → chunk-VDM3TWF6.js} +4 -4
  105. package/dist/{chunk-ASK4AZFC.js → chunk-VG7BTA5G.js} +1 -1
  106. package/dist/{chunk-R4EGL7VM.js → chunk-W3Z7AZNT.js} +1 -1
  107. package/dist/{chunk-VUOAFV27.js → chunk-WHYEXCTG.js} +1 -1
  108. package/dist/{chunk-HULEZ3D3.js → chunk-WIAZN7G4.js} +1 -1
  109. package/dist/{chunk-M7CGNE2D.js → chunk-WMVPJWWA.js} +1 -1
  110. package/dist/{chunk-4SXJKDHO.js → chunk-X6APRDUM.js} +2 -2
  111. package/dist/{chunk-OXHMUZJV.js → chunk-XMTSHHYQ.js} +1 -1
  112. package/dist/{chunk-B7TJIUKZ.js → chunk-XWO5MDEU.js} +1 -1
  113. package/dist/{chunk-AXW3WDFO.js → chunk-YF26DH4Z.js} +1 -1
  114. package/dist/{chunk-W7NI6JCF.js → chunk-YTAAF62A.js} +1 -1
  115. package/dist/{chunk-XYSFPVJX.js → chunk-ZVJGHQNG.js} +1 -1
  116. package/dist/{chunk-NGASEXVA.js → chunk-ZVZHE7KH.js} +2 -2
  117. package/dist/{chunk-W4IRHQGO.js → chunk-ZXN67F4U.js} +1 -1
  118. package/dist/{chunk-URLZULC7.js → chunk-ZZI4Y3CX.js} +1 -1
  119. package/dist/{committer-42AFWMEX.js → committer-C6UCDYMC.js} +1 -1
  120. package/dist/{config-KU2UICMC.js → config-HUK7V364.js} +1 -1
  121. package/dist/{cover-cmd-HAOBK2IC.js → cover-cmd-5LPHIOSI.js} +1 -1
  122. package/dist/{credentials-BEC4I5SE.js → credentials-6DP4KAMJ.js} +1 -1
  123. package/dist/{deps-bundle-EY5T7OH3.js → deps-bundle-PZNXSKLC.js} +1 -1
  124. package/dist/{deps-resolve-MPLFFCZZ.js → deps-resolve-62XK3LKV.js} +1 -1
  125. package/dist/design-committer-UPC6NZUF.js +2 -0
  126. package/dist/dispatch-7JCKGQVC.js +2 -0
  127. package/dist/{doctor-JBXA6WNL.js → doctor-ZQQ4VMPY.js} +1 -1
  128. package/dist/docx-convert-BIV5T7F5.js +1 -1
  129. package/dist/{dossier-WSWXZAPL.js → dossier-Y6TJWFZU.js} +1 -1
  130. package/dist/{evidence-MJV3PY2J.js → evidence-YAXIWZ6A.js} +1 -1
  131. package/dist/evolve-cmd-5ACHYQPE.js +2 -0
  132. package/dist/explain-3HAZY7Q6.js +2 -0
  133. package/dist/{explain-cmd-BXFR5DB6.js → explain-cmd-RMJPXD4U.js} +1 -1
  134. package/dist/{explain-cmd-IRQ2YX5L.js → explain-cmd-XCRO4AS6.js} +1 -1
  135. package/dist/{extract-bind-PPMY4FFA.js → extract-bind-BF2G6AS6.js} +3 -3
  136. package/dist/{extract-cmd-RHVLPNQB.js → extract-cmd-IPBCCR3T.js} +2 -2
  137. package/dist/{feeder-52VBZY3R.js → feeder-IOR3XRNF.js} +1 -1
  138. package/dist/{gaps-cmd-MSDGU6OU.js → gaps-cmd-3WXL6PAW.js} +1 -1
  139. package/dist/{generate-headless-NSK32S53.js → generate-headless-CLMSXEAS.js} +2 -2
  140. package/dist/index.js +115 -110
  141. package/dist/ingest-TTUQ7UDK.js +2 -0
  142. package/dist/ingest-cmd-KP5M6XTA.js +2 -0
  143. package/dist/install-5VWCH5GW.js +2 -0
  144. package/dist/{interactive-bind-4FNW3OYT.js → interactive-bind-MOV2VWHJ.js} +4 -4
  145. package/dist/{lifecycle-cmd-HYNG5KH6.js → lifecycle-cmd-KSMETBPP.js} +1 -1
  146. package/dist/{list-cmd-Y4WEOT3E.js → list-cmd-V3HJ5K4O.js} +1 -1
  147. package/dist/{list-commands-CJCEW7MQ.js → list-commands-KUDSKVP5.js} +1 -1
  148. package/dist/{logical-ids-N3UZACB4.js → logical-ids-MLXAH45L.js} +1 -1
  149. package/dist/login-flow-GZ3XHVCS.js +2 -0
  150. package/dist/{maintenance-cmd-UJNH47SG.js → maintenance-cmd-VFYGKY3X.js} +1 -1
  151. package/dist/{mobile-prompts-SJZVJWSB.js → mobile-prompts-WJVFBWW5.js} +1 -1
  152. package/dist/objective-variable-gate-GCQYYM77.js +2 -0
  153. package/dist/{persist-recorded-session-FWBAOQEF.js → persist-recorded-session-MHLD4A32.js} +1 -1
  154. package/dist/{phase-seed-2WI7KUYO.js → phase-seed-BMOSAA74.js} +1 -1
  155. package/dist/pipeline-G7KWRK2G.js +2 -0
  156. package/dist/prepare-target-SQ5IGKXD.js +2 -0
  157. package/dist/readmodel-TDRFVDVI.js +2 -0
  158. package/dist/reconcile-cmd-NI3AYU3Y.js +2 -0
  159. package/dist/{reconcile-deps-GMQA6ULT.js → reconcile-deps-DCHUFIEC.js} +2 -2
  160. package/dist/{reconcile-engine-XLLYS5ZB.js → reconcile-engine-QXUKUKSL.js} +1 -1
  161. package/dist/{recording-banner-CQBXZMT3.js → recording-banner-4H4AL6YN.js} +1 -1
  162. package/dist/{records-EW4PIJ5W.js → records-JLS63SDI.js} +1 -1
  163. package/dist/registry-R6QNPI5E.js +2 -0
  164. package/dist/{require-project-folder-K3E3QIOZ.js → require-project-folder-G2G4WKWW.js} +1 -1
  165. package/dist/{resolve-run-intent-3CENNCF3.js → resolve-run-intent-MZRPYN4V.js} +1 -1
  166. package/dist/{resolver-PSNP72H4.js → resolver-X5NHNX5O.js} +1 -1
  167. package/dist/{revert-RXHWWUMQ.js → revert-PRR3D4XM.js} +1 -1
  168. package/dist/{review-cmd-JUOWTME4.js → review-cmd-SAGIKWEW.js} +1 -1
  169. package/dist/run-PBS2J4N4.js +2 -0
  170. package/dist/run-VTUYLPSG.js +2 -0
  171. package/dist/{run-test-md-XBM6RMCI.js → run-test-md-4VRH7FU5.js} +2 -2
  172. package/dist/{sessions-cmd-PGE6LP2W.js → sessions-cmd-VDQGRBEM.js} +1 -1
  173. package/dist/{skill-installer-FBOPYFYS.js → skill-installer-WPW6NDCR.js} +1 -1
  174. package/dist/{spawner-URQ5OAY7.js → spawner-R3XOP3GP.js} +1 -1
  175. package/dist/{structured-answers-BZWJUX22.js → structured-answers-YAVW65G4.js} +1 -1
  176. package/dist/tcg-generate-HIC5AA3L.js +2 -0
  177. package/dist/testmd-actions-VOSP7L74.js +2 -0
  178. package/dist/{testmd-sync-TPUBEORI.js → testmd-sync-GNCDKPQN.js} +1 -1
  179. package/dist/token-refresh-GSFVJ6GU.js +2 -0
  180. package/dist/{validate-basic-BXBHTTTO.js → validate-basic-YNGP5JFB.js} +1 -1
  181. package/dist/variable-receipt-2VCUG7NN.js +2 -0
  182. package/dist/verdicts-PRXUKSDV.js +2 -0
  183. package/dist/{version-check-BGHE3LAK.js → version-check-GUGRBTIH.js} +1 -1
  184. package/dist/{view-cmd-XD5ENSML.js → view-cmd-SXXNDZIC.js} +1 -1
  185. package/dist/{walk-session-EYBUURRA.js → walk-session-G3DLBR24.js} +1 -1
  186. package/dist/{with-telemetry-L3SO6J3L.js → with-telemetry-5Y2CVPXK.js} +1 -1
  187. package/package.json +11 -11
  188. package/dist/EvidenceViewOffer-2T2ZGHIF.js +0 -2
  189. package/dist/FolderPicker-LTQW4YNR.js +0 -2
  190. package/dist/SingleShotApp-KXZF5ZJM.js +0 -2
  191. package/dist/TestMdRunView-6X6W5YAP.js +0 -2
  192. package/dist/bridge-WFSSMJ57.js +0 -2
  193. package/dist/chat-controller-6GW2HSJP.js +0 -2
  194. package/dist/chunk-2KQF6WLX.js +0 -363
  195. package/dist/design-committer-2BQVZPO4.js +0 -2
  196. package/dist/dispatch-NE35HS5F.js +0 -2
  197. package/dist/evolve-cmd-I4Z6IPIM.js +0 -2
  198. package/dist/explain-O3A2HZWD.js +0 -2
  199. package/dist/ingest-WTPY2VLS.js +0 -2
  200. package/dist/ingest-cmd-GOPW3SNF.js +0 -2
  201. package/dist/install-BDHZVEY4.js +0 -2
  202. package/dist/login-flow-DLG2WHSZ.js +0 -2
  203. package/dist/pipeline-B2TYZBMB.js +0 -2
  204. package/dist/prepare-target-JGVB7OKC.js +0 -2
  205. package/dist/readmodel-YDLGQDMH.js +0 -2
  206. package/dist/reconcile-cmd-6ILIXD3U.js +0 -2
  207. package/dist/registry-AA5YIO5Y.js +0 -2
  208. package/dist/run-6CMGGU2W.js +0 -2
  209. package/dist/run-PZIYMD35.js +0 -2
  210. package/dist/tcg-generate-BPLQ7WJ5.js +0 -2
  211. package/dist/testmd-actions-WJS2YM7B.js +0 -2
  212. package/dist/token-refresh-IT4LVE2H.js +0 -2
  213. package/dist/verdicts-J5MJHUGG.js +0 -2
@@ -1,4 +1,4 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{j as Re,k as oe,l as se,m as _e,n as $e,o as ae}from"./chunk-4SXJKDHO.js";import{a as te,c as re,d as ye,f as ie}from"./chunk-HFRMJP2P.js";import{a as P,b as we,d as ke}from"./chunk-OS4VSIHT.js";import{a as X,b as N,c as ee,d as W,e as he,g as O,h as ne}from"./chunk-W5TTF7GB.js";import{a as ge}from"./chunk-BZAGVBCX.js";import{d as ve}from"./chunk-6J5T5FEY.js";import{a as S}from"./chunk-YELGHSVH.js";import{b as Z,c as J,d as Q}from"./chunk-YQ4MRF57.js";import{h as me,j as pe}from"./chunk-3D7VYEDP.js";import{C as I}from"./chunk-R4EGL7VM.js";import{g as T}from"./chunk-OXHMUZJV.js";import{existsSync as Oe,statSync as Ue}from"fs";import{basename as G,resolve as q}from"path";function Ee(e){if(!e||e.stale_refs.length===0)return"\u2014";let n=e.direct_refs??[];return`${e.stale_refs.length} stale${n.length>0?` \xB7 ${n.length} direct`:""}`}function ce(e,n){let t=[...e.rows.filter(a=>a.kind!=="REMOVE").map(a=>[a.kind,S(a.ref),a.reason,Ee(a.impact)]),...e.archive.map(a=>["ARCHIVE",S(a.ref),a.why,Ee(a.impact)])],r=Math.max(40,n??100),i=[`reconcile ${e.source_id} \u2014 head ${e.head.status} \xB7 ${t.length} decision${t.length===1?"":"s"}`];return t.length>0&&i.push(...ve(["kind","ref","why","impact"],t,r,2)),e.changed&&i.push(e.held?`extract ran in override mode; ${e.defaultsTaken??0} default(s) auto-taken; matched-but-changed and new proposals HELD for your verdict (staged \u2014 nothing committed)`:`extract ran in override mode; ${e.defaultsTaken??0} default(s) auto-taken; matched-but-changed proposals auto-committed as edits`),i.push("each row becomes a card below \u2014 verdicts commit as they land"),e.planPath&&i.push(`plan: ${e.planPath}`),i}var xe=new Set(["interactive","agent","ci","override"]);function Ae(e,n){if(e.mode!==void 0&&!xe.has(e.mode))return{error:`--mode must be interactive | agent | ci | override, got '${e.mode}'`,code:"MODE_USAGE"};let t=e.mode,r="reconcile without a TTY needs an explicit mode \u2014 pass --mode agent|ci|override, or --plan for a preview";return t==="interactive"&&!n?{error:r}:t||(n?"interactive":e.plan?"override":{error:r})}async function Pe(e){let{makeHeadlessIO:n,agentRefusal:t}=await import("./headless-io-66RG5NN5.js");return t(n("ndjson","reconcile"),e,"MODE_USAGE")}function Me(e,n,t,r){if(J(t)){let v=Q(t),s=v?.sourceIdFor(t)??null;if(v===null||s===null)return{error:`--from '${t}' is not a supported remote URL \u2014 supported: ${Z.map(u=>u.hint).join("; ")}`};if(r!==void 0&&r!==s)return{error:`--source-id '${r}' does not match this URL's own identity '${s}' \u2014 re-run without --source-id. A source adopted with --as updates by re-running context ingest with the same --as; reconcile follows only the URL's own id`};let c=I(e);if(!c.heads.has(s))return{error:`unknown source '${s}' \u2014 see \`kane-cli context list --type source\`. If this URL was ingested under a custom id, update it by re-running context ingest with the same --as`};if(c.heads.get(s)==null)return{error:`source '${s}' is retired \u2014 restore it first with \`kane-cli context revert\`, then reconcile`};let _=z(e,s,{remoteUrl:t});return _!==null?{error:_}:{sourceId:s,remoteUrl:t}}if(r===void 0)return{error:"reconcile needs --from <file> AND --source-id <id> \u2014 see `kane-cli context list --type source` for ids"};let i=q(n,t);if(!Oe(i)||!Ue(i).isFile())return{error:`--from '${t}' is not a file \u2014 pass the changed source document`};let a=me(i);if(!a.ok)return{error:`--from '${t}' is not an ingestable document \u2014 allowed: ${a.allowlist.join(", ")}`};let o=I(e);if(!o.heads.has(r))return{error:`unknown source '${r}' \u2014 see \`kane-cli context list --type source\``};if(o.heads.get(r)==null)return{error:`source '${r}' is retired \u2014 restore it first with \`kane-cli context revert\`, then reconcile`};let w=z(e,r,{filePath:i});if(w!==null)return{error:w};let f=null;try{f=pe(i)}catch{}return f!==null&&f!==r&&o.heads.get(f)!=null?{error:`'${G(i)}' already backs live source '${f}' \u2014 did you mean --source-id ${f}? To truly move these bytes under '${r}', retire '${f}' first`}:{sourceId:r,filePath:i}}function C(e){return e==null?"(none)":e.slice(0,19)}function Y(e,n,t,r=!1,i){if(e.out(`reconcile ${n.source_id}: head ${n.head.status} \u2014 ${C(n.head.before)} \u2192 ${C(n.head.after)}`),r||(e.out(`note: ${n.note}`),e.out(`skipped arms: ${n.skipped_arms}`)),n.changed&&(e.out(n.held?`extract ran in override mode; ${t?.defaultsTaken??0} default(s) auto-taken; matched-but-changed and new proposals HELD for your verdict (staged \u2014 nothing committed)`:`extract ran in override mode; ${t?.defaultsTaken??0} default(s) auto-taken; matched-but-changed proposals auto-committed as edits`),i?.({type:"defaults_taken",count:t?.defaultsTaken??0})),r){let a=n.changeset??[],o=(f,v)=>{let s=a.filter(c=>c.kind===f).length;return s>0?`${s} ${v}`:null},w=[o("ADD","add"),o("MODIFY","modify"),o("ARCHIVE","archive")].filter(Boolean);n.changed&&e.out(`changeset: ${a.length} item(s)${w.length?` \u2014 ${w.join(" \xB7 ")}`:""}`),e.out(`plan: ${n.rows.length} row(s) \u2014 each gets a card below`);return}if(n.changed){let a=n.changeset??[];e.out(`changeset: ${a.length} item(s)`);for(let o of a)if(o.kind==="MODIFY")e.out(` [MODIFY] ${S(o.ref)} \u2014 ${o.summary} (${C(o.old_cid)} \u2192 ${o.new_cid===null?"(staged)":C(o.new_cid)})`);else if(o.kind==="ADD")e.out(` [ADD] ${S(o.ref)}`);else{e.out(` [ARCHIVE] ${S(o.ref)} \u2014 ${o.why}`);let w=le(o.impact,"retiring drops");w&&e.out(` ${w}`)}}e.out(`plan: ${n.rows.length} row(s)`);for(let a of n.rows){e.out(` [${a.kind}] ${S(a.ref)} \u2014 ${a.reason}`);let o=le(a.impact,"approving marks");o&&e.out(` ${o}`),e.out(` provenance: ${a.provenance}`),e.out(` action: ${a.action}`)}}function De(e,n){return ce({source_id:e.source_id,head:{status:e.head.status},rows:e.rows,archive:(e.changeset??[]).filter(t=>t.kind==="ARCHIVE"),changed:e.changed,held:!!e.held,defaultsTaken:n?.defaultsTaken},process.stdout.columns)}function le(e,n){if(!e||e.stale_refs.length===0)return null;let t=e.direct_refs??[];return`impact: ${n} ${e.stale_refs.length} item(s) stale`+(t.length>0?` \u2014 ${t.length} directly touched: ${t.join(", ")}`:"")}function D(e){return e==="interactive"?"override":e}async function M(e,n,t,r,i,a,o=[],w="override",f,v,s,c,_,u,E){let m;try{m=ne(e)}catch(d){return P(r,d instanceof Error?d.message:String(d)),1}try{if(!t){let{runWalkSession:d}=await import("./walk-session-EYBUURRA.js"),{telemetryEnvName:R}=await import("./bootstrap-3LNHRDQH.js");return await d({dir:e,rows:n,archive:o,held:f??null,childMode:w,runDesign:c??null,mark:a,markA:s,...v?{archiveState:v}:{},...u?{meta:{verb:"reconcile",sid:u,env:R()}}:{},...E?{resumeCmd:E}:{},signals:b=>U(e,b.ref,b.verdict,b.reason),..._?{script:_}:{}})}return await Te(e,n,t,r,i,a,o,w,f,v)}finally{m()}}var H=(e,n)=>e?`kane-cli maintain reconcile --from ${e} --source-id ${n}`:void 0,He=e=>e===null?void 0:"filePath"in e?e.filePath:e.remoteUrl,V=e=>`${e} high-risk item(s) need a human \u2014 ci mode won't guess. Walk interactively or use --mode agent.`;function F(e,n,t){let r=n.rows;e({type:"reconcile_plan",source_id:n.source_id,plan_path:t,rows:r.map(i=>({kind:i.kind,ref:i.ref,why:i.reason})),archive:n.changeset.filter(i=>i.kind==="ARCHIVE").map(i=>({ref:i.ref,why:i.why}))})}function de(e={}){return{type:"reconcile_summary",applied:0,skipped:0,deferred:0,plan_only:0,failed:0,paused:0,stale_created:0,...e}}var L=de();async function j(e,n,t,r,i,a,o,w,f){F(i,n,t);let v=n.changeset.filter(_=>_.kind==="ARCHIVE"&&f?.[_.ref]===void 0),s=n.rows,c;try{c=ne(e)}catch(_){return i({type:"error",message:_ instanceof Error?_.message:String(_)}),i(de()),2}try{return await Fe(e,n,t,r,i,a,o,s,v,w)}finally{c()}}async function Fe(e,n,t,r,i,a,o,w,f,v){let s=0,c=0,_=0,u=0,E=0,m=0,d=0,R=new Set,b=(h,p)=>{try{v?.(h,p)}catch{}};for(let[h,p]of w.entries()){i({type:"reconcile_row_start",kind:p.kind,ref:p.ref,...p.impact?{stale:p.impact.stale_refs.length,direct:p.impact.direct_refs?.length??0}:{}});let g=(l,$,x)=>i({type:"reconcile_row_end",kind:p.kind,ref:p.ref,outcome:l,...$!==void 0?{exit_code:$}:{},...x?{detail:x}:{}});if(p.applied){c++,g("skipped");continue}if(p.kind==="REMOVE"){E++,g("plan-only");continue}if(p.held_ref&&n.held){let l=new Set;if(p.kind==="MODIFY"&&p.impact){let x=I(e);for(let A of p.impact.stale_refs){let K=x.resolve(A);K&&x.stale(K.tip)==="fresh"&&l.add(A)}}let $=oe(e,n.held,p.held_ref,ue);if(!$.ok){_++,d===0&&(d=1),g("failed",1,$.message);continue}if($.kind==="ADD"){let x=await r($.ref,{yes:!0,mode:o});if(x!==0){x===3?(u++,d===0&&(d=3),g("paused",3)):(_++,d===0&&(d=1),g("failed",x));continue}}s++,$.kind!=="ADD"&&p.impact&&(m+=l.size),b(h,"approved"),U(e,p.ref,$.kind==="ADD"?"gap-resolved-create":"gap-resolved-evolve"),g("applied");continue}let y=te(I(e),p.ref);if(!y.ok){c++,g("skipped");continue}let k=y.target;if(R.has(k.ucTip)){c++,g("skipped");continue}if(p.kind==="ADD"){let l=await r(k.seamRef,{yes:!0,mode:o});if(l===3){u++,d===0&&(d=3),g("paused",3);continue}if(l!==0){_++,d===0&&(d=1),g("failed",l);continue}R.add(k.ucTip),s++,b(h,"approved"),U(e,p.ref,"gap-resolved-create"),g("applied")}else{let l=await re(e,k,{yes:!0,mode:o},a,r,"batch");l.outcome==="evolved"?(R.add(k.ucTip),s++,b(h,"approved"),U(e,p.ref,"gap-resolved-evolve"),g("applied")):l.outcome==="paused"?(u++,d===0&&(d=l.code),g("paused",l.code)):l.outcome==="failed"?(_++,d===0&&(d=1),g("failed",l.code)):(c++,g("skipped"))}}return f.length>0&&(i({type:"reconcile_paused",plan_path:t,pending:f.map(h=>({ref:h.ref,why:h.why}))}),u+=f.length,d===0&&(d=3)),i(de({applied:s,skipped:c,plan_only:E,failed:_,paused:u,stale_created:m})),d}var ue={kind:"human",id:process.env.USER??"operator"};function U(e,n,t,r){ge(e,{ts:new Date().toISOString(),command:"reconcile-walk",id:n,verdict:t,polarity:"preference",by:ue,target:n,...r!==void 0?{reason:r}:{}})}async function Te(e,n,t,r,i,a,o=[],w="override",f,v){let s=0,c=0,_=0,u=0,E=0,m=0,d=0,R=new Set;for(let[b,h]of n.entries()){if(h.applied){r.out(`skipped ${h.ref} \u2014 already applied (${h.applied.outcome} at ${h.applied.at})`),c++;continue}let p=l=>{try{a?.(b,l)}catch($){P(r,`could not record applied state for ${h.ref}: ${$ instanceof Error?$.message:String($)}`)}};if(h.kind==="REMOVE"){r.out(`REMOVE ${h.ref} \u2014 plan-only in this release (not executed)`),u++;continue}if(h.held_ref&&f){let l=oe(e,f,h.held_ref,ue);if(!l.ok){P(r,`held ${h.ref}: ${l.message}`),E++,d===0&&(d=1);continue}if(r.out(`committed ${l.ref} (${h.kind==="ADD"?"minted":"updated \u2014 old\u2192new redirect"})`),l.kind==="ADD"){let $=await i(l.ref,{yes:t,mode:w});if($===3){r.out(`design session for ${l.ref} paused \u2014 resume with the "kane-cli design tests --resume <session>" command printed above`),m++,d===0&&(d=3),p("approved");continue}if($!==0){P(r,`design run for ${l.ref} ended with exit code ${$}`),E++,d===0&&(d=1),p("approved");continue}}s++,p("approved"),U(e,h.ref,h.kind==="ADD"?"gap-resolved-create":"gap-resolved-evolve");continue}let g=I(e),y=te(g,h.ref);if(!y.ok){r.out(`skipped ${h.ref} \u2014 ${y.message}`),c++;continue}let k=y.target;if(R.has(k.ucTip)){r.out(`skipped ${h.ref} \u2014 use-case ${k.display} already handled in this walk`),c++;continue}if(h.kind==="ADD"){let l=await i(k.seamRef,{yes:t,mode:w});if(l===3){r.out(`design session for ${k.display} paused \u2014 resume with the "kane-cli design tests --resume <session>" command printed above; this row lands when that session completes`),m++,d===0&&(d=3);continue}if(l!==0){P(r,`design run for ${k.display} ended with exit code ${l}`),E++,d===0&&(d=1);continue}R.add(k.ucTip),s++,p("approved"),U(e,h.ref,"gap-resolved-create")}else{let l=await re(e,k,{yes:!0,mode:w},r,i,"batch");l.outcome==="evolved"?(R.add(k.ucTip),s++,p("approved"),U(e,h.ref,"gap-resolved-evolve")):l.outcome==="paused"?(m++,d===0&&(d=l.code)):l.outcome==="failed"?(E++,d===0&&(d=l.code)):c++}}for(let b of o)if(b.kind==="ARCHIVE"&&v?.[b.ref]===void 0){r.out(`[ARCHIVE] ${b.ref} \u2014 ${b.why}`);{let h=le(b.impact,"retiring drops");h&&r.out(` ${h}`)}r.out(" plan-only \u2014 retire belongs to the interactive session (never headless)"),u++}return r.out(`reconcile walk: ${s} applied, ${c} skipped, ${_} deferred, ${u} plan-only`+(E>0?`, ${E} failed`:"")+(m>0?`, ${m} paused`:"")),d}var Be=new Set(Z.map(e=>e.name));function z(e,n,t){let r=I(e),i=r.heads.get(n);if(i==null)return null;let a=r.mediaOf(i);if("remoteUrl"in t){let o=Q(t.remoteUrl)?.name??"remote";return a.format!==o?`source '${n}' is backed by ${a.format} content, not a ${o} source \u2014 reconcile it with the --from it was originally ingested from`:null}return Be.has(a.format)?`source '${n}' is a remote ${a.format} source \u2014 pass its URL to --from, not a file`:null}function fe(e,n,t,r){return"remoteUrl"in n?$e(e,n.remoteUrl,{out:t.out,err:t.err},r.remoteFindProvider):_e(e,n.filePath)}function Ie(e){return e.remote_url!==void 0?{remoteUrl:e.remote_url}:e.backing_path!==void 0?{filePath:e.backing_path}:null}async function Se(e,n,t,r,i,a=!1,o=!1){let w=i.seams??{reingest:fe(e,t,r,i),reextract:ae(e,{stage:a,hostOut:c=>r.out(c),hostEmit:c=>{c.type!=="run_start"&&i.emitEvent?.(c)},...i.emitEvent?{}:{hostProgress:c=>process.stderr.write(c+`
3
- `)}})},f=null,v={reingest:w.reingest,reextract:async c=>f=await w.reextract(c)},s;try{r.out(`reconciling ${n}: re-reading the source and comparing against the graph\u2026`),s=await(i.buildPlan??se)(e,n,v)}catch(c){return P(r,`reconcile failed: ${c instanceof Error?c.message:String(c)}`),null}if(s.changed)if(o)for(let c of De(s,f))r.out(c);else Y(r,s,f,!1,i.emitEvent);return s}async function Ve(e){let[{render:n},t,{ScrollbackProvider:r},{ChatSurface:i},{makeChatController:a},{makeReconcileDeps:o}]=await Promise.all([import("./build-JIKYOZUH.js"),import("./react-QWOAB3TB.js"),import("./scrollback-JLPJR25X.js"),import("./ChatSurface-YFJDAXOG.js"),import("./chat-controller-6GW2HSJP.js"),import("./reconcile-deps-GMQA6ULT.js")]),w=t.default??t,f=a(),v=o({contextDir:e,note:s=>f.note(s)});return new Promise(s=>{let c=n(w.createElement(r,null,w.createElement(i,{controller:f,verb:"extract",reconcile:v,autoReview:!0,onReviewExit:()=>{c.unmount(),s(0)},onCtrlC:()=>{c.unmount(),s(v.pending()?3:0)}})),{exitOnCtrlC:!1})})}async function Le(e,n,t,r,i){let a=N(e,n);if("error"in a)return P(r,a.error),2;let{plan:o,path:w}=a,f=t==="override"||t==="ci";if(n===void 0&&t==="interactive"&&r.isTTY&&!await r.confirm(`apply plan ${G(w)} for ${o.source_id} (created ${o.created})?`))return r.out(`not applying ${G(w)}`),0;let v=i.runDesignForUc??ie,s=i.runDesignForUc??null,c=i.sessionScript,_=(h,p)=>O(w,h,p),u=(h,p)=>W(w,h,p),E=T(e);if(E===o.head_pin){if(t==="agent"){let p=i.emitEvent??(()=>{});return j(e,B(o),w,v,p,r,D(t),_,o.archive_state)}let h=ee(o);if(t==="ci"&&h.length>0)return P(r,V(h.length)),2;if(r.out(`applying stored plan ${G(w)} for ${o.source_id} (${o.rows.length} row(s))`),!f)for(let p of ce({source_id:o.source_id,head:{status:"stored plan"},rows:o.rows,archive:(o.changeset??[]).filter(g=>g.kind==="ARCHIVE"),changed:!1,held:!!o.held},process.stdout.columns))r.out(p);return M(e,o.rows,f,r,v,_,o.changeset??[],D(t),o.held,o.archive_state,u,s,c,o.source_id,H(o.backing_path??o.remote_url,o.source_id))}if(r.out(`graph moved since this plan (${C(o.head_pin)} \u2192 ${C(E)}) \u2014 recomputing`),o.held)return Ce(e,o,r,i,t,v,!1);let m=Ie(o);if(m===null)return P(r,`stored plan for ${o.source_id} names no backing file or URL \u2014 re-run reconcile --from`),2;let d=z(e,o.source_id,m);if(d!==null)return P(r,`stored plan cannot replay: ${d}`),2;let R=await Se(e,o.source_id,m,r,i,!1,t==="interactive");if(!R)return 1;if(!R.changed)return Y(r,R,null,!1,i.emitEvent),0;if(t==="agent"){let h=i.emitEvent??(()=>{});return j(e,R,null,v,h,r,D(t))}let b=R.changeset.filter(h=>h.kind==="ARCHIVE");return t==="ci"&&b.length>0?(P(r,V(b.length)),2):M(e,R.rows,f,r,v,void 0,R.changeset,D(t),R.held,void 0,void 0,s,c,R.source_id,H(He(m),R.source_id))}function B(e,n=!1){return{source_id:e.source_id,changed:!0,head:{status:"unchanged",before:e.head_pin,after:e.head_pin},note:e.note,skipped_arms:e.skipped_arms,changeset:e.changeset??[],rows:n?e.rows.filter(t=>t.applied===void 0):e.rows,...e.held?{held:e.held}:{}}}async function je(e,n,t,r,i,a,o){let w=r.runDesignForUc??null,f=r.sessionScript,v=he(e,n);if(v===null)return null;if("error"in v)return P(t,v.error),2;let{plan:s,path:c}=v,_=s.rows.filter(d=>d.applied===void 0),u=ee(s),E=r.emitEvent??(()=>{});if(_.length===0&&u.length===0){t.out(`already reconciled \u2014 plan ${s.created} applied ${s.rows.length} row(s)`);let d=ye(I(e)).staleCount;return d>0&&(t.out(`${d} item(s) still stale \u2014 kane-cli maintain evolve --from-stale`),E({type:"stale_debt",count:d})),i==="agent"&&(F(E,B(s),c),E({...L})),0}let m=T(e);return m!==s.head_pin?(t.out(`plan ${s.created} superseded \u2014 graph moved (${C(s.head_pin)} \u2192 ${C(m)}); recomputing`),Ce(e,s,t,r,i,a,o)):(t.out(`resuming plan ${s.created} \u2014 ${_.length} pending row(s)${u.length>0?`, ${u.length} undecided archive item(s)`:""}`),o?(Y(t,B(s),null,!1,r.emitEvent),t.out(`plan stored: ${c}`),i==="agent"&&(F(E,B(s),c),E({...L})),0):i==="agent"?j(e,B(s),c,a,E,t,D(i),(d,R)=>O(c,d,R),s.archive_state):i==="ci"&&u.length>0?(P(t,V(u.length)),2):M(e,s.rows,i==="override"||i==="ci",t,a,(d,R)=>O(c,d,R),s.changeset??[],D(i),s.held,s.archive_state,(d,R)=>W(c,d,R),w,f,s.source_id,H(s.backing_path??s.remote_url,s.source_id)))}async function Ce(e,n,t,r,i,a,o){let w=r.runDesignForUc??null,f=r.sessionScript,v;if(n.held){let g=I(e),y=new Set(n.rows.filter(l=>l.held_ref!==void 0&&l.applied!==void 0).map(l=>l.held_ref)),k=[];for(let l of n.held.rows){if(y.has(l.temp_ref))continue;if(!l.matched_cid){k.push(l);continue}let $=g.tipOf(l.matched_cid);if(g.superseded.get($)===null){t.out(`dropped held "${l.title}" \u2014 its use-case was retired meanwhile`),r.emitEvent?.({type:"held_dropped",ref:l.temp_ref,title:l.title,reason:"target_retired"});continue}k.push($===l.matched_cid?l:{...l,matched_cid:$,uc:{...l.uc,matches_existing:{cid:$}}})}v={source_id:n.held.source_id,rows:k}}let s=Ie(n);if(s===null)return P(t,`stored plan for ${n.source_id} names no backing file or URL \u2014 re-run reconcile --from`),2;let c=z(e,n.source_id,s);if(c!==null)return P(t,`stored plan cannot replay: ${c}`),2;let _=r.seams??{reingest:fe(e,s,t,r),reextract:ae(e,{stage:v!==void 0,hostOut:g=>t.out(g),hostEmit:g=>{g.type!=="run_start"&&r.emitEvent?.(g)},...r.emitEvent?{}:{hostProgress:g=>process.stderr.write(g+`
4
- `)}})},u;try{u=await(r.buildPlan??se)(e,n.source_id,_,{resumeHeld:v})}catch(g){return P(t,`reconcile failed: ${g instanceof Error?g.message:String(g)}`),1}if(i==="interactive"&&!o)for(let g of De(u,null))t.out(g);else Y(t,u,null,!1,r.emitEvent);let E=T(e),m=null;if(E!=null){let g={},y=new Set(u.changeset.filter(k=>k.kind==="ARCHIVE").map(k=>k.ref));for(let[k,l]of Object.entries(n.archive_state??{}))y.has(k)&&(g[k]=l);m=X(e,{version:2,source_id:u.source_id,...n.remote_url!==void 0?{remote_url:n.remote_url}:{backing_path:n.backing_path},head_pin:E,created:new Date().toISOString().replace(/[:.]/g,"-"),skipped_arms:u.skipped_arms,note:u.note,changeset:u.changeset,rows:u.rows,...u.held?{held:u.held}:{},...Object.keys(g).length>0?{archive_state:g}:{}}),t.out(`plan stored: ${m}`)}if(o){if(i==="agent"){let g=r.emitEvent??(()=>{});F(g,u,m),g({...L})}return 0}let d=r.emitEvent??(()=>{}),R=m?N(e,m).plan.archive_state:void 0,b=m?(g,y)=>O(m,g,y):void 0,h=m?(g,y)=>W(m,g,y):void 0;if(i==="agent")return j(e,u,m,a,d,t,D(i),b,R);let p=u.changeset.filter(g=>g.kind==="ARCHIVE"&&R?.[g.ref]===void 0);return i==="ci"&&p.length>0?(P(t,V(p.length)),2):M(e,u.rows,i==="override"||i==="ci",t,a,b,u.changeset,D(i),u.held,R,h,w,f,u.source_id,H(n.backing_path??n.remote_url,u.source_id))}async function be(e,n,t={},r=process.cwd()){let{telemetryBootstrap:i,telemetryEnvName:a}=await import("./bootstrap-3LNHRDQH.js"),o=i({verb:"reconcile",mode:typeof e.mode=="string"?e.mode:"interactive",contextRoot:q(r,".context"),env:a(),applyPlanPath:typeof e.apply=="string"?q(r,e.apply):void 0,write:!0,longSession:!0});e.mode==="agent"&&t.emitEvent?.({type:"run_start",session:o.ids.session_id});let w=await Ye(e,n,t,r);return w===1&&e.mode!=="agent"&&(n.err??n.out)(o.supportFooter()),await o.end({exit_code:w}),w}async function Ye(e,n,t={},r=process.cwd()){let i=e.apply!==void 0&&e.apply!==!1,a=typeof e.apply=="string"?e.apply:void 0;if(e.plan&&i)return P(n,"pass --plan OR --apply, not both"),2;let o=e.from!==void 0||!i,w=e.from!==void 0&&J(e.from);if(o&&(!e.from||!e.sourceId&&!w))return P(n,"reconcile needs --from <file|url> AND --source-id <id> (files only \u2014 a URL derives its own id) \u2014 see `kane-cli context list --type source` for ids"),2;if(e.from&&a!==void 0)return P(n,"pass --from OR --apply <path>, not both \u2014 a stored plan names its own source"),2;let f=we(r,n);if(!f)return 2;if(e.mode!==void 0&&!xe.has(e.mode))return Pe(`--mode must be interactive | agent | ci | override, got '${e.mode}'`);let v=e.mode==="agent"||e.mode==="ci"||e.mode==="override";if(i&&!v&&!n.isTTY)return P(n,"refusing to apply without a TTY to confirm \u2014 pass --mode override|ci"),2;let s=!e.plan,c="override";if(e.from){let y=Ae(e,n.isTTY);if(typeof y=="object")return y.code==="MODE_USAGE"?Pe(y.error):(P(n,y.error),2);c=y}let _=c==="override"||c==="ci";if(i&&!e.from){let{makeReconcileDeps:y}=await import("./reconcile-deps-GMQA6ULT.js"),k=a===void 0?y({contextDir:f}).pending():null;if(k?.kind==="cards"){let $=e.mode??"interactive";return!n.isTTY||$!=="interactive"?(P(n,`a held changeset for ${k.source} awaits review (${k.count} change(s)) \u2014 resume in a terminal: kane-cli maintain reconcile --apply [HELD_REVIEW]`),2):(t.cardApplyMount??Ve)(f)}let l=e.mode??"interactive";return Le(f,a===void 0?void 0:q(r,a),l,n,t)}let u=Me(f,r,e.from,e.sourceId);if("error"in u)return P(n,u.error),2;if(!i){let{sessionsHoldingSource:y}=await import("./sessions-GIEXOCE4.js"),{holders:k,corrupt:l}=y(f,u.sourceId);if(l>0)return P(n,`cannot verify review holds \u2014 ${l} session file(s) unreadable; inspect with kane-cli context sessions list, clean with kane-cli context sessions clean, then retry [SESSIONS_UNREADABLE]`),2;if(k.length>0)return P(n,`session ${k[0]} holds item(s) for review pinned to ${u.sourceId} \u2014 finish that review first: kane-cli context extract --resume ${k[0]} [SOURCE_HELD]`),2}if(c==="interactive"&&!e.plan&&!i){let y=t.seams?.reingest??fe(f,u,n,t),k;try{k=await y(u.sourceId)}catch($){return P(n,$ instanceof Error?$.message:String($)),1}let l=k.status==="unchanged"?null:Re(f,u.sourceId);if(k.status!=="unchanged"&&!l)return n.out(`${u.sourceId} landed for the first time \u2014 extract it: kane-cli context extract --source ${u.sourceId}`),0;if(l){let x=await(t.chatMount??(async A=>{let{bindExtractInteractive:K}=await import("./extract-bind-PPMY4FFA.js");return K(A)}))({mode:"interactive",posture:"reconcile",source:u.sourceId,changeContext:l});if(x===3){let{sessionsHoldingSource:A}=await import("./sessions-GIEXOCE4.js");if(A(f,u.sourceId).holders.length===0)return 0}return x}}let E="remoteUrl"in u?{remoteUrl:u.remoteUrl}:{filePath:u.filePath},m=await Se(f,u.sourceId,E,n,t,!!e.plan||c==="interactive",c==="interactive"&&!e.plan);if(!m)return 1;let d=t.runDesignForUc??ie,R=t.runDesignForUc??null,b=t.sessionScript;if(!m.changed){let y=await je(f,u.sourceId,n,t,c,d,!!e.plan);if(y!==null)return y;if(Y(n,m,null,!1,t.emitEvent),c==="agent"){let k=t.emitEvent??(()=>{});F(k,m,null),k({...L})}return 0}let h=T(f),p=null;if(h!=null?p=X(f,{version:2,source_id:m.source_id,..."remoteUrl"in E?{remote_url:E.remoteUrl}:{backing_path:E.filePath},head_pin:h,created:new Date().toISOString().replace(/[:.]/g,"-"),skipped_arms:m.skipped_arms,note:m.note,changeset:m.changeset,rows:m.rows,...m.held?{held:m.held}:{}}):P(n,"no chain head after extract \u2014 plan not stored"),c==="agent"){let y=t.emitEvent??(()=>{});if(!s)return F(y,m,p),y({...L}),0;let k=p?(l,$)=>O(p,l,$):void 0;return j(f,m,p,d,y,n,D(c),k)}if(!s)return p&&n.out(`plan stored: ${p}`),0;let g=m.changeset.filter(y=>y.kind==="ARCHIVE");if(c==="ci"&&g.length>0)return p&&n.out(`plan stored: ${p}`),P(n,V(g.length)),2;if(p){n.out(`plan stored: ${p}`);let y=p;return M(f,Ke(f,y)??m.rows,_,n,d,(k,l)=>O(y,k,l),m.changeset,D(c),m.held,void 0,void 0,R,b,m.source_id,H(e.from,m.source_id))}return M(f,m.rows,_,n,d,void 0,m.changeset,D(c),m.held,void 0,void 0,R,b,m.source_id,H(e.from,m.source_id))}function Ke(e,n){let t=N(e,n);return"error"in t?null:t.plan.rows}async function dn(e,n={},t,r=process.cwd()){if(e.mode==="agent"){let{makeHeadlessIO:i}=await import("./headless-io-66RG5NN5.js"),a=t?i("ndjson","reconcile",t):i("ndjson","reconcile"),o={out:a.out,err:v=>a.event({type:"error",message:v}),isTTY:!1,confirm:async()=>!1,ask:async()=>""},{runWithChannel:w}=await import("./run-channel-RGH4WIQX.js"),f=2;try{f=await w({event:v=>a.event(v)},()=>be(e,o,{...n,emitEvent:v=>a.event(v)},r))}catch(v){f=1,a.event({type:"error",message:v instanceof Error?v.message:String(v)})}return a.done(f)}return be(e,ke(),n,r)}export{Ae as a,Me as b,D as c,U as d,be as e,dn as f};
2
+ import{j as Re,k as oe,l as se,m as _e,n as $e,o as ae}from"./chunk-X6APRDUM.js";import{a as te,c as re,d as ye,f as ie}from"./chunk-U2CIXGZR.js";import{a as P,b as we,d as ke}from"./chunk-OS4VSIHT.js";import{a as X,b as N,c as ee,d as W,e as he,g as O,h as ne}from"./chunk-W5TTF7GB.js";import{a as ge}from"./chunk-BZAGVBCX.js";import{d as ve}from"./chunk-6J5T5FEY.js";import{a as S}from"./chunk-O5U6EAL3.js";import{b as Z,c as J,d as Q}from"./chunk-VDM3TWF6.js";import{h as me,j as pe}from"./chunk-54JZ6VEW.js";import{C as I}from"./chunk-W3Z7AZNT.js";import{g as T}from"./chunk-XMTSHHYQ.js";import{existsSync as Oe,statSync as Ue}from"fs";import{basename as G,resolve as q}from"path";function Ee(e){if(!e||e.stale_refs.length===0)return"\u2014";let n=e.direct_refs??[];return`${e.stale_refs.length} stale${n.length>0?` \xB7 ${n.length} direct`:""}`}function ce(e,n){let t=[...e.rows.filter(a=>a.kind!=="REMOVE").map(a=>[a.kind,S(a.ref),a.reason,Ee(a.impact)]),...e.archive.map(a=>["ARCHIVE",S(a.ref),a.why,Ee(a.impact)])],r=Math.max(40,n??100),i=[`reconcile ${e.source_id} \u2014 head ${e.head.status} \xB7 ${t.length} decision${t.length===1?"":"s"}`];return t.length>0&&i.push(...ve(["kind","ref","why","impact"],t,r,2)),e.changed&&i.push(e.held?`extract ran in override mode; ${e.defaultsTaken??0} default(s) auto-taken; matched-but-changed and new proposals HELD for your verdict (staged \u2014 nothing committed)`:`extract ran in override mode; ${e.defaultsTaken??0} default(s) auto-taken; matched-but-changed proposals auto-committed as edits`),i.push("each row becomes a card below \u2014 verdicts commit as they land"),e.planPath&&i.push(`plan: ${e.planPath}`),i}var xe=new Set(["interactive","agent","ci","override"]);function Ae(e,n){if(e.mode!==void 0&&!xe.has(e.mode))return{error:`--mode must be interactive | agent | ci | override, got '${e.mode}'`,code:"MODE_USAGE"};let t=e.mode,r="reconcile without a TTY needs an explicit mode \u2014 pass --mode agent|ci|override, or --plan for a preview";return t==="interactive"&&!n?{error:r}:t||(n?"interactive":e.plan?"override":{error:r})}async function Pe(e){let{makeHeadlessIO:n,agentRefusal:t}=await import("./headless-io-66RG5NN5.js");return t(n("ndjson","reconcile"),e,"MODE_USAGE")}function Me(e,n,t,r){if(J(t)){let v=Q(t),s=v?.sourceIdFor(t)??null;if(v===null||s===null)return{error:`--from '${t}' is not a supported remote URL \u2014 supported: ${Z.map(u=>u.hint).join("; ")}`};if(r!==void 0&&r!==s)return{error:`--source-id '${r}' does not match this URL's own identity '${s}' \u2014 re-run without --source-id. A source adopted with --as updates by re-running context ingest with the same --as; reconcile follows only the URL's own id`};let c=I(e);if(!c.heads.has(s))return{error:`unknown source '${s}' \u2014 see \`kane-cli context list --type source\`. If this URL was ingested under a custom id, update it by re-running context ingest with the same --as`};if(c.heads.get(s)==null)return{error:`source '${s}' is retired \u2014 restore it first with \`kane-cli context revert\`, then reconcile`};let _=z(e,s,{remoteUrl:t});return _!==null?{error:_}:{sourceId:s,remoteUrl:t}}if(r===void 0)return{error:"reconcile needs --from <file> AND --source-id <id> \u2014 see `kane-cli context list --type source` for ids"};let i=q(n,t);if(!Oe(i)||!Ue(i).isFile())return{error:`--from '${t}' is not a file \u2014 pass the changed source document`};let a=me(i);if(!a.ok)return{error:`--from '${t}' is not an ingestable document \u2014 allowed: ${a.allowlist.join(", ")}`};let o=I(e);if(!o.heads.has(r))return{error:`unknown source '${r}' \u2014 see \`kane-cli context list --type source\``};if(o.heads.get(r)==null)return{error:`source '${r}' is retired \u2014 restore it first with \`kane-cli context revert\`, then reconcile`};let w=z(e,r,{filePath:i});if(w!==null)return{error:w};let f=null;try{f=pe(i)}catch{}return f!==null&&f!==r&&o.heads.get(f)!=null?{error:`'${G(i)}' already backs live source '${f}' \u2014 did you mean --source-id ${f}? To truly move these bytes under '${r}', retire '${f}' first`}:{sourceId:r,filePath:i}}function C(e){return e==null?"(none)":e.slice(0,19)}function Y(e,n,t,r=!1,i){if(e.out(`reconcile ${n.source_id}: head ${n.head.status} \u2014 ${C(n.head.before)} \u2192 ${C(n.head.after)}`),r||(e.out(`note: ${n.note}`),e.out(`skipped arms: ${n.skipped_arms}`)),n.changed&&(e.out(n.held?`extract ran in override mode; ${t?.defaultsTaken??0} default(s) auto-taken; matched-but-changed and new proposals HELD for your verdict (staged \u2014 nothing committed)`:`extract ran in override mode; ${t?.defaultsTaken??0} default(s) auto-taken; matched-but-changed proposals auto-committed as edits`),i?.({type:"defaults_taken",count:t?.defaultsTaken??0})),r){let a=n.changeset??[],o=(f,v)=>{let s=a.filter(c=>c.kind===f).length;return s>0?`${s} ${v}`:null},w=[o("ADD","add"),o("MODIFY","modify"),o("ARCHIVE","archive")].filter(Boolean);n.changed&&e.out(`changeset: ${a.length} item(s)${w.length?` \u2014 ${w.join(" \xB7 ")}`:""}`),e.out(`plan: ${n.rows.length} row(s) \u2014 each gets a card below`);return}if(n.changed){let a=n.changeset??[];e.out(`changeset: ${a.length} item(s)`);for(let o of a)if(o.kind==="MODIFY")e.out(` [MODIFY] ${S(o.ref)} \u2014 ${o.summary} (${C(o.old_cid)} \u2192 ${o.new_cid===null?"(staged)":C(o.new_cid)})`);else if(o.kind==="ADD")e.out(` [ADD] ${S(o.ref)}`);else{e.out(` [ARCHIVE] ${S(o.ref)} \u2014 ${o.why}`);let w=le(o.impact,"retiring drops");w&&e.out(` ${w}`)}}e.out(`plan: ${n.rows.length} row(s)`);for(let a of n.rows){e.out(` [${a.kind}] ${S(a.ref)} \u2014 ${a.reason}`);let o=le(a.impact,"approving marks");o&&e.out(` ${o}`),e.out(` provenance: ${a.provenance}`),e.out(` action: ${a.action}`)}}function De(e,n){return ce({source_id:e.source_id,head:{status:e.head.status},rows:e.rows,archive:(e.changeset??[]).filter(t=>t.kind==="ARCHIVE"),changed:e.changed,held:!!e.held,defaultsTaken:n?.defaultsTaken},process.stdout.columns)}function le(e,n){if(!e||e.stale_refs.length===0)return null;let t=e.direct_refs??[];return`impact: ${n} ${e.stale_refs.length} item(s) stale`+(t.length>0?` \u2014 ${t.length} directly touched: ${t.join(", ")}`:"")}function D(e){return e==="interactive"?"override":e}async function M(e,n,t,r,i,a,o=[],w="override",f,v,s,c,_,u,E){let m;try{m=ne(e)}catch(d){return P(r,d instanceof Error?d.message:String(d)),1}try{if(!t){let{runWalkSession:d}=await import("./walk-session-G3DLBR24.js"),{telemetryEnvName:R}=await import("./bootstrap-QTVHGL45.js");return await d({dir:e,rows:n,archive:o,held:f??null,childMode:w,runDesign:c??null,mark:a,markA:s,...v?{archiveState:v}:{},...u?{meta:{verb:"reconcile",sid:u,env:R()}}:{},...E?{resumeCmd:E}:{},signals:b=>U(e,b.ref,b.verdict,b.reason),..._?{script:_}:{}})}return await Te(e,n,t,r,i,a,o,w,f,v)}finally{m()}}var H=(e,n)=>e?`kane-cli maintain reconcile --from ${e} --source-id ${n}`:void 0,He=e=>e===null?void 0:"filePath"in e?e.filePath:e.remoteUrl,V=e=>`${e} high-risk item(s) need a human \u2014 ci mode won't guess. Walk interactively or use --mode agent.`;function F(e,n,t){let r=n.rows;e({type:"reconcile_plan",source_id:n.source_id,plan_path:t,rows:r.map(i=>({kind:i.kind,ref:i.ref,why:i.reason})),archive:n.changeset.filter(i=>i.kind==="ARCHIVE").map(i=>({ref:i.ref,why:i.why}))})}function de(e={}){return{type:"reconcile_summary",applied:0,skipped:0,deferred:0,plan_only:0,failed:0,paused:0,stale_created:0,...e}}var L=de();async function j(e,n,t,r,i,a,o,w,f){F(i,n,t);let v=n.changeset.filter(_=>_.kind==="ARCHIVE"&&f?.[_.ref]===void 0),s=n.rows,c;try{c=ne(e)}catch(_){return i({type:"error",message:_ instanceof Error?_.message:String(_)}),i(de()),2}try{return await Fe(e,n,t,r,i,a,o,s,v,w)}finally{c()}}async function Fe(e,n,t,r,i,a,o,w,f,v){let s=0,c=0,_=0,u=0,E=0,m=0,d=0,R=new Set,b=(h,p)=>{try{v?.(h,p)}catch{}};for(let[h,p]of w.entries()){i({type:"reconcile_row_start",kind:p.kind,ref:p.ref,...p.impact?{stale:p.impact.stale_refs.length,direct:p.impact.direct_refs?.length??0}:{}});let g=(l,$,x)=>i({type:"reconcile_row_end",kind:p.kind,ref:p.ref,outcome:l,...$!==void 0?{exit_code:$}:{},...x?{detail:x}:{}});if(p.applied){c++,g("skipped");continue}if(p.kind==="REMOVE"){E++,g("plan-only");continue}if(p.held_ref&&n.held){let l=new Set;if(p.kind==="MODIFY"&&p.impact){let x=I(e);for(let A of p.impact.stale_refs){let K=x.resolve(A);K&&x.stale(K.tip)==="fresh"&&l.add(A)}}let $=oe(e,n.held,p.held_ref,ue);if(!$.ok){_++,d===0&&(d=1),g("failed",1,$.message);continue}if($.kind==="ADD"){let x=await r($.ref,{yes:!0,mode:o});if(x!==0){x===3?(u++,d===0&&(d=3),g("paused",3)):(_++,d===0&&(d=1),g("failed",x));continue}}s++,$.kind!=="ADD"&&p.impact&&(m+=l.size),b(h,"approved"),U(e,p.ref,$.kind==="ADD"?"gap-resolved-create":"gap-resolved-evolve"),g("applied");continue}let y=te(I(e),p.ref);if(!y.ok){c++,g("skipped");continue}let k=y.target;if(R.has(k.ucTip)){c++,g("skipped");continue}if(p.kind==="ADD"){let l=await r(k.seamRef,{yes:!0,mode:o});if(l===3){u++,d===0&&(d=3),g("paused",3);continue}if(l!==0){_++,d===0&&(d=1),g("failed",l);continue}R.add(k.ucTip),s++,b(h,"approved"),U(e,p.ref,"gap-resolved-create"),g("applied")}else{let l=await re(e,k,{yes:!0,mode:o},a,r,"batch");l.outcome==="evolved"?(R.add(k.ucTip),s++,b(h,"approved"),U(e,p.ref,"gap-resolved-evolve"),g("applied")):l.outcome==="paused"?(u++,d===0&&(d=l.code),g("paused",l.code)):l.outcome==="failed"?(_++,d===0&&(d=1),g("failed",l.code)):(c++,g("skipped"))}}return f.length>0&&(i({type:"reconcile_paused",plan_path:t,pending:f.map(h=>({ref:h.ref,why:h.why}))}),u+=f.length,d===0&&(d=3)),i(de({applied:s,skipped:c,plan_only:E,failed:_,paused:u,stale_created:m})),d}var ue={kind:"human",id:process.env.USER??"operator"};function U(e,n,t,r){ge(e,{ts:new Date().toISOString(),command:"reconcile-walk",id:n,verdict:t,polarity:"preference",by:ue,target:n,...r!==void 0?{reason:r}:{}})}async function Te(e,n,t,r,i,a,o=[],w="override",f,v){let s=0,c=0,_=0,u=0,E=0,m=0,d=0,R=new Set;for(let[b,h]of n.entries()){if(h.applied){r.out(`skipped ${h.ref} \u2014 already applied (${h.applied.outcome} at ${h.applied.at})`),c++;continue}let p=l=>{try{a?.(b,l)}catch($){P(r,`could not record applied state for ${h.ref}: ${$ instanceof Error?$.message:String($)}`)}};if(h.kind==="REMOVE"){r.out(`REMOVE ${h.ref} \u2014 plan-only in this release (not executed)`),u++;continue}if(h.held_ref&&f){let l=oe(e,f,h.held_ref,ue);if(!l.ok){P(r,`held ${h.ref}: ${l.message}`),E++,d===0&&(d=1);continue}if(r.out(`committed ${l.ref} (${h.kind==="ADD"?"minted":"updated \u2014 old\u2192new redirect"})`),l.kind==="ADD"){let $=await i(l.ref,{yes:t,mode:w});if($===3){r.out(`design session for ${l.ref} paused \u2014 resume with the "kane-cli design tests --resume <session>" command printed above`),m++,d===0&&(d=3),p("approved");continue}if($!==0){P(r,`design run for ${l.ref} ended with exit code ${$}`),E++,d===0&&(d=1),p("approved");continue}}s++,p("approved"),U(e,h.ref,h.kind==="ADD"?"gap-resolved-create":"gap-resolved-evolve");continue}let g=I(e),y=te(g,h.ref);if(!y.ok){r.out(`skipped ${h.ref} \u2014 ${y.message}`),c++;continue}let k=y.target;if(R.has(k.ucTip)){r.out(`skipped ${h.ref} \u2014 use-case ${k.display} already handled in this walk`),c++;continue}if(h.kind==="ADD"){let l=await i(k.seamRef,{yes:t,mode:w});if(l===3){r.out(`design session for ${k.display} paused \u2014 resume with the "kane-cli design tests --resume <session>" command printed above; this row lands when that session completes`),m++,d===0&&(d=3);continue}if(l!==0){P(r,`design run for ${k.display} ended with exit code ${l}`),E++,d===0&&(d=1);continue}R.add(k.ucTip),s++,p("approved"),U(e,h.ref,"gap-resolved-create")}else{let l=await re(e,k,{yes:!0,mode:w},r,i,"batch");l.outcome==="evolved"?(R.add(k.ucTip),s++,p("approved"),U(e,h.ref,"gap-resolved-evolve")):l.outcome==="paused"?(m++,d===0&&(d=l.code)):l.outcome==="failed"?(E++,d===0&&(d=l.code)):c++}}for(let b of o)if(b.kind==="ARCHIVE"&&v?.[b.ref]===void 0){r.out(`[ARCHIVE] ${b.ref} \u2014 ${b.why}`);{let h=le(b.impact,"retiring drops");h&&r.out(` ${h}`)}r.out(" plan-only \u2014 retire belongs to the interactive session (never headless)"),u++}return r.out(`reconcile walk: ${s} applied, ${c} skipped, ${_} deferred, ${u} plan-only`+(E>0?`, ${E} failed`:"")+(m>0?`, ${m} paused`:"")),d}var Be=new Set(Z.map(e=>e.name));function z(e,n,t){let r=I(e),i=r.heads.get(n);if(i==null)return null;let a=r.mediaOf(i);if("remoteUrl"in t){let o=Q(t.remoteUrl)?.name??"remote";return a.format!==o?`source '${n}' is backed by ${a.format} content, not a ${o} source \u2014 reconcile it with the --from it was originally ingested from`:null}return Be.has(a.format)?`source '${n}' is a remote ${a.format} source \u2014 pass its URL to --from, not a file`:null}function fe(e,n,t,r){return"remoteUrl"in n?$e(e,n.remoteUrl,{out:t.out,err:t.err},r.remoteFindProvider):_e(e,n.filePath)}function Ie(e){return e.remote_url!==void 0?{remoteUrl:e.remote_url}:e.backing_path!==void 0?{filePath:e.backing_path}:null}async function Se(e,n,t,r,i,a=!1,o=!1){let w=i.seams??{reingest:fe(e,t,r,i),reextract:ae(e,{stage:a,hostOut:c=>r.out(c),hostEmit:c=>{c.type!=="run_start"&&i.emitEvent?.(c)},...i.emitEvent?{}:{hostProgress:c=>process.stderr.write(c+`
3
+ `)}})},f=null,v={reingest:w.reingest,reextract:async c=>f=await w.reextract(c)},s;try{r.out(`reconciling ${n}: re-reading the source and comparing against the graph\u2026`),s=await(i.buildPlan??se)(e,n,v)}catch(c){return P(r,`reconcile failed: ${c instanceof Error?c.message:String(c)}`),null}if(s.changed)if(o)for(let c of De(s,f))r.out(c);else Y(r,s,f,!1,i.emitEvent);return s}async function Ve(e){let[{render:n},t,{ScrollbackProvider:r},{ChatSurface:i},{makeChatController:a},{makeReconcileDeps:o}]=await Promise.all([import("./build-JIKYOZUH.js"),import("./react-QWOAB3TB.js"),import("./scrollback-JLPJR25X.js"),import("./ChatSurface-DALSIICW.js"),import("./chat-controller-YJCNU76T.js"),import("./reconcile-deps-DCHUFIEC.js")]),w=t.default??t,f=a(),v=o({contextDir:e,note:s=>f.note(s)});return new Promise(s=>{let c=n(w.createElement(r,null,w.createElement(i,{controller:f,verb:"extract",reconcile:v,autoReview:!0,onReviewExit:()=>{c.unmount(),s(0)},onCtrlC:()=>{c.unmount(),s(v.pending()?3:0)}})),{exitOnCtrlC:!1})})}async function Le(e,n,t,r,i){let a=N(e,n);if("error"in a)return P(r,a.error),2;let{plan:o,path:w}=a,f=t==="override"||t==="ci";if(n===void 0&&t==="interactive"&&r.isTTY&&!await r.confirm(`apply plan ${G(w)} for ${o.source_id} (created ${o.created})?`))return r.out(`not applying ${G(w)}`),0;let v=i.runDesignForUc??ie,s=i.runDesignForUc??null,c=i.sessionScript,_=(h,p)=>O(w,h,p),u=(h,p)=>W(w,h,p),E=T(e);if(E===o.head_pin){if(t==="agent"){let p=i.emitEvent??(()=>{});return j(e,B(o),w,v,p,r,D(t),_,o.archive_state)}let h=ee(o);if(t==="ci"&&h.length>0)return P(r,V(h.length)),2;if(r.out(`applying stored plan ${G(w)} for ${o.source_id} (${o.rows.length} row(s))`),!f)for(let p of ce({source_id:o.source_id,head:{status:"stored plan"},rows:o.rows,archive:(o.changeset??[]).filter(g=>g.kind==="ARCHIVE"),changed:!1,held:!!o.held},process.stdout.columns))r.out(p);return M(e,o.rows,f,r,v,_,o.changeset??[],D(t),o.held,o.archive_state,u,s,c,o.source_id,H(o.backing_path??o.remote_url,o.source_id))}if(r.out(`graph moved since this plan (${C(o.head_pin)} \u2192 ${C(E)}) \u2014 recomputing`),o.held)return Ce(e,o,r,i,t,v,!1);let m=Ie(o);if(m===null)return P(r,`stored plan for ${o.source_id} names no backing file or URL \u2014 re-run reconcile --from`),2;let d=z(e,o.source_id,m);if(d!==null)return P(r,`stored plan cannot replay: ${d}`),2;let R=await Se(e,o.source_id,m,r,i,!1,t==="interactive");if(!R)return 1;if(!R.changed)return Y(r,R,null,!1,i.emitEvent),0;if(t==="agent"){let h=i.emitEvent??(()=>{});return j(e,R,null,v,h,r,D(t))}let b=R.changeset.filter(h=>h.kind==="ARCHIVE");return t==="ci"&&b.length>0?(P(r,V(b.length)),2):M(e,R.rows,f,r,v,void 0,R.changeset,D(t),R.held,void 0,void 0,s,c,R.source_id,H(He(m),R.source_id))}function B(e,n=!1){return{source_id:e.source_id,changed:!0,head:{status:"unchanged",before:e.head_pin,after:e.head_pin},note:e.note,skipped_arms:e.skipped_arms,changeset:e.changeset??[],rows:n?e.rows.filter(t=>t.applied===void 0):e.rows,...e.held?{held:e.held}:{}}}async function je(e,n,t,r,i,a,o){let w=r.runDesignForUc??null,f=r.sessionScript,v=he(e,n);if(v===null)return null;if("error"in v)return P(t,v.error),2;let{plan:s,path:c}=v,_=s.rows.filter(d=>d.applied===void 0),u=ee(s),E=r.emitEvent??(()=>{});if(_.length===0&&u.length===0){t.out(`already reconciled \u2014 plan ${s.created} applied ${s.rows.length} row(s)`);let d=ye(I(e)).staleCount;return d>0&&(t.out(`${d} item(s) still stale \u2014 kane-cli maintain evolve --from-stale`),E({type:"stale_debt",count:d})),i==="agent"&&(F(E,B(s),c),E({...L})),0}let m=T(e);return m!==s.head_pin?(t.out(`plan ${s.created} superseded \u2014 graph moved (${C(s.head_pin)} \u2192 ${C(m)}); recomputing`),Ce(e,s,t,r,i,a,o)):(t.out(`resuming plan ${s.created} \u2014 ${_.length} pending row(s)${u.length>0?`, ${u.length} undecided archive item(s)`:""}`),o?(Y(t,B(s),null,!1,r.emitEvent),t.out(`plan stored: ${c}`),i==="agent"&&(F(E,B(s),c),E({...L})),0):i==="agent"?j(e,B(s),c,a,E,t,D(i),(d,R)=>O(c,d,R),s.archive_state):i==="ci"&&u.length>0?(P(t,V(u.length)),2):M(e,s.rows,i==="override"||i==="ci",t,a,(d,R)=>O(c,d,R),s.changeset??[],D(i),s.held,s.archive_state,(d,R)=>W(c,d,R),w,f,s.source_id,H(s.backing_path??s.remote_url,s.source_id)))}async function Ce(e,n,t,r,i,a,o){let w=r.runDesignForUc??null,f=r.sessionScript,v;if(n.held){let g=I(e),y=new Set(n.rows.filter(l=>l.held_ref!==void 0&&l.applied!==void 0).map(l=>l.held_ref)),k=[];for(let l of n.held.rows){if(y.has(l.temp_ref))continue;if(!l.matched_cid){k.push(l);continue}let $=g.tipOf(l.matched_cid);if(g.superseded.get($)===null){t.out(`dropped held "${l.title}" \u2014 its use-case was retired meanwhile`),r.emitEvent?.({type:"held_dropped",ref:l.temp_ref,title:l.title,reason:"target_retired"});continue}k.push($===l.matched_cid?l:{...l,matched_cid:$,uc:{...l.uc,matches_existing:{cid:$}}})}v={source_id:n.held.source_id,rows:k}}let s=Ie(n);if(s===null)return P(t,`stored plan for ${n.source_id} names no backing file or URL \u2014 re-run reconcile --from`),2;let c=z(e,n.source_id,s);if(c!==null)return P(t,`stored plan cannot replay: ${c}`),2;let _=r.seams??{reingest:fe(e,s,t,r),reextract:ae(e,{stage:v!==void 0,hostOut:g=>t.out(g),hostEmit:g=>{g.type!=="run_start"&&r.emitEvent?.(g)},...r.emitEvent?{}:{hostProgress:g=>process.stderr.write(g+`
4
+ `)}})},u;try{u=await(r.buildPlan??se)(e,n.source_id,_,{resumeHeld:v})}catch(g){return P(t,`reconcile failed: ${g instanceof Error?g.message:String(g)}`),1}if(i==="interactive"&&!o)for(let g of De(u,null))t.out(g);else Y(t,u,null,!1,r.emitEvent);let E=T(e),m=null;if(E!=null){let g={},y=new Set(u.changeset.filter(k=>k.kind==="ARCHIVE").map(k=>k.ref));for(let[k,l]of Object.entries(n.archive_state??{}))y.has(k)&&(g[k]=l);m=X(e,{version:2,source_id:u.source_id,...n.remote_url!==void 0?{remote_url:n.remote_url}:{backing_path:n.backing_path},head_pin:E,created:new Date().toISOString().replace(/[:.]/g,"-"),skipped_arms:u.skipped_arms,note:u.note,changeset:u.changeset,rows:u.rows,...u.held?{held:u.held}:{},...Object.keys(g).length>0?{archive_state:g}:{}}),t.out(`plan stored: ${m}`)}if(o){if(i==="agent"){let g=r.emitEvent??(()=>{});F(g,u,m),g({...L})}return 0}let d=r.emitEvent??(()=>{}),R=m?N(e,m).plan.archive_state:void 0,b=m?(g,y)=>O(m,g,y):void 0,h=m?(g,y)=>W(m,g,y):void 0;if(i==="agent")return j(e,u,m,a,d,t,D(i),b,R);let p=u.changeset.filter(g=>g.kind==="ARCHIVE"&&R?.[g.ref]===void 0);return i==="ci"&&p.length>0?(P(t,V(p.length)),2):M(e,u.rows,i==="override"||i==="ci",t,a,b,u.changeset,D(i),u.held,R,h,w,f,u.source_id,H(n.backing_path??n.remote_url,u.source_id))}async function be(e,n,t={},r=process.cwd()){let{telemetryBootstrap:i,telemetryEnvName:a}=await import("./bootstrap-QTVHGL45.js"),o=i({verb:"reconcile",mode:typeof e.mode=="string"?e.mode:"interactive",contextRoot:q(r,".context"),env:a(),applyPlanPath:typeof e.apply=="string"?q(r,e.apply):void 0,write:!0,longSession:!0});e.mode==="agent"&&t.emitEvent?.({type:"run_start",session:o.ids.session_id});let w=await Ye(e,n,t,r);return w===1&&e.mode!=="agent"&&(n.err??n.out)(o.supportFooter()),await o.end({exit_code:w}),w}async function Ye(e,n,t={},r=process.cwd()){let i=e.apply!==void 0&&e.apply!==!1,a=typeof e.apply=="string"?e.apply:void 0;if(e.plan&&i)return P(n,"pass --plan OR --apply, not both"),2;let o=e.from!==void 0||!i,w=e.from!==void 0&&J(e.from);if(o&&(!e.from||!e.sourceId&&!w))return P(n,"reconcile needs --from <file|url> AND --source-id <id> (files only \u2014 a URL derives its own id) \u2014 see `kane-cli context list --type source` for ids"),2;if(e.from&&a!==void 0)return P(n,"pass --from OR --apply <path>, not both \u2014 a stored plan names its own source"),2;let f=we(r,n);if(!f)return 2;if(e.mode!==void 0&&!xe.has(e.mode))return Pe(`--mode must be interactive | agent | ci | override, got '${e.mode}'`);let v=e.mode==="agent"||e.mode==="ci"||e.mode==="override";if(i&&!v&&!n.isTTY)return P(n,"refusing to apply without a TTY to confirm \u2014 pass --mode override|ci"),2;let s=!e.plan,c="override";if(e.from){let y=Ae(e,n.isTTY);if(typeof y=="object")return y.code==="MODE_USAGE"?Pe(y.error):(P(n,y.error),2);c=y}let _=c==="override"||c==="ci";if(i&&!e.from){let{makeReconcileDeps:y}=await import("./reconcile-deps-DCHUFIEC.js"),k=a===void 0?y({contextDir:f}).pending():null;if(k?.kind==="cards"){let $=e.mode??"interactive";return!n.isTTY||$!=="interactive"?(P(n,`a held changeset for ${k.source} awaits review (${k.count} change(s)) \u2014 resume in a terminal: kane-cli maintain reconcile --apply [HELD_REVIEW]`),2):(t.cardApplyMount??Ve)(f)}let l=e.mode??"interactive";return Le(f,a===void 0?void 0:q(r,a),l,n,t)}let u=Me(f,r,e.from,e.sourceId);if("error"in u)return P(n,u.error),2;if(!i){let{sessionsHoldingSource:y}=await import("./sessions-GIEXOCE4.js"),{holders:k,corrupt:l}=y(f,u.sourceId);if(l>0)return P(n,`cannot verify review holds \u2014 ${l} session file(s) unreadable; inspect with kane-cli context sessions list, clean with kane-cli context sessions clean, then retry [SESSIONS_UNREADABLE]`),2;if(k.length>0)return P(n,`session ${k[0]} holds item(s) for review pinned to ${u.sourceId} \u2014 finish that review first: kane-cli context extract --resume ${k[0]} [SOURCE_HELD]`),2}if(c==="interactive"&&!e.plan&&!i){let y=t.seams?.reingest??fe(f,u,n,t),k;try{k=await y(u.sourceId)}catch($){return P(n,$ instanceof Error?$.message:String($)),1}let l=k.status==="unchanged"?null:Re(f,u.sourceId);if(k.status!=="unchanged"&&!l)return n.out(`${u.sourceId} landed for the first time \u2014 extract it: kane-cli context extract --source ${u.sourceId}`),0;if(l){let x=await(t.chatMount??(async A=>{let{bindExtractInteractive:K}=await import("./extract-bind-BF2G6AS6.js");return K(A)}))({mode:"interactive",posture:"reconcile",source:u.sourceId,changeContext:l});if(x===3){let{sessionsHoldingSource:A}=await import("./sessions-GIEXOCE4.js");if(A(f,u.sourceId).holders.length===0)return 0}return x}}let E="remoteUrl"in u?{remoteUrl:u.remoteUrl}:{filePath:u.filePath},m=await Se(f,u.sourceId,E,n,t,!!e.plan||c==="interactive",c==="interactive"&&!e.plan);if(!m)return 1;let d=t.runDesignForUc??ie,R=t.runDesignForUc??null,b=t.sessionScript;if(!m.changed){let y=await je(f,u.sourceId,n,t,c,d,!!e.plan);if(y!==null)return y;if(Y(n,m,null,!1,t.emitEvent),c==="agent"){let k=t.emitEvent??(()=>{});F(k,m,null),k({...L})}return 0}let h=T(f),p=null;if(h!=null?p=X(f,{version:2,source_id:m.source_id,..."remoteUrl"in E?{remote_url:E.remoteUrl}:{backing_path:E.filePath},head_pin:h,created:new Date().toISOString().replace(/[:.]/g,"-"),skipped_arms:m.skipped_arms,note:m.note,changeset:m.changeset,rows:m.rows,...m.held?{held:m.held}:{}}):P(n,"no chain head after extract \u2014 plan not stored"),c==="agent"){let y=t.emitEvent??(()=>{});if(!s)return F(y,m,p),y({...L}),0;let k=p?(l,$)=>O(p,l,$):void 0;return j(f,m,p,d,y,n,D(c),k)}if(!s)return p&&n.out(`plan stored: ${p}`),0;let g=m.changeset.filter(y=>y.kind==="ARCHIVE");if(c==="ci"&&g.length>0)return p&&n.out(`plan stored: ${p}`),P(n,V(g.length)),2;if(p){n.out(`plan stored: ${p}`);let y=p;return M(f,Ke(f,y)??m.rows,_,n,d,(k,l)=>O(y,k,l),m.changeset,D(c),m.held,void 0,void 0,R,b,m.source_id,H(e.from,m.source_id))}return M(f,m.rows,_,n,d,void 0,m.changeset,D(c),m.held,void 0,void 0,R,b,m.source_id,H(e.from,m.source_id))}function Ke(e,n){let t=N(e,n);return"error"in t?null:t.plan.rows}async function dn(e,n={},t,r=process.cwd()){if(e.mode==="agent"){let{makeHeadlessIO:i}=await import("./headless-io-66RG5NN5.js"),a=t?i("ndjson","reconcile",t):i("ndjson","reconcile"),o={out:a.out,err:v=>a.event({type:"error",message:v}),isTTY:!1,confirm:async()=>!1,ask:async()=>""},{runWithChannel:w}=await import("./run-channel-RGH4WIQX.js"),f=2;try{f=await w({event:v=>a.event(v)},()=>be(e,o,{...n,emitEvent:v=>a.event(v)},r))}catch(v){f=1,a.event({type:"error",message:v instanceof Error?v.message:String(v)})}return a.done(f)}return be(e,ke(),n,r)}export{Ae as a,Me as b,D as c,U as d,be as e,dn as f};
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as k}from"./chunk-DNNZ353O.js";import{b as w}from"./chunk-R4EGL7VM.js";import{d as E,e as h}from"./chunk-AKX4VRRR.js";var g=(e,t,r=new Set)=>{let s=e.nameOf.get(t);if(s!==void 0)return s;if(r.has(t))return t;r.add(t);for(let[o,n]of e.superseded){if(n!==t)continue;let d=g(e,o,r);if(d!==o)return d}return t};function b(e,t){let r=e.stale(t);if(r==="fresh")return;if(r==="orphaned")return"orphaned \u2014 no live source evidences this item";let s=[],o=new Map;for(let n of e.derivesInto(t))o.set(String(n.props.source_id),n);for(let[n,d]of o){let i=e.heads.get(n);if(i==null||i===d.props.source_cid)continue;let a=e.convChains.get(n)?.chain;a&&a.includes(String(d.props.source_cid))||s.push(`DERIVES pin ${n}@${String(d.props.source_cid).slice(0,19)} broke \u2014 the source head moved`)}for(let n of e.edgesFrom(t)){if(n.type===h.DERIVES||!e.superseded.has(n.dst))continue;let d=e.tipOf(n.dst);if(e.superseded.has(d)){s.push(`${n.type} pin \u2192 ${g(e,n.dst)} \u2014 target retired`);continue}let i=C(e,n.dst,d);s.push(i.length>0?`${g(e,n.dst)} updated: ${i.map(a=>a.field).join(", ")}`:`${n.type} pin \u2192 ${g(e,n.dst)} \u2014 target superseded`)}return s.length>0?s.join("; "):"stale \u2014 a pinned dependency moved"}function C(e,t,r){let s=e.getNode(t)?.content??{},o=e.getNode(r)?.content??{},n=i=>i===void 0?"":Array.isArray(i)?i.map(String).join(" \xB7 "):typeof i=="object"?JSON.stringify(i):String(i),d=[];for(let i of[...new Set([...Object.keys(s),...Object.keys(o)])].sort())JSON.stringify(s[i])!==JSON.stringify(o[i])&&d.push({field:i,old:n(s[i]),new:n(o[i])});return d}function P(e,t){let r=[];for(let{cid:s}of e.byLabel(E.SCENARIO))e.superseded.has(s)||e.edgesFrom(s).some(o=>o.type===h.BELONGS_TO&&e.tipOf(o.dst)===t)&&r.push(s);return r}function O(e,t){let r=[],s=[],o=[],n=[],d=[],i=[],a=P(e,t),y=new Set(a),l=(c,f)=>{let u=b(e,f);return u===void 0?c:{...c,stale:!0,stale_reason:u}};for(let c of a){let f=e.getNode(c)?.content??{};r.push(l({ref:g(e,c),title:String(f.title??""),case_type:String(f.case_type??""),intent:String(f.intent??"")},c));for(let u of e.edgesInto(c)){if(u.type!==h.AUTOMATES||e.superseded.has(u.src))continue;let p=e.getNode(u.src)?.content??{},S=e.edgesFrom(u.src).filter(x=>x.type===h.VERIFIES&&!e.superseded.has(x.dst)).map(x=>g(e,x.dst));s.push(l({ref:g(e,u.src),title:String(p.title??""),automates:g(e,c),check:p.check,verifies:S,...typeof p.target=="string"?{target:p.target}:{},...typeof p.app=="string"?{app:p.app}:{}},u.src)),d.push(u.src)}for(let u of e.edgesFrom(c))u.type!==h.EXERCISES||e.superseded.has(u.dst)||n.push({scenario:g(e,c),ac:g(e,u.dst)})}for(let{cid:c}of e.byLabel(E.AC)){if(e.superseded.has(c))continue;let f=e.edgesFrom(c).find(x=>x.type===h.SCOPED_TO);if(!f)continue;let u=e.tipOf(f.dst);if(!(u===t||y.has(u)))continue;let S=e.getNode(c)?.content??{};o.push(l({ref:g(e,c),text:String(S.text??""),kind:String(S.kind??""),scope:u===t?"use-case":g(e,u)},c)),i.push(c)}let _=[],m=new Set;for(let c of[t,...a,...d,...i])for(let f of e.retractedEdgesTouching(c))m.has(f.ecid)||(m.add(f.ecid),_.push({type:f.type,src:g(e,f.src),dst:g(e,f.dst),at:f.retraction.at,...f.retraction.reason?{reason:f.retraction.reason}:{}}));return{scenarios:r,tests:s,acs:o,exercises:n,retracted_edges:_}}function D(e,t,r){let s=k(e,t,r);return s===null?null:s.toString("utf8")}function v(e,t){let r=t.split(`
2
+ import{a as k}from"./chunk-DNNZ353O.js";import{b as w}from"./chunk-W3Z7AZNT.js";import{d as E,e as h}from"./chunk-AKX4VRRR.js";var g=(e,t,r=new Set)=>{let s=e.nameOf.get(t);if(s!==void 0)return s;if(r.has(t))return t;r.add(t);for(let[o,n]of e.superseded){if(n!==t)continue;let d=g(e,o,r);if(d!==o)return d}return t};function b(e,t){let r=e.stale(t);if(r==="fresh")return;if(r==="orphaned")return"orphaned \u2014 no live source evidences this item";let s=[],o=new Map;for(let n of e.derivesInto(t))o.set(String(n.props.source_id),n);for(let[n,d]of o){let i=e.heads.get(n);if(i==null||i===d.props.source_cid)continue;let a=e.convChains.get(n)?.chain;a&&a.includes(String(d.props.source_cid))||s.push(`DERIVES pin ${n}@${String(d.props.source_cid).slice(0,19)} broke \u2014 the source head moved`)}for(let n of e.edgesFrom(t)){if(n.type===h.DERIVES||!e.superseded.has(n.dst))continue;let d=e.tipOf(n.dst);if(e.superseded.has(d)){s.push(`${n.type} pin \u2192 ${g(e,n.dst)} \u2014 target retired`);continue}let i=C(e,n.dst,d);s.push(i.length>0?`${g(e,n.dst)} updated: ${i.map(a=>a.field).join(", ")}`:`${n.type} pin \u2192 ${g(e,n.dst)} \u2014 target superseded`)}return s.length>0?s.join("; "):"stale \u2014 a pinned dependency moved"}function C(e,t,r){let s=e.getNode(t)?.content??{},o=e.getNode(r)?.content??{},n=i=>i===void 0?"":Array.isArray(i)?i.map(String).join(" \xB7 "):typeof i=="object"?JSON.stringify(i):String(i),d=[];for(let i of[...new Set([...Object.keys(s),...Object.keys(o)])].sort())JSON.stringify(s[i])!==JSON.stringify(o[i])&&d.push({field:i,old:n(s[i]),new:n(o[i])});return d}function P(e,t){let r=[];for(let{cid:s}of e.byLabel(E.SCENARIO))e.superseded.has(s)||e.edgesFrom(s).some(o=>o.type===h.BELONGS_TO&&e.tipOf(o.dst)===t)&&r.push(s);return r}function O(e,t){let r=[],s=[],o=[],n=[],d=[],i=[],a=P(e,t),y=new Set(a),l=(c,f)=>{let u=b(e,f);return u===void 0?c:{...c,stale:!0,stale_reason:u}};for(let c of a){let f=e.getNode(c)?.content??{};r.push(l({ref:g(e,c),title:String(f.title??""),case_type:String(f.case_type??""),intent:String(f.intent??"")},c));for(let u of e.edgesInto(c)){if(u.type!==h.AUTOMATES||e.superseded.has(u.src))continue;let p=e.getNode(u.src)?.content??{},S=e.edgesFrom(u.src).filter(x=>x.type===h.VERIFIES&&!e.superseded.has(x.dst)).map(x=>g(e,x.dst));s.push(l({ref:g(e,u.src),title:String(p.title??""),automates:g(e,c),check:p.check,verifies:S,...typeof p.target=="string"?{target:p.target}:{},...typeof p.app=="string"?{app:p.app}:{}},u.src)),d.push(u.src)}for(let u of e.edgesFrom(c))u.type!==h.EXERCISES||e.superseded.has(u.dst)||n.push({scenario:g(e,c),ac:g(e,u.dst)})}for(let{cid:c}of e.byLabel(E.AC)){if(e.superseded.has(c))continue;let f=e.edgesFrom(c).find(x=>x.type===h.SCOPED_TO);if(!f)continue;let u=e.tipOf(f.dst);if(!(u===t||y.has(u)))continue;let S=e.getNode(c)?.content??{};o.push(l({ref:g(e,c),text:String(S.text??""),kind:String(S.kind??""),scope:u===t?"use-case":g(e,u)},c)),i.push(c)}let _=[],m=new Set;for(let c of[t,...a,...d,...i])for(let f of e.retractedEdgesTouching(c))m.has(f.ecid)||(m.add(f.ecid),_.push({type:f.type,src:g(e,f.src),dst:g(e,f.dst),at:f.retraction.at,...f.retraction.reason?{reason:f.retraction.reason}:{}}));return{scenarios:r,tests:s,acs:o,exercises:n,retracted_edges:_}}function D(e,t,r){let s=k(e,t,r);return s===null?null:s.toString("utf8")}function v(e,t){let r=t.split(`
3
3
  `).map(o=>o.replace(/^\d+\| /,"")),s=[];for(let o of e.split(`
4
4
  `)){let n=o.trim();if(n.length===0)continue;let d=r.find(i=>i.includes(n));d!==void 0&&!s.includes(d.trim())&&s.push(d.trim())}return s.length>0?s.join(`
5
5
  `):{removed:!0}}function G(e,t,r,s){if(s!==void 0&&s.trim().length>0)return{kind:"user-directive",text:s.trim()};let o=[r,...O(t,r).acs.map(a=>t.resolve(a.ref)?.cid??"")].filter(Boolean),n=[],d=new Set;for(let a of o){let y=new Map;for(let l of t.derivesInto(a))y.set(String(l.props.source_id),l);for(let[l,_]of y){let m=t.heads.get(l);if(m==null||m===_.props.source_cid)continue;let c=String(_.props.anchor),f=`${l}\0${c}`;if(d.has(f)||c==="img#whole")continue;d.add(f);let u=D(e,t,String(_.props.source_cid)),p=u===null?null:w(u,c);if(p===null)continue;let S=D(e,t,m);n.push({source_id:l,anchor:c,old_anchor_text:p,new_anchor_text:S===null?{removed:!0}:v(p,S)})}}let i;for(let[a,y]of t.superseded){if(y!==r||t.nodeLabel.get(a)!==E.USECASE)continue;let l=C(t,a,r);l.length>0&&(i=l);break}return{kind:"source-change",changes:n,...i?{uc_updated:i}:{}}}function $(e,t,r,s){let o=O(t,r);if(o.scenarios.length===0&&o.tests.length===0&&o.acs.length===0)return;let n=G(e,t,r,s);if(!(n.kind==="source-change"&&n.changes.length===0&&!n.uc_updated))return{prior_design:o,change_delta:n}}export{O as a,$ as b};
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as b,b as $}from"./chunk-R4EGL7VM.js";function C(n){return n.replace(/\n$/,"").split(`
2
+ import{a as b,b as $}from"./chunk-W3Z7AZNT.js";function C(n){return n.replace(/\n$/,"").split(`
3
3
  `).map((l,o)=>`${String(o+1).padStart(4,"0")}| ${l}`).join(`
4
4
  `)}function S(n,d,l){if(!n.quote)return n;let o=$(l,n.anchor);if(o!==null&&o.includes(n.quote))return n;let a=d.indexOf(n.quote);if(a===-1||d.indexOf(n.quote,a+1)!==-1)return"gone-or-ambiguous";let t=d.slice(0,a).split(`
5
5
  `).length,r=t+n.quote.replace(/\n$/,"").split(`
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{g as o,h as a}from"./chunk-ZMJD3CI7.js";import{mkdirSync as p,writeFileSync as f,chmodSync as d,existsSync as m}from"fs";var y={darwin:"https://downloads.lambdatest.com/hyperexecute/darwin/hyperexecute",linux:"https://downloads.lambdatest.com/hyperexecute/linux/hyperexecute",win32:"https://downloads.lambdatest.com/hyperexecute/windows/hyperexecute.exe"};function h(s){let t=y[s];if(!t)throw new Error(`unsupported platform for hyperexecute: ${s}`);return t}async function g(s,t={}){let i=t.platform??process.platform,u=t.existsImpl??m,c=t.fetchImpl??(r=>fetch(r)),e=a(s);if(u(e))return{status:"present",path:e};try{let r=h(i),n=await c(r);if(!n.ok)return{status:"failed",path:e,error:`download failed: HTTP ${n.status}`};let l=Buffer.from(await n.arrayBuffer());return p(o(s),{recursive:!0}),f(e,l),d(e,493),{status:"downloaded",path:e}}catch(r){return{status:"failed",path:e,error:r instanceof Error?r.message:String(r)}}}export{h as a,g as b};
2
+ import{g as o,h as a}from"./chunk-4E4GJPEM.js";import{mkdirSync as p,writeFileSync as f,chmodSync as d,existsSync as m}from"fs";var y={darwin:"https://downloads.lambdatest.com/hyperexecute/darwin/hyperexecute",linux:"https://downloads.lambdatest.com/hyperexecute/linux/hyperexecute",win32:"https://downloads.lambdatest.com/hyperexecute/windows/hyperexecute.exe"};function h(s){let t=y[s];if(!t)throw new Error(`unsupported platform for hyperexecute: ${s}`);return t}async function g(s,t={}){let i=t.platform??process.platform,u=t.existsImpl??m,c=t.fetchImpl??(r=>fetch(r)),e=a(s);if(u(e))return{status:"present",path:e};try{let r=h(i),n=await c(r);if(!n.ok)return{status:"failed",path:e,error:`download failed: HTTP ${n.status}`};let l=Buffer.from(await n.arrayBuffer());return p(o(s),{recursive:!0}),f(e,l),d(e,493),{status:"downloaded",path:e}}catch(r){return{status:"failed",path:e,error:r instanceof Error?r.message:String(r)}}}export{h as a,g as b};
@@ -1,4 +1,4 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{b as f,d as l}from"./chunk-4VZRBBLF.js";import{a as p}from"./chunk-TZXXJWHA.js";function d(t,e,o){return{id:`${t}.internal`,label:e,required:!0,status:"fail",detail:o instanceof Error?o.message:String(o)}}async function k(t,e={}){let o=p();if(!o.supported)return{sections:[{platform:"host",checks:[{id:"host.platform",label:"host",required:!0,status:"fail",detail:o.reason}]}]};let n=t?f().filter(r=>r.toLowerCase()===t.toLowerCase()):f(),{managedDeps:i}=await import("./deps-bundle-EY5T7OH3.js"),s=n.flatMap(r=>r==="android"?["emulator"]:r==="ios"?["simulator"]:[]);await Promise.allSettled(s.map(r=>i().warmResolveCache(r)));let c=[];for(let r of n){let u=l(r);if(!u)continue;let a;try{a=await u.checks(e)}catch(h){a=[d(r,"toolchain check",h)]}c.push({platform:r,checks:a})}return{sections:c}}function m(t){return t==="pass"?"\u2713":t==="fail"?"\u2717":"\u2139"}function x(t){return t.charAt(0).toUpperCase()+t.slice(1)}function C(t){let e=[];if(t.sections.length===0)return"No mobile platforms are supported on this host.";for(let o of t.sections){e.length>0&&e.push(""),e.push(`${x(o.platform)} toolchain`);let n=o.checks.filter(s=>s.status!=="info"),i=new Set;for(let s of n){let c=s.detail?` \u2014 ${s.detail}`:"";if(e.push(` ${m(s.status)} ${s.label}${c}`),s.status==="fail"&&s.fixText&&!i.has(s.fixText)){i.add(s.fixText);for(let r of s.fixText.split(`
2
+ import{b as f,d as l}from"./chunk-ASYWKYTQ.js";import{a as p}from"./chunk-TZXXJWHA.js";function d(t,e,o){return{id:`${t}.internal`,label:e,required:!0,status:"fail",detail:o instanceof Error?o.message:String(o)}}async function k(t,e={}){let o=p();if(!o.supported)return{sections:[{platform:"host",checks:[{id:"host.platform",label:"host",required:!0,status:"fail",detail:o.reason}]}]};let n=t?f().filter(r=>r.toLowerCase()===t.toLowerCase()):f(),{managedDeps:i}=await import("./deps-bundle-PZNXSKLC.js"),s=n.flatMap(r=>r==="android"?["emulator"]:r==="ios"?["simulator"]:[]);await Promise.allSettled(s.map(r=>i().warmResolveCache(r)));let c=[];for(let r of n){let u=l(r);if(!u)continue;let a;try{a=await u.checks(e)}catch(h){a=[d(r,"toolchain check",h)]}c.push({platform:r,checks:a})}return{sections:c}}function m(t){return t==="pass"?"\u2713":t==="fail"?"\u2717":"\u2139"}function x(t){return t.charAt(0).toUpperCase()+t.slice(1)}function C(t){let e=[];if(t.sections.length===0)return"No mobile platforms are supported on this host.";for(let o of t.sections){e.length>0&&e.push(""),e.push(`${x(o.platform)} toolchain`);let n=o.checks.filter(s=>s.status!=="info"),i=new Set;for(let s of n){let c=s.detail?` \u2014 ${s.detail}`:"";if(e.push(` ${m(s.status)} ${s.label}${c}`),s.status==="fail"&&s.fixText&&!i.has(s.fixText)){i.add(s.fixText);for(let r of s.fixText.split(`
3
3
  `))e.push(` fix: ${r}`)}}}return e.join(`
4
4
  `)}function w(t){return t.sections.length===0?!0:t.sections.every(e=>e.checks.some(o=>o.required&&o.status==="fail"&&!o.fixedByBundle))}function b(t){for(let e of t.sections)for(let o of e.checks)if(o.required&&o.status!=="pass")return 2;return 0}export{k as a,C as b,w as c,b as d};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as m}from"./chunk-5NBT5IVT.js";import{x as t}from"./chunk-DEUDRSU7.js";import{a as p}from"./chunk-HCBYKLMW.js";import{a,b as r,i as u}from"./chunk-C44QQJR4.js";import{a as b}from"./chunk-6YGTRKDT.js";import{e as n}from"./chunk-UR6MHSHU.js";var c=n(b(),1);var e=n(p(),1);function R({onSubmit:l}){let[o,f]=(0,c.useState)(0),s=(0,c.useRef)(!1);return u((x,i)=>{s.current||(i.leftArrow||i.rightArrow?f(d=>d===0?1:0):i.return?(s.current=!0,l(o===0?"positive":"negative")):i.escape&&(s.current=!0,l(null)))}),(0,e.jsxs)(a,{flexDirection:"column",marginTop:1,children:[(0,e.jsxs)(a,{children:[(0,e.jsx)(r,{color:t.secondary,children:"Rate this session: "}),(0,e.jsx)(r,{color:o===0?t.orange:t.dim,children:o===0?"[ \u{1F44D} ]":" \u{1F44D} "}),(0,e.jsx)(r,{children:" "}),(0,e.jsx)(r,{color:o===1?t.orange:t.dim,children:o===1?"[ \u{1F44E} ]":" \u{1F44E} "})]}),(0,e.jsx)(m,{bindings:[{keys:"\u2190/\u2192",label:"select"},{keys:"\u21B5",label:"submit"}],escBackLabel:"skip"})]})}export{R as a};
2
+ import{a as m}from"./chunk-3CCD434H.js";import{x as t}from"./chunk-NJJQL54J.js";import{a as p}from"./chunk-HCBYKLMW.js";import{a,b as r,i as u}from"./chunk-C44QQJR4.js";import{a as b}from"./chunk-6YGTRKDT.js";import{e as n}from"./chunk-UR6MHSHU.js";var c=n(b(),1);var e=n(p(),1);function R({onSubmit:l}){let[o,f]=(0,c.useState)(0),s=(0,c.useRef)(!1);return u((x,i)=>{s.current||(i.leftArrow||i.rightArrow?f(d=>d===0?1:0):i.return?(s.current=!0,l(o===0?"positive":"negative")):i.escape&&(s.current=!0,l(null)))}),(0,e.jsxs)(a,{flexDirection:"column",marginTop:1,children:[(0,e.jsxs)(a,{children:[(0,e.jsx)(r,{color:t.secondary,children:"Rate this session: "}),(0,e.jsx)(r,{color:o===0?t.orange:t.dim,children:o===0?"[ \u{1F44D} ]":" \u{1F44D} "}),(0,e.jsx)(r,{children:" "}),(0,e.jsx)(r,{color:o===1?t.orange:t.dim,children:o===1?"[ \u{1F44E} ]":" \u{1F44E} "})]}),(0,e.jsx)(m,{bindings:[{keys:"\u2190/\u2192",label:"select"},{keys:"\u21B5",label:"submit"}],escBackLabel:"skip"})]})}export{R as a};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as f}from"./chunk-5NBT5IVT.js";import{x as r}from"./chunk-DEUDRSU7.js";import{a as g}from"./chunk-HCBYKLMW.js";import{a as i,b as n,i as p}from"./chunk-C44QQJR4.js";import{a as x}from"./chunk-6YGTRKDT.js";import{e as d}from"./chunk-UR6MHSHU.js";var b=d(x(),1);var e=d(g(),1),v=[{value:"desktop",label:"Desktop",hint:"Chrome on this machine"},{value:"emulator",label:"Emulator",hint:"a virtual Android device"},{value:"simulator",label:"Simulator",hint:"a virtual iOS device"}];function T(a){return a==="all"?v:v.filter(l=>l.value!=="desktop")}function B({mode:a="all",onSelect:l,onCancel:c}){let u=T(a),[h,m]=(0,b.useState)(0);return p((s,o)=>{if(o.escape&&c){c();return}o.upArrow&&m(t=>Math.max(0,t-1)),o.downArrow&&m(t=>Math.min(u.length-1,t+1)),o.return&&l(u[h].value)}),(0,e.jsxs)(i,{flexDirection:"column",borderStyle:"round",borderColor:r.orange,paddingX:2,paddingY:1,children:[(0,e.jsx)(n,{color:r.orange,bold:!0,children:a==="all"?"Where should tests run?":"Which kind of device?"}),(0,e.jsx)(i,{marginTop:1,flexDirection:"column",children:u.map((s,o)=>{let t=o===h;return(0,e.jsxs)(i,{children:[(0,e.jsxs)(n,{color:t?r.orange:void 0,children:[t?"\u276F ":" ",s.label]}),(0,e.jsxs)(n,{color:r.dim,children:[" ",s.hint]})]},s.value)})}),(0,e.jsx)(i,{marginTop:1,children:(0,e.jsx)(n,{color:r.dim,children:"You can change this any time with /desktop or /mobile."})}),(0,e.jsx)(f,{bindings:[{keys:"\u2191\u2193",label:"navigate"},{keys:"\u21B5",label:"select"}],suppressEscBack:!c,escBackLabel:"skip"})]})}export{B as a};
2
+ import{a as f}from"./chunk-3CCD434H.js";import{x as r}from"./chunk-NJJQL54J.js";import{a as g}from"./chunk-HCBYKLMW.js";import{a as i,b as n,i as p}from"./chunk-C44QQJR4.js";import{a as x}from"./chunk-6YGTRKDT.js";import{e as d}from"./chunk-UR6MHSHU.js";var b=d(x(),1);var e=d(g(),1),v=[{value:"desktop",label:"Desktop",hint:"Chrome on this machine"},{value:"emulator",label:"Emulator",hint:"a virtual Android device"},{value:"simulator",label:"Simulator",hint:"a virtual iOS device"}];function T(a){return a==="all"?v:v.filter(l=>l.value!=="desktop")}function B({mode:a="all",onSelect:l,onCancel:c}){let u=T(a),[h,m]=(0,b.useState)(0);return p((s,o)=>{if(o.escape&&c){c();return}o.upArrow&&m(t=>Math.max(0,t-1)),o.downArrow&&m(t=>Math.min(u.length-1,t+1)),o.return&&l(u[h].value)}),(0,e.jsxs)(i,{flexDirection:"column",borderStyle:"round",borderColor:r.orange,paddingX:2,paddingY:1,children:[(0,e.jsx)(n,{color:r.orange,bold:!0,children:a==="all"?"Where should tests run?":"Which kind of device?"}),(0,e.jsx)(i,{marginTop:1,flexDirection:"column",children:u.map((s,o)=>{let t=o===h;return(0,e.jsxs)(i,{children:[(0,e.jsxs)(n,{color:t?r.orange:void 0,children:[t?"\u276F ":" ",s.label]}),(0,e.jsxs)(n,{color:r.dim,children:[" ",s.hint]})]},s.value)})}),(0,e.jsx)(i,{marginTop:1,children:(0,e.jsx)(n,{color:r.dim,children:"You can change this any time with /desktop or /mobile."})}),(0,e.jsx)(f,{bindings:[{keys:"\u2191\u2193",label:"navigate"},{keys:"\u21B5",label:"select"}],suppressEscBack:!c,escBackLabel:"skip"})]})}export{B as a};
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as k}from"./chunk-A76UL3EN.js";import{x as u}from"./chunk-DEUDRSU7.js";import{a as f}from"./chunk-HCBYKLMW.js";import{a as m,b as s,k as b}from"./chunk-C44QQJR4.js";import{e as p}from"./chunk-UR6MHSHU.js";function B(t){let e=t;return e=e.replace(/@TS\{([^}]+)\}/g,"@S{$1}"),e=e.replace(/@TS-(\d+)/g,(o,i)=>`@S${parseInt(i,10)}.C1`),e=e.replace(/@TS(\d+)/g,(o,i)=>`@S${parseInt(i,10)}`),e=e.replace(/\\n/g,`
2
+ import{a as k}from"./chunk-5AHOVOWV.js";import{x as u}from"./chunk-NJJQL54J.js";import{a as f}from"./chunk-HCBYKLMW.js";import{a as m,b as s,k as b}from"./chunk-C44QQJR4.js";import{e as p}from"./chunk-UR6MHSHU.js";function B(t){let e=t;return e=e.replace(/@TS\{([^}]+)\}/g,"@S{$1}"),e=e.replace(/@TS-(\d+)/g,(o,i)=>`@S${parseInt(i,10)}.C1`),e=e.replace(/@TS(\d+)/g,(o,i)=>`@S${parseInt(i,10)}`),e=e.replace(/\\n/g,`
3
3
  `),e}var c=p(f(),1),S=t=>t!==void 0&&/[A-Za-z0-9]/.test(t);function x(t){let e=[],o="",i=()=>{o&&(e.push({text:o}),o="")},d=(a,l,r)=>(a===0||!S(t[a-1]))&&(l+r>=t.length||!S(t[l+r])),n=0;for(;n<t.length;){let a=t.slice(n,n+2),l=t[n];if(a==="**"||a==="__"){let r=t.indexOf(a,n+2);if(r!==-1&&r>n+2&&(a==="**"||d(n,r,2))){i(),e.push({text:t.slice(n+2,r),bold:!0}),n=r+2;continue}}if(l==="`"){let r=t.indexOf("`",n+1);if(r!==-1&&r>n+1){i(),e.push({text:t.slice(n+1,r),code:!0}),n=r+1;continue}}if(l==="*"||l==="_"){let r=t.indexOf(l,n+1);if(r!==-1&&r>n+1&&(l==="*"||d(n,r,1))){i(),e.push({text:t.slice(n+1,r),italic:!0}),n=r+1;continue}}o+=l,n+=1}return i(),e.length===0&&e.push({text:""}),e}function h(t){return t.map((e,o)=>(0,c.jsx)(s,{bold:e.bold,italic:e.italic,color:e.code?u.dim:void 0,children:e.text},o))}function T(t){return t.split(`
4
4
  `).map(e=>{if(e.trim()==="")return{kind:"blank"};let o=e.match(/^\s*[-*+]\s+(.*)$/);if(o)return{kind:"bullet",segs:x(o[1])};let i=e.match(/^\s*(\d+)\.\s+(.*)$/);if(i)return{kind:"numbered",n:i[1],segs:x(i[2])};let d=e.match(/^#{1,6}\s+(.*)$/);return d?{kind:"heading",segs:x(d[1])}:{kind:"para",segs:x(e)}})}function R(t,e,o=""){switch(t.kind){case"blank":return(0,c.jsx)(s,{children:o||" "},e);case"heading":return(0,c.jsxs)(s,{bold:!0,children:[o,h(t.segs)]},e);case"bullet":return(0,c.jsx)(m,{marginLeft:1,children:(0,c.jsxs)(s,{children:[o,"\u2022 ",h(t.segs)]})},e);case"numbered":return(0,c.jsx)(m,{marginLeft:1,children:(0,c.jsxs)(s,{children:[o,`${t.n}. `,h(t.segs)]})},e);default:return(0,c.jsxs)(s,{children:[o,h(t.segs)]},e)}}function $({text:t,accent:e=u.generateAccent}){let o=T(B(t)),{stdout:i}=b(),d=i?.columns??80;return(0,c.jsxs)(m,{marginBottom:1,children:[(0,c.jsx)(m,{width:2,flexShrink:0,children:(0,c.jsx)(s,{color:e,children:"\u2503"})}),(0,c.jsx)(m,{flexDirection:"column",width:d-2,children:o.map((n,a)=>R(n,a))})]})}var g=p(f(),1),I=5;function C({thinking:t,expanded:e,thinkingDone:o,maxLines:i=I}){if(!e)return(0,g.jsxs)(m,{paddingX:1,children:[(0,g.jsx)(s,{color:u.dim,children:o?"\u2237 thinking complete ":"\u2237 thinking\u2026 "}),(0,g.jsx)(s,{color:u.muted,children:o?"(ctrl+t to view)":"(ctrl+t to show)"})]});let d=t.split(`
5
5
  `),n=Math.max(0,d.length-i),a=n>0?d.slice(-i).join(`
@@ -1,3 +1,3 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as Ee}from"./chunk-Z4QLCWLB.js";import{a as he,b as _e,d as be,e as Se}from"./chunk-BB2W35TW.js";import{a as me}from"./chunk-DNNZ353O.js";import{B as le,c as fe,h as ue,o as pe}from"./chunk-R4EGL7VM.js";import{a as ge}from"./chunk-JQW2QFSX.js";import{a as ce,b as K}from"./chunk-TYRTD5DD.js";import{g as de,j as ae}from"./chunk-OXHMUZJV.js";import{d as u,e as p,f as ie,g as oe,h as re}from"./chunk-AKX4VRRR.js";var Ce=/\s@verifies\s+(ac-[\w.:\/-]+(?:\s*,\s*ac-[\w.:\/-]+)*)\s*$/,N=r=>({record:null,errors:r,minted:{},logicalIds:{},superseded:[],warnings:[],finalizedTests:{}});function w(r){return r.toLowerCase().trim().replace(/\s+/g," ")}function ke(r,I){let t=r.resolve(I);if(!t||r.nodeLabel.get(t.cid)!==u.USECASE||t.superseded)return[];let m=new Set;for(let{cid:g}of r.byLabel(u.SCENARIO))if(!r.superseded.has(g)&&r.edgesFrom(g).some(O=>O.type===p.BELONGS_TO&&r.tipOf(O.dst)===t.cid)){m.add(g);for(let O of r.edgesInto(g))O.type!==p.AUTOMATES||r.superseded.has(O.src)||m.add(O.src)}return[...m]}function Be(r){let{contextDir:I,graph:t,sections:m,by:g}=r,O=r.engine??"design@1",J=de(I);if(t.latestHash!==J)return N([{code:"STALE_BASIS",detail:`graph opened at ${String(t.latestHash)} but chain head is ${String(J)} \u2014 re-open and retry`}]);let D=t.resolve(r.ucRef);if(!D||t.nodeLabel.get(D.cid)!==u.USECASE||D.superseded)return N([{code:"UNKNOWN_UC",detail:`${r.ucRef} is not a live use-case`}]);let S=D.cid,_=[],W=/^design@(\d+)$/.exec(r.templateVersion??""),$e=W!==null&&Number.parseInt(W[1],10)>=3,Q=new Map,ye=(e,s)=>{let n=Q.get(e.source_cid);if(n===void 0){let c=me(r.contextDir,t,e.source_cid);n=c?Ee(c.toString("utf8")):null,Q.set(e.source_cid,n)}if(n===null)return _.push({code:"CITE_UNVERIFIED",detail:`${s}: source ${e.source_id} (${e.source_cid.slice(0,19)}) has no citable text to verify against`}),!1;let d=fe(t.mediaOf(e.source_cid),e,n);if(d.length>0){for(let c of d)_.push({code:"CITE_UNVERIFIED",detail:`${s}: ${c.code}: ${c.detail}`});return!1}return!0},T=[],L=[],y=[],G=[],F=[],E={},x={},j={},k=[],P=[],X=new Set,M=[],q=new Set,R=new Set,V=[];{let e=r.forceScope??(r.force?ke(t,r.ucRef):[]),s=new Set;r.sections.scenarios?.length&&s.add(u.SCENARIO),r.sections.tests?.length&&s.add(u.TEST);for(let n of e)t.superseded.has(n)||(s.has(t.nodeLabel.get(n)??"")?R.add(n):V.push(n))}let A=new Set,z=e=>!t.superseded.has(e)&&(!R.has(e)||A.has(e)),v=(e,s,n)=>{if(E[e])return E[e];let d=t.resolve(e),c=d?z(d.cid)?d.cid:t.tipOf(d.cid):null;return!d||!c||!z(c)?(_.push({code:"UNKNOWN_REF",detail:`${s}: '${e}' is neither in this payload nor a live committed node`}),null):n&&t.nodeLabel.get(c)!==n?(_.push({code:"ILLEGAL_EDGE",detail:`${s}: '${e}' is a ${t.nodeLabel.get(c)}, expected ${n}`}),null):c},ve=(e,s,n,d)=>{if(t.nameOf.has(s)){x[d]=t.nameOf.get(s);return}let c=le(e,h=>X.has(h),t.names.keys());c!==null&&(X.add(c),G.push({cid:s,slug:c,by:g}),x[d]=c)},B=(e,s,n,d)=>{for(let h of ie(e,n))_.push({code:h.code,detail:`${s}: ${h.detail}`});let c=ce(e,n);return t.hasNode(c)&&!t.superseded.has(c)?(R.has(c)&&A.add(c),E[s]=c,c):(T.push({cid:c,label:e,content:n}),E[s]=c,ve(e,c,d,s),c)},$=(e,s,n,d,c)=>{let h=K(e,s,n,d);if(t.edgesFrom(s).some(i=>i.ecid===h&&!t.superseded.has(i.ecid))){e===p.AUTOMATES&&q.add(n);return}if(t.superseded.has(h)){_.push({code:"EDGE_RETRACTED",detail:`${c}: this ${e} edge was retracted (${h}) \u2014 retraction is terminal for commits. Add a NEW relationship (different endpoint or props), redesign, or revert the retracting record`});return}let C=t.nodeLabel.get(s)??T.find(i=>i.cid===s)?.label??"(unknown)",U=t.nodeLabel.get(n)??T.find(i=>i.cid===n)?.label??"(unknown)";for(let i of re(e,C,U,d))_.push({code:i.code,detail:`${c}: ${i.detail}`});let a=ue(t,e,s,n,M);if(a){_.push({code:a.code,detail:`${c}: ${a.detail}`});return}if(e===p.BELONGS_TO||e===p.SCOPED_TO){let i=ge(t,{type:e,src:s,dst:n},{pending:M,retracted:new Set(y.flatMap(o=>o.kind==="edge"?[o.ecid]:[])),freed:new Set([...R].filter(o=>!A.has(o)))},c);if(i){_.push(i);return}}if(e===p.AUTOMATES){if(q.has(n)){_.push({code:"CARDINALITY_VIOLATION",detail:`${c}: two automates onto ${n} in one record (strict 1:1)`});return}if(q.add(n),!R.has(n)||A.has(n)){let i=l=>R.has(l)&&!A.has(l);if(t.edgesFrom(s).some(l=>l.type===p.AUTOMATES&&l.dst!==n&&!t.superseded.has(l.dst)&&!i(l.dst))&&t.hasNode(s)){_.push({code:"CARDINALITY_VIOLATION",detail:`${c}: automates from ${s} already has a live edge \u2014 supersede it first`});return}if(t.edgesInto(n).some(l=>l.type===p.AUTOMATES&&l.src!==s&&!t.superseded.has(l.src)&&!i(l.src))){_.push({code:"CARDINALITY_VIOLATION",detail:`${c}: automates onto ${n} already has a live edge \u2014 strict 1:1, supersede it first`});return}}}L.push({ecid:K(e,s,n,d),type:e,src:s,dst:n,props:d}),M.push({src:s,dst:n,type:e})},H=new Set;for(let e of m.gaps??[]){let s=e.temp_ref??e.ref??"gap",n=e.question;if(!n||typeof n!="object"||!n.header||!Array.isArray(n.options)||n.options.length===0||!Number.isInteger(n.recommended_index)){_.push({code:"GAP_QUESTION_INCOMPLETE",detail:`${s}: design gaps carry a full ranked question object (header/options/recommended_index)`});continue}e.kind==="budget-evicted"&&e.ref&&H.add(e.ref);let d={kind:e.kind,question:n,derived:!0,uc:S,...e.risk?{risk:e.risk}:{},...e.risk_rationale?{risk_rationale:e.risk_rationale}:{},...e.text?{text:e.text}:{},...e.ref?{ref:e.ref}:{}};B(u.GAP,s,d,String(n.header))}let Z=new Map;for(let{cid:e,content:s}of t.byLabel(u.SCENARIO))z(e)&&t.edgesFrom(e).some(n=>n.type===p.BELONGS_TO&&t.tipOf(n.dst)===S)&&Z.set(w(String(s.title??"")),e);for(let e of m.scenarios??[]){let s=Z.get(w(e.title));if(s){_.push({code:"DUPLICATE_SCENARIO",detail:`${e.temp_ref}: '${e.title}' duplicates live scenario ${t.nameOf.get(s)??s} \u2014 exercise/link it instead (reuse before minting)`});continue}let n={title:e.title,intent:e.intent,case_type:e.case_type,derived:!0,...e.technique_notes?{technique_notes:e.technique_notes}:{},...e.description?{description:e.description}:{},...e.parameters?{parameters:e.parameters}:{},...e.tags?{tags:e.tags}:{}};B(u.SCENARIO,e.temp_ref,n,e.title)}for(let e of m.scenarios??[]){let s=E[e.temp_ref];if(s){$(p.BELONGS_TO,s,S,{},e.temp_ref);for(let n of e.depends_on??[]){let d=v(n,`${e.temp_ref}.depends_on`,u.SCENARIO);d&&$(p.DEPENDS_ON,s,d,{},`${e.temp_ref}.depends_on`)}}}for(let e of m.acs??[]){let s={text:e.text,kind:e.kind,risk:e.risk,derived:!0,...e.expected_answer?{expected_answer:e.expected_answer}:{},...e.measurable!==void 0?{measurable:e.measurable}:{}},n=B(u.AC,e.temp_ref,s,e.text);if(!n)continue;let d=e.scope?.type==="scenario"&&e.scope.ref?v(e.scope.ref,`${e.temp_ref}.scope`,u.SCENARIO):S;d&&!t.edgesFrom(n).some(c=>c.type===p.SCOPED_TO&&!t.superseded.has(c.ecid))&&$(p.SCOPED_TO,n,d,{},`${e.temp_ref}.scope`);for(let c of e.cites??[]){if($e&&!ye(c,`${e.temp_ref}.cite`))continue;let h={source_id:c.source_id,source_cid:c.source_cid,anchor:c.anchor,...c.quote?{quote:c.quote}:{}};$(p.DERIVES,c.source_cid,n,h,`${e.temp_ref}.cite`)}}for(let e of m.exercises??[]){let s=v(e.scenario,"exercises.scenario",u.SCENARIO),n=v(e.ac,"exercises.ac",u.AC);s&&n&&$(p.EXERCISES,s,n,{},`exercises ${e.scenario}\u2192${e.ac}`)}let ee=0;for(let e of m.scoped_to_repoints??[]){let s=v(e.ac,"scoped_to_repoints.ac",u.AC),n=v(e.to,"scoped_to_repoints.to");if(!s||!n)continue;let d=t.edgesFrom(s).find(c=>c.type===p.SCOPED_TO&&!t.superseded.has(c.ecid));if(d&&d.dst===n){ee+=1,k.push(`scoped_to_repoints ${e.ac}: already scoped to ${e.to} \u2014 no-op`);continue}d&&y.push({kind:"edge",ecid:d.ecid,reason:`re-scoped to ${e.to} by ${g.id}`,by:g}),$(p.SCOPED_TO,s,n,{},`scoped_to_repoints ${e.ac}`)}let te=new Map;if(r.finalizeTestBody)for(let[e,s]of t.nameOf)te.set(t.tipOf(e),s);let ne=e=>t.nameOf.get(e)??te.get(t.tipOf(e))??null,Oe=e=>{let s=E[e];if(s)return x[e]??ne(s);if(t.names.has(e))return t.resolve(e)?e:null;let n=t.resolve(e);return n?ne(t.tipOf(n.cid)):null};for(let e of m.tests??[]){for(let a of e.reuses??[])H.has(a)&&_.push({code:"REUSES_EVICTED",detail:`${e.temp_ref}: reuses '${a}' which was budget-evicted \u2014 drop the edge; the dependent gap names the missing @import`});{let a=o=>o==="emulator"||o==="simulator"?o:"web",i=o=>{let f=(m.tests??[]).find(Te=>Te.temp_ref===o);if(f)return a(f.target);let l=t.resolve(o),b=l?t.getNode(t.tipOf(l.cid)??l.cid)?.content:void 0;if(typeof b?.target=="string")return a(String(b.target));let se=/^\s*\[mobile:\s*(emulator|simulator)\]/m.exec(String(b?.test_md_blob??""));return se?se[1]:"web"};for(let o of e.reuses??[]){let f=a(e.target),l=i(o);f!==l&&_.push({code:"REUSES_CROSS_SURFACE",detail:`${e.temp_ref}: reuses '${o}' which runs on ${l} while this test runs on ${f} \u2014 a test imports only same-surface units`})}}let s=e.test_md_blob,n=e.definitionId,d=e.objectives_blob;if(r.finalizeTestBody){let a;try{a=r.finalizeTestBody({temp_ref:e.temp_ref,test_md_blob:e.test_md_blob,verifies:e.verifies,reuses:e.reuses??[]},Oe)}catch(i){return N([{code:"FINALIZE_BODY",detail:`${e.temp_ref}: ${i instanceof Error?i.message:String(i)}`}])}a&&(s=a.test_md_blob,n=a.definitionId,d=a.objectives_blob??d,j[e.temp_ref]=n)}let c={title:e.title,check:e.check,definitionId:n,derived:!0,...e.config?{config:e.config}:{},...s?{test_md_blob:s}:{},...d?{objectives_blob:d}:{},...e.surface_required!==void 0?{surface_required:e.surface_required}:{},...e.target?{target:e.target}:{},...e.app&&e.target?{app:e.app}:{}},h=B(u.TEST,e.temp_ref,c,e.title);if(!h)continue;let C=v(e.automates,`${e.temp_ref}.automates`,u.SCENARIO);C&&$(p.AUTOMATES,h,C,{},`${e.temp_ref}.automates`);for(let a of e.verifies){let i=v(a,`${e.temp_ref}.verifies`,u.AC);i&&$(p.VERIFIES,h,i,{},`${e.temp_ref}.verifies`)}for(let a of e.reuses??[]){if(H.has(a))continue;let i=v(a,`${e.temp_ref}.reuses`,u.TEST);i&&$(p.REUSES,h,i,{},`${e.temp_ref}.reuses`)}for(let a of e.verifies){let i=E[a]??t.resolve(a)?.cid;i&&(t.trust.get(i)??"derived")==="derived"&&!T.some(o=>o.cid===i)?k.push(`${e.temp_ref}: verifies ${a} which is still DERIVED (unapproved) \u2014 committed anyway; approve it in chat or via review`):i&&E[a]===i&&(m.acs??[]).some(o=>o.temp_ref===a)&&k.push(`${e.temp_ref}: verifies ${a} minted in this same record (unapproved) \u2014 committed anyway; approve it in chat`)}if(!String(e.test_md_blob??"").split(`
2
+ import{a as Ee}from"./chunk-KGKJU27A.js";import{a as he,b as _e,d as be,e as Se}from"./chunk-BB2W35TW.js";import{a as me}from"./chunk-DNNZ353O.js";import{B as le,c as fe,h as ue,o as pe}from"./chunk-W3Z7AZNT.js";import{a as ge}from"./chunk-JQW2QFSX.js";import{a as ce,b as K}from"./chunk-UH2ZTX4E.js";import{g as de,j as ae}from"./chunk-XMTSHHYQ.js";import{d as u,e as p,f as ie,g as oe,h as re}from"./chunk-AKX4VRRR.js";var Ce=/\s@verifies\s+(ac-[\w.:\/-]+(?:\s*,\s*ac-[\w.:\/-]+)*)\s*$/,N=r=>({record:null,errors:r,minted:{},logicalIds:{},superseded:[],warnings:[],finalizedTests:{}});function w(r){return r.toLowerCase().trim().replace(/\s+/g," ")}function ke(r,I){let t=r.resolve(I);if(!t||r.nodeLabel.get(t.cid)!==u.USECASE||t.superseded)return[];let m=new Set;for(let{cid:g}of r.byLabel(u.SCENARIO))if(!r.superseded.has(g)&&r.edgesFrom(g).some(O=>O.type===p.BELONGS_TO&&r.tipOf(O.dst)===t.cid)){m.add(g);for(let O of r.edgesInto(g))O.type!==p.AUTOMATES||r.superseded.has(O.src)||m.add(O.src)}return[...m]}function Be(r){let{contextDir:I,graph:t,sections:m,by:g}=r,O=r.engine??"design@1",J=de(I);if(t.latestHash!==J)return N([{code:"STALE_BASIS",detail:`graph opened at ${String(t.latestHash)} but chain head is ${String(J)} \u2014 re-open and retry`}]);let D=t.resolve(r.ucRef);if(!D||t.nodeLabel.get(D.cid)!==u.USECASE||D.superseded)return N([{code:"UNKNOWN_UC",detail:`${r.ucRef} is not a live use-case`}]);let S=D.cid,_=[],W=/^design@(\d+)$/.exec(r.templateVersion??""),$e=W!==null&&Number.parseInt(W[1],10)>=3,Q=new Map,ye=(e,s)=>{let n=Q.get(e.source_cid);if(n===void 0){let c=me(r.contextDir,t,e.source_cid);n=c?Ee(c.toString("utf8")):null,Q.set(e.source_cid,n)}if(n===null)return _.push({code:"CITE_UNVERIFIED",detail:`${s}: source ${e.source_id} (${e.source_cid.slice(0,19)}) has no citable text to verify against`}),!1;let d=fe(t.mediaOf(e.source_cid),e,n);if(d.length>0){for(let c of d)_.push({code:"CITE_UNVERIFIED",detail:`${s}: ${c.code}: ${c.detail}`});return!1}return!0},T=[],L=[],y=[],G=[],F=[],E={},x={},j={},k=[],P=[],X=new Set,M=[],q=new Set,R=new Set,V=[];{let e=r.forceScope??(r.force?ke(t,r.ucRef):[]),s=new Set;r.sections.scenarios?.length&&s.add(u.SCENARIO),r.sections.tests?.length&&s.add(u.TEST);for(let n of e)t.superseded.has(n)||(s.has(t.nodeLabel.get(n)??"")?R.add(n):V.push(n))}let A=new Set,z=e=>!t.superseded.has(e)&&(!R.has(e)||A.has(e)),v=(e,s,n)=>{if(E[e])return E[e];let d=t.resolve(e),c=d?z(d.cid)?d.cid:t.tipOf(d.cid):null;return!d||!c||!z(c)?(_.push({code:"UNKNOWN_REF",detail:`${s}: '${e}' is neither in this payload nor a live committed node`}),null):n&&t.nodeLabel.get(c)!==n?(_.push({code:"ILLEGAL_EDGE",detail:`${s}: '${e}' is a ${t.nodeLabel.get(c)}, expected ${n}`}),null):c},ve=(e,s,n,d)=>{if(t.nameOf.has(s)){x[d]=t.nameOf.get(s);return}let c=le(e,h=>X.has(h),t.names.keys());c!==null&&(X.add(c),G.push({cid:s,slug:c,by:g}),x[d]=c)},B=(e,s,n,d)=>{for(let h of ie(e,n))_.push({code:h.code,detail:`${s}: ${h.detail}`});let c=ce(e,n);return t.hasNode(c)&&!t.superseded.has(c)?(R.has(c)&&A.add(c),E[s]=c,c):(T.push({cid:c,label:e,content:n}),E[s]=c,ve(e,c,d,s),c)},$=(e,s,n,d,c)=>{let h=K(e,s,n,d);if(t.edgesFrom(s).some(i=>i.ecid===h&&!t.superseded.has(i.ecid))){e===p.AUTOMATES&&q.add(n);return}if(t.superseded.has(h)){_.push({code:"EDGE_RETRACTED",detail:`${c}: this ${e} edge was retracted (${h}) \u2014 retraction is terminal for commits. Add a NEW relationship (different endpoint or props), redesign, or revert the retracting record`});return}let C=t.nodeLabel.get(s)??T.find(i=>i.cid===s)?.label??"(unknown)",U=t.nodeLabel.get(n)??T.find(i=>i.cid===n)?.label??"(unknown)";for(let i of re(e,C,U,d))_.push({code:i.code,detail:`${c}: ${i.detail}`});let a=ue(t,e,s,n,M);if(a){_.push({code:a.code,detail:`${c}: ${a.detail}`});return}if(e===p.BELONGS_TO||e===p.SCOPED_TO){let i=ge(t,{type:e,src:s,dst:n},{pending:M,retracted:new Set(y.flatMap(o=>o.kind==="edge"?[o.ecid]:[])),freed:new Set([...R].filter(o=>!A.has(o)))},c);if(i){_.push(i);return}}if(e===p.AUTOMATES){if(q.has(n)){_.push({code:"CARDINALITY_VIOLATION",detail:`${c}: two automates onto ${n} in one record (strict 1:1)`});return}if(q.add(n),!R.has(n)||A.has(n)){let i=l=>R.has(l)&&!A.has(l);if(t.edgesFrom(s).some(l=>l.type===p.AUTOMATES&&l.dst!==n&&!t.superseded.has(l.dst)&&!i(l.dst))&&t.hasNode(s)){_.push({code:"CARDINALITY_VIOLATION",detail:`${c}: automates from ${s} already has a live edge \u2014 supersede it first`});return}if(t.edgesInto(n).some(l=>l.type===p.AUTOMATES&&l.src!==s&&!t.superseded.has(l.src)&&!i(l.src))){_.push({code:"CARDINALITY_VIOLATION",detail:`${c}: automates onto ${n} already has a live edge \u2014 strict 1:1, supersede it first`});return}}}L.push({ecid:K(e,s,n,d),type:e,src:s,dst:n,props:d}),M.push({src:s,dst:n,type:e})},H=new Set;for(let e of m.gaps??[]){let s=e.temp_ref??e.ref??"gap",n=e.question;if(!n||typeof n!="object"||!n.header||!Array.isArray(n.options)||n.options.length===0||!Number.isInteger(n.recommended_index)){_.push({code:"GAP_QUESTION_INCOMPLETE",detail:`${s}: design gaps carry a full ranked question object (header/options/recommended_index)`});continue}e.kind==="budget-evicted"&&e.ref&&H.add(e.ref);let d={kind:e.kind,question:n,derived:!0,uc:S,...e.risk?{risk:e.risk}:{},...e.risk_rationale?{risk_rationale:e.risk_rationale}:{},...e.text?{text:e.text}:{},...e.ref?{ref:e.ref}:{}};B(u.GAP,s,d,String(n.header))}let Z=new Map;for(let{cid:e,content:s}of t.byLabel(u.SCENARIO))z(e)&&t.edgesFrom(e).some(n=>n.type===p.BELONGS_TO&&t.tipOf(n.dst)===S)&&Z.set(w(String(s.title??"")),e);for(let e of m.scenarios??[]){let s=Z.get(w(e.title));if(s){_.push({code:"DUPLICATE_SCENARIO",detail:`${e.temp_ref}: '${e.title}' duplicates live scenario ${t.nameOf.get(s)??s} \u2014 exercise/link it instead (reuse before minting)`});continue}let n={title:e.title,intent:e.intent,case_type:e.case_type,derived:!0,...e.technique_notes?{technique_notes:e.technique_notes}:{},...e.description?{description:e.description}:{},...e.parameters?{parameters:e.parameters}:{},...e.tags?{tags:e.tags}:{}};B(u.SCENARIO,e.temp_ref,n,e.title)}for(let e of m.scenarios??[]){let s=E[e.temp_ref];if(s){$(p.BELONGS_TO,s,S,{},e.temp_ref);for(let n of e.depends_on??[]){let d=v(n,`${e.temp_ref}.depends_on`,u.SCENARIO);d&&$(p.DEPENDS_ON,s,d,{},`${e.temp_ref}.depends_on`)}}}for(let e of m.acs??[]){let s={text:e.text,kind:e.kind,risk:e.risk,derived:!0,...e.expected_answer?{expected_answer:e.expected_answer}:{},...e.measurable!==void 0?{measurable:e.measurable}:{}},n=B(u.AC,e.temp_ref,s,e.text);if(!n)continue;let d=e.scope?.type==="scenario"&&e.scope.ref?v(e.scope.ref,`${e.temp_ref}.scope`,u.SCENARIO):S;d&&!t.edgesFrom(n).some(c=>c.type===p.SCOPED_TO&&!t.superseded.has(c.ecid))&&$(p.SCOPED_TO,n,d,{},`${e.temp_ref}.scope`);for(let c of e.cites??[]){if($e&&!ye(c,`${e.temp_ref}.cite`))continue;let h={source_id:c.source_id,source_cid:c.source_cid,anchor:c.anchor,...c.quote?{quote:c.quote}:{}};$(p.DERIVES,c.source_cid,n,h,`${e.temp_ref}.cite`)}}for(let e of m.exercises??[]){let s=v(e.scenario,"exercises.scenario",u.SCENARIO),n=v(e.ac,"exercises.ac",u.AC);s&&n&&$(p.EXERCISES,s,n,{},`exercises ${e.scenario}\u2192${e.ac}`)}let ee=0;for(let e of m.scoped_to_repoints??[]){let s=v(e.ac,"scoped_to_repoints.ac",u.AC),n=v(e.to,"scoped_to_repoints.to");if(!s||!n)continue;let d=t.edgesFrom(s).find(c=>c.type===p.SCOPED_TO&&!t.superseded.has(c.ecid));if(d&&d.dst===n){ee+=1,k.push(`scoped_to_repoints ${e.ac}: already scoped to ${e.to} \u2014 no-op`);continue}d&&y.push({kind:"edge",ecid:d.ecid,reason:`re-scoped to ${e.to} by ${g.id}`,by:g}),$(p.SCOPED_TO,s,n,{},`scoped_to_repoints ${e.ac}`)}let te=new Map;if(r.finalizeTestBody)for(let[e,s]of t.nameOf)te.set(t.tipOf(e),s);let ne=e=>t.nameOf.get(e)??te.get(t.tipOf(e))??null,Oe=e=>{let s=E[e];if(s)return x[e]??ne(s);if(t.names.has(e))return t.resolve(e)?e:null;let n=t.resolve(e);return n?ne(t.tipOf(n.cid)):null};for(let e of m.tests??[]){for(let a of e.reuses??[])H.has(a)&&_.push({code:"REUSES_EVICTED",detail:`${e.temp_ref}: reuses '${a}' which was budget-evicted \u2014 drop the edge; the dependent gap names the missing @import`});{let a=o=>o==="emulator"||o==="simulator"?o:"web",i=o=>{let f=(m.tests??[]).find(Te=>Te.temp_ref===o);if(f)return a(f.target);let l=t.resolve(o),b=l?t.getNode(t.tipOf(l.cid)??l.cid)?.content:void 0;if(typeof b?.target=="string")return a(String(b.target));let se=/^\s*\[mobile:\s*(emulator|simulator)\]/m.exec(String(b?.test_md_blob??""));return se?se[1]:"web"};for(let o of e.reuses??[]){let f=a(e.target),l=i(o);f!==l&&_.push({code:"REUSES_CROSS_SURFACE",detail:`${e.temp_ref}: reuses '${o}' which runs on ${l} while this test runs on ${f} \u2014 a test imports only same-surface units`})}}let s=e.test_md_blob,n=e.definitionId,d=e.objectives_blob;if(r.finalizeTestBody){let a;try{a=r.finalizeTestBody({temp_ref:e.temp_ref,test_md_blob:e.test_md_blob,verifies:e.verifies,reuses:e.reuses??[]},Oe)}catch(i){return N([{code:"FINALIZE_BODY",detail:`${e.temp_ref}: ${i instanceof Error?i.message:String(i)}`}])}a&&(s=a.test_md_blob,n=a.definitionId,d=a.objectives_blob??d,j[e.temp_ref]=n)}let c={title:e.title,check:e.check,definitionId:n,derived:!0,...e.config?{config:e.config}:{},...s?{test_md_blob:s}:{},...d?{objectives_blob:d}:{},...e.surface_required!==void 0?{surface_required:e.surface_required}:{},...e.target?{target:e.target}:{},...e.app&&e.target?{app:e.app}:{}},h=B(u.TEST,e.temp_ref,c,e.title);if(!h)continue;let C=v(e.automates,`${e.temp_ref}.automates`,u.SCENARIO);C&&$(p.AUTOMATES,h,C,{},`${e.temp_ref}.automates`);for(let a of e.verifies){let i=v(a,`${e.temp_ref}.verifies`,u.AC);i&&$(p.VERIFIES,h,i,{},`${e.temp_ref}.verifies`)}for(let a of e.reuses??[]){if(H.has(a))continue;let i=v(a,`${e.temp_ref}.reuses`,u.TEST);i&&$(p.REUSES,h,i,{},`${e.temp_ref}.reuses`)}for(let a of e.verifies){let i=E[a]??t.resolve(a)?.cid;i&&(t.trust.get(i)??"derived")==="derived"&&!T.some(o=>o.cid===i)?k.push(`${e.temp_ref}: verifies ${a} which is still DERIVED (unapproved) \u2014 committed anyway; approve it in chat or via review`):i&&E[a]===i&&(m.acs??[]).some(o=>o.temp_ref===a)&&k.push(`${e.temp_ref}: verifies ${a} minted in this same record (unapproved) \u2014 committed anyway; approve it in chat`)}if(!String(e.test_md_blob??"").split(`
3
3
  `).some(a=>/^##\s/.test(a)&&!/—\s?assert/.test(a)&&Ce.test(a))&&e.verifies.length>1){let a=e.check?.verified_against;k.push(`${e.temp_ref}: verifies ${e.verifies.length} ACs but machine-asserts only 1 (check.verified_against=${a!=null?String(a):"?"}) \u2014 the rest ride prose only`)}}let Y=[];{let e=(i,o)=>`${i??""}\0${w(String(o??""))}`,s=(i,o)=>r.reason?`${r.reason} \u2014 evolve by ${g.id}${o?` (${o})`:""}`:i,n=new Map;for(let i of T){if(i.label!==u.SCENARIO&&i.label!==u.TEST)continue;let o=e(i.label,i.content.title);n.set(o,[...n.get(o)??[],i.cid])}let d=new Map;for(let i of R){if(A.has(i))continue;let o=e(t.nodeLabel.get(i),t.getNode(i)?.content.title);d.set(o,[...d.get(o)??[],i])}for(let[i,o]of d){let f=n.get(i)??[],l=o.length===1&&f.length===1;for(let b of o)l?(y.push({kind:"node",old:b,new:f[0],reason:s(`--force redesign of ${r.ucRef} by ${g.id} (title-matched successor)`,"title-matched successor"),by:g}),Y.push({old:b,next:f[0]})):y.push({kind:"node",old:b,new:null,reason:s(`--force redesign of ${r.ucRef} by ${g.id}`),by:g}),P.push(b)}let c=i=>t.edgesFrom(i).some(o=>o.type!==p.SCOPED_TO?!1:o.dst===S||t.tipOf(o.dst)===S?!0:t.nodeLabel.get(o.dst)===u.SCENARIO&&t.edgesFrom(o.dst).some(f=>f.type===p.BELONGS_TO&&t.tipOf(f.dst)===S)),h=new Map;for(let{cid:i,content:o}of t.byLabel(u.AC)){if(t.superseded.has(i)||!c(i))continue;let f=w(String(o.text??""));h.set(f,[...h.get(f)??[],i])}let C=new Map;for(let i of T){if(i.label!==u.AC)continue;let o=w(String(i.content.text??""));C.set(o,[...C.get(o)??[],i.cid])}for(let[i,o]of h){let f=C.get(i)??[];o.length!==1||f.length!==1||(y.push({kind:"node",old:o[0],new:f[0],reason:s(`AC re-emitted with changed content by ${g.id} (text-matched successor)`,"AC text-matched successor"),by:g}),Y.push({old:o[0],next:f[0]}),P.push(o[0]))}let U=new Set(P),a=new Set;for(let i of y)i.kind==="edge"&&a.add(i.ecid);for(let{old:i,next:o}of Y)for(let f of t.edgesInto(i))oe(f.type)?.pin?.comparesTo!=="dst_tip"||t.superseded.has(f.src)||U.has(f.src)||a.has(f.ecid)||(y.push({kind:"edge",ecid:f.ecid,reason:`re-blessed onto ${o} (redirect successor of ${i}) by ${g.id}`,by:g}),a.add(f.ecid),L.some(b=>b.type===f.type&&b.src===f.src&&b.dst===o)||t.edgesFrom(f.src).some(b=>b.type===f.type&&b.dst===o))||f.type===p.AUTOMATES&&q.has(o)||$(f.type,f.src,o,f.props,`rebless ${f.type} from ${t.nameOf.get(f.src)??f.src}`)}if(_.length>0)return N(_);if(T.length===0&&L.length===0&&y.length===0&&F.length===0)return Object.keys(E).length>0||ee>0?(k.push("everything in this phase is already current \u2014 nothing re-committed"),{record:null,errors:null,minted:E,logicalIds:x,superseded:[],warnings:k,finalizedTests:j,...r.force||r.forceScope?{forceScopeRemaining:V}:{}}):N([{code:"EMPTY_DESIGN",detail:"finalize_design produced nothing to commit"}]);if(r.generationTicket){let e=be(t,r.generationTicket);if(e!==null)return N([e])}return{record:ae(I,{ts:new Date().toISOString(),proposal_id:null,nodes:T,edges:L,review:[],supersessions:y,source_head_moves:{},...G.length>0?{names:G}:{},...(()=>{for(let e of m.judgements??[]){let s=e.target?E[e.target]??t.resolve(e.target)?.cid??S:S;F.push({about:s,rationale:`[${e.kind}] ${e.rationale}`,by:g})}return F.length>0?{judgements:F}:{}})(),design_of:{uc_cid:S,engine:O},...r.generationTicket?{design_generation:Se(r.generationTicket,S,g)}:{},...r.eventIds&&r.eventIds.length>0?{event_ids:r.eventIds}:r.sid?{event_ids:pe(t,r.sid,"design",1)}:{},...r.sid?{sid:r.sid}:{},...r.phase?{design_phase:{uc_root:he(t,S),generation:r.generationTicket?.next_gen??_e(t,r.ucRef)?.gen??1,phase:r.phase,completeness:r.phaseCompleteness??"complete"}}:{}},{expectPrev:t.latestHash}).record,errors:null,minted:E,logicalIds:x,superseded:P,warnings:k,finalizedTests:j,...r.force||r.forceScope?{forceScopeRemaining:V}:{}}}function Ue(r,I){let t=[];for(let m of r){let g=m.design_phase;!g||typeof g!="object"||g.uc_root===I&&(typeof g.phase!="string"||typeof g.generation!="number"||t.push({phase:g.phase,generation:g.generation,seq:m.seq,completeness:g.completeness==="partial"?"partial":"complete"}))}return t.sort((m,g)=>m.seq-g.seq)}export{ke as a,Be as b,Ue as c};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{homedir as a}from"os";import{join as t}from"path";var m="0.8.11";var e=t(a(),".testmuai","kaneai"),d=t(e,"profiles"),g=t(e,"tui-config.json"),h=t(e,"media"),b="https://registry.npmjs.org/@testmuai/kane-cli",A="https://api.github.com/repos/LambdaTest/kane-cli/releases",n="@testmuai/kane-cli-skill",_=`https://registry.npmjs.org/${n}`,r="kane-cli",L=[{dir:t(a(),".claude","skills",r),agent:"Claude Code"},{dir:t(a(),".agents","skills",r),agent:"Codex CLI"},{dir:t(a(),".gemini","skills",r),agent:"Gemini CLI"}],x="https://dd-proxy.lambdatest.com/intake/kane-cli",U="https://kaneai-playground.lambdatest.io",u=9222,R=9230,I=t(e,"chrome-profiles"),o=t(e,"hints"),E=t(o,"state.json");function C(s){return t(o,`catalog-${s}.json`)}var c="127.0.0.1",T=18392,S=18400,i="/callback";function f(s){return`http://${c}:${s}${i}`}var B="KANE CLI",N="*",P={prod:{authBaseUrl:"https://auth.lambdatest.com",consentUrl:"https://accounts.lambdatest.com",controllerBaseUrl:"https://kaneai-api.lambdatest.com/v16-controller/v1",tmsBaseUrl:"https://test-manager-api.lambdatest.com/api",testGeneratorBaseUrl:"https://test-manager-api.lambdatest.com",secretsBaseUrl:"https://api-hyperexecute.lambdatest.com",testManagerUiUrl:"https://test-manager.lambdatest.com",shareApiBaseUrl:"https://api.lambdatest.com",v16ServerHost:"https://kaneai-api.lambdatest.com/v16-server",evidenceViewerUrl:"https://evidence.lambdatest.com",mediaArtefactsHost:"prod-mobile-artefacts.lambdatest.com",mobileAppBaseUrl:"https://api.lambdatest.com"},stage:{authBaseUrl:"https://stage-auth.lambdatestinternal.com",consentUrl:"https://stage-accounts.lambdatestinternal.com",controllerBaseUrl:"https://auteur-stage-automind.lambdatestinternal.com/v16-controller/v1",tmsBaseUrl:"https://stage-test-manager-api.lambdatestinternal.com/api",testGeneratorBaseUrl:"https://stage-test-manager-api.lambdatestinternal.com",secretsBaseUrl:"https://api-stage-hyperexecute.lambdatestinternal.com",testManagerUiUrl:"https://stage-test-manager.lambdatestinternal.com",shareApiBaseUrl:"https://stage-api.lambdatestinternal.com",v16ServerHost:"https://auteur-stage-automind.lambdatestinternal.com/v16-server",evidenceViewerUrl:"https://stage-evidence.lambdatestinternal.com",mediaArtefactsHost:"stage-mobile-artefacts.lambdatestinternal.com",mobileAppBaseUrl:"https://stage-api.lambdatestinternal.com"}},O={orange:"#ff9500",generateAccent:"#0d9488",assuranceAccent:"#b388ff",purple:"#b388ff",secondary:"#888888",dim:"#666666",muted:"#444444",green:"#4ade80",red:"#ef4444",amber:"#fbbf24"};export{m as a,e as b,g as c,h as d,b as e,A as f,n as g,L as h,x as i,U as j,u as k,R as l,I as m,E as n,C as o,c as p,T as q,S as r,i as s,f as t,B as u,N as v,P as w,O as x};
2
+ import{homedir as a}from"os";import{join as t}from"path";var m="0.8.12";var e=t(a(),".testmuai","kaneai"),d=t(e,"profiles"),g=t(e,"tui-config.json"),h=t(e,"media"),b="https://registry.npmjs.org/@testmuai/kane-cli",A="https://api.github.com/repos/LambdaTest/kane-cli/releases",n="@testmuai/kane-cli-skill",_=`https://registry.npmjs.org/${n}`,r="kane-cli",L=[{dir:t(a(),".claude","skills",r),agent:"Claude Code"},{dir:t(a(),".agents","skills",r),agent:"Codex CLI"},{dir:t(a(),".gemini","skills",r),agent:"Gemini CLI"}],x="https://dd-proxy.lambdatest.com/intake/kane-cli",U="https://kaneai-playground.lambdatest.io",u=9222,R=9230,I=t(e,"chrome-profiles"),o=t(e,"hints"),E=t(o,"state.json");function C(s){return t(o,`catalog-${s}.json`)}var c="127.0.0.1",T=18392,S=18400,i="/callback";function f(s){return`http://${c}:${s}${i}`}var B="KANE CLI",N="*",P={prod:{authBaseUrl:"https://auth.lambdatest.com",consentUrl:"https://accounts.lambdatest.com",controllerBaseUrl:"https://kaneai-api.lambdatest.com/v16-controller/v1",tmsBaseUrl:"https://test-manager-api.lambdatest.com/api",testGeneratorBaseUrl:"https://test-manager-api.lambdatest.com",secretsBaseUrl:"https://api-hyperexecute.lambdatest.com",testManagerUiUrl:"https://test-manager.lambdatest.com",shareApiBaseUrl:"https://api.lambdatest.com",v16ServerHost:"https://kaneai-api.lambdatest.com/v16-server",evidenceViewerUrl:"https://evidence.lambdatest.com",mediaArtefactsHost:"prod-mobile-artefacts.lambdatest.com",mobileAppBaseUrl:"https://api.lambdatest.com"},stage:{authBaseUrl:"https://stage-auth.lambdatestinternal.com",consentUrl:"https://stage-accounts.lambdatestinternal.com",controllerBaseUrl:"https://auteur-stage-automind.lambdatestinternal.com/v16-controller/v1",tmsBaseUrl:"https://stage-test-manager-api.lambdatestinternal.com/api",testGeneratorBaseUrl:"https://stage-test-manager-api.lambdatestinternal.com",secretsBaseUrl:"https://api-stage-hyperexecute.lambdatestinternal.com",testManagerUiUrl:"https://stage-test-manager.lambdatestinternal.com",shareApiBaseUrl:"https://stage-api.lambdatestinternal.com",v16ServerHost:"https://auteur-stage-automind.lambdatestinternal.com/v16-server",evidenceViewerUrl:"https://stage-evidence.lambdatestinternal.com",mediaArtefactsHost:"stage-mobile-artefacts.lambdatestinternal.com",mobileAppBaseUrl:"https://stage-api.lambdatestinternal.com"}},O={orange:"#ff9500",generateAccent:"#0d9488",assuranceAccent:"#b388ff",purple:"#b388ff",secondary:"#888888",dim:"#666666",muted:"#444444",green:"#4ade80",red:"#ef4444",amber:"#fbbf24"};export{m as a,e as b,g as c,h as d,b as e,A as f,n as g,L as h,x as i,U as j,u as k,R as l,I as m,E as n,C as o,c as p,T as q,S as r,i as s,f as t,B as u,N as v,P as w,O as x};
@@ -1,4 +1,4 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{e as $e}from"./chunk-Y4ODYIOP.js";import{a as te}from"./chunk-A4BDLZOD.js";import{a as K}from"./chunk-5Y2G4NC7.js";import{a as Be}from"./chunk-6DOS5CJ5.js";import{a as ve}from"./chunk-A76UL3EN.js";import{x as i}from"./chunk-DEUDRSU7.js";import{b as ye}from"./chunk-DFS4RMVP.js";import{a as k}from"./chunk-HCBYKLMW.js";import{a as s,b as o,i as Se,j as Te,k as ee}from"./chunk-C44QQJR4.js";import{a as V}from"./chunk-6YGTRKDT.js";import{e as R}from"./chunk-UR6MHSHU.js";var A=R(V(),1);var C=R(V(),1);function de(e){let t=e.flatMap(u=>[u,...u.children??[]]),n=t.filter(u=>u.status==="passed").length,l=t.filter(u=>u.status==="failed").length,a=t.filter(u=>u.status==="passed"||u.status==="failed").length;return{passed:n,failed:l,total:a}}function we(e){let t=$e(e.screenshotDispatcher,e.stepLogger,e.onReasoning,e.onStepComplete),[n,l]=(0,C.useState)(0),[a,u]=(0,C.useState)("idle"),c=(0,C.useRef)("idle"),v=(0,C.useRef)(0),S=(0,C.useRef)(!1),T=(0,C.useRef)(null),d=(0,C.useRef)(null),L=(0,C.useCallback)(h=>{c.current=h,u(h)},[]),O=(0,C.useCallback)(async h=>{let b=await e.getNextConfig(h);if(!b){L("done"),e.onAllComplete?.();return}let B=h?v.current+1:0;v.current=B,l(B),e.onStepStart?.(b,B),T.current=null,d.current=null,L("running"),await t.startRun(b,e.spawnOpts)},[t,e,L]);(0,C.useEffect)(()=>{S.current||(S.current=!0,O(null))},[]),(0,C.useEffect)(()=>{if(!t.lastRunEnd||t.lastRunEnd===T.current||c.current!=="running")return;T.current=t.lastRunEnd,c.current="transitioning",u("transitioning");let h=t.lastRunEnd,b=de(t.steps),B=t.bifurcationInfo,F={status:h.status==="passed"?"passed":"failed",duration_s:h.duration??0,reason:h.reason,runEnd:h,hadError:!1,stepsPassed:b.passed,stepsFailed:b.failed,stepsTotal:b.total,bifurcationFlows:B&&!B.isSingleFlow?B.flows:null,evidence:t.getEvidenceState()};if(!(e.onStepEnd?.(F,v.current)??!0)){L("done"),e.onAllComplete?.();return}O(F)},[t.lastRunEnd]),(0,C.useEffect)(()=>{if(!t.runError||t.runError===d.current||t.lastRunEnd||c.current!=="running")return;d.current=t.runError,c.current="transitioning",u("transitioning");let h=de(t.steps),b={status:"failed",duration_s:0,reason:t.runError,runEnd:null,hadError:!0,stepsPassed:h.passed,stepsFailed:h.failed,stepsTotal:h.total,bifurcationFlows:null,evidence:t.getEvidenceState()};if(!(e.onStepEnd?.(b,v.current)??!0)){L("done"),e.onAllComplete?.();return}O(b)},[t.runError,t.lastRunEnd]);let y=(0,C.useCallback)(()=>{t.cancelRun()},[t]);return{runner:t,currentStepIndex:n,phase:a,cancel:y}}var pe=R(V(),1);var ne=R(k(),1),Ee=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function ke({label:e,hasBifurcation:t=!1}){let[n,l]=(0,pe.useState)(0),[a,u]=(0,pe.useState)(0);K(()=>{l(v=>(v+1)%Ee.length)},80),K(()=>{u(v=>(v+1)%4)},400);let c=e??(t?"Planning approach":"Analyzing objective");return(0,ne.jsxs)(s,{marginLeft:1,children:[(0,ne.jsxs)(o,{color:i.orange,children:[Ee[n]," "]}),(0,ne.jsxs)(o,{color:i.dim,children:[c,".".repeat(a+1)]})]})}function Ie(e){if(!e.isRunning||e.replayInfo)return null;let t=e.bifurcationInfo;if(t&&!t.isSingleFlow){let n=e.steps.findIndex(a=>a.status==="running");return(n===-1?e.cmInitCounts.length===0:n>=e.cmInitCounts.length)?{label:n>0?`Planning flow ${n+1}`:void 0,hasBifurcation:!0}:null}return e.cmInitCounts.length>0||e.steps.some(n=>n.children?.length)?null:{hasBifurcation:!!t}}var I=R(V(),1);var Ce=R(V(),1);var re=R(k(),1),He="#ffc580",Ue="#ffd9a8",Le="#ffffff";function oe({text:e,active:t=!0}){let[n,l]=(0,Ce.useState)(0),a=4;if(K(()=>{l(c=>(c+1)%(e.length+a*2))},t?80:null),!t)return(0,re.jsx)(o,{color:Le,children:e});let u=e.split("").map((c,v)=>{let S=n-a,T=Math.abs(v-S-a/2),d;return T<=a/2?d=He:T<=a?d=Ue:d=Le,(0,re.jsx)(o,{color:d,children:c},v)});return(0,re.jsx)(o,{children:u})}var _=R(k(),1),We={starting:i.orange,running:i.orange,passed:i.green,failed:i.red,cancelled:i.dim,timed_out:i.orange};function ie({currentStep:e,maxSteps:t,elapsed:n,status:l}){let a=We[l]??i.orange,u=n<60?`${n.toFixed(1)}s`:`${Math.floor(n/60)}m ${Math.round(n%60)}s`;return(0,_.jsxs)(s,{marginLeft:3,children:[(0,_.jsx)(o,{color:i.dim,children:"Steps "}),(0,_.jsx)(o,{bold:!0,children:e}),(0,_.jsxs)(o,{color:i.dim,children:["/",t]}),(0,_.jsx)(o,{children:" "}),(0,_.jsx)(o,{color:i.dim,children:"Elapsed "}),(0,_.jsx)(o,{bold:!0,children:u}),(0,_.jsx)(o,{children:" "}),(0,_.jsx)(o,{color:i.dim,children:"Status "}),(0,_.jsx)(o,{bold:!0,color:a,children:l})]})}var Ve={click:"\u25CF",type:"\u229E",scroll:"\u2195",navigate:"\u2192",analyze:"\u25CE",assert:"\u25C8","if-else":"\u2442",select:"\u25BC",press_key:"\u21B5",wait:"\u2026",tool_call:"\u2299"};function Oe(e){return Ve[e]??"\u25CF"}var q=R(k(),1);function fe({steps:e,flows:t,cmInitCounts:n,renderStep:l}){return(0,q.jsxs)(s,{flexDirection:"column",marginLeft:2,paddingLeft:1,children:[(0,q.jsxs)(o,{color:i.dim,children:["\u2501\u2501 Bifurcated into ",t?.length??e.length," flows \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"]}),e.map((a,u)=>(0,q.jsxs)(s,{flexDirection:"column",marginTop:u>0?1:0,children:[(0,q.jsxs)(o,{color:i.orange,children:["Flow ",u+1,": ",t?.[u]??a.objective]}),n&&n[u]!=null&&(0,q.jsxs)(o,{color:i.dim,children:[" \u25AA Generated task with ",n[u]," checkpoints"]}),a.children&&a.children.length>0?a.children.map(c=>{let v=!!c.branchObjective,S=`f${u}-${c.childId??"p"}-${c.index}`;return v?(0,q.jsxs)(s,{flexDirection:"column",children:[l({...c,children:void 0},S),(c.children??[]).map(T=>(0,q.jsx)(s,{marginLeft:2,children:l(T,`${S}-${T.childId??"p"}-${T.index}`)},`${S}-${T.childId??"p"}-${T.index}`))]},`${S}-host`):l(c,S)}):a.status==="pending"&&(0,q.jsx)(o,{color:i.dim,children:" \u25CB Waiting..."})]},u))]})}var H=R(k(),1);function Pe({label:e,shimmer:t=!1}){return(0,H.jsxs)(s,{marginLeft:6,children:[(0,H.jsx)(te,{}),(0,H.jsx)(o,{children:" "}),t?(0,H.jsx)(oe,{text:e,active:!0}):(0,H.jsx)(o,{color:i.dim,children:e})]})}var De=R(V(),1);var me=R(k(),1);function ze(e,t){let n=[];for(let l of e.split(`
2
+ import{e as $e}from"./chunk-7R5K4IGS.js";import{a as te}from"./chunk-75HF3GPO.js";import{a as K}from"./chunk-5Y2G4NC7.js";import{a as Be}from"./chunk-5FYO3PFG.js";import{a as ve}from"./chunk-5AHOVOWV.js";import{x as i}from"./chunk-NJJQL54J.js";import{b as ye}from"./chunk-DFS4RMVP.js";import{a as k}from"./chunk-HCBYKLMW.js";import{a as s,b as o,i as Se,j as Te,k as ee}from"./chunk-C44QQJR4.js";import{a as V}from"./chunk-6YGTRKDT.js";import{e as R}from"./chunk-UR6MHSHU.js";var A=R(V(),1);var C=R(V(),1);function de(e){let t=e.flatMap(u=>[u,...u.children??[]]),n=t.filter(u=>u.status==="passed").length,l=t.filter(u=>u.status==="failed").length,a=t.filter(u=>u.status==="passed"||u.status==="failed").length;return{passed:n,failed:l,total:a}}function we(e){let t=$e(e.screenshotDispatcher,e.stepLogger,e.onReasoning,e.onStepComplete),[n,l]=(0,C.useState)(0),[a,u]=(0,C.useState)("idle"),c=(0,C.useRef)("idle"),v=(0,C.useRef)(0),S=(0,C.useRef)(!1),T=(0,C.useRef)(null),d=(0,C.useRef)(null),L=(0,C.useCallback)(h=>{c.current=h,u(h)},[]),O=(0,C.useCallback)(async h=>{let b=await e.getNextConfig(h);if(!b){L("done"),e.onAllComplete?.();return}let B=h?v.current+1:0;v.current=B,l(B),e.onStepStart?.(b,B),T.current=null,d.current=null,L("running"),await t.startRun(b,e.spawnOpts)},[t,e,L]);(0,C.useEffect)(()=>{S.current||(S.current=!0,O(null))},[]),(0,C.useEffect)(()=>{if(!t.lastRunEnd||t.lastRunEnd===T.current||c.current!=="running")return;T.current=t.lastRunEnd,c.current="transitioning",u("transitioning");let h=t.lastRunEnd,b=de(t.steps),B=t.bifurcationInfo,F={status:h.status==="passed"?"passed":"failed",duration_s:h.duration??0,reason:h.reason,runEnd:h,hadError:!1,stepsPassed:b.passed,stepsFailed:b.failed,stepsTotal:b.total,bifurcationFlows:B&&!B.isSingleFlow?B.flows:null,evidence:t.getEvidenceState()};if(!(e.onStepEnd?.(F,v.current)??!0)){L("done"),e.onAllComplete?.();return}O(F)},[t.lastRunEnd]),(0,C.useEffect)(()=>{if(!t.runError||t.runError===d.current||t.lastRunEnd||c.current!=="running")return;d.current=t.runError,c.current="transitioning",u("transitioning");let h=de(t.steps),b={status:"failed",duration_s:0,reason:t.runError,runEnd:null,hadError:!0,stepsPassed:h.passed,stepsFailed:h.failed,stepsTotal:h.total,bifurcationFlows:null,evidence:t.getEvidenceState()};if(!(e.onStepEnd?.(b,v.current)??!0)){L("done"),e.onAllComplete?.();return}O(b)},[t.runError,t.lastRunEnd]);let y=(0,C.useCallback)(()=>{t.cancelRun()},[t]);return{runner:t,currentStepIndex:n,phase:a,cancel:y}}var pe=R(V(),1);var ne=R(k(),1),Ee=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function ke({label:e,hasBifurcation:t=!1}){let[n,l]=(0,pe.useState)(0),[a,u]=(0,pe.useState)(0);K(()=>{l(v=>(v+1)%Ee.length)},80),K(()=>{u(v=>(v+1)%4)},400);let c=e??(t?"Planning approach":"Analyzing objective");return(0,ne.jsxs)(s,{marginLeft:1,children:[(0,ne.jsxs)(o,{color:i.orange,children:[Ee[n]," "]}),(0,ne.jsxs)(o,{color:i.dim,children:[c,".".repeat(a+1)]})]})}function Ie(e){if(!e.isRunning||e.replayInfo)return null;let t=e.bifurcationInfo;if(t&&!t.isSingleFlow){let n=e.steps.findIndex(a=>a.status==="running");return(n===-1?e.cmInitCounts.length===0:n>=e.cmInitCounts.length)?{label:n>0?`Planning flow ${n+1}`:void 0,hasBifurcation:!0}:null}return e.cmInitCounts.length>0||e.steps.some(n=>n.children?.length)?null:{hasBifurcation:!!t}}var I=R(V(),1);var Ce=R(V(),1);var re=R(k(),1),He="#ffc580",Ue="#ffd9a8",Le="#ffffff";function oe({text:e,active:t=!0}){let[n,l]=(0,Ce.useState)(0),a=4;if(K(()=>{l(c=>(c+1)%(e.length+a*2))},t?80:null),!t)return(0,re.jsx)(o,{color:Le,children:e});let u=e.split("").map((c,v)=>{let S=n-a,T=Math.abs(v-S-a/2),d;return T<=a/2?d=He:T<=a?d=Ue:d=Le,(0,re.jsx)(o,{color:d,children:c},v)});return(0,re.jsx)(o,{children:u})}var _=R(k(),1),We={starting:i.orange,running:i.orange,passed:i.green,failed:i.red,cancelled:i.dim,timed_out:i.orange};function ie({currentStep:e,maxSteps:t,elapsed:n,status:l}){let a=We[l]??i.orange,u=n<60?`${n.toFixed(1)}s`:`${Math.floor(n/60)}m ${Math.round(n%60)}s`;return(0,_.jsxs)(s,{marginLeft:3,children:[(0,_.jsx)(o,{color:i.dim,children:"Steps "}),(0,_.jsx)(o,{bold:!0,children:e}),(0,_.jsxs)(o,{color:i.dim,children:["/",t]}),(0,_.jsx)(o,{children:" "}),(0,_.jsx)(o,{color:i.dim,children:"Elapsed "}),(0,_.jsx)(o,{bold:!0,children:u}),(0,_.jsx)(o,{children:" "}),(0,_.jsx)(o,{color:i.dim,children:"Status "}),(0,_.jsx)(o,{bold:!0,color:a,children:l})]})}var Ve={click:"\u25CF",type:"\u229E",scroll:"\u2195",navigate:"\u2192",analyze:"\u25CE",assert:"\u25C8","if-else":"\u2442",select:"\u25BC",press_key:"\u21B5",wait:"\u2026",tool_call:"\u2299"};function Oe(e){return Ve[e]??"\u25CF"}var q=R(k(),1);function fe({steps:e,flows:t,cmInitCounts:n,renderStep:l}){return(0,q.jsxs)(s,{flexDirection:"column",marginLeft:2,paddingLeft:1,children:[(0,q.jsxs)(o,{color:i.dim,children:["\u2501\u2501 Bifurcated into ",t?.length??e.length," flows \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"]}),e.map((a,u)=>(0,q.jsxs)(s,{flexDirection:"column",marginTop:u>0?1:0,children:[(0,q.jsxs)(o,{color:i.orange,children:["Flow ",u+1,": ",t?.[u]??a.objective]}),n&&n[u]!=null&&(0,q.jsxs)(o,{color:i.dim,children:[" \u25AA Generated task with ",n[u]," checkpoints"]}),a.children&&a.children.length>0?a.children.map(c=>{let v=!!c.branchObjective,S=`f${u}-${c.childId??"p"}-${c.index}`;return v?(0,q.jsxs)(s,{flexDirection:"column",children:[l({...c,children:void 0},S),(c.children??[]).map(T=>(0,q.jsx)(s,{marginLeft:2,children:l(T,`${S}-${T.childId??"p"}-${T.index}`)},`${S}-${T.childId??"p"}-${T.index}`))]},`${S}-host`):l(c,S)}):a.status==="pending"&&(0,q.jsx)(o,{color:i.dim,children:" \u25CB Waiting..."})]},u))]})}var H=R(k(),1);function Pe({label:e,shimmer:t=!1}){return(0,H.jsxs)(s,{marginLeft:6,children:[(0,H.jsx)(te,{}),(0,H.jsx)(o,{children:" "}),t?(0,H.jsx)(oe,{text:e,active:!0}):(0,H.jsx)(o,{color:i.dim,children:e})]})}var De=R(V(),1);var me=R(k(),1);function ze(e,t){let n=[];for(let l of e.split(`
3
3
  `)){if(l===""){n.push("");continue}let a="";for(let u of l.split(" ")){let c=u;for(;c.length>t;)a&&(n.push(a),a=""),n.push(c.slice(0,t)),c=c.slice(t);a===""?a=c:a.length+1+c.length<=t?a+=" "+c:(n.push(a),a=c)}n.push(a)}return n}function je({text:e,maxLines:t=3}){let{stdout:n}=ee(),l=Math.max(20,(n?.columns??80)-7),a=!e.trim(),[u,c]=(0,De.useState)(!0);K(()=>c(T=>!T),500);let v=(a?"Thinking\u2026":e)+(u?"\u258C":" "),S=ze(v,l).slice(-t);for(;S.length<t;)S.push("");return(0,me.jsx)(s,{borderStyle:"round",borderColor:i.muted,paddingX:1,marginLeft:3,flexDirection:"column",children:S.map((T,d)=>(0,me.jsx)(o,{color:a?i.dim:i.secondary,wrap:"truncate-end",children:T.length?T:" "},d))})}var U=R(k(),1);function se({activity:e,describe:t,describeVisible:n}){return(0,U.jsxs)(U.Fragment,{children:[e?(0,U.jsx)(Pe,{label:e.label,shimmer:e.shimmer}):null,n?(0,U.jsx)(je,{text:t??""}):null]})}var r=R(k(),1);function le(e){for(let t of e){if(t.children&&t.children.length>0){let n=le(t.children);if(n)return n}if(t.status==="running")return t}}function z(e){return e.status==="running"&&!e.branchObjective&&(!e.children||e.children.length===0)}function Fe(e){let t=[];for(let n of e)z(n)||(n.children&&n.children.length>0?t.push({...n,children:Fe(n.children)}):t.push(n));return t}function ge(e,t){if(!e)return null;let n=e.objective??"";return n.length>0&&!/^Step \d+$/.test(n)?{label:n+"\u2026",shimmer:!1}:{label:t?"Looking at the screen\u2026":"Deciding next action\u2026",shimmer:!0}}function P({step:e,indent:t=2}){let n=e.actionType?Oe(e.actionType):null,l=e.status==="running",a=e.status==="passed",u=e.status==="failed",c=e.status==="pending"||e.status==="stopped",{stdout:v}=ee(),S=v?.columns??80,T=Math.max(20,S-t-21),d=e.objective??"",L=d.length>T?d.slice(0,T-1)+"\u2026":d,O=(e.duration??0)*1e3,y=e.duration!=null?O<1e3?`${Math.round(O)}ms`:`${(O/1e3).toFixed(1)}s`:"";return(0,r.jsxs)(s,{flexDirection:"column",children:[(0,r.jsxs)(s,{marginLeft:t,children:[(0,r.jsx)(s,{width:4,children:(0,r.jsxs)(o,{color:i.muted,children:[String(e.index).padStart(2," ")," "]})}),(0,r.jsx)(s,{width:3,children:l?(0,r.jsx)(te,{}):a?(0,r.jsx)(o,{color:i.green,bold:!0,children:"\u2713"}):u?(0,r.jsx)(o,{color:i.red,bold:!0,children:"\u2717"}):(0,r.jsx)(o,{color:i.muted,children:"\u25CB"})}),(0,r.jsx)(s,{flexGrow:1,children:l?(0,r.jsx)(oe,{text:L,active:!0}):u?(0,r.jsx)(o,{color:i.red,children:L}):c?(0,r.jsx)(o,{color:i.dim,children:L}):(0,r.jsx)(o,{color:i.dim,children:L})}),(a||u)&&n?(0,r.jsx)(s,{width:3,marginLeft:1,children:(0,r.jsx)(o,{color:i.muted,children:n})}):(0,r.jsx)(s,{width:3,marginLeft:1}),(0,r.jsx)(s,{width:7,justifyContent:"flex-end",children:(0,r.jsx)(o,{color:i.dim,children:y})})]}),e.children&&e.children.length>0&&(0,r.jsx)(s,{flexDirection:"column",children:e.children.map((h,b)=>(0,r.jsx)(P,{step:h,indent:t+2},`child-${b}`))})]})}function Xe(e){return e.type==="cm_init"?(0,r.jsx)(s,{marginLeft:2,paddingLeft:1,children:(0,r.jsxs)(o,{color:i.dim,children:["\u25AA Generated task with ",e.count," checkpoints"]})}):(0,r.jsx)(s,{marginLeft:2,paddingLeft:1,children:(0,r.jsx)(P,{step:e.step})})}function _e({steps:e,bifurcated:t,flows:n,cmInitCounts:l,maxSteps:a=50,staticSteps:u=!1,onStepCommit:c,describe:v,describeVisible:S,describeRevealing:T}){let d=(0,I.useRef)(new Set),L=(0,I.useRef)(!1),O=(0,I.useRef)(new Set),y=(0,I.useRef)(!1),h=(0,I.useRef)(new Set),b=(0,I.useRef)(0);(0,I.useEffect)(()=>{e.length===0&&b.current>0&&(d.current.clear(),L.current=!1,O.current.clear(),y.current=!1,h.current.clear()),b.current=e.length},[e.length]);let B=e.flatMap(p=>[p,...p.children??[]]),F=B.some(p=>p.status==="running"),M=B.some(p=>p.status==="failed"),X=B.length===0||B.every(p=>p.status==="pending"),Y=B.filter(p=>p.status==="passed"||p.status==="failed").length,N;X?N="starting":F?N="running":M?N="failed":N="passed";let J=(0,I.useRef)(null),[ce,he]=(0,I.useState)(0);(0,I.useEffect)(()=>{B.length===0||X?(J.current=null,he(0)):F&&J.current==null&&(J.current=Date.now())},[F,X,B.length]),(0,I.useEffect)(()=>{if(!F)return;let p=setInterval(()=>{J.current!=null&&he((Date.now()-J.current)/1e3)},500);return()=>clearInterval(p)},[F]);let ae=(0,I.useRef)(new Set),[,xe]=(0,I.useState)(0),be=(0,I.useRef)(!1);(0,I.useEffect)(()=>{if(!c||!u||t)return;let p=[];!be.current&&l&&l[0]!=null&&(be.current=!0,l[0]>0&&p.push({key:"cm_init_0",type:"cm_init",count:l[0]}));for(let g of e)(g.status==="passed"||g.status==="failed")&&!ae.current.has(g.index)&&(ae.current.add(g.index),p.push({key:`step_${g.index}`,type:"step",step:{...g,children:g.children?[...g.children]:void 0}}));if(p.length>0){for(let g of p)c(Xe(g));xe(g=>g+1)}},[e,t,l,u,c]),(0,I.useEffect)(()=>{if(!c||u)return;let p=d.current.size;if(!t&&!y.current&&l&&l[0]!=null&&(y.current=!0,l[0]>0&&c((0,r.jsx)(s,{marginLeft:2,children:(0,r.jsxs)(o,{color:i.dim,children:["\u25A0 Generated task with ",l[0]," checkpoints"]})}))),t&&n&&!L.current&&(L.current=!0,c((0,r.jsx)(o,{color:i.purple,children:"\u2501\u2501 Bifurcated into "+n.length+" flows \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"}))),t){let g=e.flatMap((x,f)=>{let m=x.children??[];return!O.current.has(f)&&m.length>0&&(O.current.add(f),c((0,r.jsx)(o,{color:i.purple,children:" Flow "+(f+1)+": "+(n?.[f]??"")})),l?.[f]!=null&&l[f]>0&&!h.current.has(f)&&(h.current.add(f),c((0,r.jsx)(s,{marginLeft:2,children:(0,r.jsxs)(o,{color:i.dim,children:[" \u25AA Generated task with ",l[f]," checkpoints"]})})))),l?.[f]!=null&&l[f]>0&&O.current.has(f)&&!h.current.has(f)&&(h.current.add(f),c((0,r.jsx)(s,{marginLeft:2,children:(0,r.jsxs)(o,{color:i.dim,children:[" \u25AA Generated task with ",l[f]," checkpoints"]})}))),m});for(let x of g){let f=`${x.childId??"p"}-${x.index}-${x.objective}`;if(!!x.branchObjective){d.current.has(f)||(d.current.add(f),c((0,r.jsx)(s,{marginLeft:2,children:(0,r.jsx)(P,{step:{...x,children:void 0}})})));for(let $ of x.children??[]){let w=`child-${x.childId??"p"}-${x.index}-${$.childId??"p"}-${$.index}-${$.objective}`;d.current.has(w)||($.status==="passed"||$.status==="failed"||$.status==="stopped")&&(d.current.add(w),c((0,r.jsx)(s,{marginLeft:4,children:(0,r.jsx)(P,{step:$})})))}continue}d.current.has(f)||(x.status==="passed"||x.status==="failed"||x.status==="stopped")&&(d.current.add(f),c((0,r.jsx)(s,{marginLeft:2,children:(0,r.jsx)(P,{step:x})})))}}else for(let g of e){let x=`${g.index}-${g.objective}`,f=!!g.branchObjective;f&&!d.current.has(x)&&(d.current.add(x),c((0,r.jsx)(s,{marginLeft:2,children:(0,r.jsx)(P,{step:{...g,children:void 0}})})));for(let m of g.children??[]){let $=`child-${g.index}-${m.childId??"p"}-${m.index}-${m.objective}`;d.current.has($)||(m.status==="passed"||m.status==="failed"||m.status==="stopped")&&(d.current.add($),c((0,r.jsx)(s,{marginLeft:4,children:(0,r.jsx)(P,{step:m})})))}!f&&!d.current.has(x)&&(g.status==="passed"||g.status==="failed"||g.status==="stopped")&&(d.current.add(x),c((0,r.jsx)(s,{marginLeft:2,children:(0,r.jsx)(P,{step:{...g,children:void 0}})})))}d.current.size>p&&xe(g=>g+1)},[e,c,t,n,l]);let G=[];if(u&&!t)for(let p of e)ae.current.has(p.index)||G.push(p);else if(c&&!u)if(t)for(let p of e){let g=p.children??[],x=[];for(let f of g){let m=`${f.childId??"p"}-${f.index}-${f.objective}`,$=d.current.has(m);if(f.branchObjective){let w=(f.children??[]).filter(Q=>{let ue=`child-${f.childId??"p"}-${f.index}-${Q.childId??"p"}-${Q.index}-${Q.objective}`;return!d.current.has(ue)});(!$||w.length>0)&&x.push({...f,children:w})}else $||x.push(f)}x.length>0&&G.push({...p,children:x})}else for(let p of e){let g=`${p.index}-${p.objective}`,x=d.current.has(g),f=(p.children??[]).filter(m=>{let $=`child-${p.index}-${m.childId??"p"}-${m.index}-${m.objective}`;return!d.current.has($)});x?f.length>0&&G.push({...p,children:f}):G.push({...p,children:f})}if(!u){let p=c?G:e,g=le(p),x=ge(g,T);return(0,r.jsxs)(s,{flexDirection:"column",children:[t?c?p.length>0?(0,r.jsx)(s,{flexDirection:"column",marginLeft:2,paddingLeft:1,children:p.map((m,$)=>(0,r.jsx)(s,{flexDirection:"column",marginTop:$>0?1:0,children:m.children&&m.children.length>0?m.children.map(w=>{if(z(w))return null;let Q=!!w.branchObjective,ue=`${w.childId??"p"}-${w.index}-${w.objective}`,Ke=d.current.has(ue);return Q?(0,r.jsxs)(s,{flexDirection:"column",children:[!Ke&&(0,r.jsx)(P,{step:{...w,children:void 0}}),(w.children??[]).filter(Z=>!z(Z)).map(Z=>(0,r.jsx)(s,{marginLeft:2,children:(0,r.jsx)(P,{step:Z})},`f${$}-${w.index}-${Z.childId??"p"}-${Z.index}`))]},`f${$}-host-${w.childId??"p"}-${w.index}`):(0,r.jsx)(P,{step:w},`f${$}-${w.childId??"p"}-${w.index}`)}):m.status==="pending"&&(0,r.jsx)(o,{color:i.dim,children:" \u25CB Waiting..."})},$))}):null:(0,r.jsx)(fe,{steps:e,flows:n,cmInitCounts:l,renderStep:(m,$)=>z(m)?null:(0,r.jsx)(P,{step:m},$)}):(0,r.jsxs)(s,{flexDirection:"column",marginLeft:2,paddingLeft:1,children:[!c&&l&&l[0]!=null&&(0,r.jsxs)(o,{color:i.dim,children:["\u25AA Generated task with ",l[0]," checkpoints"]}),p.filter(m=>!(m.status==="running"&&(!m.children||m.children.length===0))).map(m=>{let $=`${m.index}-${m.objective}`;return c&&d.current.has($)?(0,r.jsx)(s,{flexDirection:"column",children:(m.children??[]).filter(w=>!z(w)).map(w=>(0,r.jsx)(s,{marginLeft:2,children:(0,r.jsx)(P,{step:w})},`${w.childId??"p"}-${w.index}`))},`branch-children-${m.index}`):(0,r.jsx)(P,{step:m},m.index)})]}),(0,r.jsx)(se,{activity:x,describe:v,describeVisible:S}),B.length>0&&(0,r.jsx)(ie,{currentStep:Y,maxSteps:a,elapsed:ce,status:N})]})}if(t){let p=le(e),g=ge(p,T);return(0,r.jsxs)(s,{flexDirection:"column",children:[(0,r.jsx)(fe,{steps:e,flows:n,cmInitCounts:l,renderStep:(x,f)=>z(x)?null:(0,r.jsx)(P,{step:x},f)}),(0,r.jsx)(se,{activity:g,describe:v,describeVisible:S}),B.length>0&&(0,r.jsx)(ie,{currentStep:Y,maxSteps:a,elapsed:ce,status:N})]})}let Ne=le(G),Ge=ge(Ne,T),Re=Fe(G);return(0,r.jsxs)(s,{flexDirection:"column",children:[Re.length>0&&(0,r.jsx)(s,{flexDirection:"column",marginLeft:2,paddingLeft:1,children:Re.map(p=>(0,r.jsx)(P,{step:p},p.index))}),(0,r.jsx)(se,{activity:Ge,describe:v,describeVisible:S}),B.length>0&&(0,r.jsx)(ie,{currentStep:Y,maxSteps:a,elapsed:ce,status:N})]})}var W=R(k(),1);function Ae({runner:e,runKey:t,onStepCommit:n}){let l=Ie({isRunning:e.isRunning,bifurcationInfo:e.bifurcationInfo,steps:e.steps,cmInitCounts:e.cmInitCounts,replayInfo:e.replayInfo});return(0,W.jsxs)(W.Fragment,{children:[l&&(0,W.jsx)(ke,{label:l.label,hasBifurcation:l.hasBifurcation}),e.isRunning&&e.steps.length>0&&(0,W.jsx)(_e,{steps:e.steps,bifurcated:!!e.bifurcationInfo&&!e.bifurcationInfo.isSingleFlow,flows:e.bifurcationInfo?.flows,cmInitCounts:e.cmInitCounts,maxSteps:e.maxSteps,onStepCommit:n},`run-${t}`)]})}var D=R(k(),1),Ye=64;function Je(e){return e.split(`
4
4
  `).map(t=>t.replace(/^[-–•]\s*/,"").trim()).filter(t=>t.length>0)}function qe({status:e,summary:t,duration:n,steps:l,stepsPassed:a,stepsFailed:u,reason:c,creditsConsumed:v}){let S=e==="passed",T=S?i.green:i.red,d=S?"\u2713":"\u2717",L=e.toUpperCase(),O=a??(S?l:Math.max(0,l-1)),y=u??(S?0:1),h=y>0?`${l} steps (${O} passed, ${y} failed)`:`${l} steps`,b=n<60?`${n.toFixed(1)}s`:`${Math.floor(n/60)}m ${Math.round(n%60)}s`,B=Je(t);return(0,D.jsx)(s,{flexDirection:"column",marginTop:1,children:(0,D.jsxs)(s,{borderStyle:"round",borderColor:T,flexDirection:"column",paddingX:2,paddingY:1,width:Ye+6,children:[(0,D.jsxs)(s,{flexDirection:"column",children:[(0,D.jsxs)(o,{bold:!0,color:T,children:[d," ",L]}),(0,D.jsxs)(o,{color:i.dim,wrap:"wrap",children:[h," \xB7 ",b,typeof v=="number"&&v>0?` \xB7 ${parseFloat(v.toFixed(4))} credits`:""]})]}),B.length>0&&(0,D.jsx)(s,{flexDirection:"column",marginTop:1,marginLeft:1,children:B.map((F,M)=>(0,D.jsxs)(s,{marginBottom:M<B.length-1?1:0,children:[(0,D.jsx)(o,{color:i.orange,children:"\u25CF "}),(0,D.jsx)(s,{flexShrink:1,children:(0,D.jsx)(o,{wrap:"wrap",children:F})})]},M))}),c&&!S&&(0,D.jsx)(s,{marginTop:1,children:(0,D.jsxs)(o,{color:i.red,wrap:"wrap",children:["Reason: ",c]})})]})})}var j=R(k(),1);function Me({message:e,code:t,remediation:n,docsUrl:l}){return(0,j.jsx)(ve,{title:"Error",variant:"error",children:(0,j.jsxs)(s,{flexDirection:"column",paddingY:1,children:[(0,j.jsxs)(o,{color:i.red,bold:!0,children:[" \u2717 ",e]}),t&&(0,j.jsxs)(s,{marginTop:0,marginLeft:5,children:[(0,j.jsx)(o,{color:i.muted,children:"Code: "}),(0,j.jsx)(o,{color:i.dim,children:t})]}),n&&(0,j.jsxs)(s,{flexDirection:"column",marginTop:1,marginLeft:5,children:[(0,j.jsx)(o,{color:i.green,bold:!0,children:"Fix:"}),(0,j.jsxs)(o,{color:i.orange,children:["$ ",n]})]}),l&&(0,j.jsxs)(s,{marginTop:1,marginLeft:5,children:[(0,j.jsx)(o,{color:i.muted,children:"Docs: "}),(0,j.jsx)(o,{color:i.orange,underline:!0,children:l})]})]})})}var E=R(k(),1);function un(e){let{exit:t}=Te(),{append:n}=ye(),l=(0,A.useRef)(!1);(0,A.useEffect)(()=>{l.current||(l.current=!0,n((0,E.jsx)(s,{flexDirection:"column",marginBottom:1,children:(0,E.jsxs)(s,{borderStyle:"round",borderColor:"#dc4e08",paddingX:2,children:[(0,E.jsx)(o,{color:"#ff9500",bold:!0,children:"KaneAI CLI"}),(0,E.jsx)(o,{color:i.dim,children:" \u2502 "}),(0,E.jsx)(o,{color:i.orange,children:e.topBanner.model}),(0,E.jsx)(o,{color:i.dim,children:" \u2502 "}),(0,E.jsx)(o,{color:i.dim,children:e.topBanner.auth})]})})),n((0,E.jsx)(Qe,{data:e.globalConfig})),e.priorAttemptRollup&&n((0,E.jsx)(o,{color:i.dim,children:` \u21B3 replayed ${e.priorAttemptRollup.startIdx}..${e.priorAttemptRollup.endIdx-1} (${e.priorAttemptRollup.count} steps, from prior attempt)`})))},[]);let a=(0,A.useRef)(null),u=(0,A.useCallback)(async y=>{let h=await e.getNextStep(y);return h?(a.current=h,h.config):(a.current=null,null)},[e]),c=(0,A.useCallback)((y,h)=>{let b=a.current;if(!b)return;let B=b.mode==="replay"?"cyan":"#dc4e08",F=b.modeReason?` (${b.modeReason})`:"",M=b.perStepOverrides?Object.entries(b.perStepOverrides):[];n((0,E.jsxs)(s,{flexDirection:"column",marginBottom:0,children:[(0,E.jsxs)(o,{children:[(0,E.jsxs)(o,{color:i.dim,children:[b.banner.stepLabel," "]}),(0,E.jsxs)(o,{color:B,children:["[",b.mode,"]"]}),(0,E.jsx)(o,{color:i.dim,children:F})]}),(0,E.jsx)(o,{color:i.dim,children:b.banner.objective}),M.length>0&&(0,E.jsxs)(o,{color:i.dim,children:["overrides: ",M.map(([X,Y])=>`${X}=${Y}`).join(", ")]})]}))},[n]),v=(0,A.useRef)(0),S=(0,A.useRef)(!1),T=(0,A.useCallback)((y,h)=>(y.hadError?n((0,E.jsx)(Me,{message:y.reason??"Runner error",code:"RUNNER_ERROR"})):n((0,E.jsx)(s,{flexDirection:"column",marginBottom:1,children:(0,E.jsx)(qe,{status:y.status,summary:y.runEnd?.summary??"",duration:y.runEnd?.duration??0,steps:y.stepsTotal,stepsPassed:y.stepsPassed,stepsFailed:y.stepsFailed,reason:y.runEnd?.reason,creditsConsumed:y.runEnd?.credits_consumed})})),e.onStepEnd?.(y,h)??!0),[n,e]),d=we({getNextConfig:u,onStepStart:c,onStepEnd:T,onAllComplete:()=>{e.onAllComplete(),e.exitOnComplete!==!1&&setImmediate(()=>t())},screenshotDispatcher:e.screenshotDispatcher,stepLogger:e.stepLogger,onReasoning:e.onReasoning,onStepComplete:e.onStepComplete,spawnOpts:e.spawnOpts}),L=250,O=5e3;return Se((y,h)=>{if(h.ctrl&&y==="c"){let b=Date.now(),B=b-v.current;if(B<L)return;S.current&&B<O?(d.cancel(),e.onCancel?.(),e.exitOnComplete!==!1&&setImmediate(()=>t())):(S.current=!0,n((0,E.jsx)(o,{color:"yellow",children:"press Ctrl+C again to cancel run"}))),v.current=b}}),(0,E.jsx)(s,{flexDirection:"column",children:d.phase!=="done"&&(0,E.jsx)(Ae,{runner:d.runner,runKey:d.currentStepIndex,onStepCommit:n})})}function Qe({data:e}){return(0,E.jsx)(Be,{title:"test.md run",titleColor:"#ff9500",borderColor:i.dim,rows:[{label:"source",value:e.source},{label:"steps",value:`${e.steps.total} (${e.steps.replay} replay, ${e.steps.author} author per walker)`},{label:"model",value:e.model},{label:"viewport",value:`${e.viewport.width} x ${e.viewport.height}`},{label:"chrome",value:e.chrome},{label:"session",value:e.session},{label:"variables",value:`${e.variables.count} (${e.variables.secrets} secret)`},{label:"flags",value:e.flags.length>0?e.flags.join(" "):"(none)"}]})}export{_e as a,ke as b,Ie as c,de as d,qe as e,Me as f,un as g};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{A as r}from"./chunk-R4EGL7VM.js";function i(t){return r.test(t)?t.toUpperCase():t}export{i as a};
2
+ import{A as r}from"./chunk-W3Z7AZNT.js";function i(t){return r.test(t)?t.toUpperCase():t}export{i as a};
@@ -1,6 +1,6 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{d as W}from"./chunk-MSGW4JDG.js";import{d as U,e as F}from"./chunk-4JOD47QI.js";import{a as H}from"./chunk-DEUDRSU7.js";import{createHash as Y}from"crypto";import{access as Q,mkdir as S,mkdtemp as Z,readdir as O,readFile as y,rename as N,rm as v,writeFile as x}from"fs/promises";import{homedir as tt}from"os";import{arch as et,platform as st}from"process";import{dirname as C,isAbsolute as nt,join as l,relative as X,resolve as rt,sep as it}from"path";var q=1,ot={emulator:"emulator",simulator:"simulator"};function Pt(i){return ot[i.kind]??null}var j=class extends Error{constructor(s,e,n){super([`Managed mobile dependencies for ${s} are not installed.`,`- kaneai-mobile-deps ${s} ${e.bundleVersion}: ${e.url} (${_(e.bytes)})`,`Destination: ${n}`,`Run \`kane-cli doctor --target ${s} --install\` to download it.`].join(`
3
- `));this.deviceClass=s;this.name="DepsInstallRequiredError"}};function _(i){return i>=1024*1024?`${Math.ceil(i/(1024*1024))} MB`:`${i} bytes`}function at(i){let t=i/1048576;return t>=10?`${Math.round(t)} MB/s`:t>=1?`${t.toFixed(1)} MB/s`:`${Math.max(1,Math.round(i/1024))} KB/s`}function lt(i){let t=Math.max(1,Math.round(i));return t<60?`~${t}s left`:`~${Math.floor(t/60)}m ${t%60}s left`}var K=8*1024*1024,ct=8;function ut(i){if(!Number.isFinite(i)||i<2*K)return null;let t=Math.min(ct,Math.floor(i/K)),s=Math.ceil(i/t),e=[];for(let n=0;n<i;n+=s)e.push({start:n,end:Math.min(n+s,i)-1});return e}async function L(i,t){let s=i.body;if(!s||typeof s.getReader!="function"){let c=new Uint8Array(await i.arrayBuffer());return t?.(c.length),c}let e=s.getReader(),n=[],r=0;for(;;){let{done:c,value:h}=await e.read();if(c)break;h&&(n.push(h),r+=h.length,t?.(h.length))}let o=new Uint8Array(r),a=0;for(let c of n)o.set(c,a),a+=c.length;return o}var z=3,dt=3e4,k=class extends Error{};async function pt(i,t,s,e,n,r=dt){let o=new Uint8Array(s),a=0,c=new AbortController,h=null,b=!1;try{await Promise.all(e.map(async(f,M)=>{let P=0,V=d=>{P+=d,a+=d,n?.(a)},T=()=>{a=Math.max(0,a-P),P=0},R=null;for(let d=0;d<z;d+=1){if(c.signal.aborted)return;let u=new AbortController,m=()=>u.abort();c.signal.addEventListener("abort",m,{once:!0});let w=!1,g=null,$=()=>{g&&clearTimeout(g),g=setTimeout(()=>{w=!0,u.abort()},r)};try{$();let p=await i(t,{headers:{Range:`bytes=${f.start}-${f.end}`},signal:u.signal});if(typeof p.body?.getReader!="function"&&g&&(clearTimeout(g),g=null),!p.ok)throw new k(`Could not download ${t}: HTTP ${p.status}`);if(p.status!==206){b=!0,M===0?h=await L(p,I=>{$(),V(I)}):await(p.body?.cancel().catch(()=>{})??Promise.resolve());return}let D=f.end-f.start+1,E=await L(p,I=>{$(),V(I)});if(E.length!==D)throw new Error(`range ${f.start}-${f.end} returned ${E.length} bytes (expected ${D})`);o.set(E,f.start);return}catch(p){if(p instanceof k)throw p;if(c.signal.aborted)return;T(),R=w?new Error(`no data for ${Math.round(r/1e3)}s`):p instanceof Error?p:new Error(String(p))}finally{g&&clearTimeout(g),c.signal.removeEventListener("abort",m)}}throw new Error(`Could not download ${t}: range ${f.start}-${f.end} failed after ${z} attempts (${R?.message??"unknown error"}) \u2014 check your network and rerun \`kane-cli doctor --target <emulator|simulator> --install\`.`)}))}catch(f){throw c.abort(),f}return h||(b?null:o)}async function ht(i,t,s,e,n){let r=ut(s);if(r){let c=await pt(i,t,s,r,e,n?.stallMs);if(c)return c}let o=await i(t);if(!o.ok)throw new Error(`Could not download ${t}: HTTP ${o.status}`);let a=0;return L(o,e&&(c=>{a+=c,e(a)}))}function ft(i){return Y("sha256").update(i).digest("hex")}function mt(i,t){let s=X(i,t);return s!==""&&!s.startsWith(`..${it}`)&&s!==".."&&!nt(s)}async function A(i){try{return await Q(i),!0}catch{return!1}}function wt(){return{home:tt(),os:st,arch:et,cliVersion:H,nodeModuleVersion:process.versions.modules,fetch,resolveBundle:async i=>(await import("./deps-resolve-MPLFFCZZ.js")).controllerResolveBundle()(i),exec:U,now:()=>new Date,wait:F,processAlive:i=>{try{return process.kill(i,0),!0}catch{return!1}}}}var B=class extends Error{constructor(s,e,n){super(`No managed mobile dependencies are published for ${s} (kane-cli ${e}).
2
+ import{d as W}from"./chunk-MSGW4JDG.js";import{d as U,e as F}from"./chunk-4JOD47QI.js";import{a as H}from"./chunk-NJJQL54J.js";import{createHash as Y}from"crypto";import{access as Q,mkdir as S,mkdtemp as Z,readdir as O,readFile as y,rename as N,rm as v,writeFile as x}from"fs/promises";import{homedir as tt}from"os";import{arch as et,platform as st}from"process";import{dirname as C,isAbsolute as nt,join as l,relative as X,resolve as rt,sep as it}from"path";var q=1,ot={emulator:"emulator",simulator:"simulator"};function Pt(i){return ot[i.kind]??null}var j=class extends Error{constructor(s,e,n){super([`Managed mobile dependencies for ${s} are not installed.`,`- kaneai-mobile-deps ${s} ${e.bundleVersion}: ${e.url} (${_(e.bytes)})`,`Destination: ${n}`,`Run \`kane-cli doctor --target ${s} --install\` to download it.`].join(`
3
+ `));this.deviceClass=s;this.name="DepsInstallRequiredError"}};function _(i){return i>=1024*1024?`${Math.ceil(i/(1024*1024))} MB`:`${i} bytes`}function at(i){let t=i/1048576;return t>=10?`${Math.round(t)} MB/s`:t>=1?`${t.toFixed(1)} MB/s`:`${Math.max(1,Math.round(i/1024))} KB/s`}function lt(i){let t=Math.max(1,Math.round(i));return t<60?`~${t}s left`:`~${Math.floor(t/60)}m ${t%60}s left`}var K=8*1024*1024,ct=8;function ut(i){if(!Number.isFinite(i)||i<2*K)return null;let t=Math.min(ct,Math.floor(i/K)),s=Math.ceil(i/t),e=[];for(let n=0;n<i;n+=s)e.push({start:n,end:Math.min(n+s,i)-1});return e}async function L(i,t){let s=i.body;if(!s||typeof s.getReader!="function"){let c=new Uint8Array(await i.arrayBuffer());return t?.(c.length),c}let e=s.getReader(),n=[],r=0;for(;;){let{done:c,value:h}=await e.read();if(c)break;h&&(n.push(h),r+=h.length,t?.(h.length))}let o=new Uint8Array(r),a=0;for(let c of n)o.set(c,a),a+=c.length;return o}var z=3,dt=3e4,k=class extends Error{};async function pt(i,t,s,e,n,r=dt){let o=new Uint8Array(s),a=0,c=new AbortController,h=null,b=!1;try{await Promise.all(e.map(async(f,M)=>{let P=0,V=d=>{P+=d,a+=d,n?.(a)},T=()=>{a=Math.max(0,a-P),P=0},R=null;for(let d=0;d<z;d+=1){if(c.signal.aborted)return;let u=new AbortController,m=()=>u.abort();c.signal.addEventListener("abort",m,{once:!0});let w=!1,g=null,$=()=>{g&&clearTimeout(g),g=setTimeout(()=>{w=!0,u.abort()},r)};try{$();let p=await i(t,{headers:{Range:`bytes=${f.start}-${f.end}`},signal:u.signal});if(typeof p.body?.getReader!="function"&&g&&(clearTimeout(g),g=null),!p.ok)throw new k(`Could not download ${t}: HTTP ${p.status}`);if(p.status!==206){b=!0,M===0?h=await L(p,I=>{$(),V(I)}):await(p.body?.cancel().catch(()=>{})??Promise.resolve());return}let D=f.end-f.start+1,E=await L(p,I=>{$(),V(I)});if(E.length!==D)throw new Error(`range ${f.start}-${f.end} returned ${E.length} bytes (expected ${D})`);o.set(E,f.start);return}catch(p){if(p instanceof k)throw p;if(c.signal.aborted)return;T(),R=w?new Error(`no data for ${Math.round(r/1e3)}s`):p instanceof Error?p:new Error(String(p))}finally{g&&clearTimeout(g),c.signal.removeEventListener("abort",m)}}throw new Error(`Could not download ${t}: range ${f.start}-${f.end} failed after ${z} attempts (${R?.message??"unknown error"}) \u2014 check your network and rerun \`kane-cli doctor --target <emulator|simulator> --install\`.`)}))}catch(f){throw c.abort(),f}return h||(b?null:o)}async function ht(i,t,s,e,n){let r=ut(s);if(r){let c=await pt(i,t,s,r,e,n?.stallMs);if(c)return c}let o=await i(t);if(!o.ok)throw new Error(`Could not download ${t}: HTTP ${o.status}`);let a=0;return L(o,e&&(c=>{a+=c,e(a)}))}function ft(i){return Y("sha256").update(i).digest("hex")}function mt(i,t){let s=X(i,t);return s!==""&&!s.startsWith(`..${it}`)&&s!==".."&&!nt(s)}async function A(i){try{return await Q(i),!0}catch{return!1}}function wt(){return{home:tt(),os:st,arch:et,cliVersion:H,nodeModuleVersion:process.versions.modules,fetch,resolveBundle:async i=>(await import("./deps-resolve-62XK3LKV.js")).controllerResolveBundle()(i),exec:U,now:()=>new Date,wait:F,processAlive:i=>{try{return process.kill(i,0),!0}catch{return!1}}}}var B=class extends Error{constructor(s,e,n){super(`No managed mobile dependencies are published for ${s} (kane-cli ${e}).
4
4
  This is a packaging gap, not something to install locally \u2014 report it, or pass --appium-url to use an Appium server you manage yourself.`);this.coordinate=s;this.cause=n;this.name="NoPublishedBundleError"}},J=class i{deps;constructor(t={}){this.deps={...wt(),...t}}mobileRoot(){return l(this.deps.home,".testmuai","kaneai","mobile")}depsRoot(){return l(this.mobileRoot(),"deps")}classRoot(t,s){return l(this.depsRoot(),s,t)}resolveCacheFile(){return l(this.depsRoot(),"resolve-cache.json")}resolveCacheKey(t){return`${this.deps.cliVersion}|${this.deps.os}-${this.deps.arch}-${t}`}static RESOLVE_CACHE_TTL_MS=1440*60*1e3;async readCachedWantedVersion(t){try{let e=JSON.parse(await y(this.resolveCacheFile(),"utf8"))[this.resolveCacheKey(t)];if(!e?.bundleVersion||!e.fetchedAt)return null;let n=this.deps.now().getTime()-new Date(e.fetchedAt).getTime();return n>=0&&n<i.RESOLVE_CACHE_TTL_MS?e.bundleVersion:null}catch{return null}}async writeResolveCache(t,s){try{let e={};try{e=JSON.parse(await y(this.resolveCacheFile(),"utf8"))}catch{}e[this.resolveCacheKey(t)]={bundleVersion:s,fetchedAt:this.deps.now().toISOString()},await S(this.depsRoot(),{recursive:!0}),await x(this.resolveCacheFile(),`${JSON.stringify(e,null,2)}
5
5
  `)}catch{}}async warmResolveCache(t){if(await this.readCachedWantedVersion(t)===null)try{await this.resolveOrExplain(t)}catch{}}paths(t,s){let e=this.classRoot(t,s);return{root:e,appium:l(e,"appium"),appiumHome:l(e,"appium-home"),platformTools:l(e,"platform-tools"),wdaDir:l(e,"wda","Build","Products","Debug-iphonesimulator"),iwdpBinDir:l(e,"bin"),installManifest:l(e,"install-manifest.json")}}async status(t,s){s||(s=await this.readCachedWantedVersion(t)??void 0);let e=[];try{e=await O(this.depsRoot())}catch{}s&&(e=e.filter(c=>c===s));let n=null;for(let c of e){let h=this.classRoot(t,c),b=null;try{b=JSON.parse(await y(l(h,"install-manifest.json"),"utf8"))}catch{continue}b.schemaVersion===q&&(!s&&b.cliVersion!==this.deps.cliVersion||(!n||b.installedAt>n.manifest.installedAt)&&(n={manifest:b,root:h}))}if(!n)return{class:t,installed:!1};let r=this.paths(t,n.manifest.bundleVersion),o=[l(r.appium,"node_modules","appium","index.js")];t==="emulator"&&o.push(l(r.platformTools,this.deps.os==="win32"?"adb.exe":"adb")),t==="simulator"&&o.push(l(r.wdaDir,"WebDriverAgentRunner-Runner.app"));for(let c of o)if(!await A(c))return{class:t,installed:!1,version:n.manifest.bundleVersion,root:n.root,corrupt:`a bundle component is missing from disk (${X(n.root,c)})`};let a=await this.postInstallDrifted(r);return{class:t,installed:!0,version:n.manifest.bundleVersion,root:n.root,...a?{needsRepair:a}:{}}}async postInstallDrifted(t){let s=l(t.appiumHome,"node_modules",".cache","appium","extensions.yaml");if(!await A(s))return!1;let e=await y(s,"utf8");for(let n of e.split(`
6
6
  `)){let r=/^\s*installPath:\s*(.+?)\s*$/.exec(n);if(r&&!r[1].startsWith(t.appiumHome))return!0}return!1}async environment(t){let s=await this.status(t);if(!s.installed||!s.version)return{dirs:[]};let e=this.paths(t,s.version),n=[],r={dirs:n,appiumHome:e.appiumHome};return t!=="simulator"&&(n.push(e.platformTools),r.platformToolsDir=e.platformTools),n.push(l(e.appium,"node_modules",".bin")),t==="simulator"&&(n.push(e.iwdpBinDir),r.wdaDir=e.wdaDir,r.wdaRoot=l(e.root,"wda"),r.iwdpBinDir=e.iwdpBinDir),r}async ensure(t,s){let e,n;try{e=await this.resolveOrExplain(t)}catch(a){n=a}let r=await this.status(t,e?.bundleVersion);if(r.installed&&!r.needsRepair)return e&&r.version&&await this.adoptInstall(t,r.version),r;if(!e)throw n;if(r.installed&&r.needsRepair&&r.version){let a=this.paths(t,r.version);return await this.withInstallLock(async()=>{await this.postInstall(a.root,a,s.onProgress)}),await this.adoptInstall(t,r.version),this.status(t,e.bundleVersion)}let o=e;if(!s.automatic&&!s.approved)throw new j(t,o,this.classRoot(t,o.bundleVersion));return await this.withInstallLock(async()=>{(await this.status(t,o.bundleVersion)).installed||await this.install(t,o,s.onProgress)}),this.status(t,o.bundleVersion)}async adoptInstall(t,s){try{let e=this.paths(t,s).installManifest,n=JSON.parse(await y(e,"utf8"));if(n.cliVersion===this.deps.cliVersion)return;n.cliVersion=this.deps.cliVersion;let r=l(C(e),`install-manifest-${process.pid}.json`);await x(r,`${JSON.stringify(n,null,2)}
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{x as m}from"./chunk-DEUDRSU7.js";import{a as x}from"./chunk-HCBYKLMW.js";import{a as u,b as a,j as g}from"./chunk-C44QQJR4.js";import{a as b}from"./chunk-6YGTRKDT.js";import{e as f}from"./chunk-UR6MHSHU.js";var T=f(b(),1);function k(i,n){if(!n)return i;let l=i.trim()||n;return`\x1B]8;;${n}\x07${l}\x1B]8;;\x07`}var r=f(x(),1);function $({shareableLink:i,testCaseLink:n,codeExportDir:l,recordedTestPath:s,outputDir:o,autoExit:p=!0}){let{exit:c}=g();(0,T.useEffect)(()=>{if(!p)return;let t=setTimeout(()=>c(),100);return()=>clearTimeout(t)},[c,p]);let e=[];return s&&e.push({label:"Test",url:s,linkUrl:`file://${s}`}),o&&e.push({label:"Output",url:o,linkUrl:`file://${o}`}),i&&e.push({label:"ShareLink",url:i}),n&&e.push({label:"TestCase",url:n}),l&&!o&&e.push({label:"CodeExport",url:l,linkUrl:`file://${l}`}),e.length===0?(0,r.jsx)(r.Fragment,{}):(0,r.jsx)(u,{flexDirection:"column",marginTop:1,marginLeft:1,children:e.map(t=>(0,r.jsxs)(u,{flexDirection:"column",marginBottom:1,children:[(0,r.jsxs)(a,{color:m.orange,children:[t.label,":"]}),(0,r.jsx)(a,{color:m.dim,children:k(t.url,t.linkUrl??t.url)})]},t.label))})}export{$ as a};
2
+ import{x as m}from"./chunk-NJJQL54J.js";import{a as x}from"./chunk-HCBYKLMW.js";import{a as u,b as a,j as g}from"./chunk-C44QQJR4.js";import{a as b}from"./chunk-6YGTRKDT.js";import{e as f}from"./chunk-UR6MHSHU.js";var T=f(b(),1);function k(i,n){if(!n)return i;let l=i.trim()||n;return`\x1B]8;;${n}\x07${l}\x1B]8;;\x07`}var r=f(x(),1);function $({shareableLink:i,testCaseLink:n,codeExportDir:l,recordedTestPath:s,outputDir:o,autoExit:p=!0}){let{exit:c}=g();(0,T.useEffect)(()=>{if(!p)return;let t=setTimeout(()=>c(),100);return()=>clearTimeout(t)},[c,p]);let e=[];return s&&e.push({label:"Test",url:s,linkUrl:`file://${s}`}),o&&e.push({label:"Output",url:o,linkUrl:`file://${o}`}),i&&e.push({label:"ShareLink",url:i}),n&&e.push({label:"TestCase",url:n}),l&&!o&&e.push({label:"CodeExport",url:l,linkUrl:`file://${l}`}),e.length===0?(0,r.jsx)(r.Fragment,{}):(0,r.jsx)(u,{flexDirection:"column",marginTop:1,marginLeft:1,children:e.map(t=>(0,r.jsxs)(u,{flexDirection:"column",marginBottom:1,children:[(0,r.jsxs)(a,{color:m.orange,children:[t.label,":"]}),(0,r.jsx)(a,{color:m.dim,children:k(t.url,t.linkUrl??t.url)})]},t.label))})}export{$ as a};
@@ -1,7 +1,7 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{g as E}from"./chunk-R7QAS6LZ.js";import{i as S}from"./chunk-XS2LZFCH.js";import{a as C,b as k,c as R,d as D}from"./chunk-YQ4MRF57.js";import{j as T,k as $,l as b}from"./chunk-3D7VYEDP.js";import{c as y}from"./chunk-5DT7PIGB.js";import{a as O}from"./chunk-CH273NAE.js";import{C as _}from"./chunk-R4EGL7VM.js";import{existsSync as H}from"fs";import{basename as q}from"path";import{appendFileSync as L,mkdirSync as U}from"fs";import{homedir as F}from"os";import{dirname as G,join as j}from"path";function P(c,s){let n=/^(DOCX_[A-Z_]+):/.exec(s)?.[1];if(n)try{let u=process.env.KANE_CONTEXT_REFUSAL_LOG??j(F(),".testmuai","kaneai","context-refusals.log");U(G(u),{recursive:!0}),L(u,`${new Date().toISOString()} ${n} ${c}
2
+ import{g as E}from"./chunk-R7QAS6LZ.js";import{i as S}from"./chunk-XS2LZFCH.js";import{a as C,b as k,c as R,d as D}from"./chunk-VDM3TWF6.js";import{j as T,k as $,l as b}from"./chunk-54JZ6VEW.js";import{c as y}from"./chunk-5DT7PIGB.js";import{a as O}from"./chunk-CH273NAE.js";import{C as _}from"./chunk-W3Z7AZNT.js";import{existsSync as H}from"fs";import{basename as q}from"path";import{appendFileSync as L,mkdirSync as U}from"fs";import{homedir as F}from"os";import{dirname as G,join as j}from"path";function P(c,s){let n=/^(DOCX_[A-Z_]+):/.exec(s)?.[1];if(n)try{let u=process.env.KANE_CONTEXT_REFUSAL_LOG??j(F(),".testmuai","kaneai","context-refusals.log");U(G(u),{recursive:!0}),L(u,`${new Date().toISOString()} ${n} ${c}
3
3
  `)}catch{}}async function w(c,s,n,u=process.cwd(),p){let l=O(u),g=[];if(s.as!==void 0&&c.length>1)return(n.err??n.out)(`error: --as names ONE source identity \u2014 pass a single file (got ${c.length})`,"AS_SINGLE_SOURCE"),{code:2,results:g};for(let o of c){if(R(o)){let a=D(o);if(a===null)return(n.err??n.out)(`error: ${o}: unsupported remote URL \u2014 supported: ${k.map(d=>d.hint).join("; ")}`,"UNSUPPORTED_URL"),{code:1,results:g};let r=await a.ingest(o,s.as,n,l,p);if(r.code!==0)return{code:r.code,results:g};r.result&&g.push({status:r.result.status==="versioned"?"versioned":r.result.status==="unchanged"?"unchanged":"created",source_id:r.result.source_id,source_cid:r.result.source_cid});continue}let f=s.as,v;if(f===void 0&&H(l)){let a=T(o),r=$(a);if(r){let d=_(l);d.heads.get(r)!=null&&d.heads.get(a)==null&&(v=r,n.isTTY&&await n.confirm(`${a} looks like a new version of existing source '${r}' \u2014 ingest as '${r}' (replaces the current version; items built on it go stale)?`)&&(f=r))}}let e;try{e=await b({contextDir:l,filePath:o,asId:f,confirmSameSource:n.isTTY?a=>n.confirm(`identical bytes already ingested as ${a} \u2014 treat as the same source?`):void 0,converters:{pdf:E,docx:S}})}catch(a){let r=a instanceof Error?a.message:String(a);return P(o,r),(n.err??n.out)(`error: ${o}: ${r}`,"INGEST_FAILED"),{code:1,results:g}}n.out(C(n.isTTY,e,q(o)));for(let a of e.warnings??[])n.out(`warning: ${a}`);if(e.composite&&(e.composite.delivered>0||e.composite.omitted>0)){let a=e.composite.pages!==void 0?` ${e.composite.pages} pages,`:"";n.out(`${e.source_id}: ${e.composite.kind},${a} ${e.composite.delivered} images delivered (${e.composite.omitted} omitted)`)}let m;if(!n.isTTY&&e.status==="created"){let a=_(l);for(let[r,d]of a.heads.entries())if(!(r===e.source_id||d==null)&&a.getNode(d)?.content.blob===e.blob){m=r,n.out(`hint: identical bytes already ingested as ${r} \u2014 merged later via review`);break}}g.push({status:e.status,source_id:e.source_id,source_cid:e.cid,...e.warnings?.length?{warnings:e.warnings}:{},...e.composite?{media:{kind:e.composite.kind,...e.composite.pages!==void 0?{pages:e.composite.pages}:{},delivered:e.composite.delivered,omitted:e.composite.omitted}}:{},...m?{duplicate_of:m}:{},...v&&f===void 0?{lineage_candidate:v}:{}})}return{code:0,results:g}}async function se(c,s,n,u=process.cwd(),p){return(await w(c,s,n,u,p)).code}async function ie(c,s){if(s.mode!=null&&!["interactive","agent","ci","override"].includes(s.mode)){let{makeHeadlessIO:t,agentRefusal:i}=await import("./headless-io-66RG5NN5.js");return i(t("ndjson","extract"),`ingest: --mode must be interactive | agent | ci | override, got '${s.mode}'`,"MODE_USAGE")}let n=y();if(s.mode==="interactive"&&!n)return process.stderr.write(`ingest: --mode interactive needs a TTY on stdin and stdout (use --mode agent|ci|override headless)
4
4
  `),2;let u=s.mode??(n?"interactive":void 0),p=u==="interactive"||u==="agent"||u==="override";if(!p&&(s.plan||s.force||s.trust!==void 0))return process.stderr.write(`ingest: --plan/--force/--trust steer the extraction \u2014 not available when only landing (use --mode agent to extract headless)
5
5
  `),2;let{createInterface:l}=await import("readline/promises"),g=u==="agent",o=g?(await import("./headless-io-66RG5NN5.js")).makeHeadlessIO("ndjson","extract"):null,f=[],v=()=>{for(let t of f.splice(0))o.event({type:"error",message:t.message,...t.code?{code:t.code}:{}})},e=t=>{for(let i of t)o.event({type:"ingested",source_id:i.source_id,status:i.status,cid:i.source_cid,...i.warnings?.length?{warnings:i.warnings}:{},...i.media?{media:i.media}:{},...i.duplicate_of?{duplicate_of:i.duplicate_of}:{},...i.lineage_candidate?{lineage_candidate:i.lineage_candidate}:{}})},m=o?{out:()=>{},err:(t,i)=>f.push({message:t.replace(/^error: /,""),...i?{code:i}:{}}),isTTY:!1,confirm:async()=>!1}:{out:t=>process.stdout.write(t+`
6
6
  `),err:t=>process.stderr.write(t+`
7
- `),isTTY:n,confirm:async t=>{let i=l({input:process.stdin,output:process.stdout});try{let h=await i.question(`${t} [Y/n] `);return!/^n(o)?$/i.test(h.trim())}finally{i.close()}}};if(!p){let{withTelemetry:t}=await import("./with-telemetry-L3SO6J3L.js");return t("ingest",async()=>{let{code:i,results:h}=await w(c,{as:s.as},m,void 0,void 0);if(i!==0)return i;let I=h.filter(Y=>Y.status!=="unchanged").length;return I>0&&(m.err??m.out)(`landed ${I} source(s) \u2014 run kane-cli context extract to extract them`),0},{write:!0})}let a;try{a=o?await(await import("./run-channel-RGH4WIQX.js")).runWithChannel({event:o.event},()=>w(c,{as:s.as},m,void 0,void 0)):await w(c,{as:s.as},m,void 0,void 0)}catch(t){if(o)return v(),o.event({type:"error",message:t instanceof Error?t.message:String(t),code:"INGEST_FAILED"}),o.done(1,"error");throw t}let{code:r,results:d}=a;if(r!==0)return o?(e(d),v(),o.done(r,r===2?"refused":"error")):r;if(d.length===0)return o?o.done(0):0;let{extractCommand:A}=await import("./extract-cmd-RHVLPNQB.js"),N=[...new Set(d.map(t=>t.source_id))],x=await A({...s.mode!==void 0?{mode:s.mode}:{},...s.plan?{plan:!0}:{},...s.force?{force:!0}:{},...s.trust!==void 0?{trust:s.trust}:{},sources:N,landed:d});if(x===2&&!g){let t=d.filter(i=>i.status!=="unchanged").length;t>0&&(m.err??m.out)(`note: the ${t} landed source(s) are safe \u2014 extract later with kane-cli context extract`)}return x}export{w as a,se as b,ie as c};
7
+ `),isTTY:n,confirm:async t=>{let i=l({input:process.stdin,output:process.stdout});try{let h=await i.question(`${t} [Y/n] `);return!/^n(o)?$/i.test(h.trim())}finally{i.close()}}};if(!p){let{withTelemetry:t}=await import("./with-telemetry-5Y2CVPXK.js");return t("ingest",async()=>{let{code:i,results:h}=await w(c,{as:s.as},m,void 0,void 0);if(i!==0)return i;let I=h.filter(Y=>Y.status!=="unchanged").length;return I>0&&(m.err??m.out)(`landed ${I} source(s) \u2014 run kane-cli context extract to extract them`),0},{write:!0})}let a;try{a=o?await(await import("./run-channel-RGH4WIQX.js")).runWithChannel({event:o.event},()=>w(c,{as:s.as},m,void 0,void 0)):await w(c,{as:s.as},m,void 0,void 0)}catch(t){if(o)return v(),o.event({type:"error",message:t instanceof Error?t.message:String(t),code:"INGEST_FAILED"}),o.done(1,"error");throw t}let{code:r,results:d}=a;if(r!==0)return o?(e(d),v(),o.done(r,r===2?"refused":"error")):r;if(d.length===0)return o?o.done(0):0;let{extractCommand:A}=await import("./extract-cmd-IPBCCR3T.js"),N=[...new Set(d.map(t=>t.source_id))],x=await A({...s.mode!==void 0?{mode:s.mode}:{},...s.plan?{plan:!0}:{},...s.force?{force:!0}:{},...s.trust!==void 0?{trust:s.trust}:{},sources:N,landed:d});if(x===2&&!g){let t=d.filter(i=>i.status!=="unchanged").length;t>0&&(m.err??m.out)(`note: the ${t} landed source(s) are safe \u2014 extract later with kane-cli context extract`)}return x}export{w as a,se as b,ie as c};
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as $}from"./chunk-W4IRHQGO.js";import{f as D}from"./chunk-AXW3WDFO.js";import{a as E}from"./chunk-NLCCBXXV.js";function U(e){return["completed","failed","ended","stopped"].includes(e.trim().toLowerCase())}function je(e){return["ended","stopped"].includes(e.trim().toLowerCase())}function q(e){return{requestId:e.requestId,objective:e.objective,status:"",turnActive:!1,scenarios:[],thinking:"",thinkingLog:[],chatLog:[],progress:0}}function Re(e){return e.pendingClarification===void 0?e:{...e,pendingClarification:void 0}}function Ce(e){return{...e,turnActive:!0,error:void 0,thinking:"",thinkingLog:[]}}function P(e,t){switch(t.type){case"thinking":return{...e,status:"thinking",thinking:e.thinking+t.delta};case"thinking_done":return{...e,thinkingLog:[...e.thinkingLog,{text:e.thinking,tookMs:t.tookMs}],thinking:""};case"progress":return{...e,progress:t.pct};case"snapshot":return{...e,scenarios:t.data.scenarios,status:t.data.status,headline:t.data.headline??e.headline};case"chat":return{...e,turnActive:!1,chatLog:[...e.chatLog,{role:"model",text:t.text}]};case"clarification":return{...e,turnActive:!1,chatLog:[...e.chatLog,{role:"model",text:t.text}],pendingClarification:t.text};case"limit":return{...e,limits:{scenarioLimit:t.scenarioLimit,perScenarioLimit:t.perScenarioLimit}};case"error":return{...e,error:t.message};case"done":return{...e,status:t.status,turnActive:!1,error:t.status==="failed"&&!e.error?"generation failed":e.error}}}function H(e,t){let n=[],i=e.type??"",d=e.status??"";if(i==="ping")return n;switch(i){case"thinking_token":typeof e.data=="string"&&n.push({type:"thinking",delta:e.data});break;case"thinking_stopped":{let r=e.data??{},o=se(r.time_taken);n.push({type:"thinking_done",text:typeof e.data=="string"?e.data:r.message??"",tookMs:o});break}case"progress":{let r=e.data??{};typeof r.progress=="number"&&n.push({type:"progress",pct:r.progress});break}case"clarification":{let r=e.data??{};typeof r.message=="string"&&n.push({type:"clarification",text:r.message});break}case"chatting_stopped":{let r=e.data??{};typeof r.message=="string"&&r.message.length>0&&n.push({type:"chat",text:r.message});break}case"limit_update":{let r=e.data??{},o=r.test_cases_limit??e.test_cases_limit,p=r.per_scenario_test_cases_limit??e.per_scenario_test_cases_limit;n.push({type:"limit",scenarioLimit:o,perScenarioLimit:p});break}case"error":{let r=typeof e.data=="string"?e.data:e.data?.message??"generation error";n.push({type:"error",message:r});break}case"request_cancelled":return n.push({type:"done",status:"stopped"}),n;case"session_ended":return n.push({type:"done",status:"ended"}),n;default:break}if(Array.isArray(e.scenarios)&&n.push({type:"snapshot",data:{requestId:t,status:d,headline:e.headline,scenarios:e.scenarios}}),d&&U(d)){let r=d.trim().toLowerCase();n.push({type:"done",status:r})}return n}function se(e){if(!e)return;let t=/^([\d.]+)(ms|s)?$/.exec(e.trim());if(!t)return;let n=Number(t[1]);if(Number.isFinite(n))return t[2]==="ms"?Math.round(n):Math.round(n*1e3)}var v=class extends Error{constructor(t){super(t),this.name="AuthError"}},M=class extends Error{constructor(t){super(t),this.name="ForbiddenError"}},I=class extends Error{constructor(t){super(t),this.name="InsufficientCreditsError"}},k=class extends Error{constructor(n,i){super(n);this.cause=i;this.name="TransportError"}};function x(e,t){let n=t?.message??t?.error??`HTTP ${e}`;return e===401?new v(n):e===403?t?.key==="insufficient_credits"?new I(n):new M(n):new k(n)}async function*J(e){let t=e.fetchImpl??fetch,n=e.maxRetries??5,i=e.maxBackoffMs??3e4,d=e.connectTimeoutMs??1e4,r=0,o=!1;for(;;){if(e.signal.aborted)return;let p=new AbortController,a=()=>p.abort();e.signal.addEventListener("abort",a,{once:!0});let c=setTimeout(()=>p.abort(),d),g;try{g=await t(e.url,{method:"GET",headers:{Authorization:await e.authHeader(),Accept:"text/event-stream"},signal:p.signal})}catch(w){if(clearTimeout(c),e.signal.removeEventListener("abort",a),e.signal.aborted)return;if(++r>n)throw new k("SSE connect failed",w);await O(F(r,i));continue}if(clearTimeout(c),!g.ok){e.signal.removeEventListener("abort",a);let w=await oe(g);if(g.status===401&&o){if(++r>n)throw x(401,w);await O(F(r,i));continue}throw x(g.status,w)}if(!g.body)throw e.signal.removeEventListener("abort",a),new k("SSE response had no body");o=!0,r=0;let m=g.body.getReader(),h=new TextDecoder("utf-8"),b="";try{for(;;){if(e.signal.aborted){await m.cancel().catch(()=>{});return}let{done:w,value:s}=await m.read();if(w)break;b+=h.decode(s,{stream:!0});let f;for(;(f=b.indexOf(`
2
+ import{a as $}from"./chunk-ZXN67F4U.js";import{f as D}from"./chunk-YF26DH4Z.js";import{a as E}from"./chunk-NLCCBXXV.js";function U(e){return["completed","failed","ended","stopped"].includes(e.trim().toLowerCase())}function je(e){return["ended","stopped"].includes(e.trim().toLowerCase())}function q(e){return{requestId:e.requestId,objective:e.objective,status:"",turnActive:!1,scenarios:[],thinking:"",thinkingLog:[],chatLog:[],progress:0}}function Re(e){return e.pendingClarification===void 0?e:{...e,pendingClarification:void 0}}function Ce(e){return{...e,turnActive:!0,error:void 0,thinking:"",thinkingLog:[]}}function P(e,t){switch(t.type){case"thinking":return{...e,status:"thinking",thinking:e.thinking+t.delta};case"thinking_done":return{...e,thinkingLog:[...e.thinkingLog,{text:e.thinking,tookMs:t.tookMs}],thinking:""};case"progress":return{...e,progress:t.pct};case"snapshot":return{...e,scenarios:t.data.scenarios,status:t.data.status,headline:t.data.headline??e.headline};case"chat":return{...e,turnActive:!1,chatLog:[...e.chatLog,{role:"model",text:t.text}]};case"clarification":return{...e,turnActive:!1,chatLog:[...e.chatLog,{role:"model",text:t.text}],pendingClarification:t.text};case"limit":return{...e,limits:{scenarioLimit:t.scenarioLimit,perScenarioLimit:t.perScenarioLimit}};case"error":return{...e,error:t.message};case"done":return{...e,status:t.status,turnActive:!1,error:t.status==="failed"&&!e.error?"generation failed":e.error}}}function H(e,t){let n=[],i=e.type??"",d=e.status??"";if(i==="ping")return n;switch(i){case"thinking_token":typeof e.data=="string"&&n.push({type:"thinking",delta:e.data});break;case"thinking_stopped":{let r=e.data??{},o=se(r.time_taken);n.push({type:"thinking_done",text:typeof e.data=="string"?e.data:r.message??"",tookMs:o});break}case"progress":{let r=e.data??{};typeof r.progress=="number"&&n.push({type:"progress",pct:r.progress});break}case"clarification":{let r=e.data??{};typeof r.message=="string"&&n.push({type:"clarification",text:r.message});break}case"chatting_stopped":{let r=e.data??{};typeof r.message=="string"&&r.message.length>0&&n.push({type:"chat",text:r.message});break}case"limit_update":{let r=e.data??{},o=r.test_cases_limit??e.test_cases_limit,p=r.per_scenario_test_cases_limit??e.per_scenario_test_cases_limit;n.push({type:"limit",scenarioLimit:o,perScenarioLimit:p});break}case"error":{let r=typeof e.data=="string"?e.data:e.data?.message??"generation error";n.push({type:"error",message:r});break}case"request_cancelled":return n.push({type:"done",status:"stopped"}),n;case"session_ended":return n.push({type:"done",status:"ended"}),n;default:break}if(Array.isArray(e.scenarios)&&n.push({type:"snapshot",data:{requestId:t,status:d,headline:e.headline,scenarios:e.scenarios}}),d&&U(d)){let r=d.trim().toLowerCase();n.push({type:"done",status:r})}return n}function se(e){if(!e)return;let t=/^([\d.]+)(ms|s)?$/.exec(e.trim());if(!t)return;let n=Number(t[1]);if(Number.isFinite(n))return t[2]==="ms"?Math.round(n):Math.round(n*1e3)}var v=class extends Error{constructor(t){super(t),this.name="AuthError"}},M=class extends Error{constructor(t){super(t),this.name="ForbiddenError"}},I=class extends Error{constructor(t){super(t),this.name="InsufficientCreditsError"}},k=class extends Error{constructor(n,i){super(n);this.cause=i;this.name="TransportError"}};function x(e,t){let n=t?.message??t?.error??`HTTP ${e}`;return e===401?new v(n):e===403?t?.key==="insufficient_credits"?new I(n):new M(n):new k(n)}async function*J(e){let t=e.fetchImpl??fetch,n=e.maxRetries??5,i=e.maxBackoffMs??3e4,d=e.connectTimeoutMs??1e4,r=0,o=!1;for(;;){if(e.signal.aborted)return;let p=new AbortController,a=()=>p.abort();e.signal.addEventListener("abort",a,{once:!0});let c=setTimeout(()=>p.abort(),d),g;try{g=await t(e.url,{method:"GET",headers:{Authorization:await e.authHeader(),Accept:"text/event-stream"},signal:p.signal})}catch(w){if(clearTimeout(c),e.signal.removeEventListener("abort",a),e.signal.aborted)return;if(++r>n)throw new k("SSE connect failed",w);await O(F(r,i));continue}if(clearTimeout(c),!g.ok){e.signal.removeEventListener("abort",a);let w=await oe(g);if(g.status===401&&o){if(++r>n)throw x(401,w);await O(F(r,i));continue}throw x(g.status,w)}if(!g.body)throw e.signal.removeEventListener("abort",a),new k("SSE response had no body");o=!0,r=0;let m=g.body.getReader(),h=new TextDecoder("utf-8"),b="";try{for(;;){if(e.signal.aborted){await m.cancel().catch(()=>{});return}let{done:w,value:s}=await m.read();if(w)break;b+=h.decode(s,{stream:!0});let f;for(;(f=b.indexOf(`
3
3
 
4
4
  `))>=0;){let u=b.slice(0,f);b=b.slice(f+2);let l=ie(u);l&&(yield l)}}}catch(w){if(e.signal.aborted)return;if(++r>n)throw new k("SSE stream dropped",w);await O(F(r,i));continue}finally{e.signal.removeEventListener("abort",a)}return}}function ie(e){let t="message",n="";for(let i of e.split(`
5
5
  `))i.startsWith("event:")?t=i.slice(6).trim():i.startsWith("data:")&&(n+=i.slice(5).trim());if(t!=="message"||!n)return null;try{let i=Buffer.from(n,"base64").toString("utf-8");return JSON.parse(i)}catch{return null}}function F(e,t){return Math.min(t,1e3*2**(e-1))}function O(e){return new Promise(t=>setTimeout(t,e))}async function oe(e){try{return await e.clone().json()}catch{return}}function W(e,t){t?.length&&(e.append("files",t.map(n=>n.fileKey).join(",")),e.append("gemini_metadata",JSON.stringify(t.map(n=>({fileData:{fileUri:n.geminiUri,mimeType:n.mimeType}})))))}function Ue(e,t={}){let n=t.fetchImpl??fetch,i=new Map,d=!0;async function r(){let s=await e.authResolver.resolve();if(!s)throw new v("unauthorized; run `kane-cli login`");return E(s.username,s.access_key)}function o(s){return`${e.baseUrl}${s}`}async function p(s){if(!s.ok){let f;try{f=await s.clone().json()}catch{f=void 0}throw x(s.status,f)}return s.json()}function a(s){let f=s?.data??s;return{request_id:f.request_id??f.id,status:f.status??""}}function c(s,f,u,l){let y=q({requestId:s,objective:f});l&&(y=P(y,{type:"snapshot",data:l}),l.status==="cleaned_up"&&(y={...y,error:"session was reaped (cleaned_up) \u2014 continuing will destructively regenerate"}));let S=new AbortController;u&&(u.aborted?S.abort():u.addEventListener("abort",()=>S.abort(),{once:!0})),i.set(s,S);let A={requestId:s,state:y,events:void 0};return A.events=(async function*(){try{let C=J({url:o(`/requests/${s}/sse`),authHeader:r,signal:S.signal,log:e.log,fetchImpl:n});for await(let L of C)for(let z of H(L,s))A.state=P(A.state,z),yield z}finally{i.delete(s)}})(),A}async function g(s,f){let u=new FormData;u.append("prompt",s.prompt),d=s.memoryEnhancement??!0,u.append("memory_enhancement",String(d)),s.scenarioLimit!==void 0&&u.append("test_scenario_limit",String(s.scenarioLimit)),s.perScenarioLimit!==void 0&&u.append("per_scenario_test_cases_limit",String(s.perScenarioLimit));let l=s.projectId??e.projectId,y=s.folderId??e.folderId;l&&u.append("project_id",l),y&&u.append("folder_id",y),W(u,s.attachments);let S=await n(o("/requests"),{method:"POST",headers:{Authorization:await r()},body:u}),A=await p(S),{request_id:C}=a(A),L=String(C);return c(L,s.prompt,f)}async function m(s,f){let u=await n(o(`/requests/${s}`),{method:"GET",headers:{Authorization:await r()}}),l=await p(u),y=l?.data??l,S={requestId:s,status:y.status??"",headline:y.headline,scenarios:Array.isArray(y.scenarios)?y.scenarios:[]};return c(s,"",f,S)}async function h(s,f,u){let l=new FormData;l.append("prompt",f),l.append("chat_enabled","true"),l.append("memory_enhancement",String(d)),u?.mappings&&l.append("mappings",JSON.stringify(u.mappings)),W(l,u?.attachments);let y=await n(o(`/requests/${s}`),{method:"PUT",headers:{Authorization:await r()},body:l});if(!y.ok){let S;try{S=await y.clone().json()}catch{}throw x(y.status,S)}}async function b(s){i.get(s)?.abort();let u=await n(o(`/requests/${s}/stop`),{method:"DELETE",headers:{Authorization:await r()}});if(!u.ok&&u.status!==404){let l;try{l=await u.clone().json()}catch{}throw x(u.status,l)}}async function w(s){i.get(s)?.abort();let u=await n(o(`/requests/${s}/end`),{method:"DELETE",headers:{Authorization:await r()}});if(!u.ok&&u.status!==404){let l;try{l=await u.clone().json()}catch{}throw x(u.status,l)}}return{start:g,attach:m,chat:h,cancel:b,end:w}}import{statSync as ae,realpathSync as G,existsSync as ce}from"fs";import{extname as ue,resolve as j,isAbsolute as pe}from"path";import{homedir as V}from"os";var de=new Set([".txt",".md",".json",".xml",".jpg",".jpeg",".png",".gif",".bmp",".webp",".pdf",".docx",".csv",".xlsx",".mp3",".wav",".m4a",".webm",".mpeg",".mpga",".mp4",".mov"]),le=50*1024*1024,X=10;function fe(e){return e==="~"?V():e.startsWith("~/")?j(V(),e.slice(2)):e}function Ge(e,t){let n=[],i=[],d=new Set,r=[],o=(()=>{try{return G(j(t))}catch{return j(t)}})(),p=o.endsWith("/")?o:o+"/";for(let a of e){let c=fe(a),g=pe(c)?c:j(t,c);if(!ce(g)){n.push(`Not found: ${a}`);continue}let m;try{m=G(g)}catch{n.push(`Cannot resolve: ${a}`);continue}if(d.has(m))continue;let h;try{h=ae(m)}catch{n.push(`Cannot read: ${a}`);continue}if(!h.isFile()){n.push(`Not a file: ${a}`);continue}if(h.size===0){n.push(`Empty file: ${a}`);continue}let b=ue(m).toLowerCase();if(!de.has(b)){n.push(`Unsupported type ${b||"(none)"}: ${a}`);continue}if(h.size>le){n.push(`Too large (>50MB): ${a}`);continue}m!==o&&!m.startsWith(p)&&i.push(`Outside working dir: ${a}`),d.add(m),r.push(m)}return r.length>X&&n.push(`Too many files: ${r.length} (max ${X})`),{ok:n.length?[]:r,errors:n,warnings:i}}var B=class extends Error{constructor(n){super(n.join("; "));this.errors=n;this.name="AttachmentValidationError"}};async function Xe(e){let{promptText:t,filePaths:n,cwd:i,scenarios:d,isRefine:r,conn:o,deps:p}=e,{ok:a,errors:c,warnings:g}=p.validate(n,i);if(c.length)throw new B(c);e.onValidated?.();let m=a.length?await p.upload(o,a,p.onUpload):[],h=r?p.buildMappings(t,d):void 0;return{promptText:t,mappings:h,attachments:m,warnings:g}}import{readFile as me}from"fs/promises";import{basename as K}from"path";async function ge(e){let t=await e.authResolver.resolve();if(!t)throw new v("unauthorized; run `kane-cli login`");return E(t.username,t.access_key)}async function he(e,t,n={}){let i=n.fetchImpl??fetch,d=await me(t),r=K(t),o=new FormData;o.append("file",new Blob([d]),r),o.append("source","omniBox"),o.append("geminiFileUpload","true");let p=await i(`${e.tmsBaseUrl}/v1/attachment`,{method:"POST",headers:{Authorization:await ge(e)},body:o,signal:n.signal});if(!p.ok){let h;try{h=await p.clone().json()}catch{}throw x(p.status,h)}let a=await p.json(),c=a?.data??a,g=c?.gemini_response?.uri,m=c?.gemini_response?.mimeType;if(!c?.file_key||!g){let h=c&&typeof c=="object"?Object.keys(c).join(","):typeof c,b=(()=>{try{return JSON.stringify(c).slice(0,500)}catch{return"<unserializable>"}})();throw new Error(`attachment upload for ${r} returned no file_key/gemini uri \u2014 status ${p.status}, body keys: [${h}], raw: ${b}`)}return{fileName:c.file_name??r,fileKey:c.file_key,geminiUri:g,mimeType:m??"application/octet-stream"}}async function tt(e,t,n,i={}){let d=[];for(let r=0;r<t.length;r++){if(i.signal?.aborted)throw Object.assign(new Error("upload aborted"),{name:"AbortError"});let o=K(t[r]);n?.({file:o,index:r+1,total:t.length,status:"uploading"});try{d.push(await he(e,t[r],i)),n?.({file:o,index:r+1,total:t.length,status:"done"})}catch(p){throw n?.({file:o,index:r+1,total:t.length,status:"failed"}),p}}return d}var ye=/@([sS])(\d+)\.([cC])(\d+)/g,be=/@([sS])(\d+)(?!\d)(?!\.[cC]\d)/g;function rt(e,t){let n={},i={};for(let d of e.matchAll(ye)){let r=Number(d[2]),o=Number(d[4]),p=t[r-1];if(!p)continue;n[`s${r}`]=String(p.id);let a=p.test_cases??[];if(a[o-1])for(let c=0;c<o;c++){let g=a[c];g&&(i[`s${r}.c${c+1}`]=String(g.id))}}for(let d of e.matchAll(be)){let r=Number(d[2]),o=t[r-1];o&&(n[`s${r}`]=String(o.id))}if(!(Object.keys(n).length===0&&Object.keys(i).length===0))return{scenario:n,testcase:i}}function R(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(n==null||typeof n!="object")return[];let i=n;if(typeof i.step!="string")return[];let d=typeof i.expected_result=="string"?i.expected_result:typeof i.outcome=="string"?i.outcome:"";t.push({step:i.step,expected:d})}return t}var we=30,Se=300;function Z(){return{mode:"testing",max_steps:we,timeout:Se,variables:{}}}function Q(e){return e.title??`Test case ${e.id}`}function ct(e,t){return $({frontmatter:Z(),heading:Q(t),steps:e.sub_objectives.map(n=>n.objective)})}function Y(e){let t=R(e.manual_steps).map(n=>n.step);return $({frontmatter:Z(),heading:Q(e),steps:t})}import{mkdtempSync as xe,mkdirSync as N,writeFileSync as ee,rmSync as te,renameSync as _e,existsSync as ne,readFileSync as ve}from"fs";import{join as _,resolve as ke}from"path";async function ft(e,t,n,i=Y){(n.redirectBareCwd??!0)&&ke(t)===process.cwd()&&(t=_(t,".testmuai","tests"));let d=T(e.objective)??e.headline,r=T(n.suiteName)??`${T(re(d,4))??"tcg"}-${e.requestId}`,o=r,p=_(t,r);ne(p)&&!Te(p,e.requestId)&&(o=`${r}-${e.requestId}`);let a=_(t,o),c=[],g=new Map;for(let h of e.scenarios){let b=(h.test_cases??[]).filter(Ae);if(b.length===0)continue;let w=T(Ee(h.scode))??T(h.sid)??`s${h.id}`,s=g.get(w)??new Set;g.set(w,s);for(let f of b){let u=T(re(f.title,5))??"case",l=`${u}_test.md`;for(let y=2;s.has(l);y++)l=`${u}-${y}_test.md`;s.add(l),c.push({dir:w,file:l,tc:f})}}if(c.length===0)return{suiteDir:a,paths:[],warning:"no functional test cases generated"};N(t,{recursive:!0});let m=xe(_(t,".tcg-tmp-"));try{N(_(m,"helpers"),{recursive:!0}),ee(_(m,".tcg-suite.json"),JSON.stringify({requestId:e.requestId,suiteName:o}));let h=[],b=new Set;for(let s of c){let f=_(m,s.dir);b.has(f)||(N(f,{recursive:!0}),b.add(f));let u=_(f,s.file);ee(u,i(s.tc)),h.push(u)}ne(a)&&te(a,{recursive:!0,force:!0}),_e(m,a);let w=h.map(s=>s.replace(m,a));return{suiteDir:a,paths:w}}catch(h){try{te(m,{recursive:!0,force:!0})}catch{}throw h}}function Ae(e){return(e.category??"").trim().toLowerCase()==="functional"}function Te(e,t){try{return JSON.parse(ve(_(e,".tcg-suite.json"),"utf-8"))?.requestId===t}catch{return!1}}function T(e){return e&&e.length>0?e:void 0}function re(e,t){return e?e.toLowerCase().replace(/[^a-z0-9]+/g," ").trim().split(/\s+/).filter(Boolean).slice(0,t).join("-"):""}function Ee(e){return e?e.replace(/[^A-Za-z0-9._-]+/g,"-").replace(/^-+|-+$/g,""):""}function ht(e){let t=[];e.title&&t.push(e.title),e.description&&t.push("",e.description);let n=R(e.manual_steps);return n.length>0&&(t.push("","Steps:"),n.forEach((i,d)=>{t.push(`${d+1}. ${i.step}`)})),t.join(`