@testmuai/kane-cli 0.6.7 → 0.6.8

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 (162) hide show
  1. package/dist/ChatSurface-QLRMFZJG.js +8 -0
  2. package/dist/{ChromeProfilePicker-IW3K43VC.js → ChromeProfilePicker-FJOUNY2B.js} +1 -1
  3. package/dist/{CliFeedbackPrompt-ZJ4LZGPK.js → CliFeedbackPrompt-HC4NNBTK.js} +1 -1
  4. package/dist/{CliUploadProgress-SMPVN7Q6.js → CliUploadProgress-VIEZQNZ5.js} +1 -1
  5. package/dist/{ConfigView-RTAGKZH4.js → ConfigView-LK5F4F7W.js} +1 -1
  6. package/dist/EvidenceViewOffer-HZ4WZKGM.js +2 -0
  7. package/dist/{FolderPicker-QUY7LNVZ.js → FolderPicker-3S57MSC6.js} +1 -1
  8. package/dist/{HelpView-47J2NZWJ.js → HelpView-BQ3TS7WE.js} +1 -1
  9. package/dist/{InfoBox-G63WZAMH.js → InfoBox-4HVXV3TD.js} +1 -1
  10. package/dist/{LinksBox-2HIHDT5K.js → LinksBox-3B2KO5S4.js} +1 -1
  11. package/dist/{ProfilesView-TUXQXPXJ.js → ProfilesView-FLRMROUR.js} +1 -1
  12. package/dist/{ProjectPicker-VUABWG2P.js → ProjectPicker-R3KLRGHH.js} +1 -1
  13. package/dist/{SaveSessionPrompt-PNVGNLGO.js → SaveSessionPrompt-P7HSG7R7.js} +1 -1
  14. package/dist/SingleShotApp-ZBZY7KGR.js +2 -0
  15. package/dist/{SummaryBox-36MDDDYQ.js → SummaryBox-HCDIWKPS.js} +1 -1
  16. package/dist/TestMdRunView-GQP2QGFU.js +2 -0
  17. package/dist/{WhoamiView-LHU6RGIY.js → WhoamiView-ZD6FIBMK.js} +1 -1
  18. package/dist/{bind-E67W2DXG.js → bind-RSVQXQJT.js} +2 -2
  19. package/dist/{bridge-WVFTWHKP.js → bridge-D2HETW5M.js} +1 -1
  20. package/dist/{changelog-D4Y5QJIZ.js → changelog-QB7S4VV4.js} +1 -1
  21. package/dist/chat-committer-MWZ4JQMM.js +2 -0
  22. package/dist/chat-controller-YX5A7R52.js +2 -0
  23. package/dist/{chunk-3GOZ7R4G.js → chunk-27GF2OQ7.js} +3 -3
  24. package/dist/{chunk-GAD6IBZ6.js → chunk-35RV2AAV.js} +8 -8
  25. package/dist/{chunk-7ZMYAXES.js → chunk-3BIEIXJK.js} +1 -1
  26. package/dist/{chunk-UZWOHCFX.js → chunk-4GXOBABK.js} +1 -1
  27. package/dist/chunk-5VC7MBHR.js +2 -0
  28. package/dist/{chunk-XUHVQ5VL.js → chunk-66LXV7NN.js} +1 -1
  29. package/dist/{chunk-JR37W7IJ.js → chunk-6WHKJSMJ.js} +1 -1
  30. package/dist/{chunk-BBZBXSTP.js → chunk-A6TFZQV6.js} +1 -1
  31. package/dist/{chunk-AASBJJCU.js → chunk-ATO6NM45.js} +1 -1
  32. package/dist/{chunk-LVWB6TB2.js → chunk-AXJIXRYF.js} +1 -1
  33. package/dist/{chunk-RBLZUDMZ.js → chunk-B22NUHB2.js} +2 -2
  34. package/dist/chunk-BLHCGRSK.js +11 -0
  35. package/dist/chunk-BSFONZ2E.js +2 -0
  36. package/dist/{chunk-Z34XRBKQ.js → chunk-BUVRZXO3.js} +1 -1
  37. package/dist/{chunk-G5CYSC23.js → chunk-D4WLVWJQ.js} +1 -1
  38. package/dist/{chunk-3CY3DZDH.js → chunk-D5IZ77YG.js} +2 -2
  39. package/dist/{chunk-UQVKNUYO.js → chunk-ELN3EN4K.js} +1 -1
  40. package/dist/{chunk-QG6LJCZG.js → chunk-EQORZ6RT.js} +1 -1
  41. package/dist/chunk-EYZWG32F.js +13 -0
  42. package/dist/{chunk-TADJIOHV.js → chunk-F4FXE466.js} +1 -1
  43. package/dist/chunk-FCMLIK7P.js +2 -0
  44. package/dist/{chunk-TSWGQKUK.js → chunk-FCZ2YFD3.js} +2 -2
  45. package/dist/{chunk-QVJ7C4GW.js → chunk-GFKIE3AL.js} +1 -1
  46. package/dist/chunk-GG43HSU2.js +3 -0
  47. package/dist/{chunk-KVAALPTA.js → chunk-GO4CBUB6.js} +1 -1
  48. package/dist/{chunk-RWIHSR4H.js → chunk-HCWEZCKP.js} +1 -1
  49. package/dist/{chunk-SK2GVMTJ.js → chunk-IQFUBT6Z.js} +1 -1
  50. package/dist/{chunk-77PBBYRZ.js → chunk-JKHQBGFY.js} +2 -2
  51. package/dist/{chunk-3NR6OTHL.js → chunk-K4ERF7GT.js} +1 -1
  52. package/dist/chunk-K4LCN5X4.js +6 -0
  53. package/dist/{chunk-NEHF4C6X.js → chunk-K7P6VNLI.js} +1 -1
  54. package/dist/chunk-L3HG5ONB.js +4 -0
  55. package/dist/chunk-LEA6IHXC.js +2 -0
  56. package/dist/{chunk-RGQIBS32.js → chunk-MEHEGW3V.js} +1 -1
  57. package/dist/{chunk-WFQUDSKY.js → chunk-N5YIMTGV.js} +1 -1
  58. package/dist/{chunk-QYTMD6NM.js → chunk-NKCXCCPM.js} +1 -1
  59. package/dist/{chunk-DL5CXC64.js → chunk-NKUA3TSO.js} +1 -1
  60. package/dist/chunk-NVGTSXCJ.js +9 -0
  61. package/dist/{chunk-IX34JIXK.js → chunk-OYOTWI53.js} +1 -1
  62. package/dist/{chunk-X47VFBIV.js → chunk-PV4EDQY4.js} +1 -1
  63. package/dist/{chunk-NMKZHHB6.js → chunk-PXPXK4Q7.js} +1 -1
  64. package/dist/{chunk-EDM6YACR.js → chunk-Q3WHZ26R.js} +1 -1
  65. package/dist/{chunk-WJG4ZPUH.js → chunk-QFD6CB4P.js} +1 -1
  66. package/dist/chunk-QM4S2APK.js +2 -0
  67. package/dist/{chunk-OPDJD7WS.js → chunk-QOGQBVTP.js} +2 -2
  68. package/dist/{chunk-I37UOX73.js → chunk-QZ7DZXLQ.js} +3 -3
  69. package/dist/chunk-SHAA6FOD.js +11 -0
  70. package/dist/{chunk-6EC54ZHT.js → chunk-TAUSKB3O.js} +1 -1
  71. package/dist/{chunk-A2AZQ4PQ.js → chunk-TBXIOT6M.js} +1 -1
  72. package/dist/chunk-TFVMSEIA.js +2 -0
  73. package/dist/{chunk-5J3HQZNU.js → chunk-TRXNJZSL.js} +1 -1
  74. package/dist/{chunk-FYSWQ4K7.js → chunk-VRVSOGXH.js} +1 -1
  75. package/dist/{chunk-MTG2LRGV.js → chunk-VZHXNQDO.js} +1 -1
  76. package/dist/chunk-XSAZDIQV.js +347 -0
  77. package/dist/chunk-XWIN3S7O.js +4 -0
  78. package/dist/{chunk-YB54MHKU.js → chunk-YEMR62WY.js} +1 -1
  79. package/dist/{chunk-GLVDOR5G.js → chunk-YKZIACYJ.js} +1 -1
  80. package/dist/{chunk-TTJ4XMWP.js → chunk-YTK3IQUB.js} +1 -1
  81. package/dist/{config-BZ7C5NU5.js → config-JV7HNJ3I.js} +1 -1
  82. package/dist/cover-cmd-L2HSVDLH.js +2 -0
  83. package/dist/{credentials-BPJL6YIZ.js → credentials-TQW3TT2I.js} +1 -1
  84. package/dist/dossier-ZHSHATVU.js +3 -0
  85. package/dist/evidence-ZFYDHO73.js +2 -0
  86. package/dist/evolve-cmd-YGJECGND.js +2 -0
  87. package/dist/{explain-cmd-AG6ZDXV6.js → explain-cmd-327F6ESA.js} +1 -1
  88. package/dist/{explain-cmd-NZPC6537.js → explain-cmd-E366QTAD.js} +1 -1
  89. package/dist/extract-bind-7UZXDON6.js +5 -0
  90. package/dist/{extract-cmd-4PGUDJMU.js → extract-cmd-TQ2MYXOG.js} +1 -1
  91. package/dist/gaps-cmd-IAEXXESW.js +2 -0
  92. package/dist/{generate-headless-NZUDYIKJ.js → generate-headless-XXECVP6L.js} +2 -2
  93. package/dist/index.js +12 -12
  94. package/dist/ingest-CBQAXVH6.js +2 -0
  95. package/dist/ingest-cmd-JN6PLDE3.js +3 -0
  96. package/dist/interactive-bind-WA2YVAUW.js +7 -0
  97. package/dist/lifecycle-cmd-KZOC4WDW.js +2 -0
  98. package/dist/list-cmd-6X5U46RD.js +3 -0
  99. package/dist/{list-commands-55RCFEOL.js → list-commands-I577A5LK.js} +1 -1
  100. package/dist/logical-ids-RFGWBVML.js +2 -0
  101. package/dist/login-flow-OVEZXSMW.js +2 -0
  102. package/dist/{persist-recorded-session-HK7JUONC.js → persist-recorded-session-DT3K6ZYQ.js} +1 -1
  103. package/dist/pipeline-5N7HWGAL.js +2 -0
  104. package/dist/readmodel-V3DVL6NP.js +2 -0
  105. package/dist/reconcile-cmd-HYYH3SZS.js +2 -0
  106. package/dist/{recording-banner-5IYX2KBV.js → recording-banner-QI77ERTZ.js} +1 -1
  107. package/dist/{require-project-folder-J4Q4FRQ4.js → require-project-folder-2UAXXZA4.js} +1 -1
  108. package/dist/review-cmd-XVWPSWU2.js +4 -0
  109. package/dist/run-RYIYWV63.js +2 -0
  110. package/dist/run-VMKZDO7J.js +2 -0
  111. package/dist/{run-test-md-WN6BH3PC.js → run-test-md-DKRJOUFA.js} +2 -2
  112. package/dist/{skill-installer-4HYPUBNB.js → skill-installer-TK5REDD6.js} +1 -1
  113. package/dist/{spawner-VD6YFZ43.js → spawner-K7LWPNIC.js} +1 -1
  114. package/dist/tcg-generate-6EJLU5KX.js +2 -0
  115. package/dist/{testmd-actions-LT5FNIR6.js → testmd-actions-Q2XWL7P5.js} +1 -1
  116. package/dist/token-refresh-NQZJEUQE.js +2 -0
  117. package/dist/{validate-basic-XWGKC5VF.js → validate-basic-XEJGB4GN.js} +1 -1
  118. package/dist/{version-check-6FDTS6MK.js → version-check-IT7T5YKJ.js} +1 -1
  119. package/dist/{view-cmd-PCDG3FIC.js → view-cmd-G4PGJRQH.js} +3 -3
  120. package/dist/walk-session-HCTG4LN2.js +2 -0
  121. package/package.json +6 -6
  122. package/dist/ChatSurface-Y2M6HB2R.js +0 -8
  123. package/dist/EvidenceViewOffer-LHPIZUGQ.js +0 -2
  124. package/dist/SingleShotApp-BZV5CULT.js +0 -2
  125. package/dist/TestMdRunView-A655PMEY.js +0 -2
  126. package/dist/chat-committer-WOTCC7L3.js +0 -2
  127. package/dist/chat-controller-MONWZKS7.js +0 -4
  128. package/dist/chunk-64LC36AF.js +0 -2
  129. package/dist/chunk-6PS65QFF.js +0 -2
  130. package/dist/chunk-CIFVUX3B.js +0 -4
  131. package/dist/chunk-DCWCANNS.js +0 -6
  132. package/dist/chunk-GBBVP2JW.js +0 -2
  133. package/dist/chunk-IYTHPCQ2.js +0 -356
  134. package/dist/chunk-NMZATEKQ.js +0 -9
  135. package/dist/chunk-QHFUDBQH.js +0 -2
  136. package/dist/chunk-R7NNIQMH.js +0 -11
  137. package/dist/chunk-RE3BZVGE.js +0 -3
  138. package/dist/chunk-VLC24QVT.js +0 -2
  139. package/dist/chunk-Y6HPW2OQ.js +0 -2
  140. package/dist/chunk-YTZUYCFZ.js +0 -2
  141. package/dist/chunk-YZBLBPOE.js +0 -13
  142. package/dist/cover-cmd-DN5D6A3S.js +0 -2
  143. package/dist/evidence-E5B24ZO6.js +0 -2
  144. package/dist/evolve-cmd-V7H4PLCX.js +0 -2
  145. package/dist/extract-bind-3QBBCWYE.js +0 -5
  146. package/dist/gaps-cmd-42LPHWFP.js +0 -2
  147. package/dist/ingest-GOKIMEP4.js +0 -2
  148. package/dist/ingest-cmd-BTYHVJ33.js +0 -3
  149. package/dist/interactive-bind-TKRWAPJU.js +0 -7
  150. package/dist/lifecycle-cmd-E6AXODQD.js +0 -2
  151. package/dist/list-cmd-RJVLH2GR.js +0 -3
  152. package/dist/logical-ids-QZQRQ3TV.js +0 -2
  153. package/dist/login-flow-WNIHDQXF.js +0 -2
  154. package/dist/pipeline-FTLXJQRT.js +0 -2
  155. package/dist/readmodel-KTNI6QDC.js +0 -2
  156. package/dist/reconcile-cmd-5XC4AUSJ.js +0 -2
  157. package/dist/review-cmd-XB2DCTMZ.js +0 -4
  158. package/dist/run-2RFR2ASQ.js +0 -2
  159. package/dist/run-3ZYJQBBC.js +0 -2
  160. package/dist/tcg-generate-77QKMB63.js +0 -2
  161. package/dist/token-refresh-PCOAZBKK.js +0 -2
  162. package/dist/walk-session-YS62CWX5.js +0 -2
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{a as re,b as oe}from"./chunk-SHAA6FOD.js";import{a as x,b as J,d as ie}from"./chunk-GRB66C5S.js";import"./chunk-RN4OSVTG.js";import{a as X,b as Z,c as ee,d as te,e as ne,f as se}from"./chunk-FCMLIK7P.js";import{e as Q,f as L}from"./chunk-CJJXT5DO.js";import{a as I,b as W,c as M,d as K}from"./chunk-QM4S2APK.js";import"./chunk-ZPDM6FO7.js";import"./chunk-BC7UVJJB.js";import{e as Y}from"./chunk-EHN5HTUD.js";import{a as V}from"./chunk-L5LI2JF4.js";import{a as B}from"./chunk-LEA6IHXC.js";import"./chunk-RGDQMKNJ.js";import"./chunk-L3HG5ONB.js";import"./chunk-L4JIMNKW.js";import"./chunk-MBXWXBDM.js";import"./chunk-IAHKTEET.js";import{d as R,e as U}from"./chunk-5YPBPZUR.js";import"./chunk-UR6MHSHU.js";import{basename as j}from"path";import{statSync as Re}from"fs";function ye(e,t){return e.length===0?"not_run":ee(e,t).verified?"proven":Z(e,t).some(n=>n.verdict==="failed")?"failing":"blocked"}function ce(e,t){let s=null;for(let{cid:p}of e.byLabel(R.TEST))for(let o of e.execHistory(p))(!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=X[t],r=se(e),c=te(r).aspects[t],i={},d={},l=0,f=0,a=0;for(let p of r.usecases){let o=[];for(let y of p.acceptance_criteria){let u=y.executions??[],_=ye(u,n);o.push(_),_==="failing"?l++:_==="blocked"?f++:_==="not_run"&&a++;let A=[],b;if(_==="failing"){let $=null;for(let P of y.covered_by){let w=e.execHistory(P).map(k=>({verdict:String(k.per_ac?.find(E=>E.ac_ref===y.id)?.verdict??k.verdict),oracle_mode:String(k.oracle_mode),ts:String(k.started_at),execution_id:String(k.execution_id)})).filter(k=>n.counted_verdicts.includes(k.verdict)&&n.accepted_oracle_modes.includes(k.oracle_mode)),O=w[w.length-1];O?.verdict==="failed"&&(A.push(P),(!$||O.ts>$.ts)&&($={ts:O.ts,execution_id:O.execution_id}))}b=$?.execution_id}else _==="blocked"&&(b=u[u.length-1]?.execution_id);i[y.id]={state:_,viaTests:A,...b?{executionId:b}:{}}}let m=o.some(y=>y!=="not_run"),g=c.usecases[p.id],h=m?g.status==="covered"?"proven":g.status==="partial"?"partial":o.includes("failing")?"failing":o.includes("blocked")?"blocked":"not_run":"not_run";d[p.id]={pct:g.pct,status:h}}return{aspect:t,pct:c.summary.coverage_pct,acs_proven:c.summary.acs_verified,failing:l,blocked:f,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"},G={high:0,med:1,low:2};function q(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 F(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 de(e,t=5){let s=e.trim().split(/\s+/);return s.slice(0,t).join(" ")+(s.length>t?"\u2026":"")}function $e(e,t){let s=e.resolve(t),n=s?e.getNode(e.tipOf(s.cid))?.content:null;return String(n?.title??n?.text??"")}function ae(e,t){let s=e.resolve(t);return{id:s?e.displayNameOf(e.tipOf(s.cid))??e.displayNameOf(s.cid):null,title:de($e(e,t),8)}}function ke(e,t){let s=e.resolve(t);if(!s)return null;let n=e.tipOf(s.cid);if(!I(e,n))return null;let r=e.nodeLabel.get(n);if(r===R.USECASE)return n;if(r===R.AC)return M(e,n);if(r===R.TEST){let c=e.edgesFrom(n).find(d=>d.type===U.VERIFIES&&I(e,d.dst));if(c)return M(e,c.dst);let i=e.edgesFrom(n).find(d=>d.type===U.AUTOMATES&&I(e,d.dst));if(i){let d=e.edgesFrom(i.dst).find(l=>l.type===U.BELONGS_TO&&I(e,l.dst));return d?d.dst:null}}return null}function N(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 pe(e,t,s,n,r){let c=r.servePaths??new Map,i=e.byLabel(R.USECASE).filter(({cid:o})=>I(e,o)),d=new Map(i.map(o=>[o.cid,o])),l=new Map(i.map(({cid:o})=>[o,[]])),f=[];for(let o of t){if(o.stage!=="design")continue;let m={...o,...ae(e,o.ref)},g=ke(e,o.ref),h=g?l.get(g):void 0;h&&N(o)!=="other"?h.push(m):f.push(m)}let a=new Map(i.map(({cid:o})=>[o,{total:0,designed:0}]));for(let{cid:o}of e.byLabel(R.AC)){if(!I(e,o))continue;let m=M(e,o),g=m?a.get(m):void 0;if(!g)continue;g.total++;let h=W(e,o);if(h&&g.designed++,!n)continue;let y=e.nameOf.get(o)??o,u=n.perAc[y];if(!u)continue;let{id:_,title:A}=ae(e,y),b={ref:e.displayNameOf(o)??o,id:_,title:A,risk:xe(e,y),stage:"cover"},$=l.get(m);u.state==="failing"?$.push({...b,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(P=>r.testFiles.get(P)??null)}:{}}):u.state==="blocked"?$.push({...b,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"&&h&&$.push({...b,kind:"covered-not-run",tag:"reuse-candidate",why:"a covering test exists but has not run yet",ready_command:"kane-cli testrun run"})}let p=[];for(let{cid:o,content:m}of i){let g=e.displayNameOf(o)??o,h=e.nameOf.get(o)??o,y=s.perUc[g]??{pct:0,status:"undesigned",staleAcs:0},u=n?n.perUc[h]??{pct:0,status:"not_run"}:null,_=n!==null&&(u===null||u.status==="not_run"),A=a.get(o),b=l.get(o)??[],$=new Set(b.filter(v=>N(v)==="needs-refresh").map(v=>v.ref)),P=b.some(v=>N(v)==="needs-tests"&&$.has(v.ref)),w=[];for(let v of be){let T=b.filter(S=>N(S)===v);if(v==="needs-tests"&&(T=T.filter(S=>!$.has(S.ref))),T.length===0)continue;T.sort((S,H)=>(G[S.risk]??3)-(G[H.risk]??3)||q(S.ref,H.ref));let ve=v==="failing"||v==="blocked"||T.length<=2||new Set(T.map(S=>S.ready_command)).size>1;w.push({key:v,label:_e[v],...v==="needs-refresh"?{suffix:"source moved since these were designed"}:{},alsoNeedsTests:v==="needs-refresh"&&P,rows:T,...ve?{}:{rosterCommand:T[0].ready_command}})}let O=w.some(v=>v.key==="failing"),k=w.some(v=>v.key==="blocked"),E=y.pct===100&&(n===null||u?.pct===100)&&w.length===0,me=u!==null&&u.pct>0,he=O?"\u2717":k?"\u23F8":E?"\u2714":y.pct===0&&!me?"\u2716":"\u25D0";p.push({slug:g,title:String(m.title??""),risk:String(m.risk??""),des:y,prov:u,provAbsent:_,acTotal:A.total,acDesigned:A.designed,mark:he,collapse:E,groups:w})}return p.sort((o,m)=>(G[o.risk]??3)-(G[m.risk]??3)||q(o.slug,m.slug)),f.sort((o,m)=>(G[o.risk]??3)-(G[m.risk]??3)||q(o.ref,m.ref)),{stage:r.stage,aspect:r.aspect,top:r.top,dc:s,pa:n,ucs:p,other:f}}function C(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 D(e,t){return e==="all"||t.stage===e}function fe(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)} ${C(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 f=[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)} ${C(n.pct,10)} ${String(n.pct).padStart(3)}% \u2014 ${n.acs_proven} proven by execution`+(f.length?` \xB7 ${f.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)} ${C(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 f=e.top??1/0;for(let a of l.groups){let p=a.rows.filter(h=>D(e.stage,h));if(p.length===0)continue;if(d=!0,f<=0){i.push(c(` \u2026 +${p.length} more ${a.label}`));continue}let o=p.slice(0,f),m=p.length-o.length;if(f-=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 g=(a.suffix?` \u2014 ${a.suffix}`:"")+(a.alsoNeedsTests?" \u2014 also needs tests":"");if(i.push(` ${a.label} (${p.length})${g}`),a.rosterCommand&&a.key!=="failing"&&a.key!=="blocked")Se(i,o,r),i.push(c(` \u2192 ${a.rosterCommand}`));else for(let h of o)Te(i,h,a.key,c);m>0&&i.push(c(` \u2026 +${m} more ${a.label}`))}}return!d&&e.ucs.every(l=>l.groups.every(f=>f.rows.filter(a=>D(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=F(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`,f=` ${e.mark} ${C(e.des.pct,10)} ${String(e.des.pct).padStart(3)}% ${n} `,a=Math.max(0,s-f.length-l.length-2);return`${f}${le(e.title,a).padEnd(a)} ${l}`}let r=e.provAbsent?"prov \xB7 not run":`prov ${C(e.prov?.pct??0,8)} ${String(e.prov?.pct??0).padStart(3)}%`,c=`des ${C(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}${le(e.title,d).padEnd(d)} ${c}`}function le(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=F(t.id??t.ref);if(s==="failing"){let c=(t.via_tests??[]).map((d,l)=>`${F(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 Se(e,t,s){let n=t.map(c=>`${F(c.id??c.ref)} ${de(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 ge(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=>D(e.stage,c))).map(ue)})),other:e.other.filter(r=>D(e.stage,r)).map(ue)}}function ue(e){let{servePath:t,viaFiles:s,meta:n,...r}=e;return{...r}}async function Ae(e){let t=await Q(e);return t.length===0?null:t.map(s=>({p:s,m:Re(s).mtimeMs})).sort((s,n)=>n.m-s.m)[0].p}async function Qe(e,t=ie(),s=process.cwd()){if(e.flat)return Ie(e,t,s);let n=e.stage??"all";if(n!=="design"&&n!=="cover"&&n!=="all")return x(t,`--stage must be design | cover | all, got '${n}'`),2;if(e.top!==void 0&&(!Number.isInteger(e.top)||e.top<1))return x(t,"--top must be a positive integer"),2;let r=e.aspect??"lenient";if(r!=="lenient"&&r!=="strict")return x(t,`--aspect must be lenient | strict, got '${r}'`),2;if(e.from)return x(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=J(s,t);if(!c)return 2;let i=B(c),d=ne(i),l=ce(i,r),f=await K(i,"design"),a=new Map;if(l)for(let g of Object.values(l.perAc)){if(!g.executionId||a.has(g.executionId))continue;let h=await L(g.executionId,s);h&&a.set(g.executionId,h)}let p=new Map;for(let[g,h]of oe(re(s)))h.length===1&&p.set(g,j(h[0]));let o=pe(i,f,d,l,{stage:n,top:e.top,aspect:r,servePaths:a,testFiles:p});if(e.json)return t.out(JSON.stringify(ge(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 g of fe(o,{width:m,color:t.isTTY}))t.out(g);return 0}async function Ie(e,t,s){let n=e.stage??"design";if(n!=="design"&&n!=="cover"&&n!=="all")return x(t,`--stage must be design | cover | all, got '${n}'`),2;if(e.top!==void 0&&(!Number.isInteger(e.top)||e.top<1))return x(t,"--top must be a positive integer"),2;let r=J(s,t);if(!r)return 2;let c,i;if(n!=="design"){let a=e.from?await L(e.from,s):await Ae(s);if(!a)return x(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 p=await Y(a,"coverage/usecases.yaml");if(p==null)return x(t,`${j(a)} carries no coverage/usecases.yaml \u2014 re-run the tests to produce a coverage-bearing pack`),2;let o=V(p);if(!o||!Array.isArray(o.usecases))return x(t,`${j(a)}: coverage/usecases.yaml is not a usecases document`),2;c=o,i=j(a)}let d=B(r),l=await K(d,n,void 0,c),f=l.length;if(e.top!==void 0&&(l=l.slice(0,e.top)),e.json){let a=l.map(p=>Pe(d,p));return t.out(JSON.stringify({stage:n,...i?{pack:i}:{},total:f,rows:a},null,2)),0}return t.out(`gaps \u2014 stage ${n}${i?` \xB7 pack ${i}`:""} (${l.length}${l.length<f?` of ${f}`:""})`),l.length===0&&t.out(" nothing owed \u2014 design and execution are square"),l.forEach((a,p)=>{t.out(` ${String(p+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{Qe 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-AASBJJCU.js";import{b as k}from"./chunk-YB54MHKU.js";import{d as J}from"./chunk-G5CYSC23.js";import{c as E}from"./chunk-SK2GVMTJ.js";import"./chunk-NEHF4C6X.js";import{a as q}from"./chunk-QYTMD6NM.js";import"./chunk-QVJ7C4GW.js";import"./chunk-DL5CXC64.js";import"./chunk-FPFOW6BS.js";import"./chunk-WAOCHXJ5.js";import"./chunk-L5LI2JF4.js";import{e as x,f as A}from"./chunk-M5JQXOCE.js";import{h as H}from"./chunk-TTJ4XMWP.js";import"./chunk-2WVKOZ6W.js";import"./chunk-NLCCBXXV.js";import"./chunk-RZ4F3BHX.js";import{a as R}from"./chunk-3NR6OTHL.js";import"./chunk-VE3SUJMA.js";import{a as j}from"./chunk-Z34XRBKQ.js";import"./chunk-NMKZHHB6.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-ATO6NM45.js";import{b as k}from"./chunk-YEMR62WY.js";import{d as J}from"./chunk-D4WLVWJQ.js";import{c as E}from"./chunk-IQFUBT6Z.js";import"./chunk-K7P6VNLI.js";import{a as q}from"./chunk-NKCXCCPM.js";import"./chunk-GFKIE3AL.js";import"./chunk-NKUA3TSO.js";import"./chunk-FPFOW6BS.js";import"./chunk-WAOCHXJ5.js";import"./chunk-L5LI2JF4.js";import{e as x,f as A}from"./chunk-M5JQXOCE.js";import{h as H}from"./chunk-YTK3IQUB.js";import"./chunk-2WVKOZ6W.js";import"./chunk-NLCCBXXV.js";import"./chunk-RZ4F3BHX.js";import{a as R}from"./chunk-K4ERF7GT.js";import"./chunk-VE3SUJMA.js";import{a as j}from"./chunk-BUVRZXO3.js";import"./chunk-PXPXK4Q7.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-J4Q4FRQ4.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-2UAXXZA4.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}
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
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};