@testmuai/kane-cli 0.6.3 → 0.6.6

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 (174) hide show
  1. package/bin/kane-cli.cjs +91 -0
  2. package/bin/resolve-runtime.cjs +45 -0
  3. package/dist/ChatSurface-LV3KW6WN.js +8 -0
  4. package/dist/{ChromeProfilePicker-UUGUMJPI.js → ChromeProfilePicker-6PLUQ5TW.js} +1 -1
  5. package/dist/{CliFeedbackPrompt-JZWESL7Z.js → CliFeedbackPrompt-I4F56IVK.js} +1 -1
  6. package/dist/{CliUploadProgress-62U3LAUU.js → CliUploadProgress-ULRSPKY3.js} +1 -1
  7. package/dist/{ConfigView-WHEFCVHR.js → ConfigView-7NMYALEA.js} +1 -1
  8. package/dist/EvidenceViewOffer-KQKPTMXA.js +2 -0
  9. package/dist/{FolderPicker-HJUUHQEI.js → FolderPicker-4IOVDO2P.js} +1 -1
  10. package/dist/{HelpView-EWHP7LSJ.js → HelpView-SHMVMHNU.js} +1 -1
  11. package/dist/{InfoBox-GQQJVTI5.js → InfoBox-W2LZVGQS.js} +1 -1
  12. package/dist/{LinksBox-EWCPAZFN.js → LinksBox-ZS25VTBY.js} +1 -1
  13. package/dist/{ProfilesView-5FJNQMUW.js → ProfilesView-XBBRIQ3U.js} +1 -1
  14. package/dist/{ProjectPicker-IN7GFN7I.js → ProjectPicker-AUN47FXS.js} +1 -1
  15. package/dist/{SaveSessionPrompt-ISODGFP7.js → SaveSessionPrompt-Z2K225VN.js} +1 -1
  16. package/dist/SingleShotApp-M7R5PW4X.js +2 -0
  17. package/dist/{SummaryBox-R6WHU7VD.js → SummaryBox-4T545XRB.js} +1 -1
  18. package/dist/TestMdRunView-JXRXMACE.js +2 -0
  19. package/dist/{WhoamiView-YRQNOSOH.js → WhoamiView-GCVD35EX.js} +1 -1
  20. package/dist/bind-JLMT57Q3.js +6 -0
  21. package/dist/{bridge-7UMWMIJJ.js → bridge-PDJEOSAJ.js} +1 -1
  22. package/dist/{changelog-YQC2QDCO.js → changelog-D65HWZDM.js} +1 -1
  23. package/dist/{chat-committer-GHDZY5XF.js → chat-committer-ADJJTDUT.js} +1 -1
  24. package/dist/{chat-controller-QXFAB2DK.js → chat-controller-VAC57IEV.js} +1 -1
  25. package/dist/{chunk-B5LJCGAY.js → chunk-24OFJ7SE.js} +1 -1
  26. package/dist/{chunk-PJDOXRLB.js → chunk-24VYAMMK.js} +1 -1
  27. package/dist/chunk-262ES67I.js +14 -0
  28. package/dist/{chunk-CIW2KP4C.js → chunk-2BWRAY3Y.js} +1 -1
  29. package/dist/{chunk-KHDUQ33H.js → chunk-2PQXEEVY.js} +1 -1
  30. package/dist/{chunk-F66SSA4C.js → chunk-2WO7G2HO.js} +1 -1
  31. package/dist/{chunk-Y6LMHBLE.js → chunk-32GP7KTM.js} +1 -1
  32. package/dist/{chunk-NNZV5RCE.js → chunk-3C5GMAM4.js} +1 -1
  33. package/dist/{chunk-SHSV64GX.js → chunk-3Z3UIW5H.js} +1 -1
  34. package/dist/{chunk-OE7TVGNB.js → chunk-4A6BLXQN.js} +3 -3
  35. package/dist/chunk-4R2HOA7J.js +14 -0
  36. package/dist/{chunk-AV5SUGRY.js → chunk-4SXD6XWV.js} +1 -1
  37. package/dist/{chunk-FFL2TQEJ.js → chunk-5JJ245FW.js} +1 -1
  38. package/dist/chunk-5YPBPZUR.js +2 -0
  39. package/dist/chunk-64LC36AF.js +2 -0
  40. package/dist/{chunk-Z56AWGVY.js → chunk-6AYUSR7X.js} +1 -1
  41. package/dist/{chunk-Y7KW5AEN.js → chunk-6CZIEK6B.js} +1 -1
  42. package/dist/{chunk-VJUIW2ES.js → chunk-6GTOYTCQ.js} +1 -1
  43. package/dist/{chunk-EWFFJBAM.js → chunk-6NIV7AVZ.js} +1 -1
  44. package/dist/chunk-6SGPN76K.js +2 -0
  45. package/dist/{chunk-7MV5UF6O.js → chunk-6XHAXAL2.js} +1 -1
  46. package/dist/{chunk-AE6SS34N.js → chunk-74RUSHIB.js} +1 -1
  47. package/dist/{chunk-RLG5NUTE.js → chunk-AKHUNBQS.js} +1 -1
  48. package/dist/{chunk-53VDR5DN.js → chunk-BLSZ4H5W.js} +12 -12
  49. package/dist/{chunk-OGVIHL5G.js → chunk-BV5QKFMJ.js} +1 -1
  50. package/dist/{chunk-SL7AJ7JQ.js → chunk-C42WWO7Y.js} +1 -1
  51. package/dist/{chunk-FYOCF7DY.js → chunk-CJJXT5DO.js} +1 -1
  52. package/dist/chunk-D7L6UW5Z.js +7 -0
  53. package/dist/chunk-EHN5HTUD.js +147 -0
  54. package/dist/{chunk-P46TIMGQ.js → chunk-EOLQUB4Q.js} +1 -1
  55. package/dist/{chunk-C5POEXSX.js → chunk-EWTX7HSU.js} +2 -2
  56. package/dist/{chunk-RGEAEAZB.js → chunk-FJTWJ243.js} +1 -1
  57. package/dist/{chunk-CE664P73.js → chunk-GBBVP2JW.js} +1 -1
  58. package/dist/chunk-GLS46X7N.js +5 -0
  59. package/dist/{chunk-AD46OCZ4.js → chunk-GRB66C5S.js} +1 -1
  60. package/dist/{chunk-22A2ECA2.js → chunk-GYW7LVVL.js} +1 -1
  61. package/dist/{chunk-BO3JA2GS.js → chunk-HA5GE57Z.js} +15 -15
  62. package/dist/{chunk-VXGOWBET.js → chunk-HWA7WD44.js} +1 -1
  63. package/dist/{chunk-7YQW4TFI.js → chunk-JF7Q2I45.js} +1 -1
  64. package/dist/{chunk-TTSYHJLX.js → chunk-JTEY32TL.js} +1 -1
  65. package/dist/{chunk-DEEBPSJN.js → chunk-JU5KRCKD.js} +4 -4
  66. package/dist/chunk-JV356AYH.js +5 -0
  67. package/dist/chunk-K5JGCJ2K.js +6 -0
  68. package/dist/{chunk-UXJPCWGW.js → chunk-KI2DVQSA.js} +1 -1
  69. package/dist/chunk-KNCHEM6A.js +9 -0
  70. package/dist/{chunk-YZSYXNMB.js → chunk-KYHXDJN4.js} +1 -1
  71. package/dist/{chunk-326XAPMW.js → chunk-L26LU6TU.js} +2 -2
  72. package/dist/{chunk-WFRL54GK.js → chunk-LABIRPOT.js} +1 -1
  73. package/dist/{chunk-BFFCGEUH.js → chunk-LEQ2B3PR.js} +1 -1
  74. package/dist/{chunk-EEO4XWY6.js → chunk-LLS47HUA.js} +1 -1
  75. package/dist/{chunk-2S4S2XJC.js → chunk-LURGFJEE.js} +1 -1
  76. package/dist/{chunk-D5T4ARTB.js → chunk-MCQXRJGH.js} +1 -1
  77. package/dist/{chunk-2TVRHXRK.js → chunk-MSPZOEFB.js} +1 -1
  78. package/dist/{chunk-YZKPZXHY.js → chunk-MY32TBBR.js} +1 -1
  79. package/dist/{chunk-BGGNBWAJ.js → chunk-N6DO2LBH.js} +1 -1
  80. package/dist/{chunk-ARS72637.js → chunk-OFEOWKM3.js} +1 -1
  81. package/dist/{chunk-TZZYRDCF.js → chunk-P4HW2NTZ.js} +1 -1
  82. package/dist/{chunk-LMJTY32X.js → chunk-RHNKYNNZ.js} +1 -1
  83. package/dist/{chunk-RZFINU7J.js → chunk-RIMJDJWY.js} +1 -1
  84. package/dist/{chunk-ZKYYZ5NO.js → chunk-RN4OSVTG.js} +2 -2
  85. package/dist/{chunk-ME5QSYWX.js → chunk-RV2NXHIC.js} +1 -1
  86. package/dist/{chunk-SQFNMZJ2.js → chunk-S2C62SDY.js} +1 -1
  87. package/dist/chunk-SJ2KQKOV.js +3 -0
  88. package/dist/{chunk-G6AF2JUA.js → chunk-UZJ7MRBV.js} +1 -1
  89. package/dist/{chunk-XBE7PGVY.js → chunk-VBCE4U4B.js} +1 -1
  90. package/dist/chunk-WIA7TPK3.js +2 -0
  91. package/dist/{chunk-F2K3XFFH.js → chunk-WJGBXJT4.js} +2 -2
  92. package/dist/{chunk-7LFCSSPX.js → chunk-WWH7CW5R.js} +1 -1
  93. package/dist/{chunk-NFGG5DA2.js → chunk-XQL53VB7.js} +1 -1
  94. package/dist/{chunk-B2PZAB7J.js → chunk-ZG2V2ODK.js} +1 -1
  95. package/dist/{chunk-GIRXJOJI.js → chunk-ZZLR3O5A.js} +1 -1
  96. package/dist/{config-5OOP2BO3.js → config-6PAZZ7CR.js} +1 -1
  97. package/dist/{cover-cmd-Y5L4O4Q3.js → cover-cmd-K3LCXHAQ.js} +1 -1
  98. package/dist/{credentials-XCP6DJZZ.js → credentials-BJCIWQWA.js} +1 -1
  99. package/dist/descriptor-EHK3DRCZ.js +2 -0
  100. package/dist/{evidence-AX67Q6RN.js → evidence-7VE5EGEF.js} +1 -1
  101. package/dist/evolve-cmd-RUGUWKAG.js +2 -0
  102. package/dist/explain-VFIZTHFN.js +2 -0
  103. package/dist/{explain-cmd-RIDEMDMY.js → explain-cmd-KV5YUXKB.js} +1 -1
  104. package/dist/{explain-cmd-55WRDIMW.js → explain-cmd-U367SD4N.js} +1 -1
  105. package/dist/{extract-bind-ZDAXRQUS.js → extract-bind-YS7C4KZ3.js} +2 -2
  106. package/dist/{extract-cmd-5GGI6LAM.js → extract-cmd-Z4PMDIMZ.js} +2 -2
  107. package/dist/{gaps-cmd-P2DRK6FW.js → gaps-cmd-DTVDIOED.js} +1 -1
  108. package/dist/{gate-FACZRGOC.js → gate-B6C6KLFA.js} +1 -1
  109. package/dist/{generate-headless-DRDE46ON.js → generate-headless-IWY32HC4.js} +2 -2
  110. package/dist/{headless-io-GXHKDPHB.js → headless-io-PWW6YKH2.js} +1 -1
  111. package/dist/index.js +43 -43
  112. package/dist/ingest-C5ANIN7S.js +2 -0
  113. package/dist/ingest-cmd-LLC5CDQ5.js +3 -0
  114. package/dist/interactive-bind-ZIIJDRBU.js +7 -0
  115. package/dist/{lifecycle-cmd-55NZL3UO.js → lifecycle-cmd-BXE5IMFN.js} +1 -1
  116. package/dist/{list-cmd-JB2ABACD.js → list-cmd-KBWPYJMV.js} +1 -1
  117. package/dist/{list-commands-UDAL3SBY.js → list-commands-SSXJQGE7.js} +1 -1
  118. package/dist/{logical-ids-ATVR6PF2.js → logical-ids-3Y6RX5C2.js} +1 -1
  119. package/dist/login-flow-HRS6YACY.js +2 -0
  120. package/dist/{maintenance-cmd-E3HEEVQW.js → maintenance-cmd-VS3APIUN.js} +1 -1
  121. package/dist/{persist-recorded-session-BW3YSFMP.js → persist-recorded-session-3AOYZJT2.js} +1 -1
  122. package/dist/pipeline-IZSODNCC.js +2 -0
  123. package/dist/readmodel-XOGOELUP.js +2 -0
  124. package/dist/reconcile-cmd-6HVZJFG3.js +2 -0
  125. package/dist/{recording-banner-6FVTCUWQ.js → recording-banner-KKEUWS3N.js} +1 -1
  126. package/dist/{require-project-folder-AQUVEEJB.js → require-project-folder-NPTKR2AW.js} +1 -1
  127. package/dist/{revert-3TKLOYQA.js → revert-AQQ2VHRM.js} +1 -1
  128. package/dist/{review-cmd-RXPPC5GK.js → review-cmd-4WZUUOE4.js} +1 -1
  129. package/dist/run-2A7M7EJK.js +2 -0
  130. package/dist/run-6AFY35QW.js +2 -0
  131. package/dist/{run-test-md-AUK7NGLL.js → run-test-md-QNC6KDMN.js} +2 -2
  132. package/dist/{skill-installer-2MNPCPRD.js → skill-installer-ULFNSE6X.js} +1 -1
  133. package/dist/{spawner-XCOMTJJC.js → spawner-DWONVIPI.js} +1 -1
  134. package/dist/tcg-generate-IHHPRVNG.js +2 -0
  135. package/dist/{testmd-actions-TU4KTO32.js → testmd-actions-S3ZNOZEK.js} +1 -1
  136. package/dist/token-refresh-CFVOA62N.js +2 -0
  137. package/dist/{validate-basic-IYMPP7C7.js → validate-basic-4OLDKIA2.js} +1 -1
  138. package/dist/{version-check-MUPSKONS.js → version-check-UL4S6R4N.js} +1 -1
  139. package/dist/{view-cmd-QE2FS3GB.js → view-cmd-FRMQF76B.js} +1 -1
  140. package/dist/walk-session-N3BP57HK.js +2 -0
  141. package/package.json +16 -8
  142. package/bin/kane-cli.js +0 -2
  143. package/dist/ChatSurface-J777M5WC.js +0 -8
  144. package/dist/EvidenceViewOffer-JQDEAE2T.js +0 -2
  145. package/dist/SingleShotApp-QANGFAPO.js +0 -2
  146. package/dist/TestMdRunView-74A3LCNE.js +0 -2
  147. package/dist/archive-committer-3NI773TP.js +0 -2
  148. package/dist/bind-FZ4X4SOK.js +0 -6
  149. package/dist/chunk-6RQAUK5F.js +0 -5
  150. package/dist/chunk-E4OYR32M.js +0 -2
  151. package/dist/chunk-FTD3B7QA.js +0 -2
  152. package/dist/chunk-GIGD4M7V.js +0 -5
  153. package/dist/chunk-I2S6KNZW.js +0 -2
  154. package/dist/chunk-IACKIGPX.js +0 -2
  155. package/dist/chunk-NFOBDHZK.js +0 -147
  156. package/dist/chunk-Q4HLQOJI.js +0 -7
  157. package/dist/chunk-SGU72YLH.js +0 -9
  158. package/dist/chunk-TY5LWU6I.js +0 -14
  159. package/dist/chunk-YANCBRER.js +0 -3
  160. package/dist/descriptor-SL5A7RQE.js +0 -2
  161. package/dist/distill-cmd-EYCCCFL3.js +0 -2
  162. package/dist/evolve-cmd-HR25DRTC.js +0 -2
  163. package/dist/explain-JIXUWEFJ.js +0 -2
  164. package/dist/ingest-4CGBXC2L.js +0 -2
  165. package/dist/ingest-cmd-X7BWGIN7.js +0 -3
  166. package/dist/interactive-bind-T6OBLZCT.js +0 -7
  167. package/dist/login-flow-LJ4BH3OS.js +0 -2
  168. package/dist/pipeline-TZJ652NT.js +0 -2
  169. package/dist/readmodel-MPTENJ2R.js +0 -2
  170. package/dist/reconcile-cmd-242S7XNO.js +0 -8
  171. package/dist/run-UGAOGR3B.js +0 -2
  172. package/dist/signals-cmd-LXHZQLXZ.js +0 -2
  173. package/dist/tcg-generate-E5X23RVP.js +0 -2
  174. package/dist/token-refresh-GGLARJV4.js +0 -2
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as z,b as ee,c as te}from"./chunk-7YQW4TFI.js";import{c as K,d as V}from"./chunk-Y7KW5AEN.js";import{c as J}from"./chunk-7MV5UF6O.js";import{a as Q}from"./chunk-XBE7PGVY.js";import{a as Z}from"./chunk-FPFOW6BS.js";import{b as H}from"./chunk-VXGOWBET.js";import{b as W}from"./chunk-BGGNBWAJ.js";import{h as E}from"./chunk-M5JQXOCE.js";import{a as O}from"./chunk-2WVKOZ6W.js";import{a as _}from"./chunk-RLG5NUTE.js";import{a as k,b as A,d as Y}from"./chunk-VE3SUJMA.js";import{a as q}from"./chunk-TZZYRDCF.js";import{a as G}from"./chunk-HCBYKLMW.js";import{a as c,b as u,i as I,j as X}from"./chunk-C44QQJR4.js";import{a as ue}from"./chunk-6YGTRKDT.js";import{e as F}from"./chunk-UR6MHSHU.js";var i=F(ue(),1);var r=F(G(),1);function _e({resultRef:h,mode:d="singleshot",loginCompleteRef:f}){let{exit:m}=X(),C=(0,i.useRef)(new q),S=(0,i.useRef)(new Q),v=(0,i.useRef)(new J),t=C.current,l=S.current,$=v.current,ne=K(),[P,g]=(0,i.useState)(d==="login"?"login":"gate"),[L,re]=(0,i.useState)(null),[de,R]=(0,i.useState)(null),[ge,T]=(0,i.useState)(null),[N,oe]=(0,i.useState)(null),[U,B]=(0,i.useState)([]),x=(0,i.useCallback)((e,n,s,o)=>$.log(e,n,s,o),[$]),pe=(0,i.useCallback)((e,n)=>{e?k(t,l,e,n):l.save({project_id:null,project_name:null,folder_id:null,folder_name:null})},[t,l]),y=(0,i.useCallback)(()=>{d==="login"?(f&&(f.current=!0),m()):g("input")},[d,m,f]),D=(0,i.useCallback)((e,n)=>{let s=k(t,l,e,n);if(d==="login"){g("ensure-project");return}Y(s)?y():s.projectId?g("ensure-folder"):g("ensure-project")},[t,l,y,d]);I((e,n)=>{n.ctrl&&e==="c"&&E(0,"Ctrl+C exit")});let M=(0,i.useRef)(!1);i.default.useEffect(()=>{M.current||(M.current=!0,d!=="login"&&te(t,x).then(e=>{re(e),e.status==="authenticated"?D(e.result.profile,e.result.env):e.status==="needs_pick"?g("pick"):(R(e.profile??null),T(e.env??null),g("login"))}).catch(e=>{oe(`Auth check failed: ${e instanceof Error?e.message:String(e)}`)}))},[t,x]);let ie=(0,i.useCallback)(e=>{h.current={objective:e},m()},[h,m]),se=(0,i.useCallback)(async(e,n)=>{t.setActiveProfile(e),t.setDefaultEnv(n),(await ee(t,e,n,x)).status==="authenticated"?D(e,n):(R(e),T(n),g("login"))},[t,x,D]),w=(0,i.useCallback)(()=>{let e=t.getActiveProfile(),n=t.getDefaultEnv();if(!e)return null;let s=_(n),o=t.loadBasicAuth(e,n);return new Z(s.controllerBaseUrl,async()=>t.loadCredentials(e,n)?.access_token??null,o,x)},[t,x]),le=(0,i.useCallback)(async()=>{let e=w();if(!e)return null;let n=e.cached??await e.resolve();if(!n)return null;let s=_(t.getDefaultEnv()),o=new O(s.tmsBaseUrl,n.username,n.access_key);try{let p=(await o.listProjects()).find(b=>b.name==="KaneAI Generated");if(p)return{id:p.project_id,name:p.name};let j=await o.createProject("KaneAI Generated");return{id:j.id,name:j.name}}catch{return null}},[w,t]),ae=(0,i.useCallback)(async e=>{let n=w();if(!n)return null;let s=n.cached??await n.resolve();if(!s)return null;let o=_(t.getDefaultEnv()),a=new O(o.tmsBaseUrl,s.username,s.access_key);try{let j=(await a.listFolders(e)).find(ce=>ce.name==="Untitled");if(j)return{id:j.id,name:j.name};let b=await a.createFolder(e,"Untitled");return{id:b.id,name:b.name}}catch{return null}},[w,t]);if(P==="gate")return(0,r.jsx)(c,{paddingX:1,children:(0,r.jsx)(u,{color:"yellow",children:"Checking authentication..."})});if(N)return(0,r.jsxs)(c,{flexDirection:"column",paddingX:1,children:[(0,r.jsx)(u,{color:"red",children:N}),(0,r.jsx)(u,{color:"gray",children:"Press Ctrl+C to exit."})]});if(P==="pick"&&L?.status==="needs_pick")return(0,r.jsx)(fe,{profiles:L.profiles,onSelect:se});if(P==="login")return(0,r.jsx)(z,{devMode:process.env.KANE_DEV_MODE==="1",profiles:t.listProfiles(),onBasicLogin:async(e,n,s,o)=>{let{validateBasicAuth:a}=await import("./validate-basic-IYMPP7C7.js");await a(n,s,o),t.saveBasicAuth(e,n,{username:s,access_key:o}),t.setActiveProfile(e),t.setDefaultEnv(n)},onOAuthLogin:async(e,n)=>{let{LoginFlow:s}=await import("./login-flow-LJ4BH3OS.js");t.setDefaultEnv(n),t.setActiveProfile(e),await new s(e,n,t).login()},onComplete:(e,n)=>{R(e),T(n),t.setActiveProfile(e),t.setDefaultEnv(n),D(e,n)},onCancel:()=>{E(0,"Login cancelled")}});if(P==="ensure-project"){let e=t.getActiveProfile()??"default",n=t.getDefaultEnv(),s=()=>{if(d==="login"){g("ensure-folder");return}k(t,l,e,n).folderId?y():g("ensure-folder")};return(0,r.jsxs)(c,{flexDirection:"column",children:[(0,r.jsx)(c,{paddingX:1,marginBottom:1,children:(0,r.jsx)(u,{color:"yellow",children:"Project & folder are required to save tests \xB7 Esc to use defaults \xB7 Ctrl+C to exit"})}),(0,r.jsx)(H,{resolver:w(),currentProjectId:l.load().project_id,env:n,onSelect:(o,a)=>{A(t,l,e,n,{projectId:o,projectName:a}),B(p=>[...p,`\u2713 Project: ${a} (${o})`]),s()},onCancel:async()=>{let o=await le();o&&(A(t,l,e,n,{projectId:o.id,projectName:o.name}),B(a=>[...a,`\u2713 Default project: ${o.name} (${o.id})`]),s())}})]})}if(P==="ensure-folder"){let e=t.getActiveProfile()??"default",n=t.getDefaultEnv(),s=t.loadProfileConfig(e,n);return(0,r.jsxs)(c,{flexDirection:"column",children:[(0,r.jsx)(c,{paddingX:1,marginBottom:1,children:(0,r.jsx)(u,{color:"yellow",children:"Project & folder are required to save tests \xB7 Esc to use defaults \xB7 Ctrl+C to exit"})}),(0,r.jsx)(W,{resolver:w(),projectId:s?.project_id??"",currentFolderId:l.load().folder_id,env:n,onSelect:(o,a)=>{A(t,l,e,n,{folderId:o,folderName:a}),B(p=>[...p,`\u2713 Folder: ${a} (${o})`]),y()},onCancel:async()=>{if(!s?.project_id)return;let o=await ae(s.project_id);o&&(A(t,l,e,n,{folderId:o.id,folderName:o.name}),B(a=>[...a,`\u2713 Default folder: ${o.name} (${o.id})`]),y())}})]})}return P==="input"?(0,r.jsxs)(c,{flexDirection:"column",children:[U.length>0&&(0,r.jsx)(c,{flexDirection:"column",paddingX:1,marginBottom:1,children:U.map((e,n)=>(0,r.jsx)(u,{color:"green",children:e},n))}),(0,r.jsx)(V,{onSubmit:ie,onEscape:()=>E(0,"User pressed Escape"),history:ne,placeholder:"Type an objective..."})]}):(0,r.jsx)(r.Fragment,{})}function fe({profiles:h,onSelect:d}){let[f,m]=(0,i.useState)(0),[C,S]=(0,i.useState)(!1);return I((v,t)=>{if(!C){if(t.escape){E(0,"Profile picker cancelled");return}if(t.upArrow&&f>0&&m(l=>l-1),t.downArrow&&f<h.length-1&&m(l=>l+1),t.return){S(!0);let l=h[f];d(l.profile,l.env).catch(()=>S(!1))}}}),(0,r.jsxs)(c,{flexDirection:"column",paddingX:1,children:[(0,r.jsx)(u,{color:"#ff9500",bold:!0,children:"Select a profile:"}),(0,r.jsx)(c,{marginTop:1,flexDirection:"column",children:h.map((v,t)=>(0,r.jsxs)(u,{children:[t===f?"\u276F ":" ",(0,r.jsx)(u,{color:t===f?"#ff9500":"white",bold:t===f,children:v.profile}),(0,r.jsxs)(u,{color:"gray",children:[" [",v.env,"]"]})]},`${v.profile}-${v.env}`))}),C&&(0,r.jsx)(c,{marginTop:1,children:(0,r.jsx)(u,{color:"yellow",children:"Validating credentials..."})})]})}export{_e as a};
2
+ import{a as z,b as ee,c as te}from"./chunk-JF7Q2I45.js";import{c as K,d as V}from"./chunk-6CZIEK6B.js";import{c as J}from"./chunk-6XHAXAL2.js";import{a as Q}from"./chunk-VBCE4U4B.js";import{a as Z}from"./chunk-FPFOW6BS.js";import{b as H}from"./chunk-HWA7WD44.js";import{b as W}from"./chunk-N6DO2LBH.js";import{h as E}from"./chunk-M5JQXOCE.js";import{a as O}from"./chunk-2WVKOZ6W.js";import{a as _}from"./chunk-AKHUNBQS.js";import{a as k,b as A,d as Y}from"./chunk-VE3SUJMA.js";import{a as q}from"./chunk-P4HW2NTZ.js";import{a as G}from"./chunk-HCBYKLMW.js";import{a as c,b as u,i as I,j as X}from"./chunk-C44QQJR4.js";import{a as ue}from"./chunk-6YGTRKDT.js";import{e as F}from"./chunk-UR6MHSHU.js";var i=F(ue(),1);var r=F(G(),1);function _e({resultRef:h,mode:d="singleshot",loginCompleteRef:f}){let{exit:m}=X(),C=(0,i.useRef)(new q),S=(0,i.useRef)(new Q),v=(0,i.useRef)(new J),t=C.current,l=S.current,$=v.current,ne=K(),[P,g]=(0,i.useState)(d==="login"?"login":"gate"),[L,re]=(0,i.useState)(null),[de,R]=(0,i.useState)(null),[ge,T]=(0,i.useState)(null),[N,oe]=(0,i.useState)(null),[U,B]=(0,i.useState)([]),x=(0,i.useCallback)((e,n,s,o)=>$.log(e,n,s,o),[$]),pe=(0,i.useCallback)((e,n)=>{e?k(t,l,e,n):l.save({project_id:null,project_name:null,folder_id:null,folder_name:null})},[t,l]),y=(0,i.useCallback)(()=>{d==="login"?(f&&(f.current=!0),m()):g("input")},[d,m,f]),D=(0,i.useCallback)((e,n)=>{let s=k(t,l,e,n);if(d==="login"){g("ensure-project");return}Y(s)?y():s.projectId?g("ensure-folder"):g("ensure-project")},[t,l,y,d]);I((e,n)=>{n.ctrl&&e==="c"&&E(0,"Ctrl+C exit")});let M=(0,i.useRef)(!1);i.default.useEffect(()=>{M.current||(M.current=!0,d!=="login"&&te(t,x).then(e=>{re(e),e.status==="authenticated"?D(e.result.profile,e.result.env):e.status==="needs_pick"?g("pick"):(R(e.profile??null),T(e.env??null),g("login"))}).catch(e=>{oe(`Auth check failed: ${e instanceof Error?e.message:String(e)}`)}))},[t,x]);let ie=(0,i.useCallback)(e=>{h.current={objective:e},m()},[h,m]),se=(0,i.useCallback)(async(e,n)=>{t.setActiveProfile(e),t.setDefaultEnv(n),(await ee(t,e,n,x)).status==="authenticated"?D(e,n):(R(e),T(n),g("login"))},[t,x,D]),w=(0,i.useCallback)(()=>{let e=t.getActiveProfile(),n=t.getDefaultEnv();if(!e)return null;let s=_(n),o=t.loadBasicAuth(e,n);return new Z(s.controllerBaseUrl,async()=>t.loadCredentials(e,n)?.access_token??null,o,x)},[t,x]),le=(0,i.useCallback)(async()=>{let e=w();if(!e)return null;let n=e.cached??await e.resolve();if(!n)return null;let s=_(t.getDefaultEnv()),o=new O(s.tmsBaseUrl,n.username,n.access_key);try{let p=(await o.listProjects()).find(b=>b.name==="KaneAI Generated");if(p)return{id:p.project_id,name:p.name};let j=await o.createProject("KaneAI Generated");return{id:j.id,name:j.name}}catch{return null}},[w,t]),ae=(0,i.useCallback)(async e=>{let n=w();if(!n)return null;let s=n.cached??await n.resolve();if(!s)return null;let o=_(t.getDefaultEnv()),a=new O(o.tmsBaseUrl,s.username,s.access_key);try{let j=(await a.listFolders(e)).find(ce=>ce.name==="Untitled");if(j)return{id:j.id,name:j.name};let b=await a.createFolder(e,"Untitled");return{id:b.id,name:b.name}}catch{return null}},[w,t]);if(P==="gate")return(0,r.jsx)(c,{paddingX:1,children:(0,r.jsx)(u,{color:"yellow",children:"Checking authentication..."})});if(N)return(0,r.jsxs)(c,{flexDirection:"column",paddingX:1,children:[(0,r.jsx)(u,{color:"red",children:N}),(0,r.jsx)(u,{color:"gray",children:"Press Ctrl+C to exit."})]});if(P==="pick"&&L?.status==="needs_pick")return(0,r.jsx)(fe,{profiles:L.profiles,onSelect:se});if(P==="login")return(0,r.jsx)(z,{devMode:process.env.KANE_DEV_MODE==="1",profiles:t.listProfiles(),onBasicLogin:async(e,n,s,o)=>{let{validateBasicAuth:a}=await import("./validate-basic-4OLDKIA2.js");await a(n,s,o),t.saveBasicAuth(e,n,{username:s,access_key:o}),t.setActiveProfile(e),t.setDefaultEnv(n)},onOAuthLogin:async(e,n)=>{let{LoginFlow:s}=await import("./login-flow-HRS6YACY.js");t.setDefaultEnv(n),t.setActiveProfile(e),await new s(e,n,t).login()},onComplete:(e,n)=>{R(e),T(n),t.setActiveProfile(e),t.setDefaultEnv(n),D(e,n)},onCancel:()=>{E(0,"Login cancelled")}});if(P==="ensure-project"){let e=t.getActiveProfile()??"default",n=t.getDefaultEnv(),s=()=>{if(d==="login"){g("ensure-folder");return}k(t,l,e,n).folderId?y():g("ensure-folder")};return(0,r.jsxs)(c,{flexDirection:"column",children:[(0,r.jsx)(c,{paddingX:1,marginBottom:1,children:(0,r.jsx)(u,{color:"yellow",children:"Project & folder are required to save tests \xB7 Esc to use defaults \xB7 Ctrl+C to exit"})}),(0,r.jsx)(H,{resolver:w(),currentProjectId:l.load().project_id,env:n,onSelect:(o,a)=>{A(t,l,e,n,{projectId:o,projectName:a}),B(p=>[...p,`\u2713 Project: ${a} (${o})`]),s()},onCancel:async()=>{let o=await le();o&&(A(t,l,e,n,{projectId:o.id,projectName:o.name}),B(a=>[...a,`\u2713 Default project: ${o.name} (${o.id})`]),s())}})]})}if(P==="ensure-folder"){let e=t.getActiveProfile()??"default",n=t.getDefaultEnv(),s=t.loadProfileConfig(e,n);return(0,r.jsxs)(c,{flexDirection:"column",children:[(0,r.jsx)(c,{paddingX:1,marginBottom:1,children:(0,r.jsx)(u,{color:"yellow",children:"Project & folder are required to save tests \xB7 Esc to use defaults \xB7 Ctrl+C to exit"})}),(0,r.jsx)(W,{resolver:w(),projectId:s?.project_id??"",currentFolderId:l.load().folder_id,env:n,onSelect:(o,a)=>{A(t,l,e,n,{folderId:o,folderName:a}),B(p=>[...p,`\u2713 Folder: ${a} (${o})`]),y()},onCancel:async()=>{if(!s?.project_id)return;let o=await ae(s.project_id);o&&(A(t,l,e,n,{folderId:o.id,folderName:o.name}),B(a=>[...a,`\u2713 Default folder: ${o.name} (${o.id})`]),y())}})]})}return P==="input"?(0,r.jsxs)(c,{flexDirection:"column",children:[U.length>0&&(0,r.jsx)(c,{flexDirection:"column",paddingX:1,marginBottom:1,children:U.map((e,n)=>(0,r.jsx)(u,{color:"green",children:e},n))}),(0,r.jsx)(V,{onSubmit:ie,onEscape:()=>E(0,"User pressed Escape"),history:ne,placeholder:"Type an objective..."})]}):(0,r.jsx)(r.Fragment,{})}function fe({profiles:h,onSelect:d}){let[f,m]=(0,i.useState)(0),[C,S]=(0,i.useState)(!1);return I((v,t)=>{if(!C){if(t.escape){E(0,"Profile picker cancelled");return}if(t.upArrow&&f>0&&m(l=>l-1),t.downArrow&&f<h.length-1&&m(l=>l+1),t.return){S(!0);let l=h[f];d(l.profile,l.env).catch(()=>S(!1))}}}),(0,r.jsxs)(c,{flexDirection:"column",paddingX:1,children:[(0,r.jsx)(u,{color:"#ff9500",bold:!0,children:"Select a profile:"}),(0,r.jsx)(c,{marginTop:1,flexDirection:"column",children:h.map((v,t)=>(0,r.jsxs)(u,{children:[t===f?"\u276F ":" ",(0,r.jsx)(u,{color:t===f?"#ff9500":"white",bold:t===f,children:v.profile}),(0,r.jsxs)(u,{color:"gray",children:[" [",v.env,"]"]})]},`${v.profile}-${v.env}`))}),C&&(0,r.jsx)(c,{marginTop:1,children:(0,r.jsx)(u,{color:"yellow",children:"Validating credentials..."})})]})}export{_e as a};
@@ -1,6 +1,6 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- var p=1;function f(e){return e==="agent"?"ndjson":"human"}function l(){return!!(process.stdin.isTTY&&process.stdout.isTTY)}var a=/^(∷ |· |→ |✓ |✗ |… )/;function d(e){return e===0?"complete":e===2?"refused":e===3?"paused":e===130?"interrupted":"error"}function c(e,n,s={stdout:t=>process.stdout.write(t),stderr:t=>process.stderr.write(t)}){let t=!1,u=r=>{if(e!=="ndjson")return;if(r.type==="done"){if(t)return;t=!0}let{type:o,...i}=r;s.stdout(JSON.stringify({type:o,v:1,verb:n,...i})+`
2
+ var p=1;function f(e){return e==="agent"?"ndjson":"human"}function c(){return!!(process.stdin.isTTY&&process.stdout.isTTY)}var a=/^(∷ |· |→ |✓ |✗ |… )/;function d(e){return e===0?"complete":e===2?"refused":e===3?"paused":e===130?"interrupted":"error"}function l(e,n,s={stdout:t=>process.stdout.write(t),stderr:t=>process.stderr.write(t)}){let t=!1,i=r=>{if(e!=="ndjson")return;if(r.type==="done"){if(t)return;t=!0}let{type:o,...u}=r;s.stdout(JSON.stringify({type:o,v:1,verb:n,...u})+`
3
3
  `)};return{encoding:e,out:e==="ndjson"?r=>s.stderr(r+`
4
4
  `):r=>s.stdout(r+`
5
5
  `),progress:e==="ndjson"?()=>{}:r=>s.stderr(r.replace(a,"").replace(/…$/,"")+`
6
- `),event:u,done:(r,o)=>(u({type:"done",status:o??d(r),exit_code:r}),r)}}var g=8*1024;function m(e,n){return e.message==null?null:e.message.trim()?e.resume?Buffer.byteLength(e.message,"utf8")>g?`${n==="extract"?"extract":"design"}: --message is over 8KB \u2014 the agent would silently drop it; shorten the statement`:null:`${n==="extract"?"extract":"design"}: --message only rides a resume \u2014 pair it with --resume <sid> (a fresh run takes its direction from the sources)`:`${n==="extract"?"extract":"design"}: --message is empty \u2014 say what you want the agent to know`}function E(e,n,s){return e.event({type:"error",message:n,...s?{code:s}:{}}),e.done(2,"refused")}function x(e,n,s){return{out:t=>{n()&&s.test(t)||e.out(t)},emit:t=>{n()&&t.type==="error"&&s.test(String(t.message??""))||e.event(t)}}}export{p as a,f as b,l as c,c as d,g as e,m as f,E as g,x as h};
6
+ `),event:i,done:(r,o)=>(i({type:"done",status:o??d(r),exit_code:r}),r)}}var g=8*1024;function m(e,n){return e.message==null?null:e.message.trim()?e.resume?Buffer.byteLength(e.message,"utf8")>g?`${n==="extract"?"extract":"design"}: --message is over 8KB \u2014 the agent would silently drop it; shorten the statement`:null:`${n==="extract"?"extract":"design"}: --message only rides a resume \u2014 pair it with --resume <sid> (a fresh run takes its direction from the sources)`:`${n==="extract"?"extract":"design"}: --message is empty \u2014 say what you want the agent to know`}function E(e,n,s){return e.event({type:"error",message:n,...s?{code:s}:{}}),e.done(2,"refused")}function x(e,n,s){return{out:t=>{n()&&s.test(t)||e.out(t)},emit:t=>{n()&&t.type==="error"&&s.test(String(t.message??""))||e.event(t)}}}export{p as a,f as b,c,l as d,g as e,m as f,E as g,x as h};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as S}from"./chunk-EWFFJBAM.js";import{x as o}from"./chunk-E4OYR32M.js";import{a as R}from"./chunk-HCBYKLMW.js";import{a as y,b as c,j as x}from"./chunk-C44QQJR4.js";import{a as w}from"./chunk-6YGTRKDT.js";import{e as b}from"./chunk-UR6MHSHU.js";var k=b(w(),1);var i=b(R(),1);function A(e){let t=e.decisions.filter(r=>r.kind==="replay").length,l=e.decisions.filter(r=>r.kind==="author").length,p=e.outcomes.filter(r=>r.status==="passed").length,d=e.outcomes.filter(r=>r.status==="failed").length,f=e.outcomes.filter(r=>r.status==="skipped").length,a=o.green,n;e.cancelled||e.overallStatus==="interrupted"?(a=o.orange,n="CANCELLED"):e.overallStatus==="failed"?(a=o.red,n="FAILED"):n="PASSED";let s=`${n} \xB7 ${e.durationS}s \xB7 ${e.outcomes.length} steps (${p} passed, ${d} failed, ${f} skipped)`,T=`${t} replay \xB7 ${l} author`,C=e.retryTriggered,_="yes \u2014 run recovered after a replay miss",u,h=o.dim;if(e.cancelled)u="\u2013 not committed (cancellation)";else if(e.overallStatus==="failed")u="\u2013 not committed (run failed)",h=o.red;else if(!e.shouldCommit)e.isFirstRun?u="\u2013 not committed (first run skipped commit)":e.lockHeld?u="\u2013 not committed":u="\u2013 not committed (readonly fallback / no lock)";else{let r=e.uploadResult?.testcaseId;u=r?`\u2713 pushed (testcase=${r})`:"\u2713 pushed",h=o.green}let v=e.shouldReplaceLocalOutput?"output dir replaced":e.anyAuthorStepRan?"untouched (cancellation or no replace)":"untouched (replay-only)",m,g=o.dim;return e.shouldUploadArtifacts?e.uploadResult?.success?(m="\u2713 TMS",g=o.green):e.uploadResult?(m=`\u2717 failed${e.uploadResult.error?`: ${e.uploadResult.error}`:""}`,g=o.red):m="\u2013 not run":m="\u2013 skipped (--local or no auth)",{resultLine:{color:a,text:s},breakdown:T,showRetries:C,retriesText:_,commitText:u,commitColor:h,artifactsText:v,uploadText:m,uploadColor:g}}function O(e){let t=e.decisions.filter(s=>s.kind==="replay").length,l=e.decisions.filter(s=>s.kind==="author").length,p=e.outcomes.filter(s=>s.status==="passed").length,d=e.outcomes.filter(s=>s.status==="failed").length,f=e.outcomes.filter(s=>s.status==="skipped").length,a,n=!1;return e.cancelled?a="cancellation":e.overallStatus==="failed"?a="run_failed":e.shouldCommit&&e.uploadResult?.testcaseId?(a="ok",n=!0):!e.shouldCommit&&!e.lockHeld&&!e.isFirstRun?a="readonly_fallback":a="not_committed",{type:"test_md_summary",overall_status:e.overallStatus,duration_s:e.durationS,steps:{total:e.outcomes.length,passed:p,failed:d,skipped:f,replay_decisions:t,author_decisions:l},retries:{triggered:e.retryTriggered},commit:{committed:n,reason:a,...e.uploadResult?.testcaseId?{testcase_id:e.uploadResult.testcaseId}:{}},artifacts:{replaced:e.shouldReplaceLocalOutput},upload:{performed:e.shouldUploadArtifacts,...e.uploadResult?{succeeded:!!e.uploadResult.success}:{}},...e.shareUrl?{share_url:e.shareUrl}:{},cancelled:e.cancelled,...e.imports&&e.imports.length>0?{imports:e.imports}:{}}}function D({data:e}){let t=A(e),l=[{label:"result",value:(0,i.jsx)(c,{color:t.resultLine.color,bold:!0,children:t.resultLine.text})},{label:"breakdown",value:(0,i.jsx)(c,{color:o.dim,children:t.breakdown})}];return t.showRetries&&l.push({label:"retries",value:(0,i.jsx)(c,{color:o.orange,children:t.retriesText})}),l.push({label:"commit",value:(0,i.jsx)(c,{color:t.commitColor,children:t.commitText})}),l.push({label:"artifacts",value:(0,i.jsx)(c,{color:o.dim,children:t.artifactsText})}),l.push({label:"upload",value:(0,i.jsx)(c,{color:t.uploadColor,children:t.uploadText})}),(0,i.jsx)(S,{title:"Run summary",titleColor:"#ff9500",rows:l})}function I({data:e}){let{exit:t}=x();return(0,k.useEffect)(()=>{let l=setTimeout(()=>t(),50);return()=>clearTimeout(l)},[t]),(0,i.jsx)(y,{flexDirection:"column",children:(0,i.jsx)(D,{data:e})})}export{A as a,O as b,D as c,I as d};
2
+ import{a as S}from"./chunk-6NIV7AVZ.js";import{y as o}from"./chunk-6SGPN76K.js";import{a as R}from"./chunk-HCBYKLMW.js";import{a as y,b as c,j as x}from"./chunk-C44QQJR4.js";import{a as w}from"./chunk-6YGTRKDT.js";import{e as b}from"./chunk-UR6MHSHU.js";var k=b(w(),1);var i=b(R(),1);function A(e){let t=e.decisions.filter(r=>r.kind==="replay").length,l=e.decisions.filter(r=>r.kind==="author").length,p=e.outcomes.filter(r=>r.status==="passed").length,d=e.outcomes.filter(r=>r.status==="failed").length,f=e.outcomes.filter(r=>r.status==="skipped").length,a=o.green,n;e.cancelled||e.overallStatus==="interrupted"?(a=o.orange,n="CANCELLED"):e.overallStatus==="failed"?(a=o.red,n="FAILED"):n="PASSED";let s=`${n} \xB7 ${e.durationS}s \xB7 ${e.outcomes.length} steps (${p} passed, ${d} failed, ${f} skipped)`,T=`${t} replay \xB7 ${l} author`,C=e.retryTriggered,_="yes \u2014 run recovered after a replay miss",u,h=o.dim;if(e.cancelled)u="\u2013 not committed (cancellation)";else if(e.overallStatus==="failed")u="\u2013 not committed (run failed)",h=o.red;else if(!e.shouldCommit)e.isFirstRun?u="\u2013 not committed (first run skipped commit)":e.lockHeld?u="\u2013 not committed":u="\u2013 not committed (readonly fallback / no lock)";else{let r=e.uploadResult?.testcaseId;u=r?`\u2713 pushed (testcase=${r})`:"\u2713 pushed",h=o.green}let v=e.shouldReplaceLocalOutput?"output dir replaced":e.anyAuthorStepRan?"untouched (cancellation or no replace)":"untouched (replay-only)",m,g=o.dim;return e.shouldUploadArtifacts?e.uploadResult?.success?(m="\u2713 TMS",g=o.green):e.uploadResult?(m=`\u2717 failed${e.uploadResult.error?`: ${e.uploadResult.error}`:""}`,g=o.red):m="\u2013 not run":m="\u2013 skipped (--local or no auth)",{resultLine:{color:a,text:s},breakdown:T,showRetries:C,retriesText:_,commitText:u,commitColor:h,artifactsText:v,uploadText:m,uploadColor:g}}function O(e){let t=e.decisions.filter(s=>s.kind==="replay").length,l=e.decisions.filter(s=>s.kind==="author").length,p=e.outcomes.filter(s=>s.status==="passed").length,d=e.outcomes.filter(s=>s.status==="failed").length,f=e.outcomes.filter(s=>s.status==="skipped").length,a,n=!1;return e.cancelled?a="cancellation":e.overallStatus==="failed"?a="run_failed":e.shouldCommit&&e.uploadResult?.testcaseId?(a="ok",n=!0):!e.shouldCommit&&!e.lockHeld&&!e.isFirstRun?a="readonly_fallback":a="not_committed",{type:"test_md_summary",overall_status:e.overallStatus,duration_s:e.durationS,steps:{total:e.outcomes.length,passed:p,failed:d,skipped:f,replay_decisions:t,author_decisions:l},retries:{triggered:e.retryTriggered},commit:{committed:n,reason:a,...e.uploadResult?.testcaseId?{testcase_id:e.uploadResult.testcaseId}:{}},artifacts:{replaced:e.shouldReplaceLocalOutput},upload:{performed:e.shouldUploadArtifacts,...e.uploadResult?{succeeded:!!e.uploadResult.success}:{}},...e.shareUrl?{share_url:e.shareUrl}:{},cancelled:e.cancelled,...e.imports&&e.imports.length>0?{imports:e.imports}:{}}}function D({data:e}){let t=A(e),l=[{label:"result",value:(0,i.jsx)(c,{color:t.resultLine.color,bold:!0,children:t.resultLine.text})},{label:"breakdown",value:(0,i.jsx)(c,{color:o.dim,children:t.breakdown})}];return t.showRetries&&l.push({label:"retries",value:(0,i.jsx)(c,{color:o.orange,children:t.retriesText})}),l.push({label:"commit",value:(0,i.jsx)(c,{color:t.commitColor,children:t.commitText})}),l.push({label:"artifacts",value:(0,i.jsx)(c,{color:o.dim,children:t.artifactsText})}),l.push({label:"upload",value:(0,i.jsx)(c,{color:t.uploadColor,children:t.uploadText})}),(0,i.jsx)(S,{title:"Run summary",titleColor:"#ff9500",rows:l})}function I({data:e}){let{exit:t}=x();return(0,k.useEffect)(()=>{let l=setTimeout(()=>t(),50);return()=>clearTimeout(l)},[t]),(0,i.jsx)(y,{flexDirection:"column",children:(0,i.jsx)(D,{data:e})})}export{A as a,O as b,D as c,I as d};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as m}from"./chunk-AV5SUGRY.js";import{x as t}from"./chunk-E4OYR32M.js";import{a as p}from"./chunk-HCBYKLMW.js";import{a,b as r,i as u}from"./chunk-C44QQJR4.js";import{a as b}from"./chunk-6YGTRKDT.js";import{e as n}from"./chunk-UR6MHSHU.js";var c=n(b(),1);var e=n(p(),1);function R({onSubmit:l}){let[o,f]=(0,c.useState)(0),s=(0,c.useRef)(!1);return u((x,i)=>{s.current||(i.leftArrow||i.rightArrow?f(d=>d===0?1:0):i.return?(s.current=!0,l(o===0?"positive":"negative")):i.escape&&(s.current=!0,l(null)))}),(0,e.jsxs)(a,{flexDirection:"column",marginTop:1,children:[(0,e.jsxs)(a,{children:[(0,e.jsx)(r,{color:t.secondary,children:"Rate this session: "}),(0,e.jsx)(r,{color:o===0?t.orange:t.dim,children:o===0?"[ \u{1F44D} ]":" \u{1F44D} "}),(0,e.jsx)(r,{children:" "}),(0,e.jsx)(r,{color:o===1?t.orange:t.dim,children:o===1?"[ \u{1F44E} ]":" \u{1F44E} "})]}),(0,e.jsx)(m,{bindings:[{keys:"\u2190/\u2192",label:"select"},{keys:"\u21B5",label:"submit"}],escBackLabel:"skip"})]})}export{R as a};
2
+ import{a as m}from"./chunk-4SXD6XWV.js";import{y as t}from"./chunk-6SGPN76K.js";import{a as p}from"./chunk-HCBYKLMW.js";import{a,b as r,i as u}from"./chunk-C44QQJR4.js";import{a as b}from"./chunk-6YGTRKDT.js";import{e as n}from"./chunk-UR6MHSHU.js";var c=n(b(),1);var e=n(p(),1);function R({onSubmit:l}){let[o,f]=(0,c.useState)(0),s=(0,c.useRef)(!1);return u((x,i)=>{s.current||(i.leftArrow||i.rightArrow?f(d=>d===0?1:0):i.return?(s.current=!0,l(o===0?"positive":"negative")):i.escape&&(s.current=!0,l(null)))}),(0,e.jsxs)(a,{flexDirection:"column",marginTop:1,children:[(0,e.jsxs)(a,{children:[(0,e.jsx)(r,{color:t.secondary,children:"Rate this session: "}),(0,e.jsx)(r,{color:o===0?t.orange:t.dim,children:o===0?"[ \u{1F44D} ]":" \u{1F44D} "}),(0,e.jsx)(r,{children:" "}),(0,e.jsx)(r,{color:o===1?t.orange:t.dim,children:o===1?"[ \u{1F44E} ]":" \u{1F44E} "})]}),(0,e.jsx)(m,{bindings:[{keys:"\u2190/\u2192",label:"select"},{keys:"\u21B5",label:"submit"}],escBackLabel:"skip"})]})}export{R as a};
@@ -0,0 +1,3 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{b as k,c as I}from"./chunk-2PQXEEVY.js";import{a as E}from"./chunk-MCQXRJGH.js";import{a as h,c as w}from"./chunk-ZZLR3O5A.js";import{g as S}from"./chunk-ZG2V2ODK.js";import{a as x,d as y,f as b}from"./chunk-5YPBPZUR.js";import{existsSync as M,mkdirSync as R,readFileSync as C,writeFileSync as F}from"fs";import{basename as P,extname as v,join as U}from"path";var A=/^[A-Za-z0-9][A-Za-z0-9._-]*$/;function D(e){return typeof e=="string"&&e!=="."&&e!==".."&&A.test(e)}function f(e){if(!D(e))throw new Error(`unsafe logical_id: ${JSON.stringify(e)} \u2014 must match ${String(A)} (no path separators)`)}import{extname as $}from"path";var O=[{kind:"text",media_type:"text/plain",extensions:[".txt"],cite:"verbatim",maxBytes:2e6},{kind:"markdown",media_type:"text/markdown",extensions:[".md",".markdown"],cite:"verbatim",maxBytes:2e6},{kind:"image",media_type:"image/png",extensions:[".png"],cite:"anchor-only",maxBytes:5e6},{kind:"image",media_type:"image/jpeg",extensions:[".jpg",".jpeg"],cite:"anchor-only",maxBytes:5e6},{kind:"image",media_type:"image/webp",extensions:[".webp"],cite:"anchor-only",maxBytes:5e6}];function L(e){let n=$(e).toLowerCase(),t=O.find(r=>r.extensions.includes(n));return t?{ok:!0,media:t}:{ok:!1,code:"UNSUPPORTED_MEDIA",allowlist:O.flatMap(r=>r.extensions)}}function j(e){let t=P(e,v(e)).toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/^[^a-z0-9]+/,"");return f(t),t}function ee(e){let n=/^(.*?)[-_.]?v?\d+$/.exec(e);if(!n)return null;let t=(n[1]??"").replace(/[-_.]+$/,"");return t.length>0&&t!==e?t:null}function z(e){let n=U(e,"meta.json");M(n)||(R(e,{recursive:!0}),F(n,JSON.stringify({schema:x,canonicalizer:"v1"},null,2)+`
3
+ `))}async function te(e){let{contextDir:n,filePath:t,asId:r,confirmSameSource:_}=e;z(n);let c=C(t),i=L(t);if(!i.ok)throw new Error(`UNSUPPORTED_MEDIA: ${v(t)} \u2014 supported: ${i.allowlist.join(" ")}`);if(c.byteLength>i.media.maxBytes)throw new Error(`FILE_TOO_LARGE: ${c.byteLength} bytes > ${i.media.maxBytes} cap for ${i.media.media_type}`);let s=k(c),o;r!==void 0?(f(r),o=r):o=j(t);let d=E(n),a=d.heads.get(o),N=a!=null?d.getNode(a)?.content:void 0;if(a!=null&&N?.blob===s)return{status:"unchanged",source_id:o,cid:a,blob:s};if(a==null){for(let[g,p]of d.heads.entries())if(!(g===o||p==null)&&d.getNode(p)?.content.blob===s){if(_&&await _(g))return{status:"unchanged",source_id:g,cid:p,blob:s};break}}I(n,c);let m=w(o,s),l=b("source",m);if(l.length>0)throw new Error(`source node fails ${l[0].code}: ${l[0].detail}`);let u=h("source",m);return S(n,{ts:new Date().toISOString(),proposal_id:null,nodes:[{cid:u,label:y.SOURCE,content:m}],edges:[],review:[],supersessions:[],media:{[o]:{format:i.media.kind,media_type:i.media.media_type,anchors_supported:i.media.cite==="verbatim"?["L-L"]:[]}},source_head_moves:{[o]:u}}),{status:a!=null?"versioned":"created",source_id:o,cid:u,blob:s}}export{L as a,j as b,ee as c,te as d};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{b as l}from"./chunk-TTSYHJLX.js";import{a as p}from"./chunk-RZ4F3BHX.js";import{a as m}from"./chunk-RLG5NUTE.js";import{a as f}from"./chunk-TZZYRDCF.js";import{a as c,c as s,h as a,w as u}from"./chunk-E4OYR32M.js";var v="/public/skills/kane-cli";function C(){try{let n=new f().getDefaultEnv();if(n in u)return n}catch{}return"prod"}function k(){return`${m(C()).controllerBaseUrl}${v}`}import{readFileSync as S,writeFileSync as E,mkdirSync as g}from"fs";import{join as d}from"path";var h=d(s,"skill-check.json"),y=3600*1e3;function V(){try{let n=JSON.parse(S(h,"utf-8"));if(Date.now()-n.checkedAt<y)return n}catch{}return null}function A(n){try{g(s,{recursive:!0}),E(h,JSON.stringify({map:n,checkedAt:Date.now()}))}catch{}}function I(){for(let{dir:n}of a)try{let t=S(d(n,"VERSION"),"utf-8").trim();if(t)return t}catch{}return null}function M(n,t){let i=Object.keys(n.versions??{});if(i.length===0)return null;let o=i.slice().sort((r,e)=>l(r,e));for(let r of o){let e=n.versions[r]?.kaneCliMinVersion;if(!e||l(t,e)<=0)return r}return null}async function U(){try{let n=V()?.map;if(!n){let o=new AbortController,r=setTimeout(()=>o.abort(),5e3),e=await p(k(),{headers:{Accept:"application/json"},signal:o.signal});if(clearTimeout(r),!e.ok)return null;n=await e.json(),A(n)}let t=M(n,c);if(!t)return null;let i=I();return i===null?{current:null,latestCompatible:t}:l(i,t)>0?{current:i,latestCompatible:t}:null}catch{return null}}export{k as a,M as b,U as c};
2
+ import{b as l}from"./chunk-JTEY32TL.js";import{a as p}from"./chunk-RZ4F3BHX.js";import{a as m}from"./chunk-AKHUNBQS.js";import{a as f}from"./chunk-P4HW2NTZ.js";import{a as c,c as s,i as a,x as u}from"./chunk-6SGPN76K.js";var v="/public/skills/kane-cli";function C(){try{let n=new f().getDefaultEnv();if(n in u)return n}catch{}return"prod"}function k(){return`${m(C()).controllerBaseUrl}${v}`}import{readFileSync as S,writeFileSync as E,mkdirSync as g}from"fs";import{join as d}from"path";var h=d(s,"skill-check.json"),y=3600*1e3;function V(){try{let n=JSON.parse(S(h,"utf-8"));if(Date.now()-n.checkedAt<y)return n}catch{}return null}function A(n){try{g(s,{recursive:!0}),E(h,JSON.stringify({map:n,checkedAt:Date.now()}))}catch{}}function I(){for(let{dir:n}of a)try{let t=S(d(n,"VERSION"),"utf-8").trim();if(t)return t}catch{}return null}function M(n,t){let i=Object.keys(n.versions??{});if(i.length===0)return null;let o=i.slice().sort((r,e)=>l(r,e));for(let r of o){let e=n.versions[r]?.kaneCliMinVersion;if(!e||l(t,e)<=0)return r}return null}async function U(){try{let n=V()?.map;if(!n){let o=new AbortController,r=setTimeout(()=>o.abort(),5e3),e=await p(k(),{headers:{Accept:"application/json"},signal:o.signal});if(clearTimeout(r),!e.ok)return null;n=await e.json(),A(n)}let t=M(n,c);if(!t)return null;let i=I();return i===null?{current:null,latestCompatible:t}:l(i,t)>0?{current:i,latestCompatible:t}:null}catch{return null}}export{k as a,M as b,U as c};
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{d as s,j as l}from"./chunk-E4OYR32M.js";import{readFileSync as g,writeFileSync as o,mkdirSync as i,existsSync as p}from"fs";import{dirname as a}from"path";var n={window_size:{width:1920,height:1080},chrome_profile_path:"",default_url:l,model:"v16-alpha",project_id:null,project_name:null,folder_id:null,folder_name:null,mode:"testing",assertion_mode:"dom",network_ws:!1,network_sse:!1,bug_detection:"off",final_validation:!1,code_export:{enabled:!0,language:"python",skip_validation:!0},generate:{scenario_limit:2,per_scenario_limit:3,memory_enabled:!1},last_seen_version:"",hints_enabled:!0},c=class{constructor(r=s){this.path=r}exists(){return p(this.path)}load(){try{let r=g(this.path,"utf-8"),e=JSON.parse(r);return{...n,...e,code_export:{...n.code_export,...e.code_export??{}},generate:{...n.generate,...e.generate??{}}}}catch{return{...n,code_export:{...n.code_export},generate:{...n.generate}}}}set(r,e){try{let t=this.load();t[r]=e,i(a(this.path),{recursive:!0}),o(this.path,JSON.stringify(t,null,2)+`
2
+ import{d as s,k as l}from"./chunk-6SGPN76K.js";import{readFileSync as g,writeFileSync as o,mkdirSync as i,existsSync as p}from"fs";import{dirname as a}from"path";var n={window_size:{width:1920,height:1080},chrome_profile_path:"",default_url:l,model:"v16-alpha",project_id:null,project_name:null,folder_id:null,folder_name:null,mode:"testing",assertion_mode:"dom",network_ws:!1,network_sse:!1,bug_detection:"off",final_validation:!1,code_export:{enabled:!0,language:"python",skip_validation:!0},generate:{scenario_limit:2,per_scenario_limit:3,memory_enabled:!1},last_seen_version:"",hints_enabled:!0},c=class{constructor(r=s){this.path=r}exists(){return p(this.path)}load(){try{let r=g(this.path,"utf-8"),e=JSON.parse(r);return{...n,...e,code_export:{...n.code_export,...e.code_export??{}},generate:{...n.generate,...e.generate??{}}}}catch{return{...n,code_export:{...n.code_export},generate:{...n.generate}}}}set(r,e){try{let t=this.load();t[r]=e,i(a(this.path),{recursive:!0}),o(this.path,JSON.stringify(t,null,2)+`
3
3
  `)}catch(t){let d=t instanceof Error?t.message:String(t);process.stderr.write(`[config] Failed to save config: ${d}
4
4
  `)}}save(r){try{let t={...this.load(),...r};i(a(this.path),{recursive:!0}),o(this.path,JSON.stringify(t,null,2)+`
5
5
  `)}catch(e){let t=e instanceof Error?e.message:String(e);process.stderr.write(`[config] Failed to save config: ${t}
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{b as F}from"./chunk-QPZRHAYK.js";import{a as U,b as T,d as B}from"./chunk-ZZLR3O5A.js";import{e as W,g as P}from"./chunk-ZG2V2ODK.js";import{d as A,e as D,f as L,g as q,h as H}from"./chunk-5YPBPZUR.js";var G=/^[a-z0-9][a-z0-9-]{1,63}$/;function z(f,d,t,e){if(!d)return{error:{code:"SUPERSEDE_TARGET_MISSING",detail:"supersede verdict needs a target (slug or cid)"}};let n=f.resolve(d);return n?n.superseded||e.has(n.cid)?{error:{code:"ALREADY_SUPERSEDED",detail:`${d} is already superseded (tip: ${n.tip})`}}:n.cid===t?{error:{code:"SELF_SUPERSEDE",detail:"a node cannot supersede itself"}}:{targetCid:n.cid}:{error:{code:"UNKNOWN_SUPERSEDE_TARGET",detail:`${d} names nothing in the graph`}}}function X(f,d,t,e,n=[]){if(!q(d)?.acyclic)return null;if(t===e)return{code:"EDGE_CYCLE",detail:`${d} ${t} \u2192 itself`};let r=_=>[...f.edgesFrom(_).filter(E=>E.type===d).map(E=>E.dst),...n.filter(E=>E.type===d&&E.src===_).map(E=>E.dst)],c=new Set,p=[e];for(;p.length>0;){let _=p.pop();if(_===t)return{code:"EDGE_CYCLE",detail:`${d} ${t} \u2192 ${e} closes a cycle`};c.has(_)||(c.add(_),p.push(...r(_)))}return null}function de(f,d,t,e){let m=q(d)?.cardinality;if(m!=="one-live-per-src"&&m!=="one-live-per-src-and-dst")return null;let r=f.edgesFrom(t).filter(c=>c.type===d&&!f.superseded.has(c.dst));if(r.length>0)return{code:"CARDINALITY_VIOLATION",detail:`${d} from ${t} already has a live edge (${r[0].ecid}) \u2014 supersede it first`};if(m==="one-live-per-src-and-dst"&&e!==void 0){let c=f.edgesInto(e).filter(p=>p.type===d&&!f.superseded.has(p.src));if(c.length>0)return{code:"CARDINALITY_VIOLATION",detail:`${d} onto ${e} already has a live edge (${c[0].ecid}) \u2014 strict 1:1, supersede it first`}}return null}var K=new Set(["high","med","low"]);function ce(f,d,t){let e=[],n=t.mediaOf(f.source.source_cid),m=new Set;for(let r of f.use_cases){if(m.has(r.temp_ref)&&e.push({code:"DUP_TEMP_REF",detail:`duplicate temp_ref ${r.temp_ref}`}),m.add(r.temp_ref),(!r.title||!r.title.trim())&&e.push({code:"EMPTY_TITLE",detail:`${r.temp_ref}: title is empty`}),K.has(r.risk)||e.push({code:"BAD_RISK",detail:`${r.temp_ref}: risk ${JSON.stringify(r.risk)} not in high|med|low`}),!r.cite||!r.cite.anchor)e.push({code:"MISSING_CITE",detail:`${r.temp_ref}: every derived use-case must carry a cite`});else for(let c of F(n,r.cite,d))e.push({code:c.code,detail:`${r.temp_ref}: ${c.detail}`});r.matches_existing&&!t.hasNode(r.matches_existing.cid)&&e.push({code:"UNKNOWN_MATCH",detail:`${r.temp_ref}: matches_existing ${r.matches_existing.cid} is not in the graph`});for(let[c,p]of(r.criteria??[]).entries())if((!p.text||!p.text.trim())&&e.push({code:"EMPTY_CRITERION",detail:`${r.temp_ref}.criteria[${c}]: text is empty`}),!p.cite||!p.cite.anchor)e.push({code:"MISSING_CITE",detail:`${r.temp_ref}.criteria[${c}]: every criterion carries its own cite`});else for(let _ of F(n,p.cite,d))e.push({code:_.code,detail:`${r.temp_ref}.criteria[${c}]: ${_.detail}`});for(let[c,p]of(r.updated?.criteria??[]).entries())if((!p.text||!p.text.trim())&&e.push({code:"EMPTY_CRITERION",detail:`${r.temp_ref}.updated.criteria[${c}]: text is empty`}),!p.cite||!p.cite.anchor)e.push({code:"MISSING_CITE",detail:`${r.temp_ref}.updated.criteria[${c}]: every updated criterion carries its own cite`});else for(let _ of F(n,p.cite,d))e.push({code:_.code,detail:`${r.temp_ref}.updated.criteria[${c}]: ${_.detail}`})}return e}function ae(f){let{contextDir:d,graph:t,proposal:e,proposalId:n,verdicts:m,by:r,allowStaleBasis:c,extractorVersion:p,autoName:_}=f,E=W(d);if(!c&&e.read_basis!==E)return{record:null,errors:[{code:"STALE_BASIS",detail:`proposal read_basis ${String(e.read_basis)} != latest ${String(E)}`}]};if(!t.hasNode(e.source.source_cid))return{record:null,errors:[{code:"MISSING_SOURCE_NODE",detail:`source ${e.source.source_id} (${e.source.source_cid}) is not a committed node \u2014 ingest it first`}]};let l=[],g=t.mediaOf(e.source.source_cid),k=new Set,v=[],S=[],O=[],R=[],x=[],V=[],M=new Set,Y=new Set,j=(i,s,b)=>{let u=z(t,s.supersedeTarget,b,M);if("error"in u){l.push({code:u.error.code,detail:`${i}: ${u.error.detail}`});return}M.add(u.targetCid),x.push({kind:"node",old:u.targetCid,new:b,reason:s.reason??`superseded via review by ${r.id}`,by:r})};for(let i of e.use_cases){let s=m.get(i.temp_ref)??{resolution:"skipped"};if(k.has(i.temp_ref)&&l.push({code:"DUP_TEMP_REF",detail:`duplicate temp_ref ${i.temp_ref}`}),k.add(i.temp_ref),(!i.title||!i.title.trim())&&l.push({code:"EMPTY_TITLE",detail:`${i.temp_ref}: title is empty`}),K.has(i.risk)||l.push({code:"BAD_RISK",detail:`${i.temp_ref}: risk ${JSON.stringify(i.risk)} not in high|med|low`}),g.format==="image"){if(i.cite?.anchor!=="img#whole"){l.push({code:i.cite?.anchor?"CITE_ANCHOR_INVALID":"MISSING_CITE",detail:`${i.temp_ref}: image cites are anchor-only (img#whole)`});continue}}else if(!i.cite||!i.cite.anchor||!i.cite.quote){l.push({code:"MISSING_CITE",detail:`${i.temp_ref}: every derived use-case must cite anchor+quote`});continue}s.resolution==="edited"&&s.edit&&(s.edit.title!==void 0&&!s.edit.title.trim()&&l.push({code:"EMPTY_TITLE",detail:`${i.temp_ref}: edited title is empty`}),s.edit.risk!==void 0&&!K.has(s.edit.risk)&&l.push({code:"BAD_RISK",detail:`${i.temp_ref}: edited risk ${JSON.stringify(s.edit.risk)} invalid`}));let b=B({title:s.edit?.title??i.title,description:i.description,summary:s.edit?.summary??i.summary,actors:i.actors,value:i.value,risk:s.edit?.risk??i.risk,...i.criteria&&i.criteria.length>0?{criteria:i.criteria.map(o=>o.text)}:{}}),u=U("usecase",b),I={source_id:e.source.source_id,source_cid:e.source.source_cid,anchor:i.cite.anchor,...i.cite.quote?{quote:i.cite.quote}:{}};if(i.matches_existing&&!t.hasNode(i.matches_existing.cid)){l.push({code:"UNKNOWN_MATCH",detail:`${i.temp_ref}: matches_existing ${i.matches_existing.cid} is not in the graph`});continue}let N=i.matches_existing?.cid??(t.hasNode(u)?u:null);if(N&&t.superseded.has(N)){let o=t.tipOf(N);N=t.superseded.has(o)?null:o}if(N){if(i.changed&&(s.resolution==="approved"||s.resolution==="edited")){let o=i.updated;if(!o||Object.keys(o).length===0){l.push({code:"CHANGED_NEEDS_PAYLOAD",detail:`${i.temp_ref}: changed:true needs an updated{...} payload naming the moved fields`});continue}let h=t.getNode(N)?.content??{},$=(o.criteria??[]).map(a=>typeof a=="string"?{text:a,cite:void 0}:a),C=B({title:s.edit?.title??o.title??String(h.title??i.title),...o.description??h.description?{description:o.description??h.description}:{},...s.edit?.summary??o.summary??h.summary?{summary:s.edit?.summary??o.summary??h.summary}:{},...o.actors??h.actors?{actors:o.actors??h.actors}:{},...o.value??h.value?{value:o.value??h.value}:{},risk:s.edit?.risk??o.risk??String(h.risk??i.risk),...o.criteria?$.length>0?{criteria:$.map(a=>a.text)}:{}:h.criteria?{criteria:h.criteria}:{}}),w=U("usecase",C);if(w!==N){for(let a of L("usecase",C))l.push({code:a.code,detail:`${i.temp_ref}: ${a.detail}`});v.push({cid:w,label:A.USECASE,content:C}),S.push({ecid:T("DERIVES",I.source_cid,w,I),type:D.DERIVES,src:I.source_cid,dst:w,props:I});for(let a of $){if(!a.cite)continue;let y={source_id:e.source.source_id,source_cid:e.source.source_cid,anchor:a.cite.anchor,...a.cite.quote?{quote:a.cite.quote}:{},claim:a.text};S.push({ecid:T("DERIVES",y.source_cid,w,y),type:D.DERIVES,src:y.source_cid,dst:w,props:y})}j(i.temp_ref,{resolution:"supersede",supersedeTarget:N,reason:s.reason??`matches-but-changed: ${e.source.source_id} moved (${Object.keys(o).join(", ")})`},w),R.push({id:w,kind:"review-item",resolution:s.resolution,edit:s.resolution==="edited"?{...s.edit}:null,reason:null,by:r});continue}for(let a of $){if(!a.cite)continue;let y={source_id:e.source.source_id,source_cid:e.source.source_cid,anchor:a.cite.anchor,...a.cite.quote?{quote:a.cite.quote}:{},claim:a.text};S.push({ecid:T("DERIVES",y.source_cid,N,y),type:D.DERIVES,src:y.source_cid,dst:N,props:y})}}s.resolution!=="rejected"&&(S.push({ecid:T("DERIVES",I.source_cid,N,I),type:D.DERIVES,src:I.source_cid,dst:N,props:I}),(s.resolution==="approved"||s.resolution==="edited"||s.resolution==="supersede")&&R.push({id:N,kind:"review-item",resolution:"approved",edit:null,reason:null,by:r}),s.resolution==="supersede"&&j(i.temp_ref,s,N));continue}for(let o of L("usecase",b))l.push({code:o.code,detail:`${i.temp_ref}: ${o.detail}`});for(let o of H(D.DERIVES,"source","usecase",I))l.push({code:o.code,detail:`${i.temp_ref}: ${o.detail}`});v.push({cid:u,label:A.USECASE,content:b}),S.push({ecid:T("DERIVES",I.source_cid,u,I),type:D.DERIVES,src:I.source_cid,dst:u,props:I});for(let o of i.criteria??[]){let h={source_id:e.source.source_id,source_cid:e.source.source_cid,anchor:o.cite.anchor,...o.cite.quote?{quote:o.cite.quote}:{},claim:o.text};S.push({ecid:T("DERIVES",h.source_cid,u,h),type:D.DERIVES,src:h.source_cid,dst:u,props:h})}for(let o of i.depends_on_hint??[]){let h=a=>a.toLowerCase().trim().replace(/\s+/g," "),$=null,C=t.resolve(o);if(C&&!C.superseded&&t.nodeLabel.get(C.cid)===A.USECASE&&($=C.cid),!$){for(let{cid:a,content:y}of t.byLabel(A.USECASE))if(!t.superseded.has(a)&&h(String(y.title??""))===h(o)){$=a;break}}if(!$){let a=v.find(y=>y.label===A.USECASE&&h(String(y.content.title??""))===h(o));a&&($=a.cid)}!$||$===u||X(t,D.DEPENDS_ON,u,$,O)||O.some(a=>a.src===u&&a.dst===$)||(S.push({ecid:T(D.DEPENDS_ON,u,$,{reason:"extract hint"}),type:D.DEPENDS_ON,src:u,dst:$,props:{reason:"extract hint"}}),O.push({src:u,dst:$,type:D.DEPENDS_ON}))}if((s.resolution==="approved"||s.resolution==="edited"||s.resolution==="supersede")&&t.superseded.get(u)===null&&!M.has(u)&&x.push({kind:"node",old:u,new:u,reason:`re-minted after tombstone via review by ${r.id}`,by:r}),_){let o=J("usecase",s.edit?.title??i.title,h=>Y.has(h)||t.names.has(h)&&!t.superseded.has(t.names.get(h)));o!==null&&!t.nameOf.has(u)&&(Y.add(o),V.push({cid:u,slug:o,by:r}))}s.resolution==="approved"?R.push({id:u,kind:"review-item",resolution:"approved",edit:null,reason:null,by:r}):s.resolution==="edited"?R.push({id:u,kind:"review-item",resolution:"edited",edit:{...s.edit},reason:null,by:r}):s.resolution==="rejected"?R.push({id:u,kind:"review-item",resolution:"rejected",edit:null,reason:s.reason??null,by:r}):s.resolution==="supersede"&&(R.push({id:u,kind:"review-item",resolution:"approved",edit:null,reason:s.reason??null,by:r}),j(i.temp_ref,s,u))}return l.length?{record:null,errors:l}:{record:P(d,{ts:new Date().toISOString(),proposal_id:n,...n!=null?{extraction_of:e.source.source_cid}:{},...n!=null&&p?{extractor_version:p}:{},nodes:v,edges:S,review:R,supersessions:x,...V.length>0?{names:V}:{},...f.judgements&&f.judgements.length>0?{judgements:f.judgements}:{},source_head_moves:{}},{expectPrev:E}).record,errors:null}}function ue(f){let{contextDir:d,graph:t,verdicts:e,by:n}=f,m=[],r=[],c=[],p=[],_=new Set;for(let[l,g]of e){if(g.resolution==="skipped")continue;let k=t.resolve(l);if(!k){m.push({code:"UNKNOWN_NODE",detail:`${l} names nothing in the graph`});continue}if(k.superseded){m.push({code:"SUPERSEDED_TARGET",detail:`${l} is superseded \u2014 review the tip (${k.tip})`});continue}let v=k.cid;if(g.resolution==="approved")c.push({id:v,kind:"review-item",resolution:"approved",edit:null,reason:null,by:n});else if(g.resolution==="rejected")c.push({id:v,kind:"review-item",resolution:"rejected",edit:null,reason:g.reason??null,by:n});else if(g.resolution==="edited"){let S=t.getNode(v);if(!S){m.push({code:"UNKNOWN_NODE",detail:`${l}: node file unreadable`});continue}let O={...S.content,...g.edit?.title!==void 0?{title:g.edit.title}:{},...g.edit?.summary!==void 0?{summary:g.edit.summary}:{},...g.edit?.risk!==void 0?{risk:g.edit.risk}:{}},R=L(S.label,O);if(R.length>0){for(let V of R)m.push({code:V.code,detail:`${l}: ${V.detail}`});continue}let x=U(S.label,O);if(x===v){c.push({id:v,kind:"review-item",resolution:"approved",edit:null,reason:null,by:n});continue}r.push({cid:x,label:S.label,content:O}),_.add(v),p.push({kind:"node",old:v,new:x,reason:g.reason??"edited in review",by:n}),c.push({id:x,kind:"review-item",resolution:"edited",edit:{...g.edit},reason:null,by:n})}else if(g.resolution==="supersede"){let S=z(t,g.supersedeTarget,v,_);if("error"in S){m.push({code:S.error.code,detail:`${l}: ${S.error.detail}`});continue}_.add(S.targetCid),p.push({kind:"node",old:S.targetCid,new:v,reason:g.reason??`superseded via review by ${n.id}`,by:n}),c.push({id:v,kind:"review-item",resolution:"approved",edit:null,reason:g.reason??null,by:n})}}return m.length?{record:null,errors:m}:c.length===0&&p.length===0?{record:null,errors:[{code:"NO_VERDICTS",detail:"every item was skipped \u2014 nothing to commit"}]}:{record:P(d,{ts:new Date().toISOString(),proposal_id:null,nodes:r,edges:[],review:c,supersessions:p,source_head_moves:{}},{expectPrev:t.latestHash}).record,errors:null}}function le(f){let{contextDir:d,graph:t,assignments:e,by:n}=f,m=[],r=[],c=new Set;for(let{ref:_,slug:E}of e){if(!G.test(E)){m.push({code:"BAD_SLUG",detail:`${JSON.stringify(E)} \u2014 slugs are kebab-case ${String(G)}`});continue}let l=t.resolve(_);if(!l){m.push({code:"UNKNOWN_REF",detail:`${_} names nothing in the graph`});continue}if(l.superseded){m.push({code:"SUPERSEDED_TARGET",detail:`${_} is superseded \u2014 name the tip instead (${l.tip})`});continue}let g=t.names.get(E);if(g!==void 0&&!t.superseded.has(g)&&g!==l.cid||c.has(E)){m.push({code:"SLUG_TAKEN",detail:`${E} already names ${g??"another node in this record"}`});continue}c.add(E),r.push({cid:l.cid,slug:E,by:n})}return m.length?{record:null,errors:m}:r.length===0?{record:null,errors:[{code:"NO_ASSIGNMENTS",detail:"nothing to name"}]}:{record:P(d,{ts:new Date().toISOString(),proposal_id:null,nodes:[],edges:[],review:[],supersessions:[],names:r,source_head_moves:{}},{expectPrev:t.latestHash}).record,errors:null}}function pe(f){let{contextDir:d,graph:t,sourceId:e,reason:n,by:m}=f,r=t.heads.get(e);return r===void 0?{record:null,errors:[{code:"UNKNOWN_SOURCE",detail:`no source ${e} in the graph`}]}:r===null?{record:null,errors:[{code:"ALREADY_RETIRED",detail:`source ${e} is already retired`}]}:{record:P(d,{ts:new Date().toISOString(),proposal_id:null,nodes:[],edges:[],review:[],supersessions:[{kind:"node",old:r,new:null,reason:n??`retired source ${e}`,by:m}],source_head_moves:{[e]:null},names:[]},{expectPrev:t.latestHash}).record,errors:null}}function Q(f,d){let t=f.toLowerCase().trim().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"");if(t.length>60){let n=t.lastIndexOf("-",60);t=(n>0?t.slice(0,n):t.slice(0,60)).replace(/-+$/g,"")}if(!G.test(t))return null;let e=t;for(let n=2;d(e);n++)e=`${t}-${n}`;return G.test(e)?e:null}var Z={source:"src",usecase:"uc",scenario:"sc",ac:"ac",test:"t",gap:"gap",stylenote:"sty"};function J(f,d,t){let e=Z[f];return Q(e?`${e} ${d}`:d,t)}export{Z as a,J as b,X as c,de as d,ce as e,ae as f,ue as g,le as h,pe as i};
@@ -1,10 +1,10 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as B,b as V,c as se}from"./chunk-C5POEXSX.js";import{a as j,b as N}from"./chunk-Y6LMHBLE.js";import{a as ne,b as oe}from"./chunk-2YQ6TW77.js";import{a as C,b as Y,e as M,f as te,m as re}from"./chunk-RKWJG3WW.js";import{a as L}from"./chunk-XBE7PGVY.js";import{a as ee}from"./chunk-WAOCHXJ5.js";import{a as Z}from"./chunk-YZKPZXHY.js";import{a as A}from"./chunk-RZ4F3BHX.js";import{a as H}from"./chunk-RLG5NUTE.js";import{a as O}from"./chunk-TZZYRDCF.js";import{x as h}from"./chunk-E4OYR32M.js";import{a as F}from"./chunk-HCBYKLMW.js";import{a as k,b as g,i as Q}from"./chunk-C44QQJR4.js";import{a as X}from"./chunk-6YGTRKDT.js";import{e as v}from"./chunk-UR6MHSHU.js";var D=v(X(),1);import{existsSync as P,readFileSync as Je,rmSync as pe,unlinkSync as Ke}from"fs";import{resolve as G}from"path";import{promises as ie,realpathSync as ke}from"fs";import{homedir as be}from"os";import{join as q,parse as Te,relative as ae,resolve as ce}from"path";var le=new Set(["node_modules",".git","dist","build",".next",".venv","venv","target","__pycache__"]),R=class extends Error{constructor(s){super(`refusing to scan '${s}'. Run from your project root, or pass --root <dir>.`);this.cwd=s;this.name="HomeRefusedError"}};function ue(e){try{return ke(ce(e))}catch{return ce(e)}}function Ee(e){let r=ue(e),s=ue(be()),n=Te(r).root;if(process.platform==="win32"){let o=t=>t.toLowerCase();return o(r)===o(s)||o(r)===o(n)}return r===s||r===n}async function U(e){if(Ee(e.root))throw new R(e.root);let r=e.maxEntries??5e4,s=e.maxResults??5e3,n=new Set(e.ignore??[]),o=[],t=0,i=0,c=!1,f,l=[e.root];for(;l.length>0&&!c;){let a=l.shift(),m;try{m=await ie.readdir(a,{withFileTypes:!0})}catch{continue}i++;for(let b of m){if(t++,t>r){c=!0,f="max_entries";break}let w=b.name,E=q(a,w);if(b.isDirectory()){if(le.has(w)||w.startsWith(".")||w.startsWith("output-")||n.has(w))continue;l.push(E)}else if(b.isFile()&&w.endsWith("_test.md")&&(o.push({path:E,relPath:ae(e.root,E),source:"cwd"}),o.length>=s)){c=!0,f="max_results";break}}e.onProgress?.(i,o.length)}if(!c){let m=[{dir:q(e.root,".testmuai","tests"),depth:0}];for(;m.length>0&&!c;){let{dir:b,depth:w}=m.shift(),E;try{E=await ie.readdir(b,{withFileTypes:!0})}catch{continue}i++;for(let u of E){if(t++,t>r){c=!0,f="max_entries";break}let x=u.name,y=q(b,x);if(u.isDirectory()){if(w>=20||x.startsWith(".")||x.startsWith("output-")||le.has(x))continue;m.push({dir:y,depth:w+1})}else if(u.isFile()&&x.endsWith("_test.md")&&(o.push({path:y,relPath:ae(e.root,y),source:"tests-dir"}),o.length>=s)){c=!0,f="max_results";break}}}}return{results:o,aborted:c,abortReason:f,dirsScanned:i}}import{readFileSync as Se}from"fs";function W(e){try{return re(e,Se(e,"utf8")).global.tags??[]}catch{return[]}}import{mkdirSync as ve,writeFileSync as Re}from"fs";import{join as Pe}from"path";function de(e,r){return`Basic ${Buffer.from(`${e}:${r}`).toString("base64")}`}async function Me(e){let r=ne({tmsBaseUrl:e.tmsBaseUrl,testcaseId:e.testcaseId,codeExport:{enabled:!0,language:e.language,skipValidation:e.skipValidation}}),s=await A(r.url,{method:"POST",headers:{"content-type":"application/json",authorization:de(e.auth.username,e.auth.access_key)},body:JSON.stringify(r.body)});if(!s.ok)throw new Error(`code-export trigger failed: ${s.status} ${await s.text()}`);e.log("info","CODE_EXPORT_TRIGGERED","Code export triggered",{testcase_id:e.testcaseId})}async function De(e){let r=oe({tmsBaseUrl:e.tmsBaseUrl,testcaseId:e.testcaseId}),s=e.pollIntervalMs??5e3,n=e.timeoutMs??3e5,o=Date.now()+n;for(;Date.now()<o;){let t=await A(r,{headers:{authorization:de(e.auth.username,e.auth.access_key),accept:"application/json"}});if(!t.ok){await new Promise(l=>setTimeout(l,s));continue}let c=(await t.json()).data?.find(l=>l.code_name==="kane-cli-trigger");if(!c){await new Promise(l=>setTimeout(l,s));continue}let f=(c.status??"").toLowerCase();if(f==="in progress"||f==="in_progress"||f==="pending"){await new Promise(l=>setTimeout(l,s));continue}if(!c.url||c.url.length===0)throw new Error(`code-export status=${c.status} but no files returned`);ve(e.outDir,{recursive:!0});for(let l of c.url){let a=Pe(e.outDir,l.file_name),m=await A(l.file_url);if(!m.ok){e.log("warn","CODE_EXPORT_FILE_FAILED","Failed to download file",{file_name:l.file_name,status:m.status});continue}let b=await m.text();Re(a,b,"utf-8")}return e.log("info","CODE_EXPORT_DOWNLOADED","Code export saved",{out_dir:e.outDir,file_count:c.url.length}),e.outDir}throw new Error("code-export polling timed out")}async function fe(e){return await Me(e),await De(e)}var T=v(X(),1);import{existsSync as $e,readFileSync as Ce}from"fs";var p=v(F(),1);function Ie(e){B(e);let r=M(e);if(!$e(r))return null;try{return JSON.parse(Ce(r,"utf8"))}catch{return{}}}function Fe(e){return e===null?"never_run":e.testcase_id?"synced":"local_only"}function Oe(e){return e==="synced"?"\u2601":e==="local_only"?"\u25A3":"\u25CB"}function Ae(e){return e==="tests-dir"?"\u2726":" "}function Le(e,r){return r==="all"?!0:r==="synced"?e.status==="synced":r==="local"?e.status==="local_only":r==="never_run"?e.status==="never_run":r==="cli"?e.source==="tests-dir":r==="hand"?e.source==="cwd":!0}var z=["all","synced","local","never_run","cli","hand"];function Be(e){let r=z.indexOf(e);return z[(r+1)%z.length]}function me({root:e,currentOrgId:r,onSelect:s,onCancel:n}){let[o,t]=(0,T.useState)([]),[i,c]=(0,T.useState)(null),[f,l]=(0,T.useState)(!0),[a,m]=(0,T.useState)("all");(0,T.useEffect)(()=>{(async()=>{try{let u=await U({root:e}),x=[];for(let y of u.results){let K=Ie(y.path);K?.org_id!==void 0&&K.org_id!==r||x.push({path:y.path,relPath:y.relPath,name:C(y.path),status:Fe(K),source:y.source,tags:W(y.path)})}t(x),l(!1)}catch(u){u instanceof R,c(u.message),l(!1)}})()},[e,r]);let b=(0,T.useMemo)(()=>o.filter(u=>Le(u,a)).map(u=>({id:u.path,label:`${Oe(u.status)} ${Ae(u.source)} ${u.relPath}${u.tags.length>0?` [${u.tags.join(", ")}]`:""}`})),[o,a]),w=(0,T.useMemo)(()=>Ne(a,o),[a,o]);if(i)return(0,p.jsxs)(k,{flexDirection:"column",borderStyle:"round",borderColor:h.red,paddingX:2,paddingY:1,children:[(0,p.jsx)(g,{color:h.red,bold:!0,children:"testmd"}),(0,p.jsx)(k,{marginTop:1,children:(0,p.jsx)(g,{color:h.red,children:i})})]});let E=a==="all"?"all":je(a);return(0,p.jsx)(Z,{title:`testmd \xB7 filter: ${E}`,items:b,loading:f,itemNoun:"tests",onSelect:u=>{let x=o.find(y=>y.path===u.id);x&&s(x)},onCancel:n,onTab:()=>m(u=>Be(u)),extraHint:"cycle filter",footer:w})}function je(e){return e==="synced"?"synced (\u2601)":e==="local"?"local (\u25A3)":e==="never_run"?"never run (\u25CB)":e==="cli"?"cli-generated (\u2726)":e==="hand"?"hand-written":"all"}function Ne(e,r){let s={synced:r.filter(o=>o.status==="synced").length,local:r.filter(o=>o.status==="local_only").length,never:r.filter(o=>o.status==="never_run").length,cli:r.filter(o=>o.source==="tests-dir").length,hand:r.filter(o=>o.source==="cwd").length},n=o=>o?h.orange:h.dim;return(0,p.jsxs)(k,{flexDirection:"column",children:[(0,p.jsx)(g,{color:h.dim,children:"legend:"}),(0,p.jsxs)(k,{children:[(0,p.jsx)(g,{color:n(e==="synced"),children:` \u2601 synced (${s.synced}) `}),(0,p.jsx)(g,{color:n(e==="local"),children:`\u25A3 local (${s.local}) `}),(0,p.jsx)(g,{color:n(e==="never_run"),children:`\u25CB never run (${s.never})`})]}),(0,p.jsxs)(k,{children:[(0,p.jsx)(g,{color:n(e==="cli"),children:` \u2726 cli-generated (${s.cli}) `}),(0,p.jsx)(g,{color:n(e==="hand"),children:` hand-written (${s.hand})`})]})]})}var I=v(X(),1);import{existsSync as Ue,readFileSync as We}from"fs";var d=v(F(),1);function ge({path:e,relPath:r,onAction:s,onBack:n,onView:o}){let[t,i]=(0,I.useState)(null),[c,f]=(0,I.useState)(!1);(0,I.useEffect)(()=>{let a=M(e);if(Ue(a))try{i(JSON.parse(We(a,"utf8")))}catch{i(null)}},[e]),Q((a,m)=>{if(m.escape){if(c){f(!1);return}n();return}if(c){a==="y"||a==="Y"?(f(!1),s("delete")):(a==="n"||a==="N")&&f(!1);return}a==="r"&&s("run"),a==="e"&&t?.testcase_id&&s("export"),a==="d"&&f(!0),a==="v"&&o&&o()});let l=({k:a,v:m})=>m?(0,d.jsxs)(g,{children:[(0,d.jsx)(g,{color:h.dim,children:a.padEnd(14)}),m]}):null;return(0,d.jsxs)(k,{flexDirection:"column",borderStyle:"round",borderColor:h.orange,paddingX:2,paddingY:1,children:[(0,d.jsx)(g,{color:h.orange,bold:!0,children:r}),(0,d.jsx)(k,{marginTop:1,flexDirection:"column",children:t?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(l,{k:"test_id",v:t.test_id}),(0,d.jsx)(l,{k:"testcase_id",v:t.testcase_id}),(0,d.jsx)(l,{k:"project_id",v:t.project_id}),(0,d.jsx)(l,{k:"folder_id",v:t.folder_id}),(0,d.jsx)(l,{k:"org_id",v:t.org_id}),(0,d.jsx)(l,{k:"session_name",v:t.session_name}),(0,d.jsx)(l,{k:"commit_id",v:t.commit_id})]}):(0,d.jsx)(g,{color:h.dim,children:"(never run \u2014 no meta.json)"})}),c?(0,d.jsx)(k,{marginTop:1,children:(0,d.jsxs)(g,{color:h.red,bold:!0,children:["Delete ",r," and its output dir? [y/n]"]})}):(0,d.jsx)(k,{marginTop:1,children:(0,d.jsxs)(g,{color:h.dim,children:["[r] run [e] export",t?.testcase_id?"":" (need testcase_id)"," [d] delete",o?" [v] view":""," [Esc] back"]})})]})}function $(e){B(e);let r=M(e);if(!P(r))return null;try{return JSON.parse(Je(r,"utf8"))}catch{return null}}function he(e,r){return!e||e.org_id===void 0?!0:e.org_id===r}function J(e,r){return he(e,r)?null:(process.stderr.write(`error: this test belongs to org ${e.org_id}; you are logged in as org ${r}.
2
+ import{a as B,b as V,c as se}from"./chunk-EWTX7HSU.js";import{a as j,b as N}from"./chunk-32GP7KTM.js";import{a as ne,b as oe}from"./chunk-2YQ6TW77.js";import{a as C,b as Y,e as M,f as te,m as re}from"./chunk-RKWJG3WW.js";import{a as L}from"./chunk-VBCE4U4B.js";import{a as ee}from"./chunk-WAOCHXJ5.js";import{a as Z}from"./chunk-MY32TBBR.js";import{a as A}from"./chunk-RZ4F3BHX.js";import{a as H}from"./chunk-AKHUNBQS.js";import{a as O}from"./chunk-P4HW2NTZ.js";import{y as h}from"./chunk-6SGPN76K.js";import{a as F}from"./chunk-HCBYKLMW.js";import{a as k,b as g,i as Q}from"./chunk-C44QQJR4.js";import{a as X}from"./chunk-6YGTRKDT.js";import{e as v}from"./chunk-UR6MHSHU.js";var D=v(X(),1);import{existsSync as P,readFileSync as Je,rmSync as pe,unlinkSync as Ke}from"fs";import{resolve as G}from"path";import{promises as ie,realpathSync as ke}from"fs";import{homedir as be}from"os";import{join as q,parse as Te,relative as ae,resolve as ce}from"path";var le=new Set(["node_modules",".git","dist","build",".next",".venv","venv","target","__pycache__"]),R=class extends Error{constructor(s){super(`refusing to scan '${s}'. Run from your project root, or pass --root <dir>.`);this.cwd=s;this.name="HomeRefusedError"}};function ue(e){try{return ke(ce(e))}catch{return ce(e)}}function Ee(e){let r=ue(e),s=ue(be()),n=Te(r).root;if(process.platform==="win32"){let o=t=>t.toLowerCase();return o(r)===o(s)||o(r)===o(n)}return r===s||r===n}async function U(e){if(Ee(e.root))throw new R(e.root);let r=e.maxEntries??5e4,s=e.maxResults??5e3,n=new Set(e.ignore??[]),o=[],t=0,i=0,c=!1,f,l=[e.root];for(;l.length>0&&!c;){let a=l.shift(),m;try{m=await ie.readdir(a,{withFileTypes:!0})}catch{continue}i++;for(let b of m){if(t++,t>r){c=!0,f="max_entries";break}let w=b.name,E=q(a,w);if(b.isDirectory()){if(le.has(w)||w.startsWith(".")||w.startsWith("output-")||n.has(w))continue;l.push(E)}else if(b.isFile()&&w.endsWith("_test.md")&&(o.push({path:E,relPath:ae(e.root,E),source:"cwd"}),o.length>=s)){c=!0,f="max_results";break}}e.onProgress?.(i,o.length)}if(!c){let m=[{dir:q(e.root,".testmuai","tests"),depth:0}];for(;m.length>0&&!c;){let{dir:b,depth:w}=m.shift(),E;try{E=await ie.readdir(b,{withFileTypes:!0})}catch{continue}i++;for(let u of E){if(t++,t>r){c=!0,f="max_entries";break}let x=u.name,y=q(b,x);if(u.isDirectory()){if(w>=20||x.startsWith(".")||x.startsWith("output-")||le.has(x))continue;m.push({dir:y,depth:w+1})}else if(u.isFile()&&x.endsWith("_test.md")&&(o.push({path:y,relPath:ae(e.root,y),source:"tests-dir"}),o.length>=s)){c=!0,f="max_results";break}}}}return{results:o,aborted:c,abortReason:f,dirsScanned:i}}import{readFileSync as Se}from"fs";function W(e){try{return re(e,Se(e,"utf8")).global.tags??[]}catch{return[]}}import{mkdirSync as ve,writeFileSync as Re}from"fs";import{join as Pe}from"path";function de(e,r){return`Basic ${Buffer.from(`${e}:${r}`).toString("base64")}`}async function Me(e){let r=ne({tmsBaseUrl:e.tmsBaseUrl,testcaseId:e.testcaseId,codeExport:{enabled:!0,language:e.language,skipValidation:e.skipValidation}}),s=await A(r.url,{method:"POST",headers:{"content-type":"application/json",authorization:de(e.auth.username,e.auth.access_key)},body:JSON.stringify(r.body)});if(!s.ok)throw new Error(`code-export trigger failed: ${s.status} ${await s.text()}`);e.log("info","CODE_EXPORT_TRIGGERED","Code export triggered",{testcase_id:e.testcaseId})}async function De(e){let r=oe({tmsBaseUrl:e.tmsBaseUrl,testcaseId:e.testcaseId}),s=e.pollIntervalMs??5e3,n=e.timeoutMs??3e5,o=Date.now()+n;for(;Date.now()<o;){let t=await A(r,{headers:{authorization:de(e.auth.username,e.auth.access_key),accept:"application/json"}});if(!t.ok){await new Promise(l=>setTimeout(l,s));continue}let c=(await t.json()).data?.find(l=>l.code_name==="kane-cli-trigger");if(!c){await new Promise(l=>setTimeout(l,s));continue}let f=(c.status??"").toLowerCase();if(f==="in progress"||f==="in_progress"||f==="pending"){await new Promise(l=>setTimeout(l,s));continue}if(!c.url||c.url.length===0)throw new Error(`code-export status=${c.status} but no files returned`);ve(e.outDir,{recursive:!0});for(let l of c.url){let a=Pe(e.outDir,l.file_name),m=await A(l.file_url);if(!m.ok){e.log("warn","CODE_EXPORT_FILE_FAILED","Failed to download file",{file_name:l.file_name,status:m.status});continue}let b=await m.text();Re(a,b,"utf-8")}return e.log("info","CODE_EXPORT_DOWNLOADED","Code export saved",{out_dir:e.outDir,file_count:c.url.length}),e.outDir}throw new Error("code-export polling timed out")}async function fe(e){return await Me(e),await De(e)}var T=v(X(),1);import{existsSync as $e,readFileSync as Ce}from"fs";var p=v(F(),1);function Ie(e){B(e);let r=M(e);if(!$e(r))return null;try{return JSON.parse(Ce(r,"utf8"))}catch{return{}}}function Fe(e){return e===null?"never_run":e.testcase_id?"synced":"local_only"}function Oe(e){return e==="synced"?"\u2601":e==="local_only"?"\u25A3":"\u25CB"}function Ae(e){return e==="tests-dir"?"\u2726":" "}function Le(e,r){return r==="all"?!0:r==="synced"?e.status==="synced":r==="local"?e.status==="local_only":r==="never_run"?e.status==="never_run":r==="cli"?e.source==="tests-dir":r==="hand"?e.source==="cwd":!0}var z=["all","synced","local","never_run","cli","hand"];function Be(e){let r=z.indexOf(e);return z[(r+1)%z.length]}function me({root:e,currentOrgId:r,onSelect:s,onCancel:n}){let[o,t]=(0,T.useState)([]),[i,c]=(0,T.useState)(null),[f,l]=(0,T.useState)(!0),[a,m]=(0,T.useState)("all");(0,T.useEffect)(()=>{(async()=>{try{let u=await U({root:e}),x=[];for(let y of u.results){let K=Ie(y.path);K?.org_id!==void 0&&K.org_id!==r||x.push({path:y.path,relPath:y.relPath,name:C(y.path),status:Fe(K),source:y.source,tags:W(y.path)})}t(x),l(!1)}catch(u){u instanceof R,c(u.message),l(!1)}})()},[e,r]);let b=(0,T.useMemo)(()=>o.filter(u=>Le(u,a)).map(u=>({id:u.path,label:`${Oe(u.status)} ${Ae(u.source)} ${u.relPath}${u.tags.length>0?` [${u.tags.join(", ")}]`:""}`})),[o,a]),w=(0,T.useMemo)(()=>Ne(a,o),[a,o]);if(i)return(0,p.jsxs)(k,{flexDirection:"column",borderStyle:"round",borderColor:h.red,paddingX:2,paddingY:1,children:[(0,p.jsx)(g,{color:h.red,bold:!0,children:"testmd"}),(0,p.jsx)(k,{marginTop:1,children:(0,p.jsx)(g,{color:h.red,children:i})})]});let E=a==="all"?"all":je(a);return(0,p.jsx)(Z,{title:`testmd \xB7 filter: ${E}`,items:b,loading:f,itemNoun:"tests",onSelect:u=>{let x=o.find(y=>y.path===u.id);x&&s(x)},onCancel:n,onTab:()=>m(u=>Be(u)),extraHint:"cycle filter",footer:w})}function je(e){return e==="synced"?"synced (\u2601)":e==="local"?"local (\u25A3)":e==="never_run"?"never run (\u25CB)":e==="cli"?"cli-generated (\u2726)":e==="hand"?"hand-written":"all"}function Ne(e,r){let s={synced:r.filter(o=>o.status==="synced").length,local:r.filter(o=>o.status==="local_only").length,never:r.filter(o=>o.status==="never_run").length,cli:r.filter(o=>o.source==="tests-dir").length,hand:r.filter(o=>o.source==="cwd").length},n=o=>o?h.orange:h.dim;return(0,p.jsxs)(k,{flexDirection:"column",children:[(0,p.jsx)(g,{color:h.dim,children:"legend:"}),(0,p.jsxs)(k,{children:[(0,p.jsx)(g,{color:n(e==="synced"),children:` \u2601 synced (${s.synced}) `}),(0,p.jsx)(g,{color:n(e==="local"),children:`\u25A3 local (${s.local}) `}),(0,p.jsx)(g,{color:n(e==="never_run"),children:`\u25CB never run (${s.never})`})]}),(0,p.jsxs)(k,{children:[(0,p.jsx)(g,{color:n(e==="cli"),children:` \u2726 cli-generated (${s.cli}) `}),(0,p.jsx)(g,{color:n(e==="hand"),children:` hand-written (${s.hand})`})]})]})}var I=v(X(),1);import{existsSync as Ue,readFileSync as We}from"fs";var d=v(F(),1);function ge({path:e,relPath:r,onAction:s,onBack:n,onView:o}){let[t,i]=(0,I.useState)(null),[c,f]=(0,I.useState)(!1);(0,I.useEffect)(()=>{let a=M(e);if(Ue(a))try{i(JSON.parse(We(a,"utf8")))}catch{i(null)}},[e]),Q((a,m)=>{if(m.escape){if(c){f(!1);return}n();return}if(c){a==="y"||a==="Y"?(f(!1),s("delete")):(a==="n"||a==="N")&&f(!1);return}a==="r"&&s("run"),a==="e"&&t?.testcase_id&&s("export"),a==="d"&&f(!0),a==="v"&&o&&o()});let l=({k:a,v:m})=>m?(0,d.jsxs)(g,{children:[(0,d.jsx)(g,{color:h.dim,children:a.padEnd(14)}),m]}):null;return(0,d.jsxs)(k,{flexDirection:"column",borderStyle:"round",borderColor:h.orange,paddingX:2,paddingY:1,children:[(0,d.jsx)(g,{color:h.orange,bold:!0,children:r}),(0,d.jsx)(k,{marginTop:1,flexDirection:"column",children:t?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(l,{k:"test_id",v:t.test_id}),(0,d.jsx)(l,{k:"testcase_id",v:t.testcase_id}),(0,d.jsx)(l,{k:"project_id",v:t.project_id}),(0,d.jsx)(l,{k:"folder_id",v:t.folder_id}),(0,d.jsx)(l,{k:"org_id",v:t.org_id}),(0,d.jsx)(l,{k:"session_name",v:t.session_name}),(0,d.jsx)(l,{k:"commit_id",v:t.commit_id})]}):(0,d.jsx)(g,{color:h.dim,children:"(never run \u2014 no meta.json)"})}),c?(0,d.jsx)(k,{marginTop:1,children:(0,d.jsxs)(g,{color:h.red,bold:!0,children:["Delete ",r," and its output dir? [y/n]"]})}):(0,d.jsx)(k,{marginTop:1,children:(0,d.jsxs)(g,{color:h.dim,children:["[r] run [e] export",t?.testcase_id?"":" (need testcase_id)"," [d] delete",o?" [v] view":""," [Esc] back"]})})]})}function $(e){B(e);let r=M(e);if(!P(r))return null;try{return JSON.parse(Je(r,"utf8"))}catch{return null}}function he(e,r){return!e||e.org_id===void 0?!0:e.org_id===r}function J(e,r){return he(e,r)?null:(process.stderr.write(`error: this test belongs to org ${e.org_id}; you are logged in as org ${r}.
3
3
  Switch profiles with \`kane-cli profiles switch\` to act on it.
4
4
  `),2)}async function Ut(e={}){let r=!!process.stdin.isTTY&&!e.json,s=new O,n=new L;await V({isInteractive:r,creds:s,config:n});let o=s.getDefaultEnv()??"prod";try{let t=await N({creds:s,env:o,log:()=>{}});return t.resolvedCreds?.org_id===void 0?(process.stderr.write("error: TMS did not return an org_id. Run `kane-cli login` again.\n"),{ok:!1,code:2}):{ok:!0,orgId:String(t.resolvedCreds.org_id)}}catch(t){if(t instanceof j)return process.stderr.write("error: not authenticated. Run `kane-cli login` first.\n"),{ok:!1,code:2};throw t}}async function Wt(e,r){if(process.stdin.isTTY&&!e.json)return await Ye(r,e.root);let s=e.root??process.cwd(),n;try{n=await U({root:s,ignore:e.ignore})}catch(o){if(o instanceof R)return process.stderr.write(`error: ${o.message}
5
5
  `),2;throw o}for(let o of n.results){let t=$(o.path);if(!he(t,r))continue;let i={path:o.relPath.startsWith(".")?o.relPath:`./${o.relPath}`,name:C(o.path),has_meta:t!==null,source:o.source,synced:!!t?.testcase_id,tags:W(o.path)};t&&(t.test_id&&(i.test_id=t.test_id),t.testcase_id&&(i.testcase_id=t.testcase_id),t.org_id&&(i.org_id=t.org_id),t.project_id&&(i.project_id=t.project_id),t.folder_id&&(i.folder_id=t.folder_id)),process.stdout.write(JSON.stringify(i)+`
6
6
  `)}return n.aborted&&process.stderr.write(`warn: walk aborted (${n.abortReason}). Pass --root or --ignore to narrow.
7
- `),0}var _e=-1001,ye=-1002,we=-1003,_={action:null,path:null};function Xe(e,r){return _.action=e,_.path=r,e==="run"?_e:e==="export"?ye:we}function He({root:e,currentOrgId:r,onComplete:s}){let[n,o]=D.default.useState({kind:"list"});return D.default.useEffect(()=>{n.kind==="exiting"&&s(n.code)},[n,s]),n.kind==="list"?D.default.createElement(me,{root:e,currentOrgId:r,onSelect:t=>o({kind:"inspect",path:t.path,relPath:t.relPath}),onCancel:()=>o({kind:"exiting",code:0})}):n.kind==="inspect"?D.default.createElement(ge,{path:n.path,relPath:n.relPath,onAction:async t=>{o({kind:"exiting",code:Xe(t,n.path)})},onBack:()=>o({kind:"list"})}):null}async function Ye(e,r){let s=r??process.cwd(),{render:n}=await import("./build-JIKYOZUH.js"),o=await new Promise(t=>{let{unmount:i,waitUntilExit:c}=n(D.default.createElement(He,{root:s,currentOrgId:e,onComplete:f=>{i(),t(f)}}),{stdout:process.stderr,exitOnCtrlC:!0});c().then(()=>t(0)).catch(()=>t(0))});if(o===_e&&_.path){let{runTestMdFile:t}=await import("./run-test-md-AUK7NGLL.js"),i=await t(_.path,{});return _.action=null,_.path=null,i}if(o===ye&&_.path){let t=await qe(_.path,{},e);return _.action=null,_.path=null,t}if(o===we&&_.path){let t=await Ve(_.path,!0,e);return _.action=null,_.path=null,t}return o}async function Jt(e,r){let s=G(e);if(!P(s))return process.stderr.write(`error: file not found: ${s}
7
+ `),0}var _e=-1001,ye=-1002,we=-1003,_={action:null,path:null};function Xe(e,r){return _.action=e,_.path=r,e==="run"?_e:e==="export"?ye:we}function He({root:e,currentOrgId:r,onComplete:s}){let[n,o]=D.default.useState({kind:"list"});return D.default.useEffect(()=>{n.kind==="exiting"&&s(n.code)},[n,s]),n.kind==="list"?D.default.createElement(me,{root:e,currentOrgId:r,onSelect:t=>o({kind:"inspect",path:t.path,relPath:t.relPath}),onCancel:()=>o({kind:"exiting",code:0})}):n.kind==="inspect"?D.default.createElement(ge,{path:n.path,relPath:n.relPath,onAction:async t=>{o({kind:"exiting",code:Xe(t,n.path)})},onBack:()=>o({kind:"list"})}):null}async function Ye(e,r){let s=r??process.cwd(),{render:n}=await import("./build-JIKYOZUH.js"),o=await new Promise(t=>{let{unmount:i,waitUntilExit:c}=n(D.default.createElement(He,{root:s,currentOrgId:e,onComplete:f=>{i(),t(f)}}),{stdout:process.stderr,exitOnCtrlC:!0});c().then(()=>t(0)).catch(()=>t(0))});if(o===_e&&_.path){let{runTestMdFile:t}=await import("./run-test-md-QNC6KDMN.js"),i=await t(_.path,{});return _.action=null,_.path=null,i}if(o===ye&&_.path){let t=await qe(_.path,{},e);return _.action=null,_.path=null,t}if(o===we&&_.path){let t=await Ve(_.path,!0,e);return _.action=null,_.path=null,t}return o}async function Jt(e,r){let s=G(e);if(!P(s))return process.stderr.write(`error: file not found: ${s}
8
8
  `),2;let n=$(s),o=J(n,r);if(o!==null)return o;let t={path:s,name:C(s),has_meta:n!==null};return n&&(n.commit_id&&(t.commit_id=n.commit_id),n.test_id&&(t.test_id=n.test_id),n.testcase_id&&(t.testcase_id=n.testcase_id),n.project_id&&(t.project_id=n.project_id),n.folder_id&&(t.folder_id=n.folder_id),n.org_id&&(t.org_id=n.org_id),n.session_name&&(t.session_name=n.session_name)),process.stdout.write(JSON.stringify(t)+`
9
9
  `),0}async function Ve(e,r,s){let n=G(e);if(!P(n))return process.stderr.write(`error: file not found: ${n}
10
10
  `),2;let o=$(n),t=J(o,s);if(t!==null)return t;if(!r)return process.stderr.write(`error: refusing to delete without --yes.
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as Ue}from"./chunk-KHU7C6EE.js";import{a as Me,b as Ge}from"./chunk-NNZV5RCE.js";import{a as me,b as Te,c as Oe,d as Ie,g as Ne,h as je}from"./chunk-SGU72YLH.js";import{a as qe,b as Fe,g as Be,h as Pe}from"./chunk-FXPPQL4D.js";import{a as Ae}from"./chunk-RE3BZVGE.js";import{b as Re,c as De}from"./chunk-FTD3B7QA.js";import{c as Ce}from"./chunk-VJUIW2ES.js";import{a as Le}from"./chunk-Z56AWGVY.js";import{b as _e,c as be,d as ye,e as ee,f as J,g as re,h as ve,i as le}from"./chunk-RGEAEAZB.js";import{a as de}from"./chunk-L5LI2JF4.js";import{a as Y}from"./chunk-D5T4ARTB.js";import{a as xe,b as ue}from"./chunk-GIRXJOJI.js";import{e as $e,g as Ee}from"./chunk-B2PZAB7J.js";import{d as S,e as E,f as we,g as Se,h as ke}from"./chunk-IACKIGPX.js";import{mkdirSync as Et,appendFileSync as Rt}from"fs";import{randomBytes as Dt}from"crypto";import{join as ct}from"path";import{existsSync as ge,readFileSync as pe,readdirSync as dt}from"fs";import{join as te}from"path";var ze=`
2
+ import{a as Ue}from"./chunk-KHU7C6EE.js";import{a as Me,b as Ge}from"./chunk-3C5GMAM4.js";import{a as me,b as Te,c as Oe,d as Ie,g as Ne,h as je}from"./chunk-KNCHEM6A.js";import{a as qe,b as Fe,g as Be,h as Pe}from"./chunk-FXPPQL4D.js";import{a as Ae}from"./chunk-RE3BZVGE.js";import{b as Re,c as De}from"./chunk-WIA7TPK3.js";import{c as Ce}from"./chunk-6GTOYTCQ.js";import{a as Le}from"./chunk-6AYUSR7X.js";import{b as _e,c as be,d as ye,e as ee,f as J,g as re,h as ve,i as le}from"./chunk-FJTWJ243.js";import{a as de}from"./chunk-L5LI2JF4.js";import{a as Y}from"./chunk-MCQXRJGH.js";import{a as xe,b as ue}from"./chunk-ZZLR3O5A.js";import{e as $e,g as Ee}from"./chunk-ZG2V2ODK.js";import{d as S,e as E,f as we,g as Se,h as ke}from"./chunk-5YPBPZUR.js";import{mkdirSync as Et,appendFileSync as Rt}from"fs";import{randomBytes as Dt}from"crypto";import{join as ct}from"path";import{existsSync as ge,readFileSync as pe,readdirSync as dt}from"fs";import{join as te}from"path";var ze=`
3
3
  version: 1
4
4
  techniques:
5
5
  - id: eqp
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{x as m}from"./chunk-E4OYR32M.js";import{a as x}from"./chunk-HCBYKLMW.js";import{a as u,b as a,j as g}from"./chunk-C44QQJR4.js";import{a as b}from"./chunk-6YGTRKDT.js";import{e as f}from"./chunk-UR6MHSHU.js";var T=f(b(),1);function k(i,n){if(!n)return i;let l=i.trim()||n;return`\x1B]8;;${n}\x07${l}\x1B]8;;\x07`}var r=f(x(),1);function $({shareableLink:i,testCaseLink:n,codeExportDir:l,recordedTestPath:s,outputDir:o,autoExit:p=!0}){let{exit:c}=g();(0,T.useEffect)(()=>{if(!p)return;let t=setTimeout(()=>c(),100);return()=>clearTimeout(t)},[c,p]);let e=[];return s&&e.push({label:"Test",url:s,linkUrl:`file://${s}`}),o&&e.push({label:"Output",url:o,linkUrl:`file://${o}`}),i&&e.push({label:"ShareLink",url:i}),n&&e.push({label:"TestCase",url:n}),l&&!o&&e.push({label:"CodeExport",url:l,linkUrl:`file://${l}`}),e.length===0?(0,r.jsx)(r.Fragment,{}):(0,r.jsx)(u,{flexDirection:"column",marginTop:1,marginLeft:1,children:e.map(t=>(0,r.jsxs)(u,{flexDirection:"column",marginBottom:1,children:[(0,r.jsxs)(a,{color:m.orange,children:[t.label,":"]}),(0,r.jsx)(a,{color:m.dim,children:k(t.url,t.linkUrl??t.url)})]},t.label))})}export{$ as a};
2
+ import{y as m}from"./chunk-6SGPN76K.js";import{a as x}from"./chunk-HCBYKLMW.js";import{a as u,b as a,j as g}from"./chunk-C44QQJR4.js";import{a as b}from"./chunk-6YGTRKDT.js";import{e as f}from"./chunk-UR6MHSHU.js";var T=f(b(),1);function k(i,n){if(!n)return i;let l=i.trim()||n;return`\x1B]8;;${n}\x07${l}\x1B]8;;\x07`}var r=f(x(),1);function $({shareableLink:i,testCaseLink:n,codeExportDir:l,recordedTestPath:s,outputDir:o,autoExit:p=!0}){let{exit:c}=g();(0,T.useEffect)(()=>{if(!p)return;let t=setTimeout(()=>c(),100);return()=>clearTimeout(t)},[c,p]);let e=[];return s&&e.push({label:"Test",url:s,linkUrl:`file://${s}`}),o&&e.push({label:"Output",url:o,linkUrl:`file://${o}`}),i&&e.push({label:"ShareLink",url:i}),n&&e.push({label:"TestCase",url:n}),l&&!o&&e.push({label:"CodeExport",url:l,linkUrl:`file://${l}`}),e.length===0?(0,r.jsx)(r.Fragment,{}):(0,r.jsx)(u,{flexDirection:"column",marginTop:1,marginLeft:1,children:e.map(t=>(0,r.jsxs)(u,{flexDirection:"column",marginBottom:1,children:[(0,r.jsxs)(a,{color:m.orange,children:[t.label,":"]}),(0,r.jsx)(a,{color:m.dim,children:k(t.url,t.linkUrl??t.url)})]},t.label))})}export{$ as a};
@@ -1,4 +1,4 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as g}from"./chunk-IACKIGPX.js";import{createHash as E}from"crypto";function w(e){if(e===null)return"null";let r=typeof e;if(r==="string")return JSON.stringify(e.normalize("NFC"));if(r==="boolean")return e?"true":"false";if(r==="number"){if(!Number.isFinite(e))throw new Error("non-finite number is not canonicalizable");return JSON.stringify(e)}if(Array.isArray(e))return"["+e.map(n=>n===void 0?"null":w(n)).join(",")+"]";if(r==="object"){let n=e,s=new Map;for(let t of Object.keys(n)){if(n[t]===void 0)continue;let c=t.normalize("NFC");if(s.has(c))throw new Error(`canonicalization collision: NFC-equivalent duplicate key ${JSON.stringify(c)}`);s.set(c,n[t])}return"{"+[...s.keys()].sort((t,c)=>Buffer.compare(Buffer.from(t,"utf8"),Buffer.from(c,"utf8"))).map(t=>JSON.stringify(t)+":"+w(s.get(t))).join(",")+"}"}throw new Error("unsupported type for canonicalization: "+r)}function k(e){return E("sha256").update(e).digest("hex")}import{closeSync as $,existsSync as O,fsyncSync as x,mkdirSync as b,openSync as S,readFileSync as R,readdirSync as j,renameSync as F,rmSync as J,writeFileSync as _}from"fs";import{join as f}from"path";var a=class extends Error{};function v(e,r){if(e.schema_version!==void 0&&e.schema_version!==g)throw new a(`record ${r} is stamped ${e.schema_version}, this build reads ${g} \u2014 migrate explicitly`);if(e.parents!==void 0&&!(e.prev_hash===null?e.parents.length===0:e.parents.length===1&&e.parents[0]===e.prev_hash))throw new a(`record ${r}: parents does not mirror prev_hash \u2014 multi-parent records need a DAG-aware reader`)}function z(e){b(e,{recursive:!0});let r=f(e,".lock"),n=Date.now()+2e3;for(;;)try{let s=S(r,"wx");return _(s,`${process.pid}
2
+ import{a as g}from"./chunk-5YPBPZUR.js";import{createHash as E}from"crypto";function w(e){if(e===null)return"null";let r=typeof e;if(r==="string")return JSON.stringify(e.normalize("NFC"));if(r==="boolean")return e?"true":"false";if(r==="number"){if(!Number.isFinite(e))throw new Error("non-finite number is not canonicalizable");return JSON.stringify(e)}if(Array.isArray(e))return"["+e.map(n=>n===void 0?"null":w(n)).join(",")+"]";if(r==="object"){let n=e,s=new Map;for(let t of Object.keys(n)){if(n[t]===void 0)continue;let c=t.normalize("NFC");if(s.has(c))throw new Error(`canonicalization collision: NFC-equivalent duplicate key ${JSON.stringify(c)}`);s.set(c,n[t])}return"{"+[...s.keys()].sort((t,c)=>Buffer.compare(Buffer.from(t,"utf8"),Buffer.from(c,"utf8"))).map(t=>JSON.stringify(t)+":"+w(s.get(t))).join(",")+"}"}throw new Error("unsupported type for canonicalization: "+r)}function k(e){return E("sha256").update(e).digest("hex")}import{closeSync as $,existsSync as O,fsyncSync as x,mkdirSync as b,openSync as S,readFileSync as R,readdirSync as j,renameSync as F,rmSync as J,writeFileSync as _}from"fs";import{join as f}from"path";var a=class extends Error{};function v(e,r){if(e.schema_version!==void 0&&e.schema_version!==g)throw new a(`record ${r} is stamped ${e.schema_version}, this build reads ${g} \u2014 migrate explicitly`);if(e.parents!==void 0&&!(e.prev_hash===null?e.parents.length===0:e.parents.length===1&&e.parents[0]===e.prev_hash))throw new a(`record ${r}: parents does not mirror prev_hash \u2014 multi-parent records need a DAG-aware reader`)}function z(e){b(e,{recursive:!0});let r=f(e,".lock"),n=Date.now()+2e3;for(;;)try{let s=S(r,"wx");return _(s,`${process.pid}
3
3
  `),$(s),()=>{try{J(r)}catch{}}}catch(s){if(s.code!=="EEXIST")throw s;if(Date.now()>n)throw new a(`.context is locked by another process \u2014 remove ${r} if that process is gone`);Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,25)}}var A=/^\d{6}-[0-9a-f]{12}\.json$/,p=e=>f(e,"commits");function y(e){return"sha256:"+k(Buffer.from(w(e),"utf8"))}function q(e){let r=p(e);return O(r)?j(r).filter(n=>A.test(n)).sort():[]}function T(e){let r=q(e),n=[],s=[],i=null;return r.forEach((t,c)=>{let d=R(f(p(e),t),"utf8"),o;try{o=JSON.parse(d)}catch(l){throw new a(`corrupt commit record ${t}: ${String(l)}`)}if(o.seq!==c+1)throw new a(`sequence gap: expected seq ${c+1}, ${t} has ${o.seq}`);if(o.prev_hash!==i)throw new a(`broken chain at ${t}: prev_hash ${String(o.prev_hash)} != ${String(i)}`);v(o,t);let m=y(o),h=t.slice(7,19);if(!m.slice(7).startsWith(h))throw new a(`tampered record ${t}: content hash ${m} does not match filename`);n.push(o),s.push(m),i=m}),{records:n,hashes:s}}function N(e){let r=q(e);if(r.length===0)return null;let n=r[r.length-1],s=R(f(p(e),n),"utf8"),i;try{i=JSON.parse(s)}catch(c){throw new a(`corrupt tail record ${n}: ${String(c)}`)}v(i,n);let t=y(i);if(!t.slice(7).startsWith(n.slice(7,19)))throw new a(`tampered tail record ${n}: content hash ${t} does not match filename`);if(i.seq!==r.length)throw new a(`sequence gap at tail: ${r.length} record files but tail seq is ${i.seq}`);return{seq:i.seq,hash:t}}function G(e){return N(e)?.hash??null}function V(e,r,n){let s=q(e);if(s.length<r)throw new a(`derived state is ahead of the record log (applied seq ${r}, ${s.length} records) \u2014 run kane-cli context rebuild`);let i=[],t=[],c=n;for(let d=r;d<s.length;d++){let o=s[d],m=R(f(p(e),o),"utf8"),h;try{h=JSON.parse(m)}catch(u){throw new a(`corrupt commit record ${o}: ${String(u)}`)}if(h.seq!==d+1)throw new a(`sequence gap: expected seq ${d+1}, ${o} has ${h.seq}`);if(h.prev_hash!==c)throw new a(`broken chain at ${o}: prev_hash ${String(h.prev_hash)} != ${String(c)}`);v(h,o);let l=y(h);if(!l.slice(7).startsWith(o.slice(7,19)))throw new a(`tampered record ${o}: content hash ${l} does not match filename`);i.push(h),t.push(l),c=l}return{records:i,hashes:t}}function X(e,r,n={}){let s=z(e);try{return B(e,r,n)}finally{s()}}function B(e,r,n){let s=N(e),i=(s?.seq??0)+1,t=s?.hash??null;if(n.expectPrev!==void 0&&n.expectPrev!==t)throw new a(`concurrent append detected: validated against ${String(n.expectPrev)} but the chain head is ${String(t)} \u2014 re-open and retry`);let c={seq:i,prev_hash:t,...r,schema_version:g,parents:t===null?[]:[t]},d=y(c),o=p(e);b(o,{recursive:!0});let m=`${String(i).padStart(6,"0")}-${d.slice(7,19)}.json`,h=f(o,m),l=h+".tmp",u=S(l,"w");try{_(u,JSON.stringify(c)+`
4
4
  `),x(u)}finally{$(u)}F(l,h);try{let C=S(o,"r");x(C),$(C)}catch{}return{seq:i,hash:d,file:h,record:c}}export{w as a,k as b,a as c,T as d,G as e,V as f,X as g};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as t,b as i}from"./chunk-B2PZAB7J.js";import{i as s,j as e}from"./chunk-IACKIGPX.js";function a(r,n){return"sha256:"+i(Buffer.from("assurance."+r+"\0"+t(s(r,n)),"utf8"))}function f(r,n,o,u){return"sha256:"+i(Buffer.from("assurance.edge\0"+t({type:r,src:n,dst:o,props:e(r,u)}),"utf8"))}function d(r,n){return{source_id:r,blob:n}}function p(r){return{...r,derived:!0}}export{a,f as b,d as c,p as d};
2
+ import{a as t,b as i}from"./chunk-ZG2V2ODK.js";import{i as s,j as e}from"./chunk-5YPBPZUR.js";function a(r,n){return"sha256:"+i(Buffer.from("assurance."+r+"\0"+t(s(r,n)),"utf8"))}function f(r,n,o,u){return"sha256:"+i(Buffer.from("assurance.edge\0"+t({type:r,src:n,dst:o,props:e(r,u)}),"utf8"))}function d(r,n){return{source_id:r,blob:n}}function p(r){return{...r,derived:!0}}export{a,f as b,d as c,p as d};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a}from"./chunk-RLG5NUTE.js";import"./chunk-E4OYR32M.js";import"./chunk-UR6MHSHU.js";export{a as getEnvironment};
2
+ import{a}from"./chunk-AKHUNBQS.js";import"./chunk-6SGPN76K.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 as x}from"./chunk-CE664P73.js";import{a as d,b as $,d as w}from"./chunk-AD46OCZ4.js";import"./chunk-ZKYYZ5NO.js";import{e as b,f as k}from"./chunk-FYOCF7DY.js";import"./chunk-BC7UVJJB.js";import{e as v}from"./chunk-NFOBDHZK.js";import{a as h}from"./chunk-L5LI2JF4.js";import{a as y}from"./chunk-D5T4ARTB.js";import"./chunk-AE6SS34N.js";import"./chunk-GIRXJOJI.js";import"./chunk-B2PZAB7J.js";import"./chunk-IACKIGPX.js";import"./chunk-UR6MHSHU.js";import{basename as f}from"path";import{statSync as R}from"fs";function S(s,e){if(!s)return 1;let r=s.resolve(e);return!r||r.superseded?1:s.getNode(r.tip)?.content.risk==="high"?3:1}function C(s,e){return s.usecases.map(r=>{let n=r.acceptance_criteria??[],a=n.filter(o=>(o.covered_by??[]).length>0),u=n.filter(o=>o.execution==="passed"),c=n.filter(o=>o.execution==="failed"),p=n.filter(o=>o.execution==="blocked"),i=0,l=0;for(let o of n){let g=S(e,o.id);i+=g,o.execution==="passed"&&(l+=g)}let t=i===0?0:Math.round(100*l/i),m=a.length===0?"uncovered":n.length===u.length?"covered":p.length>0&&c.length===0?"blocked":"partial";return{id:r.id,title:r.title,status:m,pct:t,acs:{total:n.length,covered:a.length,passed:u.length,failed:c.length,blocked:p.length},stale:n.filter(o=>o.fresh==="stale").map(o=>o.id)}})}async function A(s){let e=await b(s);return e.length===0?null:e.map(r=>({p:r,m:R(r).mtimeMs})).sort((r,n)=>n.m-r.m)[0].p}var D={covered:"\u2714",partial:"\u25D0",uncovered:"\u2716",blocked:"\u23F8"};function G(s){let e=Math.round(s/10);return"\u2588".repeat(e)+"\u2591".repeat(10-e)}async function E(s,e=w(),r=process.cwd()){let n=$(r,e);if(!n)return 2;let a=s.from?await k(s.from,r):await A(r);if(!a)return d(e,s.from?`no evidence pack at '${s.from}'`:"no evidence pack in .testmuai/evidence \u2014 run a test first, or pass --from <pack>"),2;let u=await v(a,"coverage/usecases.yaml");if(u==null)return d(e,`${f(a)} carries no coverage/usecases.yaml \u2014 the pack predates coverage or its project had no .context at seal time`),2;let c=h(u);if(!c||!Array.isArray(c.usecases))return d(e,`${f(a)}: coverage/usecases.yaml is not a usecases document`),2;let p=y(n),i=C(c,p),l=await x(p,"design");if(s.json)return e.out(JSON.stringify({pack:a,depth:i,completeness:l},null,2)),0;e.out(`coverage \u2014 ${f(a)}`),e.out(""),e.out("depth (proven by the pack):");for(let t of i){let m=t.stale.length?` \xB7 ${t.stale.length} stale`:"";e.out(` ${D[t.status]} ${G(t.pct)} ${String(t.pct).padStart(3)}% ${t.id} \u2014 ${t.status} (${t.acs.passed}/${t.acs.total} ACs proven${t.acs.failed?`, ${t.acs.failed} failed`:""}${t.acs.blocked?`, ${t.acs.blocked} blocked`:""})${m}`)}e.out(""),e.out("completeness (live graph):"),l.length===0&&e.out(" no design gaps \u2014 every AC verified, every use-case scenarioed");for(let t of l)e.out(` [${t.risk}] ${t.tag} ${t.ref} \u2014 ${t.why}`),e.out(` \u2192 ${t.ready_command}`);return 0}export{E as coverCommand,C as depthRows};
2
+ import{a as x}from"./chunk-GBBVP2JW.js";import{a as d,b as $,d as w}from"./chunk-GRB66C5S.js";import"./chunk-RN4OSVTG.js";import{e as b,f as k}from"./chunk-CJJXT5DO.js";import"./chunk-BC7UVJJB.js";import{e as v}from"./chunk-EHN5HTUD.js";import{a as h}from"./chunk-L5LI2JF4.js";import{a as y}from"./chunk-MCQXRJGH.js";import"./chunk-74RUSHIB.js";import"./chunk-ZZLR3O5A.js";import"./chunk-ZG2V2ODK.js";import"./chunk-5YPBPZUR.js";import"./chunk-UR6MHSHU.js";import{basename as f}from"path";import{statSync as R}from"fs";function S(s,e){if(!s)return 1;let r=s.resolve(e);return!r||r.superseded?1:s.getNode(r.tip)?.content.risk==="high"?3:1}function C(s,e){return s.usecases.map(r=>{let n=r.acceptance_criteria??[],a=n.filter(o=>(o.covered_by??[]).length>0),u=n.filter(o=>o.execution==="passed"),c=n.filter(o=>o.execution==="failed"),p=n.filter(o=>o.execution==="blocked"),i=0,l=0;for(let o of n){let g=S(e,o.id);i+=g,o.execution==="passed"&&(l+=g)}let t=i===0?0:Math.round(100*l/i),m=a.length===0?"uncovered":n.length===u.length?"covered":p.length>0&&c.length===0?"blocked":"partial";return{id:r.id,title:r.title,status:m,pct:t,acs:{total:n.length,covered:a.length,passed:u.length,failed:c.length,blocked:p.length},stale:n.filter(o=>o.fresh==="stale").map(o=>o.id)}})}async function A(s){let e=await b(s);return e.length===0?null:e.map(r=>({p:r,m:R(r).mtimeMs})).sort((r,n)=>n.m-r.m)[0].p}var D={covered:"\u2714",partial:"\u25D0",uncovered:"\u2716",blocked:"\u23F8"};function G(s){let e=Math.round(s/10);return"\u2588".repeat(e)+"\u2591".repeat(10-e)}async function E(s,e=w(),r=process.cwd()){let n=$(r,e);if(!n)return 2;let a=s.from?await k(s.from,r):await A(r);if(!a)return d(e,s.from?`no evidence pack at '${s.from}'`:"no evidence pack in .testmuai/evidence \u2014 run a test first, or pass --from <pack>"),2;let u=await v(a,"coverage/usecases.yaml");if(u==null)return d(e,`${f(a)} carries no coverage/usecases.yaml \u2014 the pack predates coverage or its project had no .context at seal time`),2;let c=h(u);if(!c||!Array.isArray(c.usecases))return d(e,`${f(a)}: coverage/usecases.yaml is not a usecases document`),2;let p=y(n),i=C(c,p),l=await x(p,"design");if(s.json)return e.out(JSON.stringify({pack:a,depth:i,completeness:l},null,2)),0;e.out(`coverage \u2014 ${f(a)}`),e.out(""),e.out("depth (proven by the pack):");for(let t of i){let m=t.stale.length?` \xB7 ${t.stale.length} stale`:"";e.out(` ${D[t.status]} ${G(t.pct)} ${String(t.pct).padStart(3)}% ${t.id} \u2014 ${t.status} (${t.acs.passed}/${t.acs.total} ACs proven${t.acs.failed?`, ${t.acs.failed} failed`:""}${t.acs.blocked?`, ${t.acs.blocked} blocked`:""})${m}`)}e.out(""),e.out("completeness (live graph):"),l.length===0&&e.out(" no design gaps \u2014 every AC verified, every use-case scenarioed");for(let t of l)e.out(` [${t.risk}] ${t.tag} ${t.ref} \u2014 ${t.why}`),e.out(` \u2192 ${t.ready_command}`);return 0}export{E as coverCommand,C as depthRows};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a}from"./chunk-TZZYRDCF.js";import"./chunk-E4OYR32M.js";import"./chunk-UR6MHSHU.js";export{a as CredentialsManager};
2
+ import{a}from"./chunk-P4HW2NTZ.js";import"./chunk-6SGPN76K.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{a}from"./chunk-6AYUSR7X.js";import"./chunk-427OQS2N.js";import"./chunk-5YPBPZUR.js";import"./chunk-UR6MHSHU.js";export{a as topologyDescriptor};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{$ as fa,A as J,B as K,C as L,D as M,E as N,F as O,G as P,H as Q,L as R,M as S,N as T,O as U,P as V,Q as W,R as X,S as Y,T as Z,U as _,V as $,W as aa,X as ba,Y as ca,Z as da,_ as ea,a,aa as ga,b,ba as ha,c,ca as ia,d,e,f,g,h,i,j,k as t,l as u,m as v,n as w,o as x,p as y,q as z,r as A,s as B,t as C,u as D,v as E,w as F,x as G,y as H,z as I}from"./chunk-OE7TVGNB.js";import{a as n,b as o,c as p,e as q,f as r,g as s}from"./chunk-FYOCF7DY.js";import"./chunk-RGEAEAZB.js";import"./chunk-BC7UVJJB.js";import"./chunk-KHDUQ33H.js";import{a as k,b as l,c as m}from"./chunk-NFOBDHZK.js";import"./chunk-L5LI2JF4.js";import"./chunk-D5T4ARTB.js";import"./chunk-AE6SS34N.js";import"./chunk-GIRXJOJI.js";import"./chunk-B2PZAB7J.js";import"./chunk-IACKIGPX.js";import"./chunk-RLG5NUTE.js";import"./chunk-E4OYR32M.js";import"./chunk-UR6MHSHU.js";export{P as EvidenceSession,C as appendExecutionPointer,M as assembleExecutionEnv,i as buildEnvironment,j as buildEvidenceRunConfig,g 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,h 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,d as shortHash,c as slugify,W as startEvidenceLocalServer,R as startInlineEvidence,n as storeDir,m as sweepStore,ea as synthesizeSkippedTail,f as testIdForInline,e as testIdForTestmd,k as validatePack,a as verdictFromResultCode,X as viewerBaseFor,Y as viewerUrlFor,b as worstOf,G as worstResultCode,B as writeLogsMeta,A as writeResult};
2
+ import{$ as fa,A as J,B as K,C as L,D as M,E as N,F as O,G as P,H as Q,L as R,M as S,N as T,O as U,P as V,Q as W,R as X,S as Y,T as Z,U as _,V as $,W as aa,X as ba,Y as ca,Z as da,_ as ea,a,aa as ga,b,ba as ha,c,ca as ia,d,e,f,g,h,i,j,k as t,l as u,m as v,n as w,o as x,p as y,q as z,r as A,s as B,t as C,u as D,v as E,w as F,x as G,y as H,z as I}from"./chunk-4A6BLXQN.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-FJTWJ243.js";import"./chunk-BC7UVJJB.js";import"./chunk-2PQXEEVY.js";import{a as k,b as l,c as m}from"./chunk-EHN5HTUD.js";import"./chunk-L5LI2JF4.js";import"./chunk-MCQXRJGH.js";import"./chunk-74RUSHIB.js";import"./chunk-ZZLR3O5A.js";import"./chunk-ZG2V2ODK.js";import"./chunk-5YPBPZUR.js";import"./chunk-AKHUNBQS.js";import"./chunk-6SGPN76K.js";import"./chunk-UR6MHSHU.js";export{P as EvidenceSession,C as appendExecutionPointer,M as assembleExecutionEnv,i as buildEnvironment,j as buildEvidenceRunConfig,g 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,h 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,d as shortHash,c as slugify,W as startEvidenceLocalServer,R as startInlineEvidence,n as storeDir,m as sweepStore,ea as synthesizeSkippedTail,f as testIdForInline,e as testIdForTestmd,k as validatePack,a as verdictFromResultCode,X as viewerBaseFor,Y as viewerUrlFor,b 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-JV356AYH.js";import"./chunk-3C5GMAM4.js";import"./chunk-GRB66C5S.js";import"./chunk-JFAFKHDX.js";import"./chunk-QPZRHAYK.js";import"./chunk-RN4OSVTG.js";import"./chunk-BC7UVJJB.js";import"./chunk-2PQXEEVY.js";import"./chunk-MCQXRJGH.js";import"./chunk-74RUSHIB.js";import"./chunk-ZZLR3O5A.js";import"./chunk-ZG2V2ODK.js";import"./chunk-5YPBPZUR.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}from"./chunk-GYW7LVVL.js";import"./chunk-ZG2V2ODK.js";import"./chunk-5YPBPZUR.js";import"./chunk-UR6MHSHU.js";export{a as explain};
@@ -1,3 +1,3 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{b as E}from"./chunk-KHU7C6EE.js";import{a as x}from"./chunk-22A2ECA2.js";import{a as k}from"./chunk-BC7UVJJB.js";import"./chunk-L5LI2JF4.js";import{a as h}from"./chunk-D5T4ARTB.js";import"./chunk-AE6SS34N.js";import"./chunk-GIRXJOJI.js";import"./chunk-B2PZAB7J.js";import{d,e as g}from"./chunk-IACKIGPX.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-GYW7LVVL.js";import{a as k}from"./chunk-BC7UVJJB.js";import"./chunk-L5LI2JF4.js";import{a as h}from"./chunk-MCQXRJGH.js";import"./chunk-74RUSHIB.js";import"./chunk-ZZLR3O5A.js";import"./chunk-ZG2V2ODK.js";import{d,e as g}from"./chunk-5YPBPZUR.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-AD46OCZ4.js";import{a as i}from"./chunk-22A2ECA2.js";import"./chunk-ZKYYZ5NO.js";import"./chunk-BC7UVJJB.js";import{a as n}from"./chunk-D5T4ARTB.js";import"./chunk-AE6SS34N.js";import"./chunk-GIRXJOJI.js";import"./chunk-B2PZAB7J.js";import"./chunk-IACKIGPX.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-GRB66C5S.js";import{a as i}from"./chunk-GYW7LVVL.js";import"./chunk-RN4OSVTG.js";import"./chunk-BC7UVJJB.js";import{a as n}from"./chunk-MCQXRJGH.js";import"./chunk-74RUSHIB.js";import"./chunk-ZZLR3O5A.js";import"./chunk-ZG2V2ODK.js";import"./chunk-5YPBPZUR.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,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{d as D,e as h}from"./chunk-TY5LWU6I.js";import"./chunk-SGU72YLH.js";import"./chunk-I2S6KNZW.js";import"./chunk-FXPPQL4D.js";import"./chunk-RE3BZVGE.js";import"./chunk-6PS65QFF.js";import"./chunk-JFAFKHDX.js";import"./chunk-FTD3B7QA.js";import"./chunk-QPZRHAYK.js";import"./chunk-VJUIW2ES.js";import{c as A}from"./chunk-YKTYVJBN.js";import"./chunk-Z56AWGVY.js";import"./chunk-427OQS2N.js";import{a as y}from"./chunk-2S4S2XJC.js";import{d as C}from"./chunk-YZSYXNMB.js";import{c as E}from"./chunk-ZKYYZ5NO.js";import{a as P}from"./chunk-BC7UVJJB.js";import"./chunk-KHDUQ33H.js";import"./chunk-D5T4ARTB.js";import"./chunk-AE6SS34N.js";import"./chunk-GIRXJOJI.js";import"./chunk-B2PZAB7J.js";import"./chunk-IACKIGPX.js";import"./chunk-E4OYR32M.js";import"./chunk-UR6MHSHU.js";async function j(n){let[{render:o},e,{QuestionBatchPrompt:i}]=await Promise.all([import("./build-JIKYOZUH.js"),import("./react-QWOAB3TB.js"),import("./ui-JEJGTURD.js")]),c=e.default??e;return new Promise(t=>{let p=o(c.createElement(i,{questions:n,onSubmit:a=>{p.unmount(),t(a)}}))})}async function F(n,o){let[{render:e},i,{ReviewChecklist:c}]=await Promise.all([import("./build-JIKYOZUH.js"),import("./react-QWOAB3TB.js"),import("./ui-JEJGTURD.js")]),t=i.default??i;return new Promise(p=>{let a=e(t.createElement(c,{items:n.map(u=>{let s=o.get(u.temp_ref);return{uc:u,dedupWith:s&&!s.archived?s.cid:void 0,archivedMatch:s?.archived?{cid:s.cid,reason:s.reason}:void 0}}),onSubmit:u=>{a.unmount(),p(u)}}))})}async function G(n){let{createInterface:o}=await import("readline/promises"),e=o({input:process.stdin,output:process.stdout});try{let i=await e.question(`${n} [y/N] `);return/^y(es)?$/i.test(i.trim())}finally{e.close()}}async function O(n){let o=await C(),e=P(process.cwd()),i=await A(o);if(!i.ok)return process.stderr.write((i.message??"error: turn-endpoint preflight failed")+`
2
+ import{d as D,e as h}from"./chunk-4R2HOA7J.js";import"./chunk-K5JGCJ2K.js";import"./chunk-KNCHEM6A.js";import"./chunk-FXPPQL4D.js";import"./chunk-RE3BZVGE.js";import"./chunk-6PS65QFF.js";import"./chunk-JFAFKHDX.js";import"./chunk-WIA7TPK3.js";import"./chunk-QPZRHAYK.js";import"./chunk-6GTOYTCQ.js";import{c as A}from"./chunk-YKTYVJBN.js";import"./chunk-6AYUSR7X.js";import"./chunk-427OQS2N.js";import{a as y}from"./chunk-LURGFJEE.js";import{d as C}from"./chunk-KYHXDJN4.js";import{c as E}from"./chunk-RN4OSVTG.js";import{a as P}from"./chunk-BC7UVJJB.js";import"./chunk-2PQXEEVY.js";import"./chunk-MCQXRJGH.js";import"./chunk-74RUSHIB.js";import"./chunk-ZZLR3O5A.js";import"./chunk-ZG2V2ODK.js";import"./chunk-5YPBPZUR.js";import"./chunk-6SGPN76K.js";import"./chunk-UR6MHSHU.js";async function j(n){let[{render:o},e,{QuestionBatchPrompt:i}]=await Promise.all([import("./build-JIKYOZUH.js"),import("./react-QWOAB3TB.js"),import("./ui-JEJGTURD.js")]),c=e.default??e;return new Promise(t=>{let p=o(c.createElement(i,{questions:n,onSubmit:a=>{p.unmount(),t(a)}}))})}async function F(n,o){let[{render:e},i,{ReviewChecklist:c}]=await Promise.all([import("./build-JIKYOZUH.js"),import("./react-QWOAB3TB.js"),import("./ui-JEJGTURD.js")]),t=i.default??i;return new Promise(p=>{let a=e(t.createElement(c,{items:n.map(u=>{let s=o.get(u.temp_ref);return{uc:u,dedupWith:s&&!s.archived?s.cid:void 0,archivedMatch:s?.archived?{cid:s.cid,reason:s.reason}:void 0}}),onSubmit:u=>{a.unmount(),p(u)}}))})}async function G(n){let{createInterface:o}=await import("readline/promises"),e=o({input:process.stdin,output:process.stdout});try{let i=await e.question(`${n} [y/N] `);return/^y(es)?$/i.test(i.trim())}finally{e.close()}}async function O(n){let o=await C(),e=P(process.cwd()),i=await A(o);if(!i.ok)return process.stderr.write((i.message??"error: turn-endpoint preflight failed")+`
3
3
  `),2;let c=async()=>i;if(n.plan)return h(n,{contextDir:e,agent:y,preflightTurn:c,ask:j,review:F,confirmStale:G,out:l=>process.stdout.write(l+`
4
4
  `),progress:l=>process.stderr.write(l+`
5
- `),isTTY:E(),auth:o});let[{render:t},p,{ScrollbackProvider:a},{ChatSurface:u},{ScrollbackTap:s},{makeChatController:r},{setInkExit:w},x]=await Promise.all([import("./build-JIKYOZUH.js"),import("./react-QWOAB3TB.js"),import("./scrollback-JLPJR25X.js"),import("./ChatSurface-J777M5WC.js"),import("./ScrollbackTap-Q3IOKNMS.js"),import("./chat-controller-QXFAB2DK.js"),import("./exit-manager-VCSIUYBR.js"),Promise.all([import("./chat-committer-GHDZY5XF.js"),import("./descriptor-SL5A7RQE.js"),import("./explain-JIXUWEFJ.js"),import("./readmodel-MPTENJ2R.js")])]),[{commitChatTurn:I},{topologyDescriptor:M},{explain:V},{openGraph:k}]=x,v=p.default??p,m=r({commitChatTurn:I,descriptor:M(),contextDir:e,refreshGraph:()=>k(e),graph:k(e),explain:V,by:{kind:"human",id:"owner"},dedupFlags:l=>D(l,k(e))}),T={current:null},S=0,b=null,f=!1,N=()=>{if(S+=1,S>=2){try{g.unmount()}catch{}process.exit(130)}m.requestPause(),b=setTimeout(()=>{f||(f=!0,(async()=>{m.ledger({kind:"interrupted",detail:"the agent did not confirm the pause within 5s"}),await T.current?.flush();try{g.unmount()}catch{}process.exit(130)})())},5e3)},g=t(v.createElement(a,null,v.createElement(s,{into:T}),v.createElement(u,{controller:m,verb:"extract",onCtrlC:N})),{exitOnCtrlC:!1});w(()=>g.unmount()),m.ledger({kind:"banner",text:"kane-cli context \xB7 extract \xB7 interactive"});try{let l=h(n,{contextDir:e,agent:y,preflightTurn:c,ask:d=>m.ask(d),review:async d=>new Map(d.map(R=>[R.temp_ref,{resolution:"skipped"}])),confirmStale:async()=>!0,out:d=>m.note(d),progress:()=>{},isTTY:E(),auth:o,chat:m});return l.finally(()=>{f=!0}),await l}finally{f=!0,b&&clearTimeout(b),await T.current?.flush();try{g.unmount()}catch{}}}async function U(n){let o=await C(),{makeHeadlessIO:e,resolveEncoding:i,guardedChannels:c}=await import("./headless-io-GXHKDPHB.js"),t=e(i(n.mode),"extract"),{makeInterruptGuard:p}=await import("./interrupt-guard-UREUWNRL.js"),a=p(y,r=>t.out(r)),s=c(t,()=>a.interrupted(),/^error: (agent failed|repair run failed|agent ended)/);try{let r=await h(n,{contextDir:P(process.cwd()),agent:a.agent,preflightTurn:()=>A(o),ask:async()=>[],review:async w=>new Map(w.map(x=>[x.temp_ref,{resolution:"skipped"}])),confirmStale:async()=>!1,out:s.out,emit:s.emit,progress:t.progress,isTTY:!1,auth:o});return a.interrupted()&&r!==3?(t.out("interrupted \u2014 no session saved"),t.done(130)):t.done(r)}catch(r){return t.event({type:"error",message:`error: extract failed: ${r instanceof Error?r.message:String(r)}`}),t.out(`error: extract failed: ${r instanceof Error?r.message:String(r)}`),t.out("hint: per-run trace logs live under .context/logs/ (extract-*.log)"),t.done(1)}finally{a.dispose()}}export{U as bindExtractHeadless,O as bindExtractInteractive};
5
+ `),isTTY:E(),auth:o});let[{render:t},p,{ScrollbackProvider:a},{ChatSurface:u},{ScrollbackTap:s},{makeChatController:r},{setInkExit:w},x]=await Promise.all([import("./build-JIKYOZUH.js"),import("./react-QWOAB3TB.js"),import("./scrollback-JLPJR25X.js"),import("./ChatSurface-LV3KW6WN.js"),import("./ScrollbackTap-Q3IOKNMS.js"),import("./chat-controller-VAC57IEV.js"),import("./exit-manager-VCSIUYBR.js"),Promise.all([import("./chat-committer-ADJJTDUT.js"),import("./descriptor-EHK3DRCZ.js"),import("./explain-VFIZTHFN.js"),import("./readmodel-XOGOELUP.js")])]),[{commitChatTurn:I},{topologyDescriptor:M},{explain:V},{openGraph:k}]=x,v=p.default??p,m=r({commitChatTurn:I,descriptor:M(),contextDir:e,refreshGraph:()=>k(e),graph:k(e),explain:V,by:{kind:"human",id:"owner"},dedupFlags:l=>D(l,k(e))}),T={current:null},S=0,b=null,f=!1,N=()=>{if(S+=1,S>=2){try{g.unmount()}catch{}process.exit(130)}m.requestPause(),b=setTimeout(()=>{f||(f=!0,(async()=>{m.ledger({kind:"interrupted",detail:"the agent did not confirm the pause within 5s"}),await T.current?.flush();try{g.unmount()}catch{}process.exit(130)})())},5e3)},g=t(v.createElement(a,null,v.createElement(s,{into:T}),v.createElement(u,{controller:m,verb:"extract",onCtrlC:N})),{exitOnCtrlC:!1});w(()=>g.unmount()),m.ledger({kind:"banner",text:"kane-cli context \xB7 extract \xB7 interactive"});try{let l=h(n,{contextDir:e,agent:y,preflightTurn:c,ask:d=>m.ask(d),review:async d=>new Map(d.map(R=>[R.temp_ref,{resolution:"skipped"}])),confirmStale:async()=>!0,out:d=>m.note(d),progress:()=>{},isTTY:E(),auth:o,chat:m});return l.finally(()=>{f=!0}),await l}finally{f=!0,b&&clearTimeout(b),await T.current?.flush();try{g.unmount()}catch{}}}async function U(n){let o=await C(),{makeHeadlessIO:e,resolveEncoding:i,guardedChannels:c}=await import("./headless-io-PWW6YKH2.js"),t=e(i(n.mode),"extract"),{makeInterruptGuard:p}=await import("./interrupt-guard-UREUWNRL.js"),a=p(y,r=>t.out(r)),s=c(t,()=>a.interrupted(),/^error: (agent failed|repair run failed|agent ended)/);try{let r=await h(n,{contextDir:P(process.cwd()),agent:a.agent,preflightTurn:()=>A(o),ask:async()=>[],review:async w=>new Map(w.map(x=>[x.temp_ref,{resolution:"skipped"}])),confirmStale:async()=>!1,out:s.out,emit:s.emit,progress:t.progress,isTTY:!1,auth:o});return a.interrupted()&&r!==3?(t.out("interrupted \u2014 no session saved"),t.done(130)):t.done(r)}catch(r){return t.event({type:"error",message:`error: extract failed: ${r instanceof Error?r.message:String(r)}`}),t.out(`error: extract failed: ${r instanceof Error?r.message:String(r)}`),t.out("hint: per-run trace logs live under .context/logs/ (extract-*.log)"),t.done(1)}finally{a.dispose()}}export{U as bindExtractHeadless,O as bindExtractInteractive};
@@ -1,6 +1,6 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
2
  import{a as s}from"./chunk-BC7UVJJB.js";import"./chunk-UR6MHSHU.js";import{existsSync as d}from"fs";async function l(e){if(e.mode!=null&&!["interactive","agent","ci","override"].includes(e.mode))return process.stderr.write(`extract: --mode must be interactive | agent | ci | override, got '${e.mode}'
3
3
  `),2;let n=async(r,t)=>{if(process.stderr.write(r+`
4
- `),e.mode!=="agent")return 2;let{makeHeadlessIO:a,agentRefusal:c}=await import("./headless-io-GXHKDPHB.js");return c(a("ndjson","extract"),r,t)};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:r}=await import("./headless-io-GXHKDPHB.js"),t=r(e,"extract");if(t)return n(t)}if(!d(s(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
+ `),e.mode!=="agent")return 2;let{makeHeadlessIO:a,agentRefusal:c}=await import("./headless-io-PWW6YKH2.js");return c(a("ndjson","extract"),r,t)};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:r}=await import("./headless-io-PWW6YKH2.js"),t=r(e,"extract");if(t)return n(t)}if(!d(s(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
5
5
  `),2;let i=e.mode??"interactive";if(i==="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)
6
- `),2;let{bindExtractInteractive:r}=await import("./extract-bind-ZDAXRQUS.js");return r(e)}let{bindExtractHeadless:o}=await import("./extract-bind-ZDAXRQUS.js");return o({...e,mode:i})}export{l as extractCommand};
6
+ `),2;let{bindExtractInteractive:r}=await import("./extract-bind-YS7C4KZ3.js");return r(e)}let{bindExtractHeadless:o}=await import("./extract-bind-YS7C4KZ3.js");return o({...e,mode:i})}export{l as extractCommand};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as b}from"./chunk-CE664P73.js";import{a as o,b as h,d as w}from"./chunk-AD46OCZ4.js";import"./chunk-ZKYYZ5NO.js";import{e as $,f as y}from"./chunk-FYOCF7DY.js";import"./chunk-BC7UVJJB.js";import{e as l}from"./chunk-NFOBDHZK.js";import{a as g}from"./chunk-L5LI2JF4.js";import{a as k}from"./chunk-D5T4ARTB.js";import"./chunk-AE6SS34N.js";import"./chunk-GIRXJOJI.js";import"./chunk-B2PZAB7J.js";import"./chunk-IACKIGPX.js";import"./chunk-UR6MHSHU.js";import{basename as p}from"path";import{statSync as O}from"fs";async function P(t){let e=await $(t);return e.length===0?null:e.map(a=>({p:a,m:O(a).mtimeMs})).sort((a,r)=>r.m-a.m)[0].p}async function U(t,e=w(),a=process.cwd()){let r=t.stage??"design";if(r!=="design"&&r!=="cover"&&r!=="all")return o(e,`--stage must be design | cover | all, got '${r}'`),2;if(t.top!==void 0&&(!Number.isInteger(t.top)||t.top<1))return o(e,"--top must be a positive integer"),2;let f=h(a,e);if(!f)return 2;let d,i;if(r!=="design"){let s=t.from?await y(t.from,a):await P(a);if(!s)return o(e,`--stage ${r} needs an evidence pack \u2014 run a test first, or pass --from <pack>`),2;let c=await l(s,"coverage/usecases.yaml");if(c==null)return o(e,`${p(s)} carries no coverage/usecases.yaml \u2014 re-run the tests to produce a coverage-bearing pack`),2;let u=g(c);if(!u||!Array.isArray(u.usecases))return o(e,`${p(s)}: coverage/usecases.yaml is not a usecases document`),2;d=u,i=p(s)}let v=k(f),n=await b(v,r,void 0,d),m=n.length;return t.top!==void 0&&(n=n.slice(0,t.top)),t.json?(e.out(JSON.stringify({stage:r,...i?{pack:i}:{},total:m,rows:n},null,2)),0):(e.out(`gaps \u2014 stage ${r}${i?` \xB7 pack ${i}`:""} (${n.length}${n.length<m?` of ${m}`:""})`),n.length===0&&e.out(" nothing owed \u2014 design and execution are square"),n.forEach((s,c)=>{e.out(` ${String(c+1).padStart(2)}. [${s.risk}] ${s.tag} ${s.ref} \u2014 ${s.why}`),e.out(` \u2192 ${s.ready_command}`)}),0)}export{U as gapsCommand};
2
+ import{a as b}from"./chunk-GBBVP2JW.js";import{a as o,b as h,d as w}from"./chunk-GRB66C5S.js";import"./chunk-RN4OSVTG.js";import{e as $,f as y}from"./chunk-CJJXT5DO.js";import"./chunk-BC7UVJJB.js";import{e as l}from"./chunk-EHN5HTUD.js";import{a as g}from"./chunk-L5LI2JF4.js";import{a as k}from"./chunk-MCQXRJGH.js";import"./chunk-74RUSHIB.js";import"./chunk-ZZLR3O5A.js";import"./chunk-ZG2V2ODK.js";import"./chunk-5YPBPZUR.js";import"./chunk-UR6MHSHU.js";import{basename as p}from"path";import{statSync as O}from"fs";async function P(t){let e=await $(t);return e.length===0?null:e.map(a=>({p:a,m:O(a).mtimeMs})).sort((a,r)=>r.m-a.m)[0].p}async function U(t,e=w(),a=process.cwd()){let r=t.stage??"design";if(r!=="design"&&r!=="cover"&&r!=="all")return o(e,`--stage must be design | cover | all, got '${r}'`),2;if(t.top!==void 0&&(!Number.isInteger(t.top)||t.top<1))return o(e,"--top must be a positive integer"),2;let f=h(a,e);if(!f)return 2;let d,i;if(r!=="design"){let s=t.from?await y(t.from,a):await P(a);if(!s)return o(e,`--stage ${r} needs an evidence pack \u2014 run a test first, or pass --from <pack>`),2;let c=await l(s,"coverage/usecases.yaml");if(c==null)return o(e,`${p(s)} carries no coverage/usecases.yaml \u2014 re-run the tests to produce a coverage-bearing pack`),2;let u=g(c);if(!u||!Array.isArray(u.usecases))return o(e,`${p(s)}: coverage/usecases.yaml is not a usecases document`),2;d=u,i=p(s)}let v=k(f),n=await b(v,r,void 0,d),m=n.length;return t.top!==void 0&&(n=n.slice(0,t.top)),t.json?(e.out(JSON.stringify({stage:r,...i?{pack:i}:{},total:m,rows:n},null,2)),0):(e.out(`gaps \u2014 stage ${r}${i?` \xB7 pack ${i}`:""} (${n.length}${n.length<m?` of ${m}`:""})`),n.length===0&&e.out(" nothing owed \u2014 design and execution are square"),n.forEach((s,c)=>{e.out(` ${String(c+1).padStart(2)}. [${s.risk}] ${s.tag} ${s.ref} \u2014 ${s.why}`),e.out(` \u2192 ${s.ready_command}`)}),0)}export{U as gapsCommand};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a,b}from"./chunk-NNZV5RCE.js";import"./chunk-IACKIGPX.js";import"./chunk-UR6MHSHU.js";export{a as designFactFor,b as designGate};
2
+ import{a,b}from"./chunk-3C5GMAM4.js";import"./chunk-5YPBPZUR.js";import"./chunk-UR6MHSHU.js";export{a as designFactFor,b as designGate};
@@ -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-DEEBPSJN.js";import{b as k}from"./chunk-Y6LMHBLE.js";import{d as J}from"./chunk-TTSYHJLX.js";import{c as E}from"./chunk-7MV5UF6O.js";import"./chunk-Q4HLQOJI.js";import{a as q}from"./chunk-XBE7PGVY.js";import"./chunk-P46TIMGQ.js";import"./chunk-SL7AJ7JQ.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-CIW2KP4C.js";import"./chunk-2WVKOZ6W.js";import"./chunk-NLCCBXXV.js";import"./chunk-RZ4F3BHX.js";import{a as R}from"./chunk-RLG5NUTE.js";import"./chunk-VE3SUJMA.js";import{a as j}from"./chunk-TZZYRDCF.js";import"./chunk-E4OYR32M.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-JU5KRCKD.js";import{b as k}from"./chunk-32GP7KTM.js";import{d as J}from"./chunk-JTEY32TL.js";import{c as E}from"./chunk-6XHAXAL2.js";import"./chunk-D7L6UW5Z.js";import{a as q}from"./chunk-VBCE4U4B.js";import"./chunk-EOLQUB4Q.js";import"./chunk-C42WWO7Y.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-2BWRAY3Y.js";import"./chunk-2WVKOZ6W.js";import"./chunk-NLCCBXXV.js";import"./chunk-RZ4F3BHX.js";import{a as R}from"./chunk-AKHUNBQS.js";import"./chunk-VE3SUJMA.js";import{a as j}from"./chunk-P4HW2NTZ.js";import"./chunk-6SGPN76K.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-AQUVEEJB.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-NPTKR2AW.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};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a,b,c,d,e,f,g,h}from"./chunk-ZKYYZ5NO.js";import"./chunk-UR6MHSHU.js";export{a as EVENT_SCHEMA_VERSION,e as MAX_MESSAGE_BYTES,g as agentRefusal,c as bothTTY,h as guardedChannels,d as makeHeadlessIO,b as resolveEncoding,f as validateResumeMessage};
2
+ import{a,b,c,d,e,f,g,h}from"./chunk-RN4OSVTG.js";import"./chunk-UR6MHSHU.js";export{a as EVENT_SCHEMA_VERSION,e as MAX_MESSAGE_BYTES,g as agentRefusal,c as bothTTY,h as guardedChannels,d as makeHeadlessIO,b as resolveEncoding,f as validateResumeMessage};