@testmuai/kane-cli 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (188) hide show
  1. package/dist/ChatSurface-I6PFL3OE.js +9 -0
  2. package/dist/{ChromeProfilePicker-PIWZY4WH.js → ChromeProfilePicker-YG7TKHM5.js} +1 -1
  3. package/dist/{CliFeedbackPrompt-URXCHBZ5.js → CliFeedbackPrompt-5RUIP4KA.js} +1 -1
  4. package/dist/CliUploadProgress-YQYPZNEV.js +2 -0
  5. package/dist/{ConfigView-NWNDNTKW.js → ConfigView-HZ7MFCAJ.js} +1 -1
  6. package/dist/EvidenceViewOffer-N4UED7VY.js +2 -0
  7. package/dist/FolderPicker-NAFYP7ES.js +2 -0
  8. package/dist/HelpView-BLWTCQ6T.js +2 -0
  9. package/dist/{InfoBox-FPAWQZGQ.js → InfoBox-7ZZGMYHY.js} +1 -1
  10. package/dist/{LinksBox-O5ZFYSK2.js → LinksBox-63Q5YS5X.js} +1 -1
  11. package/dist/{ProfilesView-SPECXHZE.js → ProfilesView-AVYB43ES.js} +1 -1
  12. package/dist/{ProjectPicker-ANJ6NGNY.js → ProjectPicker-EINNALUG.js} +1 -1
  13. package/dist/{SaveSessionPrompt-W2GWELOP.js → SaveSessionPrompt-C3LCI2KZ.js} +1 -1
  14. package/dist/ScrollbackTap-Q3IOKNMS.js +2 -0
  15. package/dist/SingleShotApp-PS42WWT7.js +2 -0
  16. package/dist/{SummaryBox-DJUDYML7.js → SummaryBox-NRPQ2AMW.js} +1 -1
  17. package/dist/TestMdRunView-5FVCEQZI.js +2 -0
  18. package/dist/{WhoamiView-DH25ZD4C.js → WhoamiView-YLMIEJQN.js} +1 -1
  19. package/dist/archive-committer-3NI773TP.js +2 -0
  20. package/dist/bind-QYQ5IT4S.js +6 -0
  21. package/dist/bridge-QENVIWWC.js +2 -0
  22. package/dist/{changelog-RCKUVBFL.js → changelog-4RSI7UIO.js} +1 -1
  23. package/dist/chat-committer-RTJCKQMM.js +2 -0
  24. package/dist/chat-controller-OTBYHB4Y.js +3 -0
  25. package/dist/chunk-22A2ECA2.js +2 -0
  26. package/dist/{chunk-6E5UYAEB.js → chunk-25YSMNUP.js} +1 -1
  27. package/dist/{chunk-R5RHRG65.js → chunk-3SK5GXQM.js} +1 -1
  28. package/dist/chunk-427OQS2N.js +2 -0
  29. package/dist/chunk-5446YVGQ.js +4 -0
  30. package/dist/chunk-5ILXUQIX.js +2 -0
  31. package/dist/chunk-5Q46BEG7.js +2 -0
  32. package/dist/chunk-5U3GOEGG.js +7 -0
  33. package/dist/chunk-5Y2G4NC7.js +2 -0
  34. package/dist/{chunk-I4B2KY4X.js → chunk-6BQD2BXI.js} +1 -1
  35. package/dist/chunk-6PS65QFF.js +2 -0
  36. package/dist/chunk-ABSEKYIB.js +13 -0
  37. package/dist/chunk-AD46OCZ4.js +4 -0
  38. package/dist/chunk-AE6SS34N.js +4 -0
  39. package/dist/chunk-B2OAEEKI.js +14 -0
  40. package/dist/chunk-B2PZAB7J.js +4 -0
  41. package/dist/chunk-BC7UVJJB.js +2 -0
  42. package/dist/{chunk-T4PKTWZ6.js → chunk-BV3EARZO.js} +1 -1
  43. package/dist/{chunk-7IBNOVML.js → chunk-C5NNT7Y3.js} +1 -1
  44. package/dist/{chunk-NLIOFVMP.js → chunk-CBIW5DTU.js} +1 -1
  45. package/dist/chunk-CE664P73.js +2 -0
  46. package/dist/{chunk-GEAWRRR7.js → chunk-D5SHVZGD.js} +1 -1
  47. package/dist/chunk-D5T4ARTB.js +2 -0
  48. package/dist/chunk-DFS4RMVP.js +2 -0
  49. package/dist/chunk-DM2GL24Z.js +3 -0
  50. package/dist/chunk-FAXRERS6.js +6 -0
  51. package/dist/{chunk-QO6PAA7Q.js → chunk-FPGOV4AQ.js} +2 -2
  52. package/dist/chunk-FXPPQL4D.js +6 -0
  53. package/dist/chunk-FYOCF7DY.js +2 -0
  54. package/dist/chunk-GIGD4M7V.js +5 -0
  55. package/dist/chunk-GIRXJOJI.js +2 -0
  56. package/dist/{chunk-TPG2T5GH.js → chunk-GNGGFK7C.js} +1 -1
  57. package/dist/{chunk-THEZSXZM.js → chunk-H7ZQ4AWL.js} +1 -1
  58. package/dist/{chunk-TJWU7DOO.js → chunk-HYW5VDEC.js} +1 -1
  59. package/dist/chunk-I2S6KNZW.js +2 -0
  60. package/dist/chunk-IACKIGPX.js +2 -0
  61. package/dist/chunk-IF2R3AR4.js +6 -0
  62. package/dist/{chunk-UOGJUJCF.js → chunk-INP7FG6V.js} +1 -1
  63. package/dist/{chunk-C4LYBQT3.js → chunk-IPCC3P6T.js} +2 -2
  64. package/dist/chunk-JFAFKHDX.js +4 -0
  65. package/dist/chunk-KHDUQ33H.js +2 -0
  66. package/dist/chunk-KHU7C6EE.js +2 -0
  67. package/dist/chunk-LBBPMEO2.js +2 -0
  68. package/dist/chunk-LKXVYWKG.js +356 -0
  69. package/dist/chunk-LMJTY32X.js +6 -0
  70. package/dist/chunk-M5JQXOCE.js +12 -0
  71. package/dist/chunk-ME3GYVBV.js +2 -0
  72. package/dist/{chunk-7AEC572G.js → chunk-MESFNOY3.js} +1 -1
  73. package/dist/{chunk-HFXQU7UZ.js → chunk-MKD3KZPM.js} +1 -1
  74. package/dist/{chunk-LOQV5GME.js → chunk-MQ7DJ2XC.js} +1 -1
  75. package/dist/{chunk-YSIYPC4R.js → chunk-N2BUF6YU.js} +1 -1
  76. package/dist/chunk-NNZV5RCE.js +2 -0
  77. package/dist/{chunk-HZ46P2GR.js → chunk-NOOHQBUD.js} +1 -1
  78. package/dist/chunk-NTJDMMLC.js +61 -0
  79. package/dist/chunk-NWZTYAJB.js +9 -0
  80. package/dist/{chunk-IECUFWIZ.js → chunk-OXARXMMD.js} +1 -1
  81. package/dist/{chunk-ELBPBHTE.js → chunk-PGEMGGBS.js} +2 -2
  82. package/dist/{chunk-4IOOBSNB.js → chunk-QI6WZ56Y.js} +1 -1
  83. package/dist/{chunk-ZWAZ4QU4.js → chunk-QK6KZMYG.js} +1 -1
  84. package/dist/chunk-QPZRHAYK.js +4 -0
  85. package/dist/{chunk-3FN66LTP.js → chunk-RFHMDQXZ.js} +1 -1
  86. package/dist/chunk-RGEAEAZB.js +20 -0
  87. package/dist/chunk-RKWJG3WW.js +19 -0
  88. package/dist/chunk-RTWWPEQ7.js +8 -0
  89. package/dist/chunk-TZVURR5H.js +5 -0
  90. package/dist/chunk-VJUIW2ES.js +4 -0
  91. package/dist/chunk-VK7RF53I.js +2 -0
  92. package/dist/{chunk-XDERMCAU.js → chunk-VXS23M67.js} +1 -1
  93. package/dist/{chunk-IU53F4ZV.js → chunk-WFAMF4SG.js} +1 -1
  94. package/dist/chunk-WFSQZG26.js +11 -0
  95. package/dist/chunk-WG3BBXJF.js +7 -0
  96. package/dist/chunk-WUMNIGPR.js +2 -0
  97. package/dist/{chunk-AFCEFOIK.js → chunk-WUNN5OCH.js} +1 -1
  98. package/dist/{chunk-PISZLYS5.js → chunk-XQDDUVD3.js} +1 -1
  99. package/dist/{chunk-DTM4ZMMJ.js → chunk-Y2S3PW7N.js} +1 -1
  100. package/dist/chunk-YANCBRER.js +3 -0
  101. package/dist/{chunk-AM5WZPPY.js → chunk-YWWKKKXY.js} +1 -1
  102. package/dist/chunk-Z56AWGVY.js +2 -0
  103. package/dist/chunk-ZKYYZ5NO.js +6 -0
  104. package/dist/{chunk-PTP3WS3N.js → chunk-ZO7ROBPR.js} +1 -1
  105. package/dist/chunk-ZXDA4K6G.js +2 -0
  106. package/dist/chunk-ZZOSDBYN.js +23 -0
  107. package/dist/cover-cmd-Y5L4O4Q3.js +2 -0
  108. package/dist/{credentials-52QRPGET.js → credentials-WUEKK7FI.js} +1 -1
  109. package/dist/descriptor-SL5A7RQE.js +2 -0
  110. package/dist/distill-cmd-EYCCCFL3.js +2 -0
  111. package/dist/evidence-4BSNTVND.js +2 -0
  112. package/dist/evolve-cmd-VUWLH3CO.js +2 -0
  113. package/dist/{exit-manager-IUHAXFJ6.js → exit-manager-VCSIUYBR.js} +1 -1
  114. package/dist/explain-JIXUWEFJ.js +2 -0
  115. package/dist/explain-cmd-55WRDIMW.js +9 -0
  116. package/dist/explain-cmd-RIDEMDMY.js +3 -0
  117. package/dist/extract-bind-T7SUAID6.js +5 -0
  118. package/dist/extract-cmd-LZW7CRT3.js +6 -0
  119. package/dist/gaps-cmd-P2DRK6FW.js +2 -0
  120. package/dist/gate-FACZRGOC.js +2 -0
  121. package/dist/{generate-headless-WG6ZPINI.js → generate-headless-C55T3GGR.js} +2 -2
  122. package/dist/headless-io-GXHKDPHB.js +2 -0
  123. package/dist/index.js +55 -54
  124. package/dist/ingest-4CGBXC2L.js +2 -0
  125. package/dist/ingest-cmd-FJ3SLTT4.js +3 -0
  126. package/dist/interactive-bind-P6AGLUMM.js +7 -0
  127. package/dist/interrupt-guard-UREUWNRL.js +2 -0
  128. package/dist/lifecycle-cmd-56OZT4LY.js +2 -0
  129. package/dist/list-cmd-JB2ABACD.js +3 -0
  130. package/dist/list-commands-M34USUNO.js +2 -0
  131. package/dist/logical-ids-QRRUXV5E.js +2 -0
  132. package/dist/login-flow-GMLHK6JT.js +2 -0
  133. package/dist/maintenance-cmd-E3HEEVQW.js +2 -0
  134. package/dist/open-MQLQKFAW.js +2 -0
  135. package/dist/{persist-recorded-session-XKPZX7HW.js → persist-recorded-session-L2KAY37H.js} +1 -1
  136. package/dist/pipeline-FJXQIFW7.js +2 -0
  137. package/dist/readmodel-MPTENJ2R.js +2 -0
  138. package/dist/reconcile-cmd-KTCH4KZQ.js +8 -0
  139. package/dist/{recording-banner-2TNKQHP2.js → recording-banner-2KIVZAXY.js} +1 -1
  140. package/dist/{require-project-folder-SJG5FQY6.js → require-project-folder-NOGEHZTS.js} +1 -1
  141. package/dist/revert-3TKLOYQA.js +2 -0
  142. package/dist/review-cmd-SL52N4TM.js +4 -0
  143. package/dist/run-P4CHG2VH.js +2 -0
  144. package/dist/run-test-md-ICLG4OPX.js +17 -0
  145. package/dist/{scrollback-6GINSTL2.js → scrollback-JLPJR25X.js} +1 -1
  146. package/dist/sessions-cmd-STHKGDX4.js +23 -0
  147. package/dist/signals-cmd-LXHZQLXZ.js +2 -0
  148. package/dist/{skill-installer-M6AREQQW.js → skill-installer-KGPXQRCE.js} +1 -1
  149. package/dist/spawner-DDD3ICOX.js +2 -0
  150. package/dist/tcg-generate-KBXZIIHB.js +2 -0
  151. package/dist/testmd-actions-45BY3YFO.js +2 -0
  152. package/dist/token-refresh-OCFALJ7U.js +2 -0
  153. package/dist/turn-preflight-I5SM4UIZ.js +2 -0
  154. package/dist/ui-JEJGTURD.js +4 -0
  155. package/dist/{validate-basic-FO7C2URG.js → validate-basic-QCD4VN37.js} +1 -1
  156. package/dist/{version-check-PHZX5WS7.js → version-check-55YZMQUI.js} +1 -1
  157. package/dist/view-cmd-QE2FS3GB.js +436 -0
  158. package/package.json +6 -6
  159. package/dist/CliUploadProgress-DMH3C3UZ.js +0 -2
  160. package/dist/EvidenceViewOffer-HEBQ7C4H.js +0 -2
  161. package/dist/FolderPicker-5S23OTSY.js +0 -2
  162. package/dist/HelpView-YYKTP4JH.js +0 -2
  163. package/dist/SingleShotApp-5TYM356H.js +0 -2
  164. package/dist/TestMdRunView-BIVXQE54.js +0 -2
  165. package/dist/chunk-54TKNWXF.js +0 -5
  166. package/dist/chunk-5MTRNUAK.js +0 -2
  167. package/dist/chunk-7KDNH6JP.js +0 -10
  168. package/dist/chunk-7YRNLGUT.js +0 -11
  169. package/dist/chunk-C6S4IEBC.js +0 -2
  170. package/dist/chunk-DJL47DYJ.js +0 -8
  171. package/dist/chunk-H6QJ4YU7.js +0 -2
  172. package/dist/chunk-J75KVNX5.js +0 -18
  173. package/dist/chunk-MUPHP5W6.js +0 -27
  174. package/dist/chunk-NAYAVVTP.js +0 -6
  175. package/dist/chunk-P5XBCJYQ.js +0 -7
  176. package/dist/chunk-Q2I65L2W.js +0 -6
  177. package/dist/chunk-QCEWUUE6.js +0 -55
  178. package/dist/chunk-V2GYBVSM.js +0 -2
  179. package/dist/chunk-Y44AETOW.js +0 -2
  180. package/dist/chunk-YCNCW4O4.js +0 -8
  181. package/dist/evidence-O4AON5FU.js +0 -2
  182. package/dist/list-commands-VJAL4J3O.js +0 -2
  183. package/dist/login-flow-VZ2MITFA.js +0 -2
  184. package/dist/pipeline-CADTHPDV.js +0 -2
  185. package/dist/run-test-md-INJKPE2I.js +0 -13
  186. package/dist/tcg-generate-VKFXR5JT.js +0 -2
  187. package/dist/testmd-actions-4QLHD74A.js +0 -2
  188. package/dist/token-refresh-2HKIYD4Y.js +0 -2
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ var l="assurance/context@1";var u={source:{hashed:["blob","source_id"],required:["blob","source_id"],enums:{}},usecase:{hashed:["actors","criteria","derived","description","risk","summary","title","value"],required:["derived","risk","title"],enums:{risk:["high","med","low"]}},scenario:{hashed:["case_type","derived","description","intent","parameters","tags","technique_notes","title"],required:["case_type","derived","intent","title"],enums:{case_type:["happy","negative","boundary","edge","security","a11y","perf","i18n"]}},ac:{hashed:["derived","expected_answer","kind","measurable","risk","text"],required:["derived","risk","text"],enums:{risk:["high","med","low"],kind:["presence","forbidden-presence","count","delta","state-transition","absolute","bound","propagation","latency","graded"]}},test:{hashed:["check","config","definitionId","derived","objectives_blob","surface_required","test_md_blob","title"],required:["definitionId","derived","title"],enums:{}},gap:{hashed:["derived","kind","question","ref","risk","risk_rationale","text","uc"],required:["derived","kind"],enums:{kind:["ambiguous","incomplete","contradictory","unmeasurable","missing-expected-result","budget-evicted","invariant-unexercised"],risk:["high","med","low"]}},stylenote:{hashed:["derived","learned_from_kind","statement","tags","text"],unhashed:["learned_from"],required:["derived","learned_from_kind","statement"],enums:{learned_from_kind:["edit","directed-edit","mistake","usage"]}}},f={DERIVES:{src:["source"],dst:["usecase","ac","scenario","test"],salient:["anchor","source_cid","source_id"],props:["anchor","quote","source_cid","source_id"],pin:{comparesTo:"source_head"},cardinality:"many",acyclic:!1},belongs_to:{src:["scenario"],dst:["usecase"],salient:[],props:[],pin:{comparesTo:"dst_tip"},cardinality:"one-live-per-src",acyclic:!1},scoped_to:{src:["ac"],dst:["scenario","usecase"],salient:[],props:[],pin:{comparesTo:"dst_tip"},cardinality:"one-live-per-src",acyclic:!1},exercises:{src:["scenario"],dst:["ac"],salient:[],props:[],pin:{comparesTo:"dst_tip"},cardinality:"many",acyclic:!1},verifies:{src:["test"],dst:["ac"],salient:[],props:[],pin:{comparesTo:"dst_tip"},cardinality:"many",acyclic:!1},automates:{src:["test"],dst:["scenario"],salient:[],props:[],pin:{comparesTo:"dst_tip"},cardinality:"one-live-per-src-and-dst",acyclic:!1},depends_on:{src:["usecase","scenario"],dst:["usecase","scenario"],salient:[],props:["reason"],pin:{comparesTo:"dst_tip"},cardinality:"many",acyclic:!0},reuses:{src:["test"],dst:["test"],salient:[],props:[],pin:{comparesTo:"dst_tip"},cardinality:"many",acyclic:!0},annotates:{src:["gap","stylenote"],dst:["source","usecase","scenario","ac","test"],salient:[],props:["reason"],pin:{comparesTo:"dst_tip"},cardinality:"many",acyclic:!1}},E=["presence","forbidden-presence","count","delta","state-transition","absolute","bound","propagation","latency","graded"];var g={presence:{operators:["exists","forall"],baseline:"null",requires:[]},"forbidden-presence":{operators:["exists","forall"],baseline:"null",requires:[]},count:{operators:["equals","gte","lte"],baseline:"null",requires:[],operand_forms:["literal","derived"]},delta:{operators:["changed-by"],baseline:"required",requires:[]},"state-transition":{operators:["changed-by","equals"],baseline:"required",requires:[]},absolute:{operators:["equals","contains","gte","lte"],baseline:"null",requires:[]},bound:{operators:["gte","lte"],baseline:"null",requires:[]},propagation:{operators:["exists","equals"],baseline:"null",requires:[]},latency:{operators:["lte"],baseline:"null",requires:["within"]},graded:{operators:["gte"],baseline:"null",requires:["metric","threshold"]}},y=Object.freeze({SOURCE:"source",USECASE:"usecase",SCENARIO:"scenario",AC:"ac",TEST:"test",GAP:"gap",STYLENOTE:"stylenote"}),h=Object.freeze({DERIVES:"DERIVES",BELONGS_TO:"belongs_to",SCOPED_TO:"scoped_to",EXERCISES:"exercises",VERIFIES:"verifies",AUTOMATES:"automates",DEPENDS_ON:"depends_on",REUSES:"reuses",ANNOTATES:"annotates"});function c(r,s,t){let n=[],e=g[r];if(!e)return n.push({code:"BAD_CHECK",detail:`${t}.kind ${JSON.stringify(r)} not in ${E.join("|")}`}),n;let o=s.operator;o!==void 0&&!e.operators.includes(o)&&n.push({code:"BAD_CHECK",detail:`${t}: operator ${JSON.stringify(o)} illegal for kind "${String(r)}" (legal: ${e.operators.join("|")})`});for(let a of e.requires)(s[a]===void 0||s[a]===null||s[a]==="")&&n.push({code:"BAD_CHECK",detail:`${t}: kind "${String(r)}" requires "${a}"`});e.baseline==="null"&&s.baseline!==void 0&&s.baseline!==null&&n.push({code:"BAD_CHECK",detail:`${t}: kind "${String(r)}" must carry baseline null (only delta/state-transition have one)`});let i=s.operand;if(i!==null&&typeof i=="object"&&!Array.isArray(i)){let a=Object.keys(i),d=i.derived;(!(e.operand_forms?.includes("derived")??!1)||a.length!==1||a[0]!=="derived"||typeof d!="string"||!d.trim())&&n.push({code:"BAD_CHECK",detail:`${t}: object operand is only the count derivation form {derived: "<how the runtime value is computed>"}`})}return n}function m(r,s){let t=u[r];if(!t)return[{code:"UNKNOWN_LABEL",detail:`unknown node label ${JSON.stringify(r)}`}];let n=[];for(let e of Object.keys(s))s[e]!==void 0&&!t.hashed.includes(e)&&!(t.unhashed??[]).includes(e)&&n.push({code:"UNKNOWN_FIELD",detail:`${r}.${e} is not in the ${l} schema`});for(let e of t.required)(s[e]===void 0||s[e]===null)&&n.push({code:"MISSING_FIELD",detail:`${r}.${e} is required`});for(let[e,o]of Object.entries(t.enums)){let i=s[e];i!==void 0&&!o.includes(i)&&n.push({code:"BAD_ENUM",detail:`${r}.${e} ${JSON.stringify(i)} not in ${o.join("|")}`})}if(r==="test"&&s.check&&typeof s.check=="object"){let e=s.check;n.push(...c(e.kind,e,"test.check"))}if(r==="ac"&&s.expected_answer&&typeof s.expected_answer=="object"){let e=s.expected_answer;n.push(...c(s.kind??e.kind,e,"ac.expected_answer"))}return n}function p(r){return f[r]}function S(r,s,t,n){let e=p(r);if(!e)return[{code:"UNKNOWN_EDGE_TYPE",detail:`unknown edge type ${JSON.stringify(r)}`}];let o=[];e.src.includes(s)||o.push({code:"ILLEGAL_EDGE",detail:`${r} src must be ${e.src.join("|")}, got ${s}`}),e.dst.includes(t)||o.push({code:"ILLEGAL_EDGE",detail:`${r} dst must be ${e.dst.join("|")}, got ${t}`}),r==="depends_on"&&s!==t&&o.push({code:"ILLEGAL_EDGE",detail:`depends_on links same-label nodes only, got ${s}\u2192${t}`});for(let i of e.salient)(n[i]===void 0||n[i]===null)&&o.push({code:"MISSING_SALIENT",detail:`${r}.props.${i} is salient (inside the ecid) and required`});for(let i of Object.keys(n))n[i]!==void 0&&(e.props.includes(i)||o.push({code:"UNKNOWN_EDGE_PROP",detail:`${r}.props.${i} is not in the ${l} schema`}));return o}function k(r,s){let t=u[r];if(!t)return s;let n={};for(let e of t.hashed)s[e]!==void 0&&(n[e]=s[e]);return n}function N(r,s){let t=p(r);if(!t)return s;let n={};for(let e of t.salient)s[e]!==void 0&&(n[e]=s[e]);return n}export{l as a,u as b,f as c,y as d,h as e,m as f,p as g,S as h,k as i,N as j};
@@ -0,0 +1,6 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{b as u,c as p}from"./chunk-WUMNIGPR.js";import{spawn as m}from"child_process";var y=new Set(["progress","ask_user","graph_query","proposal","design","error","done","reasoning_delta","reasoning_done","tool_activity","decision_activity","text_delta","usage","receipt","chat_ops","session_paused","session_complete"]);function v(l,s={}){let a=s.spawnCmd!==void 0?s.spawnCmd:u();if(!a)throw new Error("assurance-agent not found \u2014 expected an npm platform package, a sibling assurance-agent/dist binary, or assurance-agent/main.py (dev)");let n=m(a.cmd,a.args,{stdio:["pipe","pipe","pipe"],env:p(l.session_id,s.auth)});if(n.stdin.write(JSON.stringify(l)+`
3
+ `),s.onStderr){let e="";n.stderr.on("data",r=>{e+=r.toString("utf8");let i;for(;(i=e.indexOf(`
4
+ `))>=0;){let o=e.slice(0,i);e=e.slice(i+1),o.trim()&&s.onStderr(o)}})}let g=new Promise(e=>{n.on("exit",(r,i)=>e({code:r,signal:i}))});async function*f(){let e="",r=!1;for await(let i of n.stdout){e+=i.toString("utf8");let o;for(;(o=e.indexOf(`
5
+ `))>=0;){let d=e.slice(0,o).trim();if(e=e.slice(o+1),!d)continue;let c;try{c=JSON.parse(d)}catch{s.onWarn?.(`agent: skipping malformed line: ${d.slice(0,120)}`);continue}let t=c;if(!t||typeof t!="object"||!y.has(t.type)){s.onWarn?.(`agent: skipping unknown event type "${t&&typeof t=="object"?String(t.type??"?"):"?"}"`);continue}if(yield t,t.type==="done"){r=!0;break}}if(r)break}await g.catch(()=>{})}return{events:f(),send:e=>{n.stdin&&!n.stdin.destroyed&&n.stdin.write(JSON.stringify(e)+`
6
+ `)},kill:()=>{n.kill("SIGTERM")},exited:g}}export{v as a};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{w as s}from"./chunk-HFXQU7UZ.js";function n(r="prod"){let e=s[r];return r!=="stage"?e:{authBaseUrl:process.env.KANE_STAGE_AUTH_URL??e.authBaseUrl,consentUrl:process.env.KANE_STAGE_CONSENT_URL??e.consentUrl,controllerBaseUrl:process.env.TESTMUAI_BASE_URL??e.controllerBaseUrl,tmsBaseUrl:process.env.KANE_STAGE_TMS_URL??e.tmsBaseUrl,testGeneratorBaseUrl:process.env.KANE_STAGE_TCG_URL??e.testGeneratorBaseUrl,secretsBaseUrl:process.env.KANE_STAGE_SECRETS_URL??e.secretsBaseUrl,testManagerUiUrl:process.env.KANE_STAGE_TEST_MANAGER_UI_URL??e.testManagerUiUrl,shareApiBaseUrl:process.env.KANE_STAGE_SHARE_API_URL??e.shareApiBaseUrl,v16ServerHost:process.env.KANE_STAGE_V16_SERVER_HOST??e.v16ServerHost,evidenceViewerUrl:process.env.KANE_STAGE_EVIDENCE_VIEWER_URL??e.evidenceViewerUrl}}export{n as a};
2
+ import{w as s}from"./chunk-MKD3KZPM.js";function n(r="prod"){let e=s[r];return r!=="stage"?e:{authBaseUrl:process.env.KANE_STAGE_AUTH_URL??e.authBaseUrl,consentUrl:process.env.KANE_STAGE_CONSENT_URL??e.consentUrl,controllerBaseUrl:process.env.TESTMUAI_BASE_URL??e.controllerBaseUrl,tmsBaseUrl:process.env.KANE_STAGE_TMS_URL??e.tmsBaseUrl,testGeneratorBaseUrl:process.env.KANE_STAGE_TCG_URL??e.testGeneratorBaseUrl,secretsBaseUrl:process.env.KANE_STAGE_SECRETS_URL??e.secretsBaseUrl,testManagerUiUrl:process.env.KANE_STAGE_TEST_MANAGER_UI_URL??e.testManagerUiUrl,shareApiBaseUrl:process.env.KANE_STAGE_SHARE_API_URL??e.shareApiBaseUrl,v16ServerHost:process.env.KANE_STAGE_V16_SERVER_HOST??e.v16ServerHost,evidenceViewerUrl:process.env.KANE_STAGE_EVIDENCE_VIEWER_URL??e.evidenceViewerUrl}}export{n as a};
@@ -1,7 +1,7 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as k}from"./chunk-FPFOW6BS.js";import{h as a}from"./chunk-7KDNH6JP.js";import{a as m}from"./chunk-2WVKOZ6W.js";import{a as y}from"./chunk-UOGJUJCF.js";import{a as h}from"./chunk-IECUFWIZ.js";var $=10,u=200,N=1e4,S=1e6;function T(t,e,r="streaming"){let n=r==="full-fetch"?S:N,o=$,i=0;if(t!==void 0){let s=Number(t);if(!Number.isInteger(s)||s<1||s>u)return{error:`--limit must be an integer in [1, ${u}] (got "${t}")`};o=s}if(e!==void 0){let s=Number(e);if(!Number.isInteger(s)||s<0||s>n)return{error:`--offset must be an integer in [0, ${n}] (got "${e}")`};i=s}return{limit:o,offset:i}}function C(t,e){if(!e)return t;let r=e.toLowerCase();return t.filter(n=>n.name.toLowerCase().includes(r))}function j(t,{limit:e,offset:r}){let n=t.slice(r,r+e),o=t.length>r+e;return{slice:n,hasMore:o}}function v(t,e,r=n=>process.stdout.write(`${n}
2
+ import{a as k}from"./chunk-FPFOW6BS.js";import{h as a}from"./chunk-M5JQXOCE.js";import{a as m}from"./chunk-2WVKOZ6W.js";import{a as y}from"./chunk-INP7FG6V.js";import{a as h}from"./chunk-OXARXMMD.js";var $=10,u=200,N=1e4,S=1e6;function T(t,e,r="streaming"){let n=r==="full-fetch"?S:N,o=$,i=0;if(t!==void 0){let s=Number(t);if(!Number.isInteger(s)||s<1||s>u)return{error:`--limit must be an integer in [1, ${u}] (got "${t}")`};o=s}if(e!==void 0){let s=Number(e);if(!Number.isInteger(s)||s<0||s>n)return{error:`--offset must be an integer in [0, ${n}] (got "${e}")`};i=s}return{limit:o,offset:i}}function C(t,e){if(!e)return t;let r=e.toLowerCase();return t.filter(n=>n.name.toLowerCase().includes(r))}function j(t,{limit:e,offset:r}){let n=t.slice(r,r+e),o=t.length>r+e;return{slice:n,hasMore:o}}function v(t,e,r=n=>process.stdout.write(`${n}
3
3
  `)){for(let n of t)r(JSON.stringify(n));r(JSON.stringify({_meta:"page",limit:e.limit,offset:e.offset,returned:t.length,has_more:e.has_more}))}function b(t,e,r=n=>process.stdout.write(`${n}
4
- `)){if(t.length===0){r("(no results)");return}let n=Math.max(2,...t.map(s=>s.id.length)),o=`${"ID".padEnd(n)} NAME`;r(o),r(`${"-".repeat(n)} ----`);for(let s of t)r(`${s.id.padEnd(n)} ${s.name}`);r("");let i=e.offset+t.length;if(e.hasMore){let s=e.totalIsLowerBound?`${e.total}+`:`${e.total}`;r(`${i} of ${s} \u2014 next: --offset ${e.offset+e.limit}`)}else r(`${t.length} shown (${e.total} total)`)}async function B(t,e,r){if(r.username&&r.accessKey)return{ok:!0,creds:{username:r.username,access_key:r.accessKey}};let n=new h,o=n.loadBasicAuth(t,e);if(o)return{ok:!0,creds:{username:o.username,access_key:o.access_key}};let i=n.loadCredentials(t,e);if(!i)return{ok:!1,reason:"no_credentials"};let s=i.access_token;try{let{refreshOAuthToken:d}=await import("./token-refresh-2HKIYD4Y.js"),w=await d({creds:n,profile:t,env:e,credentials:i});w&&(s=w.accessToken)}catch(d){return{ok:!1,reason:"refresh_failed",detail:d instanceof Error?d.message:String(d)}}let c=y(e),f=await new k(c.controllerBaseUrl,async()=>s,null).resolve();return f?{ok:!0,creds:{username:f.username,access_key:f.access_key}}:{ok:!1,reason:"exchange_failed"}}function E(t,e,r){switch(r.reason){case"no_credentials":return{message:`error: no credentials for profile "${t}" [${e}]. Run \`kane-cli login\` or pass --username/--access-key.
4
+ `)){if(t.length===0){r("(no results)");return}let n=Math.max(2,...t.map(s=>s.id.length)),o=`${"ID".padEnd(n)} NAME`;r(o),r(`${"-".repeat(n)} ----`);for(let s of t)r(`${s.id.padEnd(n)} ${s.name}`);r("");let i=e.offset+t.length;if(e.hasMore){let s=e.totalIsLowerBound?`${e.total}+`:`${e.total}`;r(`${i} of ${s} \u2014 next: --offset ${e.offset+e.limit}`)}else r(`${t.length} shown (${e.total} total)`)}async function B(t,e,r){if(r.username&&r.accessKey)return{ok:!0,creds:{username:r.username,access_key:r.accessKey}};let n=new h,o=n.loadBasicAuth(t,e);if(o)return{ok:!0,creds:{username:o.username,access_key:o.access_key}};let i=n.loadCredentials(t,e);if(!i)return{ok:!1,reason:"no_credentials"};let s=i.access_token;try{let{refreshOAuthToken:d}=await import("./token-refresh-OCFALJ7U.js"),w=await d({creds:n,profile:t,env:e,credentials:i});w&&(s=w.accessToken)}catch(d){return{ok:!1,reason:"refresh_failed",detail:d instanceof Error?d.message:String(d)}}let c=y(e),f=await new k(c.controllerBaseUrl,async()=>s,null).resolve();return f?{ok:!0,creds:{username:f.username,access_key:f.access_key}}:{ok:!1,reason:"exchange_failed"}}function E(t,e,r){switch(r.reason){case"no_credentials":return{message:`error: no credentials for profile "${t}" [${e}]. Run \`kane-cli login\` or pass --username/--access-key.
5
5
  `,exitCode:2};case"refresh_failed":return{message:`error: OAuth token refresh failed for profile "${t}" [${e}]${r.detail?`: ${r.detail}`:""}. Run \`kane-cli login\` to re-auth.
6
6
  `,exitCode:2};case"exchange_failed":return{message:`error: TMS credential exchange failed for profile "${t}" [${e}]. Token may be revoked \u2014 try \`kane-cli login\`; if the problem persists, TMS may be down.
7
7
  `,exitCode:2}}}function O(t){return{id:t.project_id,name:t.name}}function M(t){return{id:t.id,name:t.name}}async function P(t,e,r,n){let o=r+n+1,i=[],s=!0;for await(let c of t.listProjectsStream({name:e})){if(i.push(...c.projects),c.done){s=!0;break}if(i.length>=o){s=!1;break}}return{items:i,doneStreaming:s}}function g(t){return!!t.agent||!process.stdin.isTTY||!process.stdout.isTTY}function _(t,e=r=>process.stdout.write(`${r}
@@ -0,0 +1,4 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{appendFileSync as o,existsSync as u,mkdirSync as g,readFileSync as p}from"fs";import{join as d}from"path";function m(e,n){g(e,{recursive:!0}),o(d(e,"signals.ndjson"),JSON.stringify(n)+`
3
+ `)}function v(e,n){switch(n){case"approved":return[{...e,verdict:"approved",polarity:"preference"}];case"rejected":return[{...e,verdict:"rejected",polarity:"preference"},{...e,verdict:"rejected",polarity:"mistake",tag:"wrong-uc-inference"}];case"edited":return[{...e,verdict:"edited",polarity:"correction"}];case"supersede":return[{...e,verdict:"supersede",polarity:"preference"},{...e,verdict:"supersede",polarity:"correction",tag:"superseded-prior-version"}];case"skipped":return[]}}function S(e,n){let r=(t,i,s,c)=>({...n,id:s,verdict:t,polarity:i,...c!==void 0?{tag:c}:{},event_id:e.eventId,target:s});switch(e.kind){case"approve":return[r("approve","preference",e.target)];case"edit":return[r("edit","preference",e.target),r("edit","correction",e.target)];case"enhance":return[r("enhance","preference",e.target)];case"reject":{let t=[r("reject","preference",e.target),r("reject","mistake",e.target,"wrong-uc-inference")];return e.redirectTo!==void 0&&t.push(r("dedup_dropped","correction",e.target),r("dedup_kept","preference",e.redirectTo)),t}case"add":return[];case"resolve_question":{if(e.resolution==="deferred")return[];if(e.resolution==="assumed-default")return[r("default_accepted","preference",e.questionId)];let t=e.answer?.optionIds?.[0]??(e.answer?.freeText!==void 0?"free-text":void 0),i=[r("gap_resolution","preference",e.questionId,t)];return e.overrodeRecommendation&&i.push(r("default_overridden","correction",e.questionId,t)),i}}}function y(e,n){let r=d(e,"signals.ndjson");if(!u(r))return{signals:[],watermark:0};let t=p(r),i=t.lastIndexOf(10),s=i===-1?0:i+1;n!==void 0&&n<s&&(s=n);let c=[];for(let a of t.subarray(0,s).toString("utf8").split(`
4
+ `))if(a.trim())try{c.push(JSON.parse(a))}catch{}return{signals:c,watermark:s}}export{m as a,v as b,S as c,y as d};
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{b as o}from"./chunk-B2PZAB7J.js";import{existsSync as c,mkdirSync as f,readFileSync as u,renameSync as l,writeFileSync as g}from"fs";import{dirname as p,join as a}from"path";function i(t,r){let n=r.startsWith("sha256:")?r.slice(7):r;return a(t,"blobs",n.slice(0,2),n.slice(2))}function B(t,r){return i(t,r)}function m(t){let r=Buffer.concat([Buffer.from("assurance.blob\0","utf8"),t]);return"sha256:"+o(r)}function d(t,r){let n=m(r),e=i(t,n);if(!c(e)){f(p(e),{recursive:!0});let s=`${e}.tmp-${process.pid}`;g(s,r),l(s,e)}return n}function S(t,r){let n=i(t,r);return c(n)?u(n):null}export{B as a,m as b,d as c,S as d};
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{a as i,b as s}from"./chunk-L5LI2JF4.js";import{existsSync as o,mkdirSync as l,readFileSync as c,writeFileSync as g}from"fs";import{dirname as u,join as m}from"path";function a(t,r){let e=r.startsWith("sha256:")?r.slice(7):r;return m(t,"design","rationale",`${e}.yaml`)}function h(t,r,e){let n=a(t,r);return l(u(n),{recursive:!0}),g(n,s(e,{sortKeys:!0,lineWidth:-1})),n}function y(t,r){let e=a(t,r);return o(e)?i(c(e,"utf8")):null}export{h as a,y as b};
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{a as S}from"./chunk-QK6KZMYG.js";import{x as o}from"./chunk-MKD3KZPM.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};
@@ -0,0 +1,356 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{a as Ge}from"./chunk-KHU7C6EE.js";import{a as je,b as Me}from"./chunk-NNZV5RCE.js";import{a as Ae,b as Te,c as Oe,f as Ie,g as Pe}from"./chunk-NWZTYAJB.js";import{a as Ce}from"./chunk-DM2GL24Z.js";import{b as Ee,c as De}from"./chunk-5ILXUQIX.js";import{c as Re}from"./chunk-VJUIW2ES.js";import{a as Ne,b as qe,g as Be,h as Le}from"./chunk-FXPPQL4D.js";import{a as Fe}from"./chunk-Z56AWGVY.js";import{b as he,c as _e,d as be,e as ee,f as J,g as re,h as ye,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 ke,b as ue}from"./chunk-GIRXJOJI.js";import{e as xe,g as $e}from"./chunk-B2PZAB7J.js";import{d as S,e as E,f as ve,g as we,h as Se}from"./chunk-IACKIGPX.js";import{mkdirSync as $t,appendFileSync as Et}from"fs";import{randomBytes as Dt}from"crypto";import{join as at}from"path";import{existsSync as me,readFileSync as ge,readdirSync as ct}from"fs";import{join as te}from"path";var Ue=`
3
+ version: 1
4
+ techniques:
5
+ - id: eqp
6
+ name: "Equivalence partitioning"
7
+ applies_hint: "any constrained input"
8
+ emits: [absolute, forbidden-presence]
9
+ - id: bva
10
+ name: "Boundary value analysis"
11
+ applies_hint: "input has an ordered range or length"
12
+ emits: [absolute, forbidden-presence]
13
+ - id: negative
14
+ name: "Negative / error"
15
+ applies_hint: "any input or action that can fail"
16
+ emits: [forbidden-presence]
17
+ - id: state_flow
18
+ name: "State / flow"
19
+ applies_hint: "the AC sits in a multi-step flow"
20
+ emits: [state-transition]
21
+ - id: crud
22
+ name: "CRUD round-trip"
23
+ applies_hint: "AC touches a persisted resource"
24
+ emits: [delta, presence, forbidden-presence]
25
+ - id: auth
26
+ name: "Auth / permission"
27
+ applies_hint: "AC is behind a gate or role"
28
+ emits: [forbidden-presence, presence]
29
+ - id: api_contract
30
+ name: "API-contract"
31
+ applies_hint: "surface is REST/GraphQL"
32
+ emits: [absolute]
33
+ - id: concurrency
34
+ name: "Concurrency / race"
35
+ applies_hint: "high-risk (money / data-loss) or shared-resource AC"
36
+ emits: [state-transition, forbidden-presence]
37
+ - id: idempotency
38
+ name: "Idempotency / retry"
39
+ applies_hint: "money or write operations"
40
+ emits: [delta]
41
+ - id: i18n
42
+ name: "i18n / l10n"
43
+ applies_hint: "AC renders user text or formats numbers/dates/currency"
44
+ emits: [presence, absolute]
45
+ - id: a11y
46
+ name: "a11y"
47
+ applies_hint: "any rendered surface"
48
+ emits: [presence, absolute]
49
+ - id: responsiveness
50
+ name: "Responsiveness / layout"
51
+ applies_hint: "rendered surface"
52
+ emits: [presence, forbidden-presence]
53
+ - id: empty_state
54
+ name: "Empty / null / zero state"
55
+ applies_hint: "list / search / collection AC"
56
+ emits: [presence]
57
+ - id: overflow_underflow
58
+ name: "Overflow / underflow"
59
+ applies_hint: "numeric or quantity AC (R9: explicit underflow/overflow)"
60
+ emits: [forbidden-presence]
61
+ - id: persistence
62
+ name: "Persistence / refresh"
63
+ applies_hint: "AC asserts durable state"
64
+ emits: [absolute]
65
+ - id: temporal
66
+ name: "Time / timezone / expiry"
67
+ applies_hint: "AC involves dates, TTLs, schedules"
68
+ emits: [state-transition, forbidden-presence]
69
+ - id: currency
70
+ name: "Currency / rounding"
71
+ applies_hint: "money AC"
72
+ emits: [absolute]
73
+ - id: pagination
74
+ name: "Pagination / sort / filter"
75
+ applies_hint: "list / search AC"
76
+ emits: [absolute, presence]
77
+ - id: file_media
78
+ name: "File / media"
79
+ applies_hint: "upload surface"
80
+ emits: [forbidden-presence]
81
+ - id: notification
82
+ name: "Notification / async-effect"
83
+ applies_hint: "AC produces an out-of-band effect (email/SMS/push)"
84
+ emits: [presence, delta]
85
+ `;var ze={"web-form":`
86
+ id: web-form
87
+ name: "Web form"
88
+ version: 1
89
+ applies_when: >
90
+ The AC concerns a data-entry form: input fields, required fields, submit,
91
+ validation messages.
92
+ candidate_checks:
93
+ - id: field-validation
94
+ family: negative
95
+ measurable_example: "Enter 'abc' in a numeric quantity field \u2192 inline error 'must be a number', value not accepted"
96
+ emits: forbidden-presence
97
+ - id: required-fields
98
+ family: negative
99
+ measurable_example: "Submit with a required field empty \u2192 submit blocked, field flagged"
100
+ emits: forbidden-presence
101
+ - id: formats
102
+ family: negative
103
+ measurable_example: "Email without @ rejected; valid accepted"
104
+ emits: forbidden-presence
105
+ - id: empty-state
106
+ family: empty_state
107
+ measurable_example: "First load: no stale values, placeholders shown"
108
+ emits: presence
109
+ - id: error-messages
110
+ family: negative
111
+ measurable_example: "Each error is specific and tied to its field"
112
+ emits: presence
113
+ - id: a11y
114
+ family: a11y
115
+ measurable_example: "Every input has a programmatic label; keyboard-only submit works"
116
+ emits: presence
117
+ - id: responsiveness
118
+ family: responsiveness
119
+ measurable_example: "No field overlap at 1280/768/375 px"
120
+ emits: forbidden-presence
121
+ `,"rest-graphql-api":`
122
+ id: rest-graphql-api
123
+ name: "REST / GraphQL API"
124
+ version: 1
125
+ applies_when: >
126
+ The surface is an HTTP/GraphQL endpoint.
127
+ candidate_checks:
128
+ - id: response-shape
129
+ family: api_contract
130
+ measurable_example: "Body validates against the declared schema"
131
+ emits: absolute
132
+ - id: status-codes
133
+ family: api_contract
134
+ measurable_example: "GET 200, POST 201, missing 404, bad 400, unauth 401"
135
+ emits: absolute
136
+ - id: verbs
137
+ family: idempotency
138
+ measurable_example: "PUT is idempotent, POST is not"
139
+ emits: delta
140
+ - id: bad-payloads
141
+ family: negative
142
+ measurable_example: "Malformed JSON \u2192 400, never 500"
143
+ emits: absolute
144
+ - id: idempotency
145
+ family: idempotency
146
+ measurable_example: "Same POST with idempotency-key twice \u2192 one effect"
147
+ emits: delta
148
+ - id: pagination
149
+ family: pagination
150
+ measurable_example: "Page beyond last \u2192 empty list, not error; cursor stable"
151
+ emits: absolute
152
+ - id: versioning
153
+ family: api_contract
154
+ measurable_example: "v1 contract unchanged after v2 ships"
155
+ emits: absolute
156
+ - id: rate-limits
157
+ family: api_contract
158
+ measurable_example: "Over the limit \u2192 429 with retry-after"
159
+ emits: absolute
160
+ `,"mobile-native":`
161
+ id: mobile-native
162
+ name: "Mobile native"
163
+ version: 1
164
+ applies_when: >
165
+ iOS/Android native surface.
166
+ candidate_checks:
167
+ - id: interruptions
168
+ family: state_flow
169
+ measurable_example: "Incoming call mid-flow \u2192 state preserved on return"
170
+ emits: state-transition
171
+ - id: network-transitions
172
+ family: state_flow
173
+ measurable_example: "wifi\u2192cellular\u21924G drop: no data loss, graceful retry"
174
+ emits: state-transition
175
+ - id: permissions
176
+ family: negative
177
+ measurable_example: "Deny camera \u2192 feature degrades, no crash"
178
+ emits: forbidden-presence
179
+ - id: orientation
180
+ family: persistence
181
+ measurable_example: "Rotate mid-form \u2192 input preserved"
182
+ emits: absolute
183
+ - id: deep-links
184
+ family: state_flow
185
+ measurable_example: "Cold-start deep link lands on the right screen with auth"
186
+ emits: state-transition
187
+ - id: state-persistence
188
+ family: persistence
189
+ measurable_example: "Kill + relaunch \u2192 resume where left off"
190
+ emits: absolute
191
+ - id: localization
192
+ family: i18n
193
+ measurable_example: "Device locale switch reformats and re-translates"
194
+ emits: presence
195
+ `,"stateful-flow":`
196
+ id: stateful-flow
197
+ name: "Stateful flow"
198
+ version: 1
199
+ applies_when: >
200
+ Multi-step wizard / checkout / onboarding.
201
+ candidate_checks:
202
+ - id: valid-transitions
203
+ family: state_flow
204
+ measurable_example: "Each step advances only when its precondition is met"
205
+ emits: state-transition
206
+ - id: invalid-transitions
207
+ family: state_flow
208
+ measurable_example: "Can't jump to step 3 with step 2 incomplete"
209
+ emits: forbidden-presence
210
+ - id: back-and-abandon
211
+ family: state_flow
212
+ measurable_example: "Back from step 3, then abandon \u2192 no partial commit"
213
+ emits: forbidden-presence
214
+ - id: refresh-persistence
215
+ family: persistence
216
+ measurable_example: "Reload at step 2 \u2192 still at step 2 with data"
217
+ emits: absolute
218
+ - id: resume
219
+ family: persistence
220
+ measurable_example: "Return later \u2192 resume the saved flow"
221
+ emits: absolute
222
+ - id: double-submission
223
+ family: idempotency
224
+ measurable_example: "Double-click submit \u2192 exactly one submission"
225
+ emits: delta
226
+ `,"data-crud":`
227
+ id: data-crud
228
+ name: "Data CRUD"
229
+ version: 1
230
+ applies_when: >
231
+ A persisted record.
232
+ candidate_checks:
233
+ - id: crud-round-trip
234
+ family: crud
235
+ measurable_example: "Create \u2192 read shows it \u2192 update \u2192 read shows the change \u2192 delete \u2192 read 404"
236
+ emits: state-transition
237
+ - id: retry-safety
238
+ family: idempotency
239
+ measurable_example: "Retried create with same key \u2192 one row"
240
+ emits: delta
241
+ - id: concurrency-lost-update
242
+ family: concurrency
243
+ measurable_example: "Two writers, last must not silently clobber \u2192 conflict surfaced"
244
+ emits: forbidden-presence
245
+ - id: delete-cascade
246
+ family: crud
247
+ measurable_example: "Delete parent \u2192 children handled per rule"
248
+ emits: state-transition
249
+ - id: referential-consistency
250
+ family: crud
251
+ measurable_example: "Can't create a child for a missing parent"
252
+ emits: forbidden-presence
253
+ `,"auth-gated":`
254
+ id: auth-gated
255
+ name: "Auth gated"
256
+ version: 1
257
+ applies_when: >
258
+ Behind login/role.
259
+ candidate_checks:
260
+ - id: login-gate
261
+ family: auth
262
+ measurable_example: "Anonymous \u2192 redirected to login, not the resource"
263
+ emits: forbidden-presence
264
+ - id: role-permission-matrix
265
+ family: auth
266
+ measurable_example: "For each role \xD7 action: allowed/denied as specified"
267
+ emits: absolute
268
+ - id: cross-user-record
269
+ family: auth
270
+ measurable_example: "User A cannot read/edit user B's record by id"
271
+ emits: forbidden-presence
272
+ - id: token-session-expiry
273
+ family: auth
274
+ measurable_example: "Expired token \u2192 401/redirect, no stale access"
275
+ emits: forbidden-presence
276
+ - id: privilege-escalation
277
+ family: auth
278
+ measurable_example: "Non-admin cannot reach an admin action by direct URL/API"
279
+ emits: forbidden-presence
280
+ `,"search-list":`
281
+ id: search-list
282
+ name: "Search / list"
283
+ version: 1
284
+ applies_when: >
285
+ Search results / list views.
286
+ candidate_checks:
287
+ - id: pagination
288
+ family: pagination
289
+ measurable_example: "First/last/empty page correct; total accurate"
290
+ emits: absolute
291
+ - id: sorting
292
+ family: pagination
293
+ measurable_example: "Sort asc/desc actually orders; ties stable"
294
+ emits: absolute
295
+ - id: filtering
296
+ family: pagination
297
+ measurable_example: "Each filter narrows correctly; combined filters AND"
298
+ emits: absolute
299
+ - id: empty-state
300
+ family: empty_state
301
+ measurable_example: "No results \u2192 friendly empty state, not blank/error"
302
+ emits: presence
303
+ - id: invalid-input
304
+ family: negative
305
+ measurable_example: "Garbage query \u2192 no crash, sane result"
306
+ emits: forbidden-presence
307
+ - id: length-limits
308
+ family: bva
309
+ measurable_example: "Max-length query handled"
310
+ emits: absolute
311
+ - id: locale
312
+ family: i18n
313
+ measurable_example: "Locale-correct collation/casing"
314
+ emits: presence
315
+ `};var He=`
316
+ version: 1
317
+ principles:
318
+ - "Each step is one complete OBJECTIVE the browser agent achieves autonomously \u2014 state the goal and the path, never low-level actions (the agent emits its own actions)."
319
+ - "One objective (or tightly-related items of one goal) per step; unrelated goals split."
320
+ - "Verbose path: name site, page, section, panel, control, state \u2014 'On the search results page for Noida, in the filter panel's Budget section, set min to 50L and max to 1Cr'."
321
+ - "Self-contained: concrete values inline; never 'as defined in the scenario' \u2014 the agent cannot see the graph."
322
+ - "Browser-only: the agent authors/runs BROWSER tests. Direct API calls and the page's own network traffic ARE in scope; native-app-only behavior, out-of-band email/SMS, backend state with no browser surface are NOT."
323
+ verification:
324
+ - "Phrase checks against the analyzer that observes them:"
325
+ - "Visual \u2014 visible text, labels, counts, prices ('verify the price is 29.99', 'the Sold out label is shown')."
326
+ - "Textual/DOM \u2014 element states/attributes ('the Add button is disabled', 'the placeholder of the search box is \u2026')."
327
+ - "URL \u2014 'URL contains /checkout', 'redirected to /login'. Title \u2014 'page title contains \u2026'."
328
+ - "DevTools/Network \u2014 'no API calls returned 5xx', 'the POST /api/login returned 200' (covers direct API calls too)."
329
+ - "DevTools/Console \u2014 'no console errors'. Performance \u2014 'LCP under 2500ms'. Cookies/localStorage \u2014 'a cookie named session_id exists'."
330
+ - "Assertions: 'Assert/Verify/Confirm \u2026'. Extractions: 'Store \u2026 as name' \u2014 vague verbs (read/tell/report) do NOT persist values."
331
+ - "Baselines/deltas are EXTRACTIONS: 'store the result count as baseline_count' BEFORE the action; compare after. Never an abstract 'capture the state'."
332
+ variables:
333
+ - "Credentials and environment values are {{name}} variables; concrete domain values from the source stay literal."
334
+ - "A value no evidence supplies (start URL, test account, seed data) is ASKED for \u2014 actual value or a variable name \u2014 never invented."
335
+ pitfalls:
336
+ - "A test without a starting URL cannot run \u2014 the first step names it."
337
+ - "'Test the checkout flow' has no end state \u2014 state what done looks like."
338
+ - "Do not cram many unrelated operations into one step; do not reference data outside the step."
339
+ `;var dt=["presence","forbidden-presence","count","delta","state-transition","absolute","bound","propagation","latency","graded"];function Ye(s,t){for(let e of s)if(!dt.includes(e))throw new Error(`${t}: emits '${e}' is not an oracle kind`)}function We(s,t){let e=de(s);if(!e||!Array.isArray(e.techniques))throw new Error(`${t}: expected { techniques: [...] }`);for(let i of e.techniques){if(!i.id||!i.name||!i.applies_hint||!Array.isArray(i.emits))throw new Error(`${t}: technique '${i?.id??"?"}' missing id/name/applies_hint/emits`);Ye(i.emits,`${t}: technique '${i.id}'`)}return e.techniques}function Ve(s,t){let e=de(s);if(!e||!e.id||!e.name||!e.applies_when||!Array.isArray(e.candidate_checks))throw new Error(`${t}: profile missing id/name/applies_when/candidate_checks`);for(let i of e.candidate_checks){if(!i.id||!i.family||!i.measurable_example||!i.emits)throw new Error(`${t}: candidate_check '${i?.id??"?"}' missing id/family/measurable_example/emits`);Ye([i.emits],`${t}: check '${i.id}'`)}return e}function Qe(s){let t=new Map(We(Ue,"packaged techniques").map(i=>[i.id,i])),e=te(s,"design","techniques.yaml");if(me(e))for(let i of We(ge(e,"utf8"),e))t.set(i.id,i);return[...t.values()]}function Ke(s){let t=new Map(Object.entries(ze).map(([i,a])=>[i,Ve(a,`packaged profile '${i}'`)])),e=te(s,"design","profiles");if(me(e))for(let i of ct(e).filter(a=>a.endsWith(".yaml")||a.endsWith(".yml")).sort()){let a=Ve(ge(te(e,i),"utf8"),te(e,i));t.set(a.id,a)}return[...t.values()]}function Je(s){let t=te(s,"design","runner-grammar.yaml");return me(t)?ge(t,"utf8"):He}function se(s,t){return!s.superseded.has(t)}function pe(s,t,e){return{cid:t,logical_id:s.nameOf.get(t)??null,content:e}}async function Xe(s,t,e,i,a){let d=await Ae(s,"search_similar",{text:t,label:e,k:i},a);return d.ok&&Array.isArray(d.result)?d.result:[]}async function Ze(s,t,e={}){let i=Y(s),a=i.resolve(t);if(!a)throw new Error(`assembleDesignContext: unknown use-case '${t}' (run designGate first)`);let d=a.tip,R=i.getNode(d);if(!R||R.label!==S.USECASE)throw new Error(`assembleDesignContext: '${t}' is not a use-case (run designGate first)`);let N=i.derivesInto(d).map(b=>({source_id:b.props.source_id??null,anchor:b.props.anchor??null})),x=[],h=new Set;for(let{cid:b,content:p}of i.byLabel(S.SCENARIO))se(i,b)&&i.edgesFrom(b).some(o=>o.type===E.BELONGS_TO&&o.dst===d)&&(x.push(pe(i,b,p)),h.add(b));let O=[];for(let{cid:b,content:p}of i.byLabel(S.AC)){if(!se(i,b))continue;let o=i.edgesFrom(b).find(r=>r.type===E.SCOPED_TO);!o||o.dst!==d&&!h.has(o.dst)||O.push({...pe(i,b,p),scoped_to:o.dst})}let m=Array.isArray(R.content.criteria)?R.content.criteria:[],y=[R.content.title,R.content.description,...m].filter(Boolean).join(`
340
+ `),C=(await Xe(i,y,S.SCENARIO,10,e.embedSearch)).filter(b=>!h.has(b.cid)),L=[],f=new Set,q=[],F=[d],P=new Set([d]);for(;F.length>0;){let b=F.shift();for(let p of i.edgesFrom(b)){if(p.type!==E.DEPENDS_ON||i.nodeLabel.get(p.dst)!==S.USECASE)continue;let o=i.tipOf(p.dst);P.has(o)||(P.add(o),q.push(o),F.push(o))}}for(let b of q){let p=`depends_on ${i.nameOf.get(b)??b.slice(0,19)}`;for(let{cid:o}of i.byLabel(S.SCENARIO))if(se(i,o)&&i.edgesFrom(o).some(r=>r.type===E.BELONGS_TO&&r.dst===b))for(let r of i.edgesInto(o)){if(r.type!==E.AUTOMATES||!se(i,r.src)||f.has(r.src))continue;f.add(r.src);let u=String(i.getNode(r.src)?.content.title??"");L.push({cid:r.src,logical_id:i.nameOf.get(r.src)??null,title:u,via:p})}}for(let b of await Xe(i,y,S.TEST,5,e.embedSearch)){let{cid:p,title:o}=b;f.has(p)||(f.add(p),L.push({cid:p,logical_id:i.nameOf.get(p)??null,title:o??"",via:"similar"}))}let I=i.byLabel(S.STYLENOTE).filter(b=>se(i,b.cid)).sort((b,p)=>b.cid<p.cid?-1:1).slice(0,5).map(b=>`${String(b.content.statement)} [${String(b.content.learned_from_kind)}]`);return{usecase:pe(i,d,R.content),cites:N,committed_acs:O,existing:{scenarios:x,reuse_candidates:C},import_candidates:L,style_notes:I,techniques:Qe(s),profiles:Ke(s),runner_grammar:Je(s),budget:{...e.max!=null?{max_pairs:e.max}:{},...e.strength!=null?{strength_override:e.strength}:{}},design_of:(()=>{let b=je(i,d);return b?{engine:b.engine,seq:b.seq}:null})()}}function et(s){let t=e=>{if(Array.isArray(e))return e.map(t);if(e!==null&&typeof e=="object"){let i={};for(let a of Object.keys(e).sort())i[a]=t(e[a]);return i}return e};return JSON.stringify(t(s),null,1)}var ne=s=>({record:null,errors:s,minted:{},logicalIds:{},superseded:[],warnings:[],finalizedTests:{}});function ie(s){return s.toLowerCase().trim().replace(/\s+/g," ")}function fe(s,t){let e=s.resolve(t);if(!e||s.nodeLabel.get(e.cid)!==S.USECASE||e.superseded)return[];let i=new Set;for(let{cid:a}of s.byLabel(S.SCENARIO))if(!s.superseded.has(a)&&s.edgesFrom(a).some(d=>d.type===E.BELONGS_TO&&s.tipOf(d.dst)===e.cid)){i.add(a);for(let d of s.edgesInto(a))d.type!==E.AUTOMATES||s.superseded.has(d.src)||i.add(d.src)}return[...i]}function tt(s){let{contextDir:t,graph:e,sections:i,by:a}=s,d=s.engine??"design@1",R=xe(t);if(e.latestHash!==R)return ne([{code:"STALE_BASIS",detail:`graph opened at ${String(e.latestHash)} but chain head is ${String(R)} \u2014 re-open and retry`}]);let N=e.resolve(s.ucRef);if(!N||e.nodeLabel.get(N.cid)!==S.USECASE||N.superseded)return ne([{code:"UNKNOWN_UC",detail:`${s.ucRef} is not a live use-case`}]);let x=N.cid,h=[],O=[],m=[],y=[],C=[],L=[],f={},q={},F={},P=[],I=[],b=new Set,p=[],o=new Set,r=new Set,u=[];{let n=s.forceScope??(s.force?fe(e,s.ucRef):[]),l=new Set;s.sections.scenarios?.length&&l.add(S.SCENARIO),s.sections.tests?.length&&l.add(S.TEST);for(let c of n)e.superseded.has(c)||(l.has(e.nodeLabel.get(c)??"")?r.add(c):u.push(c))}let A=new Set,$=n=>!e.superseded.has(n)&&(!r.has(n)||A.has(n)),j=(n,l,c)=>{if(f[n])return f[n];let w=e.resolve(n),_=w?$(w.cid)?w.cid:e.tipOf(w.cid):null;return!w||!_||!$(_)?(h.push({code:"UNKNOWN_REF",detail:`${l}: '${n}' is neither in this payload nor a live committed node`}),null):c&&e.nodeLabel.get(_)!==c?(h.push({code:"ILLEGAL_EDGE",detail:`${l}: '${n}' is a ${e.nodeLabel.get(_)}, expected ${c}`}),null):_},H=(n,l,c,w)=>{if(e.nameOf.has(l)){q[w]=e.nameOf.get(l);return}let _=Ee(n,c,B=>b.has(B)||e.names.has(B)&&!e.superseded.has(e.names.get(B)));_!==null&&(b.add(_),C.push({cid:l,slug:_,by:a}),q[w]=_)},U=(n,l,c,w)=>{for(let B of ve(n,c))h.push({code:B.code,detail:`${l}: ${B.detail}`});let _=ke(n,c);return e.hasNode(_)&&!e.superseded.has(_)?(r.has(_)&&A.add(_),f[l]=_,_):(O.push({cid:_,label:n,content:c}),f[l]=_,H(n,_,w,l),_)},M=(n,l,c,w,_)=>{let B=ue(n,l,c,w);if(e.edgesFrom(l).some(g=>g.ecid===B&&!e.superseded.has(g.ecid))){n===E.AUTOMATES&&o.add(c);return}let Q=e.nodeLabel.get(l)??O.find(g=>g.cid===l)?.label??"(unknown)",D=e.nodeLabel.get(c)??O.find(g=>g.cid===c)?.label??"(unknown)";for(let g of Se(n,Q,D,w))h.push({code:g.code,detail:`${_}: ${g.detail}`});let T=De(e,n,l,c,p);if(T){h.push({code:T.code,detail:`${_}: ${T.detail}`});return}if(n===E.AUTOMATES){if(o.has(c)){h.push({code:"CARDINALITY_VIOLATION",detail:`${_}: two automates onto ${c} in one record (strict 1:1)`});return}if(o.add(c),!r.has(c)||A.has(c)){let g=G=>r.has(G)&&!A.has(G);if(e.edgesFrom(l).some(G=>G.type===E.AUTOMATES&&G.dst!==c&&!e.superseded.has(G.dst)&&!g(G.dst))&&e.hasNode(l)){h.push({code:"CARDINALITY_VIOLATION",detail:`${_}: automates from ${l} already has a live edge \u2014 supersede it first`});return}if(e.edgesInto(c).some(G=>G.type===E.AUTOMATES&&G.src!==l&&!e.superseded.has(G.src)&&!g(G.src))){h.push({code:"CARDINALITY_VIOLATION",detail:`${_}: automates onto ${c} already has a live edge \u2014 strict 1:1, supersede it first`});return}}}m.push({ecid:ue(n,l,c,w),type:n,src:l,dst:c,props:w}),p.push({src:l,dst:c,type:n})},W=new Set;for(let n of i.gaps??[]){let l=n.temp_ref??n.ref??"gap",c=n.question;if(!c||typeof c!="object"||!c.header||!Array.isArray(c.options)||c.options.length===0||!Number.isInteger(c.recommended_index)){h.push({code:"GAP_QUESTION_INCOMPLETE",detail:`${l}: design gaps carry a full ranked question object (header/options/recommended_index \u2014 R49)`});continue}n.kind==="budget-evicted"&&n.ref&&W.add(n.ref);let w={kind:n.kind,question:c,derived:!0,uc:x,...n.risk?{risk:n.risk}:{},...n.risk_rationale?{risk_rationale:n.risk_rationale}:{},...n.text?{text:n.text}:{},...n.ref?{ref:n.ref}:{}};U(S.GAP,l,w,String(c.header))}let K=new Map;for(let{cid:n,content:l}of e.byLabel(S.SCENARIO))$(n)&&e.edgesFrom(n).some(c=>c.type===E.BELONGS_TO&&e.tipOf(c.dst)===x)&&K.set(ie(String(l.title??"")),n);for(let n of i.scenarios??[]){let l=K.get(ie(n.title));if(l){h.push({code:"DUPLICATE_SCENARIO",detail:`${n.temp_ref}: '${n.title}' duplicates live scenario ${e.nameOf.get(l)??l} \u2014 exercise/link it instead (reuse-before-mint, D16)`});continue}let c={title:n.title,intent:n.intent,case_type:n.case_type,derived:!0,...n.technique_notes?{technique_notes:n.technique_notes}:{},...n.description?{description:n.description}:{},...n.parameters?{parameters:n.parameters}:{},...n.tags?{tags:n.tags}:{}};U(S.SCENARIO,n.temp_ref,c,n.title)}for(let n of i.scenarios??[]){let l=f[n.temp_ref];if(l){M(E.BELONGS_TO,l,x,{},n.temp_ref);for(let c of n.depends_on??[]){let w=j(c,`${n.temp_ref}.depends_on`,S.SCENARIO);w&&M(E.DEPENDS_ON,l,w,{},`${n.temp_ref}.depends_on`)}}}for(let n of i.acs??[]){let l={text:n.text,kind:n.kind,risk:n.risk,derived:!0,...n.expected_answer?{expected_answer:n.expected_answer}:{},...n.measurable!==void 0?{measurable:n.measurable}:{}},c=U(S.AC,n.temp_ref,l,n.text);if(!c)continue;let w=n.scope?.type==="scenario"&&n.scope.ref?j(n.scope.ref,`${n.temp_ref}.scope`,S.SCENARIO):x;w&&!e.edgesFrom(c).some(_=>_.type===E.SCOPED_TO&&!e.superseded.has(_.ecid))&&M(E.SCOPED_TO,c,w,{},`${n.temp_ref}.scope`);for(let _ of n.cites??[]){let B={source_id:_.source_id,source_cid:_.source_cid,anchor:_.anchor,..._.quote?{quote:_.quote}:{}};M(E.DERIVES,_.source_cid,c,B,`${n.temp_ref}.cite`)}}for(let n of i.exercises??[]){let l=j(n.scenario,"exercises.scenario",S.SCENARIO),c=j(n.ac,"exercises.ac",S.AC);l&&c&&M(E.EXERCISES,l,c,{},`exercises ${n.scenario}\u2192${n.ac}`)}for(let n of i.scoped_to_repoints??[]){let l=j(n.ac,"scoped_to_repoints.ac",S.AC),c=j(n.to,"scoped_to_repoints.to");if(!l||!c)continue;let w=e.edgesFrom(l).find(_=>_.type===E.SCOPED_TO&&!e.superseded.has(_.ecid));w&&y.push({kind:"edge",ecid:w.ecid,reason:`re-scoped to ${n.to} by ${a.id}`,by:a}),M(E.SCOPED_TO,l,c,{},`scoped_to_repoints ${n.ac}`)}let X=new Map;if(s.finalizeTestBody)for(let[n,l]of e.nameOf)X.set(e.tipOf(n),l);let V=n=>e.nameOf.get(n)??X.get(e.tipOf(n))??null,Z=n=>{let l=f[n];if(l)return q[n]??V(l);if(e.names.has(n))return e.resolve(n)?n:null;let c=e.resolve(n);return c?V(e.tipOf(c.cid)):null};for(let n of i.tests??[]){for(let D of n.reuses??[])W.has(D)&&h.push({code:"REUSES_EVICTED",detail:`${n.temp_ref}: reuses '${D}' which was budget-evicted \u2014 drop the edge; the dependent gap names the missing @import (D16)`});let l=n.test_md_blob,c=n.definitionId,w=n.objectives_blob;if(s.finalizeTestBody){let D;try{D=s.finalizeTestBody({temp_ref:n.temp_ref,test_md_blob:n.test_md_blob,verifies:n.verifies,reuses:n.reuses??[]},Z)}catch(T){return ne([{code:"FINALIZE_BODY",detail:`${n.temp_ref}: ${T instanceof Error?T.message:String(T)}`}])}D&&(l=D.test_md_blob,c=D.definitionId,w=D.objectives_blob??w,F[n.temp_ref]=c)}let _={title:n.title,check:n.check,definitionId:c,derived:!0,...n.config?{config:n.config}:{},...l?{test_md_blob:l}:{},...w?{objectives_blob:w}:{},...n.surface_required!==void 0?{surface_required:n.surface_required}:{}},B=U(S.TEST,n.temp_ref,_,n.title);if(!B)continue;let Q=j(n.automates,`${n.temp_ref}.automates`,S.SCENARIO);Q&&M(E.AUTOMATES,B,Q,{},`${n.temp_ref}.automates`);for(let D of n.verifies){let T=j(D,`${n.temp_ref}.verifies`,S.AC);T&&M(E.VERIFIES,B,T,{},`${n.temp_ref}.verifies`)}for(let D of n.reuses??[]){if(W.has(D))continue;let T=j(D,`${n.temp_ref}.reuses`,S.TEST);T&&M(E.REUSES,B,T,{},`${n.temp_ref}.reuses`)}for(let D of n.verifies){let T=f[D]??e.resolve(D)?.cid;T&&(e.trust.get(T)??"derived")==="derived"&&!O.some(g=>g.cid===T)?P.push(`${n.temp_ref}: verifies ${D} which is still DERIVED (unapproved) \u2014 committed anyway; approve it in chat or via review`):T&&f[D]===T&&(i.acs??[]).some(g=>g.temp_ref===D)&&P.push(`${n.temp_ref}: verifies ${D} minted in this same record (unapproved) \u2014 committed anyway; approve it in chat`)}if(n.verifies.length>1){let D=n.check?.verified_against;P.push(`${n.temp_ref}: verifies ${n.verifies.length} ACs but machine-asserts only 1 (check.verified_against=${D!=null?String(D):"?"}) \u2014 the rest ride prose only`)}}let ce=[];{let n=(g,v)=>`${g??""}\0${ie(String(v??""))}`,l=(g,v)=>s.reason?`${s.reason} \u2014 evolve by ${a.id}${v?` (${v})`:""}`:g,c=new Map;for(let g of O){if(g.label!==S.SCENARIO&&g.label!==S.TEST)continue;let v=n(g.label,g.content.title);c.set(v,[...c.get(v)??[],g.cid])}let w=new Map;for(let g of r){if(A.has(g))continue;let v=n(e.nodeLabel.get(g),e.getNode(g)?.content.title);w.set(v,[...w.get(v)??[],g])}for(let[g,v]of w){let k=c.get(g)??[],G=v.length===1&&k.length===1;for(let z of v)G?(y.push({kind:"node",old:z,new:k[0],reason:l(`--force redesign of ${s.ucRef} by ${a.id} (title-matched successor)`,"title-matched successor"),by:a}),ce.push({old:z,next:k[0]})):y.push({kind:"node",old:z,new:null,reason:l(`--force redesign of ${s.ucRef} by ${a.id}`),by:a}),I.push(z)}let _=g=>e.edgesFrom(g).some(v=>v.type!==E.SCOPED_TO?!1:v.dst===x||e.tipOf(v.dst)===x?!0:e.nodeLabel.get(v.dst)===S.SCENARIO&&e.edgesFrom(v.dst).some(k=>k.type===E.BELONGS_TO&&e.tipOf(k.dst)===x)),B=new Map;for(let{cid:g,content:v}of e.byLabel(S.AC)){if(e.superseded.has(g)||!_(g))continue;let k=ie(String(v.text??""));B.set(k,[...B.get(k)??[],g])}let Q=new Map;for(let g of O){if(g.label!==S.AC)continue;let v=ie(String(g.content.text??""));Q.set(v,[...Q.get(v)??[],g.cid])}for(let[g,v]of B){let k=Q.get(g)??[];v.length!==1||k.length!==1||(y.push({kind:"node",old:v[0],new:k[0],reason:l(`AC re-emitted with changed content by ${a.id} (text-matched successor)`,"AC text-matched successor"),by:a}),ce.push({old:v[0],next:k[0]}),I.push(v[0]))}let D=new Set(I),T=new Set;for(let g of y)g.kind==="edge"&&T.add(g.ecid);for(let{old:g,next:v}of ce)for(let k of e.edgesInto(g))we(k.type)?.pin?.comparesTo!=="dst_tip"||e.superseded.has(k.src)||D.has(k.src)||T.has(k.ecid)||(y.push({kind:"edge",ecid:k.ecid,reason:`re-blessed onto ${v} (redirect successor of ${g}) by ${a.id}`,by:a}),T.add(k.ecid),m.some(z=>z.type===k.type&&z.src===k.src&&z.dst===v)||e.edgesFrom(k.src).some(z=>z.type===k.type&&z.dst===v))||k.type===E.AUTOMATES&&o.has(v)||M(k.type,k.src,v,k.props,`rebless ${k.type} from ${e.nameOf.get(k.src)??k.src}`)}return h.length>0?ne(h):O.length===0&&m.length===0&&y.length===0&&L.length===0?Object.keys(f).length>0?(P.push("everything in this phase is already current \u2014 nothing re-committed"),{record:null,errors:null,minted:f,logicalIds:q,superseded:[],warnings:P,finalizedTests:F,...s.force||s.forceScope?{forceScopeRemaining:u}:{}}):ne([{code:"EMPTY_DESIGN",detail:"finalize_design produced nothing to commit"}]):{record:$e(t,{ts:new Date().toISOString(),proposal_id:null,nodes:O,edges:m,review:[],supersessions:y,source_head_moves:{},...C.length>0?{names:C}:{},...(()=>{for(let n of i.judgements??[]){let l=n.target?f[n.target]??e.resolve(n.target)?.cid??x:x;L.push({about:l,rationale:`[${n.kind}] ${n.rationale}`,by:a})}return L.length>0?{judgements:L}:{}})(),design_of:{uc_cid:x,engine:d}}).record,errors:null,minted:f,logicalIds:q,superseded:I,warnings:P,finalizedTests:F,...s.force||s.forceScope?{forceScopeRemaining:u}:{}}}import{existsSync as st,mkdirSync as lt,readdirSync as ut,readFileSync as nt,renameSync as mt,writeFileSync as gt}from"fs";import{join as oe}from"path";var pt=/^@import\s+(\S+)\s*$/;function ft(s){return oe(s,".testmuai","tests")}function ht(s){let t=new Map;if(!st(s))return t;for(let e of ut(s)){if(!e.endsWith("_test.md"))continue;let i=oe(s,e);try{let a=le(nt(i,"utf8"))?.id;a&&t.set(a,[...t.get(a)??[],i])}catch{}}return t}function _t(s,t){let e=`${s}.tmp-mint`;gt(e,t),mt(e,s)}function it(s){let{graph:t,cids:e,cwd:i}=s,a=ft(i),d=[],R=[],N=ht(a),x=new Set,h=(m,y)=>{let C=N.get(m);if(C&&C.length>1)return R.push({id:m,reason:`two files claim assurance.id ${m}: ${C.join(" \xB7 ")} \u2014 resolve the duplicate first`}),null;if(x.has(m))return O(m);if(y.includes(m))return O(m)??`${m}_test.md`;let L=t.resolve(m),f=L?t.getNode(L.tip):void 0,q=f?.content.test_md_blob,F=f?.content.definitionId;if(!q||!F)return R.push({id:m,reason:`${m} has no test definition in the graph`}),null;let I=q.split(`
341
+ `).map(o=>{let r=pt.exec(o.trim());if(!r)return o;let u=r[1];if(!t.resolve(u))return o;let A=h(u,[...y,m]);if(!A)throw new ae(`dependency ${u} could not be minted/located`);return`@import ./${A}`}).join(`
342
+ `),b=`---
343
+ assurance:
344
+ id: ${m}
345
+ base: ${F}
346
+ ---
347
+ ${I.endsWith(`
348
+ `)?I:I+`
349
+ `}`,p=C?.[0];if(p){let o=nt(p,"utf8"),r=le(o)?.base,u=ee(J(o,ye(a,t)));if(!r||u!==r)return R.push({id:m,reason:`${p} was edited since the engine last wrote it \u2014 keeping yours (reconcile via a run or maintain)`}),null}else{let o=oe(a,`${m}_test.md`);for(let r=2;st(o);r++)o=oe(a,`${m}-${r}_test.md`);p=o}return lt(a,{recursive:!0}),_t(p,b),x.add(m),N.set(m,[p]),d.push({id:m,path:p}),p.split("/").pop()},O=m=>N.get(m)?.[0]?.split("/").pop()??null;for(let m of e){let y=t.nameOf.get(m);if(!y){R.push({id:m,reason:"minted test has no logical id"});continue}try{h(y,[])}catch(C){if(C instanceof ae)R.push({id:y,reason:C.message});else throw C}}return{wrote:d,refused:R}}var ae=class extends Error{};import{dirname as bt,relative as yt,resolve as vt}from"path";var wt=new Set(["narrative","acs","scenarios","tests","exercises","gaps","scoped_to_repoints","judgements","phase"]);function St(s){let t=/strength=(\d+)\s*(?:—|-)?\s*(.*)/.exec(s??"");return t?{strength:Number(t[1]),reason:t[2]||s||""}:{strength:2,reason:s??""}}function kt(s,t,e=new Set,i=0){return J(t,re(s),e,i)}function xt(s,t,e,i){let a=t.scenarios?.find(m=>m.temp_ref===e.automates)??(()=>{let m=s.resolve(e.automates),y=m?s.getNode(m.tip)?.content:void 0;return y?{title:String(y.title??""),intent:String(y.intent??""),technique_notes:String(y.technique_notes??"")}:{}})(),d=[...(t.acs??[]).map(m=>({ref:m.temp_ref,text:m.text})),...e.verifies.filter(m=>!(t.acs??[]).some(y=>y.temp_ref===m)).map(m=>{let y=s.resolve(m);return{ref:m,text:y?String(s.getNode(y.tip)?.content.text??""):""}})],{test_md:R,objectives_yaml:N}=be({title:e.title,steps:e.steps,check:e.check,check_prose:e.check_prose,reuses:e.reuses},{title:a.title,intent:a.intent},d),x=ee(kt(s,R)),h=e.check,O={technique:a.technique_notes??"",profile_family:t.judgements?.find(m=>m.kind==="profile_family"&&(m.target===e.temp_ref||m.target===e.automates))?.rationale??"unspecified",anchor:h.verified_against,expected_how:t.judgements?.find(m=>m.kind==="expected_how"&&m.target===h.verified_against)?.rationale??`expected_mode: ${h.expected_mode??"inferred"}`,combinatorial:St(a.technique_notes),surface_state:"absent",deferred_bindings:h.expected_mode==="runtime-derived"?1:0};return i.push({definitionId:x,rationale:O,anchorRef:h.verified_against,tempRef:e.temp_ref}),{temp_ref:e.temp_ref,title:e.title,automates:e.automates,verifies:e.verifies,check:e.check,definitionId:x,test_md_blob:R,objectives_blob:N,...e.reuses?.length?{reuses:e.reuses}:{},...e.surface_required!==void 0?{surface_required:e.surface_required}:{}}}function rt(s){let t=0,e=s.forceScope??null;return{terminalEventType:"design",async onProposalEvent(i){let a=r=>s.steer?(s.steer(`[auto-repair] ${r} \u2014 please re-finalize with this fixed.`),{proposal:null,error:null}):{proposal:null,error:r};if(i==null||typeof i!="object")return a("finalize_design payload is not an object");let d=i,R=Object.keys(d).filter(r=>!wt.has(r));if(R.length>0)return a(`finalize_design carries ungated/unknown section(s): ${R.join(", ")} \u2014 mintable here: acs, scenarios, tests (+gaps)`);let N=new Map;for(let r of d.tests??[]){let u=N.get(r.automates);if(u)return a(`strict 1:1 violated in-payload: ${u} and ${r.temp_ref} both automate ${r.automates}`);N.set(r.automates,r.temp_ref)}let x=Y(s.contextDir);s.force&&!s.resuming&&t===0&&e===null&&(e=fe(x,s.ucRef));let h=x.resolve(s.ucRef),O=h?String(x.getNode(h.tip)?.content.risk??"med"):"med",m=[],y=new Set([s.ucRef,h?.cid,h?.tip].filter(Boolean)),C=r=>{if(y.has(r))return!0;let u=x.resolve(r);return u!=null&&(y.has(u.cid)||y.has(u.tip))},L;try{L={...d.acs?.length?{acs:d.acs.map(r=>({temp_ref:r.temp_ref,text:r.text,kind:r.kind,risk:r.risk??O,...r.expected_answer?{expected_answer:r.expected_answer}:{},...r.scoped_to&&!C(r.scoped_to)?{scope:{type:"scenario",ref:r.scoped_to}}:{}}))}:{},...d.scenarios?.length?{scenarios:d.scenarios}:{},...d.tests?.length?{tests:d.tests.map(r=>xt(x,d,r,m))}:{},...d.exercises?.length?{exercises:d.exercises}:{},...d.gaps?.length?{gaps:d.gaps}:{},...d.scoped_to_repoints?.length?{scoped_to_repoints:d.scoped_to_repoints}:{},...d.judgements?.length?{judgements:d.judgements}:{}}}catch(r){return a(r instanceof Error?r.message:String(r))}let f=tt({contextDir:s.contextDir,graph:x,ucRef:s.ucRef,sections:L,by:s.by,...s.engine?{engine:s.engine}:{},...e?.length?{forceScope:e}:{},...s.because?{reason:s.because}:{},finalizeTestBody:(()=>{let r=new Map((L.tests??[]).map($=>[$.temp_ref,$])),u=new Map,A=($,j,H)=>{let U=r.get($);if(!U?.test_md_blob)return null;let M=u.get($);if(M!==void 0)return M;if(H.has($))return U.test_md_blob;H.add($);let W=new Map;for(let V of U.reuses??[]){A(V,j,H);let Z=j(V);Z!==null&&Z!==V&&W.set(V,Z)}let K=U.verifies.map(j).filter(V=>V!==null),X=he(_e(U.test_md_blob,W),K);return u.set($,X),X};return($,j)=>{if(!$.test_md_blob)return null;let H=A($.temp_ref,j,new Set)??$.test_md_blob;if(H===$.test_md_blob)return null;let U=M=>{for(let W of r.keys())if(j(W)===M){let K=A(W,j,new Set);if(K!==null)return{body:K,cycleKey:`batch:${M}`,next:U}}return re(x)(M)};return{test_md_blob:H,definitionId:ee(J(H,U))}}})()});if(f.errors)return a("design commit failed: "+f.errors.map(r=>`${r.code}: ${r.detail}`).join("; "));let q=f.warnings.filter(r=>r.includes("\u2014 committed anyway; approve"));for(let r of f.warnings)(!q.includes(r)||q.length===1)&&s.note(`warning: ${r}`);q.length>1&&s.note(`warning: ${q.length} verifies edges target not-yet-approved items \u2014 committed anyway; approve them in chat or via review`);let F=(r,u)=>r?`${r} ${u}${r>1?"s":""}`:null,P=[F(d.acs?.length,"AC"),F(d.scenarios?.length,"scenario"),F(d.tests?.length,"test"),F(d.gaps?.length,"gap")].filter(Boolean);s.note(`committed ${P.join(" \xB7 ")||"judgements/wiring"} (derived) \u2014 approvals promote via chat`),s.aliases?.(Object.entries(f.minted).map(([r,u])=>({ref:r,cid:u})));let I=Y(s.contextDir);s.onCommitted?.(I);for(let r of m){let u=f.logicalIds[r.anchorRef]??f.minted[r.anchorRef];Ge(s.contextDir,f.finalizedTests[r.tempRef]??r.definitionId,{...r.rationale,anchor:u??r.rationale.anchor})}try{let r=Object.values(f.minted).filter(u=>I.getNode(u)?.label==="test");if(r.length>0){let u=bt(vt(s.contextDir)),A=it({graph:I,cids:r,cwd:u});A.wrote.length>0&&s.note(`wrote: ${A.wrote.map($=>yt(u,$.path)).join(" \xB7 ")}`);for(let $ of A.refused)s.note(`warning: mint refused ${$.id} \u2014 ${$.reason}`)}}catch(r){s.note(`warning: file mint failed (${r instanceof Error?r.message:String(r)}) \u2014 the design commit stands`)}s.event?.({type:"commit",acs:d.acs?.length??0,scenarios:d.scenarios?.length??0,tests:d.tests?.length??0,gaps:d.gaps?.length??0,warnings:f.warnings.length,minted:Object.entries(f.minted).map(([r,u])=>({temp_ref:r,cid:u,...f.logicalIds[r]?{logical_id:f.logicalIds[r]}:{}}))}),t+=1,e!==null&&(e=f.forceScopeRemaining??e,s.onForceScope?.(e));let b=Ce({verb:"design",commitN:t,ucRef:s.ucRef,phase:d.phase??(d.tests?.length?"tests":d.scenarios?.length?"scenarios":d.acs?.length?"acs":"design"),committed:Object.entries(f.minted).map(([r,u])=>({temp_ref:r,cid:u,...f.logicalIds[r]?{logical_id:f.logicalIds[r]}:{}})),warnings:f.warnings},I),p=b.event.parity?.missing??[],o=!!d.tests?.length&&p.length===0;return{proposal:f,error:null,receipt:b,...o?{sessionComplete:o}:{}}}}}function ot(s,t){return{type:"run_config",version:1,session_id:t.session_id,mode:t.mode,source:{source_id:`design:${s.usecase.logical_id??t.ucCid.slice(0,19)}`,source_cid:t.ucCid,kind:"design_context",numbered_text:et({...s,session_mode:t.mode})},existing_use_cases:[],read_basis:t.readBasis,max_free_text_rounds:2,graph_reads:!0,verb:"design",chat:!0,design_budget:s.budget,topology:t.topology}}function Rt(s,t){return{terminalEventType:"design",async onProposalEvent(e){let i=e??{},a=["acs","scenarios","tests","gaps"].map(d=>i[d]?.length?`${i[d].length} ${d}`:null).filter(Boolean).join(" \xB7 ");return s(`plan: finalize_design \u2014 ${a||"wiring/judgements only"} (nothing committed)`),s(JSON.stringify(i,null,2)),t?.({type:"plan",payload:i}),{proposal:i,error:null}}}}async function Cs(s,t){let e=Y(t.contextDir),i=null,a=s.useCase;if(s.resume){try{let u=Le(t.contextDir,s.resume,e);i=u.handle,u.staleBasis.length>0&&(t.out(`note: sources changed since the pause: ${u.staleBasis.join(", ")} \u2014 the design continues against the current versions`),t.emit?.({type:"stale_basis",sources:u.staleBasis}))}catch(u){if(u instanceof Ne)return t.out(`error: ${u.message}`),t.emit?.({type:"error",message:`error: ${u.message}`}),u.code==="SESSION_MISSING"||u.code==="SESSION_EXPIRED"?2:1;throw u}let o=i.state;if(o.verb&&o.verb!=="design")return t.out(`error: session ${s.resume} is a ${o.verb} session \u2014 resume it with kane-cli context extract --resume ${s.resume}`),t.emit?.({type:"error",message:`error: session ${s.resume} is a ${o.verb} session \u2014 resume it with kane-cli context extract --resume ${s.resume}`}),i.release(),2;if(a=a??o.use_case,o.uc_tip&&a){let u=e.resolve(a)?.tip;u&&u!==o.uc_tip&&(t.out("note: the use-case changed since the pause \u2014 the design continues against the new version"),t.emit?.({type:"stale_basis",usecase:a}))}let r=i.state.held_receipts??[];if(r.length>0)if(t.chat?.holdReceipt)for(let u of r)t.chat.holdReceipt(u);else t={...t,initialMessage:[r.join(`
350
+
351
+ `),t.initialMessage].filter(Boolean).join(`
352
+
353
+ `)};if(!a)return t.out(`error: session ${s.resume} predates use-case persistence \u2014 re-supply --use-case <ref>`),t.emit?.({type:"error",message:`error: session ${s.resume} predates use-case persistence \u2014 re-supply --use-case <ref>`}),i.release(),2}let d=!!(s.force||i?.state.force),R=!!(s.resume&&i),N=Me(e,a,d||R);if(!N.ok)return t.out(`design: ${N.message}`),t.emit?.({type:"gate_refused",message:N.message}),i?.release(),N.code;if(t.preflightTurn){let o=await t.preflightTurn();if(!o.ok)return t.out(o.message??"error: turn-endpoint preflight failed"),t.emit?.({type:"error",message:o.message??"error: turn-endpoint preflight failed",code:"PREFLIGHT"}),i?.release(),2}let x={contextDir:t.contextDir,resolveAlias:o=>Te(o,{env:process.env,auth:t.auth}),embed:(o,r)=>Oe(o,r,{env:process.env,auth:t.auth})};t.chat?.setWorking?.("assembling context\u2026");let h=await Ze(t.contextDir,a,{max:s.max,strength:s.strength,embedSearch:x});s.priorDesign!==void 0&&(h.prior_design=s.priorDesign),s.changeDelta!==void 0&&(h.change_delta=s.changeDelta),s.because&&(h.because=s.because);let O=t.now?.()??new Date,m=`${O.toISOString().replace(/[-:]/g,"").slice(0,15)}-${Dt(2).toString("hex")}`,y=s.mode??"interactive",C=ot(h,{session_id:s.resume??`design-${m}`,mode:y,ucCid:h.usecase.cid,readBasis:e.latestHash,topology:Fe("design")});s.plan?C.chat=!1:C.chat=!0,s.resume&&i&&(C.resume={agent_state:i.state.agent_state},t.out(`resuming design session ${s.resume}`),i.state.assumed.length>0&&t.out(`note: ${i.state.assumed.length} default(s) were assumed while you were away \u2014 kane-cli context sessions show ${s.resume} lists them`),s.message&&(t={...t,initialMessage:[t.initialMessage,s.message].filter(Boolean).join(`
354
+
355
+ `)}));let L=at(t.contextDir,"logs");$t(L,{recursive:!0});let f=at(L,`design-${m}.log`);t.out(`trace: ${f}`),t.emit?.({type:"run_start",mode:y,trace:f,use_case:a});let q=(o,r,u)=>{try{Et(f,JSON.stringify({ts:new Date().toISOString(),kind:o,session_id:u,data:r})+`
356
+ `)}catch{}},F=null,P={current:e};t.chat?.attachOnCommitted?.(o=>{P.current=o});let I="";if(t.chat&&!s.plan){let o=Re({contextDir:t.contextDir,graph:Y(t.contextDir),sessionStamp:C.session_id,by:t.by??{kind:"human",id:"owner"}});o.errors===null||o.errors[0]?.code==="CONV_SOURCE_EXISTS"?(I=o.sourceId,t.chat.attachConversationSource?.(I),P.current=Y(t.contextDir)):t.out(`warning: conversation source unavailable (${o.errors[0]?.detail}) \u2014 chat adds will not land this session`)}let b=s.plan?Rt(t.out,t.emit):rt({contextDir:t.contextDir,ucRef:a,by:{kind:"ai",id:"design-agent"},force:d,engine:"design@1",note:o=>t.chat?t.chat.note(o):t.out(o),steer:t.chat?o=>t.chat.submit(o):void 0,event:t.emit,resuming:R,...i?.state.force_scope?.length?{forceScope:i.state.force_scope}:{},onForceScope:o=>{F=o},...s.because?{because:s.because}:{},aliases:t.chat?o=>t.chat.registerAliases?.(o):void 0,onCommitted:o=>{P.current=o}});t.out(`designing: ${h.usecase.logical_id??a} (budget ${h.budget.max_pairs!=null?`${h.budget.max_pairs} pairs`:"no ceiling"}${h.budget.strength_override?`, strength ${h.budget.strength_override}`:""})`),t.chat?.setWorking?.(`designing ${h.usecase.logical_id??a}\u2026`);let p;try{p=await Ie(C,{...t,graphSlot:P},new Map,e,q,b)}catch(o){throw q("error",{message:o instanceof Error?o.message:String(o),stack:o instanceof Error?o.stack:void 0},C.session_id),i?.release(),o}finally{t.chat?.setWorking?.(null)}if(p.highRisk)return t.out(`error: ${p.highRisk.length} high-risk decision${p.highRisk.length===1?"":"s"} need a human \u2014 ci mode won't guess. Re-run with --mode agent to pause for review.`),t.emit?.({type:"error",message:`error: high-risk question(s) in ci mode (fail-closed): ${p.highRisk.map(o=>o.id).join(", ")}`,code:"HIGH_RISK_CI"}),i?.release(),1;if(p.paused){let o=i;o||(o=qe(t.contextDir,{sid:C.session_id,mode:"agent",created_at:O.toISOString(),expires_at:new Date(O.getTime()+1440*60*1e3).toISOString(),agent_state:p.paused.agent_state,pending:{questions:[],proposals:[]},read_basis:Object.fromEntries((e.resolve(a)?e.edgesInto(e.resolve(a).tip):[]).filter($=>$.type==="DERIVES"&&typeof $.props.source_id=="string").map($=>[String($.props.source_id),e.heads.get(String($.props.source_id))??null])),assumed:[],corpus_cursor:{remaining:[]},conv_source:I,verb:"design",use_case:a,...e.resolve(a)?.tip?{uc_tip:e.resolve(a).tip}:{},...d?{force:!0}:{}})),d&&!o.state.force&&o.save({force:!0}),I&&o.state.conv_source!==I&&o.save({conv_source:I});let r=t.chat?.drainHeldReceipts?.()??[];(r.length>0||(o.state.held_receipts?.length??0)>0)&&o.save({held_receipts:r}),F!==null&&o.save({force_scope:F}),Be(o,p.paused),q("session_paused",{sid:o.state.sid},C.session_id);let u=y!=="interactive"?` --mode ${y}`:"",A=`kane-cli design tests --resume ${o.state.sid}${u}`;return t.out(`paused \u2014 resume with: ${A}`),t.emit?.({type:"session_paused",sid:o.state.sid,mode:y,resume:A,expires_at:o.state.expires_at,pending_questions:p.paused.pending.questions}),t.chat?.ledger?.({kind:"pause",sid:o.state.sid,expires_at:o.state.expires_at,resume:A,messageForm:`${A} --message "<your words>"`}),3}if(p.error)return t.out(`error: design agent failed: ${p.error}`),t.emit?.({type:"error",message:`error: design agent failed: ${p.error}`}),i?.release(),1;if(p.proposal==null&&y!=="interactive")return t.out(`error: the design agent ended without a finalize event \u2014 nothing committed (trace: ${f})`),t.emit?.({type:"error",message:`error: the design agent ended without a finalize event \u2014 nothing committed (trace: ${f})`}),i?.release(),1;p.proposal==null&&t.out("done \u2014 nothing designed this session (no finalize before the session ended)"),p.assumedDefaults&&t.out(`assumed: ${p.assumedDefaults} default(s) auto-taken (flagged)`),i&&t.emit?.({type:"session_complete",sid:s.resume}),i?.complete();{let o=t.chat?.state.ledger.filter(A=>A.kind==="answer"&&A.receipt.form==="assumed").length??0,r=(p.assumedDefaults??0)+o,u=t.chat?.state.credits?.total??p.creditsTotal;t.chat?.ledger?.({kind:"summary",lines:[`designed: ${h.usecase.logical_id??a}${p.proposal==null?" (nothing committed this session)":""}`,...r>0?[`${r} assumed default(s)`]:[],...u!==void 0?[`credits used: ${u.toFixed(1)}`]:[],`trace: ${f}`]})}return s.plan||Pe(t.contextDir),0}export{Cs as a};
@@ -0,0 +1,6 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{b as G,c as P,e as J,h as q,i as z,j as Q,m as V,n as X,o as T}from"./chunk-RKWJG3WW.js";import{e as U}from"./chunk-NFOBDHZK.js";import{copyFileSync as ae,cpSync as le,existsSync as w,mkdirSync as ue,readFileSync as je,readdirSync as pe,rmSync as Fe,writeFileSync as Oe}from"fs";import{dirname as Te,isAbsolute as _e,join as R,relative as Le,resolve as Ae}from"path";import{writeFileSync as ge,mkdirSync as Se,readFileSync as Re}from"fs";import{dirname as Ie,basename as Y}from"path";function ee(e){let t=e.outPath??P(e.sourcePath);Se(Ie(t),{recursive:!0});let r=[];r.push("---"),r.push(`test: ../${Y(e.sourcePath)}`),r.push(`status: ${e.overallStatus}`),r.push(`started: ${e.startedISO}`),r.push(`duration_s: ${e.durationS}`),r.push(`session_id: ${e.sessionId}`),r.push("---",""),r.push(`# ${e.title??Y(e.sourcePath)} \u2014 Result`,"");for(let l=0;l<e.rootSteps.length;l++){let a=e.rootSteps[l],i=e.outcomes.find(p=>p.rootStepIndex===l+1);if(r.push(xe(a,i)),i?.stepMd5&&r.push(`md5: ${i.stepMd5}`),i?.status==="failed"&&i.reason&&r.push(`Reason: ${i.reason}`),i?.softFailures?.length)for(let p of i.softFailures){let o=p.reason?`: ${p.reason}`:"";r.push(`\u26A0 optional sub-step ${p.subStepIndex} failed${o}`)}a.body.kind==="objective"&&i?.status!=="skipped"&&r.push(a.body.text),r.push("")}return ge(t,r.join(`
3
+ `),"utf8"),t}function xe(e,t){if(!t)return`## ${e.heading} (no outcome)`;let r=t.duration_s!=null?`${t.duration_s}s`:"\u2014";if(t.status==="skipped")return`## ${e.heading} \u23ED skipped`;let l=t.softFailed?" (optional)":"";if(t.refKind&&t.status==="passed"){let a=t.helperResultRelPath?` \u2192 ${t.helperResultRelPath}`:"";return`## ${e.heading} \u2713 passed (via @${t.refKind} ${t.refLabel} \u2014 ${t.inlinedCount} inlined steps, ${r}${a})`}if(t.refKind&&t.status==="failed"){let a=t.failedSubStepIndex&&t.failedSubStepIndex.length>0?` \u2014 at sub-step ${t.failedSubStepIndex.join(" \u2192 sub-step ")}`:"",i=t.helperResultRelPath?` \u2192 ${t.helperResultRelPath}`:"";return`## ${e.heading} \u2717 failed${l} (via @${t.refKind} ${t.refLabel}${a}, ${r}${i})`}return t.status==="passed"?`## ${e.heading} \u2713 passed (${r})`:`## ${e.heading} \u2717 failed${l} (${r})`}var ye=/^##\s+(.+?)\s+(✓ passed|✗ failed(?:\s+\(optional\))?|⏭ skipped)(?:\s+\((.*)\))?\s*$/,be=/via\s+@\w+\s+(\S+).*?(?:→\s+(\S+))?\s*$/,ke=/^md5:\s+([a-f0-9]{32})\s*$/;function Z(e,t){for(let r=t;r<e.length&&!/^##\s/.test(e[r]);r++){if(e[r].trim()==="")continue;let l=ke.exec(e[r]);return l?l[1]:null}return null}function $(e){let r=Re(e,"utf8").split(`
4
+ `),l="passed";if(r[0]?.trim()==="---")for(let i=1;i<r.length&&r[i].trim()!=="---";i++){let p=/^status:\s+(passed|failed|interrupted)\s*$/.exec(r[i]);p&&(l=p[1])}let a=[];for(let i=0;i<r.length;i++){let p=ye.exec(r[i]);if(!p)continue;let o=p[1],s=p[2],c=p[3]??"",m=s.startsWith("\u2713")?"passed":s.startsWith("\u23ED")?"skipped":"failed";if(/via\s+@/.test(c)){let f=be.exec(c),b=f?.[1]??"",g=f?.[2]??null;a.push({kind:"import",heading:o,status:m,md5:Z(r,i+1),importPath:b,helperResultRelPath:g})}else a.push({kind:"objective",heading:o,status:m,md5:Z(r,i+1)})}return{overallStatus:l,steps:a}}import{copyFileSync as te,existsSync as N,mkdirSync as ve,writeFileSync as se,promises as Be}from"fs";import{join as D,dirname as re,basename as Pe}from"path";async function ne(e){for(let t=0;t<e.totalRunDirs;t++){let r=e.runIndex+t,l=D(e.sessionDir,"runs",String(r)),a=D(e.stagingStepDir,"flows",String(t));ve(a,{recursive:!0});let i=D(a,"actions.ndjson");if(e.packTestDir){let s=D(e.packTestDir,"logs",`${r}-actions.ndjson`);if(N(s)){te(s,i);continue}let c=re(re(e.packTestDir)),m=Pe(e.packTestDir),I=N(c)?await U(c,`tests/${m}/logs/${r}-actions.ndjson`).catch(()=>null):null;se(i,I??"");continue}let p=[D(l,"run-test","actions.ndjson"),D(l,"actions.ndjson")],o=!1;for(let s of p)if(N(s)){te(s,i),o=!0;break}o||se(i,"")}}import{existsSync as K}from"fs";import{dirname as we,join as j,basename as H}from"path";function Ye(e){let t=[],r=new Set,l=new Map;function a(s){if(l.has(s))return l.get(s);let c=P(s),m=K(c)?$(c):null;return l.set(s,m),m}let i=new Map;function p(s){if(i.has(s))return i.get(s);let c=j(s,"Result.md"),m=K(c)?$(c):null;return i.set(s,m),m}function o(s){for(let c=1;c<s.trace.length;c++){let m=s.trace[c-1],I=a(m.file);if(!I)continue;let f=I.steps[m.stepIndex-1];if(f){if(f.kind!=="import")return{kind:"author",reason:"structure-mismatch"};if(H(f.importPath)!==H(s.trace[c].file))return{kind:"author",reason:"structure-mismatch"};if(f.md5!=null&&f.md5!==m.rowMd5)return{kind:"author",reason:"structure-mismatch"}}}return null}for(let s of e.steps){let c=s.trace[s.trace.length-1].stepIndex,m=r.has(s.owningFile);for(let g=0;g<s.trace.length-1&&!m;g++)r.has(s.trace[g].file)&&(m=!0);if(m){t.push({kind:"author",reason:a(s.owningFile)===null?"no-result-md":"downstream-of-divergence"});continue}let I=o(s);if(I){t.push(I);for(let g=0;g<s.trace.length;g++)r.add(s.trace[g].file);continue}let f=a(s.owningFile),b;if(f===null&&s.trace.length>1){let g=W(s.trace);b=ie(s,p(g),c,g)}else b=ie(s,f,c);if(t.push(b),b.kind==="author"){r.add(s.owningFile);for(let g=0;g<s.trace.length-1;g++)r.add(s.trace[g].file)}}return t}function ie(e,t,r,l=null){if(!t)return{kind:"author",reason:"no-result-md"};let a=t.steps[r-1];if(!a)return{kind:"author",reason:"no-result-md"};if(a.kind!=="objective")return{kind:"author",reason:"structure-mismatch"};if(a.status!=="passed")return{kind:"author",reason:"recorded-failed"};let i=T(e);if(i!==a.md5)return{kind:"author",reason:"md5-mismatch"};let p=l===null?Q(e.owningFile,r,i.slice(0,8)):j(l,".internal","steps",`${r}-${i.slice(0,8)}`),o=j(p,"flows","0","actions.ndjson");return K(o)?{kind:"replay",recordingDir:p}:{kind:"author",reason:"missing-recording"}}function Ze(e){return e.some(t=>t.kind==="author")}function et(e){for(let t=0;t<e.length;t++)if(e[t].kind==="author")return t;return e.length}function W(e){let t=i=>{let p=H(i);return p.endsWith("_test.md")?p.slice(0,-8):p.endsWith(".md")?p.slice(0,-3):p},r=t(e[0].file),l=t(e[e.length-1].file),a=e.slice(0,-1).map(i=>String(i.stepIndex));return j(we(e[e.length-1].file),`helper-output-${l}-${r}-${a.join("-")}`)}function tt(e){return j(e.recordingDir,"flows","0","actions.ndjson")}import{existsSync as oe,mkdirSync as $e,rmSync as De,cpSync as Me}from"fs";function de(e,t){oe(e)&&(oe(t)&&De(t,{recursive:!0,force:!0}),$e(t,{recursive:!0}),Me(e,t,{recursive:!0}))}async function mt(e){let t=new Map;for(let o of e.stepRunRecords)t.set(o.testmdStepIndex,o);let r=e.authoredFlatIdx??new Set,l=[],a=[],i=new Map,p=o=>{if(i.has(o))return i.get(o);let s=R(o,"Result.md"),c=w(s)?$(s):null;return i.set(o,c),c};for(let o of e.resolvedTest.unitFiles){let s=o.file===e.resolvedTest.rootPath,c=V(o.file,je(o.file,"utf8")),m=P(o.file),I=w(m)?$(m):null,f=[],b=[],g=[],M=[];if(!s)for(let d of e.resolvedTest.steps){if(d.owningFile!==o.file||d.trace.length<2)continue;let n=W(d.trace);M.includes(n)||M.push(n)}let F=d=>{if(I!==null)return null;for(let n of M){let v=p(n)?.steps[d-1];if(v)return{row:v,dir:n}}return null},C=[],_=!1,B=!1,L=!1,A=!1;for(let d of c.steps){let n=d.index,u=I?.steps[n-1];if(d.body.kind==="objective"){let h=e.resolvedTest.steps.filter(S=>S.owningFile===o.file&&S.trace[S.trace.length-1].stepIndex===n&&t.has(S.flatIndex)),x=h.length>0?h[h.length-1]:null;if(x){_=!0,r.has(x.flatIndex)&&(B=!0);let S=T(x),y;s?y=e.outcomes.find(he=>he.rootStepIndex===n)??{rootStepIndex:n,status:"skipped"}:y={rootStepIndex:n,status:ce(x,e.outcomes)},y.status==="failed"&&(L=!0),y.stepMd5==null&&(y.stepMd5=S),f.push(y),b.push({stepIndex:n,md5:S,rec:t.get(x.flatIndex)}),(!u||u.kind!=="objective"||u.status!==y.status||y.status==="passed"&&u.md5!==S)&&(A=!0)}else if(u&&u.kind==="objective")f.push({rootStepIndex:n,status:u.status,...u.md5?{stepMd5:u.md5}:{}}),g.push(n);else if(!s&&F(n)?.row.kind==="objective"){let S=F(n),y=S.row;f.push({rootStepIndex:n,status:y.status,...y.md5?{stepMd5:y.md5}:{}}),C.push({psIdx:n,dir:S.dir})}else s?f.push(e.outcomes.find(S=>S.rootStepIndex===n)??{rootStepIndex:n,status:"skipped"}):f.push({rootStepIndex:n,status:"skipped"});continue}let v=_e(d.body.path)?d.body.path:Ae(Te(o.file),d.body.path),O=X({path:d.body.path,bindings:d.body.bindings,optional:d.optional??!1}),me=Le(G(o.file),P(v)),E=e.resolvedTest.steps.filter(h=>h.trace.some((x,S)=>S<h.trace.length-1&&x.file===o.file&&x.stepIndex===n)&&t.has(h.flatIndex));if(E.length>0){_=!0;let h;if(s)h=e.outcomes.find(x=>x.rootStepIndex===n)??{rootStepIndex:n,status:"passed",refKind:"import",refLabel:d.body.path};else{let x=E.some(S=>ce(S,e.outcomes)==="failed");h={rootStepIndex:n,status:x?"failed":"passed",refKind:"import",refLabel:d.body.path,inlinedCount:E.length}}h.status==="failed"&&(L=!0),h.stepMd5==null&&(h.stepMd5=O),h.helperResultRelPath==null&&(h.helperResultRelPath=me),f.push(h),(!u||u.kind!=="import"||u.status!==h.status||u.md5!==O)&&(A=!0)}else if(u&&u.kind==="import")f.push({rootStepIndex:n,status:u.status,refKind:"import",refLabel:u.importPath,...u.md5?{stepMd5:u.md5}:{},...u.helperResultRelPath?{helperResultRelPath:u.helperResultRelPath}:{}});else if(!s&&F(n)?.row.kind==="import"){let h=F(n).row;f.push({rootStepIndex:n,status:h.status,refKind:"import",refLabel:d.body.path})}else s?f.push(e.outcomes.find(h=>h.rootStepIndex===n)??{rootStepIndex:n,status:"skipped",refKind:"import",refLabel:d.body.path}):f.push({rootStepIndex:n,status:"skipped",refKind:"import",refLabel:d.body.path})}if(!(s||_&&(B||L||I===null||A)))continue;l.push(o.file);let k=q(o.file);ue(R(k,".internal"),{recursive:!0});for(let d of b){let n=R(k,".internal","steps",`${d.stepIndex}-${d.md5.slice(0,8)}`);ue(n,{recursive:!0}),await ne({sessionDir:e.sessionDir,runIndex:d.rec.runIndex,totalRunDirs:d.rec.totalRunDirs,stagingStepDir:n,packTestDir:e.packTestDir})}if(g.length>0){let d=z(o.file);if(w(d))for(let n of pe(d)){let u=parseInt(n.split("-")[0]??"",10);!Number.isNaN(u)&&g.includes(u)&&le(R(d,n),R(k,".internal","steps",n),{recursive:!0})}}for(let d of C){let n=R(d.dir,".internal","steps");if(w(n))for(let u of pe(n))parseInt(u.split("-")[0]??"",10)===d.psIdx&&le(R(n,u),R(k,".internal","steps",u),{recursive:!0})}let fe=f.some(d=>d.status==="failed");if(ee({sourcePath:o.file,title:c.title,rootSteps:c.steps,outcomes:f,overallStatus:s?e.overallStatus:fe?"failed":"passed",startedISO:e.startedISO,durationS:s?e.durationS:0,sessionId:e.sessionId,outPath:R(k,"Result.md")}),s){let d={};e.commitId&&(d.commit_id=e.commitId),e.tmsIds.testId&&(d.test_id=e.tmsIds.testId),e.tmsIds.testcaseId&&(d.testcase_id=e.tmsIds.testcaseId),e.tmsIds.projectId&&(d.project_id=e.tmsIds.projectId),e.tmsIds.folderId&&(d.folder_id=e.tmsIds.folderId),e.tmsIds.orgId&&(d.org_id=e.tmsIds.orgId),e.tmsIds.sessionName&&(d.session_name=e.tmsIds.sessionName),Oe(R(k,".internal","meta.json"),JSON.stringify(d,null,2)+`
5
+ `,"utf8");let n=R(e.sessionDir,"execution.json");if(w(n))try{ae(n,R(k,".internal","execution.json"))}catch{}if(e.codeExportDir){let u=e.codeExportLanguage??"python",v=R(k,`playwright-${u}-code`);try{de(e.codeExportDir,v)}catch(O){process.stderr.write(`warn: codegen copy failed: ${O.message}
6
+ `)}}}else if(o.kind==="test"){let d=J(o.file);if(w(d))try{ae(d,R(k,".internal","meta.json"))}catch{}}!s&&M.length>0&&f.every(n=>n.status!=="skipped")&&a.push({unitFile:o.file,dirs:M.filter(n=>w(n))})}return{changedUnitFiles:l,legacySweep:a}}function ht(e){for(let t of e)try{Fe(t,{recursive:!0,force:!0})}catch{}}function ce(e,t){let r=e.trace[0].stepIndex,l=t.find(o=>o.rootStepIndex===r);if(!l)return"skipped";if(l.status==="passed")return"passed";if(l.status==="skipped")return"skipped";let a=e.trace.slice(1).map(o=>o.stepIndex),i=l.failedSubStepIndex??[],p=Math.min(a.length,i.length);for(let o=0;o<p;o++)if(a[o]!==i[o])return a[o]<i[o]?"passed":"skipped";return a.length===i.length?"failed":a.length<i.length?"passed":"skipped"}export{ee as a,Ye as b,Ze as c,et as d,tt as e,de as f,mt as g,ht as h};
@@ -0,0 +1,12 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ var v=()=>!!process.env.KANE_DEV_MODE,r=[],g=!1,m=null,a=null,d=null,s=null,u=[];function h(e){if(s=e,e&&u.length>0){let t=u;u=[];for(let n of t)try{e.log(n.level,n.event,n.message,n.context)}catch{}}}function y(e,t,n,o){if(s){try{s.log(e,t,n,o)}catch{}return}u.push({level:e,event:t,message:n,context:o})}function R(){return s}function w(){return g}function E(e,t){r=r.filter(n=>n.name!==e),r.push({name:e,fn:t})}function $(e){r=r.filter(t=>t.name!==e)}function L(e,t){let n=r.find(i=>i.name===e);if(!n)return;r=r.filter(i=>i.name!==e);let o=!0;try{n.fn()}catch(i){o=!1,process.stderr.write(`[exit-manager] cleanup(${e}) failed: ${i instanceof Error?i.message:String(i)}
3
+ `)}t&&o&&v()&&process.stderr.write(`[exit-manager] cleanup(${e}): ${t}
4
+ `)}function f(e,t,n=!1,o){if(g){process.exit(m??e);return}if(g=!0,m=e,n&&s)try{s.log("error","CRASH",t),s.shutdownSync()}catch{}let i=[...r].reverse(),l=[];for(let c of i)try{c.fn(),l.push(c.name)}catch(p){process.stderr.write(`[exit-manager] cleanup(${c.name}) failed: ${p instanceof Error?p.message:String(p)}
5
+ `)}if(r=[],v()&&(process.stderr.write(`[exit-manager] shutdown(${e}): ${t}
6
+ `),l.length>0&&process.stderr.write(`[exit-manager] cleaned up: ${l.join(", ")}
7
+ `)),n){if(d)try{d()}catch{}e===130||e===143||(process.stderr.write(`
8
+ kane-cli crashed: ${t}
9
+ `+(l.length>0?`Resources cleaned up (${l.join(", ")}).
10
+ `:"")),o&&v()?process.stderr.write(`${o}
11
+ `):process.stderr.write(`(re-run with KANE_DEV_MODE=1 for the full stack)
12
+ `)),process.exit(e);return}if(a&&!n){a();return}process.exit(e)}function S(e){a=e}function k(e){d=e}var x=!1;function I(){x||(x=!0,process.on("SIGINT",()=>{f(130,"Received SIGINT",!0)}),process.on("SIGTERM",()=>{f(143,"Received SIGTERM",!0)}),process.on("uncaughtException",e=>{f(1,`Uncaught exception: ${e.name}: ${e.message}`,!0,e.stack)}),process.on("unhandledRejection",e=>{f(1,`Unhandled rejection: ${String(e)}`,!0,e instanceof Error?e.stack:void 0)}))}function D(){r=[],g=!1,m=null,a=null,d=null,s=null,u=[],x=!1}export{h as a,y as b,R as c,w as d,E as e,$ as f,L as g,f as h,S as i,k as j,I as k,D as l};
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{c as L}from"./chunk-RFHMDQXZ.js";import{Q as O,S}from"./chunk-ABSEKYIB.js";import{e as P,f as R}from"./chunk-M5JQXOCE.js";import{x as s}from"./chunk-MKD3KZPM.js";import{a as y}from"./chunk-HCBYKLMW.js";import{a as E,b as o,i as h}from"./chunk-C44QQJR4.js";import{a as B}from"./chunk-6YGTRKDT.js";import{e as d}from"./chunk-UR6MHSHU.js";var n=d(B(),1);import{basename as D}from"path";var r=d(y(),1),U="evidence-view-server";function Q({packPath:m,viewerBase:w,onDone:V,openUrl:k}){let[t,a]=(0,n.useState)("ask"),[g,b]=(0,n.useState)(null),[l,p]=(0,n.useState)(null),f=(0,n.useRef)(null),u=(0,n.useRef)(!1),x=async()=>{let e=f.current;f.current=null,e&&(R(U),await e.close())},v=()=>{u.current||(u.current=!0,V())};return h((e,i)=>{u.current||(t==="ask"?e==="y"||e==="Y"?a("starting"):(e==="n"||e==="N"||i.return||i.escape)&&v():t==="serving"&&(e==="q"||e==="Q"||i.escape)&&x().then(v))}),(0,n.useEffect)(()=>{if(t!=="starting")return;let e=!1;return(async()=>{try{let i=D(m),c=await O({packs:new Map([[i,m]]),allowedOrigins:[new URL(w).origin]});if(e){await c.close();return}f.current=c,P(U,()=>{c.close()});let T=S(c.urlFor(i),w);b(T);try{await(k??(q=>L(q)))(T)}catch{p("could not open browser \u2014 open the URL manually")}a("serving")}catch(i){p(`evidence view failed \u2014 ${i.message}`),a("failed")}})(),()=>{e=!0}},[t]),(0,n.useEffect)(()=>{if(t!=="failed")return;let e=setTimeout(v,0);return()=>clearTimeout(e)},[t]),(0,n.useEffect)(()=>()=>{x()},[]),t==="ask"?(0,r.jsxs)(o,{children:["View evidence in browser? ",(0,r.jsx)(o,{color:s.dim,children:"(y/N)"})]}):t==="serving"||t==="starting"?(0,r.jsxs)(E,{flexDirection:"column",children:[g?(0,r.jsxs)(o,{children:["viewer ",(0,r.jsx)(o,{color:s.orange,children:g})]}):(0,r.jsx)(o,{color:s.dim,children:"starting\u2026"}),l?(0,r.jsx)(o,{color:"yellow",children:l}):null,t==="serving"?(0,r.jsx)(o,{color:s.dim,children:"Press q when done"}):null]}):l?(0,r.jsx)(o,{color:"yellow",children:l}):null}export{Q as a};