@testmuai/kane-cli 0.9.0 → 0.10.0-rc.1
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-VPD5G67Q.js +2 -0
- package/dist/ChromeProfilePicker-CRKQEFYD.js +2 -0
- package/dist/CliFeedbackPrompt-M7BMWLKK.js +2 -0
- package/dist/CliUploadProgress-OP7DXMC2.js +2 -0
- package/dist/ConfigView-XI74BCCH.js +2 -0
- package/dist/EvidenceViewOffer-HAAK6DS5.js +2 -0
- package/dist/FolderPicker-W5S6RFCP.js +2 -0
- package/dist/InfoBox-OWUEHV2D.js +2 -0
- package/dist/LinksBox-PNSESNCU.js +2 -0
- package/dist/ProfilesView-PYDZZHKO.js +2 -0
- package/dist/ProjectPicker-BGFCUGT5.js +2 -0
- package/dist/SaveSessionPrompt-SUJE54GS.js +2 -0
- package/dist/ScrollbackTap-4SPXGFMU.js +2 -0
- package/dist/SingleShotApp-4TDXZEUA.js +2 -0
- package/dist/SummaryBox-FALOODAQ.js +2 -0
- package/dist/TestMdRunView-4GPRWHEU.js +2 -0
- package/dist/TestrunEvidenceTable-OBVQJ6IO.js +2 -0
- package/dist/WhoamiView-6WXGRANY.js +2 -0
- package/dist/{agent-parse-2MLJOJTH.js → agent-parse-CAS45UKA.js} +1 -1
- package/dist/app-client-U2YYF65L.js +2 -0
- package/dist/app-download-RXVZB6MM.js +2 -0
- package/dist/assurance-job-C3TXZGLL.js +7 -0
- package/dist/auth-7Z54TMQQ.js +2 -0
- package/dist/{binary-LVHXED3O.js → binary-DJCDMGPX.js} +1 -1
- package/dist/bind-XVO4CQYV.js +2 -0
- package/dist/bootstrap-TY5RANJ7.js +2 -0
- package/dist/bridge-T6QMYKED.js +2 -0
- package/dist/build-5ZN47FAT.js +2 -0
- package/dist/catalog-RRQF4TCA.js +2 -0
- package/dist/{changelog-N5AZHXOS.js → changelog-GBEVIUFJ.js} +1 -1
- package/dist/chat-committer-ZCSRJEUB.js +2 -0
- package/dist/chat-controller-XINCDH6Z.js +2 -0
- package/dist/child-G2GCW73X.js +2 -0
- package/dist/chunk-22PIMG52.js +2 -0
- package/dist/chunk-252FWF2G.js +19 -0
- package/dist/{chunk-UWXDURAB.js → chunk-2IZRPMZN.js} +1 -1
- package/dist/{chunk-X2A6CC6B.js → chunk-2NFS4KE4.js} +1 -1
- package/dist/{chunk-ZXY4P76I.js → chunk-2OOFURWD.js} +1 -1
- package/dist/chunk-2OSFI33O.js +97 -0
- package/dist/{chunk-CSNJPD2J.js → chunk-2S3W2JT3.js} +3 -3
- package/dist/chunk-2SWSVJUP.js +12 -0
- package/dist/chunk-2TVPA3LL.js +2 -0
- package/dist/{chunk-FMUV6UCX.js → chunk-2XW33VOK.js} +1 -1
- package/dist/chunk-33DWJV67.js +235 -0
- package/dist/chunk-34R7BNZ2.js +2 -0
- package/dist/chunk-35ECWCCK.js +2 -0
- package/dist/chunk-3BSYOCSW.js +3 -0
- package/dist/chunk-3G2LSTK5.js +2 -0
- package/dist/chunk-3GXN6VF6.js +2 -0
- package/dist/chunk-3JLEDSG5.js +4 -0
- package/dist/chunk-3QICDXY5.js +5 -0
- package/dist/chunk-3UVSAAES.js +10 -0
- package/dist/chunk-42PALMW2.js +4 -0
- package/dist/chunk-432ZOE42.js +21 -0
- package/dist/chunk-44B6THYK.js +2 -0
- package/dist/chunk-47WQBG5I.js +6 -0
- package/dist/{chunk-DOOI2JBD.js → chunk-4D5PC6QE.js} +1 -1
- package/dist/chunk-4I7YN6YY.js +3 -0
- package/dist/chunk-4IEQNX7F.js +2 -0
- package/dist/{chunk-KXEE6VCA.js → chunk-4LPX2OLV.js} +1 -1
- package/dist/chunk-4LTHDJ3D.js +2 -0
- package/dist/chunk-4QTH7VYE.js +2 -0
- package/dist/chunk-54XA5MZH.js +2 -0
- package/dist/chunk-57MDWTON.js +2 -0
- package/dist/{chunk-CNUCP6DK.js → chunk-5BUIIFLC.js} +1 -1
- package/dist/{chunk-AKE2CTV6.js → chunk-5D7ENQTQ.js} +1 -1
- package/dist/chunk-63EKRZKI.js +2 -0
- package/dist/{chunk-EHN5HTUD.js → chunk-65VANXOF.js} +51 -51
- package/dist/chunk-672CQECV.js +47 -0
- package/dist/chunk-6LIC2R22.js +3 -0
- package/dist/chunk-6NFOH4AC.js +4 -0
- package/dist/chunk-6NWT2TEJ.js +2 -0
- package/dist/chunk-6PIIUAZF.js +3 -0
- package/dist/{chunk-4CYBXJIA.js → chunk-6U7ID777.js} +1 -1
- package/dist/chunk-6UVIY56J.js +2 -0
- package/dist/chunk-72KYMWQ5.js +2 -0
- package/dist/chunk-72RC7JSA.js +21 -0
- package/dist/chunk-74W4AOT2.js +2 -0
- package/dist/chunk-77ZZQJLX.js +2 -0
- package/dist/chunk-7DFBOVUB.js +2 -0
- package/dist/chunk-7EXDYXXD.js +2 -0
- package/dist/chunk-7HO4NX5W.js +1 -0
- package/dist/chunk-7KX2BHKG.js +2 -0
- package/dist/chunk-7LKCWO2R.js +11 -0
- package/dist/{chunk-ULGZPRKU.js → chunk-7NCJMWFX.js} +1 -1
- package/dist/{chunk-EBLXHOE3.js → chunk-7RPKHKA3.js} +1 -1
- package/dist/chunk-7RWP4Y3H.js +2 -0
- package/dist/chunk-7V4BQSSV.js +2 -0
- package/dist/chunk-7XBNMOH4.js +6 -0
- package/dist/chunk-A6TJOZ24.js +2 -0
- package/dist/chunk-AA674WLL.js +2 -0
- package/dist/chunk-AIXJYMSP.js +9 -0
- package/dist/chunk-AJQZ3ST5.js +8 -0
- package/dist/chunk-AQ2OG2EF.js +2 -0
- package/dist/chunk-AUJSC7PU.js +4 -0
- package/dist/chunk-AVI5H4UM.js +13 -0
- package/dist/chunk-AZLNLHUA.js +4 -0
- package/dist/chunk-B2HXPGIZ.js +26 -0
- package/dist/{chunk-HGFWIBVF.js → chunk-B7ZX5HEN.js} +5 -5
- package/dist/{chunk-WRSIKZ2V.js → chunk-BJJUKB5K.js} +1 -1
- package/dist/{chunk-66MOZKD2.js → chunk-BSRSXYDZ.js} +1 -1
- package/dist/{chunk-4BZOG6PE.js → chunk-BVO4C5F2.js} +1 -1
- package/dist/chunk-BWXLZS5O.js +2 -0
- package/dist/chunk-BY65QAAN.js +4 -0
- package/dist/chunk-BZVNI44O.js +6 -0
- package/dist/chunk-C5Z7MQE6.js +2 -0
- package/dist/chunk-C6HI6Y3S.js +2 -0
- package/dist/chunk-CB4ARIHR.js +2 -0
- package/dist/{chunk-C25M2J5Q.js → chunk-CPBBYNL7.js} +1 -1
- package/dist/{chunk-75MMTNPB.js → chunk-D4FFXCX6.js} +2 -2
- package/dist/chunk-D756UWY2.js +6 -0
- package/dist/chunk-DBMW3VUN.js +4 -0
- package/dist/chunk-DD5TULWQ.js +34 -0
- package/dist/{chunk-Q5RDCSYM.js → chunk-DDJNYQBH.js} +1 -1
- package/dist/{chunk-6HU5M2DS.js → chunk-DHQ4SQWA.js} +1 -1
- package/dist/chunk-DNGOT65K.js +3 -0
- package/dist/chunk-DPGOAFKF.js +2 -0
- package/dist/chunk-DREQ3RAA.js +2 -0
- package/dist/chunk-DTUPEKEO.js +2 -0
- package/dist/chunk-E6KSRQXL.js +8 -0
- package/dist/chunk-EF47KRUK.js +2 -0
- package/dist/chunk-ENL4XTQ2.js +2 -0
- package/dist/chunk-EXFDIVNI.js +9 -0
- package/dist/chunk-EZN7CF45.js +4 -0
- package/dist/chunk-F3U6T4YD.js +22 -0
- package/dist/{chunk-DHJSM5DT.js → chunk-FCD3NYOM.js} +1 -1
- package/dist/chunk-FFL55I2M.js +2 -0
- package/dist/chunk-FIP5L6LV.js +9 -0
- package/dist/chunk-FOJHSG5M.js +6 -0
- package/dist/chunk-FSYOTRMC.js +2 -0
- package/dist/chunk-GFLB2SHW.js +2 -0
- package/dist/chunk-GMTHZUZ3.js +2 -0
- package/dist/chunk-GRURFGBP.js +2 -0
- package/dist/chunk-GZFLJORM.js +2 -0
- package/dist/{chunk-EOA6YPES.js → chunk-H3HHSTEK.js} +4 -4
- package/dist/chunk-HAW5WEKT.js +13 -0
- package/dist/chunk-HFJSP4KD.js +2 -0
- package/dist/chunk-HHW6MRU3.js +6 -0
- package/dist/chunk-HIUAUZNL.js +2 -0
- package/dist/chunk-HJLMH7ZM.js +2 -0
- package/dist/{chunk-5GUD3CIH.js → chunk-HQ2E2XCU.js} +1 -1
- package/dist/{chunk-K3IQEL7R.js → chunk-I2KOGINW.js} +1 -1
- package/dist/chunk-I2MC6VVX.js +2 -0
- package/dist/chunk-I5NSJBOZ.js +2 -0
- package/dist/chunk-I6OQISK4.js +2 -0
- package/dist/chunk-IBBD36FQ.js +2 -0
- package/dist/{chunk-GCISXCDU.js → chunk-IINZZ4BZ.js} +1 -1
- package/dist/{chunk-M3UAZTDK.js → chunk-IMDMRJQ6.js} +2 -2
- package/dist/chunk-IXW7FOGX.js +2 -0
- package/dist/chunk-IZ65ZPWY.js +3 -0
- package/dist/chunk-JD52IXON.js +9 -0
- package/dist/chunk-JGRXMTME.js +15 -0
- package/dist/{chunk-NBXYL2JT.js → chunk-JIRNI5TB.js} +7 -7
- package/dist/chunk-JNSWKGTB.js +2 -0
- package/dist/chunk-JPYW6U4D.js +2 -0
- package/dist/chunk-JQSLUGD4.js +3 -0
- package/dist/{chunk-GFBAK7WQ.js → chunk-K45BKGB5.js} +7 -7
- package/dist/chunk-KF4DKXSS.js +2 -0
- package/dist/chunk-KGNE5CIM.js +2 -0
- package/dist/chunk-KM3YCIDV.js +3 -0
- package/dist/chunk-KU3YHPWZ.js +2 -0
- package/dist/chunk-L4UVUFL6.js +3 -0
- package/dist/chunk-LCSJ7GOG.js +2 -0
- package/dist/chunk-LKQFG4RW.js +5 -0
- package/dist/chunk-LNNWCBPQ.js +2 -0
- package/dist/chunk-LRS5MGBY.js +3 -0
- package/dist/chunk-LRXBJTD4.js +4 -0
- package/dist/chunk-LSDJOVWW.js +6 -0
- package/dist/chunk-LWJRSUE2.js +2 -0
- package/dist/chunk-LX2I4JEH.js +2 -0
- package/dist/{chunk-RWSOZPJQ.js → chunk-M6MBMRFR.js} +1 -1
- package/dist/chunk-MGNRNLBE.js +2 -0
- package/dist/chunk-MII3JOO3.js +4 -0
- package/dist/chunk-MNBGG4H3.js +16 -0
- package/dist/chunk-MYVKUJGS.js +2 -0
- package/dist/chunk-MYZHOBS4.js +2 -0
- package/dist/chunk-MZOIHUVX.js +27 -0
- package/dist/{chunk-7GAHJZLH.js → chunk-N3TCNZSX.js} +1 -1
- package/dist/chunk-NC7D7GOM.js +21 -0
- package/dist/{chunk-HAYV4D2I.js → chunk-NDEI7R4K.js} +1 -1
- package/dist/{chunk-BL3SJDCG.js → chunk-NFRA64NU.js} +1 -1
- package/dist/chunk-NLZZLANH.js +4 -0
- package/dist/{chunk-DWMESHFI.js → chunk-NQTYWHPB.js} +1 -1
- package/dist/chunk-NWBLYMH7.js +3 -0
- package/dist/chunk-NWD54VV5.js +2 -0
- package/dist/chunk-NXRF7FFS.js +2 -0
- package/dist/chunk-O3HHTKZ5.js +6 -0
- package/dist/{chunk-F7NSSQYZ.js → chunk-OAKYUBD3.js} +1 -1
- package/dist/{chunk-7WXMV3O3.js → chunk-OEWYXCTA.js} +1 -1
- package/dist/{chunk-4FHK4LKQ.js → chunk-OF7WPCTQ.js} +1 -1
- package/dist/chunk-OFSDB7B4.js +3 -0
- package/dist/chunk-OJ33Q6DU.js +2 -0
- package/dist/chunk-OQ5G773E.js +2 -0
- package/dist/chunk-OVNRRI4E.js +2 -0
- package/dist/{chunk-C6S2RPZA.js → chunk-OZNBTSW5.js} +1 -1
- package/dist/chunk-P2ZQDQDB.js +2 -0
- package/dist/chunk-P7MSVLAH.js +6 -0
- package/dist/chunk-PUVMC4PX.js +26 -0
- package/dist/{chunk-SEEEGDVK.js → chunk-PZA3BSOE.js} +1 -1
- package/dist/chunk-Q3C6NDGI.js +2 -0
- package/dist/chunk-QCKA665H.js +2 -0
- package/dist/chunk-QDFY5GGO.js +5 -0
- package/dist/{chunk-YBAVDT3G.js → chunk-QHRUBG7J.js} +1 -1
- package/dist/chunk-QI5RZ7LL.js +2 -0
- package/dist/chunk-QNLVC5ZB.js +2 -0
- package/dist/{chunk-WDMUPK6I.js → chunk-QQ4TKLWP.js} +1 -1
- package/dist/chunk-QS5ZJFGF.js +4 -0
- package/dist/chunk-QTZBVDPR.js +12 -0
- package/dist/chunk-QXQ7KVEN.js +2 -0
- package/dist/chunk-R4JUKTDO.js +2 -0
- package/dist/chunk-R7KXAISS.js +12 -0
- package/dist/chunk-RDP7GWSY.js +2 -0
- package/dist/chunk-REKHAN53.js +5 -0
- package/dist/{chunk-KWEOLPBJ.js → chunk-RFEON5GN.js} +1 -1
- package/dist/{chunk-SOCHN2PY.js → chunk-RFIIM33J.js} +1 -1
- package/dist/chunk-RG372DON.js +6 -0
- package/dist/chunk-RPRXRKKR.js +2 -0
- package/dist/chunk-RTVWQK7I.js +2 -0
- package/dist/{chunk-2PKME4VT.js → chunk-RW3Z2HMB.js} +4 -4
- package/dist/chunk-RX47NRSM.js +2 -0
- package/dist/chunk-RX6776AI.js +5 -0
- package/dist/chunk-S53AQU7R.js +6 -0
- package/dist/{chunk-XT7XA4DN.js → chunk-SA6IKFFD.js} +1 -1
- package/dist/{chunk-Q5CINJYL.js → chunk-SLKYD44Y.js} +1 -1
- package/dist/chunk-SMTBOSEJ.js +2 -0
- package/dist/chunk-SMXABALN.js +2 -0
- package/dist/chunk-SONMD3W5.js +5 -0
- package/dist/chunk-SWMTXMKB.js +2 -0
- package/dist/{chunk-TM7VRLWS.js → chunk-SXRHKXSE.js} +1 -1
- package/dist/chunk-T3HEJASG.js +5 -0
- package/dist/chunk-T4AVLJCW.js +6 -0
- package/dist/{chunk-6VY62QC2.js → chunk-T6K2MEWP.js} +1 -1
- package/dist/{chunk-PCKIANML.js → chunk-T7H4LBFK.js} +1 -1
- package/dist/chunk-TNORODUF.js +2 -0
- package/dist/chunk-TW63WWEN.js +2 -0
- package/dist/chunk-UALJTPSA.js +18 -0
- package/dist/chunk-UAWWLLTI.js +2 -0
- package/dist/chunk-UEE3RZN4.js +14 -0
- package/dist/chunk-UTM7D4PI.js +2 -0
- package/dist/chunk-UUJIGOEO.js +2 -0
- package/dist/chunk-UYDHOHSZ.js +2 -0
- package/dist/chunk-V5JGXOV7.js +2 -0
- package/dist/chunk-V7S6S5W3.js +2 -0
- package/dist/{chunk-OHOJSADN.js → chunk-VG44B5JD.js} +1 -1
- package/dist/chunk-VJGWVBZR.js +1 -0
- package/dist/chunk-VLDCHFXF.js +2 -0
- package/dist/chunk-VO66KP2W.js +2 -0
- package/dist/{chunk-J3BGYSMD.js → chunk-VQLH63X7.js} +8 -8
- package/dist/chunk-VRIZDOO5.js +2 -0
- package/dist/chunk-VYHT2IET.js +1397 -0
- package/dist/chunk-VZJ6LUXX.js +2 -0
- package/dist/chunk-W3OVSDBN.js +29 -0
- package/dist/chunk-W7FLXW6Q.js +5 -0
- package/dist/{chunk-UA2QDAWT.js → chunk-WEM3MOAL.js} +1 -1
- package/dist/chunk-WI7K6VKQ.js +2 -0
- package/dist/chunk-WMGKUERB.js +6 -0
- package/dist/{chunk-DFS4RMVP.js → chunk-WN5VKKJ3.js} +1 -1
- package/dist/chunk-WOSANGV6.js +5 -0
- package/dist/chunk-WYSZ6TPW.js +15 -0
- package/dist/chunk-XB6BJPDL.js +2 -0
- package/dist/{chunk-YWYORBY3.js → chunk-XBEYWXPV.js} +1 -1
- package/dist/chunk-XIPKSXRQ.js +16 -0
- package/dist/chunk-XJ7HCXKW.js +2 -0
- package/dist/chunk-XMPTFXPW.js +5 -0
- package/dist/chunk-XZYA7DNH.js +2 -0
- package/dist/chunk-Y4T4SLDO.js +2 -0
- package/dist/{chunk-OIUV3ISA.js → chunk-Y6Y6RAY4.js} +1 -1
- package/dist/chunk-YDPTSDIJ.js +2 -0
- package/dist/chunk-YDSGXB25.js +2 -0
- package/dist/chunk-YIKF4ERQ.js +375 -0
- package/dist/chunk-Z55KBMYV.js +2 -0
- package/dist/chunk-ZCRZFAOT.js +2 -0
- package/dist/chunk-ZFM77AQU.js +2 -0
- package/dist/{chunk-Q6F23V7L.js → chunk-ZFMRQ57Y.js} +1 -1
- package/dist/chunk-ZHWU6L2G.js +5 -0
- package/dist/chunk-ZTHYAHDN.js +17 -0
- package/dist/chunk-ZZP5SHUV.js +3 -0
- package/dist/committer-JGY66PFM.js +2 -0
- package/dist/config-5ZOALGKE.js +2 -0
- package/dist/controller-client-PB3AZAGG.js +2 -0
- package/dist/cover-cmd-UA2SVIZZ.js +2 -0
- package/dist/{credentials-QD32Y7K7.js → credentials-MRG452Y6.js} +1 -1
- package/dist/{deps-bundle-OI7JJ22L.js → deps-bundle-FWINW4XM.js} +1 -1
- package/dist/{deps-resolve-ZOALDS6H.js → deps-resolve-IET4KIBO.js} +1 -1
- package/dist/descriptor-7T32VRMB.js +2 -0
- package/dist/design-chat-MM5PJD2N.js +2 -0
- package/dist/design-committer-TRYP3LOZ.js +2 -0
- package/dist/design-headless-FZONCKHW.js +2 -0
- package/dist/design-remote-SPVRIY2H.js +3 -0
- package/dist/device-env-LXJ65AVF.js +2 -0
- package/dist/dispatch-DVQ3H7EJ.js +2 -0
- package/dist/doctor-VAX2BWQF.js +2 -0
- package/dist/docx-convert-6IZO5P5K.js +2 -0
- package/dist/{dossier-7HVC6BNK.js → dossier-NROC2MCY.js} +1 -1
- package/dist/evidence-LVVK7ROT.js +2 -0
- package/dist/evidence-presentation-YYTIDCBS.js +2 -0
- package/dist/evolve-cmd-AGRKG7T3.js +2 -0
- package/dist/evolve-remote-BGHULJTL.js +2 -0
- package/dist/{exit-manager-ZLDO54S4.js → exit-manager-EDHCETUN.js} +1 -1
- package/dist/explain-DGJ5T6V5.js +2 -0
- package/dist/explain-cmd-VYAANFFZ.js +4 -0
- package/dist/explain-cmd-WOBGS6KX.js +12 -0
- package/dist/explore-LOKNOVNP.js +2 -0
- package/dist/explore-context-tty-JTZVZFOE.js +2 -0
- package/dist/explore-entry-5OGNLFAU.js +6 -0
- package/dist/explore-live-2XZHUYFS.js +5 -0
- package/dist/explore-run-tty-LGTIK2NA.js +5 -0
- package/dist/extract-bind-NM2BBK4I.js +14 -0
- package/dist/extract-chat-HLQMJJIC.js +2 -0
- package/dist/extract-cmd-T2TSAC3N.js +6 -0
- package/dist/extract-headless-OQTQ3FJK.js +2 -0
- package/dist/feeder-NY45UFJK.js +2 -0
- package/dist/folder-flags-WXUR6OPJ.js +2 -0
- package/dist/gaps-cmd-PTSKPTF7.js +3 -0
- package/dist/gate-P57VP4E5.js +2 -0
- package/dist/gate-WISOUTHQ.js +2 -0
- package/dist/{generate-headless-6WMJYNI6.js → generate-headless-JYZP6VXZ.js} +3 -3
- package/dist/headless-io-FFM5T6KL.js +2 -0
- package/dist/hold-passthrough-IOWPVB4W.js +2 -0
- package/dist/identity-HL5CJJXR.js +2 -0
- package/dist/index.js +178 -160
- package/dist/ingest-PDGS5ZTL.js +2 -0
- package/dist/ingest-cmd-LHCBMO4Z.js +8 -0
- package/dist/ingest-remote-D5TO5JQP.js +2 -0
- package/dist/ink-screen-RZ7QDIUI.js +2 -0
- package/dist/install-Z6K2D2VY.js +2 -0
- package/dist/interactive-bind-5EJQUGKI.js +26 -0
- package/dist/interactive-remote-D77ULJGL.js +65 -0
- package/dist/interrupt-guard-QETBPINI.js +2 -0
- package/dist/lane-AQYRIW24.js +2 -0
- package/dist/lattice-auth-74XGF77Y.js +2 -0
- package/dist/lifecycle-cmd-7SM6UCMH.js +2 -0
- package/dist/list-cmd-Z6FZXMFU.js +3 -0
- package/dist/list-commands-CZYZ7GIG.js +2 -0
- package/dist/list-remote-WOPOC6KK.js +15 -0
- package/dist/locks-cmd-JJ2QNTNY.js +2 -0
- package/dist/logical-ids-RXAQJZ3T.js +2 -0
- package/dist/login-flow-2FZEOVHM.js +2 -0
- package/dist/maintenance-cmd-VRTGZVRE.js +2 -0
- package/dist/mobile-prompts-KNAHU64X.js +2 -0
- package/dist/{next-KZXH4UA4.js → next-O6SUSX3R.js} +1 -1
- package/dist/{objective-variable-gate-CG2KK5UX.js → objective-variable-gate-3Z7DNVVC.js} +1 -1
- package/dist/onboarding-LGT6PMDZ.js +5 -0
- package/dist/open-provider-OZAG6WZS.js +2 -0
- package/dist/{paths-JCYX6UWL.js → paths-UMIX3RJF.js} +1 -1
- package/dist/pdf-convert-447ACUB3.js +2 -0
- package/dist/persist-recorded-session-BX7II5P7.js +3 -0
- package/dist/phase-seed-LCJ4WSYV.js +2 -0
- package/dist/pipeline-IXVTVRS5.js +2 -0
- package/dist/prepare-target-ULMKVKMC.js +2 -0
- package/dist/pull-cmd-6AL2WYHB.js +2 -0
- package/dist/pull-route-TTVARJMV.js +2 -0
- package/dist/readmodel-INMP6MNW.js +2 -0
- package/dist/real-device-run-2LFS5WE2.js +2 -0
- package/dist/reconcile-cmd-R6H37SQR.js +5 -0
- package/dist/reconcile-deps-TWJ3FTSU.js +2 -0
- package/dist/reconcile-remote-GWDV5CUT.js +13 -0
- package/dist/recording-banner-ACC67Q2U.js +2 -0
- package/dist/registry-6IJYQXQC.js +2 -0
- package/dist/remote-entry-YL7O2NJQ.js +2 -0
- package/dist/remote-mode-7G6PLJCW.js +4 -0
- package/dist/remote-words-45USLRVN.js +2 -0
- package/dist/require-project-folder-A3UDRELU.js +2 -0
- package/dist/resolve-run-intent-ZGPSUBXV.js +2 -0
- package/dist/resolver-IPM6R7U4.js +2 -0
- package/dist/revert-FHOBLZWF.js +2 -0
- package/dist/review-cmd-NNT5C5RZ.js +5 -0
- package/dist/run-5RQUCNYP.js +2 -0
- package/dist/run-PC5YO4AS.js +2 -0
- package/dist/run-channel-63SVP5OI.js +2 -0
- package/dist/run-remote-3AYYVPKX.js +2 -0
- package/dist/run-startup-gate-NKRMKYBB.js +2 -0
- package/dist/run-test-md-HE6DUWQR.js +17 -0
- package/dist/scrollback-GGNBDFQV.js +2 -0
- package/dist/session-target-DD53UXO7.js +2 -0
- package/dist/session-worker.js +12 -0
- package/dist/sessions-CFV7FOIT.js +2 -0
- package/dist/sessions-cmd-GYMETJHG.js +26 -0
- package/dist/sessions-remote-GI7GOBMH.js +3 -0
- package/dist/shell-arg-FN3MT5U7.js +2 -0
- package/dist/{skill-installer-32YYMM4N.js → skill-installer-3QAVQGDH.js} +1 -1
- package/dist/spawner-C7NLLM4F.js +2 -0
- package/dist/store-X6XPFSKF.js +2 -0
- package/dist/store-choice-RT73HAI7.js +2 -0
- package/dist/store-guard-SNWKLHQV.js +2 -0
- package/dist/store-id-YZ5WKJ25.js +2 -0
- package/dist/store-site-KA2DNBGY.js +2 -0
- package/dist/stream-warnings-GEQKKJU7.js +2 -0
- package/dist/structured-answers-EQ2AP3F7.js +2 -0
- package/dist/sync-cmd-NBPPDG3B.js +2 -0
- package/dist/sync-setup-5NUCH6N3.js +2 -0
- package/dist/{sync-setup-ui-RC727VK6.js → sync-setup-ui-XITPGSO4.js} +2 -2
- package/dist/tcg-generate-Z23CUISY.js +2 -0
- package/dist/test-definition-VRI4YIYL.js +2 -0
- package/dist/testmd-actions-GH5BW5V5.js +2 -0
- package/dist/testmd-sync-ACKCIOL3.js +2 -0
- package/dist/tms-client-NXAB6VJD.js +2 -0
- package/dist/token-refresh-4UCYAG6A.js +2 -0
- package/dist/trust-gate-AT2XBWN4.js +2 -0
- package/dist/turn-preflight-LHYLRL7G.js +2 -0
- package/dist/ui-SNV3FD2G.js +4 -0
- package/dist/use-case-ref-NE4X4MZN.js +2 -0
- package/dist/validate-basic-RE2WLIGQ.js +2 -0
- package/dist/{variable-receipt-YWNS24TH.js → variable-receipt-BXSZO36E.js} +1 -1
- package/dist/verdicts-XK3GAUX3.js +2 -0
- package/dist/version-check-4FJVZP3K.js +2 -0
- package/dist/{view-cmd-3WHG6MVB.js → view-cmd-N47BQZPD.js} +4 -3
- package/dist/walk-session-DA7QWXSW.js +2 -0
- package/dist/with-telemetry-7V4LY2BG.js +2 -0
- package/package.json +11 -11
- package/dist/ChatSurface-FJPK3XEJ.js +0 -8
- package/dist/ChromeProfilePicker-7DUDJTE2.js +0 -2
- package/dist/CliFeedbackPrompt-ZZPYC6OS.js +0 -2
- package/dist/CliUploadProgress-WQYKIBAR.js +0 -2
- package/dist/ConfigView-KXNOODDW.js +0 -2
- package/dist/EvidenceViewOffer-BTBVPBZX.js +0 -2
- package/dist/FolderPicker-H4YEX5LV.js +0 -2
- package/dist/InfoBox-DTM7X24Z.js +0 -2
- package/dist/LinksBox-KFG3FVOT.js +0 -2
- package/dist/ProfilesView-KBZHT4KL.js +0 -2
- package/dist/ProjectPicker-OARWULNN.js +0 -2
- package/dist/SaveSessionPrompt-37SMU5MC.js +0 -2
- package/dist/ScrollbackTap-QHJOFYMC.js +0 -2
- package/dist/SingleShotApp-UYCAW65Y.js +0 -2
- package/dist/SummaryBox-6RB5DSAH.js +0 -2
- package/dist/TestMdRunView-ZMOII3PL.js +0 -2
- package/dist/TestrunEvidenceTable-3UP2EYIV.js +0 -2
- package/dist/WhoamiView-MC62GERR.js +0 -2
- package/dist/app-client-PQFJAB63.js +0 -2
- package/dist/app-download-P6YXWSVQ.js +0 -2
- package/dist/auth-LXW4OFKF.js +0 -2
- package/dist/bind-ZYESQSCJ.js +0 -15
- package/dist/bootstrap-DI4UGMH3.js +0 -2
- package/dist/bridge-7J3JE3JS.js +0 -2
- package/dist/build-JIKYOZUH.js +0 -2
- package/dist/catalog-LLME3744.js +0 -2
- package/dist/chat-committer-6D7AQI6Z.js +0 -2
- package/dist/chat-controller-UJQ6Z4RE.js +0 -2
- package/dist/chunk-243ZJHT6.js +0 -4
- package/dist/chunk-2KVECC36.js +0 -2
- package/dist/chunk-2YEHV2CX.js +0 -2
- package/dist/chunk-3MCPTVJX.js +0 -2
- package/dist/chunk-3UI5VTQS.js +0 -4
- package/dist/chunk-3VAU3PNU.js +0 -2
- package/dist/chunk-3YIZG7WZ.js +0 -3
- package/dist/chunk-4Y2WH77W.js +0 -2
- package/dist/chunk-5EOX4MEY.js +0 -2
- package/dist/chunk-5HMN74RZ.js +0 -9
- package/dist/chunk-5LJRZI7S.js +0 -6
- package/dist/chunk-5RCS2LIQ.js +0 -26
- package/dist/chunk-5TQFOPJV.js +0 -2
- package/dist/chunk-5ZFOKYFB.js +0 -5
- package/dist/chunk-63DYVWNX.js +0 -2
- package/dist/chunk-6MD7SR7D.js +0 -9
- package/dist/chunk-7N6OCHPC.js +0 -7
- package/dist/chunk-A2SQD2AY.js +0 -4
- package/dist/chunk-AACQE24F.js +0 -2
- package/dist/chunk-AHFIRHSP.js +0 -18
- package/dist/chunk-AJT34ESA.js +0 -38
- package/dist/chunk-AUMJ4RVA.js +0 -21
- package/dist/chunk-AXTPNZPX.js +0 -2
- package/dist/chunk-BB2W35TW.js +0 -2
- package/dist/chunk-BKM2LWU2.js +0 -3
- package/dist/chunk-BUPRL2TE.js +0 -2
- package/dist/chunk-C44QQJR4.js +0 -239
- package/dist/chunk-CW3RHKLA.js +0 -5
- package/dist/chunk-D6E6KRVX.js +0 -2
- package/dist/chunk-DTRKTBCE.js +0 -17
- package/dist/chunk-DTRSYWZE.js +0 -2
- package/dist/chunk-EVFFDODK.js +0 -5
- package/dist/chunk-F2OBORCG.js +0 -2
- package/dist/chunk-FQNQVC5O.js +0 -5
- package/dist/chunk-FY7TCYPK.js +0 -6
- package/dist/chunk-GTVQYT3D.js +0 -35
- package/dist/chunk-HG5LLZBU.js +0 -2
- package/dist/chunk-I7TIGB7K.js +0 -2
- package/dist/chunk-IICT4VOU.js +0 -2
- package/dist/chunk-ILDHE4P4.js +0 -6
- package/dist/chunk-IPXKUYUK.js +0 -2
- package/dist/chunk-JQY5HRZ4.js +0 -15
- package/dist/chunk-JX6BFEDO.js +0 -4
- package/dist/chunk-K2UJYY2U.js +0 -2
- package/dist/chunk-KBM3XHAM.js +0 -2
- package/dist/chunk-KDNNMU7Q.js +0 -4
- package/dist/chunk-KJQNAOOE.js +0 -6
- package/dist/chunk-LH4IPANP.js +0 -2
- package/dist/chunk-LLG7NEGX.js +0 -6
- package/dist/chunk-LSDWPG6C.js +0 -2
- package/dist/chunk-MSGW4JDG.js +0 -2
- package/dist/chunk-NJ4BXZBX.js +0 -2
- package/dist/chunk-NLCCBXXV.js +0 -2
- package/dist/chunk-NMSZ7G6P.js +0 -2
- package/dist/chunk-OC6H6BYI.js +0 -6
- package/dist/chunk-OJAXOOZ5.js +0 -8
- package/dist/chunk-OMNLAGQC.js +0 -29
- package/dist/chunk-OOCCUUR2.js +0 -2
- package/dist/chunk-OXC6O5O7.js +0 -2
- package/dist/chunk-OZQDD2EX.js +0 -94
- package/dist/chunk-PEDINHVU.js +0 -2
- package/dist/chunk-PNUAP3RY.js +0 -8
- package/dist/chunk-Q2F5QB2W.js +0 -2
- package/dist/chunk-Q4YYAN6E.js +0 -2
- package/dist/chunk-Q6AHSGOE.js +0 -5
- package/dist/chunk-QAB3Y5FQ.js +0 -4
- package/dist/chunk-RDHWNSDP.js +0 -7
- package/dist/chunk-RKXHVP2Z.js +0 -2
- package/dist/chunk-RRY5IXOB.js +0 -2
- package/dist/chunk-RSSOJ3L2.js +0 -21
- package/dist/chunk-RTSBKCZY.js +0 -16
- package/dist/chunk-SID4X77D.js +0 -370
- package/dist/chunk-SRTKRHYI.js +0 -12
- package/dist/chunk-T2ONUKTL.js +0 -5
- package/dist/chunk-U6OTFMIT.js +0 -4
- package/dist/chunk-UD7KKHPW.js +0 -5
- package/dist/chunk-USOYXCZ4.js +0 -2
- package/dist/chunk-USY7VAO6.js +0 -2
- package/dist/chunk-V4B5QA3U.js +0 -4
- package/dist/chunk-VBS33P2C.js +0 -2
- package/dist/chunk-VHW7BMZQ.js +0 -2
- package/dist/chunk-VIO7CCFW.js +0 -5
- package/dist/chunk-VORWZLS3.js +0 -9
- package/dist/chunk-VVOKM2VO.js +0 -2
- package/dist/chunk-W5TTF7GB.js +0 -6
- package/dist/chunk-WESMQEPO.js +0 -2
- package/dist/chunk-WMI4P76K.js +0 -27
- package/dist/chunk-WNOC6MQC.js +0 -2
- package/dist/chunk-WVHMPIDQ.js +0 -2
- package/dist/chunk-XBX643ZD.js +0 -2
- package/dist/chunk-XKHWWKJZ.js +0 -3
- package/dist/chunk-XLSOQLVT.js +0 -2
- package/dist/chunk-Y3ZYN6AK.js +0 -4
- package/dist/chunk-YCCUBQY4.js +0 -2
- package/dist/chunk-YKTYVJBN.js +0 -3
- package/dist/chunk-YLQHY4A7.js +0 -2
- package/dist/chunk-Z7IGTVJW.js +0 -2
- package/dist/chunk-ZC2CKWLB.js +0 -2
- package/dist/chunk-ZER3FZSZ.js +0 -22
- package/dist/chunk-ZJYT72BA.js +0 -9
- package/dist/chunk-ZKSN2SJ7.js +0 -2
- package/dist/chunk-ZLWURCJ7.js +0 -2
- package/dist/committer-2QPBANRD.js +0 -2
- package/dist/config-YGTHSGQN.js +0 -2
- package/dist/controller-client-ZF5IXRUV.js +0 -2
- package/dist/cover-cmd-6RO366CC.js +0 -3
- package/dist/descriptor-3JJUOHBM.js +0 -2
- package/dist/design-committer-D44GSUXY.js +0 -2
- package/dist/device-env-DXDJJMTL.js +0 -2
- package/dist/dispatch-7EWWQRQ5.js +0 -2
- package/dist/doctor-TPYPEEUL.js +0 -2
- package/dist/docx-convert-SQRTF7XS.js +0 -2
- package/dist/evidence-NPFTBGDF.js +0 -2
- package/dist/evidence-presentation-XF23B7F2.js +0 -2
- package/dist/evolve-cmd-VGVXV6XW.js +0 -2
- package/dist/explain-NEFBUX5G.js +0 -2
- package/dist/explain-cmd-GOP5TE63.js +0 -9
- package/dist/explain-cmd-M7IX2YNB.js +0 -3
- package/dist/extract-bind-CKIRLXAJ.js +0 -14
- package/dist/extract-cmd-3EWLSPGS.js +0 -5
- package/dist/feeder-66TUPB2R.js +0 -2
- package/dist/gaps-cmd-WVC5GXQC.js +0 -3
- package/dist/gate-OYRDJMF6.js +0 -2
- package/dist/headless-io-75HUMWZB.js +0 -2
- package/dist/identity-ADZ4PAJF.js +0 -2
- package/dist/ingest-OSNNM3DH.js +0 -2
- package/dist/ingest-cmd-AECK5T4H.js +0 -2
- package/dist/install-ZV3KJZV4.js +0 -2
- package/dist/interactive-bind-IYS6KDOH.js +0 -26
- package/dist/interrupt-guard-UREUWNRL.js +0 -2
- package/dist/lifecycle-cmd-XCSBELFQ.js +0 -2
- package/dist/list-cmd-S4DSN2ET.js +0 -3
- package/dist/list-commands-GLNGHPDU.js +0 -2
- package/dist/locks-cmd-67OHQZNV.js +0 -2
- package/dist/logical-ids-GLVM2SVR.js +0 -2
- package/dist/login-flow-ASUUU7SO.js +0 -2
- package/dist/maintenance-cmd-K5KXRIFL.js +0 -2
- package/dist/mobile-prompts-ZUZTA3RV.js +0 -2
- package/dist/open-provider-YIBB77FE.js +0 -2
- package/dist/pdf-convert-RLXSXFWN.js +0 -2
- package/dist/persist-recorded-session-EWV56TSZ.js +0 -3
- package/dist/phase-seed-MKHEWUN6.js +0 -2
- package/dist/pipeline-LAWACB2O.js +0 -2
- package/dist/prepare-target-WGPCZKLE.js +0 -2
- package/dist/readmodel-FVLRQWZ7.js +0 -2
- package/dist/real-device-run-MDLFKFVQ.js +0 -2
- package/dist/reconcile-cmd-XFM2ZXUJ.js +0 -2
- package/dist/reconcile-deps-V5VLDPYT.js +0 -4
- package/dist/reconcile-engine-VZBTMPUK.js +0 -2
- package/dist/recording-banner-CJHRPHHF.js +0 -2
- package/dist/records-LMCVKPE5.js +0 -2
- package/dist/registry-3JXQFZEG.js +0 -2
- package/dist/require-project-folder-SE5GVCYJ.js +0 -2
- package/dist/resolve-run-intent-DD4MB6UD.js +0 -2
- package/dist/resolver-TLO4SRWV.js +0 -2
- package/dist/revert-NOUECRW4.js +0 -2
- package/dist/review-cmd-7EOYQMPE.js +0 -5
- package/dist/run-EHUNJPW6.js +0 -2
- package/dist/run-OTMPUQSH.js +0 -2
- package/dist/run-channel-RGH4WIQX.js +0 -2
- package/dist/run-test-md-KBDEHGXJ.js +0 -17
- package/dist/scrollback-JLPJR25X.js +0 -2
- package/dist/session-items-2ATN7VXG.js +0 -2
- package/dist/session-target-UMNASXI7.js +0 -2
- package/dist/sessions-NH7WQWMX.js +0 -2
- package/dist/sessions-cmd-M3SECFKQ.js +0 -25
- package/dist/spawner-DPT2RLAO.js +0 -2
- package/dist/store-guard-U32JE6JJ.js +0 -2
- package/dist/store-id-EOSGEKVK.js +0 -2
- package/dist/structured-answers-ZI2B6JJE.js +0 -2
- package/dist/sync-cmd-3EP7LZGL.js +0 -2
- package/dist/sync-setup-SWTBVQEV.js +0 -2
- package/dist/tcg-generate-KXU7E2GF.js +0 -2
- package/dist/testmd-actions-PEWCPQ5R.js +0 -2
- package/dist/testmd-sync-ZWFQWZ2X.js +0 -2
- package/dist/tms-client-KU6HCA23.js +0 -2
- package/dist/token-refresh-QD3OCGJJ.js +0 -2
- package/dist/trust-gate-EX7R2P4Y.js +0 -2
- package/dist/turn-preflight-JGYT7LXP.js +0 -2
- package/dist/ui-JEJGTURD.js +0 -4
- package/dist/validate-basic-AAIXSAWH.js +0 -2
- package/dist/verdicts-LAB5BGCC.js +0 -2
- package/dist/version-check-EHOLX3YH.js +0 -2
- package/dist/walk-session-XP4KYFKO.js +0 -2
- package/dist/with-telemetry-FJMJQDCM.js +0 -2
- /package/dist/{chunk-BKHXPBWN.js → chunk-2RUSXQ3O.js} +0 -0
- /package/dist/{chunk-6J5T5FEY.js → chunk-3AGP2BVN.js} +0 -0
- /package/dist/{chunk-CH273NAE.js → chunk-73Y6T2UK.js} +0 -0
- /package/dist/{chunk-ZMNJBUAO.js → chunk-73ZFOJOK.js} +0 -0
- /package/dist/{chunk-NOL7MNZH.js → chunk-A7RJQJNT.js} +0 -0
- /package/dist/{chunk-N2P4MI32.js → chunk-FWGUISUG.js} +0 -0
- /package/dist/{chunk-UJZZDPDY.js → chunk-HD6NR44L.js} +0 -0
- /package/dist/{chunk-LDPLJFCV.js → chunk-I6S6DZ2E.js} +0 -0
- /package/dist/{chunk-427OQS2N.js → chunk-LD5B3QFW.js} +0 -0
- /package/dist/{chunk-2UIHS2FH.js → chunk-PGESS7BW.js} +0 -0
- /package/dist/{chunk-BZAGVBCX.js → chunk-ZCIWQHCO.js} +0 -0
package/dist/chunk-CW3RHKLA.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{b as o,d as a}from"./chunk-T2ONUKTL.js";import{t as c}from"./chunk-RDHWNSDP.js";import{a as m,b as d}from"./chunk-3YIZG7WZ.js";import{resolve as l}from"path";async function u(n,w,t={}){let r=d({verb:n,mode:"cli",contextRoot:l(process.cwd(),".context"),env:m(),write:t.write}),s=()=>{o(t.mode??"")!=="ndjson"&&process.stderr.write(r.supportFooter()+`
|
|
3
|
-
`)};try{let e=await w(r);return t.write&&e===0&&await r.lateBindContext(l(process.cwd(),".context")),e===1&&s(),await r.end({exit_code:e}),e}catch(e){if(e instanceof c){if(o(t.mode??"")==="ndjson"){let i=a("ndjson",t.streamVerb??n,{stdout:y=>process.stdout.write(y),stderr:()=>{}});i.event({type:"sync_error",code:e.code,detail:e.message,remedy:e.remedy}),i.done(2,"refused")}else process.stderr.write(`error: ${e.message}
|
|
4
|
-
next: ${e.remedy}
|
|
5
|
-
`);return r.error("rebase_open"),await r.end({exit_code:2}),2}throw r.error("cli_crash"),s(),await r.end({exit_code:1}),e}}export{u as a};
|
package/dist/chunk-D6E6KRVX.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{i as a}from"./chunk-XLSOQLVT.js";function l(e,r,i,c){let n=a(r.type)?.cardinality;if(n!=="one-live-per-src"&&n!=="one-live-per-src-and-dst")return null;let o=t=>i.freed?.has(t)??!1,d=e.edgesFrom(r.src).find(t=>t.type===r.type&&!i.retracted.has(t.ecid)&&!e.superseded.has(t.dst)&&!o(t.dst))??i.pending.find(t=>t.type===r.type&&t.src===r.src);if(d){let t="ecid"in d?` (${d.ecid})`:" in this record";return{code:"CARDINALITY_VIOLATION",detail:`${c}: ${r.type} from ${r.src} already has a live edge${t} \u2014 supersede or retract it first`}}if(n==="one-live-per-src-and-dst"){let t=e.edgesInto(r.dst).find(s=>s.type===r.type&&s.src!==r.src&&!i.retracted.has(s.ecid)&&!e.superseded.has(s.src)&&!o(s.src))??i.pending.find(s=>s.type===r.type&&s.dst===r.dst&&s.src!==r.src);if(t){let s="ecid"in t?` (${t.ecid})`:" in this record";return{code:"CARDINALITY_VIOLATION",detail:`${c}: ${r.type} onto ${r.dst} already has a live edge${s} \u2014 strict 1:1, supersede or retract it first`}}}return null}export{l as a};
|
package/dist/chunk-DTRKTBCE.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as J,b as F}from"./chunk-2UIHS2FH.js";import{a as we}from"./chunk-YKTYVJBN.js";import{b as he,c as ye,d as be,e as Ee,f as _e,p as T}from"./chunk-7N6OCHPC.js";import{a as M}from"./chunk-N2P4MI32.js";import{b as B,d as W}from"./chunk-VVOKM2VO.js";import{z as j}from"./chunk-IICT4VOU.js";import{g as N}from"./chunk-RDHWNSDP.js";import{x as ge}from"./chunk-5TQFOPJV.js";var A="https://integrations.lambdatest.com",E=class extends Error{constructor(e,r){super(r);this.code=e;this.name="LisError"}};function ft(t){let n=t.TESTMUAI_ENV==="stage"?"stage":"prod";return`${ge[n].shareApiBaseUrl}/lis/api/v1`}function gt(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 k(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 ht(t,n,e="the issue"){return t===401||t===403?new E("LIS_AUTH","credentials rejected \u2014 run `kane-cli login` and retry"):t>=500?new E("LIS_UNAVAILABLE",`the integrations service returned an error (HTTP ${t}) \u2014 retry later`):new E("JIRA_ISSUE_UNAVAILABLE",`could not fetch ${e}: ${k(n)||`HTTP ${t}`}`)}function C(t){try{return JSON.parse(t.bytes.toString("utf8"))}catch{throw new E("LIS_UNAVAILABLE","the integrations service returned a malformed response \u2014 retry later")}}function ce(t){try{return JSON.parse(t.bytes.toString("utf8"))}catch{return{}}}function Le(t){return ce(t).code}function S(t,n="the issue",e="Atlassian"){let r=ce(t),s=e==="Atlassian"?"Confluence":e;switch(r.code){case"TOKEN_EXPIRED":return new E("LIS_SETUP",`your ${e} connection needs a resync \u2014 reconnect at ${A} and retry`);case"NOT_INSTALLED":return new E("LIS_SETUP",`no ${e} connection for this account \u2014 create one at ${A} and retry`);case"SCOPE_MISSING":return new E("LIS_SETUP",`the connection has no ${s} access \u2014 reconnect with ${s} at ${A} and retry`);case"FORBIDDEN":return new E("LIS_FORBIDDEN",`you don't have access to ${n}`);case"NOT_FOUND":return new E("JIRA_ISSUE_UNAVAILABLE",`could not fetch ${n}: ${k(r.message??"")||"not found"}`);case"PAYLOAD_TOO_LARGE":return new E("ATTACHMENT_TOO_LARGE","the attachment exceeds the integrations service's size cap");case"INVALID_PAYLOAD":return new E("LIS_UNAVAILABLE",`the integrations service rejected the request (${k(r.message??"")||"invalid payload"}) \u2014 retry later`);case"NOT_SUPPORTED":return new E("LIS_UNAVAILABLE","the integrations service does not support this operation yet");case"UPSTREAM_ERROR":case"UPSTREAM_TIMEOUT":return new E("LIS_UNAVAILABLE",`${e} is not responding through the integrations service \u2014 retry later`);default:return ht(t.status,r.message??"",n)}}var yt=3e4,bt=5;async function $(t,n,e){let r=e.env??process.env,s=e.fetchImpl??fetch;for(let o=0;;o++){let l=new AbortController,u=setTimeout(()=>l.abort(),yt);try{let i=await s(`${ft(r)}${t}`,{...n,headers:{"content-type":"application/json",...gt(e),...n.headers??{}},signal:l.signal}),c=await Promise.race([i.arrayBuffer(),new Promise((d,p)=>{l.signal.addEventListener("abort",()=>p(new DOMException("aborted","AbortError")),{once:!0})})]),a={status:i.status,ok:i.ok,headers:i.headers,bytes:Buffer.from(c)};if(a.status===429){if(o>0)throw new E("LIS_RATE_LIMITED","the integrations service is busy \u2014 try again in a moment");let d=ce(a).data?.retry_after_sec,p=Math.min(Math.max(typeof d=="number"&&Number.isFinite(d)?d:1,0),bt);clearTimeout(u),await new Promise(b=>setTimeout(b,p*1e3));continue}return a}catch(i){throw i instanceof E?i:l.signal.aborted?new E("LIS_UNAVAILABLE","the integrations service did not respond within 30 seconds \u2014 retry later"):new E("LIS_UNAVAILABLE",`could not reach the integrations service (${k(i instanceof Error?i.message:String(i))}) \u2014 check your connection and retry`)}finally{clearTimeout(u)}}}function V(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 H(t={}){let n=await $("/jira/info",{method:"GET"},t);if(!n.ok)throw S(n);let e=C(n),r=(e.data?.SELECTED_PROJECTS??[]).map(s=>s?.key).filter(s=>typeof s=="string"&&s.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 z(t,n={}){let e=await $("/jira/issue?details=true",{method:"POST",body:JSON.stringify({plugin_code:"jira",issueKey:t})},n);if(!e.ok)throw S(e);let r=C(e);if(r.type==="error"||!r.data)throw new E("JIRA_ISSUE_UNAVAILABLE",`could not fetch the issue: ${k(r.message??"")||"issue not found or not accessible"}`);return r.data}var Ie=100,Et=5e3,_t=60;async function X(t,n={}){let e=[],r=new Set,s=null,o=0;for(let l=0;;l++){if(l>=_t)throw new E("LIS_UNAVAILABLE","the integrations service kept returning comment pages without finishing \u2014 retry later");let u=await $("/jira/issue/comments",{method:"POST",body:JSON.stringify({resource_id:t,max_results:Ie,cursor:s,start_at:o,order_by:"created",fetch_all:!1})},n);if(!u.ok)throw S(u,"the issue's comments");let i=C(u);if(i.type==="error"||!i.data)throw new E("JIRA_ISSUE_UNAVAILABLE",`could not fetch the issue's comments: ${k(i.message??"")||"unavailable"}`);for(let w of i.data.comments??[]){let g=String(w.id);r.has(g)||(r.add(g),e.push(w))}let c=i.data.pagination;if(!c?.has_more)return e;if(e.length>=Et)throw new E("JIRA_ISSUE_UNAVAILABLE","the issue has more comments than can be ingested \u2014 cannot build a complete identity");let a=c.next_cursor??null,d=c.next_start_at!=null,p=d?c.next_start_at:o+Ie;if(!(a!=null&&a!==s||a==null&&d&&p!==o))throw new E("LIS_UNAVAILABLE","the integrations service returned a non-advancing comments page \u2014 retry later");s=a,o=p}}async function Z(t,n={}){let e=await $("/jira/attachment",{method:"POST",body:JSON.stringify({attachment_id:t})},n);if(!e.ok){if(Le(e)===void 0){if(e.status===413)throw new E("ATTACHMENT_TOO_LARGE","the attachment exceeds the integrations service's size cap");if(e.status===404)throw new E("JIRA_NOT_CONNECTED",`Jira is not connected for this account \u2014 connect it at ${A} and retry`)}throw S(e,`attachment ${t}`)}return V(e)}var q="kane.source.jira/2";function Ae(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(Ae).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 ve(t,n,e){let r=[],s={},o=t.additional_fields??{};for(let a of Object.keys(o).sort()){let d=Ae(o[a]);if(d===null){r.push(`field "${a}" has no stable text form \u2014 dropped from the envelope`);continue}s[a]=d}let l=[...t.attachments??[]].map(a=>({id:String(a.id),filename:a.filename??"",media_type:a.mime_type??"application/octet-stream",size:a.size??0})).sort((a,d)=>{let p=Number(a.id),b=Number(d.id);return Number.isFinite(p)&&Number.isFinite(b)?p-b:a.id<d.id?-1:a.id>d.id?1:0}),u=e.map(a=>({id:String(a.id),author:a.author?.display_name??"",body:a.body??"",created:a.created??""})).sort((a,d)=>{if(a.created!==d.created)return a.created<d.created?-1:1;let p=Number(a.id),b=Number(d.id);return Number.isFinite(p)&&Number.isFinite(b)&&p!==b?p-b:a.id<d.id?-1:a.id>d.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:q,site:n,project:i.slice(0,i.lastIndexOf("-")),issue:{id:t.id,key:i},content:{summary:t.summary??"",description:t.description??"",fields:s},attachments:l,comments:u};return{bytes:Buffer.from(JSON.stringify(c),"utf8"),envelope:c,warnings:r}}var Se=64,wt=16,Lt=6e6,It=5e7,At=12e6,vt={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"},St=new Set(["png","jpeg","webp"]);function $e(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!==q)throw new Error(`JIRA_ENVELOPE_SCHEMA: unknown envelope schema "${e.schema}" \u2014 this CLI understands ${q}`);let r=[],s=new Map,o=[],l=0,u=new Map,i=[];for(let d=0;d<e.attachments.length;d++){let p=e.attachments[d],b=`i${d+1}`,w=`attachment:${p.filename}`,g=v=>`[img#${b}] ${p.filename} (${p.media_type}, ${p.size} bytes${v?"":" \u2014 not delivered"})`,h=(v,R,x)=>{r.push({ref:b,loc:w,media_type:v,...x?.blob?{blob:x.blob}:{},...x?.appearance?{appearance:x.appearance}:{},delivery:R,...x?.duplicate_of?{duplicate_of:x.duplicate_of}:{}})};if(!p.media_type.startsWith("image/")){h(p.media_type,"unsupported-vision-media-type"),i.push(g(!1));continue}let _;try{_=await t.fetchAttachment(p.id)}catch{h(p.media_type,"external-image-not-fetched"),i.push(g(!1));continue}let y=_.bytes,m=J(y),f=vt[m.format],I=B(y);if(s.set(I,y),!St.has(m.format)){let v=m.format==="gif"||m.format==="bmp"||m.format==="tiff"?"unsupported-vision-media-type":"unsupported-image-kind";h(f,v,{blob:I}),i.push(g(!1));continue}if(m.width===void 0||m.height===void 0||m.width*m.height>It){h(f,"undecodable",{blob:I}),i.push(g(!1));continue}let L;if(m.format==="png"||m.format==="jpeg"){let v=F(y,m.format);if(v===null){h(f,"undecodable",{blob:I}),i.push(g(!1));continue}L=M(v.data,{width:v.width,height:v.height,channels:v.channels})}if(m.width<Se||m.height<Se){h(f,"below-dimension-floor",{blob:I,appearance:L}),i.push(g(!1));continue}let O=u.get(I);if(O!==void 0){h(f,"duplicate",{blob:I,appearance:L,duplicate_of:O}),i.push(g(!1));continue}if(y.byteLength>Lt){h(f,"image-too-large",{blob:I,appearance:L}),i.push(g(!1));continue}if(l+y.byteLength>At){h(f,"vision-byte-budget-reached",{blob:I,appearance:L}),i.push(g(!1));continue}if(o.length>=wt){h(f,"image-cap-reached",{blob:I,appearance:L}),i.push(g(!1));continue}u.set(I,b),l+=y.byteLength,o.push(b),h(f,"selected",{blob:I,appearance:L}),i.push(g(!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 a=Object.keys(e.content.fields);return a.length>0&&c.push("","--- fields ---",...a.map(d=>`${d}: ${e.content.fields[d]}`)),i.length>0&&c.push("","--- attachments ---",...i),e.comments.length>0&&(c.push("","--- comments ---"),e.comments.forEach((d,p)=>{p>0&&c.push(""),c.push(`[${p+1}] ${d.author} \xB7 ${d.created}`,...d.body.split(`
|
|
5
|
-
`))})),{projection:c.join(`
|
|
6
|
-
`)+`
|
|
7
|
-
`,inventory:r,blobs:s,delivered:o,converter:{name:"jira-convert",version:"2",policy:"v1"}}}}var $t=/^[A-Za-z][A-Za-z0-9_]*-\d+$/;function Q(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 s=e[r+1];return $t.test(s)?{site:n.hostname,issueKey:s.toUpperCase()}:null}function ee(t,n){let e=j(t),r=e.heads.get(n);return r==null?null:Ce(t,e,r)}function te(t,n){let r=ee(t,n)?.site;return typeof r=="string"&&r.length>0?r:null}function ke(t,n,e,r){let s=j(t);for(let[o,l]of s.heads){if(l==null||s.mediaOf(l).format!==n)continue;let u=Ce(t,s,l);if(u===null)continue;let i=u;for(let c of e){if(i===null||typeof i!="object"){i=void 0;break}i=i[c]}if(i===r)return o}return null}function Ce(t,n,e){let r=n.getNode(e)?.content?.blob;if(typeof r!="string")return null;let s=W(t,r);if(s===null)return null;try{let o=JSON.parse(s.toString("utf8"));return o!==null&&typeof o=="object"?o:null}catch{return null}}var Re={jira:"a jira issue source",confluence:"a confluence page source",linear:"a linear issue source","linear-doc":"a linear document source",web:"a web page source"};function P(t,n,e){let r=j(t),s=r.heads.get(n);if(s==null)return null;let o=r.mediaOf(s).format;if(o===e)return null;let l=Re[o]??`${o} content`;return`source '${n}' is already backed by ${l}, not ${Re[e]??e} \u2014 retire it first (kane-cli context retire ${n}) or ingest under a different id with --as`}async function Rt(t,n,e,r,s){let o=Q(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 l=s?.lis??{jiraInfo:H,jiraIssue:z,jiraAttachment:Z,jiraComments:X};try{let i={auth:await(s?.authEnv??(await import("./auth-LXW4OFKF.js")).resolveLisAuthEnv)(),env:process.env},c=await l.jiraInfo(i);if(!c.installed)return(e.err??e.out)(`error: ${t}: no Atlassian connection for this account \u2014 create one at ${A} 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 ${A} and retry`),{code:1};let a=o.issueKey.slice(0,o.issueKey.lastIndexOf("-"));if(!c.selectAll&&c.selectedProjects.length>0&&!c.selectedProjects.includes(a))return(e.err??e.out)(`error: ${t}: project ${a} is not in the integration's selected projects (${c.selectedProjects.join(", ")}) \u2014 add it at ${A}`),{code:1};let d=await l.jiraIssue(o.issueKey,i),p=await l.jiraComments(o.issueKey,i),b=o.site;if(d.host)try{b=new URL(d.host).hostname}catch{b=d.host.replace(/^https?:\/\//,"").replace(/[/:].*$/,"")}let{bytes:w,warnings:g}=ve(d,b,p),h=n??o.issueKey.toLowerCase();N(h);let _=P(r,h,"jira");if(_!==null)return(e.err??e.out)(`error: ${t}: ${_}`),{code:1};let y=te(r,h);if(y!==null&&y!==b)return(e.err??e.out)(`error: ${t}: source '${h}' was ingested from ${y}, but this read serves ${b} \u2014 retire it first (kane-cli context retire ${h}) or ingest under a different id with --as`),{code:1};let m=await T({contextDir:r,bytes:w,media:he,sourceId:h,label:t,confirmSameSource:e.isTTY?f=>e.confirm(`identical content already ingested as ${f} \u2014 treat as the same source?`):void 0,converters:{jira:$e({fetchAttachment:f=>l.jiraAttachment(f,i)})}});e.out(U(e.isTTY,m,o.issueKey));for(let f of g)e.out(`warning: ${f}`);for(let f of m.warnings??[])e.out(`warning: ${f}`);if(m.composite){let f=m.composite.delivered+m.composite.omitted;e.out(`${m.source_id}: jira, ${f} attachments, ${m.composite.delivered} images delivered (${m.composite.omitted} omitted)`)}return{code:0,result:{status:m.status,source_id:m.source_id,source_cid:m.cid,...m.gitignore?{gitignore:m.gitignore}:{}}}}catch(u){return u instanceof E?((e.err??e.out)(`error: ${t}: ${u.message}`),{code:1}):((e.err??e.out)(`error: ${t}: ${kt(u instanceof Error?u.message:String(u))}`),{code:1})}}function kt(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 Oe={name:"jira",hint:"Jira issue URLs (https://<site>/browse/KEY-123)",match:t=>Q(t)!==null,ingest:Rt,sourceIdFor:t=>{let n=Q(t);return n?n.issueKey.toLowerCase():null}};async function Ne(t,n={}){let e=await $("/jira/document",{method:"POST",body:JSON.stringify({resource_id:t,format:"markdown"})},n);if(!e.ok)throw S(e,"the page");let r=C(e);if(r.type==="error"||!r.data)throw new E("JIRA_ISSUE_UNAVAILABLE",`could not fetch the page: ${k(r.message??"")||"page not found or not accessible"}`);return r.data}async function Te(t,n={}){let e=await $("/jira/attachment",{method:"POST",body:JSON.stringify({source:"confluence",download:t})},n);if(!e.ok)throw S(e,"the page's attachment");return{bytes:V(e).bytes}}var ne="kane.source.confluence/1";function Pe(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,l)=>o.id<l.id?-1:o.id>l.id?1:0),s={schema:ne,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(s),"utf8"),envelope:s,warnings:[]}}var Ue=64,Ct=16,Ot=6e6,Nt=5e7,Tt=12e6,Pt={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"},Ut=new Set(["png","jpeg","webp"]);function xe(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!==ne)throw new Error(`CONFLUENCE_ENVELOPE_SCHEMA: unknown envelope schema "${r.schema}" \u2014 this CLI understands ${ne}`);let s=[],o=new Map,l=[],u=0,i=new Map,c=[];for(let d=0;d<r.attachments.length;d++){let p=r.attachments[d],b=`i${d+1}`,w=`attachment:${p.filename}`,g=R=>`[img#${b}] ${p.filename} (${p.media_type}, ${p.size} bytes${R?"":" \u2014 not delivered"})`,h=(R,x,D)=>{s.push({ref:b,loc:w,media_type:R,...D?.blob?{blob:D.blob}:{},...D?.appearance?{appearance:D.appearance}:{},delivery:x,...D?.duplicate_of?{duplicate_of:D.duplicate_of}:{}})};if(!p.media_type.startsWith("image/")){h(p.media_type,"unsupported-vision-media-type"),c.push(g(!1));continue}let _=n.get(p.id);if(!_){h(p.media_type,"external-image-not-fetched"),c.push(g(!1));continue}let y;try{y=await t.fetchAttachment({id:p.id,download:_})}catch{h(p.media_type,"external-image-not-fetched"),c.push(g(!1));continue}let m=y.bytes,f=J(m),I=Pt[f.format],L=B(m);if(o.set(L,m),!Ut.has(f.format)){let R=f.format==="gif"||f.format==="bmp"||f.format==="tiff"?"unsupported-vision-media-type":"unsupported-image-kind";h(I,R,{blob:L}),c.push(g(!1));continue}if(f.width===void 0||f.height===void 0||f.width*f.height>Nt){h(I,"undecodable",{blob:L}),c.push(g(!1));continue}let O;if(f.format==="png"||f.format==="jpeg"){let R=F(m,f.format);if(R===null){h(I,"undecodable",{blob:L}),c.push(g(!1));continue}O=M(R.data,{width:R.width,height:R.height,channels:R.channels})}if(f.width<Ue||f.height<Ue){h(I,"below-dimension-floor",{blob:L,appearance:O}),c.push(g(!1));continue}let v=i.get(L);if(v!==void 0){h(I,"duplicate",{blob:L,appearance:O,duplicate_of:v}),c.push(g(!1));continue}if(m.byteLength>Ot){h(I,"image-too-large",{blob:L,appearance:O}),c.push(g(!1));continue}if(u+m.byteLength>Tt){h(I,"vision-byte-budget-reached",{blob:L,appearance:O}),c.push(g(!1));continue}if(l.length>=Ct){h(I,"image-cap-reached",{blob:L,appearance:O}),c.push(g(!1));continue}i.set(L,b),u+=m.byteLength,l.push(b),h(I,"selected",{blob:L,appearance:O}),c.push(g(!0))}let a=[];return a.push(`${r.title} \xB7 ${r.site} \xB7 ${r.space.key}`),r.labels.length>0&&a.push(`labels: ${r.labels.join(", ")}`),r.content.body!==""&&a.push("",...r.content.body.split(`
|
|
8
|
-
`)),c.length>0&&a.push("","--- attachments ---",...c),{projection:a.join(`
|
|
9
|
-
`)+`
|
|
10
|
-
`,inventory:s,blobs:o,delivered:l,converter:{name:"confluence-convert",version:"1",policy:"v1"}}}}var xt=/^[A-Za-z0-9~][A-Za-z0-9._~-]*$/;function re(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 s=e[r+2],o=e[r+4];return s===void 0||o===void 0||!xt.test(s)||!/^\d+$/.test(o)?null:{site:n.hostname,spaceKey:s,pageId:o}}async function Dt(t,n,e,r,s){let o=re(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 l=s?.lis??{jiraInfo:H,jiraIssue:z,jiraAttachment:Z,jiraComments:X},u=s?.confluence??{confluenceDocument:Ne,confluenceAttachment:Te};try{let c={auth:await(s?.authEnv??(await import("./auth-LXW4OFKF.js")).resolveLisAuthEnv)(),env:process.env},a=await l.jiraInfo(c);if(!a.installed)return(e.err??e.out)(`error: ${t}: no Atlassian connection for this account \u2014 create one at ${A} and retry`),{code:1};if(a.capabilities.document===!1)return(e.err??e.out)(`error: ${t}: the connection has no Confluence access \u2014 reconnect with Confluence at ${A} and retry`),{code:1};let d=await u.confluenceDocument(o.pageId,c),p=o.site;if(d.url)try{p=new URL(d.url).hostname}catch{}let{bytes:b,warnings:w}=Pe(d,p),g=n??`page-${o.pageId}`;N(g);let h=P(r,g,"confluence");if(h!==null)return(e.err??e.out)(`error: ${t}: ${h}`),{code:1};let _=te(r,g);if(_!==null&&_!==p)return(e.err??e.out)(`error: ${t}: source '${g}' was ingested from ${_}, but this read serves ${p} \u2014 retire it first (kane-cli context retire ${g}) or ingest under a different id with --as`),{code:1};let y=Object.fromEntries((d.attachments??[]).filter(f=>typeof f.download=="string"&&f.download.length>0).map(f=>[String(f.id),f.download])),m=await T({contextDir:r,bytes:b,media:ye,sourceId:g,label:t,confirmSameSource:e.isTTY?f=>e.confirm(`identical content already ingested as ${f} \u2014 treat as the same source?`):void 0,converters:{confluence:xe({downloads:y,fetchAttachment:f=>u.confluenceAttachment(f.download,c)})}});e.out(U(e.isTTY,m,`${o.spaceKey}/${o.pageId}`));for(let f of w)e.out(`warning: ${f}`);for(let f of m.warnings??[])e.out(`warning: ${f}`);if(m.composite){let f=m.composite.delivered+m.composite.omitted;e.out(`${m.source_id}: confluence, ${f} attachments, ${m.composite.delivered} images delivered (${m.composite.omitted} omitted)`)}return{code:0,result:{status:m.status,source_id:m.source_id,source_cid:m.cid,...m.gitignore?{gitignore:m.gitignore}:{}}}}catch(i){return i instanceof E?((e.err??e.out)(`error: ${t}: ${i.message}`),{code:1}):((e.err??e.out)(`error: ${t}: ${jt(i instanceof Error?i.message:String(i))}`),{code:1})}}function jt(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 De={name:"confluence",hint:"Confluence page URLs (https://<site>/wiki/spaces/<KEY>/pages/<id>/\u2026)",match:t=>re(t)!==null,ingest:Dt,sourceIdFor:t=>{let n=re(t);return n?`page-${n.pageId}`:null}};async function je(t={}){let n=await $("/linear-app/info",{method:"GET"},t);if(!n.ok)throw S(n,"the connection","Linear");let e=C(n);return{installed:e.data?.INSTALLED==="YES",capabilities:{issue:e.data?.capabilities?.issue===!0,comments:e.data?.capabilities?.comments===!0,document:e.data?.capabilities?.document===!0}}}async function Be(t,n={}){let e=await $("/linear-app/issue?details=true",{method:"POST",body:JSON.stringify({plugin_code:"linear-app",issueKey:t})},n);if(!e.ok)throw S(e,"the issue","Linear");let r=C(e);if(r.type==="error"||!r.data)throw new E("JIRA_ISSUE_UNAVAILABLE",`could not fetch the issue: ${k(r.message??"")||"issue not found or not accessible"}`);return r.data}var Bt=100,Mt=5e3,Jt=60;async function Me(t,n={}){let e=[],r=new Set,s=null;for(let o=0;;o++){if(o>=Jt)throw new E("LIS_UNAVAILABLE","the integrations service kept returning comment pages without finishing \u2014 retry later");let l=await $("/linear-app/issue/comments",{method:"POST",body:JSON.stringify({resource_id:t,max_results:Bt,...s===null?{}:{cursor:s},fetch_all:!1})},n);if(!l.ok)throw S(l,"the issue's comments","Linear");let u=C(l);if(u.type==="error"||!u.data)throw new E("JIRA_ISSUE_UNAVAILABLE",`could not fetch the issue's comments: ${k(u.message??"")||"unavailable"}`);if(u.data.partial)throw new E("JIRA_ISSUE_UNAVAILABLE","the integrations service returned an incomplete comment set \u2014 retry later");for(let a of u.data.comments??[]){if(typeof a.id!="string"||a.id==="")throw new E("JIRA_ISSUE_UNAVAILABLE","the integrations service returned an incomplete comment set \u2014 a comment row has no comment id");r.has(a.id)||(r.add(a.id),e.push(a))}let i=u.data.pagination;if(!i?.has_more)return e;if(e.length>=Mt)throw new E("JIRA_ISSUE_UNAVAILABLE","the issue has more comments than can be ingested \u2014 cannot build a complete identity");let c=i.next_cursor??null;if(c==null||c===s)throw new E("LIS_UNAVAILABLE","the integrations service returned a non-advancing comments page \u2014 retry later");s=c}}async function Je(t,n={}){let e=await $("/linear-app/document",{method:"POST",body:JSON.stringify({resource_id:t,format:"markdown"})},n);if(!e.ok)throw S(e,"the document","Linear");let r=C(e);if(r.type==="error"||!r.data)throw new E("JIRA_ISSUE_UNAVAILABLE",`could not fetch the document: ${k(r.message??"")||"document not found or not accessible"}`);return r.data}async function Fe(t,n={}){let e=await $("/linear-app/attachment",{method:"POST",body:JSON.stringify({attachment_id:t})},n);if(!e.ok)throw S(e,"the attachment","Linear");return{bytes:V(e).bytes}}var oe="kane.source.linear/1",ie="kane.source.linear-doc/1",Ft=/https:\/\/uploads\.linear\.app\/[^\s)"'`]+/g;function G(t){return t.replace(Ft,n=>{let e=n.indexOf("?");return e===-1?n:n.slice(0,e)})}function Ve(t,n){return t.id<n.id?-1:t.id>n.id?1:0}function Vt(t,n){return Ve(t,n)||(t.filename<n.filename?-1:t.filename>n.filename?1:0)||(t.url<n.url?-1:t.url>n.url?1:0)}function Ge(t,n,e){if(typeof t.id!="string"||t.id==="")throw new Error("cannot build a stable identity for this issue \u2014 the integrations service returned no issue id");let r=t.key;if(!/^[A-Za-z][A-Za-z0-9]*-\d+$/.test(r)){let c=String(r).replace(/[\u0000-\u001f\u007f-\u009f]/g,"").slice(0,80);throw new Error(`cannot build a stable identity for issue key "${c}" \u2014 expected a TEAM-NUMBER key`)}let s={},o=[...t.labels??[]].filter(c=>typeof c=="string").sort();o.length>0&&(s.labels=o.join(", ")),typeof t.priority=="string"&&t.priority!==""&&(s.priority=t.priority),typeof t.project=="string"&&t.project!==""&&(s.project=t.project),typeof t.status=="string"&&t.status!==""&&(s.status=t.status);let l=(t.attachments??[]).map(c=>({id:c.id!=null&&String(c.id)!==""?String(c.id):G(c.download??""),filename:c.filename??"",url:G(c.download??"")})).sort(Vt),u=n.map(c=>({id:String(c.id),author:c.author?.display_name??"",body:G(c.body??""),created:c.created??""})).sort((c,a)=>c.created!==a.created?c.created<a.created?-1:1:Ve(c,a)),i={schema:oe,site:e,team:r.slice(0,r.lastIndexOf("-")),issue:{uuid:t.id,key:r},content:{title:t.summary??"",description:G(t.description??""),fields:s},attachments:l,comments:u};return{bytes:Buffer.from(JSON.stringify(i),"utf8"),envelope:i,warnings:[]}}function Ye(t,n,e){if(typeof t.id!="string"||t.id==="")throw new Error("cannot build a stable identity for this document \u2014 the integrations service returned no document id");let r=(t.attachments??[]).map(o=>({url:G(o.download??String(o.id??"")),filename:o.filename??""})).sort((o,l)=>o.url<l.url?-1:o.url>l.url?1:0),s={schema:ie,site:n,document:{uuid:t.id,slug_id:e},project:{id:t.space?.key??""},title:t.title??"",content:{body:G(t.body??"")},attachments:r};return{bytes:Buffer.from(JSON.stringify(s),"utf8"),envelope:s,warnings:[]}}var Ke=64,Gt=16,Yt=6e6,Kt=5e7,Wt=12e6,se=64,We="https://uploads.linear.app/",Ht=/https:\/\/uploads\.linear\.app\/[^\s)"'`]+/g,zt={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"},Xt=new Set(["png","jpeg","webp"]);async function He(t,n){let e=[],r=new Map,s=[],o=0,l=new Map,u=[];for(let i=0;i<t.length;i++){let c=t[i],a=`i${i+1}`,d=f=>`[img#${a}] ${c.label}${f?"":" \u2014 not delivered"}`,p=(f,I,L)=>{e.push({ref:a,loc:c.loc,media_type:f,...L?.blob?{blob:L.blob}:{},...L?.appearance?{appearance:L.appearance}:{},delivery:I,...L?.duplicate_of?{duplicate_of:L.duplicate_of}:{}})},b;try{b=await n(c.url)}catch{p("application/octet-stream","external-image-not-fetched"),u.push(d(!1));continue}let w=b.bytes,g=J(w),h=zt[g.format],_=B(w);if(r.set(_,w),!Xt.has(g.format)){let f=g.format==="gif"||g.format==="bmp"||g.format==="tiff"?"unsupported-vision-media-type":"unsupported-image-kind";p(h,f,{blob:_}),u.push(d(!1));continue}if(g.width===void 0||g.height===void 0||g.width*g.height>Kt){p(h,"undecodable",{blob:_}),u.push(d(!1));continue}let y;if(g.format==="png"||g.format==="jpeg"){let f=F(w,g.format);if(f===null){p(h,"undecodable",{blob:_}),u.push(d(!1));continue}y=M(f.data,{width:f.width,height:f.height,channels:f.channels})}if(g.width<Ke||g.height<Ke){p(h,"below-dimension-floor",{blob:_,appearance:y}),u.push(d(!1));continue}let m=l.get(_);if(m!==void 0){p(h,"duplicate",{blob:_,appearance:y,duplicate_of:m}),u.push(d(!1));continue}if(w.byteLength>Yt){p(h,"image-too-large",{blob:_,appearance:y}),u.push(d(!1));continue}if(o+w.byteLength>Wt){p(h,"vision-byte-budget-reached",{blob:_,appearance:y}),u.push(d(!1));continue}if(s.length>=Gt){p(h,"image-cap-reached",{blob:_,appearance:y}),u.push(d(!1));continue}l.set(_,a),o+=w.byteLength,s.push(a),p(h,"selected",{blob:_,appearance:y}),u.push(d(!0))}return{inventory:e,blobs:r,delivered:s,lines:u}}function Zt(t){let n=new Set,e=[];for(let r of t.match(Ht)??[])n.has(r)||(n.add(r),e.push(r));return e}function ze(t){return async n=>{let e;try{e=JSON.parse(n.toString("utf8"))}catch{throw new Error("LINEAR_ENVELOPE_SCHEMA: source bytes are not a kane linear envelope")}if(e.schema!==oe)throw new Error(`LINEAR_ENVELOPE_SCHEMA: unknown envelope schema "${e.schema}" \u2014 this CLI understands ${oe}`);let r=[],s=new Set;for(let a of Zt(e.content.description))s.add(a),r.push({url:a,label:a,loc:`body:${a}`});let o=[];for(let a of e.attachments)if(a.url.startsWith(We)){if(s.has(a.url)){if(a.filename!==""){let d=r.find(p=>p.url===a.url);d!==void 0&&d.label===d.url&&(d.label=a.filename)}continue}s.add(a.url),r.push({url:a.url,label:a.filename||a.url,loc:`attachment:${a.filename||a.url}`})}else a.url!==""&&o.push(`[${o.length+1}] ${a.filename||a.url} \u2014 ${a.url}`);let l=Math.max(0,r.length-se),u=await He(r.slice(0,se),t.fetchAttachment);l>0&&u.lines.push(`${l} more upload links not examined`);let i=[];i.push(`${e.issue.key} \xB7 ${e.site}`,`Title: ${e.content.title}`),e.content.description!==""&&i.push("",...e.content.description.split(`
|
|
11
|
-
`));let c=Object.keys(e.content.fields);return c.length>0&&i.push("","--- fields ---",...c.map(a=>`${a}: ${e.content.fields[a]}`)),u.lines.length>0&&i.push("","--- images ---",...u.lines),o.length>0&&i.push("","--- links ---",...o),e.comments.length>0&&(i.push("","--- comments ---"),e.comments.forEach((a,d)=>{d>0&&i.push(""),i.push(`[${d+1}] ${a.author} \xB7 ${a.created}`,...a.body.split(`
|
|
12
|
-
`))})),{projection:i.join(`
|
|
13
|
-
`)+`
|
|
14
|
-
`,inventory:u.inventory,blobs:u.blobs,delivered:u.delivered,converter:{name:"linear-convert",version:"1",policy:"v1"}}}}function Xe(t){return async n=>{let e;try{e=JSON.parse(n.toString("utf8"))}catch{throw new Error("LINEAR_DOC_ENVELOPE_SCHEMA: source bytes are not a kane linear document envelope")}if(e.schema!==ie)throw new Error(`LINEAR_DOC_ENVELOPE_SCHEMA: unknown envelope schema "${e.schema}" \u2014 this CLI understands ${ie}`);let r=new Set,s=[];for(let i of e.attachments)!i.url.startsWith(We)||r.has(i.url)||(r.add(i.url),s.push({url:i.url,label:i.filename||i.url,loc:`body:${i.url}`}));let o=Math.max(0,s.length-se),l=await He(s.slice(0,se),t.fetchAttachment);o>0&&l.lines.push(`${o} more upload links not examined`);let u=[];return u.push(`${e.title} \xB7 ${e.site}`),e.content.body!==""&&u.push("",...e.content.body.split(`
|
|
15
|
-
`)),l.lines.length>0&&u.push("","--- images ---",...l.lines),{projection:u.join(`
|
|
16
|
-
`)+`
|
|
17
|
-
`,inventory:l.inventory,blobs:l.blobs,delivered:l.delivered,converter:{name:"linear-doc-convert",version:"1",policy:"v1"}}}}var qt=/^[A-Za-z][A-Za-z0-9]*-\d+$/,Qt=/-([0-9a-f]{12})$/;function ue(t){if(!/^https?:\/\/.+/i.test(t))return null;let n;try{n=new URL(t)}catch{return null}return n.hostname.toLowerCase()!=="linear.app"?null:n.pathname.split("/").filter(Boolean)}function Ze(t){let n=ue(t);return n===null||n.length<3?null:{workspace:n[0],segs:n}}function Y(t){let n=Ze(t);if(n===null||n.segs[1]!=="issue")return null;let e=n.segs[2];return qt.test(e)?{workspace:n.workspace,key:e}:null}function K(t){let n=Ze(t);if(n===null||n.segs[1]!=="document")return null;let e=n.segs[2].match(Qt);return e===null?null:{workspace:n.workspace,slugId:e[1]}}var en=new Set(["project","team","view","initiative","cycle","roadmap","inbox","triage","my-issues"]),qe=new Set(["docs","features","method","blog","customers","pricing","integrations","developers","changelog","about","careers","security","download","contact","now","switch","homepage"]);function le(t){let n=ue(t);return n===null||n.length<2||!en.has(n[1])||qe.has(n[0].toLowerCase())?null:{workspace:n[0],section:n[1]}}function de(t){let n=ue(t);return n===null||n.length<2||n[1]!=="issue"&&n[1]!=="document"||qe.has(n[0].toLowerCase())||Y(t)!==null||K(t)!==null?null:{workspace:n[0],section:n[1]}}function Qe(t){let n=Y(t);return n?n.key.toLowerCase():null}function et(t){let n=K(t);return n?`doc-${n.slugId}`:null}var tt={linearInfo:je,linearIssue:Be,linearComments:Me,linearDocument:Je,linearAttachment:Fe};function nt(t,n){if(t)try{let e=new URL(t).pathname.split("/").filter(Boolean)[0];if(e)return`linear.app/${e.toLowerCase()}`}catch{}return`linear.app/${n.toLowerCase()}`}function rt(t,n,e,r,s,o){let l=ee(t,r);if(l!==null&&typeof l.schema=="string"&&l.schema.startsWith(`kane.source.${n}/`)){let i=l;for(let c of e)i=i!==null&&typeof i=="object"?i[c]:void 0;if(typeof i=="string"&&i!==""&&i!==s)return`source '${r}' was ingested from a different ${o} that used this key \u2014 the key was recycled; retire it first (kane-cli context retire ${r}) or ingest under a different id with --as`}let u=ke(t,n,e,s);return u!==null&&u!==r?`this ${o} is already ingested as '${u}' (its key changed) \u2014 reconcile that source, or retire it to re-ingest under the new key`:null}function ot(t,n,e,r){let s=ee(t,e);if(s===null||typeof s.schema!="string"||!s.schema.startsWith(`kane.source.${n}/`))return null;let o=s.site;return typeof o!="string"||o.length===0||o===r?null:`source '${e}' was ingested from ${o}, but this read serves ${r} \u2014 retire it first (kane-cli context retire ${e}) or ingest under a different id with --as`}async function tn(t,n,e,r,s){let o=Y(t);if(o===null)return(e.err??e.out)(`error: ${t}: unsupported remote URL \u2014 expected a Linear issue URL (https://linear.app/<workspace>/issue/KEY-123)`),{code:1};let l=s?.linear??tt;try{let i={auth:await(s?.authEnv??(await import("./auth-LXW4OFKF.js")).resolveLisAuthEnv)(),env:process.env},c=await l.linearInfo(i);if(!c.installed)return(e.err??e.out)(`error: ${t}: no Linear connection for this account \u2014 create one at ${A} and retry`),{code:1};if(c.capabilities.issue===!1||c.capabilities.comments===!1)return(e.err??e.out)(`error: ${t}: the connection cannot read issues or their comments yet \u2014 resync it at ${A} and retry`),{code:1};let a=await l.linearIssue(o.key,i),d=await l.linearComments(o.key,i),p=nt(a.host,o.workspace),{bytes:b,envelope:w,warnings:g}=Ge(a,d,p),h=n??o.key.toLowerCase();N(h);let _=rt(r,"linear",["issue","uuid"],h,w.issue.uuid,"issue")??P(r,h,"linear")??ot(r,"linear",h,p);if(_!==null)return(e.err??e.out)(`error: ${t}: ${_}`),{code:1};let y=await T({contextDir:r,bytes:b,media:Ee,sourceId:h,label:t,confirmSameSource:e.isTTY?m=>e.confirm(`identical content already ingested as ${m} \u2014 treat as the same source?`):void 0,converters:{linear:ze({fetchAttachment:m=>l.linearAttachment(m,i)})}});e.out(U(e.isTTY,y,w.issue.key));for(let m of g)e.out(`warning: ${m}`);for(let m of y.warnings??[])e.out(`warning: ${m}`);if(y.composite){let m=y.composite.delivered+y.composite.omitted;e.out(`${y.source_id}: linear, ${m} images, ${y.composite.delivered} delivered (${y.composite.omitted} omitted)`)}return{code:0,result:{status:y.status,source_id:y.source_id,source_cid:y.cid,...y.gitignore?{gitignore:y.gitignore}:{}}}}catch(u){return u instanceof E?((e.err??e.out)(`error: ${t}: ${u.message}`),{code:1}):((e.err??e.out)(`error: ${t}: ${it(u instanceof Error?u.message:String(u),"issue","Linear")}`),{code:1})}}async function nn(t,n,e,r,s){let o=K(t);if(o===null)return(e.err??e.out)(`error: ${t}: unsupported remote URL \u2014 expected a Linear document URL (https://linear.app/<workspace>/document/<slug>)`),{code:1};let l=s?.linear??tt;try{let i={auth:await(s?.authEnv??(await import("./auth-LXW4OFKF.js")).resolveLisAuthEnv)(),env:process.env},c=await l.linearInfo(i);if(!c.installed)return(e.err??e.out)(`error: ${t}: no Linear connection for this account \u2014 create one at ${A} and retry`),{code:1};if(c.capabilities.document===!1)return(e.err??e.out)(`error: ${t}: the connection cannot read documents yet \u2014 resync it at ${A} and retry`),{code:1};let a=await l.linearDocument(o.slugId,i),d=nt(a.url,o.workspace),{bytes:p,envelope:b,warnings:w}=Ye(a,d,o.slugId),g=n??`doc-${o.slugId}`;N(g);let h=rt(r,"linear-doc",["document","uuid"],g,b.document.uuid,"document")??P(r,g,"linear-doc")??ot(r,"linear-doc",g,d);if(h!==null)return(e.err??e.out)(`error: ${t}: ${h}`),{code:1};let _=await T({contextDir:r,bytes:p,media:_e,sourceId:g,label:t,confirmSameSource:e.isTTY?y=>e.confirm(`identical content already ingested as ${y} \u2014 treat as the same source?`):void 0,converters:{linearDoc:Xe({fetchAttachment:y=>l.linearAttachment(y,i)})}});e.out(U(e.isTTY,_,b.title||`document ${o.slugId}`));for(let y of w)e.out(`warning: ${y}`);for(let y of _.warnings??[])e.out(`warning: ${y}`);if(_.composite){let y=_.composite.delivered+_.composite.omitted;e.out(`${_.source_id}: linear document, ${y} images, ${_.composite.delivered} delivered (${_.composite.omitted} omitted)`)}return{code:0,result:{status:_.status,source_id:_.source_id,source_cid:_.cid,..._.gitignore?{gitignore:_.gitignore}:{}}}}catch(u){return u instanceof E?((e.err??e.out)(`error: ${t}: ${u.message}`),{code:1}):((e.err??e.out)(`error: ${t}: ${it(u instanceof Error?u.message:String(u),"document","Linear")}`),{code:1})}}function it(t,n,e){let r=t.match(/too large — ([\d.]+ [KM]B), the limit for .+ is ([\d.]+ [KM]B) \[FILE_TOO_LARGE\]/);return r?`the ${n}'s content is too large to ingest (${r[1]}; the limit is ${r[2]}) \u2014 trim the ${n} in ${e} and retry`:t.startsWith("PROJECTION_TOO_LARGE:")?`the ${n}'s text is too large to ingest \u2014 trim the ${n} in ${e} and retry`:t}var st={name:"linear",hint:"Linear issue URLs (https://linear.app/<workspace>/issue/KEY-123)",match:t=>Y(t)!==null,ingest:tn,sourceIdFor:Qe},at={name:"linear-doc",hint:"Linear document URLs (https://linear.app/<workspace>/document/<slug>)",match:t=>K(t)!==null,ingest:nn,sourceIdFor:et},ct={name:"linear-page",hint:"Linear issue or document URLs (other linear.app pages are not ingestable)",match:t=>le(t)!==null||de(t)!==null,ingest:async(t,n,e)=>{let r=le(t);if(r===null){let s=de(t);return s!==null?((e.err??e.out)(`error: ${t}: this Linear ${s.section} link is incomplete or malformed \u2014 use the full form (https://linear.app/${s.workspace}/issue/KEY-123 or https://linear.app/${s.workspace}/document/<slug>-<id>)`),{code:1}):((e.err??e.out)(`error: ${t}: unsupported remote URL \u2014 expected a Linear workspace page`),{code:1})}return(e.err??e.out)(`error: ${t}: this Linear page can't be ingested \u2014 only issue and document URLs are supported; ingest the project's issues or documents individually (https://linear.app/${r.workspace}/issue/KEY-123)`),{code:1}},sourceIdFor:()=>null};var rn=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 ut(t,n){let e=n.env??process.env,r=n.fetchImpl??fetch,s=we(e),o={"Content-Type":"application/json"},l=await n.authEnv(),u=l.TESTMUAI_BASIC_AUTH??e.TESTMUAI_BASIC_AUTH,i=l.TESTMUAI_API_KEY??e.TESTMUAI_API_KEY;u?o.Authorization=`Basic ${u}`:i&&(o.Authorization=`Bearer ${i}`);let c;try{c=await r(`${s}/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 a;try{a=await c.json()}catch{return{ok:!1,kind:c.status===404?"route_missing":"malformed_response"}}if(c.ok){let p=a.page;return p===void 0||typeof p.markdown!="string"||p.markdown===""||typeof p.final_url!="string"||p.final_url===""||typeof p.projection?.kind!="string"||typeof p.projection?.version!="string"?{ok:!1,kind:"malformed_response"}:{ok:!0,page:p}}let d=a.code;return typeof d=="string"&&rn.has(d)?{ok:!1,kind:d}:c.status===404?{ok:!1,kind:"route_missing"}:c.status===403?{ok:!1,kind:"auth_rejected"}:{ok:!1,kind:"malformed_response"}}var pe="kane.source.web/1";function lt(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:pe,url:t,projection:{kind:n.kind,version:n.version},content:{markdown:e}};return{bytes:Buffer.from(JSON.stringify(r),"utf8"),envelope:r}}var on=new Set(["markdown"]);function dt(){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!==pe)throw new Error(`unknown web envelope schema '${String(n.schema)}' \u2014 re-ingest the page with this CLI version`);if(!on.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 sn}from"crypto";function pt(t){return ae(t)!==null}function ae(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 me(t){let n=ae(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(/-+$/,""),s=sn("sha256").update(n,"utf8").digest("hex").slice(0,8);return`${r||"page"}-${s}`}function an(t,n){let e=j(t),r=e.heads.get(n);if(r==null)return null;let s=e.getNode(r)?.content?.blob;if(typeof s!="string")return null;let o=W(t,s);if(o===null)return null;try{let l=JSON.parse(o.toString("utf8"));return l.schema!=="kane.source.web/1"?null:typeof l.url=="string"&&l.url.length>0?l.url:null}catch{return null}}function fe(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 cn(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 un(t,n,e,r,s){let o=ae(t);if(o===null)return(e.err??e.out)(`error: ${t}: ${fe("invalid_url")}`),{code:1};let l=me(t),u=n??l;if(u===null)return(e.err??e.out)(`error: ${t}: ${fe("invalid_url")}`),{code:1};try{N(u)}catch(b){return(e.err??e.out)(`error: ${t}: ${b instanceof Error?b.message:String(b)}`),{code:1}}let i=P(r,u,"web");if(i!==null)return(e.err??e.out)(`error: ${t}: ${i}`),{code:1};let c=an(r,u);if(c!==null&&c!==o){if(!e.isTTY)return(e.err??e.out)(`error: ${t}: source '${u}' was ingested from ${c} \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 '${u}' was ingested from ${c} \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 a=s?.web?.scrape??ut,d=s?.authEnv??(async()=>(await import("./spawner-DPT2RLAO.js")).resolveAgentAuthEnv()),p=await a(o,{authEnv:d});if(!p.ok)return(e.err??e.out)(`error: ${t}: ${fe(p.kind)}`),{code:1};try{let{bytes:b}=lt(o,p.page.projection,p.page.markdown),w=await T({contextDir:r,bytes:b,media:be,sourceId:u,label:o,confirmSameSource:e.isTTY?h=>e.confirm(`identical content already ingested as ${h} \u2014 treat as the same source?`):void 0,converters:{web:dt()}}),g=new URL(o).hostname+new URL(o).pathname;e.out(U(e.isTTY,w,g));for(let h of w.warnings??[])e.out(`warning: ${h}`);return e.isTTY&&p.page.title&&e.out(` title: ${p.page.title}`),{code:0,result:{status:w.status,source_id:w.source_id,source_cid:w.cid,...w.gitignore?{gitignore:w.gitignore}:{}}}}catch(b){return(e.err??e.out)(`error: ${t}: ${cn(b instanceof Error?b.message:String(b))}`),{code:1}}}var mt={name:"web",hint:"any public web page URL (https://\u2026)",match:pt,ingest:un,sourceIdFor:me};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 ln=[Oe,De,st,at,ct,mt];function Kr(t){return/^https?:\/\/.+/i.test(t)}function Wr(t){return ln.find(n=>n.match(t))??null}export{U as a,ln as b,Kr as c,Wr as d};
|
package/dist/chunk-DTRSYWZE.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as l}from"./chunk-RZ4F3BHX.js";import{a,b as c,e as o}from"./chunk-5TQFOPJV.js";import{readFileSync as f,writeFileSync as d,mkdirSync as h,realpathSync as g}from"fs";import{join as y}from"path";var C="npm install -g @testmuai/kane-cli@latest",b="brew upgrade lambdatest/kane/kane-cli";function w(){try{let t=process.argv[1];if(t&&g(t).includes("/Cellar/"))return b}catch{}return C}var m=y(c,"version-check.json"),S=1440*60*1e3;function k(){try{let t=JSON.parse(f(m,"utf-8"));if(Date.now()-t.checkedAt<S)return t}catch{}return null}function A(t){try{h(c,{recursive:!0}),d(m,JSON.stringify({latest:t,checkedAt:Date.now()}))}catch{}}function u(t,r){let i=t.split(".").map(Number),n=r.split(".").map(Number);for(let s=0;s<3;s++){let e=(n[s]??0)-(i[s]??0);if(e!==0)return e}return 0}function p(t,r){let i=t.split(".").map(Number),n=r.split(".").map(Number);return(n[0]??0)!==(i[0]??0)?"major":(n[1]??0)!==(i[1]??0)?"minor":"patch"}async function j(){try{let t=k();if(t)return u(a,t.latest)>0?{current:a,latest:t.latest,severity:p(a,t.latest)}:null;let r=new AbortController,i=setTimeout(()=>r.abort(),5e3),n=await l(o,{headers:{Accept:"application/json"},signal:r.signal});if(clearTimeout(i),!n.ok)return null;let e=(await n.json())["dist-tags"]?.latest;return e?(A(e),u(a,e)>0?{current:a,latest:e,severity:p(a,e)}:null):null}catch{return null}}export{w as a,u as b,p as c,j as d};
|
package/dist/chunk-EVFFDODK.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as xe}from"./chunk-KJQNAOOE.js";import{a as Ce,b as Ie,d as Ae,e as Ne}from"./chunk-BB2W35TW.js";import{a as Te}from"./chunk-KDNNMU7Q.js";import{e as Oe,l as ke,y as Re}from"./chunk-IICT4VOU.js";import{a as ye}from"./chunk-D6E6KRVX.js";import{e as ve}from"./chunk-3UI5VTQS.js";import{H as Ee,M as $e,c as be,d as ne,m as Se}from"./chunk-RDHWNSDP.js";import{d as le,e as K,f as g,g as l,h as me,i as he,j as _e}from"./chunk-XLSOQLVT.js";var Be=/\s@verifies\s+(ac-[\w.:\/-]+(?:\s*,\s*ac-[\w.:\/-]+)*)\s*$/,D=i=>({record:null,errors:i,minted:{},logicalIds:{},superseded:[],warnings:[],finalizedTests:{}});function q(i){return i.toLowerCase().trim().replace(/\s+/g," ")}function Ge(i,k,s={}){let p=i.resolve(k);if(!p||i.nodeLabel.get(p.cid)!==g.USECASE||p.superseded)return[];let a=new Set,v=new Set;for(let{cid:m}of i.byLabel(g.SCENARIO))if(!i.superseded.has(m)&&i.edgesFrom(m).some(b=>b.type===l.BELONGS_TO&&i.tipOf(b.dst)===p.cid)){a.add(m),v.add(m),v.add(i.tipOf(m));for(let b of i.edgesInto(m))b.type!==l.AUTOMATES||i.superseded.has(b.src)||a.add(b.src)}if(s.blockerGaps){let m=new Set([p.cid,i.tipOf(p.cid)]);for(let{cid:b,content:S}of i.byLabel(g.GAP)){if(i.superseded.has(b)||i.trust.get(b)==="archived"||!K.has(String(S.kind??"")))continue;let $=typeof S.uc=="string"?S.uc:"";if(!m.has($)&&!m.has(i.tipOf($)))continue;let h=S.ref,L=typeof h=="string"&&h?i.resolve(h):null;L&&(v.has(L.cid)||v.has(i.tipOf(L.cid)))&&a.add(b)}}return[...a]}function et(i){let{contextDir:k,graph:s,sections:p,by:a}=i,v=i.engine??"design@1",m=Ee(k);if(s.latestHash!==m)return D([{code:"STALE_BASIS",detail:`graph opened at ${String(s.latestHash)} but chain head is ${String(m)} \u2014 re-open and retry`}]);let b=s.resolve(i.ucRef);if(!b||s.nodeLabel.get(b.cid)!==g.USECASE||b.superseded)return D([{code:"UNKNOWN_UC",detail:`${i.ucRef} is not a live use-case`}]);let S=b.cid,$={ucRef:S,automates:{},verifies:{},reuses:{},scope:{},depends_on:{},exercises:[],scoped_to_repoints:[],judgements:[],body_tags:{},forceScope:[]},h=[],L=/^design@(\d+)$/.exec(i.templateVersion??""),P=le(i.templateVersion)>=8,ie=e=>{if(!P||!K.has(String(e.kind))||!(e.kind==="unmeasurable"||i.phase==="tests")||e.ref&&(p.scenarios??[]).some(n=>n.temp_ref===e.ref))return!0;let t=e.ref?s.resolve(e.ref):null;return!!(t&&s.nodeLabel.get(t.cid)===g.SCENARIO&&!s.superseded.has(s.tipOf(t.cid))&&s.edgesFrom(s.tipOf(t.cid)).some(n=>n.type===l.BELONGS_TO&&s.tipOf(n.dst)===S))},Y=(p.gaps??[]).filter(ie),we=L!==null&&Number.parseInt(L[1],10)>=3,oe=new Map,De=(e,t)=>{let n=oe.get(e.source_cid);if(n===void 0){let r=Te(i.contextDir,s,e.source_cid);n=r?xe(r.toString("utf8")):null,oe.set(e.source_cid,n)}if(n===null)return h.push({code:"CITE_UNVERIFIED",detail:`${t}: source ${e.source_id} (${e.source_cid.slice(0,19)}) has no citable text to verify against`}),!1;let d=ve(s.mediaOf(e.source_cid),e,n);if(d.length>0){for(let r of d)h.push({code:"CITE_UNVERIFIED",detail:`${t}: ${r.code}: ${r.detail}`});return!1}return!0},N=[],j=[],C=[],J=[],U=[],y={},B={},W={},R=[],M=[],re=new Set,Q=[],V=new Set,x=new Set,X=[];{let e=i.forceScope??(i.force?Ge(s,i.ucRef,{blockerGaps:P}):[]);$.forceScope=[...e];let t=new Set;i.sections.scenarios?.length&&t.add(g.SCENARIO),i.sections.tests?.length&&t.add(g.TEST),P&&(i.sections.tests?.length||i.phase==="tests"&&Y.some(n=>K.has(String(n.kind))))&&(t.add(g.TEST),t.add(g.GAP));for(let n of e)s.superseded.has(n)||(t.has(s.nodeLabel.get(n)??"")?x.add(n):X.push(n))}let F=new Set,Z=e=>!s.superseded.has(e)&&(!x.has(e)||F.has(e)),I=(e,t,n)=>{if(y[e])return y[e];let d=s.resolve(e),r=d?Z(d.cid)?d.cid:s.tipOf(d.cid):null;return!d||!r||!Z(r)?(h.push({code:"UNKNOWN_REF",detail:`${t}: '${e}' is neither in this payload nor a live committed node`}),null):n&&s.nodeLabel.get(r)!==n?(h.push({code:"ILLEGAL_EDGE",detail:`${t}: '${e}' is a ${s.nodeLabel.get(r)}, expected ${n}`}),null):r},Le=(e,t,n,d)=>{if(s.nameOf.has(t)){B[d]=s.nameOf.get(t);return}let r=Re(e,E=>re.has(E),s.names.keys());r!==null&&(re.add(r),J.push({cid:t,slug:r,by:a}),B[d]=r)},z=(e,t,n,d)=>{for(let E of me(e,n))h.push({code:E.code,detail:`${t}: ${E.detail}`});let r=be(e,n);return s.hasNode(r)&&!s.superseded.has(r)?(x.has(r)&&F.add(r),y[t]=r,r):(N.push({cid:r,label:e,content:n}),y[t]=r,Le(e,r,d,t),r)},T=(e,t,n,d,r)=>{let E=ne(e,t,n,d);if(s.edgesFrom(t).some(o=>o.ecid===E&&!s.superseded.has(o.ecid))){e===l.AUTOMATES&&V.add(n);return}if(s.superseded.has(E)){h.push({code:"EDGE_RETRACTED",detail:`${r}: this ${e} edge was retracted (${E}) \u2014 retraction is terminal for commits. Add a NEW relationship (different endpoint or props), redesign, or revert the retracting record`});return}let A=s.nodeLabel.get(t)??N.find(o=>o.cid===t)?.label??"(unknown)",H=s.nodeLabel.get(n)??N.find(o=>o.cid===n)?.label??"(unknown)";for(let o of _e(e,A,H,d))h.push({code:o.code,detail:`${r}: ${o.detail}`});let f=Oe(s,e,t,n,Q);if(f){h.push({code:f.code,detail:`${r}: ${f.detail}`});return}if(e===l.BELONGS_TO||e===l.SCOPED_TO){let o=ye(s,{type:e,src:t,dst:n},{pending:Q,retracted:new Set(C.flatMap(c=>c.kind==="edge"?[c.ecid]:[])),freed:new Set([...x].filter(c=>!F.has(c)))},r);if(o){h.push(o);return}}if(e===l.AUTOMATES){if(V.has(n)){h.push({code:"CARDINALITY_VIOLATION",detail:`${r}: two automates onto ${n} in one record (strict 1:1)`});return}if(V.add(n),!x.has(n)||F.has(n)){let o=_=>x.has(_)&&!F.has(_);if(s.edgesFrom(t).some(_=>_.type===l.AUTOMATES&&_.dst!==n&&!s.superseded.has(_.dst)&&!o(_.dst))&&s.hasNode(t)){h.push({code:"CARDINALITY_VIOLATION",detail:`${r}: automates from ${t} already has a live edge \u2014 supersede it first`});return}if(s.edgesInto(n).some(_=>_.type===l.AUTOMATES&&_.src!==t&&!s.superseded.has(_.src)&&!o(_.src))){h.push({code:"CARDINALITY_VIOLATION",detail:`${r}: automates onto ${n} already has a live edge \u2014 strict 1:1, supersede it first`});return}}}j.push({ecid:ne(e,t,n,d),type:e,src:t,dst:n,props:d}),Q.push({src:t,dst:n,type:e})},ee=new Set;for(let e of Y)e.kind==="budget-evicted"&&e.ref&&ee.add(e.ref);let w=[];for(let[e,t]of(p.gaps??[]).entries()){if(ie(t))continue;let n=t.temp_ref??t.ref??"gap";w.push(e),R.push(`${n} not committed: a ${t.kind} gap stands in for a scenario's test \u2014 ref must be that scenario's committed id (sc-N) or its temp_ref in this payload; got ${t.ref?`'${t.ref}'`:"no ref"}`)}let ce=()=>{for(let e of Y){let t=e.temp_ref??e.ref??"gap",n=e.question;if(!n||typeof n!="object"||!n.header||!Array.isArray(n.options)||n.options.length===0||!Number.isInteger(n.recommended_index)){h.push({code:"GAP_QUESTION_INCOMPLETE",detail:`${t}: design gaps carry a full ranked question object (header/options/recommended_index)`});continue}let d=e.ref?P?y[e.ref]??e.ref:e.ref:void 0,r={kind:e.kind,question:n,derived:!0,uc:S,...e.risk?{risk:e.risk}:{},...e.risk_rationale?{risk_rationale:e.risk_rationale}:{},...e.text?{text:e.text}:{},...d?{ref:d}:{}};z(g.GAP,t,r,String(n.header))}};P||ce();let de=new Map;for(let{cid:e,content:t}of s.byLabel(g.SCENARIO))Z(e)&&s.edgesFrom(e).some(n=>n.type===l.BELONGS_TO&&s.tipOf(n.dst)===S)&&de.set(q(String(t.title??"")),e);for(let e of p.scenarios??[]){let t=de.get(q(e.title));if(t){h.push({code:"DUPLICATE_SCENARIO",detail:`${e.temp_ref}: '${e.title}' duplicates live scenario ${s.nameOf.get(t)??t} \u2014 exercise/link it instead (reuse before minting)`});continue}let n={title:e.title,intent:e.intent,case_type:e.case_type,derived:!0,...e.technique_notes?{technique_notes:e.technique_notes}:{},...e.description?{description:e.description}:{},...e.parameters?{parameters:e.parameters}:{},...e.tags?{tags:e.tags}:{}};z(g.SCENARIO,e.temp_ref,n,e.title)}for(let e of p.scenarios??[]){let t=y[e.temp_ref];if(t){T(l.BELONGS_TO,t,S,{},e.temp_ref);for(let n of e.depends_on??[]){let d=I(n,`${e.temp_ref}.depends_on`,g.SCENARIO);d&&(($.depends_on[e.temp_ref]??=[]).push(d),T(l.DEPENDS_ON,t,d,{},`${e.temp_ref}.depends_on`))}}}for(let e of p.acs??[]){let t={text:e.text,kind:e.kind,risk:e.risk,derived:!0,...e.expected_answer?{expected_answer:e.expected_answer}:{},...e.measurable!==void 0?{measurable:e.measurable}:{}},n=z(g.AC,e.temp_ref,t,e.text);if(!n)continue;let d=e.scope?.type==="scenario"&&e.scope.ref?I(e.scope.ref,`${e.temp_ref}.scope`,g.SCENARIO):S;d&&d!==S&&($.scope[e.temp_ref]=d),d&&!s.edgesFrom(n).some(r=>r.type===l.SCOPED_TO&&!s.superseded.has(r.ecid))&&T(l.SCOPED_TO,n,d,{},`${e.temp_ref}.scope`);for(let r of e.cites??[]){if(we&&!De(r,`${e.temp_ref}.cite`))continue;let E={source_id:r.source_id,source_cid:r.source_cid,anchor:r.anchor,...r.quote?{quote:r.quote}:{}};T(l.DERIVES,r.source_cid,n,E,`${e.temp_ref}.cite`)}}for(let e of p.exercises??[]){let t=I(e.scenario,"exercises.scenario",g.SCENARIO),n=I(e.ac,"exercises.ac",g.AC);!t||!n||($.exercises.push({scenario:t,ac:n}),T(l.EXERCISES,t,n,{},`exercises ${e.scenario}\u2192${e.ac}`))}let ae=0;for(let e of p.scoped_to_repoints??[]){let t=I(e.ac,"scoped_to_repoints.ac",g.AC),n=I(e.to,"scoped_to_repoints.to");if(!t||!n)continue;$.scoped_to_repoints.push({ac:t,to:n});let d=s.edgesFrom(t).find(r=>r.type===l.SCOPED_TO&&!s.superseded.has(r.ecid));if(d&&d.dst===n){ae+=1,R.push(`scoped_to_repoints ${e.ac}: already scoped to ${e.to} \u2014 no-op`);continue}d&&C.push({kind:"edge",ecid:d.ecid,reason:`re-scoped to ${e.to} by ${a.id}`,by:a}),T(l.SCOPED_TO,t,n,{},`scoped_to_repoints ${e.ac}`)}let fe=new Map;if(i.finalizeTestBody)for(let[e,t]of s.nameOf)fe.set(s.tipOf(e),t);let ue=e=>s.nameOf.get(e)??fe.get(s.tipOf(e))??null,pe=e=>{if(y[e])return y[e];let t=s.resolve(e);return t?s.names.has(e)&&!s.superseded.has(t.cid)?t.cid:s.tipOf(t.cid):null},Pe=e=>{let t=pe(e);if(!t&&i.strict)throw new Error(`UNMAPPED_REF: '${e}' resolves to nothing on this graph`);return t?y[e]?B[e]??ue(t):s.names.has(e)?e:ue(t):null};P&&ce();for(let e of p.tests??[]){for(let f of e.reuses??[])ee.has(f)&&h.push({code:"REUSES_EVICTED",detail:`${e.temp_ref}: reuses '${f}' which was budget-evicted \u2014 drop the edge; the dependent gap names the missing @import`});{let f=c=>c==="emulator"||c==="simulator"?c:"web",o=c=>{let u=(p.tests??[]).find(Fe=>Fe.temp_ref===c);if(u)return f(u.target);let _=s.resolve(c),O=_?s.getNode(s.tipOf(_.cid)??_.cid)?.content:void 0;if(typeof O?.target=="string")return f(String(O.target));let ge=/^\s*\[mobile:\s*(emulator|simulator)\]/m.exec(String(O?.test_md_blob??""));return ge?ge[1]:"web"};for(let c of e.reuses??[]){let u=f(e.target),_=o(c);u!==_&&h.push({code:"REUSES_CROSS_SURFACE",detail:`${e.temp_ref}: reuses '${c}' which runs on ${_} while this test runs on ${u} \u2014 a test imports only same-surface units`})}}let t=e.test_md_blob,n=e.definitionId,d=e.objectives_blob;if(i.finalizeTestBody){let f;try{f=i.finalizeTestBody({temp_ref:e.temp_ref,test_md_blob:e.test_md_blob,verifies:e.verifies,reuses:e.reuses??[]},Pe)}catch(o){return D([{code:"FINALIZE_BODY",detail:`${e.temp_ref}: ${o instanceof Error?o.message:String(o)}`}])}f&&(t=f.test_md_blob,n=f.definitionId,d=f.objectives_blob??d,W[e.temp_ref]=n)}let r={title:e.title,check:e.check,definitionId:n,derived:!0,...e.config?{config:e.config}:{},...t?{test_md_blob:t}:{},...d?{objectives_blob:d}:{},...e.surface_required!==void 0?{surface_required:e.surface_required}:{},...e.target?{target:e.target}:{},...e.app&&e.target?{app:e.app}:{}},E=z(g.TEST,e.temp_ref,r,e.title);if(!E)continue;let A=I(e.automates,`${e.temp_ref}.automates`,g.SCENARIO);A&&($.automates[e.temp_ref]=A,T(l.AUTOMATES,E,A,{},`${e.temp_ref}.automates`)),$.verifies[e.temp_ref]=[];for(let f of e.verifies){let o=I(f,`${e.temp_ref}.verifies`,g.AC);o&&($.verifies[e.temp_ref].push(o),T(l.VERIFIES,E,o,{},`${e.temp_ref}.verifies`))}$.reuses[e.temp_ref]=[];for(let f of e.reuses??[]){if(ee.has(f))continue;let o=I(f,`${e.temp_ref}.reuses`,g.TEST);o&&($.reuses[e.temp_ref].push(o),T(l.REUSES,E,o,{},`${e.temp_ref}.reuses`))}for(let f of e.verifies){let o=y[f]??s.resolve(f)?.cid;o&&(s.trust.get(o)??"derived")==="derived"&&!N.some(c=>c.cid===o)?R.push(`${e.temp_ref}: verifies ${f} which is still DERIVED (unapproved) \u2014 committed anyway; approve it in chat or via review`):o&&y[f]===o&&(p.acs??[]).some(c=>c.temp_ref===f)&&R.push(`${e.temp_ref}: verifies ${f} minted in this same record (unapproved) \u2014 committed anyway; approve it in chat`)}if(!String(e.test_md_blob??"").split(`
|
|
3
|
-
`).some(f=>/^##\s/.test(f)&&!/—\s?assert/.test(f)&&Be.test(f))&&e.verifies.length>1){let f=e.check?.verified_against;R.push(`${e.temp_ref}: verifies ${e.verifies.length} ACs but machine-asserts only 1 (check.verified_against=${f!=null?String(f):"?"}) \u2014 the rest ride prose only`)}}let G=[];for(let e of p.tests??[]){let t={};for(let n of je(e.test_md_blob,e.objectives_blob)){let d=pe(n);d?t[n]=d:G.push(`${e.temp_ref}: body tag '${n}' resolves to nothing`)}$.body_tags[e.temp_ref]=t,G.push(...qe(e.temp_ref,t,[...$.verifies[e.temp_ref]??[],...$.reuses[e.temp_ref]??[]]))}if(G.length>0){if(i.strict)return D(G.map(e=>({code:"BODY_EDGE_MISMATCH",detail:e})));R.push(...G.map(e=>`integrity: ${e}`))}let te=[];{let e=(o,c)=>`${o??""}\0${q(String(c??""))}`,t=(o,c)=>i.reason?`${i.reason} \u2014 evolve by ${a.id}${c?` (${c})`:""}`:o,n=new Map;for(let o of N){if(o.label!==g.SCENARIO&&o.label!==g.TEST)continue;let c=e(o.label,o.content.title);n.set(c,[...n.get(c)??[],o.cid])}let d=new Map;for(let o of x){if(F.has(o))continue;let c=e(s.nodeLabel.get(o),s.getNode(o)?.content.title);d.set(c,[...d.get(c)??[],o])}for(let[o,c]of d){let u=n.get(o)??[],_=c.length===1&&u.length===1;for(let O of c)_?(C.push({kind:"node",old:O,new:u[0],reason:t(`--force redesign of ${i.ucRef} by ${a.id} (title-matched successor)`,"title-matched successor"),by:a}),te.push({old:O,next:u[0]})):C.push({kind:"node",old:O,new:null,reason:t(`--force redesign of ${i.ucRef} by ${a.id}`),by:a}),M.push(O)}let r=o=>s.edgesFrom(o).some(c=>c.type!==l.SCOPED_TO?!1:c.dst===S||s.tipOf(c.dst)===S?!0:s.nodeLabel.get(c.dst)===g.SCENARIO&&s.edgesFrom(c.dst).some(u=>u.type===l.BELONGS_TO&&s.tipOf(u.dst)===S)),E=new Map;for(let{cid:o,content:c}of s.byLabel(g.AC)){if(s.superseded.has(o)||!r(o))continue;let u=q(String(c.text??""));E.set(u,[...E.get(u)??[],o])}let A=new Map;for(let o of N){if(o.label!==g.AC)continue;let c=q(String(o.content.text??""));A.set(c,[...A.get(c)??[],o.cid])}for(let[o,c]of E){let u=A.get(o)??[];c.length!==1||u.length!==1||(C.push({kind:"node",old:c[0],new:u[0],reason:t(`AC re-emitted with changed content by ${a.id} (text-matched successor)`,"AC text-matched successor"),by:a}),te.push({old:c[0],next:u[0]}),M.push(c[0]))}let H=new Set(M),f=new Set;for(let o of C)o.kind==="edge"&&f.add(o.ecid);for(let{old:o,next:c}of te)for(let u of s.edgesInto(o))he(u.type)?.pin?.comparesTo!=="dst_tip"||s.superseded.has(u.src)||H.has(u.src)||f.has(u.ecid)||(C.push({kind:"edge",ecid:u.ecid,reason:`re-blessed onto ${c} (redirect successor of ${o}) by ${a.id}`,by:a}),f.add(u.ecid),j.some(O=>O.type===u.type&&O.src===u.src&&O.dst===c)||s.edgesFrom(u.src).some(O=>O.type===u.type&&O.dst===c))||u.type===l.AUTOMATES&&V.has(c)||T(u.type,u.src,c,u.props,`rebless ${u.type} from ${s.nameOf.get(u.src)??u.src}`)}if(h.length>0)return D(h);if(N.length===0&&j.length===0&&C.length===0&&U.length===0)return Object.keys(y).length>0||ae>0?(R.push("everything in this phase is already current \u2014 nothing re-committed"),{record:null,errors:null,minted:y,logicalIds:B,superseded:[],warnings:R,finalizedTests:W,...w.length?{droppedBlockers:w}:{},...i.force||i.forceScope?{forceScopeRemaining:X}:{}}):{...D([{code:"EMPTY_DESIGN",detail:"finalize_design produced nothing to commit"}]),warnings:R,...w.length?{droppedBlockers:w}:{}};if(i.generationTicket){let e=Ae(s,i.generationTicket);if(e!==null)return D([e])}let se=i.eventIds&&i.eventIds.length>0?i.eventIds:i.sid?ke(s,i.sid,"design",1):null;return{record:$e(k,{ts:new Date().toISOString(),proposal_id:null,nodes:N,edges:j,review:[],supersessions:C,source_head_moves:{},...J.length>0?{names:J}:{},...(()=>{for(let e of p.judgements??[]){let t=e.target?y[e.target]??s.resolve(e.target)?.cid??S:S;$.judgements.push(t),U.push({about:t,rationale:`[${e.kind}] ${e.rationale}`,by:a})}return U.length>0?{judgements:U}:{}})(),design_of:{uc_cid:S,engine:v},...i.generationTicket?{design_generation:Ne(i.generationTicket,S,a)}:{},...se?{event_ids:se}:{},...i.sid?{sid:i.sid}:{},...i.phase?{design_phase:{uc_root:Ce(s,S),generation:i.generationTicket?.next_gen??Ie(s,i.ucRef)?.gen??1,phase:i.phase,completeness:i.phaseCompleteness??"complete"}}:{}},{expectPrev:s.latestHash,intent:{v:1,verb:"design",args:Se({ucRef:i.ucRef,sections:p,by:a,engine:v,force:i.force??!1,forceScope:i.forceScope??null,reason:i.reason??null,generationTicket:i.generationTicket??null,templateVersion:i.templateVersion??null,phase:i.phase??null,phaseCompleteness:i.phaseCompleteness??null,eventIds:se,sid:i.sid??null}),pins:$},provenance:i.provenance}).record,errors:null,minted:y,logicalIds:B,superseded:M,warnings:R,finalizedTests:W,...w.length?{droppedBlockers:w}:{},...i.force||i.forceScope?{forceScopeRemaining:X}:{}}}function qe(i,k,s){let p=new Set(Object.values(k));if(p.size===0)return[];let a=new Set(s),v=[];for(let[m,b]of Object.entries(k))a.has(b)||v.push(`${i}: body tag '${m}' has no verifies or reuses edge`);for(let m of a)p.has(m)||v.push(`${i}: edge to ${m} has no body tag`);return v}function je(i,k){let s=[];for(let a of(i??"").split(`
|
|
4
|
-
`)){let v=/^##\s.*?\s@verifies\s+(.+?)\s*$/.exec(a);v&&s.push(...v[1].split(",").map(b=>b.trim()).filter(Boolean));let m=/^@import\s+(\S+)\s*$/.exec(a.trim())??/^## Import: (\S+)\s*$/.exec(a);m&&s.push(m[1])}let p=!1;for(let a of(k??"").split(`
|
|
5
|
-
`)){let v=/^\s*verifies:\s*\[(.*)\]\s*$/.exec(a);if(v){s.push(...v[1].split(",").map(b=>b.trim()).filter(Boolean));continue}if(/^\s*verifies:\s*$/.test(a)){p=!0;continue}let m=p?/^\s*-\s+(\S+)\s*$/.exec(a):null;m?s.push(m[1]):p=!1}return s}function tt(i,k){let s=[];for(let p of i){let a=p.design_phase;!a||typeof a!="object"||a.uc_root===k&&(typeof a.phase!="string"||typeof a.generation!="number"||s.push({phase:a.phase,generation:a.generation,seq:p.seq,completeness:a.completeness==="partial"?"partial":"complete"}))}return s.sort((p,a)=>p.seq-a.seq)}export{Ge as a,et as b,tt as c};
|
package/dist/chunk-F2OBORCG.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{F as c}from"./chunk-RDHWNSDP.js";import{f as l}from"./chunk-XLSOQLVT.js";function h(f,o,u){let n=o.resolve(u);if(!n)return{target:null,entries:[]};let t=new Set([n.cid]),r=n.cid;for(;o.superseded.has(r);){let s=o.superseded.get(r);if(typeof s!="string"||t.has(s))break;t.add(s),r=s}let d=o.nodeLabel.get(n.cid)??"(unknown)",{records:p}=c(f),i=[];for(let s of p){for(let e of s.nodes)t.has(e.cid)&&i.push({seq:s.seq,ts:s.ts,kind:"minted",detail:`minted ${e.label} ${e.cid}`});for(let e of s.judgements??[])t.has(e.about)&&i.push({seq:s.seq,ts:s.ts,kind:"judgement",rationale:e.rationale,detail:`judgement on ${e.about}`,by:e.by});for(let e of s.review)t.has(e.id)&&i.push({seq:s.seq,ts:s.ts,kind:"review",detail:`${e.resolution}${e.reason?` \u2014 ${e.reason}`:""}`,by:e.by});for(let e of s.supersessions)e.kind==="node"&&(t.has(e.old)||e.new!==null&&t.has(e.new))&&i.push({seq:s.seq,ts:s.ts,kind:"supersession",detail:`${e.old} \u2192 ${String(e.new)} \u2014 ${e.reason}`,by:e.by});for(let e of s.names??[])t.has(e.cid)&&i.push({seq:s.seq,ts:s.ts,kind:"name",detail:`named ${e.slug}`,by:e.by});if(d===l.SOURCE)for(let[e,a]of Object.entries(s.source_head_moves))(t.has(a??"")||o.heads.get(e)!==void 0&&t.has(n.cid)&&e===o.getNode(n.cid)?.content?.source_id)&&i.push({seq:s.seq,ts:s.ts,kind:"head_move",detail:`${e} head \u2192 ${String(a)}`})}return i.sort((s,e)=>e.seq-s.seq),{target:{cid:n.cid,tip:n.tip,label:d,slug:o.nameOf.get(n.cid)},entries:i}}export{h as a};
|
package/dist/chunk-FQNQVC5O.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{b as N}from"./chunk-UD7KKHPW.js";import{closeSync as D,existsSync as J,mkdirSync as C,openSync as U,readFileSync as M,readdirSync as X,renameSync as $,rmSync as h,watch as F,writeFileSync as _}from"fs";import{join as g}from"path";import{randomBytes as q}from"crypto";var R=1440*60*1e3,m=class extends Error{constructor(a,u,f,k){super(`${a}: ${f}`);this.code=a;this.key=u;this.holder=k}},E=e=>(e?.now??(()=>new Date))();function P(e){if(!Number.isInteger(e)||e<=0)return!1;try{return process.kill(e,0),!0}catch(i){return i.code==="EPERM"}}function G(e,i){let a=i.getTime()-new Date(e.ts).getTime();return!P(e.pid)||a>=R||Number.isNaN(a)}var L=e=>g(e,"locks"),H=e=>g(L(e),"waiters");function T(e,i){return i.kind==="context"?g(L(e),"context.lock"):i.kind==="extract"?g(L(e),"extract.lock"):g(L(e),`uc-${i.id}.lock`)}var x=e=>e.kind==="uc"?e.id:e.kind,v=e=>e.kind==="uc"?`uc:${e.id}`:e.kind,K=e=>e.kind==="uc"?e.id:`~${e.kind}`;function I(e){return[...e].sort((i,a)=>K(i)<K(a)?-1:K(i)>K(a)?1:0)}function p(e){try{return JSON.parse(M(e,"utf8"))}catch{return null}}function W(e,i,a){let u=`${e}.break-${a}`;try{$(e,u)}catch(k){if(k.code==="ENOENT")return!1;throw k}let f;try{f=JSON.parse(M(u,"utf8"))}catch{f=null}if(f===null||f.nonce===i)return h(u,{force:!0}),!0;try{$(u,e)}catch{h(u,{force:!0})}return!1}var y=new Map,O=new Map;function V(e,i,a){let u=o=>`${e}|${i}|${x(o)}`;function f(o,d,s=0){if(s>20)throw new m("LOCK_CONTENTION_UNSETTLED",o,`${v(o)}: lock contention did not settle`);let c=T(e,o);C(L(e),{recursive:!0});let n=q(8).toString("hex");try{let t=U(c,"wx",384);return _(t,JSON.stringify({...d,nonce:n})+`
|
|
3
|
-
`),D(t),n}catch(t){if(t.code!=="EEXIST")throw t;let r=p(c),l=E(a);if(r!==null&&!G(r,l)){let S=o.kind==="context"?"CONTEXT_HELD":o.kind==="extract"?"EXTRACT_HELD":"UC_HELD";throw new m(S,o,`${v(o)} is held by ${r.owner_sid} (${r.verb})`,{owner_sid:r.owner_sid,pid:r.pid,ts:r.ts,verb:r.verb,alive:P(r.pid)})}return W(c,r?.nonce,n)&&N({type:"lock_steal",key:v(o),stale_owner:r?.owner_sid??"corrupt",by:i,ts:l.toISOString()}),f(o,d,s+1)}}function k(o,d){let s=!1;return{keys:d,assertHeld(){for(let{key:c,sk:n}of o){let t=y.get(n),r=t?p(t.path):null;if(!t||r===null||r.nonce!==t.nonce)throw new m("LOCK_LOST",c,`${v(c)} grant was taken over or removed`)}},touch(){for(let{sk:c}of o){let n=y.get(c);if(!n)continue;let t=p(n.path);t!==null&&t.nonce===n.nonce&&_(n.path,JSON.stringify({...t,ts:E(a).toISOString()})+`
|
|
4
|
-
`,{mode:384})}},release(){if(!s){s=!0;for(let{sk:c}of[...o].reverse()){let n=y.get(c);if(n&&(n.count-=1,n.count<=0)){y.delete(c);let t=p(n.path);t!==null&&t.nonce===n.nonce&&h(n.path,{force:!0})}}}}}}function w(o,d){let s=I(o),c=[];try{for(let n of s){let t=u(n),r=y.get(t);if(r)r.count+=1;else{let l=f(n,{owner_sid:i,pid:process.pid,ts:E(a).toISOString(),verb:d.verb??"unknown",hold:d.hold,...n.kind==="uc"?{logical_display:n.id.toUpperCase()}:{}});y.set(t,{nonce:l,count:1,path:T(e,n),key:n})}c.push({key:n,sk:t})}return k(c,s)}catch(n){for(let{sk:t}of[...c].reverse()){let r=y.get(t);if(r&&(r.count-=1,r.count<=0)){y.delete(t);let l=p(r.path);l!==null&&l.nonce===r.nonce&&h(r.path,{force:!0})}}throw n}}return{acquire:w,tryAcquire(o,d){try{return w(o,d)}catch(s){if(s instanceof m&&(s.code==="UC_HELD"||s.code==="CONTEXT_HELD"||s.code==="EXTRACT_HELD"))return{contended:s};throw s}},holder(o){return p(T(e,o))},async wait(o,d){let s=T(e,o);C(H(e),{recursive:!0});let c=g(H(e),`${x(o)}.${i}.${process.pid}.json`);try{_(c,JSON.stringify({sid:i,pid:process.pid,ts:E(a).toISOString()})+`
|
|
5
|
-
`,{mode:384})}catch{}let n=Date.now()+d.timeoutMs,t=null,r=null;try{try{t=F(L(e),()=>{r?.()}),t.on("error",()=>{r?.(),t=null})}catch{t=null}for(;;){if(d.signal?.aborted)return"cancelled";let l=p(s);if(l===null||G(l,E(a)))return"free";let S=n-Date.now();if(S<=0)return"timeout";await new Promise(b=>{r=b;let A=setTimeout(b,Math.min(t?250:100,Math.max(1,S)));d.signal?.addEventListener?.("abort",()=>{clearTimeout(A),b()},{once:!0})}),r=null}}finally{t?.close(),h(c,{force:!0})}},async withKeySerialized(o,d){let c=I(o).map(l=>`${e}|${x(l)}`),n=c.map(l=>O.get(l)??Promise.resolve()),t,r=new Promise(l=>{t=l});for(let l of c)O.set(l,r);await Promise.all(n);try{return await d()}finally{t();for(let l of c)O.get(l)===r&&O.delete(l)}},releaseAll(o){let d=`${e}|${o}|`;for(let[s,c]of[...y]){if(!s.startsWith(d))continue;y.delete(s);let n=p(c.path);n!==null&&n.nonce===c.nonce&&h(c.path,{force:!0})}}}}function Y(e,i){let a=e.resolve(i);if(a===null)return{key:{kind:"uc",id:i.toLowerCase()},display:i};let u=e.displayNameOf(a.tip)??e.displayNameOf(a.cid);if(u!==null&&/^uc-\d+$/i.test(u))return{key:{kind:"uc",id:u.toLowerCase()},display:u.toUpperCase()};let f=new Map;for(let[d,s]of e.superseded)typeof s=="string"&&f.set(s,d);let k=a.cid,w=new Set;for(;f.has(k)&&!w.has(k);)w.add(k),k=f.get(k);let o=k.slice(0,12);return{key:{kind:"uc",id:o},display:u??o}}function Z(e){let i=L(e);if(!J(i))return[];let a=[];for(let u of X(i)){if(!u.endsWith(".lock"))continue;let f=p(g(i,u));f!==null&&a.push({key:u.replace(/\.lock$/,""),grant:f})}return a}export{m as a,P as b,G as c,H as d,I as e,V as f,Y as g,Z as h};
|
package/dist/chunk-FY7TCYPK.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{F as I,L,p as V}from"./chunk-RDHWNSDP.js";var N="ckpt/1";var B="checkpoints",P="base.json",y=t=>`delta-${t}.json`,w=t=>`full-${t}.json`,oe=["turn","ask","final"],ae=["extract","design","walk"];function _(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function x(t){return Array.isArray(t)&&t.every(n=>typeof n=="string")}function H(t){let n=[],e=(r,a)=>{r||n.push(a)};if(!_(t))return{ok:!1,errors:["record: not an object"]};e(t.schema===N,`schema: expected "${N}"`);let s=t.kind;if(s==="base")e(typeof t.sid=="string"&&t.sid.length>0,"base.sid: non-empty string"),e(typeof t.verb=="string"&&ae.includes(t.verb),"base.verb: extract|design|walk"),e(typeof t.mode=="string","base.mode: string"),e(typeof t.created_at=="string","base.created_at: string"),e(_(t.run_config),"base.run_config: object"),_(t.run_config)&&e(!("resume"in t.run_config),"base.run_config: must not carry `resume`"),e(typeof t.conv_source=="string",'base.conv_source: string ("" when absent)'),e(typeof t.store_watermark=="string"||t.store_watermark===null,"base.store_watermark: string | null (null = genesis)");else if(s==="delta"||s==="full"){e(typeof t.sid=="string"&&t.sid.length>0,"delta.sid: non-empty string"),e(Number.isInteger(t.seq)&&t.seq>=1,"delta.seq: integer \u2265 1"),e(Number.isInteger(t.turn_id),"delta.turn_id: integer"),e(typeof t.at=="string"&&oe.includes(t.at),"delta.at: turn|ask|final"),e(typeof t.ts=="string","delta.ts: string");let r=t.agent;if(_(r)){e(Number.isInteger(r.agent_state_schema),"agent.agent_state_schema: integer"),e(Array.isArray(r.delta_items),"agent.delta_items: array"),e(_(r.binding),"agent.binding: object");let o=r.usage_total;e(_(o)&&typeof o.input_tokens=="number"&&typeof o.output_tokens=="number"&&typeof o.credits=="number","agent.usage_total: {input_tokens, output_tokens, credits} numbers"),r.base_fingerprint!==void 0&&e(typeof r.base_fingerprint=="string","agent.base_fingerprint: string when present"),s==="full"&&e(typeof r.base_fingerprint=="string","full: agent.base_fingerprint required")}else n.push("delta.agent: object");let a=t.kane;if(_(a)){e(x(a.applied_events),"kane.applied_events: string[]"),e(x(a.held_receipts),"kane.held_receipts: string[]");let o=a.pending;e(_(o)&&Array.isArray(o.questions)&&Array.isArray(o.proposals),"kane.pending: {questions[], proposals[]}"),e(Array.isArray(a.parent_asks),"kane.parent_asks: array"),e(_(a.read_basis),"kane.read_basis: object");let p=a.corpus_cursor;e(_(p)&&x(p.remaining),"kane.corpus_cursor: {remaining: string[]}"),e(typeof a.store_watermark=="string"||a.store_watermark===null,"kane.store_watermark: string | null (null = genesis)"),a.ingest_registry!==void 0&&e(Array.isArray(a.ingest_registry)&&a.ingest_registry.every(i=>_(i)&&typeof i.ref=="string"&&typeof i.entered_at=="string"),"kane.ingest_registry: [{ref, entered_at, consumed?}]"),a.ingest_schedule!==void 0&&e(Array.isArray(a.ingest_schedule)&&a.ingest_schedule.every(i=>_(i)&&typeof i.source_id=="string"&&typeof i.cid=="string"&&["pending","done","skipped"].includes(String(i.status))),"kane.ingest_schedule: [{source_id, cid, status}]")}else n.push("delta.kane: object")}else n.push('kind: expected "base" | "delta" | "full"');return{ok:n.length===0,errors:n}}import{closeSync as U,existsSync as Z,fsyncSync as Y,mkdirSync as ee,openSync as G,readFileSync as te,readdirSync as ne,renameSync as ce,rmSync as K,statSync as pe,writeFileSync as de}from"fs";import{join as k}from"path";var le=3,we=600*1e3,A=class extends Error{constructor(e,s){super(`${e}: ${s}`);this.code=e}},S=class extends Error{constructor(n){super(`CHECKPOINT_WRITE: ${n}`)}},j=class extends S{},E=(t,n)=>k(t,"sessions",n,B),ue=(t,n)=>k(t,"sessions",n,"state.json");function F(t,n,e){let s=`${t}.tmp-${process.pid}`,r=G(s,"w");try{de(r,n,{mode:384}),Y(r)}finally{U(r)}ce(s,t);try{let a=G(e,"r");Y(a),U(a)}catch{}}var ge=new Set,W=new Set;function J(t){let n=0;try{for(let e of ne(t))try{n+=pe(k(t,e)).size}catch{}}catch{return 0}return n}function z(t,n,e){for(let s of ge)try{s(t,n,e)}catch{}}var fe=new Set;function Se(t,n=new Date){for(let e of fe)try{e(t,n)}catch{}}function Ae(t,n,e){let s=E(t,n);ee(s,{recursive:!0});let r=k(s,P);Z(r)||F(r,JSON.stringify(e)+`
|
|
3
|
-
`,s)}function _e(t,n){let e;try{e=JSON.parse(n)}catch(r){throw new A("CHECKPOINT_CORRUPT",`${t}: ${r.message}`)}let s=H(e);if(!s.ok)throw new A("CHECKPOINT_CORRUPT",`${t}: ${s.errors.join("; ")}`);return e}function M(t,n,e){let s=k(E(t,n),e);return _e(e,te(s,"utf8"))}function re(t,n){let e=[],s=[],r=[];try{r=ne(E(t,n))}catch{return{deltas:e,fulls:s}}for(let a of r){let o=/^delta-(\d+)\.json$/.exec(a);o&&e.push(Number(o[1]));let p=/^full-(\d+)\.json$/.exec(a);p&&s.push(Number(p[1]))}return e.sort((a,o)=>a-o),s.sort((a,o)=>a-o),{deltas:e,fulls:s}}function ke(t,n){try{return JSON.parse(te(ue(t,n),"utf8")).checkpoint??null}catch{return null}}function se(t,n,e){let s=[],r,a=0;if(e.full_seq!==null){let i=M(t,n,w(e.full_seq));s.push(i),r=i.agent.base_fingerprint,a=e.full_seq}let o;for(let i=a+1;i<=e.seq;i++)try{let d=M(t,n,y(i));s.push(d),!r&&d.agent.base_fingerprint&&(r=d.agent.base_fingerprint)}catch(d){if(d instanceof A&&d.code==="CHECKPOINT_CORRUPT"){o={resumableAt:i-1,turnsLost:e.seq-(i-1)};break}throw d}if(s.length===0)throw new A("CHECKPOINT_CORRUPT",`${n}: pointer names seq ${e.seq} but no chain records exist`);return{items:s.flatMap(i=>i.agent.delta_items),last:s[s.length-1],base_fingerprint:r,fallback:o}}function Re(t,n,e,s,r){let a=performance.now(),o=n.state.sid,p=n.state.checkpoint;if(p){if(e.seq<p.seq)throw new S(`seq regression: got ${e.seq}, pointer at ${p.seq} (${o})`);if(e.seq===p.seq){if(e.turn_id===p.turn_id&&e.at===p.at)return p;throw new S(`seq regression: seq ${e.seq} re-used with different metadata (turn ${e.turn_id}/${p.turn_id}, at ${e.at}/${p.at}) (${o})`)}}let i=E(t,o);ee(i,{recursive:!0});let d=(r?.now??(()=>new Date))(),b=d.toISOString(),u={schema:N,kind:"delta",sid:o,seq:e.seq,turn_id:e.turn_id,at:e.at,ts:b,agent:{agent_state_schema:e.agent_state_schema,delta_items:e.delta_items,binding:e.binding,usage_total:e.usage_total,...e.base_fingerprint!==void 0?{base_fingerprint:e.base_fingerprint}:{}},kane:s},m=Math.max(1,r?.retries??le),g=JSON.stringify(u)+`
|
|
4
|
-
`,O=!1;Buffer.byteLength(g)>524288&&!W.has(o)&&(W.add(o),O=!0,r?.onSoftCap?.("note: this session's checkpoints are getting large \u2014 long pasted inputs are kept verbatim; consider ingesting big documents as sources instead"));let R=!1,v;for(let c=0;c<m&&!R;c++)try{F(k(i,y(e.seq)),g,i),R=!0}catch(l){v=l}if(!R)throw new S(`delta-${e.seq} write failed after ${m} attempts: ${v?.message??"unknown"} (${o})`);let h=p?.full_seq??null,$=J(i)>67108864;if(e.seq%25===0||$){let c=[],l=e.base_fingerprint;if(p){let C=se(t,o,p);c=C.items,l=l??C.base_fingerprint}if(c=[...c,...e.delta_items],!l)throw new S(`compaction at seq ${e.seq}: no base_fingerprint anywhere in the chain (${o})`);let f={...u,kind:"full",agent:{...u.agent,delta_items:c,base_fingerprint:l}};F(k(i,w(e.seq)),JSON.stringify(f)+`
|
|
5
|
-
`,i),h=e.seq}let q={seq:e.seq,turn_id:e.turn_id,at:e.at,ts:b,full_seq:h};if(n.save({checkpoint:q}),h===e.seq){let{deltas:c,fulls:l}=re(t,o);for(let f of c)f<=h&&K(k(i,y(f)),{force:!0});for(let f of l)f<h&&K(k(i,w(f)),{force:!0})}let T=J(i);if($&&T>67108864)throw z(o,q,d),new j(`session ${o} checkpoint dir is ${Math.round(T/(1024*1024))}MB (cap ${Math.round(67108864/(1024*1024))}MB) even after compaction \u2014 pausing; resume in a fresh session or trim the conversation`);return z(o,q,d),r?.onStat?.({sid:o,seq:e.seq,persist_ms:performance.now()-a,bytes:Buffer.byteLength(g),dir_bytes:T,compacted:h===e.seq,soft_warned:O}),q}function Pe(t,n,e){let s=e?._readPointer??(()=>ke(t,n)),r=k(E(t,n),P);if(!Z(r))throw new A("CHECKPOINT_MISSING",`${n}: no ${P} \u2014 not a checkpoint session`);let a=M(t,n,P),o=i=>{let{deltas:d,fulls:b}=re(t,n);if(!i){let g=[...d.map(y),...b.map(w)];return{base:a,agent:null,kane:null,pointer:null,orphans:g}}let u=se(t,n,i),m=[...d.filter(g=>g>i.seq).map(y),...b.filter(g=>g>i.seq).map(w)];return{base:a,agent:{delta_items:u.items,binding:u.last.agent.binding,base_fingerprint:u.base_fingerprint,agent_state_schema:u.last.agent.agent_state_schema},kane:u.last.kane,pointer:i,orphans:m,...u.fallback?{fallback:u.fallback}:{}}},p=s();try{return o(p)}catch(i){if(!(i.code==="ENOENT"))throw i;return o(s())}}function Ee(t,n){let e=[];for(let s of I(t).records)if(s.sid===n)for(let r of s.event_ids??[])e.push(r);return e}function ve(t,n,e,s,r){let a=r.verb??"extract",o=I(t),p=0;if(e.store_watermark!==null){let c=o.hashes.indexOf(e.store_watermark);if(c===-1)throw new V(`watermark not in chain: ${e.store_watermark} names no record in this store (rebuilt or foreign?) \u2014 re-ground the session or abandon it`);p=c+1}let i=L(t,{seq:p,hash:e.store_watermark}).records,d=o.records.filter(c=>c.sid===n).map(c=>c.seq),b=c=>d.filter(l=>l<=c.seq).length,u=new Set(e.applied_events),m=0,g=[];for(let c of i){if(typeof c.sid!="string"){m+=1;continue}if(c.sid===n){if((c.event_ids??[]).length===0){m+=1;continue}g.push(c)}}m>0&&r.onNote?.(`reconcile: skipped ${m} store record(s) not attributable to this session (pre-sid grace)`);let O=r.ownActors??["extract-agent","design-agent","owner"],R=[],v=[];for(let c of g){let l=(c.event_ids??[]).filter(ie=>!u.has(ie));if(l.length===0)continue;v.push(...l);let f;try{f=r.composeReceipt(c,s,{verb:a,commitN:b(c),...r.ucRef?{ucRef:r.ucRef}:{},...r.typedBlockers?{typedBlockers:!0}:{},...r.ignoreGaps?.size?{ignoreGaps:r.ignoreGaps}:{}}).text}catch{f=`commit ${l[0]} at ${c.ts} \u2014 details unavailable (graph moved since)`}let C=c.review?.[0]?.by;C?.id&&!O.includes(C.id)&&(f+=`
|
|
6
|
-
(committed by ${C.kind}:${C.id} while this session was suspended)`),R.push(f)}let h=e.pending.proposals??[],$=h.filter(c=>typeof c.event_id=="string"&&s.appliedEvents.has(c.event_id)),T=h.filter(c=>!(typeof c.event_id=="string"&&s.appliedEvents.has(c.event_id))).filter(c=>c.state==="accepted-pending-commit");return{redeliverReceipts:R,recommit:T,prunedPending:$,newlyApplied:v,skippedNoSid:m}}function qe(t,n,e){let s=E(t,n);for(let r of e)/^(?:delta|full)-\d+\.json$/.test(r)&&K(k(s,r),{force:!0})}export{N as a,B as b,P as c,Se as d,Ae as e,Re as f,Pe as g,Ee as h,ve as i,qe as j};
|
package/dist/chunk-GTVQYT3D.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{b as Me}from"./chunk-4Y2WH77W.js";import{c as Ft}from"./chunk-T2ONUKTL.js";import{a as Jt}from"./chunk-66MOZKD2.js";import{a as g,c as Mt,d as Bt,e as _,f as Le,g as Fe,h as Wt,i as Je,j as Ht}from"./chunk-YLQHY4A7.js";import{h as ut,k as ft,m as ht,o as _e,r as Pt,t as Lt}from"./chunk-OMNLAGQC.js";import{a as At,b as Pe,c as Ct,d as Tt}from"./chunk-VVOKM2VO.js";import{u as qt}from"./chunk-IICT4VOU.js";import{B as re,D as Ie,E as Et,F as xt,G as L,I as qe,J as he,K as Ot,O as $,P as y,Q as Ae,R as _t,S as Ce,U as Te,V as It,W as Ne,X as se,a as pt,b as fe,h as te,i as mt,j as gt,n as wt,p as x,r as St,s as $t,t as kt,v as Rt,x as vt,z as Y}from"./chunk-RDHWNSDP.js";import{b as ne,c as bt,h as yt}from"./chunk-FQNQVC5O.js";import{a as ee}from"./chunk-XLSOQLVT.js";import{a as Nt}from"./chunk-CH273NAE.js";import{b as dt}from"./chunk-5LJRZI7S.js";import{a as lt}from"./chunk-BKM2LWU2.js";import{s as at,t as ct}from"./chunk-RSSOJ3L2.js";import{y as O}from"./chunk-5TQFOPJV.js";import{a as it}from"./chunk-DFS4RMVP.js";import{a as ue}from"./chunk-HCBYKLMW.js";import{a as U,b,i as pe}from"./chunk-C44QQJR4.js";import{a as Pn}from"./chunk-6YGTRKDT.js";import{e as D}from"./chunk-UR6MHSHU.js";import{existsSync as fs}from"fs";var V=D(Pn(),1);import{existsSync as de,mkdirSync as xn,readdirSync as Hr,readFileSync as Re,rmSync as En,writeFileSync as Ur,renameSync as Yr}from"fs";import{randomBytes as jr}from"crypto";import{basename as zr,join as tt}from"path";import{appendFileSync as ye,closeSync as hr,existsSync as w,fsyncSync as mr,mkdirSync as F,openSync as gr,readdirSync as G,readFileSync as S,renameSync as $e,rmdirSync as wr,rmSync as q,realpathSync as br,statfsSync as yr,statSync as pn,writeFileSync as Sr}from"fs";import{randomBytes as un}from"crypto";import{basename as fn,dirname as R,join as h,relative as Ge}from"path";var Ln=/^sha256:[0-9a-f]{64}$/;function oe(t){let e=new Set,n=r=>{typeof r=="string"&&Ln.test(r)&&e.add(r)};for(let r of t.nodes??[])n(r.content?.blob);for(let r of Object.values(t.media??{})){n(r.text_blob);for(let s of r.images??[])n(s.blob)}return{blobs:[...e].sort(),proposalId:t.proposal_id??null}}function Be(t){return"sha256:"+fe(Buffer.from("assurance.proposal\0"+pt(JSON.parse(t)),"utf8"))}import{mkdirSync as Fn,readFileSync as Jn}from"fs";import{dirname as Mn,join as Bn}from"path";var Ut="locations.json",Yt="state.json";function me(t,e){return Bn(t,"sync",e)}function jt(t){return Zt(me(t,Ut),{version:1,locations:[]})}function Es(t,e){Xt(me(t,Ut),e)}function B(t){return Zt(me(t,Yt),{version:1,entries:{}})}function zt(t,e){Xt(me(t,Yt),e)}function Gt(t,e){let n=t.locations;if(n.length===0)throw new Error("no locations yet \u2014 add one with kane-cli context sync add <name> <descriptor>");if(e!==void 0){let s=n.find(i=>i.name===e);if(s)return s;throw new Error(`no location named ${e} \u2014 known locations: ${n.map(i=>i.name).join(", ")}`)}if(n.length===1)return n[0];let r=n.find(s=>s.name==="origin");if(r)return r;throw new Error(`name a location: ${n.map(s=>s.name).join(", ")}`)}var j=class extends Error{code="WITNESS_LOWERED"};function Kt(t,e,n){let r=t.entries[e];if(!r)throw new Error(`no sync state for ${e} \u2014 run kane-cli context sync add ${e} <descriptor> first`);let s=r.witness;if(s){if(n.seq<s.seq)throw new j(`${e} is behind what it already served: position ${s.seq} was seen there, now ${n.seq}`);if(n.seq===s.seq&&n.hash!==s.hash)throw new j(`${e} changed the record at position ${s.seq}: ${s.hash} was seen there, now ${n.hash}`)}r.witness=n}function xs(t,e,n){let r=t.locations.length,s=t.locations.filter(i=>i.name!==n);if(s.length===r){let i=r===0?"none":t.locations.map(o=>o.name).join(", ");throw new Error(`no location named ${n} \u2014 known locations: ${i}`)}return t.locations=s,e.entries[n]?.witness??null}function Zt(t,e){let n;try{n=Jn(t,"utf-8")}catch(s){if(s.code==="ENOENT")return e;throw new Error(`${t} could not be read: ${s instanceof Error?s.message:String(s)}`)}let r;try{r=JSON.parse(n)}catch(s){throw new Error(`${t} is not readable JSON: ${s instanceof Error?s.message:String(s)}`)}if(typeof r!="object"||r===null||!("version"in r)||r.version!==1)throw new Error(`${t} is not a version 1 sync file \u2014 this store was written by a newer kane-cli`);return r}function Xt(t,e){Fn(Mn(t),{recursive:!0}),$(t,JSON.stringify(e,null,2)+`
|
|
3
|
-
`)}import{closeSync as Gn,existsSync as tn,fsyncSync as Kn,linkSync as Zn,mkdirSync as Xn,openSync as Vn,readFileSync as Qn,rmSync as nn,writeFileSync as Dn}from"fs";import{dirname as ge,join as rn}from"path";import{existsSync as jn}from"fs";import{join as zn}from"path";var Vt=1e3,Wn=999999999,Qt=/^assurance\/context@(\d+)$/,Hn=Number(Qt.exec(ee)[1]);async function ae(t,e){let n=await t.get(_(e));if(n===null)throw ie(`position ${e} is absent`);return{hash:We(e,n).hash,raw:n}}function We(t,e){let n=s=>new g("SYNC_OBJECT_CORRUPT",`the record at position ${t} on the storage is not usable: ${s}`,"the storage object needs a human look; nothing was changed"),r;try{r=JSON.parse(Buffer.from(e).toString("utf8"))}catch(s){throw n(`not JSON (${s instanceof Error?s.message:String(s)})`)}if(typeof r!="object"||r===null||Array.isArray(r)||r.seq!==t)throw n(`it says it is position ${String(r?.seq)}`);if(r.schema_version!==void 0&&r.schema_version!==ee){let s=Qt.exec(r.schema_version);throw s&&Number(s[1])>Hn?new g("SYNC_CLIENT_TOO_OLD",`position ${t} is stamped ${r.schema_version}; this kane-cli reads ${ee}`,`upgrade kane-cli to a release that reads ${r.schema_version}, then run the command again`):n(`it is stamped ${r.schema_version}, this build reads ${ee}`)}if(r.parents!==void 0&&!(r.prev_hash===null?r.parents.length===0:r.parents.length===1&&r.parents[0]===r.prev_hash))throw n("parents does not mirror prev_hash");return{record:r,hash:re(r)}}async function W(t,e,n=0){let r=e,s=1,i;for(;;){let u=e+s;if(!await t.head(_(u))){i=u;break}r=u,s*=2}if(r===e&&e>0&&!await t.head(_(e)))return W(t,0);for(;i-r>1;){let u=r+Math.floor((i-r)/2);await t.head(_(u))?r=u:i=u}let o=r;if(o===0){if(await t.head(Bt))throw ie("meta.json exists but position 1 is gone");let u=(await t.list(Mt)).map(Fe).find(f=>f!==null);if(u!==void 0)throw ie(`position ${u} exists but position 1 is gone`);return{seq:0,hash:null,raw:null}}let a=[Le(o),Le(Math.min(o+Vt,Wn))];a[1]===a[0]&&a.pop();let c=new Set;for(let u of a)for(let f of await t.list(u)){let k=Fe(f);if(k!==null){if(k>o){if(await t.head(_(o+1))){if(n>=Un)throw Yn(o);return W(t,o,n+1)}throw ie(`position ${k} exists above the tail at ${o}`)}c.add(k)}}let p=o-(o-1)%Vt;for(let u=p;u<=o;u++)if(!c.has(u))throw ie(`position ${u} is missing below the tail at ${o}`);let{hash:d,raw:l}=await ae(t,o);return{seq:o,hash:d,raw:l}}var Un=3;function Yn(t){return new g("SYNC_REMOTE_HOLE",`the storage kept growing while its tail was being found (last seen at ${t}); nothing was changed`,"run the command again in a moment")}function ie(t){return new g("SYNC_REMOTE_HOLE",`the storage has a hole: ${t} \u2014 a position was deleted below evidence of a later one`,"restore the missing position from a copy that holds it; nothing was changed")}function Dt(t,e){let n=he(t,e);if(n===null)throw new x(`no local record at position ${e} \u2014 run kane-cli context fsck`);if(!(n!==qe&&jn(zn(t,"commits",`${String(e).padStart(6,"0")}-${n.slice(7,19)}.json`))))throw new g("SYNC_LOCAL_RECORD_CORRUPT",`the local record at position ${e} ${n===qe?"is unreadable":"does not hash to its file name"}`,"run kane-cli context fsck, then restore the record from a backup or a clone; nothing was changed");return n}async function en(t,e,n){let r=L(t),s=await W(e,n?.seq??0),i=async l=>l===s.seq?s.hash:(await ae(e,l)).hash;if(n&&(s.seq<n.seq||await i(n.seq)!==n.hash))throw new g("SYNC_REMOTE_ROLLED_BACK",`the storage was rolled back: position ${n.seq} was seen there with ${n.hash}, `+(s.seq<n.seq?`now its tail is ${s.seq}`:"now a different record sits there"),"restore the storage from a copy that holds the witnessed records, or remove and re-add the location after a human has decided it was rebuilt on purpose");let o=s.seq===0?null:{seq:s.seq,hash:s.hash};if(o===null)return{kind:"empty-storage",local:r,storage:o};if(r===null)return{kind:"empty-local",local:r,storage:o};if(Dt(t,1)!==await i(1))return{kind:"foreign-lineage",local:r,storage:o};let a=Math.min(r.seq,o.seq),c=async l=>(l===r.seq?r.hash:Dt(t,l))===await i(l);if(await c(a))return{kind:r.seq===o.seq?"up-to-date":r.seq<o.seq?"behind":"ahead",local:r,storage:o};let p=1,d=a;for(;d-p>1;){let l=p+Math.floor((d-p)/2);await c(l)?p=l:d=l}return{kind:"diverged",local:r,storage:o,at:d}}var er=2e3;async function Qs(t,e,n,r,s){let i=B(t).entries[n]?.witness??null,o=await en(t,e,i),a=o.local?.seq??0,c={imported:0,from:a,to:a,blobs:0,proposals:0};switch(o.kind){case"empty-storage":return r(`nothing to pull: ${n} is empty`),c;case"up-to-date":return r("up to date"),c;case"ahead":return s?.quietAhead||r(`nothing to pull; you are ahead of ${n} \u2014 run kane-cli context push ${n}`),c;case"diverged":throw new g("SYNC_DIVERGED",`you and ${n} both added work after position ${o.at-1}; nothing was pulled`,`run kane-cli context pull ${n} --rebase to save your local work, take the team version from ${n}, and then reapply yours`);case"foreign-lineage":throw new g("SYNC_FOREIGN_LINEAGE",`${n} holds a different history (its first record is not this store's)`,`to work on it, clone it: kane-cli context clone <descriptor of ${n}> <dir>; to share this store, add an empty location`);case"behind":case"empty-local":break}let p=o.storage.seq,d=await Ue(t,e,o.local,o.storage,tr(t,o.local),r);return Ye(t,d,o.local?.hash??null,n),se(t),He(t,n,{seq:p,hash:d.records[d.records.length-1].hash}),{imported:d.records.length,from:a,to:p,blobs:d.blobs.size,proposals:d.proposals.size}}function He(t,e,n,r){let s=r?.lockHeld?()=>{}:Y(t,{deadlineMs:er});try{let i=B(t),o=i.entries[e]?.witness??null;if(r?.forwardOnly&&o&&o.seq>n.seq)return;try{Kt(i,e,n)}catch(a){throw a instanceof j?new g("SYNC_REMOTE_ROLLED_BACK",a.message,"restore the storage from a copy that holds the witnessed records, or remove and re-add the location after a human has decided it was rebuilt on purpose"):a}zt(t,i)}finally{s()}}function tr(t,e){let n=It(t);return n&&n.applied.seq===(e?.seq??0)&&n.applied.hash===(e?.hash??null)?n:se(t)}async function Ue(t,e,n,r,s,i=()=>{}){let o=await rr(e,n?.seq??0,n?.hash??null,r.seq,r.hash);ir(t,o,s);let a=await sr(t,e,o),c=await or(t,e,o,i);return{records:o,blobs:a,proposals:c}}function Ye(t,e,n,r,s){for(let[a,c]of e.proposals){let[p,d]=a.split("/");nr(rn(ge(te(t,p)),d),c)}let i=n,o=null;for(let a=0;a<e.records.length;a+=Ae){let c=e.records.slice(a,a+Ae),p=s?.lockHeld?()=>{}:Y(t);try{_t(t,c.map(({seq:d,raw:l})=>({seq:d,raw:l})),i,{...s,lockHeld:!0})}catch(d){if(!(d instanceof vt))throw d;let l=`this store appended position ${L(t)?.seq??0} while the pull was`;throw new g("SYNC_LOCAL_MOVED",o===null?`${l} being prepared; nothing was imported`:`${l} landing; positions ${e.records[0].seq}..${o} were imported, a valid prefix, and nothing more`,`kane-cli context pull ${r}`)}finally{p()}i=c[c.length-1].hash,o=c[c.length-1].seq,s?.afterChunk?.(o)}}function nr(t,e){Xn(ge(t),{recursive:!0});let n=`${t}.tmp-${process.pid}`,r=Vn(n,"w");try{Dn(r,e),Kn(r)}finally{Gn(r)}try{Zn(n,t)}catch(s){if(s.code!=="EEXIST")throw nn(n,{force:!0}),s}nn(n,{force:!0}),y(ge(t))}async function rr(t,e,n,r,s){let i=[],o=n;for(let a=e+1;a<=r;a++){let c=await t.get(_(a));if(c===null)throw new g("SYNC_REMOTE_HOLE",`the storage has a hole: position ${a} is missing below its tail at ${r}`,"restore the missing position from a copy that holds it; nothing was changed");let{record:p,hash:d}=We(a,c);if(p.prev_hash!==o)throw new g("SYNC_REMOTE_CHAIN_BROKEN",`position ${a} on the storage is sealed onto ${String(p.prev_hash)}, but position ${a-1} hashes ${String(o)}`,"the storage chain needs a human look; nothing was changed");if(a===r&&d!==s)throw new g("SYNC_REMOTE_CHAIN_BROKEN",`the tail at position ${r} changed while this pull ran: it hashed ${s}, now ${d}`,"run kane-cli context pull again");i.push({seq:a,hash:d,raw:Buffer.from(c).toString("utf8"),record:p}),o=d}return i}async function sr(t,e,n){let r=new Set;for(let{seq:s,record:i}of n)for(let o of oe(i).blobs){if(r.has(o))continue;let a=Tt(t,o);if(a!==null&&Pe(a)===o)continue;let c=await e.get(Wt(o));if(c===null)throw new g("SYNC_REMOTE_HOLE",`the storage has a hole: position ${s} names blob ${o}, which the storage does not hold`,"restore the blob from a copy that holds it; nothing was changed");let p=Buffer.from(c);if(Pe(p)!==o)throw new g("SYNC_OBJECT_CORRUPT",`the blob ${o} on the storage does not hash to its name (named by position ${s})`,"the storage object needs a human look; nothing was changed");a===null?Ct(t,p):$(At(t,o),p),r.add(o)}return r}async function or(t,e,n,r){let s=new Map,i=new Set;for(let{seq:o,record:a}of n){let c=oe(a).proposalId;if(c===null||i.has(c))continue;i.add(c);let p=te(t,c),d=null;if(tn(p))try{d=Be(Qn(p,"utf8"))}catch{d=""}let l=await e.list(Ht(c));if(l.length===0)continue;if(l.length>1){r(`proposal ${c} (position ${o}) has ${l.length} payloads on the storage and the record names none of them; skipped`);continue}if(d!==null&&Je(c,d)===l[0])continue;let u=await e.get(l[0]);if(u===null)continue;let f=null;try{f=Be(Buffer.from(u).toString("utf8"))}catch{f=null}if(f===null||Je(c,f)!==l[0]){r(`proposal ${c} (position ${o}) on the storage does not digest to its key ${l[0]}; skipped`);continue}if(d===null){s.set(`${c}/proposal.json`,Buffer.from(u));continue}let k=`${c}/proposal.${f.slice(7,19)}.json`;tn(rn(ge(p),k.slice(c.length+1)))||(r(`proposal ${c} (position ${o}) differs from the one here; the storage's payload is installed beside it as ${k}`),s.set(k,Buffer.from(u)))}return s}function ir(t,e,n){let r=structuredClone(n);for(let{seq:s,hash:i,record:o}of e)try{gt(t,r,o,i)}catch(a){throw a instanceof mt?new g("SYNC_REMOTE_ADMISSION_RED",`position ${s} would not pass this store's checks: ${a.message}`,`nothing was imported; ask whoever pushed position ${s} to run kane-cli context fsck on their store, or upgrade kane-cli if theirs is newer`):a}}import{existsSync as on,mkdirSync as ar,readdirSync as cr,readFileSync as an,renameSync as dr,writeFileSync as lr}from"fs";import{join as we}from"path";var pr=/^@import\s+(\S+)\s*$/;function sn(t,e){let n=t.resolve(e),r=n?String(t.getNode(n.tip)?.content.title??""):"";return r&&qt(r,()=>!1)||e}function je(t){return we(t,".testmuai","tests")}function ze(t){let e=new Map;if(!on(t))return e;for(let n of cr(t)){if(!n.endsWith("_test.md"))continue;let r=we(t,n);try{let s=_e(an(r,"utf8"))?.id;s&&e.set(s,[...e.get(s)??[],r])}catch{}}return e}function ur(t,e,n){let r=`assurance:
|
|
4
|
-
id: ${e}
|
|
5
|
-
base: ${n}
|
|
6
|
-
`,s=t.endsWith(`
|
|
7
|
-
`)?t:t+`
|
|
8
|
-
`;return s.startsWith(`---
|
|
9
|
-
`)?`---
|
|
10
|
-
${r}${s.slice(4)}`:s.startsWith(`---\r
|
|
11
|
-
`)?`---\r
|
|
12
|
-
${r.replace(/\n/g,`\r
|
|
13
|
-
`)}${s.slice(5)}`:`---
|
|
14
|
-
${r}---
|
|
15
|
-
${s}`}function fr(t,e){let n=`${t}.tmp-mint`;lr(n,e),dr(n,t)}function oo(t){let{graph:e,cids:n,cwd:r}=t,s=je(r),i=[],o=[],a=ze(s),c=new Set,p=(l,u)=>{let f=a.get(l);if(f&&f.length>1)return o.push({id:l,reason:`two files claim assurance.id ${l}: ${f.join(" \xB7 ")} \u2014 resolve the duplicate first`}),null;if(c.has(l))return d(l);if(u.includes(l))return d(l)??`${sn(e,l)}_test.md`;let k=e.resolve(l),Q=k?e.getNode(k.tip):void 0,J=Q?.content.test_md_blob,le=Q?.content.definitionId;if(!J||!le)return o.push({id:l,reason:`${l} has no test definition in the graph`}),null;let Oe=J.split(`
|
|
16
|
-
`).map(C=>{let T=pr.exec(C.trim());if(!T)return C;let P=T[1];if(!e.resolve(P))return C;let ot=p(P,[...u,l]);if(!ot)throw new be(`dependency ${P} could not be minted/located`);return`@import ./${ot}`}).join(`
|
|
17
|
-
`),Nn=ur(Oe,l,le),N=f?.[0];if(N){let C=an(N,"utf8"),T=_e(C)?.base,P=ut(ft(C,ht(s,e)));if(!T||P!==T)return o.push({id:l,reason:`${N} was edited since the engine last wrote it \u2014 keeping yours (reconcile via a run or maintain)`}),null}else{let C=sn(e,l),T=we(s,`${C}_test.md`);for(let P=2;on(T);P++)T=we(s,`${C}-${P}_test.md`);N=T}return ar(s,{recursive:!0}),fr(N,Nn),c.add(l),a.set(l,[N]),i.push({id:l,path:N}),N.split("/").pop()},d=l=>a.get(l)?.[0]?.split("/").pop()??null;for(let l of n){let u=e.nameOf.get(l);if(!u){o.push({id:l,reason:"minted test has no logical id"});continue}try{p(u,[])}catch(f){if(f instanceof be)o.push({id:u,reason:f.message});else throw f}}return{wrote:i,refused:o}}var be=class extends Error{};var $r=["pending-facts.ndjson","signals.ndjson","store.json"],kr=/^\d{6}-[0-9a-f]{12}\.json$/,cn=["staged","fenced","backed-up","trimmed","importing","imported","unfenced"],hn=2e3,Rr=1440*60*1e3,vr=(t,e)=>h(t,"sync","backups",`${e}-reset`),Er=()=>new Date().toISOString().replace(/[:.]/g,"-"),xr=t=>h(t,"sync","incoming"),v=t=>h(t,"sync","replay"),Ke=t=>fn(t),mn=(t,e)=>h(v(t),`${Ke(e)}.receipt.json`),A=t=>h(t,"sync","journal.json"),I=t=>h(t,"commits"),ce=t=>h(I(t),Ie),K=(t,e)=>h(xr(t),e),Ze=(t,e)=>`${String(t).padStart(6,"0")}-${e.slice(7,19)}.json`,z=t=>"sha256:"+fe(t),gn=()=>({pid:process.pid,nonce:un(4).toString("hex")});async function xo(t,e,n,r,s,i={}){if(r.kind!=="diverged"||r.at===void 0)throw new Error(`reset needs a diverged relation, got ${r.kind}`);let o=r.at;if(w(A(t)))throw new g("SYNC_STORE_BUSY","a reset is already in progress","run kane-cli context sync doctor");ln(t),_r(t,n),Or(t);let{records:a,hashes:c}=xt(t),p={seq:o-1,hash:c[o-2]},d=Te();Ne(t,d,a.slice(0,o-1),c.slice(0,o-1),{writeNodeFiles:!1});let l=await Ue(t,e,p,r.storage,d),u=a.slice(o-1).map(M=>Ze(M.seq,c[M.seq-1])),f=Jr(t,a,c,o),k=yn(t,u,f);Ir(t,qr(l)+k.reduce((M,Oe)=>M+pn(Oe.src).size,0));let Q=i.ts??Er(),J={nonce:un(8).toString("hex"),state:"staged",name:n,holder:gn(),base:p,at:o,storage:r.storage,backup:vr(t,Q),ts:Q,moved:u,testIds:f,counts:{records:l.records.length,blobs:l.blobs.size,proposals:l.proposals.size},manifest:[]};Cr(t,J.nonce,l);let le=Y(t,{deadlineMs:hn});try{if(L(t)?.hash!==r.local?.hash)throw new g("SYNC_STORE_BUSY","the chain moved while the reset was being prepared",`run kane-cli context pull ${n} --rebase again`);return ln(t),Xe(t,J,i.afterTransition),wn(t,J,s,i)}catch(M){throw w(A(t))||Se(K(t,J.nonce)),M}finally{le()}}async function Oo(t,e,n=()=>{}){let r={state:"none",detail:"no reset in progress"},s=dn(t);if(s===null)return r;let i=Y(t,{deadlineMs:hn});try{let o=dn(t);if(o===null||o.nonce!==s.nonce)return r;if(o.holder.pid!==process.pid&&ne(o.holder.pid))throw new g("SYNC_STORE_BUSY",`a reset is running as pid ${o.holder.pid} \u2014 wait`,"wait for it to finish, then run the command again");if(o.holder=gn(),Xe(t,o),e==="resume"){let d=wn(t,o,n,{});return{state:"resumed",detail:`finished the reset interrupted at '${o.state}': ${d.moved.length} records moved to ${d.backup}`,result:d}}if(H(o,"imported"))return{state:"refused",detail:`the shared records are already imported, so the reset can only finish (kane-cli context sync or kane-cli context pull finishes it); its receipt will be ${mn(t,o.backup)}`};let a=Fr(t,o),c=0;for(let{name:d,hash:l}of o.manifest){if(!d.startsWith("commits/")&&!d.startsWith("intents/"))continue;let u=h(t,d);try{if(w(u)){if(z(S(u))!==l)throw new Error("the live file does not match the backup manifest");continue}let f=S(h(o.backup,d));if(z(f)!==l)throw new Error("the backup copy does not match the manifest");F(R(u),{recursive:!0}),$(u,f),d.startsWith("commits/")&&c++}catch(f){throw new Error(`restore stopped at ${d}: ${f instanceof Error?f.message:String(f)}; re-run abort`)}}bn(t,o.nonce),q(Ce(t),{recursive:!0,force:!0});let p=`${o.backup}.aborted`;return w(o.backup)&&$e(o.backup,p),y(R(o.backup)),q(A(t),{force:!0}),y(R(A(t))),Se(p),Se(K(t,o.nonce)),{state:"aborted",detail:`aborted the reset at '${o.state}': ${a} imported records removed, ${c} records put back, the chain is as it was`}}finally{i()}}function dn(t){return w(A(t))?JSON.parse(S(A(t),"utf8")):null}var H=(t,e)=>cn.indexOf(t.state)>=cn.indexOf(e);function wn(t,e,n,r){let s=d=>{e.state=d,Xe(t,e,r.afterTransition)},i=()=>{if(!Ve(t,e.nonce))throw new Error("sentinel missing \u2014 run kane-cli context sync doctor")};H(e,"fenced")||(Ar(t,e.nonce),s("fenced")),H(e,"backed-up")||(i(),e.manifest=Nr(t,e),s("backed-up")),H(e,"trimmed")||(i(),Pr(t,e),s("trimmed")),H(e,"importing")||(i(),s("importing")),H(e,"imported")||(i(),q(Ce(t),{recursive:!0,force:!0}),Lr(t,e,Tr(t,e.nonce),r.afterChunk),s("imported")),H(e,"unfenced")||(bn(t,e.nonce),s("unfenced"));let o=se(t),a=Mr(t,e),c=Lt(t,Rr),p=Br(t,h(v(t),Ke(e.backup)),new Set(Object.keys(o.nodeLabel)));F(v(t),{recursive:!0}),$(mn(t,e.backup),JSON.stringify({from:e.at,moved:e.moved,storageTail:e.storage,quarantinedTests:a,droppedPendingFacts:p,liveSideQueues:c},null,2)+`
|
|
18
|
-
`),y(v(t)),q(A(t),{force:!0}),y(R(A(t))),Se(K(t,e.nonce)),He(t,e.name,e.storage,{lockHeld:!0}),n(`saved ${e.moved.length} local record${e.moved.length===1?"":"s"} from position ${e.at} in ${e.backup}; ${e.name}'s records took their place`);for(let d of a)n(`quarantined test file ${d}: its test was minted by a moved record`);return{name:e.name,backup:e.backup,moved:e.moved,quarantinedTests:a,pulled:{imported:e.counts.records,from:e.base.seq,to:e.storage.seq,blobs:e.counts.blobs,proposals:e.counts.proposals}}}function ln(t){let e=new Date,n=h(t,"sessions");if(w(n))for(let r of G(n)){let s=h(n,r,".lock");if(!w(s))continue;let i;try{i=JSON.parse(S(s,"utf8"))}catch{continue}let o=e.getTime()-new Date(i.ts??0).getTime();if(typeof i.pid=="number"&&ne(i.pid)&&o<dt)throw new g("SYNC_STORE_BUSY",`session ${r} is live (pid ${i.pid})`,"finish or pause that session, then run the reset again")}for(let{key:r,grant:s}of yt(t))if(!bt(s,e))throw new g("SYNC_STORE_BUSY",`lock ${r} is held by ${s.verb} (pid ${s.pid})`,"wait for that command to finish, then run the reset again")}function Or(t){let e=kn(t);if(!e)return;let n=e.listHolds().length;throw new g("SYNC_REBASE_PENDING",`your last rebase still has ${n} unresolved decision${n===1?"":"s"}; no new rebase was started`,"run kane-cli context sync or kane-cli context pull again to continue. To discard the unresolved local changes instead, run kane-cli context sync doctor --abort")}function _r(t,e){let n=B(t).entries[e]?.binding,r=lt(t),s=br(t),i=pn(t),o=r!==null&&n?.instance_id===r.context_instance_id&&n.realpath===s;if(!(o&&n.dev===i.dev&&n.ino===i.ino))throw new g("SYNC_COPIED_STORE_UNRESOLVED",r===null?"this store has no store.json ids, so it cannot prove it is the one the location was added from":o?`this store's directory is not the one ${e} was bound from: same ids and path, but the .context inode changed \u2014 it was replaced in place by a copy`:`this store is not the one ${e} was added from (${n?`bound to ${n.realpath}`:"no binding"}; this is ${s})`,`re-run kane-cli context sync add ${e} <descriptor> from this directory to bind it`)}function Ir(t,e){let n=yr(t),r=n.bavail*n.bsize;if(!(r>=2*e))throw new g("SYNC_DISK_LOW",`${r} bytes free, the reset needs ${2*e} (twice the staged suffix plus the backup)`,"free some disk space, then run the reset again")}function qr(t){let e=0;for(let n of t.records)e+=Buffer.byteLength(n.raw);for(let n of t.proposals.values())e+=n.length;return e}function Xe(t,e,n){F(R(A(t)),{recursive:!0}),$(A(t),JSON.stringify(e,null,2)+`
|
|
19
|
-
`),n?.(e.state)}function Ar(t,e){let n=ce(t);try{let r=gr(n,"wx");try{Sr(r,Et(e)),mr(r)}finally{hr(r)}y(I(t))}catch(r){if(r.code!=="EEXIST")throw r;if(!Ve(t,e))throw new Error(`${n} belongs to another reset \u2014 run kane-cli context sync doctor`)}}function bn(t,e){if(w(ce(t))){if(!Ve(t,e))throw new Error(`${ce(t)} belongs to another reset \u2014 left in place`);q(ce(t)),y(I(t))}}function Ve(t,e){try{return JSON.parse(S(ce(t),"utf8")).kane?.nonce===e}catch{return!1}}function Cr(t,e,n){let r=K(t,e);for(let s of["records","proposals"])F(h(r,s),{recursive:!0});for(let s of n.records)$(h(r,"records",`${s.seq}.json`),s.raw);for(let[s,i]of n.proposals)F(R(h(r,"proposals",s)),{recursive:!0}),$(h(r,"proposals",s),i)}function Tr(t,e){let n=K(t,e),r=G(h(n,"records")).map(i=>Number(i.slice(0,-5))).sort((i,o)=>i-o).map(i=>{let o=S(h(n,"records",`${i}.json`),"utf8"),a=JSON.parse(o);return{seq:i,raw:o,record:a,hash:re(a)}}),s=new Map;for(let i of Qe(h(n,"proposals")))s.set(Ge(h(n,"proposals"),i),S(i));return{records:r,blobs:new Set,proposals:s}}function Se(t){q(t,{recursive:!0,force:!0});try{wr(R(t))}catch{}}function yn(t,e,n){let r=[],s=a=>{r.push({name:a,src:h(t,a)})},i=[];for(let a of e){s(`commits/${a}`);let c=JSON.parse(S(h(I(t),a),"utf8"));i.push(c);let p=wt(t,re(c));w(p)&&s(Ge(t,p))}let o=h(t,"sessions");if(w(o))for(let a of Qe(o))s(Ge(t,a));for(let a of $r)w(h(t,a))&&s(a);for(let a of G(t))Pt.test(a)&&s(a);for(let a of i){let c=oe(a).proposalId;c!==null&&w(te(t,c))&&s(`proposals/${c}/proposal.json`)}for(let a of $n(t,n))r.push({name:`tests/${fn(a)}`,src:a});return r}function Qe(t){let e=[];for(let n of G(t,{withFileTypes:!0})){let r=h(t,n.name);n.isDirectory()?e.push(...Qe(r)):n.isFile()&&e.push(r)}return e}function Nr(t,e){let n=h(e.backup,"manifest.json");if(w(n))return JSON.parse(S(n,"utf8"));let r=[];F(e.backup,{recursive:!0}),y(R(e.backup)),y(R(R(e.backup)));let s=(i,o)=>{let a=h(e.backup,i);F(R(a),{recursive:!0}),$(a,o),r.push({name:i,hash:z(o)})};for(let{name:i,src:o}of yn(t,e.moved,e.testIds??[]))s(i,S(o));return s("base-witness.json",Buffer.from(JSON.stringify({name:e.name,base:e.base,storage:e.storage,from:e.at},null,2)+`
|
|
20
|
-
`)),$(h(e.backup,"manifest.json"),JSON.stringify(r,null,2)+`
|
|
21
|
-
`),r}function Pr(t,e){if(!w(h(I(t),Ze(e.base.seq,e.base.hash))))throw new Error(`the record at position ${e.base.seq} is not the one the reset was planned on \u2014 nothing removed; run kane-cli context sync doctor`);let n=e.manifest.filter(r=>r.name.startsWith("commits/")).sort((r,s)=>r.name<s.name?1:-1);for(let{name:r,hash:s}of n){let i=h(t,r);if(w(i)){if(z(S(i))!==s)throw new Error(`${i} does not match the backup manifest \u2014 not removed; run kane-cli context sync doctor`);q(i)}}y(I(t));for(let{name:r}of e.manifest)r.startsWith("intents/")&&q(h(t,r),{force:!0})}function Sn(t,e){return G(I(t)).filter(n=>kr.test(n)&&n!==Ie&&Number(n.slice(0,6))>e.base.seq).sort()}function Lr(t,e,n,r){let s=Sn(t,e).at(-1),i=e.base;if(s!==void 0){let o=n.records.find(a=>s===Ze(a.seq,a.hash));if(!o)throw new Error(`commits/${s} is neither the base nor a staged record \u2014 run kane-cli context sync doctor`);i={seq:o.seq,hash:o.hash}}Ye(t,{...n,records:n.records.filter(o=>o.seq>i.seq)},i.hash,e.name,{lockHeld:!0,underReset:{nonce:e.nonce},afterChunk:r})}function Fr(t,e){let n=new Map(e.manifest.filter(o=>o.name.startsWith("commits/")).map(o=>[o.name.slice(8),o.hash])),r=h(K(t,e.nonce),"records"),s=new Set(w(r)?G(r).map(o=>z(S(h(r,o)))):[]),i=[];for(let o of Sn(t,e)){let a=z(S(h(I(t),o)));if(n.get(o)!==a){if(!s.has(a))throw new Error(`commits/${o} is neither an original of this store nor a staged record \u2014 nothing changed; ask for help before touching commits/`);i.push(o)}}for(let o of i.reverse())q(h(I(t),o));return i.length>0&&y(I(t)),i.length}function Jr(t,e,n,r){let s=new Set;for(let a of e.slice(r-1))for(let c of a.nodes)c.label==="test"&&s.add(c.cid);if(s.size===0)return[];let i=Te();Ne(t,i,e,n,{writeNodeFiles:!1});let o=a=>{let c=new Set;for(let p=a;;){let d=i.superseded[p];if(typeof d!="string"||c.has(d))return p;c.add(d),p=d}};return Object.entries(i.names).filter(([,a])=>s.has(o(a))).map(([a])=>a).sort()}function $n(t,e){if(e.length===0)return[];let n=ze(je(R(t)));return e.flatMap(r=>n.get(r)??[])}function Mr(t,e){let n=[];for(let r of $n(t,e.testIds??[]))w(r)&&($e(r,`${r}.quarantined-${e.ts}`),n.push(r));return n}function _o(t,e,n,r){let s=`${h(v(t),Ke(e))}.pending-facts.dropped.ndjson`;if(!w(s))return{reparked:0,unmapped:[]};let i=[],o=[];for(let a of S(s,"utf8").split(`
|
|
22
|
-
`).filter(c=>c!=="")){let c;try{c=JSON.parse(a)}catch{continue}let p=(c.facts??[]).flatMap(d=>{let l=d.about_cid?n.get(d.about_cid)??d.about_cid:d.about_cid;if(!l||!r.has(l))return d.about_cid&&o.push(d.about_cid),[];let u=d.per_ac?.map(f=>f.ac_cid?{...f,ac_cid:n.get(f.ac_cid)??f.ac_cid}:f);return[{...d,about_cid:l,...u?{per_ac:u}:{}}]});p.length>0&&i.push(JSON.stringify({...c,facts:p}))}return i.length>0&&ye(h(t,"pending-facts.ndjson"),i.join(`
|
|
23
|
-
`)+`
|
|
24
|
-
`),$e(s,s.replace(/\.dropped\.ndjson$/,".reparked.ndjson")),{reparked:i.reduce((a,c)=>a+JSON.parse(c).facts.length,0),unmapped:o}}function Br(t,e,n){let r=h(t,"pending-facts.ndjson"),s=`${e}.pending-facts.rotated.ndjson`;if(!w(s)){if(!w(r))return 0;F(R(e),{recursive:!0}),$e(r,s)}let i=[],o=[],a=S(s,"utf8").split(`
|
|
25
|
-
`).filter(p=>p!=="");for(let p of a){let d;try{d=JSON.parse(p)}catch{o.push(p);continue}let l=d.facts??[],u=l.filter(f=>f.about_cid!==void 0&&f.about_cid!==""&&!n.has(f.about_cid));u.length===0?o.push(p):u.length===l.length?i.push(p):(i.push(JSON.stringify({...d,facts:u})),o.push(JSON.stringify({...d,facts:l.filter(f=>!u.includes(f))})))}i.length>0&&ye(`${e}.pending-facts.dropped.ndjson`,i.join(`
|
|
26
|
-
`)+`
|
|
27
|
-
`),o.length>0&&ye(r,o.join(`
|
|
28
|
-
`)+`
|
|
29
|
-
`);let c=S(s,"utf8").split(`
|
|
30
|
-
`).filter(p=>p!=="").slice(a.length);return c.length>0&&ye(r,c.join(`
|
|
31
|
-
`)+`
|
|
32
|
-
`),q(s),i.length}var Wr=/^sha256:[0-9a-f]{64}$/,De=class t{m=new Map;get size(){return this.m.size}set(e,n){this.m.set(e,n)}get(e){return this.m.get(e)}rewrite(e){if(typeof e=="string")return Wr.test(e)?this.m.get(e)??e:e;if(Array.isArray(e))return e.map(n=>this.rewrite(n));if(e!==null&&typeof e=="object"){let n={};for(let[r,s]of Object.entries(e))n[r]=this.rewrite(s);return n}return e}toJSON(){return Object.fromEntries(this.m)}static fromJSON(e){let n=new t;for(let[r,s]of Object.entries(e??{}))n.set(r,s);return n}},et=class t{m=new Map;set(e,n){this.m.set(e.hash,{orig:e,fate:n})}get(e){let n=this.m.get(e.hash);return n&&n.orig.seq===e.seq?n.fate:void 0}byHash(e){return this.m.get(e)?.fate}toJSON(){return[...this.m.values()]}static fromJSON(e){let n=new t;for(let r of e??[])n.set(r.orig,r.fate);return n}},Rn=t=>({cid:t.cid.toJSON(),record:t.record.toJSON()}),vn=t=>({cid:De.fromJSON(t?.cid),record:et.fromJSON(t?.record)});var Jo=["keep-theirs","apply-mine","apply-mine-as-new"];function nt(t,e,n){switch(e){case"keep-theirs":return t==="generation"?"the local design stays in the backup; after this rebase, run design again if you want both":"the local change stays in the backup";case"apply-mine":return t==="slug"?`the name moves to the local node; the node that holds it on ${n} is reached by its id again`:t==="head"?`retire the source as it is now, ${n}'s version included`:`the local version lands on top of ${n}'s`;case"apply-mine-as-new":return`a new node beside ${n}'s (duplicate check first)`;case"later":return"leaves the rebase open; kane-cli context sync or kane-cli context pull asks again"}}function Mo(t,e,n){return{rebase_id:t,decision_id:e.holdId,kind:e.kind,intent:e.verb,seq:e.orig.seq,label:e.label,location:n,mine:e.mine,theirs:e.theirs,answers:e.answers.map(r=>({answer:r,consequence:nt(e.kind,r,n)}))}}var Bo=t=>({from:(e,n)=>Ot(t,e,n),hashAt:e=>{let n=he(t,e);return n===null||n==="corrupt"?null:n}}),ke=(t,e)=>tt(v(t),`${e}.json`),Gr=(t,e)=>tt(v(t),`${e}.lock`),Z=class t{constructor(e,n){this.contextDir=e;this.data=n;this.maps=vn(n.maps)}maps;static create(e,n,r,s,i){let o=zr(n);if(de(ke(e,o)))throw new x(`rebase ${o} already has a ledger \u2014 run kane-cli context sync or kane-cli context pull to continue it, or kane-cli context sync doctor --abort to close it`);let a=new t(e,{version:1,backup:n,backupId:o,from:s,state:"open",...i?{location:i}:{},items:r.map(p=>({...p})),maps:{cid:{},record:[]},aliases:[]}),c=!de(v(e));return xn(v(e),{recursive:!0}),c&&y(tt(e,"sync")),a.save(),a}static open(e,n){let r=ke(e,n);if(!de(r))throw new x(`no rebase ${n} here \u2014 kane-cli context sync doctor lists the rebases this store has`);let s;try{s=JSON.parse(Re(r,"utf8"))}catch{s=null}if(!$t(s)||typeof s.backup!="string")throw new x(Kr(n));return new t(e,s)}get backupId(){return this.data.backupId}get location(){return this.data.location??"the location"}get rev(){return this.data.rev??0}get backup(){return this.data.backup}get from(){return this.data.from}get state(){return this.data.state}get closedBy(){return this.data.closedBy}get items(){return this.data.items}get aliases(){return this.data.aliases}item(e){let n=this.data.items.find(r=>r.k===e);if(!n)throw new Error(`no replay item ${e}`);return n}itemAt(e){return this.data.items.find(n=>n.orig.seq===e||n.group?.some(r=>r.seq===e))}beginItem(e,n){this.assertOpen();let r=this.item(e);r.begin={expectPrev:n},delete r.outcome,this.save()}endItem(e,n){this.assertOpen(),this.item(e).outcome=n,this.save()}pendingItem(){return this.data.items.find(e=>e.begin!==void 0&&e.outcome===void 0)}reconcileAll(e,n){let r=this.item(e);if(!r.begin)return[];let s=r.origins??Object.fromEntries((r.group??[r.orig]).map(c=>[c.hash,c.seq])),{records:i,hashes:o}=n.from(r.begin.expectPrev.seq,r.begin.expectPrev.hash),a=[];return i.forEach((c,p)=>{let d=c.replayed_from===void 0?void 0:s[c.replayed_from.orig.hash];d!==void 0&&a.push({seq:c.seq,hash:o[p],member:d})}),a}reconcileFrom(e,n,r){let s=this.item(e),i=s.origins??Object.fromEntries((s.group??[s.orig]).map(p=>[p.hash,p.seq])),{records:o,hashes:a}=n.from(r.seq,r.hash),c=[];return o.forEach((p,d)=>{let l=p.replayed_from===void 0?void 0:i[p.replayed_from.orig.hash];l!==void 0&&c.push({seq:p.seq,hash:a[d],member:l})}),c}reconcile(e,n){let r=this.reconcileAll(e,n).at(-1);return r?{seq:r.seq,hash:r.hash}:void 0}lastAppliedInChain(e){for(let n of[...this.data.items].reverse()){let r=n.outcome;if(r&&"applied"in r)return e.hashAt(r.applied.newSeq)===r.applied.newHash;if(r&&"deduped"in r&&r.deduped.newSeq!==void 0)return e.hashAt(r.deduped.newSeq)===r.deduped.newHash}return!0}setMaps(e){this.maps=e,this.data.maps=Rn(e),this.save()}addAlias(e){this.data.aliases.push(e),this.save()}listHolds(){return this.data.items.flatMap(e=>e.outcome&&"held"in e.outcome?[e.outcome.held]:[])}resolveHold(e,n){let r=this.heldItem(e);if(!r.outcome.held.answers.includes(n))throw new x(`${n} is not an answer ${e} accepts`);return r.answer=n,this.reopen(r)}reopenHold(e){let n=this.heldItem(e);return delete n.answer,this.reopen(n)}heldItem(e){this.assertOpen();let n=this.data.items.find(r=>r.outcome&&"held"in r.outcome&&r.outcome.held.holdId===e);if(!n)throw new x(`${e} is not an open decision \u2014 kane-cli context sync status lists them`);return n}reopen(e){return delete e.outcome,delete e.begin,this.save(),e}close(e){this.data.state="closed",this.data.closedBy=e,this.save()}toJSON(){return structuredClone(this.data)}assertOpen(){if(this.data.state!=="open")throw new x(`rebase ${this.data.backupId} is closed \u2014 kane-cli context sync doctor lists every rebase and what it reapplied`)}save(){let e=ke(this.contextDir,this.data.backupId);if(de(e)){let n=0;try{n=JSON.parse(Re(e,"utf8")).rev??0}catch{n=0}if(n>(this.data.rev??0))throw new x(`the replay ledger for ${this.data.backupId} changed on disk (rev ${n}, this process holds rev ${this.data.rev??0}) \u2014 another process is working on it; run the command again`)}this.data.rev=(this.data.rev??0)+1,$(e,JSON.stringify(this.data,null,2)+`
|
|
33
|
-
`)}};function Wo(t,e){let n=Gr(t,e);xn(v(t),{recursive:!0});let r=jr(6).toString("hex");for(;;)try{return Ur(n,JSON.stringify({pid:process.pid,nonce:r}),{flag:"wx"}),()=>{try{JSON.parse(Re(n,"utf8")).nonce===r&&En(n)}catch{}}}catch(s){if(s.code!=="EEXIST")throw s;let i={};try{i=JSON.parse(Re(n,"utf8"))}catch{i={}}if(typeof i.pid=="number"&&ne(i.pid))throw new x(`rebase ${e} is being worked on by pid ${i.pid} \u2014 wait for it to finish`);En(n,{force:!0})}}var Ho=(t,e,n,r,s)=>Z.create(t,e,n,r,s),Uo=(t,e)=>Z.open(t,e),Kr=t=>`rebase ${t} has a ledger this store cannot read (sync/replay/${t}.json) \u2014 ${St}`,On=t=>{let e=v(t);return de(e)?Hr(e).filter(n=>n.endsWith(".json")&&!n.endsWith(".receipt.json")).sort().reverse().map(n=>n.slice(0,-5)):[]};function Zr(t,e={}){let n=[];for(let r of On(t))try{n.push(Z.open(t,r))}catch(s){if(!e.tolerant)throw s}return n}function Yo(t){return On(t).filter(e=>{try{return Z.open(t,e),!1}catch{return!0}})}function jo(t,e){let n=ke(t,e),r=`${n}.unreadable`;return Yr(n,r),y(v(t)),r}function kn(t){return Zr(t).find(e=>e.state==="open")}function Xr(t){let e=t.outcome;return e?"applied"in e?`reapplied \u2192 record ${e.applied.newSeq}`:"held"in e?`decision ${e.held.holdId} (${e.held.kind})`:"deduped"in e?`already present: ${e.deduped.as.slice(0,19)}`:`not reapplied: ${e.skipped.reason}`:t.begin?"pending":"waiting"}function zo(t,e,n={}){let r=t.itemAt(e);if(!r)throw new x(`no moved record at position ${e} in rebase ${t.backupId}`);let s=r.label.startsWith(`${r.verb} `)||r.label===r.verb?r.label:`${r.verb} ${r.label}`,i=[`record ${r.orig.seq}: ${s}`,`origin ${r.orig.hash}`,`outcome: ${Xr(r)}`];if(r.group&&i.push(`group: records ${r.group.map(o=>o.seq).join(", ")}`),r.outcome&&"held"in r.outcome){let o=r.outcome.held,a=Math.max(5,t.location.length)+1;i.push(`${"local:".padEnd(a+1)}${o.mine}`,`${`${t.location}:`.padEnd(a+1)}${o.theirs}`,`choose: ${o.answers.join(", ")}`),n.detail!==!1&&i.push(JSON.stringify(o.detail,null,2))}return i}var m=D(ue(),1);function _n(t,e,n){let r={"keep-theirs":`keep ${n}'s version`,"apply-mine":"apply the local version","apply-mine-as-new":"add the local version as new",later:"decide later"},s=t.answers.map(i=>({key:i,answer:i,label:r[i],detail:e(i)}));return s.push({key:"later",answer:"later",label:r.later,detail:e("later")}),s}function X({label:t,text:e,accent:n}){return(0,m.jsxs)(b,{children:[(0,m.jsx)(b,{color:O.dim,children:` ${t.padEnd(15)}`}),(0,m.jsx)(b,{color:n?O.assuranceAccent:void 0,children:e})]})}function In({card:t,index:e,total:n,rebaseId:r,location:s,diff:i,rows:o,sel:a,focused:c,expanded:p}){let d=Math.max(...(i??[]).map(l=>Math.max(l.was.length,l.local.length,l.origin.length)),8);return(0,m.jsxs)(U,{flexDirection:"column",children:[(0,m.jsxs)(b,{bold:!0,children:[`decision ${e} of ${n}`,(0,m.jsx)(b,{color:O.dim,children:` \xB7 ${t.kind} on your ${t.verb} from record ${t.orig.seq}`})]}),i&&i.length>0?(0,m.jsxs)(U,{flexDirection:"column",children:[(0,m.jsx)(b,{color:O.dim,children:` ${"".padEnd(12)}${"was".padEnd(d+2)}${"local".padEnd(d+2)}${s}`}),i.map(l=>(0,m.jsxs)(b,{children:[(0,m.jsx)(b,{color:O.dim,children:` ${l.field.padEnd(12)}`}),l.was.padEnd(d+2),(0,m.jsx)(b,{color:O.assuranceAccent,children:l.local.padEnd(d+2)}),l.origin]},l.field))]}):(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(X,{label:"local",text:t.mine,accent:!0}),(0,m.jsx)(X,{label:s,text:t.theirs})]}),p?p.map((l,u)=>(0,m.jsx)(b,{color:O.dim,children:` ${l}`},`x-${u}`)):null,(0,m.jsx)(Me,{headline:`what should happen to the local ${t.verb} from record ${t.orig.seq}`,ask:!0,rows:o,sel:a,focused:c}),(0,m.jsx)(b,{color:O.dim,children:" \u2191\u2193 select \xB7 \u23CE confirm \xB7 1\u20139 jump \xB7 v full record \xB7 a decide everything later \xB7 ctrl+c pause"})]})}function qn({name:t,count:e,from:n,backupPath:r,taking:s,sel:i,focused:o}){let a=[{key:"continue",label:"continue",detail:"save, take, reapply"},{key:"not-now",label:"not now",detail:"nothing changes"}];return(0,m.jsxs)(U,{flexDirection:"column",children:[(0,m.jsx)(b,{bold:!0,children:`rebase from ${t}`}),(0,m.jsx)(X,{label:"local",text:`${e} record${e===1?"":"s"} from position ${n} saved to ${r}`}),(0,m.jsx)(X,{label:t,text:`records ${s.from}..${s.to} taken into this store`}),(0,m.jsx)(X,{label:"then",text:"the local records reapplied on top; a disagreement becomes a decision you answer"}),(0,m.jsx)(X,{label:"never",text:`history on ${t} rewritten`}),(0,m.jsx)(Me,{headline:"continue",ask:!0,rows:a,sel:i,focused:o}),(0,m.jsx)(b,{color:O.dim,children:" \u2191\u2193 select \xB7 \u23CE confirm \xB7 esc not now"})]})}var E=D(ue(),1);function Vr(t){let e=t.detail,n=c=>c&&typeof c=="object"&&!Array.isArray(c)?c:null,r=n(e.was),s=n(e.mine),i=n(e.theirs);if(!r||!s||!i)return[];let o=c=>c==null?"":typeof c=="string"?c:JSON.stringify(c);return[...new Set([...Object.keys(r),...Object.keys(s),...Object.keys(i)])].filter(c=>o(s[c])!==o(r[c])||o(i[c])!==o(r[c])).map(c=>({field:c,was:o(r[c]),local:o(s[c]),origin:o(i[c])}))}function oi(t,e,n,r){let s={"keep-theirs":`kept ${n}'s version`,"apply-mine":"applied the local version","apply-mine-as-new":"added the local version as new",later:"decided later","later-all":"decided later"},i=r&&"deduped"in r?`already present on ${n}`:r&&"skipped"in r&&e!=="keep-theirs"?`not reapplied (${r.skipped.reason})`:s[e];return`decision ${t.holdId}: ${i}`}var rt=class{screen={kind:"idle"};version=0;interrupted=!1;scrollback={current:null};listeners=new Set;subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e));set(e){this.screen=e,this.emit()}note(e){this.scrollback.current?.append((0,E.jsx)(b,{children:e}))}flush(){return this.scrollback.current?.flush()??Promise.resolve()}emit(){this.version+=1;for(let e of this.listeners)e()}};function Qr(t){return(0,V.useSyncExternalStore)(t.subscribe,()=>t.version),t.screen}function Dr({ask:t,rows:e,done:n}){let[r,s]=(0,V.useState)(0),[i,o]=(0,V.useState)(!1);pe((c,p)=>{if(p.ctrl&&c==="c")return n("later-all");if(p.escape)return n("later");if(c==="a")return n("later-all");if(c==="v")return o(l=>!l);if(p.upArrow)return s(l=>Math.max(0,l-1));if(p.downArrow)return s(l=>Math.min(e.length-1,l+1));if(p.return)return n(e[r].answer);let d=Number(c);Number.isInteger(d)&&d>=1&&d<=e.length&&s(d-1)});let a=Vr(t.card);return(0,E.jsx)(In,{card:t.card,index:t.index,total:t.total,rebaseId:t.rebaseId,location:t.location,diff:a,rows:e,sel:r,focused:!0,expanded:i?t.record:void 0})}function es({ask:t,done:e}){let[n,r]=(0,V.useState)(0);return pe((s,i)=>{if(i.ctrl&&s==="c"||i.escape)return e(!1);if(i.upArrow)return r(0);if(i.downArrow)return r(1);if(s==="1")return r(0);if(s==="2")return r(1);if(i.return)return e(n===0)}),(0,E.jsx)(qn,{...t,sel:n,focused:!0})}function ts({store:t}){return pe((e,n)=>{n.ctrl&&e==="c"&&(t.interrupted=!0)}),null}function ns({store:t}){let e=Qr(t);return e.kind==="decide"?(0,E.jsx)(Dr,{ask:e.ask,rows:e.rows,done:e.done},e.ask.card.holdId):e.kind==="confirm"?(0,E.jsx)(es,{ask:e.ask,done:e.done}):(0,E.jsx)(ts,{store:t})}function rs({store:t}){return(0,E.jsxs)(it,{children:[(0,E.jsx)(Jt,{into:t.scrollback}),(0,E.jsx)(U,{flexDirection:"column",children:(0,E.jsx)(ns,{store:t})})]})}function ss(t,e){return _n(t,n=>nt(t.kind,n,e),e)}function An(){let t=new rt,e=null,n=async()=>{if(e)return;let{render:s}=await import("./build-JIKYOZUH.js");e=s((0,E.jsx)(rs,{store:t}),{exitOnCtrlC:!1}),at(()=>e?.unmount())},r=async()=>{if(!e)return;let s=e;e=null,await t.flush();let i=s.waitUntilExit().catch(()=>{});s.unmount(),await i,ct()};return{async confirm(s){await n();let i=await new Promise(o=>t.set({kind:"confirm",ask:s,done:o}));return t.set({kind:"idle"}),await r(),i},async decide(s){await n();let i=await new Promise(o=>t.set({kind:"decide",ask:s,rows:ss(s.card,s.location),done:o}));return t.set({kind:"idle"}),i},note(s){t.note(s)},close:r,interrupted:()=>t.interrupted}}import{resolve as os}from"path";import{fileURLToPath as is,pathToFileURL as as}from"url";var cs="us-east-1",ds=/^[a-zA-Z][a-zA-Z0-9+.-]*:\/\//,xe="use file:///abs/path, an absolute or relative directory path, s3://<bucket>/<prefix>?endpoint=<url>®ion=<region>, or a GitHub HTTPS/SSH repository URL";function Tn(t,e){let n=t.trim();if(n==="")throw new Error(`a location is required \u2014 ${xe}`);if(/^(?:git\+)?https:\/\//i.test(n)||/^(?:git\+)?ssh:\/\//i.test(n)||/^[^/\s@:]+@[^/\s:]+:/.test(n)||n.startsWith("git+scp://"))return us(n);if(!ds.test(n))return Cn(os(e,n));let r=new URL(n);switch(r.protocol){case"fake:":if(r.hostname==="")throw new Error(`fake:// needs a name \u2014 ${xe}`);return{kind:"fake",location:`fake://${r.hostname}`};case"file:":return Cn(is(r));case"s3:":return ls(r);default:throw new Error(`this release does not speak "${r.protocol}" \u2014 ${xe}`)}}function Cn(t){return{kind:"dir",location:as(t).href,path:t}}function ls(t){let e=t.hostname;if(e==="")throw new Error(`an s3 location needs a bucket \u2014 ${xe}`);let n=t.pathname.replace(/^\/+/,"").replace(/\/+$/,""),r=n===""?"":`${n}/`,s=t.searchParams.get("region")||cs;if(!/^[A-Za-z0-9-]{1,64}$/.test(s))throw new Error("the region must be letters, digits and dashes only, like us-east-1");let i=t.searchParams.get("endpoint"),o=i===null||i===""?null:ps(i),a=o===null?`?region=${s}`:`?endpoint=${o}®ion=${s}`,c={kind:"s3",location:`s3://${e}/${r}${a}`,bucket:e,prefix:r,region:s};return o!==null&&(c.endpoint=o),c}function ps(t){let e="the endpoint must be an http URL like http://127.0.0.1:9000",n;try{n=new URL(t)}catch{throw new Error(e)}if(n.protocol!=="http:"&&n.protocol!=="https:")throw new Error(e);if(n.username||n.password)throw new Error("an endpoint never carries a user name or password; pass credentials with --credential-env or --credential-file");if(n.search!==""||n.hash!==""||n.pathname!=="/")throw new Error(`the endpoint must be a host and port only, with no path or query \u2014 got ${n.origin}`);return`${n.protocol}//${n.host}`}var ve="Use a Git repository address with no dot or parent segments";function Ee(t){return t.split("/").some(e=>e==="."||e==="..")}function us(t){if(/[\x00-\x20\x7f]/.test(t))throw new Error("A Git location cannot contain whitespace or control characters");let e=t;if(e.startsWith("git+scp://")){let u=e.slice(10).replace(/[?#].*$/,"").replace(/^[^/]*/,"");if(Ee(u.slice(1)))throw new Error(ve);let f=new URL(e);e=`${decodeURIComponent(f.username)}@${f.hostname}:${f.pathname.slice(1)}${f.search}${f.hash}`}else e=e.replace(/^git\+/,"");let n=e.indexOf("#"),r=n<0?"main":decodeURIComponent(e.slice(n+1)),s=n<0?e:e.slice(0,n),i=s.indexOf("?"),o=i<0?s:s.slice(0,i),a=new URLSearchParams(i<0?"":s.slice(i+1));for(let u of a.keys())if(u!=="prefix")throw new Error("https: and ssh: Git locations accept only the prefix query option; never put credentials in a location");if(a.getAll("prefix").length>1)throw new Error("Only one Git prefix may be supplied");let c=a.get("prefix")??"";if(c&&(!/^[a-zA-Z0-9_~./-]+$/.test(c)||c.split("/").some(u=>!u||u==="."||u===".."||u.toLowerCase()===".git")))throw new Error("Use a relative Git prefix with no empty, dot or parent segments");if(!/^[A-Za-z0-9][A-Za-z0-9._/-]*$/.test(r)||r.includes("..")||r.includes("//")||r.endsWith(".")||r.split("/").some(u=>!u||u.startsWith(".")||u.endsWith(".lock")))throw new Error("Use a valid Git branch name");let p=/^([^/@:]+)@([^/:]+):(.+)$/.exec(o),d;if(p){if(!/^[A-Za-z0-9._-]+$/.test(p[1])||!/^[A-Za-z0-9.-]+$/.test(p[2])||!/^[A-Za-z0-9_~./-]+$/.test(p[3]))throw new Error("Use a valid SSH repository address");if(Ee(p[3]))throw new Error(ve);d=`git+scp://${p[1]}@${p[2]}/${p[3]}`}else{if(Ee(o.replace(/^[a-zA-Z][a-zA-Z0-9+.-]*:\/\/[^/]*/,"")))throw new Error(ve);let u=new URL(o);if(!["https:","ssh:"].includes(u.protocol)||!u.hostname||!u.pathname||u.pathname==="/"||u.password||u.protocol==="https:"&&u.username)throw new Error("Use a secret-free HTTPS or SSH repository URL; sign in through Git instead");if(/%(?:00|0a|0d)/i.test(u.pathname))throw new Error("Invalid repository path");if(Ee(u.pathname))throw new Error(ve);o=u.href,d=`git+${u.href}`}let l=c?`?${new URLSearchParams({prefix:c})}`:"";return{kind:"git",gitUrl:o,branch:r,prefix:c,location:`${d}${l}#${encodeURIComponent(r)}`}}function di(t){if(t.kind==="dir")return t.path;if(t.kind!=="git")return t.location;let e=t.prefix?`?${new URLSearchParams({prefix:t.prefix})}`:"",n=t.branch&&t.branch!=="main"?`#${encodeURIComponent(t.branch)}`:"";return`${t.gitUrl}${e}${n}`}function st(t,e){(t.err??t.out)(`error: ${e}`)}function $i(t,e){let n=Nt(t);return fs(n)?n:(st(e,"no context store here (run `kane-cli context ingest <files>` first)"),null)}async function ki(t,e,n){return n?!0:t.isTTY?t.confirm(`${e}?`):(st(t,`refusing to ${e} without --yes (no TTY to confirm)`),!1)}function Ri(){return{out:t=>process.stdout.write(t+`
|
|
34
|
-
`),err:t=>process.stderr.write(t+`
|
|
35
|
-
`),isTTY:Ft(),walkUI:An,confirm:async t=>{let{createInterface:e}=await import("readline/promises"),n=e({input:process.stdin,output:process.stdout});try{let r=await n.question(`${t} [y/N] `);return/^y(es)?$/i.test(r.trim())}catch(r){if(r.name==="AbortError")return!1;throw r}finally{n.close()}},ask:async t=>{let{createInterface:e}=await import("readline/promises"),n=e({input:process.stdin,output:process.stdout});try{return await n.question(t)}finally{n.close()}}}}var hs=1500;function ms(t,e){return t==="behind"?`${e} has moved past this machine \u2014 run kane-cli context pull ${e}`:`this store and ${e} have diverged \u2014 run kane-cli context pull ${e} --rebase`}async function vi(t,e,n){let r=await gs(t,n);r&&e(r.text)}async function gs(t,e){if(process.env.KANE_SYNC_GUARD==="0")return null;try{let n=jt(t);if(n.locations.length===0)return null;let r=Gt(n),s=B(t).entries[r.name]?.witness;if(!s)return null;let{openProvider:i}=await import("./open-provider-YIBB77FE.js"),o=i(Tn(r.location,t),r.name,e),a=await Promise.race([ws(t,o,s),bs()]);return a?{text:ms(a.kind,r.name),name:r.name,localSeq:a.localSeq,storageSeq:a.storageSeq}:null}catch{return null}}function Ei(t){return{type:"sync_behind",name:t.name,local_seq:t.localSeq,storage_seq:t.storageSeq,text:t.text}}async function ws(t,e,n){try{let r=L(t),s=r?.seq??0;return await e.head(_(n.seq+1))?{kind:"behind",localSeq:s,storageSeq:(await W(e,n.seq+1)).seq}:r===null||(await ae(e,r.seq)).hash===r.hash?null:{kind:"diverged",localSeq:s,storageSeq:(await W(e,r.seq)).seq}}catch{return null}}function bs(){return new Promise(t=>{setTimeout(()=>t(null),hs).unref()})}function ys(t){try{return Rt(t),null}catch(e){if(e instanceof kt)return{code:e.code,text:e.message,remedy:e.remedy};throw e}}function xi(t){return{type:"sync_error",code:t.code,detail:t.text,remedy:t.remedy}}function Oi(t,e){let n=ys(t);return n?(st(e,n.text),(e.err??e.out)(`next: ${n.remedy}`),!0):!1}export{oe as a,Be as b,jt as c,Es as d,B as e,zt as f,Gt as g,xs as h,ae as i,W as j,en as k,Qs as l,He as m,sn as n,je as o,ze as p,oo as q,vr as r,Er as s,xr as t,v as u,Ke as v,mn as w,xo as x,Oo as y,dn as z,_o as A,Jo as B,Mo as C,Bo as D,Wo as E,Ho as F,Uo as G,Zr as H,Yo as I,jo as J,kn as K,zo as L,oi as M,Tn as N,di as O,st as P,$i as Q,ki as R,Ri as S,vi as T,gs as U,Ei as V,ys as W,xi as X,Oi as Y};
|
package/dist/chunk-HG5LLZBU.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{b as s}from"./chunk-XT7XA4DN.js";import{promises as o}from"fs";import{basename as d,join as a}from"path";function l(t){let e=(t??"").trim().replace(/^lt:\/\//i,"").trim();if(e)return(s(e)?e:d(e))||void 0}function g(t){return t.replace(/\([^)]*\)/g," ").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||void 0}async function w(t){try{let e=a(t,"steps"),u=(await o.readdir(e,{withFileTypes:!0})).filter(n=>n.isDirectory()).map(n=>n.name).sort((n,i)=>(parseInt(n,10)||0)-(parseInt(i,10)||0));for(let n of u)try{let i=await o.readFile(a(e,n,"step.json"),"utf8"),r=JSON.parse(i).basis?.window;if(Array.isArray(r)&&r.length===2&&Number.isFinite(Number(r[0]))&&Number.isFinite(Number(r[1]))&&Number(r[0])>0&&Number(r[1])>0)return`${Math.round(Number(r[0]))}x${Math.round(Number(r[1]))}`}catch{}return}catch{return}}export{l as a,g as b,w as c};
|
package/dist/chunk-I7TIGB7K.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{c as v}from"./chunk-UD7KKHPW.js";var E=.8,y="usecase-dedup";function w(n,r){let i=Math.min(n.length,r.length),u=0,s=0,c=0;for(let e=0;e<i;e++)u+=n[e]*r[e],s+=n[e]*n[e],c+=r[e]*r[e];return s===0||c===0?0:u/(Math.sqrt(s)*Math.sqrt(c))}function C(n,r,i){return i*n+(1-i)*r}var D=.7;function A(n){return new Set(n.toLowerCase().replace(/[^\p{L}\p{N}]+/gu," ").split(" ").filter(Boolean))}function R(n,...r){let i=A(n);if(i.size===0)return 0;let u=n.trim().toLowerCase(),s=0;for(let c of r){let e=A(c);if(e.size===0)continue;let p=0;for(let b of i)e.has(b)&&p++;let m=i.size+e.size-p,d=m===0?0:p/m;u&&c.toLowerCase().includes(u)&&(d=Math.max(d,.9)),s=Math.max(s,d)}return s}var S=n=>String(n.title??"");function _(n){return n.byLabel("usecase").filter(r=>!n.superseded.has(r.cid)).map(r=>({cid:r.cid,text:S(r.content)}))}function L(n,r){let i=r.threshold??E,u=new Map,s=null;return{async batchSimilar(c,e){let p=c.latestHash;if(e.length===0)return{hits:[],degraded:!1,probeBasis:p};let m=_(c),d=[];try{s=(await r.resolveAlias(y)).alias;let f=new Map,g=[];for(let t of m){let a=r.readVector?.(s,t.cid)??null;a!==null?f.set(t.cid,a):g.push(t)}let o=[...e.map(t=>t.probeText),...g.map(t=>t.text)],{vectors:P}=await r.embed(y,o);e.forEach((t,a)=>u.set(t.tempRef,Float32Array.from(P[a]))),g.forEach((t,a)=>{let l=Float32Array.from(P[e.length+a]);f.set(t.cid,l),r.writeVector?.(s,t.cid,l)});for(let t of e){let a=u.get(t.tempRef);for(let l of m){let x=f.get(l.cid);if(x===void 0)continue;let h=C(w(a,x),R(t.probeText,l.text),D);h>=i&&d.push({tempRef:t.tempRef,candidateCid:l.cid,score:h,scorer:"embedding"})}}return{hits:d,degraded:!1,probeBasis:p}}catch(b){v(JSON.stringify({event:"dedup_probe_degraded",contextDir:n,candidates:e.length,reason:String(b?.message??b).slice(0,160),ts:new Date().toISOString()}),"DEDUP_PROBE_DEGRADED");for(let f of e)for(let g of m){let o=R(f.probeText,g.text);o>=i&&d.push({tempRef:f.tempRef,candidateCid:g.cid,score:o,scorer:"lexical_fallback"})}return{hits:d,degraded:!0,probeBasis:p}}},recheckLocal(c,e,p,m){let d=[],b=[],f=new Set;for(let g of m)for(let o of g.nodes){if(o.label!=="usecase"||f.has(o.cid)||(f.add(o.cid),c.superseded.has(o.cid)||!c.hasNode(o.cid)))continue;let P=S(o.content),t=s!==null?r.readVector?.(s,o.cid)??null:null,a=t!==null;for(let l of e){let x=u.get(l.tempRef),h;t!==null&&x!==void 0?h=C(w(x,t),R(l.probeText,P),D):(h=R(l.probeText,P),a=a&&!1),h>=i&&d.push({tempRef:l.tempRef,candidateCid:o.cid,score:h,scorer:t!==null&&x!==void 0?"embedding":"lexical_fallback"})}a||b.push(o.cid)}return{hits:d,uncachedNewNodes:b}}}}export{L as a};
|
package/dist/chunk-IICT4VOU.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as De}from"./chunk-D6E6KRVX.js";import{a as we,e as Te}from"./chunk-3UI5VTQS.js";import{H as ge,M as re,T as xe,X as Oe,c as ne,d as K,f as fe,m as te,p as be,x as Se}from"./chunk-RDHWNSDP.js";import{f as se,g as O,h as ie,i as ae,j as pe}from"./chunk-XLSOQLVT.js";function Ge(t,i){let r=t.toLowerCase().trim().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"");if(r.length>60){let c=r.lastIndexOf("-",60);r=(c>0?r.slice(0,c):r.slice(0,60)).replace(/-+$/g,"")}if(!le.test(r))return null;let e=r;for(let c=2;i(e);c++)e=`${r}-${c}`;return le.test(e)?e:null}var Le={source:"src",usecase:"uc",scenario:"sc",ac:"ac",test:"t",gap:"gap",stylenote:"sty"};function Ze(t,i,r){let e=Le[t];return Ge(e?`${e} ${i}`:i,r)}var Ue={usecase:"uc",scenario:"sc",ac:"ac",test:"t",gap:"gap",stylenote:"sty"},ke=/^(uc|sc|ac|t|gap|sty)-\d+$/i;function Ae(t,i,r){let e=Ue[t];if(!e)return null;let c=new RegExp(`^${e}-(\\d+)$`),p=0;for(let d of r){let a=c.exec(d);if(!a)continue;let n=Number(a[1]);Number.isSafeInteger(n)&&n>p&&(p=n)}let o=p+1;for(;i(`${e}-${o}`);)o+=1;return`${e}-${o}`}import{existsSync as Fe,readFileSync as je}from"fs";function ot(t){return He(t,Oe(t))}function He(t,i,r){let e=new Map(Object.entries(i.heads)),c=new Map(Object.entries(i.trust)),p=new Map(Object.entries(i.nodeLabel)),o=new Map(Object.entries(i.superseded)),d=new Map(Object.entries(i.names)),a=new Map(Object.entries(i.archivedReason)),n=new Set(i.appliedEvents),E=new Map(Object.entries(i.conv)),f=l=>i.media[l]??{format:"text",media_type:"text/plain",anchors_supported:["L-L"]},_=new Map;for(let[l,m]of d)_.set(m,l);let g=new Map,C=l=>{if(g.has(l))return g.get(l);if(!p.has(l))return g.set(l,null),null;let m=r?.get(l);if(m)return g.set(l,m),m;let I=xe(t,l);if(!Fe(I))throw new be(`derived node file missing for ${l} \u2014 run kane-cli context rebuild`);let R=JSON.parse(je(I,"utf8"));return g.set(l,R),R},v=l=>{let m=l,I=new Set;for(;o.has(m)&&!I.has(m);){I.add(m);let R=o.get(m);if(typeof R!="string")break;m=R}return m},w=null,N=l=>{let m=_.get(l);if(m!==void 0)return m;if(w===null){w=new Map;for(let[F,A]of o)typeof A=="string"&&w.set(A,F)}let I=new Set,R=l;for(;!I.has(R);){I.add(R);let F=w.get(R);if(F===void 0)return null;let A=_.get(F);if(A!==void 0)return A;R=F}return null},T=l=>{ke.test(l)&&(l=l.toLowerCase());let m=e.get(l),I=p.has(l)?l:d.get(l)??(typeof m=="string"?m:void 0);if(I===void 0||!p.has(I))return null;let R=v(I);return{cid:I,tip:R,superseded:o.has(I)||o.has(R)}},G=new Map;for(let l of Object.values(i.forward))for(let m of l){let I=G.get(m.dst);I?I.push(m):G.set(m.dst,[m])}let P=l=>(l??[]).filter(m=>!o.has(m.ecid)),W=l=>P(G.get(l)),L=l=>W(l).filter(m=>m.type===O.DERIVES),X=l=>P(i.forward[l]).some(m=>ae(m.type)?.pin?.comparesTo==="dst_tip"&&o.has(m.dst)),oe=l=>{if(o.has(l))return"superseded";let m=L(l);if(m.length===0)return X(l)?"stale":"fresh";let I=new Map;for(let A of m)I.set(A.props.source_id,A);let R=!1,F=!1;for(let[A,k]of I){let M=e.get(A);if(M!=null&&(R=!0,M!==k.props.source_cid)){let ce=E.get(A)?.chain;(!ce||!ce.includes(k.props.source_cid))&&(F=!0)}}return R?F||X(l)?"stale":"fresh":"orphaned"};return{heads:e,trust:c,nodeLabel:p,superseded:o,names:d,nameOf:_,archivedReason:a,appliedEvents:n,convChains:E,mediaOf:f,extractedSourceCids:new Set(i.extracted),extractionCompleteness:new Map(Object.entries(i.completeness??{}).map(([l,{seq:m,...I}])=>[l,I])),designOf:new Map(Object.entries(i.design_of??{})),designGenerationOf:new Map(Object.entries(i.design_generation??{})),latestHash:i.applied.hash,lastSeq:i.applied.seq,hasNode:l=>p.has(l),getNode:C,byLabel:l=>[...p.entries()].filter(([,m])=>m===l).map(([m])=>({cid:m,content:C(m)?.content??{}})),edgesFrom:l=>P(i.forward[l]),edgesInto:W,derivesInto:L,resolve:T,tipOf:v,displayNameOf:N,stale:oe,staleList:()=>[...p.keys()].map(l=>({cid:l,state:oe(l)})).filter(l=>l.state!=="fresh"),execHistory:l=>{let m=T(l);if(!m)return[];let I=v(m.cid),R=new Set([I]),F=!0;for(;F;){F=!1;for(let[k,M]of o)M!==null&&R.has(M)&&!R.has(k)&&(R.add(k),F=!0)}let A=[];for(let k of Object.entries(i.exec??{}))R.has(k[0])&&A.push(...k[1]);return A.sort((k,M)=>k.started_at<M.started_at?-1:1)},retractedEdgesTouching:l=>{let m=new Set([v(l),l]),I=!0;for(;I;){I=!1;for(let[k,M]of o)typeof M=="string"&&m.has(M)&&!m.has(k)&&(m.add(k),I=!0)}let R=i.edgeRetractions??{},F=[],A=new Set;for(let k of m)for(let M of[...i.forward[k]??[],...G.get(k)??[]]){let ce=R[M.ecid];!ce||A.has(M.ecid)||(A.add(M.ecid),F.push({...M,retraction:ce}))}return F}}}function ct(t,i){if(t.stale(i)!=="stale")return!1;let r=new Map;for(let e of t.derivesInto(i))r.set(e.props.source_id,e);for(let[e,c]of r){let p=t.heads.get(e);if(p==null||p===c.props.source_cid)continue;let o=t.convChains.get(e)?.chain;if(!o||!o.includes(c.props.source_cid))return!0}for(let e of t.edgesFrom(i)){if(ae(e.type)?.pin?.comparesTo!=="dst_tip"||!t.superseded.has(e.dst))continue;let c=t.tipOf(e.dst);if(t.superseded.has(c)||t.nodeLabel.get(c)==="usecase")return!0}return!1}function he(t,i){let r=new Map;for(let[o,d]of t.superseded)typeof d=="string"&&d!==o&&r.set(d,[...r.get(d)??[],o]);let e=[],c=[i],p=new Set;for(;c.length>0;){let o=c.pop();p.has(o)||(p.add(o),e.push(o),c.push(...r.get(o)??[]))}return e}function qe(t,i){return(t.extraction_claims??[]).some(r=>r.source_id===i&&r.completeness==="complete")}function Ke(t,i){let r=new Set;for(let e of he(t,i))for(let c of t.derivesInto(e))r.add(c.props?.source_id??"conversation");return r}function ye(t,i){let r=[],e=[],c=t.archived??[];if(c.length===0)return{valid:r,errors:e};let p=new Set([...t.source?[t.source.source_id]:[],...(t.sources??[]).map(d=>d.source_id)]),o=new Set;for(let d of t.use_cases){if(!d.matches_existing)continue;let a=i.resolve(d.matches_existing.cid);a&&o.add(i.tipOf(a.cid))}for(let d of c){let a=`archived[${d.target}]`,n=i.resolve(d.target),E=n?i.tipOf(n.cid):null;if(!E||(i.trust.get(E)??null)==="archived"){e.push({code:"ARCHIVE_TARGET_UNKNOWN",detail:`${a}: target does not resolve to an existing, live item`});continue}let f=Ke(i,E);if(!f.has(d.basis)){e.push({code:"ARCHIVE_FOREIGN_PROVENANCE",detail:`${a}: its provenance does not include ${d.basis} \u2014 an archive claim must come from a source that evidences the item`});continue}if(!p.has(d.basis)){e.push({code:"ARCHIVE_WITHOUT_COMPLETE_CLAIM",detail:`${a}: ${d.basis} was not read by this extraction \u2014 a completeness claim only counts for a source this run actually read`});continue}if(!qe(t,d.basis)){e.push({code:"ARCHIVE_WITHOUT_COMPLETE_CLAIM",detail:`${a}: archiving needs an EXPLICIT complete extraction claim for ${d.basis} (the omitted-claims default does not count) \u2014 add extraction_claims`});continue}if(o.has(E)){e.push({code:"ARCHIVE_TARGET_MATCHED",detail:`${a}: 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 _=[...f].filter(g=>g!==d.basis);if(_.length>0){e.push({code:"ARCHIVE_OTHER_LIVE_EVIDENCE",detail:`${a}: still evidenced by ${_.join(", ")} \u2014 an item another live source evidences is never archived from here`});continue}r.push({op:d,cid:E})}return{valid:r,errors:e}}function Ce(t,i,r){return t.superseded.has(r)}function Me(t){let{graph:i,oldTip:r,newCid:e,newLabel:c,by:p}=t,o=[],d=[],a=[],n=[],E=new Set;for(let f of i.edgesFrom(r)){if(f.type===O.DERIVES||t.skipEcids?.has(f.ecid))continue;d.push({kind:"edge",ecid:f.ecid,reason:t.reason,by:p}),E.add(f.ecid);let _=t.dstRedirect?.get(f.dst)??f.dst,g=i.nodeLabel.get(f.dst)??"(unknown)",C=pe(f.type,c,g,f.props);if(C.length>0){a.push(`rebless ${f.type} \u2192 ${f.dst}: ${C.map(N=>N.detail).join("; ")}`);continue}let v=De(i,{type:f.type,src:e,dst:_},{pending:n,retracted:E},`rebless ${f.type}`);if(v){a.push(v.detail);continue}let w=K(f.type,e,_,f.props);if(i.superseded.has(w)){a.push(`rebless ${f.type} \u2192 ${_}: the re-derived edge (${w}) was retracted \u2014 retraction is terminal, the successor cannot revive it`);continue}o.push({ecid:w,type:f.type,src:e,dst:_,props:f.props}),n.push({src:e,dst:_,type:f.type})}return{edges:o,supersessions:d,errors:a}}var le=/^[a-z0-9][a-z0-9-]{1,63}$/;function Pe(t,i,r,e){if(!i)return{error:{code:"SUPERSEDE_TARGET_MISSING",detail:"supersede verdict needs a target (slug or cid)"}};let c=t.resolve(i);return c?c.superseded||e.has(c.cid)?{error:{code:"ALREADY_SUPERSEDED",detail:`${i} is already superseded (tip: ${c.tip})`}}:c.cid===r?{error:{code:"SELF_SUPERSEDE",detail:"a node cannot supersede itself"}}:{targetCid:c.cid}:{error:{code:"UNKNOWN_SUPERSEDE_TARGET",detail:`${i} names nothing in the graph`}}}function We(t,i,r,e,c=[]){if(!ae(i)?.acyclic)return null;if(r===e)return{code:"EDGE_CYCLE",detail:`${i} ${r} \u2192 itself`};let o=n=>[...t.edgesFrom(n).filter(E=>E.type===i).map(E=>E.dst),...c.filter(E=>E.type===i&&E.src===n).map(E=>E.dst)],d=new Set,a=[e];for(;a.length>0;){let n=a.pop();if(n===r)return{code:"EDGE_CYCLE",detail:`${i} ${r} \u2192 ${e} closes a cycle`};d.has(n)||(d.add(n),a.push(...o(n)))}return null}function Rt(t,i,r,e){let p=ae(i)?.cardinality;if(p!=="one-live-per-src"&&p!=="one-live-per-src-and-dst")return null;let o=t.edgesFrom(r).filter(d=>d.type===i&&!t.superseded.has(d.dst));if(o.length>0)return{code:"CARDINALITY_VIOLATION",detail:`${i} from ${r} already has a live edge (${o[0].ecid}) \u2014 supersede it first`};if(p==="one-live-per-src-and-dst"&&e!==void 0){let d=t.edgesInto(e).filter(a=>a.type===i&&!t.superseded.has(a.src));if(d.length>0)return{code:"CARDINALITY_VIOLATION",detail:`${i} onto ${e} already has a live edge (${d[0].ecid}) \u2014 strict 1:1, supersede it first`}}return null}var Ie=new Set(["high","med","low"]),me=t=>t.cites&&t.cites.length>0?t.cites:[t.cite];function _e(t){let i=0;for(let r of t)typeof r=="object"&&r!==null&&"op"in r&&i++;return i===0?"flat":i===t.length?"ops":"mixed"}var Be=/^c[1-9][0-9]*$/;function Ve(t,i,r,e){let c=new Map,p=[],o=[];for(let[a,n]of i.entries()){let E=`${t}.updated.criteria[${a}]`;if(n.op==="keep"||n.op==="remove"){if(!Be.test(n.ref??"")){e.push({code:"CRITERIA_REF_UNKNOWN",detail:`${E}: ref ${JSON.stringify(n.ref)} is not a c<N> criterion index`});continue}if(c.has(n.ref)){e.push({code:"CRITERIA_REF_DUPLICATE",detail:`${E}: ${n.ref} is already named by another op \u2014 every prior criterion appears in exactly one keep or remove`});continue}c.set(n.ref,n);let f=Number.parseInt(n.ref.slice(1),10);if(f>r.length){e.push({code:"CRITERIA_REF_UNKNOWN",detail:`${E}: ${n.ref} \u2014 the live target has ${r.length} criteria`});continue}if(r[f-1]!==n.text){e.push({code:"CRITERIA_REF_MISMATCH",detail:`${E}: ${n.ref} echo mismatch \u2014 the live target's criterion ${f} reads ${JSON.stringify(r[f-1])}, the op echoed ${JSON.stringify(n.text)} \u2014 re-read the node and re-emit`});continue}n.op==="remove"&&(p.push(n.text),(!n.reason||!n.reason.trim())&&e.push({code:"EMPTY_REASON",detail:`${E}: a remove op carries its reason`}))}else!n.text||!n.text.trim()?e.push({code:"EMPTY_CRITERION",detail:`${E}: set text is empty`}):o.push(n.text)}let d=[];for(let a=1;a<=r.length;a++)c.has(`c${a}`)||d.push(`c${a}`);d.length>0&&e.push({code:"CRITERIA_PARTITION_INCOMPLETE",detail:`${t}: prior criteria ${d.join(", ")} named by no keep/remove op \u2014 every prior criterion must be kept or removed (with a reason)`});for(let a of p)o.includes(a)&&e.push({code:"CRITERIA_OP_CONFLICT",detail:`${t}: ${JSON.stringify(a)} is removed AND re-set in the same update \u2014 drop one of the two ops`})}function bt(t,i,r){let e=[],c=t.sources??[t.source],p=new Map(c.map(n=>[n.source_id,n.source_cid])),o=new Map;if(typeof i=="string")o.set(t.source.source_id,{media:r.mediaOf(t.source.source_cid),numberedText:i});else for(let[n,E]of i)o.set(n,E);for(let n of c)r.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 d=(n,E)=>{let f=E.source_id??t.source.source_id;if(!p.has(f)){e.push({code:"CITE_SOURCE_UNKNOWN",detail:`${n}: cite source ${JSON.stringify(f)} is not in read_basis`});return}let _=o.get(f);if(!_){e.push({code:"MISSING_SOURCE_NODE",detail:`${n}: no citable text available for source ${f}`});return}for(let g of Te(_.media,E,_.numberedText))e.push({code:g.code,detail:`${n}: ${g.detail}`})},a=new Set;for(let n of t.use_cases){if(a.has(n.temp_ref)&&e.push({code:"DUP_TEMP_REF",detail:`duplicate temp_ref ${n.temp_ref}`}),a.add(n.temp_ref),(!n.title||!n.title.trim())&&e.push({code:"EMPTY_TITLE",detail:`${n.temp_ref}: title is empty`}),Ie.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 f of me(n))d(n.temp_ref,f);n.matches_existing&&!r.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[f,_]of(n.criteria??[]).entries())(!_.text||!_.text.trim())&&e.push({code:"EMPTY_CRITERION",detail:`${n.temp_ref}.criteria[${f}]: text is empty`}),!_.cite||!_.cite.anchor?e.push({code:"MISSING_CITE",detail:`${n.temp_ref}.criteria[${f}]: every criterion carries its own cite`}):d(`${n.temp_ref}.criteria[${f}]`,_.cite);let E=n.updated?.criteria??[];if(E.length>0){let f=_e(E);if(f==="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(f==="ops"){let _=E,g=n.matches_existing?Xe(r,n.matches_existing.cid):null;if(!g)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 C=r.getNode(g.cid)?.content.criteria??[];Ve(n.temp_ref,_,C,e)}for(let[C,v]of _.entries())v.op==="set"&&(!v.cite||!v.cite.anchor?e.push({code:"MISSING_CITE",detail:`${n.temp_ref}.updated.criteria[${C}]: a set op carries the proposing source's cite`}):d(`${n.temp_ref}.updated.criteria[${C}]`,v.cite))}else for(let[_,g]of E.entries())(!g.text||!g.text.trim())&&e.push({code:"EMPTY_CRITERION",detail:`${n.temp_ref}.updated.criteria[${_}]: text is empty`}),!g.cite||!g.cite.anchor?e.push({code:"MISSING_CITE",detail:`${n.temp_ref}.updated.criteria[${_}]: every updated criterion carries its own cite`}):d(`${n.temp_ref}.updated.criteria[${_}]`,g.cite)}}return e.push(...ye(t,r).errors),e}function Je(t,i,r){return`${t}:${i}:${r}`}function Ye(t,i,r,e){let c=`${i}:${r}:`,p=0;for(let o of t.appliedEvents){if(!o.startsWith(c))continue;let d=o.slice(c.length);if(!/^\d+$/.test(d))continue;let a=Number.parseInt(d,10);a>p&&(p=a)}return Array.from({length:e},(o,d)=>Je(i,r,p+1+d))}function Xe(t,i){let r=t.resolve(i);if(r===null)return null;let e=r.cid;if(t.superseded.has(e)){let c=t.tipOf(e);return t.superseded.has(c)?null:{cid:c,redirected:!0}}return{cid:e,redirected:!1}}function xt(t){let{contextDir:i,graph:r,proposal:e,proposalId:c,verdicts:p,by:o,allowStaleBasis:d,extractorVersion:a,autoName:n}=t,E=ge(i);if(!d&&e.read_basis!==E)return{record:null,errors:[{code:"STALE_BASIS",detail:`proposal read_basis ${String(e.read_basis)} != latest ${String(E)}`}]};for(let s of e.sources??[e.source])if(!r.hasNode(s.source_cid))return{record:null,errors:[{code:"MISSING_SOURCE_NODE",detail:`source ${s.source_id} (${s.source_cid}) is not a committed node \u2014 ingest it first`}]};let f=new Map((e.sources??[e.source]).map(s=>[s.source_id,s.source_cid])),_={supersedeTarget:{},matches_existing:{},conflicts_with:{},depends_on_hint:{},read_basis_heads:Object.fromEntries(f)},g=[],C=[],v=new Map,w=[],N=r.mediaOf(e.source.source_cid),T=new Set,G=[],P=[],W=[],L=[];for(let s of ye(e,r).valid)L.push({id:s.cid,kind:"pending_archive",resolution:"pending",edit:null,reason:s.op.reason,by:o});let X=[],oe=[],l=new Set,m=new Set,I=(s,h,j)=>{let Y=Pe(r,h.supersedeTarget,j,l);if("error"in Y){g.push({code:Y.error.code,detail:`${s}: ${Y.error.detail}`});return}l.add(Y.targetCid),_.supersedeTarget[s]=Y.targetCid,X.push({kind:"node",old:Y.targetCid,new:j,reason:h.reason??`superseded via review by ${o.id}`,by:o})};for(let s of e.use_cases){let h=p.get(s.temp_ref)??{resolution:"skipped"};T.has(s.temp_ref)&&g.push({code:"DUP_TEMP_REF",detail:`duplicate temp_ref ${s.temp_ref}`}),T.add(s.temp_ref),s.conflicts_with&&(_.conflicts_with[s.temp_ref]=s.conflicts_with.map(u=>r.resolve(u)?.cid??null)),(!s.title||!s.title.trim())&&g.push({code:"EMPTY_TITLE",detail:`${s.temp_ref}: title is empty`}),Ie.has(s.risk)||g.push({code:"BAD_RISK",detail:`${s.temp_ref}: risk ${JSON.stringify(s.risk)} not in high|med|low`});let j=we(s.cite?.anchor??""),Y=s.cite?.source_id!==void 0&&f.has(s.cite.source_id)?r.mediaOf(f.get(s.cite.source_id)):N;if(Y.format==="image"){if(j?.kind!=="img-whole"){g.push({code:s.cite?.anchor?"CITE_ANCHOR_INVALID":"MISSING_CITE",detail:`${s.temp_ref}: image cites are anchor-only (img#whole)`});continue}}else if(j?.kind==="img-part"){if(!(Y.images??[]).some(S=>S.ref===j.ref)){g.push({code:"CITE_ANCHOR_INVALID",detail:`${s.temp_ref}: anchor ${s.cite?.anchor} names no embedded image of this source version`});continue}}else if(!s.cite||!s.cite.anchor||!s.cite.quote){g.push({code:"MISSING_CITE",detail:`${s.temp_ref}: every derived use-case must cite anchor+quote`});continue}h.resolution==="edited"&&h.edit&&(h.edit.title!==void 0&&!h.edit.title.trim()&&g.push({code:"EMPTY_TITLE",detail:`${s.temp_ref}: edited title is empty`}),h.edit.risk!==void 0&&!Ie.has(h.edit.risk)&&g.push({code:"BAD_RISK",detail:`${s.temp_ref}: edited risk ${JSON.stringify(h.edit.risk)} invalid`}));let Ee=fe({title:h.edit?.title??s.title,description:s.description,summary:h.edit?.summary??s.summary,actors:s.actors,value:s.value,risk:h.edit?.risk??s.risk,...s.criteria&&s.criteria.length>0?{criteria:s.criteria.map(u=>u.text)}:{}}),b=ne("usecase",Ee),ve=s.cite.source_id??e.source.source_id,$e=f.get(ve);if(s.cite.source_id!==void 0&&$e===void 0){g.push({code:"CITE_SOURCE_UNKNOWN",detail:`${s.temp_ref}: cite source ${JSON.stringify(ve)} is not in read_basis`});continue}let ee={source_id:ve,source_cid:$e??e.source.source_cid,anchor:s.cite.anchor,...s.cite.quote?{quote:s.cite.quote}:{}};if(s.matches_existing&&!r.hasNode(s.matches_existing.cid)){g.push({code:"UNKNOWN_MATCH",detail:`${s.temp_ref}: matches_existing ${s.matches_existing.cid} is not in the graph`});continue}let x=s.matches_existing?.cid??(r.hasNode(b)?b:null);if(x&&r.superseded.has(x)){let u=r.tipOf(x);x=r.superseded.has(u)?null:u}if(x&&s.matches_existing&&(_.matches_existing[s.temp_ref]=x),x&&s.matches_existing&&(r.trust.get(x)??null)==="derived"){let u=s.updated?.criteria??[];if(s.changed&&u.length>0&&_e(u)==="ops"&&(h.resolution==="approved"||h.resolution==="edited")){g.push({code:"UC_UNREVIEWED",detail:`${s.temp_ref}: merge target ${x.slice(0,19)} is unreviewed (derived) \u2014 bless it first (kane-cli context review) and re-propose the merge`});continue}let S=(t.probeHits??[]).find(y=>y.tempRef===s.temp_ref&&y.candidateCid===x);w.push({tempRef:s.temp_ref,candidate_cid:x,score:S?.score??1,scorer:S?.scorer??"lexical_fallback"}),x=null}if(x){if(s.changed&&(h.resolution==="approved"||h.resolution==="edited")){let u=s.updated;if(!u||Object.keys(u).length===0){g.push({code:"CHANGED_NEEDS_PAYLOAD",detail:`${s.temp_ref}: changed:true needs an updated{...} payload naming the moved fields`});continue}let S=r.getNode(x)?.content??{},y=u.criteria??[],V=y.length>0?_e(y):"flat";if(V==="mixed"){g.push({code:"CRITERIA_SHAPE_MIXED",detail:`${s.temp_ref}.updated.criteria mixes op-shaped (keep/set/remove) and {text, cite} entries \u2014 emit ONE shape for the whole array`});continue}if(V==="ops"){let U=y,H=S.criteria??[],q=g.length;Ve(s.temp_ref,U,H,g);for(let[de,ue]of U.entries())ue.op==="set"&&(!ue.cite||!ue.cite.anchor)&&g.push({code:"MISSING_CITE",detail:`${s.temp_ref}.updated.criteria[${de}]: a set op carries the proposing source's cite`});if(g.length>q)continue;let D=U.filter(de=>de.op!=="remove").map(de=>de.text),J=fe({title:h.edit?.title??u.title??String(S.title??s.title),...u.description??S.description?{description:u.description??S.description}:{},...h.edit?.summary??u.summary??S.summary?{summary:h.edit?.summary??u.summary??S.summary}:{},...u.actors??S.actors?{actors:u.actors??S.actors}:{},...u.value??S.value?{value:u.value??S.value}:{},risk:h.edit?.risk??u.risk??String(S.risk??s.risk),...D.length>0?{criteria:D}:{}}),Q=ne("usecase",J);if(Q!==x){for(let $ of ie("usecase",J))g.push({code:$.code,detail:`${s.temp_ref}: ${$.detail}`});G.push({cid:Q,label:se.USECASE,content:J});for(let $ of me(s)){let z=$.source_id??e.source.source_id,B=f.get(z);if(!B){g.push({code:"CITE_SOURCE_UNKNOWN",detail:`${s.temp_ref}: cite source ${JSON.stringify(z)} is not in read_basis`});continue}let Z={source_id:z,source_cid:B,anchor:$.anchor,...$.quote?{quote:$.quote}:{}};P.push({ecid:K("DERIVES",B,Q,Z),type:O.DERIVES,src:B,dst:Q,props:Z})}let ue=he(r,x).flatMap($=>r.edgesInto($)).filter($=>$.type===O.DERIVES&&typeof $.props.claim=="string");for(let $ of U){if($.op!=="keep")continue;let z=new Set;for(let B of ue){let Z=B.props;if(Z.claim!==$.text)continue;let Ne=`${Z.source_id}|${Z.source_cid}|${Z.anchor}`;if(z.has(Ne))continue;z.add(Ne);let Re={...B.props};P.push({ecid:K("DERIVES",B.src,Q,Re),type:O.DERIVES,src:B.src,dst:Q,props:Re})}}for(let $ of U){if($.op!=="set")continue;let z=$.cite.source_id??e.source.source_id,B=f.get(z);if(!B){g.push({code:"CITE_SOURCE_UNKNOWN",detail:`${s.temp_ref}: set cite source ${JSON.stringify(z)} is not in read_basis`});continue}let Z={source_id:z,source_cid:B,anchor:$.cite.anchor,...$.cite.quote?{quote:$.cite.quote}:{},claim:$.text};P.push({ecid:K("DERIVES",B,Q,Z),type:O.DERIVES,src:B,dst:Q,props:Z})}for(let $ of U)$.op==="remove"&&C.push({about:x,ref:$.ref,text:$.text,reason:$.reason});I(s.temp_ref,{resolution:"supersede",supersedeTarget:x,reason:h.reason??`criteria merge: ${e.source.source_id} (${U.filter($=>$.op==="keep").length} kept, ${U.filter($=>$.op==="set").length} set, ${U.filter($=>$.op==="remove").length} removed)`},Q),L.push({id:Q,kind:"review-item",resolution:h.resolution,edit:h.resolution==="edited"?{...h.edit}:null,reason:null,by:o});continue}}else{let U=y.map(D=>typeof D=="string"?{text:D,cite:void 0}:D),H=fe({title:h.edit?.title??u.title??String(S.title??s.title),...u.description??S.description?{description:u.description??S.description}:{},...h.edit?.summary??u.summary??S.summary?{summary:h.edit?.summary??u.summary??S.summary}:{},...u.actors??S.actors?{actors:u.actors??S.actors}:{},...u.value??S.value?{value:u.value??S.value}:{},risk:h.edit?.risk??u.risk??String(S.risk??s.risk),...u.criteria?U.length>0?{criteria:U.map(D=>D.text)}:{}:S.criteria?{criteria:S.criteria}:{}}),q=ne("usecase",H);if(q!==x){for(let D of ie("usecase",H))g.push({code:D.code,detail:`${s.temp_ref}: ${D.detail}`});G.push({cid:q,label:se.USECASE,content:H}),P.push({ecid:K("DERIVES",ee.source_cid,q,ee),type:O.DERIVES,src:ee.source_cid,dst:q,props:ee});for(let D of U){if(!D.cite)continue;let J={source_id:e.source.source_id,source_cid:e.source.source_cid,anchor:D.cite.anchor,...D.cite.quote?{quote:D.cite.quote}:{},claim:D.text};P.push({ecid:K("DERIVES",J.source_cid,q,J),type:O.DERIVES,src:J.source_cid,dst:q,props:J})}I(s.temp_ref,{resolution:"supersede",supersedeTarget:x,reason:h.reason??`matches-but-changed: ${e.source.source_id} moved (${Object.keys(u).join(", ")})`},q),L.push({id:q,kind:"review-item",resolution:h.resolution,edit:h.resolution==="edited"?{...h.edit}:null,reason:null,by:o});continue}for(let D of U){if(!D.cite)continue;let J={source_id:e.source.source_id,source_cid:e.source.source_cid,anchor:D.cite.anchor,...D.cite.quote?{quote:D.cite.quote}:{},claim:D.text};P.push({ecid:K("DERIVES",J.source_cid,x,J),type:O.DERIVES,src:J.source_cid,dst:x,props:J})}}}if(s.changed&&h.resolution==="skipped"){let u=s.updated?.criteria??[];u.length>0&&_e(u)==="ops"&&L.push({id:x,kind:"pending_update",resolution:"pending",edit:{temp_ref:s.temp_ref,source_id:e.source.source_id,updated:s.updated},reason:s.change_note??null,by:o})}if(h.resolution!=="rejected"){for(let u of me(s)){let S=u.source_id??e.source.source_id,y=f.get(S);if(!y){g.push({code:"CITE_SOURCE_UNKNOWN",detail:`${s.temp_ref}: cite source ${JSON.stringify(S)} is not in read_basis`});continue}let V={source_id:S,source_cid:y,anchor:u.anchor,...u.quote?{quote:u.quote}:{}};P.push({ecid:K("DERIVES",y,x,V),type:O.DERIVES,src:y,dst:x,props:V})}(h.resolution==="approved"||h.resolution==="edited"||h.resolution==="supersede")&&L.push({id:x,kind:"review-item",resolution:"approved",edit:null,reason:null,by:o}),h.resolution==="supersede"&&I(s.temp_ref,h,x)}continue}for(let u of ie("usecase",Ee))g.push({code:u.code,detail:`${s.temp_ref}: ${u.detail}`});for(let u of pe(O.DERIVES,"source","usecase",ee))g.push({code:u.code,detail:`${s.temp_ref}: ${u.detail}`});G.push({cid:b,label:se.USECASE,content:Ee}),v.set(s.temp_ref,b),P.push({ecid:K("DERIVES",ee.source_cid,b,ee),type:O.DERIVES,src:ee.source_cid,dst:b,props:ee});for(let u of me(s).slice(1)){let S=u.source_id??e.source.source_id,y=f.get(S);if(!y){g.push({code:"CITE_SOURCE_UNKNOWN",detail:`${s.temp_ref}: cite source ${JSON.stringify(S)} is not in read_basis`});continue}let V={source_id:S,source_cid:y,anchor:u.anchor,...u.quote?{quote:u.quote}:{}};for(let U of pe(O.DERIVES,"source","usecase",V))g.push({code:U.code,detail:`${s.temp_ref}: ${U.detail}`});P.push({ecid:K("DERIVES",y,b,V),type:O.DERIVES,src:y,dst:b,props:V})}for(let u of s.criteria??[]){let S=u.cite.source_id??e.source.source_id,y=f.get(S);if(!y){g.push({code:"CITE_SOURCE_UNKNOWN",detail:`${s.temp_ref}: criterion cite source ${JSON.stringify(S)} is not in read_basis`});continue}let V={source_id:S,source_cid:y,anchor:u.cite.anchor,...u.cite.quote?{quote:u.cite.quote}:{},claim:u.text};P.push({ecid:K("DERIVES",V.source_cid,b,V),type:O.DERIVES,src:V.source_cid,dst:b,props:V})}for(let u of s.depends_on_hint??[]){let S=H=>H.toLowerCase().trim().replace(/\s+/g," "),y=null,V=r.resolve(u);if(V&&!V.superseded&&r.nodeLabel.get(V.cid)===se.USECASE&&(y=V.cid),!y){for(let{cid:H,content:q}of r.byLabel(se.USECASE))if(!r.superseded.has(H)&&S(String(q.title??""))===S(u)){y=H;break}}if(!y){let H=G.find(q=>q.label===se.USECASE&&S(String(q.content.title??""))===S(u));H&&(y=H.cid)}!y||y===b||We(r,O.DEPENDS_ON,b,y,W)||W.some(H=>H.src===b&&H.dst===y)||(P.push({ecid:K(O.DEPENDS_ON,b,y,{reason:"extract hint"}),type:O.DEPENDS_ON,src:b,dst:y,props:{reason:"extract hint"}}),W.push({src:b,dst:y,type:O.DEPENDS_ON}),(_.depends_on_hint[s.temp_ref]??=[]).push(y))}if((h.resolution==="approved"||h.resolution==="edited"||h.resolution==="supersede")&&r.superseded.get(b)===null&&!l.has(b)&&X.push({kind:"node",old:b,new:b,reason:`re-minted after tombstone via review by ${o.id}`,by:o}),n){let u=Ae("usecase",S=>m.has(S),r.names.keys());u!==null&&!r.nameOf.has(b)&&(m.add(u),oe.push({cid:b,slug:u,by:o}))}h.resolution==="approved"?L.push({id:b,kind:"review-item",resolution:"approved",edit:null,reason:null,by:o}):h.resolution==="edited"?L.push({id:b,kind:"review-item",resolution:"edited",edit:{...h.edit},reason:null,by:o}):h.resolution==="rejected"?L.push({id:b,kind:"review-item",resolution:"rejected",edit:null,reason:h.reason??null,by:o}):h.resolution==="supersede"&&(L.push({id:b,kind:"review-item",resolution:"approved",edit:null,reason:h.reason??null,by:o}),I(s.temp_ref,h,b))}if(g.length)return{record:null,errors:g};let R=new Date().toISOString(),F=(e.sources?.length??0)>1||(e.extraction_claims?.length??0)>0,A;if(F){let s=[];if(e.extraction_claims==null)s.push({source_id:e.source.source_id,source_cid:e.source.source_cid,completeness:"complete",...a?{extractor_version:a}:{},at:R});else{let h=new Map(e.extraction_claims.map(j=>[j.source_id,j.completeness]));for(let j of e.sources??[e.source]){let Y=h.get(j.source_id)??null;Y!==null&&s.push({source_id:j.source_id,source_cid:j.source_cid,completeness:Y,...a?{extractor_version:a}:{},at:R})}}A=s}else A=e.source.source_cid;let k=[];for(let s of t.probeHits??[])k.push({...v.has(s.tempRef)?{new_cid:v.get(s.tempRef)}:{},candidate_cid:s.candidateCid,score:s.score,scorer:s.scorer,probe_basis:null});for(let s of w){let h=v.get(s.tempRef);k.some(j=>j.new_cid===h&&j.candidate_cid===s.candidate_cid)||k.push({...h!==void 0?{new_cid:h}:{},candidate_cid:s.candidate_cid,score:s.score,scorer:s.scorer,probe_basis:null})}let M=t.eventIds&&t.eventIds.length>0?t.eventIds:t.sid?Ye(r,t.sid,"extract",1):void 0;return{record:re(i,{ts:R,proposal_id:c,...c!=null?{extraction_of:A}:{},...c!=null&&a?{extractor_version:a}:{},...C.length>0?{criteria_removed:C}:{},...k.length>0?{dedup_hits:k}:{},nodes:G,edges:P,review:L,supersessions:X,...oe.length>0?{names:oe}:{},...t.judgements&&t.judgements.length>0?{judgements:t.judgements}:{},...M?{event_ids:M}:{},...t.sid?{sid:t.sid}:{},source_head_moves:{}},{expectPrev:E,intent:{v:1,verb:"extract",args:te({proposal:e,proposalId:c,verdicts:Object.fromEntries(p),by:o,flags:{allowStaleBasis:d??null,autoName:n??null,extractorVersion:a??null,sid:t.sid??null},judgements:t.judgements??null,probeHits:t.probeHits??null,eventIds:M??null}),pins:_},provenance:t.provenance}).record,errors:null}}function Ot(t){let{contextDir:i,graph:r,verdicts:e,by:c}=t,p=[],o=[],d=[],a=[],n=[],E=new Set,f={verdicts:{},supersedeTarget:{}},_=new Map;for(let[C,v]of e){if(v.resolution!=="edited")continue;let w=r.resolve(C);if(!w||w.superseded)continue;let N=r.getNode(w.cid);if(!N)continue;let T={...N.content,...v.edit?.title!==void 0?{title:v.edit.title}:{},...v.edit?.summary!==void 0?{summary:v.edit.summary}:{},...v.edit?.risk!==void 0?{risk:v.edit.risk}:{}};if(ie(N.label,T).length>0)continue;let G=ne(N.label,T);G===w.cid||Ce(r,w.cid,G)||_.set(w.cid,G)}for(let[C,v]of e){if(v.resolution==="skipped")continue;let w=r.resolve(C);if(!w){p.push({code:"UNKNOWN_NODE",detail:`${C} names nothing in the graph`});continue}if(w.superseded){p.push({code:"SUPERSEDED_TARGET",detail:`${C} is superseded \u2014 review the tip (${w.tip})`});continue}let N=w.cid;if(f.verdicts[C]=N,v.resolution==="approved")a.push({id:N,kind:"review-item",resolution:"approved",edit:null,reason:null,by:c});else if(v.resolution==="rejected")t.holdArchives?a.push({id:N,kind:"pending_archive",resolution:"pending",edit:null,reason:v.reason??null,by:c}):a.push({id:N,kind:"review-item",resolution:"rejected",edit:null,reason:v.reason??null,by:c});else if(v.resolution==="edited"){if(E.has(N)){p.push({code:"DUPLICATE_TARGET",detail:`${C}: this node was already superseded by another verdict in this batch \u2014 one verdict per node`});continue}let T=r.getNode(N);if(!T){p.push({code:"UNKNOWN_NODE",detail:`${C}: node file unreadable`});continue}let G={...T.content,...v.edit?.title!==void 0?{title:v.edit.title}:{},...v.edit?.summary!==void 0?{summary:v.edit.summary}:{},...v.edit?.risk!==void 0?{risk:v.edit.risk}:{}},P=ie(T.label,G);if(P.length>0){for(let X of P)p.push({code:X.code,detail:`${C}: ${X.detail}`});continue}let W=ne(T.label,G);if(W===N){a.push({id:N,kind:"review-item",resolution:"approved",edit:null,reason:null,by:c});continue}if(Ce(r,N,W)){p.push({code:"SUPERSEDE_CYCLE",detail:`${C}: edit reproduces an already-superseded version (supersession cycle guard) \u2014 re-edit forward or redesign`});continue}let L=Me({graph:r,oldTip:N,newCid:W,newLabel:T.label,by:c,reason:`re-blessed onto ${W} (edited in review)`,dstRedirect:_});if(L.errors.length>0){for(let X of L.errors)p.push({code:"REBLESS_REFUSED",detail:`${C}: ${X}`});continue}o.push({cid:W,label:T.label,content:G}),d.push(...L.edges),E.add(N),n.push({kind:"node",old:N,new:W,reason:v.reason??"edited in review",by:c}),n.push(...L.supersessions),a.push({id:W,kind:"review-item",resolution:"edited",edit:{...v.edit},reason:null,by:c})}else if(v.resolution==="supersede"){let T=Pe(r,v.supersedeTarget,N,E);if("error"in T){p.push({code:T.error.code,detail:`${C}: ${T.error.detail}`});continue}E.add(T.targetCid),f.supersedeTarget[C]=T.targetCid,t.holdArchives?a.push({id:T.targetCid,kind:"pending_archive",resolution:"pending",edit:null,reason:`supersede by ${N}${v.reason?` \u2014 ${v.reason}`:""}`,by:c}):(n.push({kind:"node",old:T.targetCid,new:N,reason:v.reason??`superseded via review by ${c.id}`,by:c}),a.push({id:N,kind:"review-item",resolution:"approved",edit:null,reason:v.reason??null,by:c}))}}return p.length?{record:null,errors:p}:a.length===0&&n.length===0?{record:null,errors:[{code:"NO_VERDICTS",detail:"every item was skipped \u2014 nothing to commit"}]}:{record:re(i,{ts:new Date().toISOString(),proposal_id:null,nodes:o,edges:d,review:a,supersessions:n,source_head_moves:{}},{expectPrev:r.latestHash,intent:{v:1,verb:"review",args:te({verdicts:Object.fromEntries(e),by:c,holdArchives:t.holdArchives??null}),pins:f},provenance:t.provenance}).record,errors:null}}function wt(t){let{contextDir:i,graph:r,survivor:e,merged:c,reason:p,by:o}=t,d=r.resolve(e),a=r.resolve(c);return d?a?d.superseded||a.superseded?{record:null,errors:[{code:"ALREADY_SUPERSEDED",detail:"a side of the pair is already superseded \u2014 the pair is drained"}]}:d.cid===a.cid?{record:null,errors:[{code:"SELF_SUPERSEDE",detail:"a pair cannot merge a node into itself"}]}:{record:re(i,{ts:new Date().toISOString(),proposal_id:null,nodes:[],edges:[],review:[],supersessions:[{kind:"node",old:a.cid,new:d.cid,reason:p??`pair merge: duplicate of ${e}`,by:o}],source_head_moves:{}},{expectPrev:r.latestHash,intent:{v:1,verb:"pair-merge",args:te({survivor:e,merged:c,reason:p??null,by:o}),pins:{survivor:d.cid,merged:a.cid}},provenance:t.provenance}).record,errors:null}:{record:null,errors:[{code:"UNKNOWN_NODE",detail:`${c} names nothing in the graph`}]}:{record:null,errors:[{code:"UNKNOWN_NODE",detail:`${e} names nothing in the graph`}]}}function Tt(t){let{contextDir:i,graph:r,assignments:e,by:c}=t,p=new Set(t.reassign??[]),o=[],d=[],a=new Set,n={};for(let{ref:f,slug:_}of e){if(!le.test(_)){o.push({code:"BAD_SLUG",detail:`${JSON.stringify(_)} \u2014 slugs are kebab-case ${String(le)}`});continue}let g=r.resolve(f);if(!g){o.push({code:"UNKNOWN_REF",detail:`${f} names nothing in the graph`});continue}if(g.superseded){o.push({code:"SUPERSEDED_TARGET",detail:`${f} is superseded \u2014 name the tip instead (${g.tip})`});continue}let C=r.names.get(_);if(C!==void 0&&!r.superseded.has(C)&&C!==g.cid&&!p.has(_)||a.has(_)){o.push({code:"SLUG_TAKEN",detail:`${_} already names ${C??"another node in this record"}`});continue}a.add(_),n[f]=g.cid,d.push({cid:g.cid,slug:_,by:c})}return o.length?{record:null,errors:o}:d.length===0?{record:null,errors:[{code:"NO_ASSIGNMENTS",detail:"nothing to name"}]}:{record:re(i,{ts:new Date().toISOString(),proposal_id:null,nodes:[],edges:[],review:[],supersessions:[],names:d,source_head_moves:{}},{expectPrev:r.latestHash,intent:{v:1,verb:"names",args:te({assignments:e,by:c,...t.reassign&&t.reassign.length>0?{reassign:t.reassign}:{}}),pins:{refs:n}},provenance:t.provenance}).record,errors:null}}function Dt(t){let{contextDir:i,graph:r,sourceId:e,reason:c,by:p}=t,o=r.heads.get(e);return o===void 0?{record:null,errors:[{code:"UNKNOWN_SOURCE",detail:`no source ${e} in the graph`}]}:o===null?{record:null,errors:[{code:"ALREADY_RETIRED",detail:`source ${e} is already retired`}]}:{record:re(i,{ts:new Date().toISOString(),proposal_id:null,nodes:[],edges:[],review:[],supersessions:[{kind:"node",old:o,new:null,reason:c??`retired source ${e}`,by:p}],source_head_moves:{[e]:null},names:[]},{expectPrev:r.latestHash,intent:{v:1,verb:"retire",args:te({sourceId:e,reason:c??null,by:p}),pins:{head:o}},provenance:t.provenance}).record,errors:null}}function kt(t){let i=ie("gap",t.content);if(i.length>0)return{ok:!1,refusal:`defer gap failed schema validation: ${i.map(p=>p.detail).join("; ")}`};let r=ne("gap",t.content),e={reason:"reconcile change deferred"},c=t.annotates?[{ecid:K(O.ANNOTATES,r,t.annotates,e),type:O.ANNOTATES,src:r,dst:t.annotates,props:e}]:[];for(let p=0;;p++)try{return re(t.contextDir,{ts:new Date().toISOString(),proposal_id:null,nodes:[{cid:r,label:"gap",content:t.content}],edges:c,review:[],supersessions:[],source_head_moves:{}},{expectPrev:ge(t.contextDir),intent:{v:1,verb:"gap",args:te({content:t.content,annotates:t.annotates??null}),pins:{annotates:t.annotates??null}},provenance:t.provenance}),{ok:!0,cid:r}}catch(o){if(o instanceof Se){if(p<3)continue;return{ok:!1,refusal:"concurrent activity kept moving the store \u2014 try the card again"}}throw o}}function At(t){let i=t.graph.byLabel("gap").filter(r=>(t.gaps===void 0||t.gaps.includes(r.cid))&&r.content.kind==="reconcile_deferred"&&typeof r.content.uc=="string"&&t.graph.tipOf(r.content.uc)===t.targetTip&&(t.sourceId===void 0||r.content.basis?.source_id===void 0||r.content.basis.source_id===t.sourceId)&&!t.graph.superseded.has(r.cid)&&t.graph.trust.get(r.cid)!=="archived");if(i.length===0)return{resolved:0};for(let r=0;;r++)try{return re(t.contextDir,{ts:new Date().toISOString(),proposal_id:null,nodes:[],edges:[],review:[],supersessions:i.map(e=>({kind:"node",old:e.cid,new:t.resolvedBy,reason:"reconcile change resolved by a later verdict",by:t.by})),source_head_moves:{}},{expectPrev:ge(t.contextDir),intent:{v:1,verb:"gap-close",args:te({targetTip:t.targetTip,resolvedBy:t.resolvedBy,sourceId:t.sourceId??null,by:t.by}),pins:{gaps:i.map(e=>e.cid)}},provenance:t.provenance}),{resolved:i.length}}catch(e){if(e instanceof Se){if(r<3)continue;return{resolved:0}}throw e}}export{ye as a,Ce as b,Me as c,le as d,We as e,Rt as f,me as g,_e as h,Ve as i,bt as j,Je as k,Ye as l,Xe as m,xt as n,Ot as o,wt as p,Tt as q,Dt as r,kt as s,At as t,Ge as u,Le as v,Ze as w,ke as x,Ae as y,ot as z,He as A,ct as B,he as C};
|
package/dist/chunk-ILDHE4P4.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{b as y}from"./chunk-WD52ZNQY.js";import{b as l,d,e as m,g,h as S}from"./chunk-JQY5HRZ4.js";import{a as f}from"./chunk-QAB3Y5FQ.js";import{r as u,s as p}from"./chunk-RSSOJ3L2.js";import{existsSync as s,mkdirSync as h,readFileSync as C,renameSync as w,writeFileSync as R}from"fs";import{join as x}from"path";function G(e){y(l(e));let r=l(e);if(!s(r))return;let n=x(r,"meta.json"),o=m(e);if(s(n)&&!s(o))try{h(d(e),{recursive:!0}),w(n,o)}catch(t){process.stderr.write(`warn: meta.json migration failed: ${t.message}
|
|
3
|
-
`)}let a=S(e);if(s(a)){let t="python";try{let i=new f().load();i.code_export?.language&&(t=i.code_export.language)}catch{}let c=g(e,"playwright",t);if(!s(c))try{w(a,c)}catch(i){process.stderr.write(`warn: generated-code migration failed: ${i.message}
|
|
4
|
-
`)}}if(s(o))try{let t=JSON.parse(C(o,"utf8"));"md5sum"in t&&(delete t.md5sum,R(o,JSON.stringify(t,null,2)+`
|
|
5
|
-
`,"utf8"))}catch(t){process.stderr.write(`warn: meta.json md5sum strip failed: ${t.message}
|
|
6
|
-
`)}}async function O(e){if(!e.isInteractive)return{recovered:!1};if(E(e.creds))return{recovered:!1};let{SingleShotApp:r}=await import("./SingleShotApp-UYCAW65Y.js"),{ScrollbackProvider:n}=await import("./scrollback-JLPJR25X.js"),{render:o}=await import("./build-JIKYOZUH.js"),a=await import("./react-QWOAB3TB.js"),t={current:null},c={current:!1},{waitUntilExit:i,unmount:v}=o(a.default.createElement(n,null,a.default.createElement(r,{resultRef:t,mode:"login",loginCompleteRef:c})),{exitOnCtrlC:!1});p(()=>v()),await i();try{process.stdin.setRawMode?.(!1)}catch{}return process.stdout.write("\x1B[?25h"),c.current?{recovered:!0}:(u(0,"Startup gate cancelled"),{recovered:!1})}function E(e){let r=e.getActiveProfile(),n=e.getDefaultEnv();if(!r||!!!(e.loadBasicAuth(r,n)||e.loadCredentials(r,n)))return!1;let a=e.loadProfileConfig(r,n)??{};return!!a.project_id&&!!a.folder_id}export{G as a,O as b};
|
package/dist/chunk-IPXKUYUK.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as S}from"./chunk-I7TIGB7K.js";import{a as x,b as P,c as C,d as V,e as j}from"./chunk-XKHWWKJZ.js";import{a as R,b as D}from"./chunk-KDNNMU7Q.js";import{o as f,p as k,z as y}from"./chunk-IICT4VOU.js";import{e as b}from"./chunk-3UI5VTQS.js";import{f as w}from"./chunk-FQNQVC5O.js";function I(o,t){return{contextDir:o,rootSid:t,locks:w(o,t),probe:S(o,{resolveAlias:i=>P(i),embed:(i,s)=>C(i,s),readVector:(i,s)=>V(o,i,s),writeVector:(i,s,n)=>j(o,i,s,n)})}}var N=new Set(["archive"]);async function Y(o,t,i,s){let n=y(o.contextDir);if(i.v==="defer")return{outcome:"deferred"};if(t.kind==="MODIFY_HELD"){if(!t.heldPayload)return{outcome:"failed",detail:`${t.ref} carries no held payload`};let e=t.heldPayload;if(i.v==="keep_current"){if(!e.event_id)return{outcome:"failed",detail:`this held row has no durable event id \u2014 resume the owner to drop it: kane-cli context extract --resume ${e.sid}`};let{commitChatTurn:r}=await import("./chat-committer-6D7AQI6Z.js"),u=r({contextDir:o.contextDir,graph:n,ops:[{kind:"resolve_question",questionId:`drop-held:${e.sid}:${e.tempRef}`,resolution:"deferred",eventId:e.event_id}],by:s});return u.errors?{outcome:"failed",detail:u.errors.map(d=>`${d.code}: ${d.detail}`).join("; ")}:(o.signals?.({ref:t.ref,verdict:"held-dropped"}),{outcome:"committed",detail:"held payload dropped (recorded) \u2014 the owner's resume will not re-present it"})}if(i.v==="approve"){let r=e.content._held??null;if(!r?.source_id||!r.source_cid||!r.anchor||!r.quote)return{outcome:"failed",detail:`this held row carries no committable provenance \u2014 resume the owner to apply it: kane-cli context extract --resume ${e.sid}`};{let a=n.mediaOf(r.source_cid),m=R(o.contextDir,n,r.source_cid),g=a.format==="image"?null:m?D(m):null;if(a.format!=="image"&&g===null)return{outcome:"failed",detail:`the pinned source ${r.source_id} (${r.source_cid.slice(0,19)}) has no citable text to verify this held row against \u2014 resume the owner: kane-cli context extract --resume ${e.sid}`};let _=b(a,{anchor:r.anchor,quote:r.quote},g);if(_.length>0)return{outcome:"failed",detail:`held provenance does not verify against the pinned source (${_.map($=>`${$.code}: ${$.detail}`).join("; ")}) \u2014 resume the owner: kane-cli context extract --resume ${e.sid}`}}let{commitProposal:u}=await import("./committer-2QPBANRD.js"),{_held:d,...c}=e.content,q={version:1,read_basis:n.latestHash,source:{source_id:r.source_id,source_cid:r.source_cid},use_cases:[{temp_ref:e.tempRef,title:String(c.title??e.tempRef),...c.summary!==void 0?{summary:c.summary}:{},risk:String(c.risk??"med"),cite:{anchor:r.anchor,quote:r.quote},depends_on_hint:[],matches_existing:null}]},l=await x(I(o.contextDir,o.rootSid??`review-${process.pid}`),{verb:"maintain",ucTargets:[],newBuCandidates:[{tempRef:e.tempRef,title:String(c.title??e.tempRef),probeText:`${String(c.title??"")} ${String(c.summary??"")}`.trim()}],sourcePins:[{source_id:r.source_id,source_cid:r.source_cid}],readBasis:n.latestHash,...e.event_id?{eventIds:[e.event_id]}:{}},a=>{let m=u({contextDir:o.contextDir,graph:a.graph,proposal:q,proposalId:null,verdicts:new Map([[e.tempRef,{resolution:"skipped"}]]),by:s,autoName:!0,allowStaleBasis:!0,eventIds:e.event_id?[e.event_id]:a.eventIds("maintain",1),sid:a.sid,probeHits:a.probeHits});return m.errors!==null?{errors:m.errors}:{result:m,record:m.record}}),h=l.ok&&"result"in l?l.result:{record:null,errors:l.ok?null:l.kind==="validation"?l.errors:[{code:l.kind==="contended"?l.err.code:"UNSETTLED",detail:l.kind==="contended"?`held by ${l.err.holder?.owner_sid??"another session"}`:"concurrent activity kept moving the store"}]};return h.errors?{outcome:"failed",detail:h.errors.map(a=>`${a.code}: ${a.detail}`).join("; ")}:(o.signals?.({ref:t.ref,verdict:"held-applied"}),{outcome:"committed",detail:`held payload committed (derived) by ${s.id}`})}return{outcome:"failed",detail:`verdict ${i.v} does not apply to a MODIFY_HELD card`}}let v=n.resolve(t.ref);if(!v)return{outcome:"failed",detail:`${t.ref} names nothing in the graph`};let p=n.tipOf(v.cid);if(i.v==="archive"){if(!i.because||!i.because.trim())return{outcome:"failed",detail:"archive requires --because (a reason the record keeps)"};let e=f({contextDir:o.contextDir,graph:n,verdicts:new Map([[p,{resolution:"rejected",reason:i.because}]]),by:s});return e.errors?{outcome:"failed",detail:e.errors.map(r=>`${r.code}: ${r.detail}`).join("; ")}:(o.signals?.({ref:t.ref,verdict:"archived",reason:i.because}),{outcome:"retired"})}if(i.v==="approve"){let e=f({contextDir:o.contextDir,graph:n,verdicts:new Map([[p,{resolution:"approved"}]]),by:s});return e.errors?{outcome:"failed",detail:e.errors.map(r=>`${r.code}: ${r.detail}`).join("; ")}:(o.signals?.({ref:t.ref,verdict:"approved"}),{outcome:"applied"})}if(i.v==="merge"||i.v==="keep_both"){if(t.kind!=="PAIR"||!t.pair)return{outcome:"failed",detail:`${t.ref} is not a PAIR card`};let e=n.resolve(t.pair.candidate_cid);if(!e)return{outcome:"failed",detail:`pair candidate ${t.pair.candidate_ref} names nothing`};let r=n.tipOf(e.cid);if(i.v==="merge"){let d=k({contextDir:o.contextDir,graph:n,survivor:r,merged:p,reason:`pair merge: duplicate of ${t.pair.candidate_ref} (score ${t.pair.score})`,by:s});return d.errors?{outcome:"failed",detail:d.errors.map(c=>`${c.code}: ${c.detail}`).join("; ")}:(o.signals?.({ref:t.ref,verdict:"pair-merged",reason:t.pair.candidate_ref}),{outcome:"committed",detail:`merged into ${t.pair.candidate_ref} \u2014 survivor stays derived`})}let u=f({contextDir:o.contextDir,graph:n,verdicts:new Map([[p,{resolution:"approved"}],[r,{resolution:"approved"}]]),by:s});return u.errors?{outcome:"failed",detail:u.errors.map(d=>`${d.code}: ${d.detail}`).join("; ")}:(o.signals?.({ref:t.ref,verdict:"pair-kept-both",reason:t.pair.candidate_ref}),{outcome:"applied",detail:"both promoted as distinct"})}return{outcome:"failed",detail:`verdict ${i.v} does not apply to a ${t.kind} card`}}export{I as a,N as b,Y as c};
|