@testmuai/kane-cli 0.8.5 → 0.8.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{ChatSurface-HAIVTS4J.js → ChatSurface-3PEXML4X.js} +1 -1
- package/dist/{ChromeProfilePicker-5ILSVC2K.js → ChromeProfilePicker-E3CZ52RH.js} +1 -1
- package/dist/{CliFeedbackPrompt-LFKEYMKP.js → CliFeedbackPrompt-BEVZRLQA.js} +1 -1
- package/dist/{CliUploadProgress-Y7ITY2I7.js → CliUploadProgress-V2FLLVR6.js} +1 -1
- package/dist/ConfigView-ZOGKVFQT.js +2 -0
- package/dist/EvidenceViewOffer-KWX27WNZ.js +2 -0
- package/dist/FolderPicker-EIKQSSF6.js +2 -0
- package/dist/{InfoBox-HWMHNWPM.js → InfoBox-4TNE7QMG.js} +1 -1
- package/dist/{LinksBox-TAGYCFFO.js → LinksBox-TXO5X5UD.js} +1 -1
- package/dist/{ProfilesView-QJBR3RCM.js → ProfilesView-S4YPEZEF.js} +1 -1
- package/dist/{ProjectPicker-PP75ILZU.js → ProjectPicker-LWFX2QT2.js} +1 -1
- package/dist/{SaveSessionPrompt-UCRET3II.js → SaveSessionPrompt-MJTCIQIZ.js} +1 -1
- package/dist/SingleShotApp-5LCIH6DQ.js +2 -0
- package/dist/{SummaryBox-SLM3OFS2.js → SummaryBox-UIVK3QDR.js} +1 -1
- package/dist/TestMdRunView-RE5GX5QX.js +2 -0
- package/dist/{TestrunEvidenceTable-PTIBYAXO.js → TestrunEvidenceTable-GYGVNCYW.js} +1 -1
- package/dist/{WhoamiView-WPHMNYUV.js → WhoamiView-NRGMMLL4.js} +1 -1
- package/dist/{app-download-GYQYLGT3.js → app-download-HTQOD3YF.js} +1 -1
- package/dist/{auth-3DLNMZC2.js → auth-5URO2XJU.js} +1 -1
- package/dist/{binary-XJ3RF3VO.js → binary-2U4YTTFS.js} +1 -1
- package/dist/{bind-2N4Q6YKH.js → bind-NO4TMSHJ.js} +3 -3
- package/dist/{bootstrap-5IHKW5SE.js → bootstrap-UOEW3VZM.js} +1 -1
- package/dist/bridge-P2EBLXPY.js +2 -0
- package/dist/{changelog-WCCTI47M.js → changelog-7BPYLUDK.js} +1 -1
- package/dist/chat-committer-GUK6IBCL.js +2 -0
- package/dist/{chat-controller-R4THYYPU.js → chat-controller-6GUUMUVP.js} +1 -1
- package/dist/{chunk-EFRJNPBZ.js → chunk-2RO2BWCZ.js} +2 -2
- package/dist/chunk-3BY7MX3D.js +8 -0
- package/dist/{chunk-AMULIFC5.js → chunk-3IM5QGVV.js} +1 -1
- package/dist/{chunk-MUGMUKSZ.js → chunk-3YKNJIVB.js} +1 -1
- package/dist/{chunk-7JUUNZQP.js → chunk-44PZPNXJ.js} +1 -1
- package/dist/{chunk-GZ4X53ZA.js → chunk-46HYKID6.js} +2 -2
- package/dist/{chunk-CNNJ4U2L.js → chunk-4EFDEDTL.js} +1 -1
- package/dist/chunk-5ZV64NAG.js +5 -0
- package/dist/{chunk-E3BXNQYE.js → chunk-6AUSG5SB.js} +1 -1
- package/dist/{chunk-AJPLHW4T.js → chunk-6YVVTYVO.js} +1 -1
- package/dist/{chunk-HFCDUFV3.js → chunk-72J4V3DA.js} +1 -1
- package/dist/{chunk-4UMQDH52.js → chunk-76ILJPZF.js} +1 -1
- package/dist/{chunk-NLECZCMZ.js → chunk-7CU5EBC6.js} +1 -1
- package/dist/{chunk-O3AY6JHJ.js → chunk-7EFG27IZ.js} +4 -4
- package/dist/chunk-7UCICMK7.js +5 -0
- package/dist/{chunk-M335FQYJ.js → chunk-7VAE7WXF.js} +2 -2
- package/dist/{chunk-DJ7T7BMV.js → chunk-A66ZGHO2.js} +1 -1
- package/dist/chunk-AJXOJF2X.js +4 -0
- package/dist/{chunk-K7UYWAZH.js → chunk-AUERMBX5.js} +1 -1
- package/dist/{chunk-PCOSE5SW.js → chunk-B27X3C2E.js} +1 -1
- package/dist/chunk-B2KXIFZD.js +2 -0
- package/dist/{chunk-R7OGNE3W.js → chunk-BISBPWN3.js} +1 -1
- package/dist/{chunk-RY6TFVAX.js → chunk-BPHQNTUD.js} +1 -1
- package/dist/{chunk-JFAFKHDX.js → chunk-BZAGVBCX.js} +1 -1
- package/dist/chunk-C4OVX65Q.js +4 -0
- package/dist/{chunk-JRQKUQWL.js → chunk-C5ZIKKIB.js} +1 -1
- package/dist/{chunk-PUFJEU46.js → chunk-C765HUXU.js} +1 -1
- package/dist/{chunk-MJ56GUKS.js → chunk-DJC6MLO4.js} +1 -1
- package/dist/{chunk-PEI2566X.js → chunk-DMOZM22N.js} +1 -1
- package/dist/{chunk-FRSHEJUS.js → chunk-DSNB7EI6.js} +1 -1
- package/dist/{chunk-JN2DP4R2.js → chunk-DTBKKC2R.js} +1 -1
- package/dist/chunk-E5C3HUIY.js +2 -0
- package/dist/chunk-E5Q5CDOX.js +2 -0
- package/dist/{chunk-7PADFQ5S.js → chunk-E6AF53HZ.js} +42 -43
- package/dist/chunk-EU5ZH334.js +2 -0
- package/dist/{chunk-GFKCTYCA.js → chunk-F43KOMVB.js} +1 -1
- package/dist/{chunk-FDWEL5HR.js → chunk-F7RR24BL.js} +1 -1
- package/dist/{chunk-KWKUMBHS.js → chunk-FVKLNQ4T.js} +2 -2
- package/dist/{chunk-ZGBSGZZM.js → chunk-GAO6ZMCT.js} +1 -1
- package/dist/chunk-GDB2V6QA.js +21 -0
- package/dist/{chunk-5NSYHRDN.js → chunk-GJ6RJVXH.js} +1 -1
- package/dist/{chunk-OWTEHU6B.js → chunk-GYTZLUFV.js} +1 -1
- package/dist/{chunk-WLOGO44E.js → chunk-HAGJA7KG.js} +1 -1
- package/dist/{chunk-7KORP5FF.js → chunk-HEWWWMUN.js} +1 -1
- package/dist/{chunk-KX2GOJ4C.js → chunk-HHQ67JCU.js} +1 -1
- package/dist/chunk-HL4UXOHV.js +2 -0
- package/dist/{chunk-DUAXZYAD.js → chunk-HLXOYLZV.js} +3 -3
- package/dist/{chunk-BJHII5SD.js → chunk-HO3T5LJH.js} +1 -1
- package/dist/{chunk-PWYEOBXV.js → chunk-IJABR5SX.js} +1 -1
- package/dist/chunk-ILKSL4PI.js +4 -0
- package/dist/{chunk-2WSOPZJU.js → chunk-IQBKCLLR.js} +1 -1
- package/dist/{chunk-GYF4CH62.js → chunk-IRPAWAK7.js} +2 -2
- package/dist/{chunk-T3XDMR5B.js → chunk-K7VX6YIT.js} +1 -1
- package/dist/{chunk-DCUT3GJA.js → chunk-LOMPRMG3.js} +1 -1
- package/dist/{chunk-ZFZ7YXEU.js → chunk-LRZXVDPY.js} +1 -1
- package/dist/chunk-LWZ7EIXX.js +2 -0
- package/dist/{chunk-Q6JHBDW2.js → chunk-MROHDW4W.js} +1 -1
- package/dist/{chunk-CCUGKBIH.js → chunk-N2N5T5JN.js} +1 -1
- package/dist/{chunk-TYI4MLFJ.js → chunk-NM6PEYED.js} +1 -1
- package/dist/{chunk-TJZMYU2W.js → chunk-NQFAZM2D.js} +1 -1
- package/dist/{chunk-W27F2NWA.js → chunk-OADHU5HL.js} +1 -1
- package/dist/{chunk-66BSTNLD.js → chunk-OHD4CZXT.js} +1 -1
- package/dist/{chunk-T5LKD2OB.js → chunk-P4JUY54O.js} +1 -1
- package/dist/chunk-Q3S5EKX5.js +21 -0
- package/dist/{chunk-AFPHLUQ5.js → chunk-Q4CTSXDM.js} +1 -1
- package/dist/{chunk-CGYSFLM2.js → chunk-QQ67Z4IW.js} +1 -1
- package/dist/{chunk-NHOHQBIF.js → chunk-QZB7CBRO.js} +1 -1
- package/dist/{chunk-PB3GADUD.js → chunk-R2JRQD4I.js} +1 -1
- package/dist/{chunk-CLGC7VEO.js → chunk-SWXEBLKX.js} +1 -1
- package/dist/{chunk-5S46D5AJ.js → chunk-SZTUZZEA.js} +1 -1
- package/dist/{chunk-PQUMOFT5.js → chunk-T3DVIDBA.js} +1 -1
- package/dist/{chunk-YFLKS4UV.js → chunk-T4LAHU57.js} +3 -3
- package/dist/{chunk-4D3DNCQY.js → chunk-TKQSIKMR.js} +1 -1
- package/dist/chunk-TMFFHGCT.js +17 -0
- package/dist/{chunk-35EUIBYJ.js → chunk-U35Y7SGB.js} +1 -1
- package/dist/{chunk-V444REBC.js → chunk-UASEGQ7B.js} +1 -1
- package/dist/{chunk-K2QV7FGP.js → chunk-UFYIQ4E3.js} +1 -1
- package/dist/chunk-UOLERTKE.js +2 -0
- package/dist/{chunk-NYSMQ7UY.js → chunk-VHA7UNDW.js} +1 -1
- package/dist/{chunk-JJWQUQJ2.js → chunk-VMRP44MN.js} +1 -1
- package/dist/{chunk-FTZPWXF7.js → chunk-VOXDZS4N.js} +1 -1
- package/dist/{chunk-6KPPGMO2.js → chunk-WNHLKDOT.js} +1 -1
- package/dist/chunk-X7R2JWOJ.js +4 -0
- package/dist/chunk-XAQ3Y63J.js +21 -0
- package/dist/chunk-YC2TFACE.js +5 -0
- package/dist/{chunk-UX3KPYTI.js → chunk-YC6HYBLN.js} +1 -1
- package/dist/{chunk-ZIRMSWKS.js → chunk-YDEK2FJQ.js} +1 -1
- package/dist/chunk-YGVY63PE.js +20 -0
- package/dist/chunk-YKYZKBMH.js +26 -0
- package/dist/{chunk-BAL7E4OH.js → chunk-YYSWJU6H.js} +1 -1
- package/dist/{chunk-VRVFPMCR.js → chunk-Z3EEMIVV.js} +1 -1
- package/dist/{chunk-6BTZ2Q4P.js → chunk-Z7HUW3L4.js} +1 -1
- package/dist/chunk-Z7S3IWUX.js +2 -0
- package/dist/{chunk-TCK3QMKY.js → chunk-ZFRWVWUR.js} +1 -1
- package/dist/{chunk-Z2T7E5HM.js → chunk-ZH2ROVHE.js} +2 -2
- package/dist/committer-JC6BIBNR.js +2 -0
- package/dist/{config-OKTAPFOT.js → config-XNDP425N.js} +1 -1
- package/dist/cover-cmd-HREOYWWD.js +3 -0
- package/dist/{credentials-SO3DSQEM.js → credentials-ZTBWB3LK.js} +1 -1
- package/dist/{deps-bundle-FRM65BQO.js → deps-bundle-OHCYH5KL.js} +1 -1
- package/dist/{deps-resolve-RPZORKUN.js → deps-resolve-K2NX2W3K.js} +1 -1
- package/dist/design-committer-IIHKNEYF.js +2 -0
- package/dist/device-ref-LAZWPRQN.js +2 -0
- package/dist/dispatch-JZWIFKRB.js +2 -0
- package/dist/doctor-XXOGVMAI.js +2 -0
- package/dist/dossier-2M62K2PA.js +3 -0
- package/dist/evidence-FN2SQB6Z.js +2 -0
- package/dist/evolve-cmd-WQB7E2B5.js +2 -0
- package/dist/{explain-UAAQWHYR.js → explain-AOZNHWMB.js} +1 -1
- package/dist/{explain-cmd-2TKO7GRW.js → explain-cmd-2SCD5T6U.js} +1 -1
- package/dist/{explain-cmd-EX24XKD6.js → explain-cmd-7VTWRROR.js} +1 -1
- package/dist/{extract-bind-EW7XUDLQ.js → extract-bind-3YXY7ZU2.js} +3 -3
- package/dist/{extract-cmd-HOVGMBGM.js → extract-cmd-WGXEJ54C.js} +2 -2
- package/dist/{feeder-C3TOJPKK.js → feeder-GVZSWX6Q.js} +1 -1
- package/dist/gaps-cmd-MFZ52DC7.js +3 -0
- package/dist/{generate-headless-FYTJULPG.js → generate-headless-PCNAJ2LS.js} +2 -2
- package/dist/index.js +141 -135
- package/dist/ingest-TTSDUMH5.js +2 -0
- package/dist/ingest-cmd-D2MD6EAK.js +2 -0
- package/dist/install-RHINEFR5.js +2 -0
- package/dist/{interactive-bind-PSEYAL54.js → interactive-bind-ZFMG2JIX.js} +4 -4
- package/dist/lifecycle-cmd-5FRGYY3M.js +2 -0
- package/dist/list-cmd-DD4WYJSH.js +3 -0
- package/dist/{list-commands-2SVSEAP6.js → list-commands-64THS67Y.js} +1 -1
- package/dist/logical-ids-U2OUMYCP.js +2 -0
- package/dist/login-flow-B5J6JXQN.js +2 -0
- package/dist/{maintenance-cmd-6XSVO6FO.js → maintenance-cmd-7V44VGL4.js} +1 -1
- package/dist/{mobile-prompts-T6HZ2YLY.js → mobile-prompts-RITBS32L.js} +1 -1
- package/dist/{persist-recorded-session-O2NCYTSD.js → persist-recorded-session-Z5SCYWXR.js} +1 -1
- package/dist/phase-seed-ATH337WF.js +2 -0
- package/dist/pipeline-HMFLLUZJ.js +2 -0
- package/dist/prepare-target-HOEFIKXN.js +2 -0
- package/dist/readmodel-UZETCXV6.js +2 -0
- package/dist/reconcile-cmd-Q7CBNPRX.js +2 -0
- package/dist/reconcile-deps-XEUZHUQX.js +4 -0
- package/dist/reconcile-engine-ES2INERY.js +2 -0
- package/dist/{recording-banner-5VXVKCV4.js → recording-banner-NLS7K2RV.js} +1 -1
- package/dist/records-XWF6KDQH.js +2 -0
- package/dist/registry-E5RSXYQJ.js +2 -0
- package/dist/{require-project-folder-2IO6IX5W.js → require-project-folder-V4F74R4A.js} +1 -1
- package/dist/resolve-run-intent-WSOCGJUN.js +2 -0
- package/dist/{resolver-CBTWTZZR.js → resolver-7EAM4A6O.js} +1 -1
- package/dist/revert-2UCOMQ4J.js +2 -0
- package/dist/review-cmd-VN6VGUWJ.js +4 -0
- package/dist/run-45ODACZR.js +2 -0
- package/dist/run-ZYARNPAS.js +2 -0
- package/dist/{run-test-md-664ASWRQ.js → run-test-md-CPGKD3DD.js} +2 -2
- package/dist/{sessions-cmd-ZZIZN2VB.js → sessions-cmd-ME7NM6ES.js} +1 -1
- package/dist/{skill-installer-QLQK4JJE.js → skill-installer-WEV2M32J.js} +1 -1
- package/dist/{spawner-ANLF7OX3.js → spawner-GG6YQB4A.js} +1 -1
- package/dist/{structured-answers-5EY2AZN7.js → structured-answers-2WOTULBQ.js} +1 -1
- package/dist/tcg-generate-DASCY23M.js +2 -0
- package/dist/{testmd-actions-QZD3N4EH.js → testmd-actions-X6HEL5NH.js} +1 -1
- package/dist/token-refresh-ZTQFC3Q3.js +2 -0
- package/dist/{validate-basic-D7IJUFUQ.js → validate-basic-QJL4DCKY.js} +1 -1
- package/dist/verdicts-CRNN765C.js +2 -0
- package/dist/{version-check-JRLPWQ6T.js → version-check-KONSQ4M3.js} +1 -1
- package/dist/{view-cmd-KPJTP4DI.js → view-cmd-ZSMU4I4J.js} +1 -1
- package/dist/walk-session-X2N4XHLU.js +2 -0
- package/dist/{with-telemetry-ASNQQBGP.js → with-telemetry-Y6MVROKX.js} +1 -1
- package/package.json +11 -11
- package/dist/ConfigView-OECNNCXC.js +0 -2
- package/dist/EvidenceViewOffer-FODRAS6Z.js +0 -2
- 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/chat-committer-ZWWCLJFD.js +0 -2
- package/dist/chunk-2K2BX23I.js +0 -2
- package/dist/chunk-3AJ3QSF5.js +0 -15
- package/dist/chunk-3Q6WAK6P.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-DEZ7CXGM.js +0 -21
- package/dist/chunk-G4AFOZKU.js +0 -2
- package/dist/chunk-HQWLSA5M.js +0 -2
- package/dist/chunk-KBMQGNKO.js +0 -26
- package/dist/chunk-LA2EMSHE.js +0 -2
- package/dist/chunk-LQQXPY5B.js +0 -4
- package/dist/chunk-R5T4RLF5.js +0 -2
- package/dist/chunk-TH47OOBV.js +0 -4
- package/dist/chunk-TRJUD3XJ.js +0 -5
- package/dist/chunk-UOMRMCMI.js +0 -2
- package/dist/chunk-VAYBKR76.js +0 -4
- package/dist/chunk-VT2XNEOD.js +0 -10
- package/dist/chunk-WYST42WI.js +0 -7
- package/dist/chunk-X2FM67OM.js +0 -4
- package/dist/chunk-ZSXDZI56.js +0 -20
- package/dist/committer-SWEWEYNX.js +0 -2
- package/dist/cover-cmd-7JILZJUK.js +0 -3
- package/dist/design-committer-VYT6NU3T.js +0 -2
- package/dist/dispatch-OZRMWY25.js +0 -2
- package/dist/doctor-VWGEQYBB.js +0 -2
- package/dist/dossier-KTLTGT2X.js +0 -3
- package/dist/evidence-5AUZMKE3.js +0 -2
- package/dist/evolve-cmd-TWYJL4EG.js +0 -2
- package/dist/gaps-cmd-3ZX3PZF4.js +0 -3
- package/dist/ingest-4447MYLF.js +0 -2
- package/dist/ingest-cmd-RJLTFNMN.js +0 -2
- package/dist/install-46S4VOZ4.js +0 -2
- package/dist/lifecycle-cmd-O2324GN6.js +0 -2
- package/dist/list-cmd-N4KMA34H.js +0 -3
- package/dist/logical-ids-TEBCQJGO.js +0 -2
- package/dist/login-flow-U43QVFPH.js +0 -2
- package/dist/phase-seed-DIRETNU6.js +0 -2
- package/dist/pipeline-BHEA7ODT.js +0 -2
- package/dist/prepare-target-27UN4KNO.js +0 -2
- package/dist/readmodel-XOYGGQ3S.js +0 -2
- package/dist/reconcile-cmd-FU3JIHTO.js +0 -2
- package/dist/reconcile-deps-SUKZA2FL.js +0 -4
- package/dist/reconcile-engine-ILL4M3NW.js +0 -2
- package/dist/records-IOZTZUZV.js +0 -2
- package/dist/registry-BKV3EDTK.js +0 -2
- package/dist/resolve-run-intent-ZML3HKG7.js +0 -2
- package/dist/revert-NQ7GEVSE.js +0 -2
- package/dist/review-cmd-DQRKQUMG.js +0 -4
- package/dist/run-EXIYK6PU.js +0 -2
- package/dist/run-R7GND73C.js +0 -2
- package/dist/tcg-generate-VBC5ODDI.js +0 -2
- package/dist/token-refresh-PIUX5OFA.js +0 -2
- package/dist/types-VYEOJ6U2.js +0 -2
- package/dist/verdicts-EO5TZ5BW.js +0 -2
- package/dist/walk-session-IODOH7QU.js +0 -2
package/dist/chunk-LA2EMSHE.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as R}from"./chunk-ZIRMSWKS.js";import{x as i}from"./chunk-CCUGKBIH.js";import{a as X}from"./chunk-HCBYKLMW.js";import{a,b as l,i as p}from"./chunk-C44QQJR4.js";import{a as G}from"./chunk-6YGTRKDT.js";import{e as P}from"./chunk-UR6MHSHU.js";var x=P(G(),1);var e=P(X(),1),f=5;function K(t,I){if(!I)return t;let c=I.toLowerCase();return t.filter(B=>B.label.toLowerCase().includes(c))}function J(t){let{title:I,items:c,loading:B=!1,loadingText:Y,error:L=null,itemNoun:v="items",onSelect:F,onCancel:E,defaultActiveId:w,onTab:y,extraHint:H}=t,[g,d]=(0,x.useState)(0),[S,u]=(0,x.useState)(0),[s,A]=(0,x.useState)(""),[C,h]=(0,x.useState)(null);(0,x.useEffect)(()=>{if(c.length===0)return;if(t.preserveSelectionById&&C!==null){let o=c.findIndex(n=>n.id===C);if(o>=0){u(Math.floor(o/f)),d(o%f);return}}let r=w?c.findIndex(o=>o.id===w):c.findIndex(o=>o.isActive);r>=0?(u(Math.floor(r/f)),d(r%f),t.preserveSelectionById&&h(c[r].id)):t.preserveSelectionById&&(u(0),d(0),h(c[0]?.id??null))},[c,w,t.preserveSelectionById,C]),(0,x.useEffect)(()=>{if(!t.onSearch)return;let r=setTimeout(()=>t.onSearch(s),t.searchDebounceMs??250);return()=>clearTimeout(r)},[s,t.onSearch,t.searchDebounceMs]);let b=t.onSearch?c:K(c,s),D=S*f,N=Math.min(D+f,b.length),M=Math.ceil(b.length/f),O=N-D,T=b.slice(D,N);return p((r,o)=>{if(L){o.escape&&E();return}if(o.escape){s?(A(""),d(0),u(0)):E();return}if(o.tab&&y){y();return}if(o.upArrow){if(g>0){let n=g-1;d(n),t.preserveSelectionById&&h(T[n]?.id??null)}else if(S>0){let n=S-1,m=f-1;u(n),d(m),t.preserveSelectionById&&h(b[n*f+m]?.id??null)}return}if(o.downArrow){if(g<O-1){let n=g+1;d(n),t.preserveSelectionById&&h(T[n]?.id??null)}else if(S<M-1){let n=S+1,m=0;u(n),d(m),t.preserveSelectionById&&h(b[n*f+m]?.id??null)}return}if(o.return&&T[g]){if(T[g].disabled)return;F(T[g]);return}if(o.backspace||o.delete){A(n=>n.slice(0,-1)),d(0),u(0);return}r&&!o.ctrl&&!o.meta&&(A(n=>n+r),d(0),u(0))},{isActive:!B}),B?(0,e.jsxs)(a,{flexDirection:"column",borderStyle:"round",borderColor:i.orange,paddingX:2,paddingY:1,children:[(0,e.jsx)(l,{color:i.orange,bold:!0,children:I}),(0,e.jsx)(a,{marginTop:1,children:(0,e.jsx)(l,{color:i.secondary,children:Y??`Loading ${v}\u2026`})})]}):L?(0,e.jsxs)(a,{flexDirection:"column",borderStyle:"round",borderColor:i.red,paddingX:2,paddingY:1,children:[(0,e.jsx)(l,{color:i.red,bold:!0,children:I}),(0,e.jsx)(a,{marginTop:1,children:(0,e.jsx)(l,{color:i.red,children:L})}),(0,e.jsx)(R,{bindings:[]})]}):(0,e.jsxs)(a,{flexDirection:"column",borderStyle:"round",borderColor:i.orange,paddingX:2,paddingY:1,children:[(0,e.jsxs)(a,{children:[(0,e.jsx)(l,{color:i.orange,bold:!0,children:I}),(0,e.jsxs)(l,{color:i.dim,children:[" (",b.length,!t.onSearch&&s?`/${c.length}`:""," ",v,t.loadingMore?" \xB7 loading more":"",")"]})]}),(0,e.jsxs)(a,{marginTop:1,children:[(0,e.jsx)(l,{color:i.secondary,children:s?"filter: ":""}),s?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(l,{children:s}),(0,e.jsx)(l,{inverse:!0,children:" "})]}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)(l,{color:i.dim,children:["Search ",v,"\u2026"]}),(0,e.jsx)(l,{inverse:!0,children:" "})]})]}),(0,e.jsx)(a,{flexDirection:"column",marginTop:1,children:t.searching?(0,e.jsxs)(l,{color:i.secondary,children:["Searching ",v,"\u2026"]}):b.length===0?(0,e.jsxs)(l,{color:i.dim,children:["No ",v,' match "',s,'"']}):T.map((r,o)=>{let n=o===g,m=n?"\u276F ":" ",$=r.disabled?i.muted:r.isActive?i.green:n?i.orange:void 0;return(0,e.jsxs)(a,{flexDirection:"column",children:[(0,e.jsxs)(l,{color:$,children:[m,r.label,r.isActive&&!r.disabled?" \u25CF selected":""]}),n&&r.disabled&&r.disabledHint&&(0,e.jsxs)(l,{color:i.red,children:[" ",r.disabledHint]})]},r.id)})}),!t.searching&&M>1&&(0,e.jsx)(a,{marginTop:1,children:(0,e.jsxs)(l,{color:i.dim,children:["Page ",S+1,"/",M]})}),t.footer&&(0,e.jsx)(a,{marginTop:1,flexDirection:"column",children:t.footer}),(0,e.jsx)(R,{bindings:[{keys:"\u2191\u2193",label:"navigate"},{keys:"type",label:"to search"},{keys:"\u21B5",label:"select"},...y&&H?[{keys:"tab",label:H}]:[]],escBackLabel:s?"clear":"back to chat"})]})}export{J as a};
|
package/dist/chunk-LQQXPY5B.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{d as ae,e as ue}from"./chunk-AXTPNZPX.js";import{a as oe}from"./chunk-L2TV4G56.js";import{b as K,d as se}from"./chunk-6KPPGMO2.js";import{d as ie}from"./chunk-NVGBE2DR.js";var ge=new Set(["approve","edit","reject"]);function pe(s,t){return`chatop:${t}:${s.target??"new"}:${s.op}:${s.seq}`}function me(s,t,y,k){let c=pe(s,t),h=s.payload;switch(s.op){case"approve":return{kind:"approve",target:s.target,expectedCid:s.expected_cid,eventId:c};case"edit":{let{reason:o,...v}=h;return{kind:"edit",target:s.target,expectedCid:s.expected_cid,edit:v,reason:o,eventId:c}}case"enhance":return{kind:"enhance",target:s.target,expectedCid:s.expected_cid,edges:h.edges??[],eventId:c};case"reject":return{kind:"reject",target:s.target,expectedCid:s.expected_cid,reason:h.reason??"",redirectTo:h.redirect_to,eventId:c};case"add":{let o=h.proposal_item??{},v=String(o.label??"");if(!y.mint_gate.includes(v))throw new Error(`GATED_LABEL: cannot mint "${v}" (gate: ${y.mint_gate.join(", ")})`);let l=o.cite??{},m=o.conv_source_id??k;if(!m||typeof l.turn!="number"||!l.quote)throw new Error("INVALID_ADD: a chat add requires a conversation cite {turn, quote} and conv_source_id");let _=o.content,C=_&&typeof _=="object"&&!Array.isArray(_)&&Object.keys(_).length>0?_:null,w=new Set(["label","cite","conv_source_id","content","rationale","edges"]),x=C??Object.fromEntries(Object.entries(o).filter(([D])=>!w.has(D)));return{kind:"add",label:v,content:x,cite:{turn:l.turn,quote:l.quote},convSourceId:m,rationale:o.rationale,eventId:c}}}}function ce(s,t,y={}){let k=y.turn??0,c=[],h=[];for(let l of s)(l.op==="add"||l.op==="enhance")&&h.push(l);let o=new Map;for(let l of s){if(!ge.has(l.op)||!l.target)continue;let m=o.get(l.target)??[];m.push(l),o.set(l.target,m)}for(let[l,m]of o){let _=Math.max(...m.map(w=>w.seq)),C=m.filter(w=>w.seq===_);if(C.length>1){c.push({target:l,seq:_,kinds:C.map(w=>w.op)});continue}h.push(C[0])}return{chatOps:h.sort((l,m)=>l.seq-m.seq).map(l=>me(l,k,t,y.convSourceId)),ambiguous:c}}function fe(s){let t=[];return s.questions.forEach((y,k)=>{if(s.resolution[k])return;let c=y.recommended_index!=null?y.options[y.recommended_index]?.label:void 0;c!=null&&t.push(y.risk==="high"?`${c} \u203C`:c)}),t.length>3?`${t.slice(0,3).join(" \xB7 ")} \xB7 +${t.length-3} more`:t.join(" \xB7 ")}function le(s){let t=s.text.replace(/\?+\s*$/,"");return t.length<=36?t:`${t.slice(0,33)}\u2026`}function he(s){return s.use_cases??[]}var ke={acs:"acceptance criteria",scenarios:"scenarios",exercises:"exercises",tests:"tests",gaps:"gaps"};function be(s){let t=[],y=[],k=(o,v)=>{v.length!==0&&(y.push(o),t.push(...v))},c=o=>typeof o=="string"&&/^[a-z]{1,4}\d{1,4}$/i.test(o)?o:null,h=o=>{let v=c(o.automates)??"1 scenario",l=o.verifies??[],m=l.map(c).filter(w=>w!==null).slice(0,2),_=l.length-m.length,C=m.length?`${m.join(" ")}${_>0?` +${_}`:""}`:`${l.length} ACs`;return`covers ${v} \xB7 verifies ${C}`};return k("acs",(s.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",(s.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("exercises",(s.exercises??[]).map(o=>({temp_ref:c(o.scenario)??"wiring",title:`${c(o.scenario)??"scenario"} exercises ${c(o.ac)??"1 AC"}`,kind:"exercise",badge:"wires",why:o.rationale}))),k("tests",(s.tests??[]).map(o=>({temp_ref:o.temp_ref,title:o.title,kind:"test",why:h(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",(s.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:y.join(" + ")||"design"}}function Se(s={}){let t={turns:[],thinking:ae(),pending:null,confirm:null,status:"idle",ledger:[],activeTurn:null,stream:null,checkpoint:!1},y=e=>{let n=[],r=e.minted.map(a=>a.slug).filter(Boolean);r.length&&n.push(`added ${r.join(", ")}`);let i=e.applied.length-e.minted.length;return i>0&&n.push(`${i} change${i===1?"":"s"} applied`),e.staleDelta.length&&n.push(`stales ${e.staleDelta.length}`),n.join(" \xB7 ")||"no changes"},k=[];s.onRender&&k.push(s.onRender);let c=0,h=0,o=null,v=null,l=null,m=[],_=0,C=e=>{if(!(!l||!s.contextDir||!e.trim()))try{let n=s.refreshGraph?.()??s.graph;if(!n)return;se({contextDir:s.contextDir,graph:n,sourceId:l,text:e,by:s.by??{kind:"human",id:"owner"}})}catch{}},w=e=>{if(!l||!s.contextDir)return;let n=s.refreshGraph?.()??s.graph,r=n?.heads.get(l),i=n?.convChains.get(l);if(!n||typeof r!="string"||!i)return;let a=n.getNode(r)?.content?.blob,u=typeof a=="string"?ie(s.contextDir,a)?.toString("utf8")??"":"";if(u)for(let f of e){if(f.kind!=="add"||f.convSourceId!==l)continue;let F=K(u,f.cite.turn);if(!(F!==null&&F.includes(f.cite.quote)))for(let $=i.turns;$>=1;$--){let z=K(u,$);if(z!==null&&z.includes(f.cite.quote)){f.cite={...f.cite,turn:$};break}}}},x={startedAt:null,thinkMs:0,toolCalls:0,tools:new Map},D=()=>{x.startedAt??=Date.now()},A=()=>{if(x.toolCalls>0){let e=x.startedAt!=null?Math.max(1,Math.round((Date.now()-x.startedAt)/1e3)):Math.max(1,Math.round(x.thinkMs/1e3));g({kind:"worked",durS:e,toolCalls:x.toolCalls,tools:[...x.tools.entries()].map(([n,r])=>({name:n,n:r}))})}x.startedAt=null,x.thinkMs=0,x.toolCalls=0,x.tools.clear()},I=null,G=new Map,V=e=>JSON.stringify([e.id,e.text,e.options.map(n=>n.label)]),q=null,J=new Map,U=new Map,Y=null,p=()=>{j&&(clearTimeout(j),j=null);for(let e of k)e()},j=null,X=()=>{j||(j=setTimeout(()=>{j=null;for(let e of k)e()},80))},B=0,g=e=>{e.kind==="childClose"&&B>0&&(B-=1),B>0&&e.kind!=="childOpen"&&e.kind!=="childBack"&&(e.era=B),e.kind==="childOpen"&&(B+=1),t.ledger.push(e)},E=null,W=!1,L=(e=!1)=>{E?g({kind:"agent",text:E}):e&&W&&g({kind:"note",text:'chat to refine ("looks good" approves; /done finishes)'}),E=null,W=!1},de=()=>{E=null,W=!1},P=null,H=e=>{if(P){if(e)for(let n of P.items){let r=e.get(n.temp_ref);r&&(n.logical_id=r)}g({kind:"turn",...P}),P=null}},M=()=>{H(),t.activeTurn&&(t.activeTurn=null)},Z=(e,n)=>n.choice||(n.selected_index!=null?e.options[n.selected_index]?.label??"?":"?"),N=()=>{let e=t.pending;if(!e)return;if(!e.resolution.every(Boolean)){e.cursor=e.resolution.findIndex(i=>i===null);return}let n=e.questions.map((i,a)=>{let u=e.resolution[a];return u.form==="deferred"?{id:i.id,selected_index:null,free_text:null}:{id:i.id,selected_index:u.selected_index,free_text:u.free_text}});t.pending=null,t.status=t.status==="pausing"?"pausing":"streaming",t.status==="streaming"&&(t.busySince=Date.now());let r=I;I=null,r?.(n)},R=(e,n)=>{let r=t.pending,i=r.questions[e],a=r.resolution[e];r.resolution[e]=n;let u=le(i);a?g({kind:"answer",receipt:{form:"changed",qNum:e+1,stub:u,choice:Z(i,n),prev:a.choice}}):n.form==="deferred"?g({kind:"answer",receipt:{form:"deferred",qNum:e+1,stub:u}}):g({kind:"answer",receipt:{form:n.form,qNum:e+1,stub:u,choice:Z(i,n)}})},ee=()=>{let e=t.pending;e&&(e.questions.forEach((n,r)=>{e.resolution[r]||R(r,{form:"deferred",selected_index:null,free_text:null,choice:""})}),N())},Q=new Map,te=e=>{Q.clear();let n={high:0,med:1,low:2};return e=e.map((r,i)=>({q:r,i})).sort((r,i)=>(n[r.q.risk]??3)-(n[i.q.risk]??3)||r.i-i.i).map(({q:r})=>r),{questions:e,cursor:0,resolution:e.map(()=>null)}};return{state:t,explainLines(e){if(!s.explain||!s.graph||s.contextDir===void 0)return null;let n=s.explain(s.contextDir,s.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(!s.explain||!s.graph||s.contextDir===void 0){g({kind:"note",text:"explain isn't available here"}),p();return}let n=s.explain(s.contextDir,s.graph,e),r=n.target?[`${n.target.label} ${n.target.slug??n.target.cid.slice(0,19)}:`,...n.entries.map(i=>` [${i.kind}] ${i.rationale??i.detail}`)].join(`
|
|
3
|
-
`):`unknown ref: ${e}`;g({kind:"note",text:r}),p()},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}),g({kind:"user",text:e}),t.notice="the agent isn't running \u2014 nothing sent",p();return}for(t.notice=void 0,t.checkpoint=!1,L(),t.turns.push({role:"user",text:e}),g({kind:"user",text:e}),C(e),t.status="streaming",t.busySince=Date.now(),D(),t.error=void 0,h+=1;m.length>0;)h+=1,o({type:"user_message",message_id:`u${h}-receipt`,text:m.shift()});o({type:"user_message",message_id:`u${h}`,text:e}),p()}},attachSender(e){let n=o;return o=e,()=>{o=n}},attachOnCommitted(e){v=e},attachConversationSource(e){l=e},attachSession(e){s.session=e},holdReceipt(e){m.push(e),t.checkpoint=!0,p()},drainHeldReceipts(){return m.splice(0,m.length)},peekHeldReceipts(){return[...m]},submitAnswer(e,n){let r=t.pending,i=r?.questions[e],a=i?.options[n]?.label;!r||!i||a==null||(R(e,{form:"answered",selected_index:n,free_text:null,choice:a}),N(),p())},submitFreeText(e,n){let r=t.pending,i=r?.questions[e],a=n.trim();!r||!i||!a||(R(e,{form:"answered",selected_index:null,free_text:a,choice:a}),N(),p())},deferBatch(e){let n=t.pending;if(!n||!I)return;n.questions.forEach((i,a)=>{let u=n.resolution[a];u&&u.form==="answered"&&G.set(V(i),u)}),t.pending=null,t.status=t.status==="pausing"?"pausing":"streaming",t.status==="streaming"&&(t.busySince=Date.now()),g({kind:"note",text:`questions set aside \u2014 source ${e.source_id} landed; the agent reads it next`});let r=I;I=null,r({deferred:!0,ingested:e}),p()},submitAnswerWithText(e,n,r){let i=t.pending,a=i?.questions[e],u=a?.options[n]?.label;if(!i||!a||u==null)return;let f=r.trim();R(e,{form:"answered",selected_index:n,free_text:f||null,choice:f?`${u} \u2014 ${f}`:u}),N(),p()},toggleOption(e,n){let r=t.pending?.questions[e];if(!r||r.options[n]==null)return;let i=Q.get(e)??new Set;i.has(n)?i.delete(n):i.add(n),Q.set(e,i),p()},multiSelection(e){return[...Q.get(e)??[]].sort((n,r)=>n-r)},confirmMulti(e){let n=t.pending,r=n?.questions[e];if(!n||!r)return;let i=[...Q.get(e)??[]].sort((u,f)=>u-f).map(u=>r.options[u]?.label).filter(u=>u!=null);if(i.length===0)return;Q.delete(e);let a=i.join(", ");R(e,{form:"answered",selected_index:null,free_text:a,choice:a}),N(),p()},goWithRecommendations(){let e=t.pending;if(!e)return{picks:""};let n=fe(e),r=null;return e.questions.forEach((i,a)=>{if(e.resolution[a])return;let u=i.recommended_index,f=u!=null?i.options[u]?.label:void 0;if(f==null){r===null&&(r=a);return}R(a,{form:"assumed",selected_index:u,free_text:null,choice:f})}),r!==null?(e.cursor=r,p(),{blocked:r}):(N(),p(),{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,p();return}},continueParked(){if(o){for(t.checkpoint=!1,g({kind:"continued"});m.length>0;)h+=1,o({type:"user_message",message_id:`u${h}-receipt`,text:m.shift()});h+=1,o({type:"user_message",message_id:`u${h}`,text:"continue"}),t.status="streaming",t.busySince=Date.now(),D(),p()}},note(e){g({kind:"note",text:e}),p()},finalizeForExit(){M(),A(),L(),t.stream=null,p()},aliasOf(e){return U.get(e)},registerAliases(e){for(let n of e)U.set(n.ref,n.cid);H(new Map(e.filter(n=>n.id).map(n=>[n.ref,n.id]))),p()},setWorking(e){if(e!=null){if(t.status!=="idle"&&t.status!=="working")return;t.status==="idle"&&(t.busySince=Date.now()),D(),t.status="working",t.workingLabel=e}else{if(t.status!=="working")return;t.status="idle",t.workingLabel=void 0,t.busySince=void 0}p()},ledger(e){e.kind==="commit"&&H(),e.kind==="error"&&(M(),A(),L()),g(e),e.kind==="commit"&&(e.ok?L(!0):de()),p()},senderAlive(){return o!=null},completeSession(){ee(),o?.({type:"session_complete"}),t.status="idle",t.busySince=void 0,p()},requestPause(){ee(),t.status="pausing",t.busySince=void 0;let e=o;Promise.resolve().then(()=>e?.({type:"pause"})),p()},ask(e){t.pending=te(e),J=new Map(e.map((r,i)=>[r.id,i+1])),t.status="awaiting-input",t.busySince=void 0;let n=new Promise(r=>{I=r});if(G.size>0){let r=0;e.forEach((i,a)=>{let u=V(i),f=G.get(u);f&&(G.delete(u),R(a,{...f}),r+=1)}),r>0&&g({kind:"note",text:`your earlier answer${r>1?"s are":" is"} pre-filled \u2014 press enter to send, or pick a different answer`})}return p(),n},attachIngest(e){let n=q;return q=e,()=>{q===e&&(q=n)}},canIngest(){return q!==null},async ingestAttach(e){let n=q,r=e.trim();if(!n||!r)return;let i;try{i=await n(r)}catch(a){i={ok:!1,error:a instanceof Error?a.message:String(a)}}i.ok||(g({kind:"note",text:i.error??"the source could not be ingested"}),p())},noteCoercion(e,n){g({kind:"answer",receipt:{form:"assumed",qNum:J.get(e.id)??0,stub:le(e),choice:n,note:"your typed answer couldn't be used here"}}),p()},onAgentEvent(e){switch(e.type){case"reasoning_delta":case"reasoning_done":case"tool_activity":case"decision_activity":{let n=t.thinking;if(t.thinking=ue(n,e),t.thinking!==n&&(e.type==="reasoning_done"&&e.present?(D(),x.thinkMs+=e.took_ms):e.type==="tool_activity"&&e.status!=="started"&&(D(),x.toolCalls+=1,x.tools.set(e.name,(x.tools.get(e.name)??0)+1))),e.type==="reasoning_delta"){X();return}break}case"usage":t.credits={turn:e.credits,total:e.total_credits};break;case"text_delta":{let n=Y;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)&&(Y={turn_id:e.turn_id,attempt:e.attempt},t.stream={text:""}),t.stream={text:(t.stream?.text??"")+e.text},X();return}case"progress":break;case"proposal":{c+=1,M(),t.stream=null,t.busySince=void 0,A();let n=he(e.proposal),r=s.dedupFlags?.(e.proposal);if(r)for(let i of n){let a=r.get(i.temp_ref);a&&(i.matches_existing=a)}t.turns.push({role:"agent",turnIndex:c,items:n,text:e.narrative}),E=e.narrative??null,W=!0,t.activeTurn={turnIndex:c,heading:"use-cases",items:n},P={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,M(),t.stream=null,t.busySince=void 0,A();let{items:n,heading:r}=be(e.design),i=e.design.phase==="wiring"?"acceptance criteria + exercises":r.split(" + ").map(a=>ke[a]??a).join(" + ");g({kind:"banner",text:`designing: ${i}`}),t.turns.push({role:"agent",turnIndex:c,items:n,itemsHeading:r,text:e.narrative}),E=e.narrative??null,W=!0,t.activeTurn={turnIndex:c,heading:r,items:n},P={turnIndex:c,heading:r,items:n},(t.status==="streaming"||t.status==="working")&&(t.status="idle"),t.workingLabel=void 0;break}case"ask_user":A(),t.pending=te(e.questions),t.status="awaiting-input",t.busySince=void 0;break;case"chat_ops":{c+=1,M(),A(),t.stream=null,(t.status==="streaming"||t.status==="working")&&(t.status="idle",t.busySince=void 0,t.workingLabel=void 0);let n=e.chat_ops??e,r=Array.isArray(n.ops)?n.ops:[],i=n.text??e.text??"",a=s.refreshGraph?.()??s.graph,u=d=>U.get(d)??d,f=r.map(d=>{if(!d.target)return d;let b=u(d.target),S=d.expected_cid;if(S==null&&a){let re=a.resolve(b);re&&(S=a.tipOf(re.cid))}let O=d.payload?.redirect_to,T=O&&u(O);return b===d.target&&S===d.expected_cid&&T===O?d:{...d,target:b,expected_cid:S,...T!==O?{payload:{...d.payload,redirect_to:T}}:{}}}),F;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");F=ce(f,s.descriptor??{mint_gate:[]},{turn:c,...l?{convSourceId:l}:{}})}catch(d){t.error=d instanceof Error?d.message:String(d),t.turns.push({role:"agent",turnIndex:c,text:i,narration:t.error}),i&&g({kind:"agent",text:i}),g({kind:"error",title:t.error,detail:[]});break}let{chatOps:$,ambiguous:z}=F;if(z.length>0){let d=z[0];t.confirm={kind:"ambiguity-confirm",prompt:`did you mean edit or ${d.kinds.filter(b=>b!=="edit").join("/")} on ${d.target}?`},t.turns.push({role:"agent",turnIndex:c,text:i}),i&&g({kind:"agent",text:i});break}if(w($),s.commitChatTurn&&$.length>0){let d=s.commitChatTurn({contextDir:s.contextDir??"",graph:s.refreshGraph?.()??s.graph,ops:$,by:s.by??{kind:"human",id:"owner"},...s.descriptor?.mint_gate?{mintable:s.descriptor.mint_gate}:{},...s.session?.state?.sid?{sid:s.session.state.sid}:{}});if(d.errors)t.error=d.errors.map(b=>b.detail).join("; "),t.turns.push({role:"agent",turnIndex:c,text:i}),g({kind:"commit",ok:!1,line:"commit failed \u2014 nothing landed",warnings:d.errors.map(b=>`${b.code}: ${b.detail}`)}),m.push(["COMMIT FAILED (chat turn) \u2014 nothing landed; do not assume any of your last ops applied.",...d.errors.map(b=>`- ${b.code}: ${b.detail}`),...d.errors.some(b=>b.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
|
-
`)),i&&g({kind:"agent",text:i});else{d.applied.length>0&&s.session?.markApplied(d.applied);let b=y(d);t.turns.push({role:"agent",turnIndex:c,text:i,narration:b}),g({kind:"commit",ok:!0,line:b});let S=s.refreshGraph?.();if(S&&v&&v(S),S)try{_+=1;let ne=s.descriptor?.mint_gate?.includes("usecase")?"extract":"design",O=oe({verb:ne,commitN:_,phase:"chat",committed:d.minted.map(T=>({cid:T.cid,...T.slug?{logical_id:T.slug}:{}}))},S);m.push(O.text)}catch{}i&&g({kind:"agent",text:i})}}else t.turns.push({role:"agent",turnIndex:c,text:i}),i&&g({kind:"agent",text:i});C(i);break}case"done":case"session_complete":M(),A(),L(),t.status="idle",t.busySince=void 0,o=null;break;case"error":M(),A(),L(),t.stream=null,t.status="idle",t.busySince=void 0,t.error=e.message,o=null,g({kind:"error",title:e.message,detail:[]});break;case"session_paused":break;default:break}p()}}}export{fe as a,le as b,Se as c};
|
package/dist/chunk-R5T4RLF5.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as h}from"./chunk-RZ4F3BHX.js";var l=class{config;buffer=[];stepBuffer=new Map;flushTimer=null;currentRunIndex=null;stopped=!1;_droppedBatches=0;_droppedEntries=0;constructor(t){this.config=t}start(){if(this.flushTimer)return;let t=this.config.flushIntervalMs??5e3;this.flushTimer=setInterval(()=>{this.flush().catch(()=>{})},t),this.flushTimer.unref&&this.flushTimer.unref()}setRunIndex(t){this.currentRunIndex=t}log(t,e,n,i={}){if(this.stopped)return;let s=this.buildEntry(t,e,n,i);this.buffer.push(s)}logStep(t,e,n,i={}){if(this.stopped)return;let s=this.buildEntry("debug",e,n,i);s.run_index=t,this.stepBuffer.has(t)||this.stepBuffer.set(t,[]),this.stepBuffer.get(t).push(s)}escalate(t){let e=this.stepBuffer.get(t);e&&e.length>0&&this.buffer.push(...e),this.stepBuffer.delete(t)}discardSteps(t){this.stepBuffer.delete(t)}async flush(){if(this.buffer.length===0)return;let t=this.buffer.splice(0),e=null;try{e=await this.config.getToken()}catch{this.buffer.unshift(...t);return}let n={"Content-Type":"application/json"};e&&(n.Authorization=`Bearer ${e}`);let i=JSON.stringify(t);for(let s=0;s<3;s++){try{let u=new AbortController,f=setTimeout(()=>u.abort(),1e4),o=await h(this.config.proxyUrl,{method:"POST",headers:n,body:i,signal:u.signal});if(clearTimeout(f),o.ok)return}catch{}s<2&&await new Promise(u=>setTimeout(u,1e3*Math.pow(2,s)))}this._droppedBatches++,this._droppedEntries+=t.length}async flushOnce(t){if(this.buffer.length===0)return"empty";let e=this.buffer.splice(0),n=Date.now()+t,i=null;try{i=await Promise.race([this.config.getToken(),new Promise(f=>{let o=setTimeout(()=>f(null),t);o.unref&&o.unref()})])}catch{i=null}let s=n-Date.now();if(s<=0)return this.buffer.unshift(...e),"timeout";let u={"Content-Type":"application/json"};i&&(u.Authorization=`Bearer ${i}`);try{let f=new AbortController,o=setTimeout(()=>f.abort(),s);o.unref&&o.unref();let c=await h(this.config.proxyUrl,{method:"POST",headers:u,body:JSON.stringify(e),signal:f.signal});return clearTimeout(o),c.ok?"sent":(this.buffer.unshift(...e),"failed")}catch{return this.buffer.unshift(...e),Date.now()>=n?"timeout":"failed"}}drainBuffer(){return this.buffer.splice(0)}get droppedBatches(){return this._droppedBatches}get droppedEntries(){return this._droppedEntries}async shutdown(){this._droppedBatches>0&&this.log("warn","LOG_DROPS",`Dropped ${this._droppedEntries} entries in ${this._droppedBatches} batches`,{dropped_batches:this._droppedBatches,dropped_entries:this._droppedEntries}),this.stopped=!0,this.flushTimer&&(clearInterval(this.flushTimer),this.flushTimer=null),await this.flush()}shutdownSync(){this.stopped=!0,this.flushTimer&&(clearInterval(this.flushTimer),this.flushTimer=null)}get bufferSize(){return this.buffer.length}stepBufferSize(t){return this.stepBuffer.get(t)?.length??0}buildEntry(t,e,n,i){return{hostname:"kane-cli",service:"kane-cli",ddsource:"kane-cli",ddtags:`version:${this.config.device.cli_version}`,level:t,event:e,message:n,session_id:this.config.sessionId,run_index:e.startsWith("tcg_")?null:this.currentRunIndex,identity:this.config.identity,device:this.config.device,context:i,timestamp:new Date().toISOString()}}};function g(r=process.env){try{let t=r.KANE_CLI_USER_AGENT;return t&&t.trim()?a(t):r.CLAUDECODE==="1"||r.CLAUDE_CODE_ENTRYPOINT?"claude-code":r.CURSOR_TRACE_ID||r.TERM_PROGRAM==="cursor"?"cursor":r.TERM_PROGRAM==="vscode"||r.VSCODE_PID?"vscode":r.CI==="true"||r.GITHUB_ACTIONS==="true"||r.GITLAB_CI==="true"||r.CIRCLECI==="true"||r.BUILDKITE==="true"?"ci":"unknown"}catch{return"unknown"}}function a(r){return r.toLowerCase().replace(/[^a-z0-9_-]/g,"-").slice(0,40)}export{l as a,g as b};
|
package/dist/chunk-TH47OOBV.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as xe,b as ye}from"./chunk-VAYBKR76.js";import{a as oe,b as q,d as ae}from"./chunk-CUM23TLF.js";import{a as Ne,b as Ee,f as ue,i as X}from"./chunk-DUAXZYAD.js";import{d as Z,e as b,f as se,g as ne,h as _e}from"./chunk-WXHQYYD5.js";function ke(r,s){let t=r.toLowerCase().trim().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"");if(t.length>60){let o=t.lastIndexOf("-",60);t=(o>0?t.slice(0,o):t.slice(0,60)).replace(/-+$/g,"")}if(!de.test(t))return null;let e=t;for(let o=2;s(e);o++)e=`${t}-${o}`;return de.test(e)?e:null}var Ae={source:"src",usecase:"uc",scenario:"sc",ac:"ac",test:"t",gap:"gap",stylenote:"sty"};function Ye(r,s,t){let e=Ae[r];return ke(e?`${e} ${s}`:s,t)}var De={usecase:"uc",scenario:"sc",ac:"ac",test:"t",gap:"gap",stylenote:"sty"},Re=/^(uc|sc|ac|t|gap|sty)-\d+$/i;function Oe(r,s,t){let e=De[r];if(!e)return null;let o=new RegExp(`^${e}-(\\d+)$`),u=0;for(let a of t){let g=o.exec(a);if(!g)continue;let n=Number(g[1]);Number.isSafeInteger(n)&&n>u&&(u=n)}let d=u+1;for(;s(`${e}-${d}`);)d+=1;return`${e}-${d}`}var Me=/^L([1-9]\d*)-L([1-9]\d*)$/,Ve=/^img#(p[1-9]\d*-[1-9]\d*|i[1-9]\d*)$/;function le(r){if(r==="img#whole")return{kind:"img-whole"};let s=Ve.exec(r);if(s)return{kind:"img-part",ref:s[1]};let t=Me.exec(r);return t?{kind:"lines",a:parseInt(t[1],10),b:parseInt(t[2],10)}:null}function Pe(r,s){let t=/^L(\d+)-L(\d+)$/.exec(s);if(!t)return null;let e=parseInt(t[1],10),o=parseInt(t[2],10),u=r.split(`
|
|
3
|
-
`);return e<1||o<e||o>u.length?null:u.slice(e-1,o).map(d=>d.replace(/^\d+\| /,"")).join(`
|
|
4
|
-
`)}function be(r,s,t){let e=le(s.anchor);if(r.format==="image")return e?.kind==="img-whole"?[]:[{code:"CITE_ANCHOR_INVALID",detail:`image cites are anchor-only (img#whole), got ${s.anchor}`}];if(e?.kind==="img-part")return new Set((r.images??[]).map(d=>d.ref)).has(e.ref)?[]:[{code:"CITE_ANCHOR_INVALID",detail:`anchor ${s.anchor} names no embedded image of this source version`}];if(!s.anchor||s.quote===void 0||s.quote==="")return[{code:"MISSING_CITE",detail:"text-kind cites need anchor+quote"}];let o=t!==null?Pe(t,s.anchor):null;return o===null?[{code:"BAD_ANCHOR",detail:`anchor ${s.anchor} does not resolve in the source`}]:o.includes(s.quote)?[]:[{code:"QUOTE_MISMATCH",detail:`quote is not verbatim within ${s.anchor}`}]}import{existsSync as Ge,readFileSync as Le}from"fs";function nt(r){let s=ye(r),t=new Map(Object.entries(s.heads)),e=new Map(Object.entries(s.trust)),o=new Map(Object.entries(s.nodeLabel)),u=new Map(Object.entries(s.superseded)),d=new Map(Object.entries(s.names)),a=new Map(Object.entries(s.archivedReason)),g=new Set(s.appliedEvents),n=new Map(Object.entries(s.conv)),_=p=>s.media[p]??{format:"text",media_type:"text/plain",anchors_supported:["L-L"]},h=new Map;for(let[p,E]of d)h.set(E,p);let c=new Map,C=p=>{if(c.has(p))return c.get(p);if(!o.has(p))return c.set(p,null),null;let E=xe(r,p);if(!Ge(E))throw new Ne(`derived node file missing for ${p} \u2014 run kane-cli context rebuild`);let I=JSON.parse(Le(E,"utf8"));return c.set(p,I),I},N=p=>{let E=p,I=new Set;for(;u.has(E)&&!I.has(E);){I.add(E);let O=u.get(E);if(typeof O!="string")break;E=O}return E},x=null,z=p=>{let E=h.get(p);if(E!==void 0)return E;if(x===null){x=new Map;for(let[L,k]of u)typeof k=="string"&&x.set(k,L)}let I=new Set,O=p;for(;!I.has(O);){I.add(O);let L=x.get(O);if(L===void 0)return null;let k=h.get(L);if(k!==void 0)return k;O=L}return null},Q=p=>{Re.test(p)&&(p=p.toLowerCase());let E=t.get(p),I=o.has(p)?p:d.get(p)??(typeof E=="string"?E:void 0);if(I===void 0||!o.has(I))return null;let O=N(I);return{cid:I,tip:O,superseded:u.has(I)||u.has(O)}},G=new Map;for(let p of Object.values(s.forward))for(let E of p){let I=G.get(E.dst);I?I.push(E):G.set(E.dst,[E])}let w=p=>(p??[]).filter(E=>!u.has(E.ecid)),ee=p=>w(G.get(p)),F=p=>ee(p).filter(E=>E.type===b.DERIVES),te=p=>w(s.forward[p]).some(E=>ne(E.type)?.pin?.comparesTo==="dst_tip"&&u.has(E.dst)),re=p=>{if(u.has(p))return"superseded";let E=F(p);if(E.length===0)return te(p)?"stale":"fresh";let I=new Map;for(let k of E)I.set(k.props.source_id,k);let O=!1,L=!1;for(let[k,D]of I){let J=t.get(k);if(J!=null&&(O=!0,J!==D.props.source_cid)){let i=n.get(k)?.chain;(!i||!i.includes(D.props.source_cid))&&(L=!0)}}return O?L||te(p)?"stale":"fresh":"orphaned"};return{heads:t,trust:e,nodeLabel:o,superseded:u,names:d,nameOf:h,archivedReason:a,appliedEvents:g,convChains:n,mediaOf:_,extractedSourceCids:new Set(s.extracted),extractionCompleteness:new Map(Object.entries(s.completeness??{}).map(([p,{seq:E,...I}])=>[p,I])),designOf:new Map(Object.entries(s.design_of??{})),designGenerationOf:new Map(Object.entries(s.design_generation??{})),latestHash:s.applied.hash,lastSeq:s.applied.seq,hasNode:p=>o.has(p),getNode:C,byLabel:p=>[...o.entries()].filter(([,E])=>E===p).map(([E])=>({cid:E,content:C(E)?.content??{}})),edgesFrom:p=>w(s.forward[p]),edgesInto:ee,derivesInto:F,resolve:Q,tipOf:N,displayNameOf:z,stale:re,staleList:()=>[...o.keys()].map(p=>({cid:p,state:re(p)})).filter(p=>p.state!=="fresh"),execHistory:p=>{let E=Q(p);if(!E)return[];let I=N(E.cid),O=new Set([I]),L=!0;for(;L;){L=!1;for(let[D,J]of u)J!==null&&O.has(J)&&!O.has(D)&&(O.add(D),L=!0)}let k=[];for(let D of Object.entries(s.exec??{}))O.has(D[0])&&k.push(...D[1]);return k.sort((D,J)=>D.started_at<J.started_at?-1:1)}}}function ot(r,s){if(r.stale(s)!=="stale")return!1;let t=new Map;for(let e of r.derivesInto(s))t.set(e.props.source_id,e);for(let[e,o]of t){let u=r.heads.get(e);if(u==null||u===o.props.source_cid)continue;let d=r.convChains.get(e)?.chain;if(!d||!d.includes(o.props.source_cid))return!0}for(let e of r.edgesFrom(s)){if(ne(e.type)?.pin?.comparesTo!=="dst_tip"||!r.superseded.has(e.dst))continue;let o=r.tipOf(e.dst);if(r.superseded.has(o)||r.nodeLabel.get(o)==="usecase")return!0}return!1}function pe(r,s){let t=new Map;for(let[d,a]of r.superseded)typeof a=="string"&&a!==d&&t.set(a,[...t.get(a)??[],d]);let e=[],o=[s],u=new Set;for(;o.length>0;){let d=o.pop();u.has(d)||(u.add(d),e.push(d),o.push(...t.get(d)??[]))}return e}function Ue(r,s){return(r.extraction_claims??[]).some(t=>t.source_id===s&&t.completeness==="complete")}function Fe(r,s){let t=new Set;for(let e of pe(r,s))for(let o of r.derivesInto(e))t.add(o.props?.source_id??"conversation");return t}function ve(r,s){let t=[],e=[],o=r.archived??[];if(o.length===0)return{valid:t,errors:e};let u=new Set([...r.source?[r.source.source_id]:[],...(r.sources??[]).map(a=>a.source_id)]),d=new Set;for(let a of r.use_cases){if(!a.matches_existing)continue;let g=s.resolve(a.matches_existing.cid);g&&d.add(s.tipOf(g.cid))}for(let a of o){let g=`archived[${a.target}]`,n=s.resolve(a.target),_=n?s.tipOf(n.cid):null;if(!_||(s.trust.get(_)??null)==="archived"){e.push({code:"ARCHIVE_TARGET_UNKNOWN",detail:`${g}: target does not resolve to an existing, live item`});continue}let h=Fe(s,_);if(!h.has(a.basis)){e.push({code:"ARCHIVE_FOREIGN_PROVENANCE",detail:`${g}: its provenance does not include ${a.basis} \u2014 an archive claim must come from a source that evidences the item`});continue}if(!u.has(a.basis)){e.push({code:"ARCHIVE_WITHOUT_COMPLETE_CLAIM",detail:`${g}: ${a.basis} was not read by this extraction \u2014 a completeness claim only counts for a source this run actually read`});continue}if(!Ue(r,a.basis)){e.push({code:"ARCHIVE_WITHOUT_COMPLETE_CLAIM",detail:`${g}: archiving needs an EXPLICIT complete extraction claim for ${a.basis} (the omitted-claims default does not count) \u2014 add extraction_claims`});continue}if(d.has(_)){e.push({code:"ARCHIVE_TARGET_MATCHED",detail:`${g}: this proposal also matches the target via matches_existing \u2014 a matched item cannot be archived by the same extraction; propose the change as an update instead`});continue}let c=[...h].filter(C=>C!==a.basis);if(c.length>0){e.push({code:"ARCHIVE_OTHER_LIVE_EVIDENCE",detail:`${g}: still evidenced by ${c.join(", ")} \u2014 an item another live source evidences is never archived from here`});continue}t.push({op:a,cid:_})}return{valid:t,errors:e}}var de=/^[a-z0-9][a-z0-9-]{1,63}$/;function we(r,s,t,e){if(!s)return{error:{code:"SUPERSEDE_TARGET_MISSING",detail:"supersede verdict needs a target (slug or cid)"}};let o=r.resolve(s);return o?o.superseded||e.has(o.cid)?{error:{code:"ALREADY_SUPERSEDED",detail:`${s} is already superseded (tip: ${o.tip})`}}:o.cid===t?{error:{code:"SELF_SUPERSEDE",detail:"a node cannot supersede itself"}}:{targetCid:o.cid}:{error:{code:"UNKNOWN_SUPERSEDE_TARGET",detail:`${s} names nothing in the graph`}}}function He(r,s,t,e,o=[]){if(!ne(s)?.acyclic)return null;if(t===e)return{code:"EDGE_CYCLE",detail:`${s} ${t} \u2192 itself`};let d=n=>[...r.edgesFrom(n).filter(_=>_.type===s).map(_=>_.dst),...o.filter(_=>_.type===s&&_.src===n).map(_=>_.dst)],a=new Set,g=[e];for(;g.length>0;){let n=g.pop();if(n===t)return{code:"EDGE_CYCLE",detail:`${s} ${t} \u2192 ${e} closes a cycle`};a.has(n)||(a.add(n),g.push(...d(n)))}return null}function vt(r,s,t,e){let u=ne(s)?.cardinality;if(u!=="one-live-per-src"&&u!=="one-live-per-src-and-dst")return null;let d=r.edgesFrom(t).filter(a=>a.type===s&&!r.superseded.has(a.dst));if(d.length>0)return{code:"CARDINALITY_VIOLATION",detail:`${s} from ${t} already has a live edge (${d[0].ecid}) \u2014 supersede it first`};if(u==="one-live-per-src-and-dst"&&e!==void 0){let a=r.edgesInto(e).filter(g=>g.type===s&&!r.superseded.has(g.src));if(a.length>0)return{code:"CARDINALITY_VIOLATION",detail:`${s} onto ${e} already has a live edge (${a[0].ecid}) \u2014 strict 1:1, supersede it first`}}return null}var Se=new Set(["high","med","low"]),fe=r=>r.cites&&r.cites.length>0?r.cites:[r.cite];function ge(r){let s=0;for(let t of r)typeof t=="object"&&t!==null&&"op"in t&&s++;return s===0?"flat":s===r.length?"ops":"mixed"}var qe=/^c[1-9][0-9]*$/;function Te(r,s,t,e){let o=new Map,u=[],d=[];for(let[g,n]of s.entries()){let _=`${r}.updated.criteria[${g}]`;if(n.op==="keep"||n.op==="remove"){if(!qe.test(n.ref??"")){e.push({code:"CRITERIA_REF_UNKNOWN",detail:`${_}: ref ${JSON.stringify(n.ref)} is not a c<N> criterion index`});continue}if(o.has(n.ref)){e.push({code:"CRITERIA_REF_DUPLICATE",detail:`${_}: ${n.ref} is already named by another op \u2014 every prior criterion appears in exactly one keep or remove`});continue}o.set(n.ref,n);let h=Number.parseInt(n.ref.slice(1),10);if(h>t.length){e.push({code:"CRITERIA_REF_UNKNOWN",detail:`${_}: ${n.ref} \u2014 the live target has ${t.length} criteria`});continue}if(t[h-1]!==n.text){e.push({code:"CRITERIA_REF_MISMATCH",detail:`${_}: ${n.ref} echo mismatch \u2014 the live target's criterion ${h} reads ${JSON.stringify(t[h-1])}, the op echoed ${JSON.stringify(n.text)} \u2014 re-read the node and re-emit`});continue}n.op==="remove"&&(u.push(n.text),(!n.reason||!n.reason.trim())&&e.push({code:"EMPTY_REASON",detail:`${_}: a remove op carries its reason`}))}else!n.text||!n.text.trim()?e.push({code:"EMPTY_CRITERION",detail:`${_}: set text is empty`}):d.push(n.text)}let a=[];for(let g=1;g<=t.length;g++)o.has(`c${g}`)||a.push(`c${g}`);a.length>0&&e.push({code:"CRITERIA_PARTITION_INCOMPLETE",detail:`${r}: prior criteria ${a.join(", ")} named by no keep/remove op \u2014 every prior criterion must be kept or removed (with a reason)`});for(let g of u)d.includes(g)&&e.push({code:"CRITERIA_OP_CONFLICT",detail:`${r}: ${JSON.stringify(g)} is removed AND re-set in the same update \u2014 drop one of the two ops`})}function St(r,s,t){let e=[],o=r.sources??[r.source],u=new Map(o.map(n=>[n.source_id,n.source_cid])),d=new Map;if(typeof s=="string")d.set(r.source.source_id,{media:t.mediaOf(r.source.source_cid),numberedText:s});else for(let[n,_]of s)d.set(n,_);for(let n of o)t.hasNode(n.source_cid)||e.push({code:"MISSING_SOURCE_NODE",detail:`source ${n.source_id} (${n.source_cid}) is not a committed node \u2014 ingest it first`});let a=(n,_)=>{let h=_.source_id??r.source.source_id;if(!u.has(h)){e.push({code:"CITE_SOURCE_UNKNOWN",detail:`${n}: cite source ${JSON.stringify(h)} is not in read_basis`});return}let c=d.get(h);if(!c){e.push({code:"MISSING_SOURCE_NODE",detail:`${n}: no citable text available for source ${h}`});return}for(let C of be(c.media,_,c.numberedText))e.push({code:C.code,detail:`${n}: ${C.detail}`})},g=new Set;for(let n of r.use_cases){if(g.has(n.temp_ref)&&e.push({code:"DUP_TEMP_REF",detail:`duplicate temp_ref ${n.temp_ref}`}),g.add(n.temp_ref),(!n.title||!n.title.trim())&&e.push({code:"EMPTY_TITLE",detail:`${n.temp_ref}: title is empty`}),Se.has(n.risk)||e.push({code:"BAD_RISK",detail:`${n.temp_ref}: risk ${JSON.stringify(n.risk)} not in high|med|low`}),!n.cite||!n.cite.anchor)e.push({code:"MISSING_CITE",detail:`${n.temp_ref}: every derived use-case must carry a cite`});else for(let h of fe(n))a(n.temp_ref,h);n.matches_existing&&!t.hasNode(n.matches_existing.cid)&&e.push({code:"UNKNOWN_MATCH",detail:`${n.temp_ref}: matches_existing ${n.matches_existing.cid} is not in the graph`});for(let[h,c]of(n.criteria??[]).entries())(!c.text||!c.text.trim())&&e.push({code:"EMPTY_CRITERION",detail:`${n.temp_ref}.criteria[${h}]: text is empty`}),!c.cite||!c.cite.anchor?e.push({code:"MISSING_CITE",detail:`${n.temp_ref}.criteria[${h}]: every criterion carries its own cite`}):a(`${n.temp_ref}.criteria[${h}]`,c.cite);let _=n.updated?.criteria??[];if(_.length>0){let h=ge(_);if(h==="mixed")e.push({code:"CRITERIA_SHAPE_MIXED",detail:`${n.temp_ref}.updated.criteria mixes op-shaped (keep/set/remove) and {text, cite} entries \u2014 emit ONE shape for the whole array`});else if(h==="ops"){let c=_,C=n.matches_existing?We(t,n.matches_existing.cid):null;if(!C)e.push({code:"CRITERIA_REF_UNKNOWN",detail:`${n.temp_ref}: op-union criteria address a prior version \u2014 they need a resolvable matches_existing target`});else{let N=t.getNode(C.cid)?.content.criteria??[];Te(n.temp_ref,c,N,e)}for(let[N,x]of c.entries())x.op==="set"&&(!x.cite||!x.cite.anchor?e.push({code:"MISSING_CITE",detail:`${n.temp_ref}.updated.criteria[${N}]: a set op carries the proposing source's cite`}):a(`${n.temp_ref}.updated.criteria[${N}]`,x.cite))}else for(let[c,C]of _.entries())(!C.text||!C.text.trim())&&e.push({code:"EMPTY_CRITERION",detail:`${n.temp_ref}.updated.criteria[${c}]: text is empty`}),!C.cite||!C.cite.anchor?e.push({code:"MISSING_CITE",detail:`${n.temp_ref}.updated.criteria[${c}]: every updated criterion carries its own cite`}):a(`${n.temp_ref}.updated.criteria[${c}]`,C.cite)}}return e.push(...ve(r,t).errors),e}function je(r,s,t){return`${r}:${s}:${t}`}function Ke(r,s,t,e){let o=`${s}:${t}:`,u=0;for(let d of r.appliedEvents){if(!d.startsWith(o))continue;let a=d.slice(o.length);if(!/^\d+$/.test(a))continue;let g=Number.parseInt(a,10);g>u&&(u=g)}return Array.from({length:e},(d,a)=>je(s,t,u+1+a))}function We(r,s){let t=r.resolve(s);if(t===null)return null;let e=t.cid;if(r.superseded.has(e)){let o=r.tipOf(e);return r.superseded.has(o)?null:{cid:o,redirected:!0}}return{cid:e,redirected:!1}}function It(r){let{contextDir:s,graph:t,proposal:e,proposalId:o,verdicts:u,by:d,allowStaleBasis:a,extractorVersion:g,autoName:n}=r,_=ue(s);if(!a&&e.read_basis!==_)return{record:null,errors:[{code:"STALE_BASIS",detail:`proposal read_basis ${String(e.read_basis)} != latest ${String(_)}`}]};for(let i of e.sources??[e.source])if(!t.hasNode(i.source_cid))return{record:null,errors:[{code:"MISSING_SOURCE_NODE",detail:`source ${i.source_id} (${i.source_cid}) is not a committed node \u2014 ingest it first`}]};let h=new Map((e.sources??[e.source]).map(i=>[i.source_id,i.source_cid])),c=[],C=[],N=new Map,x=[],z=t.mediaOf(e.source.source_cid),Q=new Set,G=[],w=[],ee=[],F=[];for(let i of ve(e,t).valid)F.push({id:i.cid,kind:"pending_archive",resolution:"pending",edit:null,reason:i.op.reason,by:d});let te=[],re=[],p=new Set,E=new Set,I=(i,f,M)=>{let j=we(t,f.supersedeTarget,M,p);if("error"in j){c.push({code:j.error.code,detail:`${i}: ${j.error.detail}`});return}p.add(j.targetCid),te.push({kind:"node",old:j.targetCid,new:M,reason:f.reason??`superseded via review by ${d.id}`,by:d})};for(let i of e.use_cases){let f=u.get(i.temp_ref)??{resolution:"skipped"};Q.has(i.temp_ref)&&c.push({code:"DUP_TEMP_REF",detail:`duplicate temp_ref ${i.temp_ref}`}),Q.add(i.temp_ref),(!i.title||!i.title.trim())&&c.push({code:"EMPTY_TITLE",detail:`${i.temp_ref}: title is empty`}),Se.has(i.risk)||c.push({code:"BAD_RISK",detail:`${i.temp_ref}: risk ${JSON.stringify(i.risk)} not in high|med|low`});let M=le(i.cite?.anchor??""),j=i.cite?.source_id!==void 0&&h.has(i.cite.source_id)?t.mediaOf(h.get(i.cite.source_id)):z;if(j.format==="image"){if(M?.kind!=="img-whole"){c.push({code:i.cite?.anchor?"CITE_ANCHOR_INVALID":"MISSING_CITE",detail:`${i.temp_ref}: image cites are anchor-only (img#whole)`});continue}}else if(M?.kind==="img-part"){if(!(j.images??[]).some(m=>m.ref===M.ref)){c.push({code:"CITE_ANCHOR_INVALID",detail:`${i.temp_ref}: anchor ${i.cite?.anchor} names no embedded image of this source version`});continue}}else if(!i.cite||!i.cite.anchor||!i.cite.quote){c.push({code:"MISSING_CITE",detail:`${i.temp_ref}: every derived use-case must cite anchor+quote`});continue}f.resolution==="edited"&&f.edit&&(f.edit.title!==void 0&&!f.edit.title.trim()&&c.push({code:"EMPTY_TITLE",detail:`${i.temp_ref}: edited title is empty`}),f.edit.risk!==void 0&&!Se.has(f.edit.risk)&&c.push({code:"BAD_RISK",detail:`${i.temp_ref}: edited risk ${JSON.stringify(f.edit.risk)} invalid`}));let he=ae({title:f.edit?.title??i.title,description:i.description,summary:f.edit?.summary??i.summary,actors:i.actors,value:i.value,risk:f.edit?.risk??i.risk,...i.criteria&&i.criteria.length>0?{criteria:i.criteria.map(l=>l.text)}:{}}),$=oe("usecase",he),me=i.cite.source_id??e.source.source_id,Ie=h.get(me);if(i.cite.source_id!==void 0&&Ie===void 0){c.push({code:"CITE_SOURCE_UNKNOWN",detail:`${i.temp_ref}: cite source ${JSON.stringify(me)} is not in read_basis`});continue}let Y={source_id:me,source_cid:Ie??e.source.source_cid,anchor:i.cite.anchor,...i.cite.quote?{quote:i.cite.quote}:{}};if(i.matches_existing&&!t.hasNode(i.matches_existing.cid)){c.push({code:"UNKNOWN_MATCH",detail:`${i.temp_ref}: matches_existing ${i.matches_existing.cid} is not in the graph`});continue}let y=i.matches_existing?.cid??(t.hasNode($)?$:null);if(y&&t.superseded.has(y)){let l=t.tipOf(y);y=t.superseded.has(l)?null:l}if(y&&i.matches_existing&&(t.trust.get(y)??null)==="derived"){let l=i.updated?.criteria??[];if(i.changed&&l.length>0&&ge(l)==="ops"&&(f.resolution==="approved"||f.resolution==="edited")){c.push({code:"UC_UNREVIEWED",detail:`${i.temp_ref}: merge target ${y.slice(0,19)} is unreviewed (derived) \u2014 bless it first (kane-cli context review) and re-propose the merge`});continue}let m=(r.probeHits??[]).find(v=>v.tempRef===i.temp_ref&&v.candidateCid===y);x.push({tempRef:i.temp_ref,candidate_cid:y,score:m?.score??1,scorer:m?.scorer??"lexical_fallback"}),y=null}if(y){if(i.changed&&(f.resolution==="approved"||f.resolution==="edited")){let l=i.updated;if(!l||Object.keys(l).length===0){c.push({code:"CHANGED_NEEDS_PAYLOAD",detail:`${i.temp_ref}: changed:true needs an updated{...} payload naming the moved fields`});continue}let m=t.getNode(y)?.content??{},v=l.criteria??[],T=v.length>0?ge(v):"flat";if(T==="mixed"){c.push({code:"CRITERIA_SHAPE_MIXED",detail:`${i.temp_ref}.updated.criteria mixes op-shaped (keep/set/remove) and {text, cite} entries \u2014 emit ONE shape for the whole array`});continue}if(T==="ops"){let A=v,V=m.criteria??[],P=c.length;Te(i.temp_ref,A,V,c);for(let[ie,ce]of A.entries())ce.op==="set"&&(!ce.cite||!ce.cite.anchor)&&c.push({code:"MISSING_CITE",detail:`${i.temp_ref}.updated.criteria[${ie}]: a set op carries the proposing source's cite`});if(c.length>P)continue;let R=A.filter(ie=>ie.op!=="remove").map(ie=>ie.text),H=ae({title:f.edit?.title??l.title??String(m.title??i.title),...l.description??m.description?{description:l.description??m.description}:{},...f.edit?.summary??l.summary??m.summary?{summary:f.edit?.summary??l.summary??m.summary}:{},...l.actors??m.actors?{actors:l.actors??m.actors}:{},...l.value??m.value?{value:l.value??m.value}:{},risk:f.edit?.risk??l.risk??String(m.risk??i.risk),...R.length>0?{criteria:R}:{}}),K=oe("usecase",H);if(K!==y){for(let S of se("usecase",H))c.push({code:S.code,detail:`${i.temp_ref}: ${S.detail}`});G.push({cid:K,label:Z.USECASE,content:H});for(let S of fe(i)){let W=S.source_id??e.source.source_id,U=h.get(W);if(!U){c.push({code:"CITE_SOURCE_UNKNOWN",detail:`${i.temp_ref}: cite source ${JSON.stringify(W)} is not in read_basis`});continue}let B={source_id:W,source_cid:U,anchor:S.anchor,...S.quote?{quote:S.quote}:{}};w.push({ecid:q("DERIVES",U,K,B),type:b.DERIVES,src:U,dst:K,props:B})}let ce=pe(t,y).flatMap(S=>t.edgesInto(S)).filter(S=>S.type===b.DERIVES&&typeof S.props.claim=="string");for(let S of A){if(S.op!=="keep")continue;let W=new Set;for(let U of ce){let B=U.props;if(B.claim!==S.text)continue;let $e=`${B.source_id}|${B.source_cid}|${B.anchor}`;if(W.has($e))continue;W.add($e);let Ce={...U.props};w.push({ecid:q("DERIVES",U.src,K,Ce),type:b.DERIVES,src:U.src,dst:K,props:Ce})}}for(let S of A){if(S.op!=="set")continue;let W=S.cite.source_id??e.source.source_id,U=h.get(W);if(!U){c.push({code:"CITE_SOURCE_UNKNOWN",detail:`${i.temp_ref}: set cite source ${JSON.stringify(W)} is not in read_basis`});continue}let B={source_id:W,source_cid:U,anchor:S.cite.anchor,...S.cite.quote?{quote:S.cite.quote}:{},claim:S.text};w.push({ecid:q("DERIVES",U,K,B),type:b.DERIVES,src:U,dst:K,props:B})}for(let S of A)S.op==="remove"&&C.push({about:y,ref:S.ref,text:S.text,reason:S.reason});I(i.temp_ref,{resolution:"supersede",supersedeTarget:y,reason:f.reason??`criteria merge: ${e.source.source_id} (${A.filter(S=>S.op==="keep").length} kept, ${A.filter(S=>S.op==="set").length} set, ${A.filter(S=>S.op==="remove").length} removed)`},K),F.push({id:K,kind:"review-item",resolution:f.resolution,edit:f.resolution==="edited"?{...f.edit}:null,reason:null,by:d});continue}}else{let A=v.map(R=>typeof R=="string"?{text:R,cite:void 0}:R),V=ae({title:f.edit?.title??l.title??String(m.title??i.title),...l.description??m.description?{description:l.description??m.description}:{},...f.edit?.summary??l.summary??m.summary?{summary:f.edit?.summary??l.summary??m.summary}:{},...l.actors??m.actors?{actors:l.actors??m.actors}:{},...l.value??m.value?{value:l.value??m.value}:{},risk:f.edit?.risk??l.risk??String(m.risk??i.risk),...l.criteria?A.length>0?{criteria:A.map(R=>R.text)}:{}:m.criteria?{criteria:m.criteria}:{}}),P=oe("usecase",V);if(P!==y){for(let R of se("usecase",V))c.push({code:R.code,detail:`${i.temp_ref}: ${R.detail}`});G.push({cid:P,label:Z.USECASE,content:V}),w.push({ecid:q("DERIVES",Y.source_cid,P,Y),type:b.DERIVES,src:Y.source_cid,dst:P,props:Y});for(let R of A){if(!R.cite)continue;let H={source_id:e.source.source_id,source_cid:e.source.source_cid,anchor:R.cite.anchor,...R.cite.quote?{quote:R.cite.quote}:{},claim:R.text};w.push({ecid:q("DERIVES",H.source_cid,P,H),type:b.DERIVES,src:H.source_cid,dst:P,props:H})}I(i.temp_ref,{resolution:"supersede",supersedeTarget:y,reason:f.reason??`matches-but-changed: ${e.source.source_id} moved (${Object.keys(l).join(", ")})`},P),F.push({id:P,kind:"review-item",resolution:f.resolution,edit:f.resolution==="edited"?{...f.edit}:null,reason:null,by:d});continue}for(let R of A){if(!R.cite)continue;let H={source_id:e.source.source_id,source_cid:e.source.source_cid,anchor:R.cite.anchor,...R.cite.quote?{quote:R.cite.quote}:{},claim:R.text};w.push({ecid:q("DERIVES",H.source_cid,y,H),type:b.DERIVES,src:H.source_cid,dst:y,props:H})}}}if(i.changed&&f.resolution==="skipped"){let l=i.updated?.criteria??[];l.length>0&&ge(l)==="ops"&&F.push({id:y,kind:"pending_update",resolution:"pending",edit:{temp_ref:i.temp_ref,source_id:e.source.source_id,updated:i.updated},reason:i.change_note??null,by:d})}if(f.resolution!=="rejected"){for(let l of fe(i)){let m=l.source_id??e.source.source_id,v=h.get(m);if(!v){c.push({code:"CITE_SOURCE_UNKNOWN",detail:`${i.temp_ref}: cite source ${JSON.stringify(m)} is not in read_basis`});continue}let T={source_id:m,source_cid:v,anchor:l.anchor,...l.quote?{quote:l.quote}:{}};w.push({ecid:q("DERIVES",v,y,T),type:b.DERIVES,src:v,dst:y,props:T})}(f.resolution==="approved"||f.resolution==="edited"||f.resolution==="supersede")&&F.push({id:y,kind:"review-item",resolution:"approved",edit:null,reason:null,by:d}),f.resolution==="supersede"&&I(i.temp_ref,f,y)}continue}for(let l of se("usecase",he))c.push({code:l.code,detail:`${i.temp_ref}: ${l.detail}`});for(let l of _e(b.DERIVES,"source","usecase",Y))c.push({code:l.code,detail:`${i.temp_ref}: ${l.detail}`});G.push({cid:$,label:Z.USECASE,content:he}),N.set(i.temp_ref,$),w.push({ecid:q("DERIVES",Y.source_cid,$,Y),type:b.DERIVES,src:Y.source_cid,dst:$,props:Y});for(let l of fe(i).slice(1)){let m=l.source_id??e.source.source_id,v=h.get(m);if(!v){c.push({code:"CITE_SOURCE_UNKNOWN",detail:`${i.temp_ref}: cite source ${JSON.stringify(m)} is not in read_basis`});continue}let T={source_id:m,source_cid:v,anchor:l.anchor,...l.quote?{quote:l.quote}:{}};for(let A of _e(b.DERIVES,"source","usecase",T))c.push({code:A.code,detail:`${i.temp_ref}: ${A.detail}`});w.push({ecid:q("DERIVES",v,$,T),type:b.DERIVES,src:v,dst:$,props:T})}for(let l of i.criteria??[]){let m=l.cite.source_id??e.source.source_id,v=h.get(m);if(!v){c.push({code:"CITE_SOURCE_UNKNOWN",detail:`${i.temp_ref}: criterion cite source ${JSON.stringify(m)} is not in read_basis`});continue}let T={source_id:m,source_cid:v,anchor:l.cite.anchor,...l.cite.quote?{quote:l.cite.quote}:{},claim:l.text};w.push({ecid:q("DERIVES",T.source_cid,$,T),type:b.DERIVES,src:T.source_cid,dst:$,props:T})}for(let l of i.depends_on_hint??[]){let m=V=>V.toLowerCase().trim().replace(/\s+/g," "),v=null,T=t.resolve(l);if(T&&!T.superseded&&t.nodeLabel.get(T.cid)===Z.USECASE&&(v=T.cid),!v){for(let{cid:V,content:P}of t.byLabel(Z.USECASE))if(!t.superseded.has(V)&&m(String(P.title??""))===m(l)){v=V;break}}if(!v){let V=G.find(P=>P.label===Z.USECASE&&m(String(P.content.title??""))===m(l));V&&(v=V.cid)}!v||v===$||He(t,b.DEPENDS_ON,$,v,ee)||ee.some(V=>V.src===$&&V.dst===v)||(w.push({ecid:q(b.DEPENDS_ON,$,v,{reason:"extract hint"}),type:b.DEPENDS_ON,src:$,dst:v,props:{reason:"extract hint"}}),ee.push({src:$,dst:v,type:b.DEPENDS_ON}))}if((f.resolution==="approved"||f.resolution==="edited"||f.resolution==="supersede")&&t.superseded.get($)===null&&!p.has($)&&te.push({kind:"node",old:$,new:$,reason:`re-minted after tombstone via review by ${d.id}`,by:d}),n){let l=Oe("usecase",m=>E.has(m),t.names.keys());l!==null&&!t.nameOf.has($)&&(E.add(l),re.push({cid:$,slug:l,by:d}))}f.resolution==="approved"?F.push({id:$,kind:"review-item",resolution:"approved",edit:null,reason:null,by:d}):f.resolution==="edited"?F.push({id:$,kind:"review-item",resolution:"edited",edit:{...f.edit},reason:null,by:d}):f.resolution==="rejected"?F.push({id:$,kind:"review-item",resolution:"rejected",edit:null,reason:f.reason??null,by:d}):f.resolution==="supersede"&&(F.push({id:$,kind:"review-item",resolution:"approved",edit:null,reason:f.reason??null,by:d}),I(i.temp_ref,f,$))}if(c.length)return{record:null,errors:c};let O=new Date().toISOString(),L=(e.sources?.length??0)>1||(e.extraction_claims?.length??0)>0,k;if(L){let i=[];if(e.extraction_claims==null)i.push({source_id:e.source.source_id,source_cid:e.source.source_cid,completeness:"complete",...g?{extractor_version:g}:{},at:O});else{let f=new Map(e.extraction_claims.map(M=>[M.source_id,M.completeness]));for(let M of e.sources??[e.source]){let j=f.get(M.source_id)??null;j!==null&&i.push({source_id:M.source_id,source_cid:M.source_cid,completeness:j,...g?{extractor_version:g}:{},at:O})}}k=i}else k=e.source.source_cid;let D=[];for(let i of r.probeHits??[])D.push({...N.has(i.tempRef)?{new_cid:N.get(i.tempRef)}:{},candidate_cid:i.candidateCid,score:i.score,scorer:i.scorer,probe_basis:null});for(let i of x){let f=N.get(i.tempRef);D.some(M=>M.new_cid===f&&M.candidate_cid===i.candidate_cid)||D.push({...f!==void 0?{new_cid:f}:{},candidate_cid:i.candidate_cid,score:i.score,scorer:i.scorer,probe_basis:null})}return{record:X(s,{ts:O,proposal_id:o,...o!=null?{extraction_of:k}:{},...o!=null&&g?{extractor_version:g}:{},...C.length>0?{criteria_removed:C}:{},...D.length>0?{dedup_hits:D}:{},nodes:G,edges:w,review:F,supersessions:te,...re.length>0?{names:re}:{},...r.judgements&&r.judgements.length>0?{judgements:r.judgements}:{},...r.eventIds&&r.eventIds.length>0?{event_ids:r.eventIds}:r.sid?{event_ids:Ke(t,r.sid,"extract",1)}:{},...r.sid?{sid:r.sid}:{},source_head_moves:{}},{expectPrev:_}).record,errors:null}}function $t(r){let{contextDir:s,graph:t,verdicts:e,by:o}=r,u=[],d=[],a=[],g=[],n=new Set;for(let[h,c]of e){if(c.resolution==="skipped")continue;let C=t.resolve(h);if(!C){u.push({code:"UNKNOWN_NODE",detail:`${h} names nothing in the graph`});continue}if(C.superseded){u.push({code:"SUPERSEDED_TARGET",detail:`${h} is superseded \u2014 review the tip (${C.tip})`});continue}let N=C.cid;if(c.resolution==="approved")a.push({id:N,kind:"review-item",resolution:"approved",edit:null,reason:null,by:o});else if(c.resolution==="rejected")r.holdArchives?a.push({id:N,kind:"pending_archive",resolution:"pending",edit:null,reason:c.reason??null,by:o}):a.push({id:N,kind:"review-item",resolution:"rejected",edit:null,reason:c.reason??null,by:o});else if(c.resolution==="edited"){let x=t.getNode(N);if(!x){u.push({code:"UNKNOWN_NODE",detail:`${h}: node file unreadable`});continue}let z={...x.content,...c.edit?.title!==void 0?{title:c.edit.title}:{},...c.edit?.summary!==void 0?{summary:c.edit.summary}:{},...c.edit?.risk!==void 0?{risk:c.edit.risk}:{}},Q=se(x.label,z);if(Q.length>0){for(let w of Q)u.push({code:w.code,detail:`${h}: ${w.detail}`});continue}let G=oe(x.label,z);if(G===N){a.push({id:N,kind:"review-item",resolution:"approved",edit:null,reason:null,by:o});continue}d.push({cid:G,label:x.label,content:z}),n.add(N),g.push({kind:"node",old:N,new:G,reason:c.reason??"edited in review",by:o}),a.push({id:G,kind:"review-item",resolution:"edited",edit:{...c.edit},reason:null,by:o})}else if(c.resolution==="supersede"){let x=we(t,c.supersedeTarget,N,n);if("error"in x){u.push({code:x.error.code,detail:`${h}: ${x.error.detail}`});continue}n.add(x.targetCid),r.holdArchives?a.push({id:x.targetCid,kind:"pending_archive",resolution:"pending",edit:null,reason:`supersede by ${N}${c.reason?` \u2014 ${c.reason}`:""}`,by:o}):(g.push({kind:"node",old:x.targetCid,new:N,reason:c.reason??`superseded via review by ${o.id}`,by:o}),a.push({id:N,kind:"review-item",resolution:"approved",edit:null,reason:c.reason??null,by:o}))}}return u.length?{record:null,errors:u}:a.length===0&&g.length===0?{record:null,errors:[{code:"NO_VERDICTS",detail:"every item was skipped \u2014 nothing to commit"}]}:{record:X(s,{ts:new Date().toISOString(),proposal_id:null,nodes:d,edges:[],review:a,supersessions:g,source_head_moves:{}},{expectPrev:t.latestHash}).record,errors:null}}function Ct(r){let{contextDir:s,graph:t,survivor:e,merged:o,reason:u,by:d}=r,a=t.resolve(e),g=t.resolve(o);return a?g?a.superseded||g.superseded?{record:null,errors:[{code:"ALREADY_SUPERSEDED",detail:"a side of the pair is already superseded \u2014 the pair is drained"}]}:a.cid===g.cid?{record:null,errors:[{code:"SELF_SUPERSEDE",detail:"a pair cannot merge a node into itself"}]}:{record:X(s,{ts:new Date().toISOString(),proposal_id:null,nodes:[],edges:[],review:[],supersessions:[{kind:"node",old:g.cid,new:a.cid,reason:u??`pair merge: duplicate of ${e}`,by:d}],source_head_moves:{}},{expectPrev:t.latestHash}).record,errors:null}:{record:null,errors:[{code:"UNKNOWN_NODE",detail:`${o} names nothing in the graph`}]}:{record:null,errors:[{code:"UNKNOWN_NODE",detail:`${e} names nothing in the graph`}]}}function Nt(r){let{contextDir:s,graph:t,assignments:e,by:o}=r,u=[],d=[],a=new Set;for(let{ref:n,slug:_}of e){if(!de.test(_)){u.push({code:"BAD_SLUG",detail:`${JSON.stringify(_)} \u2014 slugs are kebab-case ${String(de)}`});continue}let h=t.resolve(n);if(!h){u.push({code:"UNKNOWN_REF",detail:`${n} names nothing in the graph`});continue}if(h.superseded){u.push({code:"SUPERSEDED_TARGET",detail:`${n} is superseded \u2014 name the tip instead (${h.tip})`});continue}let c=t.names.get(_);if(c!==void 0&&!t.superseded.has(c)&&c!==h.cid||a.has(_)){u.push({code:"SLUG_TAKEN",detail:`${_} already names ${c??"another node in this record"}`});continue}a.add(_),d.push({cid:h.cid,slug:_,by:o})}return u.length?{record:null,errors:u}:d.length===0?{record:null,errors:[{code:"NO_ASSIGNMENTS",detail:"nothing to name"}]}:{record:X(s,{ts:new Date().toISOString(),proposal_id:null,nodes:[],edges:[],review:[],supersessions:[],names:d,source_head_moves:{}},{expectPrev:t.latestHash}).record,errors:null}}function xt(r){let{contextDir:s,graph:t,sourceId:e,reason:o,by:u}=r,d=t.heads.get(e);return d===void 0?{record:null,errors:[{code:"UNKNOWN_SOURCE",detail:`no source ${e} in the graph`}]}:d===null?{record:null,errors:[{code:"ALREADY_RETIRED",detail:`source ${e} is already retired`}]}:{record:X(s,{ts:new Date().toISOString(),proposal_id:null,nodes:[],edges:[],review:[],supersessions:[{kind:"node",old:d,new:null,reason:o??`retired source ${e}`,by:u}],source_head_moves:{[e]:null},names:[]},{expectPrev:t.latestHash}).record,errors:null}}function yt(r){let s=se("gap",r.content);if(s.length>0)return{ok:!1,refusal:`defer gap failed schema validation: ${s.map(u=>u.detail).join("; ")}`};let t=oe("gap",r.content),e={reason:"reconcile change deferred"},o=r.annotates?[{ecid:q(b.ANNOTATES,t,r.annotates,e),type:b.ANNOTATES,src:t,dst:r.annotates,props:e}]:[];for(let u=0;;u++)try{return X(r.contextDir,{ts:new Date().toISOString(),proposal_id:null,nodes:[{cid:t,label:"gap",content:r.content}],edges:o,review:[],supersessions:[],source_head_moves:{}},{expectPrev:ue(r.contextDir)}),{ok:!0,cid:t}}catch(d){if(d instanceof Ee){if(u<3)continue;return{ok:!1,refusal:"concurrent activity kept moving the store \u2014 try the card again"}}throw d}}function Rt(r){let s=r.graph.byLabel("gap").filter(t=>t.content.kind==="reconcile_deferred"&&typeof t.content.uc=="string"&&r.graph.tipOf(t.content.uc)===r.targetTip&&(r.sourceId===void 0||t.content.basis?.source_id===void 0||t.content.basis.source_id===r.sourceId)&&!r.graph.superseded.has(t.cid)&&r.graph.trust.get(t.cid)!=="archived");if(s.length===0)return{resolved:0};for(let t=0;;t++)try{return X(r.contextDir,{ts:new Date().toISOString(),proposal_id:null,nodes:[],edges:[],review:[],supersessions:s.map(e=>({kind:"node",old:e.cid,new:r.resolvedBy,reason:"reconcile change resolved by a later verdict",by:r.by})),source_head_moves:{}},{expectPrev:ue(r.contextDir)}),{resolved:s.length}}catch(e){if(e instanceof Ee){if(t<3)continue;return{resolved:0}}throw e}}export{le as a,Pe as b,be as c,ve as d,de as e,He as f,vt as g,fe as h,ge as i,Te as j,St as k,je as l,Ke as m,We as n,It as o,$t as p,Ct as q,Nt as r,xt as s,yt as t,Rt as u,ke as v,Ae as w,Ye as x,Re as y,Oe as z,nt as A,ot as B,pe as C};
|
package/dist/chunk-TRJUD3XJ.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as w}from"./chunk-DNNZ353O.js";import{b as k}from"./chunk-TH47OOBV.js";import{d as S,e as m}from"./chunk-WXHQYYD5.js";var a=(e,t,o=new Set)=>{let s=e.nameOf.get(t);if(s!==void 0)return s;if(o.has(t))return t;o.add(t);for(let[r,n]of e.superseded){if(n!==t)continue;let u=a(e,r,o);if(u!==r)return u}return t};function b(e,t){let o=e.stale(t);if(o==="fresh")return;if(o==="orphaned")return"orphaned \u2014 no live source evidences this item";let s=[],r=new Map;for(let n of e.derivesInto(t))r.set(String(n.props.source_id),n);for(let[n,u]of r){let i=e.heads.get(n);if(i==null||i===u.props.source_cid)continue;let c=e.convChains.get(n)?.chain;c&&c.includes(String(u.props.source_cid))||s.push(`DERIVES pin ${n}@${String(u.props.source_cid).slice(0,19)} broke \u2014 the source head moved`)}for(let n of e.edgesFrom(t)){if(n.type===m.DERIVES||!e.superseded.has(n.dst))continue;let u=e.tipOf(n.dst);if(e.superseded.has(u)){s.push(`${n.type} pin \u2192 ${a(e,n.dst)} \u2014 target retired`);continue}let i=D(e,n.dst,u);s.push(i.length>0?`${a(e,n.dst)} updated: ${i.map(c=>c.field).join(", ")}`:`${n.type} pin \u2192 ${a(e,n.dst)} \u2014 target superseded`)}return s.length>0?s.join("; "):"stale \u2014 a pinned dependency moved"}function D(e,t,o){let s=e.getNode(t)?.content??{},r=e.getNode(o)?.content??{},n=i=>i===void 0?"":Array.isArray(i)?i.map(String).join(" \xB7 "):typeof i=="object"?JSON.stringify(i):String(i),u=[];for(let i of[...new Set([...Object.keys(s),...Object.keys(r)])].sort())JSON.stringify(s[i])!==JSON.stringify(r[i])&&u.push({field:i,old:n(s[i]),new:n(r[i])});return u}function C(e,t){let o=[];for(let{cid:s}of e.byLabel(S.SCENARIO))e.superseded.has(s)||e.edgesFrom(s).some(r=>r.type===m.BELONGS_TO&&e.tipOf(r.dst)===t)&&o.push(s);return o}function O(e,t){let o=[],s=[],r=[],n=C(e,t),u=new Set(n),i=(c,f)=>{let d=b(e,f);return d===void 0?c:{...c,stale:!0,stale_reason:d}};for(let c of n){let f=e.getNode(c)?.content??{};o.push(i({ref:a(e,c),title:String(f.title??""),case_type:String(f.case_type??""),intent:String(f.intent??"")},c));for(let d of e.edgesInto(c)){if(d.type!==m.AUTOMATES||e.superseded.has(d.src))continue;let p=e.getNode(d.src)?.content??{},g=e.edgesFrom(d.src).filter(l=>l.type===m.VERIFIES&&!e.superseded.has(l.dst)).map(l=>a(e,l.dst));s.push(i({ref:a(e,d.src),title:String(p.title??""),check:p.check,verifies:g},d.src))}}for(let{cid:c}of e.byLabel(S.AC)){if(e.superseded.has(c))continue;let f=e.edgesFrom(c).find(l=>l.type===m.SCOPED_TO);if(!f)continue;let d=e.tipOf(f.dst);if(!(d===t||u.has(d)))continue;let g=e.getNode(c)?.content??{};r.push(i({ref:a(e,c),text:String(g.text??""),kind:String(g.kind??""),scope:d===t?"use-case":a(e,d)},c))}return{scenarios:o,tests:s,acs:r}}function E(e,t,o){let s=w(e,t,o);return s===null?null:s.toString("utf8")}function v(e,t){let o=t.split(`
|
|
3
|
-
`).map(r=>r.replace(/^\d+\| /,"")),s=[];for(let r of e.split(`
|
|
4
|
-
`)){let n=r.trim();if(n.length===0)continue;let u=o.find(i=>i.includes(n));u!==void 0&&!s.includes(u.trim())&&s.push(u.trim())}return s.length>0?s.join(`
|
|
5
|
-
`):{removed:!0}}function G(e,t,o,s){if(s!==void 0&&s.trim().length>0)return{kind:"user-directive",text:s.trim()};let r=[o,...O(t,o).acs.map(c=>t.resolve(c.ref)?.cid??"")].filter(Boolean),n=[],u=new Set;for(let c of r){let f=new Map;for(let d of t.derivesInto(c))f.set(String(d.props.source_id),d);for(let[d,p]of f){let g=t.heads.get(d);if(g==null||g===p.props.source_cid)continue;let l=String(p.props.anchor),_=`${d}\0${l}`;if(u.has(_)||l==="img#whole")continue;u.add(_);let y=E(e,t,String(p.props.source_cid)),h=y===null?null:k(y,l);if(h===null)continue;let x=E(e,t,g);n.push({source_id:d,anchor:l,old_anchor_text:h,new_anchor_text:x===null?{removed:!0}:v(h,x)})}}let i;for(let[c,f]of t.superseded){if(f!==o||t.nodeLabel.get(c)!==S.USECASE)continue;let d=D(t,c,o);d.length>0&&(i=d);break}return{kind:"source-change",changes:n,...i?{uc_updated:i}:{}}}function P(e,t,o,s){let r=O(t,o);if(r.scenarios.length===0&&r.tests.length===0&&r.acs.length===0)return;let n=G(e,t,o,s);if(!(n.kind==="source-change"&&n.changes.length===0&&!n.uc_updated))return{prior_design:r,change_delta:n}}export{O as a,P as b};
|
package/dist/chunk-UOMRMCMI.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
function o(e){return e.kind==="simulator"?e.id:e.virtualName??e.id}function n(e,i,r={}){let t={platform:e.platform,udid:e.id,target_kind:e.kind};return i&&(t.app_package=i),r.noReset!==void 0&&(t.no_reset=r.noReset),r.appiumUrl&&(t.appium_url=r.appiumUrl),t}export{o as a,n as b};
|
package/dist/chunk-VAYBKR76.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as j}from"./chunk-CUM23TLF.js";import{a as v,d as N,g as C}from"./chunk-DUAXZYAD.js";import{a as y,e as S,f as D,g as F,h as L}from"./chunk-WXHQYYD5.js";import{existsSync as b,mkdirSync as V,readFileSync as $,renameSync as G,rmSync as J,writeFileSync as W}from"fs";import{dirname as H,join as w}from"path";var q=i=>w(i,"derived"),M=i=>w(q(i),"index.json");function T(i,s){let t=s.startsWith("sha256:")?s.slice(7):s;return w(q(i),"nodes",t.slice(0,2),t.slice(2)+".json")}function O(){return{applied:{seq:0,hash:null},heads:{},trust:{},nodeLabel:{},forward:{},extracted:[],design_of:{},design_generation:{},exec:{},superseded:{},names:{},archivedReason:{},appliedEvents:[],completeness:{},srcOwner:{},conv:{},media:{},design_phases:{}}}function U(i){let s=M(i);if(!b(s))return null;try{let t=JSON.parse($(s,"utf8"));return t.superseded===void 0||t.names===void 0||t.archivedReason===void 0||t.appliedEvents===void 0||t.conv===void 0||t.media===void 0||t.exec===void 0||t.completeness===void 0||t.srcOwner===void 0||t.design_phases===void 0||t.reverse!==void 0?null:t}catch{return null}}function P(i,s){V(H(i),{recursive:!0});let t=`${i}.tmp-${process.pid}`;W(t,s),G(t,i)}function R(i,s,t,p,_={}){let l=_.writeNodeFiles!==!1,g=new Set(s.extracted),h=new Set(s.appliedEvents);t.forEach((n,E)=>{for(let e of n.nodes){let d=T(i,e.cid);l&&!b(d)&&P(d,JSON.stringify({label:e.label,content:e.content})+`
|
|
3
|
-
`),!(e.cid in s.trust)&&e.content.derived===!0&&(s.trust[e.cid]="derived"),s.nodeLabel[e.cid]=e.label}for(let[e,d]of Object.entries(n.source_head_moves))typeof d=="string"&&(s.srcOwner[d]=e);if(n.proposal_id!=null&&typeof n.extraction_of=="string"){g.add(n.extraction_of);let e=null;for(let d of n.edges)if(d.type===S.DERIVES&&d.props.source_cid===n.extraction_of&&typeof d.props.source_id=="string"){e=d.props.source_id;break}if(e??=s.srcOwner[n.extraction_of]??null,e!==null){let d=s.completeness[e];(!d||n.seq>=d.seq)&&(s.completeness[e]={source_cid:n.extraction_of,completeness:"complete",...n.extractor_version?{extractor_version:n.extractor_version}:{},at:n.ts,seq:n.seq})}else s.completenessSkipped=(s.completenessSkipped??0)+1}else if(n.proposal_id!=null&&Array.isArray(n.extraction_of))for(let e of n.extraction_of){g.add(e.source_cid);let d=s.completeness[e.source_id];(!d||n.seq>=d.seq)&&(s.completeness[e.source_id]={source_cid:e.source_cid,completeness:e.completeness,...e.extractor_version?{extractor_version:e.extractor_version}:{},at:e.at,seq:n.seq})}n.design_of&&((s.design_of??={})[n.design_of.uc_cid]={engine:n.design_of.engine,seq:n.seq}),n.design_generation&&((s.design_generation??={})[n.design_generation.uc_root]={gen:n.design_generation.generation,seq:n.seq});{let e=n.design_phase;e&&typeof e.uc_root=="string"&&typeof e.phase=="string"&&typeof e.generation=="number"&&((s.design_phases??={})[e.uc_root]??=[]).push({phase:e.phase,generation:e.generation,seq:n.seq,completeness:e.completeness==="partial"?"partial":"complete"})}for(let e of n.executions??[])((s.exec??={})[e.about]??=[]).push(e);for(let e of n.edges){let{quote:d,...r}=e.props,o=s.forward[e.src]??=[];o.some(a=>a.ecid===e.ecid)||o.push({...e,props:r}),n.proposal_id!=null&&e.type===S.DERIVES&&typeof e.props.source_cid=="string"&&g.add(e.props.source_cid)}for(let e of n.review)e.resolution==="approved"||e.resolution==="edited"?(s.trust[e.id]="trusted",delete s.archivedReason[e.id]):e.resolution==="rejected"?(s.trust[e.id]="archived",e.reason?s.archivedReason[e.id]=e.reason:delete s.archivedReason[e.id]):e.resolution==="reset"&&(s.trust[e.id]="derived",delete s.archivedReason[e.id]);for(let e of n.supersessions)e.kind==="node"?e.new===e.old?delete s.superseded[e.old]:s.superseded[e.old]=e.new:s.superseded[e.ecid]=null;for(let e of n.names??[])s.names[e.slug]=e.cid;for(let[e,d]of Object.entries(n.source_head_moves))s.heads[e]=d;for(let e of n.event_ids??[])h.add(e);if(n.media)for(let[e,d]of Object.entries(n.media)){let r=n.source_head_moves[e];typeof r=="string"&&(s.media[r]=d)}if(n.conv){let e=n.source_head_moves[n.conv.source_id];if(typeof e=="string"){let d=s.conv[n.conv.source_id],r=d&&d.chain.length>0?d.chain[d.chain.length-1]:null;n.conv.append_of===r?s.conv[n.conv.source_id]={turns:n.conv.turn,chain:[...d?.chain??[],e]}:s.conv[n.conv.source_id]={turns:n.conv.turn,chain:[e]}}}for(let[e,d]of Object.entries(n.source_head_moves))n.conv?.source_id!==e&&s.conv[e]!==void 0&&(s.conv[e]=typeof d=="string"?{turns:s.conv[e].turns,chain:[d]}:{turns:s.conv[e].turns,chain:[]});s.applied={seq:n.seq,hash:p[E]}}),s.extracted=[...g].sort(),s.appliedEvents=[...h].sort()}function x(i,s){P(M(i),JSON.stringify(s)+`
|
|
4
|
-
`)}function K(i){let s=w(i,"meta.json");if(b(s))try{let t=JSON.parse($(s,"utf8"));if(t.schema!==y||t.canonicalizer!=="v1")throw new v(`schema fence: store is ${t.schema}/${t.canonicalizer}, this build is ${y}/${"v1"} \u2014 migrate explicitly (kane-cli context rebuild after upgrading)`)}catch(t){throw t instanceof v?t:new v(`corrupt meta.json in ${i} \u2014 fix or remove it`)}}function Y(i){K(i);let s=U(i);if(s===null){s=O();let{records:_,hashes:l}=N(i);return R(i,s,_,l),x(i,s),s}let{records:t,hashes:p}=C(i,s.applied.seq,s.applied.hash);return t.length>0&&(R(i,s,t,p),x(i,s)),s}function se(i){return J(q(i),{recursive:!0,force:!0}),Y(i)}var z=new Set(["CHAIN_ERROR","DERIVED_MISSING","DERIVED_DRIFT","NODE_FILE_MISSING","NODE_FILE_MISMATCH","NODE_FILE_CORRUPT"]);function ne(i){return z.has(i.code)?i.detail:`${i.code}: ${i.detail}`}function te(i){let s=[],t=(r,o)=>{s.push({code:r,detail:o})},p=[],_=[];try{({records:p,hashes:_}=N(i))}catch(r){return{ok:!1,issues:[{code:"CHAIN_ERROR",detail:r instanceof v?r.message:String(r)}],records:0}}let l=O();R(i,l,p,_,{writeNodeFiles:!1});let g=U(i),h=0,n=l;if(g!==null&&g.applied.seq<p.length){let r=g.applied.seq;g.applied.hash===(r===0?null:_[r-1])&&(h=p.length-r,n=O(),R(i,n,p.slice(0,r),_.slice(0,r),{writeNodeFiles:!1}))}if(g===null)t("DERIVED_MISSING","derived/index.json missing or corrupt (run kane-cli context rebuild)");else{let r=o=>JSON.stringify(k(o));for(let o of["applied","heads","trust","nodeLabel","forward","extracted","superseded","names","archivedReason","appliedEvents","conv","media","design_of","design_generation","design_phases","exec","completeness","srcOwner"])r(n[o])!==r(g[o])&&t("DERIVED_DRIFT",`derived drift in index.${o} (run kane-cli context rebuild)`)}let E=new Set;for(let r of Object.values(l.forward))for(let o of r)E.add(o.ecid);let e=new Set;for(let r of p)for(let o of r.supersessions)o.kind==="node"?(o.old in l.nodeLabel||t("SUPERSEDE_UNKNOWN_OLD",`${o.old} (record ${r.seq})`),o.new!==null&&o.new!==o.old&&!(o.new in l.nodeLabel)&&t("SUPERSEDE_UNKNOWN_NEW",`${String(o.new)} (record ${r.seq})`),o.new===o.old?e.delete(o.old):(e.has(o.old)&&t("DOUBLE_SUPERSEDE",`${o.old} re-superseded while live (record ${r.seq})`),e.add(o.old))):E.has(o.ecid)||t("SUPERSEDE_UNKNOWN_ECID",`${o.ecid} (record ${r.seq})`);for(let r of Object.keys(l.superseded)){let o=new Set,a=r;for(;a!==null&&a in l.superseded;){if(o.has(a)){t("SUPERSEDE_CYCLE",`chain from ${r} revisits ${a}`);break}o.add(a),a=l.superseded[a]}}for(let[r,o]of Object.entries(l.names))o in l.nodeLabel||t("NAME_UNKNOWN_TARGET",`slug ${r} \u2192 ${o} not in the graph`);for(let r of p)for(let o of r.edges){let a=l.nodeLabel[o.src]??"(unknown)",f=l.nodeLabel[o.dst]??"(unknown)";for(let c of L(o.type,a,f,o.props))t(c.code,`${o.ecid} ${c.detail}`)}let d=new Map;for(let r of Object.values(l.forward))for(let o of r){if(o.ecid in l.superseded)continue;let a=d.get(o.type)??[];a.push(o),d.set(o.type,a)}for(let[r,o]of d){let a=F(r);if(a?.acyclic){let f=new Map;for(let u of o)f.set(u.src,[...f.get(u.src)??[],u.dst]);let c=new Map,m=u=>{c.set(u,1);for(let I of f.get(u)??[])if(c.get(I)===1||c.get(I)===void 0&&m(I))return!0;return c.set(u,2),!1};for(let u of f.keys())if(c.get(u)===void 0&&m(u)){t("EDGE_CYCLE",`live ${r} edges form a cycle reachable from ${u}`);break}}if(a?.cardinality==="one-live-per-src"||a?.cardinality==="one-live-per-src-and-dst"){let f=new Map;for(let c of o)c.dst in l.superseded||f.set(c.src,[...f.get(c.src)??[],c]);for(let[c,m]of f)m.length>1&&t("CARDINALITY_VIOLATION",`${m.length} live ${r} edges from ${c} (one-live-per-src): ecids ${m.map(u=>u.ecid).join(",")}`)}if(a?.cardinality==="one-live-per-src-and-dst"){let f=new Map;for(let c of o)c.src in l.superseded||c.dst in l.superseded||f.set(c.dst,[...f.get(c.dst)??[],c]);for(let[c,m]of f)m.length>1&&t("CARDINALITY_VIOLATION",`${m.length} live ${r} edges onto ${c} (one-live-per-dst): ecids ${m.map(u=>u.ecid).join(",")}`)}}for(let[r,o]of Object.entries(n.nodeLabel)){let a=T(i,r);if(!b(a)){t("NODE_FILE_MISSING",`missing node file for ${r} (run kane-cli context rebuild)`);continue}try{let f=JSON.parse($(a,"utf8"));(f.label!==o||j(f.label,f.content)!==r)&&t("NODE_FILE_MISMATCH",`node file content mismatch for ${r} (run kane-cli context rebuild)`);for(let c of D(f.label,f.content))t(c.code,`${r} ${c.detail}`)}catch{t("NODE_FILE_CORRUPT",`corrupt node file for ${r} (run kane-cli context rebuild)`)}}return{ok:s.length===0,issues:s,records:p.length,...h>0?{pending:h}:{}}}function k(i){return Array.isArray(i)?i.map(k):i&&typeof i=="object"?Object.fromEntries(Object.entries(i).sort(([s],[t])=>s<t?-1:1).map(([s,t])=>[s,k(t)])):i}export{T as a,Y as b,se as c,ne as d,te as e};
|
package/dist/chunk-VT2XNEOD.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as D,b as F}from"./chunk-2UIHS2FH.js";import{a as ce}from"./chunk-YKTYVJBN.js";import{a as k,b as se,c as ie,d as ae,k as P}from"./chunk-X2FM67OM.js";import{a as J}from"./chunk-N2P4MI32.js";import{b as B,d as M}from"./chunk-NVGBE2DR.js";import{A as x}from"./chunk-TH47OOBV.js";import{w as oe}from"./chunk-CCUGKBIH.js";var v="https://integrations.lambdatest.com",b=class extends Error{constructor(e,r){super(r);this.code=e;this.name="LisError"}};function Re(t){let n=t.TESTMUAI_ENV==="stage"?"stage":"prod";return`${oe[n].shareApiBaseUrl}/lis/api/v1`}function $e(t){let n=t.env??process.env,e=t.auth?.TESTMUAI_BASIC_AUTH||n.TESTMUAI_BASIC_AUTH;if(e)return{authorization:`Basic ${e}`};let r=t.auth?.TESTMUAI_API_KEY||n.TESTMUAI_API_KEY;return r?{authorization:`Bearer ${r}`}:{}}function $(t){let n=t.split(`
|
|
3
|
-
`,1)[0].replace(/[\u0000-\u001f\u007f-\u009f]/g,"");return n.length>200?`${n.slice(0,200)}\u2026`:n}function Te(t,n,e="the issue"){return t===401||t===403?new b("LIS_AUTH","credentials rejected \u2014 run `kane-cli login` and retry"):t>=500?new b("LIS_UNAVAILABLE",`the integrations service returned an error (HTTP ${t}) \u2014 retry later`):new b("JIRA_ISSUE_UNAVAILABLE",`could not fetch ${e}: ${$(n)||`HTTP ${t}`}`)}function j(t){try{return JSON.parse(t.bytes.toString("utf8"))}catch{throw new b("LIS_UNAVAILABLE","the integrations service returned a malformed response \u2014 retry later")}}function ee(t){try{return JSON.parse(t.bytes.toString("utf8"))}catch{return{}}}function ue(t){return ee(t).code}function C(t,n="the issue"){let e=ee(t);switch(e.code){case"TOKEN_EXPIRED":return new b("LIS_SETUP",`your Atlassian connection needs a resync \u2014 reconnect at ${v} and retry`);case"NOT_INSTALLED":return new b("LIS_SETUP",`no Atlassian connection for this account \u2014 create one at ${v} and retry`);case"SCOPE_MISSING":return new b("LIS_SETUP",`the connection has no Confluence access \u2014 reconnect with Confluence at ${v} and retry`);case"FORBIDDEN":return new b("LIS_FORBIDDEN",`you don't have access to ${n}`);case"NOT_FOUND":return new b("JIRA_ISSUE_UNAVAILABLE",`could not fetch ${n}: ${$(e.message??"")||"not found"}`);case"PAYLOAD_TOO_LARGE":return new b("ATTACHMENT_TOO_LARGE","the attachment exceeds the integrations service's size cap");case"INVALID_PAYLOAD":return new b("LIS_UNAVAILABLE",`the integrations service rejected the request (${$(e.message??"")||"invalid payload"}) \u2014 retry later`);case"NOT_SUPPORTED":return new b("LIS_UNAVAILABLE","the integrations service does not support this operation yet");case"UPSTREAM_ERROR":case"UPSTREAM_TIMEOUT":return new b("LIS_UNAVAILABLE","Atlassian is not responding through the integrations service \u2014 retry later");default:return Te(t.status,e.message??"",n)}}var Ce=3e4,Oe=5;async function O(t,n,e){let r=e.env??process.env,l=e.fetchImpl??fetch;for(let o=0;;o++){let d=new AbortController,f=setTimeout(()=>d.abort(),Ce);try{let i=await l(`${Re(r)}${t}`,{...n,headers:{"content-type":"application/json",...$e(e),...n.headers??{}},signal:d.signal}),c=await Promise.race([i.arrayBuffer(),new Promise((a,s)=>{d.signal.addEventListener("abort",()=>s(new DOMException("aborted","AbortError")),{once:!0})})]),u={status:i.status,ok:i.ok,headers:i.headers,bytes:Buffer.from(c)};if(u.status===429){if(o>0)throw new b("LIS_RATE_LIMITED","the integrations service is busy \u2014 try again in a moment");let a=ee(u).data?.retry_after_sec,s=Math.min(Math.max(typeof a=="number"&&Number.isFinite(a)?a:1,0),Oe);clearTimeout(f),await new Promise(y=>setTimeout(y,s*1e3));continue}return u}catch(i){throw i instanceof b?i:d.signal.aborted?new b("LIS_UNAVAILABLE","the integrations service did not respond within 30 seconds \u2014 retry later"):new b("LIS_UNAVAILABLE",`could not reach the integrations service (${$(i instanceof Error?i.message:String(i))}) \u2014 check your connection and retry`)}finally{clearTimeout(f)}}}function K(t){let n=t.headers.get("content-type")??"application/octet-stream";if(n.includes("json"))try{let e=JSON.parse(t.bytes.toString("utf8")),r=e.content??e.data?.content;if(typeof r=="string")return{bytes:Buffer.from(r,"base64"),mediaType:e.mime_type??e.data?.mime_type??"application/octet-stream"}}catch{}return{bytes:t.bytes,mediaType:n}}async function V(t={}){let n=await O("/jira/info",{method:"GET"},t);if(!n.ok)throw C(n);let e=j(n),r=(e.data?.SELECTED_PROJECTS??[]).map(l=>l?.key).filter(l=>typeof l=="string"&&l.length>0);return{installed:e.data?.INSTALLED==="YES",selectAll:e.data?.SELECT_ALL===!0,selectedProjects:r,capabilities:{document:e.data?.capabilities?.document===!0,comments:e.data?.capabilities?.comments===!0}}}async function W(t,n={}){let e=await O("/jira/issue?details=true",{method:"POST",body:JSON.stringify({plugin_code:"jira",issueKey:t})},n);if(!e.ok)throw C(e);let r=j(e);if(r.type==="error"||!r.data)throw new b("JIRA_ISSUE_UNAVAILABLE",`could not fetch the issue: ${$(r.message??"")||"issue not found or not accessible"}`);return r.data}var le=100,Ne=5e3,ke=60;async function G(t,n={}){let e=[],r=new Set,l=null,o=0;for(let d=0;;d++){if(d>=ke)throw new b("LIS_UNAVAILABLE","the integrations service kept returning comment pages without finishing \u2014 retry later");let f=await O("/jira/issue/comments",{method:"POST",body:JSON.stringify({resource_id:t,max_results:le,cursor:l,start_at:o,order_by:"created",fetch_all:!1})},n);if(!f.ok)throw C(f,"the issue's comments");let i=j(f);if(i.type==="error"||!i.data)throw new b("JIRA_ISSUE_UNAVAILABLE",`could not fetch the issue's comments: ${$(i.message??"")||"unavailable"}`);for(let L of i.data.comments??[]){let m=String(L.id);r.has(m)||(r.add(m),e.push(L))}let c=i.data.pagination;if(!c?.has_more)return e;if(e.length>=Ne)throw new b("JIRA_ISSUE_UNAVAILABLE","the issue has more comments than can be ingested \u2014 cannot build a complete identity");let u=c.next_cursor??null,a=c.next_start_at!=null,s=a?c.next_start_at:o+le;if(!(u!=null&&u!==l||u==null&&a&&s!==o))throw new b("LIS_UNAVAILABLE","the integrations service returned a non-advancing comments page \u2014 retry later");l=u,o=s}}async function Y(t,n={}){let e=await O("/jira/attachment",{method:"POST",body:JSON.stringify({attachment_id:t})},n);if(!e.ok){if(ue(e)===void 0){if(e.status===413)throw new b("ATTACHMENT_TOO_LARGE","the attachment exceeds the integrations service's size cap");if(e.status===404)throw new b("JIRA_NOT_CONNECTED",`Jira is not connected for this account \u2014 connect it at ${v} and retry`)}throw C(e,`attachment ${t}`)}return K(e)}var H="kane.source.jira/2";function pe(t){if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return String(t);if(Array.isArray(t)){let n=t.map(pe).filter(e=>e!==null);return n.length===0?null:n.join(", ")}if(t!==null&&typeof t=="object"){let n=t;for(let e of["name","value","displayName"])if(typeof n[e]=="string")return n[e];return null}return null}function de(t,n,e){let r=[],l={},o=t.additional_fields??{};for(let u of Object.keys(o).sort()){let a=pe(o[u]);if(a===null){r.push(`field "${u}" has no stable text form \u2014 dropped from the envelope`);continue}l[u]=a}let d=[...t.attachments??[]].map(u=>({id:String(u.id),filename:u.filename??"",media_type:u.mime_type??"application/octet-stream",size:u.size??0})).sort((u,a)=>{let s=Number(u.id),y=Number(a.id);return Number.isFinite(s)&&Number.isFinite(y)?s-y:u.id<a.id?-1:u.id>a.id?1:0}),f=e.map(u=>({id:String(u.id),author:u.author?.display_name??"",body:u.body??"",created:u.created??""})).sort((u,a)=>{if(u.created!==a.created)return u.created<a.created?-1:1;let s=Number(u.id),y=Number(a.id);return Number.isFinite(s)&&Number.isFinite(y)&&s!==y?s-y:u.id<a.id?-1:u.id>a.id?1:0}),i=t.key;if(!/^[A-Za-z][A-Za-z0-9_]*-\d+$/.test(i))throw new Error(`cannot build a stable identity for issue key "${i}" \u2014 expected a PROJECT-NUMBER key`);let c={schema:H,site:n,project:i.slice(0,i.lastIndexOf("-")),issue:{id:t.id,key:i},content:{summary:t.summary??"",description:t.description??"",fields:l},attachments:d,comments:f};return{bytes:Buffer.from(JSON.stringify(c),"utf8"),envelope:c,warnings:r}}var me=64,Pe=16,je=6e6,Ue=5e7,xe=12e6,Be={png:"image/png",jpeg:"image/jpeg",webp:"image/webp",gif:"image/gif",bmp:"image/bmp",tiff:"image/tiff",emf:"image/emf",wmf:"image/wmf",unknown:"application/octet-stream"},Me=new Set(["png","jpeg","webp"]);function fe(t){return async n=>{let e;try{e=JSON.parse(n.toString("utf8"))}catch{throw new Error("JIRA_ENVELOPE_SCHEMA: source bytes are not a kane jira envelope")}if(e.schema!==H)throw new Error(`JIRA_ENVELOPE_SCHEMA: unknown envelope schema "${e.schema}" \u2014 this CLI understands ${H}`);let r=[],l=new Map,o=[],d=0,f=new Map,i=[];for(let a=0;a<e.attachments.length;a++){let s=e.attachments[a],y=`i${a+1}`,L=`attachment:${s.filename}`,m=I=>`[img#${y}] ${s.filename} (${s.media_type}, ${s.size} bytes${I?"":" \u2014 not delivered"})`,g=(I,A,T)=>{r.push({ref:y,loc:L,media_type:I,...T?.blob?{blob:T.blob}:{},...T?.appearance?{appearance:T.appearance}:{},delivery:A,...T?.duplicate_of?{duplicate_of:T.duplicate_of}:{}})};if(!s.media_type.startsWith("image/")){g(s.media_type,"unsupported-vision-media-type"),i.push(m(!1));continue}let S;try{S=await t.fetchAttachment(s.id)}catch{g(s.media_type,"external-image-not-fetched"),i.push(m(!1));continue}let h=S.bytes,p=D(h),_=Be[p.format],E=B(h);if(l.set(E,h),!Me.has(p.format)){let I=p.format==="gif"||p.format==="bmp"||p.format==="tiff"?"unsupported-vision-media-type":"unsupported-image-kind";g(_,I,{blob:E}),i.push(m(!1));continue}if(p.width===void 0||p.height===void 0||p.width*p.height>Ue){g(_,"undecodable",{blob:E}),i.push(m(!1));continue}let w;if(p.format==="png"||p.format==="jpeg"){let I=F(h,p.format);if(I===null){g(_,"undecodable",{blob:E}),i.push(m(!1));continue}w=J(I.data,{width:I.width,height:I.height,channels:I.channels})}if(p.width<me||p.height<me){g(_,"below-dimension-floor",{blob:E,appearance:w}),i.push(m(!1));continue}let R=f.get(E);if(R!==void 0){g(_,"duplicate",{blob:E,appearance:w,duplicate_of:R}),i.push(m(!1));continue}if(h.byteLength>je){g(_,"image-too-large",{blob:E,appearance:w}),i.push(m(!1));continue}if(d+h.byteLength>xe){g(_,"vision-byte-budget-reached",{blob:E,appearance:w}),i.push(m(!1));continue}if(o.length>=Pe){g(_,"image-cap-reached",{blob:E,appearance:w}),i.push(m(!1));continue}f.set(E,y),d+=h.byteLength,o.push(y),g(_,"selected",{blob:E,appearance:w}),i.push(m(!0))}let c=[];c.push(`${e.issue.key} \xB7 ${e.site}/${e.project}`,`Summary: ${e.content.summary}`),e.content.description!==""&&c.push("",...e.content.description.split(`
|
|
4
|
-
`));let u=Object.keys(e.content.fields);return u.length>0&&c.push("","--- fields ---",...u.map(a=>`${a}: ${e.content.fields[a]}`)),i.length>0&&c.push("","--- attachments ---",...i),e.comments.length>0&&(c.push("","--- comments ---"),e.comments.forEach((a,s)=>{s>0&&c.push(""),c.push(`[${s+1}] ${a.author} \xB7 ${a.created}`,...a.body.split(`
|
|
5
|
-
`))})),{projection:c.join(`
|
|
6
|
-
`)+`
|
|
7
|
-
`,inventory:r,blobs:l,delivered:o,converter:{name:"jira-convert",version:"2",policy:"v1"}}}}var Je=/^[A-Za-z][A-Za-z0-9_]*-\d+$/;function z(t){if(!/^https?:\/\/.+/i.test(t))return null;let n;try{n=new URL(t)}catch{return null}let e=n.pathname.split("/").filter(Boolean),r=e.lastIndexOf("browse");if(r===-1||r+1>=e.length)return null;let l=e[r+1];return Je.test(l)?{site:n.hostname,issueKey:l.toUpperCase()}:null}function X(t,n){let e=x(t),r=e.heads.get(n);if(r==null)return null;let l=e.getNode(r)?.content?.blob;if(typeof l!="string")return null;let o=M(t,l);if(o===null)return null;try{let d=JSON.parse(o.toString("utf8"));return typeof d.site=="string"&&d.site.length>0?d.site:null}catch{return null}}async function De(t,n,e,r,l){let o=z(t);if(o===null)return(e.err??e.out)(`error: ${t}: unsupported remote URL \u2014 expected a Jira issue URL (https://<site>/browse/KEY-123)`),{code:1};let d=l?.lis??{jiraInfo:V,jiraIssue:W,jiraAttachment:Y,jiraComments:G};try{let i={auth:await(l?.authEnv??(await import("./auth-3DLNMZC2.js")).resolveLisAuthEnv)(),env:process.env},c=await d.jiraInfo(i);if(!c.installed)return(e.err??e.out)(`error: ${t}: no Atlassian connection for this account \u2014 create one at ${v} and retry`),{code:1};if(c.capabilities.comments===!1)return(e.err??e.out)(`error: ${t}: the connection cannot read issue comments yet \u2014 resync it at ${v} and retry`),{code:1};let u=o.issueKey.slice(0,o.issueKey.lastIndexOf("-"));if(!c.selectAll&&c.selectedProjects.length>0&&!c.selectedProjects.includes(u))return(e.err??e.out)(`error: ${t}: project ${u} is not in the integration's selected projects (${c.selectedProjects.join(", ")}) \u2014 add it at ${v}`),{code:1};let a=await d.jiraIssue(o.issueKey,i),s=await d.jiraComments(o.issueKey,i),y=o.site;if(a.host)try{y=new URL(a.host).hostname}catch{y=a.host.replace(/^https?:\/\//,"").replace(/[/:].*$/,"")}let{bytes:L,warnings:m}=de(a,y,s),g=n??o.issueKey.toLowerCase();k(g);let S=X(r,g);if(S!==null&&S!==y)return(e.err??e.out)(`error: ${t}: source '${g}' was ingested from ${S}, but this read serves ${y} \u2014 retire it first (kane-cli context retire ${g}) or ingest under a different id with --as`),{code:1};let h=await P({contextDir:r,bytes:L,media:se,sourceId:g,label:t,confirmSameSource:e.isTTY?p=>e.confirm(`identical content already ingested as ${p} \u2014 treat as the same source?`):void 0,converters:{jira:fe({fetchAttachment:p=>d.jiraAttachment(p,i)})}});e.out(U(e.isTTY,h,o.issueKey));for(let p of m)e.out(`warning: ${p}`);for(let p of h.warnings??[])e.out(`warning: ${p}`);if(h.composite){let p=h.composite.delivered+h.composite.omitted;e.out(`${h.source_id}: jira, ${p} attachments, ${h.composite.delivered} images delivered (${h.composite.omitted} omitted)`)}return{code:0,result:{status:h.status,source_id:h.source_id,source_cid:h.cid}}}catch(f){return f instanceof b?((e.err??e.out)(`error: ${t}: ${f.message}`),{code:1}):((e.err??e.out)(`error: ${t}: ${Fe(f instanceof Error?f.message:String(f))}`),{code:1})}}function Fe(t){let n=t.match(/too large — ([\d.]+ [KM]B), the limit for .+ is ([\d.]+ [KM]B) \[FILE_TOO_LARGE\]/);return n?`the issue's content is too large to ingest (${n[1]}; the limit is ${n[2]}) \u2014 trim the description or attachments in Jira and retry`:t.startsWith("PROJECTION_TOO_LARGE:")?"the issue's text is too large to ingest \u2014 trim the description in Jira and retry":t}var ge={name:"jira",hint:"Jira issue URLs (https://<site>/browse/KEY-123)",match:t=>z(t)!==null,ingest:De,sourceIdFor:t=>{let n=z(t);return n?n.issueKey.toLowerCase():null}};async function he(t,n={}){let e=await O("/jira/document",{method:"POST",body:JSON.stringify({resource_id:t,format:"markdown"})},n);if(!e.ok)throw C(e,"the page");let r=j(e);if(r.type==="error"||!r.data)throw new b("JIRA_ISSUE_UNAVAILABLE",`could not fetch the page: ${$(r.message??"")||"page not found or not accessible"}`);return r.data}async function ye(t,n={}){let e=await O("/jira/attachment",{method:"POST",body:JSON.stringify({source:"confluence",download:t})},n);if(!e.ok)throw C(e,"the page's attachment");return{bytes:K(e).bytes}}var q="kane.source.confluence/1";function be(t,n){if(typeof t.id!="string"||t.id==="")throw new Error("cannot build a stable identity for this page \u2014 the integrations service returned no page id");let e=[...t.labels??[]].filter(o=>typeof o=="string").sort(),r=[...t.attachments??[]].map(o=>({id:String(o.id),filename:o.filename??"",media_type:o.mime_type??"application/octet-stream",size:o.size??0})).sort((o,d)=>o.id<d.id?-1:o.id>d.id?1:0),l={schema:q,site:n,page:{id:t.id},space:{key:t.space?.key??""},title:t.title??"",labels:e,content:{body:t.body??""},attachments:r};return{bytes:Buffer.from(JSON.stringify(l),"utf8"),envelope:l,warnings:[]}}var _e=64,Ke=16,Ve=6e6,We=5e7,Ge=12e6,Ye={png:"image/png",jpeg:"image/jpeg",webp:"image/webp",gif:"image/gif",bmp:"image/bmp",tiff:"image/tiff",emf:"image/emf",wmf:"image/wmf",unknown:"application/octet-stream"},He=new Set(["png","jpeg","webp"]);function Ee(t){let n=new Map(Object.entries(t.downloads));return async e=>{let r;try{r=JSON.parse(e.toString("utf8"))}catch{throw new Error("CONFLUENCE_ENVELOPE_SCHEMA: source bytes are not a kane confluence envelope")}if(r.schema!==q)throw new Error(`CONFLUENCE_ENVELOPE_SCHEMA: unknown envelope schema "${r.schema}" \u2014 this CLI understands ${q}`);let l=[],o=new Map,d=[],f=0,i=new Map,c=[];for(let a=0;a<r.attachments.length;a++){let s=r.attachments[a],y=`i${a+1}`,L=`attachment:${s.filename}`,m=A=>`[img#${y}] ${s.filename} (${s.media_type}, ${s.size} bytes${A?"":" \u2014 not delivered"})`,g=(A,T,N)=>{l.push({ref:y,loc:L,media_type:A,...N?.blob?{blob:N.blob}:{},...N?.appearance?{appearance:N.appearance}:{},delivery:T,...N?.duplicate_of?{duplicate_of:N.duplicate_of}:{}})};if(!s.media_type.startsWith("image/")){g(s.media_type,"unsupported-vision-media-type"),c.push(m(!1));continue}let S=n.get(s.id);if(!S){g(s.media_type,"external-image-not-fetched"),c.push(m(!1));continue}let h;try{h=await t.fetchAttachment({id:s.id,download:S})}catch{g(s.media_type,"external-image-not-fetched"),c.push(m(!1));continue}let p=h.bytes,_=D(p),E=Ye[_.format],w=B(p);if(o.set(w,p),!He.has(_.format)){let A=_.format==="gif"||_.format==="bmp"||_.format==="tiff"?"unsupported-vision-media-type":"unsupported-image-kind";g(E,A,{blob:w}),c.push(m(!1));continue}if(_.width===void 0||_.height===void 0||_.width*_.height>We){g(E,"undecodable",{blob:w}),c.push(m(!1));continue}let R;if(_.format==="png"||_.format==="jpeg"){let A=F(p,_.format);if(A===null){g(E,"undecodable",{blob:w}),c.push(m(!1));continue}R=J(A.data,{width:A.width,height:A.height,channels:A.channels})}if(_.width<_e||_.height<_e){g(E,"below-dimension-floor",{blob:w,appearance:R}),c.push(m(!1));continue}let I=i.get(w);if(I!==void 0){g(E,"duplicate",{blob:w,appearance:R,duplicate_of:I}),c.push(m(!1));continue}if(p.byteLength>Ve){g(E,"image-too-large",{blob:w,appearance:R}),c.push(m(!1));continue}if(f+p.byteLength>Ge){g(E,"vision-byte-budget-reached",{blob:w,appearance:R}),c.push(m(!1));continue}if(d.length>=Ke){g(E,"image-cap-reached",{blob:w,appearance:R}),c.push(m(!1));continue}i.set(w,y),f+=p.byteLength,d.push(y),g(E,"selected",{blob:w,appearance:R}),c.push(m(!0))}let u=[];return u.push(`${r.title} \xB7 ${r.site} \xB7 ${r.space.key}`),r.labels.length>0&&u.push(`labels: ${r.labels.join(", ")}`),r.content.body!==""&&u.push("",...r.content.body.split(`
|
|
8
|
-
`)),c.length>0&&u.push("","--- attachments ---",...c),{projection:u.join(`
|
|
9
|
-
`)+`
|
|
10
|
-
`,inventory:l,blobs:o,delivered:d,converter:{name:"confluence-convert",version:"1",policy:"v1"}}}}var ze=/^[A-Za-z0-9~][A-Za-z0-9._~-]*$/;function Z(t){if(!/^https?:\/\/.+/i.test(t))return null;let n;try{n=new URL(t)}catch{return null}let e=n.pathname.split("/").filter(Boolean),r=e.indexOf("wiki");if(r===-1||e[r+1]!=="spaces"||e[r+3]!=="pages")return null;let l=e[r+2],o=e[r+4];return l===void 0||o===void 0||!ze.test(l)||!/^\d+$/.test(o)?null:{site:n.hostname,spaceKey:l,pageId:o}}async function Xe(t,n,e,r,l){let o=Z(t);if(o===null)return(e.err??e.out)(`error: ${t}: unsupported remote URL \u2014 expected a Confluence page URL (https://<site>/wiki/spaces/<KEY>/pages/<id>/\u2026)`),{code:1};let d=l?.lis??{jiraInfo:V,jiraIssue:W,jiraAttachment:Y,jiraComments:G},f=l?.confluence??{confluenceDocument:he,confluenceAttachment:ye};try{let c={auth:await(l?.authEnv??(await import("./auth-3DLNMZC2.js")).resolveLisAuthEnv)(),env:process.env},u=await d.jiraInfo(c);if(!u.installed)return(e.err??e.out)(`error: ${t}: no Atlassian connection for this account \u2014 create one at ${v} and retry`),{code:1};if(u.capabilities.document===!1)return(e.err??e.out)(`error: ${t}: the connection has no Confluence access \u2014 reconnect with Confluence at ${v} and retry`),{code:1};let a=await f.confluenceDocument(o.pageId,c),s=o.site;if(a.url)try{s=new URL(a.url).hostname}catch{}let{bytes:y,warnings:L}=be(a,s),m=n??`page-${o.pageId}`;k(m);let g=X(r,m);if(g!==null&&g!==s)return(e.err??e.out)(`error: ${t}: source '${m}' was ingested from ${g}, but this read serves ${s} \u2014 retire it first (kane-cli context retire ${m}) or ingest under a different id with --as`),{code:1};let S=Object.fromEntries((a.attachments??[]).filter(p=>typeof p.download=="string"&&p.download.length>0).map(p=>[String(p.id),p.download])),h=await P({contextDir:r,bytes:y,media:ie,sourceId:m,label:t,confirmSameSource:e.isTTY?p=>e.confirm(`identical content already ingested as ${p} \u2014 treat as the same source?`):void 0,converters:{confluence:Ee({downloads:S,fetchAttachment:p=>f.confluenceAttachment(p.download,c)})}});e.out(U(e.isTTY,h,`${o.spaceKey}/${o.pageId}`));for(let p of L)e.out(`warning: ${p}`);for(let p of h.warnings??[])e.out(`warning: ${p}`);if(h.composite){let p=h.composite.delivered+h.composite.omitted;e.out(`${h.source_id}: confluence, ${p} attachments, ${h.composite.delivered} images delivered (${h.composite.omitted} omitted)`)}return{code:0,result:{status:h.status,source_id:h.source_id,source_cid:h.cid}}}catch(i){return i instanceof b?((e.err??e.out)(`error: ${t}: ${i.message}`),{code:1}):((e.err??e.out)(`error: ${t}: ${qe(i instanceof Error?i.message:String(i))}`),{code:1})}}function qe(t){let n=t.match(/too large — ([\d.]+ [KM]B), the limit for .+ is ([\d.]+ [KM]B) \[FILE_TOO_LARGE\]/);return n?`the page's content is too large to ingest (${n[1]}; the limit is ${n[2]}) \u2014 trim the page in Confluence and retry`:t.startsWith("PROJECTION_TOO_LARGE:")?"the page's text is too large to ingest \u2014 trim the page in Confluence and retry":t}var we={name:"confluence",hint:"Confluence page URLs (https://<site>/wiki/spaces/<KEY>/pages/<id>/\u2026)",match:t=>Z(t)!==null,ingest:Xe,sourceIdFor:t=>{let n=Z(t);return n?`page-${n.pageId}`:null}};var Ze=new Set(["invalid_url","target_disallowed","page_not_found","page_access_blocked","page_paywalled","unsupported_content_type","page_too_large","page_timeout","scrape_unavailable","scrape_rate_limited","internal_error","credit_denied"]);async function Ie(t,n){let e=n.env??process.env,r=n.fetchImpl??fetch,l=ce(e),o={"Content-Type":"application/json"},d=await n.authEnv(),f=d.TESTMUAI_BASIC_AUTH??e.TESTMUAI_BASIC_AUTH,i=d.TESTMUAI_API_KEY??e.TESTMUAI_API_KEY;f?o.Authorization=`Basic ${f}`:i&&(o.Authorization=`Bearer ${i}`);let c;try{c=await r(`${l}/assurance/web/scrape`,{method:"POST",headers:o,body:JSON.stringify({url:t}),signal:AbortSignal.timeout(n.timeoutMs??55e3)})}catch{return{ok:!1,kind:"transport_unreachable"}}if(c.status===401)return{ok:!1,kind:"auth_rejected"};let u;try{u=await c.json()}catch{return{ok:!1,kind:c.status===404?"route_missing":"malformed_response"}}if(c.ok){let s=u.page;return s===void 0||typeof s.markdown!="string"||s.markdown===""||typeof s.final_url!="string"||s.final_url===""||typeof s.projection?.kind!="string"||typeof s.projection?.version!="string"?{ok:!1,kind:"malformed_response"}:{ok:!0,page:s}}let a=u.code;return typeof a=="string"&&Ze.has(a)?{ok:!1,kind:a}:c.status===404?{ok:!1,kind:"route_missing"}:c.status===403?{ok:!1,kind:"auth_rejected"}:{ok:!1,kind:"malformed_response"}}var te="kane.source.web/1";function Ae(t,n,e){if(e==="")throw new Error("cannot build a web source from an empty page projection");if(n.kind===""||n.version==="")throw new Error("cannot build a stable identity without a server-reported projection kind/version");let r={schema:te,url:t,projection:{kind:n.kind,version:n.version},content:{markdown:e}};return{bytes:Buffer.from(JSON.stringify(r),"utf8"),envelope:r}}var Qe=new Set(["markdown"]);function Le(){return async t=>{let n;try{n=JSON.parse(t.toString("utf8"))}catch{throw new Error("this web source's stored envelope is not readable \u2014 re-ingest the page")}if(n.schema!==te)throw new Error(`unknown web envelope schema '${String(n.schema)}' \u2014 re-ingest the page with this CLI version`);if(!Qe.has(n.projection?.kind??""))throw new Error(`unknown web projection kind '${String(n.projection?.kind)}' \u2014 update kane-cli to read this source`);if(typeof n.content?.markdown!="string"||n.content.markdown==="")throw new Error("this web source's stored envelope carries no content \u2014 re-ingest the page");return{projection:n.content.markdown,inventory:[],blobs:new Map,delivered:[],converter:{name:"web-convert",version:"1",policy:"markdown-passthrough"}}}}import{createHash as et}from"crypto";function ve(t){return Q(t)!==null}function Q(t){if(!/^https?:\/\//i.test(t))return null;let n;try{n=new URL(t)}catch{return null}return n.hostname===""?null:(n.hash="",n.username="",n.password="",n.toString())}function ne(t){let n=Q(t);if(n===null)return null;let e=new URL(n),r=(e.hostname+e.pathname).toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,40).replace(/-+$/,""),l=et("sha256").update(n,"utf8").digest("hex").slice(0,8);return`${r||"page"}-${l}`}function tt(t,n){let e=x(t),r=e.heads.get(n);if(r==null)return null;let l=e.getNode(r)?.content?.blob;if(typeof l!="string")return null;let o=M(t,l);if(o===null)return null;try{let d=JSON.parse(o.toString("utf8"));return d.schema!=="kane.source.web/1"?null:typeof d.url=="string"&&d.url.length>0?d.url:null}catch{return null}}function re(t){switch(t){case"invalid_url":return"this is not a valid public HTTP or HTTPS page URL \u2014 check the address and try again";case"target_disallowed":return"that address cannot be fetched because it does not point to an allowed public web page";case"page_not_found":return"the page could not be found \u2014 check that the URL is correct and that the page still exists";case"page_access_blocked":return"the page refused automated access, so its contents could not be ingested \u2014 use a publicly accessible version of the page";case"page_paywalled":return"the page is behind a paywall or sign-in screen, so its full contents could not be ingested \u2014 use a publicly accessible copy";case"unsupported_content_type":return"the URL does not point to an HTML web page \u2014 download the document and ingest the supported file instead";case"page_too_large":return"the page contains too much text to ingest as a single source \u2014 use a narrower page or trim the content first";case"page_timeout":return"the page took too long to load \u2014 try again later";case"scrape_unavailable":case"scrape_rate_limited":case"internal_error":return"the page ingest service is temporarily unavailable \u2014 try again later";case"credit_denied":return"the page could not be ingested \u2014 your organization is out of credits";case"auth_rejected":return"your credentials were rejected \u2014 run `kane-cli login` and retry";case"route_missing":return"ingesting web pages is not available in your environment yet \u2014 nothing is wrong with the URL; try again later";case"transport_unreachable":return"the page ingest service could not be reached \u2014 check your connection and try again";case"malformed_response":return"the page ingest service returned a response that could not be read safely \u2014 try again later"}}function nt(t){let n=t.match(/too large — ([\d.]+ [KM]B), the limit for .+ is ([\d.]+ [KM]B) \[FILE_TOO_LARGE\]/);return n?`the page contains too much text to ingest as a single source (${n[1]}; the limit is ${n[2]}) \u2014 use a narrower page or trim the content first`:t.startsWith("PROJECTION_TOO_LARGE:")?"the page contains too much text to ingest as a single source \u2014 use a narrower page or trim the content first":t}async function rt(t,n,e,r,l){let o=Q(t);if(o===null)return(e.err??e.out)(`error: ${t}: ${re("invalid_url")}`),{code:1};let d=ne(t),f=n??d;if(f===null)return(e.err??e.out)(`error: ${t}: ${re("invalid_url")}`),{code:1};try{k(f)}catch(s){return(e.err??e.out)(`error: ${t}: ${s instanceof Error?s.message:String(s)}`),{code:1}}let i=tt(r,f);if(i!==null&&i!==o){if(!e.isTTY)return(e.err??e.out)(`error: ${t}: source '${f}' was ingested from ${i} \u2014 re-run on a TTY to adopt the new URL as its next version, or ingest under a different id with --as`),{code:1};if(!await e.confirm(`source '${f}' was ingested from ${i} \u2014 treat ${o} as its new version (replaces the current version; items built on it go stale)?`))return e.out(`skipped ${t} \u2014 ingest under a different id with --as to keep both pages`),{code:1}}let c=l?.web?.scrape??Ie,u=l?.authEnv??(async()=>(await import("./spawner-ANLF7OX3.js")).resolveAgentAuthEnv()),a=await c(o,{authEnv:u});if(!a.ok)return(e.err??e.out)(`error: ${t}: ${re(a.kind)}`),{code:1};try{let{bytes:s}=Ae(o,a.page.projection,a.page.markdown),y=await P({contextDir:r,bytes:s,media:ae,sourceId:f,label:o,confirmSameSource:e.isTTY?m=>e.confirm(`identical content already ingested as ${m} \u2014 treat as the same source?`):void 0,converters:{web:Le()}}),L=new URL(o).hostname+new URL(o).pathname;e.out(U(e.isTTY,y,L));for(let m of y.warnings??[])e.out(`warning: ${m}`);return e.isTTY&&a.page.title&&e.out(` title: ${a.page.title}`),{code:0,result:{status:y.status,source_id:y.source_id,source_cid:y.cid}}}catch(s){return(e.err??e.out)(`error: ${t}: ${nt(s instanceof Error?s.message:String(s))}`),{code:1}}}var Se={name:"web",hint:"any public web page URL (https://\u2026)",match:ve,ingest:rt,sourceIdFor:ne};function U(t,n,e){return t?n.status==="created"?`landed ${n.source_id} (${e}) \u2014 new source`:n.status==="versioned"?`landed ${n.source_id} (${e}) \u2014 new version; dependents go stale`:`${n.source_id} unchanged \u2014 already landed`:`${n.status} ${n.source_id} source ${n.cid} blob ${n.blob}`}var ot=[ge,we,Se];function _n(t){return/^https?:\/\/.+/i.test(t)}function En(t){return ot.find(n=>n.match(t))??null}export{U as a,ot as b,_n as c,En as d};
|
package/dist/chunk-WYST42WI.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{e as v,f as l}from"./chunk-2K2BX23I.js";import{a as f,c as m,e as p}from"./chunk-EYOCNMUM.js";var R=["desktop","emulator","simulator"];function k(e,n){return e.kind==="app_id"?!0:n==="emulator"?e.kind==="apk":e.kind==="zip"}function g(e,n,t){let s=l(e);return s?k(s,n)?null:n==="emulator"?`${t} cannot run on an emulator (needs an .apk, or an APP\u2026 id).`:`${t} cannot run on a simulator (needs a .zip of the .app bundle, or an APP\u2026 id).`:`${e}: ${v}`}function b(e){return R.includes(e)?e:null}function T(e){return`--target must be one of desktop, emulator, simulator (got "${e}")`}function h(e){let n=[];for(let[t,s]of[["--device",e.device],["--app",e.app]])s!==void 0&&n.push(`ignored ${t} ${s}: session target is desktop \u2014 set --target emulator|simulator to run on a device`);return n}function I(e){let{flags:n,saved:t}=e,s=[],r;if(n.target!==void 0){let i=b(n.target);if(!i)return{kind:"invalid",message:T(n.target)};r=i}else{let i=f(t?.tui_target,t?.default_target?.kind);if(i.kind==="choose-mobile")return{kind:"choose-mobile-kind"};r=i.kind==="unset"?"desktop":i.kind}if(r==="desktop")return s.push(...h(n)),{kind:"web",warnings:s};if(!e.host.supported)return{kind:"invalid",message:e.host.reason??"this machine cannot run mobile targets."};let a=[],o;n.device!==void 0?o={value:n.device,source:"flag"}:t?.default_target&&t.default_target.kind===r?o={value:t.default_target.id,source:"saved"}:a.push("device");let d;if(n.app!==void 0){let i=g(n.app,r,`--app ${n.app}`);if(i)return{kind:"invalid",message:i};d={value:n.app,source:"flag"}}else{let i=t?.default_app,c=i?l(i):null;c&&k(c,r)&&t?.default_target?.kind===r?d={value:i,source:"saved"}:a.push("app")}return{kind:"mobile",target:r,...o?{device:o}:{},...d?{app:d}:{},missing:a,warnings:s}}function P(e){let{flags:n,file:t}=e,s=[],r=t.target==="emulator"||t.target==="simulator"?t.target:void 0,a;if(n.target!==void 0){let i=b(n.target);if(!i)return{kind:"invalid",message:T(n.target)};a=i,r&&r!==a&&s.push(`--target ${a} overrides the file's \`target: ${r}\` \u2014 steps recorded on ${r==="emulator"?"an emulator":"a simulator"} may not replay here`)}else a=r??"desktop";if(a==="desktop")return s.push(...h(n)),{kind:"web",warnings:s};if(n.app!==void 0){let i=g(n.app,a,`--app ${n.app}`);if(i)return{kind:"invalid",message:i}}else if(t.app){let i=g(t.app,a,`the file's app: ${t.app}`);if(i)return{kind:"invalid",message:i}}let o=n.app??(t.app||void 0),d=n.device?.trim();return{kind:"mobile",target:a,platform:m(a)??"",...d?{device:d}:{},...o?{app:o}:{},...t.no_reset!==void 0?{noReset:t.no_reset}:{},warnings:s}}function _(e){return e.target==="desktop"?"Running on: Desktop \xB7 Chrome":`Running on: ${p(e.target)} \xB7 ${e.deviceLabel} \xB7 ${e.appLabel}`}var u={emulator:"</path/to/app.apk | APPid>",simulator:"</path/to/app.zip | APPid>"};function x(e,n){let t=p(e).toLowerCase();return n==="device"?[`session target is "${t}" but no device is set.`,` See devices: kane-cli devices list --target ${e}`,' Set one: kane-cli config set-device "<name>"',' Or per-run: --device "<name>"'].join(`
|
|
3
|
-
`):[`session target is "${t}" but no app is set.`,` Set one: kane-cli config set-app ${u[e]}`,` Or per-run: --app ${u[e]}`].join(`
|
|
4
|
-
`)}function A(e){return[`saved device "${e}" was not found on this machine.`," See devices: kane-cli devices list",' Set one: kane-cli config set-device "<name>"'].join(`
|
|
5
|
-
`)}function w(e,n){return[`saved app ${e} no longer exists on disk.`," The build may have been moved or cleaned. Set a new one:",` kane-cli config set-app ${u[n]}`].join(`
|
|
6
|
-
`)}var y=['session target is "mobile" from an older version \u2014 say which kind:'," kane-cli config set-target emulator|simulator"].join(`
|
|
7
|
-
`);export{k as a,I as b,P as c,_ as d,x as e,A as f,w as g,y as h};
|
package/dist/chunk-X2FM67OM.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{b as U}from"./chunk-DNNZ353O.js";import{a as G}from"./chunk-Q2F5QB2W.js";import{b as I,c as b}from"./chunk-NVGBE2DR.js";import{A as T}from"./chunk-TH47OOBV.js";import{a as L,c as F}from"./chunk-CUM23TLF.js";import{b as P,i as j}from"./chunk-DUAXZYAD.js";import{a as R,d as $,f as D}from"./chunk-WXHQYYD5.js";import{existsSync as ie,mkdirSync as oe,readFileSync as re,writeFileSync as se}from"fs";import{basename as S,extname as H,join as ae}from"path";var K=/^[A-Za-z0-9][A-Za-z0-9._-]*$/;function Z(e){return typeof e=="string"&&e!=="."&&e!==".."&&K.test(e)}function k(e){if(!Z(e))throw new Error(`unsafe logical_id: ${JSON.stringify(e)} \u2014 must match ${String(K)} (no path separators)`)}import{extname as q}from"path";var Q={kind:"jira",media_type:"application/x-kane-jira-envelope",extensions:[],cite:"verbatim",maxBytes:2e6},ee={kind:"confluence",media_type:"application/x-kane-confluence-envelope",extensions:[],cite:"verbatim",maxBytes:2e6},fe={kind:"web",media_type:"application/x-kane-web-envelope",extensions:[],cite:"verbatim",maxBytes:2e6},z=[{kind:"text",media_type:"text/plain",extensions:[".txt"],cite:"verbatim",maxBytes:2e6},{kind:"markdown",media_type:"text/markdown",extensions:[".md",".markdown"],cite:"verbatim",maxBytes:2e6},{kind:"image",media_type:"image/png",extensions:[".png"],cite:"anchor-only",maxBytes:5e6},{kind:"image",media_type:"image/jpeg",extensions:[".jpg",".jpeg"],cite:"anchor-only",maxBytes:5e6},{kind:"image",media_type:"image/webp",extensions:[".webp"],cite:"anchor-only",maxBytes:5e6},{kind:"text",media_type:"application/json",extensions:[".json"],cite:"verbatim",maxBytes:2e6},{kind:"text",media_type:"application/yaml",extensions:[".yaml",".yml"],cite:"verbatim",maxBytes:2e6},{kind:"text",media_type:"application/toml",extensions:[".toml"],cite:"verbatim",maxBytes:2e6},{kind:"text",media_type:"application/xml",extensions:[".xml"],cite:"verbatim",maxBytes:2e6},{kind:"text",media_type:"text/plain",extensions:[".log"],cite:"verbatim",maxBytes:2e6},{kind:"pdf",media_type:"application/pdf",extensions:[".pdf"],cite:"verbatim",maxBytes:25e6,sniff:e=>e.subarray(0,5).toString("latin1")==="%PDF-"},{kind:"docx",media_type:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",extensions:[".docx"],cite:"verbatim",maxBytes:25e6,sniff:e=>e.length>=4&&e[0]===80&&e[1]===75&&e[2]===3&&e[3]===4,sniffFail:e=>e.length>=8&&e.subarray(0,8).equals(te)?"DOCX_ENCRYPTED_OR_LEGACY: password-protected Office file (or a legacy .doc renamed .docx) \u2014 remove the password / save as .docx and re-ingest":void 0},Q,ee],te=Buffer.from([208,207,17,224,161,177,26,225]),M={pdf:"pdf",docx:"docx",jira:"jira",confluence:"confluence",web:"web"},ue=new Set(Object.keys(M));function J(e){let n=q(e).toLowerCase(),t=z.find(i=>i.extensions.includes(n));return t?{ok:!0,media:t}:{ok:!1,code:"UNSUPPORTED_MEDIA",allowlist:z.flatMap(i=>i.extensions)}}function v(e){return e>=1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:`${Math.max(1,Math.round(e/1024))} KB`}function de(e,n,t){return G({source_id:e,source_cid:"sha256:".padEnd(71,"0"),doc_kind:n,numbered_text:U(t)})}var Y=2e3;function ce(e){let t=S(e,H(e)).toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/^[^a-z0-9]+/,"");return k(t),t}function Me(e){let n=/^(.*?)[-_.]?v?\d+$/.exec(e);if(!n)return null;let t=(n[1]??"").replace(/[-_.]+$/,"");return t.length>0&&t!==e?t:null}function W(e){let n=ae(e,"meta.json");ie(n)||(oe(e,{recursive:!0}),se(n,JSON.stringify({schema:R,canonicalizer:"v1"},null,2)+`
|
|
3
|
-
`))}async function Se(e){let{contextDir:n,filePath:t,asId:i,confirmSameSource:_,converters:h}=e;W(n);let o=re(t),s=J(t);if(!s.ok)throw new Error(`${S(t)} is a file type kane can't ingest (${H(t)||"no extension"}) \u2014 supported: ${s.allowlist.join(" ")} [UNSUPPORTED_MEDIA]`);if(o.byteLength>s.media.maxBytes)throw new Error(`${S(t)} is too large \u2014 ${v(o.byteLength)}, the limit for ${s.media.media_type} is ${v(s.media.maxBytes)} [FILE_TOO_LARGE]`);if(s.media.sniff&&!s.media.sniff(o)){let m=s.media.sniffFail?.(o);throw new Error(m??`MEDIA_SNIFF_MISMATCH: ${t} does not look like ${s.media.media_type}`)}let l;return i!==void 0?(k(i),l=i):l=ce(t),le({contextDir:n,bytes:o,media:s.media,sourceId:l,label:t,confirmSameSource:_,converters:h})}async function le(e){let{contextDir:n,bytes:t,media:i,confirmSameSource:_,converters:h}=e,o=e.sourceId,s=e.label??o;if(W(n),t.byteLength>i.maxBytes)throw new Error(`the content is too large \u2014 ${v(t.byteLength)}, the limit for ${i.media_type} is ${v(i.maxBytes)} [FILE_TOO_LARGE]`);let l=[],m=M[i.kind];if(i.cite==="verbatim"&&!m){try{new TextDecoder("utf-8",{fatal:!0}).decode(t)}catch{throw new Error(`ENCODING_UNSUPPORTED: ${s} is not valid UTF-8 \u2014 re-save it as UTF-8 and re-ingest`)}t.toString("utf8").split(`
|
|
4
|
-
`).some(f=>f.length>Y)&&l.push(`long line detected (> ${Y} chars) \u2014 anchors lose granularity; consider pretty-printing before ingest`)}let p=I(t),y=new Map,c=null,C=!1;for(let f=0;;f++){let x=T(n),u=x.heads.get(o),X=u!=null?x.getNode(u)?.content:void 0;if(u!=null&&X?.blob===p)return{status:"unchanged",source_id:o,cid:u,blob:p};if(u==null){for(let[r,g]of x.heads.entries())if(!(r===o||g==null)&&x.getNode(g)?.content.blob===p){let a;if(y.has(r)?a=y.get(r):f===0&&_?(a=await _(r),y.set(r,a)):(a=!1,y.set(r,a),f>0&&l.push(`same bytes already ingested as '${r}' \u2014 minted under '${o}' anyway (the twin appeared mid-commit; not prompted)`)),a)return{status:"unchanged",source_id:r,cid:g,blob:p};break}}if(c===null){let r={},g,a=null,A=null;if(m){let O=h?.[m];if(!O)throw new Error(`${m.toUpperCase()}_CONVERTER_MISSING: ${m} ingestion requires the converter \u2014 the command layer wires it`);let d=await O(t);a=Buffer.from(d.projection,"utf8");let N=de(o,i.kind,a);if(N>4e5)throw new Error(`PROJECTION_TOO_LARGE: serialized source payload ${N} bytes > ${4e5} \u2014 split the document and re-ingest`);r={text_blob:I(a),...d.inventory.length>0?{images:d.inventory}:{},converter:d.converter},A=d.blobs,g={kind:i.kind,...d.pages!==void 0?{pages:d.pages}:{},delivered:d.delivered.length,omitted:d.inventory.length-d.delivered.length}}c={derived:r,composite:g,projBytes:a,derivedBlobs:A}}if(!C){if(b(n,t),c.projBytes!==null&&b(n,c.projBytes),c.derivedBlobs!==null)for(let[,r]of c.derivedBlobs)b(n,r);C=!0}let w=F(o,p),E=D("source",w);if(E.length>0)throw new Error(`source node fails ${E[0].code}: ${E[0].detail}`);let B=L("source",w);try{j(n,{ts:new Date().toISOString(),proposal_id:null,nodes:[{cid:B,label:$.SOURCE,content:w}],edges:[],review:[],supersessions:[],media:{[o]:{format:i.kind,media_type:i.media_type,anchors_supported:m?["L-L","img#ref"]:i.cite==="verbatim"?["L-L"]:[],...c.derived}},...e.eventIds&&e.eventIds.length>0?{event_ids:e.eventIds}:{},source_head_moves:{[o]:B}},{expectPrev:x.latestHash})}catch(r){if(r instanceof P&&f<3)continue;throw r}return{status:u!=null?"versioned":"created",source_id:o,cid:B,blob:p,...l.length?{warnings:l}:{},...c.composite?{composite:c.composite}:{}}}}export{k as a,Q as b,ee as c,fe as d,ue as e,J as f,de as g,ce as h,Me as i,Se as j,le as k};
|
package/dist/chunk-ZSXDZI56.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{b as p,c as d}from"./chunk-VZ7KXRXB.js";import{b as f}from"./chunk-IAHKTEET.js";var m=new Set(["delta","state-transition"]),b=/^capture baseline:/i;function g(e){return typeof e=="string"?e:e.text}function h(e){return typeof e=="object"&&e.baseline===!0||b.test(g(e).trim())}function v(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&"derived"in e}function S(e,r){if(e.check_prose)return e.check_prose;let n=r.find(i=>i.ref===e.check.verified_against),t=n?.text?` \u2014 the stated promise: ${n.text}`:"",o=String(e.check.operand??e.check.within??e.check.metric??"");return e.check.kind==="forbidden-presence"?`Confirm '${o}' does NOT appear (forbidden-presence)${t}`:`Confirm ${e.check.kind} check: ${o} (${e.check.operator})${t}`}var y=/^## Step \d+ — assert\s*$/;function B(e,r){if(r.length===0)return e;let n=e.split(`
|
|
3
|
-
`);for(let t=n.length-1;t>=0;t--){if(/^## Step \d+ — assert @verifies /.test(n[t]))return e;if(y.test(n[t]))return n[t]=`${n[t].trimEnd()} @verifies ${r.join(", ")}`,n.join(`
|
|
4
|
-
`)}return e}function C(e,r){return r.size===0?e:e.split(`
|
|
5
|
-
`).map(n=>{let t=n.match(/^@import\s+(\S+)\s*$/);if(t&&r.has(t[1]))return`@import ${r.get(t[1])}`;let o=n.match(/^## Import: (\S+)\s*$/);return o&&r.has(o[1])?`## Import: ${r.get(o[1])}`:n}).join(`
|
|
6
|
-
`)}function D(e,r,n){if(m.has(e.check.kind)&&!e.steps.some(h))throw new Error(`emitTestMd: check kind '${e.check.kind}' needs a baseline-capture step before the action (a step starting 'capture baseline: <metric>' or { baseline: true }) \u2014 the validator should have caught this`);let t=[`# ${e.title}`,""];r.intent&&t.push(`> ${r.intent}`,"");for(let u of e.reuses??[])t.push(`## Import: ${u}`,"",`@import ${u}`,"");let o=[],i=0;for(let u of e.steps){i++;let a=g(u).trim();t.push(`## Step ${i}`,"",a,""),o.push({step:i,objective:a,...h(u)?{baseline:!0}:{}})}i++;let s=S(e,n),c=e.check.expected_mode??(v(e.check.operand)?"runtime-derived":"inferred");t.push(`## Step ${i} \u2014 assert`,"",s,""),o.push({step:i,objective:s,check:{kind:e.check.kind,operator:e.check.operator,...e.check.operand!==void 0?{operand:e.check.operand}:{},...m.has(e.check.kind)?{baseline:e.check.baseline??null}:{},...e.check.within!==void 0?{within:e.check.within}:{},...e.check.metric!==void 0?{metric:e.check.metric}:{},...e.check.threshold!==void 0?{threshold:e.check.threshold}:{},...e.check.unit!==void 0?{unit:e.check.unit}:{},verified_against:e.check.verified_against,expected_mode:c,review_required:e.check.review_required??c==="runtime-derived"}});let l=d({title:e.title,...r.title?{scenario:r.title}:{},objectives:o},{sortKeys:!0,lineWidth:-1});return{test_md:t.join(`
|
|
7
|
-
`),objectives_yaml:l}}function G(e){let n=e.replace(/\r\n/g,`
|
|
8
|
-
`).split(`
|
|
9
|
-
`).map(i=>i.replace(/[ \t]+$/,""));if(n[0]?.trim()==="---"){let i=n.slice(1).findIndex(s=>s.trim()==="---");if(i>=0){let s=p(n.slice(1,i+1).join(`
|
|
10
|
-
`))??{},c="assurance"in s;delete s.assurance,Object.keys(s).length===0&&c?n=n.slice(i+2):n=["---",...d(s,{sortKeys:!0,lineWidth:-1}).trimEnd().split(`
|
|
11
|
-
`),"---",...n.slice(i+2)]}}let t=[];for(let i of n)i===""&&t[t.length-1]===""||t.push(i);for(;t[0]==="";)t.shift();for(;t[t.length-1]==="";)t.pop();let o=t.join(`
|
|
12
|
-
`)+`
|
|
13
|
-
`;return"sha256:"+f(Buffer.from("assurance.testdef\0"+o,"utf8"))}import{existsSync as $,readFileSync as E}from"fs";import{dirname as w,isAbsolute as I,resolve as j}from"path";var k=/^@import\s+(\S+)\s*$/;function _(e){let r=new Set;for(let n=0;n<e.length;n++)if(k.test(e[n].trim()))for(let t=n-1;t>=0;t--){let o=e[t].trim();if(o!==""){o==="```"&&r.add(n);break}}return r}function R(e,r,n=new Set,t=0){if(t>10)return e;let o=e.split(`
|
|
14
|
-
`),i=_(o);return o.map((s,c)=>{let l=k.exec(s.trim());if(!l||i.has(c))return s;let u=r(l[1]);if(!u||n.has(u.cycleKey))return s;let a=new Set(n);return a.add(u.cycleKey),R(u.body.trimEnd(),u.next,a,t+1)}).join(`
|
|
15
|
-
`)}function A(e){return r=>{let n=e.resolve(r);if(!n)return null;let t=e.getNode(n.tip)?.content.test_md_blob;return t?{body:t,cycleKey:n.tip,next:A(e)}:null}}function K(e,r){return n=>{let t=I(n)?n:j(e,n);if(!$(t))return null;let o=E(t,"utf8"),i=T(o);return!i||!r.resolve(i)?null:{body:M(o),cycleKey:t,next:K(w(t),r)}}}function L(e){let r=x(e);if(!r)return null;let n=/^assurance:\s*$[\s\S]*?^\s+id:\s*(\S+)\s*$/m.exec(r.text);if(!n)return null;let t=/^assurance:\s*$[\s\S]*?^\s+base:\s*(\S+)\s*$/m.exec(r.text);return{id:n[1],...t?{base:t[1]}:{}}}function T(e){return L(e)?.id??null}function x(e){let r=e.split(`
|
|
16
|
-
`);if(r[0]?.trim()!=="---")return null;for(let n=1;n<r.length;n++)if(r[n].trim()==="---")return{text:r.slice(1,n).join(`
|
|
17
|
-
`),endLine:n};return null}function M(e){let r=x(e);if(!r)return e;let n=e.split(`
|
|
18
|
-
`),t=n.slice(1,r.endLine),o=[],i=!1;for(let c of t){if(/^assurance:\s*$/.test(c)||/^assurance:\s*\{/.test(c)){i=!0;continue}i&&/^\s+\S/.test(c)||(i=!1,o.push(c))}let s=n.slice(r.endLine+1).join(`
|
|
19
|
-
`);return o.every(c=>c.trim()==="")?s:["---",...o,"---",s].join(`
|
|
20
|
-
`)}export{v as a,B as b,C as c,D as d,G as e,k as f,_ as g,R as h,A as i,K as j,L as k,M as l};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{e as b,f as c,g as d,h as e,i as f,j as g,k as h,l as i,m as j,n as k,o as l,p as m,q as n,r as o,s as p,t as q,u as r}from"./chunk-TH47OOBV.js";import"./chunk-VAYBKR76.js";import"./chunk-CUM23TLF.js";import{h as a}from"./chunk-DUAXZYAD.js";import"./chunk-DBIBROYW.js";import"./chunk-WXHQYYD5.js";import"./chunk-IAHKTEET.js";import"./chunk-UD7KKHPW.js";import"./chunk-UR6MHSHU.js";export{b as SLUG_RE,c as checkAcyclic,d as checkCardinality,e as citesOf,q as commitDeferGap,o as commitNames,n as commitPairMerge,l as commitProposal,p as commitRetire,m as commitReviewFacts,f as criteriaShape,i as mintEventId,j as nextEventIds,a as recordsSince,r as resolveDeferGaps,k as resolveLivingTip,g as validateCriterionOps,h as validateProposal};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{b as O}from"./chunk-DYW5C6II.js";import{a as g,b as S,d as G}from"./chunk-OS4VSIHT.js";import"./chunk-5DT7PIGB.js";import{e as w,f as $}from"./chunk-5GUD3CIH.js";import{d as x}from"./chunk-XWKUZJCP.js";import{e as k}from"./chunk-EHN5HTUD.js";import"./chunk-CH273NAE.js";import{b}from"./chunk-VZ7KXRXB.js";import{A as R}from"./chunk-TH47OOBV.js";import"./chunk-VAYBKR76.js";import"./chunk-CUM23TLF.js";import"./chunk-DUAXZYAD.js";import"./chunk-DBIBROYW.js";import"./chunk-WXHQYYD5.js";import"./chunk-IAHKTEET.js";import"./chunk-UD7KKHPW.js";import"./chunk-UR6MHSHU.js";import{basename as h}from"path";import{statSync as A}from"fs";function C(t,e){if(!t)return 1;let o=t.resolve(e);return!o||o.superseded?1:t.getNode(o.tip)?.content.risk==="high"?3:1}function D(t,e){return t.usecases.map(o=>{let s=o.acceptance_criteria??[],a=s.filter(n=>(n.covered_by??[]).length>0),l=s.filter(n=>n.execution==="passed"),i=s.filter(n=>n.execution==="failed"),u=s.filter(n=>n.execution==="blocked"),d=0,m=0;for(let n of s){let f=C(e,n.id);d+=f,n.execution==="passed"&&(m+=f)}let r=d===0?0:Math.round(100*m/d),p=a.length===0?"uncovered":s.length===l.length?"covered":u.length>0&&i.length===0?"blocked":"partial";return{id:o.id,title:o.title,status:p,pct:r,acs:{total:s.length,covered:a.length,passed:l.length,failed:i.length,blocked:u.length},stale:s.filter(n=>n.fresh==="stale").map(n=>n.id)}})}async function P(t){let e=await w(t);return e.length===0?null:e.map(o=>({p:o,m:A(o).mtimeMs})).sort((o,s)=>s.m-o.m)[0].p}var N={covered:"\u2714",partial:"\u25D0",uncovered:"\u2716",blocked:"\u23F8"};function _(t){let e=Math.round(t/10);return"\u2588".repeat(e)+"\u2591".repeat(10-e)}async function I(t,e=G(),o=process.cwd()){if(t.mode!==void 0&&t.mode!=="agent"&&t.mode!=="ci"&&t.mode!=="interactive")return g(e,`--mode must be interactive | agent | ci, got '${t.mode}'`),2;if(t.mode==="agent"||t.mode==="ci"){let{makeHeadlessIO:r,agentRefusal:p}=await import("./headless-io-66RG5NN5.js"),n=r("ndjson","cover",{stdout:c=>e.out(c.replace(/\n$/,"")),stderr:c=>(e.err??e.out)(c.replace(/\n$/,""))}),f=[],v=[],j={out:c=>f.push(c),err:c=>v.push(c),confirm:async()=>!1,isTTY:!1};if(await I({...t,json:!0,mode:void 0},j,o)!==0)return p(n,v.join("; ")||"cover refused");let y=JSON.parse(f.join(`
|
|
3
|
-
`));return n.event({type:"coverage",...y}),n.done(0,void 0,M(y.completeness??[]))}let s=S(o,e);if(!s)return 2;let a=t.from?await $(t.from,o):await P(o);if(!a)return g(e,t.from?`no evidence pack at '${t.from}'`:"no evidence pack in .testmuai/evidence \u2014 run a test first, or pass --from <pack>"),2;let l=await k(a,"coverage/usecases.yaml");if(l==null)return g(e,`${h(a)} carries no coverage/usecases.yaml \u2014 the pack predates coverage or its project had no .context at seal time`),2;let i=b(l);if(!i||!Array.isArray(i.usecases))return g(e,`${h(a)}: coverage/usecases.yaml is not a usecases document`),2;let u=R(s),d=D(i,u),m=await x(u,"design");if(t.json)return e.out(JSON.stringify({pack:a,depth:d,completeness:m},null,2)),0;e.out(`coverage \u2014 ${h(a)}`),e.out(""),e.out("depth (proven by the pack):");for(let r of d){let p=r.stale.length?` \xB7 ${r.stale.length} stale`:"";e.out(` ${N[r.status]} ${_(r.pct)} ${String(r.pct).padStart(3)}% ${r.id} \u2014 ${r.status} (${r.acs.passed}/${r.acs.total} ACs proven${r.acs.failed?`, ${r.acs.failed} failed`:""}${r.acs.blocked?`, ${r.acs.blocked} blocked`:""})${p}`)}e.out(""),e.out("completeness (live graph):"),m.length===0&&e.out(" no design gaps \u2014 every AC verified, every use-case scenarioed");for(let r of m)e.out(` [${r.risk}] ${r.tag} ${r.ref} \u2014 ${r.why}`),e.out(` \u2192 ${r.ready_command}`);return 0}function M(t){return t.filter(e=>e.ready_command.startsWith("kane-cli ")&&O(e.ready_command)).slice(0,4).map(e=>({cmd:e.ready_command,why:e.why}))}export{I as coverCommand,M as coverNext,D as depthRows};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a,b,c}from"./chunk-3Q6WAK6P.js";import"./chunk-AFPHLUQ5.js";import"./chunk-BB2W35TW.js";import"./chunk-DNNZ353O.js";import"./chunk-NVGBE2DR.js";import"./chunk-TH47OOBV.js";import"./chunk-VAYBKR76.js";import"./chunk-CUM23TLF.js";import"./chunk-DUAXZYAD.js";import"./chunk-DBIBROYW.js";import"./chunk-WXHQYYD5.js";import"./chunk-IAHKTEET.js";import"./chunk-UD7KKHPW.js";import"./chunk-UR6MHSHU.js";export{a as captureForceScope,b as commitDesign,c as designPhaseLadder};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a,b,c,d}from"./chunk-VT2XNEOD.js";import"./chunk-2UIHS2FH.js";import"./chunk-YKTYVJBN.js";import"./chunk-X2FM67OM.js";import"./chunk-DNNZ353O.js";import"./chunk-Q2F5QB2W.js";import"./chunk-N2P4MI32.js";import"./chunk-NVGBE2DR.js";import"./chunk-TH47OOBV.js";import"./chunk-VAYBKR76.js";import"./chunk-CUM23TLF.js";import"./chunk-DUAXZYAD.js";import"./chunk-DBIBROYW.js";import"./chunk-WXHQYYD5.js";import"./chunk-IAHKTEET.js";import"./chunk-UD7KKHPW.js";import"./chunk-CCUGKBIH.js";import"./chunk-UR6MHSHU.js";export{b as REMOTE_PROVIDERS,d as findProvider,a as landingReceipt,c as looksLikeUrl};
|
package/dist/doctor-VWGEQYBB.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a,b,c,d}from"./chunk-35EUIBYJ.js";import"./chunk-BG66IAO6.js";import"./chunk-MMBBQ4OZ.js";import"./chunk-Z2T7E5HM.js";import"./chunk-MSGW4JDG.js";import"./chunk-TZXXJWHA.js";import"./chunk-4JOD47QI.js";import"./chunk-RZ4F3BHX.js";import"./chunk-CCUGKBIH.js";import"./chunk-UR6MHSHU.js";export{d as doctorExitCode,c as doctorPreflightBlocked,b as renderDoctorText,a as runDoctor};
|
package/dist/dossier-KTLTGT2X.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as u}from"./chunk-CLGC7VEO.js";import"./chunk-TH47OOBV.js";import"./chunk-VAYBKR76.js";import"./chunk-CUM23TLF.js";import"./chunk-DUAXZYAD.js";import"./chunk-DBIBROYW.js";import"./chunk-WXHQYYD5.js";import"./chunk-IAHKTEET.js";import"./chunk-UD7KKHPW.js";import"./chunk-UR6MHSHU.js";var q=i=>`cite ${i.source_id??"?"} ${i.anchor??""}${i.quote?` \u2014 "${i.quote}"`:""}`;function I(i,_){let l=i.resolve(_);if(!l)return null;let c=l.tip,y=i.nodeLabel.get(c);if(!y)return null;let h=i.getNode(c);if(!h)return null;let s=h.content,f=i.displayNameOf(c)??_,d=[],o=(e,t,n=!1)=>{d.push({text:`${e.padEnd(12)} ${t}`,dim:n})},L=i.trust.get(c)??"derived";o("status",`${L}${i.superseded.has(c)?" \xB7 superseded":""}`,!0);let k=typeof s.risk=="string"?s.risk:null;k&&o("risk",k);for(let[e,t]of[["title",null],["description","description"],["value","value"],["summary","summary"],["statement","statement"],["text","text"],["intent","intent"],["case_type","case type"],["technique_notes","technique"],["kind","kind"],["change_note","change"]]){if(!t)continue;let n=s[e];typeof n=="string"&&n&&o(t,n)}let p=[];{let e=l.cid,t=new Set;for(;!t.has(e);){t.add(e),p.push(e);let n=i.superseded.get(e);if(typeof n!="string")break;e=n}}let g=p.flatMap(e=>i.edgesInto(e)).filter(e=>e.type==="DERIVES"),x=e=>{if(!e.source_cid||!e.anchor)return;let t=/^L(\d+)-L(\d+)$/.exec(e.anchor);if(!t)return;let n=i.getNode(e.source_cid)?.content?.text_blob;if(typeof n!="string")return;let r=n.split(`
|
|
3
|
-
`).slice(Number(t[1])-1,Number(t[2])).join(" ").trim();return r?r.length>120?`${r.slice(0,119)}\u2026`:r:void 0},m=new Map,b=new Set;for(let e of g){let t=e.props;if(!t.claim)continue;let n=`${t.claim}|${t.source_id??"?"}|${t.source_cid??"?"}|${t.anchor??"?"}`;if(b.has(n))continue;b.add(n);let r=m.get(t.claim)??[];r.push({source_id:t.source_id,anchor:t.anchor,quote:x(t)}),m.set(t.claim,r)}let D=Array.isArray(s.criteria)?s.criteria:[];for(let[e,t]of D.entries()){o(e===0?"criteria":"",`${e+1}. ${t}`);for(let n of m.get(t)??[])d.push({text:` ${q(n)}`,dim:!0})}let v=g.find(e=>!e.props.claim);if(v){let e=v.props;d.push({text:` ${q({...e,quote:x(e)})}`,dim:!0})}let a=s.check;a?.kind&&o("check",`${a.kind}${a.verified_against?` vs ${u(String(a.verified_against))}`:""}`);let $=s.expected_answer;$?.operator&&o("expects",`${$.operator} \xB7 ${String($.operand??"")}`);let S=new Set,w=!0;for(let e of g){let t=e.props,n=`${t.source_id??"?"}@${t.source_cid??e.src}`;S.has(n)||(S.add(n),o(w?"provenance":"",`${t.source_id??"?"} @ ${String(t.source_cid??e.src).slice(7,15)}`,!0),w=!1)}let N=p.flatMap(e=>i.edgesFrom(e)).filter(e=>e.type==="depends_on");for(let[e,t]of N.entries()){let n=String(i.getNode(i.tipOf(t.dst))?.content?.title??""),r=i.displayNameOf(t.dst);o(e===0?"depends on":"",`${r?u(r):t.dst.slice(0,12)}${n?` ${n}`:""}`)}return{id:u(f),rawId:f,title:String(s.title??s.text??s.statement??f),label:y,lines:d}}export{I as buildDossier};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{A as L,C as M,D as N,E as O,F as P,G as Q,K as R,L as S,M as T,N as U,O as _,Q as $,R as aa,S as ba,T as ca,U as da,V as ea,W as fa,X as ga,Y as ha,Z as ia,a as c,b as d,c as e,d as f,e as g,f as h,g as i,h as j,i as t,j as u,k as v,l as w,m as x,n as y,o as z,p as A,q as B,r as C,s as D,t as E,u as F,v as G,w as H,x as I,y as J,z as K}from"./chunk-3AJ3QSF5.js";import"./chunk-5DBK6QNS.js";import{a as V,b as W,c as X,d as Y,e as Z}from"./chunk-TJZMYU2W.js";import{a as n,b as o,c as p,e as q,f as r,g as s}from"./chunk-5GUD3CIH.js";import"./chunk-XWKUZJCP.js";import"./chunk-ZSXDZI56.js";import{a as k,b as l,c as m}from"./chunk-EHN5HTUD.js";import"./chunk-NVGBE2DR.js";import"./chunk-CH273NAE.js";import"./chunk-VZ7KXRXB.js";import{a,f as b}from"./chunk-P7YZ3PU3.js";import"./chunk-TH47OOBV.js";import"./chunk-VAYBKR76.js";import"./chunk-CUM23TLF.js";import"./chunk-DUAXZYAD.js";import"./chunk-DBIBROYW.js";import"./chunk-WXHQYYD5.js";import"./chunk-IAHKTEET.js";import"./chunk-UD7KKHPW.js";import"./chunk-KX2GOJ4C.js";import"./chunk-MMBBQ4OZ.js";import"./chunk-Z2T7E5HM.js";import"./chunk-MSGW4JDG.js";import"./chunk-4JOD47QI.js";import"./chunk-WLOGO44E.js";import"./chunk-RZ4F3BHX.js";import"./chunk-CCUGKBIH.js";import"./chunk-UR6MHSHU.js";export{P as EvidenceSession,C as appendExecutionPointer,M as assembleExecutionEnv,b as buildEnvironment,j as buildEvidenceRunConfig,i as buildExternalId,z as buildLogsMetaYaml,y as buildResultYaml,t as buildRunYaml,O as createCdpBrowserCapture,u as createRunningPack,v as createRunningPackRoot,H as declareLogsFromDir,J as diagnostics,x as discardPack,ba as ensureAuteurExecution,N as fetchCdpBrowserString,L as finalizeEvidencePack,U as finalizeInlineEvidence,K as finalizeMemberTestLogs,da as flattenAuteurLeafIds,ca as flattenAuteurLeaves,T as inlineEvidenceBlock,q as listPacks,p as newExecutionId,a as normalizeOs,S as noteInlineSpawn,$ as offerEvidenceView,o as packPath,I as packTestLogsDir,V as parseRange,D as readExecutionPointers,ia as readPackLeafIds,ha as readPackLeaves,s as recoverStore,fa as remapReplayActionIds,r as resolvePack,ga as resolveReplayResultSteps,F as rollupTestStatus,aa as runEvidenceMerge,_ as runEvidenceServe,E as runEvidenceValidate,Q as runStartupRecovery,l as sealPack,w as sealPackById,Z as serveHint,f as shortHash,e as slugify,W as startEvidenceLocalServer,R as startInlineEvidence,n as storeDir,m as sweepStore,ea as synthesizeSkippedTail,h as testIdForInline,g as testIdForTestmd,k as validatePack,c as verdictFromResultCode,X as viewerBaseFor,Y as viewerUrlFor,d as worstOf,G as worstResultCode,B as writeLogsMeta,A as writeResult};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a,b,c,d,e,f,g}from"./chunk-DCUT3GJA.js";import"./chunk-OS4VSIHT.js";import"./chunk-TRJUD3XJ.js";import"./chunk-JZ26R6UL.js";import"./chunk-UJZZDPDY.js";import"./chunk-JFAFKHDX.js";import"./chunk-DNNZ353O.js";import"./chunk-5DT7PIGB.js";import"./chunk-NVGBE2DR.js";import"./chunk-CH273NAE.js";import"./chunk-TH47OOBV.js";import"./chunk-VAYBKR76.js";import"./chunk-CUM23TLF.js";import"./chunk-DUAXZYAD.js";import"./chunk-DBIBROYW.js";import"./chunk-WXHQYYD5.js";import"./chunk-IAHKTEET.js";import"./chunk-UD7KKHPW.js";import"./chunk-UR6MHSHU.js";export{b as designStateOf,g as evolveCommand,c as evolveOneUc,f as liveRunDesignForUc,a as resolveParentUc,e as runEvolveCommand,d as staleTargets};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as M,b as se,d as re}from"./chunk-OS4VSIHT.js";import{a as te,b as ne}from"./chunk-V444REBC.js";import"./chunk-5DT7PIGB.js";import{a as H,b as q,c as Q,d as X,e as Z,f as ee}from"./chunk-5DBK6QNS.js";import{f as Y}from"./chunk-5GUD3CIH.js";import{a as O,b as F,c as G,d as z}from"./chunk-XWKUZJCP.js";import"./chunk-ZSXDZI56.js";import"./chunk-EHN5HTUD.js";import"./chunk-CH273NAE.js";import"./chunk-VZ7KXRXB.js";import{A as V}from"./chunk-TH47OOBV.js";import"./chunk-VAYBKR76.js";import"./chunk-CUM23TLF.js";import"./chunk-DUAXZYAD.js";import"./chunk-DBIBROYW.js";import{d as E,e as U}from"./chunk-WXHQYYD5.js";import"./chunk-IAHKTEET.js";import"./chunk-UD7KKHPW.js";import"./chunk-UR6MHSHU.js";function ge(e,t){return e.length===0?"not_run":Q(e,t).verified?"proven":q(e,t).some(r=>r.verdict==="failed")?"failing":"blocked"}function oe(e,t){let s=null;for(let{cid:g}of e.byLabel(E.TEST))for(let o of e.execHistory(g))(!s||String(o.started_at)>s.started_at)&&(s={execution_id:String(o.execution_id),started_at:String(o.started_at)});if(!s)return null;let r=H[t],a=ee(e),l=X(a).aspects[t],x={},d={},m=0,h=0,T=0;for(let g of a.usecases){let o=[];for(let b of g.acceptance_criteria){let f=b.executions??[],p=ge(f,r);o.push(p),p==="failing"?m++:p==="blocked"?h++:p==="not_run"&&T++;let y=[],c;if(p==="failing"){let n=null;for(let u of b.covered_by){let v=e.execHistory(u).map(S=>({verdict:String(S.per_ac?.find(R=>R.ac_ref===b.id)?.verdict??S.verdict),oracle_mode:String(S.oracle_mode),ts:String(S.started_at),execution_id:String(S.execution_id)})).filter(S=>r.counted_verdicts.includes(S.verdict)&&r.accepted_oracle_modes.includes(S.oracle_mode)),$=v[v.length-1];$?.verdict==="failed"&&(y.push(u),(!n||$.ts>n.ts)&&(n={ts:$.ts,execution_id:$.execution_id}))}c=n?.execution_id}else p==="blocked"&&(c=f[f.length-1]?.execution_id);x[b.id]={state:p,viaTests:y,...c?{executionId:c}:{}}}let i=o.some(b=>b!=="not_run"),_=l.usecases[g.id],k=i?_.status==="covered"?"proven":_.status==="partial"?"partial":o.includes("failing")?"failing":o.includes("blocked")?"blocked":"not_run":"not_run";d[g.id]={pct:_.pct,status:k}}return{aspect:t,pct:l.summary.coverage_pct,acs_proven:l.summary.acs_verified,failing:m,blocked:h,not_run:T,latest_run:s,perUc:d,perAc:x,config:{...r,source:"graph_execution_facts",denominator:"current_live_acs"}}}var me=["failing","blocked","needs-refresh","needs-tests","needs-scenarios","happy-only","possible-duplicate","not-yet-run"],he={failing:"failing",blocked:"blocked","needs-refresh":"needs refresh","needs-tests":"needs tests","needs-scenarios":"needs scenarios","happy-only":"happy path only","possible-duplicate":"possible duplicate","not-yet-run":"not yet run"},C={high:0,med:1,low:2};function D(e,t){let s=/^(.*?)(\d+)$/.exec(e),r=/^(.*?)(\d+)$/.exec(t);return s&&r&&s[1]===r[1]?Number(s[2])-Number(r[2]):e<t?-1:e>t?1:0}function I(e){if(!e||/^sha256:/.test(e))return"(unnamed)";let t=/^(uc|ac|sc|t)-(\d+)$/.exec(e);return t?`${t[1].toUpperCase()}-${t[2]}`:e}function ve(e,t=5){let s=e.trim().split(/\s+/);return s.slice(0,t).join(" ")+(s.length>t?"\u2026":"")}function be(e,t){let s=e.resolve(t),r=s?e.getNode(e.tipOf(s.cid))?.content:null;return String(r?.title??r?.text??"")}function ie(e,t){let s=e.resolve(t);return{id:s?e.displayNameOf(e.tipOf(s.cid))??e.displayNameOf(s.cid):null,title:ve(be(e,t),8)}}function ye(e,t){let s=e.resolve(t);if(!s)return null;let r=e.tipOf(s.cid);if(!O(e,r))return null;let a=e.nodeLabel.get(r);if(a===E.USECASE)return r;if(a===E.AC)return G(e,r);if(a===E.TEST){let l=e.edgesFrom(r).find(d=>d.type===U.VERIFIES&&O(e,d.dst));if(l)return G(e,l.dst);let x=e.edgesFrom(r).find(d=>d.type===U.AUTOMATES&&O(e,d.dst));if(x){let d=e.edgesFrom(x.dst).find(m=>m.type===U.BELONGS_TO&&O(e,m.dst));return d?d.dst:null}}return null}function L(e){if(e.tag==="reuse-candidate"&&e.stage==="design")return"possible-duplicate";switch(e.kind){case"no-verifies":return"needs-tests";case"zero-scenario":return"needs-scenarios";case"happy-only":return"happy-only";case"stale-ac":case"stale-test":return"needs-refresh";case"execution-failed":return"failing";case"execution-blocked":return"blocked";case"covered-not-run":return"not-yet-run";default:return"other"}}function xe(e,t){let s=e.resolve(t),r=s?e.getNode(e.tipOf(s.cid))?.content.risk:null;return r==="high"||r==="med"||r==="low"?r:"med"}function ae(e,t,s,r,a){let l=a.servePaths??new Map,x=e.byLabel(E.USECASE).filter(({cid:o})=>O(e,o)),d=new Map(x.map(o=>[o.cid,o])),m=new Map(x.map(({cid:o})=>[o,[]])),h=[];for(let o of t){if(o.stage!=="design")continue;let i={...o,...ie(e,o.ref)},_=ye(e,o.ref),k=_?m.get(_):void 0;k&&L(o)!=="other"?k.push(i):h.push(i)}let T=new Map(x.map(({cid:o})=>[o,{total:0,designed:0}]));for(let{cid:o}of e.byLabel(E.AC)){if(!O(e,o))continue;let i=G(e,o),_=i?T.get(i):void 0;if(!_)continue;_.total++;let k=F(e,o);if(k&&_.designed++,!r)continue;let b=e.nameOf.get(o)??o,f=r.perAc[b];if(!f)continue;let{id:p,title:y}=ie(e,b),c={ref:e.displayNameOf(o)??o,id:p,title:y,risk:xe(e,b),stage:"cover"},n=m.get(i);f.state==="failing"?n.push({...c,kind:"execution-failed",tag:"evolve",why:"covering test failed against this AC",ready_command:f.executionId&&l.has(f.executionId)?`kane-cli evidence serve ${l.get(f.executionId)}`:"kane-cli testrun run",via_tests:f.viaTests,...f.executionId?{execution_id:f.executionId}:{},...f.executionId&&l.has(f.executionId)?{servePath:l.get(f.executionId)}:{},...a.testFiles?{viaFiles:f.viaTests.map(u=>a.testFiles.get(u)??null)}:{}}):f.state==="blocked"?n.push({...c,kind:"execution-blocked",tag:"reuse-candidate",why:"the formula could count no run \u2014 broken/skipped or an unaccepted oracle",ready_command:f.executionId&&l.has(f.executionId)?`kane-cli evidence serve ${l.get(f.executionId)}`:"kane-cli testrun run",...f.executionId?{execution_id:f.executionId}:{},...f.executionId&&l.has(f.executionId)?{servePath:l.get(f.executionId)}:{}}):f.state==="not_run"&&k&&n.push({...c,kind:"covered-not-run",tag:"reuse-candidate",why:"a covering test exists but has not run yet",ready_command:"kane-cli testrun run"})}let g=[];for(let{cid:o,content:i}of x){let _=e.displayNameOf(o)??o,k=e.nameOf.get(o)??o,b=s.perUc[_]??{pct:0,status:"undesigned",staleAcs:0},f=r?r.perUc[k]??{pct:0,status:"not_run"}:null,p=r!==null&&(f===null||f.status==="not_run"),y=T.get(o),c=m.get(o)??[],n=new Set(c.filter(v=>L(v)==="needs-refresh").map(v=>v.ref)),u=[];for(let v of me){let $=c.filter(R=>L(R)===v);if(v==="needs-tests"&&($=$.filter(R=>!n.has(R.ref))),$.length===0)continue;$.sort((R,w)=>(C[R.risk]??3)-(C[w.risk]??3)||D(R.ref,w.ref));let S=v==="failing"||v==="blocked"||$.length<=2||new Set($.map(R=>R.ready_command)).size>1;u.push({key:v,label:he[v],...v==="needs-refresh"?{suffix:"source moved since these were designed"}:{},rows:$,...S?{}:{rosterCommand:$[0].ready_command}})}g.push({slug:_,title:String(i.title??""),risk:String(i.risk??""),des:b,prov:f,provAbsent:p,acTotal:y.total,acDesigned:y.designed,groups:u})}return g.sort((o,i)=>(C[o.risk]??3)-(C[i.risk]??3)||D(o.slug,i.slug)),h.sort((o,i)=>(C[o.risk]??3)-(C[i.risk]??3)||D(o.ref,i.ref)),{stage:a.stage,aspect:a.aspect,top:a.top,dc:s,pa:r,ucs:g,other:h}}function N(e,t){let s=Math.round(e/100*t);return"\u2588".repeat(s)+"\u2591".repeat(t-s)}function W(e,t){return e==="all"||t.stage===e}function B(e,t){return e.length<=t?e:t<=1?e.slice(0,t):e.slice(0,t-1)+"\u2026"}var _e={failing:"failing",blocked:"blocked","needs-refresh":"stale","needs-tests":"needs test","needs-scenarios":"no scenario","happy-only":"happy only","possible-duplicate":"duplicate?","not-yet-run":"to run"},ke=["failing","blocked","needs-refresh","needs-tests","needs-scenarios","happy-only","possible-duplicate"];function le(e,t){let s=Date.parse(e);if(Number.isNaN(s))return e;let r=Math.max(0,Math.floor((t-s)/1e3));return r<60?"just now":r<3600?`${Math.floor(r/60)}m ago`:r<86400?`${Math.floor(r/3600)}h ago`:`${Math.floor(r/86400)}d ago`}function $e(e,t){return(t.get("failing")??[]).length?0:(t.get("blocked")??[]).length?1:(t.get("needs-tests")??[]).length||(t.get("needs-scenarios")??[]).length?2:(t.get("needs-refresh")??[]).length?3:(t.get("not-yet-run")??[]).length>0||e.provAbsent?4:5}function ue(e,t){let s=new Map;for(let g of t.groups)g.rows.length&&s.set(g.key,g.rows);let r=new Map;for(let g of t.groups){let o=g.rows.filter(i=>W(e.stage,i));o.length&&r.set(g.key,o)}let a=[],l=[],x=[],d=new Set;for(let g of ke){let o=r.get(g);if(o){for(let i of o){let _=g==="failing"&&i.via_tests?.length?` \xB7 via ${i.via_tests.map(k=>I(k)).join(", ")}`:"";a.push({id:i.ref===t.slug?"\u2014":I(i.id??i.ref),cls:_e[g],risk:i.ref===t.slug?"\u2014":i.risk,title:(i.ref===t.slug?i.why:i.title)+_})}if(g==="failing"||g==="blocked")for(let i of o)i.servePath&&d.add(`kane-cli evidence serve ${i.servePath}`);for(let i of o)i.ready_command&&!i.ready_command.startsWith("kane-cli evidence serve")&&i.ready_command!=="kane-cli testrun run"&&d.add(i.ready_command)}}let m=[...d].sort((g,o)=>Number(o.startsWith("kane-cli evidence serve"))-Number(g.startsWith("kane-cli evidence serve")));l.push(...m.map(g=>`\u21B3 ${g}`));let h=s.get("not-yet-run")??[],T=e.pa===null?t.acDesigned:h.length;return e.pa!==null&&T>0&&x.push(`${T} to run`),{uc:t,rows:a,spans:l,tails:x,toRun:T,severity:$e(t,s)}}function de(e,t){let{dc:s,pa:r}=e,a=Math.max(80,Math.min(t.width,100)),l=n=>t.color?`\x1B[2m${n}\x1B[22m`:n,x=t.now??Date.now(),d=[],m=r?.latest_run?`last run ${le(r.latest_run.started_at,x)}`:"no runs yet";d.push(`coverage \u2014 designed \xD7 proven \xB7 ${e.aspect} \xB7 ${m}`),d.push(""),d.push(P(`designed ${String(s.pct).padStart(3)}% ${N(s.pct,10)} ${s.acs_designed} ACs have a verifying test`,t.color)),r?d.push(P(`proven ${String(r.pct).padStart(3)}% ${N(r.pct,10)} ${r.acs_proven} \xB7 ${r.failing} failing \xB7 ${r.blocked} blocked \xB7 ${r.not_run} not yet run`,t.color)):d.push("proven \u2014 no runs recorded yet \xB7 run tests, then re-run"),d.push("");let h=e.ucs.map(n=>ue(e,n));h.sort((n,u)=>n.severity-u.severity||D(n.uc.slug,u.uc.slug));let T=h.some(n=>n.rows.length||n.spans.length||n.tails.length||r!==null&&n.toRun>0),g=n=>{let[u,v]=n.split("/").map(Number);return v>0&&u===v};if(!T&&g(s.acs_designed)&&(r===null||g(r.acs_proven))){let n=e.ucs.length,u=`use-case${n===1?"":"s"}`;return d.push(r?`no gaps \u2014 all ${n} ${u} designed and proven`:`no gaps \u2014 all ${n} ${u} designed \xB7 nothing run yet`),d.push(l("inspect a use-case: kane-cli cover gaps <uc-id>")),d}let o=(n,u)=>n.groups.filter(v=>u.includes(v.key)).reduce((v,$)=>v+$.rows.length,0),i=h.map(n=>({band:n,failing:o(n.uc,["failing"]),blocked:o(n.uc,["blocked"]),stale:o(n.uc,["needs-refresh"]),design:o(n.uc,["needs-tests","needs-scenarios"]),run:n.toRun})),_=[];i.some(n=>n.failing)&&_.push({hdr:"FAILING",get:n=>n.failing}),i.some(n=>n.blocked)&&_.push({hdr:"BLOCKED",get:n=>n.blocked}),i.some(n=>n.stale)&&_.push({hdr:"STALE",get:n=>n.stale}),i.some(n=>n.design)&&_.push({hdr:"TO DESIGN",get:n=>n.design}),i.some(n=>n.run)&&_.push({hdr:"TO RUN",get:n=>n.run}),a<100&&(_.length=0);let k=Math.min(16,Math.max(4,...h.map(n=>I(n.uc.slug).length))),b=15,f=_.map(n=>n.hdr.length+2),p=a-k-2-3-b-3-b-f.reduce((n,u)=>n+u,0)-2,y=n=>n.padStart(Math.floor((b+n.length)/2)).padEnd(b),c=`${" ".repeat(k+2)}${"USE CASE".padEnd(p+3)}${y("DESIGNED")} ${y("PROVEN")}`+_.map((n,u)=>n.hdr.padStart(f[u])).join("");d.push(l(c.trimEnd().slice(0,a)));for(let n of i){let u=n.band.uc,v=`${String(u.des.pct).padStart(3)}% ${N(u.des.pct,10)}`,$=r===null||u.provAbsent?we("no runs",b,t.color):`${String(u.prov?.pct??0).padStart(3)}% ${N(u.prov?.pct??0,10)}`,S=_.map((w,j)=>String(w.get(n)||"\u2014").padStart(f[j])).join(""),R=`${B(I(u.slug),k).padEnd(k)} ${B(u.title,p).padEnd(p)} ${v} ${$}${S}`;d.push(P(R,t.color))}return d.push(""),d.push(l("inspect a use-case: kane-cli cover gaps <uc-id>")),d}function we(e,t,s){let r=e.padStart(Math.floor((t+e.length)/2)).padEnd(t);return s?`\x1B[2m${r}\x1B[22m`:r}function P(e,t){return t?e.replace(/(\s*\d+%) (█*)(░*)/g,(s,r,a,l)=>{let x=Number(r.trim().replace("%","")),d=x===100?"\x1B[32m":"\x1B[33m";return`${x===0?"\x1B[31m":d}${r}\x1B[39m ${d}${a}\x1B[39m\x1B[2m${l}\x1B[22m`}):e}function pe(e,t,s,r){let{pa:a}=e,l=Math.max(80,Math.min(r.width,100)),x=p=>r.color?`\x1B[2m${p}\x1B[22m`:p,d=r.now??Date.now(),m=[],h=e.ucs.find(p=>p.slug===t),T=a?.latest_run?`last run ${le(a.latest_run.started_at,d)}`:"no runs yet";m.push(`${I(t)} \xB7 ${h?.title??""} \u2014 risk ${h?.risk??"\u2014"} \xB7 ${e.aspect} \xB7 ${T}`.slice(0,l)),m.push("");let g=h?ue(e,h):null;if(h&&g){m.push(P(`designed ${String(h.des.pct).padStart(3)}% ${N(h.des.pct,10)} ${h.acDesigned}/${h.acTotal} ACs have a verifying test`,r.color));let p=g.tails.length?` \xB7 ${g.tails.join(" \xB7 ")}`:"";a===null||h.provAbsent?m.push(`proven \u2014 no runs yet${p}`):m.push(P(`proven ${String(h.prov?.pct??0).padStart(3)}% ${N(h.prov?.pct??0,10)} ${p.replace(/^ · /,"")}`,r.color)),m.push("")}let o=Math.min(16,Math.max(5,...s.map(p=>I(p.id).length))),i=10,_=5,k=l-o-2-i-2-_-2;m.push(x(`${" ".repeat(o+2)}${"STATE".padEnd(i+2)}${"RISK".padEnd(_+2)}ACCEPTANCE CRITERION`));let b=p=>{if(!r.color)return p;let y=p.trim(),c=y.startsWith("proven")?"\x1B[32m":y==="failing"||y==="needs test"?"\x1B[31m":y==="blocked"||y==="stale"?"\x1B[33m":"\x1B[2m",n=c==="\x1B[2m"?"\x1B[22m":"\x1B[39m";return p.replace(y,`${c}${y}${n}`)};for(let p of s){let c=(p.text+(p.via?` \xB7 via ${p.via}`:"")).split(/\s+/),n=[],u="";for(let v of c)u&&u.length+1+v.length>k?(n.push(u),u=v):u=u?`${u} ${v}`:v;u&&n.push(u),n.forEach((v,$)=>{$===0?m.push(`${B(I(p.id),o).padEnd(o)} ${b(p.state.padEnd(i))} ${p.risk.padEnd(_)} ${v}`):m.push(`${" ".repeat(o+2+i+2+_+2)}${v}`)})}let f=[];if(h&&g){for(let y of g.spans){let c=y.replace(/^↳ /,"");if(c.startsWith("kane-cli evidence serve")){let n=s.filter(u=>u.state==="blocked"||u.state==="failing").map(u=>I(u.id)).join(" \xB7 ");f.push({label:"see why",cmd:c,...n?{note:`(explains ${n})`}:{}})}else f.push({label:"design",cmd:c})}let p=s.filter(y=>y.state==="to run").length;if(p>0){let c=s.some(n=>n.state==="failing")?"(review evidence first \u2014 a re-run may heal over failures)":f.some(n=>n.label==="see why")?`(${p} ACs never executed \u2014 see why first)`:`(${p} ACs never executed)`;f.push({label:"first run",cmd:"kane-cli testrun run",note:c})}}if(f.length){m.push(""),m.push("next");let p=Math.max(...f.map(c=>c.label.length))+2,y=c=>r.color?`\x1B[36m${c}\x1B[39m`:c;for(let c of f){let n=` ${c.label.padEnd(p)}`;if(n.length+c.cmd.length>l){let u=c.cmd.lastIndexOf(" ",l-n.length),v=u>0?c.cmd.slice(0,u):c.cmd.slice(0,l-n.length),$=u>0?c.cmd.slice(u+1):c.cmd.slice(l-n.length);m.push(`${n}${y(v)}`),m.push(`${" ".repeat(n.length)}${y($)}`),c.note&&m.push(x(`${" ".repeat(n.length)}${c.note}`))}else c.note&&n.length+c.cmd.length+3+c.note.length<=l?m.push(`${n}${y(c.cmd)} ${x(c.note)}`):(m.push(`${n}${y(c.cmd)}`),c.note&&m.push(x(`${" ".repeat(n.length)}${c.note}`)))}}return m.push(""),m.push(x("all use-cases: kane-cli cover gaps")),m}function K(e){let{dc:t,pa:s}=e,r=a=>e.top!==void 0?a.slice(0,e.top):a;return{stage:e.stage,rollup_version:1,design_completeness:{pct:t.pct,acs_designed:t.acs_designed,usecases_complete:t.usecases_complete,ucs_needing_scenarios:t.ucs_needing_scenarios,config:t.config},...s?{proven:{aspect:s.aspect,pct:s.pct,acs_proven:s.acs_proven,failing:s.failing,blocked:s.blocked,not_run:s.not_run,latest_run:s.latest_run,config:s.config}}:{},usecases:e.ucs.map(a=>({id:/^sha256:/.test(a.slug)?null:a.slug,title:a.title,risk:a.risk,design_completeness:{pct:a.des.pct,status:a.des.status},stale_acs:a.des.staleAcs,...s?{proven:a.prov??{pct:0,status:"not_run"}}:{},pending:r(a.groups.flatMap(l=>l.rows).filter(l=>W(e.stage,l))).map(ce)})),other:e.other.filter(a=>W(e.stage,a)).map(ce)}}function ce(e){let{servePath:t,viaFiles:s,meta:r,...a}=e;return{...a}}async function Te(e,t,s=re(),r=process.cwd()){if(t.mode!==void 0&&t.mode!=="agent"&&t.mode!=="ci"&&t.mode!=="interactive")return M(s,`--mode must be interactive | agent | ci, got '${t.mode}'`),2;if(t.mode==="agent"||t.mode==="ci"){let{makeHeadlessIO:k,agentRefusal:b}=await import("./headless-io-66RG5NN5.js"),{parsesAgainstGrammar:f}=await import("./next-TRSKMBO5.js"),p=k("ndjson","gaps",{stdout:w=>s.out(w.replace(/\n$/,"")),stderr:w=>(s.err??s.out)(w.replace(/\n$/,""))}),y=[],c=[],n={out:w=>y.push(w),err:w=>c.push(w),confirm:async()=>!1,isTTY:!1};if(await Te(e,{...t,json:!0,mode:void 0},n,r)!==0)return b(p,c.join("; ")||"cover gaps refused");let v=JSON.parse(y.join(`
|
|
3
|
-
`));p.event({type:"gaps",...v});let $=[],S=new Set,R=(w,j)=>{if(Array.isArray(w)){for(let A of w)R(A,j);return}if(w&&typeof w=="object"){let A=w,J=typeof A.why=="string"?A.why:j;typeof A.ready_command=="string"&&A.ready_command.startsWith("kane-cli ")&&f(A.ready_command)&&!S.has(A.ready_command)&&(S.add(A.ready_command),$.push({cmd:A.ready_command,why:J||"close the gap"}));for(let fe of Object.values(A))R(fe,J)}};return R(v,"close the gap"),p.done(0,void 0,$.slice(0,4))}let a=t.stage??"all";if(a!=="design"&&a!=="cover"&&a!=="all")return M(s,`--stage must be design | cover | all, got '${a}'`),2;if(t.top!==void 0&&(!Number.isInteger(t.top)||t.top<1))return M(s,"--top must be a positive integer"),2;let l=t.rollup??"lenient";if(l!=="lenient"&&l!=="strict")return M(s,`--rollup must be lenient | strict, got '${l}'`),2;let x=se(r,s);if(!x)return 2;let d=V(x),m=Z(d),h=oe(d,l),T=await z(d,"design"),g=new Map;if(h)for(let k of Object.values(h.perAc)){if(!k.executionId||g.has(k.executionId))continue;let b=await Y(k.executionId,r);b&&g.set(k.executionId,Re(b,r))}let o=new Map;for(let[k,b]of ne(te(r)))b.length===1&&o.set(k,b[0].split("/").pop());let i=ae(d,T,m,h,{stage:a,top:t.top,aspect:l,servePaths:g,testFiles:o});if(e!==void 0){let k=d.resolve(e),b=k?d.tipOf(k.cid):null;if(!b||d.nodeLabel.get(b)!==E.USECASE||!O(d,b))return M(s,`no use-case '${e}' in the graph`),2;let f=d.displayNameOf(b)??b;if(t.json){let c=K(i);return s.out(JSON.stringify({...c,usecases:c.usecases.filter(n=>n.id===f),other:[]},null,2)),0}let p=Se(d,b,h,o),y=s.isTTY&&process.stdout.columns?process.stdout.columns:100;for(let c of pe(i,f,p,{width:y,color:s.isTTY}))s.out(c);return 0}if(t.json)return s.out(JSON.stringify(K(i),null,2)),0;if(m.usecases_complete==="0/0")return s.out("nothing to measure yet \u2014 no live use-cases in the graph"),0;let _=s.isTTY&&process.stdout.columns?process.stdout.columns:100;for(let k of de(i,{width:_,color:s.isTTY}))s.out(k);return 0}function Re(e,t){let s=t.endsWith("/")?t:t+"/";return e.startsWith(s)?e.slice(s.length):e}function Se(e,t,s,r){let a=[];for(let{cid:l,content:x}of e.byLabel(E.AC)){if(!O(e,l)||G(e,l)!==t)continue;let d=F(e,l),m=e.nameOf.get(l)??l,h=s?.perAc[m],T=e.stale(l)!=="fresh",g=d?h?.state==="proven"?"proven \u2713":h?.state==="failing"?"failing":h?.state==="blocked"?"blocked":T?"stale":"to run":"needs test",o=h?.state==="failing"&&h.viaTests.length?h.viaTests.map(i=>`${I(i)}${r.get(i)?` ${r.get(i)}`:""}`).join(", "):void 0;a.push({id:e.displayNameOf(l)??l,state:g,risk:String(x.risk??""),text:String(x.text??x.title??""),...o?{via:o}:{}})}return a.sort((l,x)=>D(l.id,x.id)),a}export{Te as gapsCommand};
|
package/dist/ingest-4447MYLF.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{g as a,h as b,i as c,j as d,k as e}from"./chunk-X2FM67OM.js";import"./chunk-DNNZ353O.js";import"./chunk-Q2F5QB2W.js";import"./chunk-NVGBE2DR.js";import"./chunk-TH47OOBV.js";import"./chunk-VAYBKR76.js";import"./chunk-CUM23TLF.js";import"./chunk-DUAXZYAD.js";import"./chunk-DBIBROYW.js";import"./chunk-WXHQYYD5.js";import"./chunk-IAHKTEET.js";import"./chunk-UD7KKHPW.js";import"./chunk-UR6MHSHU.js";export{a as compositePayloadBytes,e as ingestBytes,d as ingestFile,b as slugFromFilename,c as versionBaseOf};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a,b,c}from"./chunk-EFRJNPBZ.js";import"./chunk-KRKGZ2ZW.js";import"./chunk-VT2XNEOD.js";import"./chunk-2UIHS2FH.js";import"./chunk-YKTYVJBN.js";import"./chunk-X2FM67OM.js";import"./chunk-DNNZ353O.js";import"./chunk-Q2F5QB2W.js";import"./chunk-R7QAS6LZ.js";import"./chunk-BKHXPBWN.js";import"./chunk-N2P4MI32.js";import"./chunk-5DT7PIGB.js";import"./chunk-NVGBE2DR.js";import"./chunk-CH273NAE.js";import"./chunk-TH47OOBV.js";import"./chunk-VAYBKR76.js";import"./chunk-CUM23TLF.js";import"./chunk-DUAXZYAD.js";import"./chunk-DBIBROYW.js";import"./chunk-WXHQYYD5.js";import"./chunk-IAHKTEET.js";import"./chunk-UD7KKHPW.js";import"./chunk-MSGW4JDG.js";import"./chunk-CCUGKBIH.js";import"./chunk-UR6MHSHU.js";export{c as ingestCommand,b as runIngestCommand,a as runIngestWithResults};
|
package/dist/install-46S4VOZ4.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as l,b as a,c as f,d as m}from"./chunk-OS4VSIHT.js";import"./chunk-5DT7PIGB.js";import"./chunk-CH273NAE.js";import{A as c,r as y,s as b,y as v}from"./chunk-TH47OOBV.js";import"./chunk-VAYBKR76.js";import"./chunk-CUM23TLF.js";import"./chunk-DUAXZYAD.js";import"./chunk-DBIBROYW.js";import"./chunk-WXHQYYD5.js";import"./chunk-IAHKTEET.js";import"./chunk-UD7KKHPW.js";import"./chunk-UR6MHSHU.js";var g={kind:"human",id:process.env.USER??"operator"},C=/^(UNKNOWN_|BAD_|INVALID_|MALFORMED_|NOT_|SLUG_TAKEN|ALREADY_|SUPERSEDED_)/;function w(e){return e.every(r=>C.test(r.code))?2:1}function p(e,r){for(let n of r)l(e,`${n.code}: ${n.detail}`);return w(r)}async function E(e,r,n,o=process.cwd()){let t=a(o,n);if(!t||!await f(n,`retire source ${e} (head \u2192 null + tombstone record)`,r.yes))return 2;let i=c(t),s=b({contextDir:t,graph:i,sourceId:e,reason:r.reason,by:g});return s.errors?p(n,s.errors):(n.out(`retired ${e} (record ${s.record.seq}) \u2014 its use-cases stay until no live source evidences them`),0)}async function _(e,r,n,o=process.cwd()){let t=a(o,n);if(!t)return 2;if(v.test(r))return l(n,`"${r}" is in the reserved sequential-id namespace (assigned at mint) \u2014 pick a descriptive name`),2;let i=c(t),s=y({contextDir:t,graph:i,assignments:[{ref:e,slug:r}],by:g});return s.errors?p(n,s.errors):(n.out(`named ${s.record.names[0].cid} as "${r}" (record ${s.record.seq})`),0)}async function x(e,r,n,o=process.cwd()){let t=a(o,n);if(!t)return 2;let i=Number(e);if(!await f(n,`revert record ${i} via a compensation record`,r.yes))return 2;let s=c(t),{commitRevert:$}=await import("./revert-NQ7GEVSE.js"),d=$({contextDir:t,graph:s,seq:i,reason:r.reason,by:g});for(let h of d.warnings)n.out(`note: ${h}`);if(d.errors)return p(n,d.errors);let u=d.record;return n.out(`reverted record ${i} via compensation record ${u.seq}: ${u.supersessions.length} supersession(s), ${u.review.length} trust restoration(s), ${Object.keys(u.source_head_moves).length} head move(s) \u2014 history unchanged, effects inverted`),0}async function P(e,r){return E(e,r,m())}async function R(e,r){return _(e,r,m())}async function k(e={},r=process.cwd()){return D(e,m(),r)}async function D(e,r,n=process.cwd()){let o=a(n,r);if(!o||!await f(r,"assign logical ids to every live unnamed node (one commit record)",e.yes))return 2;let{backfillLogicalIds:t}=await import("./logical-ids-TEBCQJGO.js"),i=c(o),s=t(o,i);return s.errors?p(r,s.errors):(r.out(s.assigned===0?"backfill: every live node already has a logical id":`backfill: assigned ${s.assigned} logical id(s) (record ${s.record.seq})`),0)}async function q(e,r){return x(e,r,m())}export{k as nameBackfillCommand,R as nameCommand,P as retireCommand,q as revertCommand,D as runNameBackfillCommand,_ as runNameCommand,E as runRetireCommand,x as runRevertCommand};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{b as m}from"./chunk-OS4VSIHT.js";import"./chunk-5DT7PIGB.js";import"./chunk-CH273NAE.js";import{A as g}from"./chunk-TH47OOBV.js";import"./chunk-VAYBKR76.js";import"./chunk-CUM23TLF.js";import"./chunk-DUAXZYAD.js";import"./chunk-DBIBROYW.js";import{d as s}from"./chunk-WXHQYYD5.js";import"./chunk-IAHKTEET.js";import"./chunk-UD7KKHPW.js";import"./chunk-UR6MHSHU.js";var h=[s.SOURCE,s.USECASE,s.SCENARIO,s.AC,s.TEST,s.GAP];function b(n,e){if(n===s.SOURCE)return String(e.source_id??"");let l=e.question?.header,o=e.title??e.text??l??e.kind??"";return String(o)}function E(n,e){if(n.length<=e)return n;let l=n.slice(0,e-1),o=l.lastIndexOf(" ");return`${(o>e*.6?l.slice(0,o):l).trimEnd()}\u2026`}var p=58;async function O(n,e,l=process.cwd()){let o=m(l,e);if(!o)return 2;let a=g(o),i=[...a.nodeLabel.entries()].filter(([t])=>n.all||!a.superseded.has(t)).map(([t,r])=>{let u=a.getNode(t)?.content??{},f=a.trust.get(t)??(r===s.SOURCE?"-":"derived");return{id:r===s.SOURCE?String(u.source_id??""):a.nameOf.get(t)??t.slice(0,19),cid:t,label:r,title:b(r,u),trust:f,fresh:f==="archived"?"-":a.stale(t)}});if(n.type&&(i=i.filter(t=>t.label===n.type)),n.inferred&&(i=i.filter(t=>t.trust==="derived")),n.stale&&(i=i.filter(t=>t.fresh!=="fresh")),!n.all){let t=new Map;for(let r of i)t.set(`${r.label}:${r.id}`,r);i=[...t.values()]}let c=t=>{let r=h.indexOf(t);return r===-1?h.length:r};if(i.sort((t,r)=>c(t.label)-c(r.label)||t.title.localeCompare(r.title)),n.json){for(let t of i)e.out(JSON.stringify(t));return 0}if(i.length===0)return e.out("(no matching nodes)"),0;e.out("trust \xB7 fresh \xB7 title \xB7 id");let d=null;for(let t of i){if(t.label!==d){d=t.label;let u=i.filter(f=>f.label===t.label).length;e.out(""),e.out(`\u2500\u2500 ${t.label} \xB7 ${u} \u2500\u2500`)}let r=E(t.title||"(untitled)",p);e.out(` ${t.trust.padEnd(8)} ${t.fresh.padEnd(6)} ${r.padEnd(p)} ${t.id}`)}{let{heldArchiveScan:t}=await import("./feeder-C3TOJPKK.js"),r=t(o,a).live.size;r>0&&(e.out(""),e.out(`${r} held archive(s) awaiting confirmation \u2014 kane-cli context review walks them (or --allow-archive --because applies headlessly)`))}return 0}async function C(n){return O(n,{out:e=>process.stdout.write(e+`
|
|
3
|
-
`),confirm:async()=>!1,isTTY:!!process.stdout.isTTY})}export{E as capWord,C as listCommand,O as runListCommand,b as titleOf};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{r as d,w as f,x as m}from"./chunk-TH47OOBV.js";import"./chunk-VAYBKR76.js";import"./chunk-CUM23TLF.js";import"./chunk-DUAXZYAD.js";import"./chunk-DBIBROYW.js";import"./chunk-WXHQYYD5.js";import"./chunk-IAHKTEET.js";import"./chunk-UD7KKHPW.js";import"./chunk-UR6MHSHU.js";var y=Object.keys(f).filter(n=>n!=="source");function b(n,t,u={kind:"system",id:"logical-id-backfill"}){let l=new Set(t.names.keys()),r=[];for(let c of y)for(let{cid:s,content:e}of t.byLabel(c)){if(t.superseded.has(s)||t.nameOf.has(s))continue;let a=typeof e.title=="string"&&e.title||typeof e.intent=="string"&&e.intent||typeof e.statement=="string"&&e.statement||typeof e.text=="string"&&e.text||"",i=a?m(c,a,g=>l.has(g)):null;i&&(l.add(i),r.push({ref:s,slug:i}))}if(r.length===0)return{record:null,errors:null,assigned:0};let o=d({contextDir:n,graph:t,assignments:r,by:u});return o.errors?{record:null,errors:o.errors,assigned:0}:{record:o.record,errors:null,assigned:r.length}}export{b as backfillLogicalIds};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a}from"./chunk-FDWEL5HR.js";import"./chunk-RFHMDQXZ.js";import"./chunk-PB3GADUD.js";import"./chunk-WLOGO44E.js";import"./chunk-RZ4F3BHX.js";import"./chunk-4UMQDH52.js";import"./chunk-CCUGKBIH.js";import"./chunk-UR6MHSHU.js";export{a as LoginFlow};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as p}from"./chunk-TRJUD3XJ.js";import{c}from"./chunk-3Q6WAK6P.js";import"./chunk-AFPHLUQ5.js";import{a as g}from"./chunk-BB2W35TW.js";import"./chunk-DNNZ353O.js";import"./chunk-NVGBE2DR.js";import"./chunk-TH47OOBV.js";import"./chunk-VAYBKR76.js";import"./chunk-CUM23TLF.js";import{d}from"./chunk-DUAXZYAD.js";import"./chunk-DBIBROYW.js";import"./chunk-WXHQYYD5.js";import"./chunk-IAHKTEET.js";import"./chunk-UD7KKHPW.js";import"./chunk-UR6MHSHU.js";var u=["grounding","acs","scenarios","wiring","tests"];function l(i,r,o){let s=r.resolve(o);if(s===null)return[];let n=g(r,s.cid),a=c(d(i).records,n),e=a.reduce((t,m)=>Math.max(t,m.generation),0);return a.filter(t=>t.generation===e)}function E(i,r,o,s){let n=u;if(!n.includes(s))return{ok:!1,code:"UNKNOWN_PHASE",message:`--phase must be one of ${n.join(" | ")}, got '${s}'`,valid:[...n]};let a=new Set(l(i,r,o).map(t=>t.phase)),e=n.slice(0,n.indexOf(s)).filter(t=>t!=="grounding"&&!a.has(t));return e.length===0?{ok:!0,phase:s}:{ok:!1,code:"PHASE_ORDER",message:`--phase ${s} needs ${e.join(" + ")} committed first (nothing recorded for ${e.join(", ")})`,missing:e,earliest:e[0]}}function y(i,r,o,s){let n=l(i,r,o),a=r.resolve(o);if(a===null)return{priorDesign:void 0,phaseLadder:n};let e=p(r,a.tip);return{priorDesign:e.scenarios.length===0&&e.tests.length===0&&e.acs.length===0?void 0:e,phaseLadder:n}}function R(i,r,o){return`kane-cli design tests --use-case ${i} --phase ${r}${o?" --mode agent":""}`}export{u as PHASE_ORDER,y as buildPhaseSeed,E as checkPhaseEntry,R as phaseEntryCmd,l as phaseLadderFor};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a,b,c}from"./chunk-BVKDHHPK.js";import"./chunk-2YQ6TW77.js";import"./chunk-3AJ3QSF5.js";import"./chunk-5DBK6QNS.js";import"./chunk-TJZMYU2W.js";import"./chunk-5GUD3CIH.js";import"./chunk-XWKUZJCP.js";import"./chunk-ZSXDZI56.js";import"./chunk-EHN5HTUD.js";import"./chunk-NVGBE2DR.js";import"./chunk-CH273NAE.js";import"./chunk-VZ7KXRXB.js";import"./chunk-P7YZ3PU3.js";import"./chunk-TH47OOBV.js";import"./chunk-VAYBKR76.js";import"./chunk-CUM23TLF.js";import"./chunk-DUAXZYAD.js";import"./chunk-DBIBROYW.js";import"./chunk-WXHQYYD5.js";import"./chunk-IAHKTEET.js";import"./chunk-UD7KKHPW.js";import"./chunk-KX2GOJ4C.js";import"./chunk-BPMSNGXQ.js";import"./chunk-MMBBQ4OZ.js";import"./chunk-Z2T7E5HM.js";import"./chunk-MSGW4JDG.js";import"./chunk-4JOD47QI.js";import"./chunk-WLOGO44E.js";import"./chunk-DPUV6OSP.js";import"./chunk-NLCCBXXV.js";import"./chunk-RZ4F3BHX.js";import"./chunk-CCUGKBIH.js";import"./chunk-UR6MHSHU.js";export{c as UploadPipeline,b as packPresignEntry,a as readPackForUpload};
|