@testmuai/kane-cli 0.6.4 → 0.6.7
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/bin/kane-cli.cjs +91 -0
- package/bin/resolve-runtime.cjs +45 -0
- package/dist/{ChatSurface-VXYU6KFW.js → ChatSurface-Y2M6HB2R.js} +1 -1
- package/dist/{ChromeProfilePicker-QWTM7DK6.js → ChromeProfilePicker-IW3K43VC.js} +1 -1
- package/dist/{CliFeedbackPrompt-6NVWMONO.js → CliFeedbackPrompt-ZJ4LZGPK.js} +1 -1
- package/dist/{CliUploadProgress-2YRQLECI.js → CliUploadProgress-SMPVN7Q6.js} +1 -1
- package/dist/{ConfigView-I4R5M7BO.js → ConfigView-RTAGKZH4.js} +1 -1
- package/dist/EvidenceViewOffer-LHPIZUGQ.js +2 -0
- package/dist/{FolderPicker-5VWBYTAK.js → FolderPicker-QUY7LNVZ.js} +1 -1
- package/dist/{HelpView-OJZW4XWX.js → HelpView-47J2NZWJ.js} +1 -1
- package/dist/{InfoBox-TGELGCBR.js → InfoBox-G63WZAMH.js} +1 -1
- package/dist/{LinksBox-B5EBRY26.js → LinksBox-2HIHDT5K.js} +1 -1
- package/dist/{ProfilesView-3SJRIBHQ.js → ProfilesView-TUXQXPXJ.js} +1 -1
- package/dist/{ProjectPicker-72HKMBEY.js → ProjectPicker-VUABWG2P.js} +1 -1
- package/dist/{SaveSessionPrompt-CK5SGNRO.js → SaveSessionPrompt-PNVGNLGO.js} +1 -1
- package/dist/SingleShotApp-BZV5CULT.js +2 -0
- package/dist/{SummaryBox-ABB7ST26.js → SummaryBox-36MDDDYQ.js} +1 -1
- package/dist/TestMdRunView-A655PMEY.js +2 -0
- package/dist/{WhoamiView-OF354UGC.js → WhoamiView-LHU6RGIY.js} +1 -1
- package/dist/{bind-BWILBZGR.js → bind-E67W2DXG.js} +2 -2
- package/dist/{bridge-LNDJS3HH.js → bridge-WVFTWHKP.js} +1 -1
- package/dist/{changelog-BWCEZQ23.js → changelog-D4Y5QJIZ.js} +1 -1
- package/dist/chat-committer-WOTCC7L3.js +2 -0
- package/dist/chat-controller-MONWZKS7.js +4 -0
- package/dist/{chunk-YI4XULHR.js → chunk-3CY3DZDH.js} +15 -15
- package/dist/{chunk-IOTJZTHX.js → chunk-3GOZ7R4G.js} +12 -12
- package/dist/{chunk-DNOBOZPO.js → chunk-3NR6OTHL.js} +1 -1
- package/dist/{chunk-MK2G7VIF.js → chunk-5J3HQZNU.js} +1 -1
- package/dist/{chunk-ADOXYGZE.js → chunk-6EC54ZHT.js} +1 -1
- package/dist/{chunk-CLTANA4L.js → chunk-77PBBYRZ.js} +2 -2
- package/dist/{chunk-GYW7LVVL.js → chunk-7Z64BL5D.js} +1 -1
- package/dist/{chunk-5CTMOJG4.js → chunk-7ZMYAXES.js} +1 -1
- package/dist/{chunk-WFEGGQJ4.js → chunk-A2AZQ4PQ.js} +1 -1
- package/dist/{chunk-HNE4TDOZ.js → chunk-AASBJJCU.js} +4 -4
- package/dist/{chunk-5KSB5MOF.js → chunk-BBZBXSTP.js} +1 -1
- package/dist/chunk-CIFVUX3B.js +4 -0
- package/dist/chunk-CVOGP253.js +2 -0
- package/dist/{chunk-O66EU5UV.js → chunk-DCWCANNS.js} +1 -1
- package/dist/{chunk-4MUHS3UL.js → chunk-DL5CXC64.js} +1 -1
- package/dist/chunk-DNNZ353O.js +4 -0
- package/dist/chunk-E4EHWO3J.js +4 -0
- package/dist/{chunk-AXABTFCD.js → chunk-EDM6YACR.js} +1 -1
- package/dist/{chunk-YMSN25DX.js → chunk-FYSWQ4K7.js} +1 -1
- package/dist/{chunk-QZI43UNV.js → chunk-G5CYSC23.js} +1 -1
- package/dist/chunk-GAD6IBZ6.js +12 -0
- package/dist/chunk-GLS46X7N.js +5 -0
- package/dist/chunk-GLVDOR5G.js +2 -0
- package/dist/chunk-I37UOX73.js +14 -0
- package/dist/chunk-IAHKTEET.js +2 -0
- package/dist/{chunk-IXVR66NS.js → chunk-IX34JIXK.js} +1 -1
- package/dist/{chunk-BNN6ZDJW.js → chunk-IYTHPCQ2.js} +1 -1
- package/dist/chunk-JR37W7IJ.js +6 -0
- package/dist/{chunk-IRRGSC7B.js → chunk-KVAALPTA.js} +1 -1
- package/dist/{chunk-ZZLR3O5A.js → chunk-L4JIMNKW.js} +1 -1
- package/dist/{chunk-WT3SMSY5.js → chunk-LVWB6TB2.js} +1 -1
- package/dist/chunk-MBXWXBDM.js +4 -0
- package/dist/{chunk-UZSG54OY.js → chunk-MTG2LRGV.js} +1 -1
- package/dist/chunk-NEHF4C6X.js +7 -0
- package/dist/chunk-NMKZHHB6.js +2 -0
- package/dist/{chunk-DXK55KGR.js → chunk-NMZATEKQ.js} +8 -8
- package/dist/{chunk-2PQXEEVY.js → chunk-NVGBE2DR.js} +1 -1
- package/dist/{chunk-ANIVHX3P.js → chunk-OPDJD7WS.js} +2 -2
- package/dist/{chunk-6GTOYTCQ.js → chunk-OSALXGD4.js} +1 -1
- package/dist/{chunk-ZQP3MCZW.js → chunk-QG6LJCZG.js} +1 -1
- package/dist/{chunk-MCQXRJGH.js → chunk-QHFUDBQH.js} +1 -1
- package/dist/{chunk-MVF4KRHA.js → chunk-QVJ7C4GW.js} +1 -1
- package/dist/{chunk-W36P7S5W.js → chunk-QYTMD6NM.js} +1 -1
- package/dist/{chunk-OB6CKLEL.js → chunk-R7NNIQMH.js} +1 -1
- package/dist/{chunk-652FEDL4.js → chunk-RBLZUDMZ.js} +2 -2
- package/dist/chunk-RGDQMKNJ.js +4 -0
- package/dist/{chunk-XUJ5EPVW.js → chunk-RGQIBS32.js} +1 -1
- package/dist/{chunk-FV4LLU3T.js → chunk-RWIHSR4H.js} +1 -1
- package/dist/{chunk-I2JUBAPU.js → chunk-SK2GVMTJ.js} +1 -1
- package/dist/{chunk-POI6DCP6.js → chunk-TADJIOHV.js} +1 -1
- package/dist/{chunk-PYB2EXRE.js → chunk-TSWGQKUK.js} +2 -2
- package/dist/{chunk-64QURIT6.js → chunk-TTJ4XMWP.js} +1 -1
- package/dist/{chunk-WE57PD6K.js → chunk-UQVKNUYO.js} +1 -1
- package/dist/chunk-UZWOHCFX.js +4 -0
- package/dist/chunk-VLC24QVT.js +2 -0
- package/dist/{chunk-2K4XOHVK.js → chunk-WFQUDSKY.js} +1 -1
- package/dist/{chunk-3WJJ43MT.js → chunk-WJG4ZPUH.js} +1 -1
- package/dist/{chunk-STH6I3UB.js → chunk-X47VFBIV.js} +1 -1
- package/dist/{chunk-PICCLJSO.js → chunk-XUHVQ5VL.js} +1 -1
- package/dist/{chunk-3HEPW6SN.js → chunk-Y6HPW2OQ.js} +1 -1
- package/dist/{chunk-BYUARJE7.js → chunk-YB54MHKU.js} +1 -1
- package/dist/{chunk-CY5NDMO7.js → chunk-YTZUYCFZ.js} +1 -1
- package/dist/{chunk-QNNBNIR7.js → chunk-YZBLBPOE.js} +2 -2
- package/dist/{chunk-BOO7YXAV.js → chunk-Z34XRBKQ.js} +1 -1
- package/dist/{chunk-FJTWJ243.js → chunk-ZPDM6FO7.js} +1 -1
- package/dist/{config-OJF53CHL.js → config-BZ7C5NU5.js} +1 -1
- package/dist/cover-cmd-DN5D6A3S.js +2 -0
- package/dist/{credentials-NLJHSVBY.js → credentials-BPJL6YIZ.js} +1 -1
- package/dist/{descriptor-EHK3DRCZ.js → descriptor-KXDJ4XYD.js} +1 -1
- package/dist/evidence-E5B24ZO6.js +2 -0
- package/dist/evolve-cmd-V7H4PLCX.js +2 -0
- package/dist/explain-VTRHEVUQ.js +2 -0
- package/dist/{explain-cmd-U367SD4N.js → explain-cmd-AG6ZDXV6.js} +1 -1
- package/dist/{explain-cmd-KV5YUXKB.js → explain-cmd-NZPC6537.js} +1 -1
- package/dist/{extract-bind-SSTKQGTV.js → extract-bind-3QBBCWYE.js} +2 -2
- package/dist/{extract-cmd-GO4UV7ER.js → extract-cmd-4PGUDJMU.js} +1 -1
- package/dist/gaps-cmd-42LPHWFP.js +2 -0
- package/dist/{generate-headless-2HYMSVN5.js → generate-headless-NZUDYIKJ.js} +2 -2
- package/dist/index.js +12 -12
- package/dist/ingest-GOKIMEP4.js +2 -0
- package/dist/ingest-cmd-BTYHVJ33.js +3 -0
- package/dist/{interactive-bind-Q5TQFQ6N.js → interactive-bind-TKRWAPJU.js} +3 -3
- package/dist/lifecycle-cmd-E6AXODQD.js +2 -0
- package/dist/list-cmd-RJVLH2GR.js +3 -0
- package/dist/{list-commands-6WDXAECV.js → list-commands-55RCFEOL.js} +1 -1
- package/dist/logical-ids-QZQRQ3TV.js +2 -0
- package/dist/login-flow-WNIHDQXF.js +2 -0
- package/dist/maintenance-cmd-UJG4LPWD.js +2 -0
- package/dist/pdf-convert-KYXI4FU4.js +2 -0
- package/dist/{persist-recorded-session-KHIMN4A3.js → persist-recorded-session-HK7JUONC.js} +1 -1
- package/dist/pipeline-FTLXJQRT.js +2 -0
- package/dist/readmodel-KTNI6QDC.js +2 -0
- package/dist/reconcile-cmd-5XC4AUSJ.js +2 -0
- package/dist/{recording-banner-SADVYNEP.js → recording-banner-5IYX2KBV.js} +1 -1
- package/dist/{require-project-folder-LP7V26IU.js → require-project-folder-J4Q4FRQ4.js} +1 -1
- package/dist/revert-FRXNIP5R.js +2 -0
- package/dist/review-cmd-XB2DCTMZ.js +4 -0
- package/dist/run-2RFR2ASQ.js +2 -0
- package/dist/run-3ZYJQBBC.js +2 -0
- package/dist/{run-test-md-ATB2HZRG.js → run-test-md-WN6BH3PC.js} +2 -2
- package/dist/{skill-installer-DE2LSSKU.js → skill-installer-4HYPUBNB.js} +1 -1
- package/dist/{spawner-GOTVIFR5.js → spawner-VD6YFZ43.js} +1 -1
- package/dist/tcg-generate-77QKMB63.js +2 -0
- package/dist/{testmd-actions-RYQHBX4K.js → testmd-actions-LT5FNIR6.js} +1 -1
- package/dist/token-refresh-PCOAZBKK.js +2 -0
- package/dist/{validate-basic-6BQ2L7TT.js → validate-basic-XWGKC5VF.js} +1 -1
- package/dist/{version-check-YW3FUWDH.js → version-check-6FDTS6MK.js} +1 -1
- package/dist/{view-cmd-FRMQF76B.js → view-cmd-PCDG3FIC.js} +1 -1
- package/dist/walk-session-YS62CWX5.js +2 -0
- package/package.json +16 -7
- package/bin/kane-cli.js +0 -2
- package/dist/EvidenceViewOffer-54GEARRX.js +0 -2
- package/dist/SingleShotApp-AJBIWW74.js +0 -2
- package/dist/TestMdRunView-5PMLLLFT.js +0 -2
- package/dist/chat-committer-ADJJTDUT.js +0 -2
- package/dist/chat-controller-VAC57IEV.js +0 -3
- package/dist/chunk-6AYUSR7X.js +0 -2
- package/dist/chunk-6LRKYF67.js +0 -14
- package/dist/chunk-74RUSHIB.js +0 -4
- package/dist/chunk-ACEODVSC.js +0 -14
- package/dist/chunk-CT2I5KUM.js +0 -2
- package/dist/chunk-E3BO7OVR.js +0 -7
- package/dist/chunk-HJGUEZLW.js +0 -2
- package/dist/chunk-IJPFAWBH.js +0 -5
- package/dist/chunk-OLXOZJ7X.js +0 -6
- package/dist/chunk-QPZRHAYK.js +0 -4
- package/dist/chunk-SJ2KQKOV.js +0 -3
- package/dist/chunk-WIA7TPK3.js +0 -2
- package/dist/chunk-ZG2V2ODK.js +0 -4
- package/dist/cover-cmd-K3LCXHAQ.js +0 -2
- package/dist/evidence-UPOFW3XC.js +0 -2
- package/dist/evolve-cmd-MVALOB3G.js +0 -2
- package/dist/explain-VFIZTHFN.js +0 -2
- package/dist/gaps-cmd-DTVDIOED.js +0 -2
- package/dist/ingest-C5ANIN7S.js +0 -2
- package/dist/ingest-cmd-LLC5CDQ5.js +0 -3
- package/dist/lifecycle-cmd-BXE5IMFN.js +0 -2
- package/dist/list-cmd-KBWPYJMV.js +0 -3
- package/dist/logical-ids-3Y6RX5C2.js +0 -2
- package/dist/login-flow-XQMJFC4H.js +0 -2
- package/dist/maintenance-cmd-VS3APIUN.js +0 -2
- package/dist/pipeline-2HRAWT5U.js +0 -2
- package/dist/readmodel-XOGOELUP.js +0 -2
- package/dist/reconcile-cmd-DH4VV6PG.js +0 -2
- package/dist/revert-AQQ2VHRM.js +0 -2
- package/dist/review-cmd-4WZUUOE4.js +0 -4
- package/dist/run-RT2VMPTQ.js +0 -2
- package/dist/run-XAZMT7WO.js +0 -2
- package/dist/tcg-generate-7PUXJ5R4.js +0 -2
- package/dist/token-refresh-F5KRV7ER.js +0 -2
- package/dist/walk-session-O4TMVORI.js +0 -2
package/dist/chunk-74RUSHIB.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as j}from"./chunk-ZZLR3O5A.js";import{c as m,d as _,f as L}from"./chunk-ZG2V2ODK.js";import{a as w,e as N,f as k,g as O,h as I}from"./chunk-5YPBPZUR.js";import{existsSync as v,mkdirSync as M,readFileSync as S,renameSync as T,rmSync as P,writeFileSync as J}from"fs";import{dirname as W,join as b}from"path";var $=s=>b(s,"derived"),q=s=>b($(s),"index.json");function x(s,n){let t=n.startsWith("sha256:")?n.slice(7):n;return b($(s),"nodes",t.slice(0,2),t.slice(2)+".json")}function A(){return{applied:{seq:0,hash:null},heads:{},trust:{},nodeLabel:{},forward:{},extracted:[],design_of:{},exec:{},superseded:{},names:{},archivedReason:{},appliedEvents:[],conv:{},media:{}}}function D(s){let n=q(s);if(!v(n))return null;try{let t=JSON.parse(S(n,"utf8"));return t.superseded===void 0||t.names===void 0||t.archivedReason===void 0||t.appliedEvents===void 0||t.conv===void 0||t.media===void 0||t.exec===void 0||t.reverse!==void 0?null:t}catch{return null}}function U(s,n){M(W(s),{recursive:!0});let t=`${s}.tmp-${process.pid}`;J(t,n),T(t,s)}function y(s,n,t,l,a={}){let p=a.writeNodeFiles!==!1,g=new Set(n.extracted),h=new Set(n.appliedEvents);t.forEach((i,o)=>{for(let e of i.nodes){let r=x(s,e.cid);p&&!v(r)&&U(r,JSON.stringify({label:e.label,content:e.content})+`
|
|
3
|
-
`),!(e.cid in n.trust)&&e.content.derived===!0&&(n.trust[e.cid]="derived"),n.nodeLabel[e.cid]=e.label}i.proposal_id!=null&&typeof i.extraction_of=="string"&&g.add(i.extraction_of),i.design_of&&((n.design_of??={})[i.design_of.uc_cid]={engine:i.design_of.engine,seq:i.seq});for(let e of i.executions??[])((n.exec??={})[e.about]??=[]).push(e);for(let e of i.edges){let{quote:r,...d}=e.props,c=n.forward[e.src]??=[];c.some(u=>u.ecid===e.ecid)||c.push({...e,props:d}),i.proposal_id!=null&&e.type===N.DERIVES&&typeof e.props.source_cid=="string"&&g.add(e.props.source_cid)}for(let e of i.review)e.resolution==="approved"||e.resolution==="edited"?(n.trust[e.id]="trusted",delete n.archivedReason[e.id]):e.resolution==="rejected"?(n.trust[e.id]="archived",e.reason?n.archivedReason[e.id]=e.reason:delete n.archivedReason[e.id]):e.resolution==="reset"&&(n.trust[e.id]="derived",delete n.archivedReason[e.id]);for(let e of i.supersessions)e.kind==="node"?e.new===e.old?delete n.superseded[e.old]:n.superseded[e.old]=e.new:n.superseded[e.ecid]=null;for(let e of i.names??[])n.names[e.slug]=e.cid;for(let[e,r]of Object.entries(i.source_head_moves))n.heads[e]=r;for(let e of i.event_ids??[])h.add(e);if(i.media)for(let[e,r]of Object.entries(i.media)){let d=i.source_head_moves[e];typeof d=="string"&&(n.media[d]=r)}if(i.conv){let e=i.source_head_moves[i.conv.source_id];if(typeof e=="string"){let r=n.conv[i.conv.source_id],d=r&&r.chain.length>0?r.chain[r.chain.length-1]:null;i.conv.append_of===d?n.conv[i.conv.source_id]={turns:i.conv.turn,chain:[...r?.chain??[],e]}:n.conv[i.conv.source_id]={turns:i.conv.turn,chain:[e]}}}for(let[e,r]of Object.entries(i.source_head_moves))i.conv?.source_id!==e&&n.conv[e]!==void 0&&(n.conv[e]=typeof r=="string"?{turns:n.conv[e].turns,chain:[r]}:{turns:n.conv[e].turns,chain:[]});n.applied={seq:i.seq,hash:l[o]}}),n.extracted=[...g].sort(),n.appliedEvents=[...h].sort()}function F(s,n){U(q(s),JSON.stringify(n)+`
|
|
4
|
-
`)}function K(s){let n=b(s,"meta.json");if(v(n))try{let t=JSON.parse(S(n,"utf8"));if(t.schema!==w||t.canonicalizer!=="v1")throw new m(`schema fence: store is ${t.schema}/${t.canonicalizer}, this build is ${w}/${"v1"} \u2014 migrate explicitly (kane-cli context rebuild after upgrading)`)}catch(t){throw t instanceof m?t:new m(`corrupt meta.json in ${s} \u2014 fix or remove it`)}}function V(s){K(s);let n=D(s);if(n===null){n=A();let{records:a,hashes:p}=_(s);return y(s,n,a,p),F(s,n),n}let{records:t,hashes:l}=L(s,n.applied.seq,n.applied.hash);return t.length>0&&(y(s,n,t,l),F(s,n)),n}function Z(s){return P($(s),{recursive:!0,force:!0}),V(s)}function Q(s){let n=[],t=[],l=[];try{({records:t,hashes:l}=_(s))}catch(o){return{ok:!1,issues:[o instanceof m?o.message:String(o)],records:0}}let a=A();y(s,a,t,l,{writeNodeFiles:!1});let p=D(s);if(p===null)n.push("derived/index.json missing or corrupt (run kane-cli context rebuild)");else{let o=e=>JSON.stringify(R(e));for(let e of["applied","heads","trust","nodeLabel","forward","extracted","superseded","names","archivedReason","appliedEvents","conv","media","design_of","exec"])o(a[e])!==o(p[e])&&n.push(`derived drift in index.${e} (run kane-cli context rebuild)`)}let g=new Set;for(let o of Object.values(a.forward))for(let e of o)g.add(e.ecid);let h=new Set;for(let o of t)for(let e of o.supersessions)e.kind==="node"?(e.old in a.nodeLabel||n.push(`SUPERSEDE_UNKNOWN_OLD: ${e.old} (record ${o.seq})`),e.new!==null&&e.new!==e.old&&!(e.new in a.nodeLabel)&&n.push(`SUPERSEDE_UNKNOWN_NEW: ${String(e.new)} (record ${o.seq})`),e.new===e.old?h.delete(e.old):(h.has(e.old)&&n.push(`DOUBLE_SUPERSEDE: ${e.old} re-superseded while live (record ${o.seq})`),h.add(e.old))):g.has(e.ecid)||n.push(`SUPERSEDE_UNKNOWN_ECID: ${e.ecid} (record ${o.seq})`);for(let o of Object.keys(a.superseded)){let e=new Set,r=o;for(;r!==null&&r in a.superseded;){if(e.has(r)){n.push(`SUPERSEDE_CYCLE: chain from ${o} revisits ${r}`);break}e.add(r),r=a.superseded[r]}}for(let[o,e]of Object.entries(a.names))e in a.nodeLabel||n.push(`NAME_UNKNOWN_TARGET: slug ${o} \u2192 ${e} not in the graph`);for(let o of t)for(let e of o.edges){let r=a.nodeLabel[e.src]??"(unknown)",d=a.nodeLabel[e.dst]??"(unknown)";for(let c of I(e.type,r,d,e.props))n.push(`${c.code}: ${e.ecid} ${c.detail}`)}let i=new Map;for(let o of Object.values(a.forward))for(let e of o){if(e.ecid in a.superseded)continue;let r=i.get(e.type)??[];r.push(e),i.set(e.type,r)}for(let[o,e]of i){let r=O(o);if(r?.acyclic){let d=new Map;for(let f of e)d.set(f.src,[...d.get(f.src)??[],f.dst]);let c=new Map,u=f=>{c.set(f,1);for(let E of d.get(f)??[])if(c.get(E)===1||c.get(E)===void 0&&u(E))return!0;return c.set(f,2),!1};for(let f of d.keys())if(c.get(f)===void 0&&u(f)){n.push(`EDGE_CYCLE: live ${o} edges form a cycle reachable from ${f}`);break}}if(r?.cardinality==="one-live-per-src"||r?.cardinality==="one-live-per-src-and-dst"){let d=new Map;for(let c of e)c.dst in a.superseded||d.set(c.src,(d.get(c.src)??0)+1);for(let[c,u]of d)u>1&&n.push(`CARDINALITY_VIOLATION: ${u} live ${o} edges from ${c} (one-live-per-src)`)}if(r?.cardinality==="one-live-per-src-and-dst"){let d=new Map;for(let c of e)c.src in a.superseded||c.dst in a.superseded||d.set(c.dst,(d.get(c.dst)??0)+1);for(let[c,u]of d)u>1&&n.push(`CARDINALITY_VIOLATION: ${u} live ${o} edges onto ${c} (one-live-per-dst)`)}}for(let[o,e]of Object.entries(a.nodeLabel)){let r=x(s,o);if(!v(r)){n.push(`missing node file for ${o} (run kane-cli context rebuild)`);continue}try{let d=JSON.parse(S(r,"utf8"));(d.label!==e||j(d.label,d.content)!==o)&&n.push(`node file content mismatch for ${o} (run kane-cli context rebuild)`);for(let c of k(d.label,d.content))n.push(`${c.code}: ${o} ${c.detail}`)}catch{n.push(`corrupt node file for ${o} (run kane-cli context rebuild)`)}}return{ok:n.length===0,issues:n,records:t.length}}function R(s){return Array.isArray(s)?s.map(R):s&&typeof s=="object"?Object.fromEntries(Object.entries(s).sort(([n],[t])=>n<t?-1:1).map(([n,t])=>[n,R(t)])):s}export{x as a,V as b,Z as c,Q as d};
|
package/dist/chunk-ACEODVSC.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{f as Be}from"./chunk-K5JGCJ2K.js";import{a as fe,e as Me,g as Te,h as Ge}from"./chunk-DXK55KGR.js";import{b as Ne,f as je,g as Ue,h as He}from"./chunk-FXPPQL4D.js";import{a as Oe}from"./chunk-RE3BZVGE.js";import{a as Pe,b as Ae}from"./chunk-JFAFKHDX.js";import{e as z,f as re}from"./chunk-WIA7TPK3.js";import{c as Ee}from"./chunk-6GTOYTCQ.js";import{b as Ie}from"./chunk-YKTYVJBN.js";import{a as Fe}from"./chunk-6AYUSR7X.js";import{a as ee,d as te}from"./chunk-2PQXEEVY.js";import{a as R}from"./chunk-MCQXRJGH.js";import{b as Re}from"./chunk-ZG2V2ODK.js";import{d as U}from"./chunk-5YPBPZUR.js";import{appendFileSync as rt,mkdirSync as he,writeFileSync as pe}from"fs";import{extname as st,join as M}from"path";var E=class extends Error{code;constructor(e,c){super(`${e}: ${c}`),this.name="ProposalAdapterError",this.code=e}};function qe(s){return s.version===2}function Le(s,e){if(s.read_basis.length!==1)throw new E("READ_BASIS_COUNT",`read_basis must have exactly 1 element, got ${s.read_basis.length}`);let c=s.read_basis[0],x=s.use_cases.map(o=>{if(o.cite.length!==1)throw new E("CITE_COUNT",`${o.temp_ref}: cite must have exactly 1 element, got ${o.cite.length}`);let m=o.cite[0];if(m.source_id!==c.source_id)throw new E("SOURCE_MISMATCH",`${o.temp_ref}: cite source ${m.source_id} != read_basis source ${c.source_id} (single-source)`);return{temp_ref:o.temp_ref,title:o.title,...o.description!==void 0?{description:o.description}:{},...o.summary!==void 0?{summary:o.summary}:{},...o.actors!==void 0?{actors:o.actors}:{},...o.value!==void 0?{value:o.value}:{},risk:o.risk,cite:{anchor:m.anchor,quote:m.quote},...o.criteria!=null&&o.criteria.length>0?{criteria:o.criteria.map((u,h)=>{if(u.cite.source_id!==c.source_id)throw new E("SOURCE_MISMATCH",`${o.temp_ref}.criteria[${h}]: cite source ${u.cite.source_id} != read_basis source ${c.source_id} (single-source)`);return{text:u.text,cite:{anchor:u.cite.anchor,quote:u.cite.quote}}})}:{},depends_on_hint:o.depends_on_hint,matches_existing:o.matches_existing,...o.conflicts_with!=null?{conflicts_with:o.conflicts_with}:{},...o.changed?{changed:!0}:{},...o.updated!=null?{updated:{...o.updated.title!=null?{title:o.updated.title}:{},...o.updated.description!=null?{description:o.updated.description}:{},...o.updated.summary!=null?{summary:o.updated.summary}:{},...o.updated.actors!=null?{actors:o.updated.actors}:{},...o.updated.value!=null?{value:o.updated.value}:{},...o.updated.risk!=null?{risk:o.updated.risk}:{},...o.updated.criteria!=null?{criteria:o.updated.criteria.map((u,h)=>{if(u.cite.source_id!==c.source_id)throw new E("SOURCE_MISMATCH",`${o.temp_ref}.updated.criteria[${h}]: cite source ${u.cite.source_id} != read_basis source ${c.source_id} (single-source)`);return{text:u.text,cite:{anchor:u.cite.anchor,quote:u.cite.quote}}})}:{}}}:{},...o.change_note!=null?{change_note:o.change_note}:{}}});return{version:1,read_basis:e,source:{source_id:c.source_id,source_cid:c.source_cid},use_cases:x}}function We(s){let{contextDir:e,graph:c}=s,x=s.maxDigestBytes??4096,o={},m=[];for(let[d,g]of c.heads){if(o[d]=g,typeof g!="string")continue;let _=c.mediaOf(g),w=c.getNode(g)?.content?.blob;if(typeof w=="string")if(_.format==="image")m.push({source_id:d,cid:g,format:"image",blobRef:{path:ee(e,w),cid:w}});else{let n=te(e,w)?.toString("utf8")??"";m.push({source_id:d,cid:g,format:_.format,text:n})}}m.sort((d,g)=>d.source_id<g.source_id?-1:1);let u=[];for(let d of c.byLabel(U.STYLENOTE).sort((g,_)=>g.cid<_.cid?-1:1))c.superseded.has(d.cid)||u.push(`\u2022 ${String(d.content.statement)} [${String(d.content.learned_from_kind)}]`);let h="";for(let d of u){if(Buffer.byteLength(h+d+`
|
|
3
|
-
`,"utf8")>x)break;h+=d+`
|
|
4
|
-
`}return{read_basis:o,sources:m,styleNoteDigest:h}}function ze(s,e){let c=We({contextDir:s,graph:e}).styleNoteDigest;return c.length>0?c:void 0}function ot(s){return s.length>8&&s[0]===137&&s[1]===80&&s[2]===78&&s[3]===71?"image/png":s.length>3&&s[0]===255&&s[1]===216&&s[2]===255?"image/jpeg":s.length>12&&s.toString("ascii",0,4)==="RIFF"&&s.toString("ascii",8,12)==="WEBP"?"image/webp":null}function it(s){return s.toString("utf8").replace(/\n$/,"").split(`
|
|
5
|
-
`).map((c,x)=>`${String(x+1).padStart(4,"0")}| ${c}`).join(`
|
|
6
|
-
`)}function Ve(s){return s.toISOString().replace(/[-:]/g,"").slice(0,15)}function nt(s){return s.startsWith("su-conv-")?`conv-${Re(Buffer.from(s,"utf8")).slice(0,8)}`:s}function Ke(s){return s.source_id.startsWith("su-conv-")?"the conversation":s.source_id}function at(s,e,c){return`reading ${Ke(s)}${c>1?` (source ${e} of ${c})`:""}`}function V(s){return s.toLowerCase().trim().replace(/\s+/g," ")}function Je(s,e){let c=new Map,x=new Map,o=new Map;for(let{cid:u,content:h}of e.byLabel(U.USECASE)){if(e.superseded.has(u))continue;(e.trust.get(u)==="archived"?o:x).set(V(String(h.title??"")),u)}let m=u=>e.trust.get(u)==="archived"?{cid:u,archived:!0,reason:e.archivedReason.get(u)}:{cid:u};for(let u of s.use_cases){if(u.matches_existing){let g=u.matches_existing.cid;if(e.superseded.has(g)){let _=e.tipOf(g);g=e.superseded.has(_)?null:_}if(g!==null){c.set(u.temp_ref,m(g));continue}}let h=x.get(V(u.title));if(h){c.set(u.temp_ref,{cid:h});continue}let d=o.get(V(u.title));d&&c.set(u.temp_ref,m(d))}return c}var Xe=/^(\S+)\.criteria\[(\d+)\]/;function ct(s,e,c){if(e.length===0||!e.every(o=>Xe.test(o.detail)))return!1;let x=new Map;for(let o of e){let m=Xe.exec(o.detail),u=x.get(m[1])??new Set;u.add(Number(m[2])),x.set(m[1],u)}for(let o of s.use_cases){let m=x.get(o.temp_ref);m?.size&&(o.criteria=(o.criteria??[]).filter((u,h)=>!m.has(h)),c(`${o.temp_ref}: dropped ${m.size} criteria with unverifiable cites \u2014 committed without them (criteria are hints, not oracles)`))}return!0}async function Ye(s,e,c,x,o=()=>{},m){let u=(h,d)=>o(h,d,s.session_id);return Te(s,e,c,x,o,{async onProposalEvent(h){let d=h,g=null,_=null;if(qe(d))try{g=Le(d,s.read_basis),u("adapter",{ok:!0,use_cases:g.use_cases.length})}catch(w){_=w instanceof E?w.message:String(w),u("adapter",{ok:!1,error:_})}else g=d;return g&&g.use_cases.length===0&&e.out("warning: the agent proposed ZERO use-cases for this source"),g&&m&&await m(g),{proposal:g,error:_}}})}var ut=new Set(["agent","ci","override"]);async function Ut(s,e){let c=s.mode??"interactive";if(c==="interactive"){if(!e.isTTY)return e.out("extract: --mode interactive needs a TTY (use --mode agent|ci|override headless)"),2}else if(!ut.has(c))return e.out(`extract: unknown mode "${c}" \u2014 interactive | agent | ci | override`),2;let x=Ve(e.now?.()??new Date),o=M(e.contextDir,"logs");he(o,{recursive:!0});let m=M(o,`extract-${x}.log`),u=`run-${x}-${Math.random().toString(36).slice(2,8)}`,h=t=>t==="error"||t==="failed_proposal"?"error":t==="repair_respawn"?"warn":"info",d=(t,a,l)=>{try{rt(m,JSON.stringify({ts:new Date().toISOString(),level:h(t),run_id:u,...l?{session_id:l}:{},kind:t,data:a})+`
|
|
7
|
-
`)}catch{}};e.out(`trace: ${fe(m)}`),e.emit?.({type:"run_start",mode:c,trace:m});let g=Ie();if(g&&e.out(g),e.preflightTurn){let t=await e.preflightTurn();if(d("preflight",t),!t.ok)return e.out(t.message??"error: turn-endpoint preflight failed"),e.emit?.({type:"error",message:t.message??"error: turn-endpoint preflight failed",code:"PREFLIGHT"}),2}let _=R(e.contextDir),w=ze(e.contextDir,_);if(s.source){if(s.resume){let a="error: --source cannot be combined with --resume (the resumed session already has its scope)";return e.out(a),e.emit?.({type:"error",message:a,code:"SOURCE_WITH_RESUME"}),2}let t=_.heads.get(s.source);if(typeof t!="string"){let a=t===null?`error: --source ${s.source} was ingested but is retired \u2014 re-ingest it to extract again`:`error: --source ${s.source} is not an ingested source (kane-cli context list shows them)`;return e.out(a),e.emit?.({type:"error",message:a,code:"SOURCE_UNKNOWN"}),2}}let n=null;if(s.resume){try{n=He(e.contextDir,s.resume,_)}catch(l){return e.out(`error: ${l instanceof Error?l.message:String(l)}`),e.emit?.({type:"error",message:`error: ${l instanceof Error?l.message:String(l)}`}),1}let t=n.handle.state.change_basis;if(t&&(_.heads.get(t.source_id)??null)!==t.new_head){let l=`error: ${t.source_id} moved while this reconcile extraction was paused \u2014 its recorded change context no longer matches; re-run kane-cli maintain reconcile against the current file (session ${s.resume} is defunct and can be ignored)`;return e.out(l),e.emit?.({type:"error",message:l,code:"CHANGE_BASIS_MOVED"}),n.handle.release(),2}n.staleBasis.length>0&&e.out(`note: changed since the pause: ${n.staleBasis.join(", ")} \u2014 re-presented items may be stale`);let a=n.handle.state.held_receipts??[];if(a.length>0)if(e.chat?.holdReceipt)for(let l of a)e.chat.holdReceipt(l);else e={...e,initialMessage:[a.join(`
|
|
8
|
-
|
|
9
|
-
`),e.initialMessage].filter(Boolean).join(`
|
|
10
|
-
|
|
11
|
-
`)};n.handle.state.assumed.length>0&&e.out(`note: ${n.handle.state.assumed.length} default(s) were assumed while you were away \u2014 kane-cli context sessions show ${s.resume} lists them`)}let _e=_.extractedSourceCids,J=!!(s.force||n?.handle.state.force),v=[],P=[];for(let[t,a]of _.heads.entries())if(a!=null&&!(s.source&&t!==s.source)){if(!s.source&&!n&&t.startsWith("su-conv-")){e.out(`skipped: ${t} \u2014 conversation source (extract it explicitly with --source ${t})`),P.push({source_id:t,reason:"conversation"});continue}if(n){let l=t in n.handle.state.read_basis,I=n.handle.state.corpus_cursor.remaining.includes(t);if(!l&&!I)continue;if(I&&!J&&_e.has(a)){e.out(`cached: ${t} @ ${a.slice(0,19)} already extracted \u2014 skipping`),P.push({source_id:t,reason:"cached"});continue}}else if(!J&&_e.has(a)){e.out(`cached: ${t} @ ${a.slice(0,19)} already extracted \u2014 skipping`),P.push({source_id:t,reason:"cached"});continue}v.push({source_id:t,cid:a})}let Qe=t=>{let a=Be(e.contextDir,t);a&&e.out(`note: a reconcile plan for ${t} is pending (${a.pending} item(s)) \u2014 resume with \`kane-cli maintain reconcile --apply ${a.path}\``)};for(let t of P)t.reason==="cached"&&Qe(t.source_id);if(e.emit?.({type:"corpus",sources:v,skipped:P}),v.length===0){if(n){let l=`error: resumed session's paused source (${Object.keys(n.handle.state.read_basis).join(", ")||"unknown"}) is no longer in the corpus \u2014 restore/re-ingest it and re-run --resume ${s.resume}, or discard with: kane-cli context sessions clean ${s.resume}`;return e.out(l),e.emit?.({type:"error",message:l,code:"SOURCE_MISSING"}),n.handle.release(),2}let t=P.length>0&&P.every(a=>a.reason==="conversation");return e.out(s.source?`extract: nothing to do \u2014 ${s.source} is already extracted at its current snapshot (--force to re-run)`:t?"extract: nothing to do \u2014 only conversation sources here (extract one explicitly with --source <id>)":"extract: nothing to do \u2014 every ingested source is already extracted"),0}let X=new Map;if(n&&n.questions.length>0&&!s.message){e.out(`re-presenting ${n.questions.length} unanswered question(s) from the paused session`);let t=await e.ask(n.questions.map(je));for(let a of t)X.set(a.id,a)}let H=e.by??{kind:"human",id:"owner"},A=c==="interactive"&&!s.plan&&!!e.chat,se=0,xe=0;try{for(let t of v){let a=R(e.contextDir),l={current:a};e.chat?.attachOnCommitted?.(r=>{l.current=r});let I=a.getNode(t.cid),G=String(I?.content.blob??""),oe=te(e.contextDir,G);if(!oe)return e.out(`error: ${t.source_id}: blob ${G} missing from .context/blobs`),e.emit?.({type:"error",source_id:t.source_id,message:`error: ${t.source_id}: blob ${G} missing from .context/blobs`,code:"BLOB_MISSING"}),1;let ve=a.mediaOf(t.cid),ie=ve.media_type.startsWith("image/");if(!ie){let r=ot(oe);if(r){e.out(`skipping ${t.source_id}: binary ${r} ingested before image support \u2014 re-ingest it (kane-cli context ingest) to extract from it`),e.emit?.({type:"source_skipped",source_id:t.source_id,reason:"binary_pre_media"});continue}}let q=ie?`0001| (image source ${t.source_id} \u2014 the content is attached as an image; cite it with anchor img#whole)`:it(oe),ye=Ve(e.now?.()??new Date),T=`${ye}-${t.source_id}`,$e=!!(n&&t.source_id in n.handle.state.read_basis)?s.resume:`ext-${ye}-${nt(t.source_id)}`,N="";if(A){let r=Ee({contextDir:e.contextDir,graph:R(e.contextDir),sessionStamp:$e,by:H});r.errors===null||r.errors[0]?.code==="CONV_SOURCE_EXISTS"?(N=r.sourceId,e.chat.attachConversationSource?.(N),l.current=R(e.contextDir)):e.out(`warning: conversation source unavailable (${r.errors[0]?.detail}) \u2014 chat adds will not land this session`)}let b={type:"run_config",version:1,session_id:$e,mode:c,source:{source_id:t.source_id,source_cid:t.cid,kind:st(t.source_id)||"md",numbered_text:q},existing_use_cases:a.byLabel(U.USECASE).filter(({cid:r})=>a.trust.get(r)!=="archived"&&!a.superseded.has(r)).map(({cid:r,content:i})=>({id:r,title:String(i.title??""),summary:String(i.summary??"")})),read_basis:l.current.latestHash,max_free_text_rounds:Me,graph_reads:!0,verb:"extract",...w!==void 0?{style_note_digest:w}:{},...s.changeContext&&s.changeContext.source_id===t.source_id?{change_context:s.changeContext}:{},topology:Fe(),...A?{chat:!0}:{},...ie?{image_sources:[{source_id:t.source_id,source_cid:t.cid,media_type:ve.media_type,blob_ref:{path:ee(e.contextDir,G),cid:G}}]}:{},...n&&t.source_id in n.handle.state.read_basis?{resume:{agent_state:n.handle.state.agent_state}}:{}};A||e.out(n&&t.source_id in n.handle.state.read_basis?`resuming: ${t.source_id} (session ${s.resume})`:`extracting: ${t.source_id} @ ${t.cid.slice(0,19)}`),e.emit?.({type:"source_start",source_id:t.source_id,cid:t.cid,index:v.indexOf(t)+1,total:v.length,resumed:!!(n&&t.source_id in n.handle.state.read_basis)}),e.chat?.ledger?.({kind:"banner",text:at(t,v.indexOf(t)+1,v.length)}),e.chat?.setWorking?.(`Reading ${Ke(t)}\u2026`);let be=new Map;d("spawn",{source_id:t.source_id,source_cid:t.cid,resume:!!n,chat:A},b.session_id);let Se=!1,Ze=async r=>{let i=z(r,q,R(e.contextDir));if(d("kane_validate",{errors:i.map(p=>p.code)},b.session_id),i.length>0){e.chat.submit("[auto-repair] the proposal failed validation: "+i.map(p=>`${p.code}: ${p.detail}`).join("; ")+" \u2014 please re-finalize with these fixed.");return}let y=R(e.contextDir),k=Je(r,y),Q=M(e.contextDir,"proposals",T);he(Q,{recursive:!0}),pe(M(Q,"proposal.json"),JSON.stringify(r,null,2)+`
|
|
12
|
-
`);let tt=new Map(r.use_cases.map(p=>[p.temp_ref,{resolution:"skipped"}])),Z=re({contextDir:e.contextDir,graph:y,proposal:r,proposalId:T,verdicts:tt,by:{kind:"ai",id:"extract-agent"},autoName:!0});if(Z.errors){e.chat.ledger?.({kind:"commit",ok:!1,line:"commit failed \u2014 nothing landed",warnings:Z.errors.map(p=>`${p.code}: ${p.detail}`)});return}Se=!0;let B=Z.record.nodes.length;se+=B;let j=r.use_cases.length-B;{let p=R(e.contextDir),De=new Map;for(let{cid:$,content:C}of p.byLabel(U.USECASE))p.superseded.has($)||De.set(V(String(C.title??"")),$);let ge=[];for(let $ of r.use_cases){let C=null;if($.matches_existing?.cid&&p.hasNode($.matches_existing.cid)){let W=p.tipOf($.matches_existing.cid);C=p.superseded.has(W)?null:W}C=C??De.get(V($.title))??null,C&&ge.push({ref:$.temp_ref,cid:C})}ge.length>0&&e.chat.registerAliases?.(ge),l.current=p;let ke=$=>{for(let[C,W]of p.names)if(W===$&&!p.superseded.has(W))return C},Ce=Oe({verb:"extract",commitN:1,phase:"proposal",committed:Z.record.nodes.map($=>({cid:$.cid,...ke($.cid)?{logical_id:ke($.cid)}:{}})),reused:j},p);e.emit?.(Ce.event),e.chat.holdReceipt?.(Ce.text)}d("commit",{derived:B,evidence_matched:j,chat:!0},b.session_id),e.chat.ledger?.({kind:"commit",ok:!0,line:B===0&&j>0?`all ${j} matched existing \u2014 nothing new to save`:`saved ${B} use-case${B===1?"":"s"} as drafts`+(j>0?` \xB7 ${j} matched existing`:"")})},we=!!(n&&t.source_id in n.handle.state.read_basis),Y=we&&X.size>0?{...e,ask:async r=>r.every(i=>X.has(i.id))?(n.handle.markApplied(r.map(i=>`resolveq:${s.resume}:${i.id}`)),e.out(`answered ${r.length} re-asked question(s) from the held resume answers`),r.map(i=>X.get(i.id))):e.ask(r)}:e;we&&s.message&&(Y={...Y,initialMessage:s.message});let f=await Ye(b,{...Y,graphSlot:l},be,a,d,A?Ze:void 0);if(e.chat?.setWorking?.(null),f.error)return e.out(`error: agent failed for ${t.source_id}: ${f.error}`),e.emit?.({type:"error",source_id:t.source_id,message:`error: agent failed for ${t.source_id}: ${f.error}`}),1;if(f.highRisk)return e.out(`error: ${f.highRisk.length} high-risk decision${f.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",source_id:t.source_id,message:`error: high-risk question(s) in ci mode (fail-closed): ${f.highRisk.map(r=>r.id).join(", ")}`,code:"HIGH_RISK_CI"}),1;if(f.paused){let r=v.slice(v.indexOf(t)+1).map(Q=>Q.source_id),i=n?.handle??Ne(e.contextDir,{sid:b.session_id,mode:"agent",created_at:(e.now?.()??new Date).toISOString(),expires_at:new Date((e.now?.()??new Date).getTime()+1440*60*1e3).toISOString(),agent_state:f.paused.agent_state,pending:{questions:[],proposals:[]},assumed:[],read_basis:{[t.source_id]:t.cid},corpus_cursor:{remaining:r},conv_source:N,verb:"extract",...J?{force:!0}:{},...s.changeContext?{change_basis:{source_id:s.changeContext.source_id,new_head:s.changeContext.new_head}}:{}});N&&i.state.conv_source!==N&&i.save({conv_source:N});let y=e.chat?.drainHeldReceipts?.()??[];(y.length>0||(i.state.held_receipts?.length??0)>0)&&i.save({held_receipts:y}),n?.handle&&i.save({read_basis:{[t.source_id]:t.cid},corpus_cursor:{remaining:r},...J&&!i.state.force?{force:!0}:{}}),Ue(i,f.paused),d("session_paused",{sid:i.state.sid},b.session_id);let k=`kane-cli context extract --resume ${i.state.sid} --mode ${c}`;return e.out(`paused: session ${i.state.sid} saved \u2014 resume with: ${k}`),e.emit?.({type:"session_paused",sid:i.state.sid,source_id:t.source_id,mode:c,resume:k,expires_at:i.state.expires_at,pending_questions:f.paused.pending.questions}),e.chat?.ledger?.({kind:"pause",sid:i.state.sid,expires_at:i.state.expires_at,resume:k,messageForm:`${k} --message "<your words>"`}),3}if(A){if(xe+=f.assumedDefaults??0,f.error)return 1;if(!Se){let r=v.length-v.indexOf(t)-1;return e.out(`done \u2014 nothing committed for ${t.source_id} (no finalize before the session ended)`+(r>0?`; stopping here \u2014 ${r} remaining source(s) not extracted (re-run kane-cli context extract to continue)`:"")),n&&t.source_id in n.handle.state.read_basis&&(n.handle.complete(),n=null),0}n&&t.source_id in n.handle.state.read_basis&&(n.handle.complete(),n=null);continue}if(!f.proposal)return e.out(`error: agent ended without a proposal for ${t.source_id}`),e.emit?.({type:"error",source_id:t.source_id,message:`error: agent ended without a proposal for ${t.source_id}`}),1;let D=z(f.proposal,q,a);if(d("kane_validate",{errors:D.map(r=>r.code)},b.session_id),D.length>0&&ct(f.proposal,D,r=>e.out(r))&&(d("criteria_dropped",{source_id:t.source_id},b.session_id),D=z(f.proposal,q,a)),D.length>0){if(e.out("the agent's proposal didn't validate \u2014 retrying once"),e.emit?.({type:"validate_failed",source_id:t.source_id,codes:D.map(r=>r.code),repairing:!0}),d("repair_respawn",{source_id:t.source_id},b.session_id),f=await Ye(b,{...Y,graphSlot:l},be,a,d),f.error||!f.proposal)return e.out(`error: repair run failed for ${t.source_id}`),e.emit?.({type:"error",source_id:t.source_id,message:`error: repair run failed for ${t.source_id}`}),1;if(D=z(f.proposal,q,a),D.length>0){for(let r of D)e.out(` ${r.detail}`);return e.emit?.({type:"validate_failed",source_id:t.source_id,codes:D.map(r=>r.code),repairing:!1}),e.emit?.({type:"error",source_id:t.source_id,message:`error: proposal failed validation after repair (${D.map(r=>r.code).join(", ")})`}),1}}let S=f.proposal,K=Je(S,a),ne=M(e.contextDir,"proposals",T);if(he(ne,{recursive:!0}),pe(M(ne,"proposal.json"),JSON.stringify(S,null,2)+`
|
|
13
|
-
`),s.plan){e.out(`plan: ${S.use_cases.length} use-case(s) proposed from ${t.source_id} (nothing committed)`);for(let r of S.use_cases){let i=K.get(r.temp_ref),y=i?i.archived?` \u2248 matches ARCHIVED ${i.cid.slice(0,19)}${i.reason?` \u2014 previously rejected: "${i.reason}"`:" \u2014 previously rejected"}`:` \u2248 matches ${i.cid.slice(0,19)}`:"";e.out(` [${r.risk}] ${r.title} \u2014 cite ${r.cite.anchor}${y}`)}e.emit?.({type:"plan",source_id:t.source_id,use_cases:S.use_cases.map(r=>{let i=K.get(r.temp_ref);return{risk:r.risk,title:r.title,anchor:r.cite.anchor,...i?{match:i.cid,match_archived:!!i.archived}:{}}})}),f.assumedDefaults&&e.out(`assumed: ${f.assumedDefaults} default(s) auto-taken (flagged)`);continue}for(let r of S.use_cases){if(!r.conflicts_with?.length)continue;let i=r.conflicts_with.filter(k=>a.resolve(k)!==null),y=r.conflicts_with.filter(k=>a.resolve(k)===null);y.length>0&&(e.out(`note: ${r.temp_ref}: dropped unresolvable conflict hint(s): ${y.join(", ")}`),r.conflicts_with=i.length>0?i:void 0)}d("review_start",{use_cases:S.use_cases.length,flags:K.size},b.session_id);let L=await e.review(S.use_cases,K);d("review_verdicts",[...L.entries()].map(([r,i])=>({ref:r,resolution:i.resolution})),b.session_id),pe(M(ne,"review.json"),JSON.stringify(S.use_cases.map(r=>{let i=L.get(r.temp_ref)??{resolution:"skipped"};return{id:r.temp_ref,kind:"review-item",resolution:i.resolution,edit:i.edit??null,reason:i.reason??null,...i.supersedeTarget?{supersede_target:i.supersedeTarget}:{},by:H}}),null,2)+`
|
|
14
|
-
`);let ae=a,O=re({contextDir:e.contextDir,graph:ae,proposal:S,proposalId:T,verdicts:L,by:H,autoName:!0});if(O.errors&&O.errors[0]?.code==="STALE_BASIS"){if(!await e.confirmStale(`the context changed while you reviewed (${O.errors[0].detail}) \u2014 commit against the new head anyway?`))return e.out("aborted: proposal not committed"),e.emit?.({type:"error",source_id:t.source_id,message:"aborted: proposal not committed",code:"STALE_BASIS"}),e.emit?.({type:"done",status:"aborted",exit_code:1}),1;ae=R(e.contextDir),O=re({contextDir:e.contextDir,graph:ae,proposal:S,proposalId:T,verdicts:L,by:H,allowStaleBasis:!0,autoName:!0})}if(O.errors){for(let r of O.errors)e.out(` ${r.detail}`);return e.emit?.({type:"error",source_id:t.source_id,message:`error: commit failed: ${O.errors.map(r=>`${r.code}: ${r.detail}`).join("; ")}`}),1}let et=new Date().toISOString();for(let r of S.use_cases){let i=L.get(r.temp_ref)??{resolution:"skipped"};for(let y of Ae({ts:et,command:"context extract",id:r.temp_ref,by:H},i.resolution))Pe(e.contextDir,y)}let F=O.record,ce=new Map(F.review.map(r=>[r.id,r.resolution])),ue=[...ce.values()].filter(r=>r==="approved"||r==="edited").length,de=[...ce.values()].filter(r=>r==="rejected").length,le=F.nodes.filter(r=>!ce.has(r.cid)).length,me=F.supersessions.filter(r=>r.kind==="node"&&r.new!==r.old).length;d("commit",{trusted:ue,derived:le,archived:de},b.session_id),e.out(`committed: ${ue} trusted, ${le} derived (queued), ${de} archived`+(me>0?`, ${me} superseded`:"")),f.assumedDefaults&&e.out(`assumed: ${f.assumedDefaults} default(s) auto-taken (flagged)`),e.emit?.({type:"commit",source_id:t.source_id,proposal_id:T,trusted:ue,derived:le,archived:de,superseded:me,assumed:f.assumedDefaults??0,evidence_matched:Math.max(0,S.use_cases.length-F.nodes.length),minted:F.nodes.map(r=>{let i=F.names?.find(y=>y.cid===r.cid)?.slug;return{cid:r.cid,...i?{logical_id:i}:{}}})}),n&&t.source_id in n.handle.state.read_basis&&(n.handle.complete(),e.out(`session ${s.resume} complete`),e.emit?.({type:"session_complete",sid:s.resume,source_id:t.source_id}),n=null)}}finally{n?.handle.release()}if(A){let t=e.chat?.state.ledger.filter(I=>I.kind==="answer"&&I.receipt.form==="assumed").length??0,a=xe+t,l=e.chat?.state.credits?.total;e.chat?.ledger?.({kind:"summary",lines:[`saved ${se} use-case${se===1?"":"s"} across ${v.length} source${v.length===1?"":"s"}`,...a>0?[`${a} assumed default(s)`]:[],...l!==void 0?[`credits used: ${l.toFixed(1)}`]:[],`trace: ${fe(m)}`]})}return s.plan||Ge(e.contextDir),0}export{nt as a,Ke as b,at as c,Je as d,Ut as e};
|
package/dist/chunk-CT2I5KUM.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{existsSync as l}from"fs";import{dirname as f,resolve as i}from"path";import{fileURLToPath as d}from"url";var g=f(d(import.meta.url));function p(){return[i(g,".."),i(g,"../../..")]}function A(o){return{"darwin-arm64":"kane-cli-darwin-arm64","darwin-x64":"kane-cli-darwin-x64","linux-x64":"kane-cli-linux-x64","linux-arm64":"kane-cli-linux-arm64","win32-x64":"kane-cli-win-x64"}[o]??null}function h(){let o=A(`${process.platform}-${process.arch}`),n=process.platform==="win32"?"assurance-agent.exe":"assurance-agent";for(let r of p()){for(let s of o?["@testmuai","@lambdatestincprivate"]:[]){let e=i(r,"node_modules",s,o,"bin",n);if(l(e))return{cmd:e,args:[]}}let a=i(r,"../assurance-agent/dist",n);if(l(a))return{cmd:a,args:[]};let t=i(r,"../assurance-agent/main.py");if(l(t)){let s=i(r,"../assurance-agent/.venv/bin/python");return{cmd:l(s)?s:"python3",args:[t]}}}return null}function w(o,n={}){return{...process.env,...n,TESTMUAI_SOURCE:"kane-cli",TESTMUAI_SESSION_ID:o,ASSURANCE_LOG_LEVEL:process.env.ASSURANCE_LOG_LEVEL??"info"}}async function x(){if(process.env.TESTMUAI_API_KEY||process.env.TESTMUAI_BASIC_AUTH)return{};try{let{CredentialsManager:o}=await import("./credentials-NLJHSVBY.js"),n=process.env.TESTMUAI_ENV==="stage"?"stage":"prod",r=new o,a=r.getActiveProfile()??"default",t={TESTMUAI_ENV:n},s=r.loadBasicAuth(a,n);if(s)return t.TESTMUAI_BASIC_AUTH=Buffer.from(`${s.username}:${s.access_key}`,"utf8").toString("base64"),t;let e=r.loadCredentials(a,n);if(e){try{let{refreshOAuthToken:u}=await import("./token-refresh-F5KRV7ER.js");await u({creds:r,profile:a,env:n,credentials:e})}catch{}let c=r.loadCredentials(a,n)??e;if(typeof c.access_token=="string"){let u=await E(n,c.access_token);return u?(t.TESTMUAI_BASIC_AUTH=u,t):(t.TESTMUAI_API_KEY=c.access_token,t)}}return{}}catch{return{}}}var _=8e3;function m(){return process.stderr.write("warn: session auth may expire during long runs \u2014 if that happens, run `kane-cli login` and retry\n"),null}async function E(o,n){if(process.env.TESTMUAI_BASE_URL)return null;try{let[{getEnvironment:r},{ControllerClient:a}]=await Promise.all([import("./config-OJF53CHL.js"),import("./controller-client-RD2YEMAH.js")]),t=new a(r(o).controllerBaseUrl,n),s;try{let e=await Promise.race([t.getTmsCredentials().catch(()=>null),new Promise(c=>{s=setTimeout(()=>c(null),_)})]);return typeof e?.username!="string"||!e.username||typeof e.access_key!="string"||!e.access_key?m():Buffer.from(`${e.username}:${e.access_key}`,"utf8").toString("base64")}finally{clearTimeout(s)}}catch{return m()}}export{A as a,h as b,w as c,x as d};
|
package/dist/chunk-E3BO7OVR.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as x}from"./chunk-W36P7S5W.js";import{a as w}from"./chunk-DNOBOZPO.js";import{spawn as M,execSync as V}from"child_process";import{appendFileSync as T,existsSync as g,mkdirSync as k}from"fs";import{homedir as P}from"os";import{join as U,resolve as t,dirname as h}from"path";import{fileURLToPath as B}from"url";import{createInterface as L}from"readline";async function*A(n){let e=L({input:n,crlfDelay:1/0});for await(let d of e){let r=d.trim();if(r)try{let l=JSON.parse(r);l&&typeof l.type=="string"&&(yield l)}catch{}}}function N(n){return n==="action"?{set:{V16_AGENT_ENABLE_ALL_BLOCKERS:"true",V16_BIFURCATION_PHASES:"1"},unset:["V16_NETWORK_WS","V16_NETWORK_SSE"]}:{set:{V16_BIFURCATION_PHASES:"1"},unset:["V16_AGENT_ENABLE_ALL_BLOCKERS","V16_NETWORK_WS","V16_NETWORK_SSE"]}}function O(n){return n?{set:{},unset:["V16_AGENT_SKIP_CP_FINAL"]}:{set:{V16_AGENT_SKIP_CP_FINAL:"true"},unset:[]}}function b(n){return n==="dom"?{set:{V16_AGENT_ENABLE_TEXTUAL_VISUAL:"true"},unset:[]}:{set:{},unset:["V16_AGENT_ENABLE_TEXTUAL_VISUAL"]}}var o=h(B(import.meta.url));function G(){for(let n of["python3","python"])try{return V(`${n} --version`,{stdio:"ignore"}),n}catch{}return null}function K(){let e=process.platform==="win32"?"v16-runner.exe":"v16-runner",d={"darwin-arm64":["@testmuai/kane-cli-darwin-arm64","@lambdatestincprivate/kane-cli-darwin-arm64"],"darwin-x64":["@testmuai/kane-cli-darwin-x64","@lambdatestincprivate/kane-cli-darwin-x64"],"linux-x64":["@testmuai/kane-cli-linux-x64","@lambdatestincprivate/kane-cli-linux-x64"],"linux-arm64":["@testmuai/kane-cli-linux-arm64","@lambdatestincprivate/kane-cli-linux-arm64"],"win32-x64":["@testmuai/kane-cli-win-x64","@lambdatestincprivate/kane-cli-win-x64"]},r=`${process.platform}-${process.arch}`,l=d[r];if(l)for(let i of l){let m=[t(o,"..","node_modules",i,"bin",e),t(o,"..","..","node_modules",i,"bin",e),t(o,"..","..","..","node_modules",i,"bin",e),t(o,"..","..","..","..","node_modules",i,"bin",e)];for(let c of m)if(g(c))return{cmd:c,args:[]}}let v=[t(o,"bin",e),t(o,"..","bin",e),t(o,"..","..","..","..","v16-runner","dist",e),t(o,"..","..","..","v16-runner","dist",e),t(o,"..","..","v16-runner","dist",e),t(process.cwd(),"v16-runner","dist",e),t(process.cwd(),"..","v16-runner","dist",e)];for(let i of v)if(g(i))return{cmd:i,args:[]};let _=[t(o,"..","..","v16-runner"),t(o,"..","..","..","..","v16-runner"),t(o,"..","..","..","v16-runner"),t(process.cwd(),"v16-runner"),t(process.cwd(),"..","v16-runner")];for(let i of _)if(g(t(i,"main.py"))){for(let c of[t(i,".venv","bin","python"),t(i,"..",".venv","bin","python"),t(i,"..","browser-agent",".venv","bin","python")])if(g(c))return{cmd:c,args:["main.py"],cwd:i};let m=G();if(m)return{cmd:m,args:["main.py"],cwd:i}}return null}function Z(n,e){let d=K();if(!d)throw new Error("v16-runner not found. Build the binary with `cd v16-runner && python build.py` or ensure Python is available.");process.env.KANE_SPAWN_DEBUG&&process.stderr.write(`[spawn-debug] ${JSON.stringify(d)}
|
|
3
|
-
`);let r={...process.env};e?.environment&&(r.TESTMUAI_ENV=e.environment),r.TESTMUAI_SOURCE="kane-cli",process.platform==="win32"&&(r.PYTHONIOENCODING="utf-8");let l=w(e?.environment);r.V16_SERVER_API_HOST=l.v16ServerHost,r.ATMS_URL=l.tmsBaseUrl.replace(/\/api\/?$/,""),n.username&&n.access_key&&(r.LT_USERNAME=n.username,r.LT_ACCESS_KEY=n.access_key),n.session_id&&(r.TESTMUAI_SESSION_ID=n.session_id);let v=N(e?.mode??"testing");Object.assign(r,v.set);for(let s of v.unset)delete r[s];let _=new x().load(),i=b(e?.assertionMode??(_.assertion_mode==="visual"?"visual":"dom"));Object.assign(r,i.set);for(let s of i.unset)delete r[s];let m=e?.finalValidation??_.final_validation,c=O(m);Object.assign(r,c.set);for(let s of c.unset)delete r[s];let a=M(d.cmd,d.args,{stdio:["pipe","pipe","pipe"],env:r,cwd:d.cwd});a.stdin.on("error",()=>{}),a.stdin.write(JSON.stringify(n)+`
|
|
4
|
-
`);let p=n.session_id?U(P(),".testmuai","kaneai","sessions",n.session_id,"runner-stderr.log"):null;if(p)try{k(h(p),{recursive:!0}),T(p,`--- runner spawn ${new Date().toISOString()} run_index=${n.run_index} ---
|
|
5
|
-
`)}catch{}let E=1e5,f="";a.stderr.on("data",s=>{if(f+=s.toString(),f.length>E&&(f=f.slice(-E)),p)try{T(p,s)}catch{}}),a.on("error",s=>{e?.log?.("error","RUNNER_SPAWN_ERROR","Runner spawn error",{error:s.message})});let S=null,y=null,C=new Promise(s=>{a.on("close",(u,R)=>{S=u,y=R?String(R):null,e?.log?.("info","RUNNER_EXIT","Runner exited",{code:u,signal:y??"none"}),s({code:u,signal:y})})}),I=A(a.stdout);return{child:a,events:I,sendUserResponse(s){let u=JSON.stringify({type:"user_response",answer:s});try{a.stdin.write(u+`
|
|
6
|
-
`)}catch{}},sendCancel(s){let u=JSON.stringify({type:"cancel",reason:s});try{a.stdin.write(u+`
|
|
7
|
-
`)}catch{}},cancel(){a.kill("SIGTERM")},get stderr(){return f},get exitCode(){return S},get exitSignal(){return y},exited:C}}export{K as a,Z as b};
|
package/dist/chunk-HJGUEZLW.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{homedir as e}from"os";import{join as t}from"path";var m="0.6.4",d="kane-cli",a=t(e(),".testmuai","kaneai"),g=t(a,"profiles"),h=t(a,"tui-config.json"),_="https://registry.npmjs.org/@testmuai/kane-cli",L="https://api.github.com/repos/LambdaTest/kane-cli/releases",n="@testmuai/kane-cli-skill",x=`https://registry.npmjs.org/${n}`,r="kane-cli",A=[{dir:t(e(),".claude","skills",r),agent:"Claude Code"},{dir:t(e(),".agents","skills",r),agent:"Codex CLI"},{dir:t(e(),".gemini","skills",r),agent:"Gemini CLI"}],u="https://dd-proxy.lambdatest.com/intake/kane-cli",U="https://kaneai-playground.lambdatest.io",b=9222,R=9230,I=t(a,"chrome-profiles"),o=t(a,"hints"),C=t(o,"state.json");function E(s){return t(o,`catalog-${s}.json`)}var i="127.0.0.1",T=18392,S=18400,c="/callback";function N(s){return`http://${i}:${s}${c}`}var P="KANE CLI",B="*",O={prod:{authBaseUrl:"https://auth.lambdatest.com",consentUrl:"https://accounts.lambdatest.com",controllerBaseUrl:"https://kaneai-api.lambdatest.com/v16-controller/v1",tmsBaseUrl:"https://test-manager-api.lambdatest.com/api",testGeneratorBaseUrl:"https://test-manager-api.lambdatest.com",secretsBaseUrl:"https://api-hyperexecute.lambdatest.com",testManagerUiUrl:"https://test-manager.lambdatest.com",shareApiBaseUrl:"https://api.lambdatest.com",v16ServerHost:"https://kaneai-api.lambdatest.com/v16-server",evidenceViewerUrl:"https://evidence.lambdatest.com"},stage:{authBaseUrl:"https://stage-auth.lambdatestinternal.com",consentUrl:"https://stage-accounts.lambdatestinternal.com",controllerBaseUrl:"https://auteur-stage-automind.lambdatestinternal.com/v16-controller/v1",tmsBaseUrl:"https://stage-test-manager-api.lambdatestinternal.com/api",testGeneratorBaseUrl:"https://stage-test-manager-api.lambdatestinternal.com",secretsBaseUrl:"https://api-stage-hyperexecute.lambdatestinternal.com",testManagerUiUrl:"https://stage-test-manager.lambdatestinternal.com",shareApiBaseUrl:"https://stage-api.lambdatestinternal.com",v16ServerHost:"https://auteur-stage-automind.lambdatestinternal.com/v16-server",evidenceViewerUrl:"https://stage-evidence.lambdatestinternal.com"}},k={orange:"#ff9500",generateAccent:"#0d9488",purple:"#b388ff",secondary:"#888888",dim:"#666666",muted:"#444444",green:"#4ade80",red:"#ef4444"};export{m as a,d as b,a as c,h as d,_ as e,L as f,n as g,A as h,u as i,U as j,b as k,R as l,I as m,C as n,E as o,i as p,T as q,S as r,c as s,N as t,P as u,B as v,O as w,k as x};
|
package/dist/chunk-IJPFAWBH.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as F,b as z,c as ne,d as R}from"./chunk-2YQ6TW77.js";import{a as D}from"./chunk-WAOCHXJ5.js";import{b as U}from"./chunk-CJJXT5DO.js";import{a as j}from"./chunk-2WVKOZ6W.js";import{a as C}from"./chunk-NLCCBXXV.js";import{a as O}from"./chunk-RZ4F3BHX.js";import{e as te}from"./chunk-UR6MHSHU.js";import{readFileSync as Z,existsSync as w,readdirSync as Ee,mkdirSync as T,writeFileSync as x}from"fs";import{readFile as ee,unlink as be}from"fs/promises";import{join as E}from"path";import{randomUUID as P}from"crypto";function V(t){return t?t.includes(`
|
|
3
|
-
`)?t.split(`
|
|
4
|
-
`).map(e=>e.trim()).filter(Boolean):t.split(". ").map(e=>e.trim()).filter(Boolean).map(e=>e.endsWith(".")?e:e+"."):[]}function L(t,e){return!t||!e?t:t.replace(/\{\{(.+?)\}\}/g,(s,n)=>{let o=e[n];return o?o.value:s}).replace(/\$\{(.+?)\}/g,(s,n)=>{let o=e[n];return o?o.value:s})}var ie={click:"CLICK",double_click:"CLICK",type:"TYPE",fill:"TYPE",select:"SELECT",hover:"HOVER",drag:"DRAG_DROP",upload_files:"UPLOAD",navigate:"OPEN",go_back:"NAVIGATE",go_forward:"NAVIGATE",refresh:"REFRESH",press_key:"SENDKEYS",scroll:"SCROLL_PIXELS",scroll_into_view:"SCROLL_UNTIL_ELEMENT",wait:"WAIT",wait_until:"WAIT_UNTIL",wait_for_load:"WAIT_FOR_LOAD",switch_tab:"SWITCH_TAB",new_tab:"NEW_TAB",close_tab:"CLOSE_TAB",api:"API",evaluate_js:"EVALUATE_JS",vision_query:"VISION_QUERY",textual_query:"TEXTUAL_QUERY",get_url:"GET_URL",get_title:"GET_TITLE",assert:"ASSERTION",math:"MATHEMATICAL_OPERATION",set_cookies:"SET_COOKIES",delete_cookies:"DELETE_COOKIES",clear_cookies:"CLEAR_COOKIES",set_local_storage:"SET_LOCAL_STORAGE",delete_local_storage:"DELETE_LOCAL_STORAGE",clear_local_storage:"CLEAR_LOCAL_STORAGE",set_clipboard:"SET_CLIPBOARD",paste_clipboard:"PASTE_CLIPBOARD",clear_clipboard:"CLEAR_CLIPBOARD"},q={literal:"SET_VARIABLE",condition:"SET_VARIABLE",visual:"VISION_QUERY",dom:"TEXTUAL_QUERY",url:"GET_URL",title:"GET_TITLE",devtool_network:"DEVTOOLS_NETWORK_QUERY",devtool_console:"DEVTOOLS_CONSOLE_QUERY",devtool_cookies:"DEVTOOLS_COOKIES_QUERY",devtool_storage:"DEVTOOLS_STORAGE_QUERY",devtool_performance:"DEVTOOLS_PERFORMANCE",api_response:"API_CALLS_QUERY",textual_visual:"TEXTUAL_ANALYZER"},se=new Set(["CLICK","TYPE","FILL","HOVER","SCROLL_UNTIL_ELEMENT","UPLOAD","VISION_QUERY","DRAG_DROP","SELECT"]);function $(t,e){if(t==="analyze"){let n=e?.action_params?.analyzer_type??"";return q[n]}let s=ie[t];return s||console.warn(`[migrator] UNKNOWN action_type "${t}" \u2014 falling back to "${t.toUpperCase()}"; explicit mapping required`),s??t.toUpperCase()}function K(t,e){if(!t||!e)return"";try{let s=new Date(t);return isNaN(s.getTime())?"":new Date(s.getTime()+e).toISOString()}catch{return""}}function G(t){try{return JSON.parse(t.output_value??"{}")}catch{return{}}}function oe(t){let e=t.output_variable??"";if(!e)return"[]";let n={...G(t)};return delete n.body,JSON.stringify([{name:e,unique_key:(t.action_id??"").replace(/-/g,"").slice(0,8)||P().replace(/-/g,"").slice(0,8),value:n,variable_description:"API Response"}])}function re(t,e,s){let n=t.action_params??{},o=se.has(e)?"Vision Agent":"Operation Agent",c={operation_type:e};e==="OPEN"&&(c.url=n.url??""),e==="SET_VARIABLE"&&(c.variable_name=t.output_variable??n.key??"",c.variable_value=t.output_value??"");let i={},r={},a=t.action_instruction??"",u=n.text??"",d=n.url??"",g=[["intent",a],["value",u],["url",d]];for(let[h,m]of Object.entries(s)){let b=String(m);if(h.startsWith("secrets."))for(let[I,v]of g)v.includes(b)&&(r[I]=h);for(let[I,v]of g)v.includes(b)&&!(I in i)&&(i[I]=v)}let _=t.action_type,l={operation:t.action_instruction??"",agent:o,operation_dict:c,reasoning:_==="analyze"?n.query??"":t.intent??t.action_instruction??"",variable:i,secrets:r,params:{}};_==="analyze"&&typeof n.code=="string"&&n.code&&(l.code=n.code),_==="analyze"&&typeof n.code_js=="string"&&n.code_js&&(l.code_js=n.code_js),_==="analyze"&&typeof n.condition_expression=="string"&&n.condition_expression&&(l.condition_expression=n.condition_expression),n.uses_websocket===!0&&(l.uses_websocket=!0),n.uses_sse===!0&&(l.uses_sse=!0),_==="analyze"&&n.analyzer_type==="textual_visual"&&(typeof n.wrapped_js=="string"&&(l.wrapped_js=n.wrapped_js),Array.isArray(n.locators)&&(l.locators=n.locators),typeof n.operator=="string"&&(l.operator=n.operator),Array.isArray(n.transforms)&&(l.transforms=n.transforms),typeof n.query=="string"&&(l.query=n.query),typeof n.expected_value=="string"&&(l.expected_value=n.expected_value),typeof n.needs_unit_conversion=="boolean"&&(l.needs_unit_conversion=n.needs_unit_conversion),typeof n.condition=="string"&&(l.condition=n.condition));let f={set_cookies:"cookies",set_clipboard:"text",delete_cookies:"names",set_local_storage:"items",delete_local_storage:"keys"}[_];return f&&n[f]!==void 0&&(l[f]=n[f]),_==="set_clipboard"&&typeof n.html=="string"&&n.html&&(l.html=n.html),l}function ae(t){let e=t.assertion_tree??{};if(typeof e.passed=="boolean")return e.passed;let s=e.sub_results??[];return s.length===0?e.status==="passed":(e.composite_operator??"and")==="or"?s.some(o=>o.passed===!0):s.every(o=>o.passed===!0)}function X(t){return t.map(e=>({description:e.description??"",store_key:e.store_key??"",expected_value:e.expected??"",extracted_value:e.extracted_value??"",operator:e.operator??"equals",transforms:e.transforms??[]}))}function ce(t){let e=t.assertion_tree??{},s=e.sub_results??[],n=X(s);return{operator:[],assertion_operands:[],left_operand:null,right_operand:null,operands:[],sub_results:s,sub_checks:n,composite_operator:e.composite_operator??"and",verification:e.verification??"",claim:e.description??""}}function le(t){let s=(t.action_params??{}).assertion_tree??{},n=s.sub_results??[],o=X(n);return[{operation:t.action_instruction??"",agent:"Operation Agent",operation_dict:{operation_type:"ASSERTION",assertion_tree:{sub_results:n,sub_checks:o,composite_operator:s.composite_operator??"and",verification:"",claim:s.description??t.action_instruction??"",operator:[],assertion_operands:[],left_operand:null,right_operand:null,operands:[]}},variable:{},secrets:{},params:{}}]}function ue(t,e,s,n){let o=t.visual_data;if(!o||o.x==null||o.y==null)return null;let c=e?`${e}/test_screenshots`:"";return{x:o.x,y:o.y,confidence:0,bbox:o.bbox??null,bbox_source:o.bbox?"accessibility_tree":"fallback",viewport_width:o.viewport_width??1280,viewport_height:o.viewport_height??800,scale_factor:null,raw_image_url:c?`${c}/untagged_screenshot/${s}.${n?.get(s)??"png"}`:"",raw_image_sas_url:"",annotated_image_url:"",annotated_image_sas_url:""}}function B(t,e={},s="",n){let o=t.action_type,c=$(o,t),i=t.action_params??{},r=t.coordinates??null,a=t.selectors??null,u=!!(a&&a.length>0),d=t.timestamp??"",g=t.duration_ms??0,_=t.variables_used??{},l=t.action_id??P(),p=P(),f=K(d,g),h="",m="";o==="navigate"?(m=i.url??"",h=m):o==="type"||o==="fill"?h=i.text??"":o==="press_key"?h=i.key??"":o==="wait"?h=String(i.ms??i.timeout_ms??""):o==="evaluate_js"?h=i.script??"":o==="analyze"&&c==="SET_VARIABLE"&&(h=t.output_value??"");let b="";o==="go_back"?b="back":o==="go_forward"&&(b="forward");let I=L(h,e),v=L(m,e),A=L(t.action_instruction??"",e),y=re(t,c,_);return{operation_id:l,instruction_id:p,instruction:A,intent:A,operation_start:d,operation_end:f,status:t.status??"",command:c,name:"",target:"",value:I,message:"",operation_dict:"",frame:t.frame_info?JSON.stringify(t.frame_info):"",error_message:t.error??"",code_snippet:"",sub_instruction_obj:JSON.stringify(y),test_id:"",test_version:"",action:"",string_to_float:!1,feedback_msg:"",time_taken:"",create_time_stamp:"",update_time_stamp:"",locator_variable:"",locator_variable_name:"",image_url:s?`${s}/test_screenshots/untagged_screenshot/${l}.${n?.get(l)??"png"}`:"",alternative_xpaths:[],attribute:"",value_description:"",url:v,navigation_direction:b,tagified_image_url:"",query_variable_name:t.output_variable??"",query_variable_value:t.output_value??"",query_variable_type:"",expected_value:"",queried_value:"",operator:"",assertion_status:c==="ASSERTION"?ae(i):"",query_info_dict:{},query_content_confidence:"none",debugging_logs:[],locator_index:0,query_html:"",user_variables:"[]",optional_flag:!1,max_retries:0,retries_delay:0,explicit_wait:0,implicit_wait:0,tab_index:String(i.tab_index??""),tab_identifier:String(i.tab_identifier??""),scroll_value:i.amount??1,scroll_direction:i.direction??"",mi_scroll_payload:{},sleep_duration:0,app_id:"",manual_interaction_tag:"",string_to_float_list:[],js_snippet:o==="evaluate_js"?i.script??"":"",code_error:"",hide:!1,dismiss_dialog:!1,use_v2_mobile_tagging:!1,multiple_inputs:!1,dialog_action:"",dialog_type:"",is_coordinates_used_for_interaction:r!==null&&!u,element_coordinates_ratio:[],element_bounds_ratio:[],x_coord:u?null:r?.x??null,y_coord:u?null:r?.y??null,target_x_coord:i.target_x??null,target_y_coord:i.target_y??null,source_description:i.source_description??null,target_description:i.target_description??null,use_coordinates:r!==null&&!u,kaneaiMobileTaggingImageLimit:1,clicks_order_code:"se_js_ac",selector:u?a.map(k=>({type:k.isXPath?"xpath":"css",...k})):"",selector_target:"",math_result_variable_name:"",math_result_variable_value:"",expression_tree:c==="ASSERTION"?ce(i):i.expression_tree??{},assertion_tree:i.assertion_tree??{},assertion_tree_simplified:{},network_throttle:{},is_mobile_offline:!1,autoheal:!1,db_query:"",db_details:{},db_query_decoded:"",is_global_variable:!1,is_global_variable_persist:!1,global_variable_id:"",wait_for_element_timeout:0,failure_condition:c==="ASSERTION"?"Fail test immediately":"",screenshot_command:"",smartui_contents:{},smartui_results:{},result_type:"",result_hint:"",drag_offset:{},start_coordinates:i.source_coordinates?{x:i.source_coordinates[0],y:i.source_coordinates[1]}:{},end_coordinates:i.target_coordinates?{x:i.target_coordinates[0],y:i.target_coordinates[1]}:{},element_rect:null,is_canvas:!1,until_condition:"",until_max_retries:0,until_settle_ms:0,api_data:o==="api"?{request:t.action_params?.api_data?.request??{}}:{},output_variables:o==="api"?t.output_variable?{[t.output_variable]:null}:{}:t.output_variable?{[t.output_variable]:t.output_value??""}:{},visual_context:ue(t,s,l,n),reasoning:o==="analyze"?i.query??"":t.intent??t.action_instruction??""}}function M(t,e,s={}){let n=t.action_type,o=$(n,t),c=t.timestamp??"",i=t.duration_ms??0,r=K(c,i),a=o==="ASSERTION"||o==="MATHEMATICAL_OPERATION";return{instruction_id:e.instruction_id,instruction_class:a?"non_driver_action":"driver_action",module_id:"",instruction:L(t.action_instruction??"",s),command:o,error:null,parent_instruction_id:"",classification_layer_resp:o==="ASSERTION"?le(t):[],classification_error:{},operations:[e],status:t.status??"",start_timestamp:c,end_timestamp:r,type:"agent_generated",tags:[],html_paths:[],optional_flag:!1,max_retries:0,retries_delay:0,explicit_wait:0,implicit_wait:0,content_type:n==="api"?"api":n==="analyze"&&t.action_params?.analyzer_type==="api_response"?"api_calls_query":n==="analyze"&&t.action_params?.analyzer_type?.startsWith("devtool_")?t.action_params.analyzer_type.replace("devtool_","devtools_"):"instruction",js_snippet:n==="evaluate_js"?t.action_params?.script??"":"",user_variables:n==="api"?oe(t):"[]",api_data:n==="api"?{request:t.action_params?.api_data?.request??{},response:G(t)}:{},params_used:!1,hard_assertion:o==="ASSERTION"?t.action_params?.failure_condition==="hard":!1,expected_outcome:"",module_execution_index:0,module_version:null,network_throttle:{},isEdited:!1,use_query_assertion_v2:!1,db_query:"",db_details:{},network_assertion_content:{},screenshot_command:"",smartui_contents:{},generative_id:"",plan_id:"",generative_objective:"",error_message:"",error_code:"",reason:"",title:"",used_variables:[],reasoning:n==="analyze"?t.action_params?.query??"":t.intent??t.action_instruction??""}}function de(t,e=[]){let s=t.action_params??{},n=s.branches??[],o=s.winning_index??-1,c=s.sub_results??[],i={};for(let a of c){let u=a.sub_results;if(u)for(let d of u){let g=d.store_key;g&&(i[g]=d)}}let r=n.map((a,u)=>{let d=u===o,g=(a.sub_checks??[]).map(_=>{let l=i[_.store_key];return{description:_.description,store_key:_.store_key,expected_value:_.expected_value,stored_value:l?.extracted_value??_.stored_value,operator:_.operator??l?.operator??"equals",transforms:_.transforms??l?.transforms??[]}});if(g.length===0&&a.condition&&c.length>0){let l=c.find(p=>p.branch_index===u)?.sub_results??[];l.length>0&&(g=l.map(p=>({description:p.description??a.condition,store_key:p.store_key??"",expected_value:p.expected??"true",stored_value:p.extracted_value??void 0,operator:p.operator??"equals",transforms:p.transforms??[]})))}return{branch_index:u,condition:a.condition??null,branch_type:a.branch_type??"sub_objective",passed:d,sub_objective:null,custom_event:a.custom_event??null,children:d?e:[],sub_checks:a.condition?g:[],composite_operator:a.composite_operator??"and"}});return{content_type:"conditional_block",instruction_id:`if_else_${P().slice(0,8)}`,instruction:t.action_instruction??"",instruction_class:"driver_action",command:"",status:t.status??"success",resolved_branch_index:o,branches:r,generative_id:"",generative_objective:"",variables_used:{},classification_layer_resp:[],classification_error:{},used_variables:[],user_variables:"[]",module_id:"",module_execution_index:0,module_version:"",plan_id:"",optional_flag:!1,max_retries:0,retries_delay:0,explicit_wait:0,implicit_wait:0,error:null,error_message:"",error_code:"",reason:"",start_timestamp:t.timestamp??"",end_timestamp:"",type:"agent_generated",hook:null,hook_type:null,evaluation_context:{},query_variables:{}}}function Y(t,e,s){for(let n of t)n.content_type==="instruction"&&"generative_id"in n&&(n.generative_id=e,n.generative_objective=s)}function N(t,e={},s="",n,o){let c=[],i=0;for(;i<t.length;){let r=t[i],a=r.action_type;if(!o?.keepFailedActions&&r.status==="error"&&a!=="assert"&&a!=="if_else"&&a!=="child_agent_start"&&a!=="child_agent_end"&&!(r.until_condition&&!r.error)){i+=1;continue}if(a==="analyze"&&!q[r.action_params?.analyzer_type??""]){i+=1;continue}if(a==="child_agent_start"){let u=r.action_params?.child_id??"",d=r.action_params?.objective??"",g=[];i+=1;let _=1,l="error",p;for(;i<t.length&&_>0;){let y=t[i],k=y.action_type;if(k==="child_agent_start")_+=1;else if(k==="child_agent_end"&&(_-=1,_===0)){l=y.status??"success",p=y,i+=1;break}_>0&&g.push(y),i+=1}let f=N(g,e,s,n);Y(f,u,d);let h=p?.action_params?.result_code??null,m=p?.action_params?.reason_code??null,b=p?.action_params?.error_message??null,I=p?.action_params?.summary??null,v=p?.action_params?.one_liner??null,A=l==="error";c.push({content_type:"generative_block",instruction_id:`generative_block_${u}`,generative_id:u,objective:d,status:l,children:f,error_message:A?b??null:null,error_code:A?m??null:null,result_code:h??null,bifurcation_context:[],approach_reason:V(I),one_liner:v??null});continue}else if(a==="child_agent_end"){i+=1;continue}else if(a==="if_else"){i+=1;let u=[];for(;i<t.length&&t[i].action_type==="child_agent_start";){let d=t[i],g=d.action_params?.child_id??"",_=d.action_params?.objective??"",l=[];i+=1;let p=1,f="error";for(;i<t.length&&p>0;){let m=t[i];if(m.action_type==="child_agent_start")p+=1;else if(m.action_type==="child_agent_end"&&(p-=1,p===0)){f=m.status??"success",i+=1;break}p>0&&l.push(m),i+=1}let h=N(l,e,s,n);u.push(...h)}c.push(de(r,u));continue}else if(a==="query_tool"){i+=1;continue}else if(r.until_condition){let u=B(r,e,s,n),d=M(r,u,e),g=typeof r.until_condition_met=="boolean"?r.until_condition_met:r.status==="success";c.push({content_type:"until_block",instruction_id:`until_${P().slice(0,8)}`,condition:r.until_condition,max_retries:r.until_max_retries??10,settle_ms:r.until_settle_ms??500,current_count:0,condition_met:g,children:[d],generative_id:"",generative_objective:"",variables_used:{},status:r.status??"success"})}else{let u=B(r,e,s,n),d=M(r,u,e);c.push(d)}i+=1}return c}function S(t,e={},s="",n,o){let c=[];for(let i of t){let r=N(i.records,e,s,n,o);if(r.length===0)continue;let a=P().replace(/-/g,"");Y(r,a,i.objective);let u=r.some(l=>"status"in l&&typeof l.status=="string"?l.status==="error"||l.status==="failed":!1),d=i.resultCode?parseInt(i.resultCode,10):null,g=d!==null&&!isNaN(d)&&d>=200,_=u||g?"error":"success";c.push({content_type:"generative_block",instruction_id:`generative_block_${a}`,generative_id:a,objective:i.objective,status:_,children:r,error_message:_==="error"?i.errorMessage??null:null,error_code:_==="error"?i.reasonCode??null:null,result_code:i.resultCode??null,bifurcation_context:[],approach_reason:V(i.summary),one_liner:i.oneLiner??null})}return{instructions:c}}var H=te(ne(),1);import{createWriteStream as _e}from"fs";import{readFile as pe}from"fs/promises";import{join as ge,basename as fe}from"path";import{tmpdir as he}from"os";var me=["**/screenshots/**","**/annotated/**","**/tcg/**","**/bifurcation/**"];async function W(t){let e=ge(he(),`${fe(t)}_artifacts.zip`);return new Promise((s,n)=>{let o=_e(e),c=(0,H.default)("zip",{zlib:{level:6}});o.on("close",()=>s(e)),c.on("error",n),c.pipe(o),c.glob("**/*",{cwd:t,ignore:me}),c.finalize()})}async function J(t){return pe(t)}async function Ie(t,e){return ee(U(t,e))}function ve(t){return{key:"artifacts",content_type:"application/zip",filename:`${t}.evidence`}}var Q=class{config;controller;testId;constructor(e){this.config=e,this.controller=new D(e.controllerBaseUrl,e.auth),this.testId=e.testId}log(e,s,n,o){this.config.log?.(e,s,n,o)}async execute(){let{onProgress:e}=this.config;try{if(!this.testId)return this.log("error","PIPELINE_ABORT","No test_id available"),{success:!1,testId:null,error:"No test_id available"};let s=this.config.evidence,n=null;if(this.config.shouldUploadArtifacts!==!1){e("convert","running");let r=this.collectNdjsonPerRun(),a=r.reduce((f,h)=>f+h.records.length,0);this.log("info","PIPELINE_CONVERT","Collected NDJSON records",{total_records:a,run_groups:r.length});let u=this.config.variables??{};this.log("info","PIPELINE_CONVERT_VARS","Variables for template resolution",{keys:Object.keys(u)});let{instructions:d}=r.length>0?S(r,u,this.config.screenshotBaseUrl??"",this.config.screenshotExtMap):{instructions:[]};this.log("info","PIPELINE_CONVERT_INSTRUCTIONS","Auteur instructions produced",{count:d.length});let g=this.buildExecutionEnvelope(d),_=Buffer.from(JSON.stringify(g));this.log("info","PIPELINE_CONVERT_BLOB","Blob created",{size_kb:+(_.length/1024).toFixed(1)});let l=E(this.config.sessionDir,"execution.json");x(l,JSON.stringify(g,null,2)),this.log("info","PIPELINE_CONVERT_LOCAL_SAVE","Execution blob saved locally",{path:l});let p=s?.packTestDir??this.config.evidenceRead?.packTestDir;if(p){let f=E(p,"auteur");T(f,{recursive:!0}),x(E(f,"execution.json"),JSON.stringify(g,null,2)),this.log("info","PIPELINE_CONVERT_PACK_COPY","Execution blob copied into pack",{path:E(f,"execution.json")})}if(e("convert","done"),s)n=_;else{e("zip","running"),this.log("info","PIPELINE_ZIP_START","Zipping session",{session_dir:this.config.sessionDir});let f=null,h;try{f=await W(this.config.sessionDir),h=await J(f),this.log("info","PIPELINE_ZIP_DONE","Zip complete",{size_mb:+(h.length/1024/1024).toFixed(1),path:f}),e("zip","done",`${(h.length/1024/1024).toFixed(1)}MB`)}finally{f&&await be(f).catch(()=>{})}e("presign","running"),this.log("info","PIPELINE_PRESIGN_START","Requesting presigned URLs",{url:`${this.config.controllerBaseUrl}/upload/presign`,test_id:this.testId,session_id:this.config.sessionId});let m=await this.controller.getPresignedUrls(this.testId,this.config.sessionId,[{key:"artifacts",content_type:"application/zip",filename:`${this.config.sessionId}_artifacts.zip`},{key:"blob",content_type:"application/json",filename:`${this.config.commitId}.json`}]);this.log("info","PIPELINE_PRESIGN_OK","Presigned URLs received",{artifacts_url:m.urls.artifacts?.blob_url,blob_url:m.urls.blob?.blob_url}),e("presign","done"),e("upload","running"),this.log("info","PIPELINE_UPLOAD_START","Uploading artifacts and blob",{artifact_size_mb:+(h.length/1024/1024).toFixed(1),blob_size_kb:+(_.length/1024).toFixed(1)}),await Promise.all([R(m.urls.artifacts.upload_url,h,"application/zip"),R(m.urls.blob.upload_url,_,"application/json")]),this.log("info","PIPELINE_UPLOAD_OK","Upload complete"),e("upload","done")}}else{let r=this.collectNdjsonPerRun(),a=this.config.variables??{},{instructions:u}=r.length>0?S(r,a,this.config.screenshotBaseUrl??"",this.config.screenshotExtMap,{keepFailedActions:!0}):{instructions:[]},d=this.buildExecutionEnvelope(u),g=E(this.config.sessionDir,"execution.json");x(g,JSON.stringify(d,null,2)),this.log("info","PIPELINE_LOCAL_SAVE","Execution blob saved locally (no upload)",{path:g});let _=this.config.evidence?.packTestDir??this.config.evidenceRead?.packTestDir;if(_){let l=E(_,"auteur");T(l,{recursive:!0});let p=this.readAuthoredExecution();x(E(l,"execution.json"),p??JSON.stringify(d,null,2)),this.log("info","PIPELINE_CONVERT_PACK_COPY","Execution blob copied into pack (gated)",{path:E(l,"execution.json"),source:p?"authored":"run_envelope"})}e("convert","skipped"),e("zip","skipped"),e("presign","skipped"),e("upload","skipped"),this.log("info","PIPELINE_UPLOAD_SKIPPED","Upload steps skipped (gate disabled)")}if(this.config.shouldReplaceLocalOutput&&this.config.onAtomicReplace){e("atomic_replace","running");try{await this.config.onAtomicReplace(),this.log("info","PIPELINE_ATOMIC_REPLACE_OK","Local output replaced"),e("atomic_replace","done")}catch(r){let a=r instanceof Error?r.message:String(r);throw this.log("error","PIPELINE_ATOMIC_REPLACE_FAILED","Atomic-replace failed",{error:a}),e("atomic_replace","failed",a),r}}else e("atomic_replace","skipped");let o,c;if(this.config.shouldCommit&&!this.config.isFirstRun&&this.config.onCommitLock){e("commit_lock","running");let r=await this.config.onCommitLock();if(r.ok)o=r.testcaseId,this.log("info","PIPELINE_COMMIT_LOCK_OK","Commit lock acquired",{testcase_id:o??"none"}),e("commit_lock","done");else return this.log("error","PIPELINE_COMMIT_LOCK_FAILED","Commit lock failed",{reason:r.reason,message:r.message}),e("commit_lock","failed",`${r.reason??"unknown"}: ${r.message??""}`),{success:!1,testId:this.testId,error:`commit-lock failed: ${r.reason??"unknown"}`}}else e("commit_lock","skipped");if(this.config.isFirstRun&&!this.config.skipTmsFinalize){e("finalize","running"),this.log("info","PIPELINE_FINALIZE_START","Finalizing test (first-run)",{test_id:this.testId,commit_id:this.config.commitId});let r=new j(this.config.tmsBaseUrl,this.config.tmsUsername,this.config.tmsAccessKey),a=this.config.runObjectives&&this.config.runObjectives.length>0?this.config.runObjectives:[this.config.firstObjective];if(o=(await r.endTest(this.testId,{commit_id:this.config.commitId,time_taken:Math.round(this.config.totalDuration),steps_count:this.config.totalSteps,commit_message:this.config.firstObjective.slice(0,255),objectives:a})).testcase_id||void 0,this.log("info","PIPELINE_FINALIZE_OK","Test finalized",{testcase_id:o??"none"}),this.config.onFinalizeSuccess)try{await this.config.onFinalizeSuccess(o)}catch(d){this.log("warn","PIPELINE_FINALIZE_META_FAILED","Meta-rewrite after endTest failed",{error:String(d)})}e("finalize","done")}else e("finalize","skipped"),this.log("info","PIPELINE_FINALIZE_SKIPPED","Finalize skipped (evolve flow or first-run disabled)");if(o&&this.config.shareApiBaseUrl)try{c=await this.generateShareLink(o),this.log("info","PIPELINE_SHARE_OK","Share link generated",{share_id:c})}catch(r){this.log("warn","PIPELINE_SHARE_FAILED","Share link failed",{error:String(r)})}if(s&&n){let r=null;e("zip","running");try{await s.sealFn({testcaseId:o,shareId:c}),r=s.sealedPackPath?await ee(s.sealedPackPath):await Ie(s.executionId,s.cwd),this.log("info","PIPELINE_EVIDENCE_SEALED","Evidence pack sealed",{execution_id:s.executionId}),this.log("info","PIPELINE_PACK_READ","Sealed pack read",{size_mb:+(r.length/1024/1024).toFixed(1)})}catch(a){let u=a instanceof Error?a.message:String(a);this.log("warn","PIPELINE_EVIDENCE_UPLOAD_SKIPPED","Evidence seal/read failed \u2014 uploading blob only",{execution_id:s.executionId,error:u})}if(r){e("zip","done",`${(r.length/1024/1024).toFixed(1)}MB`),e("presign","running");let a=await this.controller.getPresignedUrls(this.testId,this.config.sessionId,[ve(s.executionId),{key:"blob",content_type:"application/json",filename:`${this.config.commitId}.json`}]);this.log("info","PIPELINE_PRESIGN_OK","Presigned URLs received",{artifacts_url:a.urls.artifacts?.blob_url,blob_url:a.urls.blob?.blob_url}),e("presign","done"),e("upload","running"),this.log("info","PIPELINE_UPLOAD_START","Uploading pack and blob",{artifact_size_mb:+(r.length/1024/1024).toFixed(1),blob_size_kb:+(n.length/1024).toFixed(1)}),await Promise.all([R(a.urls.artifacts.upload_url,r,"application/zip"),R(a.urls.blob.upload_url,n,"application/json")]),this.log("info","PIPELINE_UPLOAD_OK","Upload complete"),e("upload","done")}else{e("zip","skipped"),e("presign","running");let a=await this.controller.getPresignedUrls(this.testId,this.config.sessionId,[{key:"blob",content_type:"application/json",filename:`${this.config.commitId}.json`}]);e("presign","done"),e("upload","running"),this.log("info","PIPELINE_UPLOAD_START","Uploading blob only (evidence skipped)",{blob_size_kb:+(n.length/1024).toFixed(1)}),await R(a.urls.blob.upload_url,n,"application/json"),this.log("info","PIPELINE_UPLOAD_OK","Blob upload complete (pack skipped)"),e("upload","done")}}let i;if(this.config.codeExport?.enabled&&o){let r=!1;try{await this.triggerCodeExport(o),this.log("info","PIPELINE_CODE_EXPORT_START","Code export triggered"),r=!0}catch(a){let u=a instanceof Error?a.message:String(a);this.log("error","PIPELINE_CODE_EXPORT_FAILED","Code export trigger failed; skipping poll",{error:u}),e("code_export","failed",`trigger failed: ${u}`)}if(r){e("code_export","running","Waiting for code generation\u2026");try{i=await this.pollAndDownloadCode(o,e),this.log("info","PIPELINE_CODE_EXPORT_OK","Code export complete",{dir:i}),e("code_export","done",i)}catch(a){let u=a instanceof Error?a.message:String(a);this.log("error","PIPELINE_CODE_EXPORT_FAILED","Code export failed",{error:u}),e("code_export","failed",u)}}}else e("code_export","skipped");return this.log("info","PIPELINE_COMPLETE","Pipeline complete"),{success:!0,testId:this.testId,testcaseId:o,shareId:c,codeExportDir:i}}catch(s){return{success:!1,testId:this.testId,error:s instanceof Error?s.message:String(s)}}}async runCodeExport(e,s){let n=s??this.config.onProgress,o=!1;try{await this.triggerCodeExport(e),this.log("info","PIPELINE_CODE_EXPORT_TRIGGER","Code export triggered",{testcase_id:e}),o=!0}catch(c){let i=c instanceof Error?c.message:String(c);this.log("error","PIPELINE_CODE_EXPORT_TRIGGER_FAILED","Code export trigger failed; skipping poll",{error:i}),n("code_export","failed",`trigger failed: ${i}`)}if(o){n("code_export","running","Waiting for code generation\u2026");try{let c=await this.pollAndDownloadCode(e,n);return this.log("info","PIPELINE_CODE_EXPORT_OK","Code export complete",{dir:c}),n("code_export","done",c),c}catch(c){let i=c instanceof Error?c.message:String(c);this.log("error","PIPELINE_CODE_EXPORT_FAILED","Code export failed",{error:i}),n("code_export","failed",i);return}}}collectNdjsonPerRun(){let e=[],s=this.config.runObjectives??[],n=this.config.runMetadata??[],o=this.config.evidence??this.config.evidenceRead;for(let c=0;c<this.config.runDirs.length;c++){let i=this.config.runDirs[c],r=s[c]||this.config.firstObjective,a=n[c],u=o?this.readNdjsonFromFile(E(o.packTestDir,"logs",`${o.runIndices?.[c]??c}-actions.ndjson`)):this.readNdjsonFromDir(i);u.length>0&&e.push({objective:r,records:u,resultCode:a?.resultCode,reasonCode:a?.reasonCode,errorMessage:a?.errorMessage,summary:a?.summary,oneLiner:a?.oneLiner})}if(e.length===0){let c=E(this.config.sessionDir,"runs");if(w(c))try{let r=Ee(c,{withFileTypes:!0}).filter(a=>a.isDirectory()).map(a=>a.name).sort();for(let a of r){let u=E(c,a),d=this.readNdjsonFromDir(u);d.length>0&&e.push({objective:this.config.firstObjective,records:d})}}catch{}}return e}readNdjsonFromDir(e){let s=[E(e,"run-test","actions.ndjson"),E(e,"actions.ndjson")];for(let n of s)if(w(n))return this.readNdjsonFromFile(n);return[]}readNdjsonFromFile(e){let s=[];if(!w(e))return s;this.log("debug","PIPELINE_COLLECT_READ","Reading NDJSON file",{path:e});let n=Z(e,"utf-8");for(let o of n.split(`
|
|
5
|
-
`)){let c=o.trim();if(c)try{s.push(JSON.parse(c))}catch{}}return s}async generateShareLink(e){let s=`${this.config.shareApiBaseUrl}/lshs/api/v1.0/share-item/generate-sharable-link`;this.log("info","PIPELINE_SHARE_START","Requesting share link",{url:s,testcase_id:e});let n={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({entityIds:[e],entityType:"Test Case Details",expiresAt:7})},o=!!this.config.authResolver;this.log("debug","PIPELINE_SHARE_AUTH","Share link auth config",{resolver:o,fallback_auth_type:typeof this.config.auth=="string"?"bearer":"basic",tms_user:this.config.tmsUsername});let c=o?await this.config.authResolver.fetch(s,n):await O(s,{...n,headers:{...n.headers,Authorization:this.buildAuthHeader()}});if(!c.ok)throw new Error(`Share link API failed: ${c.status} ${await c.text()}`);let i=await c.json();if(!i.shareId)throw new Error("Share link API returned no shareId");return i.shareId}async triggerCodeExport(e){if(!this.config.codeExport)throw new Error("triggerCodeExport called without resolved codeExport config");let{url:s,body:n}=F({tmsBaseUrl:this.config.tmsBaseUrl,testcaseId:e,codeExport:this.config.codeExport});this.log("info","PIPELINE_CODE_EXPORT_POST","Triggering code export",{url:s});let o={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(n)},c=this.config.authResolver?await this.config.authResolver.fetch(s,o):await O(s,{...o,headers:{...o.headers,Authorization:this.buildAuthHeader()}});if(!c.ok)throw new Error(`Code export failed: ${c.status} ${await c.text()}`)}async pollAndDownloadCode(e,s){let n=z({tmsBaseUrl:this.config.tmsBaseUrl,testcaseId:e}),o=this.config.exitTimeoutMs??3e5,c=5e3,i=Date.now()+o;this.log("info","PIPELINE_CODE_EXPORT_POLL","Polling for code export",{url:n,timeout_ms:o});let r=(a,u)=>this.config.authResolver?this.config.authResolver.fetch(a,u):O(a,{...u,headers:{...u?.headers,Authorization:this.buildAuthHeader()}});for(;Date.now()<i;){let a=await r(n,{method:"GET",headers:{Accept:"application/json"}});if(!a.ok){let l=await a.text().catch(()=>"");throw this.log("warn","PIPELINE_CODE_EXPORT_POLL_FAILED","Code export poll non-200; skipping",{status:a.status,body:l.slice(0,200)}),new Error(`code export poll skipped: HTTP ${a.status}`)}let d=(await a.json()).data?.find(l=>l.code_name==="kane-cli-trigger");if(!d){this.log("debug","PIPELINE_CODE_EXPORT_WAITING","No kane-cli-trigger entry yet"),s("code_export","running","Waiting for code generation\u2026"),await this.sleep(c);continue}let g=d.status.toLowerCase();if(g==="in progress"||g==="in_progress"||g==="pending"){this.log("debug","PIPELINE_CODE_EXPORT_IN_PROGRESS","Code export in progress",{status:d.status}),s("code_export","running","Generating code\u2026"),await this.sleep(c);continue}if(!d.url||d.url.length===0)throw new Error(`Code export status=${d.status} but no files returned`);let _=this.config.codeExportDir??E(this.config.sessionDir,"code-export");T(_,{recursive:!0}),this.log("info","PIPELINE_CODE_EXPORT_DOWNLOAD","Downloading code files",{file_count:d.url.length,dir:_}),s("code_export","running",`Downloading ${d.url.length} files\u2026`);for(let l of d.url){let p=E(_,l.file_name),f=await O(l.file_url);if(!f.ok){this.log("warn","PIPELINE_CODE_EXPORT_FILE_FAILED","Failed to download file",{file_name:l.file_name,status:f.status});continue}let h=await f.text();x(p,h,"utf-8"),this.log("info","PIPELINE_CODE_EXPORT_FILE_SAVED","File saved",{file_name:l.file_name,size_bytes:h.length})}return _}throw new Error("Code export timed out")}sleep(e){return new Promise(s=>setTimeout(s,e))}buildAuthHeader(){return typeof this.config.auth=="string"?`Bearer ${this.config.auth}`:C(this.config.auth.username,this.config.auth.accessKey)}readAuthoredExecution(){let e=this.config.authoredExecutionPath;if(!e)return null;try{let s=Z(e,"utf8");return JSON.parse(s),s}catch{return this.log("warn","PIPELINE_AUTHORED_BLOB_UNREADABLE","Authored execution.json missing/unreadable \u2014 pack gets this run's envelope",{path:e}),null}}buildExecutionEnvelope(e){let s=this.config.runStatuses.every(i=>i==="passed")?"success":"error",n=this.config.variableIds??{},o=[];if(this.config.variables)for(let[i,r]of Object.entries(this.config.variables)){if(r.secret)continue;let a=i.startsWith("global.")?i.slice(7):i;o.push({id:n[a]??0,name:a,value:r.value,session_value:r.value,is_persist:!1,environment_id:0,environment_name:"No Env"})}let c=[];for(let i of this.collectNdjsonPerRun())for(let r of i.records)r.output_variable&&r.output_value!=null&&c.push({name:r.output_variable,value:String(r.output_value),value_type:"test_level",variable_description:"ANALYZE result"});return{test_id:this.testId,version:"v4",session_id:this.config.sessionId,org_id:String(this.config.orgId),user_id:String(this.config.userId),url:this.config.firstUrl??"",start_timestamp:this.config.startedAt,end_timestamp:this.config.endedAt,status:s,commit_id:this.config.commitId,instructions:e,modules:[],uploaded_files:[],test_params:[],test_level_variables:JSON.stringify(c),test_global_variables:o,max_network_wait:0,wait_buffer:0,network_throttle:{},secrets:this.config.secrets??[],totp:[],environment_id:0,environment:"",mobile_browser:!1,native_popups:[],smartui:{},module_index:0}}};export{Ie as a,ve as b,Q as c};
|
package/dist/chunk-OLXOZJ7X.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{b as c,c as p}from"./chunk-CT2I5KUM.js";import{spawn as m}from"child_process";var y=new Set(["progress","ask_user","graph_query","proposal","design","error","done","reasoning_delta","reasoning_done","tool_activity","decision_activity","text_delta","usage","receipt","chat_ops","session_paused","session_complete"]);function S(d,s={}){let a=s.spawnCmd!==void 0?s.spawnCmd:c();if(!a)throw new Error("assurance agent not found \u2014 your platform package may be missing; reinstall kane-cli (npm i -g @testmuai/kane-cli)");let n=m(a.cmd,a.args,{stdio:["pipe","pipe","pipe"],env:p(d.session_id,s.auth)});if(n.stdin.write(JSON.stringify(d)+`
|
|
3
|
-
`),s.onStderr){let e="";n.stderr.on("data",r=>{e+=r.toString("utf8");let i;for(;(i=e.indexOf(`
|
|
4
|
-
`))>=0;){let o=e.slice(0,i);e=e.slice(i+1),o.trim()&&s.onStderr(o)}})}let g=new Promise(e=>{n.on("exit",(r,i)=>e({code:r,signal:i}))});async function*f(){let e="",r=!1;for await(let i of n.stdout){e+=i.toString("utf8");let o;for(;(o=e.indexOf(`
|
|
5
|
-
`))>=0;){let l=e.slice(0,o).trim();if(e=e.slice(o+1),!l)continue;let u;try{u=JSON.parse(l)}catch{s.onWarn?.(`agent: skipping malformed line: ${l.slice(0,120)}`);continue}let t=u;if(!t||typeof t!="object"||!y.has(t.type)){s.onWarn?.(`agent: skipping unknown event type "${t&&typeof t=="object"?String(t.type??"?"):"?"}"`);continue}if(yield t,t.type==="done"){r=!0;break}}if(r)break}await g.catch(()=>{})}return{events:f(),send:e=>{n.stdin&&!n.stdin.destroyed&&n.stdin.write(JSON.stringify(e)+`
|
|
6
|
-
`)},kill:()=>{n.kill("SIGTERM")},exited:g}}export{S as a};
|
package/dist/chunk-QPZRHAYK.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
function l(e,n){let r=/^L(\d+)-L(\d+)$/.exec(n);if(!r)return null;let t=parseInt(r[1],10),o=parseInt(r[2],10),i=e.split(`
|
|
3
|
-
`);return t<1||o<t||o>i.length?null:i.slice(t-1,o).map(a=>a.replace(/^\d+\| /,"")).join(`
|
|
4
|
-
`)}function s(e,n,r){if(e.format==="image")return n.anchor==="img#whole"?[]:[{code:"CITE_ANCHOR_INVALID",detail:`image cites are anchor-only (img#whole), got ${n.anchor}`}];if(!n.anchor||n.quote===void 0||n.quote==="")return[{code:"MISSING_CITE",detail:"text-kind cites need anchor+quote"}];let t=r!==null?l(r,n.anchor):null;return t===null?[{code:"BAD_ANCHOR",detail:`anchor ${n.anchor} does not resolve in the source`}]:t.includes(n.quote)?[]:[{code:"QUOTE_MISMATCH",detail:`quote is not verbatim within ${n.anchor}`}]}export{l as a,s as b};
|
package/dist/chunk-SJ2KQKOV.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{b as k,c as I}from"./chunk-2PQXEEVY.js";import{a as E}from"./chunk-MCQXRJGH.js";import{a as h,c as w}from"./chunk-ZZLR3O5A.js";import{g as S}from"./chunk-ZG2V2ODK.js";import{a as x,d as y,f as b}from"./chunk-5YPBPZUR.js";import{existsSync as M,mkdirSync as R,readFileSync as C,writeFileSync as F}from"fs";import{basename as P,extname as v,join as U}from"path";var A=/^[A-Za-z0-9][A-Za-z0-9._-]*$/;function D(e){return typeof e=="string"&&e!=="."&&e!==".."&&A.test(e)}function f(e){if(!D(e))throw new Error(`unsafe logical_id: ${JSON.stringify(e)} \u2014 must match ${String(A)} (no path separators)`)}import{extname as $}from"path";var O=[{kind:"text",media_type:"text/plain",extensions:[".txt"],cite:"verbatim",maxBytes:2e6},{kind:"markdown",media_type:"text/markdown",extensions:[".md",".markdown"],cite:"verbatim",maxBytes:2e6},{kind:"image",media_type:"image/png",extensions:[".png"],cite:"anchor-only",maxBytes:5e6},{kind:"image",media_type:"image/jpeg",extensions:[".jpg",".jpeg"],cite:"anchor-only",maxBytes:5e6},{kind:"image",media_type:"image/webp",extensions:[".webp"],cite:"anchor-only",maxBytes:5e6}];function L(e){let n=$(e).toLowerCase(),t=O.find(r=>r.extensions.includes(n));return t?{ok:!0,media:t}:{ok:!1,code:"UNSUPPORTED_MEDIA",allowlist:O.flatMap(r=>r.extensions)}}function j(e){let t=P(e,v(e)).toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/^[^a-z0-9]+/,"");return f(t),t}function ee(e){let n=/^(.*?)[-_.]?v?\d+$/.exec(e);if(!n)return null;let t=(n[1]??"").replace(/[-_.]+$/,"");return t.length>0&&t!==e?t:null}function z(e){let n=U(e,"meta.json");M(n)||(R(e,{recursive:!0}),F(n,JSON.stringify({schema:x,canonicalizer:"v1"},null,2)+`
|
|
3
|
-
`))}async function te(e){let{contextDir:n,filePath:t,asId:r,confirmSameSource:_}=e;z(n);let c=C(t),i=L(t);if(!i.ok)throw new Error(`UNSUPPORTED_MEDIA: ${v(t)} \u2014 supported: ${i.allowlist.join(" ")}`);if(c.byteLength>i.media.maxBytes)throw new Error(`FILE_TOO_LARGE: ${c.byteLength} bytes > ${i.media.maxBytes} cap for ${i.media.media_type}`);let s=k(c),o;r!==void 0?(f(r),o=r):o=j(t);let d=E(n),a=d.heads.get(o),N=a!=null?d.getNode(a)?.content:void 0;if(a!=null&&N?.blob===s)return{status:"unchanged",source_id:o,cid:a,blob:s};if(a==null){for(let[g,p]of d.heads.entries())if(!(g===o||p==null)&&d.getNode(p)?.content.blob===s){if(_&&await _(g))return{status:"unchanged",source_id:g,cid:p,blob:s};break}}I(n,c);let m=w(o,s),l=b("source",m);if(l.length>0)throw new Error(`source node fails ${l[0].code}: ${l[0].detail}`);let u=h("source",m);return S(n,{ts:new Date().toISOString(),proposal_id:null,nodes:[{cid:u,label:y.SOURCE,content:m}],edges:[],review:[],supersessions:[],media:{[o]:{format:i.media.kind,media_type:i.media.media_type,anchors_supported:i.media.cite==="verbatim"?["L-L"]:[]}},source_head_moves:{[o]:u}}),{status:a!=null?"versioned":"created",source_id:o,cid:u,blob:s}}export{L as a,j as b,ee as c,te as d};
|
package/dist/chunk-WIA7TPK3.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{b as F}from"./chunk-QPZRHAYK.js";import{a as U,b as T,d as B}from"./chunk-ZZLR3O5A.js";import{e as W,g as P}from"./chunk-ZG2V2ODK.js";import{d as A,e as D,f as L,g as q,h as H}from"./chunk-5YPBPZUR.js";var G=/^[a-z0-9][a-z0-9-]{1,63}$/;function z(f,d,t,e){if(!d)return{error:{code:"SUPERSEDE_TARGET_MISSING",detail:"supersede verdict needs a target (slug or cid)"}};let n=f.resolve(d);return n?n.superseded||e.has(n.cid)?{error:{code:"ALREADY_SUPERSEDED",detail:`${d} is already superseded (tip: ${n.tip})`}}:n.cid===t?{error:{code:"SELF_SUPERSEDE",detail:"a node cannot supersede itself"}}:{targetCid:n.cid}:{error:{code:"UNKNOWN_SUPERSEDE_TARGET",detail:`${d} names nothing in the graph`}}}function X(f,d,t,e,n=[]){if(!q(d)?.acyclic)return null;if(t===e)return{code:"EDGE_CYCLE",detail:`${d} ${t} \u2192 itself`};let r=_=>[...f.edgesFrom(_).filter(E=>E.type===d).map(E=>E.dst),...n.filter(E=>E.type===d&&E.src===_).map(E=>E.dst)],c=new Set,p=[e];for(;p.length>0;){let _=p.pop();if(_===t)return{code:"EDGE_CYCLE",detail:`${d} ${t} \u2192 ${e} closes a cycle`};c.has(_)||(c.add(_),p.push(...r(_)))}return null}function de(f,d,t,e){let m=q(d)?.cardinality;if(m!=="one-live-per-src"&&m!=="one-live-per-src-and-dst")return null;let r=f.edgesFrom(t).filter(c=>c.type===d&&!f.superseded.has(c.dst));if(r.length>0)return{code:"CARDINALITY_VIOLATION",detail:`${d} from ${t} already has a live edge (${r[0].ecid}) \u2014 supersede it first`};if(m==="one-live-per-src-and-dst"&&e!==void 0){let c=f.edgesInto(e).filter(p=>p.type===d&&!f.superseded.has(p.src));if(c.length>0)return{code:"CARDINALITY_VIOLATION",detail:`${d} onto ${e} already has a live edge (${c[0].ecid}) \u2014 strict 1:1, supersede it first`}}return null}var K=new Set(["high","med","low"]);function ce(f,d,t){let e=[],n=t.mediaOf(f.source.source_cid),m=new Set;for(let r of f.use_cases){if(m.has(r.temp_ref)&&e.push({code:"DUP_TEMP_REF",detail:`duplicate temp_ref ${r.temp_ref}`}),m.add(r.temp_ref),(!r.title||!r.title.trim())&&e.push({code:"EMPTY_TITLE",detail:`${r.temp_ref}: title is empty`}),K.has(r.risk)||e.push({code:"BAD_RISK",detail:`${r.temp_ref}: risk ${JSON.stringify(r.risk)} not in high|med|low`}),!r.cite||!r.cite.anchor)e.push({code:"MISSING_CITE",detail:`${r.temp_ref}: every derived use-case must carry a cite`});else for(let c of F(n,r.cite,d))e.push({code:c.code,detail:`${r.temp_ref}: ${c.detail}`});r.matches_existing&&!t.hasNode(r.matches_existing.cid)&&e.push({code:"UNKNOWN_MATCH",detail:`${r.temp_ref}: matches_existing ${r.matches_existing.cid} is not in the graph`});for(let[c,p]of(r.criteria??[]).entries())if((!p.text||!p.text.trim())&&e.push({code:"EMPTY_CRITERION",detail:`${r.temp_ref}.criteria[${c}]: text is empty`}),!p.cite||!p.cite.anchor)e.push({code:"MISSING_CITE",detail:`${r.temp_ref}.criteria[${c}]: every criterion carries its own cite`});else for(let _ of F(n,p.cite,d))e.push({code:_.code,detail:`${r.temp_ref}.criteria[${c}]: ${_.detail}`});for(let[c,p]of(r.updated?.criteria??[]).entries())if((!p.text||!p.text.trim())&&e.push({code:"EMPTY_CRITERION",detail:`${r.temp_ref}.updated.criteria[${c}]: text is empty`}),!p.cite||!p.cite.anchor)e.push({code:"MISSING_CITE",detail:`${r.temp_ref}.updated.criteria[${c}]: every updated criterion carries its own cite`});else for(let _ of F(n,p.cite,d))e.push({code:_.code,detail:`${r.temp_ref}.updated.criteria[${c}]: ${_.detail}`})}return e}function ae(f){let{contextDir:d,graph:t,proposal:e,proposalId:n,verdicts:m,by:r,allowStaleBasis:c,extractorVersion:p,autoName:_}=f,E=W(d);if(!c&&e.read_basis!==E)return{record:null,errors:[{code:"STALE_BASIS",detail:`proposal read_basis ${String(e.read_basis)} != latest ${String(E)}`}]};if(!t.hasNode(e.source.source_cid))return{record:null,errors:[{code:"MISSING_SOURCE_NODE",detail:`source ${e.source.source_id} (${e.source.source_cid}) is not a committed node \u2014 ingest it first`}]};let l=[],g=t.mediaOf(e.source.source_cid),k=new Set,v=[],S=[],O=[],R=[],x=[],V=[],M=new Set,Y=new Set,j=(i,s,b)=>{let u=z(t,s.supersedeTarget,b,M);if("error"in u){l.push({code:u.error.code,detail:`${i}: ${u.error.detail}`});return}M.add(u.targetCid),x.push({kind:"node",old:u.targetCid,new:b,reason:s.reason??`superseded via review by ${r.id}`,by:r})};for(let i of e.use_cases){let s=m.get(i.temp_ref)??{resolution:"skipped"};if(k.has(i.temp_ref)&&l.push({code:"DUP_TEMP_REF",detail:`duplicate temp_ref ${i.temp_ref}`}),k.add(i.temp_ref),(!i.title||!i.title.trim())&&l.push({code:"EMPTY_TITLE",detail:`${i.temp_ref}: title is empty`}),K.has(i.risk)||l.push({code:"BAD_RISK",detail:`${i.temp_ref}: risk ${JSON.stringify(i.risk)} not in high|med|low`}),g.format==="image"){if(i.cite?.anchor!=="img#whole"){l.push({code:i.cite?.anchor?"CITE_ANCHOR_INVALID":"MISSING_CITE",detail:`${i.temp_ref}: image cites are anchor-only (img#whole)`});continue}}else if(!i.cite||!i.cite.anchor||!i.cite.quote){l.push({code:"MISSING_CITE",detail:`${i.temp_ref}: every derived use-case must cite anchor+quote`});continue}s.resolution==="edited"&&s.edit&&(s.edit.title!==void 0&&!s.edit.title.trim()&&l.push({code:"EMPTY_TITLE",detail:`${i.temp_ref}: edited title is empty`}),s.edit.risk!==void 0&&!K.has(s.edit.risk)&&l.push({code:"BAD_RISK",detail:`${i.temp_ref}: edited risk ${JSON.stringify(s.edit.risk)} invalid`}));let b=B({title:s.edit?.title??i.title,description:i.description,summary:s.edit?.summary??i.summary,actors:i.actors,value:i.value,risk:s.edit?.risk??i.risk,...i.criteria&&i.criteria.length>0?{criteria:i.criteria.map(o=>o.text)}:{}}),u=U("usecase",b),I={source_id:e.source.source_id,source_cid:e.source.source_cid,anchor:i.cite.anchor,...i.cite.quote?{quote:i.cite.quote}:{}};if(i.matches_existing&&!t.hasNode(i.matches_existing.cid)){l.push({code:"UNKNOWN_MATCH",detail:`${i.temp_ref}: matches_existing ${i.matches_existing.cid} is not in the graph`});continue}let N=i.matches_existing?.cid??(t.hasNode(u)?u:null);if(N&&t.superseded.has(N)){let o=t.tipOf(N);N=t.superseded.has(o)?null:o}if(N){if(i.changed&&(s.resolution==="approved"||s.resolution==="edited")){let o=i.updated;if(!o||Object.keys(o).length===0){l.push({code:"CHANGED_NEEDS_PAYLOAD",detail:`${i.temp_ref}: changed:true needs an updated{...} payload naming the moved fields`});continue}let h=t.getNode(N)?.content??{},$=(o.criteria??[]).map(a=>typeof a=="string"?{text:a,cite:void 0}:a),C=B({title:s.edit?.title??o.title??String(h.title??i.title),...o.description??h.description?{description:o.description??h.description}:{},...s.edit?.summary??o.summary??h.summary?{summary:s.edit?.summary??o.summary??h.summary}:{},...o.actors??h.actors?{actors:o.actors??h.actors}:{},...o.value??h.value?{value:o.value??h.value}:{},risk:s.edit?.risk??o.risk??String(h.risk??i.risk),...o.criteria?$.length>0?{criteria:$.map(a=>a.text)}:{}:h.criteria?{criteria:h.criteria}:{}}),w=U("usecase",C);if(w!==N){for(let a of L("usecase",C))l.push({code:a.code,detail:`${i.temp_ref}: ${a.detail}`});v.push({cid:w,label:A.USECASE,content:C}),S.push({ecid:T("DERIVES",I.source_cid,w,I),type:D.DERIVES,src:I.source_cid,dst:w,props:I});for(let a of $){if(!a.cite)continue;let y={source_id:e.source.source_id,source_cid:e.source.source_cid,anchor:a.cite.anchor,...a.cite.quote?{quote:a.cite.quote}:{},claim:a.text};S.push({ecid:T("DERIVES",y.source_cid,w,y),type:D.DERIVES,src:y.source_cid,dst:w,props:y})}j(i.temp_ref,{resolution:"supersede",supersedeTarget:N,reason:s.reason??`matches-but-changed: ${e.source.source_id} moved (${Object.keys(o).join(", ")})`},w),R.push({id:w,kind:"review-item",resolution:s.resolution,edit:s.resolution==="edited"?{...s.edit}:null,reason:null,by:r});continue}for(let a of $){if(!a.cite)continue;let y={source_id:e.source.source_id,source_cid:e.source.source_cid,anchor:a.cite.anchor,...a.cite.quote?{quote:a.cite.quote}:{},claim:a.text};S.push({ecid:T("DERIVES",y.source_cid,N,y),type:D.DERIVES,src:y.source_cid,dst:N,props:y})}}s.resolution!=="rejected"&&(S.push({ecid:T("DERIVES",I.source_cid,N,I),type:D.DERIVES,src:I.source_cid,dst:N,props:I}),(s.resolution==="approved"||s.resolution==="edited"||s.resolution==="supersede")&&R.push({id:N,kind:"review-item",resolution:"approved",edit:null,reason:null,by:r}),s.resolution==="supersede"&&j(i.temp_ref,s,N));continue}for(let o of L("usecase",b))l.push({code:o.code,detail:`${i.temp_ref}: ${o.detail}`});for(let o of H(D.DERIVES,"source","usecase",I))l.push({code:o.code,detail:`${i.temp_ref}: ${o.detail}`});v.push({cid:u,label:A.USECASE,content:b}),S.push({ecid:T("DERIVES",I.source_cid,u,I),type:D.DERIVES,src:I.source_cid,dst:u,props:I});for(let o of i.criteria??[]){let h={source_id:e.source.source_id,source_cid:e.source.source_cid,anchor:o.cite.anchor,...o.cite.quote?{quote:o.cite.quote}:{},claim:o.text};S.push({ecid:T("DERIVES",h.source_cid,u,h),type:D.DERIVES,src:h.source_cid,dst:u,props:h})}for(let o of i.depends_on_hint??[]){let h=a=>a.toLowerCase().trim().replace(/\s+/g," "),$=null,C=t.resolve(o);if(C&&!C.superseded&&t.nodeLabel.get(C.cid)===A.USECASE&&($=C.cid),!$){for(let{cid:a,content:y}of t.byLabel(A.USECASE))if(!t.superseded.has(a)&&h(String(y.title??""))===h(o)){$=a;break}}if(!$){let a=v.find(y=>y.label===A.USECASE&&h(String(y.content.title??""))===h(o));a&&($=a.cid)}!$||$===u||X(t,D.DEPENDS_ON,u,$,O)||O.some(a=>a.src===u&&a.dst===$)||(S.push({ecid:T(D.DEPENDS_ON,u,$,{reason:"extract hint"}),type:D.DEPENDS_ON,src:u,dst:$,props:{reason:"extract hint"}}),O.push({src:u,dst:$,type:D.DEPENDS_ON}))}if((s.resolution==="approved"||s.resolution==="edited"||s.resolution==="supersede")&&t.superseded.get(u)===null&&!M.has(u)&&x.push({kind:"node",old:u,new:u,reason:`re-minted after tombstone via review by ${r.id}`,by:r}),_){let o=J("usecase",s.edit?.title??i.title,h=>Y.has(h)||t.names.has(h)&&!t.superseded.has(t.names.get(h)));o!==null&&!t.nameOf.has(u)&&(Y.add(o),V.push({cid:u,slug:o,by:r}))}s.resolution==="approved"?R.push({id:u,kind:"review-item",resolution:"approved",edit:null,reason:null,by:r}):s.resolution==="edited"?R.push({id:u,kind:"review-item",resolution:"edited",edit:{...s.edit},reason:null,by:r}):s.resolution==="rejected"?R.push({id:u,kind:"review-item",resolution:"rejected",edit:null,reason:s.reason??null,by:r}):s.resolution==="supersede"&&(R.push({id:u,kind:"review-item",resolution:"approved",edit:null,reason:s.reason??null,by:r}),j(i.temp_ref,s,u))}return l.length?{record:null,errors:l}:{record:P(d,{ts:new Date().toISOString(),proposal_id:n,...n!=null?{extraction_of:e.source.source_cid}:{},...n!=null&&p?{extractor_version:p}:{},nodes:v,edges:S,review:R,supersessions:x,...V.length>0?{names:V}:{},...f.judgements&&f.judgements.length>0?{judgements:f.judgements}:{},source_head_moves:{}},{expectPrev:E}).record,errors:null}}function ue(f){let{contextDir:d,graph:t,verdicts:e,by:n}=f,m=[],r=[],c=[],p=[],_=new Set;for(let[l,g]of e){if(g.resolution==="skipped")continue;let k=t.resolve(l);if(!k){m.push({code:"UNKNOWN_NODE",detail:`${l} names nothing in the graph`});continue}if(k.superseded){m.push({code:"SUPERSEDED_TARGET",detail:`${l} is superseded \u2014 review the tip (${k.tip})`});continue}let v=k.cid;if(g.resolution==="approved")c.push({id:v,kind:"review-item",resolution:"approved",edit:null,reason:null,by:n});else if(g.resolution==="rejected")c.push({id:v,kind:"review-item",resolution:"rejected",edit:null,reason:g.reason??null,by:n});else if(g.resolution==="edited"){let S=t.getNode(v);if(!S){m.push({code:"UNKNOWN_NODE",detail:`${l}: node file unreadable`});continue}let O={...S.content,...g.edit?.title!==void 0?{title:g.edit.title}:{},...g.edit?.summary!==void 0?{summary:g.edit.summary}:{},...g.edit?.risk!==void 0?{risk:g.edit.risk}:{}},R=L(S.label,O);if(R.length>0){for(let V of R)m.push({code:V.code,detail:`${l}: ${V.detail}`});continue}let x=U(S.label,O);if(x===v){c.push({id:v,kind:"review-item",resolution:"approved",edit:null,reason:null,by:n});continue}r.push({cid:x,label:S.label,content:O}),_.add(v),p.push({kind:"node",old:v,new:x,reason:g.reason??"edited in review",by:n}),c.push({id:x,kind:"review-item",resolution:"edited",edit:{...g.edit},reason:null,by:n})}else if(g.resolution==="supersede"){let S=z(t,g.supersedeTarget,v,_);if("error"in S){m.push({code:S.error.code,detail:`${l}: ${S.error.detail}`});continue}_.add(S.targetCid),p.push({kind:"node",old:S.targetCid,new:v,reason:g.reason??`superseded via review by ${n.id}`,by:n}),c.push({id:v,kind:"review-item",resolution:"approved",edit:null,reason:g.reason??null,by:n})}}return m.length?{record:null,errors:m}:c.length===0&&p.length===0?{record:null,errors:[{code:"NO_VERDICTS",detail:"every item was skipped \u2014 nothing to commit"}]}:{record:P(d,{ts:new Date().toISOString(),proposal_id:null,nodes:r,edges:[],review:c,supersessions:p,source_head_moves:{}},{expectPrev:t.latestHash}).record,errors:null}}function le(f){let{contextDir:d,graph:t,assignments:e,by:n}=f,m=[],r=[],c=new Set;for(let{ref:_,slug:E}of e){if(!G.test(E)){m.push({code:"BAD_SLUG",detail:`${JSON.stringify(E)} \u2014 slugs are kebab-case ${String(G)}`});continue}let l=t.resolve(_);if(!l){m.push({code:"UNKNOWN_REF",detail:`${_} names nothing in the graph`});continue}if(l.superseded){m.push({code:"SUPERSEDED_TARGET",detail:`${_} is superseded \u2014 name the tip instead (${l.tip})`});continue}let g=t.names.get(E);if(g!==void 0&&!t.superseded.has(g)&&g!==l.cid||c.has(E)){m.push({code:"SLUG_TAKEN",detail:`${E} already names ${g??"another node in this record"}`});continue}c.add(E),r.push({cid:l.cid,slug:E,by:n})}return m.length?{record:null,errors:m}:r.length===0?{record:null,errors:[{code:"NO_ASSIGNMENTS",detail:"nothing to name"}]}:{record:P(d,{ts:new Date().toISOString(),proposal_id:null,nodes:[],edges:[],review:[],supersessions:[],names:r,source_head_moves:{}},{expectPrev:t.latestHash}).record,errors:null}}function pe(f){let{contextDir:d,graph:t,sourceId:e,reason:n,by:m}=f,r=t.heads.get(e);return r===void 0?{record:null,errors:[{code:"UNKNOWN_SOURCE",detail:`no source ${e} in the graph`}]}:r===null?{record:null,errors:[{code:"ALREADY_RETIRED",detail:`source ${e} is already retired`}]}:{record:P(d,{ts:new Date().toISOString(),proposal_id:null,nodes:[],edges:[],review:[],supersessions:[{kind:"node",old:r,new:null,reason:n??`retired source ${e}`,by:m}],source_head_moves:{[e]:null},names:[]},{expectPrev:t.latestHash}).record,errors:null}}function Q(f,d){let t=f.toLowerCase().trim().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"");if(t.length>60){let n=t.lastIndexOf("-",60);t=(n>0?t.slice(0,n):t.slice(0,60)).replace(/-+$/g,"")}if(!G.test(t))return null;let e=t;for(let n=2;d(e);n++)e=`${t}-${n}`;return G.test(e)?e:null}var Z={source:"src",usecase:"uc",scenario:"sc",ac:"ac",test:"t",gap:"gap",stylenote:"sty"};function J(f,d,t){let e=Z[f];return Q(e?`${e} ${d}`:d,t)}export{Z as a,J as b,X as c,de as d,ce as e,ae as f,ue as g,le as h,pe as i};
|
package/dist/chunk-ZG2V2ODK.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as g}from"./chunk-5YPBPZUR.js";import{createHash as E}from"crypto";function w(e){if(e===null)return"null";let r=typeof e;if(r==="string")return JSON.stringify(e.normalize("NFC"));if(r==="boolean")return e?"true":"false";if(r==="number"){if(!Number.isFinite(e))throw new Error("non-finite number is not canonicalizable");return JSON.stringify(e)}if(Array.isArray(e))return"["+e.map(n=>n===void 0?"null":w(n)).join(",")+"]";if(r==="object"){let n=e,s=new Map;for(let t of Object.keys(n)){if(n[t]===void 0)continue;let c=t.normalize("NFC");if(s.has(c))throw new Error(`canonicalization collision: NFC-equivalent duplicate key ${JSON.stringify(c)}`);s.set(c,n[t])}return"{"+[...s.keys()].sort((t,c)=>Buffer.compare(Buffer.from(t,"utf8"),Buffer.from(c,"utf8"))).map(t=>JSON.stringify(t)+":"+w(s.get(t))).join(",")+"}"}throw new Error("unsupported type for canonicalization: "+r)}function k(e){return E("sha256").update(e).digest("hex")}import{closeSync as $,existsSync as O,fsyncSync as x,mkdirSync as b,openSync as S,readFileSync as R,readdirSync as j,renameSync as F,rmSync as J,writeFileSync as _}from"fs";import{join as f}from"path";var a=class extends Error{};function v(e,r){if(e.schema_version!==void 0&&e.schema_version!==g)throw new a(`record ${r} is stamped ${e.schema_version}, this build reads ${g} \u2014 migrate explicitly`);if(e.parents!==void 0&&!(e.prev_hash===null?e.parents.length===0:e.parents.length===1&&e.parents[0]===e.prev_hash))throw new a(`record ${r}: parents does not mirror prev_hash \u2014 multi-parent records need a DAG-aware reader`)}function z(e){b(e,{recursive:!0});let r=f(e,".lock"),n=Date.now()+2e3;for(;;)try{let s=S(r,"wx");return _(s,`${process.pid}
|
|
3
|
-
`),$(s),()=>{try{J(r)}catch{}}}catch(s){if(s.code!=="EEXIST")throw s;if(Date.now()>n)throw new a(`.context is locked by another process \u2014 remove ${r} if that process is gone`);Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,25)}}var A=/^\d{6}-[0-9a-f]{12}\.json$/,p=e=>f(e,"commits");function y(e){return"sha256:"+k(Buffer.from(w(e),"utf8"))}function q(e){let r=p(e);return O(r)?j(r).filter(n=>A.test(n)).sort():[]}function T(e){let r=q(e),n=[],s=[],i=null;return r.forEach((t,c)=>{let d=R(f(p(e),t),"utf8"),o;try{o=JSON.parse(d)}catch(l){throw new a(`corrupt commit record ${t}: ${String(l)}`)}if(o.seq!==c+1)throw new a(`sequence gap: expected seq ${c+1}, ${t} has ${o.seq}`);if(o.prev_hash!==i)throw new a(`broken chain at ${t}: prev_hash ${String(o.prev_hash)} != ${String(i)}`);v(o,t);let m=y(o),h=t.slice(7,19);if(!m.slice(7).startsWith(h))throw new a(`tampered record ${t}: content hash ${m} does not match filename`);n.push(o),s.push(m),i=m}),{records:n,hashes:s}}function N(e){let r=q(e);if(r.length===0)return null;let n=r[r.length-1],s=R(f(p(e),n),"utf8"),i;try{i=JSON.parse(s)}catch(c){throw new a(`corrupt tail record ${n}: ${String(c)}`)}v(i,n);let t=y(i);if(!t.slice(7).startsWith(n.slice(7,19)))throw new a(`tampered tail record ${n}: content hash ${t} does not match filename`);if(i.seq!==r.length)throw new a(`sequence gap at tail: ${r.length} record files but tail seq is ${i.seq}`);return{seq:i.seq,hash:t}}function G(e){return N(e)?.hash??null}function V(e,r,n){let s=q(e);if(s.length<r)throw new a(`derived state is ahead of the record log (applied seq ${r}, ${s.length} records) \u2014 run kane-cli context rebuild`);let i=[],t=[],c=n;for(let d=r;d<s.length;d++){let o=s[d],m=R(f(p(e),o),"utf8"),h;try{h=JSON.parse(m)}catch(u){throw new a(`corrupt commit record ${o}: ${String(u)}`)}if(h.seq!==d+1)throw new a(`sequence gap: expected seq ${d+1}, ${o} has ${h.seq}`);if(h.prev_hash!==c)throw new a(`broken chain at ${o}: prev_hash ${String(h.prev_hash)} != ${String(c)}`);v(h,o);let l=y(h);if(!l.slice(7).startsWith(o.slice(7,19)))throw new a(`tampered record ${o}: content hash ${l} does not match filename`);i.push(h),t.push(l),c=l}return{records:i,hashes:t}}function X(e,r,n={}){let s=z(e);try{return B(e,r,n)}finally{s()}}function B(e,r,n){let s=N(e),i=(s?.seq??0)+1,t=s?.hash??null;if(n.expectPrev!==void 0&&n.expectPrev!==t)throw new a(`concurrent append detected: validated against ${String(n.expectPrev)} but the chain head is ${String(t)} \u2014 re-open and retry`);let c={seq:i,prev_hash:t,...r,schema_version:g,parents:t===null?[]:[t]},d=y(c),o=p(e);b(o,{recursive:!0});let m=`${String(i).padStart(6,"0")}-${d.slice(7,19)}.json`,h=f(o,m),l=h+".tmp",u=S(l,"w");try{_(u,JSON.stringify(c)+`
|
|
4
|
-
`),x(u)}finally{$(u)}F(l,h);try{let C=S(o,"r");x(C),$(C)}catch{}return{seq:i,hash:d,file:h,record:c}}export{w as a,k as b,a as c,T as d,G as e,V as f,X as g};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as x}from"./chunk-GBBVP2JW.js";import{a as d,b as $,d as w}from"./chunk-GRB66C5S.js";import"./chunk-RN4OSVTG.js";import{e as b,f as k}from"./chunk-CJJXT5DO.js";import"./chunk-BC7UVJJB.js";import{e as v}from"./chunk-EHN5HTUD.js";import{a as h}from"./chunk-L5LI2JF4.js";import{a as y}from"./chunk-MCQXRJGH.js";import"./chunk-74RUSHIB.js";import"./chunk-ZZLR3O5A.js";import"./chunk-ZG2V2ODK.js";import"./chunk-5YPBPZUR.js";import"./chunk-UR6MHSHU.js";import{basename as f}from"path";import{statSync as R}from"fs";function S(s,e){if(!s)return 1;let r=s.resolve(e);return!r||r.superseded?1:s.getNode(r.tip)?.content.risk==="high"?3:1}function C(s,e){return s.usecases.map(r=>{let n=r.acceptance_criteria??[],a=n.filter(o=>(o.covered_by??[]).length>0),u=n.filter(o=>o.execution==="passed"),c=n.filter(o=>o.execution==="failed"),p=n.filter(o=>o.execution==="blocked"),i=0,l=0;for(let o of n){let g=S(e,o.id);i+=g,o.execution==="passed"&&(l+=g)}let t=i===0?0:Math.round(100*l/i),m=a.length===0?"uncovered":n.length===u.length?"covered":p.length>0&&c.length===0?"blocked":"partial";return{id:r.id,title:r.title,status:m,pct:t,acs:{total:n.length,covered:a.length,passed:u.length,failed:c.length,blocked:p.length},stale:n.filter(o=>o.fresh==="stale").map(o=>o.id)}})}async function A(s){let e=await b(s);return e.length===0?null:e.map(r=>({p:r,m:R(r).mtimeMs})).sort((r,n)=>n.m-r.m)[0].p}var D={covered:"\u2714",partial:"\u25D0",uncovered:"\u2716",blocked:"\u23F8"};function G(s){let e=Math.round(s/10);return"\u2588".repeat(e)+"\u2591".repeat(10-e)}async function E(s,e=w(),r=process.cwd()){let n=$(r,e);if(!n)return 2;let a=s.from?await k(s.from,r):await A(r);if(!a)return d(e,s.from?`no evidence pack at '${s.from}'`:"no evidence pack in .testmuai/evidence \u2014 run a test first, or pass --from <pack>"),2;let u=await v(a,"coverage/usecases.yaml");if(u==null)return d(e,`${f(a)} carries no coverage/usecases.yaml \u2014 the pack predates coverage or its project had no .context at seal time`),2;let c=h(u);if(!c||!Array.isArray(c.usecases))return d(e,`${f(a)}: coverage/usecases.yaml is not a usecases document`),2;let p=y(n),i=C(c,p),l=await x(p,"design");if(s.json)return e.out(JSON.stringify({pack:a,depth:i,completeness:l},null,2)),0;e.out(`coverage \u2014 ${f(a)}`),e.out(""),e.out("depth (proven by the pack):");for(let t of i){let m=t.stale.length?` \xB7 ${t.stale.length} stale`:"";e.out(` ${D[t.status]} ${G(t.pct)} ${String(t.pct).padStart(3)}% ${t.id} \u2014 ${t.status} (${t.acs.passed}/${t.acs.total} ACs proven${t.acs.failed?`, ${t.acs.failed} failed`:""}${t.acs.blocked?`, ${t.acs.blocked} blocked`:""})${m}`)}e.out(""),e.out("completeness (live graph):"),l.length===0&&e.out(" no design gaps \u2014 every AC verified, every use-case scenarioed");for(let t of l)e.out(` [${t.risk}] ${t.tag} ${t.ref} \u2014 ${t.why}`),e.out(` \u2192 ${t.ready_command}`);return 0}export{E as coverCommand,C as depthRows};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{$ as fa,A as J,B as K,C as L,D as M,E as N,F as O,G as P,H as Q,L as R,M as S,N as T,O as U,P as V,Q as W,R as X,S as Y,T as Z,U as _,V as $,W as aa,X as ba,Y as ca,Z as da,_ as ea,a,aa as ga,b,ba as ha,c,ca as ia,d,e,f,g,h,i,j,k as t,l as u,m as v,n as w,o as x,p as y,q as z,r as A,s as B,t as C,u as D,v as E,w as F,x as G,y as H,z as I}from"./chunk-QNNBNIR7.js";import{a as n,b as o,c as p,e as q,f as r,g as s}from"./chunk-CJJXT5DO.js";import"./chunk-FJTWJ243.js";import"./chunk-BC7UVJJB.js";import"./chunk-2PQXEEVY.js";import{a as k,b as l,c as m}from"./chunk-EHN5HTUD.js";import"./chunk-L5LI2JF4.js";import"./chunk-MCQXRJGH.js";import"./chunk-74RUSHIB.js";import"./chunk-ZZLR3O5A.js";import"./chunk-ZG2V2ODK.js";import"./chunk-5YPBPZUR.js";import"./chunk-DNOBOZPO.js";import"./chunk-HJGUEZLW.js";import"./chunk-UR6MHSHU.js";export{P as EvidenceSession,C as appendExecutionPointer,M as assembleExecutionEnv,i as buildEnvironment,j as buildEvidenceRunConfig,g as buildExternalId,z as buildLogsMetaYaml,y as buildResultYaml,t as buildRunYaml,O as createCdpBrowserCapture,u as createRunningPack,v as createRunningPackRoot,H as declareLogsFromDir,J as diagnostics,x as discardPack,ba as ensureAuteurExecution,N as fetchCdpBrowserString,L as finalizeEvidencePack,U as finalizeInlineEvidence,K as finalizeMemberTestLogs,da as flattenAuteurLeafIds,ca as flattenAuteurLeaves,T as inlineEvidenceBlock,q as listPacks,p as newExecutionId,h as normalizeOs,S as noteInlineSpawn,$ as offerEvidenceView,o as packPath,I as packTestLogsDir,V as parseRange,D as readExecutionPointers,ia as readPackLeafIds,ha as readPackLeaves,s as recoverStore,fa as remapReplayActionIds,r as resolvePack,ga as resolveReplayResultSteps,F as rollupTestStatus,aa as runEvidenceMerge,_ as runEvidenceServe,E as runEvidenceValidate,Q as runStartupRecovery,l as sealPack,w as sealPackById,Z as serveHint,d as shortHash,c as slugify,W as startEvidenceLocalServer,R as startInlineEvidence,n as storeDir,m as sweepStore,ea as synthesizeSkippedTail,f as testIdForInline,e as testIdForTestmd,k as validatePack,a as verdictFromResultCode,X as viewerBaseFor,Y as viewerUrlFor,b as worstOf,G as worstResultCode,B as writeLogsMeta,A as writeResult};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a,b,c,d,e,f,g}from"./chunk-ANIVHX3P.js";import"./chunk-3C5GMAM4.js";import"./chunk-GRB66C5S.js";import"./chunk-JFAFKHDX.js";import"./chunk-QPZRHAYK.js";import"./chunk-RN4OSVTG.js";import"./chunk-BC7UVJJB.js";import"./chunk-2PQXEEVY.js";import"./chunk-MCQXRJGH.js";import"./chunk-74RUSHIB.js";import"./chunk-ZZLR3O5A.js";import"./chunk-ZG2V2ODK.js";import"./chunk-5YPBPZUR.js";import"./chunk-UR6MHSHU.js";export{b as designStateOf,g as evolveCommand,c as evolveOneUc,f as liveRunDesignForUc,a as resolveParentUc,e as runEvolveCommand,d as staleTargets};
|
package/dist/explain-VFIZTHFN.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as b}from"./chunk-GBBVP2JW.js";import{a as o,b as h,d as w}from"./chunk-GRB66C5S.js";import"./chunk-RN4OSVTG.js";import{e as $,f as y}from"./chunk-CJJXT5DO.js";import"./chunk-BC7UVJJB.js";import{e as l}from"./chunk-EHN5HTUD.js";import{a as g}from"./chunk-L5LI2JF4.js";import{a as k}from"./chunk-MCQXRJGH.js";import"./chunk-74RUSHIB.js";import"./chunk-ZZLR3O5A.js";import"./chunk-ZG2V2ODK.js";import"./chunk-5YPBPZUR.js";import"./chunk-UR6MHSHU.js";import{basename as p}from"path";import{statSync as O}from"fs";async function P(t){let e=await $(t);return e.length===0?null:e.map(a=>({p:a,m:O(a).mtimeMs})).sort((a,r)=>r.m-a.m)[0].p}async function U(t,e=w(),a=process.cwd()){let r=t.stage??"design";if(r!=="design"&&r!=="cover"&&r!=="all")return o(e,`--stage must be design | cover | all, got '${r}'`),2;if(t.top!==void 0&&(!Number.isInteger(t.top)||t.top<1))return o(e,"--top must be a positive integer"),2;let f=h(a,e);if(!f)return 2;let d,i;if(r!=="design"){let s=t.from?await y(t.from,a):await P(a);if(!s)return o(e,`--stage ${r} needs an evidence pack \u2014 run a test first, or pass --from <pack>`),2;let c=await l(s,"coverage/usecases.yaml");if(c==null)return o(e,`${p(s)} carries no coverage/usecases.yaml \u2014 re-run the tests to produce a coverage-bearing pack`),2;let u=g(c);if(!u||!Array.isArray(u.usecases))return o(e,`${p(s)}: coverage/usecases.yaml is not a usecases document`),2;d=u,i=p(s)}let v=k(f),n=await b(v,r,void 0,d),m=n.length;return t.top!==void 0&&(n=n.slice(0,t.top)),t.json?(e.out(JSON.stringify({stage:r,...i?{pack:i}:{},total:m,rows:n},null,2)),0):(e.out(`gaps \u2014 stage ${r}${i?` \xB7 pack ${i}`:""} (${n.length}${n.length<m?` of ${m}`:""})`),n.length===0&&e.out(" nothing owed \u2014 design and execution are square"),n.forEach((s,c)=>{e.out(` ${String(c+1).padStart(2)}. [${s.risk}] ${s.tag} ${s.ref} \u2014 ${s.why}`),e.out(` \u2192 ${s.ready_command}`)}),0)}export{U as gapsCommand};
|
package/dist/ingest-C5ANIN7S.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{b as a,c as b,d as c}from"./chunk-SJ2KQKOV.js";import"./chunk-2PQXEEVY.js";import"./chunk-MCQXRJGH.js";import"./chunk-74RUSHIB.js";import"./chunk-ZZLR3O5A.js";import"./chunk-ZG2V2ODK.js";import"./chunk-5YPBPZUR.js";import"./chunk-UR6MHSHU.js";export{c as ingestFile,a as slugFromFilename,b as versionBaseOf};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{b as g,c as b,d as p}from"./chunk-SJ2KQKOV.js";import{c as l}from"./chunk-RN4OSVTG.js";import{a as f}from"./chunk-BC7UVJJB.js";import"./chunk-2PQXEEVY.js";import{a as d}from"./chunk-MCQXRJGH.js";import"./chunk-74RUSHIB.js";import"./chunk-ZZLR3O5A.js";import"./chunk-ZG2V2ODK.js";import"./chunk-5YPBPZUR.js";import"./chunk-UR6MHSHU.js";import{existsSync as $}from"fs";async function h(o,u,e,i=process.cwd()){let n=f(i);if(u.as!==void 0&&o.length>1)return(e.err??e.out)(`error: --as names ONE source identity \u2014 pass a single file (got ${o.length})`),2;for(let a of o){let m=u.as;if(e.isTTY&&m===void 0&&$(n)){let t=g(a),s=b(t);if(s){let c=d(n);c.heads.get(s)!=null&&c.heads.get(t)==null&&await e.confirm(`${t} looks like a new version of existing source '${s}' \u2014 ingest as '${s}' (moves its head)?`)&&(m=s)}}let r;try{r=await p({contextDir:n,filePath:a,asId:m,confirmSameSource:e.isTTY?t=>e.confirm(`identical bytes already ingested as ${t} \u2014 treat as the same source?`):void 0})}catch(t){return e.out(`error: ${a}: ${t instanceof Error?t.message:String(t)}`),1}if(e.out(`${r.status} ${r.source_id} source ${r.cid} blob ${r.blob}`),!e.isTTY&&r.status==="created"){let t=d(n);for(let[s,c]of t.heads.entries())if(!(s===r.source_id||c==null)&&t.getNode(c)?.content.blob===r.blob){e.out(`hint: identical bytes already ingested as ${s} \u2014 merged later via review`);break}}}return 0}async function Y(o,u){let{createInterface:e}=await import("readline/promises");return h(o,u,{out:i=>process.stdout.write(i+`
|
|
3
|
-
`),isTTY:l(),confirm:async i=>{let n=e({input:process.stdin,output:process.stdout});try{let a=await n.question(`${i} [Y/n] `);return!/^n(o)?$/i.test(a.trim())}finally{n.close()}}})}export{Y as ingestCommand,h as runIngestCommand};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as b,b as a,c as f,d as m}from"./chunk-GRB66C5S.js";import{h as p,i as y}from"./chunk-WIA7TPK3.js";import"./chunk-QPZRHAYK.js";import"./chunk-RN4OSVTG.js";import"./chunk-BC7UVJJB.js";import{a as c}from"./chunk-MCQXRJGH.js";import"./chunk-74RUSHIB.js";import"./chunk-ZZLR3O5A.js";import"./chunk-ZG2V2ODK.js";import"./chunk-5YPBPZUR.js";import"./chunk-UR6MHSHU.js";var g={kind:"human",id:process.env.USER??"operator"},$=/^(UNKNOWN_|BAD_|INVALID_|MALFORMED_|NOT_|SLUG_TAKEN|ALREADY_|SUPERSEDED_)/;function h(e){return e.every(r=>$.test(r.code))?2:1}function l(e,r){for(let n of r)b(e,`${n.code}: ${n.detail}`);return h(r)}async function w(e,r,n,t=process.cwd()){let s=a(t,n);if(!s||!await f(n,`retire source ${e} (head \u2192 null + tombstone record)`,r.yes))return 2;let i=c(s),o=y({contextDir:s,graph:i,sourceId:e,reason:r.reason,by:g});return o.errors?l(n,o.errors):(n.out(`retired ${e} (record ${o.record.seq}) \u2014 its use-cases stay until no live source evidences them`),0)}async function x(e,r,n,t=process.cwd()){let s=a(t,n);if(!s)return 2;let i=c(s),o=p({contextDir:s,graph:i,assignments:[{ref:e,slug:r}],by:g});return o.errors?l(n,o.errors):(n.out(`named ${o.record.names[0].cid} as "${r}" (record ${o.record.seq})`),0)}async function O(e,r,n,t=process.cwd()){let s=a(t,n);if(!s)return 2;let i=Number(e);if(!await f(n,`revert record ${i} via a compensation record`,r.yes))return 2;let o=c(s),{commitRevert:v}=await import("./revert-AQQ2VHRM.js"),d=v({contextDir:s,graph:o,seq:i,reason:r.reason,by:g});for(let C of d.warnings)n.out(`note: ${C}`);if(d.errors)return l(n,d.errors);let u=d.record;return n.out(`reverted record ${i} via compensation record ${u.seq}: ${u.supersessions.length} supersession(s), ${u.review.length} trust restoration(s), ${Object.keys(u.source_head_moves).length} head move(s) \u2014 history unchanged, effects inverted`),0}async function A(e,r){return w(e,r,m())}async function P(e,r){return x(e,r,m())}async function I(e={},r=process.cwd()){return D(e,m(),r)}async function D(e,r,n=process.cwd()){let t=a(n,r);if(!t||!await f(r,"assign logical ids to every live unnamed node (one commit record)",e.yes))return 2;let{backfillLogicalIds:s}=await import("./logical-ids-3Y6RX5C2.js"),i=c(t),o=s(t,i);return o.errors?l(r,o.errors):(r.out(o.assigned===0?"backfill: every live node already has a logical id":`backfill: assigned ${o.assigned} logical id(s) (record ${o.record.seq})`),0)}async function R(e,r){return O(e,r,m())}export{I as nameBackfillCommand,P as nameCommand,A as retireCommand,R as revertCommand,D as runNameBackfillCommand,x as runNameCommand,w as runRetireCommand,O as runRevertCommand};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{b as m}from"./chunk-GRB66C5S.js";import"./chunk-RN4OSVTG.js";import"./chunk-BC7UVJJB.js";import{a as g}from"./chunk-MCQXRJGH.js";import"./chunk-74RUSHIB.js";import"./chunk-ZZLR3O5A.js";import"./chunk-ZG2V2ODK.js";import{d as o}from"./chunk-5YPBPZUR.js";import"./chunk-UR6MHSHU.js";var p=[o.SOURCE,o.USECASE,o.SCENARIO,o.AC,o.TEST,o.GAP];function h(n,e){if(n===o.SOURCE)return String(e.source_id??"");let i=e.question?.header,l=e.title??e.text??i??e.kind??"";return String(l)}function E(n,e){if(n.length<=e)return n;let i=n.slice(0,e-1),l=i.lastIndexOf(" ");return`${(l>e*.6?i.slice(0,l):i).trimEnd()}\u2026`}var b=58;async function O(n,e,i=process.cwd()){let l=m(i,e);if(!l)return 2;let a=g(l),s=[...a.nodeLabel.entries()].filter(([t])=>n.all||!a.superseded.has(t)).map(([t,r])=>{let u=a.getNode(t)?.content??{},f=a.trust.get(t)??(r===o.SOURCE?"-":"derived");return{id:r===o.SOURCE?String(u.source_id??""):a.nameOf.get(t)??t.slice(0,19),cid:t,label:r,title:h(r,u),trust:f,fresh:f==="archived"?"-":a.stale(t)}});if(n.type&&(s=s.filter(t=>t.label===n.type)),n.inferred&&(s=s.filter(t=>t.trust==="derived")),n.stale&&(s=s.filter(t=>t.fresh!=="fresh")),!n.all){let t=new Map;for(let r of s)t.set(`${r.label}:${r.id}`,r);s=[...t.values()]}let d=t=>{let r=p.indexOf(t);return r===-1?p.length:r};if(s.sort((t,r)=>d(t.label)-d(r.label)||t.title.localeCompare(r.title)),n.json){for(let t of s)e.out(JSON.stringify(t));return 0}if(s.length===0)return e.out("(no matching nodes)"),0;e.out("trust \xB7 fresh \xB7 title \xB7 id");let c=null;for(let t of s){if(t.label!==c){c=t.label;let u=s.filter(f=>f.label===t.label).length;e.out(""),e.out(`\u2500\u2500 ${t.label} \xB7 ${u} \u2500\u2500`)}let r=E(t.title||"(untitled)",b);e.out(` ${t.trust.padEnd(8)} ${t.fresh.padEnd(6)} ${r.padEnd(b)} ${t.id}`)}return 0}async function R(n){return O(n,{out:e=>process.stdout.write(e+`
|
|
3
|
-
`),confirm:async()=>!1,isTTY:!!process.stdout.isTTY})}export{E as capWord,R as listCommand,O as runListCommand,h as titleOf};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as d,b as f,h as m}from"./chunk-WIA7TPK3.js";import"./chunk-QPZRHAYK.js";import"./chunk-ZZLR3O5A.js";import"./chunk-ZG2V2ODK.js";import"./chunk-5YPBPZUR.js";import"./chunk-UR6MHSHU.js";var y=Object.keys(d).filter(n=>n!=="source");function b(n,t,u={kind:"system",id:"logical-id-backfill"}){let l=new Set(t.names.keys()),r=[];for(let c of y)for(let{cid:s,content:e}of t.byLabel(c)){if(t.superseded.has(s)||t.nameOf.has(s))continue;let a=typeof e.title=="string"&&e.title||typeof e.intent=="string"&&e.intent||typeof e.statement=="string"&&e.statement||typeof e.text=="string"&&e.text||"",i=a?f(c,a,g=>l.has(g)):null;i&&(l.add(i),r.push({ref:s,slug:i}))}if(r.length===0)return{record:null,errors:null,assigned:0};let o=m({contextDir:n,graph:t,assignments:r,by:u});return o.errors?{record:null,errors:o.errors,assigned:0}:{record:o.record,errors:null,assigned:r.length}}export{b as backfillLogicalIds};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a}from"./chunk-5CTMOJG4.js";import"./chunk-4MUHS3UL.js";import"./chunk-RFHMDQXZ.js";import"./chunk-RZ4F3BHX.js";import"./chunk-DNOBOZPO.js";import"./chunk-BOO7YXAV.js";import"./chunk-HJGUEZLW.js";import"./chunk-UR6MHSHU.js";export{a as LoginFlow};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{b as i,c,d as s}from"./chunk-GRB66C5S.js";import"./chunk-RN4OSVTG.js";import{a as t}from"./chunk-BC7UVJJB.js";import{c as m,d as u}from"./chunk-74RUSHIB.js";import"./chunk-ZZLR3O5A.js";import"./chunk-ZG2V2ODK.js";import"./chunk-5YPBPZUR.js";import"./chunk-UR6MHSHU.js";async function d(e,r=process.cwd()){if(!i(r,e))return 2;let o=u(t(r));if(o.ok)return e.out(`ok: ${o.records} record(s) verified, derived projection in parity`),0;for(let n of o.issues)e.out(`issue: ${n}`);return 1}async function f(e,r,o=process.cwd()){if(!i(o,r)||!await c(r,"wipe .context/derived and rebuild it from the verified commit chain",e.yes))return 2;let n=m(t(o));return r.out(`rebuilt: ${n.applied.seq} record(s) replayed, ${Object.keys(n.nodeLabel).length} node(s) projected`),0}async function l(){return d(s())}async function y(e={}){return f(e,s())}export{l as fsckCommand,y as rebuildCommand,d as runFsckCommand,f as runRebuildCommand};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a,b,c}from"./chunk-IJPFAWBH.js";import"./chunk-2YQ6TW77.js";import"./chunk-WAOCHXJ5.js";import"./chunk-QNNBNIR7.js";import"./chunk-CJJXT5DO.js";import"./chunk-FJTWJ243.js";import"./chunk-BC7UVJJB.js";import"./chunk-2PQXEEVY.js";import"./chunk-EHN5HTUD.js";import"./chunk-L5LI2JF4.js";import"./chunk-MCQXRJGH.js";import"./chunk-74RUSHIB.js";import"./chunk-ZZLR3O5A.js";import"./chunk-ZG2V2ODK.js";import"./chunk-5YPBPZUR.js";import"./chunk-2WVKOZ6W.js";import"./chunk-NLCCBXXV.js";import"./chunk-RZ4F3BHX.js";import"./chunk-DNOBOZPO.js";import"./chunk-HJGUEZLW.js";import"./chunk-UR6MHSHU.js";export{c as UploadPipeline,b as packPresignEntry,a as readPackForUpload};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a,b}from"./chunk-MCQXRJGH.js";import"./chunk-74RUSHIB.js";import"./chunk-ZZLR3O5A.js";import"./chunk-ZG2V2ODK.js";import"./chunk-5YPBPZUR.js";import"./chunk-UR6MHSHU.js";export{a as openGraph,b as staleForEvolve};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as G,b as Z,c as J,d as Q}from"./chunk-6LRKYF67.js";import"./chunk-GBBVP2JW.js";import{a as N,c as q,d as ue,f as z}from"./chunk-ANIVHX3P.js";import"./chunk-3C5GMAM4.js";import{a as P,b as le,d as de}from"./chunk-GRB66C5S.js";import{a as se,b as oe}from"./chunk-SJ2KQKOV.js";import{a as B,b as T,c as L,d as V,e as ce,g as I,h as K}from"./chunk-K5JGCJ2K.js";import{a as ae}from"./chunk-JFAFKHDX.js";import"./chunk-WIA7TPK3.js";import"./chunk-QPZRHAYK.js";import"./chunk-RN4OSVTG.js";import"./chunk-BC7UVJJB.js";import"./chunk-2PQXEEVY.js";import{a as x}from"./chunk-MCQXRJGH.js";import"./chunk-74RUSHIB.js";import"./chunk-ZZLR3O5A.js";import{e as F}from"./chunk-ZG2V2ODK.js";import"./chunk-5YPBPZUR.js";import"./chunk-UR6MHSHU.js";import{existsSync as ve,statSync as we}from"fs";import{basename as j,resolve as pe}from"path";var ge=new Set(["interactive","agent","ci","override"]);function ke(e,t){if(e.mode!==void 0&&!ge.has(e.mode))return{error:`--mode must be interactive | agent | ci | override, got '${e.mode}'`};let r=e.mode,n="reconcile without a TTY needs an explicit mode \u2014 pass --mode agent|ci|override, or --plan for a preview";return r==="interactive"&&!t?{error:n}:r||(t?"interactive":e.plan?"override":{error:n})}function ye(e,t,r,n){let i=pe(t,r);if(!ve(i)||!we(i).isFile())return{error:`--from '${r}' is not a file \u2014 pass the changed source document`};let p=se(i);if(!p.ok)return{error:`--from '${r}' is not an ingestable document \u2014 allowed: ${p.allowlist.join(", ")}`};let f=x(e);if(!f.heads.has(n))return{error:`unknown source '${n}' \u2014 see \`kane-cli context list --type source\``};if(f.heads.get(n)==null)return{error:`source '${n}' is retired \u2014 restore it first with \`kane-cli context revert\`, then reconcile`};let d=null;try{d=oe(i)}catch{}return d!==null&&d!==n&&f.heads.get(d)!=null?{error:`'${j(i)}' already backs live source '${d}' \u2014 did you mean --source-id ${d}? To truly move these bytes under '${n}', retire '${d}' first`}:{sourceId:n,filePath:i}}function O(e){return e==null?"(none)":e.slice(0,19)}function M(e,t,r){if(e.out(`reconcile ${t.source_id}: head ${t.head.status} \u2014 ${O(t.head.before)} \u2192 ${O(t.head.after)}`),e.out(`note: ${t.note}`),e.out(`skipped arms: ${t.skipped_arms}`),t.changed&&e.out(t.held?`extract ran in override mode; ${r?.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; ${r?.defaultsTaken??0} default(s) auto-taken; matched-but-changed proposals auto-committed as edits`),t.changed){let n=t.changeset??[];e.out(`changeset: ${n.length} item(s)`);for(let i of n)if(i.kind==="MODIFY")e.out(` [MODIFY] ${i.ref} \u2014 ${i.summary} (${O(i.old_cid)} \u2192 ${i.new_cid===null?"(staged)":O(i.new_cid)})`);else if(i.kind==="ADD")e.out(` [ADD] ${i.ref}`);else{e.out(` [ARCHIVE] ${i.ref} \u2014 ${i.why}`);let p=X(i.impact,"retiring drops");p&&e.out(` ${p}`)}}e.out(`plan: ${t.rows.length} row(s)`);for(let n of t.rows){e.out(` [${n.kind}] ${n.ref} \u2014 ${n.reason}`);let i=X(n.impact,"approving marks");i&&e.out(` ${i}`),e.out(` provenance: ${n.provenance}`),e.out(` action: ${n.action}`)}}function X(e,t){if(!e||e.stale_refs.length===0)return null;let r=e.direct_refs??[];return`impact: ${t} ${e.stale_refs.length} item(s) stale`+(r.length>0?` \u2014 ${r.length} directly touched: ${r.join(", ")}`:"")}function E(e){return e==="interactive"?"override":e}async function A(e,t,r,n,i,p,f=[],d="override",y,w,s,u,h){let l;try{l=K(e)}catch($){return P(n,$ instanceof Error?$.message:String($)),1}try{if(!r){let{runWalkSession:$}=await import("./walk-session-O4TMVORI.js");return await $({dir:e,rows:t,archive:f,held:y??null,childMode:d,runDesign:u??null,mark:p,markA:s,...w?{archiveState:w}:{},signals:k=>C(e,k.ref,k.verdict,k.reason),...h?{script:h}:{}})}return await $e(e,t,r,n,i,p,f,d,y,w)}finally{l()}}var H=e=>`${e} high-risk item(s) need a human \u2014 ci mode won't guess. Walk interactively or use --mode agent.`;function W(e,t,r){let n=t.rows;e({type:"reconcile_plan",source_id:t.source_id,plan_path:r,rows:n.map(i=>({kind:i.kind,ref:i.ref,why:i.reason})),archive:t.changeset.filter(i=>i.kind==="ARCHIVE").map(i=>({ref:i.ref,why:i.why}))})}function ne(e={}){return{type:"reconcile_summary",applied:0,skipped:0,deferred:0,plan_only:0,failed:0,paused:0,stale_created:0,...e}}var ee=ne();async function U(e,t,r,n,i,p,f,d,y){W(i,t,r);let w=t.changeset.filter(h=>h.kind==="ARCHIVE"&&y?.[h.ref]===void 0),s=t.rows,u;try{u=K(e)}catch(h){return i({type:"error",message:h instanceof Error?h.message:String(h)}),i(ne()),2}try{return await Re(e,t,r,n,i,p,f,s,w,d)}finally{u()}}async function Re(e,t,r,n,i,p,f,d,y,w){let s=0,u=0,h=0,l=0,$=0,k=0,a=0,R=new Set,v=(c,o)=>{try{w?.(c,o)}catch{}};for(let[c,o]of d.entries()){i({type:"reconcile_row_start",kind:o.kind,ref:o.ref,...o.impact?{stale:o.impact.stale_refs.length,direct:o.impact.direct_refs?.length??0}:{}});let g=(m,D,S)=>i({type:"reconcile_row_end",kind:o.kind,ref:o.ref,outcome:m,...D!==void 0?{exit_code:D}:{},...S?{detail:S}:{}});if(o.applied){u++,g("skipped");continue}if(o.kind==="REMOVE"){$++,g("plan-only");continue}if(o.held_ref&&t.held){let m=new Set;if(o.kind==="MODIFY"&&o.impact){let S=x(e);for(let re of o.impact.stale_refs){let ie=S.resolve(re);ie&&S.stale(ie.tip)==="fresh"&&m.add(re)}}let D=G(e,t.held,o.held_ref,te);if(!D.ok){h++,a===0&&(a=1),g("failed",1,D.message);continue}if(D.kind==="ADD"){let S=await n(D.ref,{yes:!0,mode:f});if(S!==0){S===3?(l++,a===0&&(a=3),g("paused",3)):(h++,a===0&&(a=1),g("failed",S));continue}}s++,D.kind!=="ADD"&&o.impact&&(k+=m.size),v(c,"approved"),C(e,o.ref,D.kind==="ADD"?"gap-resolved-create":"gap-resolved-evolve"),g("applied");continue}let _=N(x(e),o.ref);if(!_.ok){u++,g("skipped");continue}let b=_.target;if(R.has(b.ucTip)){u++,g("skipped");continue}if(o.kind==="ADD"){let m=await n(b.seamRef,{yes:!0,mode:f});if(m===3){l++,a===0&&(a=3),g("paused",3);continue}if(m!==0){h++,a===0&&(a=1),g("failed",m);continue}R.add(b.ucTip),s++,v(c,"approved"),C(e,o.ref,"gap-resolved-create"),g("applied")}else{let m=await q(e,b,{yes:!0,mode:f},p,n,"batch");m.outcome==="evolved"?(R.add(b.ucTip),s++,v(c,"approved"),C(e,o.ref,"gap-resolved-evolve"),g("applied")):m.outcome==="paused"?(l++,a===0&&(a=m.code),g("paused",m.code)):m.outcome==="failed"?(h++,a===0&&(a=1),g("failed",m.code)):(u++,g("skipped"))}}return y.length>0&&(i({type:"reconcile_paused",plan_path:r,pending:y.map(c=>({ref:c.ref,why:c.why}))}),l+=y.length,a===0&&(a=3)),i(ne({applied:s,skipped:u,plan_only:$,failed:h,paused:l,stale_created:k})),a}var te={kind:"human",id:process.env.USER??"operator"};function C(e,t,r,n){ae(e,{ts:new Date().toISOString(),command:"reconcile-walk",id:t,verdict:r,polarity:"preference",by:te,target:t,...n!==void 0?{reason:n}:{}})}async function $e(e,t,r,n,i,p,f=[],d="override",y,w){let s=0,u=0,h=0,l=0,$=0,k=0,a=0,R=new Set;for(let[v,c]of t.entries()){if(c.applied){n.out(`skipped ${c.ref} \u2014 already applied (${c.applied.outcome} at ${c.applied.at})`),u++;continue}let o=m=>{try{p?.(v,m)}catch(D){P(n,`could not record applied state for ${c.ref}: ${D instanceof Error?D.message:String(D)}`)}};if(c.kind==="REMOVE"){n.out(`REMOVE ${c.ref} \u2014 plan-only in this release (not executed)`),l++;continue}if(c.held_ref&&y){let m=G(e,y,c.held_ref,te);if(!m.ok){P(n,`held ${c.ref}: ${m.message}`),$++,a===0&&(a=1);continue}if(n.out(`committed ${m.ref} (${c.kind==="ADD"?"minted":"updated \u2014 old\u2192new redirect"})`),m.kind==="ADD"){let D=await i(m.ref,{yes:r,mode:d});if(D===3){n.out(`design session for ${m.ref} paused \u2014 resume with "kane-cli design tests --resume"`),k++,a===0&&(a=3),o("approved");continue}if(D!==0){P(n,`design run for ${m.ref} ended with exit code ${D}`),$++,a===0&&(a=1),o("approved");continue}}s++,o("approved"),C(e,c.ref,c.kind==="ADD"?"gap-resolved-create":"gap-resolved-evolve");continue}let g=x(e),_=N(g,c.ref);if(!_.ok){n.out(`skipped ${c.ref} \u2014 ${_.message}`),u++;continue}let b=_.target;if(R.has(b.ucTip)){n.out(`skipped ${c.ref} \u2014 use-case ${b.display} already handled in this walk`),u++;continue}if(c.kind==="ADD"){let m=await i(b.seamRef,{yes:r,mode:d});if(m===3){n.out(`design session for ${b.display} paused \u2014 resume with "kane-cli design tests --resume"; this row lands when that session completes`),k++,a===0&&(a=3);continue}if(m!==0){P(n,`design run for ${b.display} ended with exit code ${m}`),$++,a===0&&(a=1);continue}R.add(b.ucTip),s++,o("approved"),C(e,c.ref,"gap-resolved-create")}else{let m=await q(e,b,{yes:!0,mode:d},n,i,"batch");m.outcome==="evolved"?(R.add(b.ucTip),s++,o("approved"),C(e,c.ref,"gap-resolved-evolve")):m.outcome==="paused"?(k++,a===0&&(a=m.code)):m.outcome==="failed"?($++,a===0&&(a=m.code)):u++}}for(let v of f)if(v.kind==="ARCHIVE"&&w?.[v.ref]===void 0){n.out(`[ARCHIVE] ${v.ref} \u2014 ${v.why}`);{let c=X(v.impact,"retiring drops");c&&n.out(` ${c}`)}n.out(" plan-only \u2014 retire belongs to the interactive session (never headless)"),l++}return n.out(`reconcile walk: ${s} applied, ${u} skipped, ${h} deferred, ${l} plan-only`+($>0?`, ${$} failed`:"")+(k>0?`, ${k} paused`:"")),a}async function me(e,t,r,n,i,p=!1){let f=i.seams??{reingest:J(e,r),reextract:Q(e,{stage:p})},d=null,y={reingest:f.reingest,reextract:async s=>d=await f.reextract(s)},w;try{n.out(`reconciling ${t}: re-reading the source and comparing against the graph\u2026`),w=await(i.buildPlan??Z)(e,t,y)}catch(s){return P(n,`reconcile failed: ${s instanceof Error?s.message:String(s)}`),null}return w.changed&&M(n,w,d),w}async function _e(e,t,r,n,i){let p=T(e,t);if("error"in p)return P(n,p.error),2;let{plan:f,path:d}=p,y=r==="override"||r==="ci";if(t===void 0&&r==="interactive"&&n.isTTY&&!await n.confirm(`apply plan ${j(d)} for ${f.source_id} (created ${f.created})?`))return n.out(`not applying ${j(d)}`),0;let w=i.runDesignForUc??z,s=i.runDesignForUc??null,u=i.sessionScript,h=(R,v)=>I(d,R,v),l=(R,v)=>V(d,R,v),$=F(e);if($===f.head_pin){if(r==="agent"){let v=i.emitEvent??(()=>{});return U(e,Y(f),d,w,v,n,E(r),h,f.archive_state)}let R=L(f);return r==="ci"&&R.length>0?(P(n,H(R.length)),2):(n.out(`applying stored plan ${j(d)} for ${f.source_id} (${f.rows.length} row(s))`),A(e,f.rows,y,n,w,h,f.changeset??[],E(r),f.held,f.archive_state,l,s,u))}if(n.out(`graph moved since this plan (${O(f.head_pin)} \u2192 ${O($)}) \u2014 recomputing`),f.held)return he(e,f,n,i,r,w,!1);let k=await me(e,f.source_id,f.backing_path,n,i);if(!k)return 1;if(!k.changed)return M(n,k,null),0;if(r==="agent"){let R=i.emitEvent??(()=>{});return U(e,k,null,w,R,n,E(r))}let a=k.changeset.filter(R=>R.kind==="ARCHIVE");return r==="ci"&&a.length>0?(P(n,H(a.length)),2):A(e,k.rows,y,n,w,void 0,k.changeset,E(r),k.held,void 0,void 0,s,u)}function Y(e,t=!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:t?e.rows.filter(r=>r.applied===void 0):e.rows,...e.held?{held:e.held}:{}}}async function Pe(e,t,r,n,i,p,f){let d=n.runDesignForUc??null,y=n.sessionScript,w=ce(e,t);if(w===null)return null;if("error"in w)return P(r,w.error),2;let{plan:s,path:u}=w,h=s.rows.filter(a=>a.applied===void 0),l=L(s),$=n.emitEvent??(()=>{});if(h.length===0&&l.length===0){r.out(`already reconciled \u2014 plan ${s.created} applied ${s.rows.length} row(s)`);let a=ue(x(e)).staleCount;return a>0&&r.out(`${a} item(s) still stale \u2014 kane-cli maintain evolve --from-stale`),i==="agent"&&(W($,Y(s),u),$({...ee})),0}let k=F(e);return k!==s.head_pin?(r.out(`plan ${s.created} superseded \u2014 graph moved (${O(s.head_pin)} \u2192 ${O(k)}); recomputing`),he(e,s,r,n,i,p,f)):(r.out(`resuming plan ${s.created} \u2014 ${h.length} pending row(s)${l.length>0?`, ${l.length} undecided archive item(s)`:""}`),f?(M(r,Y(s),null),r.out(`plan stored: ${u}`),0):i==="agent"?U(e,Y(s),u,p,$,r,E(i),(a,R)=>I(u,a,R),s.archive_state):i==="ci"&&l.length>0?(P(r,H(l.length)),2):A(e,s.rows,i==="override"||i==="ci",r,p,(a,R)=>I(u,a,R),s.changeset??[],E(i),s.held,s.archive_state,(a,R)=>V(u,a,R),d,y))}async function he(e,t,r,n,i,p,f){let d=n.runDesignForUc??null,y=n.sessionScript,w;if(t.held){let c=x(e),o=new Set(t.rows.filter(_=>_.held_ref!==void 0&&_.applied!==void 0).map(_=>_.held_ref)),g=[];for(let _ of t.held.rows){if(o.has(_.temp_ref))continue;if(!_.matched_cid){g.push(_);continue}let b=c.tipOf(_.matched_cid);if(c.superseded.get(b)===null){r.out(`dropped held "${_.title}" \u2014 its use-case was retired meanwhile`);continue}g.push(b===_.matched_cid?_:{..._,matched_cid:b,uc:{..._.uc,matches_existing:{cid:b}}})}w={source_id:t.held.source_id,rows:g}}let s=n.seams??{reingest:J(e,t.backing_path),reextract:Q(e,{stage:w!==void 0})},u;try{u=await(n.buildPlan??Z)(e,t.source_id,s,{resumeHeld:w})}catch(c){return P(r,`reconcile failed: ${c instanceof Error?c.message:String(c)}`),1}M(r,u,null);let h=F(e),l=null;if(h!=null){let c={},o=new Set(u.changeset.filter(g=>g.kind==="ARCHIVE").map(g=>g.ref));for(let[g,_]of Object.entries(t.archive_state??{}))o.has(g)&&(c[g]=_);l=B(e,{version:2,source_id:u.source_id,backing_path:t.backing_path,head_pin:h,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(c).length>0?{archive_state:c}:{}}),r.out(`plan stored: ${l}`)}if(f)return 0;let $=n.emitEvent??(()=>{}),k=l?T(e,l).plan.archive_state:void 0,a=l?(c,o)=>I(l,c,o):void 0,R=l?(c,o)=>V(l,c,o):void 0;if(i==="agent")return U(e,u,l,p,$,r,E(i),a,k);let v=u.changeset.filter(c=>c.kind==="ARCHIVE"&&k?.[c.ref]===void 0);return i==="ci"&&v.length>0?(P(r,H(v.length)),2):A(e,u.rows,i==="override"||i==="ci",r,p,a,u.changeset,E(i),u.held,k,R,d,y)}async function fe(e,t,r={},n=process.cwd()){let i=e.apply!==void 0&&e.apply!==!1,p=typeof e.apply=="string"?e.apply:void 0;if(e.plan&&i)return P(t,"pass --plan OR --apply, not both"),2;if((e.from!==void 0||!i)&&(!e.from||!e.sourceId))return P(t,"reconcile needs --from <file> AND --source-id <id> \u2014 see `kane-cli context list --type source` for ids"),2;if(e.from&&p!==void 0)return P(t,"pass --from OR --apply <path>, not both \u2014 a stored plan names its own source"),2;let d=le(n,t);if(!d)return 2;if(e.mode!==void 0&&!ge.has(e.mode))return P(t,`--mode must be interactive | agent | ci | override, got '${e.mode}'`),2;let y=e.mode==="agent"||e.mode==="ci"||e.mode==="override";if(i&&!y&&!t.isTTY)return P(t,"refusing to apply without a TTY to confirm \u2014 pass --mode override|ci"),2;let w=!e.plan,s="override";if(e.from){let o=ke(e,t.isTTY);if(typeof o=="object")return P(t,o.error),2;s=o}let u=s==="override"||s==="ci";if(i&&!e.from){let o=e.mode??"interactive";return _e(d,p===void 0?void 0:pe(n,p),o,t,r)}let h=ye(d,n,e.from,e.sourceId);if("error"in h)return P(t,h.error),2;let l=await me(d,h.sourceId,h.filePath,t,r,!!e.plan||s==="interactive");if(!l)return 1;let $=r.runDesignForUc??z,k=r.runDesignForUc??null,a=r.sessionScript;if(!l.changed){let o=await Pe(d,h.sourceId,t,r,s,$,!!e.plan);if(o!==null)return o;if(M(t,l,null),s==="agent"){let g=r.emitEvent??(()=>{});W(g,l,null),g({...ee})}return 0}let R=F(d),v=null;if(R!=null?v=B(d,{version:2,source_id:l.source_id,backing_path:h.filePath,head_pin:R,created:new Date().toISOString().replace(/[:.]/g,"-"),skipped_arms:l.skipped_arms,note:l.note,changeset:l.changeset,rows:l.rows,...l.held?{held:l.held}:{}}):P(t,"no chain head after extract \u2014 plan not stored"),s==="agent"){let o=r.emitEvent??(()=>{});if(!w)return W(o,l,v),o({...ee}),0;let g=v?(_,b)=>I(v,_,b):void 0;return U(d,l,v,$,o,t,E(s),g)}if(!w)return v&&t.out(`plan stored: ${v}`),0;let c=l.changeset.filter(o=>o.kind==="ARCHIVE");if(s==="ci"&&c.length>0)return v&&t.out(`plan stored: ${v}`),P(t,H(c.length)),2;if(v){t.out(`plan stored: ${v}`);let o=v;return A(d,be(d,o)??l.rows,u,t,$,(g,_)=>I(o,g,_),l.changeset,E(s),l.held,void 0,void 0,k,a)}return A(d,l.rows,u,t,$,void 0,l.changeset,E(s),l.held,void 0,void 0,k,a)}function be(e,t){let r=T(e,t);return"error"in r?null:r.plan.rows}async function Te(e,t={},r,n=process.cwd()){if(e.mode==="agent"){let{makeHeadlessIO:i}=await import("./headless-io-PWW6YKH2.js"),p=r?i("ndjson","reconcile",r):i("ndjson","reconcile"),f={out:p.out,err:y=>p.event({type:"error",message:y}),isTTY:!1,confirm:async()=>!1,ask:async()=>""},d=2;try{d=await fe(e,f,{...t,emitEvent:y=>p.event(y)},n)}catch(y){p.event({type:"error",message:y instanceof Error?y.message:String(y)})}return p.done(d)}return fe(e,de(),t,n)}export{E as childModeFor,Te as reconcileCommand,ke as resolveReconcileMode,fe as runReconcileCommand,ye as validateReconcileInputs};
|
package/dist/revert-AQQ2VHRM.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{d as _,g as k}from"./chunk-ZG2V2ODK.js";import"./chunk-5YPBPZUR.js";import"./chunk-UR6MHSHU.js";function j(w){let{contextDir:v,graph:y,seq:r,by:d}=w,{records:l,hashes:$}=_(v);if(!Number.isInteger(r)||r<1||r>l.length)return{record:null,warnings:[],errors:[{code:"UNKNOWN_SEQ",detail:`no record ${r} (chain has ${l.length})`}]};let i=l[r-1],p=l.slice(0,r-1),c=w.reason??`revert of record ${r}`,t=[],u=[],f=[],g=[],m={},b=new Set(i.nodes.map(e=>e.cid));for(let e of i.nodes){if(y.superseded.has(e.cid)){t.push(`${e.cid} was already superseded after record ${r} \u2014 left as is`);continue}u.push({kind:"node",old:e.cid,new:null,reason:c,by:d})}for(let e of i.supersessions){if(e.kind==="edge"){t.push(`edge retraction ${e.ecid} cannot be auto-restored \u2014 re-extract to re-evidence`);continue}if(l.slice(r).some(n=>n.supersessions.some(s=>s.kind==="node"&&s.old===e.old))){t.push(`supersession of ${e.old.slice(0,19)} was changed again after record ${r} \u2014 later state kept`);continue}let o;for(let n of p)for(let s of n.supersessions)s.kind==="node"&&s.old===e.old&&(o=s.new===s.old?void 0:s.new);o===void 0?u.push({kind:"node",old:e.old,new:e.old,reason:c,by:d}):u.push({kind:"node",old:e.old,new:o,reason:c,by:d})}let h=l.slice(r);for(let e of Object.keys(i.source_head_moves)){if(h.some(n=>e in n.source_head_moves)){t.push(`head of ${e} was moved again after record ${r} \u2014 later state kept`);continue}let o=null;for(let n of p)e in n.source_head_moves&&(o=n.source_head_moves[e]);m[e]=o}let R=new Set;for(let e of i.review){if(R.has(e.id)||b.has(e.id))continue;if(R.add(e.id),h.some(s=>s.review.some(a=>a.id===e.id))){t.push(`trust of ${e.id.slice(0,19)} was reviewed again after record ${r} \u2014 later state kept`);continue}let o=null,n=null;for(let s of p)for(let a of s.review)a.id===e.id&&(o=a.resolution==="reset"?null:a.resolution,n=a.reason);o==="approved"||o==="edited"?f.push({id:e.id,kind:"review-item",resolution:"approved",edit:null,reason:c,by:d}):o==="rejected"?f.push({id:e.id,kind:"review-item",resolution:"rejected",edit:null,reason:n??c,by:d}):f.push({id:e.id,kind:"review-item",resolution:"reset",edit:null,reason:c,by:d})}for(let e of i.names??[]){if(h.some(n=>(n.names??[]).some(s=>s.slug===e.slug))){t.push(`slug "${e.slug}" was reassigned after record ${r} \u2014 later state kept`);continue}let o;for(let n of p)for(let s of n.names??[])s.slug===e.slug&&(o=s.cid);o!==void 0?g.push({cid:o,slug:e.slug,by:d}):t.push(`slug "${e.slug}" was first assigned by record ${r} \u2014 unassignment unsupported, reassign manually`)}return u.length===0&&f.length===0&&g.length===0&&Object.keys(m).length===0?{record:null,warnings:t,errors:[{code:"NOTHING_TO_REVERT",detail:`record ${r} left no compensable facts`}]}:(i.extraction_of&&t.push(`extraction cache for ${i.extraction_of.slice(0,19)} stays \u2014 re-extract with --force`),{record:k(v,{ts:new Date().toISOString(),proposal_id:null,nodes:[],edges:[],review:f,supersessions:u,...g.length>0?{names:g}:{},source_head_moves:m},{expectPrev:$[$.length-1]??null}).record,warnings:t,errors:null})}export{j as commitRevert};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{b as j}from"./chunk-GRB66C5S.js";import{g as b}from"./chunk-WIA7TPK3.js";import"./chunk-QPZRHAYK.js";import"./chunk-RN4OSVTG.js";import"./chunk-BC7UVJJB.js";import{a as _}from"./chunk-MCQXRJGH.js";import"./chunk-74RUSHIB.js";import"./chunk-ZZLR3O5A.js";import{d as V}from"./chunk-ZG2V2ODK.js";import"./chunk-5YPBPZUR.js";import"./chunk-UR6MHSHU.js";import{readFileSync as E}from"fs";var O=new Set(["derived","skipped","archived","drift"]),q={kind:"human",id:process.env.USER??"operator"};function R(d,r){return d.nameOf.get(r)??r.slice(0,19)}function N(d,r){let n=d.getNode(r)?.content??{},a=d.derivesInto(r)[0]?.props.anchor;return{cid:r,uc:{temp_ref:r,title:String(n.title??n.text??""),summary:n.summary!==void 0?String(n.summary):void 0,risk:String(n.risk??"med"),cite:{anchor:typeof a=="string"?a:"\u2014",quote:""},depends_on_hint:[],matches_existing:null}}}function T(d,r){let n=new Set,{records:a}=V(d);for(let s of a){if(s.proposal_id==null)continue;let u=new Set(s.review.map(e=>e.id));for(let e of s.nodes)u.has(e.cid)||n.add(e.cid)}for(let s of[...n])(r.trust.get(s)!=="derived"||r.superseded.has(s))&&n.delete(s);return n}var x=new Set(["approved","edited","rejected","skipped","supersede"]);function C(d){let r;try{r=JSON.parse(d)}catch(s){return{errors:[`not valid JSON: ${s instanceof Error?s.message:String(s)}`]}}if(!Array.isArray(r))return{errors:['expected a top-level array of {"ref", "resolution", ...} entries']};let n=[],a=[];return r.forEach((s,u)=>{if(s==null||typeof s!="object"||Array.isArray(s)){n.push(`[${u}]: not an object`);return}let e=s;(typeof e.ref!="string"||!e.ref.trim())&&n.push(`[${u}]: "ref" (slug or cid) is required`),(typeof e.resolution!="string"||!x.has(e.resolution))&&n.push(`[${u}]: "resolution" must be one of approved | edited | rejected | skipped | supersede`),e.resolution==="supersede"&&(typeof e.supersede_target!="string"||!e.supersede_target.trim())&&n.push(`[${u}]: resolution "supersede" requires "supersede_target" (slug or cid)`),e.edit!==void 0&&(e.edit==null||typeof e.edit!="object"||Array.isArray(e.edit))&&n.push(`[${u}]: "edit" must be an object ({title?, summary?, risk?})`),n.length===0&&a.push(e)}),n.length>0?{errors:n}:{entries:a}}async function I(d,r,n,a=process.cwd()){let s=d.queue??"derived";if(!O.has(s))return r.out(`unknown queue ${s} \u2014 one of: derived | skipped | archived | drift`),2;let u=j(a,r);if(!u)return 2;let e=_(u);if(d.verdicts){let i=t=>(r.err??r.out)(t),o;try{o=E(d.verdicts,"utf8")}catch{return i(`error: cannot read verdicts file ${d.verdicts}`),2}let l=C(o);if("errors"in l){for(let t of l.errors)i(`error: --verdicts ${d.verdicts}: ${t}`);return 2}let c=new Set([...e.trust.entries()].filter(([t,p])=>(p==="derived"||p==="archived")&&!e.superseded.has(t)).map(([t])=>t)),f=new Map,y=[];for(let t of l.entries){let p=e.resolve(t.ref),m=p&&!e.superseded.has(p.tip)?p.tip:null;if(!m){y.push(`${t.ref}: names nothing in the graph`);continue}if(!c.has(m)){y.push(`${t.ref}: not in a review queue (trust: ${e.trust.get(m)??"?"})`);continue}if(f.has(m)){y.push(`${t.ref}: duplicate \u2014 an earlier entry already resolves to this node (${R(e,m)})`);continue}f.set(m,{resolution:t.resolution,...t.reason?{reason:t.reason}:{},...t.edit?{edit:t.edit}:{},...t.supersede_target?{supersedeTarget:t.supersede_target}:{}})}if(y.length>0){for(let t of y)i(`error: --verdicts: ${t}`);return i("error: nothing committed (the verdicts file is atomic \u2014 fix every offender and re-run)"),2}let k=b({contextDir:u,graph:e,verdicts:f,by:q});if(k.errors){if(k.errors[0]?.code==="NO_VERDICTS")return i("nothing changed \u2014 every item was skipped"),0;for(let t of k.errors)i(`${t.code}: ${t.detail}`);return 1}let S=new Map;for(let t of f.values())S.set(t.resolution,(S.get(t.resolution)??0)+1);if(d.json)for(let[t,p]of f.entries())r.out(JSON.stringify({ref:R(e,t),cid:t,resolution:p.resolution}));else{let t=[...S.entries()].map(([p,m])=>`${m} ${p}`).join(", ");r.out(`review: committed record ${k.record.seq} \u2014 ${t}`)}return 0}if(s==="drift"){let i=e.staleList().filter(({state:o})=>o!=="superseded").map(({cid:o,state:l})=>({ref:R(e,o),cid:o,state:l,title:String(e.getNode(o)?.content.title??e.getNode(o)?.content.source_id??""),pinned_sources:[...new Set(e.derivesInto(o).map(c=>String(c.props.source_id)))]}));if(d.json){for(let o of i)r.out(JSON.stringify(o));return 0}if(i.length===0)return r.out("drift queue is empty \u2014 every node's evidence matches the current source snapshots"),0;r.out(`${i.length} node(s) with drifting evidence (re-extract the source to re-bless):`);for(let o of i)r.out(` [${o.state}] ${o.ref} \xB7 ${o.title} \xB7 sources: ${o.pinned_sources.join(", ")||"\u2014"}`);return 0}if(!r.isTTY)return r.out("review: verdict queues need a TTY (drift listing works anywhere, or pass --verdicts <file.json>)"),2;let g,h;if(s==="archived")g=[...e.trust.entries()].filter(([i,o])=>o==="archived"&&!e.superseded.has(i)).map(([i])=>N(e,i)),h="skipped";else{let i=T(u,e),o=[...e.trust.entries()].filter(([c,f])=>f==="derived"&&!e.superseded.has(c)).map(([c])=>c),l=s==="skipped"?o.filter(c=>i.has(c)):o;l.sort((c,f)=>Number(i.has(f))-Number(i.has(c))),g=l.map(c=>N(e,c)),h="skipped"}if(g.length===0)return r.out(`${s} queue is empty`),0;r.out(`${g.length} node(s) in the ${s} queue \u2014 approve promotes, reject ${s==="archived"?"re-archives":"archives"}, edit mints a new version, skip leaves it for later`);let v=await n(g,e,h),w=b({contextDir:u,graph:e,verdicts:v,by:q});if(w.errors){if(w.errors[0]?.code==="NO_VERDICTS")return r.out("nothing changed \u2014 every item was skipped"),0;for(let i of w.errors)r.out(`${i.code}: ${i.detail}`);return 1}let $=w.record;return r.out(`committed record ${$.seq}: ${$.review.length} review fact(s), ${$.supersessions.length} supersession(s), ${$.nodes.length} new version(s)`),0}async function P(d,r,n){let[{render:a},s,{ReviewChecklist:u}]=await Promise.all([import("./build-JIKYOZUH.js"),import("./react-QWOAB3TB.js"),import("./ui-JEJGTURD.js")]),e=s.default??s;return new Promise(g=>{let h=a(e.createElement(u,{items:d.map(v=>({uc:v.uc})),defaultResolution:n,onSubmit:v=>{h.unmount(),g(v)}}))})}async function D(d){let{bothTTY:r}=await import("./headless-io-PWW6YKH2.js");return I(d,{out:n=>process.stdout.write(n+`
|
|
3
|
-
`),err:n=>process.stderr.write(n+`
|
|
4
|
-
`),confirm:async()=>!1,isTTY:r()},P)}export{C as parseVerdictsFile,D as reviewCommand,I as runReviewCommand};
|
package/dist/run-RT2VMPTQ.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as b,b as c,c as d,d as e,e as f}from"./chunk-ACEODVSC.js";import"./chunk-K5JGCJ2K.js";import{f as a}from"./chunk-DXK55KGR.js";import"./chunk-FXPPQL4D.js";import"./chunk-RE3BZVGE.js";import"./chunk-6PS65QFF.js";import"./chunk-JFAFKHDX.js";import"./chunk-WIA7TPK3.js";import"./chunk-QPZRHAYK.js";import"./chunk-6GTOYTCQ.js";import"./chunk-YKTYVJBN.js";import"./chunk-6AYUSR7X.js";import"./chunk-427OQS2N.js";import"./chunk-2PQXEEVY.js";import"./chunk-MCQXRJGH.js";import"./chunk-74RUSHIB.js";import"./chunk-ZZLR3O5A.js";import"./chunk-ZG2V2ODK.js";import"./chunk-5YPBPZUR.js";import"./chunk-HJGUEZLW.js";import"./chunk-UR6MHSHU.js";export{e as dedupPreFlags,c as displaySourceName,a as resolveAnswers,f as runExtract,b as sessionSourceRef,d as sourceBanner};
|
package/dist/run-XAZMT7WO.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a}from"./chunk-BNN6ZDJW.js";import"./chunk-KHU7C6EE.js";import"./chunk-3C5GMAM4.js";import"./chunk-DXK55KGR.js";import"./chunk-FXPPQL4D.js";import"./chunk-RE3BZVGE.js";import"./chunk-6PS65QFF.js";import"./chunk-JFAFKHDX.js";import"./chunk-WIA7TPK3.js";import"./chunk-QPZRHAYK.js";import"./chunk-6GTOYTCQ.js";import"./chunk-YKTYVJBN.js";import"./chunk-6AYUSR7X.js";import"./chunk-427OQS2N.js";import"./chunk-FJTWJ243.js";import"./chunk-2PQXEEVY.js";import"./chunk-L5LI2JF4.js";import"./chunk-MCQXRJGH.js";import"./chunk-74RUSHIB.js";import"./chunk-ZZLR3O5A.js";import"./chunk-ZG2V2ODK.js";import"./chunk-5YPBPZUR.js";import"./chunk-HJGUEZLW.js";import"./chunk-UR6MHSHU.js";export{a as runDesign};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{d as a}from"./chunk-IOTJZTHX.js";import"./chunk-WT3SMSY5.js";import"./chunk-HNE4TDOZ.js";import"./chunk-3MSXQU2C.js";import"./chunk-O66EU5UV.js";import"./chunk-YI4XULHR.js";import"./chunk-IJPFAWBH.js";import"./chunk-CLTANA4L.js";import"./chunk-PYB2EXRE.js";import"./chunk-BYUARJE7.js";import"./chunk-2YQ6TW77.js";import"./chunk-WE57PD6K.js";import"./chunk-RHNKYNNZ.js";import"./chunk-RKWJG3WW.js";import"./chunk-3HEPW6SN.js";import"./chunk-OB6CKLEL.js";import"./chunk-I2JUBAPU.js";import"./chunk-MK2G7VIF.js";import"./chunk-ADOXYGZE.js";import"./chunk-E3BO7OVR.js";import"./chunk-W36P7S5W.js";import"./chunk-UZSG54OY.js";import"./chunk-2K4XOHVK.js";import"./chunk-5Y2G4NC7.js";import"./chunk-ZQP3MCZW.js";import"./chunk-WFEGGQJ4.js";import"./chunk-C5UNZ6ZY.js";import"./chunk-S3DAAAE5.js";import"./chunk-MVF4KRHA.js";import"./chunk-5CTMOJG4.js";import"./chunk-4MUHS3UL.js";import"./chunk-FPFOW6BS.js";import"./chunk-WAOCHXJ5.js";import"./chunk-AXABTFCD.js";import"./chunk-RFHMDQXZ.js";import"./chunk-QNNBNIR7.js";import"./chunk-CJJXT5DO.js";import"./chunk-FJTWJ243.js";import"./chunk-BC7UVJJB.js";import"./chunk-2PQXEEVY.js";import"./chunk-EHN5HTUD.js";import"./chunk-L5LI2JF4.js";import"./chunk-MCQXRJGH.js";import"./chunk-74RUSHIB.js";import"./chunk-ZZLR3O5A.js";import"./chunk-ZG2V2ODK.js";import"./chunk-5YPBPZUR.js";import"./chunk-3WJJ43MT.js";import"./chunk-YMSN25DX.js";import"./chunk-STH6I3UB.js";import"./chunk-YCCUBQY4.js";import"./chunk-PICCLJSO.js";import"./chunk-M5JQXOCE.js";import"./chunk-64QURIT6.js";import"./chunk-2WVKOZ6W.js";import"./chunk-NLCCBXXV.js";import"./chunk-RZ4F3BHX.js";import"./chunk-DNOBOZPO.js";import"./chunk-VE3SUJMA.js";import"./chunk-E47GFYXA.js";import"./chunk-BOO7YXAV.js";import"./chunk-POI6DCP6.js";import"./chunk-IRRGSC7B.js";import{a as o}from"./chunk-DFS4RMVP.js";import"./chunk-IXVR66NS.js";import"./chunk-XUJ5EPVW.js";import"./chunk-HJGUEZLW.js";import{a as t}from"./chunk-HCBYKLMW.js";import{c as n}from"./chunk-C44QQJR4.js";import"./chunk-6YGTRKDT.js";import{e as r}from"./chunk-UR6MHSHU.js";var e=r(t(),1);async function p(i){let c=i.scenarioLimit!==void 0||i.perScenarioLimit!==void 0?{scenarioLimit:i.scenarioLimit,perScenarioLimit:i.perScenarioLimit}:void 0,{waitUntilExit:m}=n((0,e.jsx)(o,{children:(0,e.jsx)(a,{initialChatMode:"generate",initialObjective:i.objective,initialGenerateLimits:c})}),{exitOnCtrlC:!1});await m()}export{p as runGenerate};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a}from"./chunk-MVF4KRHA.js";import"./chunk-4MUHS3UL.js";import"./chunk-RZ4F3BHX.js";import"./chunk-DNOBOZPO.js";import"./chunk-HJGUEZLW.js";import"./chunk-UR6MHSHU.js";export{a as refreshOAuthToken};
|