@testmuai/kane-cli 0.8.5 → 0.8.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{ChatSurface-HAIVTS4J.js → ChatSurface-S2P7WMBI.js} +1 -1
- package/dist/{ChromeProfilePicker-5ILSVC2K.js → ChromeProfilePicker-7DTJK2QW.js} +1 -1
- package/dist/{CliFeedbackPrompt-LFKEYMKP.js → CliFeedbackPrompt-Y3OYZX54.js} +1 -1
- package/dist/{CliUploadProgress-Y7ITY2I7.js → CliUploadProgress-I3N5WDNJ.js} +1 -1
- package/dist/{ConfigView-OECNNCXC.js → ConfigView-EOYCKYJS.js} +1 -1
- package/dist/{EvidenceViewOffer-FODRAS6Z.js → EvidenceViewOffer-AQ3KB3EN.js} +1 -1
- package/dist/FolderPicker-RCHRYYC4.js +2 -0
- package/dist/{InfoBox-HWMHNWPM.js → InfoBox-QBXPPMM2.js} +1 -1
- package/dist/{LinksBox-TAGYCFFO.js → LinksBox-L24KON4U.js} +1 -1
- package/dist/{ProfilesView-QJBR3RCM.js → ProfilesView-H6XCTIXI.js} +1 -1
- package/dist/{ProjectPicker-PP75ILZU.js → ProjectPicker-F6JGF2B3.js} +1 -1
- package/dist/{SaveSessionPrompt-UCRET3II.js → SaveSessionPrompt-QGO65DZN.js} +1 -1
- package/dist/SingleShotApp-AY3XFEYT.js +2 -0
- package/dist/{SummaryBox-SLM3OFS2.js → SummaryBox-OZIZQY4B.js} +1 -1
- package/dist/TestMdRunView-RPW4MIJA.js +2 -0
- package/dist/{TestrunEvidenceTable-PTIBYAXO.js → TestrunEvidenceTable-A7WTTKTV.js} +1 -1
- package/dist/{WhoamiView-WPHMNYUV.js → WhoamiView-EB5AV27X.js} +1 -1
- package/dist/{app-download-GYQYLGT3.js → app-download-SQ4RDY3E.js} +1 -1
- package/dist/{auth-3DLNMZC2.js → auth-TW24FZQF.js} +1 -1
- package/dist/{binary-XJ3RF3VO.js → binary-5LMQJ3CZ.js} +1 -1
- package/dist/{bind-2N4Q6YKH.js → bind-SJ6DOVQ4.js} +2 -2
- package/dist/{bootstrap-5IHKW5SE.js → bootstrap-BTEXO6HX.js} +1 -1
- package/dist/bridge-GQJ35GTL.js +2 -0
- package/dist/{changelog-WCCTI47M.js → changelog-JLSLSA3Y.js} +1 -1
- package/dist/chunk-2DCNCH32.js +4 -0
- package/dist/{chunk-PEI2566X.js → chunk-2R7KL7YG.js} +1 -1
- package/dist/{chunk-T3XDMR5B.js → chunk-3LEVCW6R.js} +1 -1
- package/dist/{chunk-NLECZCMZ.js → chunk-3UUPP5W3.js} +1 -1
- package/dist/{chunk-PCOSE5SW.js → chunk-4NSP2NPT.js} +1 -1
- package/dist/{chunk-FTZPWXF7.js → chunk-4ONGF4NT.js} +1 -1
- package/dist/{chunk-ZFZ7YXEU.js → chunk-5COGCNED.js} +1 -1
- package/dist/{chunk-DCUT3GJA.js → chunk-7VZCXW74.js} +1 -1
- package/dist/{chunk-CGYSFLM2.js → chunk-A44G533S.js} +1 -1
- package/dist/{chunk-ZIRMSWKS.js → chunk-AO3PBE2V.js} +1 -1
- package/dist/{chunk-AJPLHW4T.js → chunk-ATWDQCDA.js} +1 -1
- package/dist/{chunk-UX3KPYTI.js → chunk-AWD56KGX.js} +1 -1
- package/dist/{chunk-YFLKS4UV.js → chunk-B4Q6FMIP.js} +3 -3
- package/dist/chunk-B5QGIUJA.js +26 -0
- package/dist/chunk-BN6AHQL7.js +17 -0
- package/dist/chunk-BRTARADN.js +4 -0
- package/dist/{chunk-BAL7E4OH.js → chunk-C4WTZSX4.js} +1 -1
- package/dist/{chunk-TCK3QMKY.js → chunk-CLLQQPBZ.js} +1 -1
- package/dist/{chunk-LA2EMSHE.js → chunk-CZUOGGUK.js} +1 -1
- package/dist/{chunk-FRSHEJUS.js → chunk-D4SRHIJ5.js} +1 -1
- package/dist/{chunk-Z2T7E5HM.js → chunk-DN3E6RT6.js} +2 -2
- package/dist/{chunk-PUFJEU46.js → chunk-DZCG7FFP.js} +1 -1
- package/dist/{chunk-CNNJ4U2L.js → chunk-E5S4BASB.js} +1 -1
- package/dist/{chunk-HQWLSA5M.js → chunk-ESC7AOCX.js} +1 -1
- package/dist/{chunk-W27F2NWA.js → chunk-EXERQHXV.js} +1 -1
- package/dist/{chunk-PWYEOBXV.js → chunk-FJYDEWOA.js} +1 -1
- package/dist/{chunk-35EUIBYJ.js → chunk-FMUCZWS3.js} +1 -1
- package/dist/{chunk-PB3GADUD.js → chunk-FUNKVREV.js} +1 -1
- package/dist/{chunk-GZ4X53ZA.js → chunk-FYS5VIOG.js} +2 -2
- package/dist/{chunk-HFCDUFV3.js → chunk-GC5U55MW.js} +1 -1
- package/dist/{chunk-RY6TFVAX.js → chunk-GELPKSLC.js} +1 -1
- package/dist/{chunk-5S46D5AJ.js → chunk-IGJIDN4U.js} +1 -1
- package/dist/{chunk-K2QV7FGP.js → chunk-INK66XQS.js} +1 -1
- package/dist/{chunk-EFRJNPBZ.js → chunk-IWM5EZC3.js} +2 -2
- package/dist/chunk-JCD6FP7A.js +5 -0
- package/dist/{chunk-M335FQYJ.js → chunk-JN44V63O.js} +2 -2
- package/dist/{chunk-GYF4CH62.js → chunk-KDXQNLVV.js} +2 -2
- package/dist/{chunk-O3AY6JHJ.js → chunk-KLTKEGDH.js} +1 -1
- package/dist/{chunk-MJ56GUKS.js → chunk-KQ2MYMOS.js} +1 -1
- package/dist/chunk-LN7233E2.js +20 -0
- package/dist/{chunk-KWKUMBHS.js → chunk-MKSTP2XN.js} +2 -2
- package/dist/{chunk-NHOHQBIF.js → chunk-NT3UETTV.js} +1 -1
- package/dist/{chunk-CCUGKBIH.js → chunk-OFW3ZVTP.js} +1 -1
- package/dist/{chunk-WLOGO44E.js → chunk-OYJBABRV.js} +1 -1
- package/dist/{chunk-JJWQUQJ2.js → chunk-P3RKXL3V.js} +1 -1
- package/dist/{chunk-MUGMUKSZ.js → chunk-PT7V5WDQ.js} +1 -1
- package/dist/chunk-Q4V2GK5U.js +2 -0
- package/dist/{chunk-3AJ3QSF5.js → chunk-QBG7XEGQ.js} +2 -2
- package/dist/{chunk-E3BXNQYE.js → chunk-QISE272H.js} +1 -1
- package/dist/{chunk-G4AFOZKU.js → chunk-QQAAPFIR.js} +1 -1
- package/dist/{chunk-PQUMOFT5.js → chunk-RDNKYRKY.js} +1 -1
- package/dist/{chunk-5NSYHRDN.js → chunk-RX5TZZNQ.js} +1 -1
- package/dist/{chunk-TJZMYU2W.js → chunk-RZLD7TPG.js} +1 -1
- package/dist/{chunk-66BSTNLD.js → chunk-S66MCU2Y.js} +1 -1
- package/dist/{chunk-WYST42WI.js → chunk-SORVX3KI.js} +1 -1
- package/dist/{chunk-KX2GOJ4C.js → chunk-SQC4P2Q7.js} +1 -1
- package/dist/{chunk-JRQKUQWL.js → chunk-SQGBFCFO.js} +1 -1
- package/dist/{chunk-T5LKD2OB.js → chunk-SS5TOK2J.js} +1 -1
- package/dist/{chunk-DJ7T7BMV.js → chunk-TDS6LG6T.js} +1 -1
- package/dist/{chunk-7JUUNZQP.js → chunk-TKYJTXWL.js} +1 -1
- package/dist/{chunk-JN2DP4R2.js → chunk-TQKIE7AX.js} +1 -1
- package/dist/{chunk-K7UYWAZH.js → chunk-TZFT7R7B.js} +1 -1
- package/dist/{chunk-AMULIFC5.js → chunk-USI2WMAK.js} +1 -1
- package/dist/{chunk-NYSMQ7UY.js → chunk-VMCSRLRC.js} +1 -1
- package/dist/{chunk-7PADFQ5S.js → chunk-VOBXYDJW.js} +2 -2
- package/dist/{chunk-R7OGNE3W.js → chunk-WMQJBEQP.js} +1 -1
- package/dist/{chunk-OWTEHU6B.js → chunk-XJILZ2WN.js} +1 -1
- package/dist/{chunk-2K2BX23I.js → chunk-XQFITNA3.js} +1 -1
- package/dist/{chunk-4D3DNCQY.js → chunk-XY325HDJ.js} +1 -1
- package/dist/{chunk-Q6JHBDW2.js → chunk-YEQVJWEF.js} +1 -1
- package/dist/{chunk-6BTZ2Q4P.js → chunk-YHTYPTDD.js} +1 -1
- package/dist/{chunk-2WSOPZJU.js → chunk-YZ45OEH3.js} +1 -1
- package/dist/{chunk-BJHII5SD.js → chunk-Z35BUPZT.js} +1 -1
- package/dist/{chunk-4UMQDH52.js → chunk-ZLSWHCWO.js} +1 -1
- package/dist/{chunk-FDWEL5HR.js → chunk-ZRKPZLLG.js} +1 -1
- package/dist/{config-OKTAPFOT.js → config-6TQIMTNB.js} +1 -1
- package/dist/{credentials-SO3DSQEM.js → credentials-ZSNM4BTD.js} +1 -1
- package/dist/{deps-bundle-FRM65BQO.js → deps-bundle-D2ZC2SPT.js} +1 -1
- package/dist/{deps-resolve-RPZORKUN.js → deps-resolve-VRBMFUTX.js} +1 -1
- package/dist/{dispatch-OZRMWY25.js → dispatch-2PBSJ7YW.js} +1 -1
- package/dist/doctor-OWRRDA4Z.js +2 -0
- package/dist/{evidence-5AUZMKE3.js → evidence-NDAKCCHQ.js} +1 -1
- package/dist/{evolve-cmd-TWYJL4EG.js → evolve-cmd-DIA5EWUT.js} +1 -1
- package/dist/{extract-bind-EW7XUDLQ.js → extract-bind-TJ2STXV5.js} +2 -2
- package/dist/{extract-cmd-HOVGMBGM.js → extract-cmd-FLOYO6HL.js} +1 -1
- package/dist/{generate-headless-FYTJULPG.js → generate-headless-DBT4MKQT.js} +2 -2
- package/dist/index.js +69 -69
- package/dist/{ingest-4447MYLF.js → ingest-JO5NJENZ.js} +1 -1
- package/dist/{ingest-cmd-RJLTFNMN.js → ingest-cmd-T6HM3AHK.js} +1 -1
- package/dist/install-NIVU4XVS.js +2 -0
- package/dist/{interactive-bind-PSEYAL54.js → interactive-bind-7UDJY4CF.js} +3 -3
- package/dist/{list-commands-2SVSEAP6.js → list-commands-DA4ZXOPJ.js} +1 -1
- package/dist/login-flow-NHBJVDW6.js +2 -0
- package/dist/{mobile-prompts-T6HZ2YLY.js → mobile-prompts-JS7GPVKS.js} +1 -1
- package/dist/{persist-recorded-session-O2NCYTSD.js → persist-recorded-session-LE3LGFOS.js} +1 -1
- package/dist/pipeline-MTAZDCZR.js +2 -0
- package/dist/prepare-target-YK2DLDWB.js +2 -0
- package/dist/{reconcile-cmd-FU3JIHTO.js → reconcile-cmd-CYRYVS5B.js} +1 -1
- package/dist/{reconcile-deps-SUKZA2FL.js → reconcile-deps-FYXRAMF2.js} +2 -2
- package/dist/{reconcile-engine-ILL4M3NW.js → reconcile-engine-6AT6EVGS.js} +1 -1
- package/dist/{recording-banner-5VXVKCV4.js → recording-banner-YMKWR3M3.js} +1 -1
- package/dist/{registry-BKV3EDTK.js → registry-V45ZQ6Q5.js} +1 -1
- package/dist/{require-project-folder-2IO6IX5W.js → require-project-folder-3KS7KTME.js} +1 -1
- package/dist/resolve-run-intent-W32G6WM6.js +2 -0
- package/dist/{resolver-CBTWTZZR.js → resolver-V5VP5FLT.js} +1 -1
- package/dist/{run-EXIYK6PU.js → run-26IR3CKX.js} +1 -1
- package/dist/{run-R7GND73C.js → run-5IYI2TJI.js} +1 -1
- package/dist/{run-test-md-664ASWRQ.js → run-test-md-FO2RNNOD.js} +2 -2
- package/dist/{skill-installer-QLQK4JJE.js → skill-installer-W4TT5MST.js} +1 -1
- package/dist/{spawner-ANLF7OX3.js → spawner-ZSYJQGQW.js} +1 -1
- package/dist/tcg-generate-ONLV5GXG.js +2 -0
- package/dist/{testmd-actions-QZD3N4EH.js → testmd-actions-NPILETCQ.js} +1 -1
- package/dist/token-refresh-G2CSTY4B.js +2 -0
- package/dist/{types-VYEOJ6U2.js → types-O23GN2YM.js} +1 -1
- package/dist/{validate-basic-D7IJUFUQ.js → validate-basic-727KRHX6.js} +1 -1
- package/dist/{verdicts-EO5TZ5BW.js → verdicts-TDJLJJ3F.js} +1 -1
- package/dist/{version-check-JRLPWQ6T.js → version-check-A2JQYRI2.js} +1 -1
- package/dist/{walk-session-IODOH7QU.js → walk-session-HB3OOWVR.js} +1 -1
- package/dist/{with-telemetry-ASNQQBGP.js → with-telemetry-HSD6CXDS.js} +1 -1
- package/package.json +11 -11
- package/dist/FolderPicker-5U3RHHBE.js +0 -2
- package/dist/SingleShotApp-XWOPGLKZ.js +0 -2
- package/dist/TestMdRunView-6BY3IUH5.js +0 -2
- package/dist/bridge-LOBTHY3P.js +0 -2
- package/dist/chunk-6DTWVLSJ.js +0 -4
- package/dist/chunk-BG66IAO6.js +0 -19
- package/dist/chunk-BVKDHHPK.js +0 -5
- package/dist/chunk-KBMQGNKO.js +0 -26
- package/dist/chunk-UOMRMCMI.js +0 -2
- package/dist/chunk-VT2XNEOD.js +0 -10
- package/dist/chunk-X2FM67OM.js +0 -4
- package/dist/doctor-VWGEQYBB.js +0 -2
- package/dist/install-46S4VOZ4.js +0 -2
- package/dist/login-flow-U43QVFPH.js +0 -2
- package/dist/pipeline-BHEA7ODT.js +0 -2
- package/dist/prepare-target-27UN4KNO.js +0 -2
- package/dist/resolve-run-intent-ZML3HKG7.js +0 -2
- package/dist/tcg-generate-VBC5ODDI.js +0 -2
- package/dist/token-refresh-PIUX5OFA.js +0 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as ke}from"./chunk-
|
|
2
|
+
import{a as ke}from"./chunk-IWM5EZC3.js";import{b as he,c as _e,d as Z,e as ee}from"./chunk-EXERQHXV.js";import{d as ye,e as we}from"./chunk-AXTPNZPX.js";import{d as P}from"./chunk-JFAFKHDX.js";import{a as pe}from"./chunk-AWD56KGX.js";import{a as L}from"./chunk-DNNZ353O.js";import{A as I,z as me}from"./chunk-TH47OOBV.js";import{b as ge}from"./chunk-VAYBKR76.js";import{a as ue}from"./chunk-CUM23TLF.js";import{d as de,i as fe}from"./chunk-DUAXZYAD.js";import{d as ae,f as le}from"./chunk-WXHQYYD5.js";function bt(t){let e=process.env.HOME??"";return e&&t.startsWith(e)?`~${t.slice(e.length)}`:t}import{randomBytes as mt}from"crypto";function te(t,e){let n=Math.min(t.length,e.length),o=0,r=0,c=0;for(let s=0;s<n;s++)o+=t[s]*e[s],r+=t[s]*t[s],c+=e[s]*e[s];return r===0||c===0?0:o/(Math.sqrt(r)*Math.sqrt(c))}function ne(t,e,n){return n*t+(1-n)*e}var re=.7;var ze=["get_node","get_edges","find_by_provenance","match_by_type","stale_nodes","search_similar","search_similar_batch","history"],Qe=["source_read","source_grep","source_list"],Ke=[...ze,...Qe],Se=50,Ee=200,se=10,Re=50,be=20,We=200,Xe=50;function U(t,e,n){let o=typeof t=="number"&&Number.isFinite(t)?Math.floor(t):e;return Math.max(1,Math.min(o,n))}function M(t,e){let n=t[e];if(typeof n!="string"||n.length===0)throw new b(`param "${e}" must be a non-empty string`);return n}function D(t,e){let n=t[e];if(n==null)return null;if(typeof n!="string")throw new b(`param "${e}" must be a string when present`);return n}var b=class extends Error{},xe=24,qe=10,Ye=10;function Je(t){let e=t.cursor;if(e==null)return 0;if(typeof e=="string"&&/^\d+$/.test(e))return Number.parseInt(e,10);throw new b(`BAD_CURSOR: cursor ${JSON.stringify(e)} is not a cursor this store minted`)}function Ae(t,e){let n=e.fields;if(!Array.isArray(n)||n.length===0)return t;let o=new Set(n.filter(r=>typeof r=="string"));return t.map(r=>Object.fromEntries(Object.entries(r).filter(([c])=>o.has(c))))}function oe(t,e,n=Se,o=Ee){let r=Je(e),c=U(e.limit,n,o),s=t.slice(r,r+c),d=r+s.length<t.length;return{rows:Ae(s,e),truncated:d,next_cursor:d?String(r+s.length):null}}var Ze=t=>t.cursor!=null||t.fields!=null;function z(t,e,n=Se){let o=oe(t,e,n);return Ze(e)||o.truncated?{rows:o.rows,truncated:o.truncated,next_cursor:o.next_cursor}:o.rows}function ie(t,e){let n=t.getNode(e);return n?{cid:e,label:n.label,content:n.content,trust:t.trust.get(e)??null,freshness:t.stale(e)}:null}function ve(t){return new Set(t.toLowerCase().replace(/[^\p{L}\p{N}]+/gu," ").split(" ").filter(Boolean))}function Q(t,...e){let n=ve(t);if(n.size===0)return 0;let o=t.trim().toLowerCase(),r=0;for(let c of e){let s=ve(c);if(s.size===0)continue;let d=0;for(let u of n)s.has(u)&&d++;let m=n.size+s.size-d,f=m===0?0:d/m;o&&c.toLowerCase().includes(o)&&(f=Math.max(f,.9)),r=Math.max(r,f)}return r}function et(t,e){let n=M(e,"cid"),o=D(e,"type"),r=D(e,"direction")??"both";if(!["out","in","both"].includes(r))throw new b('param "direction" must be out|in|both');let c=[];(r==="out"||r==="both")&&c.push(...t.edgesFrom(n)),(r==="in"||r==="both")&&c.push(...t.edgesInto(n));let s=c.filter(d=>o==null||d.type===o);return z(s,e)}function tt(t,e){let n=M(e,"source_id"),o=t.heads.get(n)??null,r=[];for(let c of t.nodeLabel.keys()){let s=t.derivesInto(c).filter(m=>m.props.source_id===n).map(m=>({source_cid:m.props.source_cid,anchor:m.props.anchor??null}));if(s.length===0)continue;let d=ie(t,c);d&&r.push({...d,pins:s,pinned_to_head:o!=null&&s.some(m=>m.source_cid===o)})}return z(r,e,Ee)}function nt(t,e){let n=M(e,"label"),o=D(e,"trust"),r=D(e,"freshness"),c=[];for(let{cid:s}of t.byLabel(n)){let d=ie(t,s);d&&(o!=null&&d.trust!==o||r!=null&&d.freshness!==r||c.push(d))}return z(c,e)}function rt(t,e={}){let n=D(e,"label"),o=t.staleList().map(({cid:r,state:c})=>{let s=t.getNode(r);return{cid:r,state:c,label:s?.label??null,title:s?.content.title??null}}).filter(r=>n==null||r.label===n);return z(o,e)}function st(t,e,n){let o=e.extracted,r=D(e,"kind"),c=[];for(let f of[...t.heads.keys()].sort()){let u=t.heads.get(f);if(typeof u!="string")continue;let h=t.mediaOf(u).format;if(r!=null&&h!==r)continue;let _=t.extractedSourceCids.has(u);if(typeof o=="boolean"&&_!==o)continue;let E=0;if(h!=="image"){let y=L(n,t,u);y&&(E=y.toString("utf8").replace(/\n$/,"").split(`
|
|
3
3
|
`).length)}let l=t.extractionCompleteness.get(f);c.push({source_id:f,kind:h,lines:E,head_cid:u,extracted:_,last_extract_at:l?.at??null,extractor_version:l?.extractor_version??null})}let{rows:s,truncated:d,next_cursor:m}=oe(c,e);return{sources:s,truncated:d,next_cursor:m}}function ot(t,e,n){let o=M(e,"ref"),r=t.resolve(o);if(!r)throw new b(`UNKNOWN_REF: ${o} names nothing in the graph`);let c=r.tip,s=new Map;for(let[p,k]of t.superseded)typeof k=="string"&&k!==p&&s.set(k,[...s.get(k)??[],p]);let d=[],m=[c],f=new Set;for(;m.length>0;){let p=m.pop();f.has(p)||(f.add(p),d.push(p),m.push(...s.get(p)??[]))}let{records:u}=de(n),g=new Map,h=new Map;for(let p of u){for(let k of p.nodes)g.has(k.cid)||g.set(k.cid,p.ts);for(let k of p.supersessions)k.kind==="node"&&h.set(k.old,{by_cid:k.new,reason:k.reason})}let _=d.map(p=>({cid:p,minted_at:g.get(p)??null,superseded_by:h.get(p)?.by_cid??null,reason:h.get(p)?.reason??null,change_note:null})),{rows:E,truncated:l,next_cursor:y}=oe(_,e,Ye);return{root_logical_id:t.displayNameOf(c),live_tip:t.superseded.has(c)?null:c,truncated:l,next_cursor:y,chain:E}}function $e(t){let e=t.queries;if(!Array.isArray(e)||e.length<1||e.length>xe)throw new b(`param "queries" must be 1..${xe} entries`);return e.map((n,o)=>{if(typeof n!="object"||n===null)throw new b(`queries[${o}] must be an object`);let r=n;if(typeof r.qid!="string"||r.qid.length===0)throw new b(`queries[${o}].qid must be a non-empty string`);if(typeof r.text!="string"||r.text.length===0)throw new b(`queries[${o}].text must be a non-empty string`);return{qid:r.qid,text:r.text,topK:U(r.top_k,se,qe)}})}function De(t){let e=[];for(let{cid:n,content:o}of t.byLabel("usecase"))t.superseded.has(n)||e.push({cid:n,title:String(o.title??""),summary:String(o.summary??""),description:String(o.description??"")});return e}function Me(t,e,n){let o=De(t);return e.map(r=>{let c=[];for(let s of o){let d=n(r,s);d<=0||c.push({cid:s.cid,logical_id:t.displayNameOf(s.cid),title:s.title,score:Math.round(d*1e3)/1e3,trust:t.trust.get(s.cid)??null,superseded:!1})}return c.sort((s,d)=>d.score-s.score||s.cid.localeCompare(d.cid)),{qid:r.qid,truncated:c.length>r.topK,matches:c.slice(0,r.topK)}})}function Ce(t,e){let n=$e(e);return{results:Me(t,n,(o,r)=>Q(o.text,r.title,r.summary,r.description)),scorer:"lexical_fallback"}}function it(t,e){let n=M(e,"text"),o=D(e,"label")??"usecase",r=U(e.k,se,Re),c=[];for(let{cid:s,content:d}of t.byLabel(o)){let m=String(d.title??""),f=String(d.summary??""),u=Q(n,m,f);u<=0||c.push({cid:s,title:m,summary:f,score:Math.round(u*1e3)/1e3,trust:t.trust.get(s)??null,freshness:t.stale(s)})}return c.sort((s,d)=>d.score-s.score||s.cid.localeCompare(d.cid)),c.slice(0,r)}function Te(t,e,n){let o=t.heads.get(n);if(typeof o!="string"){let c=[...t.heads.keys()].sort().join(", ");throw new b(`unknown source_id "${n}" \u2014 known: ${c||"(none)"}`)}if(t.mediaOf(o).format==="image")throw new b(`source "${n}" is an image \u2014 no line window (cite img#whole)`);let r=L(e,t,o);if(r==null)throw new b(`source "${n}" blob is missing from the store`);return{head:o,lines:r.toString("utf8").replace(/\n$/,"").split(`
|
|
4
4
|
`)}}function ct(t,e,n){return t.slice(e-1,n).map((o,r)=>`${String(e+r).padStart(4,"0")}| ${o}`).join(`
|
|
5
5
|
`)}function at(t,e,n){let o=M(e,"source_id"),r=D(e,"anchor"),c=e.line_range;if(r!=null&&c!=null)throw new b("give anchor OR line_range, not both");let{head:s,lines:d}=Te(t,n,o),m=d.length,f,u;if(r!=null){let g=/^L(\d+)-L(\d+)$/.exec(r);if(!g)throw new b(`anchor "${r}" is not L<a>-L<b>`);let h=Number(g[1]),_=Number(g[2]);if(h<1||_<h||_>m)throw new b(`anchor "${r}" does not resolve (source has ${m} lines)`);f=Math.max(1,h-be),u=Math.min(m,_+be)}else if(c!=null){if(!Array.isArray(c)||c.length!==2||!c.every(_=>Number.isInteger(_)))throw new b('param "line_range" must be [from_line, to_line]');let[g,h]=c;if(g<1||h<g)throw new b('param "line_range" must be 1-based with from \u2264 to');if(g>m)throw new b(`line_range starts past the end (source has ${m} lines)`);f=g,u=Math.min(h,m)}else f=1,u=m;return u=Math.min(u,f+We-1),{window:ct(d,f,u),from_line:f,to_line:u,source_cid:s,total_lines:m}}function lt(t,e,n){let o=M(e,"pattern"),r=D(e,"source_id"),c;try{c=new RegExp(o,"u")}catch(f){throw new b(`invalid pattern: ${f instanceof Error?f.message:String(f)}`)}let s=r!=null?[r]:[...t.heads.keys()].sort(),d=[],m=!1;e:for(let f of s){if(r==null){let g=t.heads.get(f);if(typeof g!="string"||t.mediaOf(g).format==="image")continue}let{lines:u}=Te(t,n,f);for(let g=0;g<u.length;g++)if(c.test(u[g])){if(d.length>=Xe){m=!0;break e}d.push({source_id:f,line:g+1,text:u[g]})}}return{matches:d,truncated:m}}function ut(t,e,n,o){try{switch(e){case"get_node":{let r=ie(t,M(n,"cid"));return r==null?{ok:!0,result:null}:{ok:!0,result:Ae([r],n)[0]}}case"get_edges":return{ok:!0,result:et(t,n)};case"find_by_provenance":return{ok:!0,result:tt(t,n)};case"match_by_type":return{ok:!0,result:nt(t,n)};case"stale_nodes":return{ok:!0,result:rt(t,n)};case"search_similar":return{ok:!0,result:it(t,n)};case"search_similar_batch":return{ok:!0,result:Ce(t,n)};case"history":{if(o==null)throw new b("history unavailable (no context store)");return{ok:!0,result:ot(t,n,o)}}case"source_list":{if(o==null)throw new b("source roster unavailable (no context store)");return{ok:!0,result:st(t,n,o)}}case"source_read":case"source_grep":{if(o==null)throw new b("source text unavailable (no context store)");return{ok:!0,result:(e==="source_read"?at:lt)(t,n,o)}}default:return{ok:!1,error:`unknown method: ${e} \u2014 available: ${Ke.join(", ")}`}}}catch(r){return r instanceof b?{ok:!1,error:`${e}: ${r.message}`}:{ok:!1,error:`${e}: graph read failed: ${r instanceof Error?r.message:String(r)}`}}}var H="assurance.sim";function dt(t){return[t.title,t.summary,t.description].filter(Boolean).join(`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as n}from"./chunk-
|
|
2
|
+
import{a as n}from"./chunk-OFW3ZVTP.js";import{createHash as _}from"crypto";import{existsSync as m,readFileSync as u}from"fs";import{dirname as T,join as f,resolve as o}from"path";import{fileURLToPath as E}from"url";var s=T(E(import.meta.url)),l=2;function p(e,r){let t=_("sha256");return t.update(`kane-assurance-contract
|
|
3
3
|
`),t.update(e),t.update(`
|
|
4
4
|
agent_state_schema=${r}`),"sha256:"+t.digest("hex")}function d(){return[o(s,".."),o(s,"../../..")]}function i(){return"sha256:85dd52f33a9fd9cf22ebb81f04dfd3c05bdbeca2e62e3a7a53e8caaaa4060752"}var a=class extends Error{constructor(t,c){super(`agent/cli contract mismatch (cli ${t||"<unset>"}, agent ${c||"<unset>"}) \u2014 rebuild or reinstall the stale half`);this.expected=t;this.actual=c;this.name="PairMismatchError"}};function I(){return{TESTMUAI_CONTRACT_DIGEST:i(),TESTMUAI_CLIENT_VERSION:process.env.KANE_DEV_FORCE_CLIENT_RELEASE??`kane-cli/${n}`}}export{a,I as b};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{j as Re,k as oe,l as se,m as _e,n as $e,o as ae}from"./chunk-M335FQYJ.js";import{a as te,c as re,d as ye,f as ie}from"./chunk-DCUT3GJA.js";import{a as P,b as we,d as ke}from"./chunk-OS4VSIHT.js";import{d as ve}from"./chunk-6J5T5FEY.js";import{a as S}from"./chunk-CLGC7VEO.js";import{a as X,b as N,c as ee,d as W,e as he,g as O,h as ne}from"./chunk-W5TTF7GB.js";import{a as ge}from"./chunk-JFAFKHDX.js";import{b as Z,c as J,d as Q}from"./chunk-VT2XNEOD.js";import{f as me,h as pe}from"./chunk-X2FM67OM.js";import{A as I}from"./chunk-TH47OOBV.js";import{f as T}from"./chunk-DUAXZYAD.js";import{existsSync as Oe,statSync as Ue}from"fs";import{basename as G,resolve as q}from"path";function Ee(e){if(!e||e.stale_refs.length===0)return"\u2014";let n=e.direct_refs??[];return`${e.stale_refs.length} stale${n.length>0?` \xB7 ${n.length} direct`:""}`}function ce(e,n){let t=[...e.rows.filter(a=>a.kind!=="REMOVE").map(a=>[a.kind,S(a.ref),a.reason,Ee(a.impact)]),...e.archive.map(a=>["ARCHIVE",S(a.ref),a.why,Ee(a.impact)])],r=Math.max(40,n??100),i=[`reconcile ${e.source_id} \u2014 head ${e.head.status} \xB7 ${t.length} decision${t.length===1?"":"s"}`];return t.length>0&&i.push(...ve(["kind","ref","why","impact"],t,r,2)),e.changed&&i.push(e.held?`extract ran in override mode; ${e.defaultsTaken??0} default(s) auto-taken; matched-but-changed and new proposals HELD for your verdict (staged \u2014 nothing committed)`:`extract ran in override mode; ${e.defaultsTaken??0} default(s) auto-taken; matched-but-changed proposals auto-committed as edits`),i.push("each row becomes a card below \u2014 verdicts commit as they land"),e.planPath&&i.push(`plan: ${e.planPath}`),i}var xe=new Set(["interactive","agent","ci","override"]);function Ae(e,n){if(e.mode!==void 0&&!xe.has(e.mode))return{error:`--mode must be interactive | agent | ci | override, got '${e.mode}'`,code:"MODE_USAGE"};let t=e.mode,r="reconcile without a TTY needs an explicit mode \u2014 pass --mode agent|ci|override, or --plan for a preview";return t==="interactive"&&!n?{error:r}:t||(n?"interactive":e.plan?"override":{error:r})}async function Pe(e){let{makeHeadlessIO:n,agentRefusal:t}=await import("./headless-io-66RG5NN5.js");return t(n("ndjson","reconcile"),e,"MODE_USAGE")}function Me(e,n,t,r){if(J(t)){let v=Q(t),s=v?.sourceIdFor(t)??null;if(v===null||s===null)return{error:`--from '${t}' is not a supported remote URL \u2014 supported: ${Z.map(u=>u.hint).join("; ")}`};if(r!==void 0&&r!==s)return{error:`--source-id '${r}' does not match this URL's own identity '${s}' \u2014 re-run without --source-id. A source adopted with --as updates by re-running context ingest with the same --as; reconcile follows only the URL's own id`};let c=I(e);if(!c.heads.has(s))return{error:`unknown source '${s}' \u2014 see \`kane-cli context list --type source\`. If this URL was ingested under a custom id, update it by re-running context ingest with the same --as`};if(c.heads.get(s)==null)return{error:`source '${s}' is retired \u2014 restore it first with \`kane-cli context revert\`, then reconcile`};let _=z(e,s,{remoteUrl:t});return _!==null?{error:_}:{sourceId:s,remoteUrl:t}}if(r===void 0)return{error:"reconcile needs --from <file> AND --source-id <id> \u2014 see `kane-cli context list --type source` for ids"};let i=q(n,t);if(!Oe(i)||!Ue(i).isFile())return{error:`--from '${t}' is not a file \u2014 pass the changed source document`};let a=me(i);if(!a.ok)return{error:`--from '${t}' is not an ingestable document \u2014 allowed: ${a.allowlist.join(", ")}`};let o=I(e);if(!o.heads.has(r))return{error:`unknown source '${r}' \u2014 see \`kane-cli context list --type source\``};if(o.heads.get(r)==null)return{error:`source '${r}' is retired \u2014 restore it first with \`kane-cli context revert\`, then reconcile`};let w=z(e,r,{filePath:i});if(w!==null)return{error:w};let f=null;try{f=pe(i)}catch{}return f!==null&&f!==r&&o.heads.get(f)!=null?{error:`'${G(i)}' already backs live source '${f}' \u2014 did you mean --source-id ${f}? To truly move these bytes under '${r}', retire '${f}' first`}:{sourceId:r,filePath:i}}function C(e){return e==null?"(none)":e.slice(0,19)}function Y(e,n,t,r=!1,i){if(e.out(`reconcile ${n.source_id}: head ${n.head.status} \u2014 ${C(n.head.before)} \u2192 ${C(n.head.after)}`),r||(e.out(`note: ${n.note}`),e.out(`skipped arms: ${n.skipped_arms}`)),n.changed&&(e.out(n.held?`extract ran in override mode; ${t?.defaultsTaken??0} default(s) auto-taken; matched-but-changed and new proposals HELD for your verdict (staged \u2014 nothing committed)`:`extract ran in override mode; ${t?.defaultsTaken??0} default(s) auto-taken; matched-but-changed proposals auto-committed as edits`),i?.({type:"defaults_taken",count:t?.defaultsTaken??0})),r){let a=n.changeset??[],o=(f,v)=>{let s=a.filter(c=>c.kind===f).length;return s>0?`${s} ${v}`:null},w=[o("ADD","add"),o("MODIFY","modify"),o("ARCHIVE","archive")].filter(Boolean);n.changed&&e.out(`changeset: ${a.length} item(s)${w.length?` \u2014 ${w.join(" \xB7 ")}`:""}`),e.out(`plan: ${n.rows.length} row(s) \u2014 each gets a card below`);return}if(n.changed){let a=n.changeset??[];e.out(`changeset: ${a.length} item(s)`);for(let o of a)if(o.kind==="MODIFY")e.out(` [MODIFY] ${S(o.ref)} \u2014 ${o.summary} (${C(o.old_cid)} \u2192 ${o.new_cid===null?"(staged)":C(o.new_cid)})`);else if(o.kind==="ADD")e.out(` [ADD] ${S(o.ref)}`);else{e.out(` [ARCHIVE] ${S(o.ref)} \u2014 ${o.why}`);let w=le(o.impact,"retiring drops");w&&e.out(` ${w}`)}}e.out(`plan: ${n.rows.length} row(s)`);for(let a of n.rows){e.out(` [${a.kind}] ${S(a.ref)} \u2014 ${a.reason}`);let o=le(a.impact,"approving marks");o&&e.out(` ${o}`),e.out(` provenance: ${a.provenance}`),e.out(` action: ${a.action}`)}}function De(e,n){return ce({source_id:e.source_id,head:{status:e.head.status},rows:e.rows,archive:(e.changeset??[]).filter(t=>t.kind==="ARCHIVE"),changed:e.changed,held:!!e.held,defaultsTaken:n?.defaultsTaken},process.stdout.columns)}function le(e,n){if(!e||e.stale_refs.length===0)return null;let t=e.direct_refs??[];return`impact: ${n} ${e.stale_refs.length} item(s) stale`+(t.length>0?` \u2014 ${t.length} directly touched: ${t.join(", ")}`:"")}function D(e){return e==="interactive"?"override":e}async function M(e,n,t,r,i,a,o=[],w="override",f,v,s,c,_,u,E){let m;try{m=ne(e)}catch(d){return P(r,d instanceof Error?d.message:String(d)),1}try{if(!t){let{runWalkSession:d}=await import("./walk-session-IODOH7QU.js"),{telemetryEnvName:R}=await import("./bootstrap-5IHKW5SE.js");return await d({dir:e,rows:n,archive:o,held:f??null,childMode:w,runDesign:c??null,mark:a,markA:s,...v?{archiveState:v}:{},...u?{meta:{verb:"reconcile",sid:u,env:R()}}:{},...E?{resumeCmd:E}:{},signals:b=>U(e,b.ref,b.verdict,b.reason),..._?{script:_}:{}})}return await Te(e,n,t,r,i,a,o,w,f,v)}finally{m()}}var H=(e,n)=>e?`kane-cli maintain reconcile --from ${e} --source-id ${n}`:void 0,He=e=>e===null?void 0:"filePath"in e?e.filePath:e.remoteUrl,V=e=>`${e} high-risk item(s) need a human \u2014 ci mode won't guess. Walk interactively or use --mode agent.`;function F(e,n,t){let r=n.rows;e({type:"reconcile_plan",source_id:n.source_id,plan_path:t,rows:r.map(i=>({kind:i.kind,ref:i.ref,why:i.reason})),archive:n.changeset.filter(i=>i.kind==="ARCHIVE").map(i=>({ref:i.ref,why:i.why}))})}function de(e={}){return{type:"reconcile_summary",applied:0,skipped:0,deferred:0,plan_only:0,failed:0,paused:0,stale_created:0,...e}}var L=de();async function j(e,n,t,r,i,a,o,w,f){F(i,n,t);let v=n.changeset.filter(_=>_.kind==="ARCHIVE"&&f?.[_.ref]===void 0),s=n.rows,c;try{c=ne(e)}catch(_){return i({type:"error",message:_ instanceof Error?_.message:String(_)}),i(de()),2}try{return await Fe(e,n,t,r,i,a,o,s,v,w)}finally{c()}}async function Fe(e,n,t,r,i,a,o,w,f,v){let s=0,c=0,_=0,u=0,E=0,m=0,d=0,R=new Set,b=(h,p)=>{try{v?.(h,p)}catch{}};for(let[h,p]of w.entries()){i({type:"reconcile_row_start",kind:p.kind,ref:p.ref,...p.impact?{stale:p.impact.stale_refs.length,direct:p.impact.direct_refs?.length??0}:{}});let g=(l,$,x)=>i({type:"reconcile_row_end",kind:p.kind,ref:p.ref,outcome:l,...$!==void 0?{exit_code:$}:{},...x?{detail:x}:{}});if(p.applied){c++,g("skipped");continue}if(p.kind==="REMOVE"){E++,g("plan-only");continue}if(p.held_ref&&n.held){let l=new Set;if(p.kind==="MODIFY"&&p.impact){let x=I(e);for(let A of p.impact.stale_refs){let K=x.resolve(A);K&&x.stale(K.tip)==="fresh"&&l.add(A)}}let $=oe(e,n.held,p.held_ref,ue);if(!$.ok){_++,d===0&&(d=1),g("failed",1,$.message);continue}if($.kind==="ADD"){let x=await r($.ref,{yes:!0,mode:o});if(x!==0){x===3?(u++,d===0&&(d=3),g("paused",3)):(_++,d===0&&(d=1),g("failed",x));continue}}s++,$.kind!=="ADD"&&p.impact&&(m+=l.size),b(h,"approved"),U(e,p.ref,$.kind==="ADD"?"gap-resolved-create":"gap-resolved-evolve"),g("applied");continue}let y=te(I(e),p.ref);if(!y.ok){c++,g("skipped");continue}let k=y.target;if(R.has(k.ucTip)){c++,g("skipped");continue}if(p.kind==="ADD"){let l=await r(k.seamRef,{yes:!0,mode:o});if(l===3){u++,d===0&&(d=3),g("paused",3);continue}if(l!==0){_++,d===0&&(d=1),g("failed",l);continue}R.add(k.ucTip),s++,b(h,"approved"),U(e,p.ref,"gap-resolved-create"),g("applied")}else{let l=await re(e,k,{yes:!0,mode:o},a,r,"batch");l.outcome==="evolved"?(R.add(k.ucTip),s++,b(h,"approved"),U(e,p.ref,"gap-resolved-evolve"),g("applied")):l.outcome==="paused"?(u++,d===0&&(d=l.code),g("paused",l.code)):l.outcome==="failed"?(_++,d===0&&(d=1),g("failed",l.code)):(c++,g("skipped"))}}return f.length>0&&(i({type:"reconcile_paused",plan_path:t,pending:f.map(h=>({ref:h.ref,why:h.why}))}),u+=f.length,d===0&&(d=3)),i(de({applied:s,skipped:c,plan_only:E,failed:_,paused:u,stale_created:m})),d}var ue={kind:"human",id:process.env.USER??"operator"};function U(e,n,t,r){ge(e,{ts:new Date().toISOString(),command:"reconcile-walk",id:n,verdict:t,polarity:"preference",by:ue,target:n,...r!==void 0?{reason:r}:{}})}async function Te(e,n,t,r,i,a,o=[],w="override",f,v){let s=0,c=0,_=0,u=0,E=0,m=0,d=0,R=new Set;for(let[b,h]of n.entries()){if(h.applied){r.out(`skipped ${h.ref} \u2014 already applied (${h.applied.outcome} at ${h.applied.at})`),c++;continue}let p=l=>{try{a?.(b,l)}catch($){P(r,`could not record applied state for ${h.ref}: ${$ instanceof Error?$.message:String($)}`)}};if(h.kind==="REMOVE"){r.out(`REMOVE ${h.ref} \u2014 plan-only in this release (not executed)`),u++;continue}if(h.held_ref&&f){let l=oe(e,f,h.held_ref,ue);if(!l.ok){P(r,`held ${h.ref}: ${l.message}`),E++,d===0&&(d=1);continue}if(r.out(`committed ${l.ref} (${h.kind==="ADD"?"minted":"updated \u2014 old\u2192new redirect"})`),l.kind==="ADD"){let $=await i(l.ref,{yes:t,mode:w});if($===3){r.out(`design session for ${l.ref} paused \u2014 resume with the "kane-cli design tests --resume <session>" command printed above`),m++,d===0&&(d=3),p("approved");continue}if($!==0){P(r,`design run for ${l.ref} ended with exit code ${$}`),E++,d===0&&(d=1),p("approved");continue}}s++,p("approved"),U(e,h.ref,h.kind==="ADD"?"gap-resolved-create":"gap-resolved-evolve");continue}let g=I(e),y=te(g,h.ref);if(!y.ok){r.out(`skipped ${h.ref} \u2014 ${y.message}`),c++;continue}let k=y.target;if(R.has(k.ucTip)){r.out(`skipped ${h.ref} \u2014 use-case ${k.display} already handled in this walk`),c++;continue}if(h.kind==="ADD"){let l=await i(k.seamRef,{yes:t,mode:w});if(l===3){r.out(`design session for ${k.display} paused \u2014 resume with the "kane-cli design tests --resume <session>" command printed above; this row lands when that session completes`),m++,d===0&&(d=3);continue}if(l!==0){P(r,`design run for ${k.display} ended with exit code ${l}`),E++,d===0&&(d=1);continue}R.add(k.ucTip),s++,p("approved"),U(e,h.ref,"gap-resolved-create")}else{let l=await re(e,k,{yes:!0,mode:w},r,i,"batch");l.outcome==="evolved"?(R.add(k.ucTip),s++,p("approved"),U(e,h.ref,"gap-resolved-evolve")):l.outcome==="paused"?(m++,d===0&&(d=l.code)):l.outcome==="failed"?(E++,d===0&&(d=l.code)):c++}}for(let b of o)if(b.kind==="ARCHIVE"&&v?.[b.ref]===void 0){r.out(`[ARCHIVE] ${b.ref} \u2014 ${b.why}`);{let h=le(b.impact,"retiring drops");h&&r.out(` ${h}`)}r.out(" plan-only \u2014 retire belongs to the interactive session (never headless)"),u++}return r.out(`reconcile walk: ${s} applied, ${c} skipped, ${_} deferred, ${u} plan-only`+(E>0?`, ${E} failed`:"")+(m>0?`, ${m} paused`:"")),d}var Be=new Set(Z.map(e=>e.name));function z(e,n,t){let r=I(e),i=r.heads.get(n);if(i==null)return null;let a=r.mediaOf(i);if("remoteUrl"in t){let o=Q(t.remoteUrl)?.name??"remote";return a.format!==o?`source '${n}' is backed by ${a.format} content, not a ${o} source \u2014 reconcile it with the --from it was originally ingested from`:null}return Be.has(a.format)?`source '${n}' is a remote ${a.format} source \u2014 pass its URL to --from, not a file`:null}function fe(e,n,t,r){return"remoteUrl"in n?$e(e,n.remoteUrl,{out:t.out,err:t.err},r.remoteFindProvider):_e(e,n.filePath)}function Ie(e){return e.remote_url!==void 0?{remoteUrl:e.remote_url}:e.backing_path!==void 0?{filePath:e.backing_path}:null}async function Se(e,n,t,r,i,a=!1,o=!1){let w=i.seams??{reingest:fe(e,t,r,i),reextract:ae(e,{stage:a,hostOut:c=>r.out(c),hostEmit:c=>{c.type!=="run_start"&&i.emitEvent?.(c)},...i.emitEvent?{}:{hostProgress:c=>process.stderr.write(c+`
|
|
3
|
-
`)}})},f=null,v={reingest:w.reingest,reextract:async c=>f=await w.reextract(c)},s;try{r.out(`reconciling ${n}: re-reading the source and comparing against the graph\u2026`),s=await(i.buildPlan??se)(e,n,v)}catch(c){return P(r,`reconcile failed: ${c instanceof Error?c.message:String(c)}`),null}if(s.changed)if(o)for(let c of De(s,f))r.out(c);else Y(r,s,f,!1,i.emitEvent);return s}async function Ve(e){let[{render:n},t,{ScrollbackProvider:r},{ChatSurface:i},{makeChatController:a},{makeReconcileDeps:o}]=await Promise.all([import("./build-JIKYOZUH.js"),import("./react-QWOAB3TB.js"),import("./scrollback-JLPJR25X.js"),import("./ChatSurface-
|
|
4
|
-
`)}})},u;try{u=await(r.buildPlan??se)(e,n.source_id,_,{resumeHeld:v})}catch(g){return P(t,`reconcile failed: ${g instanceof Error?g.message:String(g)}`),1}if(i==="interactive"&&!o)for(let g of De(u,null))t.out(g);else Y(t,u,null,!1,r.emitEvent);let E=T(e),m=null;if(E!=null){let g={},y=new Set(u.changeset.filter(k=>k.kind==="ARCHIVE").map(k=>k.ref));for(let[k,l]of Object.entries(n.archive_state??{}))y.has(k)&&(g[k]=l);m=X(e,{version:2,source_id:u.source_id,...n.remote_url!==void 0?{remote_url:n.remote_url}:{backing_path:n.backing_path},head_pin:E,created:new Date().toISOString().replace(/[:.]/g,"-"),skipped_arms:u.skipped_arms,note:u.note,changeset:u.changeset,rows:u.rows,...u.held?{held:u.held}:{},...Object.keys(g).length>0?{archive_state:g}:{}}),t.out(`plan stored: ${m}`)}if(o){if(i==="agent"){let g=r.emitEvent??(()=>{});F(g,u,m),g({...L})}return 0}let d=r.emitEvent??(()=>{}),R=m?N(e,m).plan.archive_state:void 0,b=m?(g,y)=>O(m,g,y):void 0,h=m?(g,y)=>W(m,g,y):void 0;if(i==="agent")return j(e,u,m,a,d,t,D(i),b,R);let p=u.changeset.filter(g=>g.kind==="ARCHIVE"&&R?.[g.ref]===void 0);return i==="ci"&&p.length>0?(P(t,V(p.length)),2):M(e,u.rows,i==="override"||i==="ci",t,a,b,u.changeset,D(i),u.held,R,h,w,f,u.source_id,H(n.backing_path??n.remote_url,u.source_id))}async function be(e,n,t={},r=process.cwd()){let{telemetryBootstrap:i,telemetryEnvName:a}=await import("./bootstrap-
|
|
2
|
+
import{j as Re,k as oe,l as se,m as _e,n as $e,o as ae}from"./chunk-JN44V63O.js";import{a as te,c as re,d as ye,f as ie}from"./chunk-7VZCXW74.js";import{a as P,b as we,d as ke}from"./chunk-OS4VSIHT.js";import{d as ve}from"./chunk-6J5T5FEY.js";import{a as S}from"./chunk-CLGC7VEO.js";import{a as X,b as N,c as ee,d as W,e as he,g as O,h as ne}from"./chunk-W5TTF7GB.js";import{a as ge}from"./chunk-JFAFKHDX.js";import{b as Z,c as J,d as Q}from"./chunk-BN6AHQL7.js";import{h as me,j as pe}from"./chunk-2DCNCH32.js";import{A as I}from"./chunk-TH47OOBV.js";import{f as T}from"./chunk-DUAXZYAD.js";import{existsSync as Oe,statSync as Ue}from"fs";import{basename as G,resolve as q}from"path";function Ee(e){if(!e||e.stale_refs.length===0)return"\u2014";let n=e.direct_refs??[];return`${e.stale_refs.length} stale${n.length>0?` \xB7 ${n.length} direct`:""}`}function ce(e,n){let t=[...e.rows.filter(a=>a.kind!=="REMOVE").map(a=>[a.kind,S(a.ref),a.reason,Ee(a.impact)]),...e.archive.map(a=>["ARCHIVE",S(a.ref),a.why,Ee(a.impact)])],r=Math.max(40,n??100),i=[`reconcile ${e.source_id} \u2014 head ${e.head.status} \xB7 ${t.length} decision${t.length===1?"":"s"}`];return t.length>0&&i.push(...ve(["kind","ref","why","impact"],t,r,2)),e.changed&&i.push(e.held?`extract ran in override mode; ${e.defaultsTaken??0} default(s) auto-taken; matched-but-changed and new proposals HELD for your verdict (staged \u2014 nothing committed)`:`extract ran in override mode; ${e.defaultsTaken??0} default(s) auto-taken; matched-but-changed proposals auto-committed as edits`),i.push("each row becomes a card below \u2014 verdicts commit as they land"),e.planPath&&i.push(`plan: ${e.planPath}`),i}var xe=new Set(["interactive","agent","ci","override"]);function Ae(e,n){if(e.mode!==void 0&&!xe.has(e.mode))return{error:`--mode must be interactive | agent | ci | override, got '${e.mode}'`,code:"MODE_USAGE"};let t=e.mode,r="reconcile without a TTY needs an explicit mode \u2014 pass --mode agent|ci|override, or --plan for a preview";return t==="interactive"&&!n?{error:r}:t||(n?"interactive":e.plan?"override":{error:r})}async function Pe(e){let{makeHeadlessIO:n,agentRefusal:t}=await import("./headless-io-66RG5NN5.js");return t(n("ndjson","reconcile"),e,"MODE_USAGE")}function Me(e,n,t,r){if(J(t)){let v=Q(t),s=v?.sourceIdFor(t)??null;if(v===null||s===null)return{error:`--from '${t}' is not a supported remote URL \u2014 supported: ${Z.map(u=>u.hint).join("; ")}`};if(r!==void 0&&r!==s)return{error:`--source-id '${r}' does not match this URL's own identity '${s}' \u2014 re-run without --source-id. A source adopted with --as updates by re-running context ingest with the same --as; reconcile follows only the URL's own id`};let c=I(e);if(!c.heads.has(s))return{error:`unknown source '${s}' \u2014 see \`kane-cli context list --type source\`. If this URL was ingested under a custom id, update it by re-running context ingest with the same --as`};if(c.heads.get(s)==null)return{error:`source '${s}' is retired \u2014 restore it first with \`kane-cli context revert\`, then reconcile`};let _=z(e,s,{remoteUrl:t});return _!==null?{error:_}:{sourceId:s,remoteUrl:t}}if(r===void 0)return{error:"reconcile needs --from <file> AND --source-id <id> \u2014 see `kane-cli context list --type source` for ids"};let i=q(n,t);if(!Oe(i)||!Ue(i).isFile())return{error:`--from '${t}' is not a file \u2014 pass the changed source document`};let a=me(i);if(!a.ok)return{error:`--from '${t}' is not an ingestable document \u2014 allowed: ${a.allowlist.join(", ")}`};let o=I(e);if(!o.heads.has(r))return{error:`unknown source '${r}' \u2014 see \`kane-cli context list --type source\``};if(o.heads.get(r)==null)return{error:`source '${r}' is retired \u2014 restore it first with \`kane-cli context revert\`, then reconcile`};let w=z(e,r,{filePath:i});if(w!==null)return{error:w};let f=null;try{f=pe(i)}catch{}return f!==null&&f!==r&&o.heads.get(f)!=null?{error:`'${G(i)}' already backs live source '${f}' \u2014 did you mean --source-id ${f}? To truly move these bytes under '${r}', retire '${f}' first`}:{sourceId:r,filePath:i}}function C(e){return e==null?"(none)":e.slice(0,19)}function Y(e,n,t,r=!1,i){if(e.out(`reconcile ${n.source_id}: head ${n.head.status} \u2014 ${C(n.head.before)} \u2192 ${C(n.head.after)}`),r||(e.out(`note: ${n.note}`),e.out(`skipped arms: ${n.skipped_arms}`)),n.changed&&(e.out(n.held?`extract ran in override mode; ${t?.defaultsTaken??0} default(s) auto-taken; matched-but-changed and new proposals HELD for your verdict (staged \u2014 nothing committed)`:`extract ran in override mode; ${t?.defaultsTaken??0} default(s) auto-taken; matched-but-changed proposals auto-committed as edits`),i?.({type:"defaults_taken",count:t?.defaultsTaken??0})),r){let a=n.changeset??[],o=(f,v)=>{let s=a.filter(c=>c.kind===f).length;return s>0?`${s} ${v}`:null},w=[o("ADD","add"),o("MODIFY","modify"),o("ARCHIVE","archive")].filter(Boolean);n.changed&&e.out(`changeset: ${a.length} item(s)${w.length?` \u2014 ${w.join(" \xB7 ")}`:""}`),e.out(`plan: ${n.rows.length} row(s) \u2014 each gets a card below`);return}if(n.changed){let a=n.changeset??[];e.out(`changeset: ${a.length} item(s)`);for(let o of a)if(o.kind==="MODIFY")e.out(` [MODIFY] ${S(o.ref)} \u2014 ${o.summary} (${C(o.old_cid)} \u2192 ${o.new_cid===null?"(staged)":C(o.new_cid)})`);else if(o.kind==="ADD")e.out(` [ADD] ${S(o.ref)}`);else{e.out(` [ARCHIVE] ${S(o.ref)} \u2014 ${o.why}`);let w=le(o.impact,"retiring drops");w&&e.out(` ${w}`)}}e.out(`plan: ${n.rows.length} row(s)`);for(let a of n.rows){e.out(` [${a.kind}] ${S(a.ref)} \u2014 ${a.reason}`);let o=le(a.impact,"approving marks");o&&e.out(` ${o}`),e.out(` provenance: ${a.provenance}`),e.out(` action: ${a.action}`)}}function De(e,n){return ce({source_id:e.source_id,head:{status:e.head.status},rows:e.rows,archive:(e.changeset??[]).filter(t=>t.kind==="ARCHIVE"),changed:e.changed,held:!!e.held,defaultsTaken:n?.defaultsTaken},process.stdout.columns)}function le(e,n){if(!e||e.stale_refs.length===0)return null;let t=e.direct_refs??[];return`impact: ${n} ${e.stale_refs.length} item(s) stale`+(t.length>0?` \u2014 ${t.length} directly touched: ${t.join(", ")}`:"")}function D(e){return e==="interactive"?"override":e}async function M(e,n,t,r,i,a,o=[],w="override",f,v,s,c,_,u,E){let m;try{m=ne(e)}catch(d){return P(r,d instanceof Error?d.message:String(d)),1}try{if(!t){let{runWalkSession:d}=await import("./walk-session-HB3OOWVR.js"),{telemetryEnvName:R}=await import("./bootstrap-BTEXO6HX.js");return await d({dir:e,rows:n,archive:o,held:f??null,childMode:w,runDesign:c??null,mark:a,markA:s,...v?{archiveState:v}:{},...u?{meta:{verb:"reconcile",sid:u,env:R()}}:{},...E?{resumeCmd:E}:{},signals:b=>U(e,b.ref,b.verdict,b.reason),..._?{script:_}:{}})}return await Te(e,n,t,r,i,a,o,w,f,v)}finally{m()}}var H=(e,n)=>e?`kane-cli maintain reconcile --from ${e} --source-id ${n}`:void 0,He=e=>e===null?void 0:"filePath"in e?e.filePath:e.remoteUrl,V=e=>`${e} high-risk item(s) need a human \u2014 ci mode won't guess. Walk interactively or use --mode agent.`;function F(e,n,t){let r=n.rows;e({type:"reconcile_plan",source_id:n.source_id,plan_path:t,rows:r.map(i=>({kind:i.kind,ref:i.ref,why:i.reason})),archive:n.changeset.filter(i=>i.kind==="ARCHIVE").map(i=>({ref:i.ref,why:i.why}))})}function de(e={}){return{type:"reconcile_summary",applied:0,skipped:0,deferred:0,plan_only:0,failed:0,paused:0,stale_created:0,...e}}var L=de();async function j(e,n,t,r,i,a,o,w,f){F(i,n,t);let v=n.changeset.filter(_=>_.kind==="ARCHIVE"&&f?.[_.ref]===void 0),s=n.rows,c;try{c=ne(e)}catch(_){return i({type:"error",message:_ instanceof Error?_.message:String(_)}),i(de()),2}try{return await Fe(e,n,t,r,i,a,o,s,v,w)}finally{c()}}async function Fe(e,n,t,r,i,a,o,w,f,v){let s=0,c=0,_=0,u=0,E=0,m=0,d=0,R=new Set,b=(h,p)=>{try{v?.(h,p)}catch{}};for(let[h,p]of w.entries()){i({type:"reconcile_row_start",kind:p.kind,ref:p.ref,...p.impact?{stale:p.impact.stale_refs.length,direct:p.impact.direct_refs?.length??0}:{}});let g=(l,$,x)=>i({type:"reconcile_row_end",kind:p.kind,ref:p.ref,outcome:l,...$!==void 0?{exit_code:$}:{},...x?{detail:x}:{}});if(p.applied){c++,g("skipped");continue}if(p.kind==="REMOVE"){E++,g("plan-only");continue}if(p.held_ref&&n.held){let l=new Set;if(p.kind==="MODIFY"&&p.impact){let x=I(e);for(let A of p.impact.stale_refs){let K=x.resolve(A);K&&x.stale(K.tip)==="fresh"&&l.add(A)}}let $=oe(e,n.held,p.held_ref,ue);if(!$.ok){_++,d===0&&(d=1),g("failed",1,$.message);continue}if($.kind==="ADD"){let x=await r($.ref,{yes:!0,mode:o});if(x!==0){x===3?(u++,d===0&&(d=3),g("paused",3)):(_++,d===0&&(d=1),g("failed",x));continue}}s++,$.kind!=="ADD"&&p.impact&&(m+=l.size),b(h,"approved"),U(e,p.ref,$.kind==="ADD"?"gap-resolved-create":"gap-resolved-evolve"),g("applied");continue}let y=te(I(e),p.ref);if(!y.ok){c++,g("skipped");continue}let k=y.target;if(R.has(k.ucTip)){c++,g("skipped");continue}if(p.kind==="ADD"){let l=await r(k.seamRef,{yes:!0,mode:o});if(l===3){u++,d===0&&(d=3),g("paused",3);continue}if(l!==0){_++,d===0&&(d=1),g("failed",l);continue}R.add(k.ucTip),s++,b(h,"approved"),U(e,p.ref,"gap-resolved-create"),g("applied")}else{let l=await re(e,k,{yes:!0,mode:o},a,r,"batch");l.outcome==="evolved"?(R.add(k.ucTip),s++,b(h,"approved"),U(e,p.ref,"gap-resolved-evolve"),g("applied")):l.outcome==="paused"?(u++,d===0&&(d=l.code),g("paused",l.code)):l.outcome==="failed"?(_++,d===0&&(d=1),g("failed",l.code)):(c++,g("skipped"))}}return f.length>0&&(i({type:"reconcile_paused",plan_path:t,pending:f.map(h=>({ref:h.ref,why:h.why}))}),u+=f.length,d===0&&(d=3)),i(de({applied:s,skipped:c,plan_only:E,failed:_,paused:u,stale_created:m})),d}var ue={kind:"human",id:process.env.USER??"operator"};function U(e,n,t,r){ge(e,{ts:new Date().toISOString(),command:"reconcile-walk",id:n,verdict:t,polarity:"preference",by:ue,target:n,...r!==void 0?{reason:r}:{}})}async function Te(e,n,t,r,i,a,o=[],w="override",f,v){let s=0,c=0,_=0,u=0,E=0,m=0,d=0,R=new Set;for(let[b,h]of n.entries()){if(h.applied){r.out(`skipped ${h.ref} \u2014 already applied (${h.applied.outcome} at ${h.applied.at})`),c++;continue}let p=l=>{try{a?.(b,l)}catch($){P(r,`could not record applied state for ${h.ref}: ${$ instanceof Error?$.message:String($)}`)}};if(h.kind==="REMOVE"){r.out(`REMOVE ${h.ref} \u2014 plan-only in this release (not executed)`),u++;continue}if(h.held_ref&&f){let l=oe(e,f,h.held_ref,ue);if(!l.ok){P(r,`held ${h.ref}: ${l.message}`),E++,d===0&&(d=1);continue}if(r.out(`committed ${l.ref} (${h.kind==="ADD"?"minted":"updated \u2014 old\u2192new redirect"})`),l.kind==="ADD"){let $=await i(l.ref,{yes:t,mode:w});if($===3){r.out(`design session for ${l.ref} paused \u2014 resume with the "kane-cli design tests --resume <session>" command printed above`),m++,d===0&&(d=3),p("approved");continue}if($!==0){P(r,`design run for ${l.ref} ended with exit code ${$}`),E++,d===0&&(d=1),p("approved");continue}}s++,p("approved"),U(e,h.ref,h.kind==="ADD"?"gap-resolved-create":"gap-resolved-evolve");continue}let g=I(e),y=te(g,h.ref);if(!y.ok){r.out(`skipped ${h.ref} \u2014 ${y.message}`),c++;continue}let k=y.target;if(R.has(k.ucTip)){r.out(`skipped ${h.ref} \u2014 use-case ${k.display} already handled in this walk`),c++;continue}if(h.kind==="ADD"){let l=await i(k.seamRef,{yes:t,mode:w});if(l===3){r.out(`design session for ${k.display} paused \u2014 resume with the "kane-cli design tests --resume <session>" command printed above; this row lands when that session completes`),m++,d===0&&(d=3);continue}if(l!==0){P(r,`design run for ${k.display} ended with exit code ${l}`),E++,d===0&&(d=1);continue}R.add(k.ucTip),s++,p("approved"),U(e,h.ref,"gap-resolved-create")}else{let l=await re(e,k,{yes:!0,mode:w},r,i,"batch");l.outcome==="evolved"?(R.add(k.ucTip),s++,p("approved"),U(e,h.ref,"gap-resolved-evolve")):l.outcome==="paused"?(m++,d===0&&(d=l.code)):l.outcome==="failed"?(E++,d===0&&(d=l.code)):c++}}for(let b of o)if(b.kind==="ARCHIVE"&&v?.[b.ref]===void 0){r.out(`[ARCHIVE] ${b.ref} \u2014 ${b.why}`);{let h=le(b.impact,"retiring drops");h&&r.out(` ${h}`)}r.out(" plan-only \u2014 retire belongs to the interactive session (never headless)"),u++}return r.out(`reconcile walk: ${s} applied, ${c} skipped, ${_} deferred, ${u} plan-only`+(E>0?`, ${E} failed`:"")+(m>0?`, ${m} paused`:"")),d}var Be=new Set(Z.map(e=>e.name));function z(e,n,t){let r=I(e),i=r.heads.get(n);if(i==null)return null;let a=r.mediaOf(i);if("remoteUrl"in t){let o=Q(t.remoteUrl)?.name??"remote";return a.format!==o?`source '${n}' is backed by ${a.format} content, not a ${o} source \u2014 reconcile it with the --from it was originally ingested from`:null}return Be.has(a.format)?`source '${n}' is a remote ${a.format} source \u2014 pass its URL to --from, not a file`:null}function fe(e,n,t,r){return"remoteUrl"in n?$e(e,n.remoteUrl,{out:t.out,err:t.err},r.remoteFindProvider):_e(e,n.filePath)}function Ie(e){return e.remote_url!==void 0?{remoteUrl:e.remote_url}:e.backing_path!==void 0?{filePath:e.backing_path}:null}async function Se(e,n,t,r,i,a=!1,o=!1){let w=i.seams??{reingest:fe(e,t,r,i),reextract:ae(e,{stage:a,hostOut:c=>r.out(c),hostEmit:c=>{c.type!=="run_start"&&i.emitEvent?.(c)},...i.emitEvent?{}:{hostProgress:c=>process.stderr.write(c+`
|
|
3
|
+
`)}})},f=null,v={reingest:w.reingest,reextract:async c=>f=await w.reextract(c)},s;try{r.out(`reconciling ${n}: re-reading the source and comparing against the graph\u2026`),s=await(i.buildPlan??se)(e,n,v)}catch(c){return P(r,`reconcile failed: ${c instanceof Error?c.message:String(c)}`),null}if(s.changed)if(o)for(let c of De(s,f))r.out(c);else Y(r,s,f,!1,i.emitEvent);return s}async function Ve(e){let[{render:n},t,{ScrollbackProvider:r},{ChatSurface:i},{makeChatController:a},{makeReconcileDeps:o}]=await Promise.all([import("./build-JIKYOZUH.js"),import("./react-QWOAB3TB.js"),import("./scrollback-JLPJR25X.js"),import("./ChatSurface-S2P7WMBI.js"),import("./chat-controller-R4THYYPU.js"),import("./reconcile-deps-FYXRAMF2.js")]),w=t.default??t,f=a(),v=o({contextDir:e,note:s=>f.note(s)});return new Promise(s=>{let c=n(w.createElement(r,null,w.createElement(i,{controller:f,verb:"extract",reconcile:v,autoReview:!0,onReviewExit:()=>{c.unmount(),s(0)},onCtrlC:()=>{c.unmount(),s(v.pending()?3:0)}})),{exitOnCtrlC:!1})})}async function Le(e,n,t,r,i){let a=N(e,n);if("error"in a)return P(r,a.error),2;let{plan:o,path:w}=a,f=t==="override"||t==="ci";if(n===void 0&&t==="interactive"&&r.isTTY&&!await r.confirm(`apply plan ${G(w)} for ${o.source_id} (created ${o.created})?`))return r.out(`not applying ${G(w)}`),0;let v=i.runDesignForUc??ie,s=i.runDesignForUc??null,c=i.sessionScript,_=(h,p)=>O(w,h,p),u=(h,p)=>W(w,h,p),E=T(e);if(E===o.head_pin){if(t==="agent"){let p=i.emitEvent??(()=>{});return j(e,B(o),w,v,p,r,D(t),_,o.archive_state)}let h=ee(o);if(t==="ci"&&h.length>0)return P(r,V(h.length)),2;if(r.out(`applying stored plan ${G(w)} for ${o.source_id} (${o.rows.length} row(s))`),!f)for(let p of ce({source_id:o.source_id,head:{status:"stored plan"},rows:o.rows,archive:(o.changeset??[]).filter(g=>g.kind==="ARCHIVE"),changed:!1,held:!!o.held},process.stdout.columns))r.out(p);return M(e,o.rows,f,r,v,_,o.changeset??[],D(t),o.held,o.archive_state,u,s,c,o.source_id,H(o.backing_path??o.remote_url,o.source_id))}if(r.out(`graph moved since this plan (${C(o.head_pin)} \u2192 ${C(E)}) \u2014 recomputing`),o.held)return Ce(e,o,r,i,t,v,!1);let m=Ie(o);if(m===null)return P(r,`stored plan for ${o.source_id} names no backing file or URL \u2014 re-run reconcile --from`),2;let d=z(e,o.source_id,m);if(d!==null)return P(r,`stored plan cannot replay: ${d}`),2;let R=await Se(e,o.source_id,m,r,i,!1,t==="interactive");if(!R)return 1;if(!R.changed)return Y(r,R,null,!1,i.emitEvent),0;if(t==="agent"){let h=i.emitEvent??(()=>{});return j(e,R,null,v,h,r,D(t))}let b=R.changeset.filter(h=>h.kind==="ARCHIVE");return t==="ci"&&b.length>0?(P(r,V(b.length)),2):M(e,R.rows,f,r,v,void 0,R.changeset,D(t),R.held,void 0,void 0,s,c,R.source_id,H(He(m),R.source_id))}function B(e,n=!1){return{source_id:e.source_id,changed:!0,head:{status:"unchanged",before:e.head_pin,after:e.head_pin},note:e.note,skipped_arms:e.skipped_arms,changeset:e.changeset??[],rows:n?e.rows.filter(t=>t.applied===void 0):e.rows,...e.held?{held:e.held}:{}}}async function je(e,n,t,r,i,a,o){let w=r.runDesignForUc??null,f=r.sessionScript,v=he(e,n);if(v===null)return null;if("error"in v)return P(t,v.error),2;let{plan:s,path:c}=v,_=s.rows.filter(d=>d.applied===void 0),u=ee(s),E=r.emitEvent??(()=>{});if(_.length===0&&u.length===0){t.out(`already reconciled \u2014 plan ${s.created} applied ${s.rows.length} row(s)`);let d=ye(I(e)).staleCount;return d>0&&(t.out(`${d} item(s) still stale \u2014 kane-cli maintain evolve --from-stale`),E({type:"stale_debt",count:d})),i==="agent"&&(F(E,B(s),c),E({...L})),0}let m=T(e);return m!==s.head_pin?(t.out(`plan ${s.created} superseded \u2014 graph moved (${C(s.head_pin)} \u2192 ${C(m)}); recomputing`),Ce(e,s,t,r,i,a,o)):(t.out(`resuming plan ${s.created} \u2014 ${_.length} pending row(s)${u.length>0?`, ${u.length} undecided archive item(s)`:""}`),o?(Y(t,B(s),null,!1,r.emitEvent),t.out(`plan stored: ${c}`),i==="agent"&&(F(E,B(s),c),E({...L})),0):i==="agent"?j(e,B(s),c,a,E,t,D(i),(d,R)=>O(c,d,R),s.archive_state):i==="ci"&&u.length>0?(P(t,V(u.length)),2):M(e,s.rows,i==="override"||i==="ci",t,a,(d,R)=>O(c,d,R),s.changeset??[],D(i),s.held,s.archive_state,(d,R)=>W(c,d,R),w,f,s.source_id,H(s.backing_path??s.remote_url,s.source_id)))}async function Ce(e,n,t,r,i,a,o){let w=r.runDesignForUc??null,f=r.sessionScript,v;if(n.held){let g=I(e),y=new Set(n.rows.filter(l=>l.held_ref!==void 0&&l.applied!==void 0).map(l=>l.held_ref)),k=[];for(let l of n.held.rows){if(y.has(l.temp_ref))continue;if(!l.matched_cid){k.push(l);continue}let $=g.tipOf(l.matched_cid);if(g.superseded.get($)===null){t.out(`dropped held "${l.title}" \u2014 its use-case was retired meanwhile`),r.emitEvent?.({type:"held_dropped",ref:l.temp_ref,title:l.title,reason:"target_retired"});continue}k.push($===l.matched_cid?l:{...l,matched_cid:$,uc:{...l.uc,matches_existing:{cid:$}}})}v={source_id:n.held.source_id,rows:k}}let s=Ie(n);if(s===null)return P(t,`stored plan for ${n.source_id} names no backing file or URL \u2014 re-run reconcile --from`),2;let c=z(e,n.source_id,s);if(c!==null)return P(t,`stored plan cannot replay: ${c}`),2;let _=r.seams??{reingest:fe(e,s,t,r),reextract:ae(e,{stage:v!==void 0,hostOut:g=>t.out(g),hostEmit:g=>{g.type!=="run_start"&&r.emitEvent?.(g)},...r.emitEvent?{}:{hostProgress:g=>process.stderr.write(g+`
|
|
4
|
+
`)}})},u;try{u=await(r.buildPlan??se)(e,n.source_id,_,{resumeHeld:v})}catch(g){return P(t,`reconcile failed: ${g instanceof Error?g.message:String(g)}`),1}if(i==="interactive"&&!o)for(let g of De(u,null))t.out(g);else Y(t,u,null,!1,r.emitEvent);let E=T(e),m=null;if(E!=null){let g={},y=new Set(u.changeset.filter(k=>k.kind==="ARCHIVE").map(k=>k.ref));for(let[k,l]of Object.entries(n.archive_state??{}))y.has(k)&&(g[k]=l);m=X(e,{version:2,source_id:u.source_id,...n.remote_url!==void 0?{remote_url:n.remote_url}:{backing_path:n.backing_path},head_pin:E,created:new Date().toISOString().replace(/[:.]/g,"-"),skipped_arms:u.skipped_arms,note:u.note,changeset:u.changeset,rows:u.rows,...u.held?{held:u.held}:{},...Object.keys(g).length>0?{archive_state:g}:{}}),t.out(`plan stored: ${m}`)}if(o){if(i==="agent"){let g=r.emitEvent??(()=>{});F(g,u,m),g({...L})}return 0}let d=r.emitEvent??(()=>{}),R=m?N(e,m).plan.archive_state:void 0,b=m?(g,y)=>O(m,g,y):void 0,h=m?(g,y)=>W(m,g,y):void 0;if(i==="agent")return j(e,u,m,a,d,t,D(i),b,R);let p=u.changeset.filter(g=>g.kind==="ARCHIVE"&&R?.[g.ref]===void 0);return i==="ci"&&p.length>0?(P(t,V(p.length)),2):M(e,u.rows,i==="override"||i==="ci",t,a,b,u.changeset,D(i),u.held,R,h,w,f,u.source_id,H(n.backing_path??n.remote_url,u.source_id))}async function be(e,n,t={},r=process.cwd()){let{telemetryBootstrap:i,telemetryEnvName:a}=await import("./bootstrap-BTEXO6HX.js"),o=i({verb:"reconcile",mode:typeof e.mode=="string"?e.mode:"interactive",contextRoot:q(r,".context"),env:a(),applyPlanPath:typeof e.apply=="string"?q(r,e.apply):void 0,write:!0,longSession:!0});e.mode==="agent"&&t.emitEvent?.({type:"run_start",session:o.ids.session_id});let w=await Ye(e,n,t,r);return w===1&&e.mode!=="agent"&&(n.err??n.out)(o.supportFooter()),await o.end({exit_code:w}),w}async function Ye(e,n,t={},r=process.cwd()){let i=e.apply!==void 0&&e.apply!==!1,a=typeof e.apply=="string"?e.apply:void 0;if(e.plan&&i)return P(n,"pass --plan OR --apply, not both"),2;let o=e.from!==void 0||!i,w=e.from!==void 0&&J(e.from);if(o&&(!e.from||!e.sourceId&&!w))return P(n,"reconcile needs --from <file|url> AND --source-id <id> (files only \u2014 a URL derives its own id) \u2014 see `kane-cli context list --type source` for ids"),2;if(e.from&&a!==void 0)return P(n,"pass --from OR --apply <path>, not both \u2014 a stored plan names its own source"),2;let f=we(r,n);if(!f)return 2;if(e.mode!==void 0&&!xe.has(e.mode))return Pe(`--mode must be interactive | agent | ci | override, got '${e.mode}'`);let v=e.mode==="agent"||e.mode==="ci"||e.mode==="override";if(i&&!v&&!n.isTTY)return P(n,"refusing to apply without a TTY to confirm \u2014 pass --mode override|ci"),2;let s=!e.plan,c="override";if(e.from){let y=Ae(e,n.isTTY);if(typeof y=="object")return y.code==="MODE_USAGE"?Pe(y.error):(P(n,y.error),2);c=y}let _=c==="override"||c==="ci";if(i&&!e.from){let{makeReconcileDeps:y}=await import("./reconcile-deps-FYXRAMF2.js"),k=a===void 0?y({contextDir:f}).pending():null;if(k?.kind==="cards"){let $=e.mode??"interactive";return!n.isTTY||$!=="interactive"?(P(n,`a held changeset for ${k.source} awaits review (${k.count} change(s)) \u2014 resume in a terminal: kane-cli maintain reconcile --apply [HELD_REVIEW]`),2):(t.cardApplyMount??Ve)(f)}let l=e.mode??"interactive";return Le(f,a===void 0?void 0:q(r,a),l,n,t)}let u=Me(f,r,e.from,e.sourceId);if("error"in u)return P(n,u.error),2;if(!i){let{sessionsHoldingSource:y}=await import("./sessions-GIEXOCE4.js"),{holders:k,corrupt:l}=y(f,u.sourceId);if(l>0)return P(n,`cannot verify review holds \u2014 ${l} session file(s) unreadable; inspect with kane-cli context sessions list, clean with kane-cli context sessions clean, then retry [SESSIONS_UNREADABLE]`),2;if(k.length>0)return P(n,`session ${k[0]} holds item(s) for review pinned to ${u.sourceId} \u2014 finish that review first: kane-cli context extract --resume ${k[0]} [SOURCE_HELD]`),2}if(c==="interactive"&&!e.plan&&!i){let y=t.seams?.reingest??fe(f,u,n,t),k;try{k=await y(u.sourceId)}catch($){return P(n,$ instanceof Error?$.message:String($)),1}let l=k.status==="unchanged"?null:Re(f,u.sourceId);if(k.status!=="unchanged"&&!l)return n.out(`${u.sourceId} landed for the first time \u2014 extract it: kane-cli context extract --source ${u.sourceId}`),0;if(l){let x=await(t.chatMount??(async A=>{let{bindExtractInteractive:K}=await import("./extract-bind-TJ2STXV5.js");return K(A)}))({mode:"interactive",posture:"reconcile",source:u.sourceId,changeContext:l});if(x===3){let{sessionsHoldingSource:A}=await import("./sessions-GIEXOCE4.js");if(A(f,u.sourceId).holders.length===0)return 0}return x}}let E="remoteUrl"in u?{remoteUrl:u.remoteUrl}:{filePath:u.filePath},m=await Se(f,u.sourceId,E,n,t,!!e.plan||c==="interactive",c==="interactive"&&!e.plan);if(!m)return 1;let d=t.runDesignForUc??ie,R=t.runDesignForUc??null,b=t.sessionScript;if(!m.changed){let y=await je(f,u.sourceId,n,t,c,d,!!e.plan);if(y!==null)return y;if(Y(n,m,null,!1,t.emitEvent),c==="agent"){let k=t.emitEvent??(()=>{});F(k,m,null),k({...L})}return 0}let h=T(f),p=null;if(h!=null?p=X(f,{version:2,source_id:m.source_id,..."remoteUrl"in E?{remote_url:E.remoteUrl}:{backing_path:E.filePath},head_pin:h,created:new Date().toISOString().replace(/[:.]/g,"-"),skipped_arms:m.skipped_arms,note:m.note,changeset:m.changeset,rows:m.rows,...m.held?{held:m.held}:{}}):P(n,"no chain head after extract \u2014 plan not stored"),c==="agent"){let y=t.emitEvent??(()=>{});if(!s)return F(y,m,p),y({...L}),0;let k=p?(l,$)=>O(p,l,$):void 0;return j(f,m,p,d,y,n,D(c),k)}if(!s)return p&&n.out(`plan stored: ${p}`),0;let g=m.changeset.filter(y=>y.kind==="ARCHIVE");if(c==="ci"&&g.length>0)return p&&n.out(`plan stored: ${p}`),P(n,V(g.length)),2;if(p){n.out(`plan stored: ${p}`);let y=p;return M(f,Ke(f,y)??m.rows,_,n,d,(k,l)=>O(y,k,l),m.changeset,D(c),m.held,void 0,void 0,R,b,m.source_id,H(e.from,m.source_id))}return M(f,m.rows,_,n,d,void 0,m.changeset,D(c),m.held,void 0,void 0,R,b,m.source_id,H(e.from,m.source_id))}function Ke(e,n){let t=N(e,n);return"error"in t?null:t.plan.rows}async function dn(e,n={},t,r=process.cwd()){if(e.mode==="agent"){let{makeHeadlessIO:i}=await import("./headless-io-66RG5NN5.js"),a=t?i("ndjson","reconcile",t):i("ndjson","reconcile"),o={out:a.out,err:v=>a.event({type:"error",message:v}),isTTY:!1,confirm:async()=>!1,ask:async()=>""},{runWithChannel:w}=await import("./run-channel-RGH4WIQX.js"),f=2;try{f=await w({event:v=>a.event(v)},()=>be(e,o,{...n,emitEvent:v=>a.event(v)},r))}catch(v){f=1,a.event({type:"error",message:v instanceof Error?v.message:String(v)})}return a.done(f)}return be(e,ke(),n,r)}export{Ae as a,Me as b,D as c,U as d,be as e,dn as f};
|