@testmuai/kane-cli 0.8.1 → 0.8.2
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.
- package/dist/ChatSurface-B3ULYDYC.js +8 -0
- package/dist/{ChromeProfilePicker-AUU7JF6F.js → ChromeProfilePicker-T77E7ZSC.js} +1 -1
- package/dist/{CliFeedbackPrompt-4W74Y3UF.js → CliFeedbackPrompt-FQ2XV5DZ.js} +1 -1
- package/dist/{CliUploadProgress-6HL7WTEX.js → CliUploadProgress-TZ55LONO.js} +1 -1
- package/dist/{ConfigView-6BSCZP5Y.js → ConfigView-WWQMH36G.js} +1 -1
- package/dist/EvidenceViewOffer-L5FVBQNK.js +2 -0
- package/dist/FolderPicker-6Z3CYSHF.js +2 -0
- package/dist/{HelpView-TU7ED43J.js → HelpView-XXPCPJNF.js} +1 -1
- package/dist/{InfoBox-JLTMKVDE.js → InfoBox-SHBRHQX5.js} +1 -1
- package/dist/{LinksBox-LREUUJDV.js → LinksBox-ENNF7TDJ.js} +1 -1
- package/dist/{ProfilesView-W3GX2N2E.js → ProfilesView-CNF2FXF3.js} +1 -1
- package/dist/{ProjectPicker-SYQUJK2J.js → ProjectPicker-PVPLS642.js} +1 -1
- package/dist/{SaveSessionPrompt-MR5NJMRP.js → SaveSessionPrompt-4QP4GNGO.js} +1 -1
- package/dist/SingleShotApp-M3HNSUMZ.js +2 -0
- package/dist/{SummaryBox-UAYSVFB7.js → SummaryBox-HYNINDNN.js} +1 -1
- package/dist/TestMdRunView-ISOVQ7YP.js +2 -0
- package/dist/{WhoamiView-2YU76ASQ.js → WhoamiView-NN2HOK6H.js} +1 -1
- package/dist/app-client-ZCCNE3RV.js +2 -0
- package/dist/{app-download-AEEFQ63M.js → app-download-5UJMXPF3.js} +1 -1
- package/dist/{auth-HET3TBRI.js → auth-QKBTOWQX.js} +1 -1
- package/dist/{bind-STKXOUYI.js → bind-LVGP5KHO.js} +2 -2
- package/dist/bootstrap-RUJBMB2P.js +2 -0
- package/dist/bridge-QDPBIIOW.js +2 -0
- package/dist/{changelog-7OWRHFHZ.js → changelog-HBPBPR2O.js} +1 -1
- package/dist/{chat-controller-T2FAI55V.js → chat-controller-R4THYYPU.js} +1 -1
- package/dist/chunk-2E3ZWGIK.js +12 -0
- package/dist/{chunk-ZVHCQMJ6.js → chunk-2KH2JUGL.js} +2 -2
- package/dist/{chunk-ZIUAOEUC.js → chunk-2TYCUPCN.js} +1 -1
- package/dist/{chunk-FEJXWJ3L.js → chunk-2ZZDNPFN.js} +1 -1
- package/dist/{chunk-KFSUPQAG.js → chunk-3654GK6O.js} +43 -43
- package/dist/{chunk-RFR4ZKIC.js → chunk-3NHO5R4P.js} +2 -2
- package/dist/{chunk-3LJWYRAA.js → chunk-4II6VDXG.js} +1 -1
- package/dist/chunk-4J6DQFPC.js +4 -0
- package/dist/{chunk-SDPRO2LE.js → chunk-4U4OSOA4.js} +1 -1
- package/dist/chunk-5NIYYD7O.js +2 -0
- package/dist/{chunk-L7MXYCD7.js → chunk-5SNT2MK5.js} +1 -1
- package/dist/chunk-6J5T5FEY.js +2 -0
- package/dist/chunk-6N726QLP.js +349 -0
- package/dist/chunk-7F2ZV46B.js +2 -0
- package/dist/{chunk-BRHNRCEZ.js → chunk-7S3JZ6FQ.js} +1 -1
- package/dist/chunk-A2SQD2AY.js +4 -0
- package/dist/{chunk-AW2XUHH4.js → chunk-AJQT4IWZ.js} +1 -1
- package/dist/{chunk-6XX4LEVJ.js → chunk-AN2ZPHCE.js} +1 -1
- package/dist/{chunk-3POR47RC.js → chunk-ATGRRKEV.js} +2 -2
- package/dist/chunk-AXTPNZPX.js +2 -0
- package/dist/{chunk-RC52N7PC.js → chunk-BKVDAZEJ.js} +1 -1
- package/dist/{chunk-2WVKOZ6W.js → chunk-BPMSNGXQ.js} +1 -1
- package/dist/{chunk-UV462FZR.js → chunk-BSYX225I.js} +1 -1
- package/dist/{chunk-DZGCXKKI.js → chunk-CAMO26QU.js} +1 -1
- package/dist/chunk-ECZMYPLJ.js +19 -0
- package/dist/{chunk-65ZTD5SJ.js → chunk-FNS2EAA5.js} +2 -2
- package/dist/{chunk-7BZSCUPP.js → chunk-GNIFMQNK.js} +3 -3
- package/dist/chunk-GUVM6SZF.js +2 -0
- package/dist/{chunk-2BGUUWNF.js → chunk-HFFPPCZO.js} +2 -2
- package/dist/{chunk-T5Y6MOLM.js → chunk-HRZOFTV7.js} +1 -1
- package/dist/chunk-HWH3UYD6.js +4 -0
- package/dist/{chunk-EDSZJZFG.js → chunk-I7RQS65W.js} +1 -1
- package/dist/chunk-IUEEFGEW.js +11 -0
- package/dist/{chunk-DO5HAO3H.js → chunk-IV76ZXCY.js} +1 -1
- package/dist/{chunk-UXDL4XDL.js → chunk-IZ2FJYHG.js} +1 -1
- package/dist/{chunk-766WGMBU.js → chunk-J7KT44IC.js} +1 -1
- package/dist/{chunk-QW6EZC53.js → chunk-JEDLXUO5.js} +1 -1
- package/dist/chunk-JGOZUAMC.js +2 -0
- package/dist/{chunk-XO5ZH3ZR.js → chunk-JHKM7W5X.js} +1 -1
- package/dist/{chunk-IOFZSQAA.js → chunk-JJN76EXE.js} +1 -1
- package/dist/{chunk-YFYCCTSL.js → chunk-JUVQQP42.js} +1 -1
- package/dist/chunk-KKRNTSLL.js +6 -0
- package/dist/{chunk-IP2O264K.js → chunk-LDCLZR2U.js} +1 -1
- package/dist/chunk-LQQXPY5B.js +4 -0
- package/dist/{chunk-FMRSMN34.js → chunk-LVCY5IYI.js} +1 -1
- package/dist/{chunk-G7VQCS4J.js → chunk-LVN6VHFN.js} +1 -1
- package/dist/chunk-MMBBQ4OZ.js +2 -0
- package/dist/{chunk-QSDH5P7C.js → chunk-MTIC65NK.js} +1 -1
- package/dist/chunk-NHBYZCSX.js +4 -0
- package/dist/{chunk-GZPK6FRP.js → chunk-NRUD56FY.js} +1 -1
- package/dist/{chunk-GKYPNSQP.js → chunk-NXFAEDHV.js} +2 -2
- package/dist/{chunk-ELM6MXGJ.js → chunk-NXXJ56QA.js} +1 -1
- package/dist/{chunk-JJHG3BWO.js → chunk-O3AHFP3K.js} +1 -1
- package/dist/{chunk-FQLIW3LM.js → chunk-OAVPM6YJ.js} +1 -1
- package/dist/{chunk-QRZRSAZH.js → chunk-OJTCIZDK.js} +1 -1
- package/dist/{chunk-YJELGSKJ.js → chunk-OOEPLMKA.js} +1 -1
- package/dist/{chunk-6O3DDOP2.js → chunk-PXCMEI73.js} +1 -1
- package/dist/{chunk-C7HSWZP6.js → chunk-R4UCBA5R.js} +1 -1
- package/dist/chunk-RKXHVP2Z.js +2 -0
- package/dist/{chunk-KU6IXFGZ.js → chunk-RN4PKQFR.js} +1 -1
- package/dist/chunk-RUCSRS4C.js +5 -0
- package/dist/chunk-TAOHYWEO.js +2 -0
- package/dist/{chunk-TFPPEOAK.js → chunk-U5GHOGLM.js} +1 -1
- package/dist/chunk-UJZZDPDY.js +2 -0
- package/dist/{chunk-EWCAFKLX.js → chunk-UODLRQQ4.js} +1 -1
- package/dist/chunk-VK3NU742.js +21 -0
- package/dist/{chunk-DCY6R5DP.js → chunk-VPRNGWIY.js} +1 -1
- package/dist/{chunk-NX7TM662.js → chunk-WOEQDUJ6.js} +1 -1
- package/dist/{chunk-OMQCD3KR.js → chunk-WQPQNL4S.js} +1 -1
- package/dist/{chunk-HMYMSRA4.js → chunk-WV27D55O.js} +1 -1
- package/dist/{chunk-GCBKDX2J.js → chunk-WVCH66YH.js} +1 -1
- package/dist/{chunk-7JWKHKFU.js → chunk-YCLG3T5E.js} +1 -1
- package/dist/chunk-YGMC3FGJ.js +26 -0
- package/dist/{chunk-TKGUT425.js → chunk-YHYTCENI.js} +1 -1
- package/dist/{chunk-UDIQOJEL.js → chunk-YSSYT5F5.js} +1 -1
- package/dist/{chunk-OTTGS2TE.js → chunk-YTDSQAYN.js} +1 -1
- package/dist/{chunk-HCKH44I2.js → chunk-ZEDAPY7M.js} +1 -1
- package/dist/chunk-ZI6UIJUN.js +11 -0
- package/dist/{config-RS47F5SC.js → config-RLDXM5ZH.js} +1 -1
- package/dist/{credentials-OH6AVI6N.js → credentials-CALNKQMN.js} +1 -1
- package/dist/deps-bundle-GVHIMZ5E.js +2 -0
- package/dist/{deps-resolve-XC5S53DG.js → deps-resolve-T6P4EACP.js} +1 -1
- package/dist/{dispatch-SE5GY3Z2.js → dispatch-ECUEAMXS.js} +1 -1
- package/dist/doctor-SIBHJVGC.js +2 -0
- package/dist/evidence-ZVQHPELX.js +2 -0
- package/dist/evolve-cmd-JGCFTXWA.js +2 -0
- package/dist/extract-bind-EXW32RUY.js +10 -0
- package/dist/{extract-cmd-UZMEZMGP.js → extract-cmd-7IOLJJCL.js} +1 -1
- package/dist/gaps-cmd-WPCJPLGB.js +3 -0
- package/dist/{generate-headless-D3SVQ2AI.js → generate-headless-U4GTG234.js} +2 -2
- package/dist/index.js +61 -60
- package/dist/{ingest-cmd-EAE7N5RC.js → ingest-cmd-YYNAKI2U.js} +1 -1
- package/dist/interactive-bind-Y65XV4Y5.js +25 -0
- package/dist/{list-commands-MRXL5HGS.js → list-commands-3EROWJWV.js} +1 -1
- package/dist/login-flow-TRINUSBB.js +2 -0
- package/dist/mobile-prompts-TP3ODM5M.js +2 -0
- package/dist/{persist-recorded-session-TLDQ5HKP.js → persist-recorded-session-EHYT3PVN.js} +1 -1
- package/dist/{phase-seed-VFHIH6FL.js → phase-seed-DIRETNU6.js} +1 -1
- package/dist/{pipeline-UOM4LNAI.js → pipeline-5GOS2KV2.js} +1 -1
- package/dist/prepare-target-BUEOZVJV.js +2 -0
- package/dist/reconcile-cmd-TY3MWZL3.js +2 -0
- package/dist/reconcile-deps-6KTJHBMJ.js +4 -0
- package/dist/reconcile-engine-O7QEZVX6.js +2 -0
- package/dist/{recording-banner-4M7XHVGI.js → recording-banner-BWWFOJCR.js} +1 -1
- package/dist/registry-KXEDLM6X.js +2 -0
- package/dist/{require-project-folder-4UPQNEBJ.js → require-project-folder-CXDRRWEQ.js} +1 -1
- package/dist/resolve-run-intent-PZXEQTHC.js +7 -0
- package/dist/{resolver-UBOZLFFE.js → resolver-FTU5KO7H.js} +1 -1
- package/dist/{run-URPGHOQM.js → run-CMFBSYWF.js} +1 -1
- package/dist/run-WKHPVWUN.js +2 -0
- package/dist/{run-test-md-76ZPKXO6.js → run-test-md-7HGOZJSU.js} +2 -2
- package/dist/session-items-2ATN7VXG.js +2 -0
- package/dist/{skill-installer-CIS6GAYF.js → skill-installer-QNUDLGPD.js} +1 -1
- package/dist/{spawner-J67QR4QP.js → spawner-DQZRJIE6.js} +1 -1
- package/dist/tcg-generate-XKSTMCOG.js +2 -0
- package/dist/{testmd-actions-77ELR5UU.js → testmd-actions-IFRW7NGG.js} +1 -1
- package/dist/{tms-client-VD3B3SMU.js → tms-client-V3TR4QW3.js} +1 -1
- package/dist/token-refresh-FP6JFLXB.js +2 -0
- package/dist/{validate-basic-2GVSQ2R5.js → validate-basic-3CNUDDH7.js} +1 -1
- package/dist/{verdicts-TRSTJLCL.js → verdicts-NYCSBWUC.js} +1 -1
- package/dist/{version-check-O6PYTI4T.js → version-check-7TSAVA6V.js} +1 -1
- package/dist/walk-session-AINBHZKB.js +2 -0
- package/dist/with-telemetry-3DL7ZEZL.js +2 -0
- package/package.json +11 -11
- package/dist/ChatSurface-U37VZDCW.js +0 -8
- package/dist/EvidenceViewOffer-62XHEEGW.js +0 -2
- package/dist/FolderPicker-S7U2EN2M.js +0 -2
- package/dist/SingleShotApp-XOKVOM7C.js +0 -2
- package/dist/TestMdRunView-7UVSDAF4.js +0 -2
- package/dist/app-client-OEXESV4U.js +0 -2
- package/dist/bootstrap-44YKVWWE.js +0 -2
- package/dist/bridge-5Z3BIB77.js +0 -2
- package/dist/chunk-27U4PLPX.js +0 -2
- package/dist/chunk-2KDGIZED.js +0 -4
- package/dist/chunk-3PECJD6S.js +0 -11
- package/dist/chunk-7Q6M6P4X.js +0 -26
- package/dist/chunk-CTW2VQKS.js +0 -6
- package/dist/chunk-FNH55WSR.js +0 -19
- package/dist/chunk-GPG3FIN3.js +0 -21
- package/dist/chunk-HEAIJCGZ.js +0 -2
- package/dist/chunk-KCCSWEGA.js +0 -4
- package/dist/chunk-MA34UWKX.js +0 -4
- package/dist/chunk-MBF3FP5P.js +0 -5
- package/dist/chunk-MXHHMIO2.js +0 -349
- package/dist/chunk-QGKPLOUI.js +0 -2
- package/dist/chunk-RLRNLIRS.js +0 -2
- package/dist/chunk-TYLYFERW.js +0 -10
- package/dist/chunk-V2R3LCA3.js +0 -12
- package/dist/chunk-VGFTNLQQ.js +0 -2
- package/dist/chunk-W2JFDDIB.js +0 -2
- package/dist/chunk-YRFMPIU2.js +0 -4
- package/dist/doctor-FSECFZUU.js +0 -2
- package/dist/evidence-OYPHZUKI.js +0 -2
- package/dist/evolve-cmd-BCPNXAMV.js +0 -2
- package/dist/extract-bind-LLEASZAK.js +0 -10
- package/dist/gaps-cmd-IVXFPFAQ.js +0 -3
- package/dist/interactive-bind-ORMN2REX.js +0 -25
- package/dist/login-flow-QJQM3RHT.js +0 -2
- package/dist/mobile-prompts-TOX35ER6.js +0 -2
- package/dist/prepare-target-QYWIJIVQ.js +0 -2
- package/dist/reconcile-cmd-3H34KVVD.js +0 -2
- package/dist/reconcile-deps-XIH75ZLY.js +0 -4
- package/dist/reconcile-engine-UKWPG2LV.js +0 -2
- package/dist/registry-PYOTKZYZ.js +0 -2
- package/dist/resolve-run-intent-X72V3KJA.js +0 -7
- package/dist/run-2COODVX2.js +0 -2
- package/dist/tcg-generate-BDTRKY2A.js +0 -2
- package/dist/token-refresh-4BPAPXKK.js +0 -2
- package/dist/walk-session-CHJXHZMO.js +0 -2
- package/dist/with-telemetry-CQCWLVOC.js +0 -2
- /package/dist/{lifecycle-cmd-O2324GN6.js → lifecycle-cmd-HO5VL7AM.js} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{b as p,c as E,d as j,e as y,f as M,g as C,i as A,l as D,m as F,q as T,s as $,t as O}from"./chunk-
|
|
2
|
+
import{b as p,c as E,d as j,e as y,f as M,g as C,i as A,l as D,m as F,q as T,s as $,t as O}from"./chunk-VK3NU742.js";import{c as H,d as z}from"./chunk-2YQ6TW77.js";import{a as k}from"./chunk-HRZOFTV7.js";import{p as B,q as R}from"./chunk-56PAQAX5.js";import{a as P}from"./chunk-7F2ZV46B.js";import{e as q}from"./chunk-UR6MHSHU.js";import{existsSync as f,mkdirSync as V,readFileSync as Z,renameSync as N,writeFileSync as K}from"fs";import{join as Q}from"path";function fe(e){D(p(e));let t=p(e);if(!f(t))return;let n=Q(t,"meta.json"),r=y(e);if(f(n)&&!f(r))try{V(j(e),{recursive:!0}),N(n,r)}catch(o){process.stderr.write(`warn: meta.json migration failed: ${o.message}
|
|
3
3
|
`)}let i=C(e);if(f(i)){let o="python";try{let c=new k().load();c.code_export?.language&&(o=c.code_export.language)}catch{}let a=M(e,"playwright",o);if(!f(a))try{N(i,a)}catch(c){process.stderr.write(`warn: generated-code migration failed: ${c.message}
|
|
4
4
|
`)}}if(f(r))try{let o=JSON.parse(Z(r,"utf8"));"md5sum"in o&&(delete o.md5sum,K(r,JSON.stringify(o,null,2)+`
|
|
5
5
|
`,"utf8"))}catch(o){process.stderr.write(`warn: meta.json md5sum strip failed: ${o.message}
|
|
6
|
-
`)}}async function ye(e){if(!e.isInteractive)return{recovered:!1};if(W(e.creds))return{recovered:!1};let{SingleShotApp:t}=await import("./SingleShotApp-
|
|
6
|
+
`)}}async function ye(e){if(!e.isInteractive)return{recovered:!1};if(W(e.creds))return{recovered:!1};let{SingleShotApp:t}=await import("./SingleShotApp-M3HNSUMZ.js"),{ScrollbackProvider:n}=await import("./scrollback-JLPJR25X.js"),{render:r}=await import("./build-JIKYOZUH.js"),i=await import("./react-QWOAB3TB.js"),o={current:null},a={current:!1},{waitUntilExit:c,unmount:l}=r(i.default.createElement(n,null,i.default.createElement(t,{resultRef:o,mode:"login",loginCompleteRef:a})),{exitOnCtrlC:!1});R(()=>l()),await c();try{process.stdin.setRawMode?.(!1)}catch{}return process.stdout.write("\x1B[?25h"),a.current?{recovered:!0}:(B(0,"Startup gate cancelled"),{recovered:!1})}function W(e){let t=e.getActiveProfile(),n=e.getDefaultEnv();if(!t||!!!(e.loadBasicAuth(t,n)||e.loadCredentials(t,n)))return!1;let i=e.loadProfileConfig(t,n)??{};return!!i.project_id&&!!i.folder_id}var J=q(H(),1);import{existsSync as v,readFileSync as U,readdirSync as X,statSync as Y}from"fs";import{dirname as ee,isAbsolute as te,join as g,relative as x,resolve as re,sep as h}from"path";import{createHash as ne}from"crypto";var S="testmd-bundle.json",d=class extends Error{constructor(t){super(t),this.name="BundleUsageError"}},_=e=>e.split(h).join("/");function I(e){if(!v(e))return[];let t=[];for(let n of X(e).sort()){let r=g(e,n);Y(r).isDirectory()?t.push(...I(r)):t.push(r)}return t}function se(e){let t=e.map(r=>ee(r).split(h)),n=t[0];for(let r of t.slice(1)){let i=0;for(;i<n.length&&i<r.length&&n[i]===r[i];)i++;n=n.slice(0,i)}return n.join(h)||h}function ie(e){for(let t of e){let n=F(t,U(t,"utf8"));for(let r of n.steps)if(r.body.kind==="import_ref"&&te(r.body.path))throw new d(`bundle sync: absolute @import is not portable after unzip: ${t} step ${r.index} (@import ${r.body.path})`)}}function G(e){let t=re(e),n=T(t);if(!n?.commit_id||!n?.test_id)throw new d(`bundle sync: ${t} is not authored \u2014 run \`kane-cli testmd run\` first (output-<stem>/.internal/meta.json needs commit_id + test_id)`);let r;try{r=O(t)}catch(s){throw s instanceof $?new d(`bundle sync: ${s.message}`):s}let i=[t];for(let s of r.steps)for(let u of s.trace.slice(1))i.includes(u.file)||i.push(u.file);ie(i);let o=[];for(let s of r.unitFiles){if(s.file===t)continue;let u=p(s.file);o.includes(u)||o.push(u)}let a=[...i],c=s=>{v(s)&&a.push(s)};c(E(t)),a.push(y(t)),c(g(p(t),".internal","execution.json")),a.push(...I(A(t)));for(let s of o)c(g(s,"Result.md")),a.push(...I(g(s,".internal","steps")));let l=se(a);if(v(g(l,S)))throw new d(`bundle sync: a real file named ${S} exists at the zip root (${l}) \u2014 it would collide with the generated manifest`);let b=a.map(s=>{let u=U(s);return{abs:s,rel:_(x(l,s)),sha256:ne("sha256").update(u).digest("hex"),bytes:u.length}}).sort((s,u)=>s.rel<u.rel?-1:1),m=_(x(l,t)),L={schema_version:2,entry:m,commit_id:n.commit_id,test_id:n.test_id,testcase_id:n.testcase_id??null,project_id:n.project_id??null,folder_id:n.folder_id??null,org_id:n.org_id??null,created_at:new Date().toISOString(),producer:{name:"kane-cli",version:P},files:b.map(s=>({path:s.rel,sha256:s.sha256,bytes:s.bytes})),units:r.unitFiles.filter(s=>s.file!==t).map(s=>({path:_(x(l,s.file)),kind:s.kind}))};return{zipRoot:l,entry:m,files:b,manifest:L}}var w=e=>e instanceof Error?e.message:String(e);function oe(e){return new Promise((t,n)=>{let r=(0,J.default)("zip",{zlib:{level:6}}),i=[];r.on("data",o=>i.push(o)),r.on("error",n),r.on("end",()=>t(Buffer.concat(i))),r.append(JSON.stringify(e.manifest,null,2)+`
|
|
7
7
|
`,{name:S});for(let o of e.files)r.file(o.abs,{name:o.rel});r.finalize()})}async function ae(e){let{plan:t,controller:n,testId:r,sessionId:i,commitId:o}=e,a;try{a=await oe(t)}catch(l){return{ok:!1,stage:"zip",error:w(l)}}let c;try{let l={key:"testmd",content_type:"application/zip",filename:`${o}-testmd.zip`},m=(await n.getPresignedUrls(r,i,[l])).urls?.testmd?.upload_url;if(!m)return{ok:!1,stage:"presign",error:"presign response missing testmd upload_url"};c=m}catch(l){return{ok:!1,stage:"presign",error:w(l)}}try{await z(c,a,"application/zip")}catch(l){return{ok:!1,stage:"upload",error:w(l)}}return{ok:!0,bytes:a.length}}async function Ee(e){let t;try{t=G(e.sourcePath)}catch(n){return n instanceof d?{ok:!1,stage:"collect",error:n.message}:{ok:!1,stage:"collect",error:w(n)}}return ae({...e,plan:t})}function je(e){return e.shouldUploadPipeline&&e.uploadSucceeded&&!!e.metaCommitId&&!!e.metaTestId}export{fe as a,ye as b,Ee as c,je as d};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as k}from"./chunk-
|
|
2
|
+
import{a as k}from"./chunk-2ZZDNPFN.js";import{y as u}from"./chunk-7F2ZV46B.js";import{a as f}from"./chunk-HCBYKLMW.js";import{a as m,b as s,k as b}from"./chunk-C44QQJR4.js";import{e as p}from"./chunk-UR6MHSHU.js";function B(t){let e=t;return e=e.replace(/@TS\{([^}]+)\}/g,"@S{$1}"),e=e.replace(/@TS-(\d+)/g,(o,i)=>`@S${parseInt(i,10)}.C1`),e=e.replace(/@TS(\d+)/g,(o,i)=>`@S${parseInt(i,10)}`),e=e.replace(/\\n/g,`
|
|
3
3
|
`),e}var c=p(f(),1),S=t=>t!==void 0&&/[A-Za-z0-9]/.test(t);function x(t){let e=[],o="",i=()=>{o&&(e.push({text:o}),o="")},d=(a,l,r)=>(a===0||!S(t[a-1]))&&(l+r>=t.length||!S(t[l+r])),n=0;for(;n<t.length;){let a=t.slice(n,n+2),l=t[n];if(a==="**"||a==="__"){let r=t.indexOf(a,n+2);if(r!==-1&&r>n+2&&(a==="**"||d(n,r,2))){i(),e.push({text:t.slice(n+2,r),bold:!0}),n=r+2;continue}}if(l==="`"){let r=t.indexOf("`",n+1);if(r!==-1&&r>n+1){i(),e.push({text:t.slice(n+1,r),code:!0}),n=r+1;continue}}if(l==="*"||l==="_"){let r=t.indexOf(l,n+1);if(r!==-1&&r>n+1&&(l==="*"||d(n,r,1))){i(),e.push({text:t.slice(n+1,r),italic:!0}),n=r+1;continue}}o+=l,n+=1}return i(),e.length===0&&e.push({text:""}),e}function h(t){return t.map((e,o)=>(0,c.jsx)(s,{bold:e.bold,italic:e.italic,color:e.code?u.dim:void 0,children:e.text},o))}function T(t){return t.split(`
|
|
4
4
|
`).map(e=>{if(e.trim()==="")return{kind:"blank"};let o=e.match(/^\s*[-*+]\s+(.*)$/);if(o)return{kind:"bullet",segs:x(o[1])};let i=e.match(/^\s*(\d+)\.\s+(.*)$/);if(i)return{kind:"numbered",n:i[1],segs:x(i[2])};let d=e.match(/^#{1,6}\s+(.*)$/);return d?{kind:"heading",segs:x(d[1])}:{kind:"para",segs:x(e)}})}function R(t,e,o=""){switch(t.kind){case"blank":return(0,c.jsx)(s,{children:o||" "},e);case"heading":return(0,c.jsxs)(s,{bold:!0,children:[o,h(t.segs)]},e);case"bullet":return(0,c.jsx)(m,{marginLeft:1,children:(0,c.jsxs)(s,{children:[o,"\u2022 ",h(t.segs)]})},e);case"numbered":return(0,c.jsx)(m,{marginLeft:1,children:(0,c.jsxs)(s,{children:[o,`${t.n}. `,h(t.segs)]})},e);default:return(0,c.jsxs)(s,{children:[o,h(t.segs)]},e)}}function $({text:t,accent:e=u.generateAccent}){let o=T(B(t)),{stdout:i}=b(),d=i?.columns??80;return(0,c.jsxs)(m,{marginBottom:1,children:[(0,c.jsx)(m,{width:2,flexShrink:0,children:(0,c.jsx)(s,{color:e,children:"\u2503"})}),(0,c.jsx)(m,{flexDirection:"column",width:d-2,children:o.map((n,a)=>R(n,a))})]})}var g=p(f(),1),I=5;function C({thinking:t,expanded:e,thinkingDone:o,maxLines:i=I}){if(!e)return(0,g.jsxs)(m,{paddingX:1,children:[(0,g.jsx)(s,{color:u.dim,children:o?"\u2237 thinking complete ":"\u2237 thinking\u2026 "}),(0,g.jsx)(s,{color:u.muted,children:o?"(ctrl+t to view)":"(ctrl+t to show)"})]});let d=t.split(`
|
|
5
5
|
`),n=Math.max(0,d.length-i),a=n>0?d.slice(-i).join(`
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{j as Re,k as oe,l as se,m as _e,n as $e,o as ae}from"./chunk-ATGRRKEV.js";import{a as te,c as re,d as ye,f as ie}from"./chunk-JGOZUAMC.js";import{a as P,b as we,d as ke}from"./chunk-OS4VSIHT.js";import{d as ve}from"./chunk-6J5T5FEY.js";import{a as S}from"./chunk-CLGC7VEO.js";import{a as X,b as N,c as ee,d as W,e as he,g as O,h as ne}from"./chunk-W5TTF7GB.js";import{a as ge}from"./chunk-JFAFKHDX.js";import{b as Z,c as J,d as Q}from"./chunk-GNIFMQNK.js";import{e as me,g as pe}from"./chunk-W4B5LOEX.js";import{A as I}from"./chunk-TH47OOBV.js";import{f as T}from"./chunk-DUAXZYAD.js";import{existsSync as Oe,statSync as Ue}from"fs";import{basename as G,resolve as q}from"path";function Ee(e){if(!e||e.stale_refs.length===0)return"\u2014";let n=e.direct_refs??[];return`${e.stale_refs.length} stale${n.length>0?` \xB7 ${n.length} direct`:""}`}function ce(e,n){let t=[...e.rows.filter(a=>a.kind!=="REMOVE").map(a=>[a.kind,S(a.ref),a.reason,Ee(a.impact)]),...e.archive.map(a=>["ARCHIVE",S(a.ref),a.why,Ee(a.impact)])],r=Math.max(40,n??100),i=[`reconcile ${e.source_id} \u2014 head ${e.head.status} \xB7 ${t.length} decision${t.length===1?"":"s"}`];return t.length>0&&i.push(...ve(["kind","ref","why","impact"],t,r,2)),e.changed&&i.push(e.held?`extract ran in override mode; ${e.defaultsTaken??0} default(s) auto-taken; matched-but-changed and new proposals HELD for your verdict (staged \u2014 nothing committed)`:`extract ran in override mode; ${e.defaultsTaken??0} default(s) auto-taken; matched-but-changed proposals auto-committed as edits`),i.push("each row becomes a card below \u2014 verdicts commit as they land"),e.planPath&&i.push(`plan: ${e.planPath}`),i}var xe=new Set(["interactive","agent","ci","override"]);function Ae(e,n){if(e.mode!==void 0&&!xe.has(e.mode))return{error:`--mode must be interactive | agent | ci | override, got '${e.mode}'`,code:"MODE_USAGE"};let t=e.mode,r="reconcile without a TTY needs an explicit mode \u2014 pass --mode agent|ci|override, or --plan for a preview";return t==="interactive"&&!n?{error:r}:t||(n?"interactive":e.plan?"override":{error:r})}async function Pe(e){let{makeHeadlessIO:n,agentRefusal:t}=await import("./headless-io-66RG5NN5.js");return t(n("ndjson","reconcile"),e,"MODE_USAGE")}function Me(e,n,t,r){if(J(t)){let v=Q(t),s=v?.sourceIdFor(t)??null;if(v===null||s===null)return{error:`--from '${t}' is not a supported remote URL \u2014 supported: ${Z.map(u=>u.hint).join("; ")}`};if(r!==void 0&&r!==s)return{error:`--source-id '${r}' does not match this URL's own identity '${s}' \u2014 re-run without --source-id. A source adopted with --as updates by re-running context ingest with the same --as; reconcile follows only the URL's own id`};let c=I(e);if(!c.heads.has(s))return{error:`unknown source '${s}' \u2014 see \`kane-cli context list --type source\`. If this URL was ingested under a custom id, update it by re-running context ingest with the same --as`};if(c.heads.get(s)==null)return{error:`source '${s}' is retired \u2014 restore it first with \`kane-cli context revert\`, then reconcile`};let _=z(e,s,{remoteUrl:t});return _!==null?{error:_}:{sourceId:s,remoteUrl:t}}if(r===void 0)return{error:"reconcile needs --from <file> AND --source-id <id> \u2014 see `kane-cli context list --type source` for ids"};let i=q(n,t);if(!Oe(i)||!Ue(i).isFile())return{error:`--from '${t}' is not a file \u2014 pass the changed source document`};let a=me(i);if(!a.ok)return{error:`--from '${t}' is not an ingestable document \u2014 allowed: ${a.allowlist.join(", ")}`};let o=I(e);if(!o.heads.has(r))return{error:`unknown source '${r}' \u2014 see \`kane-cli context list --type source\``};if(o.heads.get(r)==null)return{error:`source '${r}' is retired \u2014 restore it first with \`kane-cli context revert\`, then reconcile`};let w=z(e,r,{filePath:i});if(w!==null)return{error:w};let f=null;try{f=pe(i)}catch{}return f!==null&&f!==r&&o.heads.get(f)!=null?{error:`'${G(i)}' already backs live source '${f}' \u2014 did you mean --source-id ${f}? To truly move these bytes under '${r}', retire '${f}' first`}:{sourceId:r,filePath:i}}function C(e){return e==null?"(none)":e.slice(0,19)}function Y(e,n,t,r=!1,i){if(e.out(`reconcile ${n.source_id}: head ${n.head.status} \u2014 ${C(n.head.before)} \u2192 ${C(n.head.after)}`),r||(e.out(`note: ${n.note}`),e.out(`skipped arms: ${n.skipped_arms}`)),n.changed&&(e.out(n.held?`extract ran in override mode; ${t?.defaultsTaken??0} default(s) auto-taken; matched-but-changed and new proposals HELD for your verdict (staged \u2014 nothing committed)`:`extract ran in override mode; ${t?.defaultsTaken??0} default(s) auto-taken; matched-but-changed proposals auto-committed as edits`),i?.({type:"defaults_taken",count:t?.defaultsTaken??0})),r){let a=n.changeset??[],o=(f,v)=>{let s=a.filter(c=>c.kind===f).length;return s>0?`${s} ${v}`:null},w=[o("ADD","add"),o("MODIFY","modify"),o("ARCHIVE","archive")].filter(Boolean);n.changed&&e.out(`changeset: ${a.length} item(s)${w.length?` \u2014 ${w.join(" \xB7 ")}`:""}`),e.out(`plan: ${n.rows.length} row(s) \u2014 each gets a card below`);return}if(n.changed){let a=n.changeset??[];e.out(`changeset: ${a.length} item(s)`);for(let o of a)if(o.kind==="MODIFY")e.out(` [MODIFY] ${S(o.ref)} \u2014 ${o.summary} (${C(o.old_cid)} \u2192 ${o.new_cid===null?"(staged)":C(o.new_cid)})`);else if(o.kind==="ADD")e.out(` [ADD] ${S(o.ref)}`);else{e.out(` [ARCHIVE] ${S(o.ref)} \u2014 ${o.why}`);let w=le(o.impact,"retiring drops");w&&e.out(` ${w}`)}}e.out(`plan: ${n.rows.length} row(s)`);for(let a of n.rows){e.out(` [${a.kind}] ${S(a.ref)} \u2014 ${a.reason}`);let o=le(a.impact,"approving marks");o&&e.out(` ${o}`),e.out(` provenance: ${a.provenance}`),e.out(` action: ${a.action}`)}}function De(e,n){return ce({source_id:e.source_id,head:{status:e.head.status},rows:e.rows,archive:(e.changeset??[]).filter(t=>t.kind==="ARCHIVE"),changed:e.changed,held:!!e.held,defaultsTaken:n?.defaultsTaken},process.stdout.columns)}function le(e,n){if(!e||e.stale_refs.length===0)return null;let t=e.direct_refs??[];return`impact: ${n} ${e.stale_refs.length} item(s) stale`+(t.length>0?` \u2014 ${t.length} directly touched: ${t.join(", ")}`:"")}function D(e){return e==="interactive"?"override":e}async function M(e,n,t,r,i,a,o=[],w="override",f,v,s,c,_,u,E){let m;try{m=ne(e)}catch(d){return P(r,d instanceof Error?d.message:String(d)),1}try{if(!t){let{runWalkSession:d}=await import("./walk-session-AINBHZKB.js"),{telemetryEnvName:R}=await import("./bootstrap-RUJBMB2P.js");return await d({dir:e,rows:n,archive:o,held:f??null,childMode:w,runDesign:c??null,mark:a,markA:s,...v?{archiveState:v}:{},...u?{meta:{verb:"reconcile",sid:u,env:R()}}:{},...E?{resumeCmd:E}:{},signals:b=>U(e,b.ref,b.verdict,b.reason),..._?{script:_}:{}})}return await Te(e,n,t,r,i,a,o,w,f,v)}finally{m()}}var H=(e,n)=>e?`kane-cli maintain reconcile --from ${e} --source-id ${n}`:void 0,He=e=>e===null?void 0:"filePath"in e?e.filePath:e.remoteUrl,V=e=>`${e} high-risk item(s) need a human \u2014 ci mode won't guess. Walk interactively or use --mode agent.`;function F(e,n,t){let r=n.rows;e({type:"reconcile_plan",source_id:n.source_id,plan_path:t,rows:r.map(i=>({kind:i.kind,ref:i.ref,why:i.reason})),archive:n.changeset.filter(i=>i.kind==="ARCHIVE").map(i=>({ref:i.ref,why:i.why}))})}function de(e={}){return{type:"reconcile_summary",applied:0,skipped:0,deferred:0,plan_only:0,failed:0,paused:0,stale_created:0,...e}}var L=de();async function j(e,n,t,r,i,a,o,w,f){F(i,n,t);let v=n.changeset.filter(_=>_.kind==="ARCHIVE"&&f?.[_.ref]===void 0),s=n.rows,c;try{c=ne(e)}catch(_){return i({type:"error",message:_ instanceof Error?_.message:String(_)}),i(de()),2}try{return await Fe(e,n,t,r,i,a,o,s,v,w)}finally{c()}}async function Fe(e,n,t,r,i,a,o,w,f,v){let s=0,c=0,_=0,u=0,E=0,m=0,d=0,R=new Set,b=(h,p)=>{try{v?.(h,p)}catch{}};for(let[h,p]of w.entries()){i({type:"reconcile_row_start",kind:p.kind,ref:p.ref,...p.impact?{stale:p.impact.stale_refs.length,direct:p.impact.direct_refs?.length??0}:{}});let g=(l,$,x)=>i({type:"reconcile_row_end",kind:p.kind,ref:p.ref,outcome:l,...$!==void 0?{exit_code:$}:{},...x?{detail:x}:{}});if(p.applied){c++,g("skipped");continue}if(p.kind==="REMOVE"){E++,g("plan-only");continue}if(p.held_ref&&n.held){let l=new Set;if(p.kind==="MODIFY"&&p.impact){let x=I(e);for(let A of p.impact.stale_refs){let K=x.resolve(A);K&&x.stale(K.tip)==="fresh"&&l.add(A)}}let $=oe(e,n.held,p.held_ref,ue);if(!$.ok){_++,d===0&&(d=1),g("failed",1,$.message);continue}if($.kind==="ADD"){let x=await r($.ref,{yes:!0,mode:o});if(x!==0){x===3?(u++,d===0&&(d=3),g("paused",3)):(_++,d===0&&(d=1),g("failed",x));continue}}s++,$.kind!=="ADD"&&p.impact&&(m+=l.size),b(h,"approved"),U(e,p.ref,$.kind==="ADD"?"gap-resolved-create":"gap-resolved-evolve"),g("applied");continue}let y=te(I(e),p.ref);if(!y.ok){c++,g("skipped");continue}let k=y.target;if(R.has(k.ucTip)){c++,g("skipped");continue}if(p.kind==="ADD"){let l=await r(k.seamRef,{yes:!0,mode:o});if(l===3){u++,d===0&&(d=3),g("paused",3);continue}if(l!==0){_++,d===0&&(d=1),g("failed",l);continue}R.add(k.ucTip),s++,b(h,"approved"),U(e,p.ref,"gap-resolved-create"),g("applied")}else{let l=await re(e,k,{yes:!0,mode:o},a,r,"batch");l.outcome==="evolved"?(R.add(k.ucTip),s++,b(h,"approved"),U(e,p.ref,"gap-resolved-evolve"),g("applied")):l.outcome==="paused"?(u++,d===0&&(d=l.code),g("paused",l.code)):l.outcome==="failed"?(_++,d===0&&(d=1),g("failed",l.code)):(c++,g("skipped"))}}return f.length>0&&(i({type:"reconcile_paused",plan_path:t,pending:f.map(h=>({ref:h.ref,why:h.why}))}),u+=f.length,d===0&&(d=3)),i(de({applied:s,skipped:c,plan_only:E,failed:_,paused:u,stale_created:m})),d}var ue={kind:"human",id:process.env.USER??"operator"};function U(e,n,t,r){ge(e,{ts:new Date().toISOString(),command:"reconcile-walk",id:n,verdict:t,polarity:"preference",by:ue,target:n,...r!==void 0?{reason:r}:{}})}async function Te(e,n,t,r,i,a,o=[],w="override",f,v){let s=0,c=0,_=0,u=0,E=0,m=0,d=0,R=new Set;for(let[b,h]of n.entries()){if(h.applied){r.out(`skipped ${h.ref} \u2014 already applied (${h.applied.outcome} at ${h.applied.at})`),c++;continue}let p=l=>{try{a?.(b,l)}catch($){P(r,`could not record applied state for ${h.ref}: ${$ instanceof Error?$.message:String($)}`)}};if(h.kind==="REMOVE"){r.out(`REMOVE ${h.ref} \u2014 plan-only in this release (not executed)`),u++;continue}if(h.held_ref&&f){let l=oe(e,f,h.held_ref,ue);if(!l.ok){P(r,`held ${h.ref}: ${l.message}`),E++,d===0&&(d=1);continue}if(r.out(`committed ${l.ref} (${h.kind==="ADD"?"minted":"updated \u2014 old\u2192new redirect"})`),l.kind==="ADD"){let $=await i(l.ref,{yes:t,mode:w});if($===3){r.out(`design session for ${l.ref} paused \u2014 resume with the "kane-cli design tests --resume <session>" command printed above`),m++,d===0&&(d=3),p("approved");continue}if($!==0){P(r,`design run for ${l.ref} ended with exit code ${$}`),E++,d===0&&(d=1),p("approved");continue}}s++,p("approved"),U(e,h.ref,h.kind==="ADD"?"gap-resolved-create":"gap-resolved-evolve");continue}let g=I(e),y=te(g,h.ref);if(!y.ok){r.out(`skipped ${h.ref} \u2014 ${y.message}`),c++;continue}let k=y.target;if(R.has(k.ucTip)){r.out(`skipped ${h.ref} \u2014 use-case ${k.display} already handled in this walk`),c++;continue}if(h.kind==="ADD"){let l=await i(k.seamRef,{yes:t,mode:w});if(l===3){r.out(`design session for ${k.display} paused \u2014 resume with the "kane-cli design tests --resume <session>" command printed above; this row lands when that session completes`),m++,d===0&&(d=3);continue}if(l!==0){P(r,`design run for ${k.display} ended with exit code ${l}`),E++,d===0&&(d=1);continue}R.add(k.ucTip),s++,p("approved"),U(e,h.ref,"gap-resolved-create")}else{let l=await re(e,k,{yes:!0,mode:w},r,i,"batch");l.outcome==="evolved"?(R.add(k.ucTip),s++,p("approved"),U(e,h.ref,"gap-resolved-evolve")):l.outcome==="paused"?(m++,d===0&&(d=l.code)):l.outcome==="failed"?(E++,d===0&&(d=l.code)):c++}}for(let b of o)if(b.kind==="ARCHIVE"&&v?.[b.ref]===void 0){r.out(`[ARCHIVE] ${b.ref} \u2014 ${b.why}`);{let h=le(b.impact,"retiring drops");h&&r.out(` ${h}`)}r.out(" plan-only \u2014 retire belongs to the interactive session (never headless)"),u++}return r.out(`reconcile walk: ${s} applied, ${c} skipped, ${_} deferred, ${u} plan-only`+(E>0?`, ${E} failed`:"")+(m>0?`, ${m} paused`:"")),d}var Be=new Set(Z.map(e=>e.name));function z(e,n,t){let r=I(e),i=r.heads.get(n);if(i==null)return null;let a=r.mediaOf(i);if("remoteUrl"in t){let o=Q(t.remoteUrl)?.name??"remote";return a.format!==o?`source '${n}' is backed by ${a.format} content, not a ${o} source \u2014 reconcile it with the --from it was originally ingested from`:null}return Be.has(a.format)?`source '${n}' is a remote ${a.format} source \u2014 pass its URL to --from, not a file`:null}function fe(e,n,t,r){return"remoteUrl"in n?$e(e,n.remoteUrl,{out:t.out,err:t.err},r.remoteFindProvider):_e(e,n.filePath)}function Ie(e){return e.remote_url!==void 0?{remoteUrl:e.remote_url}:e.backing_path!==void 0?{filePath:e.backing_path}:null}async function Se(e,n,t,r,i,a=!1,o=!1){let w=i.seams??{reingest:fe(e,t,r,i),reextract:ae(e,{stage:a,hostOut:c=>r.out(c),hostEmit:c=>{c.type!=="run_start"&&i.emitEvent?.(c)},...i.emitEvent?{}:{hostProgress:c=>process.stderr.write(c+`
|
|
3
|
+
`)}})},f=null,v={reingest:w.reingest,reextract:async c=>f=await w.reextract(c)},s;try{r.out(`reconciling ${n}: re-reading the source and comparing against the graph\u2026`),s=await(i.buildPlan??se)(e,n,v)}catch(c){return P(r,`reconcile failed: ${c instanceof Error?c.message:String(c)}`),null}if(s.changed)if(o)for(let c of De(s,f))r.out(c);else Y(r,s,f,!1,i.emitEvent);return s}async function Ve(e){let[{render:n},t,{ScrollbackProvider:r},{ChatSurface:i},{makeChatController:a},{makeReconcileDeps:o}]=await Promise.all([import("./build-JIKYOZUH.js"),import("./react-QWOAB3TB.js"),import("./scrollback-JLPJR25X.js"),import("./ChatSurface-B3ULYDYC.js"),import("./chat-controller-R4THYYPU.js"),import("./reconcile-deps-6KTJHBMJ.js")]),w=t.default??t,f=a(),v=o({contextDir:e,note:s=>f.note(s)});return new Promise(s=>{let c=n(w.createElement(r,null,w.createElement(i,{controller:f,verb:"extract",reconcile:v,autoReview:!0,onReviewExit:()=>{c.unmount(),s(0)},onCtrlC:()=>{c.unmount(),s(v.pending()?3:0)}})),{exitOnCtrlC:!1})})}async function Le(e,n,t,r,i){let a=N(e,n);if("error"in a)return P(r,a.error),2;let{plan:o,path:w}=a,f=t==="override"||t==="ci";if(n===void 0&&t==="interactive"&&r.isTTY&&!await r.confirm(`apply plan ${G(w)} for ${o.source_id} (created ${o.created})?`))return r.out(`not applying ${G(w)}`),0;let v=i.runDesignForUc??ie,s=i.runDesignForUc??null,c=i.sessionScript,_=(h,p)=>O(w,h,p),u=(h,p)=>W(w,h,p),E=T(e);if(E===o.head_pin){if(t==="agent"){let p=i.emitEvent??(()=>{});return j(e,B(o),w,v,p,r,D(t),_,o.archive_state)}let h=ee(o);if(t==="ci"&&h.length>0)return P(r,V(h.length)),2;if(r.out(`applying stored plan ${G(w)} for ${o.source_id} (${o.rows.length} row(s))`),!f)for(let p of ce({source_id:o.source_id,head:{status:"stored plan"},rows:o.rows,archive:(o.changeset??[]).filter(g=>g.kind==="ARCHIVE"),changed:!1,held:!!o.held},process.stdout.columns))r.out(p);return M(e,o.rows,f,r,v,_,o.changeset??[],D(t),o.held,o.archive_state,u,s,c,o.source_id,H(o.backing_path??o.remote_url,o.source_id))}if(r.out(`graph moved since this plan (${C(o.head_pin)} \u2192 ${C(E)}) \u2014 recomputing`),o.held)return Ce(e,o,r,i,t,v,!1);let m=Ie(o);if(m===null)return P(r,`stored plan for ${o.source_id} names no backing file or URL \u2014 re-run reconcile --from`),2;let d=z(e,o.source_id,m);if(d!==null)return P(r,`stored plan cannot replay: ${d}`),2;let R=await Se(e,o.source_id,m,r,i,!1,t==="interactive");if(!R)return 1;if(!R.changed)return Y(r,R,null,!1,i.emitEvent),0;if(t==="agent"){let h=i.emitEvent??(()=>{});return j(e,R,null,v,h,r,D(t))}let b=R.changeset.filter(h=>h.kind==="ARCHIVE");return t==="ci"&&b.length>0?(P(r,V(b.length)),2):M(e,R.rows,f,r,v,void 0,R.changeset,D(t),R.held,void 0,void 0,s,c,R.source_id,H(He(m),R.source_id))}function B(e,n=!1){return{source_id:e.source_id,changed:!0,head:{status:"unchanged",before:e.head_pin,after:e.head_pin},note:e.note,skipped_arms:e.skipped_arms,changeset:e.changeset??[],rows:n?e.rows.filter(t=>t.applied===void 0):e.rows,...e.held?{held:e.held}:{}}}async function je(e,n,t,r,i,a,o){let w=r.runDesignForUc??null,f=r.sessionScript,v=he(e,n);if(v===null)return null;if("error"in v)return P(t,v.error),2;let{plan:s,path:c}=v,_=s.rows.filter(d=>d.applied===void 0),u=ee(s),E=r.emitEvent??(()=>{});if(_.length===0&&u.length===0){t.out(`already reconciled \u2014 plan ${s.created} applied ${s.rows.length} row(s)`);let d=ye(I(e)).staleCount;return d>0&&(t.out(`${d} item(s) still stale \u2014 kane-cli maintain evolve --from-stale`),E({type:"stale_debt",count:d})),i==="agent"&&(F(E,B(s),c),E({...L})),0}let m=T(e);return m!==s.head_pin?(t.out(`plan ${s.created} superseded \u2014 graph moved (${C(s.head_pin)} \u2192 ${C(m)}); recomputing`),Ce(e,s,t,r,i,a,o)):(t.out(`resuming plan ${s.created} \u2014 ${_.length} pending row(s)${u.length>0?`, ${u.length} undecided archive item(s)`:""}`),o?(Y(t,B(s),null,!1,r.emitEvent),t.out(`plan stored: ${c}`),i==="agent"&&(F(E,B(s),c),E({...L})),0):i==="agent"?j(e,B(s),c,a,E,t,D(i),(d,R)=>O(c,d,R),s.archive_state):i==="ci"&&u.length>0?(P(t,V(u.length)),2):M(e,s.rows,i==="override"||i==="ci",t,a,(d,R)=>O(c,d,R),s.changeset??[],D(i),s.held,s.archive_state,(d,R)=>W(c,d,R),w,f,s.source_id,H(s.backing_path??s.remote_url,s.source_id)))}async function Ce(e,n,t,r,i,a,o){let w=r.runDesignForUc??null,f=r.sessionScript,v;if(n.held){let g=I(e),y=new Set(n.rows.filter(l=>l.held_ref!==void 0&&l.applied!==void 0).map(l=>l.held_ref)),k=[];for(let l of n.held.rows){if(y.has(l.temp_ref))continue;if(!l.matched_cid){k.push(l);continue}let $=g.tipOf(l.matched_cid);if(g.superseded.get($)===null){t.out(`dropped held "${l.title}" \u2014 its use-case was retired meanwhile`),r.emitEvent?.({type:"held_dropped",ref:l.temp_ref,title:l.title,reason:"target_retired"});continue}k.push($===l.matched_cid?l:{...l,matched_cid:$,uc:{...l.uc,matches_existing:{cid:$}}})}v={source_id:n.held.source_id,rows:k}}let s=Ie(n);if(s===null)return P(t,`stored plan for ${n.source_id} names no backing file or URL \u2014 re-run reconcile --from`),2;let c=z(e,n.source_id,s);if(c!==null)return P(t,`stored plan cannot replay: ${c}`),2;let _=r.seams??{reingest:fe(e,s,t,r),reextract:ae(e,{stage:v!==void 0,hostOut:g=>t.out(g),hostEmit:g=>{g.type!=="run_start"&&r.emitEvent?.(g)},...r.emitEvent?{}:{hostProgress:g=>process.stderr.write(g+`
|
|
4
|
+
`)}})},u;try{u=await(r.buildPlan??se)(e,n.source_id,_,{resumeHeld:v})}catch(g){return P(t,`reconcile failed: ${g instanceof Error?g.message:String(g)}`),1}if(i==="interactive"&&!o)for(let g of De(u,null))t.out(g);else Y(t,u,null,!1,r.emitEvent);let E=T(e),m=null;if(E!=null){let g={},y=new Set(u.changeset.filter(k=>k.kind==="ARCHIVE").map(k=>k.ref));for(let[k,l]of Object.entries(n.archive_state??{}))y.has(k)&&(g[k]=l);m=X(e,{version:2,source_id:u.source_id,...n.remote_url!==void 0?{remote_url:n.remote_url}:{backing_path:n.backing_path},head_pin:E,created:new Date().toISOString().replace(/[:.]/g,"-"),skipped_arms:u.skipped_arms,note:u.note,changeset:u.changeset,rows:u.rows,...u.held?{held:u.held}:{},...Object.keys(g).length>0?{archive_state:g}:{}}),t.out(`plan stored: ${m}`)}if(o){if(i==="agent"){let g=r.emitEvent??(()=>{});F(g,u,m),g({...L})}return 0}let d=r.emitEvent??(()=>{}),R=m?N(e,m).plan.archive_state:void 0,b=m?(g,y)=>O(m,g,y):void 0,h=m?(g,y)=>W(m,g,y):void 0;if(i==="agent")return j(e,u,m,a,d,t,D(i),b,R);let p=u.changeset.filter(g=>g.kind==="ARCHIVE"&&R?.[g.ref]===void 0);return i==="ci"&&p.length>0?(P(t,V(p.length)),2):M(e,u.rows,i==="override"||i==="ci",t,a,b,u.changeset,D(i),u.held,R,h,w,f,u.source_id,H(n.backing_path??n.remote_url,u.source_id))}async function be(e,n,t={},r=process.cwd()){let{telemetryBootstrap:i,telemetryEnvName:a}=await import("./bootstrap-RUJBMB2P.js"),o=i({verb:"reconcile",mode:typeof e.mode=="string"?e.mode:"interactive",contextRoot:q(r,".context"),env:a(),applyPlanPath:typeof e.apply=="string"?q(r,e.apply):void 0,write:!0,longSession:!0});e.mode==="agent"&&t.emitEvent?.({type:"run_start",session:o.ids.session_id});let w=await Ye(e,n,t,r);return w===1&&e.mode!=="agent"&&(n.err??n.out)(o.supportFooter()),await o.end({exit_code:w}),w}async function Ye(e,n,t={},r=process.cwd()){let i=e.apply!==void 0&&e.apply!==!1,a=typeof e.apply=="string"?e.apply:void 0;if(e.plan&&i)return P(n,"pass --plan OR --apply, not both"),2;let o=e.from!==void 0||!i,w=e.from!==void 0&&J(e.from);if(o&&(!e.from||!e.sourceId&&!w))return P(n,"reconcile needs --from <file|url> AND --source-id <id> (files only \u2014 a URL derives its own id) \u2014 see `kane-cli context list --type source` for ids"),2;if(e.from&&a!==void 0)return P(n,"pass --from OR --apply <path>, not both \u2014 a stored plan names its own source"),2;let f=we(r,n);if(!f)return 2;if(e.mode!==void 0&&!xe.has(e.mode))return Pe(`--mode must be interactive | agent | ci | override, got '${e.mode}'`);let v=e.mode==="agent"||e.mode==="ci"||e.mode==="override";if(i&&!v&&!n.isTTY)return P(n,"refusing to apply without a TTY to confirm \u2014 pass --mode override|ci"),2;let s=!e.plan,c="override";if(e.from){let y=Ae(e,n.isTTY);if(typeof y=="object")return y.code==="MODE_USAGE"?Pe(y.error):(P(n,y.error),2);c=y}let _=c==="override"||c==="ci";if(i&&!e.from){let{makeReconcileDeps:y}=await import("./reconcile-deps-6KTJHBMJ.js"),k=a===void 0?y({contextDir:f}).pending():null;if(k?.kind==="cards"){let $=e.mode??"interactive";return!n.isTTY||$!=="interactive"?(P(n,`a held changeset for ${k.source} awaits review (${k.count} change(s)) \u2014 resume in a terminal: kane-cli maintain reconcile --apply [HELD_REVIEW]`),2):(t.cardApplyMount??Ve)(f)}let l=e.mode??"interactive";return Le(f,a===void 0?void 0:q(r,a),l,n,t)}let u=Me(f,r,e.from,e.sourceId);if("error"in u)return P(n,u.error),2;if(!i){let{sessionsHoldingSource:y}=await import("./sessions-GIEXOCE4.js"),{holders:k,corrupt:l}=y(f,u.sourceId);if(l>0)return P(n,`cannot verify review holds \u2014 ${l} session file(s) unreadable; inspect with kane-cli context sessions list, clean with kane-cli context sessions clean, then retry [SESSIONS_UNREADABLE]`),2;if(k.length>0)return P(n,`session ${k[0]} holds item(s) for review pinned to ${u.sourceId} \u2014 finish that review first: kane-cli context extract --resume ${k[0]} [SOURCE_HELD]`),2}if(c==="interactive"&&!e.plan&&!i){let y=t.seams?.reingest??fe(f,u,n,t),k;try{k=await y(u.sourceId)}catch($){return P(n,$ instanceof Error?$.message:String($)),1}let l=k.status==="unchanged"?null:Re(f,u.sourceId);if(k.status!=="unchanged"&&!l)return n.out(`${u.sourceId} landed for the first time \u2014 extract it: kane-cli context extract --source ${u.sourceId}`),0;if(l){let x=await(t.chatMount??(async A=>{let{bindExtractInteractive:K}=await import("./extract-bind-EXW32RUY.js");return K(A)}))({mode:"interactive",posture:"reconcile",source:u.sourceId,changeContext:l});if(x===3){let{sessionsHoldingSource:A}=await import("./sessions-GIEXOCE4.js");if(A(f,u.sourceId).holders.length===0)return 0}return x}}let E="remoteUrl"in u?{remoteUrl:u.remoteUrl}:{filePath:u.filePath},m=await Se(f,u.sourceId,E,n,t,!!e.plan||c==="interactive",c==="interactive"&&!e.plan);if(!m)return 1;let d=t.runDesignForUc??ie,R=t.runDesignForUc??null,b=t.sessionScript;if(!m.changed){let y=await je(f,u.sourceId,n,t,c,d,!!e.plan);if(y!==null)return y;if(Y(n,m,null,!1,t.emitEvent),c==="agent"){let k=t.emitEvent??(()=>{});F(k,m,null),k({...L})}return 0}let h=T(f),p=null;if(h!=null?p=X(f,{version:2,source_id:m.source_id,..."remoteUrl"in E?{remote_url:E.remoteUrl}:{backing_path:E.filePath},head_pin:h,created:new Date().toISOString().replace(/[:.]/g,"-"),skipped_arms:m.skipped_arms,note:m.note,changeset:m.changeset,rows:m.rows,...m.held?{held:m.held}:{}}):P(n,"no chain head after extract \u2014 plan not stored"),c==="agent"){let y=t.emitEvent??(()=>{});if(!s)return F(y,m,p),y({...L}),0;let k=p?(l,$)=>O(p,l,$):void 0;return j(f,m,p,d,y,n,D(c),k)}if(!s)return p&&n.out(`plan stored: ${p}`),0;let g=m.changeset.filter(y=>y.kind==="ARCHIVE");if(c==="ci"&&g.length>0)return p&&n.out(`plan stored: ${p}`),P(n,V(g.length)),2;if(p){n.out(`plan stored: ${p}`);let y=p;return M(f,Ke(f,y)??m.rows,_,n,d,(k,l)=>O(y,k,l),m.changeset,D(c),m.held,void 0,void 0,R,b,m.source_id,H(e.from,m.source_id))}return M(f,m.rows,_,n,d,void 0,m.changeset,D(c),m.held,void 0,void 0,R,b,m.source_id,H(e.from,m.source_id))}function Ke(e,n){let t=N(e,n);return"error"in t?null:t.plan.rows}async function dn(e,n={},t,r=process.cwd()){if(e.mode==="agent"){let{makeHeadlessIO:i}=await import("./headless-io-66RG5NN5.js"),a=t?i("ndjson","reconcile",t):i("ndjson","reconcile"),o={out:a.out,err:v=>a.event({type:"error",message:v}),isTTY:!1,confirm:async()=>!1,ask:async()=>""},{runWithChannel:w}=await import("./run-channel-RGH4WIQX.js"),f=2;try{f=await w({event:v=>a.event(v)},()=>be(e,o,{...n,emitEvent:v=>a.event(v)},r))}catch(v){f=1,a.event({type:"error",message:v instanceof Error?v.message:String(v)})}return a.done(f)}return be(e,ke(),n,r)}export{Ae as a,Me as b,D as c,U as d,be as e,dn as f};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as n}from"./chunk-
|
|
2
|
+
import{a as n}from"./chunk-7F2ZV46B.js";import{createHash as _}from"crypto";import{existsSync as m,readFileSync as u}from"fs";import{dirname as T,join as f,resolve as o}from"path";import{fileURLToPath as E}from"url";var s=T(E(import.meta.url)),l=2;function p(e,r){let t=_("sha256");return t.update(`kane-assurance-contract
|
|
3
3
|
`),t.update(e),t.update(`
|
|
4
4
|
agent_state_schema=${r}`),"sha256:"+t.digest("hex")}function d(){return[o(s,".."),o(s,"../../..")]}function i(){return"sha256:85dd52f33a9fd9cf22ebb81f04dfd3c05bdbeca2e62e3a7a53e8caaaa4060752"}var a=class extends Error{constructor(t,c){super(`agent/cli contract mismatch (cli ${t||"<unset>"}, agent ${c||"<unset>"}) \u2014 rebuild or reinstall the stale half`);this.expected=t;this.actual=c;this.name="PairMismatchError"}};function I(){return{TESTMUAI_CONTRACT_DIGEST:i(),TESTMUAI_CLIENT_VERSION:process.env.KANE_DEV_FORCE_CLIENT_RELEASE??`kane-cli/${n}`}}export{a,I as b};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{a as j}from"./chunk-CLGC7VEO.js";import{d as K}from"./chunk-RKXHVP2Z.js";import{a as L}from"./chunk-5Y2G4NC7.js";import{a as M}from"./chunk-YCCUBQY4.js";import{y as s}from"./chunk-7F2ZV46B.js";import{a as O}from"./chunk-HCBYKLMW.js";import{a as x,b as n,i as D,k as E}from"./chunk-C44QQJR4.js";import{a as I}from"./chunk-6YGTRKDT.js";import{e as y}from"./chunk-UR6MHSHU.js";var g=y(O(),1);function ee(e){let t=e.findIndex(r=>r.free);return t>=0?t:null}var q=60,Q=100;function te({headline:e,ask:t=!1,rows:r,sel:o,focused:d,freeText:c=null,freeTextNote:h,sublines:b=[]}){let{stdout:p}=E(),i=p?.columns??80,v=i<q,k=Math.min(i-1,Q),u=a=>d&&o===a?(0,g.jsx)(n,{color:s.assuranceAccent,children:"\u276F"}):" ",m=t?`? ${e}`:e,A=Math.max(4,k-3),S=b.map((a,w)=>(0,g.jsx)(n,{color:s.dim,children:` ${a.length>A?`${a.slice(0,A-1)}\u2026`:a}`},`sub-${w}`)),R=0,B=r.map((a,w)=>a.free?c?(0,g.jsxs)(x,{flexDirection:"column",children:[(0,g.jsxs)(x,{children:[(0,g.jsxs)(n,{children:[(0,g.jsx)(n,{color:s.assuranceAccent,children:"\u276F"})," ",(0,g.jsx)(n,{color:s.dim,children:"\u270E "})]}),(0,g.jsx)(M,{value:c.value,onChange:c.onChange,onSubmit:c.onSubmit,onCancel:c.onCancel,placeholder:a.label})]}),h?(0,g.jsx)(n,{color:s.muted,children:` ${h}`}):null]},a.key):(0,g.jsxs)(n,{children:[u(w)," ",(0,g.jsx)(n,{color:s.dim,children:`\u270E ${a.label}`})]},a.key):(R+=1,(0,g.jsxs)(n,{bold:d&&o===w,children:[u(w),` ${R}. ${a.label}`,a.detail?(0,g.jsx)(n,{color:s.dim,bold:!1,children:` \u2014 ${a.detail}`}):null]},a.key)));return v?(0,g.jsxs)(x,{marginTop:1,marginBottom:1,flexDirection:"column",children:[(0,g.jsx)(n,{bold:!0,color:s.assuranceAccent,children:m}),S,B]}):(0,g.jsxs)(x,{marginTop:1,marginBottom:1,flexDirection:"column",children:[(0,g.jsx)(n,{bold:!0,color:s.assuranceAccent,children:m}),S,(0,g.jsx)(n,{children:" "}),B]})}var H=y(I(),1);var $=y(O(),1),N=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function le(e){let t=e.replace(/…$/,"");return t&&t.charAt(0).toLowerCase()+t.slice(1)}function F(e,t){if(e.length<=t)return e;if(t<=1)return"\u2026";let r=Math.ceil((t-1)/2),o=Math.floor((t-1)/2);return`${e.slice(0,r)}\u2026${o>0?e.slice(-o):""}`}function ce({status:e,meta:t,tallies:r,keys:o,child:d,cols:c}){let{stdout:h}=E(),b=c??h?.columns??80,p=e.kind==="working"||e.kind==="child-working",[i,v]=(0,H.useState)(0);L(()=>v(f=>f+1),p?120:null);let k=N[i%N.length],u,m;switch(e.kind){case"working":u=`${k} ${e.step}${e.elapsedS!==void 0?` \xB7 ${e.elapsedS}s`:""}`,m=s.assuranceAccent;break;case"waiting":u=`\u25CF waiting on you${e.pending?` \u2014 ${e.pending} question${e.pending===1?"":"s"}`:""}`,m=s.amber;break;case"idle":u="\u25CF idle",m=s.assuranceAccent;break;case"card":u=`\u25CF card ${e.n} of ${e.m}`,m=s.amber;break;case"child-working":u=`${k} child: ${e.step}`,m=s.assuranceAccent;break;case"child-waiting":u="\u25CF child waiting on you",m=s.amber;break}let A=d?`${t.verb} \u25B8 ${d.verb}`:t.verb,S=d?.sid?t.sid?`${F(t.sid,14)} \u25B8 ${d.sid}`:d.sid:t.sid,R=t.env==="prod"?"":t.env,B=[A,S,R].filter(Boolean),a=" \xB7 ",w=u.length+a.length+B.join(a).length,C=t.subject;if(C){let f=b-w-a.length;C=f>=8?F(C,f):void 0}let _=[A,...C?[C]:[],S,R].filter(Boolean).join(a);return(0,$.jsxs)(x,{flexDirection:"column",children:[(0,$.jsx)(n,{color:s.muted,children:"\u2500".repeat(Math.max(1,b))}),(0,$.jsxs)(n,{children:[(0,$.jsx)(n,{color:m,children:u}),(0,$.jsx)(n,{color:s.dim,children:`${a}${_}`})]}),(0,$.jsx)(n,{color:s.dim,children:r.items.length>0?r.items.join(a):" "}),(0,$.jsx)(n,{color:s.muted,children:o.join(a)})]})}var P=y(I(),1);function ue({onToggleThinking:e,onCtrlC:t,explorer:r,panel:o}){let c=(0,P.useRef)(null),h=(0,P.useRef)(""),b=()=>{c.current&&clearTimeout(c.current),c.current=null,h.current=""};return(0,P.useEffect)(()=>b,[]),D((p,i)=>{if(i.ctrl&&p==="t"){e();return}if(i.ctrl&&p==="c"){t();return}if(!i.ctrl&&p.includes("")){t();return}if(!i.ctrl&&p.includes("")){e();return}if(r&&r.isOpen()){let v=()=>{c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{b(),r.onBack()},150)};if(c.current){if(i.upArrow||i.downArrow||i.return){b(),i.return?r.onEnter():r.onMove(i.upArrow?-1:1);return}if(h.current+=p,h.current==="["){v();return}let k=h.current;b();let u=/^\[([ABCD])/.exec(k);if(u){(u[1]==="A"||u[1]==="B")&&r.onMove(u[1]==="A"?-1:1);return}r.onBack();return}if(i.upArrow){r.onMove(-1);return}if(i.downArrow){r.onMove(1);return}if(i.return){r.onEnter();return}if(i.escape){h.current="",v();return}return}if(o&&o.isFocused()){let v=()=>{c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{b(),o.onBack()},150)};if(c.current){if(i.upArrow||i.downArrow||i.return||i.leftArrow||i.rightArrow){b(),i.return?o.onSelect():i.leftArrow?o.onLeft?.():i.rightArrow?o.onRight?.():o.onMove(i.upArrow?-1:1);return}if(h.current+=p,h.current==="["){v();return}let k=h.current;b();let u=/^\[([ABCD])/.exec(k);if(u){u[1]==="A"||u[1]==="B"?o.onMove(u[1]==="A"?-1:1):u[1]==="C"?o.onRight?.():o.onLeft?.();return}o.onBack();return}if(i.upArrow){o.onMove(-1);return}if(i.downArrow){o.onMove(1);return}if(i.leftArrow){o.onLeft?.();return}if(i.rightArrow){o.onRight?.();return}if(i.return){o.onSelect();return}if(i.escape){h.current="",v();return}if(/^[1-9]$/.test(p)){o.onDigit(Number(p));return}if(i.tab){o.onTab?.();return}if(p===" "&&o.isMulti()){o.onSpace();return}if(p&&!i.ctrl&&!i.meta){o.onType(p);return}return}}),null}var l=y(O(),1);function X(e){return e.kind==="REVIEW"?[{v:"approve",label:"approve",detail:"mark it reviewed and trusted"},{v:"archive",label:"archive",detail:"reject it \u2014 asks for a reason; impact shown above"},{v:"defer",label:"defer",detail:"not now \u2014 stays queued"}]:e.kind==="PAIR"?[{v:"merge",label:"merge",detail:"duplicate \u2014 fold into the older item (it stays unreviewed)"},{v:"keep_both",label:"keep both",detail:"genuinely distinct \u2014 promote both"},{v:"defer",label:"defer",detail:"not now \u2014 stays queued"}]:e.kind==="ARCHIVE"?[{v:"archive",label:"retire",detail:"hidden from now on; history is kept and it can be reverted"},{v:"skip",label:"skip",detail:"keep it \u2014 decided, never re-offered"},{v:"defer",label:"defer",detail:"not now \u2014 the plan re-offers it"}]:e.heldPayload?[{v:"approve",label:"approve update",detail:"commit the held payload \u2014 impact preview above"},{v:"skip",label:"keep current",detail:"drop the held payload (the owner's disk state stays untouched)"},{v:"defer",label:"defer",detail:"not now \u2014 stays held"}]:[{v:"approve",label:"approve",detail:e.kind==="ADD"?"commit + design it":"commit the updated version (old\u2192new redirect)"},{v:"skip",label:e.origin==="content-change"?"reject":"skip",detail:e.origin==="content-change"?"drop the staged proposal \u2014 nothing committed":"leave it as is"},{v:"defer",label:"defer",detail:"not now \u2014 the plan keeps it staged"}]}function V(e){let t=X(e);return e.viewDiff&&t.push({v:"view_diff",label:"view diff",detail:"full old \u2192 new"}),t}function W(e){return e.kind==="ARCHIVE"?null:V(e).length}var Y={ADD:{color:s.green??"green"},MODIFY:{color:"yellow"},ARCHIVE:{color:s.red},REVIEW:{color:"cyan"},PAIR:{color:"magenta"}},U=60;function be({card:e,position:t,sel:r=0,focused:o=!1,freeText:d=null,editorIntent:c="steer"}){let{stdout:h}=E(),b=h?.columns??80,p=b<U,i=V(e),v=W(e),k=Y[e.kind],u=f=>o&&r===f?(0,l.jsx)(n,{color:s.assuranceAccent,children:"\u276F"}):" ",m=e.impact,A=m&&"stale_refs"in m&&m.stale_refs.length>0?`${e.kind==="ARCHIVE"?"retiring leaves":"approving marks"} ${m.stale_refs.length} item(s) stale`+((m.direct_refs?.length??0)>0?` \u2014 ${m.direct_refs.length} directly touched: ${m.direct_refs.join(", ")}`:""):m&&"design_children"in m?`${e.kind==="REVIEW"?"archiving drops":"merging folds"} ${m.design_children} design child(ren)`:null,S=e.provenance&&e.provenance!==e.why?e.provenance:e.origin??null,R=[{label:"why",text:e.why},...S?[{label:"from",text:S,dimmer:!0}]:[],...e.tier?[{label:"match",text:e.tier,dimmer:!0}]:[],...A?[{label:"impact",text:A}]:[]],B=Math.max(...R.map(f=>f.label.length)),a="? reconcile",w=`item ${t.n} of ${t.of}`,C=(0,l.jsxs)(x,{flexDirection:"column",children:[(0,l.jsx)(x,{paddingLeft:2,children:(0,l.jsxs)(n,{bold:!0,children:[(0,l.jsx)(n,{color:k.color,children:`[${e.kind}]`}),` ${j(e.title)}`]})}),R.map((f,T)=>(0,l.jsx)(x,{paddingLeft:2,children:(0,l.jsxs)(n,{children:[(0,l.jsx)(n,{color:s.dim,children:`${f.label.padEnd(B)} `}),(0,l.jsx)(n,{color:f.dimmer?s.dim:void 0,children:f.text})]})},`f-${T}`)),e.diffSummary?(0,l.jsx)(x,{paddingLeft:2,children:(0,l.jsx)(n,{color:s.dim,children:e.diffSummary})}):(e.diff??[]).map((f,T)=>(0,l.jsx)(x,{paddingLeft:4,children:(0,l.jsx)(n,{color:f.op==="-"?"red":"green",children:`${f.op==="-"?"\u2212":"+"} ${f.field==="criteria"?"criterion":f.field}: ${f.text}`})},`d-${T}`)),(e.citeLines??[]).map((f,T)=>(0,l.jsx)(x,{paddingLeft:2,children:(0,l.jsx)(n,{color:s.dim,children:f})},`c-${T}`)),(0,l.jsx)(n,{children:" "}),i.map((f,T)=>(0,l.jsxs)(n,{children:[u(T),` ${T+1}. ${f.label}`,(0,l.jsx)(n,{color:s.dim,children:` \u2014 ${f.detail}`})]},`o-${T}`)),v!==null||d&&c==="because"?d?(0,l.jsxs)(x,{flexDirection:"column",children:[(0,l.jsxs)(x,{children:[(0,l.jsxs)(n,{children:[(0,l.jsx)(n,{color:s.assuranceAccent,children:"\u276F"})," ",(0,l.jsx)(n,{color:s.dim,children:"\u270E "})]}),(0,l.jsx)(M,{value:d.value,onChange:d.onChange,onSubmit:d.onSubmit,onCancel:d.onCancel,placeholder:c==="because"?"why archive it?":"say what to adjust"})]}),(0,l.jsx)(n,{color:s.muted,children:c==="because"?" submits as: archive \xB7 your reason goes on the record":e.kind==="PAIR"?" submits as: defer \xB7 your note parks with the card (it re-offers)":" submits as: approve \xB7 your words steer the re-design"})]}):v!==null?(0,l.jsxs)(n,{children:[u(v)," ",(0,l.jsx)(n,{color:s.dim,children:e.kind==="PAIR"?"\u270E defer with a note \u2014 say what you noticed":"\u270E approve with changes \u2014 say what to adjust"})]}):null:null]});if(p)return(0,l.jsxs)(x,{marginTop:1,marginBottom:1,flexDirection:"column",children:[(0,l.jsx)(n,{bold:!0,color:s.assuranceAccent,children:a}),(0,l.jsx)(n,{color:s.dim,children:w}),C]});let _=Math.max(2,Math.min(b-1,100)-a.length-w.length);return(0,l.jsxs)(x,{marginTop:1,marginBottom:1,flexDirection:"column",children:[(0,l.jsxs)(n,{children:[(0,l.jsx)(n,{bold:!0,color:s.assuranceAccent,children:a})," ".repeat(_),(0,l.jsx)(n,{color:s.dim,children:w})]}),(0,l.jsx)(n,{children:" "}),C]})}var z={"acceptance criteria":1,scenarios:2,"acceptance criteria + exercises":3,"tests + gaps":4};function we(e,t){let r=[],o=K(e.turns).entries.length;if(t==="design"){let c;for(let b=e.ledger.length-1;b>=0;b--){let p=e.ledger[b];if(p.kind==="banner"&&p.text.startsWith("designing: ")){c=p.text.slice(11);break}}let h=c?z[c]:void 0;h&&r.push(`phase ${h}/4`),o>0&&r.push(`${o} item${o===1?"":"s"} this session`)}else o>0&&r.push(`${o} saved as draft${o===1?"":"s"}`);let d=e.pending?e.pending.resolution.filter(c=>!c).length:0;return d>0&&r.push(`${d} question${d===1?"":"s"} pending`),e.credits&&r.push(`${e.credits.total.toFixed(1)} credits`),{items:r}}function ke(e,t){let r=[],o=e.applied+e.committed+e.retired;r.push(`${o} applied`),r.push(`${t} to decide`);let d=[];return e.skipped>0&&d.push(`${e.skipped} skipped`),e.deferred>0&&d.push(`${e.deferred} deferred`),e.failed>0&&d.push(`${e.failed} failed`),{items:[...r,...d]}}function Ae(e,t){let r=["\u2191\u2193 select","\u23CE confirm"];return e.multi_select&&r.push("space toggle"),t.batchCount>1&&r.push("\u2190 \u2192 questions"),(e.allow_free_text||e.options.some(o=>o.input===!0))&&r.push("\u270E type your own"),t.canAttach&&r.push("@ attach a file or URL"),t.escBack&&r.push("esc back"),{keys:r}}function Se(e,t){let r=["\u2191\u2193 select","\u23CE confirm"];return e.some(o=>o.free)&&r.push("\u270E type your own"),t.escBack&&r.push("esc back"),{keys:r}}function Re(e){let t=["\u2191\u2193 select","\u23CE confirm","1-9 verdict"];return W(e)!==null&&t.push("type = adjust"),t.push("esc \xB7 nothing to undo"),{keys:t}}export{ee as a,te as b,le as c,ce as d,ue as e,X as f,V as g,W as h,be as i,we as j,ke as k,Ae as l,Se as m,Re as n};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as R}from"./chunk-
|
|
2
|
+
import{a as R}from"./chunk-U5GHOGLM.js";import{y as i}from"./chunk-7F2ZV46B.js";import{a as X}from"./chunk-HCBYKLMW.js";import{a,b as l,i as p}from"./chunk-C44QQJR4.js";import{a as G}from"./chunk-6YGTRKDT.js";import{e as P}from"./chunk-UR6MHSHU.js";var x=P(G(),1);var e=P(X(),1),f=5;function K(t,I){if(!I)return t;let c=I.toLowerCase();return t.filter(B=>B.label.toLowerCase().includes(c))}function J(t){let{title:I,items:c,loading:B=!1,loadingText:Y,error:L=null,itemNoun:v="items",onSelect:F,onCancel:E,defaultActiveId:w,onTab:y,extraHint:H}=t,[g,d]=(0,x.useState)(0),[S,u]=(0,x.useState)(0),[s,A]=(0,x.useState)(""),[C,h]=(0,x.useState)(null);(0,x.useEffect)(()=>{if(c.length===0)return;if(t.preserveSelectionById&&C!==null){let o=c.findIndex(n=>n.id===C);if(o>=0){u(Math.floor(o/f)),d(o%f);return}}let r=w?c.findIndex(o=>o.id===w):c.findIndex(o=>o.isActive);r>=0?(u(Math.floor(r/f)),d(r%f),t.preserveSelectionById&&h(c[r].id)):t.preserveSelectionById&&(u(0),d(0),h(c[0]?.id??null))},[c,w,t.preserveSelectionById,C]),(0,x.useEffect)(()=>{if(!t.onSearch)return;let r=setTimeout(()=>t.onSearch(s),t.searchDebounceMs??250);return()=>clearTimeout(r)},[s,t.onSearch,t.searchDebounceMs]);let b=t.onSearch?c:K(c,s),D=S*f,N=Math.min(D+f,b.length),M=Math.ceil(b.length/f),O=N-D,T=b.slice(D,N);return p((r,o)=>{if(L){o.escape&&E();return}if(o.escape){s?(A(""),d(0),u(0)):E();return}if(o.tab&&y){y();return}if(o.upArrow){if(g>0){let n=g-1;d(n),t.preserveSelectionById&&h(T[n]?.id??null)}else if(S>0){let n=S-1,m=f-1;u(n),d(m),t.preserveSelectionById&&h(b[n*f+m]?.id??null)}return}if(o.downArrow){if(g<O-1){let n=g+1;d(n),t.preserveSelectionById&&h(T[n]?.id??null)}else if(S<M-1){let n=S+1,m=0;u(n),d(m),t.preserveSelectionById&&h(b[n*f+m]?.id??null)}return}if(o.return&&T[g]){if(T[g].disabled)return;F(T[g]);return}if(o.backspace||o.delete){A(n=>n.slice(0,-1)),d(0),u(0);return}r&&!o.ctrl&&!o.meta&&(A(n=>n+r),d(0),u(0))},{isActive:!B}),B?(0,e.jsxs)(a,{flexDirection:"column",borderStyle:"round",borderColor:i.orange,paddingX:2,paddingY:1,children:[(0,e.jsx)(l,{color:i.orange,bold:!0,children:I}),(0,e.jsx)(a,{marginTop:1,children:(0,e.jsx)(l,{color:i.secondary,children:Y??`Loading ${v}\u2026`})})]}):L?(0,e.jsxs)(a,{flexDirection:"column",borderStyle:"round",borderColor:i.red,paddingX:2,paddingY:1,children:[(0,e.jsx)(l,{color:i.red,bold:!0,children:I}),(0,e.jsx)(a,{marginTop:1,children:(0,e.jsx)(l,{color:i.red,children:L})}),(0,e.jsx)(R,{bindings:[]})]}):(0,e.jsxs)(a,{flexDirection:"column",borderStyle:"round",borderColor:i.orange,paddingX:2,paddingY:1,children:[(0,e.jsxs)(a,{children:[(0,e.jsx)(l,{color:i.orange,bold:!0,children:I}),(0,e.jsxs)(l,{color:i.dim,children:[" (",b.length,!t.onSearch&&s?`/${c.length}`:""," ",v,t.loadingMore?" \xB7 loading more":"",")"]})]}),(0,e.jsxs)(a,{marginTop:1,children:[(0,e.jsx)(l,{color:i.secondary,children:s?"filter: ":""}),s?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(l,{children:s}),(0,e.jsx)(l,{inverse:!0,children:" "})]}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)(l,{color:i.dim,children:["Search ",v,"\u2026"]}),(0,e.jsx)(l,{inverse:!0,children:" "})]})]}),(0,e.jsx)(a,{flexDirection:"column",marginTop:1,children:t.searching?(0,e.jsxs)(l,{color:i.secondary,children:["Searching ",v,"\u2026"]}):b.length===0?(0,e.jsxs)(l,{color:i.dim,children:["No ",v,' match "',s,'"']}):T.map((r,o)=>{let n=o===g,m=n?"\u276F ":" ",$=r.disabled?i.muted:r.isActive?i.green:n?i.orange:void 0;return(0,e.jsxs)(a,{flexDirection:"column",children:[(0,e.jsxs)(l,{color:$,children:[m,r.label,r.isActive&&!r.disabled?" \u25CF selected":""]}),n&&r.disabled&&r.disabledHint&&(0,e.jsxs)(l,{color:i.red,children:[" ",r.disabledHint]})]},r.id)})}),!t.searching&&M>1&&(0,e.jsx)(a,{marginTop:1,children:(0,e.jsxs)(l,{color:i.dim,children:["Page ",S+1,"/",M]})}),t.footer&&(0,e.jsx)(a,{marginTop:1,flexDirection:"column",children:t.footer}),(0,e.jsx)(R,{bindings:[{keys:"\u2191\u2193",label:"navigate"},{keys:"type",label:"to search"},{keys:"\u21B5",label:"select"},...y&&H?[{keys:"tab",label:H}]:[]],escBackLabel:s?"clear":"back to chat"})]})}export{J as a};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
var u=(n,t)=>n.length<=t?n:t<=1?"\u2026":`${n.slice(0,t-1)}\u2026`,a=(n,t)=>n+" ".repeat(Math.max(0,t-n.length));function c(n,t,o,e){return n+e.map(r=>"\u2500".repeat(r+2)).join(t)+o}function h(n,t,o,e=n.length-1){let r=n.map((i,g)=>Math.max(i.length,...t.map(p=>(p[g]??"").length),1)),s=n.length*3+1,m=r.reduce((i,g)=>i+g,0)+s-o;return m>0&&(r[e]=Math.max(7,r[e]-m)),r}function l(n,t,o=100,e){let r=h(n,t,o,e),s=m=>"\u2502 "+r.map((i,g)=>a(u(m[g]??"",i),i)).join(" \u2502 ")+" \u2502";return[c("\u250C","\u252C","\u2510",r),s(n),c("\u251C","\u253C","\u2524",r),...t.map(s),c("\u2514","\u2534","\u2518",r)]}export{u as a,a as b,c,l as d};
|
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{a as Ke}from"./chunk-KHU7C6EE.js";import{c as Ve}from"./chunk-IOD3HQVW.js";import{a as We,b as ue}from"./chunk-3Q6WAK6P.js";import{a as Ue,b as ze}from"./chunk-JZ26R6UL.js";import{a as Z,b as je,e as le,f as de,g as Me,h as He}from"./chunk-RN4PKQFR.js";import{a as Ne,c as Le,d as Be,e as me,f as Ge}from"./chunk-ZGBSGZZM.js";import{a as Ae,b as Ie,c as Pe}from"./chunk-7S3JZ6FQ.js";import{a as Ee,b as Ce,c as Te}from"./chunk-BB2W35TW.js";import{a as qe}from"./chunk-L2TV4G56.js";import{c as Oe}from"./chunk-6KPPGMO2.js";import{a as $e,e as Re}from"./chunk-GFKCTYCA.js";import{a as Fe}from"./chunk-IMR64OCZ.js";import{b as be,c as we,d as ve,e as ae,f as oe,g as ce}from"./chunk-ZPDM6FO7.js";import{a as ne}from"./chunk-L5LI2JF4.js";import{a as ye,b as re}from"./chunk-IDX3TOPY.js";import{A as U}from"./chunk-TH47OOBV.js";import{f as De}from"./chunk-DUAXZYAD.js";import{a as ke,e as xe,f as Se}from"./chunk-DBIBROYW.js";import{d as W,e as X}from"./chunk-WXHQYYD5.js";import{a as _e}from"./chunk-5EOX4MEY.js";import{mkdirSync as St,appendFileSync as Dt,rmdirSync as dt}from"fs";import{randomBytes as $t}from"crypto";import{dirname as mt,join as he}from"path";function Qe(t,e){let n=[];for(let i of e??[]){let g=t.resolve(i.ref)?.tip??null;g!==i.cid&&n.push({ref:i.ref,pinned:i.cid,now:g})}return n}import{existsSync as ge,readFileSync as pe,readdirSync as pt}from"fs";import{join as te}from"path";var Ye=`
|
|
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 Je={"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 Xe=`
|
|
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 ft=["presence","forbidden-presence","count","delta","state-transition","absolute","bound","propagation","latency","graded"];function tt(t,e){for(let n of t)if(!ft.includes(n))throw new Error(`${e}: emits '${n}' is not an oracle kind`)}function Ze(t,e){let n=ne(t);if(!n||!Array.isArray(n.techniques))throw new Error(`${e}: expected { techniques: [...] }`);for(let i of n.techniques){if(!i.id||!i.name||!i.applies_hint||!Array.isArray(i.emits))throw new Error(`${e}: technique '${i?.id??"?"}' missing id/name/applies_hint/emits`);tt(i.emits,`${e}: technique '${i.id}'`)}return n.techniques}function et(t,e){let n=ne(t);if(!n||!n.id||!n.name||!n.applies_when||!Array.isArray(n.candidate_checks))throw new Error(`${e}: profile missing id/name/applies_when/candidate_checks`);for(let i of n.candidate_checks){if(!i.id||!i.family||!i.measurable_example||!i.emits)throw new Error(`${e}: candidate_check '${i?.id??"?"}' missing id/family/measurable_example/emits`);tt([i.emits],`${e}: check '${i.id}'`)}return n}function st(t){let e=new Map(Ze(Ye,"packaged techniques").map(i=>[i.id,i])),n=te(t,"design","techniques.yaml");if(ge(n))for(let i of Ze(pe(n,"utf8"),n))e.set(i.id,i);return[...e.values()]}function it(t){let e=new Map(Object.entries(Je).map(([i,g])=>[i,et(g,`packaged profile '${i}'`)])),n=te(t,"design","profiles");if(ge(n))for(let i of pt(n).filter(g=>g.endsWith(".yaml")||g.endsWith(".yml")).sort()){let g=et(pe(te(n,i),"utf8"),te(n,i));e.set(g.id,g)}return[...e.values()]}function nt(t){let e=te(t,"design","runner-grammar.yaml");return ge(e)?pe(e,"utf8"):Xe}function se(t,e){return!t.superseded.has(e)}function fe(t,e,n){return{cid:e,logical_id:t.nameOf.get(e)??null,content:n}}async function rt(t,e,n,i,g){let r=await je(t,"search_similar",{text:e,label:n,k:i},g);return r.ok&&Array.isArray(r.result)?r.result:[]}async function at(t,e,n={}){let i=U(t),g=i.resolve(e);if(!g)throw new Error(`assembleDesignContext: unknown use-case '${e}' (run designGate first)`);let r=g.tip,w=i.getNode(r);if(!w||w.label!==W.USECASE)throw new Error(`assembleDesignContext: '${e}' is not a use-case (run designGate first)`);let I=i.derivesInto(r).map(u=>({source_id:u.props.source_id??null,anchor:u.props.anchor??null})),k=[],T=new Set;for(let{cid:u,content:f}of i.byLabel(W.SCENARIO))se(i,u)&&i.edgesFrom(u).some(b=>b.type===X.BELONGS_TO&&b.dst===r)&&(k.push(fe(i,u,f)),T.add(u));let x=[];for(let{cid:u,content:f}of i.byLabel(W.AC)){if(!se(i,u))continue;let b=i.edgesFrom(u).find($=>$.type===X.SCOPED_TO);!b||b.dst!==r&&!T.has(b.dst)||x.push({...fe(i,u,f),scoped_to:b.dst})}let y=Array.isArray(w.content.criteria)?w.content.criteria:[],h=[w.content.title,w.content.description,...y].filter(Boolean).join(`
|
|
340
|
+
`),F=(await rt(i,h,W.SCENARIO,10,n.embedSearch)).filter(u=>!T.has(u.cid)),L=[],S=new Set,O=[],c=[r],N=new Set([r]);for(;c.length>0;){let u=c.shift();for(let f of i.edgesFrom(u)){if(f.type!==X.DEPENDS_ON||i.nodeLabel.get(f.dst)!==W.USECASE)continue;let b=i.tipOf(f.dst);N.has(b)||(N.add(b),O.push(b),c.push(b))}}for(let u of O){let f=`depends_on ${i.nameOf.get(u)??u.slice(0,19)}`;for(let{cid:b}of i.byLabel(W.SCENARIO))if(se(i,b)&&i.edgesFrom(b).some($=>$.type===X.BELONGS_TO&&$.dst===u))for(let $ of i.edgesInto(b)){if($.type!==X.AUTOMATES||!se(i,$.src)||S.has($.src))continue;S.add($.src);let V=String(i.getNode($.src)?.content.title??"");L.push({cid:$.src,logical_id:i.nameOf.get($.src)??null,title:V,via:f})}}for(let u of await rt(i,h,W.TEST,5,n.embedSearch)){let{cid:f,title:b}=u;S.has(f)||(S.add(f),L.push({cid:f,logical_id:i.nameOf.get(f)??null,title:b??"",via:"similar"}))}let v=i.byLabel(W.STYLENOTE).filter(u=>se(i,u.cid)).sort((u,f)=>u.cid<f.cid?-1:1).slice(0,5).map(u=>`${String(u.content.statement)} [${String(u.content.learned_from_kind)}]`);return{usecase:fe(i,r,w.content),cites:I,committed_acs:x,existing:{scenarios:k,reuse_candidates:F},import_candidates:L,style_notes:v,techniques:st(t),profiles:it(t),runner_grammar:nt(t),budget:{...n.max!=null?{max_pairs:n.max}:{},...n.strength!=null?{strength_override:n.strength}:{}},design_of:(()=>{let u=Ue(i,r);return u?{engine:u.engine,seq:u.seq}:null})()}}function ot(t){let e=n=>{if(Array.isArray(n))return n.map(e);if(n!==null&&typeof n=="object"){let i={};for(let g of Object.keys(n).sort())i[g]=e(n[g]);return i}return n};return JSON.stringify(e(t),null,1)}import{basename as _t,dirname as yt,resolve as bt}from"path";var ht=oe,wt=new Set(["narrative","acs","scenarios","tests","exercises","gaps","scoped_to_repoints","judgements","phase"]);function vt(t){let e=/strength=(\d+)\s*(?:—|-)?\s*(.*)/.exec(t??"");return e?{strength:Number(e[1]),reason:e[2]||t||""}:{strength:2,reason:t??""}}function kt(t,e,n=new Set,i=0){return ht(e,ce(t),n,i)}function xt(t,e,n,i){let g=e.scenarios?.find(y=>y.temp_ref===n.automates)??(()=>{let y=t.resolve(n.automates),h=y?t.getNode(y.tip)?.content:void 0;return h?{title:String(h.title??""),intent:String(h.intent??""),technique_notes:String(h.technique_notes??"")}:{}})(),r=[...(e.acs??[]).map(y=>({ref:y.temp_ref,text:y.text})),...n.verifies.filter(y=>!(e.acs??[]).some(h=>h.temp_ref===y)).map(y=>{let h=t.resolve(y);return{ref:y,text:h?String(t.getNode(h.tip)?.content.text??""):""}})],{test_md:w,objectives_yaml:I}=ve({title:n.title,steps:n.steps,check:n.check,check_prose:n.check_prose,reuses:n.reuses},{title:g.title,intent:g.intent},r),k=ae(kt(t,w)),T=n.check,x={technique:g.technique_notes??"",profile_family:e.judgements?.find(y=>y.kind==="profile_family"&&(y.target===n.temp_ref||y.target===n.automates))?.rationale??"unspecified",anchor:T.verified_against,expected_how:e.judgements?.find(y=>y.kind==="expected_how"&&y.target===T.verified_against)?.rationale??`expected_mode: ${T.expected_mode??"inferred"}`,combinatorial:vt(g.technique_notes),surface_state:"absent",deferred_bindings:T.expected_mode==="runtime-derived"?1:0};return i.push({definitionId:k,rationale:x,anchorRef:T.verified_against,tempRef:n.temp_ref}),{temp_ref:n.temp_ref,title:n.title,automates:n.automates,verifies:n.verifies,check:n.check,definitionId:k,test_md_blob:w,objectives_blob:I,...n.reuses?.length?{reuses:n.reuses}:{},...n.surface_required!==void 0?{surface_required:n.surface_required}:{}}}function ct(t){let e=0,n=t.forceScope??null;return{terminalEventType:"design",async onProposalEvent(i){let g=a=>t.steer?(t.steer(`[auto-repair] ${a} \u2014 please re-finalize with this fixed.`),{proposal:null,error:null}):{proposal:null,error:a};if(i==null||typeof i!="object")return g("finalize_design payload is not an object");let r=i,w=Object.keys(r).filter(a=>!wt.has(a));if(w.length>0)return g(`finalize_design carries ungated/unknown section(s): ${w.join(", ")} \u2014 mintable here: acs, scenarios, tests (+gaps)`);let I=new Map;for(let a of r.tests??[]){let p=I.get(a.automates);if(p)return g(`strict 1:1 violated in-payload: ${p} and ${a.temp_ref} both automate ${a.automates}`);I.set(a.automates,a.temp_ref)}let k=U(t.contextDir);t.force&&!t.resuming&&e===0&&n===null&&(n=We(k,t.ucRef));let T=k.resolve(t.ucRef),x=T?String(k.getNode(T.tip)?.content.risk??"med"):"med",y=[],h=new Set([t.ucRef,T?.cid,T?.tip].filter(Boolean)),F=a=>{if(h.has(a))return!0;let p=k.resolve(a);return p!=null&&(h.has(p.cid)||h.has(p.tip))},L;try{L={...r.acs?.length?{acs:r.acs.map(a=>({temp_ref:a.temp_ref,text:a.text,kind:a.kind,risk:a.risk??x,...a.expected_answer?{expected_answer:a.expected_answer}:{},...a.scoped_to&&!F(a.scoped_to)?{scope:{type:"scenario",ref:a.scoped_to}}:{}}))}:{},...r.scenarios?.length?{scenarios:r.scenarios}:{},...r.tests?.length?{tests:r.tests.map(a=>xt(k,r,a,y))}:{},...r.exercises?.length?{exercises:r.exercises}:{},...r.gaps?.length?{gaps:r.gaps}:{},...r.scoped_to_repoints?.length?{scoped_to_repoints:r.scoped_to_repoints}:{},...r.judgements?.length?{judgements:r.judgements}:{}}}catch(a){return g(a instanceof Error?a.message:String(a))}let S=r.phase??(r.tests?.length?"tests":r.scenarios?.length?"scenarios":r.acs?.length?"acs":"design"),O=(a,p={})=>({contextDir:t.contextDir,graph:a,ucRef:t.ucRef,sections:L,by:t.by,phase:S,...p,...t.templateVersion?{templateVersion:t.templateVersion()}:{},...t.engine?{engine:t.engine}:{},...n?.length?{forceScope:n}:{},...t.because?{reason:t.because}:{},finalizeTestBody:(()=>{let R=new Map((L.tests??[]).map(A=>[A.temp_ref,A])),E=new Map,K=(A,B,P)=>{let G=R.get(A);if(!G?.test_md_blob)return null;let z=E.get(A);if(z!==void 0)return z;if(P.has(A))return G.test_md_blob;P.add(A);let Q=new Map;for(let q of G.reuses??[]){K(q,B,P);let J=B(q);J!==null&&J!==q&&Q.set(q,J)}let Y=G.verifies.map(B).filter(q=>q!==null),H=be(we(G.test_md_blob,Q),Y);return E.set(A,H),H};return(A,B)=>{if(!A.test_md_blob)return null;let P=K(A.temp_ref,B,new Set)??A.test_md_blob;if(P===A.test_md_blob)return null;let G=z=>{for(let Q of R.keys())if(B(Q)===z){let Y=K(Q,B,new Set);if(Y!==null)return{body:Y,cycleKey:`batch:${z}`,next:G}}return ce(k)(z)};return{test_md_blob:P,definitionId:ae(oe(P,G))}}})()}),c;if(t.protocol){let a=t.generationTicket,p=await Ae(t.protocol,{verb:"design",ucTargets:[{ref:t.ucRef}],newBuCandidates:[],sourcePins:[],readBasis:k.latestHash,...a?{generationTicket:a}:{}},R=>{let E=ue(O(R.graph,{eventIds:R.eventIds("design",1),sid:R.sid,...a&&!t.generationStamped?{generationTicket:a}:{}}));return E.errors!==null?{errors:E.errors}:{result:E,record:E.record}});p.ok&&"result"in p?(c=p.result,a&&!t.generationStamped&&(t.generationStamped=!0,t.generationTicket={...a,expected_prev_gen:a.next_gen})):p.ok?c={record:null,errors:null,minted:{},logicalIds:{},superseded:[],warnings:["commit already applied (recommit)"],finalizedTests:{}}:c={record:null,errors:p.kind==="validation"?p.errors:p.kind==="contended"?[{code:p.err.code,detail:`${t.ucRef} is held by ${p.err.holder?.owner_sid??"another session"}${p.err.holder?.alive?" (live)":" (stale)"} \u2014 try another use-case or wait for it to free`}]:p.kind==="drifted"?p.asks.map(E=>({code:"DRIFTED",detail:E.detail})):[{code:"UNSETTLED",detail:`concurrent activity kept moving the store (${p.attempts} attempts) \u2014 retry when the store is quieter`}],minted:{},logicalIds:{},superseded:[],warnings:[],finalizedTests:{}}}else c=ue(O(k));if(c.errors)return g("design commit failed: "+c.errors.map(a=>`${a.code}: ${a.detail}`).join("; "));let N=c.warnings.filter(a=>a.includes("\u2014 committed anyway; approve"));for(let a of c.warnings)(!N.includes(a)||N.length===1)&&t.note(`warning: ${a}`);N.length>1&&t.note(`warning: ${N.length} test link(s) refer to items still awaiting approval \u2014 saved anyway; review and approve those items in chat or via kane-cli context review`);let v=(a,p)=>a?`${a} ${p}${a>1?"s":""}`:null,u=[v(r.acs?.length,"AC"),v(r.scenarios?.length,"scenario"),v(r.tests?.length,"test"),v(r.gaps?.length,"gap")].filter(Boolean);t.aliases?.(Object.entries(c.minted).map(([a,p])=>({ref:a,cid:p,...c.logicalIds[a]?{id:c.logicalIds[a]}:{}})));{let a=`saved ${u.join(" \xB7 ")||"judgements/wiring"} as drafts`;(t.commitLine??t.note)(a)}let f=U(t.contextDir);t.onCommitted?.(f);for(let a of y){let p=c.logicalIds[a.anchorRef]??c.minted[a.anchorRef];Ke(t.contextDir,c.finalizedTests[a.tempRef]??a.definitionId,{...a.rationale,anchor:p??a.rationale.anchor})}try{let a=Object.values(c.minted).filter(p=>f.getNode(p)?.label==="test");if(a.length>0){let p=yt(bt(t.contextDir)),R=Ve({graph:f,cids:a,cwd:p});R.wrote.length>0&&t.note(`\u2692 wrote ${R.wrote.map(E=>_t(E.path)).join(" \xB7 ")}`);for(let E of R.refused)t.note(`warning: could not create the test file for ${E.id} \u2014 ${E.reason}`)}}catch(a){t.note(`warning: the design was saved, but its test file could not be created (${a instanceof Error?a.message:String(a)})`)}t.event?.({type:"commit",acs:r.acs?.length??0,scenarios:r.scenarios?.length??0,tests:r.tests?.length??0,gaps:r.gaps?.length??0,warnings:c.warnings.length,minted:Object.entries(c.minted).map(([a,p])=>({temp_ref:a,cid:p,...c.logicalIds[a]?{logical_id:c.logicalIds[a]}:{}}))}),e+=1,n!==null&&(n=c.forceScopeRemaining??n,t.onForceScope?.(n));let b=qe({verb:"design",commitN:e,ucRef:t.ucRef,phase:S,committed:Object.entries(c.minted).map(([a,p])=>({temp_ref:a,cid:p,...c.logicalIds[a]?{logical_id:c.logicalIds[a]}:{}})),warnings:c.warnings},f),$=b.event.parity?.missing??[],V=!!r.tests?.length&&$.length===0;return{proposal:c,error:null,receipt:b,...V?{sessionComplete:V}:{}}}}}function lt(t,e){return{type:"run_config",version:1,session_id:e.session_id,mode:e.mode,source:{source_id:`design:${t.usecase.logical_id??e.ucCid.slice(0,19)}`,source_cid:e.ucCid,kind:"design_context",numbered_text:ot({...t,session_mode:e.mode})},existing_use_cases:[],read_basis:e.readBasis,max_free_text_rounds:2,graph_reads:!0,verb:"design",chat:!0,design_budget:t.budget,topology:e.topology}}var ut=Symbol("design-out-tee");function Rt(t,e,n,i){return{terminalEventType:"design",async onProposalEvent(g){let r=g??{},w=["acs","scenarios","tests","gaps"].map(I=>r[I]?.length?`${r[I].length} ${I}`:null).filter(Boolean).join(" \xB7 ");return n?.("plan_payload",{payload:r}),t(`plan: finalize_design \u2014 ${w||"wiring/judgements only"} (nothing committed${i?`; full payload: ${Z(i)}`:""})`),e?.({type:"plan",payload:r}),{proposal:r,error:null}}}}async function Rs(t,e){let n=U(e.contextDir),i=null,g=null,r=t.useCase;if(t.resume){try{{let m=await Ge(e.contextDir,t.resume,n,{deps:{onWarn:_=>e.out(`note: ${_}`)}});g=m,i=m.handle,m.drift.length>0&&(e.out(`note: sources changed since the pause: ${m.drift.map(_=>_.subject).join(", ")} \u2014 the design continues against the current versions`),e.emit?.({type:"stale_basis",sources:m.drift.map(_=>_.subject)}))}}catch(m){if(m instanceof ye||m instanceof me)return e.out(`error: ${m.message}`),e.emit?.({type:"error",message:`error: ${m.message}`}),m instanceof me||m.code==="SESSION_MISSING"||m.code==="SESSION_EXPIRED"?2:1;throw m}let s=i.state,d=Ne(s.verb,"design",t.resume);if(d)return e.out(d.message),e.emit?.({type:"error",message:d.message,code:d.code}),i.release(),2;if(r&&s.use_case&&r!==s.use_case){let m=`session ${t.resume} was designing ${s.use_case}; --use-case ${r} RETARGETS it`;if(!(t.confirmRetarget?await t.confirmRetarget(`${m} \u2014 continue with the new target?`):!1))return e.out(`error: ${m} \u2014 resume without --use-case to continue ${s.use_case}, or start a fresh session on ${r}`),e.emit?.({type:"error",code:"RETARGET_MISMATCH",message:m}),i.release(),2}if(r=r??s.use_case,s.uc_tip&&r){let m=n.resolve(r)?.tip;if(m&&m!==s.uc_tip){let _=`the use-case changed since the pause (${s.uc_tip.slice(0,19)}\u2026 \u2192 ${m.slice(0,19)}\u2026)`;if(!(t.confirmRetarget?await t.confirmRetarget(`${_} \u2014 re-ground and continue against the new version?`):!1))return e.out(`error: ${_} \u2014 resume interactively to re-ground, or abandon this session`),e.emit?.({type:"error",code:"UC_TIP_MOVED",message:_}),i.release(),2;e.emit?.({type:"stale_basis",usecase:r})}}let l=Qe(n,s.target_pins);if(l.length>0){let m=`items this session pinned have changed since it paused: ${l.map(C=>`${C.ref}${C.now===null?" (now gone)":""}`).join(", ")}`;if(!(t.confirmRetarget?await t.confirmRetarget(`${m} \u2014 re-ground and continue?`):!1))return e.out(`error: ${m} \u2014 resume interactively to re-ground, or abandon`),e.emit?.({type:"error",code:"TARGET_PIN_MOVED",message:m}),i.release(),2;i.save({target_pins:(s.target_pins??[]).map(C=>({ref:C.ref,cid:n.resolve(C.ref)?.tip??C.cid}))})}let o=[...new Set([...i.state.held_receipts??[],...g?.view.kane?.held_receipts??[]])];if(o.length>0)if(e.chat?.holdReceipt)for(let m of o)e.chat.holdReceipt(m);else e={...e,initialMessage:[o.join(`
|
|
341
|
+
|
|
342
|
+
`),e.initialMessage].filter(Boolean).join(`
|
|
343
|
+
|
|
344
|
+
`)};if(!r)return e.out(`error: session ${t.resume} predates use-case persistence \u2014 re-supply --use-case <ref>`),e.emit?.({type:"error",message:`error: session ${t.resume} predates use-case persistence \u2014 re-supply --use-case <ref>`}),i.release(),2}let w=t.resume?void 0:t.phase,I=!1;if(w!==void 0){let{checkPhaseEntry:s,phaseEntryCmd:d,phaseLadderFor:l}=await import("./phase-seed-DIRETNU6.js");I=l(e.contextDir,n,r).length>0;let o=s(e.contextDir,n,r,w);if(!o.ok&&o.code==="UNKNOWN_PHASE")return e.out(`error: ${o.message}`),e.emit?.({type:"error",code:"UNKNOWN_PHASE",message:o.message}),i?.release(),2;if(!o.ok&&o.code==="PHASE_ORDER"){let m=t.askPhaseEntry?await t.askPhaseEntry({message:o.message,earliest:o.earliest}):"cancel";if(m==="earliest")e.out(`starting at ${o.earliest} instead (${o.missing.join(", ")} not committed yet)`),w=o.earliest;else if(m==="proceed")e.out(`note: entering at ${w} with ${o.missing.join(", ")} uncommitted \u2014 proceeding on your say-so`),e.emit?.({type:"phase_entry_override",phase:w,missing:o.missing});else{let _=(t.mode??"interactive")==="agent",C=d(r,o.earliest,_);return e.out(`error: ${o.message}`),e.emit?.({type:"error",code:"PHASE_ORDER",message:o.message,next:[{cmd:C,why:`${o.earliest} is the earliest uncommitted phase for ${r}`,title:`Start at ${o.earliest}`}]}),i?.release(),2}}}let k=!!(t.force||i?.state.force),T=!!(t.resume&&i),x=ze(n,r,k||T||I);if(!x.ok){let s=(t.mode??"interactive")==="interactive";if(x.wall&&s&&t.askDesignEntry){let{captureForceScope:d}=await import("./design-committer-VYT6NU3T.js"),l=d(n,r).length,o=await t.askDesignEntry({wall:x.wall.kind,message:x.message,display:x.wall.display,impactPairs:l});if(o.pick==="redesign"||o.pick==="proceed"){if(!o.because.trim())return e.out("a redesign needs a reason (--because) \u2014 nothing executed"),i?.release(),2;e.out(o.pick==="redesign"?`redesigning ${x.wall.display} (${l} pair(s) superseded) \u2014 because: ${o.because.trim()}`:`proceeding against the stale design (noted) \u2014 because: ${o.because.trim()}`),t={...t,force:!0,because:t.because??o.because.trim()},k=!0}else return o.pick==="view"?(e.out(`view the existing design: kane-cli context view ${x.wall.display}`),i?.release(),0):o.pick==="refresh"?(e.out(`refresh it first: kane-cli maintain evolve ${x.wall.display}`),i?.release(),0):(e.out("nothing executed \u2014 list use-cases: kane-cli context list"),i?.release(),0)}else{e.out(`design: ${x.message}`);let d=x.wall&&t.mode==="agent"?[{cmd:`kane-cli context view ${x.wall.display}`,why:"view the existing design",title:"View the design"},...x.wall.kind==="designed-stale"?[{cmd:`kane-cli maintain evolve ${x.wall.display}`,why:"the use-case moved since the design \u2014 evolve refreshes it",title:"Evolve the design"}]:[],{cmd:`kane-cli design tests --use-case ${x.wall.display} --force --mode agent`,why:"redesign \u2014 supersedes the live scenario+test pairs",title:"Redesign"}]:void 0;return e.emit?.({type:"gate_refused",message:x.message,...d?{next:d}:{}}),i?.release(),x.code}}if(e.preflightTurn){let s=await e.preflightTurn();if(!s.ok)return e.out(s.message??"error: turn-endpoint preflight failed"),e.emit?.({type:"error",message:s.message??"error: turn-endpoint preflight failed",code:"PREFLIGHT"}),i?.release(),2}let y={contextDir:e.contextDir,resolveAlias:s=>Ie(s,{env:process.env,auth:e.auth}),embed:(s,d)=>Pe(s,d,{env:process.env,auth:e.auth})};e.chat?.setWorking?.("assembling context\u2026");let h=await at(e.contextDir,r,{max:t.max,strength:t.strength,embedSearch:y});if(t.priorDesign!==void 0&&(h.prior_design=t.priorDesign),t.changeDelta!==void 0&&(h.change_delta=t.changeDelta),t.because&&(h.because=t.because),w!==void 0){let{buildPhaseSeed:s}=await import("./phase-seed-DIRETNU6.js"),d=s(e.contextDir,n,r,w);h.prior_design===void 0&&d.priorDesign!==void 0&&(h.prior_design=d.priorDesign),h.entry_phase=w,d.phaseLadder.length>0&&(h.phase_ladder=d.phaseLadder)}let F=e.now?.()??new Date,L=`${F.toISOString().replace(/[-:]/g,"").slice(0,15)}-${$t(2).toString("hex")}`,S=t.mode??"interactive",O=S==="interactive"&&!!e.chat&&!e.nested,c=g?{...g.spawnConfig,mode:S}:lt(h,{session_id:t.resume??`design-${L}`,mode:S,ucCid:h.usecase.cid,readBasis:n.latestHash,topology:Fe("design")}),N={current:null};if(c.resume&&"schema"in c.resume){let s=c.resume.binding?.template_version;typeof s=="string"&&(N.current=s)}t.plan?c.chat=!1:c.chat=!0;let v=e.telemetry?.enabled?e.telemetry:void 0,u=v?_e(v.ids.context_instance_id??null,"design",v.ids.session_id):he(e.contextDir,"logs",`design-${L}.log`);St(mt(u),{recursive:!0}),O||e.out(`trace: ${Z(u)}`),e.emit?.({type:"run_start",mode:S,trace:u,use_case:r,...v?{session:v.ids.session_id}:{}});let f=(s,d,l)=>{try{Dt(u,JSON.stringify({ts:new Date().toISOString(),level:s==="error"?"error":"info",run_id:v?.ids.operation_id,...v?{user_session_id:v.ids.session_id}:{},kind:s,session_id:l,data:d})+`
|
|
345
|
+
`)}catch{}v?.wireTrace(s,d,l)};{let s=e.out;if(s[ut]!==!0){let d=l=>{f("transcript",{line:l}),s(l)};d[ut]=!0,e.out=d}}if(t.resume&&i){g||(c.resume={agent_state:i.state.agent_state}),e.out(`resuming design session ${t.resume}`),i.state.assumed.length>0&&e.out(`note: ${i.state.assumed.length} default(s) were assumed while you were away \u2014 kane-cli context sessions show ${t.resume} lists them`);try{let{readRecords:s}=await import("./records-IOZTZUZV.js"),d=s(e.contextDir).records.filter(l=>l.sid===t.resume).map(l=>l.design_phase).filter(l=>l!=null&&typeof l.phase=="string");if(d.length>0){let l=d.map(m=>`${m.phase}${m.completeness==="partial"?" (partial)":""}`).join(" \u2192 "),o=`[kane] durable record for this session (${t.resume}) on ${r}: design phases already COMMITTED \u2014 ${l}. Those finalizes landed; do not re-send them. Continue from the next uncommitted phase, or finish if the design is complete.`;e={...e,initialMessage:[e.initialMessage,o].filter(Boolean).join(`
|
|
346
|
+
|
|
347
|
+
`)}}}catch{}t.message&&(e={...e,initialMessage:[e.initialMessage,t.message].filter(Boolean).join(`
|
|
348
|
+
|
|
349
|
+
`)})}let b=null,$={current:n},V={detach:null},a=()=>{let s=V.detach;V.detach=null,s&&s()},p=(s,d)=>{let l=i;if(!l)return{};let o=s.ask,m=Me({contextDir:s.contextDir,cwd:mt(s.contextDir),handle:l,note:_=>s.chat?s.chat.note(_):s.out(_),graphSlot:d,...s.now?{now:s.now}:{}});if(s.chat?.attachIngest){let _=s.chat;V.detach=_.attachIngest(async C=>{try{l.save({ingest_registry:de(l.state.ingest_registry,C,s.now?.()??new Date)});let j=await m({id:`attach-${l.state.sid}-${(l.state.ingest_registry??[]).length}`,ref:C,purpose:null});return j.ok?(_.deferBatch({source_id:j.result.source_id,cid:j.result.cid}),{ok:!0}):{ok:!1,error:j.error.message}}catch(j){return{ok:!1,error:j instanceof Error?j.message:String(j)}}})}return{ask:async _=>{let C=await o(_);if(Array.isArray(C)){let j=C.filter(M=>{if(M.free_text==null||M.free_text.trim()==="")return!1;let ie=_.find(gt=>gt.id===M.id);return M.selected_index!=null&&ie?.options[M.selected_index]?.input===!0}).map(M=>M.free_text.trim());if(j.length>0){let M=l.state.ingest_registry;for(let ie of j)M=de(M,ie,s.now?.()??new Date);l.save({ingest_registry:M})}}return C},ingest:m}};e.nested||e.chat?.attachOnCommitted?.(s=>{$.current=s});let R="";if(e.chat&&!t.plan&&!e.nested){let s=Oe({contextDir:e.contextDir,graph:U(e.contextDir),sessionStamp:c.session_id,by:e.by??{kind:"human",id:"owner"}});s.errors===null||s.errors[0]?.code==="CONV_SOURCE_EXISTS"?(R=s.sourceId,e.chat.attachConversationSource?.(R),$.current=U(e.contextDir)):e.out(`warning: notes you add in chat can't be saved to the context this session (${s.errors[0]?.detail})`)}let E=U(e.contextDir),K;if(!t.plan){let s=Ce(E,r);if(T&&s!==null&&s.live){let d=E.resolve(r);K={uc_root:Ee(E,d.cid),next_gen:s.gen,expected_prev_gen:s.gen}}else{let d=Te(E,r,{...k?{force:!0}:{},because:t.because??(k?"forced redesign (--force)":void 0)});if("error"in d)return e.out(`design: ${d.error.detail}`),e.emit?.({type:"gate_refused",message:d.error.detail,code:d.error.code}),i?.release(),2;K=d}}let A=xe(e.contextDir,c.session_id),B=null,P=()=>{try{B?.release()}catch{}};if(!t.plan)try{B=A.acquire([Se(E,r).key],{hold:"session",verb:"design"})}catch(s){if(s instanceof ke&&s.code==="UC_HELD"){let d=s.holder,l=`design: ${r} is being designed by another session${d?.alive===!1?` \u2014 that session looks stopped; resume it with kane-cli design tests --resume ${d?.owner_sid??"<session>"}`:""} \u2014 pick another use-case (kane-cli design tests) or wait for it to finish`;return e.out(l),e.emit?.({type:"error",code:"UC_HELD",message:l}),i?.release(),2}throw s}let G={contextDir:e.contextDir,rootSid:c.session_id,locks:A,probe:{batchSimilar:async()=>({hits:[],degraded:!1,probeBasis:null}),recheckLocal:()=>({hits:[],uncachedNewNodes:[]})}},z=!t.plan&&S!=="ci",Q=()=>Object.fromEntries((n.resolve(r)?n.edgesInto(n.resolve(r).tip):[]).filter(s=>s.type==="DERIVES"&&typeof s.props.source_id=="string").map(s=>[String(s.props.source_id),n.heads.get(String(s.props.source_id))??null])),Y=!1;z&&!i&&(Y=!0,i=re(e.contextDir,{sid:c.session_id,mode:"agent",created_at:F.toISOString(),expires_at:new Date(F.getTime()+1440*60*1e3).toISOString(),agent_state:{schema:2,items:[],provider_state:""},pending:{questions:[],proposals:[]},read_basis:Q(),assumed:[],corpus_cursor:{remaining:[]},conv_source:R,target_pins:n.resolve(r)?[{ref:r,cid:n.resolve(r).tip}]:[],verb:"design",use_case:r,...n.resolve(r)?.tip?{uc_tip:n.resolve(r).tip}:{},...k?{force:!0}:{},...v?{user_session_id:v.ids.session_id}:{}}));let H;if(z&&i){let{resume:s,...d}=c;Re(e.contextDir,c.session_id,{schema:$e,kind:"base",sid:c.session_id,verb:"design",mode:S,created_at:F.toISOString(),run_config:d,conv_source:R||i.state.conv_source||"",...r?{use_case:r}:{},...n.resolve(r)?.tip?{uc_tip:n.resolve(r).tip}:{},store_watermark:De(e.contextDir)}),c.checkpoints=!0,t.resume&&f("resume_kind",{kind:g?g.view.pointer===null?"bare-base":g.view.pointer.at==="final"?"pause":"crash":"v1-shim"},c.session_id);let l=g?0:i.state.checkpoint?.seq??0,o=i;H=Be({contextDir:e.contextDir,handle:o,seqBase:()=>l,peekHeldReceipts:()=>e.chat?.peekHeldReceipts?.()??[],readBasis:()=>Q(),corpusCursor:()=>({remaining:[]}),onSoftCap:_=>e.out(_),onStat:_=>f("ckpt_stat",_,c.session_id),...e.now?{now:e.now}:{}});let m=H;H={...m,persist:_=>{let C=_.binding?.template_version;return typeof C=="string"&&C&&(N.current=C),m.persist(_)}}}let q=()=>{if(!i)return;let s=i.state.checkpoint;if(s){let d=S!=="interactive"?` --mode ${S}`:"";e.out(`session ${i.state.sid} kept its last checkpoint (seq ${s.seq}, ${s.ts}) \u2014 resume with: kane-cli design tests --resume ${i.state.sid}${d}`),i.release()}else if(Y){try{i.complete()}catch{i.release()}try{dt(he(e.contextDir,"sessions"))}catch{}}else i.release();i=null},J=t.plan?Rt(e.out,e.emit,f,u):ct({templateVersion:()=>N.current,contextDir:e.contextDir,ucRef:r,by:{kind:"ai",id:"design-agent"},force:k,engine:"design@1",note:s=>e.chat?e.chat.note(s):e.out(s),commitLine:s=>e.chat?e.chat.ledger({kind:"commit",ok:!0,line:s}):e.out(s),steer:e.chat?s=>e.chat.submit(s):void 0,event:e.emit,resuming:T,...i?.state.force_scope?.length?{forceScope:i.state.force_scope}:{},onForceScope:s=>{b=s},...t.because?{because:t.because}:{},aliases:e.chat?s=>e.chat.registerAliases?.(s):void 0,onCommitted:s=>{$.current=s},protocol:G,...K?{generationTicket:K}:{},...T?{generationStamped:!0}:{}});e.chat||(f("design_budget",{max_pairs:h.budget.max_pairs??null,strength:h.budget.strength_override??null}),e.out(`designing: ${h.usecase.logical_id??r}`)),e.chat?.setWorking?.(`designing ${h.usecase.logical_id??r}\u2026`);let D;try{D=await le(c,{...e,graphSlot:$,...p(e,$),...H?{checkpoint:H}:{}},new Map,n,f,J)}catch(s){throw f("error",{message:s instanceof Error?s.message:String(s),stack:s instanceof Error?s.stack:void 0},c.session_id),q(),s}finally{e.chat?.setWorking?.(null),a()}if(D.errorCode==="binding_mismatch"&&g){let s=await e.ask([{id:"binding-mismatch",text:"this session's saved conversation is no longer accepted by the service \u2014 start the conversation fresh (committed work is kept), or stop and keep the session?",risk:"high",rationale:"the service refused the saved conversation on the first turn after resume",options:[{label:"start fresh",detail:"continue with a fresh conversation \u2014 earlier answers may be re-asked"},{label:"stop",detail:"stop here; the session stays resumable"}],recommended_index:1,allow_free_text:!1}]);if((Array.isArray(s)?s.find(o=>o.id==="binding-mismatch"):void 0)?.selected_index!==0){let o=`resume abandoned: binding mismatch on session ${c.session_id} \u2014 the session is preserved`;return e.out(o),e.emit?.({type:"error",message:o,code:"BINDING_MISMATCH"}),i?.release(),2}f("binding_migrate",{sid:c.session_id},c.session_id);let l=c.resume&&"schema"in c.resume?{...c.resume,binding:{}}:void 0;try{D=await le({...c,...l?{resume:l}:{}},{...e,graphSlot:$,...p(e,$),...H?{checkpoint:H}:{}},new Map,n,f,J)}catch(o){throw f("error",{message:o instanceof Error?o.message:String(o),stack:o instanceof Error?o.stack:void 0},c.session_id),q(),o}finally{e.chat?.setWorking?.(null),a()}}if(D.highRisk)return e.out(`error: ${D.highRisk.length} high-risk decision${D.highRisk.length===1?"":"s"} need a human \u2014 ci mode won't guess. Re-run with --mode agent to pause for review.`),e.emit?.({type:"error",message:`error: high-risk question(s) in ci mode (fail-closed): ${D.highRisk.map(s=>s.id).join(", ")}`,code:"HIGH_RISK_CI"}),q(),P(),1;if(D.paused){let s=i;s||(s=re(e.contextDir,{sid:c.session_id,mode:"agent",created_at:F.toISOString(),expires_at:new Date(F.getTime()+1440*60*1e3).toISOString(),agent_state:D.paused.agent_state,pending:{questions:[],proposals:[]},read_basis:Object.fromEntries((n.resolve(r)?n.edgesInto(n.resolve(r).tip):[]).filter(o=>o.type==="DERIVES"&&typeof o.props.source_id=="string").map(o=>[String(o.props.source_id),n.heads.get(String(o.props.source_id))??null])),assumed:[],corpus_cursor:{remaining:[]},conv_source:R,target_pins:n.resolve(r)?[{ref:r,cid:n.resolve(r).tip}]:[],verb:"design",use_case:r,...n.resolve(r)?.tip?{uc_tip:n.resolve(r).tip}:{},...k?{force:!0}:{},...v?{user_session_id:v.ids.session_id}:{}}));try{k&&!s.state.force&&s.save({force:!0}),v&&s.state.user_session_id!==v.ids.session_id&&s.save({user_session_id:v.ids.session_id}),R&&s.state.conv_source!==R&&s.save({conv_source:R});let o=e.chat?.drainHeldReceipts?.()??[];(o.length>0||(s.state.held_receipts?.length??0)>0)&&s.save({held_receipts:o}),b!==null&&s.save({force_scope:b}),Le(s,D.paused)}catch(o){let m=s.state.checkpoint,_=`error: couldn't persist the pause for session ${s.state.sid}`+(m?` \u2014 last durable checkpoint: seq ${m.seq} @ ${m.ts}`:" \u2014 no durable checkpoint exists")+` (${o instanceof Error?o.message:String(o)})`;return e.out(_),e.emit?.({type:"error",message:_,code:"PAUSE_PERSIST_FAILED",sid:s.state.sid}),1}f("session_paused",{sid:s.state.sid},c.session_id);let d=S!=="interactive"?` --mode ${S}`:"",l=`kane-cli design tests --resume ${s.state.sid}${d}`;if(O||e.out(`paused \u2014 resume with: ${l}`),e.emit?.({type:"session_paused",sid:s.state.sid,mode:S,resume:l,expires_at:s.state.expires_at,pending_questions:D.paused.pending.questions}),O){let o=e.chat?.state.credits?.total;e.onSummary?.({state:"paused",reason:"ctrl+c",facts:[`session ${s.state.sid} saved \u2014 designing ${h.usecase.logical_id??r}`,...s.state.expires_at?[`expires: ${s.state.expires_at}`]:[],...o!==void 0?[`credits used: ${o.toFixed(1)}`]:[]],resume:l,resumeMessage:`${l} --message "<your words>"`,tracePath:Z(u)})}return P(),3}if(D.crashed&&i?.state.checkpoint){let s=i.state.checkpoint,d=S!=="interactive"?` --mode ${S}`:"",l=`kane-cli design tests --resume ${i.state.sid}${d}`;if(f("agent_crashed_resumable",{sid:i.state.sid,seq:s.seq},c.session_id),O||e.out(`agent crashed \u2014 session ${i.state.sid} is resumable at checkpoint seq ${s.seq} (at most the in-flight turn lost); resume with: ${l}`),e.emit?.({type:"session_paused",sid:i.state.sid,mode:S,resume:l,expires_at:i.state.expires_at,crashed:!0}),O){let o=e.chat?.state.credits?.total;e.onSummary?.({state:"crashed",facts:[`agent crashed \u2014 session ${i.state.sid} is resumable at checkpoint seq ${s.seq}`,"at most the in-flight turn was lost",...o!==void 0?[`credits used: ${o.toFixed(1)}`]:[]],resume:l,resumeMessage:`${l} --message "<your words>"`,tracePath:Z(u)})}return i.release(),i=null,3}if(D.error)return e.out(`error: design agent failed: ${D.error}`),e.emit?.({type:"error",message:`error: design agent failed: ${D.error}`}),q(),P(),1;if(D.proposal==null&&S!=="interactive")return e.out(`error: the design session stopped before saving anything \u2014 nothing committed (trace: ${u})`),e.emit?.({type:"error",message:`error: the design session stopped before saving anything \u2014 nothing committed (trace: ${u})`}),q(),P(),1;let ee=0;if(D.proposal==null)try{let{readRecords:s}=await import("./records-IOZTZUZV.js"),d=t.resume??c.session_id;ee=s(e.contextDir).records.filter(l=>l.sid===d).reduce((l,o)=>l+o.nodes.filter(m=>m.label!=="source").length,0)}catch{}if(D.proposal==null&&e.out(ee>0?`done \u2014 ${ee} item(s) committed in this session (earlier legs included); nothing new since the resume`:"done \u2014 nothing designed this session (no finalize before the session ended)"),D.assumedDefaults&&e.out(`assumed: ${D.assumedDefaults} default(s) taken while unattended`),i&&e.emit?.({type:"session_complete",sid:t.resume??c.session_id}),v?.event("ASR_SESSION_COMPLETE",{}),i?.complete(),Y)try{dt(he(e.contextDir,"sessions"))}catch{}if(O){let s=e.chat.state.ledger.filter(o=>o.kind==="answer"&&o.receipt.form==="assumed").length??0,d=(D.assumedDefaults??0)+s,l=e.chat.state.credits?.total??D.creditsTotal;e.onSummary?.({state:"complete",facts:[`designed: ${h.usecase.logical_id??r}${D.proposal==null?ee>0?` (${ee} item(s) committed across this session)`:" (nothing committed this session)":""}`,...d>0?[`${d} assumed default(s)`]:[],...l!==void 0?[`credits used: ${l.toFixed(1)}`]:[]],tracePath:Z(u)})}return t.plan||He(e.contextDir),P(),0}export{Rs as a};
|