@testmuai/kane-cli 0.7.2 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (207) hide show
  1. package/dist/{ChatSurface-E7QKI4LA.js → ChatSurface-U37VZDCW.js} +1 -1
  2. package/dist/{ChromeProfilePicker-DGDWGCZD.js → ChromeProfilePicker-AUU7JF6F.js} +1 -1
  3. package/dist/{CliFeedbackPrompt-SYCZXSME.js → CliFeedbackPrompt-4W74Y3UF.js} +1 -1
  4. package/dist/{CliUploadProgress-VDEAKXJY.js → CliUploadProgress-6HL7WTEX.js} +1 -1
  5. package/dist/ConfigView-6BSCZP5Y.js +2 -0
  6. package/dist/EvidenceViewOffer-62XHEEGW.js +2 -0
  7. package/dist/FolderPicker-S7U2EN2M.js +2 -0
  8. package/dist/{HelpView-ON6BFGJM.js → HelpView-TU7ED43J.js} +1 -1
  9. package/dist/{InfoBox-B23NZ6IG.js → InfoBox-JLTMKVDE.js} +1 -1
  10. package/dist/{LinksBox-TI26VFFH.js → LinksBox-LREUUJDV.js} +1 -1
  11. package/dist/{ProfilesView-CRO5AH3H.js → ProfilesView-W3GX2N2E.js} +1 -1
  12. package/dist/{ProjectPicker-3N7LJOXU.js → ProjectPicker-SYQUJK2J.js} +1 -1
  13. package/dist/{SaveSessionPrompt-UTOEC5AW.js → SaveSessionPrompt-MR5NJMRP.js} +1 -1
  14. package/dist/SingleShotApp-XOKVOM7C.js +2 -0
  15. package/dist/{SummaryBox-JK64EKC2.js → SummaryBox-UAYSVFB7.js} +1 -1
  16. package/dist/TestMdRunView-7UVSDAF4.js +2 -0
  17. package/dist/{WhoamiView-6QSLPNF6.js → WhoamiView-2YU76ASQ.js} +1 -1
  18. package/dist/adbkit-apkreader-ORZBGCJQ.js +184 -0
  19. package/dist/app-client-OEXESV4U.js +2 -0
  20. package/dist/app-download-AEEFQ63M.js +2 -0
  21. package/dist/{auth-IKFVW3NX.js → auth-HET3TBRI.js} +1 -1
  22. package/dist/{bind-KCUSVJXG.js → bind-STKXOUYI.js} +3 -3
  23. package/dist/bootstrap-44YKVWWE.js +2 -0
  24. package/dist/bridge-5Z3BIB77.js +2 -0
  25. package/dist/{changelog-AAH2ZBYO.js → changelog-7OWRHFHZ.js} +1 -1
  26. package/dist/{chat-committer-UUC6JTRJ.js → chat-committer-ZWWCLJFD.js} +1 -1
  27. package/dist/{chunk-ZUGCHQFC.js → chunk-27U4PLPX.js} +1 -1
  28. package/dist/{chunk-ZBOWFJB2.js → chunk-2BGUUWNF.js} +2 -2
  29. package/dist/chunk-2KDGIZED.js +4 -0
  30. package/dist/{chunk-SFII7HPP.js → chunk-3LJWYRAA.js} +1 -1
  31. package/dist/chunk-3PECJD6S.js +11 -0
  32. package/dist/{chunk-7QJ75SYR.js → chunk-3POR47RC.js} +2 -2
  33. package/dist/chunk-4JOD47QI.js +2 -0
  34. package/dist/{chunk-QIGPXYMF.js → chunk-56PAQAX5.js} +6 -6
  35. package/dist/{chunk-DZPGG4S6.js → chunk-65ZTD5SJ.js} +2 -2
  36. package/dist/chunk-6IA6QMPH.js +2 -0
  37. package/dist/{chunk-VT54ARGE.js → chunk-6O3DDOP2.js} +1 -1
  38. package/dist/chunk-6XX4LEVJ.js +2 -0
  39. package/dist/{chunk-4NFCAGRK.js → chunk-766WGMBU.js} +1 -1
  40. package/dist/{chunk-VMM4LC4V.js → chunk-7BZSCUPP.js} +3 -3
  41. package/dist/{chunk-PLOWZLG5.js → chunk-7JWKHKFU.js} +2 -2
  42. package/dist/chunk-7Q6M6P4X.js +26 -0
  43. package/dist/chunk-AW2XUHH4.js +2 -0
  44. package/dist/{chunk-7OYZR6JA.js → chunk-BRHNRCEZ.js} +1 -1
  45. package/dist/chunk-BRIEBB2U.js +2 -0
  46. package/dist/{chunk-APPYQZFK.js → chunk-C7HSWZP6.js} +1 -1
  47. package/dist/chunk-CTW2VQKS.js +6 -0
  48. package/dist/{chunk-FDIPQRX4.js → chunk-DCY6R5DP.js} +1 -1
  49. package/dist/{chunk-KWIK22R6.js → chunk-DO5HAO3H.js} +1 -1
  50. package/dist/chunk-DPUV6OSP.js +2 -0
  51. package/dist/{chunk-B5RS2XZU.js → chunk-DZGCXKKI.js} +3 -3
  52. package/dist/{chunk-JKM2PUHI.js → chunk-EDSZJZFG.js} +1 -1
  53. package/dist/{chunk-OIYGGEUL.js → chunk-ELM6MXGJ.js} +1 -1
  54. package/dist/{chunk-VHZ4S57N.js → chunk-EWCAFKLX.js} +1 -1
  55. package/dist/chunk-EYOCNMUM.js +2 -0
  56. package/dist/{chunk-GYNTNKNB.js → chunk-FEJXWJ3L.js} +1 -1
  57. package/dist/{chunk-UC7MNPIN.js → chunk-FMRSMN34.js} +1 -1
  58. package/dist/chunk-FNH55WSR.js +19 -0
  59. package/dist/chunk-FQLIW3LM.js +2 -0
  60. package/dist/{chunk-O75ZHGJG.js → chunk-G7VQCS4J.js} +1 -1
  61. package/dist/{chunk-2WFZIQ62.js → chunk-GCBKDX2J.js} +1 -1
  62. package/dist/chunk-GKYPNSQP.js +26 -0
  63. package/dist/chunk-GPG3FIN3.js +21 -0
  64. package/dist/chunk-GZPK6FRP.js +7 -0
  65. package/dist/{chunk-XUS4WKDS.js → chunk-HCKH44I2.js} +1 -1
  66. package/dist/chunk-HEAIJCGZ.js +2 -0
  67. package/dist/{chunk-SL6PCVM2.js → chunk-HMYMSRA4.js} +1 -1
  68. package/dist/chunk-IOFZSQAA.js +2 -0
  69. package/dist/{chunk-YTHQNN2L.js → chunk-IP2O264K.js} +1 -1
  70. package/dist/{chunk-AXTGYOMK.js → chunk-JJHG3BWO.js} +1 -1
  71. package/dist/chunk-KFSUPQAG.js +66 -0
  72. package/dist/chunk-KRKGZ2ZW.js +47 -0
  73. package/dist/{chunk-AJ56AMT6.js → chunk-KU6IXFGZ.js} +1 -1
  74. package/dist/chunk-L7MXYCD7.js +2 -0
  75. package/dist/{chunk-5ZQZOVWY.js → chunk-MA34UWKX.js} +3 -3
  76. package/dist/chunk-MBF3FP5P.js +5 -0
  77. package/dist/chunk-MSGW4JDG.js +2 -0
  78. package/dist/{chunk-C3T7TKAC.js → chunk-MXHHMIO2.js} +2 -2
  79. package/dist/{chunk-RDNFVZEB.js → chunk-NX7TM662.js} +1 -1
  80. package/dist/chunk-OMQCD3KR.js +2 -0
  81. package/dist/{chunk-OR6MCL6Z.js → chunk-OTTGS2TE.js} +1 -1
  82. package/dist/chunk-QGKPLOUI.js +2 -0
  83. package/dist/{chunk-FBHRBFHP.js → chunk-QRZRSAZH.js} +1 -1
  84. package/dist/{chunk-VLWMMOMF.js → chunk-QSDH5P7C.js} +1 -1
  85. package/dist/{chunk-VOOPWFHW.js → chunk-QW6EZC53.js} +1 -1
  86. package/dist/{chunk-ZRASQ63J.js → chunk-RC52N7PC.js} +1 -1
  87. package/dist/{chunk-M6FKJKC6.js → chunk-RFR4ZKIC.js} +3 -3
  88. package/dist/{chunk-AFBKGZFG.js → chunk-RLRNLIRS.js} +1 -1
  89. package/dist/{chunk-5FJJJNJK.js → chunk-SDPRO2LE.js} +1 -1
  90. package/dist/chunk-T5Y6MOLM.js +4 -0
  91. package/dist/{chunk-VRLUNZAK.js → chunk-TFPPEOAK.js} +1 -1
  92. package/dist/{chunk-5SXMV66P.js → chunk-TKGUT425.js} +1 -1
  93. package/dist/chunk-TYLYFERW.js +10 -0
  94. package/dist/chunk-TZXXJWHA.js +2 -0
  95. package/dist/{chunk-KQZA2QSC.js → chunk-UDIQOJEL.js} +1 -1
  96. package/dist/chunk-UV462FZR.js +2 -0
  97. package/dist/{chunk-HYSFJSIG.js → chunk-UXDL4XDL.js} +1 -1
  98. package/dist/{chunk-53IBTIL3.js → chunk-V2R3LCA3.js} +1 -1
  99. package/dist/{chunk-VFII6C46.js → chunk-W2JFDDIB.js} +1 -1
  100. package/dist/{chunk-4LTXE3IX.js → chunk-XO5ZH3ZR.js} +1 -1
  101. package/dist/{chunk-EOLFTMWF.js → chunk-YFYCCTSL.js} +1 -1
  102. package/dist/{chunk-JPWLGHPM.js → chunk-YJELGSKJ.js} +1 -1
  103. package/dist/chunk-YRFMPIU2.js +4 -0
  104. package/dist/{chunk-F7ISS545.js → chunk-ZGBSGZZM.js} +1 -1
  105. package/dist/{chunk-VWKVUOXU.js → chunk-ZIUAOEUC.js} +1 -1
  106. package/dist/chunk-ZVHCQMJ6.js +13 -0
  107. package/dist/{config-CWZV6XPT.js → config-RS47F5SC.js} +1 -1
  108. package/dist/{controller-client-RD2YEMAH.js → controller-client-OB4WD2C4.js} +1 -1
  109. package/dist/{cover-cmd-NWIRJY5Z.js → cover-cmd-HDZZWJXG.js} +1 -1
  110. package/dist/{credentials-YHTJGKEO.js → credentials-OH6AVI6N.js} +1 -1
  111. package/dist/deps-resolve-XC5S53DG.js +2 -0
  112. package/dist/{dispatch-WVNXB7AD.js → dispatch-SE5GY3Z2.js} +1 -1
  113. package/dist/doctor-FSECFZUU.js +2 -0
  114. package/dist/docx-convert-JMUMT5C4.js +2 -0
  115. package/dist/evidence-OYPHZUKI.js +2 -0
  116. package/dist/evolve-cmd-BCPNXAMV.js +2 -0
  117. package/dist/exec-P2IKJRRR.js +2 -0
  118. package/dist/exit-manager-3FVBTNYR.js +2 -0
  119. package/dist/{explain-cmd-IZEHWZV5.js → explain-cmd-3GEKR7O5.js} +1 -1
  120. package/dist/{explain-cmd-75MCF2ZV.js → explain-cmd-EX24XKD6.js} +1 -1
  121. package/dist/{extract-bind-5OWELRME.js → extract-bind-LLEASZAK.js} +3 -3
  122. package/dist/{extract-cmd-ZRYMJ6IC.js → extract-cmd-UZMEZMGP.js} +2 -2
  123. package/dist/{gaps-cmd-XBRXKXDL.js → gaps-cmd-IVXFPFAQ.js} +1 -1
  124. package/dist/{generate-headless-D6BISWDC.js → generate-headless-D3SVQ2AI.js} +3 -3
  125. package/dist/host-7GZPBA74.js +2 -0
  126. package/dist/index.js +85 -69
  127. package/dist/ingest-cmd-EAE7N5RC.js +2 -0
  128. package/dist/{interactive-bind-XSRD36MO.js → interactive-bind-ORMN2REX.js} +3 -3
  129. package/dist/{lifecycle-cmd-EQSFAZG6.js → lifecycle-cmd-O2324GN6.js} +1 -1
  130. package/dist/{list-cmd-IRJSUCM5.js → list-cmd-N4KMA34H.js} +1 -1
  131. package/dist/list-commands-MRXL5HGS.js +2 -0
  132. package/dist/login-flow-QJQM3RHT.js +2 -0
  133. package/dist/{maintenance-cmd-MVFA6H74.js → maintenance-cmd-6XSVO6FO.js} +1 -1
  134. package/dist/mobile-prompts-TOX35ER6.js +2 -0
  135. package/dist/persist-recorded-session-TLDQ5HKP.js +3 -0
  136. package/dist/{phase-seed-DIRETNU6.js → phase-seed-VFHIH6FL.js} +1 -1
  137. package/dist/pipeline-UOM4LNAI.js +2 -0
  138. package/dist/prepare-target-QYWIJIVQ.js +2 -0
  139. package/dist/reconcile-cmd-3H34KVVD.js +2 -0
  140. package/dist/{reconcile-deps-HTT6IPHT.js → reconcile-deps-XIH75ZLY.js} +2 -2
  141. package/dist/reconcile-engine-UKWPG2LV.js +2 -0
  142. package/dist/{recording-banner-76GCIPUN.js → recording-banner-4M7XHVGI.js} +1 -1
  143. package/dist/registry-PYOTKZYZ.js +2 -0
  144. package/dist/{require-project-folder-ACRDP5ZB.js → require-project-folder-4UPQNEBJ.js} +1 -1
  145. package/dist/resolve-run-intent-X72V3KJA.js +7 -0
  146. package/dist/{resolver-SRPCFW7P.js → resolver-UBOZLFFE.js} +1 -1
  147. package/dist/{review-cmd-L3V5UP5T.js → review-cmd-DQRKQUMG.js} +1 -1
  148. package/dist/run-2COODVX2.js +2 -0
  149. package/dist/run-URPGHOQM.js +2 -0
  150. package/dist/{run-test-md-KEHSRMCM.js → run-test-md-76ZPKXO6.js} +3 -3
  151. package/dist/session-target-UWROGOCY.js +2 -0
  152. package/dist/{sessions-cmd-ZVYGSRJ3.js → sessions-cmd-ZZIZN2VB.js} +1 -1
  153. package/dist/{skill-installer-HBN3A35K.js → skill-installer-CIS6GAYF.js} +1 -1
  154. package/dist/spawner-J67QR4QP.js +2 -0
  155. package/dist/{structured-answers-A43Q25CZ.js → structured-answers-5EY2AZN7.js} +1 -1
  156. package/dist/tcg-generate-BDTRKY2A.js +2 -0
  157. package/dist/testmd-actions-77ELR5UU.js +2 -0
  158. package/dist/token-refresh-4BPAPXKK.js +2 -0
  159. package/dist/types-6E2HTDKJ.js +2 -0
  160. package/dist/{validate-basic-ZGWPBYB6.js → validate-basic-2GVSQ2R5.js} +1 -1
  161. package/dist/{verdicts-SCETLY5J.js → verdicts-TRSTJLCL.js} +1 -1
  162. package/dist/{version-check-CJWKDAXV.js → version-check-O6PYTI4T.js} +1 -1
  163. package/dist/{view-cmd-SOVM64L2.js → view-cmd-KPJTP4DI.js} +1 -1
  164. package/dist/{walk-session-YUYRULPY.js → walk-session-CHJXHZMO.js} +1 -1
  165. package/dist/with-telemetry-CQCWLVOC.js +2 -0
  166. package/package.json +12 -6
  167. package/dist/ConfigView-HPKRQXMC.js +0 -2
  168. package/dist/EvidenceViewOffer-F5YG54OC.js +0 -2
  169. package/dist/FolderPicker-4NSDXQY5.js +0 -2
  170. package/dist/SingleShotApp-Y3YDFQSD.js +0 -2
  171. package/dist/TestMdRunView-O6JTHV5W.js +0 -2
  172. package/dist/bootstrap-NFYYRGGR.js +0 -2
  173. package/dist/bridge-JSKEO4N3.js +0 -2
  174. package/dist/chunk-23VPUWBD.js +0 -23
  175. package/dist/chunk-2WRBTLFN.js +0 -13
  176. package/dist/chunk-5WXGMXGA.js +0 -26
  177. package/dist/chunk-74HTO7K3.js +0 -11
  178. package/dist/chunk-AECMF3T2.js +0 -8
  179. package/dist/chunk-BXYWX4J3.js +0 -2
  180. package/dist/chunk-DBKNJRJG.js +0 -2
  181. package/dist/chunk-H32GM5G4.js +0 -2
  182. package/dist/chunk-J5FBU425.js +0 -62
  183. package/dist/chunk-MK7JUOYV.js +0 -6
  184. package/dist/chunk-ORQNKZ2Z.js +0 -5
  185. package/dist/chunk-OUJQVBUT.js +0 -7
  186. package/dist/chunk-QOFZSHSC.js +0 -47
  187. package/dist/chunk-RKWJG3WW.js +0 -19
  188. package/dist/chunk-STVP2XHO.js +0 -2
  189. package/dist/chunk-WAOCHXJ5.js +0 -2
  190. package/dist/docx-convert-CHLJUTFH.js +0 -2
  191. package/dist/evidence-IVDNXWPL.js +0 -2
  192. package/dist/evolve-cmd-XBX4SX5H.js +0 -2
  193. package/dist/exit-manager-XZL4KIJU.js +0 -2
  194. package/dist/ingest-cmd-YTGOICTC.js +0 -2
  195. package/dist/list-commands-RCYHJ5Y3.js +0 -2
  196. package/dist/login-flow-PYAPYCPY.js +0 -2
  197. package/dist/persist-recorded-session-DTYCLXTQ.js +0 -3
  198. package/dist/pipeline-MXFOD6ES.js +0 -2
  199. package/dist/reconcile-cmd-EG6BOU3A.js +0 -2
  200. package/dist/reconcile-engine-JQNXALNY.js +0 -2
  201. package/dist/run-GMZCDRDD.js +0 -2
  202. package/dist/run-TFRWPGXP.js +0 -2
  203. package/dist/spawner-GC5CFAJ7.js +0 -2
  204. package/dist/tcg-generate-V7YFNC5O.js +0 -2
  205. package/dist/testmd-actions-MNDOO76O.js +0 -2
  206. package/dist/token-refresh-3UYMCYG3.js +0 -2
  207. package/dist/with-telemetry-E7QWPGL6.js +0 -2
@@ -0,0 +1,13 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{d as ot,g as st}from"./chunk-5DBK6QNS.js";import{b as w,c as ne,d as Ze,f as ie,g as oe}from"./chunk-CJJXT5DO.js";import{a as Qe,e as P,f as j,g as et,h as U,i as L,j as tt}from"./chunk-ZPDM6FO7.js";import{a as M,b as T,d as qe}from"./chunk-EHN5HTUD.js";import{d as at}from"./chunk-NVGBE2DR.js";import{a as W}from"./chunk-CH273NAE.js";import{a as R,b as _}from"./chunk-L5LI2JF4.js";import{a as te,c as We,d as Je,e as Xe,f as re}from"./chunk-6IA6QMPH.js";import{A as x}from"./chunk-TH47OOBV.js";import{b as K}from"./chunk-VAYBKR76.js";import{a as nt}from"./chunk-CUM23TLF.js";import{b as it,f as G,i as Y}from"./chunk-DUAXZYAD.js";import{d as se,f as rt}from"./chunk-WXHQYYD5.js";import{a as Ye,b as Ke}from"./chunk-2KDGIZED.js";import{a as Ge}from"./chunk-G7VQCS4J.js";import{a as Ue}from"./chunk-27U4PLPX.js";function C(t){if(t===null)return"broken";let e=Math.floor(t/100);return e===1?"passed":e===7?"failed":e===2?"skipped":"broken"}var A={failed:3,broken:2,passed:1,skipped:0};function ae(t){let e="skipped";for(let r of t)A[r]>A[e]&&(e=r);return e}import{createHash as Vt}from"crypto";import{basename as Bt}from"path";function ce(t){let e=t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,40);return e.length>0?e:"session"}function de(t){return Vt("sha256").update(t).digest("hex").slice(0,8)}function ue(t){let e=Bt(t).replace(/_test\.md$/i,"").replace(/\.md$/i,"");return`${ce(e)}-${de(t)}`}function le(t,e){return`${ce(t)}-${de(e)}`}function pe(t){let e={};for(let[r,n]of Object.entries(t))typeof n=="string"&&n.length>0&&(e[r]=n);return e}function Ht(t,e){return{pack_test_dir:t,ordinal_offset:e}}import{promises as k}from"fs";import{join as E}from"path";function fe(t){let e={evidence:"0.1",run_id:t.execution_id,status:"running",title:t.title,started:t.started,environment:{producer:{name:"kane-cli",version:t.producerVersion},...t.surfaces?{surfaces:t.surfaces}:{},run_kind:t.run_kind,origin:t.origin,pid:t.pid},...t.credits!==void 0?{metrics:{credits:{value:t.credits,type:"count"}}}:{}};return _(e,{lineWidth:-1})}async function me(t,e,r,n=process.cwd(),i){let o=i??w(t.execution_id,n),s=E(o,"tests",e);return await k.mkdir(E(o,"coverage"),{recursive:!0}),await k.writeFile(E(o,"coverage",".keep"),""),await k.mkdir(s,{recursive:!0}),await k.writeFile(E(o,"run.yaml"),fe(t)),r&&await k.writeFile(E(s,r.path),r.content),o}async function zt(t,e=process.cwd()){let r=w(t.execution_id,e);await k.mkdir(E(r,"coverage"),{recursive:!0}),await k.writeFile(E(r,"coverage",".keep"),"");let n=R(fe(t));return n.environment&&delete n.environment.run_kind,await k.writeFile(E(r,"run.yaml"),_(n,{lineWidth:-1})),r}async function Ut(t,e=process.cwd()){return T(w(t,e),new Date().toISOString())}async function ge(t,e=process.cwd()){await k.rm(w(t,e),{recursive:!0,force:!0})}import{promises as he}from"fs";import{join as ve}from"path";function J(t){let e={evidence:"0.1",test:t.testId,status:t.status,...t.durationMs!==void 0?{duration_ms:t.durationMs}:{},...t.attempts&&t.attempts.length?{attempts:t.attempts}:{},...t.flaky!==void 0?{flaky:t.flaky}:{},...t.definitionPath?{definition:{path:t.definitionPath}}:{},...t.definitionId?{definition_id:t.definitionId}:{},...t.assuranceId?{assurance_id:t.assuranceId}:{},...Object.keys(t.externalId).length?{external_id:t.externalId}:{},...t.tags&&t.tags.length?{tags:t.tags}:{},...Object.keys(t.environment).length?{environment:t.environment}:{},steps:t.steps};return _(e,{lineWidth:-1})}function ye(t){return _({logs:t},{lineWidth:-1})}async function we(t,e,r){await he.writeFile(ve(t,"tests",e,"result.yaml"),r)}async function _e(t,e,r){let n=ve(t,"tests",e,"logs");await he.mkdir(n,{recursive:!0}),await he.writeFile(ve(n,"meta.yaml"),r)}import{promises as X}from"fs";import{join as ct}from"path";function dt(t){return ct(t,".internal","meta.json")}async function ut(t){let e;try{e=await X.readFile(dt(t),"utf8")}catch(n){if(n?.code==="ENOENT")return null;throw n}let r=JSON.parse(e);if(!r||typeof r!="object"||Array.isArray(r))throw new Error("meta.json is not a JSON object");return r}async function xe(t,e){let r;try{r=await ut(t)??{}}catch(s){console.warn(`evidence: meta.json at ${t} unreadable \u2014 skipping execution-pointer append to preserve identity`,s);return}let n=Array.isArray(r.executions)?r.executions:[];n.push(e),r.executions=n,await X.mkdir(ct(t,".internal"),{recursive:!0});let i=dt(t),o=`${i}.tmp-${process.pid}-${Date.now()}`;await X.writeFile(o,JSON.stringify(r,null,2)+`
3
+ `),await X.rename(o,i)}async function Gt(t){try{let e=await ut(t);return e&&Array.isArray(e.executions)?e.executions:[]}catch{return[]}}async function Yt(t,e,r=process.cwd()){let n=await ie(t,r);if(!n){let o=`evidence: no pack found for "${t}"`;return e.json?console.log(JSON.stringify({valid:!1,error:"not_found",target:t})):console.error(o),2}let i=await M(n,e.profile??"L1");return e.json?console.log(JSON.stringify({valid:i.valid,status:i.status,diagnostics:i.diagnostics})):console.log(`evidence: ${i.valid?"valid":"INVALID"} (${e.profile??"L1"}, status ${i.status})`),i.valid?0:1}function ke(t){let e=[];for(let r of t){let n=r.perFlow&&r.perFlow.length?r.perFlow.map(i=>i.resultCode):[r.resultCode];for(let i of n)e.push(C(i))}return ae(e)}function Kt(t){let e=null;for(let r of t){let n=r.perFlow&&r.perFlow.length?r.perFlow.map(i=>i.resultCode):[r.resultCode];for(let i of n)i!=null&&(e==null||A[C(i)]>A[C(e)]||A[C(i)]===A[C(e)]&&i>e)&&(e=i)}return e}import{promises as Wt}from"fs";import{extname as lt,basename as Jt}from"path";var Xt={".ndjson":"ndjson",".log":"log",".json":"json",".har":"har"};async function be(t){let e;try{e=await Wt.readdir(t)}catch{return[]}return e.filter(r=>r!=="meta.yaml").sort().map(r=>({name:Jt(r,lt(r)),file:r,format:Xt[lt(r)]??"txt"}))}import{mkdirSync as qt,appendFileSync as Zt}from"fs";import{join as pt}from"path";function Se(t,e){return pt(t,"tests",e,"logs")}function Ee(t,e,r,n={},i){try{i?.(e,r,r,n)}catch{}if(t)try{qt(t,{recursive:!0});let o=JSON.stringify({ts:new Date().toISOString(),level:e,event:r,...n})+`
4
+ `;Zt(pt(t,"diagnostics.ndjson"),o)}catch{}}import{promises as I}from"fs";import{dirname as ar,join as D}from"path";import{statSync as Qt}from"fs";import{promises as Ie}from"fs";import{basename as er,join as tr}from"path";var rr=1e6,nr=2e6;function ir(){return Ye.map(t=>Ke(t))}function ft(t=ir()){return t.map(e=>{let r=0;try{r=Qt(e).size}catch{}return{path:e,offset:r}})}var or=/\x1b\[[0-9;]*[A-Za-z]/g;async function sr(t,e,r){let n;try{n=await Ie.open(t,"r");let i=(await n.stat()).size,o=e<=i?e:0,s=i-o;if(s<=0)return null;let a=s>r?i-r:o,c=Buffer.alloc(Math.min(s,r));return await n.read(c,0,c.length,a),c.toString("utf8")}catch{return null}finally{await n?.close().catch(()=>{})}}async function mt(t,e){let r=e.caps?.stderr??rr,n=e.caps?.appium??nr,i=[];e.runnerStderrPath&&i.push({src:e.runnerStderrPath,from:0,cap:r});for(let o of e.appiumMarks??[])i.push({src:o.path,from:o.offset,cap:n});for(let o of i){let s=await sr(o.src,o.from,o.cap);if(s===null)continue;let a=s.replace(or,"");if(a!=="")try{await Ie.mkdir(t,{recursive:!0}),await Ie.writeFile(tr(t,er(o.src)),a)}catch{}}}async function cr(t){try{let e=D(t,"tests"),r=await I.readdir(e).catch(()=>[]);for(let n of r){let i=D(e,n,"steps"),o=await I.readdir(i).catch(()=>[]);for(let s of o){let a=await I.readFile(D(i,s,"failure.yaml"),"utf8").catch(()=>null);if(a!=null)try{let c=R(a);if(c&&typeof c=="object"&&c.triage)return!0}catch{}}}}catch{}return!1}async function gt(t,e,r,n={}){let i=D(t,"tests",e,"logs");if(r)try{await I.mkdir(i,{recursive:!0}),await I.copyFile(r,D(i,"tui.log"))}catch{}await mt(i,{runnerStderrPath:r?D(ar(r),"runner-stderr.log"):void 0,appiumMarks:n.appiumMarks});let o=await be(i);if(!o.length&&n.requireRealLog)throw new Error(`evidence test ${e} has no real log to declare`);o.length&&await _e(t,e,ye(o))}async function Re(t){let e=t.cwd??process.cwd(),r=t.packDir??w(t.executionId,e);if(!t.saved&&!t.packDir)return await ge(t.executionId,e),{sealed:!1};await gt(r,t.testId,t.tuiLogPath,{requireRealLog:t.requireRealLog,appiumMarks:t.appiumMarks});let n=D(r,"run.yaml"),i=R(await I.readFile(n,"utf8"));i.environment={...i.environment??{},saved:t.saved,run_kind:t.runKind},await I.writeFile(n,_(i,{lineWidth:-1}));let o=await I.open(n,"r+");try{await o.sync()}finally{await o.close()}let s=await cr(r);await T(r,new Date().toISOString());let a;try{let d=await M(r,"L1");a=d.valid;let u=(d.diagnostics??[]).filter(p=>String(p?.code??"").includes("failure.status_disagrees"));if(u.length>0)if(t.expectStatusDisagrees||s){let p=t.expectStatusDisagrees?"expected under --bug-detection continue":"self-explained by triaged failure record(s)";console.warn(`evidence: ${u.length} status_disagrees advisory(ies) \u2014 ${p}`)}else console.warn(`evidence: ${u.length} status_disagrees advisory(ies) \u2014 step verdicts disagree with their failure records`,u);if(!d.valid){console.warn(`evidence: sealed pack ${t.executionId} failed L1 validation`,d.diagnostics);let p=String(d.diagnostics?.[0]?.code??"");Ee(Se(r,t.testId),"warn","EVIDENCE_INVALID",{execution_id:t.executionId,first_code:p,surface:t.surface??"testmd"},t.log)}}catch(d){console.warn(`evidence: validation error for ${t.executionId}`,d)}let c;if(t.saved&&t.packDir)try{c=await Ze(r,t.executionId,e)}catch(d){console.warn(`evidence: store install failed for ${t.executionId}`,d)}if(t.outputStemDir)try{await xe(t.outputStemDir,{execution_id:t.executionId,run_kind:t.runKind,status:t.verdict,valid:a,at:new Date().toISOString()})}catch(d){console.warn(`evidence: execution-pointer append failed for ${t.executionId} (pack is sealed)`,d)}return{sealed:!0,valid:a,storePath:c}}import{release as ht}from"os";import{execFileSync as dr}from"child_process";var vt=!1,q;function ur(){if(!vt)if(vt=!0,process.platform==="darwin")try{q=dr("sw_vers",["-productVersion"],{timeout:2e3}).toString().trim()||void 0}catch{q=ht()||void 0}else q=ht()||void 0;return q}function Pe(t){let e={os:te(process.platform)},r=ur();if(r&&(e.os_version=r),t.cdpBrowser){let n=/^([A-Za-z]+)\/(\d+)/.exec(t.cdpBrowser);n&&(e.browser=n[1].replace(/^Headless/,""),e.browser_version=n[2])}return t.resolution&&(e.resolution=t.resolution),Je(e,t.runnerEnvironment)}async function yt(t){if(t)try{let e=await fetch(`${t}/json/version`,{signal:AbortSignal.timeout(2e3)});if(!e.ok)return;let r=await e.json();return typeof r.Browser=="string"?r.Browser:void 0}catch{return}}function lr(t){let e;return()=>(e||(e=yt(t)),e)}import{promises as $,existsSync as O,readFileSync as gr}from"fs";import{basename as hr,join as h}from"path";import{readFileSync as pr}from"fs";import{dirname as fr,resolve as mr}from"path";function wt(t,e){let r=mr(t),n=pr(r,"utf8");return P(e?j(n,U(fr(r),e)):n)}var N=class t{constructor(e){this.opts=e}executionId;testId;definitionPath=null;definitionContent=null;accumulatedSteps=[];maxOrdinal=0;_attempts=[];_packDirOverride;_attached=!1;appiumMarks=ft();get attached(){return this._attached}static async attach(e){let r=hr(e.packDir).replace(/\.evidence$/,""),n=new t({origin:"testrun",runKind:"author",pid:process.pid,title:e.testId,started:new Date().toISOString(),producerVersion:Ue,cwd:e.cwd});n.executionId=r,n.testId=e.testId,n._packDirOverride=e.packDir,n._attached=!0;let i=h(e.packDir,"tests",e.testId);return await $.mkdir(i,{recursive:!0}),e.definition&&(await $.writeFile(h(i,e.definition.path),e.definition.content),n.definitionPath=e.definition.path,n.definitionContent=e.definition.content),n}async start(){if(this._attached)throw new Error("attach-mode session is already started");this.executionId=ne(),this.testId=this.opts.testmdRelPath?ue(this.opts.testmdRelPath):le(this.opts.objectiveOrName??"session",this.opts.sessionId??this.executionId);let e=this.opts.definition??null;return await me({execution_id:this.executionId,title:this.opts.title,started:this.opts.started,producerVersion:this.opts.producerVersion,surfaces:this.opts.surfaces,run_kind:this.opts.runKind,origin:this.opts.origin,pid:this.opts.pid,...this.opts.credits!==void 0?{credits:this.opts.credits}:{}},this.testId,e,this.opts.cwd,this.opts.packRootDir?this.pack:void 0),e&&(this.definitionPath=e.path,this.definitionContent=e.content),{executionId:this.executionId,testId:this.testId,packTestDir:this.packTestDir}}get pack(){return this._packDirOverride?this._packDirOverride:this.opts.packRootDir?h(this.opts.packRootDir,`${this.executionId}.evidence`):w(this.executionId,this.opts.cwd)}get packTestDir(){return h(this.pack,"tests",this.testId)}async writeDefinition(e,r="test.md"){await $.writeFile(h(this.packTestDir,r),e),this.definitionPath=r,this.definitionContent=e}computeAssuranceId(){try{if(this.opts.testmdRelPath&&this.opts.cwd){let e=h(this.opts.cwd,this.opts.testmdRelPath);if(O(e))return L(gr(e,"utf8"))?.id}}catch{}}computeDefinitionId(){try{if(this.opts.testmdRelPath&&this.opts.cwd){let e=h(this.opts.cwd,this.opts.testmdRelPath),r=h(this.opts.cwd,".context"),n=O(r)?x(r):void 0;if(O(e))return wt(e,n)}if(this.definitionContent!=null)return P(this.definitionContent)}catch{}}noteSpawn(e){this.accumulatedSteps.push(...e.steps),this.maxOrdinal=Math.max(this.maxOrdinal,e.maxOrdinal)}nextOrdinalOffset(){return this.maxOrdinal}get steps(){return this.accumulatedSteps}get attempts(){return this._attempts}async archiveAttempt(e,r){let n=this._attempts.length+1,i=h(this.packTestDir,String(n));try{await $.mkdir(i,{recursive:!0});for(let o of["steps","logs","v16-trajectory"]){let s=h(this.packTestDir,o);O(s)&&await $.rename(s,h(i,o))}this.definitionPath&&O(h(this.packTestDir,this.definitionPath))&&await $.copyFile(h(this.packTestDir,this.definitionPath),h(i,this.definitionPath))}catch{}return this._attempts.push({n,status:e,steps:this.accumulatedSteps,...r!==void 0?{durationMs:r}:{}}),this.accumulatedSteps=[],this.maxOrdinal=0,n}async writeResult(e){let r=ke(e.spawns),n=this._attempts.length?[...this._attempts.map(u=>({status:u.status,...u.durationMs!==void 0?{duration_ms:u.durationMs}:{}})),{status:r,...e.durationMs!==void 0?{duration_ms:e.durationMs}:{}}]:void 0,i=n?new Set(n.map(u=>u.status)).size>1:void 0,o=this.pack,s=pe(e.externalIdInput),a=re(e.runnerEnv,e.intentEnv),c=this.computeDefinitionId(),d=this.computeAssuranceId();await we(o,this.testId,J({testId:this.testId,status:r,durationMs:e.durationMs,definitionPath:this.definitionPath,definitionId:c,assuranceId:d,externalId:s,environment:a,steps:e.steps,tags:e.tags,attempts:n,flaky:i}));for(let u of this._attempts){let p=h(this.packTestDir,String(u.n));O(p)&&await $.writeFile(h(p,"result.yaml"),J({testId:this.testId,status:u.status,durationMs:u.durationMs,definitionPath:this.definitionPath,definitionId:c,assuranceId:d,externalId:s,environment:a,steps:u.steps,tags:e.tags}))}let l=e.externalIdInput;return e.log&&(l.commit_id||l.test_id||l.testcase_id)&&e.log("info","EVIDENCE_EXTERNAL_ID","Evidence external-id mapping",{execution_id:this.executionId,commit_id:l.commit_id??null,test_id:l.test_id??null,testcase_id:l.testcase_id??null,project_id:l.project_id??null,session_id:l.session_id??null,session_name:l.session_name??null}),r}get id(){return this.executionId}get test(){return this.testId}};async function vr(t,e,r=oe){try{let n=await r(t);if(n.aborted.length>0||n.removed.length>0)try{e?.("info","EVIDENCE_RECOVERY","Startup evidence recovery swept incomplete packs",{aborted:n.aborted,removed:n.removed,origin:"startup"})}catch{}return n}catch(n){return console.warn("evidence: startup recovery failed",n),{aborted:[],removed:[]}}}import{promises as jr}from"fs";import{existsSync as De,mkdirSync as Dr,readdirSync as $r,readFileSync as Lr,rmSync as Or,statSync as Fr,writeFileSync as Mr}from"fs";import{join as F}from"path";import{mkdirSync as yr,renameSync as wr,rmSync as _r,writeFileSync as xr}from"fs";import{join as _t}from"path";var kr=5e6;function xt(t,e,r){let n=_t(t,"coverage","sources"),i=new Map,o=!1;try{for(let s of r.usecases)for(let a of s.sources){if(i.has(a.id)){a.file=i.get(a.id);continue}if(!a.cid)continue;let c=at(e,a.cid);if(c===null||c.byteLength>kr)continue;o||(yr(n,{recursive:!0}),o=!0);let d=_t(n,a.id),l=`${d}.tmp-${process.pid}`;xr(l,c),wr(l,d);let u=`coverage/sources/${a.id}`;i.set(a.id,u),a.file=u}}catch{for(let s of r.usecases)for(let a of s.sources)delete a.file;if(o)try{_r(n,{recursive:!0,force:!0})}catch{}}}import{existsSync as Ce,readFileSync as V,renameSync as Ir,writeFileSync as Rr}from"fs";import{dirname as It,isAbsolute as Rt,resolve as Pt}from"path";var br=new Set(["inline","testmd","testrun"]),Sr=new Set(["inferred","authored","runtime-derived"]),Ae=new Set(["passed","failed","broken","skipped"]);function kt(t,e,r){if(r.facts.length===0)return{record:null,errors:[{code:"EMPTY_EXECUTIONS",detail:"a run with no designed units attaches no facts \u2014 skip the call"}]};let n=e;for(let i=0;;i++){let o=G(t);if(n.latestHash!==o){if(i>=3)return{record:null,errors:[{code:"STALE_BASIS",detail:`graph opened at ${String(n.latestHash)} but chain head is ${String(o)} \u2014 retry budget exhausted`}]};n=x(t);continue}let s=Er(t,n,r);if(s!=="cas")return s;if(i>=3)return{record:null,errors:[{code:"STALE_BASIS",detail:"concurrent appends kept moving the head \u2014 retry budget exhausted"}]};n=x(t)}}function Er(t,e,r){let n=[],i=[];for(let s of r.facts){let a=`executions[${s.ref}]`,c=e.resolve(s.ref),d=c?e.tipOf(c.cid):null;if(!c||!d||e.superseded.has(d)){n.push({code:"UNKNOWN_REF",detail:`${a}: '${s.ref}' is not a live committed node`});continue}if(e.nodeLabel.get(d)!==se.TEST){n.push({code:"ILLEGAL_TARGET",detail:`${a}: execution facts attach to tests \u2014 '${s.ref}' is a ${e.nodeLabel.get(d)}`});continue}if(!br.has(s.mode)){n.push({code:"BAD_MODE",detail:`${a}: mode '${s.mode}' not in inline|testmd|testrun`});continue}if(!Ae.has(s.verdict)){n.push({code:"BAD_VERDICT",detail:`${a}: verdict '${s.verdict}' not in ${[...Ae].join("|")}`});continue}if(!Sr.has(s.oracle_mode)){n.push({code:"BAD_ORACLE_MODE",detail:`${a}: oracle_mode '${s.oracle_mode}' not in inferred|authored|runtime-derived`});continue}if(typeof s.drift_flag!="boolean"||typeof s.stale_at_run!="boolean"){n.push({code:"MISSING_FIELD",detail:`${a}: drift_flag and stale_at_run are required booleans`});continue}if(!s.execution_id||!s.started_at||!s.definition_id_at_run){n.push({code:"MISSING_FIELD",detail:`${a}: execution_id, started_at and definition_id_at_run are required`});continue}let l=[];for(let u of s.per_ac??[]){let p=e.resolve(u.ac_ref),f=p?e.tipOf(p.cid):null;if(!p||!f||e.superseded.has(f)||e.nodeLabel.get(f)!==se.AC){n.push({code:"UNKNOWN_REF",detail:`${a}.per_ac: '${u.ac_ref}' is not a live AC`});continue}if(!Ae.has(u.verdict)){n.push({code:"BAD_VERDICT",detail:`${a}.per_ac['${u.ac_ref}']: verdict '${u.verdict}'`});continue}l.push({ac_ref:e.nameOf.get(f)??f,verdict:u.verdict})}i.push({about:d,definition_id_at_run:s.definition_id_at_run,verdict:s.verdict,...l.length?{per_ac:l}:{},drift_flag:s.drift_flag,oracle_mode:s.oracle_mode,stale_at_run:s.stale_at_run,...s.unresolved_acs?.length?{unresolved_acs:s.unresolved_acs}:{},execution_id:s.execution_id,...s.evidence_id?{evidence_id:s.evidence_id}:{},...s.duration_ms!==void 0?{duration_ms:s.duration_ms}:{},started_at:s.started_at,mode:s.mode,local:s.local,...s.via_parent?{via_parent:s.via_parent}:{}})}if(n.length>0)return{record:null,errors:n};let o;try{o=Y(t,{ts:new Date().toISOString(),proposal_id:null,nodes:[],edges:[],review:[],supersessions:[],executions:i,...r.eventIds&&r.eventIds.length>0?{event_ids:r.eventIds}:{},source_head_moves:{}},{expectPrev:e.latestHash})}catch(s){if(s instanceof it)return"cas";throw s}return K(t),{record:o.record,errors:null}}function At(t){let e={failed:3,broken:2,skipped:1,passed:0},r=new Map;for(let n of t)for(let i of n.verifies??[]){let o=r.get(i);(o===void 0||(e[n.status]??0)>(e[o]??0))&&r.set(i,n.status)}return[...r.entries()].map(([n,i])=>({ref:n,verdict:i}))}function Ct(t){let e=[],r=W(t.cwd);if(!Ce(r))return{synced:0,superseded:0,skipped:"no-context",warnings:e};let n=t.by??{kind:"ai",id:"exec-sync"},i=x(r),o=[],s=0,a=new Set;for(let d of t.members){let l=Rt(d.path)?d.path:Pt(t.cwd,d.path);for(let u of Pr(l)){if(a.has(u.path))continue;a.add(u.path);let p=u.path===l?void 0:L(V(l,"utf8"))?.id,f=V(u.path,"utf8"),m=L(f);if(!m?.id)continue;let g=i.resolve(m.id),b=g?i.tipOf(g.cid):null;if(!g||!b||i.superseded.has(b)){e.push(`sync: ${m.id} does not resolve to a live test \u2014 skipped (foreign store?)`);continue}let S=P(j(f,U(It(u.path),i))),v=String(i.getNode(b)?.content.test_md_blob??""),H=P(j(v,et(i))),z=!1,ee=b;if(S===H)m.base!==H&&Et(u.path,f,H,e);else if(m.base===H){let y=Ar(r,i,b,f,S,n);y.error?(e.push(`sync: could not supersede ${m.id}: ${y.error}`),z=!0):(s++,ee=y.newCid,z=y.oracleTier,Et(u.path,V(u.path,"utf8"),S,e),i=x(r))}else z=!0,e.push(m.base?`sync: ${m.id} was edited from an older version \u2014 graph kept; reconcile via a redesign or maintain`:`sync: ${m.id} carries no base pin (hand-copied file?) \u2014 fact attached with drift flag`);let Ve=i.getNode(ee)?.content.check,Be=u.path===l?d.acs??[]:[],He=Be.filter(y=>bt(i,y.ref)),ze=Be.filter(y=>!bt(i,y.ref)).map(y=>y.ref);o.push({ref:m.id,definition_id_at_run:S,verdict:d.verdict,...He.length?{per_ac:He.map(y=>({ac_ref:y.ref,verdict:y.verdict}))}:{},drift_flag:z,oracle_mode:Ve?.expected_mode??(Qe(Ve?.operand)?"runtime-derived":"inferred"),stale_at_run:i.stale(ee)!=="fresh",...ze.length?{unresolved_acs:ze}:{},execution_id:d.executionId,...d.evidenceId?{evidence_id:d.evidenceId}:{},...d.durationMs!==void 0?{duration_ms:d.durationMs}:{},started_at:d.startedAt,mode:d.mode,local:d.local,...p?{via_parent:p}:{}})}}if(o.length===0)return{synced:0,superseded:s,warnings:e};let c=kt(r,x(r),{facts:o,by:n});return c.errors?(e.push(...c.errors.map(d=>`sync facts: ${d.code}: ${d.detail}`)),{synced:0,superseded:s,warnings:e}):{synced:o.length,superseded:s,warnings:e}}function Pr(t){let e=[],r=new Set,n=i=>{if(r.has(i)||!Ce(i))return;r.add(i);let o=V(i,"utf8");for(let s of o.split(`
5
+ `)){let a=/^@import\s+(\S+)\s*$/.exec(s.trim());if(!a)continue;let c=Rt(a[1])?a[1]:Pt(It(i),a[1]);Ce(c)&&L(V(c,"utf8"))?.id&&n(c)}e.push({path:i})};return n(t),e}function bt(t,e){let r=t.resolve(e),n=r?t.tipOf(r.cid):null;return!!(r&&n&&!t.superseded.has(n)&&t.nodeLabel.get(n)==="ac")}function Ar(t,e,r,n,i,o){let s=e.getNode(r);if(!s)return{oracleTier:!1,error:"tip unreadable"};let a=tt(n),c=String(s.content.test_md_blob??""),d=/^#\s+(.+?)\s*$/m.exec(a)?.[1]??String(s.content.title??""),l={...s.content,test_md_blob:a,definitionId:i,title:d},u=rt("test",l);if(u.length>0)return{oracleTier:!1,error:u.map(g=>g.detail).join("; ")};let p=nt("test",l);if(p===r)return{newCid:r,oracleTier:!1};let f=St(c)!==St(a),m=G(t);if(e.latestHash!==m)return{oracleTier:f,error:`store advanced under the sync (basis ${String(e.latestHash)} vs head ${String(m)}) \u2014 re-run to retry`};try{Y(t,{ts:new Date().toISOString(),proposal_id:null,nodes:[{cid:p,label:"test",content:l}],edges:[],review:[{id:p,kind:"review-item",resolution:"edited",edit:null,reason:"edited on disk (run sync)",by:o}],supersessions:[{kind:"node",old:r,new:p,reason:"edited on disk (run sync)",by:o}],source_head_moves:{}},{expectPrev:m})}catch(g){return{oracleTier:f,error:g instanceof Error?g.message:String(g)}}return K(t),{newCid:p,oracleTier:f}}var Cr=/\s@verifies\s+(ac-[\w.:\/-]+(?:\s*,\s*ac-[\w.:\/-]+)*)\s*$/;function St(t){let e=[],r=t.split(`
6
+ `),n=!1;for(let i of r){if(/^##\s/.test(i)){n=/\bassert\b/i.test(i);let o=Cr.exec(i);o&&e.push(`v:${o[1].trim()}`);continue}n&&i.trim()!==""&&e.push(i.trim())}return e.join(`
7
+ `)}function Et(t,e,r,n){try{let i=e.split(`
8
+ `),o=-1;if(i[0]?.trim()==="---"){for(let c=1;c<i.length;c++)if(i[c].trim()==="---"){o=c;break}}if(o<0)return;let s=!1;for(let c=1;c<o;c++){if(/^\s+base:\s*sha256:[0-9a-f]+\s*$/.test(i[c])){i[c]=i[c].replace(/sha256:[0-9a-f]+/,r),s=!0;break}if(/^assurance:\s*$/.test(i[c])&&!i.slice(c,Math.min(c+3,o)).some(d=>/^\s+base:/.test(d))){i.splice(c+2,0,` base: ${r}`),s=!0;break}}if(!s)return;let a=`${t}.tmp-sync`;Rr(a,i.join(`
9
+ `)),Ir(a,t)}catch(i){n.push(`sync: pin refresh failed for ${t} (${i instanceof Error?i.message:String(i)}) \u2014 next run self-heals`)}}var Tr={passed:"passed",failed:"failed",broken:"blocked",skipped:"not-run"},Dt=(t,e)=>{try{if(!De(e))return{status:"skipped",reason:"no context store at the project root"};let r=F(t,"tests");if(!De(r))return{status:"skipped",reason:"pack has no tests/"};let n=new Map;for(let a of $r(r)){let c=F(r,a,"result.yaml");if(!De(c)||!Fr(F(r,a)).isDirectory())continue;let d=R(Lr(c,"utf8"));if(!d?.definition_id&&!d?.assurance_id)continue;let l=At(d.steps??[]),u={testShortId:String(d.test??a),execution:Tr[String(d.status)]??"not-run",...l.length?{acs:l}:{}};d.assurance_id&&n.set(`id:${d.assurance_id}`,u),d.definition_id&&n.set(`def:${d.definition_id}`,u)}let i=st(x(e),n,{scope:"run"}),o=ot(i);xt(t,e,i);let s=_({...i,rollup:o},{lineWidth:-1});return Dr(F(t,"coverage"),{recursive:!0}),Mr(F(t,"coverage","usecases.yaml"),s),{status:"written"}}catch(r){try{Or(F(t,"coverage","sources"),{recursive:!0,force:!0})}catch{}return{status:"skipped",reason:r instanceof Error?r.message:String(r)}}};async function Nr(t){try{let e=new N({origin:"inline",runKind:"author",pid:t.pid,title:t.title,started:new Date().toISOString(),producerVersion:t.producerVersion,surfaces:t.surfaces,objectiveOrName:t.objectiveOrName,sessionId:t.sessionId,cwd:t.cwd,packRootDir:t.packRootDir}),r=await e.start();return{session:e,...r,packDir:e.pack,spawns:[],startedAtMs:Date.now(),cwd:t.cwd}}catch(e){return console.warn("evidence: inline pack creation failed",e),null}}function Vr(t,e,r){if(!t)return;t.session.noteSpawn(e),e.resolution&&(t.resolution=e.resolution),t.runnerEnvironment=We(t.runnerEnvironment,e.runnerEnvironment);let n=(r?.per_flow_metadata??[]).map(i=>({resultCode:i?.result_code!=null?Number(i.result_code):null}));t.spawns.push({resultCode:r?.result_code!=null?Number(r.result_code):null,...n.length?{perFlow:n}:{}})}function Br(t){if(t)return{packTestDir:t.packTestDir,ordinalOffset:t.session.nextOrdinalOffset()}}async function Hr(t,e){if(!t)return null;if(t.finalized)return t.finalized;let r=(n,i,o)=>e.log?e.log("warn",n,i,o):console.warn(`evidence: ${i}`,o??"");try{if(e.recordedTestPath)try{await t.session.writeDefinition(await jr.readFile(e.recordedTestPath,"utf8"))}catch(s){r("EVIDENCE_DEFINITION_FAILED","could not attach synthesized test.md",{error:String(s)})}let n=e.cdpBrowserCapture?await e.cdpBrowserCapture():void 0,i=await t.session.writeResult({steps:t.session.steps,spawns:t.spawns.length?t.spawns:[{resultCode:null}],externalIdInput:{...e.externalIdInput,execution_id:t.executionId},runnerEnv:Pe({cdpBrowser:n,resolution:t.resolution,runnerEnvironment:t.runnerEnvironment}),intentEnv:Xe(e.model,t.runnerEnvironment),durationMs:e.durationMs??Date.now()-t.startedAtMs,log:e.log});try{if(e.recordedTestPath){let s=Ct({cwd:e.cwd??t.cwd??process.cwd(),members:[{path:e.recordedTestPath,verdict:i,executionId:t.executionId,startedAt:new Date(t.startedAtMs).toISOString(),mode:"inline",local:e.local??!1}]});for(let a of s.warnings)r("EXEC_SYNC",a)}}catch(s){r("EXEC_SYNC","exec-sync failed",{error:String(s)})}try{let s=(e.coverageWriter??Dt)(t.packDir,W(e.cwd??t.cwd??process.cwd()));s.status==="skipped"&&r("EVIDENCE_COVERAGE_SKIPPED",`coverage/usecases.yaml not written: ${s.reason}`)}catch(s){r("EVIDENCE_COVERAGE_SKIPPED","coverage writer threw",{error:String(s)})}let o=await Re({executionId:t.executionId,testId:t.testId,saved:e.saved,runKind:"author",verdict:i,cwd:e.cwd??t.cwd,packDir:t.packDir,tuiLogPath:e.tuiLogPath,log:e.log,surface:"inline",requireRealLog:!!t.runnerEnvironment?.native_platform,appiumMarks:t.session.appiumMarks});return t.finalized=o,e.log?.("info","EVIDENCE_SEALED","Inline pack sealed",{execution_id:t.executionId,verdict:i,valid:o.valid,pack:t.packDir,store_copy:o.storePath??null}),o}catch(n){return r("EVIDENCE_SEAL_FAILED","inline pack finalize failed",{error:String(n)}),null}}import{statSync as Wr,openSync as Jr,readSync as Xr,closeSync as qr}from"fs";import{basename as Zr,resolve as Qr}from"path";import{createServer as zr}from"http";import{createReadStream as Ur,promises as Gr}from"fs";import{randomBytes as Yr}from"crypto";var Z="127.0.0.1";function $t(t,e){if(!t)return null;let r=/^bytes=(\d*)-(\d*)$/.exec(t.trim());if(!r)return null;let[,n,i]=r;if(n===""&&i==="")return null;if(n===""){let a=Number(i);return a===0||e===0?"unsatisfiable":{start:Math.max(0,e-a),end:e-1}}let o=Number(n);if(o>=e)return"unsatisfiable";let s=i===""?e-1:Math.min(Number(i),e-1);return s<o?null:{start:o,end:s}}async function $e(t){let e=Yr(16).toString("hex"),r=zr((i,o)=>{Kr(i,o,t,e).catch(()=>o.destroy())});await new Promise((i,o)=>{r.once("error",o),r.listen(t.port??0,Z,()=>{r.removeListener("error",o),i()})});let n=r.address().port;return{port:n,urlFor:i=>`http://${Z}:${n}/${e}/${encodeURIComponent(i)}`,close:()=>new Promise(i=>{r.close(()=>i()),r.closeAllConnections()})}}async function Kr(t,e,r,n){let i=t.url??"/",o=v=>{try{r.log?.("warn","EVIDENCE_SERVE_DENIED",{reason:v,path:i})}catch{}};if(t.headers.host!==`${Z}:${t.socket.localPort}`){o("host_mismatch"),e.writeHead(403).end();return}let s=t.headers.origin;if(s!==void 0&&!r.allowedOrigins.includes(s)){o("origin_denied"),e.writeHead(403).end();return}let a=s?{"Access-Control-Allow-Origin":s,Vary:"Origin","Access-Control-Expose-Headers":"Content-Range, Content-Length"}:{};if(t.method==="OPTIONS"){let v={...a,"Access-Control-Allow-Methods":"GET, HEAD, OPTIONS","Access-Control-Allow-Headers":"range","Access-Control-Max-Age":"86400"};t.headers["access-control-request-private-network"]==="true"&&(v["Access-Control-Allow-Private-Network"]="true"),e.writeHead(204,v).end();return}if(t.method!=="GET"&&t.method!=="HEAD"){e.writeHead(405,a).end();return}let c;try{let v=new URL(t.url??"/",`http://${Z}`).pathname.split("/");if(v.length!==3||v[1]!==n){o("bad_token"),e.writeHead(404,a).end();return}c=decodeURIComponent(v[2])}catch{o("not_found"),e.writeHead(404,a).end();return}let d=r.packs.get(c);if(!d){o("not_found"),e.writeHead(404,a).end();return}let l;try{let v=await Gr.stat(d);if(!v.isFile())throw new Error("not a file");l=v.size}catch{o("not_found"),e.writeHead(404,a).end();return}let u={...a,"Accept-Ranges":"bytes","Content-Type":"application/zip","Cache-Control":"no-store"};if(t.method==="HEAD"){e.writeHead(200,{...u,"Content-Length":String(l)}).end();return}let p=$t(t.headers.range,l);if(p==="unsatisfiable"){o("unsatisfiable"),e.writeHead(416,{...a,"Content-Range":`bytes */${l}`}).end();return}let[f,m,g]=p===null?[0,l-1,200]:[p.start,p.end,206],b={...u,"Content-Length":String(m-f+1)};if(g===206&&(b["Content-Range"]=`bytes ${f}-${m}/${l}`),e.writeHead(g,b),l===0){e.end();return}let S=Ur(d,{start:f,end:m});S.on("error",()=>e.destroy()),e.on("close",()=>S.destroy()),S.pipe(e)}function B(t,e){return(e??Ge(t).evidenceViewerUrl).replace(/\/+$/,"")}function Le(t,e){return`${e}/?pack=${encodeURIComponent(t)}`}function Oe(t){return`evidence: view locally with \`kane-cli evidence serve ${t}\``}async function en(t,e,r={}){let n=r.out??(l=>process.stdout.write(l+`
10
+ `)),i=l=>(n(`error: ${l}`),2);if(e.env!=="prod"&&e.env!=="stage")return i(`invalid --env: ${String(e.env)}`);if(e.port!==void 0&&(!Number.isInteger(e.port)||e.port<1||e.port>65535))return i("invalid --port: expected an integer 1-65535");let o;try{o=B(e.env,e.viewerUrl),new URL(o)}catch{return i(`invalid --viewer-url: ${e.viewerUrl}`)}if(t.length===0)return i("no pack paths given");let s=new Map;for(let l of t){let u=Qr(l),p;try{p=Wr(u)}catch{return i(`${l}: not found`)}if(p.isDirectory())return i(`${l}: is a directory \u2014 packs must be sealed .evidence files (run the execution to completion, or seal it, first)`);if(!p.isFile())return i(`${l}: not a regular file`);let f=Buffer.alloc(2),m=Jr(u,"r");try{Xr(m,f,0,2,0)}finally{qr(m)}if(f.toString("latin1")!=="PK")return i(`${l}: not a sealed evidence pack (zip magic missing)`);let g=Zr(u);if(s.has(g))return i(`duplicate pack basename: ${g} (URL names collide \u2014 rename one)`);s.set(g,u)}let a=r.log??((l,u,p)=>process.stderr.write(`warn: ${u} reason=${p.reason} path=${p.path}
11
+ `)),c;try{c=await $e({packs:s,allowedOrigins:[new URL(o).origin],port:e.port,log:a})}catch(l){return i(`could not bind 127.0.0.1${e.port?`:${e.port}`:""} \u2014 ${l.message}`)}n(`serving ${s.size} pack${s.size===1?"":"s"} on http://127.0.0.1:${c.port}`);for(let l of s.keys()){let u=c.urlFor(l);n(l),n(` pack ${u}`),n(` viewer ${Le(u,o)}`)}return n("press Ctrl-C to stop"),await(r.hold??tn)(),await c.close(),0}function tn(){return new Promise(t=>{let e=process.listeners("SIGINT");process.removeAllListeners("SIGINT"),process.once("SIGINT",()=>{for(let r of e)process.on("SIGINT",r);t()})})}import{promises as Q}from"fs";import{tmpdir as sn}from"os";import{join as Ft,resolve as Me}from"path";var rn=["error","prefer_first","prefer_latest","discard"],nn=["external_id.commit_id","external_id.test_id"];function Lt(t){let e=t.replace(/-/g,"_");return rn.includes(e)?e:null}function Ot(t){let e=t==="discard"?{on_collision:"discard"}:{on_collision:"error",identity:{keys:[...nn],on_same:t??"nest",on_different:t?"error":"split"}};return _({packs:{require_status:"finalized",require_valid:"L1",on_ineligible:"abort"},tests:e,rules:[{file:"run.yaml",key:"run_id",must:"different",on_violation:"skip"},{file:"result.yaml",key:"external_id.project_id",must:"same",on_violation:"error"},{file:"result.yaml",key:"external_id.org_id",must:"same",on_violation:"error"}]},{lineWidth:-1})}async function Fe(t){try{if(!t.isTTY){t.log(Oe(t.packPath));return}let e=B(t.env);await(t.renderPrompt??on)(t.packPath,e)}catch(e){try{t.log(`evidence view failed \u2014 ${e.message}`)}catch{}}}async function on(t,e){let r=await import("./react-QWOAB3TB.js"),{render:n}=await import("./build-JIKYOZUH.js"),{EvidenceViewOffer:i}=await import("./EvidenceViewOffer-62XHEEGW.js");await new Promise(o=>{let s=n(r.default.createElement(i,{packPath:t,viewerBase:e,onDone:()=>{s.unmount(),o()}}),{stdout:process.stderr,exitOnCtrlC:!1})})}async function an(t,e,r=process.cwd(),n={}){let i=n.out??(p=>process.stdout.write(p+`
12
+ `)),o=n.err??(p=>process.stderr.write(p+`
13
+ `)),s=p=>(o(`evidence merge: ${p}`),2);if(!e.runId)return s("--run-id is required (merged identity is the caller's fact)");if(e.rules&&e.onCollision)return s("--rules and --on-collision are mutually exclusive");let a;if(e.onCollision!==void 0){let p=Lt(e.onCollision);if(!p)return s(`invalid --on-collision: ${e.onCollision} (expected error | prefer-first | prefer-latest | discard)`);a=p}let c=[];for(let p of t){let f=await cn(p,r);if(!f)return s(`no pack found for "${p}"`);c.push(f)}let d=e.out?Me(r,e.out):w(e.runId,r),l=null,u;e.rules?u=Me(r,e.rules):(l=await Q.mkdtemp(Ft(sn(),"kane-merge-rules-")),u=Ft(l,"merge-rules.yaml"),await Q.writeFile(u,Ot(a)));try{let p=await(n.mergeFn??qe)(c,{runId:e.runId,out:d,rulesPath:u,title:e.title,finalize:e.finalize});return e.json?i(JSON.stringify(p)):dn(i,p),p.output.finalized&&!e.json&&await(n.offer??Fe)({packPath:d,env:e.env,isTTY:n.isTTY??(!!process.stdin.isTTY&&!!process.stderr.isTTY),log:o}),0}catch(p){let f=p instanceof Error?p.message:String(p);return p?.code==="ABORT"?(o(`evidence merge: aborted \u2014 ${f}`),1):s(f)}finally{l&&await Q.rm(l,{recursive:!0,force:!0}).catch(()=>{})}}async function cn(t,e){let r=Me(e,t);if(await Mt(r))return r;let n=w(t,e);return await Mt(n)?n:null}async function Mt(t){try{return await Q.stat(t),!0}catch{return!1}}function dn(t,e){let{packs:r,tests:n,output:i}=e;t(`evidence: merged ${n.merged} tests from ${r.eligible.length} packs -> ${i.path} (${i.finalized?"sealed":"live"})`);for(let o of r.skipped)t(` skipped ${o.runId}: ${o.rule} \u2014 ${o.reason}`);for(let o of n.collisions){let s;o.action==="nest"?s=`nested into ${o.folder}, latest ${o.winner}`:o.action==="split"?s=`split into ${o.folder}`:s=`winner ${o.winner}`,t(` collision ${o.test}: ${s} (${o.rule})`)}for(let o of n.discarded)t(` discarded ${o}`)}import{copyFileSync as un,existsSync as Te,mkdirSync as ln}from"fs";import{join as Tt}from"path";function pn(t,e,r){try{let n=Tt(t,"auteur","execution.json");if(Te(n))return!0;for(let i of e)if(!(!i||!Te(i)))return ln(Tt(t,"auteur"),{recursive:!0}),un(i,n),!0}catch(n){try{r?.("debug","EVIDENCE_BLOB_COPY_FAILED","auteur execution blob copy failed",{operation:"ensureAuteurExecution",source:e.find(i=>i&&Te(i))??null,error:n instanceof Error?n.message:String(n)})}catch{}}return!1}import{readFileSync as fn}from"fs";import{join as mn}from"path";function Ne(t){let e=[],r=!0,n=o=>{if(o===null||typeof o!="object")return;let s=o;if(Array.isArray(s.operations))for(let a of s.operations){let c=a?.operation_id;typeof c=="string"&&c&&e.push(c)}if(Array.isArray(s.children)){s.content_type!=="generative_block"&&(r=!1);for(let a of s.children)n(a)}if(Array.isArray(s.branches)){r=!1;for(let a of s.branches){let c=a?.children;if(Array.isArray(c))for(let d of c)n(d)}}},i=t?.instructions;if(Array.isArray(i))for(let o of i)n(o);return{ids:e,linear:r}}function gn(t){return Ne(t).ids}function je(t,e){let r=new Set(e.map(a=>a.action_id).filter(Boolean)),n=-1;for(let a of r){let c=t.indexOf(a);c>n&&(n=c)}let i=e.reduce((a,c)=>Math.max(a,c.ordinal),0),o=new Set,s=[];for(let a of t.slice(n+1))r.has(a)||o.has(a)||(o.add(a),s.push({id:a,ordinal:++i,status:"skipped",action_id:a}));return s}function jt(t,e){let r=new Set(e),n=t.filter(o=>o.action_id);if(n.some(o=>r.has(o.action_id))||n.length>e.length)return null;let i=0;return t.map(o=>o.action_id?{...o,action_id:e[i++]}:o)}function hn(t,e){if(t.length>e.length)return!1;for(let r=0;r<t.length;r++)if(e[r]!==t[r].action_id)return!1;return!0}function vn(t,e,r,n=!0){if(e.length===0)return{steps:t,tail:[]};let i=(r&&n?jt(t,e):null)??t,o=i.filter(a=>a.action_id),s=new Set(e);return o.length>0&&o.every(a=>s.has(a.action_id))?{steps:i,tail:je(e,i)}:o.length>0&&!hn(o,e)?{steps:i,tail:[],unjoined:!0}:{steps:i,tail:je(e,i)}}function Nt(t){try{let e=fn(mn(t,"auteur","execution.json"),"utf8");return Ne(JSON.parse(e))}catch{return{ids:[],linear:!0}}}function yn(t){return Nt(t).ids}export{C as a,ae as b,ce as c,de as d,ue as e,le as f,pe as g,Ht as h,fe as i,me as j,zt as k,Ut as l,ge as m,J as n,ye as o,we as p,_e as q,xe as r,Gt as s,Yt as t,ke as u,Kt as v,be as w,Se as x,Ee as y,gt as z,Re as A,Pe as B,yt as C,lr as D,N as E,vr as F,At as G,Ct as H,Dt as I,Nr as J,Vr as K,Br as L,Hr as M,$t as N,$e as O,B as P,Le as Q,Oe as R,en as S,Fe as T,an as U,pn as V,Ne as W,gn as X,je as Y,jt as Z,vn as _,Nt as $,yn as aa};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a}from"./chunk-O75ZHGJG.js";import"./chunk-ZUGCHQFC.js";import"./chunk-UR6MHSHU.js";export{a as getEnvironment};
2
+ import{a}from"./chunk-G7VQCS4J.js";import"./chunk-27U4PLPX.js";import"./chunk-UR6MHSHU.js";export{a as getEnvironment};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a}from"./chunk-WAOCHXJ5.js";import"./chunk-NLCCBXXV.js";import"./chunk-RZ4F3BHX.js";import"./chunk-UR6MHSHU.js";export{a as ControllerClient};
2
+ import{a}from"./chunk-DPUV6OSP.js";import"./chunk-NLCCBXXV.js";import"./chunk-RZ4F3BHX.js";import"./chunk-UR6MHSHU.js";export{a as ControllerClient};
@@ -1,3 +1,3 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{b as O}from"./chunk-DYW5C6II.js";import{a as g,b as S,d as G}from"./chunk-OS4VSIHT.js";import"./chunk-5DT7PIGB.js";import{e as w,f as $}from"./chunk-CJJXT5DO.js";import{d as x}from"./chunk-XWKUZJCP.js";import{e as k}from"./chunk-EHN5HTUD.js";import{a as b}from"./chunk-L5LI2JF4.js";import{A as R}from"./chunk-TH47OOBV.js";import"./chunk-VAYBKR76.js";import"./chunk-CUM23TLF.js";import"./chunk-DUAXZYAD.js";import"./chunk-DBIBROYW.js";import"./chunk-WXHQYYD5.js";import"./chunk-IAHKTEET.js";import"./chunk-UD7KKHPW.js";import"./chunk-CH273NAE.js";import"./chunk-UR6MHSHU.js";import{basename as h}from"path";import{statSync as A}from"fs";function C(t,e){if(!t)return 1;let o=t.resolve(e);return!o||o.superseded?1:t.getNode(o.tip)?.content.risk==="high"?3:1}function D(t,e){return t.usecases.map(o=>{let s=o.acceptance_criteria??[],a=s.filter(n=>(n.covered_by??[]).length>0),l=s.filter(n=>n.execution==="passed"),i=s.filter(n=>n.execution==="failed"),u=s.filter(n=>n.execution==="blocked"),d=0,m=0;for(let n of s){let f=C(e,n.id);d+=f,n.execution==="passed"&&(m+=f)}let r=d===0?0:Math.round(100*m/d),p=a.length===0?"uncovered":s.length===l.length?"covered":u.length>0&&i.length===0?"blocked":"partial";return{id:o.id,title:o.title,status:p,pct:r,acs:{total:s.length,covered:a.length,passed:l.length,failed:i.length,blocked:u.length},stale:s.filter(n=>n.fresh==="stale").map(n=>n.id)}})}async function P(t){let e=await w(t);return e.length===0?null:e.map(o=>({p:o,m:A(o).mtimeMs})).sort((o,s)=>s.m-o.m)[0].p}var N={covered:"\u2714",partial:"\u25D0",uncovered:"\u2716",blocked:"\u23F8"};function _(t){let e=Math.round(t/10);return"\u2588".repeat(e)+"\u2591".repeat(10-e)}async function I(t,e=G(),o=process.cwd()){if(t.mode!==void 0&&t.mode!=="agent"&&t.mode!=="ci"&&t.mode!=="interactive")return g(e,`--mode must be interactive | agent | ci, got '${t.mode}'`),2;if(t.mode==="agent"||t.mode==="ci"){let{makeHeadlessIO:r,agentRefusal:p}=await import("./headless-io-66RG5NN5.js"),n=r("ndjson","cover",{stdout:c=>e.out(c.replace(/\n$/,"")),stderr:c=>(e.err??e.out)(c.replace(/\n$/,""))}),f=[],v=[],j={out:c=>f.push(c),err:c=>v.push(c),confirm:async()=>!1,isTTY:!1};if(await I({...t,json:!0,mode:void 0},j,o)!==0)return p(n,v.join("; ")||"cover refused");let y=JSON.parse(f.join(`
2
+ import{b as O}from"./chunk-DYW5C6II.js";import{a as g,b as S,d as G}from"./chunk-OS4VSIHT.js";import"./chunk-5DT7PIGB.js";import{e as w,f as $}from"./chunk-CJJXT5DO.js";import{d as x}from"./chunk-XWKUZJCP.js";import{e as k}from"./chunk-EHN5HTUD.js";import"./chunk-CH273NAE.js";import{a as b}from"./chunk-L5LI2JF4.js";import{A as R}from"./chunk-TH47OOBV.js";import"./chunk-VAYBKR76.js";import"./chunk-CUM23TLF.js";import"./chunk-DUAXZYAD.js";import"./chunk-DBIBROYW.js";import"./chunk-WXHQYYD5.js";import"./chunk-IAHKTEET.js";import"./chunk-UD7KKHPW.js";import"./chunk-UR6MHSHU.js";import{basename as h}from"path";import{statSync as A}from"fs";function C(t,e){if(!t)return 1;let o=t.resolve(e);return!o||o.superseded?1:t.getNode(o.tip)?.content.risk==="high"?3:1}function D(t,e){return t.usecases.map(o=>{let s=o.acceptance_criteria??[],a=s.filter(n=>(n.covered_by??[]).length>0),l=s.filter(n=>n.execution==="passed"),i=s.filter(n=>n.execution==="failed"),u=s.filter(n=>n.execution==="blocked"),d=0,m=0;for(let n of s){let f=C(e,n.id);d+=f,n.execution==="passed"&&(m+=f)}let r=d===0?0:Math.round(100*m/d),p=a.length===0?"uncovered":s.length===l.length?"covered":u.length>0&&i.length===0?"blocked":"partial";return{id:o.id,title:o.title,status:p,pct:r,acs:{total:s.length,covered:a.length,passed:l.length,failed:i.length,blocked:u.length},stale:s.filter(n=>n.fresh==="stale").map(n=>n.id)}})}async function P(t){let e=await w(t);return e.length===0?null:e.map(o=>({p:o,m:A(o).mtimeMs})).sort((o,s)=>s.m-o.m)[0].p}var N={covered:"\u2714",partial:"\u25D0",uncovered:"\u2716",blocked:"\u23F8"};function _(t){let e=Math.round(t/10);return"\u2588".repeat(e)+"\u2591".repeat(10-e)}async function I(t,e=G(),o=process.cwd()){if(t.mode!==void 0&&t.mode!=="agent"&&t.mode!=="ci"&&t.mode!=="interactive")return g(e,`--mode must be interactive | agent | ci, got '${t.mode}'`),2;if(t.mode==="agent"||t.mode==="ci"){let{makeHeadlessIO:r,agentRefusal:p}=await import("./headless-io-66RG5NN5.js"),n=r("ndjson","cover",{stdout:c=>e.out(c.replace(/\n$/,"")),stderr:c=>(e.err??e.out)(c.replace(/\n$/,""))}),f=[],v=[],j={out:c=>f.push(c),err:c=>v.push(c),confirm:async()=>!1,isTTY:!1};if(await I({...t,json:!0,mode:void 0},j,o)!==0)return p(n,v.join("; ")||"cover refused");let y=JSON.parse(f.join(`
3
3
  `));return n.event({type:"coverage",...y}),n.done(0,void 0,M(y.completeness??[]))}let s=S(o,e);if(!s)return 2;let a=t.from?await $(t.from,o):await P(o);if(!a)return g(e,t.from?`no evidence pack at '${t.from}'`:"no evidence pack in .testmuai/evidence \u2014 run a test first, or pass --from <pack>"),2;let l=await k(a,"coverage/usecases.yaml");if(l==null)return g(e,`${h(a)} carries no coverage/usecases.yaml \u2014 the pack predates coverage or its project had no .context at seal time`),2;let i=b(l);if(!i||!Array.isArray(i.usecases))return g(e,`${h(a)}: coverage/usecases.yaml is not a usecases document`),2;let u=R(s),d=D(i,u),m=await x(u,"design");if(t.json)return e.out(JSON.stringify({pack:a,depth:d,completeness:m},null,2)),0;e.out(`coverage \u2014 ${h(a)}`),e.out(""),e.out("depth (proven by the pack):");for(let r of d){let p=r.stale.length?` \xB7 ${r.stale.length} stale`:"";e.out(` ${N[r.status]} ${_(r.pct)} ${String(r.pct).padStart(3)}% ${r.id} \u2014 ${r.status} (${r.acs.passed}/${r.acs.total} ACs proven${r.acs.failed?`, ${r.acs.failed} failed`:""}${r.acs.blocked?`, ${r.acs.blocked} blocked`:""})${p}`)}e.out(""),e.out("completeness (live graph):"),m.length===0&&e.out(" no design gaps \u2014 every AC verified, every use-case scenarioed");for(let r of m)e.out(` [${r.risk}] ${r.tag} ${r.ref} \u2014 ${r.why}`),e.out(` \u2192 ${r.ready_command}`);return 0}function M(t){return t.filter(e=>e.ready_command.startsWith("kane-cli ")&&O(e.ready_command)).slice(0,4).map(e=>({cmd:e.ready_command,why:e.why}))}export{I as coverCommand,M as coverNext,D as depthRows};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a}from"./chunk-VT54ARGE.js";import"./chunk-ZUGCHQFC.js";import"./chunk-UR6MHSHU.js";export{a as CredentialsManager};
2
+ import{a}from"./chunk-6O3DDOP2.js";import"./chunk-27U4PLPX.js";import"./chunk-UR6MHSHU.js";export{a as CredentialsManager};
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import"./chunk-UR6MHSHU.js";var c="Mobile dependencies are resolved through your KaneAI account. Run `kane-cli login` first.";function d(l,o,e=process.env){return e.KANE_MOBILE_DEPS_BASE_URL||o(l)}async function u(){let[{CredentialsManager:l},{refreshOAuthToken:o},{getEnvironment:e},{ControllerClient:n}]=await Promise.all([import("./credentials-OH6AVI6N.js"),import("./token-refresh-4BPAPXKK.js"),import("./config-RS47F5SC.js"),import("./controller-client-OB4WD2C4.js")]),s=new l;return{creds:s,refresh:r=>o({creds:s,profile:r.profile,env:r.env,credentials:r.credentials}),controllerBaseUrlFor:r=>d(r,t=>e(t).controllerBaseUrl),makeClient:(r,t)=>new n(r,t)}}function p(l){return async o=>{let e=l??await u(),n=e.creds.getActiveProfile();if(!n)throw new Error(c);let s=e.creds.getDefaultEnv(),r=e.controllerBaseUrlFor(s),t=e.creds.loadBasicAuth(n,s);if(t)return e.makeClient(r,{username:t.username,accessKey:t.access_key}).resolveMobileDepsBundle(o);let i=e.creds.loadCredentials(n,s);if(!i)throw new Error(c);try{await e.refresh({creds:e.creds,profile:n,env:s,credentials:i})}catch{}let a=(e.creds.loadCredentials(n,s)??i).access_token;if(typeof a!="string"||!a)throw new Error(c);return e.makeClient(r,a).resolveMobileDepsBundle(o)}}export{p as controllerResolveBundle,d as depsControllerBaseUrl};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a,b,c,d}from"./chunk-VMM4LC4V.js";import"./chunk-W4B5LOEX.js";import"./chunk-DNNZ353O.js";import"./chunk-2UIHS2FH.js";import"./chunk-Q2F5QB2W.js";import"./chunk-N2P4MI32.js";import"./chunk-NVGBE2DR.js";import"./chunk-TH47OOBV.js";import"./chunk-VAYBKR76.js";import"./chunk-CUM23TLF.js";import"./chunk-DUAXZYAD.js";import"./chunk-DBIBROYW.js";import"./chunk-WXHQYYD5.js";import"./chunk-IAHKTEET.js";import"./chunk-UD7KKHPW.js";import"./chunk-ZUGCHQFC.js";import"./chunk-UR6MHSHU.js";export{b as REMOTE_PROVIDERS,d as findProvider,a as landingReceipt,c as looksLikeUrl};
2
+ import{a,b,c,d}from"./chunk-7BZSCUPP.js";import"./chunk-W4B5LOEX.js";import"./chunk-DNNZ353O.js";import"./chunk-2UIHS2FH.js";import"./chunk-Q2F5QB2W.js";import"./chunk-N2P4MI32.js";import"./chunk-NVGBE2DR.js";import"./chunk-TH47OOBV.js";import"./chunk-VAYBKR76.js";import"./chunk-CUM23TLF.js";import"./chunk-DUAXZYAD.js";import"./chunk-DBIBROYW.js";import"./chunk-WXHQYYD5.js";import"./chunk-IAHKTEET.js";import"./chunk-UD7KKHPW.js";import"./chunk-27U4PLPX.js";import"./chunk-UR6MHSHU.js";export{b as REMOTE_PROVIDERS,d as findProvider,a as landingReceipt,c as looksLikeUrl};
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{a,b,c,d}from"./chunk-YRFMPIU2.js";import"./chunk-FNH55WSR.js";import"./chunk-TYLYFERW.js";import"./chunk-MSGW4JDG.js";import"./chunk-TZXXJWHA.js";import"./chunk-4JOD47QI.js";import"./chunk-RZ4F3BHX.js";import"./chunk-27U4PLPX.js";import"./chunk-UR6MHSHU.js";export{d as doctorExitCode,c as doctorPreflightBlocked,b as renderDoctorText,a as runDoctor};
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{a,b,c,d,e,f,g,h,i}from"./chunk-KRKGZ2ZW.js";import"./chunk-2UIHS2FH.js";import"./chunk-Q2F5QB2W.js";import"./chunk-BKHXPBWN.js";import"./chunk-N2P4MI32.js";import"./chunk-NVGBE2DR.js";import"./chunk-IAHKTEET.js";import"./chunk-MSGW4JDG.js";import"./chunk-UR6MHSHU.js";export{a as DOCX_CONVERTER_POLICY,b as DOCX_CONVERTER_VERSION,d as DOCX_IMAGE_CAP,c as DOCX_IMAGE_DIMENSION_FLOOR,f as DOCX_IMAGE_MAX_BYTES,g as DOCX_IMAGE_MAX_PIXELS,e as DOCX_VISION_BYTE_BUDGET,i as convertDocx,h as renderTokens};
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{$ as ha,A as L,B as M,C as N,D as O,E as P,F as Q,J as R,K as S,L as T,M as U,N as V,O as W,P as X,Q as Y,R as Z,S as _,T as $,U as aa,V as ba,W as ca,X as da,Y as ea,Z as fa,_ as ga,a as c,aa as ia,b as d,c as e,d as f,e as g,f as h,g as i,h as j,i as t,j as u,k as v,l as w,m as x,n as y,o as z,p as A,q as B,r as C,s as D,t as E,u as F,v as G,w as H,x as I,y as J,z as K}from"./chunk-ZVHCQMJ6.js";import"./chunk-5DBK6QNS.js";import{a as n,b as o,c as p,e as q,f as r,g as s}from"./chunk-CJJXT5DO.js";import"./chunk-XWKUZJCP.js";import"./chunk-ZPDM6FO7.js";import{a as k,b as l,c as m}from"./chunk-EHN5HTUD.js";import"./chunk-NVGBE2DR.js";import"./chunk-CH273NAE.js";import"./chunk-L5LI2JF4.js";import{a,f as b}from"./chunk-6IA6QMPH.js";import"./chunk-TH47OOBV.js";import"./chunk-VAYBKR76.js";import"./chunk-CUM23TLF.js";import"./chunk-DUAXZYAD.js";import"./chunk-DBIBROYW.js";import"./chunk-WXHQYYD5.js";import"./chunk-IAHKTEET.js";import"./chunk-UD7KKHPW.js";import"./chunk-2KDGIZED.js";import"./chunk-TYLYFERW.js";import"./chunk-MSGW4JDG.js";import"./chunk-4JOD47QI.js";import"./chunk-G7VQCS4J.js";import"./chunk-RZ4F3BHX.js";import"./chunk-27U4PLPX.js";import"./chunk-UR6MHSHU.js";export{P as EvidenceSession,C as appendExecutionPointer,M as assembleExecutionEnv,b as buildEnvironment,j as buildEvidenceRunConfig,i as buildExternalId,z as buildLogsMetaYaml,y as buildResultYaml,t as buildRunYaml,O as createCdpBrowserCapture,u as createRunningPack,v as createRunningPackRoot,H as declareLogsFromDir,J as diagnostics,x as discardPack,ba as ensureAuteurExecution,N as fetchCdpBrowserString,L as finalizeEvidencePack,U as finalizeInlineEvidence,K as finalizeMemberTestLogs,da as flattenAuteurLeafIds,ca as flattenAuteurLeaves,T as inlineEvidenceBlock,q as listPacks,p as newExecutionId,a as normalizeOs,S as noteInlineSpawn,$ as offerEvidenceView,o as packPath,I as packTestLogsDir,V as parseRange,D as readExecutionPointers,ia as readPackLeafIds,ha as readPackLeaves,s as recoverStore,fa as remapReplayActionIds,r as resolvePack,ga as resolveReplayResultSteps,F as rollupTestStatus,aa as runEvidenceMerge,_ as runEvidenceServe,E as runEvidenceValidate,Q as runStartupRecovery,l as sealPack,w as sealPackById,Z as serveHint,f as shortHash,e as slugify,W as startEvidenceLocalServer,R as startInlineEvidence,n as storeDir,m as sweepStore,ea as synthesizeSkippedTail,h as testIdForInline,g as testIdForTestmd,k as validatePack,c as verdictFromResultCode,X as viewerBaseFor,Y as viewerUrlFor,d as worstOf,G as worstResultCode,B as writeLogsMeta,A as writeResult};
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{a,b,c,d,e,f,g}from"./chunk-RLRNLIRS.js";import"./chunk-OS4VSIHT.js";import"./chunk-TRJUD3XJ.js";import"./chunk-JFAFKHDX.js";import"./chunk-JZ26R6UL.js";import"./chunk-DNNZ353O.js";import"./chunk-5DT7PIGB.js";import"./chunk-NVGBE2DR.js";import"./chunk-CH273NAE.js";import"./chunk-TH47OOBV.js";import"./chunk-VAYBKR76.js";import"./chunk-CUM23TLF.js";import"./chunk-DUAXZYAD.js";import"./chunk-DBIBROYW.js";import"./chunk-WXHQYYD5.js";import"./chunk-IAHKTEET.js";import"./chunk-UD7KKHPW.js";import"./chunk-UR6MHSHU.js";export{b as designStateOf,g as evolveCommand,c as evolveOneUc,f as liveRunDesignForUc,a as resolveParentUc,e as runEvolveCommand,d as staleTargets};
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{a,b,c,d,e}from"./chunk-4JOD47QI.js";import"./chunk-UR6MHSHU.js";export{a as DEFAULT_EXEC_TIMEOUT_MS,c as EXEC_SPAWN_FAILURE_CODE,b as EXEC_TIMEOUT_CODE,d as runExec,e as sleep};
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{g as a,h as b,i as c,j as d,k as e,l as f,m as g,n as h,o as i,p as j,q as k,r as l,s as m,t as n,u as o}from"./chunk-56PAQAX5.js";import"./chunk-5EOX4MEY.js";import"./chunk-UR6MHSHU.js";export{o as _reset,i as cleanup,l as clearInkExit,h as deregister,e as getRemoteLogger,b as getSupportContext,n as installHandlers,f as isShuttingDown,d as logOrBufferRemote,g as register,k as setInkExit,c as setRemoteLogger,a as setSupportContext,m as setTerminalRestore,j as shutdown};
@@ -1,3 +1,3 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as x}from"./chunk-7KORP5FF.js";import{b as E}from"./chunk-KHU7C6EE.js";import"./chunk-L5LI2JF4.js";import{A as h}from"./chunk-TH47OOBV.js";import"./chunk-VAYBKR76.js";import"./chunk-CUM23TLF.js";import"./chunk-DUAXZYAD.js";import"./chunk-DBIBROYW.js";import{d,e as g}from"./chunk-WXHQYYD5.js";import"./chunk-IAHKTEET.js";import"./chunk-UD7KKHPW.js";import{a as k}from"./chunk-CH273NAE.js";import"./chunk-UR6MHSHU.js";async function _(f,$={}){let m=$.contextDir??k(process.cwd()),e=$.out??(c=>process.stdout.write(c+`
2
+ import{b as E}from"./chunk-KHU7C6EE.js";import{a as x}from"./chunk-7KORP5FF.js";import{a as k}from"./chunk-CH273NAE.js";import"./chunk-L5LI2JF4.js";import{A as h}from"./chunk-TH47OOBV.js";import"./chunk-VAYBKR76.js";import"./chunk-CUM23TLF.js";import"./chunk-DUAXZYAD.js";import"./chunk-DBIBROYW.js";import{d,e as g}from"./chunk-WXHQYYD5.js";import"./chunk-IAHKTEET.js";import"./chunk-UD7KKHPW.js";import"./chunk-UR6MHSHU.js";async function _(f,$={}){let m=$.contextDir??k(process.cwd()),e=$.out??(c=>process.stdout.write(c+`
3
3
  `)),o=h(m),u=o.resolve(f);if(!u){let c=[...o.names.keys()].filter(n=>/^(t|sc|ac|gap)-/.test(n)).sort();return e(`no design rationale recorded for ${f} (exists: ${c.slice(0,12).join(", ")||"(no designed items)"})`),1}let a=u.tip,s=o.nodeLabel.get(a),r=o.getNode(a),l=o.nameOf.get(a)??a.slice(0,19);if(s===d.TEST){let c=String(r?.content.definitionId??""),n=c?E(m,c):null;if(!n){let i=null;for(let S of o.edgesFrom(a))if(S.type===g.VERIFIES){for(let p of o.edgesFrom(S.dst))if(p.type===g.SCOPED_TO){i=o.nameOf.get(p.dst)??p.dst.slice(0,19);break}if(i)break}return e(`no design rationale recorded for ${f} (exists: test ${l}, but its sidecar is missing \u2014 re-run: kane-cli design tests${i?` --use-case ${i}`:""} --force)`),1}e(`${l} \u2014 ${String(r?.content.title??"")}`),e(`technique: ${n.technique}`),e(`profile family: ${n.profile_family}`),e(`anchored to: ${n.anchor}`),e(`expected how: ${n.expected_how}`),e(`combinatorial: strength ${n.combinatorial.strength} \u2014 ${n.combinatorial.reason}`),e(`surface: ${n.surface_state} \xB7 deferred bindings: ${n.deferred_bindings}`);let t=r?.content.check;t&&e(`check: ${String(t.kind)} ${String(t.operator)} ${String(t.operand??t.within??"")} \u2014 verified against ${String(t.verified_against)}`);for(let i of o.edgesFrom(a))i.type===g.AUTOMATES&&e(`automates: ${o.nameOf.get(i.dst)??i.dst.slice(0,19)}`),i.type===g.VERIFIES&&e(`verifies: ${o.nameOf.get(i.dst)??i.dst.slice(0,19)}`),i.type===g.REUSES&&e(`imports: ${o.nameOf.get(i.dst)??i.dst.slice(0,19)}`);return 0}if(s===d.SCENARIO||s===d.AC||s===d.GAP){let n=x(m,o,f).entries.filter(t=>t.kind==="judgement"||t.kind==="review");if(e(`${l} \u2014 ${String(r?.content.title??r?.content.text??"")}`),s===d.SCENARIO&&(e(`case type: ${String(r?.content.case_type??"")} \xB7 intent: ${String(r?.content.intent??"")}`),e(`technique: ${String(r?.content.technique_notes??"")}`)),s===d.AC){let t=r?.content.expected_answer;e(`kind: ${String(r?.content.kind??"")}${t?` \xB7 oracle: ${String(t.operator)} ${String(t.operand??"")}`:""}`)}n.length===0&&e("(no recorded judgements yet \u2014 approvals and design-time judgements land here)");for(let t of n)e(t.kind==="judgement"?`judgement: ${t.rationale??t.detail}`:`review: ${t.detail}`);return 0}return e(`no design rationale recorded for ${f} (exists: ${s??"nothing"} ${l} \u2014 design explains tests, scenarios, ACs, and gaps)`),1}export{_ as designExplainCommand};
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{b as a}from"./chunk-OS4VSIHT.js";import{a as i}from"./chunk-7KORP5FF.js";import"./chunk-5DT7PIGB.js";import{A as n}from"./chunk-TH47OOBV.js";import"./chunk-VAYBKR76.js";import"./chunk-CUM23TLF.js";import"./chunk-DUAXZYAD.js";import"./chunk-DBIBROYW.js";import"./chunk-WXHQYYD5.js";import"./chunk-IAHKTEET.js";import"./chunk-UD7KKHPW.js";import"./chunk-CH273NAE.js";import"./chunk-UR6MHSHU.js";async function f(s,p){let o=a(process.cwd(),{out:r=>process.stdout.write(r+`
2
+ import{b as a}from"./chunk-OS4VSIHT.js";import{a as i}from"./chunk-7KORP5FF.js";import"./chunk-5DT7PIGB.js";import"./chunk-CH273NAE.js";import{A as n}from"./chunk-TH47OOBV.js";import"./chunk-VAYBKR76.js";import"./chunk-CUM23TLF.js";import"./chunk-DUAXZYAD.js";import"./chunk-DBIBROYW.js";import"./chunk-WXHQYYD5.js";import"./chunk-IAHKTEET.js";import"./chunk-UD7KKHPW.js";import"./chunk-UR6MHSHU.js";async function f(s,p){let o=a(process.cwd(),{out:r=>process.stdout.write(r+`
3
3
  `),err:r=>process.stderr.write(r+`
4
4
  `),confirm:async()=>!1,isTTY:!!process.stdout.isTTY});if(!o)return 2;let c=n(o),t=i(o,c,s);if(p.json)return process.stdout.write(JSON.stringify(t)+`
5
5
  `),t.target?0:1;if(!t.target)return process.stdout.write(`error: ${s} names nothing in the graph
@@ -1,10 +1,10 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{f as Y,g as F}from"./chunk-53IBTIL3.js";import"./chunk-ZMNJBUAO.js";import"./chunk-W5TTF7GB.js";import"./chunk-I7TIGB7K.js";import"./chunk-AJ56AMT6.js";import"./chunk-DZPGG4S6.js";import"./chunk-F7ISS545.js";import"./chunk-7OYZR6JA.js";import"./chunk-JFAFKHDX.js";import"./chunk-BB2W35TW.js";import{c as Q}from"./chunk-YKTYVJBN.js";import"./chunk-IMR64OCZ.js";import"./chunk-427OQS2N.js";import{a as P}from"./chunk-VLWMMOMF.js";import{a as q}from"./chunk-JZ26R6UL.js";import"./chunk-VGFTNLQQ.js";import"./chunk-L2TV4G56.js";import"./chunk-6KPPGMO2.js";import{c as U}from"./chunk-5DT7PIGB.js";import"./chunk-R7QAS6LZ.js";import"./chunk-QOFZSHSC.js";import"./chunk-BKHXPBWN.js";import{d as $}from"./chunk-DBKNJRJG.js";import"./chunk-5FJJJNJK.js";import"./chunk-VMM4LC4V.js";import"./chunk-W4B5LOEX.js";import"./chunk-DNNZ353O.js";import"./chunk-2UIHS2FH.js";import"./chunk-Q2F5QB2W.js";import"./chunk-N2P4MI32.js";import"./chunk-GFKCTYCA.js";import"./chunk-NVGBE2DR.js";import"./chunk-TH47OOBV.js";import"./chunk-VAYBKR76.js";import"./chunk-CUM23TLF.js";import"./chunk-DUAXZYAD.js";import"./chunk-DBIBROYW.js";import"./chunk-WXHQYYD5.js";import"./chunk-IAHKTEET.js";import"./chunk-UD7KKHPW.js";import{a as C}from"./chunk-CH273NAE.js";import{a as M,b as N}from"./chunk-YTHQNN2L.js";import"./chunk-R5T4RLF5.js";import"./chunk-KBM3XHAM.js";import"./chunk-2YEHV2CX.js";import"./chunk-IDX3TOPY.js";import"./chunk-BKM2LWU2.js";import"./chunk-QIGPXYMF.js";import"./chunk-5EOX4MEY.js";import"./chunk-RZ4F3BHX.js";import"./chunk-ZUGCHQFC.js";import"./chunk-UR6MHSHU.js";async function X(r){let[{render:n},s,{QuestionBatchPrompt:p}]=await Promise.all([import("./build-JIKYOZUH.js"),import("./react-QWOAB3TB.js"),import("./ui-JEJGTURD.js")]),m=s.default??s;return new Promise(w=>{let y=n(m.createElement(p,{questions:r,onSubmit:t=>{y.unmount(),w(t)}}))})}async function Z(r,n){let[{render:s},p,{ReviewChecklist:m}]=await Promise.all([import("./build-JIKYOZUH.js"),import("./react-QWOAB3TB.js"),import("./ui-JEJGTURD.js")]),w=p.default??p;return new Promise(y=>{let t=s(w.createElement(m,{items:r.map(x=>{let g=n.get(x.temp_ref);return{uc:x,dedupWith:g&&!g.archived?g.cid:void 0,archivedMatch:g?.archived?{cid:g.cid,reason:g.reason}:void 0}}),onSubmit:x=>{t.unmount(),y(x)}}))})}async function ee(r){let{createInterface:n}=await import("readline/promises"),s=n({input:process.stdin,output:process.stdout});try{let p=await s.question(`${r} [y/N] `);return/^y(es)?$/i.test(p.trim())}finally{s.close()}}async function de(r){let n=C(process.cwd()),s=N({verb:"extract",mode:r.plan?"cli":"interactive",contextRoot:n,env:M(),resumeSid:r.resume,write:!0,longSession:!0}),m={...await $(),...s.spawnEnv()},w=await Q(m);if(!w.ok)return process.stderr.write((w.message??"error: turn-endpoint preflight failed")+`
2
+ import{f as Y,g as F}from"./chunk-V2R3LCA3.js";import"./chunk-ZMNJBUAO.js";import"./chunk-W5TTF7GB.js";import"./chunk-I7TIGB7K.js";import"./chunk-KU6IXFGZ.js";import"./chunk-ZGBSGZZM.js";import"./chunk-65ZTD5SJ.js";import"./chunk-BRHNRCEZ.js";import"./chunk-BB2W35TW.js";import"./chunk-VGFTNLQQ.js";import"./chunk-L2TV4G56.js";import"./chunk-JFAFKHDX.js";import"./chunk-6KPPGMO2.js";import"./chunk-7BZSCUPP.js";import"./chunk-GFKCTYCA.js";import{c as Q}from"./chunk-YKTYVJBN.js";import"./chunk-IMR64OCZ.js";import"./chunk-427OQS2N.js";import{a as P}from"./chunk-QSDH5P7C.js";import{a as q}from"./chunk-JZ26R6UL.js";import"./chunk-W4B5LOEX.js";import"./chunk-DNNZ353O.js";import"./chunk-R7QAS6LZ.js";import"./chunk-KRKGZ2ZW.js";import"./chunk-2UIHS2FH.js";import"./chunk-Q2F5QB2W.js";import"./chunk-BKHXPBWN.js";import"./chunk-N2P4MI32.js";import{e as $}from"./chunk-OMQCD3KR.js";import"./chunk-SDPRO2LE.js";import{c as U}from"./chunk-5DT7PIGB.js";import"./chunk-NVGBE2DR.js";import{a as C}from"./chunk-CH273NAE.js";import{a as M,b as N}from"./chunk-IP2O264K.js";import"./chunk-R5T4RLF5.js";import"./chunk-IDX3TOPY.js";import"./chunk-BKM2LWU2.js";import"./chunk-TH47OOBV.js";import"./chunk-VAYBKR76.js";import"./chunk-CUM23TLF.js";import"./chunk-DUAXZYAD.js";import"./chunk-DBIBROYW.js";import"./chunk-WXHQYYD5.js";import"./chunk-IAHKTEET.js";import"./chunk-UD7KKHPW.js";import"./chunk-KBM3XHAM.js";import"./chunk-2YEHV2CX.js";import"./chunk-MSGW4JDG.js";import"./chunk-56PAQAX5.js";import"./chunk-5EOX4MEY.js";import"./chunk-RZ4F3BHX.js";import"./chunk-27U4PLPX.js";import"./chunk-UR6MHSHU.js";async function X(r){let[{render:n},s,{QuestionBatchPrompt:p}]=await Promise.all([import("./build-JIKYOZUH.js"),import("./react-QWOAB3TB.js"),import("./ui-JEJGTURD.js")]),m=s.default??s;return new Promise(w=>{let y=n(m.createElement(p,{questions:r,onSubmit:t=>{y.unmount(),w(t)}}))})}async function Z(r,n){let[{render:s},p,{ReviewChecklist:m}]=await Promise.all([import("./build-JIKYOZUH.js"),import("./react-QWOAB3TB.js"),import("./ui-JEJGTURD.js")]),w=p.default??p;return new Promise(y=>{let t=s(w.createElement(m,{items:r.map(x=>{let g=n.get(x.temp_ref);return{uc:x,dedupWith:g&&!g.archived?g.cid:void 0,archivedMatch:g?.archived?{cid:g.cid,reason:g.reason}:void 0}}),onSubmit:x=>{t.unmount(),y(x)}}))})}async function ee(r){let{createInterface:n}=await import("readline/promises"),s=n({input:process.stdin,output:process.stdout});try{let p=await s.question(`${r} [y/N] `);return/^y(es)?$/i.test(p.trim())}finally{s.close()}}async function de(r){let n=C(process.cwd()),s=N({verb:"extract",mode:r.plan?"cli":"interactive",contextRoot:n,env:M(),resumeSid:r.resume,write:!0,longSession:!0}),m={...await $(),...s.spawnEnv()},w=await Q(m);if(!w.ok)return process.stderr.write((w.message??"error: turn-endpoint preflight failed")+`
3
3
  `),process.stderr.write(s.supportFooter()+`
4
4
  `),s.error("preflight_auth"),await s.end({exit_code:2}),2;let y=async()=>w;if(r.plan){let i=await F(r,{contextDir:n,agent:P,preflightTurn:y,ask:X,review:Z,confirmStale:ee,out:u=>process.stdout.write(u+`
5
5
  `),progress:u=>process.stderr.write(u+`
6
6
  `),isTTY:U(),auth:m,telemetry:s});return i===1&&process.stderr.write(s.supportFooter()+`
7
- `),await s.end({exit_code:i}),i}let[{render:t},x,{ScrollbackProvider:g},{ChatSurface:c},{ScrollbackTap:E},{makeChatController:V},{setInkExit:T},G]=await Promise.all([import("./build-JIKYOZUH.js"),import("./react-QWOAB3TB.js"),import("./scrollback-JLPJR25X.js"),import("./ChatSurface-E7QKI4LA.js"),import("./ScrollbackTap-Q3IOKNMS.js"),import("./chat-controller-T2FAI55V.js"),import("./exit-manager-XZL4KIJU.js"),Promise.all([import("./chat-committer-UUC6JTRJ.js"),import("./descriptor-OEUZZCOK.js"),import("./explain-UAAQWHYR.js"),import("./readmodel-XOYGGQ3S.js")])]),[{commitChatTurn:S},{topologyDescriptor:e},{explain:a},{openGraph:v}]=G,_=x.default??x,d=V({commitChatTurn:S,descriptor:e(),contextDir:n,refreshGraph:()=>v(n),graph:v(n),explain:a,by:{kind:"human",id:"owner"},dedupFlags:i=>Y(i,v(n))}),j={current:null},H=0,I=null,D=!1,z=()=>{if(H+=1,H>=2){try{A.unmount()}catch{}process.exit(130)}d.requestPause(),I=setTimeout(()=>{D||(D=!0,(async()=>{d.ledger({kind:"interrupted",detail:"the agent did not confirm the pause within 5s"}),await j.current?.flush();try{A.unmount()}catch{}process.exit(130)})())},5e3)},O=await import("./dossier-KTLTGT2X.js"),B=i=>{try{return O.buildDossier(v(n),i)}catch{return null}},L={listUcs:()=>{let i=v(n),u=new Set(d.state.turns.flatMap(o=>(o.items??[]).map(l=>l.title.toLowerCase()))),f={high:0,med:1,low:2};return i.byLabel("usecase").filter(o=>!i.superseded.has(o.cid)).map((o,l)=>{let h=o.content,b=String(h.title??o.cid.slice(0,12)),k=q(i,o.cid),R=k?k.designed_at_cid===o.cid?"current":"stale":void 0;return{key:o.cid,title:b,badge:R==="current"?"designed":R==="stale"?"designed \xB7 stale":u.has(b.toLowerCase())?"drafted this session":"existing",designed:R,risk:h.risk,i:l}}).sort((o,l)=>(f[o.risk??"zz"]??3)-(f[l.risk??"zz"]??3)||o.i-l.i).map(({key:o,title:l,badge:h,designed:b})=>({key:o,title:l,badge:h,designed:b}))},runDesignChild:async(i,u=!1)=>{try{let{designEntryCheck:h,confirmUnreviewedViaAsk:b}=await import("./trust-gate-EX7R2P4Y.js"),k=h(v(n),i);if(!k.ok&&(k.code==="UC_UNREVIEWED"||k.code==="UC_ARCHIVED")&&!await b(K=>d.ask(K),k))return d.note(`design child refused \u2014 approve it first: ${k.reviewCmd}`),2}catch{}let[{runDesign:f}]=await Promise.all([import("./run-GMZCDRDD.js")]),o="",l=await f({useCase:i,force:u,mode:"interactive"},{contextDir:n,agent:P,preflightTurn:y,ask:h=>d.ask(h),chat:d,nested:!0,out:h=>{o=h},progress:()=>{},isTTY:!0,auth:m});return l!==0&&o&&d.note(o),l}},{makeReconcileDeps:W}=await import("./reconcile-deps-HTT6IPHT.js"),J=W({contextDir:n,...r.changeContext?{changeContext:r.changeContext}:{},note:i=>d.note(i)}),A=t(_.createElement(g,null,_.createElement(E,{into:j}),_.createElement(c,{controller:d,verb:"extract",onCtrlC:z,chain:L,inspect:B,reconcile:J})),{exitOnCtrlC:!1});T(()=>A.unmount()),d.ledger({kind:"banner",text:"kane-cli context \xB7 extract \xB7 interactive"});try{let i=F(r,{contextDir:n,agent:P,preflightTurn:y,ask:f=>d.ask(f),review:async f=>new Map(f.map(o=>[o.temp_ref,{resolution:"skipped"}])),confirmStale:async()=>!0,out:f=>d.note(f),progress:()=>{},isTTY:U(),auth:m,chat:d,telemetry:s});i.finally(()=>{D=!0});let u=await i;return u===1&&process.stderr.write(s.supportFooter()+`
8
- `),await s.end({exit_code:u}),u}finally{D=!0,I&&clearTimeout(I),await j.current?.flush();try{A.unmount()}catch{}}}async function ue(r){let n=N({verb:"extract",mode:r.mode,contextRoot:C(process.cwd()),env:M(),resumeSid:r.resume,write:!0,longSession:!0}),{makeHeadlessIO:s,resolveEncoding:p,guardedChannels:m}=await import("./headless-io-66RG5NN5.js"),{withStructuredNext:w,prepareStructuredResume:y}=await import("./structured-answers-A43Q25CZ.js"),t=w(s(p(r.mode),"extract")),{runWithChannel:x}=await import("./run-channel-RGH4WIQX.js"),g=p(r.mode)==="ndjson"?e=>x({event:a=>t.event(a)},e):e=>e();for(let e of r.landed??[]){let a=e;t.event({type:"ingested",source_id:e.source_id,status:e.status,cid:e.source_cid,...a.warnings?.length?{warnings:a.warnings}:{},...a.media?{media:a.media}:{},...a.duplicate_of?{duplicate_of:a.duplicate_of}:{},...a.lineage_candidate?{lineage_candidate:a.lineage_candidate}:{}})}let c;try{c=y({opts:r,contextDir:C(process.cwd()),verb:"extract"})}catch(e){let a=e instanceof Error?e.message:String(e);return t.out(`error: ${a}`),r.mode==="agent"&&t.event({type:"error",message:a}),await n.end({exit_code:1}),r.mode==="agent"?t.done(1,"error"):1}if(c.kind==="refuse")return t.out(c.error),r.mode==="agent"&&t.event({type:"error",message:c.error,code:c.code}),await n.end({exit_code:2}),r.mode==="agent"?t.done(2,"refused"):2;let E=r;if(c.kind==="apply"){for(let e of c.notes)t.out(e);if(c.matchedQids.length>0){t.out(`applying ${c.matchedQids.length} structured answer(s) from --answer to the paused session's pending questions`);for(let e of c.matchedQids)t.event({type:"panel_resolved",id:e,by:"user",via:"flag"})}c.statement&&(E={...r,message:[r.message,c.statement].filter(Boolean).join(`
7
+ `),await s.end({exit_code:i}),i}let[{render:t},x,{ScrollbackProvider:g},{ChatSurface:c},{ScrollbackTap:E},{makeChatController:V},{setInkExit:T},G]=await Promise.all([import("./build-JIKYOZUH.js"),import("./react-QWOAB3TB.js"),import("./scrollback-JLPJR25X.js"),import("./ChatSurface-U37VZDCW.js"),import("./ScrollbackTap-Q3IOKNMS.js"),import("./chat-controller-T2FAI55V.js"),import("./exit-manager-3FVBTNYR.js"),Promise.all([import("./chat-committer-ZWWCLJFD.js"),import("./descriptor-OEUZZCOK.js"),import("./explain-UAAQWHYR.js"),import("./readmodel-XOYGGQ3S.js")])]),[{commitChatTurn:S},{topologyDescriptor:e},{explain:a},{openGraph:v}]=G,_=x.default??x,d=V({commitChatTurn:S,descriptor:e(),contextDir:n,refreshGraph:()=>v(n),graph:v(n),explain:a,by:{kind:"human",id:"owner"},dedupFlags:i=>Y(i,v(n))}),j={current:null},H=0,I=null,D=!1,z=()=>{if(H+=1,H>=2){try{A.unmount()}catch{}process.exit(130)}d.requestPause(),I=setTimeout(()=>{D||(D=!0,(async()=>{d.ledger({kind:"interrupted",detail:"the agent did not confirm the pause within 5s"}),await j.current?.flush();try{A.unmount()}catch{}process.exit(130)})())},5e3)},O=await import("./dossier-KTLTGT2X.js"),B=i=>{try{return O.buildDossier(v(n),i)}catch{return null}},L={listUcs:()=>{let i=v(n),u=new Set(d.state.turns.flatMap(o=>(o.items??[]).map(l=>l.title.toLowerCase()))),f={high:0,med:1,low:2};return i.byLabel("usecase").filter(o=>!i.superseded.has(o.cid)).map((o,l)=>{let h=o.content,b=String(h.title??o.cid.slice(0,12)),k=q(i,o.cid),R=k?k.designed_at_cid===o.cid?"current":"stale":void 0;return{key:o.cid,title:b,badge:R==="current"?"designed":R==="stale"?"designed \xB7 stale":u.has(b.toLowerCase())?"drafted this session":"existing",designed:R,risk:h.risk,i:l}}).sort((o,l)=>(f[o.risk??"zz"]??3)-(f[l.risk??"zz"]??3)||o.i-l.i).map(({key:o,title:l,badge:h,designed:b})=>({key:o,title:l,badge:h,designed:b}))},runDesignChild:async(i,u=!1)=>{try{let{designEntryCheck:h,confirmUnreviewedViaAsk:b}=await import("./trust-gate-EX7R2P4Y.js"),k=h(v(n),i);if(!k.ok&&(k.code==="UC_UNREVIEWED"||k.code==="UC_ARCHIVED")&&!await b(K=>d.ask(K),k))return d.note(`design child refused \u2014 approve it first: ${k.reviewCmd}`),2}catch{}let[{runDesign:f}]=await Promise.all([import("./run-2COODVX2.js")]),o="",l=await f({useCase:i,force:u,mode:"interactive"},{contextDir:n,agent:P,preflightTurn:y,ask:h=>d.ask(h),chat:d,nested:!0,out:h=>{o=h},progress:()=>{},isTTY:!0,auth:m});return l!==0&&o&&d.note(o),l}},{makeReconcileDeps:W}=await import("./reconcile-deps-XIH75ZLY.js"),J=W({contextDir:n,...r.changeContext?{changeContext:r.changeContext}:{},note:i=>d.note(i)}),A=t(_.createElement(g,null,_.createElement(E,{into:j}),_.createElement(c,{controller:d,verb:"extract",onCtrlC:z,chain:L,inspect:B,reconcile:J})),{exitOnCtrlC:!1});T(()=>A.unmount()),d.ledger({kind:"banner",text:"kane-cli context \xB7 extract \xB7 interactive"});try{let i=F(r,{contextDir:n,agent:P,preflightTurn:y,ask:f=>d.ask(f),review:async f=>new Map(f.map(o=>[o.temp_ref,{resolution:"skipped"}])),confirmStale:async()=>!0,out:f=>d.note(f),progress:()=>{},isTTY:U(),auth:m,chat:d,telemetry:s});i.finally(()=>{D=!0});let u=await i;return u===1&&process.stderr.write(s.supportFooter()+`
8
+ `),await s.end({exit_code:u}),u}finally{D=!0,I&&clearTimeout(I),await j.current?.flush();try{A.unmount()}catch{}}}async function ue(r){let n=N({verb:"extract",mode:r.mode,contextRoot:C(process.cwd()),env:M(),resumeSid:r.resume,write:!0,longSession:!0}),{makeHeadlessIO:s,resolveEncoding:p,guardedChannels:m}=await import("./headless-io-66RG5NN5.js"),{withStructuredNext:w,prepareStructuredResume:y}=await import("./structured-answers-5EY2AZN7.js"),t=w(s(p(r.mode),"extract")),{runWithChannel:x}=await import("./run-channel-RGH4WIQX.js"),g=p(r.mode)==="ndjson"?e=>x({event:a=>t.event(a)},e):e=>e();for(let e of r.landed??[]){let a=e;t.event({type:"ingested",source_id:e.source_id,status:e.status,cid:e.source_cid,...a.warnings?.length?{warnings:a.warnings}:{},...a.media?{media:a.media}:{},...a.duplicate_of?{duplicate_of:a.duplicate_of}:{},...a.lineage_candidate?{lineage_candidate:a.lineage_candidate}:{}})}let c;try{c=y({opts:r,contextDir:C(process.cwd()),verb:"extract"})}catch(e){let a=e instanceof Error?e.message:String(e);return t.out(`error: ${a}`),r.mode==="agent"&&t.event({type:"error",message:a}),await n.end({exit_code:1}),r.mode==="agent"?t.done(1,"error"):1}if(c.kind==="refuse")return t.out(c.error),r.mode==="agent"&&t.event({type:"error",message:c.error,code:c.code}),await n.end({exit_code:2}),r.mode==="agent"?t.done(2,"refused"):2;let E=r;if(c.kind==="apply"){for(let e of c.notes)t.out(e);if(c.matchedQids.length>0){t.out(`applying ${c.matchedQids.length} structured answer(s) from --answer to the paused session's pending questions`);for(let e of c.matchedQids)t.event({type:"panel_resolved",id:e,by:"user",via:"flag"})}c.statement&&(E={...r,message:[r.message,c.statement].filter(Boolean).join(`
9
9
 
10
10
  `)})}let{makeInterruptGuard:V}=await import("./interrupt-guard-UREUWNRL.js"),T=V(P,e=>t.out(e)),S=m(t,()=>T.interrupted(),/^error: (agent failed|repair run failed|agent ended)/);try{let e=await g(async()=>{let a={...await $(),...n.spawnEnv()};return F(E,{contextDir:C(process.cwd()),agent:T.agent,preflightTurn:()=>Q(a),ask:async()=>[],review:async v=>new Map(v.map(_=>[_.temp_ref,{resolution:"skipped"}])),confirmStale:async()=>!1,out:S.out,emit:S.emit,progress:t.progress,isTTY:!1,auth:a,telemetry:n})});return T.interrupted()&&e!==3?(t.out("interrupted \u2014 no session saved"),await n.end({exit_code:130}),t.done(130)):(e===1&&t.out(n.supportFooter()),await n.end({exit_code:e}),t.done(e))}catch(e){return t.event({type:"error",message:`error: extract failed: ${e instanceof Error?e.message:String(e)}`}),t.out(`error: extract failed: ${e instanceof Error?e.message:String(e)}`),t.out('hint: the full trace is in the file named on the "trace:" line at the start of this run'),t.done(1)}finally{T.dispose()}}export{ue as bindExtractHeadless,de as bindExtractInteractive};
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
2
  import{a as i}from"./chunk-CH273NAE.js";import"./chunk-UR6MHSHU.js";import{existsSync as u}from"fs";async function g(e){if(e.mode!=null&&!["interactive","agent","ci","override"].includes(e.mode)){let{makeHeadlessIO:t,agentRefusal:r}=await import("./headless-io-66RG5NN5.js");return r(t("ndjson","extract"),`extract: --mode must be interactive | agent | ci | override, got '${e.mode}'`,"MODE_USAGE")}let n=async(t,r)=>{if(e.mode!=="agent")return process.stderr.write(t+`
3
- `),2;let{makeHeadlessIO:o,agentRefusal:c}=await import("./headless-io-66RG5NN5.js");return c(o("ndjson","extract"),t,r)};if(e.apply)return n("extract: --apply is not implemented yet \u2014 coming with the plan\u2192apply workflow (run without --apply, or use --plan to preview)");{let{validateResumeMessage:t}=await import("./headless-io-66RG5NN5.js"),r=t(e,"extract");if(r)return n(r)}{let{gateStructuredFlags:t}=await import("./structured-answers-A43Q25CZ.js"),r=t(e,"extract");if(r)return n(r,"STRUCTURED_FLAGS_USAGE")}if(e.withSource&&!e.resume)return n("extract: --with-source pairs with --resume \u2014 it lands the source and sets the resumed session's pending questions aside");if(e.queued)return n("extract: --queued is gone \u2014 extract sweeps every pending source by default (just run kane-cli context extract)");if(!u(i(process.cwd())))return n("error: no context store here (run `kane-cli context ingest <files>` first)","NO_STORE");if(!e.mode&&!process.stdin.isTTY)return process.stderr.write(`extract: no TTY \u2014 pass an explicit --mode agent|ci|override to run headless
3
+ `),2;let{makeHeadlessIO:o,agentRefusal:c}=await import("./headless-io-66RG5NN5.js");return c(o("ndjson","extract"),t,r)};if(e.apply)return n("extract: --apply is not implemented yet \u2014 coming with the plan\u2192apply workflow (run without --apply, or use --plan to preview)");{let{validateResumeMessage:t}=await import("./headless-io-66RG5NN5.js"),r=t(e,"extract");if(r)return n(r)}{let{gateStructuredFlags:t}=await import("./structured-answers-5EY2AZN7.js"),r=t(e,"extract");if(r)return n(r,"STRUCTURED_FLAGS_USAGE")}if(e.withSource&&!e.resume)return n("extract: --with-source pairs with --resume \u2014 it lands the source and sets the resumed session's pending questions aside");if(e.queued)return n("extract: --queued is gone \u2014 extract sweeps every pending source by default (just run kane-cli context extract)");if(!u(i(process.cwd())))return n("error: no context store here (run `kane-cli context ingest <files>` first)","NO_STORE");if(!e.mode&&!process.stdin.isTTY)return process.stderr.write(`extract: no TTY \u2014 pass an explicit --mode agent|ci|override to run headless
4
4
  `),2;let s=e.mode??"interactive";if(s==="interactive"){if(!process.stdin.isTTY||!process.stdout.isTTY)return process.stderr.write(`extract: --mode interactive needs a TTY on stdin and stdout (use --mode agent|ci|override headless)
5
- `),2;let{bindExtractInteractive:t}=await import("./extract-bind-5OWELRME.js");return t(e)}let{bindExtractHeadless:a}=await import("./extract-bind-5OWELRME.js");return a({...e,mode:s})}export{g as extractCommand};
5
+ `),2;let{bindExtractInteractive:t}=await import("./extract-bind-LLEASZAK.js");return t(e)}let{bindExtractHeadless:a}=await import("./extract-bind-LLEASZAK.js");return a({...e,mode:s})}export{g as extractCommand};
@@ -1,3 +1,3 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as R,b as H,d as ae}from"./chunk-OS4VSIHT.js";import{a as ie,b as ce}from"./chunk-IOD3HQVW.js";import"./chunk-5DT7PIGB.js";import{a as ee,b as te,c as ne,d as se,e as re,f as oe}from"./chunk-5DBK6QNS.js";import{e as X,f as J}from"./chunk-CJJXT5DO.js";import{a as C,b as Z,c as F,d as q}from"./chunk-XWKUZJCP.js";import"./chunk-ZPDM6FO7.js";import{e as Q}from"./chunk-EHN5HTUD.js";import{a as W}from"./chunk-L5LI2JF4.js";import{A as K}from"./chunk-TH47OOBV.js";import"./chunk-VAYBKR76.js";import"./chunk-CUM23TLF.js";import"./chunk-DUAXZYAD.js";import"./chunk-DBIBROYW.js";import{d as G,e as M}from"./chunk-WXHQYYD5.js";import"./chunk-IAHKTEET.js";import"./chunk-UD7KKHPW.js";import"./chunk-CH273NAE.js";import"./chunk-UR6MHSHU.js";import{basename as B}from"path";import{statSync as Se}from"fs";function ye(e,t){return e.length===0?"not_run":ne(e,t).verified?"proven":te(e,t).some(n=>n.verdict==="failed")?"failing":"blocked"}function le(e,t){let s=null;for(let{cid:f}of e.byLabel(G.TEST))for(let o of e.execHistory(f))(!s||String(o.started_at)>s.started_at)&&(s={execution_id:String(o.execution_id),started_at:String(o.started_at)});if(!s)return null;let n=ee[t],r=oe(e),c=se(r).aspects[t],i={},d={},l=0,g=0,a=0;for(let f of r.usecases){let o=[];for(let b of f.acceptance_criteria){let u=b.executions??[],_=ye(u,n);o.push(_),_==="failing"?l++:_==="blocked"?g++:_==="not_run"&&a++;let S=[],k;if(_==="failing"){let w=null;for(let O of b.covered_by){let T=e.execHistory(O).map($=>({verdict:String($.per_ac?.find(y=>y.ac_ref===b.id)?.verdict??$.verdict),oracle_mode:String($.oracle_mode),ts:String($.started_at),execution_id:String($.execution_id)})).filter($=>n.counted_verdicts.includes($.verdict)&&n.accepted_oracle_modes.includes($.oracle_mode)),I=T[T.length-1];I?.verdict==="failed"&&(S.push(O),(!w||I.ts>w.ts)&&(w={ts:I.ts,execution_id:I.execution_id}))}k=w?.execution_id}else _==="blocked"&&(k=u[u.length-1]?.execution_id);i[b.id]={state:_,viaTests:S,...k?{executionId:k}:{}}}let m=o.some(b=>b!=="not_run"),p=c.usecases[f.id],v=m?p.status==="covered"?"proven":p.status==="partial"?"partial":o.includes("failing")?"failing":o.includes("blocked")?"blocked":"not_run":"not_run";d[f.id]={pct:p.pct,status:v}}return{aspect:t,pct:c.summary.coverage_pct,acs_proven:c.summary.acs_verified,failing:l,blocked:g,not_run:a,latest_run:s,perUc:d,perAc:i,config:{...n,source:"graph_execution_facts",denominator:"current_live_acs"}}}var be=["failing","blocked","needs-refresh","needs-tests","needs-scenarios","happy-only","possible-duplicate","not-yet-run"],_e={failing:"failing",blocked:"blocked","needs-refresh":"needs refresh","needs-tests":"needs tests","needs-scenarios":"needs scenarios","happy-only":"happy path only","possible-duplicate":"possible duplicate","not-yet-run":"not yet run"},E={high:0,med:1,low:2};function Y(e,t){let s=/^(.*?)(\d+)$/.exec(e),n=/^(.*?)(\d+)$/.exec(t);return s&&n&&s[1]===n[1]?Number(s[2])-Number(n[2]):e<t?-1:e>t?1:0}function D(e){if(!e||/^sha256:/.test(e))return"(unnamed)";let t=/^(uc|ac|sc|t)-(\d+)$/.exec(e);return t?`${t[1].toUpperCase()}-${t[2]}`:e}function fe(e,t=5){let s=e.trim().split(/\s+/);return s.slice(0,t).join(" ")+(s.length>t?"\u2026":"")}function ke(e,t){let s=e.resolve(t),n=s?e.getNode(e.tipOf(s.cid))?.content:null;return String(n?.title??n?.text??"")}function ue(e,t){let s=e.resolve(t);return{id:s?e.displayNameOf(e.tipOf(s.cid))??e.displayNameOf(s.cid):null,title:fe(ke(e,t),8)}}function $e(e,t){let s=e.resolve(t);if(!s)return null;let n=e.tipOf(s.cid);if(!C(e,n))return null;let r=e.nodeLabel.get(n);if(r===G.USECASE)return n;if(r===G.AC)return F(e,n);if(r===G.TEST){let c=e.edgesFrom(n).find(d=>d.type===M.VERIFIES&&C(e,d.dst));if(c)return F(e,c.dst);let i=e.edgesFrom(n).find(d=>d.type===M.AUTOMATES&&C(e,d.dst));if(i){let d=e.edgesFrom(i.dst).find(l=>l.type===M.BELONGS_TO&&C(e,l.dst));return d?d.dst:null}}return null}function j(e){if(e.tag==="reuse-candidate"&&e.stage==="design")return"possible-duplicate";switch(e.kind){case"no-verifies":return"needs-tests";case"zero-scenario":return"needs-scenarios";case"happy-only":return"happy-only";case"stale-ac":case"stale-test":return"needs-refresh";case"execution-failed":return"failing";case"execution-blocked":return"blocked";case"covered-not-run":return"not-yet-run";default:return"other"}}function xe(e,t){let s=e.resolve(t),n=s?e.getNode(e.tipOf(s.cid))?.content.risk:null;return n==="high"||n==="med"||n==="low"?n:"med"}function ge(e,t,s,n,r){let c=r.servePaths??new Map,i=e.byLabel(G.USECASE).filter(({cid:o})=>C(e,o)),d=new Map(i.map(o=>[o.cid,o])),l=new Map(i.map(({cid:o})=>[o,[]])),g=[];for(let o of t){if(o.stage!=="design")continue;let m={...o,...ue(e,o.ref)},p=$e(e,o.ref),v=p?l.get(p):void 0;v&&j(o)!=="other"?v.push(m):g.push(m)}let a=new Map(i.map(({cid:o})=>[o,{total:0,designed:0}]));for(let{cid:o}of e.byLabel(G.AC)){if(!C(e,o))continue;let m=F(e,o),p=m?a.get(m):void 0;if(!p)continue;p.total++;let v=Z(e,o);if(v&&p.designed++,!n)continue;let b=e.nameOf.get(o)??o,u=n.perAc[b];if(!u)continue;let{id:_,title:S}=ue(e,b),k={ref:e.displayNameOf(o)??o,id:_,title:S,risk:xe(e,b),stage:"cover"},w=l.get(m);u.state==="failing"?w.push({...k,kind:"execution-failed",tag:"evolve",why:"covering test failed against this AC",ready_command:u.executionId&&c.has(u.executionId)?`kane-cli evidence serve ${c.get(u.executionId)}`:"kane-cli testrun run",via_tests:u.viaTests,...u.executionId?{execution_id:u.executionId}:{},...u.executionId&&c.has(u.executionId)?{servePath:c.get(u.executionId)}:{},...r.testFiles?{viaFiles:u.viaTests.map(O=>r.testFiles.get(O)??null)}:{}}):u.state==="blocked"?w.push({...k,kind:"execution-blocked",tag:"reuse-candidate",why:"the formula could count no run \u2014 broken/skipped or an unaccepted oracle",ready_command:u.executionId&&c.has(u.executionId)?`kane-cli evidence serve ${c.get(u.executionId)}`:"kane-cli testrun run",...u.executionId?{execution_id:u.executionId}:{},...u.executionId&&c.has(u.executionId)?{servePath:c.get(u.executionId)}:{}}):u.state==="not_run"&&v&&w.push({...k,kind:"covered-not-run",tag:"reuse-candidate",why:"a covering test exists but has not run yet",ready_command:"kane-cli testrun run"})}let f=[];for(let{cid:o,content:m}of i){let p=e.displayNameOf(o)??o,v=e.nameOf.get(o)??o,b=s.perUc[p]??{pct:0,status:"undesigned",staleAcs:0},u=n?n.perUc[v]??{pct:0,status:"not_run"}:null,_=n!==null&&(u===null||u.status==="not_run"),S=a.get(o),k=l.get(o)??[],w=new Set(k.filter(h=>j(h)==="needs-refresh").map(h=>h.ref)),O=k.some(h=>j(h)==="needs-tests"&&w.has(h.ref)),T=[];for(let h of be){let A=k.filter(P=>j(P)===h);if(h==="needs-tests"&&(A=A.filter(P=>!w.has(P.ref))),A.length===0)continue;A.sort((P,V)=>(E[P.risk]??3)-(E[V.risk]??3)||Y(P.ref,V.ref));let ve=h==="failing"||h==="blocked"||A.length<=2||new Set(A.map(P=>P.ready_command)).size>1;T.push({key:h,label:_e[h],...h==="needs-refresh"?{suffix:"source moved since these were designed"}:{},alsoNeedsTests:h==="needs-refresh"&&O,rows:A,...ve?{}:{rosterCommand:A[0].ready_command}})}let I=T.some(h=>h.key==="failing"),$=T.some(h=>h.key==="blocked"),y=b.pct===100&&(n===null||u?.pct===100)&&T.length===0,U=u!==null&&u.pct>0,x=I?"\u2717":$?"\u23F8":y?"\u2714":b.pct===0&&!U?"\u2716":"\u25D0";f.push({slug:p,title:String(m.title??""),risk:String(m.risk??""),des:b,prov:u,provAbsent:_,acTotal:S.total,acDesigned:S.designed,mark:x,collapse:y,groups:T})}return f.sort((o,m)=>(E[o.risk]??3)-(E[m.risk]??3)||Y(o.slug,m.slug)),g.sort((o,m)=>(E[o.risk]??3)-(E[m.risk]??3)||Y(o.ref,m.ref)),{stage:r.stage,aspect:r.aspect,top:r.top,dc:s,pa:n,ucs:f,other:g}}function N(e,t){let s=Math.round(e/100*t);return"\u2588".repeat(s)+"\u2591".repeat(t-s)}function z(e){return e===100?"\u2714":e>0?"\u25D0":"\u2716"}function L(e,t){return e==="all"||t.stage===e}function me(e,t){let{dc:s,pa:n}=e,r=Math.max(80,Math.min(t.width,120)),c=l=>t.color?`\x1B[2m${l}\x1B[22m`:l,i=[];if(n){i.push(`coverage \u2014 designed \xD7 proven \xB7 live graph \xB7 aspect ${n.aspect}`),i.push("");let l=s.ucs_needing_scenarios;i.push(` designed ${z(s.pct)} ${N(s.pct,10)} ${String(s.pct).padStart(3)}% \u2014 ${s.acs_designed} ACs have verifying tests`+(l>0?` \xB7 scenario debt: ${l} UC${l>1?"s":""}`:""));let g=[n.failing>0?`${n.failing} failing`:null,n.blocked>0?`${n.blocked} blocked`:null,n.not_run>0?`${n.not_run} not yet run`:null].filter(Boolean);i.push(` proven ${z(n.pct)} ${N(n.pct,10)} ${String(n.pct).padStart(3)}% \u2014 ${n.acs_proven} proven by execution`+(g.length?` \xB7 ${g.join(" \xB7 ")}`:""))}else i.push("AC design completeness \u2014 live graph (what design owes; execution proof not shown)"),i.push(""),i.push(` designed ${z(s.pct)} ${N(s.pct,10)} ${String(s.pct).padStart(3)}% \u2014 ${s.acs_designed} ACs have verifying tests \xB7 ${s.usecases_complete} UCs complete`),s.ucs_needing_scenarios>0&&i.push(` scenario debt: ${s.ucs_needing_scenarios} use-case${s.ucs_needing_scenarios>1?"s":""} need scenarios`),i.push(" proven \u2014 no runs recorded yet \xB7 run tests, then re-run");i.push("");let d=!1;for(let l of e.ucs){if(i.push(we(l,n!==null,r)),l.collapse)continue;let g=e.top??1/0;for(let a of l.groups){let f=a.rows.filter(v=>L(e.stage,v));if(f.length===0)continue;if(d=!0,g<=0){i.push(c(` \u2026 +${f.length} more ${a.label}`));continue}let o=f.slice(0,g),m=f.length-o.length;if(g-=o.length,(a.key==="needs-scenarios"||a.key==="happy-only")&&o.length===1&&o[0].ref===l.slug){i.push(` ${a.label}${a.key==="needs-scenarios"?" \u2014 design from scratch":""}`),i.push(c(` \u2192 ${o[0].ready_command}`));continue}let p=(a.suffix?` \u2014 ${a.suffix}`:"")+(a.alsoNeedsTests?" \u2014 also needs tests":"");if(i.push(` ${a.label} (${f.length})${p}`),a.rosterCommand&&a.key!=="failing"&&a.key!=="blocked")Re(i,o,r),i.push(c(` \u2192 ${a.rosterCommand}`));else for(let v of o)Te(i,v,a.key,c);m>0&&i.push(c(` \u2026 +${m} more ${a.label}`))}}return!d&&e.ucs.every(l=>l.groups.every(g=>g.rows.filter(a=>L(e.stage,a)).length===0))&&i.push(" nothing owed \u2014 design and execution are square"),i.push(""),i.push(c(" metric: live verifies edges \xB7 high \xD73 \xB7 staleness shown, not discounted")),n?i.push(c(` proven: graph execution facts \xB7 latest run ${n.latest_run?.started_at??"\u2014"} \xB7 ${n.aspect} formula verbatim`)):i.push(c(" proof: no runs recorded yet \u2014 run tests, then re-run")),i}function we(e,t,s){let n=D(e.slug);if(!t){let l=e.acTotal===0?"no scenarios yet":e.collapse||e.des.status==="complete"?`${e.acTotal} ACs \xB7 complete`:e.des.staleAcs>0?`${e.acTotal} ACs \xB7 ${e.des.staleAcs} stale`:`${e.acTotal} ACs \xB7 ${e.acTotal-e.acDesigned} unverified`,g=` ${e.mark} ${N(e.des.pct,10)} ${String(e.des.pct).padStart(3)}% ${n} `,a=Math.max(0,s-g.length-l.length-2);return`${g}${de(e.title,a).padEnd(a)} ${l}`}let r=e.provAbsent?"prov \xB7 not run":`prov ${N(e.prov?.pct??0,8)} ${String(e.prov?.pct??0).padStart(3)}%`,c=`des ${N(e.des.pct,8)} ${String(e.des.pct).padStart(3)}% \xB7 ${r}`,i=` ${e.mark} ${n} `,d=Math.max(0,s-i.length-c.length-2);return`${i}${de(e.title,d).padEnd(d)} ${c}`}function de(e,t){return e.length<=t?e:t<=1?e.slice(0,t):e.slice(0,t-1)+"\u2026"}function Te(e,t,s,n){let r=D(t.id??t.ref);if(s==="failing"){let c=(t.via_tests??[]).map((d,l)=>`${D(d)}${t.viaFiles?.[l]?` ${t.viaFiles[l]}`:""}`).join(", ");e.push(` \u2717 ${r} ${t.title} \u2014 failed${c?` \xB7 via ${c}`:""}`),t.servePath&&e.push(n(` \u2192 kane-cli evidence serve ${t.servePath} (see why it failed)`));let i=(t.viaFiles??[]).filter(d=>d!==null);i.length===1?e.push(n(` re-run after fixing: kane-cli testmd run ${i[0]} (heals on failure \u2014 fix the app first, or the test may re-author)`)):i.length>1&&e.push(n(" re-run after fixing: kane-cli testrun run (heals on failure \u2014 fix the app first, or the tests may re-author)"));return}if(s==="blocked"){e.push(` \u23F8 ${r} ${t.title} \u2014 (blocked \u2014 see why)`),t.servePath&&e.push(n(` \u2192 kane-cli evidence serve ${t.servePath} (see why)`));return}e.push(` ${r} ${t.title} \u2014 ${t.why}`),e.push(n(` \u2192 ${t.ready_command}`))}function Re(e,t,s){let n=t.map(c=>`${D(c.id??c.ref)} ${fe(c.title,4)}`),r=" ";for(let c of n){let i=r.trim().length?" \xB7 ":"";r.length+i.length+c.length>s&&r.trim().length?(e.push(r),r=" "+c):r+=i+c}r.trim().length&&e.push(r)}function he(e){let{dc:t,pa:s}=e,n=r=>e.top!==void 0?r.slice(0,e.top):r;return{stage:e.stage,rollup_version:1,design_completeness:{pct:t.pct,acs_designed:t.acs_designed,usecases_complete:t.usecases_complete,ucs_needing_scenarios:t.ucs_needing_scenarios,config:t.config},...s?{proven:{aspect:s.aspect,pct:s.pct,acs_proven:s.acs_proven,failing:s.failing,blocked:s.blocked,not_run:s.not_run,latest_run:s.latest_run,config:s.config}}:{},usecases:e.ucs.map(r=>({id:/^sha256:/.test(r.slug)?null:r.slug,title:r.title,risk:r.risk,design_completeness:{pct:r.des.pct,status:r.des.status},stale_acs:r.des.staleAcs,...s?{proven:r.prov??{pct:0,status:"not_run"}}:{},pending:n(r.groups.flatMap(c=>c.rows).filter(c=>L(e.stage,c))).map(pe)})),other:e.other.filter(r=>L(e.stage,r)).map(pe)}}function pe(e){let{servePath:t,viaFiles:s,meta:n,...r}=e;return{...r}}async function Ae(e){let t=await X(e);return t.length===0?null:t.map(s=>({p:s,m:Se(s).mtimeMs})).sort((s,n)=>n.m-s.m)[0].p}async function Oe(e,t=ae(),s=process.cwd()){if(e.mode!==void 0&&e.mode!=="agent"&&e.mode!=="ci"&&e.mode!=="interactive")return R(t,`--mode must be interactive | agent | ci, got '${e.mode}'`),2;if(e.mode==="agent"||e.mode==="ci"){let{makeHeadlessIO:p,agentRefusal:v}=await import("./headless-io-66RG5NN5.js"),{parsesAgainstGrammar:b}=await import("./next-TRSKMBO5.js"),u=p("ndjson","gaps",{stdout:y=>t.out(y.replace(/\n$/,"")),stderr:y=>(t.err??t.out)(y.replace(/\n$/,""))}),_=[],S=[],k={out:y=>_.push(y),err:y=>S.push(y),confirm:async()=>!1,isTTY:!1};if(await Oe({...e,json:!0,mode:void 0},k,s)!==0)return v(u,S.join("; ")||"cover gaps refused");let O=JSON.parse(_.join(`
2
+ import{a as ie,b as ce}from"./chunk-IOD3HQVW.js";import{a as R,b as H,d as ae}from"./chunk-OS4VSIHT.js";import"./chunk-5DT7PIGB.js";import{a as ee,b as te,c as ne,d as se,e as re,f as oe}from"./chunk-5DBK6QNS.js";import{e as X,f as J}from"./chunk-CJJXT5DO.js";import{a as C,b as Z,c as F,d as q}from"./chunk-XWKUZJCP.js";import"./chunk-ZPDM6FO7.js";import{e as Q}from"./chunk-EHN5HTUD.js";import"./chunk-CH273NAE.js";import{a as W}from"./chunk-L5LI2JF4.js";import{A as K}from"./chunk-TH47OOBV.js";import"./chunk-VAYBKR76.js";import"./chunk-CUM23TLF.js";import"./chunk-DUAXZYAD.js";import"./chunk-DBIBROYW.js";import{d as G,e as M}from"./chunk-WXHQYYD5.js";import"./chunk-IAHKTEET.js";import"./chunk-UD7KKHPW.js";import"./chunk-UR6MHSHU.js";import{basename as B}from"path";import{statSync as Se}from"fs";function ye(e,t){return e.length===0?"not_run":ne(e,t).verified?"proven":te(e,t).some(n=>n.verdict==="failed")?"failing":"blocked"}function le(e,t){let s=null;for(let{cid:f}of e.byLabel(G.TEST))for(let o of e.execHistory(f))(!s||String(o.started_at)>s.started_at)&&(s={execution_id:String(o.execution_id),started_at:String(o.started_at)});if(!s)return null;let n=ee[t],r=oe(e),c=se(r).aspects[t],i={},d={},l=0,g=0,a=0;for(let f of r.usecases){let o=[];for(let b of f.acceptance_criteria){let u=b.executions??[],_=ye(u,n);o.push(_),_==="failing"?l++:_==="blocked"?g++:_==="not_run"&&a++;let S=[],k;if(_==="failing"){let w=null;for(let O of b.covered_by){let T=e.execHistory(O).map($=>({verdict:String($.per_ac?.find(y=>y.ac_ref===b.id)?.verdict??$.verdict),oracle_mode:String($.oracle_mode),ts:String($.started_at),execution_id:String($.execution_id)})).filter($=>n.counted_verdicts.includes($.verdict)&&n.accepted_oracle_modes.includes($.oracle_mode)),I=T[T.length-1];I?.verdict==="failed"&&(S.push(O),(!w||I.ts>w.ts)&&(w={ts:I.ts,execution_id:I.execution_id}))}k=w?.execution_id}else _==="blocked"&&(k=u[u.length-1]?.execution_id);i[b.id]={state:_,viaTests:S,...k?{executionId:k}:{}}}let m=o.some(b=>b!=="not_run"),p=c.usecases[f.id],v=m?p.status==="covered"?"proven":p.status==="partial"?"partial":o.includes("failing")?"failing":o.includes("blocked")?"blocked":"not_run":"not_run";d[f.id]={pct:p.pct,status:v}}return{aspect:t,pct:c.summary.coverage_pct,acs_proven:c.summary.acs_verified,failing:l,blocked:g,not_run:a,latest_run:s,perUc:d,perAc:i,config:{...n,source:"graph_execution_facts",denominator:"current_live_acs"}}}var be=["failing","blocked","needs-refresh","needs-tests","needs-scenarios","happy-only","possible-duplicate","not-yet-run"],_e={failing:"failing",blocked:"blocked","needs-refresh":"needs refresh","needs-tests":"needs tests","needs-scenarios":"needs scenarios","happy-only":"happy path only","possible-duplicate":"possible duplicate","not-yet-run":"not yet run"},E={high:0,med:1,low:2};function Y(e,t){let s=/^(.*?)(\d+)$/.exec(e),n=/^(.*?)(\d+)$/.exec(t);return s&&n&&s[1]===n[1]?Number(s[2])-Number(n[2]):e<t?-1:e>t?1:0}function D(e){if(!e||/^sha256:/.test(e))return"(unnamed)";let t=/^(uc|ac|sc|t)-(\d+)$/.exec(e);return t?`${t[1].toUpperCase()}-${t[2]}`:e}function fe(e,t=5){let s=e.trim().split(/\s+/);return s.slice(0,t).join(" ")+(s.length>t?"\u2026":"")}function ke(e,t){let s=e.resolve(t),n=s?e.getNode(e.tipOf(s.cid))?.content:null;return String(n?.title??n?.text??"")}function ue(e,t){let s=e.resolve(t);return{id:s?e.displayNameOf(e.tipOf(s.cid))??e.displayNameOf(s.cid):null,title:fe(ke(e,t),8)}}function $e(e,t){let s=e.resolve(t);if(!s)return null;let n=e.tipOf(s.cid);if(!C(e,n))return null;let r=e.nodeLabel.get(n);if(r===G.USECASE)return n;if(r===G.AC)return F(e,n);if(r===G.TEST){let c=e.edgesFrom(n).find(d=>d.type===M.VERIFIES&&C(e,d.dst));if(c)return F(e,c.dst);let i=e.edgesFrom(n).find(d=>d.type===M.AUTOMATES&&C(e,d.dst));if(i){let d=e.edgesFrom(i.dst).find(l=>l.type===M.BELONGS_TO&&C(e,l.dst));return d?d.dst:null}}return null}function j(e){if(e.tag==="reuse-candidate"&&e.stage==="design")return"possible-duplicate";switch(e.kind){case"no-verifies":return"needs-tests";case"zero-scenario":return"needs-scenarios";case"happy-only":return"happy-only";case"stale-ac":case"stale-test":return"needs-refresh";case"execution-failed":return"failing";case"execution-blocked":return"blocked";case"covered-not-run":return"not-yet-run";default:return"other"}}function xe(e,t){let s=e.resolve(t),n=s?e.getNode(e.tipOf(s.cid))?.content.risk:null;return n==="high"||n==="med"||n==="low"?n:"med"}function ge(e,t,s,n,r){let c=r.servePaths??new Map,i=e.byLabel(G.USECASE).filter(({cid:o})=>C(e,o)),d=new Map(i.map(o=>[o.cid,o])),l=new Map(i.map(({cid:o})=>[o,[]])),g=[];for(let o of t){if(o.stage!=="design")continue;let m={...o,...ue(e,o.ref)},p=$e(e,o.ref),v=p?l.get(p):void 0;v&&j(o)!=="other"?v.push(m):g.push(m)}let a=new Map(i.map(({cid:o})=>[o,{total:0,designed:0}]));for(let{cid:o}of e.byLabel(G.AC)){if(!C(e,o))continue;let m=F(e,o),p=m?a.get(m):void 0;if(!p)continue;p.total++;let v=Z(e,o);if(v&&p.designed++,!n)continue;let b=e.nameOf.get(o)??o,u=n.perAc[b];if(!u)continue;let{id:_,title:S}=ue(e,b),k={ref:e.displayNameOf(o)??o,id:_,title:S,risk:xe(e,b),stage:"cover"},w=l.get(m);u.state==="failing"?w.push({...k,kind:"execution-failed",tag:"evolve",why:"covering test failed against this AC",ready_command:u.executionId&&c.has(u.executionId)?`kane-cli evidence serve ${c.get(u.executionId)}`:"kane-cli testrun run",via_tests:u.viaTests,...u.executionId?{execution_id:u.executionId}:{},...u.executionId&&c.has(u.executionId)?{servePath:c.get(u.executionId)}:{},...r.testFiles?{viaFiles:u.viaTests.map(O=>r.testFiles.get(O)??null)}:{}}):u.state==="blocked"?w.push({...k,kind:"execution-blocked",tag:"reuse-candidate",why:"the formula could count no run \u2014 broken/skipped or an unaccepted oracle",ready_command:u.executionId&&c.has(u.executionId)?`kane-cli evidence serve ${c.get(u.executionId)}`:"kane-cli testrun run",...u.executionId?{execution_id:u.executionId}:{},...u.executionId&&c.has(u.executionId)?{servePath:c.get(u.executionId)}:{}}):u.state==="not_run"&&v&&w.push({...k,kind:"covered-not-run",tag:"reuse-candidate",why:"a covering test exists but has not run yet",ready_command:"kane-cli testrun run"})}let f=[];for(let{cid:o,content:m}of i){let p=e.displayNameOf(o)??o,v=e.nameOf.get(o)??o,b=s.perUc[p]??{pct:0,status:"undesigned",staleAcs:0},u=n?n.perUc[v]??{pct:0,status:"not_run"}:null,_=n!==null&&(u===null||u.status==="not_run"),S=a.get(o),k=l.get(o)??[],w=new Set(k.filter(h=>j(h)==="needs-refresh").map(h=>h.ref)),O=k.some(h=>j(h)==="needs-tests"&&w.has(h.ref)),T=[];for(let h of be){let A=k.filter(P=>j(P)===h);if(h==="needs-tests"&&(A=A.filter(P=>!w.has(P.ref))),A.length===0)continue;A.sort((P,V)=>(E[P.risk]??3)-(E[V.risk]??3)||Y(P.ref,V.ref));let ve=h==="failing"||h==="blocked"||A.length<=2||new Set(A.map(P=>P.ready_command)).size>1;T.push({key:h,label:_e[h],...h==="needs-refresh"?{suffix:"source moved since these were designed"}:{},alsoNeedsTests:h==="needs-refresh"&&O,rows:A,...ve?{}:{rosterCommand:A[0].ready_command}})}let I=T.some(h=>h.key==="failing"),$=T.some(h=>h.key==="blocked"),y=b.pct===100&&(n===null||u?.pct===100)&&T.length===0,U=u!==null&&u.pct>0,x=I?"\u2717":$?"\u23F8":y?"\u2714":b.pct===0&&!U?"\u2716":"\u25D0";f.push({slug:p,title:String(m.title??""),risk:String(m.risk??""),des:b,prov:u,provAbsent:_,acTotal:S.total,acDesigned:S.designed,mark:x,collapse:y,groups:T})}return f.sort((o,m)=>(E[o.risk]??3)-(E[m.risk]??3)||Y(o.slug,m.slug)),g.sort((o,m)=>(E[o.risk]??3)-(E[m.risk]??3)||Y(o.ref,m.ref)),{stage:r.stage,aspect:r.aspect,top:r.top,dc:s,pa:n,ucs:f,other:g}}function N(e,t){let s=Math.round(e/100*t);return"\u2588".repeat(s)+"\u2591".repeat(t-s)}function z(e){return e===100?"\u2714":e>0?"\u25D0":"\u2716"}function L(e,t){return e==="all"||t.stage===e}function me(e,t){let{dc:s,pa:n}=e,r=Math.max(80,Math.min(t.width,120)),c=l=>t.color?`\x1B[2m${l}\x1B[22m`:l,i=[];if(n){i.push(`coverage \u2014 designed \xD7 proven \xB7 live graph \xB7 aspect ${n.aspect}`),i.push("");let l=s.ucs_needing_scenarios;i.push(` designed ${z(s.pct)} ${N(s.pct,10)} ${String(s.pct).padStart(3)}% \u2014 ${s.acs_designed} ACs have verifying tests`+(l>0?` \xB7 scenario debt: ${l} UC${l>1?"s":""}`:""));let g=[n.failing>0?`${n.failing} failing`:null,n.blocked>0?`${n.blocked} blocked`:null,n.not_run>0?`${n.not_run} not yet run`:null].filter(Boolean);i.push(` proven ${z(n.pct)} ${N(n.pct,10)} ${String(n.pct).padStart(3)}% \u2014 ${n.acs_proven} proven by execution`+(g.length?` \xB7 ${g.join(" \xB7 ")}`:""))}else i.push("AC design completeness \u2014 live graph (what design owes; execution proof not shown)"),i.push(""),i.push(` designed ${z(s.pct)} ${N(s.pct,10)} ${String(s.pct).padStart(3)}% \u2014 ${s.acs_designed} ACs have verifying tests \xB7 ${s.usecases_complete} UCs complete`),s.ucs_needing_scenarios>0&&i.push(` scenario debt: ${s.ucs_needing_scenarios} use-case${s.ucs_needing_scenarios>1?"s":""} need scenarios`),i.push(" proven \u2014 no runs recorded yet \xB7 run tests, then re-run");i.push("");let d=!1;for(let l of e.ucs){if(i.push(we(l,n!==null,r)),l.collapse)continue;let g=e.top??1/0;for(let a of l.groups){let f=a.rows.filter(v=>L(e.stage,v));if(f.length===0)continue;if(d=!0,g<=0){i.push(c(` \u2026 +${f.length} more ${a.label}`));continue}let o=f.slice(0,g),m=f.length-o.length;if(g-=o.length,(a.key==="needs-scenarios"||a.key==="happy-only")&&o.length===1&&o[0].ref===l.slug){i.push(` ${a.label}${a.key==="needs-scenarios"?" \u2014 design from scratch":""}`),i.push(c(` \u2192 ${o[0].ready_command}`));continue}let p=(a.suffix?` \u2014 ${a.suffix}`:"")+(a.alsoNeedsTests?" \u2014 also needs tests":"");if(i.push(` ${a.label} (${f.length})${p}`),a.rosterCommand&&a.key!=="failing"&&a.key!=="blocked")Re(i,o,r),i.push(c(` \u2192 ${a.rosterCommand}`));else for(let v of o)Te(i,v,a.key,c);m>0&&i.push(c(` \u2026 +${m} more ${a.label}`))}}return!d&&e.ucs.every(l=>l.groups.every(g=>g.rows.filter(a=>L(e.stage,a)).length===0))&&i.push(" nothing owed \u2014 design and execution are square"),i.push(""),i.push(c(" metric: live verifies edges \xB7 high \xD73 \xB7 staleness shown, not discounted")),n?i.push(c(` proven: graph execution facts \xB7 latest run ${n.latest_run?.started_at??"\u2014"} \xB7 ${n.aspect} formula verbatim`)):i.push(c(" proof: no runs recorded yet \u2014 run tests, then re-run")),i}function we(e,t,s){let n=D(e.slug);if(!t){let l=e.acTotal===0?"no scenarios yet":e.collapse||e.des.status==="complete"?`${e.acTotal} ACs \xB7 complete`:e.des.staleAcs>0?`${e.acTotal} ACs \xB7 ${e.des.staleAcs} stale`:`${e.acTotal} ACs \xB7 ${e.acTotal-e.acDesigned} unverified`,g=` ${e.mark} ${N(e.des.pct,10)} ${String(e.des.pct).padStart(3)}% ${n} `,a=Math.max(0,s-g.length-l.length-2);return`${g}${de(e.title,a).padEnd(a)} ${l}`}let r=e.provAbsent?"prov \xB7 not run":`prov ${N(e.prov?.pct??0,8)} ${String(e.prov?.pct??0).padStart(3)}%`,c=`des ${N(e.des.pct,8)} ${String(e.des.pct).padStart(3)}% \xB7 ${r}`,i=` ${e.mark} ${n} `,d=Math.max(0,s-i.length-c.length-2);return`${i}${de(e.title,d).padEnd(d)} ${c}`}function de(e,t){return e.length<=t?e:t<=1?e.slice(0,t):e.slice(0,t-1)+"\u2026"}function Te(e,t,s,n){let r=D(t.id??t.ref);if(s==="failing"){let c=(t.via_tests??[]).map((d,l)=>`${D(d)}${t.viaFiles?.[l]?` ${t.viaFiles[l]}`:""}`).join(", ");e.push(` \u2717 ${r} ${t.title} \u2014 failed${c?` \xB7 via ${c}`:""}`),t.servePath&&e.push(n(` \u2192 kane-cli evidence serve ${t.servePath} (see why it failed)`));let i=(t.viaFiles??[]).filter(d=>d!==null);i.length===1?e.push(n(` re-run after fixing: kane-cli testmd run ${i[0]} (heals on failure \u2014 fix the app first, or the test may re-author)`)):i.length>1&&e.push(n(" re-run after fixing: kane-cli testrun run (heals on failure \u2014 fix the app first, or the tests may re-author)"));return}if(s==="blocked"){e.push(` \u23F8 ${r} ${t.title} \u2014 (blocked \u2014 see why)`),t.servePath&&e.push(n(` \u2192 kane-cli evidence serve ${t.servePath} (see why)`));return}e.push(` ${r} ${t.title} \u2014 ${t.why}`),e.push(n(` \u2192 ${t.ready_command}`))}function Re(e,t,s){let n=t.map(c=>`${D(c.id??c.ref)} ${fe(c.title,4)}`),r=" ";for(let c of n){let i=r.trim().length?" \xB7 ":"";r.length+i.length+c.length>s&&r.trim().length?(e.push(r),r=" "+c):r+=i+c}r.trim().length&&e.push(r)}function he(e){let{dc:t,pa:s}=e,n=r=>e.top!==void 0?r.slice(0,e.top):r;return{stage:e.stage,rollup_version:1,design_completeness:{pct:t.pct,acs_designed:t.acs_designed,usecases_complete:t.usecases_complete,ucs_needing_scenarios:t.ucs_needing_scenarios,config:t.config},...s?{proven:{aspect:s.aspect,pct:s.pct,acs_proven:s.acs_proven,failing:s.failing,blocked:s.blocked,not_run:s.not_run,latest_run:s.latest_run,config:s.config}}:{},usecases:e.ucs.map(r=>({id:/^sha256:/.test(r.slug)?null:r.slug,title:r.title,risk:r.risk,design_completeness:{pct:r.des.pct,status:r.des.status},stale_acs:r.des.staleAcs,...s?{proven:r.prov??{pct:0,status:"not_run"}}:{},pending:n(r.groups.flatMap(c=>c.rows).filter(c=>L(e.stage,c))).map(pe)})),other:e.other.filter(r=>L(e.stage,r)).map(pe)}}function pe(e){let{servePath:t,viaFiles:s,meta:n,...r}=e;return{...r}}async function Ae(e){let t=await X(e);return t.length===0?null:t.map(s=>({p:s,m:Se(s).mtimeMs})).sort((s,n)=>n.m-s.m)[0].p}async function Oe(e,t=ae(),s=process.cwd()){if(e.mode!==void 0&&e.mode!=="agent"&&e.mode!=="ci"&&e.mode!=="interactive")return R(t,`--mode must be interactive | agent | ci, got '${e.mode}'`),2;if(e.mode==="agent"||e.mode==="ci"){let{makeHeadlessIO:p,agentRefusal:v}=await import("./headless-io-66RG5NN5.js"),{parsesAgainstGrammar:b}=await import("./next-TRSKMBO5.js"),u=p("ndjson","gaps",{stdout:y=>t.out(y.replace(/\n$/,"")),stderr:y=>(t.err??t.out)(y.replace(/\n$/,""))}),_=[],S=[],k={out:y=>_.push(y),err:y=>S.push(y),confirm:async()=>!1,isTTY:!1};if(await Oe({...e,json:!0,mode:void 0},k,s)!==0)return v(u,S.join("; ")||"cover gaps refused");let O=JSON.parse(_.join(`
3
3
  `));u.event({type:"gaps",...O});let T=[],I=new Set,$=(y,U)=>{if(Array.isArray(y)){for(let x of y)$(x,U);return}if(y&&typeof y=="object"){let x=y,h=typeof x.why=="string"?x.why:U;typeof x.ready_command=="string"&&x.ready_command.startsWith("kane-cli ")&&b(x.ready_command)&&!I.has(x.ready_command)&&(I.add(x.ready_command),T.push({cmd:x.ready_command,why:h||"close the gap"}));for(let A of Object.values(x))$(A,h)}};return $(O,"close the gap"),u.done(0,void 0,T.slice(0,4))}if(e.flat)return Ie(e,t,s);let n=e.stage??"all";if(n!=="design"&&n!=="cover"&&n!=="all")return R(t,`--stage must be design | cover | all, got '${n}'`),2;if(e.top!==void 0&&(!Number.isInteger(e.top)||e.top<1))return R(t,"--top must be a positive integer"),2;let r=e.aspect??"lenient";if(r!=="lenient"&&r!=="strict")return R(t,`--aspect must be lenient | strict, got '${r}'`),2;if(e.from)return R(t,"the tree reads the live graph \u2014 for a specific run's view use: kane-cli cover --from <pack> (legacy worklist: add --flat)"),2;let c=H(s,t);if(!c)return 2;let i=K(c),d=re(i),l=le(i,r),g=await q(i,"design"),a=new Map;if(l)for(let p of Object.values(l.perAc)){if(!p.executionId||a.has(p.executionId))continue;let v=await J(p.executionId,s);v&&a.set(p.executionId,v)}let f=new Map;for(let[p,v]of ce(ie(s)))v.length===1&&f.set(p,B(v[0]));let o=ge(i,g,d,l,{stage:n,top:e.top,aspect:r,servePaths:a,testFiles:f});if(e.json)return t.out(JSON.stringify(he(o),null,2)),0;if(d.usecases_complete==="0/0")return t.out("nothing to measure yet \u2014 no live use-cases in the graph"),0;let m=t.isTTY&&process.stdout.columns?process.stdout.columns:100;for(let p of me(o,{width:m,color:t.isTTY}))t.out(p);return 0}async function Ie(e,t,s){let n=e.stage??"design";if(n!=="design"&&n!=="cover"&&n!=="all")return R(t,`--stage must be design | cover | all, got '${n}'`),2;if(e.top!==void 0&&(!Number.isInteger(e.top)||e.top<1))return R(t,"--top must be a positive integer"),2;let r=H(s,t);if(!r)return 2;let c,i;if(n!=="design"){let a=e.from?await J(e.from,s):await Ae(s);if(!a)return R(t,e.from?`no evidence pack at '${e.from}'`:`--stage ${n} needs an evidence pack \u2014 run a test first, or pass --from <pack> (live view: drop --flat)`),2;let f=await Q(a,"coverage/usecases.yaml");if(f==null)return R(t,`${B(a)} carries no coverage/usecases.yaml \u2014 re-run the tests to produce a coverage-bearing pack`),2;let o=W(f);if(!o||!Array.isArray(o.usecases))return R(t,`${B(a)}: coverage/usecases.yaml is not a usecases document`),2;c=o,i=B(a)}let d=K(r),l=await q(d,n,void 0,c),g=l.length;if(e.top!==void 0&&(l=l.slice(0,e.top)),e.json){let a=l.map(f=>Pe(d,f));return t.out(JSON.stringify({stage:n,...i?{pack:i}:{},total:g,rows:a},null,2)),0}return t.out(`gaps \u2014 stage ${n}${i?` \xB7 pack ${i}`:""} (${l.length}${l.length<g?` of ${g}`:""})`),l.length===0&&t.out(" nothing owed \u2014 design and execution are square"),l.forEach((a,f)=>{t.out(` ${String(f+1).padStart(2)}. [${a.risk}] ${a.tag} ${a.ref} \u2014 ${a.why}`),t.out(` \u2192 ${a.ready_command}`)}),0}function Pe(e,t){let s=e.resolve(t.ref),n=s?e.tipOf(s.cid):null,r=n?e.getNode(n)?.content:null;return{...t,id:n?e.displayNameOf(n)??e.displayNameOf(s.cid):null,title:String(r?.title??r?.text??"")}}export{Oe as gapsCommand};
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as T,f as P,g as $,h as G,j as N,k as M,l as B,m as I,n as L,o as U,p as F,r as z,s as C,t as _,u as O,v as K}from"./chunk-PLOWZLG5.js";import{b as k}from"./chunk-JPWLGHPM.js";import{d as J}from"./chunk-VOOPWFHW.js";import{c as E}from"./chunk-SL6PCVM2.js";import"./chunk-OUJQVBUT.js";import"./chunk-TDPWFYTJ.js";import{a as q}from"./chunk-AECMF3T2.js";import"./chunk-OR6MCL6Z.js";import"./chunk-L5LI2JF4.js";import"./chunk-4LTXE3IX.js";import"./chunk-4NFCAGRK.js";import"./chunk-WAOCHXJ5.js";import{m as x,n as A}from"./chunk-QIGPXYMF.js";import"./chunk-5EOX4MEY.js";import{h as H}from"./chunk-B5RS2XZU.js";import"./chunk-2WVKOZ6W.js";import"./chunk-NLCCBXXV.js";import"./chunk-RZ4F3BHX.js";import{a as R}from"./chunk-O75ZHGJG.js";import"./chunk-VE3SUJMA.js";import{a as j}from"./chunk-VT54ARGE.js";import"./chunk-ZUGCHQFC.js";import"./chunk-UR6MHSHU.js";import{join as se}from"path";async function V(t){let e=t.projectId,n=t.folderId,r=null;if(!e&&t.autoResolve){let l=await t.resolver.resolve();if(!l)throw new $("unauthorized; run `kane-cli login`");let u=await H({creds:t.autoResolve.creds,config:t.autoResolve.config,profile:t.autoResolve.profile,env:t.autoResolve.envName,tmsCreds:{username:l.username,access_key:l.access_key},isLocal:!1,log:t.log});u.status==="ok"&&(e=u.projectId,n=n??u.folderId,u.autoDefaulted&&(r={projectId:u.autoDefaulted.projectId,projectName:u.autoDefaulted.projectName,folderId:u.autoDefaulted.folderId,folderName:u.autoDefaulted.folderName}))}return{baseUrl:`${t.env.testGeneratorBaseUrl}/test-generator/api/v2`,tmsBaseUrl:t.env.tmsBaseUrl,authResolver:t.resolver,projectId:e,folderId:n,suiteName:t.suiteName,autoDefaulted:r,log:t.log}}function Z(t){return t.reduce((e,n)=>e+(n.test_cases?.length??0),0)}var y=class{constructor(e=n=>process.stdout.write(n)){this.write=e}emit(e){this.write(JSON.stringify(e)+`
2
+ import{a as T,f as P,g as $,h as G,j as N,k as M,l as B,m as I,n as L,o as U,p as F,r as z,s as C,t as _,u as O,v as K}from"./chunk-7JWKHKFU.js";import{d as J}from"./chunk-QW6EZC53.js";import{b as k}from"./chunk-YJELGSKJ.js";import{c as x}from"./chunk-HMYMSRA4.js";import"./chunk-L5LI2JF4.js";import"./chunk-GZPK6FRP.js";import"./chunk-TDPWFYTJ.js";import{a as A}from"./chunk-T5Y6MOLM.js";import"./chunk-OTTGS2TE.js";import{h as H}from"./chunk-DZGCXKKI.js";import"./chunk-2WVKOZ6W.js";import"./chunk-VE3SUJMA.js";import"./chunk-FNH55WSR.js";import"./chunk-TYLYFERW.js";import"./chunk-MSGW4JDG.js";import{m as E,n as q}from"./chunk-56PAQAX5.js";import"./chunk-5EOX4MEY.js";import"./chunk-4JOD47QI.js";import"./chunk-XO5ZH3ZR.js";import"./chunk-766WGMBU.js";import{a as R}from"./chunk-G7VQCS4J.js";import"./chunk-DPUV6OSP.js";import"./chunk-NLCCBXXV.js";import"./chunk-RZ4F3BHX.js";import"./chunk-EYOCNMUM.js";import{a as j}from"./chunk-6O3DDOP2.js";import"./chunk-27U4PLPX.js";import"./chunk-UR6MHSHU.js";import{join as se}from"path";async function V(t){let e=t.projectId,n=t.folderId,r=null;if(!e&&t.autoResolve){let l=await t.resolver.resolve();if(!l)throw new $("unauthorized; run `kane-cli login`");let u=await H({creds:t.autoResolve.creds,config:t.autoResolve.config,profile:t.autoResolve.profile,env:t.autoResolve.envName,tmsCreds:{username:l.username,access_key:l.access_key},isLocal:!1,log:t.log});u.status==="ok"&&(e=u.projectId,n=n??u.folderId,u.autoDefaulted&&(r={projectId:u.autoDefaulted.projectId,projectName:u.autoDefaulted.projectName,folderId:u.autoDefaulted.folderId,folderName:u.autoDefaulted.folderName}))}return{baseUrl:`${t.env.testGeneratorBaseUrl}/test-generator/api/v2`,tmsBaseUrl:t.env.tmsBaseUrl,authResolver:t.resolver,projectId:e,folderId:n,suiteName:t.suiteName,autoDefaulted:r,log:t.log}}function Z(t){return t.reduce((e,n)=>e+(n.test_cases?.length??0),0)}var y=class{constructor(e=n=>process.stdout.write(n)){this.write=e}emit(e){this.write(JSON.stringify(e)+`
3
3
  `)}onStart(e){this.emit({type:"generate_start",request_id:e.requestId,objective_chars:e.objectiveChars,scenario_limit:e.scenarioLimit,per_scenario_limit:e.perScenarioLimit,is_refine:e.isRefine})}onUpload(e){this.emit({type:"generate_upload",file:e.file,index:e.index,total:e.total,status:e.status})}onThinking(e){this.emit({type:"generate_thinking",took_ms:e.tookMs})}onProgress(e){this.emit({type:"generate_progress",pct:e})}onSnapshot(e){this.emit({type:"generate_snapshot",scenario_count:e.scenarios.length,case_count:Z(e.scenarios),scenarios:e.scenarios})}onClarification(e){this.emit({type:"generate_clarification",text:e})}onChat(e){this.emit({type:"generate_chat",text:e})}onError(e){this.emit({type:"error",message:e})}onSaveResult(e){this.emit({type:"generate_save_result",suite_dir:e.suiteDir,saved:e.saved,fell_back:e.fellBack,...e.warning?{warning:e.warning}:{}})}onDone(e){this.emit({type:"generate_done",request_id:e.requestId,status:e.status,scenario_count:e.scenarioCount,case_count:e.caseCount,refine_hint:e.refineHint,save_hint:e.saveHint,...e.suiteDir?{suite_dir:e.suiteDir}:{}})}onUpdateAvailable(e){this.emit({type:"update_available",current:e.current,latest:e.latest,severity:e.severity})}},S=class{constructor(e=n=>process.stdout.write(n)){this.write=e}onStart(e){let n=e.isRefine?"Refining":"Generating";this.write(`${n} (request ${e.requestId})\u2026
4
4
  `)}onUpload(e){e.status==="uploading"&&this.write(` uploading ${e.file} (${e.index}/${e.total})
5
5
  `)}onThinking(e){let n=e.tookMs?` (${Math.round(e.tookMs/1e3)}s)`:"";this.write(` thinking${n}
@@ -16,6 +16,6 @@ import{a as T,f as P,g as $,h as G,j as N,k as M,l as B,m as I,n as L,o as U,p a
16
16
  `),this.write(` Save: ${e.saveHint}
17
17
  `),e.suiteDir&&this.write(` Saved: ${e.suiteDir}
18
18
  `)}onUpdateAvailable(e){this.write(`(update available: ${e.current} \u2192 ${e.latest})
19
- `)}};import{createHash as ee}from"crypto";function te(t){return ee("sha1").update(JSON.stringify({t:t.title,p:t.preconditions,m:t.manual_steps})).digest("hex")}function re(t){let e=[];for(let n of t.scenarios)for(let r of n.test_cases??[])I(r)&&r.manual_steps!=null&&e.push(r);return e}async function ne(t,e,n){let r=new Array(t.length),l=0,u=Array.from({length:Math.min(e,t.length)},async()=>{for(;;){let d=l++;if(d>=t.length)return;try{r[d]={ok:!0,value:await n(t[d])}}catch{r[d]={ok:!1}}}});return await Promise.all(u),r}async function Y(t,e,n){let r=re(t),l=n.run??(async(c,s)=>{let m=await n.resolveAuth(),o=U({objective:c,model:n.model,sessionId:n.sessionId,auth:m});return F(o,n.spawnOpts,s)}),u=r.map(te),d=[...new Set(u)],g=new Map;d.forEach(c=>{g.set(c,r[u.indexOf(c)])});let p=d.map(c=>g.get(c)),v=await ne(p,n.concurrency??3,c=>l(L(c))),i=new Map;d.forEach((c,s)=>{let m=v[s];m.ok&&i.set(c,m.value)});let f=new Map;r.forEach((c,s)=>{f.set(c.id,i.get(u[s]))});let a=0;for(let c of t.scenarios)for(let s of c.test_cases??[])I(s)&&!f.get(s.id)&&a++;let w=c=>{let s=f.get(c.id);return s?N(s,c):M(c)};return{...await B(t,e,{suiteName:n.suiteName,redirectBareCwd:!1},w),fellBack:a}}function Pe(t,e){let n=!!t.agent||!!t.refine||!!t.save||!e,r=t.agent?"agent":"plain";return{headless:n,mode:r}}function $e(t){return t.refine&&t.save?{error:"use --refine or --save, not both"}:t.save?t.objective?{error:"--save takes no objective; use --refine to add to a request"}:t.req?{op:"save"}:{error:"--save requires --req <id>"}:t.refine?t.req?t.objective?t.out?{error:"--out is only valid with --save"}:{op:"refine"}:{error:"--refine needs a refinement objective"}:{error:"--refine requires --req <id>"}:t.req?{error:"--req requires --refine or --save"}:t.out?{error:"--out is only valid with --save"}:t.objective?{op:"new"}:{error:"provide an objective, or use --refine/--save with --req"}}function ie(){return se(process.cwd(),".testmuai","tests")}function Ge(t){if(typeof t!="string")return;let e=t.split(",").map(n=>n.trim()).filter(Boolean);return e.length?e:void 0}var X="tcg-generate-headless";function Q(t){return{refineHint:`kane-cli generate "<refinement>" --refine --req ${t}`,saveHint:`kane-cli generate --save --req ${t}`}}function W(t){return t.scenarios.reduce((e,n)=>e+(n.test_cases?.length??0),0)}function oe(t){return t==="completed"?0:t==="stopped"?3:1}async function Ne(t,e){let n=e.write??(i=>process.stdout.write(i)),r=e.sink??(e.mode==="agent"?new y(n):new S(n)),l,u,d=null;try{let i=await e.makeClient();l=i.client,u=i.conn,d=i.autoDefaulted}catch(i){return r.onError(i.message),2}if(e.mode==="agent"&&d){let{buildAutoDefaultedNdjson:i}=await import("./require-project-folder-ACRDP5ZB.js");n(i(d))}try{let i=await(e.checkUpdate??J)();i&&r.onUpdateAvailable(i)}catch{}let g=t.reqId??null;x(X,()=>{g&&l.cancel(g).catch(()=>{})});let p=process.cwd(),v={validate:e.validate??z,upload:e.upload??O,buildMappings:K,onUpload:i=>r.onUpload(i)};try{if(t.op==="save"){let s;try{s=(await l.attach(t.reqId)).state}catch(D){return r.onError(D.message),2}g=s.requestId,r.onSnapshot(s);let m=t.outDir??ie(),o=await e.materialize(s,m,t.suiteName);r.onSaveResult({suiteDir:o.suiteDir,saved:o.paths.length,fellBack:o.fellBack,warning:o.warning});let h=Q(s.requestId);return r.onDone({requestId:s.requestId,status:"completed",scenarioCount:s.scenarios.length,caseCount:W(s),refineHint:h.refineHint,saveHint:h.saveHint,suiteDir:o.suiteDir}),0}let i=t.op==="refine",f,a;if(i){let s;try{s=await l.attach(t.reqId)}catch(o){return r.onError(o.message),2}if(a=s.state,g=a.requestId,a.error)return r.onError(a.error),2;let m;try{m=await _({promptText:t.objective,filePaths:t.files??[],cwd:p,scenarios:a.scenarios,isRefine:!0,conn:u,deps:v})}catch(o){if(o instanceof C){for(let h of o.errors)r.onError(h);return 2}return r.onError(o.message),2}for(let o of m.warnings)process.stderr.write(`warning: ${o}
19
+ `)}};import{createHash as ee}from"crypto";function te(t){return ee("sha1").update(JSON.stringify({t:t.title,p:t.preconditions,m:t.manual_steps})).digest("hex")}function re(t){let e=[];for(let n of t.scenarios)for(let r of n.test_cases??[])I(r)&&r.manual_steps!=null&&e.push(r);return e}async function ne(t,e,n){let r=new Array(t.length),l=0,u=Array.from({length:Math.min(e,t.length)},async()=>{for(;;){let d=l++;if(d>=t.length)return;try{r[d]={ok:!0,value:await n(t[d])}}catch{r[d]={ok:!1}}}});return await Promise.all(u),r}async function Y(t,e,n){let r=re(t),l=n.run??(async(c,s)=>{let m=await n.resolveAuth(),o=U({objective:c,model:n.model,sessionId:n.sessionId,auth:m});return F(o,n.spawnOpts,s)}),u=r.map(te),d=[...new Set(u)],g=new Map;d.forEach(c=>{g.set(c,r[u.indexOf(c)])});let p=d.map(c=>g.get(c)),v=await ne(p,n.concurrency??3,c=>l(L(c))),i=new Map;d.forEach((c,s)=>{let m=v[s];m.ok&&i.set(c,m.value)});let f=new Map;r.forEach((c,s)=>{f.set(c.id,i.get(u[s]))});let a=0;for(let c of t.scenarios)for(let s of c.test_cases??[])I(s)&&!f.get(s.id)&&a++;let w=c=>{let s=f.get(c.id);return s?N(s,c):M(c)};return{...await B(t,e,{suiteName:n.suiteName,redirectBareCwd:!1},w),fellBack:a}}function Pe(t,e){let n=!!t.agent||!!t.refine||!!t.save||!e,r=t.agent?"agent":"plain";return{headless:n,mode:r}}function $e(t){return t.refine&&t.save?{error:"use --refine or --save, not both"}:t.save?t.objective?{error:"--save takes no objective; use --refine to add to a request"}:t.req?{op:"save"}:{error:"--save requires --req <id>"}:t.refine?t.req?t.objective?t.out?{error:"--out is only valid with --save"}:{op:"refine"}:{error:"--refine needs a refinement objective"}:{error:"--refine requires --req <id>"}:t.req?{error:"--req requires --refine or --save"}:t.out?{error:"--out is only valid with --save"}:t.objective?{op:"new"}:{error:"provide an objective, or use --refine/--save with --req"}}function ie(){return se(process.cwd(),".testmuai","tests")}function Ge(t){if(typeof t!="string")return;let e=t.split(",").map(n=>n.trim()).filter(Boolean);return e.length?e:void 0}var X="tcg-generate-headless";function Q(t){return{refineHint:`kane-cli generate "<refinement>" --refine --req ${t}`,saveHint:`kane-cli generate --save --req ${t}`}}function W(t){return t.scenarios.reduce((e,n)=>e+(n.test_cases?.length??0),0)}function oe(t){return t==="completed"?0:t==="stopped"?3:1}async function Ne(t,e){let n=e.write??(i=>process.stdout.write(i)),r=e.sink??(e.mode==="agent"?new y(n):new S(n)),l,u,d=null;try{let i=await e.makeClient();l=i.client,u=i.conn,d=i.autoDefaulted}catch(i){return r.onError(i.message),2}if(e.mode==="agent"&&d){let{buildAutoDefaultedNdjson:i}=await import("./require-project-folder-4UPQNEBJ.js");n(i(d))}try{let i=await(e.checkUpdate??J)();i&&r.onUpdateAvailable(i)}catch{}let g=t.reqId??null;E(X,()=>{g&&l.cancel(g).catch(()=>{})});let p=process.cwd(),v={validate:e.validate??z,upload:e.upload??O,buildMappings:K,onUpload:i=>r.onUpload(i)};try{if(t.op==="save"){let s;try{s=(await l.attach(t.reqId)).state}catch(D){return r.onError(D.message),2}g=s.requestId,r.onSnapshot(s);let m=t.outDir??ie(),o=await e.materialize(s,m,t.suiteName);r.onSaveResult({suiteDir:o.suiteDir,saved:o.paths.length,fellBack:o.fellBack,warning:o.warning});let h=Q(s.requestId);return r.onDone({requestId:s.requestId,status:"completed",scenarioCount:s.scenarios.length,caseCount:W(s),refineHint:h.refineHint,saveHint:h.saveHint,suiteDir:o.suiteDir}),0}let i=t.op==="refine",f,a;if(i){let s;try{s=await l.attach(t.reqId)}catch(o){return r.onError(o.message),2}if(a=s.state,g=a.requestId,a.error)return r.onError(a.error),2;let m;try{m=await _({promptText:t.objective,filePaths:t.files??[],cwd:p,scenarios:a.scenarios,isRefine:!0,conn:u,deps:v})}catch(o){if(o instanceof C){for(let h of o.errors)r.onError(h);return 2}return r.onError(o.message),2}for(let o of m.warnings)process.stderr.write(`warning: ${o}
20
20
  `);r.onStart({requestId:a.requestId,objectiveChars:m.promptText.length,scenarioLimit:t.scenarioLimit,perScenarioLimit:t.perScenarioLimit,isRefine:!0});try{await l.chat(t.reqId,m.promptText,{mappings:m.mappings,attachments:m.attachments})}catch(o){return r.onError(o.message),2}f=s.events}else{let s;try{s=await _({promptText:t.objective,filePaths:t.files??[],cwd:p,scenarios:[],isRefine:!1,conn:u,deps:v})}catch(o){if(o instanceof C){for(let h of o.errors)r.onError(h);return 2}return r.onError(o.message),2}for(let o of s.warnings)process.stderr.write(`warning: ${o}
21
- `);let m;try{m=await l.start({prompt:s.promptText,attachments:s.attachments,scenarioLimit:t.scenarioLimit,perScenarioLimit:t.perScenarioLimit,memoryEnhancement:t.memory})}catch(o){return r.onError(o.message),2}a=m.state,g=a.requestId,r.onStart({requestId:a.requestId,objectiveChars:s.promptText.length,scenarioLimit:t.scenarioLimit,perScenarioLimit:t.perScenarioLimit,isRefine:!1}),f=m.events}let w="";for await(let s of f){switch(a=P(a,s),s.type){case"thinking_done":r.onThinking({tookMs:s.tookMs});break;case"progress":r.onProgress(s.pct);break;case"clarification":r.onClarification(s.text);break;case"chat":r.onChat(s.text);break;case"error":r.onError(s.message);break;case"done":w=s.status;break;default:break}if(s.type==="done"||s.type!=="thinking"&&a.status&&T(a.status))break}r.onSnapshot(a);let b=w||a.status||"completed",c=Q(a.requestId);return r.onDone({requestId:a.requestId,status:b,scenarioCount:a.scenarios.length,caseCount:W(a),refineHint:c.refineHint,saveHint:c.saveHint,suiteDir:void 0}),oe(b)}finally{A(X)}}var ae=()=>{};async function Me(t){let e=new j,n=new q,r=e.getActiveProfile()??"default",l=t.env??e.getDefaultEnv()??"prod",u=R(l),d=new E;t.name&&d.setSessionName(t.name);let g=n.load().model,p=async()=>{let i=await k({creds:e,env:l,usernameFlag:t.username,accessKeyFlag:t.accessKey,log:()=>{}}),f=await V({resolver:i.resolver,env:u,log:ae,projectId:t.projectId,folderId:t.folderId,autoResolve:t.projectId?void 0:{creds:e,config:n,profile:r,envName:l}});return{client:G(f),conn:f,autoDefaulted:f.autoDefaulted??null}},v=async()=>{let i=await k({creds:e,env:l,usernameFlag:t.username,accessKeyFlag:t.accessKey,log:()=>{}});return i.basicAuth?{username:i.basicAuth.username,access_key:i.basicAuth.access_key}:i.token?{auth:{type:"bearer",token:i.token}}:{}};return{mode:t.mode,makeClient:p,materialize:(i,f,a)=>Y(i,f,{model:g,sessionId:d.sessionId,resolveAuth:v,spawnOpts:{environment:l},suiteName:a})}}export{Me as buildHeadlessDeps,Pe as decideGenerateMode,ie as defaultOutDir,Ge as parseFilesFlag,$e as resolveGenerateOp,Ne as runGenerateHeadless};
21
+ `);let m;try{m=await l.start({prompt:s.promptText,attachments:s.attachments,scenarioLimit:t.scenarioLimit,perScenarioLimit:t.perScenarioLimit,memoryEnhancement:t.memory})}catch(o){return r.onError(o.message),2}a=m.state,g=a.requestId,r.onStart({requestId:a.requestId,objectiveChars:s.promptText.length,scenarioLimit:t.scenarioLimit,perScenarioLimit:t.perScenarioLimit,isRefine:!1}),f=m.events}let w="";for await(let s of f){switch(a=P(a,s),s.type){case"thinking_done":r.onThinking({tookMs:s.tookMs});break;case"progress":r.onProgress(s.pct);break;case"clarification":r.onClarification(s.text);break;case"chat":r.onChat(s.text);break;case"error":r.onError(s.message);break;case"done":w=s.status;break;default:break}if(s.type==="done"||s.type!=="thinking"&&a.status&&T(a.status))break}r.onSnapshot(a);let b=w||a.status||"completed",c=Q(a.requestId);return r.onDone({requestId:a.requestId,status:b,scenarioCount:a.scenarios.length,caseCount:W(a),refineHint:c.refineHint,saveHint:c.saveHint,suiteDir:void 0}),oe(b)}finally{q(X)}}var ae=()=>{};async function Me(t){let e=new j,n=new A,r=e.getActiveProfile()??"default",l=t.env??e.getDefaultEnv()??"prod",u=R(l),d=new x;t.name&&d.setSessionName(t.name);let g=n.load().model,p=async()=>{let i=await k({creds:e,env:l,usernameFlag:t.username,accessKeyFlag:t.accessKey,log:()=>{}}),f=await V({resolver:i.resolver,env:u,log:ae,projectId:t.projectId,folderId:t.folderId,autoResolve:t.projectId?void 0:{creds:e,config:n,profile:r,envName:l}});return{client:G(f),conn:f,autoDefaulted:f.autoDefaulted??null}},v=async()=>{let i=await k({creds:e,env:l,usernameFlag:t.username,accessKeyFlag:t.accessKey,log:()=>{}});return i.basicAuth?{username:i.basicAuth.username,access_key:i.basicAuth.access_key}:i.token?{auth:{type:"bearer",token:i.token}}:{}};return{mode:t.mode,makeClient:p,materialize:(i,f,a)=>Y(i,f,{model:g,sessionId:d.sessionId,resolveAuth:v,spawnOpts:{environment:l},suiteName:a})}}export{Me as buildHeadlessDeps,Pe as decideGenerateMode,ie as defaultOutDir,Ge as parseFilesFlag,$e as resolveGenerateOp,Ne as runGenerateHeadless};
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{a,b,c}from"./chunk-TZXXJWHA.js";import"./chunk-UR6MHSHU.js";export{a as mobileHostSupport,b as mobileSupported,c as mobileUnsupportedMessage};