@testmuai/kane-cli 0.6.7 → 0.6.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (162) hide show
  1. package/dist/ChatSurface-B2QJYKV4.js +8 -0
  2. package/dist/{ChromeProfilePicker-IW3K43VC.js → ChromeProfilePicker-FSZB4SZR.js} +1 -1
  3. package/dist/{CliFeedbackPrompt-ZJ4LZGPK.js → CliFeedbackPrompt-WNMDCIHZ.js} +1 -1
  4. package/dist/{CliUploadProgress-SMPVN7Q6.js → CliUploadProgress-H4265KXU.js} +1 -1
  5. package/dist/{ConfigView-RTAGKZH4.js → ConfigView-XCUZ44SP.js} +1 -1
  6. package/dist/EvidenceViewOffer-5TJCRM2T.js +2 -0
  7. package/dist/{FolderPicker-QUY7LNVZ.js → FolderPicker-S2XVCPYN.js} +1 -1
  8. package/dist/{HelpView-47J2NZWJ.js → HelpView-OPKRGNNM.js} +1 -1
  9. package/dist/{InfoBox-G63WZAMH.js → InfoBox-TW2PGJK5.js} +1 -1
  10. package/dist/{LinksBox-2HIHDT5K.js → LinksBox-66M7XP5Y.js} +1 -1
  11. package/dist/{ProfilesView-TUXQXPXJ.js → ProfilesView-T2CFQPR5.js} +1 -1
  12. package/dist/{ProjectPicker-VUABWG2P.js → ProjectPicker-7ALN52CY.js} +1 -1
  13. package/dist/{SaveSessionPrompt-PNVGNLGO.js → SaveSessionPrompt-HM3F6QML.js} +1 -1
  14. package/dist/SingleShotApp-YQYS6HTB.js +2 -0
  15. package/dist/{SummaryBox-36MDDDYQ.js → SummaryBox-BQZEGOIV.js} +1 -1
  16. package/dist/TestMdRunView-7CL3PM3J.js +2 -0
  17. package/dist/{WhoamiView-LHU6RGIY.js → WhoamiView-722MBPSG.js} +1 -1
  18. package/dist/{bind-E67W2DXG.js → bind-HNI5LCNK.js} +2 -2
  19. package/dist/{bridge-WVFTWHKP.js → bridge-V4FF5QPK.js} +1 -1
  20. package/dist/{changelog-D4Y5QJIZ.js → changelog-KMYZW5MI.js} +1 -1
  21. package/dist/chat-committer-MWZ4JQMM.js +2 -0
  22. package/dist/chat-controller-YX5A7R52.js +2 -0
  23. package/dist/{chunk-GAD6IBZ6.js → chunk-2Z5MSC23.js} +8 -8
  24. package/dist/{chunk-UQVKNUYO.js → chunk-345PY4SZ.js} +1 -1
  25. package/dist/{chunk-KVAALPTA.js → chunk-3YI4QRXF.js} +1 -1
  26. package/dist/{chunk-NEHF4C6X.js → chunk-4BAL4OGF.js} +1 -1
  27. package/dist/chunk-4CKZAGBD.js +2 -0
  28. package/dist/{chunk-7ZMYAXES.js → chunk-4FH2KFRT.js} +1 -1
  29. package/dist/{chunk-UZWOHCFX.js → chunk-4GXOBABK.js} +1 -1
  30. package/dist/{chunk-GLVDOR5G.js → chunk-7BCZLDNX.js} +1 -1
  31. package/dist/{chunk-AASBJJCU.js → chunk-AU7WQ2O5.js} +2 -2
  32. package/dist/{chunk-3CY3DZDH.js → chunk-CLYG26XV.js} +2 -2
  33. package/dist/{chunk-TADJIOHV.js → chunk-DKERZJYF.js} +1 -1
  34. package/dist/{chunk-Z34XRBKQ.js → chunk-DPOES6G3.js} +1 -1
  35. package/dist/{chunk-EDM6YACR.js → chunk-EASTDHNW.js} +1 -1
  36. package/dist/{chunk-G5CYSC23.js → chunk-EWLLPUP4.js} +1 -1
  37. package/dist/{chunk-WFQUDSKY.js → chunk-F42YVALT.js} +1 -1
  38. package/dist/chunk-FCMLIK7P.js +2 -0
  39. package/dist/{chunk-RBLZUDMZ.js → chunk-FFHBQK5N.js} +2 -2
  40. package/dist/{chunk-FYSWQ4K7.js → chunk-FT4G3QGO.js} +1 -1
  41. package/dist/{chunk-QYTMD6NM.js → chunk-FVM7TWKT.js} +1 -1
  42. package/dist/{chunk-BBZBXSTP.js → chunk-G6F2BOFT.js} +1 -1
  43. package/dist/{chunk-LVWB6TB2.js → chunk-GBYH35H5.js} +1 -1
  44. package/dist/chunk-GG43HSU2.js +3 -0
  45. package/dist/{chunk-MTG2LRGV.js → chunk-GNNMHYWE.js} +1 -1
  46. package/dist/{chunk-A2AZQ4PQ.js → chunk-IWBPV3VS.js} +1 -1
  47. package/dist/{chunk-XUHVQ5VL.js → chunk-JHAGEBKE.js} +1 -1
  48. package/dist/chunk-L3HG5ONB.js +4 -0
  49. package/dist/chunk-LEA6IHXC.js +2 -0
  50. package/dist/{chunk-5J3HQZNU.js → chunk-LMMOR7CR.js} +1 -1
  51. package/dist/{chunk-QG6LJCZG.js → chunk-LRA3V5GY.js} +1 -1
  52. package/dist/chunk-MXLXKHW4.js +2 -0
  53. package/dist/{chunk-RWIHSR4H.js → chunk-NIKA2V6B.js} +1 -1
  54. package/dist/chunk-O4HWPV67.js +13 -0
  55. package/dist/{chunk-77PBBYRZ.js → chunk-OAEZKYYQ.js} +2 -2
  56. package/dist/{chunk-IX34JIXK.js → chunk-OV2W7KBC.js} +1 -1
  57. package/dist/{chunk-JR37W7IJ.js → chunk-P4SE6YON.js} +1 -1
  58. package/dist/{chunk-X47VFBIV.js → chunk-QB4IOM3X.js} +1 -1
  59. package/dist/chunk-QM3XF5TW.js +11 -0
  60. package/dist/chunk-QM4S2APK.js +2 -0
  61. package/dist/{chunk-RGQIBS32.js → chunk-QTHITA73.js} +1 -1
  62. package/dist/{chunk-3NR6OTHL.js → chunk-QZJID3OZ.js} +1 -1
  63. package/dist/{chunk-QVJ7C4GW.js → chunk-QZNUTCSD.js} +1 -1
  64. package/dist/{chunk-SK2GVMTJ.js → chunk-R65HNFRB.js} +1 -1
  65. package/dist/{chunk-YB54MHKU.js → chunk-RLICAFFQ.js} +1 -1
  66. package/dist/chunk-RQM3DUSB.js +9 -0
  67. package/dist/chunk-SHAA6FOD.js +11 -0
  68. package/dist/chunk-SORKKW7B.js +6 -0
  69. package/dist/{chunk-TTJ4XMWP.js → chunk-T2ULEJK7.js} +1 -1
  70. package/dist/{chunk-OPDJD7WS.js → chunk-T4WZWKIU.js} +2 -2
  71. package/dist/{chunk-TSWGQKUK.js → chunk-TACPTX64.js} +2 -2
  72. package/dist/chunk-TFVMSEIA.js +2 -0
  73. package/dist/{chunk-DL5CXC64.js → chunk-U5QTE3WX.js} +1 -1
  74. package/dist/{chunk-6EC54ZHT.js → chunk-U6TLLYRG.js} +1 -1
  75. package/dist/{chunk-NMKZHHB6.js → chunk-VCYVSKPM.js} +1 -1
  76. package/dist/chunk-VXLOEM2U.js +347 -0
  77. package/dist/{chunk-I37UOX73.js → chunk-XTO236AL.js} +3 -3
  78. package/dist/chunk-XWIN3S7O.js +4 -0
  79. package/dist/{chunk-3GOZ7R4G.js → chunk-YY6WPFMT.js} +3 -3
  80. package/dist/{chunk-WJG4ZPUH.js → chunk-ZA4GR5R7.js} +1 -1
  81. package/dist/{config-BZ7C5NU5.js → config-Z4OS3HEE.js} +1 -1
  82. package/dist/cover-cmd-L2HSVDLH.js +2 -0
  83. package/dist/{credentials-BPJL6YIZ.js → credentials-TNEVAUHI.js} +1 -1
  84. package/dist/dossier-ZHSHATVU.js +3 -0
  85. package/dist/evidence-MA3LDBWG.js +2 -0
  86. package/dist/evolve-cmd-DTW4EOXM.js +2 -0
  87. package/dist/{explain-cmd-AG6ZDXV6.js → explain-cmd-327F6ESA.js} +1 -1
  88. package/dist/{explain-cmd-NZPC6537.js → explain-cmd-E366QTAD.js} +1 -1
  89. package/dist/extract-bind-DZLG4GUE.js +5 -0
  90. package/dist/{extract-cmd-4PGUDJMU.js → extract-cmd-LFVMG6UE.js} +1 -1
  91. package/dist/gaps-cmd-IAEXXESW.js +2 -0
  92. package/dist/{generate-headless-NZUDYIKJ.js → generate-headless-TYQRYQKJ.js} +2 -2
  93. package/dist/index.js +12 -12
  94. package/dist/ingest-CBQAXVH6.js +2 -0
  95. package/dist/ingest-cmd-JN6PLDE3.js +3 -0
  96. package/dist/interactive-bind-QEBWUJCN.js +7 -0
  97. package/dist/lifecycle-cmd-KZOC4WDW.js +2 -0
  98. package/dist/list-cmd-6X5U46RD.js +3 -0
  99. package/dist/{list-commands-55RCFEOL.js → list-commands-BU2MSYRH.js} +1 -1
  100. package/dist/logical-ids-RFGWBVML.js +2 -0
  101. package/dist/login-flow-4L62GWLT.js +2 -0
  102. package/dist/{persist-recorded-session-HK7JUONC.js → persist-recorded-session-RAL7UCQT.js} +1 -1
  103. package/dist/pipeline-PLI5WQKX.js +2 -0
  104. package/dist/readmodel-V3DVL6NP.js +2 -0
  105. package/dist/reconcile-cmd-UXY36ROJ.js +2 -0
  106. package/dist/{recording-banner-5IYX2KBV.js → recording-banner-MBR3Q7VD.js} +1 -1
  107. package/dist/{require-project-folder-J4Q4FRQ4.js → require-project-folder-KE7XOOFN.js} +1 -1
  108. package/dist/review-cmd-XVWPSWU2.js +4 -0
  109. package/dist/run-5DQSL5KH.js +2 -0
  110. package/dist/run-B7BRNC3X.js +2 -0
  111. package/dist/{run-test-md-WN6BH3PC.js → run-test-md-ZCAWNP35.js} +2 -2
  112. package/dist/{skill-installer-4HYPUBNB.js → skill-installer-H5DPJJFW.js} +1 -1
  113. package/dist/{spawner-VD6YFZ43.js → spawner-C6B5J73J.js} +1 -1
  114. package/dist/tcg-generate-DIMZXAV3.js +2 -0
  115. package/dist/{testmd-actions-LT5FNIR6.js → testmd-actions-X6XCV53D.js} +1 -1
  116. package/dist/token-refresh-7PAPCMQK.js +2 -0
  117. package/dist/{validate-basic-XWGKC5VF.js → validate-basic-VBPGGHES.js} +1 -1
  118. package/dist/{version-check-6FDTS6MK.js → version-check-YPRCQJ7E.js} +1 -1
  119. package/dist/{view-cmd-PCDG3FIC.js → view-cmd-G4PGJRQH.js} +3 -3
  120. package/dist/walk-session-GWOP27TX.js +2 -0
  121. package/package.json +6 -6
  122. package/dist/ChatSurface-Y2M6HB2R.js +0 -8
  123. package/dist/EvidenceViewOffer-LHPIZUGQ.js +0 -2
  124. package/dist/SingleShotApp-BZV5CULT.js +0 -2
  125. package/dist/TestMdRunView-A655PMEY.js +0 -2
  126. package/dist/chat-committer-WOTCC7L3.js +0 -2
  127. package/dist/chat-controller-MONWZKS7.js +0 -4
  128. package/dist/chunk-64LC36AF.js +0 -2
  129. package/dist/chunk-6PS65QFF.js +0 -2
  130. package/dist/chunk-CIFVUX3B.js +0 -4
  131. package/dist/chunk-DCWCANNS.js +0 -6
  132. package/dist/chunk-GBBVP2JW.js +0 -2
  133. package/dist/chunk-IYTHPCQ2.js +0 -356
  134. package/dist/chunk-NMZATEKQ.js +0 -9
  135. package/dist/chunk-QHFUDBQH.js +0 -2
  136. package/dist/chunk-R7NNIQMH.js +0 -11
  137. package/dist/chunk-RE3BZVGE.js +0 -3
  138. package/dist/chunk-VLC24QVT.js +0 -2
  139. package/dist/chunk-Y6HPW2OQ.js +0 -2
  140. package/dist/chunk-YTZUYCFZ.js +0 -2
  141. package/dist/chunk-YZBLBPOE.js +0 -13
  142. package/dist/cover-cmd-DN5D6A3S.js +0 -2
  143. package/dist/evidence-E5B24ZO6.js +0 -2
  144. package/dist/evolve-cmd-V7H4PLCX.js +0 -2
  145. package/dist/extract-bind-3QBBCWYE.js +0 -5
  146. package/dist/gaps-cmd-42LPHWFP.js +0 -2
  147. package/dist/ingest-GOKIMEP4.js +0 -2
  148. package/dist/ingest-cmd-BTYHVJ33.js +0 -3
  149. package/dist/interactive-bind-TKRWAPJU.js +0 -7
  150. package/dist/lifecycle-cmd-E6AXODQD.js +0 -2
  151. package/dist/list-cmd-RJVLH2GR.js +0 -3
  152. package/dist/logical-ids-QZQRQ3TV.js +0 -2
  153. package/dist/login-flow-WNIHDQXF.js +0 -2
  154. package/dist/pipeline-FTLXJQRT.js +0 -2
  155. package/dist/readmodel-KTNI6QDC.js +0 -2
  156. package/dist/reconcile-cmd-5XC4AUSJ.js +0 -2
  157. package/dist/review-cmd-XB2DCTMZ.js +0 -4
  158. package/dist/run-2RFR2ASQ.js +0 -2
  159. package/dist/run-3ZYJQBBC.js +0 -2
  160. package/dist/tcg-generate-77QKMB63.js +0 -2
  161. package/dist/token-refresh-PCOAZBKK.js +0 -2
  162. package/dist/walk-session-YS62CWX5.js +0 -2
@@ -1,14 +1,14 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as j}from"./chunk-GBBVP2JW.js";import{b as U}from"./chunk-OPDJD7WS.js";import{e as N,f as F}from"./chunk-VLC24QVT.js";import{a as L,b as M}from"./chunk-CIFVUX3B.js";import{a as G}from"./chunk-DNNZ353O.js";import{a as C}from"./chunk-QHFUDBQH.js";import{b as V}from"./chunk-MBXWXBDM.js";import{d as E,e as $,g as P}from"./chunk-5YPBPZUR.js";function W(e,n,t,i,r){let d=t.rows.filter(p=>{let u=i.get(p.temp_ref);return u!==void 0&&u!=="reject"});if(d.length===0)return{record:null,errors:null};let s={version:1,read_basis:n.latestHash,source:{source_id:t.source_id,source_cid:n.heads.get(t.source_id)??""},use_cases:d.map(p=>p.uc)},g=new Map;for(let p of d){let u=i.get(p.temp_ref);typeof u=="object"?g.set(p.temp_ref,{resolution:"edited",edit:u.edited}):g.set(p.temp_ref,{resolution:p.uc.matches_existing&&p.uc.changed?"edited":"approved"})}let l=ee(s,n,t.staged_source_cid);if(l.errors!==null)return{record:null,errors:l.errors};let o=l.proposal,f=s.source.source_cid?D(e,n,s.source.source_cid):null;if(f!==null){o=Z(o,f);let p=N(o,z(f),n);if(p.length>0)return{record:null,errors:[{code:"HELD_CITES_STALE",detail:"the source moved after this plan staged \u2014 its quotes no longer verify against the current head; re-run kane-cli maintain reconcile to re-stage"},...p]}}let m=`held-${(n.latestHash??"root").slice(-12)}-${d.length}`;return F({contextDir:e,graph:n,proposal:o,proposalId:m,verdicts:g,by:r,autoName:!0})}function z(e){return e.replace(/\n$/,"").split(`
2
+ import{b as j}from"./chunk-T4WZWKIU.js";import{a as U}from"./chunk-DNNZ353O.js";import{d as F}from"./chunk-QM4S2APK.js";import{a as C}from"./chunk-LEA6IHXC.js";import{a as L,b as M,e as G,f as N}from"./chunk-L3HG5ONB.js";import{b as V}from"./chunk-MBXWXBDM.js";import{d as E,e as $,g as P}from"./chunk-5YPBPZUR.js";function W(e,n,t,i,r){let d=t.rows.filter(p=>{let u=i.get(p.temp_ref);return u!==void 0&&u!=="reject"});if(d.length===0)return{record:null,errors:null};let s={version:1,read_basis:n.latestHash,source:{source_id:t.source_id,source_cid:n.heads.get(t.source_id)??""},use_cases:d.map(p=>p.uc)},g=new Map;for(let p of d){let u=i.get(p.temp_ref);typeof u=="object"?g.set(p.temp_ref,{resolution:"edited",edit:u.edited}):g.set(p.temp_ref,{resolution:p.uc.matches_existing&&p.uc.changed?"edited":"approved"})}let l=ee(s,n,t.staged_source_cid);if(l.errors!==null)return{record:null,errors:l.errors};let o=l.proposal,f=s.source.source_cid?D(e,n,s.source.source_cid):null;if(f!==null){o=Z(o,f);let p=G(o,z(f),n);if(p.length>0)return{record:null,errors:[{code:"HELD_CITES_STALE",detail:"the source moved after this plan staged \u2014 its quotes no longer verify against the current head; re-run kane-cli maintain reconcile to re-stage"},...p]}}let m=`held-${(n.latestHash??"root").slice(-12)}-${d.length}`;return N({contextDir:e,graph:n,proposal:o,proposalId:m,verdicts:g,by:r,autoName:!0})}function z(e){return e.replace(/\n$/,"").split(`
3
3
  `).map((t,i)=>`${String(i+1).padStart(4,"0")}| ${t}`).join(`
4
4
  `)}function Z(e,n){let t=n.replace(/\n$/,""),i=z(n),r=d=>{if(!d?.quote)return d;let s=M(i,d.anchor);if(s!==null&&s.includes(d.quote))return d;let g=t.indexOf(d.quote);if(g===-1||t.indexOf(d.quote,g+1)!==-1)return d;let l=t.slice(0,g).split(`
5
5
  `).length,o=l+d.quote.replace(/\n$/,"").split(`
6
- `).length-1;return{...d,anchor:`L${l}-L${o}`}};return{...e,use_cases:e.use_cases.map(d=>({...d,cite:r(d.cite)??d.cite,...d.criteria?{criteria:d.criteria.map(s=>({...s,cite:r(s.cite)??s.cite}))}:{},...d.updated?.criteria?{updated:{...d.updated,criteria:d.updated.criteria.map(s=>({...s,cite:r(s.cite)??s.cite}))}}:{}}))}}function ee(e,n,t){let i=[],r=n.mediaOf(e.source.source_cid).images??[],d=t!==void 0?n.mediaOf(t).images??[]:null,s=(l,o)=>{let f=l?L(l.anchor):null;if(!l||f?.kind!=="img-part")return l;if(d===null)return i.push({code:"HELD_CITES_STALE",detail:`${o}: this plan predates image-part staging \u2014 ${l.anchor} cannot be verified against the version it staged under; re-run kane-cli maintain reconcile to re-stage`}),l;let m=d.find(c=>c.ref===f.ref)?.blob;if(m===void 0)return i.push({code:"HELD_CITES_STALE",detail:`${o}: ${l.anchor} names no decodable image of the staged version \u2014 re-run kane-cli maintain reconcile to re-stage`}),l;if(r.some(c=>c.ref===f.ref&&c.blob===m))return l;let p=r.filter(c=>c.blob===m),u=p.filter(c=>c.delivery==="selected");return u.length===1?{...l,anchor:`img#${u[0].ref}`}:p.length===1?{...l,anchor:`img#${p[0].ref}`}:(i.push({code:"HELD_CITES_STALE",detail:`${o}: the image behind ${l.anchor} is ${p.length===0?"no longer in":"ambiguous in"} the current head \u2014 re-run kane-cli maintain reconcile to re-stage`}),l)};return{proposal:{...e,use_cases:e.use_cases.map(l=>({...l,cite:s(l.cite,l.temp_ref)??l.cite,...l.criteria?{criteria:l.criteria.map(o=>({...o,cite:s(o.cite,l.temp_ref)??o.cite}))}:{},...l.updated?.criteria?{updated:{...l.updated,criteria:l.updated.criteria.map(o=>({...o,cite:s(o.cite,l.temp_ref)??o.cite}))}}:{}}))},errors:i.length>0?i:null}}function J(e,n,t=[]){let i=U(e,n),r=new Set,d=[],s=f=>{!f||r.has(f)||(r.add(f),d.push(R(e,f)))};for(let f of i.pairs)s(f.scenario),s(f.test);for(let[f,m]of i.verifies){s(f);for(let p of m)s(p)}if(t.length===0)return{stale_refs:d};let g=f=>`${String(f.props.source_id)}\0${String(f.props.anchor)}`,l=new Set;for(let{cid:f}of e.byLabel(E.USECASE))if(e.tipOf(f)===n)for(let m of e.edgesInto(f)){if(m.type!==$.DERIVES)continue;let p=m.props.claim;typeof p=="string"&&t.includes(p)&&l.add(g(m))}if(l.size===0)return{stale_refs:d};let o=new Set;for(let[f,m]of i.verifies)if(e.edgesInto(f).some(u=>u.type===$.DERIVES&&l.has(g(u)))){o.add(R(e,f));for(let u of m)o.add(R(e,u))}return{stale_refs:d,...o.size>0?{direct_refs:[...o]}:{}}}var B="this release plans changes only \u2014 blast-radius impact and drift meaning-checks are not measured, and REMOVE rows are never executed automatically",te="suite untouched; graph updated";function T(e,n){return!e.superseded.has(n)&&e.trust.get(n)!=="archived"}function R(e,n,t=new Set){let i=e.nameOf.get(n);if(i!==void 0)return i;if(t.has(n))return n;t.add(n);for(let[r,d]of e.superseded){if(d!==n)continue;let s=R(e,r,t);if(s!==r)return s}return n}function k(e){return String(e).slice(0,19)}function A(e,n,t){let i=e.edgesFrom(n).find(r=>r.type===t);return i?e.tipOf(i.dst):null}function Y(e,n){let t=e.nodeLabel.get(n);if(t===E.USECASE)return n;if(t===E.SCENARIO)return A(e,n,$.BELONGS_TO);if(t===E.AC){let i=A(e,n,$.SCOPED_TO);return i?e.nodeLabel.get(i)===E.USECASE?i:A(e,i,$.BELONGS_TO):null}if(t===E.TEST){let i=A(e,n,$.AUTOMATES);return i?A(e,i,$.BELONGS_TO):null}return null}function q(e,n){let t=[],i=new Map;for(let r of e.derivesInto(n))i.set(String(r.props.source_id),r);for(let[r,d]of i){let s=e.heads.get(r);if(s==null){t.push(`DERIVES pin ${r} @ ${k(d.props.source_cid)} \u2014 source retired`);continue}if(s!==d.props.source_cid){let g=e.convChains.get(r)?.chain;if(g&&g.includes(String(d.props.source_cid)))continue;t.push(`DERIVES pin ${r} @ ${k(d.props.source_cid)} \u2014 source head moved to ${k(s)}`)}}for(let r of e.edgesFrom(n))P(r.type)?.pin?.comparesTo==="dst_tip"&&e.superseded.has(r.dst)&&t.push(`${r.type} pin \u2192 ${R(e,r.dst)} \u2014 target superseded`);return t.join("; ")||"structural pin broken"}var ne=new Set([E.USECASE,E.SCENARIO,E.AC,E.TEST]);function O(e,n){return e.ref<n.ref?-1:e.ref>n.ref?1:0}function D(e,n,t){let i=G(e,n,t);return i===null?null:i.toString("utf8")}function re(e,n,t,i,r){let d=t.props.quote;if(typeof d=="string"&&d.length>0)return i.includes(d);let s=String(t.props.source_cid);r.has(s)||r.set(s,D(e,n,s));let g=r.get(s);if(g===null)return!1;let l=M(g,String(t.props.anchor));return l===null?!1:l.split(`
6
+ `).length-1;return{...d,anchor:`L${l}-L${o}`}};return{...e,use_cases:e.use_cases.map(d=>({...d,cite:r(d.cite)??d.cite,...d.criteria?{criteria:d.criteria.map(s=>({...s,cite:r(s.cite)??s.cite}))}:{},...d.updated?.criteria?{updated:{...d.updated,criteria:d.updated.criteria.map(s=>({...s,cite:r(s.cite)??s.cite}))}}:{}}))}}function ee(e,n,t){let i=[],r=n.mediaOf(e.source.source_cid).images??[],d=t!==void 0?n.mediaOf(t).images??[]:null,s=(l,o)=>{let f=l?L(l.anchor):null;if(!l||f?.kind!=="img-part")return l;if(d===null)return i.push({code:"HELD_CITES_STALE",detail:`${o}: this plan predates image-part staging \u2014 ${l.anchor} cannot be verified against the version it staged under; re-run kane-cli maintain reconcile to re-stage`}),l;let m=d.find(c=>c.ref===f.ref)?.blob;if(m===void 0)return i.push({code:"HELD_CITES_STALE",detail:`${o}: ${l.anchor} names no decodable image of the staged version \u2014 re-run kane-cli maintain reconcile to re-stage`}),l;if(r.some(c=>c.ref===f.ref&&c.blob===m))return l;let p=r.filter(c=>c.blob===m),u=p.filter(c=>c.delivery==="selected");return u.length===1?{...l,anchor:`img#${u[0].ref}`}:p.length===1?{...l,anchor:`img#${p[0].ref}`}:(i.push({code:"HELD_CITES_STALE",detail:`${o}: the image behind ${l.anchor} is ${p.length===0?"no longer in":"ambiguous in"} the current head \u2014 re-run kane-cli maintain reconcile to re-stage`}),l)};return{proposal:{...e,use_cases:e.use_cases.map(l=>({...l,cite:s(l.cite,l.temp_ref)??l.cite,...l.criteria?{criteria:l.criteria.map(o=>({...o,cite:s(o.cite,l.temp_ref)??o.cite}))}:{},...l.updated?.criteria?{updated:{...l.updated,criteria:l.updated.criteria.map(o=>({...o,cite:s(o.cite,l.temp_ref)??o.cite}))}}:{}}))},errors:i.length>0?i:null}}function J(e,n,t=[]){let i=j(e,n),r=new Set,d=[],s=f=>{!f||r.has(f)||(r.add(f),d.push(R(e,f)))};for(let f of i.pairs)s(f.scenario),s(f.test);for(let[f,m]of i.verifies){s(f);for(let p of m)s(p)}if(t.length===0)return{stale_refs:d};let g=f=>`${String(f.props.source_id)}\0${String(f.props.anchor)}`,l=new Set;for(let{cid:f}of e.byLabel(E.USECASE))if(e.tipOf(f)===n)for(let m of e.edgesInto(f)){if(m.type!==$.DERIVES)continue;let p=m.props.claim;typeof p=="string"&&t.includes(p)&&l.add(g(m))}if(l.size===0)return{stale_refs:d};let o=new Set;for(let[f,m]of i.verifies)if(e.edgesInto(f).some(u=>u.type===$.DERIVES&&l.has(g(u)))){o.add(R(e,f));for(let u of m)o.add(R(e,u))}return{stale_refs:d,...o.size>0?{direct_refs:[...o]}:{}}}var B="this release plans changes only \u2014 blast-radius impact and drift meaning-checks are not measured, and REMOVE rows are never executed automatically",te="suite untouched; graph updated";function T(e,n){return!e.superseded.has(n)&&e.trust.get(n)!=="archived"}function R(e,n,t=new Set){let i=e.nameOf.get(n);if(i!==void 0)return i;if(t.has(n))return n;t.add(n);for(let[r,d]of e.superseded){if(d!==n)continue;let s=R(e,r,t);if(s!==r)return s}return n}function k(e){return String(e).slice(0,19)}function A(e,n,t){let i=e.edgesFrom(n).find(r=>r.type===t);return i?e.tipOf(i.dst):null}function Y(e,n){let t=e.nodeLabel.get(n);if(t===E.USECASE)return n;if(t===E.SCENARIO)return A(e,n,$.BELONGS_TO);if(t===E.AC){let i=A(e,n,$.SCOPED_TO);return i?e.nodeLabel.get(i)===E.USECASE?i:A(e,i,$.BELONGS_TO):null}if(t===E.TEST){let i=A(e,n,$.AUTOMATES);return i?A(e,i,$.BELONGS_TO):null}return null}function q(e,n){let t=[],i=new Map;for(let r of e.derivesInto(n))i.set(String(r.props.source_id),r);for(let[r,d]of i){let s=e.heads.get(r);if(s==null){t.push(`DERIVES pin ${r} @ ${k(d.props.source_cid)} \u2014 source retired`);continue}if(s!==d.props.source_cid){let g=e.convChains.get(r)?.chain;if(g&&g.includes(String(d.props.source_cid)))continue;t.push(`DERIVES pin ${r} @ ${k(d.props.source_cid)} \u2014 source head moved to ${k(s)}`)}}for(let r of e.edgesFrom(n))P(r.type)?.pin?.comparesTo==="dst_tip"&&e.superseded.has(r.dst)&&t.push(`${r.type} pin \u2192 ${R(e,r.dst)} \u2014 target superseded`);return t.join("; ")||"structural pin broken"}var ne=new Set([E.USECASE,E.SCENARIO,E.AC,E.TEST]);function O(e,n){return e.ref<n.ref?-1:e.ref>n.ref?1:0}function D(e,n,t){let i=U(e,n,t);return i===null?null:i.toString("utf8")}function re(e,n,t,i,r){let d=t.props.quote;if(typeof d=="string"&&d.length>0)return i.includes(d);let s=String(t.props.source_cid);r.has(s)||r.set(s,D(e,n,s));let g=r.get(s);if(g===null)return!1;let l=M(g,String(t.props.anchor));return l===null?!1:l.split(`
7
7
  `).some(o=>o.trim().length>0&&i.includes(o.trim()))}function se(e,n,t){let i=L(String(n.props.anchor));if(i?.kind!=="img-part")return!1;let d=(e.mediaOf(String(n.props.source_cid)).images??[]).find(s=>s.ref===i.ref)?.blob;return d===void 0?!1:(e.mediaOf(t).images??[]).some(s=>s.blob===d)}var K=128*1024,X=64*1024;function oe(e,n){let t=e.split(`
8
8
  `),i=n.split(`
9
9
  `),r=0;for(;r<t.length&&r<i.length&&t[r]===i[r];)r++;let d=t.length,s=i.length;for(;d>r&&s>r&&t[d-1]===i[s-1];)d--,s--;if(d===r&&s===r)return"";let g=t.slice(r,d),l=i.slice(r,s),f=ie(g,l,2e3),m=[];if(f===null)m.push(`@@ old L${r+1}-L${d} \u2192 new L${r+1}-L${s} @@`,...g.map(p=>`- ${p}`),...l.map(p=>`+ ${p}`));else{let p=f.map((c,h)=>c.op==="="?-1:h).filter(c=>c>=0),u=0;for(;u<p.length;){let c=u;for(;c+1<p.length&&p[c+1]-p[c]<=3;)c++;let h=Math.max(p[u]-1,0),v=Math.min(p[c]+1,f.length-1),y=f.slice(h,v+1),S=r+(y[0].ai??0)+1,w=r+(y[0].bi??0)+1,a=y.filter(b=>b.op!=="+").length,_=y.filter(b=>b.op!=="-").length;m.push(`@@ old L${S}-L${S+Math.max(a-1,0)} \u2192 new L${w}-L${w+Math.max(_-1,0)} @@`);for(let b of y)m.push(b.op==="="?` ${b.line}`:`${b.op} ${b.line}`);u=c+1}}return m.join(`
10
10
  `)}function ie(e,n,t){let i=e.length,r=n.length,d=Math.min(i+r,t),s=new Map([[1,0]]),g=[],l=!1;for(let p=0;p<=d&&!l;p++){g.push(new Map(s));for(let u=-p;u<=p;u+=2){let c=u===-p||u!==p&&(s.get(u-1)??0)<(s.get(u+1)??0)?s.get(u+1)??0:(s.get(u-1)??0)+1,h=c-u;for(;c<i&&h<r&&e[c]===n[h];)c++,h++;if(s.set(u,c),c>=i&&h>=r){l=!0;break}}}if(!l)return null;let o=i,f=r,m=[];for(let p=g.length-1;p>0;p--){let u=g[p],c=o-f,h=c===-p||c!==p&&(u.get(c-1)??0)<(u.get(c+1)??0)?c+1:c-1,v=u.get(h)??0,y=v-h;for(;o>v&&f>y;)m.push({op:"=",line:e[o-1],ai:o-1,bi:f-1}),o--,f--;p>0&&(o===v?(m.push({op:"+",line:n[f-1],ai:o,bi:f-1}),f--):(m.push({op:"-",line:e[o-1],ai:o-1,bi:f}),o--))}for(;o>0&&f>0;)m.push({op:"=",line:e[o-1],ai:o-1,bi:f-1}),o--,f--;for(;o>0;)m.push({op:"-",line:e[o-1],ai:o-1,bi:0}),o--;for(;f>0;)m.push({op:"+",line:n[f-1],ai:0,bi:f-1}),f--;return m.reverse()}function ce(e){let n=Buffer.byteLength(e,"utf8");if(n<=K+X)return{diff:e,truncated:!1};let t=Buffer.from(e,"utf8"),i=K;for(;i>0&&(t[i]&192)===128;)i--;let r=n-X;for(;r<n&&(t[r]&192)===128;)r++;let d=t.subarray(0,i).toString("utf8"),s=t.subarray(r).toString("utf8");return{diff:`${d}
11
11
  \u2026 [diff truncated: ${n-i-(n-r)} bytes omitted] \u2026
12
- ${s}`,truncated:!0}}function ae(e,n){let t=C(e),i=t.heads.get(n);if(typeof i!="string")return null;let r=[];for(let u of V(e).records){let c=u.source_head_moves?.[n];c!==void 0&&c!==r[r.length-1]&&r.push(c)}let d=r.lastIndexOf(i),s=d>0?r[d-1]:null;if(typeof s!="string"||s===i)return null;let g=D(e,t,s),l=D(e,t,i);if(g===null||l===null)return null;let{diff:o,truncated:f}=ce(oe(g,l)),m=new Set,p=[];for(let u of t.edgesFrom(s))u.type!==$.DERIVES||t.nodeLabel.get(u.dst)!==E.USECASE||m.has(u.dst)||(m.add(u.dst),p.push({id:u.dst,title:String(t.getNode(u.dst)?.content.title??"")}));return{source_id:n,old_head:s,new_head:i,diff:o,...f?{truncated:!0}:{},prior_ucs:p}}function de(e,n,t){let i=e.getNode(n)?.content??{},r=e.getNode(t)?.content??{},s=[...new Set([...Object.keys(i),...Object.keys(r)])].sort().filter(g=>JSON.stringify(i[g])!==JSON.stringify(r[g]));return s.length>0?`updated: ${s.join(", ")}`:"updated"}function le(e,n,t,i,r,d,s){let g=new Set((s?.rows??[]).map(c=>c.matched_cid).filter(c=>!!c)),l=[];for(let[c,h]of t.superseded)h===null||c===h||n.superseded.has(c)||t.nodeLabel.get(c)===E.USECASE&&l.push({kind:"MODIFY",ref:R(t,c),old_cid:c,new_cid:h,summary:de(t,c,h)});let o=d.map(c=>({kind:"ADD",ref:R(t,c),cid:c}));for(let c of s?.rows??[])c.kind==="MODIFY"&&c.matched_cid?l.push({kind:"MODIFY",ref:R(t,c.matched_cid),old_cid:c.matched_cid,new_cid:null,summary:`${c.why} (staged)`}):c.kind==="ADD"&&o.push({kind:"ADD",ref:c.title,cid:null});let f=[],m=D(e,t,r),p=new Map;for(let{cid:c}of t.byLabel(E.USECASE)){if(!T(t,c)||g.has(c))continue;let h=t.derivesInto(c),v=h.filter(w=>String(w.props.source_id)===i);v.length===0||v.some(w=>w.props.source_cid===r)||v.some(w=>{let a=String(w.props.anchor),_=L(a);return _?.kind==="img-whole"?!1:_?.kind==="img-part"?se(t,w,r):m!==null&&re(e,t,w,m,p)})||h.some(w=>{let a=String(w.props.source_id);if(a===i)return!1;let _=t.heads.get(a);return _!=null})||f.push({kind:"ARCHIVE",ref:R(t,c),cid:c,why:`evidence decayed: no quote from ${i} relocates into @${k(r)}, no other live source, no fresh evidence this run`,impact:J(t,t.tipOf(c))})}let u=(c,h)=>c.ref<h.ref?-1:c.ref>h.ref?1:0;return[...l.sort(u),...o.sort(u),...f.sort(u)]}function Ee(e,n,t,i,r){let d=n.rows.find(u=>u.temp_ref===t);if(!d)return{ok:!1,message:`held item ${t} missing from the plan artifact`};let s=d,g=C(e);if(s.matched_cid){let u=g.tipOf(s.matched_cid);if(g.superseded.get(u)===null)return{ok:!1,message:`use-case for "${s.title}" was retired meanwhile \u2014 nothing to update`};u!==s.matched_cid&&(s={...s,matched_cid:u,uc:{...s.uc,matches_existing:{cid:u}}})}let l=r?{edited:r}:"approve",o=W(e,g,{source_id:n.source_id,...n.staged_source_cid!==void 0?{staged_source_cid:n.staged_source_cid}:{},rows:[s]},new Map([[s.temp_ref,l]]),i);if(o.errors)return{ok:!1,message:o.errors.map(u=>`${u.code}: ${u.detail}`).join("; ")};let f=C(e),m=s.matched_cid?f.tipOf(s.matched_cid):o.record?.nodes.find(u=>u.label==="usecase")?.cid??o.record?.review[0]?.id;return{ok:!0,ref:m?R(f,m):s.title,kind:s.kind}}async function be(e,n,t,i={}){let r=C(e),d=r.heads.get(n)??null,s=new Set(r.staleList().filter(a=>a.state==="stale").map(a=>a.cid)),g=await t.reingest(n);if(g.status==="unchanged"&&!i.resumeHeld)return{source_id:n,changed:!1,head:{status:g.status,before:d,after:g.cid},note:`nothing to reconcile \u2014 ${n} is unchanged`,skipped_arms:B,changeset:[],rows:[]};let l=i.resumeHeld?{minted:[],matched:[],held:i.resumeHeld}:await t.reextract(n),o=C(e),f=l.minted.map(a=>{let _=R(o,a);return{kind:"ADD",origin:"content-change",ref:_,reason:`new use-case extracted from ${n}`,provenance:`extraction commit \u2014 DERIVES ${n} @ ${k(g.cid)}`,action:`kane-cli design tests --use-case ${_}`}}),m=o.staleList().filter(a=>a.state==="stale"&&!s.has(a.cid)&&T(o,a.cid)).map(a=>a.cid),p=m.map(a=>{let _=R(o,a),b=ne.has(o.nodeLabel.get(a)??"");return{kind:"MODIFY",origin:"structural-stale",ref:_,reason:"stale (structural)",provenance:q(o,a),action:b?`kane-cli maintain evolve ${_}`:`kane-cli design explain ${_}`}}),u=[],c=[];for(let a of l.held?.rows??[])if(a.kind==="ADD")u.push({kind:"ADD",origin:"content-change",ref:a.title,held_ref:a.temp_ref,reason:`${a.why} (staged \u2014 commits on approval)`,provenance:`staged extraction of ${n} @ ${k(g.cid)}`,action:"approve to commit + design"});else{let _=a.matched_cid?o.tipOf(a.matched_cid):null,b=_?o.getNode(_)?.content.criteria??[]:[],I=(a.uc.updated?.criteria??[]).map(x=>typeof x=="string"?x:x.text),Q=[...I.filter(x=>!b.includes(x)),...a.uc.updated?.criteria!==void 0?b.filter(x=>!I.includes(x)):[]],H=_?J(o,_,Q):void 0;c.push({kind:"MODIFY",origin:"content-change",ref:a.matched_cid?R(o,a.matched_cid):a.title,held_ref:a.temp_ref,reason:`${a.why} (staged \u2014 commits on approval)`,provenance:`staged extraction of ${n} @ ${k(g.cid)}`,action:"approve to commit the updated version (old\u2192new redirect)",...H?{impact:H}:{}})}let h=new Set;for(let a of[...l.minted,...l.matched])h.add(o.tipOf(a));for(let a of l.held?.rows??[])a.matched_cid&&h.add(o.tipOf(a.matched_cid));for(let a of m){let _=Y(o,o.tipOf(a));_&&o.nodeLabel.get(_)===E.USECASE&&h.add(o.tipOf(_))}let v=[];for(let a of await j(o,"design")){if(a.kind!=="no-verifies")continue;let _=o.resolve(a.ref);if(!_)continue;let b=Y(o,_.tip);!b||!h.has(o.tipOf(b))||v.push({kind:"ADD",origin:"content-change",ref:a.ref,reason:a.why,provenance:`gaps engine (design) \u2014 uncovered AC of touched use-case ${R(o,b)}`,action:a.ready_command})}let y=[];for(let{cid:a}of o.byLabel(E.USECASE))T(o,a)&&o.stale(a)==="orphaned"&&y.push({kind:"REMOVE",ref:R(o,a),reason:"orphaned \u2014 no live source evidences this use-case",provenance:q(o,a),action:"plan-only \u2014 REMOVE is not executed in this release"});let S=new Set,w=[...f.sort(O),...u.sort(O),...v.sort(O),...c.sort(O),...p.sort(O),...y.sort(O)].filter(a=>{let _=`${a.kind}\0${a.ref}`;return S.has(_)?!1:(S.add(_),!0)});return{source_id:n,changed:!0,head:{status:g.status,before:d,after:g.cid},note:te,skipped_arms:B,changeset:le(e,r,o,n,g.cid,l.minted,l.held),rows:w,...l.held?{held:l.held}:{}}}function ve(e,n){return async t=>{let{ingestFile:i}=await import("./ingest-GOKIMEP4.js"),{convertPdf:r}=await import("./pdf-convert-KYXI4FU4.js"),d=await i({contextDir:e,filePath:n,asId:t,pdfConverter:r});return{status:d.status,cid:d.cid}}}function Re(e,n={}){return async t=>{let i=[],[{runExtract:r},{resolveAgentAuthEnv:d},{runAgent:s},{preflightTurn:g}]=await Promise.all([import("./run-3ZYJQBBC.js"),import("./spawner-VD6YFZ43.js"),import("./bridge-WVFTWHKP.js"),import("./turn-preflight-JGYT7LXP.js")]),l=await d(),o=new Set(C(e).byLabel(E.USECASE).map(S=>S.cid)),f=ae(e,t)??void 0,m=0,p=await r({mode:"override",...f?{changeContext:f}:{}},{contextDir:e,agent:s,preflightTurn:()=>g(l),ask:async()=>[],review:async S=>{if(!n.stage)return new Map(S.map(a=>[a.temp_ref,{resolution:a.matches_existing&&a.changed?"edited":"skipped"}]));let w=new Map;for(let a of S){if(a.matches_existing&&!a.changed){w.set(a.temp_ref,{resolution:"skipped"});continue}i.push({kind:a.matches_existing?"MODIFY":"ADD",temp_ref:a.temp_ref,title:a.title,why:a.matches_existing?`updated: ${Object.keys(a.updated??{}).join(", ")||"content"}`:`newly extracted from ${t}`,...a.matches_existing?{matched_cid:a.matches_existing.cid,updated:a.updated}:{},uc:a}),w.set(a.temp_ref,{resolution:"rejected"})}return w},confirmStale:async()=>!1,out:S=>process.stderr.write(S+`
12
+ ${s}`,truncated:!0}}function ae(e,n){let t=C(e),i=t.heads.get(n);if(typeof i!="string")return null;let r=[];for(let u of V(e).records){let c=u.source_head_moves?.[n];c!==void 0&&c!==r[r.length-1]&&r.push(c)}let d=r.lastIndexOf(i),s=d>0?r[d-1]:null;if(typeof s!="string"||s===i)return null;let g=D(e,t,s),l=D(e,t,i);if(g===null||l===null)return null;let{diff:o,truncated:f}=ce(oe(g,l)),m=new Set,p=[];for(let u of t.edgesFrom(s))u.type!==$.DERIVES||t.nodeLabel.get(u.dst)!==E.USECASE||m.has(u.dst)||(m.add(u.dst),p.push({id:u.dst,title:String(t.getNode(u.dst)?.content.title??"")}));return{source_id:n,old_head:s,new_head:i,diff:o,...f?{truncated:!0}:{},prior_ucs:p}}function de(e,n,t){let i=e.getNode(n)?.content??{},r=e.getNode(t)?.content??{},s=[...new Set([...Object.keys(i),...Object.keys(r)])].sort().filter(g=>JSON.stringify(i[g])!==JSON.stringify(r[g]));return s.length>0?`updated: ${s.join(", ")}`:"updated"}function le(e,n,t,i,r,d,s){let g=new Set((s?.rows??[]).map(c=>c.matched_cid).filter(c=>!!c)),l=[];for(let[c,h]of t.superseded)h===null||c===h||n.superseded.has(c)||t.nodeLabel.get(c)===E.USECASE&&l.push({kind:"MODIFY",ref:R(t,c),old_cid:c,new_cid:h,summary:de(t,c,h)});let o=d.map(c=>({kind:"ADD",ref:R(t,c),cid:c}));for(let c of s?.rows??[])c.kind==="MODIFY"&&c.matched_cid?l.push({kind:"MODIFY",ref:R(t,c.matched_cid),old_cid:c.matched_cid,new_cid:null,summary:`${c.why} (staged)`}):c.kind==="ADD"&&o.push({kind:"ADD",ref:c.title,cid:null});let f=[],m=D(e,t,r),p=new Map;for(let{cid:c}of t.byLabel(E.USECASE)){if(!T(t,c)||g.has(c))continue;let h=t.derivesInto(c),v=h.filter(w=>String(w.props.source_id)===i);v.length===0||v.some(w=>w.props.source_cid===r)||v.some(w=>{let a=String(w.props.anchor),_=L(a);return _?.kind==="img-whole"?!1:_?.kind==="img-part"?se(t,w,r):m!==null&&re(e,t,w,m,p)})||h.some(w=>{let a=String(w.props.source_id);if(a===i)return!1;let _=t.heads.get(a);return _!=null})||f.push({kind:"ARCHIVE",ref:R(t,c),cid:c,why:`evidence decayed: no quote from ${i} relocates into @${k(r)}, no other live source, no fresh evidence this run`,impact:J(t,t.tipOf(c))})}let u=(c,h)=>c.ref<h.ref?-1:c.ref>h.ref?1:0;return[...l.sort(u),...o.sort(u),...f.sort(u)]}function Ee(e,n,t,i,r){let d=n.rows.find(u=>u.temp_ref===t);if(!d)return{ok:!1,message:`held item ${t} missing from the plan artifact`};let s=d,g=C(e);if(s.matched_cid){let u=g.tipOf(s.matched_cid);if(g.superseded.get(u)===null)return{ok:!1,message:`use-case for "${s.title}" was retired meanwhile \u2014 nothing to update`};u!==s.matched_cid&&(s={...s,matched_cid:u,uc:{...s.uc,matches_existing:{cid:u}}})}let l=r?{edited:r}:"approve",o=W(e,g,{source_id:n.source_id,...n.staged_source_cid!==void 0?{staged_source_cid:n.staged_source_cid}:{},rows:[s]},new Map([[s.temp_ref,l]]),i);if(o.errors)return{ok:!1,message:o.errors.map(u=>`${u.code}: ${u.detail}`).join("; ")};let f=C(e),m=s.matched_cid?f.tipOf(s.matched_cid):o.record?.nodes.find(u=>u.label==="usecase")?.cid??o.record?.review[0]?.id;return{ok:!0,ref:m?R(f,m):s.title,kind:s.kind}}async function be(e,n,t,i={}){let r=C(e),d=r.heads.get(n)??null,s=new Set(r.staleList().filter(a=>a.state==="stale").map(a=>a.cid)),g=await t.reingest(n);if(g.status==="unchanged"&&!i.resumeHeld)return{source_id:n,changed:!1,head:{status:g.status,before:d,after:g.cid},note:`nothing to reconcile \u2014 ${n} is unchanged`,skipped_arms:B,changeset:[],rows:[]};let l=i.resumeHeld?{minted:[],matched:[],held:i.resumeHeld}:await t.reextract(n),o=C(e),f=l.minted.map(a=>{let _=R(o,a);return{kind:"ADD",origin:"content-change",ref:_,reason:`new use-case extracted from ${n}`,provenance:`extraction commit \u2014 DERIVES ${n} @ ${k(g.cid)}`,action:`kane-cli design tests --use-case ${_}`}}),m=o.staleList().filter(a=>a.state==="stale"&&!s.has(a.cid)&&T(o,a.cid)).map(a=>a.cid),p=m.map(a=>{let _=R(o,a),b=ne.has(o.nodeLabel.get(a)??"");return{kind:"MODIFY",origin:"structural-stale",ref:_,reason:"stale (structural)",provenance:q(o,a),action:b?`kane-cli maintain evolve ${_}`:`kane-cli design explain ${_}`}}),u=[],c=[];for(let a of l.held?.rows??[])if(a.kind==="ADD")u.push({kind:"ADD",origin:"content-change",ref:a.title,held_ref:a.temp_ref,reason:`${a.why} (staged \u2014 commits on approval)`,provenance:`staged extraction of ${n} @ ${k(g.cid)}`,action:"approve to commit + design"});else{let _=a.matched_cid?o.tipOf(a.matched_cid):null,b=_?o.getNode(_)?.content.criteria??[]:[],I=(a.uc.updated?.criteria??[]).map(x=>typeof x=="string"?x:x.text),Q=[...I.filter(x=>!b.includes(x)),...a.uc.updated?.criteria!==void 0?b.filter(x=>!I.includes(x)):[]],H=_?J(o,_,Q):void 0;c.push({kind:"MODIFY",origin:"content-change",ref:a.matched_cid?R(o,a.matched_cid):a.title,held_ref:a.temp_ref,reason:`${a.why} (staged \u2014 commits on approval)`,provenance:`staged extraction of ${n} @ ${k(g.cid)}`,action:"approve to commit the updated version (old\u2192new redirect)",...H?{impact:H}:{}})}let h=new Set;for(let a of[...l.minted,...l.matched])h.add(o.tipOf(a));for(let a of l.held?.rows??[])a.matched_cid&&h.add(o.tipOf(a.matched_cid));for(let a of m){let _=Y(o,o.tipOf(a));_&&o.nodeLabel.get(_)===E.USECASE&&h.add(o.tipOf(_))}let v=[];for(let a of await F(o,"design")){if(a.kind!=="no-verifies")continue;let _=o.resolve(a.ref);if(!_)continue;let b=Y(o,_.tip);!b||!h.has(o.tipOf(b))||v.push({kind:"ADD",origin:"content-change",ref:a.ref,reason:a.why,provenance:`gaps engine (design) \u2014 uncovered AC of touched use-case ${R(o,b)}`,action:a.ready_command})}let y=[];for(let{cid:a}of o.byLabel(E.USECASE))T(o,a)&&o.stale(a)==="orphaned"&&y.push({kind:"REMOVE",ref:R(o,a),reason:"orphaned \u2014 no live source evidences this use-case",provenance:q(o,a),action:"plan-only \u2014 REMOVE is not executed in this release"});let S=new Set,w=[...f.sort(O),...u.sort(O),...v.sort(O),...c.sort(O),...p.sort(O),...y.sort(O)].filter(a=>{let _=`${a.kind}\0${a.ref}`;return S.has(_)?!1:(S.add(_),!0)});return{source_id:n,changed:!0,head:{status:g.status,before:d,after:g.cid},note:te,skipped_arms:B,changeset:le(e,r,o,n,g.cid,l.minted,l.held),rows:w,...l.held?{held:l.held}:{}}}function ve(e,n){return async t=>{let{ingestFile:i}=await import("./ingest-CBQAXVH6.js"),{convertPdf:r}=await import("./pdf-convert-KYXI4FU4.js"),d=await i({contextDir:e,filePath:n,asId:t,pdfConverter:r});return{status:d.status,cid:d.cid}}}function Re(e,n={}){return async t=>{let i=[],[{runExtract:r},{resolveAgentAuthEnv:d},{runAgent:s},{preflightTurn:g}]=await Promise.all([import("./run-B7BRNC3X.js"),import("./spawner-C6B5J73J.js"),import("./bridge-V4FF5QPK.js"),import("./turn-preflight-JGYT7LXP.js")]),l=await d(),o=new Set(C(e).byLabel(E.USECASE).map(S=>S.cid)),f=ae(e,t)??void 0,m=0,p=await r({mode:"override",...f?{changeContext:f}:{}},{contextDir:e,agent:s,preflightTurn:()=>g(l),ask:async()=>[],review:async S=>{if(!n.stage)return new Map(S.map(a=>[a.temp_ref,{resolution:a.matches_existing&&a.changed?"edited":"skipped"}]));let w=new Map;for(let a of S){if(a.matches_existing&&!a.changed){w.set(a.temp_ref,{resolution:"skipped"});continue}i.push({kind:a.matches_existing?"MODIFY":"ADD",temp_ref:a.temp_ref,title:a.title,why:a.matches_existing?`updated: ${Object.keys(a.updated??{}).join(", ")||"content"}`:`newly extracted from ${t}`,...a.matches_existing?{matched_cid:a.matches_existing.cid,updated:a.updated}:{},uc:a}),w.set(a.temp_ref,{resolution:"rejected"})}return w},confirmStale:async()=>!1,out:S=>process.stderr.write(S+`
13
13
  `),progress:S=>process.stderr.write(S+`
14
14
  `),emit:S=>{S.type==="commit"&&typeof S.assumed=="number"&&(m+=S.assumed)},isTTY:!1,auth:l});if(p!==0)throw new Error(`reconcile: re-extract of ${t} failed (exit ${p})`);let u=C(e),c=u.heads.get(t),h=[],v=[];if(typeof c=="string"){let S=new Set;for(let w of u.edgesFrom(c))w.type!==$.DERIVES||u.nodeLabel.get(w.dst)!==E.USECASE||S.has(w.dst)||(S.add(w.dst),!(n.stage&&u.trust.get(w.dst)==="archived")&&(o.has(w.dst)?v:h).push(w.dst))}let y=C(e).heads.get(t);return{minted:h,matched:v,defaultsTaken:m,...n.stage?{held:{source_id:t,...y!=null?{staged_source_cid:y}:{},rows:i}}:{}}}}export{Ee as a,be as b,ve as c,Re as d};
@@ -0,0 +1,4 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{a as Z,d as ee,e as te,f as ne}from"./chunk-GG43HSU2.js";import{b as B,d as Y}from"./chunk-OSALXGD4.js";import{d as X}from"./chunk-NVGBE2DR.js";var oe=new Set(["approve","edit","reject"]);function ae(i,t){return`chatop:${t}:${i.target??"new"}:${i.op}:${i.seq}`}function ue(i,t,x,k){let c=ae(i,t),f=i.payload;switch(i.op){case"approve":return{kind:"approve",target:i.target,expectedCid:i.expected_cid,eventId:c};case"edit":{let{reason:o,...b}=f;return{kind:"edit",target:i.target,expectedCid:i.expected_cid,edit:b,reason:o,eventId:c}}case"enhance":return{kind:"enhance",target:i.target,expectedCid:i.expected_cid,edges:f.edges??[],eventId:c};case"reject":return{kind:"reject",target:i.target,expectedCid:i.expected_cid,reason:f.reason??"",redirectTo:f.redirect_to,eventId:c};case"add":{let o=f.proposal_item??{},b=String(o.label??"");if(!x.mint_gate.includes(b))throw new Error(`GATED_LABEL: cannot mint "${b}" (gate: ${x.mint_gate.join(", ")})`);let a=o.cite??{},g=o.conv_source_id??k;if(!g||typeof a.turn!="number"||!a.quote)throw new Error("INVALID_ADD: a chat add requires a conversation cite {turn, quote} and conv_source_id");return{kind:"add",label:b,content:o.content??{},cite:{turn:a.turn,quote:a.quote},convSourceId:g,rationale:o.rationale,eventId:c}}}}function re(i,t,x={}){let k=x.turn??0,c=[],f=[];for(let a of i)(a.op==="add"||a.op==="enhance")&&f.push(a);let o=new Map;for(let a of i){if(!oe.has(a.op)||!a.target)continue;let g=o.get(a.target)??[];g.push(a),o.set(a.target,g)}for(let[a,g]of o){let w=Math.max(...g.map(_=>_.seq)),C=g.filter(_=>_.seq===w);if(C.length>1){c.push({target:a,seq:w,kinds:C.map(_=>_.op)});continue}f.push(C[0])}return{chatOps:f.sort((a,g)=>a.seq-g.seq).map(a=>ue(a,k,t,x.convSourceId)),ambiguous:c}}function ce(i){let t=[];return i.questions.forEach((x,k)=>{if(i.resolution[k])return;let c=x.recommended_index!=null?x.options[x.recommended_index]?.label:void 0;c!=null&&t.push(x.risk==="high"?`${c} \u203C`:c)}),t.length>3?`${t.slice(0,3).join(" \xB7 ")} \xB7 +${t.length-3} more`:t.join(" \xB7 ")}function ie(i){let t=i.text.replace(/\?+\s*$/,"");return t.length<=36?t:`${t.slice(0,33)}\u2026`}function le(i){return i.use_cases??[]}var de={acs:"acceptance criteria",scenarios:"scenarios",tests:"tests",gaps:"gaps"};function ge(i){let t=[],x=[],k=(o,b)=>{b.length!==0&&(x.push(o),t.push(...b))},c=o=>typeof o=="string"&&/^[a-z]{1,4}\d{1,4}$/i.test(o)?o:null,f=o=>{let b=c(o.automates)??"1 scenario",a=o.verifies??[],g=a.map(c).filter(_=>_!==null).slice(0,2),w=a.length-g.length,C=g.length?`${g.join(" ")}${w>0?` +${w}`:""}`:`${a.length} ACs`;return`covers ${b} \xB7 verifies ${C}`};return k("acs",(i.acs??[]).map(o=>({temp_ref:o.temp_ref,title:o.text,kind:"ac",badge:String(o.kind),extra:{...o.expected_answer?{expects:`${String(o.expected_answer.operator??"")} \xB7 ${String(o.expected_answer.operand??"")}`}:{},"scoped to":o.scoped_to??"(use-case)"}}))),k("scenarios",(i.scenarios??[]).map(o=>({temp_ref:o.temp_ref,title:o.title,kind:"scenario",badge:o.case_type,why:o.intent,depends_on_hint:o.depends_on??[],extra:{technique:o.technique_notes}}))),k("tests",(i.tests??[]).map(o=>({temp_ref:o.temp_ref,title:o.title,kind:"test",why:f(o),depends_on_hint:o.reuses??[],extra:{automates:String(o.automates??"?"),verifies:(o.verifies??[]).join(", "),check:o.check?`${String(o.check.kind)} vs ${String(o.check.verified_against)}`:"?"}}))),k("gaps",(i.gaps??[]).map(o=>({temp_ref:o.temp_ref??o.ref??"?",title:String(o.question?.header??o.kind),kind:"gap",badge:o.kind,why:o.risk_rationale}))),{items:t,heading:x.join(" + ")||"design"}}function be(i={}){let t={turns:[],thinking:ee(),pending:null,confirm:null,status:"idle",ledger:[],activeTurn:null,stream:null,checkpoint:!1},x=e=>{let n=[],r=e.minted.map(u=>u.slug).filter(Boolean);r.length&&n.push(`added ${r.join(", ")}`);let s=e.applied.length-e.minted.length;return s>0&&n.push(`${s} change${s===1?"":"s"} applied`),e.staleDelta.length&&n.push(`stales ${e.staleDelta.length}`),n.join(" \xB7 ")||"no changes"},k=[];i.onRender&&k.push(i.onRender);let c=0,f=0,o=null,b=null,a=null,g=[],w=0,C=e=>{if(!(!a||!i.contextDir||!e.trim()))try{let n=i.refreshGraph?.()??i.graph;if(!n)return;Y({contextDir:i.contextDir,graph:n,sourceId:a,text:e,by:i.by??{kind:"human",id:"owner"}})}catch{}},_=e=>{if(!a||!i.contextDir)return;let n=i.refreshGraph?.()??i.graph,r=n?.heads.get(a),s=n?.convChains.get(a);if(!n||typeof r!="string"||!s)return;let u=n.getNode(r)?.content?.blob,p=typeof u=="string"?X(i.contextDir,u)?.toString("utf8")??"":"";if(p)for(let y of e){if(y.kind!=="add"||y.convSourceId!==a)continue;let E=B(p,y.cite.turn);if(!(E!==null&&E.includes(y.cite.quote)))for(let S=s.turns;S>=1;S--){let N=B(p,S);if(N!==null&&N.includes(y.cite.quote)){y.cite={...y.cite,turn:S};break}}}},P=null,F=new Map,Q=new Map,G=null,m=()=>{D&&(clearTimeout(D),D=null);for(let e of k)e()},D=null,U=()=>{D||(D=setTimeout(()=>{D=null;for(let e of k)e()},80))},d=e=>{t.ledger.push(e)},R=null,O=!1,q=(e=!1)=>{R?d({kind:"agent",text:R}):e&&O&&d({kind:"note",text:'chat to refine ("looks good" approves; /done finishes)'}),R=null,O=!1},se=()=>{R=null,O=!1},T=null,W=e=>{if(T){if(e)for(let n of T.items){let r=e.get(n.temp_ref);r&&(n.logical_id=r)}d({kind:"turn",...T}),T=null}},A=()=>{W(),t.activeTurn&&(t.activeTurn=null)},z=(e,n)=>n.choice||(n.selected_index!=null?e.options[n.selected_index]?.label??"?":"?"),L=()=>{let e=t.pending;if(!e)return;if(!e.resolution.every(Boolean)){e.cursor=e.resolution.findIndex(s=>s===null);return}let n=e.questions.map((s,u)=>{let p=e.resolution[u];return p.form==="deferred"?{id:s.id,selected_index:null,free_text:null}:p.free_text!=null?{id:s.id,selected_index:null,free_text:p.free_text}:{id:s.id,selected_index:p.selected_index,free_text:null}});t.pending=null,t.status=t.status==="pausing"?"pausing":"streaming";let r=P;P=null,r?.(n)},j=(e,n)=>{let r=t.pending,s=r.questions[e],u=r.resolution[e];r.resolution[e]=n;let p=ie(s);u?d({kind:"answer",receipt:{form:"changed",qNum:e+1,stub:p,choice:z(s,n),prev:u.choice}}):n.form==="deferred"?d({kind:"answer",receipt:{form:"deferred",qNum:e+1,stub:p}}):d({kind:"answer",receipt:{form:n.form,qNum:e+1,stub:p,choice:z(s,n)}})},H=()=>{let e=t.pending;e&&(e.questions.forEach((n,r)=>{e.resolution[r]||j(r,{form:"deferred",selected_index:null,free_text:null,choice:""})}),L())},I=new Map,K=e=>{I.clear();let n={high:0,med:1,low:2};return e=e.map((r,s)=>({q:r,i:s})).sort((r,s)=>(n[r.q.risk]??3)-(n[s.q.risk]??3)||r.i-s.i).map(({q:r})=>r),{questions:e,cursor:0,resolution:e.map(()=>null)}};return{state:t,explainLines(e){if(!i.explain||!i.graph||i.contextDir===void 0)return null;let n=i.explain(i.contextDir,i.graph,e);return n.target?[`${n.target.label} ${n.target.slug??n.target.cid.slice(0,19)}:`,...n.entries.map(r=>` [${r.kind}] ${r.rationale??r.detail}`)]:null},explainRef(e){if(!i.explain||!i.graph||i.contextDir===void 0){d({kind:"note",text:"explain isn't available here"}),m();return}let n=i.explain(i.contextDir,i.graph,e),r=n.target?[`${n.target.label} ${n.target.slug??n.target.cid.slice(0,19)}:`,...n.entries.map(s=>` [${s.kind}] ${s.rationale??s.detail}`)].join(`
3
+ `):`unknown ref: ${e}`;d({kind:"note",text:r}),m()},subscribe(e){return k.push(e),()=>{let n=k.indexOf(e);n>=0&&k.splice(n,1)}},submit(e){if(t.confirm&&(t.confirm=null),!t.pending){if(!o){t.turns.push({role:"user",text:e}),d({kind:"user",text:e}),t.notice="the agent isn't running \u2014 nothing sent",m();return}for(t.notice=void 0,t.checkpoint=!1,q(),t.turns.push({role:"user",text:e}),d({kind:"user",text:e}),C(e),t.status="streaming",t.busySince=Date.now(),t.error=void 0,f+=1;g.length>0;)f+=1,o({type:"user_message",message_id:`u${f}-receipt`,text:g.shift()});o({type:"user_message",message_id:`u${f}`,text:e}),m()}},attachSender(e){let n=o;return o=e,()=>{o=n}},attachOnCommitted(e){b=e},attachConversationSource(e){a=e},holdReceipt(e){g.push(e),t.checkpoint=!0,m()},drainHeldReceipts(){return g.splice(0,g.length)},submitAnswer(e,n){let r=t.pending,s=r?.questions[e],u=s?.options[n]?.label;!r||!s||u==null||(j(e,{form:"answered",selected_index:n,free_text:null,choice:u}),L(),m())},submitFreeText(e,n){let r=t.pending,s=r?.questions[e],u=n.trim();!r||!s||!u||(j(e,{form:"answered",selected_index:null,free_text:u,choice:u}),L(),m())},toggleOption(e,n){let r=t.pending?.questions[e];if(!r||r.options[n]==null)return;let s=I.get(e)??new Set;s.has(n)?s.delete(n):s.add(n),I.set(e,s),m()},multiSelection(e){return[...I.get(e)??[]].sort((n,r)=>n-r)},confirmMulti(e){let n=t.pending,r=n?.questions[e];if(!n||!r)return;let s=[...I.get(e)??[]].sort((p,y)=>p-y).map(p=>r.options[p]?.label).filter(p=>p!=null);if(s.length===0)return;I.delete(e);let u=s.join(", ");j(e,{form:"answered",selected_index:null,free_text:u,choice:u}),L(),m()},goWithRecommendations(){let e=t.pending;if(!e)return{picks:""};let n=ce(e),r=null;return e.questions.forEach((s,u)=>{if(e.resolution[u])return;let p=s.recommended_index,y=p!=null?s.options[p]?.label:void 0;if(y==null){r===null&&(r=u);return}j(u,{form:"assumed",selected_index:p,free_text:null,choice:y})}),r!==null?(e.cursor=r,m(),{blocked:r}):(L(),m(),{picks:n})},reopenQuestion(){let e=t.pending;if(!e)return;let n=e.cursor<0?e.questions.length:e.cursor;for(let r=n-1;r>=0;r--)if(e.resolution[r]){e.cursor=r,m();return}},continueParked(){if(!(!o||g.length===0)){for(t.checkpoint=!1,d({kind:"continued"});g.length>0;)f+=1,o({type:"user_message",message_id:`u${f}-receipt`,text:g.shift()});f+=1,o({type:"user_message",message_id:`u${f}`,text:"continue"}),t.status="streaming",t.busySince=Date.now(),m()}},note(e){d({kind:"note",text:e}),m()},aliasOf(e){return Q.get(e)},registerAliases(e){for(let n of e)Q.set(n.ref,n.cid);W(new Map(e.filter(n=>n.id).map(n=>[n.ref,n.id]))),m()},setWorking(e){if(e!=null){if(t.status!=="idle"&&t.status!=="working")return;t.status==="idle"&&(t.busySince=Date.now()),t.status="working",t.workingLabel=e}else{if(t.status!=="working")return;t.status="idle",t.workingLabel=void 0}m()},ledger(e){e.kind==="commit"&&W(),(e.kind==="pause"||e.kind==="error"||e.kind==="summary")&&(A(),q()),(e.kind==="summary"||e.kind==="pause")&&(t.stream=null),d(e),e.kind==="commit"&&(e.ok?q(!0):se()),m()},completeSession(){H(),o?.({type:"session_complete"}),t.status="idle",m()},requestPause(){H(),t.status="pausing";let e=o;Promise.resolve().then(()=>e?.({type:"pause"})),m()},ask(e){return t.pending=K(e),F=new Map(e.map((n,r)=>[n.id,r+1])),t.status="awaiting-input",m(),new Promise(n=>{P=n})},noteCoercion(e,n){d({kind:"answer",receipt:{form:"assumed",qNum:F.get(e.id)??0,stub:ie(e),choice:n,note:"your typed answer couldn't be used here"}}),m()},onAgentEvent(e){switch(e.type){case"reasoning_delta":case"reasoning_done":case"tool_activity":case"decision_activity":{let n=t.thinking;if(t.thinking=ne(n,e),t.thinking!==n){if(e.type==="reasoning_done"&&e.present)d({kind:"thinking",tookMs:e.took_ms});else if(e.type==="tool_activity"&&e.status!=="started")d({kind:"tool",name:e.name,status:e.status==="done"?"ok":e.status,detail:e.detail});else if(e.type==="decision_activity"){let r=`\xB7 ${te(e)}`,s=t.ledger[t.ledger.length-1];s&&s.kind==="note"&&s.text===r||d({kind:"note",text:r})}}if(e.type==="reasoning_delta"){U();return}break}case"usage":t.credits={turn:e.credits,total:e.total_credits};break;case"text_delta":{let n=G;if(n&&(e.turn_id<n.turn_id||e.turn_id===n.turn_id&&e.attempt<n.attempt))return;(!n||n.turn_id!==e.turn_id||n.attempt!==e.attempt)&&(G={turn_id:e.turn_id,attempt:e.attempt},t.stream={text:""}),t.stream={text:(t.stream?.text??"")+e.text},U();return}case"progress":break;case"proposal":{c+=1,A(),t.stream=null,t.busySince&&(d({kind:"note",text:`\u2713 done in ${Math.max(1,Math.round((Date.now()-t.busySince)/1e3))}s`}),t.busySince=void 0);let n=le(e.proposal),r=i.dedupFlags?.(e.proposal);if(r)for(let s of n){let u=r.get(s.temp_ref);u&&(s.matches_existing=u)}t.turns.push({role:"agent",turnIndex:c,items:n,text:e.narrative}),R=e.narrative??null,O=!0,t.activeTurn={turnIndex:c,heading:"use-cases",items:n},T={turnIndex:c,heading:"use-cases",items:n},(t.status==="streaming"||t.status==="working")&&(t.status="idle"),t.workingLabel=void 0;break}case"design":{c+=1,A(),t.stream=null,t.busySince&&(d({kind:"note",text:`\u2713 done in ${Math.max(1,Math.round((Date.now()-t.busySince)/1e3))}s`}),t.busySince=void 0);let{items:n,heading:r}=ge(e.design),s=r.split(" + ").map(u=>de[u]??u).join(" + ");d({kind:"banner",text:`designing: ${s}`}),t.turns.push({role:"agent",turnIndex:c,items:n,itemsHeading:r,text:e.narrative}),R=e.narrative??null,O=!0,t.activeTurn={turnIndex:c,heading:r,items:n},T={turnIndex:c,heading:r,items:n},(t.status==="streaming"||t.status==="working")&&(t.status="idle"),t.workingLabel=void 0;break}case"ask_user":t.pending=K(e.questions),t.status="awaiting-input";break;case"chat_ops":{c+=1,A(),t.stream=null,t.status==="streaming"&&(t.status="idle");let n=e.chat_ops??e,r=Array.isArray(n.ops)?n.ops:[],s=n.text??e.text??"",u=i.refreshGraph?.()??i.graph,p=l=>Q.get(l)??l,y=r.map(l=>{if(!l.target)return l;let h=p(l.target),v=l.expected_cid;if(v==null&&u){let J=u.resolve(h);J&&(v=u.tipOf(J.cid))}let $=l.payload?.redirect_to,M=$&&p($);return h===l.target&&v===l.expected_cid&&M===$?l:{...l,target:h,expected_cid:v,...M!==$?{payload:{...l.payload,redirect_to:M}}:{}}}),E;try{if(!Array.isArray(n.ops))throw new Error("the agent sent an unreadable change set (no ops array) \u2014 say it again in different words");E=re(y,i.descriptor??{mint_gate:[]},{turn:c,...a?{convSourceId:a}:{}})}catch(l){t.error=l instanceof Error?l.message:String(l),t.turns.push({role:"agent",turnIndex:c,text:s,narration:t.error}),s&&d({kind:"agent",text:s}),d({kind:"error",title:t.error,detail:[]});break}let{chatOps:S,ambiguous:N}=E;if(N.length>0){let l=N[0];t.confirm={kind:"ambiguity-confirm",prompt:`did you mean edit or ${l.kinds.filter(h=>h!=="edit").join("/")} on ${l.target}?`},t.turns.push({role:"agent",turnIndex:c,text:s}),s&&d({kind:"agent",text:s});break}if(_(S),i.commitChatTurn&&S.length>0){let l=i.commitChatTurn({contextDir:i.contextDir??"",graph:i.refreshGraph?.()??i.graph,ops:S,by:i.by??{kind:"human",id:"owner"},...i.descriptor?.mint_gate?{mintable:i.descriptor.mint_gate}:{}});if(l.errors)t.error=l.errors.map(h=>h.detail).join("; "),t.turns.push({role:"agent",turnIndex:c,text:s}),d({kind:"commit",ok:!1,line:"commit failed \u2014 nothing landed",warnings:l.errors.map(h=>`${h.code}: ${h.detail}`)}),g.push(["COMMIT FAILED (chat turn) \u2014 nothing landed; do not assume any of your last ops applied.",...l.errors.map(h=>`- ${h.code}: ${h.detail}`),...l.errors.some(h=>h.code==="UNKNOWN_FIELD")?["If you were changing citations or matched-existing content, that is proposal territory (approve/re-propose) \u2014 a chat edit can only replace a node's own schema fields."]:[]].join(`
4
+ `)),s&&d({kind:"agent",text:s});else{l.applied.length>0&&i.session?.markApplied(l.applied);let h=x(l);t.turns.push({role:"agent",turnIndex:c,text:s,narration:h}),d({kind:"commit",ok:!0,line:h});let v=i.refreshGraph?.();if(v&&b&&b(v),v)try{w+=1;let V=i.descriptor?.mint_gate?.includes("usecase")?"extract":"design",$=Z({verb:V,commitN:w,phase:"chat",committed:l.minted.map(M=>({cid:M.cid,...M.slug?{logical_id:M.slug}:{}}))},v);g.push($.text)}catch{}s&&d({kind:"agent",text:s})}}else t.turns.push({role:"agent",turnIndex:c,text:s}),s&&d({kind:"agent",text:s});C(s);break}case"done":case"session_complete":A(),q(),t.status="idle",o=null;break;case"error":A(),q(),t.stream=null,t.status="idle",t.error=e.message,o=null,d({kind:"error",title:e.message,detail:[]});break;case"session_paused":break;default:break}m()}}}export{ce as a,ie as b,be as c};