@testmuai/kane-cli 0.8.13 → 0.8.15
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-B6ZIO3JL.js → ChatSurface-2GPR4S7I.js} +3 -3
- package/dist/{ChromeProfilePicker-QSICCUMV.js → ChromeProfilePicker-XAZGCJKR.js} +1 -1
- package/dist/{CliFeedbackPrompt-LLLNSKW2.js → CliFeedbackPrompt-4SILDU7S.js} +1 -1
- package/dist/{CliUploadProgress-N5IY66T2.js → CliUploadProgress-OAQBY55Y.js} +1 -1
- package/dist/{ConfigView-UQIRPENS.js → ConfigView-FDBMJC26.js} +1 -1
- package/dist/EvidenceViewOffer-YSNRKKPC.js +2 -0
- package/dist/FolderPicker-XCTJ5447.js +2 -0
- package/dist/{InfoBox-ZGSLEOPE.js → InfoBox-ZPUBB7J4.js} +1 -1
- package/dist/{LinksBox-JFT44YUK.js → LinksBox-MNNNOH23.js} +1 -1
- package/dist/{ProfilesView-WZSPK3HF.js → ProfilesView-GY5QCIT3.js} +1 -1
- package/dist/{ProjectPicker-SBBGVF4L.js → ProjectPicker-UCHMCNFV.js} +1 -1
- package/dist/{SaveSessionPrompt-F3563T3C.js → SaveSessionPrompt-ATVHKAHN.js} +1 -1
- package/dist/ScrollbackTap-QHJOFYMC.js +2 -0
- package/dist/SingleShotApp-IPNZBFXB.js +2 -0
- package/dist/{SummaryBox-6N6NESLI.js → SummaryBox-2DTNE25L.js} +1 -1
- package/dist/TestMdRunView-2FQIEI5W.js +2 -0
- package/dist/{TestrunEvidenceTable-JLJBJ76Q.js → TestrunEvidenceTable-6UE5EMON.js} +1 -1
- package/dist/{WhoamiView-PNVUCWLB.js → WhoamiView-TFCHIOW5.js} +1 -1
- package/dist/agent-parse-XMWVKCRD.js +2 -0
- package/dist/{app-download-NNB52ZRJ.js → app-download-N7MLJQ42.js} +1 -1
- package/dist/attach-target-V6LECVES.js +2 -0
- package/dist/{auth-JIDDELKY.js → auth-IQPCVCZK.js} +1 -1
- package/dist/{binary-LXYAW7WQ.js → binary-VML7EGV4.js} +1 -1
- package/dist/bind-YV6V5AI6.js +15 -0
- package/dist/{bootstrap-THOC3SS7.js → bootstrap-KCPWDBLX.js} +1 -1
- package/dist/bridge-5UKX7YIO.js +2 -0
- package/dist/{changelog-BSMZXLTG.js → changelog-CJFWGRIL.js} +1 -1
- package/dist/chat-committer-HDE3TP5I.js +2 -0
- package/dist/chat-controller-3EPK7UZG.js +2 -0
- package/dist/chunk-27ERHOW3.js +2 -0
- package/dist/{chunk-RN5ERSV2.js → chunk-2WRBCTNM.js} +1 -1
- package/dist/chunk-3D5MKSG3.js +5 -0
- package/dist/{chunk-FNIL4G3V.js → chunk-3GELV4IN.js} +3 -3
- package/dist/{chunk-EEFZXZTZ.js → chunk-3IXEARDX.js} +1 -1
- package/dist/chunk-3N6IAVD5.js +7 -0
- package/dist/{chunk-DXFMELKC.js → chunk-4TMQTSIO.js} +1 -1
- package/dist/chunk-52WM3XYO.js +4 -0
- package/dist/{chunk-R7QAS6LZ.js → chunk-55YDTPB7.js} +1 -1
- package/dist/{chunk-477DYMXZ.js → chunk-5HTSKF5K.js} +1 -1
- package/dist/{chunk-IDX3TOPY.js → chunk-5LJRZI7S.js} +1 -1
- package/dist/chunk-66MOZKD2.js +2 -0
- package/dist/chunk-6DHEOPXX.js +9 -0
- package/dist/{chunk-NU45ROHH.js → chunk-6GLFQHSW.js} +2 -2
- package/dist/chunk-6K4FDYMH.js +89 -0
- package/dist/{chunk-7GUFVQOQ.js → chunk-6L5RV62W.js} +1 -1
- package/dist/{chunk-TDNM22BQ.js → chunk-74FHTDEE.js} +1 -1
- package/dist/chunk-7EGIX6Y4.js +8 -0
- package/dist/chunk-7O54QURK.js +2 -0
- package/dist/chunk-7WDPU33M.js +2 -0
- package/dist/{chunk-BTBUIL4Q.js → chunk-7X4R6464.js} +1 -1
- package/dist/{chunk-FUP4AP6J.js → chunk-A557OSRS.js} +1 -1
- package/dist/chunk-AHXOKBVE.js +7 -0
- package/dist/{chunk-DNNZ353O.js → chunk-ALCE5RLK.js} +1 -1
- package/dist/{chunk-I75FRXKE.js → chunk-AYJ2YZP5.js} +1 -1
- package/dist/chunk-BMVE73M7.js +21 -0
- package/dist/chunk-CAOZKSQ3.js +8 -0
- package/dist/{chunk-BJAHVN2F.js → chunk-CNPIJFZM.js} +1 -1
- package/dist/{chunk-EV64VI66.js → chunk-CRZUBDJ3.js} +1 -1
- package/dist/{chunk-PUM5J56E.js → chunk-D6GBOFK5.js} +1 -1
- package/dist/{chunk-YEZYO5QH.js → chunk-DMCEGMGB.js} +1 -1
- package/dist/{chunk-TMRLBSIA.js → chunk-DMT3W26F.js} +1 -1
- package/dist/{chunk-XS3HIVNS.js → chunk-EDQZIEPJ.js} +1 -1
- package/dist/{chunk-VJ3ES3RR.js → chunk-EFTRH35G.js} +1 -1
- package/dist/{chunk-Q4YAJJPP.js → chunk-EJXBKCNF.js} +1 -1
- package/dist/{chunk-NUWOQS6L.js → chunk-EPE2ELDH.js} +1 -1
- package/dist/{chunk-WIAZN7G4.js → chunk-FFVNISYH.js} +1 -1
- package/dist/chunk-FQNQVC5O.js +5 -0
- package/dist/chunk-FXO7JKMZ.js +4 -0
- package/dist/chunk-GP7WD4UY.js +4 -0
- package/dist/{chunk-K2UEVCIJ.js → chunk-GSDXZS4U.js} +1 -1
- package/dist/{chunk-J2UN2AHO.js → chunk-GZ65ZA4C.js} +1 -1
- package/dist/chunk-H6TNBKGR.js +5 -0
- package/dist/{chunk-GILD6RGH.js → chunk-HLCETZ73.js} +1 -1
- package/dist/chunk-HOA4VWSD.js +5 -0
- package/dist/{chunk-33GXXC2L.js → chunk-HYTBEPC2.js} +1 -1
- package/dist/{chunk-PWRIG6UB.js → chunk-IAHOLH5W.js} +1 -1
- package/dist/chunk-IE3OO5GI.js +2 -0
- package/dist/{chunk-UF4JZXEE.js → chunk-JCMHB4KH.js} +1 -1
- package/dist/{chunk-KV5BOFPK.js → chunk-JFUFWICY.js} +2 -2
- package/dist/{chunk-FE6XRABM.js → chunk-JGAMMOUC.js} +1 -1
- package/dist/{chunk-CAO3XRA2.js → chunk-JL3L6KOG.js} +1 -1
- package/dist/chunk-JQCOKL6U.js +15 -0
- package/dist/{chunk-IZU5ND2C.js → chunk-JSS22MFY.js} +9 -9
- package/dist/chunk-JVEZBJJ7.js +2 -0
- package/dist/{chunk-3SP4JVDN.js → chunk-KALEPJAV.js} +2 -2
- package/dist/{chunk-AIVOYTYQ.js → chunk-KUS324VE.js} +1 -1
- package/dist/chunk-KZG4E5RM.js +2 -0
- package/dist/{chunk-KSLJOUH4.js → chunk-LJGAXIDU.js} +1 -1
- package/dist/chunk-M36MOFJW.js +9 -0
- package/dist/{chunk-ZOSY2PJM.js → chunk-MLYNVJNH.js} +1 -1
- package/dist/{chunk-XL6HDWM3.js → chunk-N3CVR4Z2.js} +1 -1
- package/dist/{chunk-2X3TANEV.js → chunk-NLEA6NPU.js} +1 -1
- package/dist/{chunk-4PARDPK2.js → chunk-NUJVYAI4.js} +1 -1
- package/dist/{chunk-3M2D7UUI.js → chunk-NWNG5UWD.js} +1 -1
- package/dist/{chunk-IWVA37B6.js → chunk-O25AL4B7.js} +1 -1
- package/dist/{chunk-KAZGHWGK.js → chunk-O3XBIURC.js} +1 -1
- package/dist/chunk-O66WXOOC.js +5 -0
- package/dist/{chunk-W2UYUV47.js → chunk-OFWJBOGT.js} +2 -2
- package/dist/{chunk-DMLYUTS4.js → chunk-OGDAWNFY.js} +1 -1
- package/dist/chunk-OPL2MIQG.js +2 -0
- package/dist/{chunk-F5AI3UVS.js → chunk-ORQGQSWG.js} +2 -2
- package/dist/{chunk-7KIIM6H7.js → chunk-OWGFFJKK.js} +1 -1
- package/dist/{chunk-6AZNGOLH.js → chunk-PGXJ275T.js} +1 -1
- package/dist/chunk-Q77QO3PC.js +17 -0
- package/dist/{chunk-XH2KDLZO.js → chunk-QVLYK5JL.js} +1 -1
- package/dist/{chunk-UZCSVEWP.js → chunk-QXRT6HSV.js} +1 -1
- package/dist/{chunk-LWQNRZH3.js → chunk-R7QMZBBH.js} +1 -1
- package/dist/{chunk-DIM5X2FR.js → chunk-RI4ILZZC.js} +1 -1
- package/dist/{chunk-D4G3SEBU.js → chunk-RQILLYSP.js} +1 -1
- package/dist/chunk-S4JUCBCT.js +7 -0
- package/dist/{chunk-VYMMGWVO.js → chunk-SHSXOYKT.js} +1 -1
- package/dist/{chunk-XAM5E27U.js → chunk-SIYSKT6I.js} +1 -1
- package/dist/chunk-SWTJMTBY.js +29 -0
- package/dist/chunk-T4R26WER.js +9 -0
- package/dist/{chunk-O5U6EAL3.js → chunk-TCAHDVII.js} +1 -1
- package/dist/{chunk-LAQBCZ5A.js → chunk-TEHZUSUY.js} +1 -1
- package/dist/chunk-TNBF5OMZ.js +2 -0
- package/dist/chunk-TU6IMGWO.js +2 -0
- package/dist/{chunk-NM76SG3S.js → chunk-TVELOH5A.js} +1 -1
- package/dist/chunk-UHSNUUX3.js +35 -0
- package/dist/{chunk-5G22NOZK.js → chunk-UHT5SVP5.js} +1 -1
- package/dist/{chunk-KXUTO5WC.js → chunk-UZIMYV5U.js} +1 -1
- package/dist/chunk-VOTIGXQ4.js +16 -0
- package/dist/{chunk-MXDWS7S4.js → chunk-VZDLRJ5N.js} +7 -7
- package/dist/{chunk-3FXNQTCE.js → chunk-W77SZLFC.js} +1 -1
- package/dist/{chunk-OHK6V7JX.js → chunk-WFBJNVMQ.js} +1 -1
- package/dist/{chunk-N2I23ANS.js → chunk-WNB2IYHY.js} +1 -1
- package/dist/chunk-XSUJJB7Z.js +11 -0
- package/dist/{chunk-TXZ66K4Q.js → chunk-XUJXGE42.js} +1 -1
- package/dist/{chunk-AQWTK6IN.js → chunk-XXE7W5AV.js} +1 -1
- package/dist/{chunk-EXLXV5OU.js → chunk-YAAQER2L.js} +1 -1
- package/dist/{chunk-XS2LZFCH.js → chunk-YCH7H7JX.js} +1 -1
- package/dist/{chunk-SEKJZOKW.js → chunk-YGMUNNKH.js} +1 -1
- package/dist/{chunk-ARU6KAGY.js → chunk-YKYKOV6U.js} +1 -1
- package/dist/chunk-YLQHY4A7.js +2 -0
- package/dist/{chunk-KGKJU27A.js → chunk-YYYQ5MVD.js} +1 -1
- package/dist/chunk-YZVR7ESF.js +2 -0
- package/dist/{chunk-PYQS5ST6.js → chunk-Z3YYMZHT.js} +2 -2
- package/dist/{chunk-QD2BUO5M.js → chunk-Z73ZYROU.js} +1 -1
- package/dist/{chunk-JX2CAVX6.js → chunk-ZCSEBT2W.js} +1 -1
- package/dist/{chunk-MCKBJIBB.js → chunk-ZEVU2OT3.js} +1 -1
- package/dist/{chunk-K4SULRBL.js → chunk-ZKCCG3GK.js} +1 -1
- package/dist/chunk-ZUZ6QJRA.js +23 -0
- package/dist/committer-IYQPXG6C.js +2 -0
- package/dist/{config-BCGD2FEX.js → config-UGCWZGH5.js} +1 -1
- package/dist/cover-cmd-SWJ2NZUZ.js +3 -0
- package/dist/{credentials-YNH5BU2Z.js → credentials-GWLYYRTL.js} +1 -1
- package/dist/{deps-bundle-LOFI4DAJ.js → deps-bundle-VNGC2UG6.js} +1 -1
- package/dist/{deps-resolve-GA6IPHVZ.js → deps-resolve-YLCEU6I7.js} +1 -1
- package/dist/design-committer-J57IAAA5.js +2 -0
- package/dist/dispatch-OMQCT7WO.js +2 -0
- package/dist/{doctor-W5TQBYB5.js → doctor-B4Z6RPKQ.js} +1 -1
- package/dist/docx-convert-WPZS6OIC.js +2 -0
- package/dist/{dossier-Y6TJWFZU.js → dossier-UGJMYYAB.js} +1 -1
- package/dist/evidence-XJGXVLO5.js +2 -0
- package/dist/evolve-cmd-QQQPPGL3.js +2 -0
- package/dist/explain-H5HJEDEF.js +2 -0
- package/dist/{explain-cmd-XCRO4AS6.js → explain-cmd-R45I5MT7.js} +1 -1
- package/dist/explain-cmd-XVE6Z67Q.js +9 -0
- package/dist/extract-bind-7IDQS4QP.js +14 -0
- package/dist/{extract-cmd-7FKQJNS7.js → extract-cmd-KIEOBRIT.js} +3 -3
- package/dist/feeder-RSHMGW6B.js +2 -0
- package/dist/gaps-cmd-RGIPUSIR.js +3 -0
- package/dist/{generate-headless-OBMB5CSB.js → generate-headless-XGRIDD6O.js} +2 -2
- package/dist/headless-io-3A3BZVQ5.js +2 -0
- package/dist/index.js +187 -206
- package/dist/ingest-QGLVY7ND.js +2 -0
- package/dist/ingest-cmd-R5H5SF5K.js +2 -0
- package/dist/install-W3VPVPAQ.js +2 -0
- package/dist/interactive-bind-X5DVLRRW.js +26 -0
- package/dist/lifecycle-cmd-6R2PR2HM.js +2 -0
- package/dist/{list-cmd-V3HJ5K4O.js → list-cmd-QCIYKWYQ.js} +1 -1
- package/dist/{list-commands-SH4HPFI4.js → list-commands-VRRCVWKO.js} +1 -1
- package/dist/{locks-cmd-CSVSWY2Y.js → locks-cmd-67OHQZNV.js} +1 -1
- package/dist/logical-ids-DN6IZSUM.js +2 -0
- package/dist/login-flow-5HL2QYEL.js +2 -0
- package/dist/maintenance-cmd-GZ4EMT3V.js +2 -0
- package/dist/{mobile-prompts-UZTRJ3L7.js → mobile-prompts-CMIVWDHQ.js} +1 -1
- package/dist/objective-variable-gate-EEYJ6B3X.js +2 -0
- package/dist/open-provider-UFSCTIQQ.js +2 -0
- package/dist/pdf-convert-5H4HQNN3.js +2 -0
- package/dist/{persist-recorded-session-QMRY4DOF.js → persist-recorded-session-JXL5E53A.js} +1 -1
- package/dist/phase-seed-HKJ2EF7R.js +2 -0
- package/dist/pipeline-RSCRNNPW.js +2 -0
- package/dist/prepare-target-XZ3FTVBW.js +2 -0
- package/dist/readmodel-IBFRM6EO.js +2 -0
- package/dist/reconcile-cmd-4VRTUM2D.js +2 -0
- package/dist/reconcile-deps-ZCJ2QCK5.js +4 -0
- package/dist/reconcile-engine-IVLZCYZB.js +2 -0
- package/dist/{recording-banner-7E75ERQJ.js → recording-banner-SRLPSTFP.js} +1 -1
- package/dist/records-TJJJWBUD.js +2 -0
- package/dist/registry-CPQHW2L2.js +2 -0
- package/dist/{require-project-folder-LBUYWQOF.js → require-project-folder-SKEZMSN7.js} +1 -1
- package/dist/{resolve-run-intent-GHISMXLZ.js → resolve-run-intent-THC3EPAX.js} +1 -1
- package/dist/{resolver-7JC5VZ4S.js → resolver-2NUNLK7N.js} +1 -1
- package/dist/revert-6BBBK3I4.js +2 -0
- package/dist/review-cmd-BMJQZ6XJ.js +5 -0
- package/dist/run-TURFDLC6.js +2 -0
- package/dist/run-UDP5VPYS.js +2 -0
- package/dist/{run-test-md-5LPCKCW7.js → run-test-md-MRYNFNPO.js} +2 -2
- package/dist/sessions-NH7WQWMX.js +2 -0
- package/dist/{sessions-cmd-VDQGRBEM.js → sessions-cmd-DV442ZCY.js} +1 -1
- package/dist/{skill-installer-YQPZZB7I.js → skill-installer-CVJ5VTEJ.js} +1 -1
- package/dist/{spawner-X2FOOONV.js → spawner-7FUA3JXA.js} +1 -1
- package/dist/store-guard-XQ5MSUB2.js +2 -0
- package/dist/structured-answers-NADW6D44.js +5 -0
- package/dist/sync-cmd-5INKTZN2.js +2 -0
- package/dist/sync-setup-4R54VRAO.js +2 -0
- package/dist/sync-setup-ui-RC727VK6.js +3 -0
- package/dist/tcg-generate-2BOPGRM6.js +2 -0
- package/dist/testmd-actions-2CPJZAC2.js +2 -0
- package/dist/testmd-sync-HYZI6NRM.js +2 -0
- package/dist/token-refresh-NTE4LQRN.js +2 -0
- package/dist/{validate-basic-GTSVZFQI.js → validate-basic-OKLJLDML.js} +1 -1
- package/dist/{variable-receipt-IHQAYWMZ.js → variable-receipt-CMCDUJI2.js} +1 -1
- package/dist/verdicts-EMCYGQWM.js +2 -0
- package/dist/{version-check-IPEPJZDX.js → version-check-4DQJBSXW.js} +1 -1
- package/dist/{view-cmd-SXXNDZIC.js → view-cmd-P3XRFORJ.js} +1 -1
- package/dist/walk-session-MUGS6CZY.js +2 -0
- package/dist/with-telemetry-3T53GIQC.js +2 -0
- package/package.json +12 -11
- package/dist/EvidenceViewOffer-AZRAILJQ.js +0 -2
- package/dist/FolderPicker-OJFR7AKZ.js +0 -2
- package/dist/ScrollbackTap-Q3IOKNMS.js +0 -2
- package/dist/SingleShotApp-72D5VVLE.js +0 -2
- package/dist/TestMdRunView-4OA52DA2.js +0 -2
- package/dist/bind-F36JFHUK.js +0 -12
- package/dist/bridge-KMDML2NB.js +0 -2
- package/dist/chat-committer-RAOIL2T6.js +0 -2
- package/dist/chat-controller-YJCNU76T.js +0 -2
- package/dist/chunk-4WOVHRI2.js +0 -15
- package/dist/chunk-54JZ6VEW.js +0 -4
- package/dist/chunk-5DT7PIGB.js +0 -5
- package/dist/chunk-6FCPS2VT.js +0 -4
- package/dist/chunk-6IAA644J.js +0 -9
- package/dist/chunk-6J635CRI.js +0 -5
- package/dist/chunk-AGRUULPT.js +0 -4
- package/dist/chunk-BZTWTYQQ.js +0 -6
- package/dist/chunk-CUSTYILP.js +0 -2
- package/dist/chunk-DBIBROYW.js +0 -5
- package/dist/chunk-I27YRAGO.js +0 -7
- package/dist/chunk-IAHKTEET.js +0 -2
- package/dist/chunk-IVQX3AKL.js +0 -4
- package/dist/chunk-J3Q63NFG.js +0 -2
- package/dist/chunk-K6RAOZHP.js +0 -4
- package/dist/chunk-KO3FL2XW.js +0 -26
- package/dist/chunk-L32DKFRQ.js +0 -16
- package/dist/chunk-LPDBTGO5.js +0 -21
- package/dist/chunk-N7Z7BQYO.js +0 -3
- package/dist/chunk-NVGBE2DR.js +0 -2
- package/dist/chunk-OS4VSIHT.js +0 -4
- package/dist/chunk-OTMAFCZK.js +0 -8
- package/dist/chunk-P5MJMM3X.js +0 -85
- package/dist/chunk-QQ5MHSSY.js +0 -2
- package/dist/chunk-T7DGNWI2.js +0 -17
- package/dist/chunk-UH2ZTX4E.js +0 -2
- package/dist/chunk-W3Z7AZNT.js +0 -4
- package/dist/chunk-WUV3FJ7C.js +0 -11
- package/dist/chunk-XMTSHHYQ.js +0 -4
- package/dist/committer-C6UCDYMC.js +0 -2
- package/dist/cover-cmd-5LPHIOSI.js +0 -3
- package/dist/design-committer-UPC6NZUF.js +0 -2
- package/dist/dispatch-FRCPK3AZ.js +0 -2
- package/dist/docx-convert-BIV5T7F5.js +0 -2
- package/dist/evidence-FHO36EEV.js +0 -2
- package/dist/evolve-cmd-6RXLKERE.js +0 -2
- package/dist/explain-3HAZY7Q6.js +0 -2
- package/dist/explain-cmd-RMJPXD4U.js +0 -9
- package/dist/extract-bind-BFJPRNPQ.js +0 -10
- package/dist/feeder-IOR3XRNF.js +0 -2
- package/dist/gaps-cmd-FDJ3PT4C.js +0 -3
- package/dist/headless-io-66RG5NN5.js +0 -2
- package/dist/ingest-TTUQ7UDK.js +0 -2
- package/dist/ingest-cmd-AV66Q5LC.js +0 -2
- package/dist/install-SFJ2FFQ6.js +0 -2
- package/dist/interactive-bind-N5AQB26T.js +0 -25
- package/dist/lifecycle-cmd-KSMETBPP.js +0 -2
- package/dist/logical-ids-MLXAH45L.js +0 -2
- package/dist/login-flow-ODVWEPRU.js +0 -2
- package/dist/maintenance-cmd-VFYGKY3X.js +0 -2
- package/dist/objective-variable-gate-3VUXNDCZ.js +0 -2
- package/dist/pdf-convert-OZIRUADA.js +0 -2
- package/dist/phase-seed-BMOSAA74.js +0 -2
- package/dist/pipeline-5FHWZAXK.js +0 -2
- package/dist/prepare-target-UJEY2FSR.js +0 -2
- package/dist/readmodel-TDRFVDVI.js +0 -2
- package/dist/reconcile-cmd-2QHZML2L.js +0 -2
- package/dist/reconcile-deps-ZBWUY3SM.js +0 -4
- package/dist/reconcile-engine-YC4RQYF2.js +0 -2
- package/dist/records-JLS63SDI.js +0 -2
- package/dist/registry-JJTRUPH7.js +0 -2
- package/dist/revert-PRR3D4XM.js +0 -2
- package/dist/review-cmd-SAGIKWEW.js +0 -4
- package/dist/run-43ACVPJK.js +0 -2
- package/dist/run-EOTOXNQO.js +0 -2
- package/dist/sessions-GIEXOCE4.js +0 -2
- package/dist/structured-answers-YAVW65G4.js +0 -5
- package/dist/tcg-generate-V4QRNEZV.js +0 -2
- package/dist/testmd-actions-2UMU3QMV.js +0 -2
- package/dist/testmd-sync-UBXDLWYD.js +0 -2
- package/dist/token-refresh-NL5AM446.js +0 -2
- package/dist/verdicts-QU6W3TUF.js +0 -2
- package/dist/walk-session-7JVB4Z5S.js +0 -2
- package/dist/with-telemetry-LRI7H6DH.js +0 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{b as N,c as O,e as S,f as D,j as T,n as y,p as z,r as U}from"./chunk-
|
|
2
|
+
import{b as N,c as O,e as S,f as D,j as T,n as y,p as z,r as U}from"./chunk-JQCOKL6U.js";import{a as Y,b as M}from"./chunk-NBXYL2JT.js";import{a as F}from"./chunk-CAOZKSQ3.js";import{a as R}from"./chunk-DHJSM5DT.js";import{a as A}from"./chunk-HYTBEPC2.js";import{e as $}from"./chunk-UR6MHSHU.js";var C=$(Y(),1);import{existsSync as k,readFileSync as I,readdirSync as J,statSync as K}from"fs";import{dirname as H,isAbsolute as V,join as h,relative as P,resolve as Z,sep as _}from"path";import{createHash as q}from"crypto";var b="testmd-bundle.json",u=class extends Error{constructor(t){super(t),this.name="BundleUsageError"}},B=e=>e.split(_).join("/");function v(e){if(!k(e))return[];let t=[];for(let s of J(e).sort()){let r=h(e,s);K(r).isDirectory()?t.push(...v(r)):t.push(r)}return t}function G(e){let t=e.map(r=>H(r).split(_)),s=t[0];for(let r of t.slice(1)){let i=0;for(;i<s.length&&i<r.length&&s[i]===r[i];)i++;s=s.slice(0,i)}return s.join(_)||_}function Q(e){for(let t of e){let s=F(t,I(t,"utf8"));for(let r of s.steps)if(r.body.kind==="import_ref"&&V(r.body.path))throw new u(`bundle sync: absolute @import is not portable after unzip: ${t} step ${r.index} (@import ${r.body.path})`)}}function j(e,t={}){let s=Z(e),r=S(s),i=y(s);if(!i?.commit_id||!i?.test_id)throw new u(`bundle sync: ${s} is not authored \u2014 run \`kane-cli testmd run\` first (output-<stem>/.internal/meta.json needs commit_id + test_id)`);let l;try{l=U(s)}catch(n){throw n instanceof z?new u(`bundle sync: ${n.message}`):n}let c=[s];for(let n of l.steps)for(let a of n.trace.slice(1))c.includes(a.file)||c.push(a.file);Q(c);let o=[],d=[];for(let n of l.unitFiles){if(n.file===s)continue;let a=N(n.file);o.includes(a)||o.push(a),n.kind==="module"&&d.push(S(n.file))}let m=[...c],p=n=>{k(n)&&m.push(n)};p(O(s)),m.push(r),p(D(s)),m.push(...v(T(s)));for(let n of o)p(h(n,"Result.md")),m.push(...v(h(n,".internal","steps")));for(let n of d)p(n);let f=G(m);if(k(h(f,b)))throw new u(`bundle sync: a real file named ${b} exists at the zip root (${f}) \u2014 it would collide with the generated manifest`);let w=m.map(n=>{let a=n===r&&t.identityOverride?Buffer.from(JSON.stringify({...JSON.parse(I(n,"utf8")),commit_id:t.identityOverride.commit_id},null,2)+`
|
|
3
3
|
`):void 0,E=a??I(n);return{abs:n,rel:B(P(f,n)),sha256:q("sha256").update(E).digest("hex"),bytes:E.length,...a?{contents:a}:{}}}).sort((n,a)=>n.rel<a.rel?-1:1),x=B(P(f,s)),L={schema_version:2,entry:x,commit_id:t.identityOverride?.commit_id??i.commit_id,test_id:i.test_id,testcase_id:i.testcase_id??null,project_id:i.project_id??null,folder_id:i.folder_id??null,org_id:i.org_id??null,created_at:new Date().toISOString(),producer:{name:"kane-cli",version:A},files:w.map(n=>({path:n.rel,sha256:n.sha256,bytes:n.bytes})),units:l.unitFiles.filter(n=>n.file!==s).map(n=>({path:B(P(f,n.file)),kind:n.kind}))};return{zipRoot:f,entry:x,files:w,manifest:L}}var g=e=>e instanceof Error?e.message:String(e);function W(e){return new Promise((t,s)=>{let r=(0,C.default)("zip",{zlib:{level:6}}),i=[];r.on("data",l=>i.push(l)),r.on("error",s),r.on("end",()=>t(Buffer.concat(i))),r.append(JSON.stringify(e.manifest,null,2)+`
|
|
4
4
|
`,{name:b});for(let l of e.files)l.contents?r.append(l.contents,{name:l.rel}):r.file(l.abs,{name:l.rel});r.finalize()})}async function X(e){let{plan:t,controller:s,testId:r,sessionId:i,commitId:l}=e,c;try{c=await W(t)}catch(d){return{ok:!1,stage:"zip",error:g(d)}}let o;try{let d={key:"testmd",content_type:"application/zip",filename:`${l}-testmd.zip`},p=(await s.getPresignedUrls(r,i,[d])).urls?.testmd?.upload_url;if(!p)return{ok:!1,stage:"presign",error:"presign response missing testmd upload_url"};o=p}catch(d){return{ok:!1,stage:"presign",error:g(d)}}try{await M(o,c,"application/zip")}catch(d){return{ok:!1,stage:"upload",error:g(d)}}return{ok:!0,bytes:c.length}}async function ee(e){let t;try{t=j(e.sourcePath,{identityOverride:e.identityOverride})}catch(s){return s instanceof u?{ok:!1,stage:"collect",error:s.message}:{ok:!1,stage:"collect",error:g(s)}}return X({...e,plan:t})}function ge(e){return e.shouldUploadPipeline&&e.uploadSucceeded&&!!e.metaCommitId&&!!e.metaTestId}function te(e){return e.persisted?e.uploadSucceeded?e.local?"local":e.hasBasicAuth?!e.metaCommitId||!e.metaTestId?"not_authored":null:"no_auth":"upload_failed":"not_persisted"}async function ye(e){let t=e.recordedTestPath??null,s=t?y(t):null,r=te({persisted:!!t,uploadSucceeded:e.uploadSucceeded,local:e.local,hasBasicAuth:!!e.basicAuth,metaCommitId:s?.commit_id,metaTestId:s?.test_id});if(r)return e.log("info","BUNDLE_SYNC_SKIPPED","testmd bundle sync skipped",{reason:r,...t?{path:t}:{}}),{skipped:r};let i=s.commit_id,l=s.test_id,c=o=>{try{e.onAgentEvent?.(o)}catch{}};try{let o=await(e.syncFn??ee)({sourcePath:t,testId:l,sessionId:e.sessionId,commitId:i,controller:new R(e.controllerBaseUrl,{username:e.basicAuth.username,accessKey:e.basicAuth.access_key})});return o.ok?(e.log("info","BUNDLE_SYNC_OK","testmd bundle pushed",{commit_id:i,path:t,bytes:o.bytes}),c({type:"test_md_bundle_sync",status:"ok",commit_id:i,path:t,bytes:o.bytes})):(e.log("warn","BUNDLE_SYNC_FAILED","testmd bundle sync failed",{commit_id:i,path:t,stage:o.stage,error:o.error}),c({type:"test_md_bundle_sync",status:"failed",commit_id:i,path:t,stage:o.stage})),o}catch(o){let d=g(o);return e.log("warn","BUNDLE_SYNC_FAILED","testmd bundle sync threw",{commit_id:i,path:t,error:d}),c({type:"test_md_bundle_sync",status:"failed",commit_id:i,path:t,stage:"upload"}),{ok:!1,stage:"upload",error:d}}}export{j as a,W as b,X as c,ee as d,ge as e,te as f,ye as g};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{c as m,d as p,e as g}from"./chunk-
|
|
2
|
+
import{c as m,d as p,e as g}from"./chunk-EDQZIEPJ.js";import{b as d}from"./chunk-HYTBEPC2.js";import{mkdirSync as h,writeFileSync as o,existsSync as u,readFileSync as M}from"fs";import{join as a}from"path";var E={name:"remote-execution",version:"0.5.0",backendId:"hyper",kaneCompat:">=0.4.0",defaults:{runson:"mac",concurrency:1}},f={runson:"mac",concurrency:1,timeoutMinutes:120,mobile:{runson:"mac26",deviceName:"Galaxy A53 5G",osVersion:"15",queueTimeout:300,appiumPort:4739,androidHome:"$HOME/android-sdk-shim",globalTimeout:90,testSuiteTimeout:90,testSuiteStep:45,ios:{deviceName:"iPhone 15",osVersion:"17.5",runson:{}}}},v=`version: "0.1"
|
|
3
3
|
runson: {{runson}}
|
|
4
4
|
autosplit: true
|
|
5
5
|
concurrency: {{concurrency}}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{y as m}from"./chunk-
|
|
2
|
+
import{y as m}from"./chunk-HYTBEPC2.js";import{a as x}from"./chunk-HCBYKLMW.js";import{a as u,b as a,j as g}from"./chunk-C44QQJR4.js";import{a as b}from"./chunk-6YGTRKDT.js";import{e as f}from"./chunk-UR6MHSHU.js";var T=f(b(),1);function k(i,n){if(!n)return i;let l=i.trim()||n;return`\x1B]8;;${n}\x07${l}\x1B]8;;\x07`}var r=f(x(),1);function $({shareableLink:i,testCaseLink:n,codeExportDir:l,recordedTestPath:s,outputDir:o,autoExit:p=!0}){let{exit:c}=g();(0,T.useEffect)(()=>{if(!p)return;let t=setTimeout(()=>c(),100);return()=>clearTimeout(t)},[c,p]);let e=[];return s&&e.push({label:"Test",url:s,linkUrl:`file://${s}`}),o&&e.push({label:"Output",url:o,linkUrl:`file://${o}`}),i&&e.push({label:"ShareLink",url:i}),n&&e.push({label:"TestCase",url:n}),l&&!o&&e.push({label:"CodeExport",url:l,linkUrl:`file://${l}`}),e.length===0?(0,r.jsx)(r.Fragment,{}):(0,r.jsx)(u,{flexDirection:"column",marginTop:1,marginLeft:1,children:e.map(t=>(0,r.jsxs)(u,{flexDirection:"column",marginBottom:1,children:[(0,r.jsxs)(a,{color:m.orange,children:[t.label,":"]}),(0,r.jsx)(a,{color:m.dim,children:k(t.url,t.linkUrl??t.url)})]},t.label))})}export{$ as a};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{e as z}from"./chunk-EHN5HTUD.js";import{b as X,c as v,e as W,i as Y,j as Z,k as ee,l as te,m as E}from"./chunk-JQCOKL6U.js";import{a as Q}from"./chunk-CAOZKSQ3.js";import{d as q}from"./chunk-HYTBEPC2.js";import{copyFileSync as ye,cpSync as Se,existsSync as P,mkdirSync as Re,readFileSync as Ge,readdirSync as xe,rmSync as qe,writeFileSync as ze}from"fs";import{dirname as Qe,isAbsolute as Xe,join as R,relative as Ye,resolve as Ze}from"path";import{writeFileSync as Me,mkdirSync as we,readFileSync as ve}from"fs";import{dirname as Pe,basename as ne}from"path";function re(e){let t=e.outPath??v(e.sourcePath);we(Pe(t),{recursive:!0});let n=[];n.push("---"),n.push(`test: ../${ne(e.sourcePath)}`),n.push(`status: ${e.overallStatus}`),n.push(`started: ${e.startedISO}`),n.push(`duration_s: ${e.durationS}`),n.push(`session_id: ${e.sessionId}`),n.push("---",""),n.push(`# ${e.title??ne(e.sourcePath)} \u2014 Result`,"");for(let r=0;r<e.rootSteps.length;r++){let o=e.rootSteps[r],s=e.outcomes.find(p=>p.rootStepIndex===r+1);if(n.push(je(o,s)),s?.stepMd5&&n.push(`md5: ${s.stepMd5}`),s?.status==="failed"&&s.reason&&n.push(`Reason: ${s.reason}`),s?.softFailures?.length)for(let p of s.softFailures){let a=p.reason?`: ${p.reason}`:"";n.push(`\u26A0 optional sub-step ${p.subStepIndex} failed${a}`)}o.body.kind==="objective"&&s?.status!=="skipped"&&n.push(o.body.text),n.push("")}return Me(t,n.join(`
|
|
3
|
+
`),"utf8"),t}function je(e,t){if(!t)return`## ${e.heading} (no outcome)`;let n=t.duration_s!=null?`${t.duration_s}s`:"\u2014";if(t.status==="skipped")return`## ${e.heading} \u23ED skipped`;let r=t.softFailed?" (optional)":"";if(t.refKind&&t.status==="passed"){let o=t.helperResultRelPath?` \u2192 ${t.helperResultRelPath}`:"";return`## ${e.heading} \u2713 passed (via @${t.refKind} ${t.refLabel} \u2014 ${t.inlinedCount} inlined steps, ${n}${o})`}if(t.refKind&&t.status==="failed"){let o=t.failedSubStepIndex&&t.failedSubStepIndex.length>0?` \u2014 at sub-step ${t.failedSubStepIndex.join(" \u2192 sub-step ")}`:"",s=t.helperResultRelPath?` \u2192 ${t.helperResultRelPath}`:"";return`## ${e.heading} \u2717 failed${r} (via @${t.refKind} ${t.refLabel}${o}, ${n}${s})`}return t.status==="passed"?`## ${e.heading} \u2713 passed (${n})`:`## ${e.heading} \u2717 failed${r} (${n})`}var De=/^##\s+(.+?)\s+(✓ passed|✗ failed(?:\s+\(optional\))?|⏭ skipped)(?:\s+\((.*)\))?\s*$/,$e=/via\s+@\w+\s+(\S+).*?(?:→\s+(\S+))?\s*$/,Fe=/^md5:\s+([a-f0-9]{32})\s*$/;function se(e,t){for(let n=t;n<e.length&&!/^##\s/.test(e[n]);n++){if(e[n].trim()==="")continue;let r=Fe.exec(e[n]);return r?r[1]:null}return null}function D(e){let n=ve(e,"utf8").split(`
|
|
4
|
+
`),r="passed";if(n[0]?.trim()==="---")for(let s=1;s<n.length&&n[s].trim()!=="---";s++){let p=/^status:\s+(passed|failed|interrupted)\s*$/.exec(n[s]);p&&(r=p[1])}let o=[];for(let s=0;s<n.length;s++){let p=De.exec(n[s]);if(!p)continue;let a=p[1],i=p[2],c=p[3]??"",f=i.startsWith("\u2713")?"passed":i.startsWith("\u23ED")?"skipped":"failed";if(/via\s+@/.test(c)){let m=$e.exec(c),M=m?.[1]??"",x=m?.[2]??null;o.push({kind:"import",heading:a,status:f,md5:se(n,s+1),importPath:M,helperResultRelPath:x})}else o.push({kind:"objective",heading:a,status:f,md5:se(n,s+1)})}return{overallStatus:r,steps:o}}import{copyFileSync as ie,existsSync as H,mkdirSync as Oe,writeFileSync as oe,promises as ot}from"fs";import{join as $,dirname as ae,basename as _e}from"path";async function de(e){for(let t=0;t<e.totalRunDirs;t++){let n=e.runIndex+t,r=$(e.sessionDir,"runs",String(n)),o=$(e.stagingStepDir,"flows",String(t));Oe(o,{recursive:!0});let s=$(o,"actions.ndjson");if(e.packTestDir){let i=$(e.packTestDir,"logs",`${n}-actions.ndjson`);if(H(i)){ie(i,s);continue}let c=ae(ae(e.packTestDir)),f=_e(e.packTestDir),S=H(c)?await z(c,`tests/${f}/logs/${n}-actions.ndjson`).catch(()=>null):null;oe(s,S??"");continue}let p=[$(r,"run-test","actions.ndjson"),$(r,"actions.ndjson")],a=!1;for(let i of p)if(H(i)){ie(i,s),a=!0;break}a||oe(s,"")}}import{existsSync as le,readFileSync as ue,readdirSync as Ue}from"fs";import{join as F}from"path";function Ae(e){if(e.action_type!=="upload_files")return null;let t=e.action_params?.media;if(!t||typeof t!="object")return null;let n=typeof t.media_id=="string"?t.media_id:"",r=typeof t.name=="string"?t.name:"",o=typeof t.media_url=="string"?t.media_url:"";if(!n||!r||!o)return null;let s=typeof t.type=="string"&&t.type?t.type:"doc";return{media_id:n,name:r,media_url:o,type:s}}function Te(e){let t=e.action_params?.file_paths,n=Array.isArray(t)?t[0]:t;return typeof n=="string"&&n.length>0?n:null}function Ee(e){let t={};for(let[n,r]of Object.entries(e??{}))t[n]={...r,refs:[...r.refs??[]]};return t}function Le(e,t){if(!t)return!1;let n=t.endsWith("/")?t:t+"/";return e.startsWith(n)}function pe(e,t,n,r={}){let o=Ee(e);for(let s of t){let p=Ae(s);if(!p)continue;let a=o[p.media_id]??={name:p.name,media_url:p.media_url,type:p.type,refs:[],recorded_at:n};a.recorded_at=n;let i=Te(s);if(!(!i||Le(i,r.ignoreAliasUnder))){for(let[c,f]of Object.entries(o))c!==p.media_id&&(f.refs=f.refs.filter(S=>S!==i));a.refs.includes(i)||a.refs.push(i)}}return o}function lt(e){let t=e?.media;if(!t||typeof t!="object")return[];let n=[];for(let[r,o]of Object.entries(t)){if(!r||!o||typeof o!="object")continue;let s=o;typeof s.name!="string"||!s.name||typeof s.media_url!="string"||!s.media_url||n.push({media_id:r,name:s.name,media_url:s.media_url,type:typeof s.type=="string"&&s.type?s.type:"doc",refs:Array.isArray(s.refs)?s.refs.filter(p=>typeof p=="string"&&p.length>0):[]})}return n}function Ke(e){let t=[];for(let n of e){let r;try{r=ue(n,"utf8")}catch{continue}for(let o of r.split(`
|
|
5
|
+
`)){let s=o.trim();if(s)try{let p=JSON.parse(s);p&&typeof p=="object"&&t.push(p)}catch{}}}return t}function V(e){try{return Ue(e,{withFileTypes:!0}).filter(t=>t.isDirectory()).map(t=>t.name).sort((t,n)=>t.localeCompare(n,void 0,{numeric:!0}))}catch{return[]}}function ht(e){if(!e)return[];let t=[];for(let n of V(F(e,"runs")))for(let r of[F(e,"runs",n,"run-test","actions.ndjson"),F(e,"runs",n,"actions.ndjson")])if(le(r)){t.push(r);break}return t}function ce(e){let t=[],n=F(e,".internal","steps");for(let r of V(n)){let o=F(n,r,"flows");for(let s of V(o)){let p=F(o,s,"actions.ndjson");le(p)&&t.push(p)}}return t}function Ne(e){try{let n=JSON.parse(ue(e,"utf8"))?.media;return n&&typeof n=="object"?n:void 0}catch{return}}function fe(e){let t=Ne(e.priorMetaPath),n=Ke(e.recordFiles),r=pe(t,n,e.now??new Date().toISOString(),{ignoreAliasUnder:e.ignoreAliasUnder??q});return Object.keys(r).length>0?r:void 0}import{existsSync as L,readdirSync as Ce}from"fs";import{dirname as We,join as O,basename as B}from"path";function bt(e,t){let n=[];return e.steps.forEach((r,o)=>{let s=t[o];r.block||!r.replayOnly||!s||s.kind!=="author"||n.push({flatIndex:r.flatIndex,file:r.owningFile,heading:r.trace[r.trace.length-1].heading,kind:r.replayOnly,reason:s.reason})}),n}function Mt(e){let t=[],n=new Set,r=new Map;function o(i){if(r.has(i))return r.get(i);let c=v(i),f=L(c)?D(c):null;return r.set(i,f),f}let s=new Map;function p(i){if(s.has(i))return s.get(i);let c=O(i,"Result.md"),f=L(c)?D(c):null;return s.set(i,f),f}function a(i){for(let c=1;c<i.trace.length;c++){let f=i.trace[c-1],S=o(f.file);if(!S)continue;let m=S.steps[f.stepIndex-1];if(m){if(m.kind!=="import")return{kind:"author",reason:"structure-mismatch"};if(B(m.importPath)!==B(i.trace[c].file))return{kind:"author",reason:"structure-mismatch"};if(m.md5!=null&&m.md5!==f.rowMd5)return{kind:"author",reason:"structure-mismatch"}}}return null}for(let i of e.steps){let c=i.trace[i.trace.length-1].stepIndex,f=i.replayOnly;if(i.block){let g=o(i.owningFile)?.steps[c-1],j=i.controlFlow!==void 0,A=g?.kind==="objective"&&g.status==="skipped";if(j||A){t.push({kind:"replay",recordingDir:"",flowCount:0,unrecorded:!0,...f?{replayOnly:f}:{}});continue}}let S=n.has(i.owningFile);for(let g=0;g<i.trace.length-1&&!S;g++)n.has(i.trace[g].file)&&(S=!0);if(S&&!f){t.push({kind:"author",reason:o(i.owningFile)===null?"no-result-md":"downstream-of-divergence"});continue}let m=a(i);if(m){for(let g=0;g<i.trace.length;g++)n.add(i.trace[g].file);if(!f){t.push(m);continue}}let M=o(i.owningFile),x;if(M===null&&i.trace.length>1){let g=J(i.trace);x=me(i,p(g),c,g)}else x=me(i,M,c);if(f&&x.kind==="replay"&&(x={...x,replayOnly:f}),t.push(x),x.kind==="author"){n.add(i.owningFile);for(let g=0;g<i.trace.length-1;g++)n.add(i.trace[g].file)}}return t}function me(e,t,n,r=null){if(!t)return{kind:"author",reason:"no-result-md"};let o=t.steps[n-1];if(!o)return{kind:"author",reason:"no-result-md"};if(o.kind!=="objective")return{kind:"author",reason:"structure-mismatch"};if(o.status!=="passed")return{kind:"author",reason:"recorded-failed"};let s=E(e);if(s!==o.md5)return{kind:"author",reason:"md5-mismatch"};let p=r===null?ee(e.owningFile,n,s.slice(0,8)):O(r,".internal","steps",`${n}-${s.slice(0,8)}`),a=He(p);return a===0?{kind:"author",reason:"missing-recording"}:{kind:"replay",recordingDir:p,flowCount:a}}function He(e){let t=O(e,"flows");if(!L(t))return 0;let n;try{n=Ce(t,{withFileTypes:!0}).filter(o=>o.isDirectory()&&/^\d+$/.test(o.name)).map(o=>parseInt(o.name,10))}catch{return 0}if(n.length===0)return 0;let r=Math.max(...n);for(let o=0;o<=r;o++)if(!L(O(t,String(o),"actions.ndjson")))return 0;return r+1}function wt(e){return e.some(t=>t.kind==="author")}function vt(e){for(let t=0;t<e.length;t++)if(e[t].kind==="author")return t;return e.length}function J(e){let t=s=>{let p=B(s);return p.endsWith("_test.md")?p.slice(0,-8):p.endsWith(".md")?p.slice(0,-3):p},n=t(e[0].file),r=t(e[e.length-1].file),o=e.slice(0,-1).map(s=>String(s.stepIndex));return O(We(e[e.length-1].file),`helper-output-${r}-${n}-${o.join("-")}`)}function Pt(e){return Array.from({length:e.flowCount},(t,n)=>O(e.recordingDir,"flows",String(n),"actions.ndjson"))}import{existsSync as ge,mkdirSync as Ve,rmSync as Be,cpSync as Je}from"fs";function he(e,t){ge(e)&&(ge(t)&&Be(t,{recursive:!0,force:!0}),Ve(t,{recursive:!0}),Je(e,t,{recursive:!0}))}async function Ct(e){let t=new Map;for(let a of e.stepRunRecords)t.set(a.testmdStepIndex,a);let n=e.authoredFlatIdx??new Set,r=[],o=[],s=new Map,p=a=>{if(s.has(a))return s.get(a);let i=R(a,"Result.md"),c=P(i)?D(i):null;return s.set(a,c),c};for(let a of e.resolvedTest.unitFiles){let i=a.file===e.resolvedTest.rootPath,c=Q(a.file,Ge(a.file,"utf8")),f=v(a.file),S=P(f)?D(f):null,m=[],M=[],x=[],g=[];if(!i)for(let l of e.resolvedTest.steps){if(l.owningFile!==a.file||l.trace.length<2)continue;let d=J(l.trace);g.includes(d)||g.push(d)}let j=l=>{if(S!==null)return null;for(let d of g){let w=p(d)?.steps[l-1];if(w)return{row:w,dir:d}}return null},A=[],U=!1,G=!1,K=!1,N=!1;for(let l of c.steps){let d=l.index,u=S?.steps[d-1];if(l.body.kind==="objective"){let h=e.resolvedTest.steps.filter(y=>y.owningFile===a.file&&y.trace[y.trace.length-1].stepIndex===d&&t.has(y.flatIndex)),I=h.length>0?h[h.length-1]:null;if(I){U=!0,n.has(I.flatIndex)&&(G=!0);let y=E(I),k;i?k=e.outcomes.find(be=>be.rootStepIndex===d)??{rootStepIndex:d,status:"skipped"}:k={rootStepIndex:d,status:Ie(I,e.outcomes)},k.status==="failed"&&(K=!0),k.stepMd5==null&&(k.stepMd5=y),m.push(k),M.push({stepIndex:d,md5:y,rec:t.get(I.flatIndex)}),(!u||u.kind!=="objective"||u.status!==k.status||k.status==="passed"&&u.md5!==y)&&(N=!0)}else if(u&&u.kind==="objective")m.push({rootStepIndex:d,status:u.status,...u.md5?{stepMd5:u.md5}:{}}),x.push(d);else if(!i&&j(d)?.row.kind==="objective"){let y=j(d),k=y.row;m.push({rootStepIndex:d,status:k.status,...k.md5?{stepMd5:k.md5}:{}}),A.push({psIdx:d,dir:y.dir})}else i?m.push(e.outcomes.find(y=>y.rootStepIndex===d)??{rootStepIndex:d,status:"skipped"}):m.push({rootStepIndex:d,status:"skipped"});continue}let w=Xe(l.body.path)?l.body.path:Ze(Qe(a.file),l.body.path),T=te({path:l.body.path,bindings:l.body.bindings,optional:l.optional??!1}),C=Ye(X(a.file),v(w)),_=e.resolvedTest.steps.filter(h=>h.trace.some((I,y)=>y<h.trace.length-1&&I.file===a.file&&I.stepIndex===d)&&t.has(h.flatIndex));if(_.length>0){U=!0;let h;if(i)h=e.outcomes.find(I=>I.rootStepIndex===d)??{rootStepIndex:d,status:"passed",refKind:"import",refLabel:l.body.path};else{let I=_.some(y=>Ie(y,e.outcomes)==="failed");h={rootStepIndex:d,status:I?"failed":"passed",refKind:"import",refLabel:l.body.path,inlinedCount:_.length}}h.status==="failed"&&(K=!0),h.stepMd5==null&&(h.stepMd5=T),h.helperResultRelPath==null&&(h.helperResultRelPath=C),m.push(h),(!u||u.kind!=="import"||u.status!==h.status||u.md5!==T)&&(N=!0)}else if(u&&u.kind==="import")m.push({rootStepIndex:d,status:u.status,refKind:"import",refLabel:u.importPath,...u.md5?{stepMd5:u.md5}:{},...u.helperResultRelPath?{helperResultRelPath:u.helperResultRelPath}:{}});else if(!i&&j(d)?.row.kind==="import"){let h=j(d).row;m.push({rootStepIndex:d,status:h.status,refKind:"import",refLabel:l.body.path})}else i?m.push(e.outcomes.find(h=>h.rootStepIndex===d)??{rootStepIndex:d,status:"skipped",refKind:"import",refLabel:l.body.path}):m.push({rootStepIndex:d,status:"skipped",refKind:"import",refLabel:l.body.path})}if(!(i||U&&(G||K||S===null||N)))continue;r.push(a.file);let b=Y(a.file);Re(R(b,".internal"),{recursive:!0});for(let l of M){let d=R(b,".internal","steps",`${l.stepIndex}-${l.md5.slice(0,8)}`);Re(d,{recursive:!0}),await de({sessionDir:e.sessionDir,runIndex:l.rec.runIndex,totalRunDirs:l.rec.totalRunDirs,stagingStepDir:d,packTestDir:e.packTestDir})}if(x.length>0){let l=Z(a.file);if(P(l))for(let d of xe(l)){let u=parseInt(d.split("-")[0]??"",10);!Number.isNaN(u)&&x.includes(u)&&Se(R(l,d),R(b,".internal","steps",d),{recursive:!0})}}for(let l of A){let d=R(l.dir,".internal","steps");if(P(d))for(let u of xe(d))parseInt(u.split("-")[0]??"",10)===l.psIdx&&Se(R(d,u),R(b,".internal","steps",u),{recursive:!0})}let ke=m.some(l=>l.status==="failed");if(re({sourcePath:a.file,title:c.title,rootSteps:c.steps,outcomes:m,overallStatus:i?e.overallStatus:ke?"failed":"passed",startedISO:e.startedISO,durationS:i?e.durationS:0,sessionId:e.sessionId,outPath:R(b,"Result.md")}),i){let l={};e.commitId&&(l.commit_id=e.commitId),e.tmsIds.testId&&(l.test_id=e.tmsIds.testId),e.tmsIds.testcaseId&&(l.testcase_id=e.tmsIds.testcaseId),e.tmsIds.projectId&&(l.project_id=e.tmsIds.projectId),e.tmsIds.folderId&&(l.folder_id=e.tmsIds.folderId),e.tmsIds.orgId&&(l.org_id=e.tmsIds.orgId),e.tmsIds.sessionName&&(l.session_name=e.tmsIds.sessionName);let d=fe({priorMetaPath:W(a.file),recordFiles:ce(b)});d&&(l.media=d),ze(R(b,".internal","meta.json"),JSON.stringify(l,null,2)+`
|
|
6
|
+
`,"utf8");let u=R(e.sessionDir,"execution.json");if(P(u))try{ye(u,R(b,".internal","execution.json"))}catch{}if(e.codeExportDir){let w=e.codeExportLanguage??"python",T=e.codeExportFramework??"playwright",C=R(b,`${T}-${w}-code`);try{he(e.codeExportDir,C)}catch(_){process.stderr.write(`warn: codegen copy failed: ${_.message}
|
|
7
|
+
`)}}}else if(a.kind==="test"||a.kind==="module"){let l=W(a.file);if(P(l))try{ye(l,R(b,".internal","meta.json"))}catch{}}!i&&g.length>0&&m.every(d=>d.status!=="skipped")&&o.push({unitFile:a.file,dirs:g.filter(d=>P(d))})}return{changedUnitFiles:r,legacySweep:o}}function Wt(e){for(let t of e)try{qe(t,{recursive:!0,force:!0})}catch{}}function Ie(e,t){let n=e.trace[0].stepIndex,r=t.find(a=>a.rootStepIndex===n);if(!r)return"skipped";if(r.status==="passed")return"passed";if(r.status==="skipped")return"skipped";let o=e.trace.slice(1).map(a=>a.stepIndex),s=r.failedSubStepIndex??[],p=Math.min(o.length,s.length);for(let a=0;a<p;a++)if(o[a]!==s[a])return o[a]<s[a]?"passed":"skipped";return o.length===s.length?"failed":o.length<s.length?"passed":"skipped"}export{re as a,bt as b,Mt as c,wt as d,vt as e,Pt as f,lt as g,ht as h,fe as i,he as j,Ct as k,Wt as l};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as l}from"./chunk-DHJSM5DT.js";import{a as c}from"./chunk-NLCCBXXV.js";import{a}from"./chunk-RZ4F3BHX.js";var h=class{constructor(e,t,r,s){this.controllerBaseUrl=e;this.getOAuthToken=t;this.directBasicAuth=r;this.log=s}_cached=null;_revoked=!1;_lastError=null;revoke(){this._revoked=!0,this._cached=null}prime(e){this._revoked||(this._cached=e)}get revoked(){return this._revoked}get cached(){return this._cached}get lastError(){return this._lastError}async resolve(e=!1){if(this._cached&&!e)return this._cached;try{let t;if(this.directBasicAuth)t=new l(this.controllerBaseUrl,{username:this.directBasicAuth.username,accessKey:this.directBasicAuth.access_key});else{let s=await this.getOAuthToken();if(!s)return null;t=new l(this.controllerBaseUrl,s)}let r=await t.getTmsCredentials();this.directBasicAuth&&!r.access_key&&(r.access_key=this.directBasicAuth.access_key),this._cached=r,this._lastError=null;try{let[{refreshIdentitySnapshot:s},{telemetryEnvName:n}]=await Promise.all([import("./identity-ADZ4PAJF.js"),import("./bootstrap-
|
|
2
|
+
import{a as l}from"./chunk-DHJSM5DT.js";import{a as c}from"./chunk-NLCCBXXV.js";import{a}from"./chunk-RZ4F3BHX.js";var h=class{constructor(e,t,r,s){this.controllerBaseUrl=e;this.getOAuthToken=t;this.directBasicAuth=r;this.log=s}_cached=null;_revoked=!1;_lastError=null;revoke(){this._revoked=!0,this._cached=null}prime(e){this._revoked||(this._cached=e)}get revoked(){return this._revoked}get cached(){return this._cached}get lastError(){return this._lastError}async resolve(e=!1){if(this._cached&&!e)return this._cached;try{let t;if(this.directBasicAuth)t=new l(this.controllerBaseUrl,{username:this.directBasicAuth.username,accessKey:this.directBasicAuth.access_key});else{let s=await this.getOAuthToken();if(!s)return null;t=new l(this.controllerBaseUrl,s)}let r=await t.getTmsCredentials();this.directBasicAuth&&!r.access_key&&(r.access_key=this.directBasicAuth.access_key),this._cached=r,this._lastError=null;try{let[{refreshIdentitySnapshot:s},{telemetryEnvName:n}]=await Promise.all([import("./identity-ADZ4PAJF.js"),import("./bootstrap-KCPWDBLX.js")]);await s(n(),r)}catch{}return this.log?.("info","AUTH_RESOLVE_OK","Auth resolved",{username:r.username,org_id:r.org_id,user_id:r.user_id}),r}catch(t){return this._lastError=t instanceof Error?t:new Error(String(t)),this.log?.("warn","AUTH_RESOLVE_FAILED","Auth resolve failed",{error:this._lastError.message}),null}}async fetch(e,t={}){if(this._revoked)throw new Error("Resolver has been revoked \u2014 identity changed");let r=await this.resolve();if(!r)throw new Error("Not authenticated \u2014 no credentials resolved");let s=i=>({...t,headers:{...t.headers,Authorization:c(i.username,i.access_key)}}),n=await a(e,s(r));if(n.status===401){if(this._revoked)throw new Error("Resolver has been revoked \u2014 identity changed");this.log?.("warn","AUTH_RESOLVE_401","Got 401, re-resolving",{url:e});let i=await this.resolve(!0);if(!i)throw new Error("Re-authentication failed after 401");return a(e,s(i))}return n}};function _(o){if(!o)return"network";let e=/failed:\s*(\d{3})\b/.exec(o.message)?.[1];return e==="401"||e==="403"?"auth":e?"server":"network"}export{h as a,_ as b};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
2
|
function l(r){let{isAgent:m,log:d}=r,a=r.stdout??process.stderr,s=r.stdin??process.stdin,p=t=>{m&&process.stdout.write(JSON.stringify(t)+`
|
|
3
|
-
`)};return{async runSteps(t){let{default:e}=await import("./react-QWOAB3TB.js"),{render:o}=await import("./build-JIKYOZUH.js"),{TestMdRunView:i}=await import("./TestMdRunView-
|
|
3
|
+
`)};return{async runSteps(t){let{default:e}=await import("./react-QWOAB3TB.js"),{render:o}=await import("./build-JIKYOZUH.js"),{TestMdRunView:i}=await import("./TestMdRunView-2FQIEI5W.js"),{ScrollbackProvider:n}=await import("./scrollback-JLPJR25X.js"),{waitUntilExit:c}=o(e.createElement(n,null,e.createElement(i,t)),{stdout:a,stdin:s,exitOnCtrlC:!1});await c()},async runUpload(t,e){let{renderUploadProgress:o}=await import("./CliUploadProgress-OAQBY55Y.js");return await o(t,e)},async onSummary(t){try{let{default:e}=await import("./react-QWOAB3TB.js"),{render:o}=await import("./build-JIKYOZUH.js"),{AutoExitSummaryBox:i}=await import("./SummaryBox-2DTNE25L.js"),{waitUntilExit:n}=o(e.createElement(i,{data:t}),{stdout:a,stdin:s});await n()}catch(e){d("warn","TEST_MD_SUMMARY_RENDER_FAILED","Summary box render failed",{error:String(e)})}},async onLinks(t){try{let{default:e}=await import("./react-QWOAB3TB.js"),{render:o}=await import("./build-JIKYOZUH.js"),{LinksBox:i}=await import("./LinksBox-MNNNOH23.js"),{waitUntilExit:n}=o(e.createElement(i,t),{stdout:a,stdin:s});await n()}catch(e){d("warn","TEST_MD_LINKS_RENDER_FAILED","LinksBox render failed",{error:String(e)})}},onLockState(t){p({type:"test_md_lock_state",...t})},onAdaptiveHeal(t){p({type:"test_md_adaptive_heal",...t})},onAgentEvent(t){p(t)}}}export{l as a};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{d as w}from"./chunk-CAOZKSQ3.js";import{b,c as v}from"./chunk-VZ7KXRXB.js";import{b as $}from"./chunk-3N6IAVD5.js";import{b as E}from"./chunk-FQNQVC5O.js";var _=new Set(["delta","state-transition"]),N=/^capture baseline:/i;function R(e){return typeof e=="string"?e:e.text}function j(e){return typeof e=="object"&&e.baseline===!0||N.test(R(e).trim())}function T(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&"derived"in e}function M(e,i){if(e.check_prose)return e.check_prose;let t=i.find(o=>o.ref===e.check.verified_against),n=t?.text?` \u2014 the stated promise: ${t.text}`:"",s=String(e.check.operand??e.check.within??e.check.metric??"");return e.check.kind==="forbidden-presence"?`Confirm '${s}' does NOT appear (forbidden-presence)${n}`:`Confirm ${e.check.kind} check: ${s} (${e.check.operator})${n}`}var F=/^## Step \d+ — assert\s*$/;function ae(e,i){let t=e.split(`
|
|
3
|
+
`),n=!1;for(let s=0;s<t.length;s++){let o=/^(##\s.*?)\s@verifies\s+(.+?)\s*$/.exec(t[s]);if(!o)continue;n=!0;let c=o[2].split(",").map(a=>a.trim()).filter(Boolean).map(a=>{let r=i(a)??(a.startsWith("ac-")?a:null);if(!r)throw new Error(`@verifies ref '${a}' does not resolve to a committed AC`);return r});t[s]=`${o[1]} @verifies ${c.join(", ")}`}return{md:t.join(`
|
|
4
|
+
`),tagged:n}}function de(e,i){if(i.length!==0&&!e.split(`
|
|
5
|
+
`).some(t=>/^##\s/.test(t)&&w.test(t)))throw new Error("generated body has no @verifies binding for its ACs \u2014 the emitter contract is broken")}function ue(e){let i=e.split(`
|
|
6
|
+
`);if(i[0]?.trim()!=="---")return{};let t=i.slice(1).findIndex(n=>n.trim()==="---");if(t<0)return{};try{return b(i.slice(1,t+1).join(`
|
|
7
|
+
`))??{}}catch{return{}}}function le(e,i){if(i.length===0)return e;let t=e.split(`
|
|
8
|
+
`);for(let n=t.length-1;n>=0;n--){if(/^## Step \d+ — assert @verifies /.test(t[n]))return e;if(F.test(t[n]))return t[n]=`${t[n].trimEnd()} @verifies ${i.join(", ")}`,t.join(`
|
|
9
|
+
`)}return e}function fe(e,i){return i.size===0?e:e.split(`
|
|
10
|
+
`).map(t=>{let n=t.match(/^@import\s+(\S+)\s*$/);if(n&&i.has(n[1]))return`@import ${i.get(n[1])}`;let s=t.match(/^## Import: (\S+)\s*$/);return s&&i.has(s[1])?`## Import: ${i.get(s[1])}`:t}).join(`
|
|
11
|
+
`)}function I(e){let i=e.expected_mode??(T(e.operand)?"runtime-derived":"inferred");return{kind:e.kind,operator:e.operator,...e.operand!==void 0?{operand:e.operand}:{},..._.has(e.kind)?{baseline:e.baseline??null}:{},...e.within!==void 0?{within:e.within}:{},...e.metric!==void 0?{metric:e.metric}:{},...e.threshold!==void 0?{threshold:e.threshold}:{},...e.unit!==void 0?{unit:e.unit}:{},verified_against:e.verified_against,expected_mode:i,review_required:e.review_required??i==="runtime-derived"}}function pe(e,i,t){if(_.has(e.check.kind)&&!e.steps.some(j))throw new Error(`emitTestMd: check kind '${e.check.kind}' needs a baseline-capture step before the action (a step starting 'capture baseline: <metric>' or { baseline: true }) \u2014 the validator should have caught this`);let n=[];if(e.target){let r=d=>/^[A-Za-z0-9._/@-]+$/.test(d)?d:JSON.stringify(d);n.push("---",`target: ${e.target}`),e.app&&n.push(`app: ${r(e.app)}`),n.push("---","")}n.push(`# ${e.title}`,""),i.intent&&n.push(`> ${i.intent}`,"");for(let r of e.reuses??[])n.push(`## Import: ${r}`,"",`@import ${r}`,"");let s=[],o=e.steps.some(r=>typeof r=="object"&&(r.verifies?.length??0)>0),c=0;for(let r of e.steps){c++;let d=R(r).trim(),l=typeof r=="object"&&r.verifies?.length?` @verifies ${r.verifies.join(", ")}`:"";n.push(`## Step ${c}${l}`,"",d,""),s.push({step:c,objective:d,...j(r)?{baseline:!0}:{},...typeof r=="object"&&r.verifies?.length?{verifies:[...r.verifies]}:{}})}if(o){let r=-1;if(e.steps.forEach((d,l)=>{typeof d=="object"&&d.verifies?.includes(e.check.verified_against)&&(r=l)}),r<0)throw new Error(`emitTestMd: no tagged step claims check.verified_against (${String(e.check.verified_against)}) \u2014 the check would be dropped`);s[r].check=I(e.check)}else{c++;let r=M(e,t);n.push(`## Step ${c} \u2014 assert`,"",r,""),s.push({step:c,objective:r,check:I(e.check)})}let a=v({title:e.title,...i.title?{scenario:i.title}:{},objectives:s},{sortKeys:!0,lineWidth:-1});return{test_md:n.join(`
|
|
12
|
+
`),objectives_yaml:a}}function me(e){let t=e.replace(/\r\n/g,`
|
|
13
|
+
`).split(`
|
|
14
|
+
`).map(o=>o.replace(/[ \t]+$/,""));if(t[0]?.trim()==="---"){let o=t.slice(1).findIndex(c=>c.trim()==="---");if(o>=0){let c=b(t.slice(1,o+1).join(`
|
|
15
|
+
`))??{},a="assurance"in c;delete c.assurance,Object.keys(c).length===0&&a?t=t.slice(o+2):t=["---",...v(c,{sortKeys:!0,lineWidth:-1}).trimEnd().split(`
|
|
16
|
+
`),"---",...t.slice(o+2)]}}let n=[];for(let o of t)o===""&&n[n.length-1]===""||n.push(o);for(;n[0]==="";)n.shift();for(;n[n.length-1]==="";)n.pop();let s=n.join(`
|
|
17
|
+
`)+`
|
|
18
|
+
`;return"sha256:"+$(Buffer.from("assurance.testdef\0"+s,"utf8"))}import{existsSync as O,readFileSync as W}from"fs";import{dirname as z,isAbsolute as G,resolve as Q}from"path";var A=/^@import\s+(\S+)\s*$/;function U(e){let i=new Set;for(let t=0;t<e.length;t++)if(A.test(e[t].trim()))for(let n=t-1;n>=0;n--){let s=e[n].trim();if(s!==""){s==="```"&&i.add(t);break}}return i}function q(e,i,t=new Set,n=0){if(n>10)return e;let s=e.split(`
|
|
19
|
+
`),o=U(s);return s.map((c,a)=>{let r=A.exec(c.trim());if(!r||o.has(a))return c;let d=i(r[1]);if(!d||t.has(d.cycleKey))return c;let l=new Set(t);return l.add(d.cycleKey),q(d.body.trimEnd(),d.next,l,n+1)}).join(`
|
|
20
|
+
`)}function V(e){return i=>{let t=e.resolve(i);if(!t)return null;let n=e.getNode(t.tip)?.content.test_md_blob;return n?{body:n,cycleKey:t.tip,next:V(e)}:null}}function D(e,i){return t=>{let n=G(t)?t:Q(e,t);if(!O(n))return null;let s=W(n,"utf8"),o=P(s);return!o||!i.resolve(o)?null:{body:J(s),cycleKey:n,next:D(z(n),i)}}}function L(e,i){let t=-1;for(let u=1;u<i;u++)if(/^assurance\s*:\s*$/.test(e[u])){t=u;break}if(t<0)return null;let n=i;for(let u=t+1;u<i;u++)if(/^[^\s#]/.test(e[u])){n=u;break}let s,o=t,c,a,r,d,l,f=!1;for(let u=t+1;u<n;u++){let p=e[u].endsWith("\r")?e[u].slice(0,-1):e[u];if(p.trim()===""||/^\s*#/.test(p))continue;o=u;let x=/^(\s+)([^\s:#][^:]*):\s*(.*)$/.exec(p);if(!x){/^\s*["']?base["']?\s*:/.test(p)&&(f=!0);continue}let[,y,B,K]=x,m=B.trimEnd();s===void 0&&(s=y);let h=y===s,k=/^([^#\s]\S*)?\s*(#.*)?$/.exec(K.trim()),S=k?.[1];m==="id"&&h&&c===void 0&&(c=u,a=S),m==="base"&&(h&&r===void 0?(r=u,d=S,l=k?.[2]):h||(f=!0)),m!=="base"&&/^["']base["']$/.test(m)&&(f=!0)}return{start:t,lastChild:o,childIndent:s,idLine:c,id:a,baseLine:r,base:d,baseComment:l,strayBase:f}}function H(e){let i=C(e);if(!i)return null;let t=e.split(`
|
|
21
|
+
`),n=L(t,i.endLine);return n?.id?{id:n.id,...n.base!==void 0?{base:n.base}:{}}:null}function P(e){return H(e)?.id??null}function C(e){let i=e.split(`
|
|
22
|
+
`);if(i[0]?.trim()!=="---")return null;for(let t=1;t<i.length;t++)if(i[t].trim()==="---")return{text:i.slice(1,t).join(`
|
|
23
|
+
`),endLine:t};return null}function J(e){let i=C(e);if(!i)return e;let t=e.split(`
|
|
24
|
+
`),n=L(t,i.endLine),s=[],o=!1;for(let a=1;a<i.endLine;a++){let r=t[a];if(n&&a>=n.start&&a<=n.lastChild){o=!1;continue}if(/^assurance\s*:\s*\{/.test(r)){o=!0;continue}o&&/^\s+\S/.test(r)||(o=!1,s.push(r))}let c=t.slice(i.endLine+1).join(`
|
|
25
|
+
`);return s.every(a=>a.trim()==="")?c:["---",...s,"---",c].join(`
|
|
26
|
+
`)}import{appendFileSync as Z,readdirSync as X,readFileSync as Y,rmSync as ee,statSync as te}from"fs";import{join as g}from"path";import{randomBytes as ne}from"crypto";var ie="pending-facts.ndjson",re=/^pending-facts\.(\d+)-[0-9a-f]+\.ndjson$/,we=()=>`pending-facts.${process.pid}-${ne(4).toString("hex")}.ndjson`;function $e(e,i=1/0){let t=[];for(let n of X(e)){let s=re.exec(n);if(!s)continue;let o=Number(s[1]),c=Date.now()-te(g(e,n)).mtimeMs;if(o!==process.pid&&E(o)&&c<i){t.push(n);continue}let a=Y(g(e,n),"utf8").split(`
|
|
27
|
+
`).filter(r=>r!=="");a.length>0&&Z(g(e,ie),a.join(`
|
|
28
|
+
`)+`
|
|
29
|
+
`),ee(g(e,n))}return t}export{T as a,ae as b,de as c,ue as d,le as e,fe as f,pe as g,me as h,A as i,U as j,q as k,V as l,D as m,L as n,H as o,J as p,ie as q,re as r,we as s,$e as t};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{a as N,b as U,c as Y,d as L}from"./chunk-Q77QO3PC.js";import{l as R,m as D,o as P}from"./chunk-AHXOKBVE.js";import{g as A}from"./chunk-55YDTPB7.js";import{i as G}from"./chunk-YCH7H7JX.js";import{T as S,W as k,X as C}from"./chunk-UHSNUUX3.js";import{c as E}from"./chunk-H6TNBKGR.js";import{a as h}from"./chunk-CH273NAE.js";import{C as y}from"./chunk-GP7WD4UY.js";import{t as T}from"./chunk-3N6IAVD5.js";import{existsSync as H}from"fs";import{basename as Z}from"path";import{appendFileSync as W,mkdirSync as B}from"fs";import{homedir as X}from"os";import{dirname as K,join as V}from"path";function F(d,a){let t=/^(DOCX_[A-Z_]+):/.exec(a)?.[1];if(t)try{let u=process.env.KANE_CONTEXT_REFUSAL_LOG??V(X(),".testmuai","kaneai","context-refusals.log");B(K(u),{recursive:!0}),W(u,`${new Date().toISOString()} ${t} ${d}
|
|
3
|
+
`)}catch{}}function j(d){return d?.outcome==="added"?"added .context/ to .gitignore":d?.outcome==="failed"?`warning: could not add .context/ to .gitignore: ${d.reason}`:null}async function x(d,a,t,u=process.cwd(),f){let l=h(u),g=[];if(a.as!==void 0&&d.length>1)return(t.err??t.out)(`error: --as names ONE source identity \u2014 pass a single file (got ${d.length})`,"AS_SINGLE_SOURCE"),{code:2,results:g};for(let i of d){if(Y(i)){let e=L(i);if(e===null)return(t.err??t.out)(`error: ${i}: unsupported remote URL \u2014 supported: ${U.map(c=>c.hint).join("; ")}`,"UNSUPPORTED_URL"),{code:1,results:g};let o=await e.ingest(i,a.as,t,l,f);if(o.code!==0)return{code:o.code,results:g};if(o.result){let c=j(o.result.gitignore);c&&t.out(c),g.push({status:o.result.status==="versioned"?"versioned":o.result.status==="unchanged"?"unchanged":"created",source_id:o.result.source_id,source_cid:o.result.source_cid,...o.result.gitignore?{gitignore:o.result.gitignore}:{}})}continue}let m=a.as,p;if(m===void 0&&H(l)){let e=R(i),o=D(e);if(o){let c=y(l);c.heads.get(o)!=null&&c.heads.get(e)==null&&(p=o,t.isTTY&&await t.confirm(`${e} looks like a new version of existing source '${o}' \u2014 ingest as '${o}' (replaces the current version; items built on it go stale)?`)&&(m=o))}}let n;try{n=await P({contextDir:l,filePath:i,asId:m,confirmSameSource:t.isTTY?e=>t.confirm(`identical bytes already ingested as ${e} \u2014 treat as the same source?`):void 0,converters:{pdf:A,docx:G}})}catch(e){let o=e instanceof Error?e.message:String(e);return e instanceof T?((t.err??t.out)(`error: ${o}`,e.code),(t.err??t.out)(`next: ${e.remedy}`,e.code),{code:2,results:g}):(F(i,o),(t.err??t.out)(`error: ${i}: ${o}`,"INGEST_FAILED"),{code:1,results:g})}t.out(N(t.isTTY,n,Z(i)));for(let e of n.warnings??[])t.out(`warning: ${e}`);let _=j(n.gitignore);if(_&&t.out(_),n.composite&&(n.composite.delivered>0||n.composite.omitted>0)){let e=n.composite.pages!==void 0?` ${n.composite.pages} pages,`:"";t.out(`${n.source_id}: ${n.composite.kind},${e} ${n.composite.delivered} images delivered (${n.composite.omitted} omitted)`)}let v;if(!t.isTTY&&n.status==="created"){let e=y(l);for(let[o,c]of e.heads.entries())if(!(o===n.source_id||c==null)&&e.getNode(c)?.content.blob===n.blob){v=o,t.out(`hint: identical bytes already ingested as ${o} \u2014 merged later via review`);break}}g.push({status:n.status,source_id:n.source_id,source_cid:n.cid,...n.warnings?.length?{warnings:n.warnings}:{},...n.composite?{media:{kind:n.composite.kind,...n.composite.pages!==void 0?{pages:n.composite.pages}:{},delivered:n.composite.delivered,omitted:n.composite.omitted}}:{},...v?{duplicate_of:v}:{},...p&&m===void 0?{lineage_candidate:p}:{},...n.gitignore?{gitignore:n.gitignore}:{}})}return{code:0,results:g}}async function le(d,a,t,u=process.cwd(),f){return(await x(d,a,t,u,f)).code}async function fe(d,a){if(a.mode!=null&&!["interactive","agent","ci","override"].includes(a.mode)){let{makeHeadlessIO:r,agentRefusal:s}=await import("./headless-io-3A3BZVQ5.js");return s(r("ndjson","extract"),`ingest: --mode must be interactive | agent | ci | override, got '${a.mode}'`,"MODE_USAGE")}let t=E();if(a.mode==="interactive"&&!t)return process.stderr.write(`ingest: --mode interactive needs a TTY on stdin and stdout (use --mode agent|ci|override headless)
|
|
4
|
+
`),2;let u=a.mode??(t?"interactive":void 0),f=u==="interactive"||u==="agent"||u==="override";if(!f&&(a.plan||a.force||a.trust!==void 0))return process.stderr.write(`ingest: --plan/--force/--trust steer the extraction \u2014 not available when only landing (use --mode agent to extract headless)
|
|
5
|
+
`),2;let{createInterface:l}=await import("readline/promises"),g=u==="agent",i=g?(await import("./headless-io-3A3BZVQ5.js")).makeHeadlessIO("ndjson","extract"):null,m=H(h(process.cwd()))?k(h(process.cwd())):null;if(m)return i?(i.event(C(m)),i.done(2,"refused")):(process.stderr.write(`error: ${m.text}
|
|
6
|
+
next: ${m.remedy}
|
|
7
|
+
`),2);let p=[],n=()=>{for(let r of p.splice(0))i.event({type:"error",message:r.message,...r.code?{code:r.code}:{}})},_=r=>{for(let s of r)i.event({type:"ingested",source_id:s.source_id,status:s.status,cid:s.source_cid,...s.warnings?.length?{warnings:s.warnings}:{},...s.media?{media:s.media}:{},...s.duplicate_of?{duplicate_of:s.duplicate_of}:{},...s.lineage_candidate?{lineage_candidate:s.lineage_candidate}:{}})},v=r=>{for(let s of r)s.gitignore?.outcome==="added"?i.event({type:"gitignore_updated",path:".gitignore"}):s.gitignore?.outcome==="failed"&&i.event({type:"warning",message:`could not add .context/ to .gitignore: ${s.gitignore.reason}`})},e=i?{out:()=>{},err:(r,s)=>p.push({message:r.replace(/^error: /,""),...s?{code:s}:{}}),isTTY:!1,confirm:async()=>!1}:{out:r=>process.stdout.write(r+`
|
|
8
|
+
`),err:r=>process.stderr.write(r+`
|
|
9
|
+
`),isTTY:t,confirm:async r=>{let s=l({input:process.stdin,output:process.stdout});try{let O=await s.question(`${r} [Y/n] `);return!/^n(o)?$/i.test(O.trim())}finally{s.close()}}};if(!f){let{withTelemetry:r}=await import("./with-telemetry-3T53GIQC.js");return r("ingest",async()=>{await S(h(process.cwd()),I=>(e.err??e.out)(I));let{code:s,results:O}=await x(d,{as:a.as},e,void 0,void 0);if(s!==0)return s;let b=O.filter(I=>I.status!=="unchanged").length;return b>0&&(e.err??e.out)(`landed ${b} source(s) \u2014 run kane-cli context extract to extract them`),0},{write:!0})}let o;try{o=i?await(await import("./run-channel-RGH4WIQX.js")).runWithChannel({event:i.event},()=>x(d,{as:a.as},e,void 0,void 0)):await x(d,{as:a.as},e,void 0,void 0)}catch(r){if(i)return n(),i.event({type:"error",message:r instanceof Error?r.message:String(r),code:"INGEST_FAILED"}),i.done(1,"error");throw r}let{code:c,results:w}=o;if(i&&v(w),c!==0)return i?(_(w),n(),i.done(c,c===2?"refused":"error")):c;if(w.length===0)return i?i.done(0):0;let{extractCommand:q}=await import("./extract-cmd-KIEOBRIT.js"),M=[...new Set(w.map(r=>r.source_id))],$=await q({...a.mode!==void 0?{mode:a.mode}:{},...a.plan?{plan:!0}:{},...a.force?{force:!0}:{},...a.trust!==void 0?{trust:a.trust}:{},sources:M,landed:w});if($===2&&!g){let r=w.filter(s=>s.status!=="unchanged").length;r>0&&(e.err??e.out)(`note: the ${r} landed source(s) are safe \u2014 extract later with kane-cli context extract`)}return $}export{x as a,le as b,fe as c};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{A as r}from"./chunk-
|
|
2
|
+
import{A as r}from"./chunk-GP7WD4UY.js";function i(t){return r.test(t)?t.toUpperCase():t}export{i as a};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as c}from"./chunk-
|
|
2
|
+
import{a as c}from"./chunk-EPE2ELDH.js";import{a as n}from"./chunk-RZ4F3BHX.js";import{v as s,w as a}from"./chunk-HYTBEPC2.js";import{createHash as h,randomBytes as g}from"crypto";var l=class{authBaseUrl;consentUrl;constructor(t="prod"){let e=c(t);this.authBaseUrl=e.authBaseUrl,this.consentUrl=e.consentUrl}static generatePkce(){let t=g(96).toString("base64url").slice(0,128),e=h("sha256").update(t).digest("base64url");return[t,e]}buildAuthorizationUrl(t,e,r,o){let i=new URLSearchParams({response_type:"code",client_id:t,redirect_uri:o,scope:a,code_challenge:e,code_challenge_method:"S256",state:r});return`${this.consentUrl}/oauth2?${i.toString()}`}async registerClient(t){let e=await n(`${this.authBaseUrl}/oauth2/register`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_name:s,redirect_uris:[t],grant_types:["authorization_code"],response_types:["code"],client_type:"public",application_type:"native"})});if(!e.ok)throw new Error(`DCR failed: ${e.status} ${await e.text()}`);return e.json()}async exchangeCode(t,e,r,o){let i=await n(`${this.authBaseUrl}/oauth2/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({grant_type:"authorization_code",code:t,redirect_uri:o,client_id:e,code_verifier:r})});if(!i.ok)throw new Error(`Token exchange failed: ${i.status}`);return i.json()}async refreshToken(t,e){let r=await n(`${this.authBaseUrl}/oauth2/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({grant_type:"refresh_token",refresh_token:t,client_id:e})});if(!r.ok)throw new Error(`Token refresh failed: ${r.status}`);return r.json()}async revokeToken(t,e,r="access_token"){await n(`${this.authBaseUrl}/oauth2/revoke`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:t,token_type_hint:r,client_id:e})})}async validateToken(t){let e=new AbortController,r=setTimeout(()=>e.abort(),1e4);try{let o=await n(`${this.authBaseUrl}/api/user`,{headers:{Authorization:`Bearer ${t}`,Accept:"application/json","Content-Type":"application/json"},signal:e.signal});return clearTimeout(r),o.ok}catch{return clearTimeout(r),!1}}};export{l as a};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{a as J,c as ve}from"./chunk-BZAGVBCX.js";import{a as M,b as me}from"./chunk-52WM3XYO.js";import{a as Ee}from"./chunk-427OQS2N.js";import{d as he}from"./chunk-IE3OO5GI.js";import{B as ue,C as ge,F as fe,e as ae,f as le,h as pe,p as j}from"./chunk-GP7WD4UY.js";import{a as ce}from"./chunk-JQW2QFSX.js";import{H as re,M as oe,c as F,d as k,m as de}from"./chunk-3N6IAVD5.js";import{e as N,f as L,g as se,h as Y}from"./chunk-AKX4VRRR.js";var Se=new Set(["approve","edit","reject"]);function je(v){let{contextDir:E,graph:s,ops:z,by:f}=v,w=v.mintable??Ee(),U=re(E);if(s.latestHash!==U)return{record:null,errors:[{code:"STALE_BASIS",detail:`graph opened at ${String(s.latestHash)} but chain head is ${String(U)} \u2014 re-open and retry`}]};let V=[],b=[],Q=new Set;for(let e of z){if(s.appliedEvents.has(e.eventId)||Q.has(e.eventId)){V.push(e.eventId);continue}Q.add(e.eventId),b.push(e)}if(b.length===0)return{record:null,errors:null,applied:[],skipped:V,minted:[],staleDelta:[]};let d=[],B=[],y=[],C=[],$=[],G=[],D=[...v.judgements??[]],K=[],q=new Map,X=new Set,Z=[],_=new Set,ye=new Set(w),ee=new Set;for(let e of b){if(!Se.has(e.kind))continue;let i=e.target,t=s.resolve(i),n=t?s.tipOf(t.cid):i;ee.has(n)&&d.push({code:"MULTIPLE_TERMINAL_OPS",detail:`${i} has more than one terminal op in this turn \u2014 normalize latest-wins first`}),ee.add(n)}let I={targets:{},enhance:{},redirectTo:{},retract:{},conv:{}},T=(e,i)=>{let{target:t,expectedCid:n}=i,o=s.resolve(t);if(!o)return d.push({code:"UNKNOWN_NODE",detail:`${e}: ${t} names nothing in the graph`}),null;let r=s.tipOf(o.cid);return r!==n||s.superseded.has(n)?(d.push({code:"EXPECTED_CID_MOVED",detail:`${e}: ${t} moved or was archived since it was displayed`,data:{tip:r}}),null):(I.targets[i.eventId]=n,n)},P=e=>new Set(fe(s,s.tipOf(e))),O=[],R=new Set,te=e=>({code:"RETRACT_FORBIDDEN",detail:`retract ${e}: provenance edges cannot be retracted \u2014 DERIVES is historical evidence; reject or edit the node instead`});for(let e of b){if(e.kind!=="retract"){O.push(e);continue}let i=T("retract",e);if(!i)continue;let t=new Map;for(let r of P(i))for(let p of[...s.edgesFrom(r),...s.edgesInto(r)])t.set(p.ecid,p);let n,o={};if(e.edgeEcid!==void 0){if(s.superseded.has(e.edgeEcid)){d.push({code:"UNKNOWN_EDGE",detail:`retract ${e.target}: ${e.edgeEcid} is already retracted`});continue}if(n=t.get(e.edgeEcid),!n){d.push({code:"UNKNOWN_EDGE",detail:`retract ${e.target}: ${e.edgeEcid} is not a live edge touching ${e.target} (checked the full version chain)`});continue}}else if(e.edgeRef!==void 0){let r=e.edgeRef;if(r.type===N.DERIVES){d.push(te(e.target));continue}let p=(a,h)=>{let S=j(s,h);if(S)return S;let u=s.resolve(h)!==null;return d.push(u?{code:"TOMBSTONED_REF",detail:`retract ${e.target}: ${r.type} ${a} '${h}' is tombstoned (retired with no live successor) \u2014 pick a live node`}:{code:"UNKNOWN_REF",detail:`retract ${e.target}: ${r.type} ${a} got (unknown) for '${h}' \u2014 not a committed node (a node added in this same turn has no id yet: commit the add first)`}),null},l=p("dst",r.dst);if(!l)continue;o.dst=l.cid;let c=P(l.cid),m=null;if(r.src!==void 0){let a=p("src",r.src);if(!a)continue;o.src=a.cid,m=P(a.cid)}let g=[...t.values()].filter(a=>a.type===r.type&&c.has(a.dst)&&(m===null||m.has(a.src)));if(g.length===0){d.push({code:"UNKNOWN_EDGE",detail:`retract ${e.target}: no live ${r.type} edge onto ${r.dst}${r.src!==void 0?` from ${r.src}`:""} touches ${e.target} (checked the full version chain)`});continue}if(g.length>1){let a=g.map(h=>`${h.type} ${s.displayNameOf(h.src)??h.src} \u2192 ${s.displayNameOf(h.dst)??h.dst} (${h.ecid})`).join("; ");d.push({code:"AMBIGUOUS_RETRACT",detail:`retract ${e.target}: ${g.length} live ${r.type} edges match \u2014 ${a} \u2014 add src to disambiguate`});continue}n=g[0]}else{d.push({code:"INVALID_RETRACT",detail:`retract ${e.target}: neither edge_ecid nor edge {type, dst, src?} was given`});continue}if(n.type===N.DERIVES){d.push(te(e.target));continue}if(R.has(n.ecid)){d.push({code:"EDGE_RETRACTED",detail:`retract ${e.target}: ${n.ecid} was retracted earlier in this turn`});continue}R.add(n.ecid),I.retract[e.eventId]={ecid:n.ecid,...o},O.push({kind:"retract",target:e.target,expectedCid:e.expectedCid,edgeEcid:n.ecid,reason:e.reason,eventId:e.eventId})}let x=new Map;for(let e of O){if(e.kind!=="edit")continue;let i=s.resolve(e.target);if(!i||s.tipOf(i.cid)!==e.expectedCid||s.superseded.has(e.expectedCid))continue;let t=s.getNode(e.expectedCid);if(!t)continue;let n={...t.content};for(let[r,p]of Object.entries(e.edit))p!==void 0&&(n[r]=p);if(typeof n.title=="string"&&!n.title.trim()||L(t.label,n).length>0)continue;let o=F(t.label,n);o!==e.expectedCid&&x.set(e.expectedCid,o)}for(let e of O)if(e.kind==="approve"){let i=T("approve",e);i&&C.push({id:i,kind:"review-item",resolution:"approved",edit:null,reason:null,by:f})}else if(e.kind==="reject"){let i=T("reject",e);if(!i)continue;if(C.push({id:i,kind:"review-item",resolution:"rejected",edit:null,reason:e.reason,by:f}),e.redirectTo!==void 0){let t=s.resolve(e.redirectTo);if(!t||t.superseded){d.push({code:"UNKNOWN_NODE",detail:`reject.redirectTo: ${e.redirectTo} is not a live node`});continue}I.redirectTo[e.eventId]=t.cid,$.push({kind:"node",old:i,new:t.cid,reason:e.reason,by:f})}}else if(e.kind==="edit"){let i=T("edit",e);if(!i)continue;let t=s.getNode(i);if(!t){d.push({code:"UNKNOWN_NODE",detail:`edit: ${e.target} node file unreadable`});continue}let n={...t.content};for(let[l,c]of Object.entries(e.edit))c!==void 0&&(n[l]=c);if(typeof n.title=="string"&&!n.title.trim()){d.push({code:"EMPTY_TITLE",detail:`edit: ${e.target} edited title is empty`});continue}let o=L(t.label,n);if(o.length>0){for(let l of o)d.push({code:l.code,detail:`edit ${e.target}: ${l.detail}`});continue}let r=F(t.label,n);if(r===i){C.push({id:i,kind:"review-item",resolution:"approved",edit:null,reason:null,by:f});continue}if(ae(s,i,r)){d.push({code:"SUPERSEDE_CYCLE",detail:`edit ${e.target}: edit reproduces an already-superseded version (supersession cycle guard) \u2014 re-edit forward or redesign`});continue}let p=le({graph:s,oldTip:i,newCid:r,newLabel:t.label,by:f,reason:`re-blessed onto ${r} (edited in chat)`,skipEcids:R,dstRedirect:x});if(p.errors.length>0){for(let l of p.errors)d.push({code:"REBLESS_REFUSED",detail:`edit ${e.target}: ${l}`});continue}B.push({cid:r,label:t.label,content:n}),y.push(...p.edges),$.push({kind:"node",old:i,new:r,reason:e.reason??"edited in chat",by:f}),$.push(...p.supersessions),C.push({id:r,kind:"review-item",resolution:"edited",edit:{...e.edit},reason:null,by:f})}else if(e.kind==="enhance"){if(!T("enhance",e))continue;for(let t of e.edges){let n=j(s,t.src),o=j(s,t.dst);if(!n||!o){let[u,H]=n?["dst",t.dst]:["src",t.src],Re=s.resolve(H)!==null;d.push(Re?{code:"TOMBSTONED_REF",detail:`enhance ${e.target}: ${t.type} ${u} '${H}' is tombstoned (retired with no live successor) \u2014 pick a live node`}:{code:"UNKNOWN_REF",detail:`enhance ${e.target}: ${t.type} ${u} got (unknown) for '${H}' \u2014 not a committed node (a node added in this same turn has no id yet: commit the add first)`});continue}(I.enhance[e.eventId]??=[]).push({src:n.cid,dst:o.cid});let r=s.nodeLabel.get(n.cid)??"(unknown)",p=s.nodeLabel.get(o.cid)??"(unknown)";for(let u of Y(t.type,r,p,t.props))d.push({code:u.code,detail:`enhance ${e.target}: ${u.detail}`});let l=k(t.type,n.cid,o.cid,t.props),c=x.get(n.cid)??n.cid,m=x.get(o.cid)??o.cid,g=k(t.type,c,m,t.props);if(s.superseded.has(l)||R.has(l)||s.superseded.has(g)){let u=s.superseded.has(l)||R.has(l)?l:g;d.push({code:"EDGE_RETRACTED",detail:`enhance ${e.target}: this ${t.type} edge was retracted (${u}) \u2014 re-adding a retracted edge is refused (revival unsupported)`});continue}if(s.edgesFrom(n.cid).some(u=>u.ecid===l)||y.some(u=>u.ecid===g))continue;let a=pe(s,t.type,n.cid,o.cid,Z);a&&d.push(a);let h=ce(s,{type:t.type,src:n.cid,dst:o.cid},{pending:[],retracted:R},`enhance ${e.target}`);h&&d.push(h);let S=se(t.type)?.cardinality;if(S==="one-live-per-src"||S==="one-live-per-src-and-dst"){let u=`${t.type}|${n.cid}`;_.has(u)&&d.push({code:"CARDINALITY_VIOLATION",detail:`${t.type} from ${n.cid}: two one-live edges in one turn`}),_.add(u)}if(S==="one-live-per-src-and-dst"){let u=`${t.type}|dst|${o.cid}`;_.has(u)&&d.push({code:"CARDINALITY_VIOLATION",detail:`${t.type} onto ${o.cid}: two one-live edges in one turn (strict 1:1)`}),_.add(u)}y.push({ecid:g,type:t.type,src:c,dst:m,props:t.props}),Z.push({src:n.cid,dst:o.cid,type:t.type})}}else if(e.kind==="retract")$.push({kind:"edge",ecid:e.edgeEcid,reason:e.reason,by:f});else if(e.kind==="add"){if(!ye.has(e.label)){d.push({code:"GATED_LABEL",detail:`add: ${e.label} is not mintable in v1 (gate: ${w.join("|")})`,data:{gate:[...w]}});continue}let i=s.heads.get(e.convSourceId),t=s.convChains.get(e.convSourceId);if(typeof i!="string"||!t){d.push({code:"CONV_SOURCE_MISSING",detail:`add: ${e.convSourceId} is not a live conversation source`});continue}I.conv[e.eventId]=i;let n=s.getNode(i)?.content?.blob,o=typeof n=="string"?he(E,n)?.toString("utf8")??"":"",r=me(o,e.cite.turn);if(r===null){d.push({code:"BAD_ANCHOR",detail:`add: ${M(e.cite.turn)} does not resolve in ${e.convSourceId}`});continue}if(!r.includes(e.cite.quote)){d.push({code:"QUOTE_MISMATCH",detail:`add: quote is not verbatim within ${M(e.cite.turn)}`});continue}let p={...e.content,derived:!0},l=L(e.label,p);if(l.length>0){for(let a of l)d.push({code:a.code,detail:`add: ${a.detail}`});continue}let c=F(e.label,p),m={source_id:e.convSourceId,source_cid:i,anchor:M(e.cite.turn),quote:e.cite.quote};for(let a of Y(N.DERIVES,"source",e.label,m))d.push({code:a.code,detail:`add: ${a.detail}`});if(s.hasNode(c)){if(s.superseded.has(c)){d.push({code:"NODE_TOMBSTONED",detail:`add: ${s.nameOf.get(c)??c} already exists and was retired \u2014 restore it deliberately or add it under new content`});continue}y.push({ecid:k("DERIVES",i,c,m),type:N.DERIVES,src:i,dst:c,props:m}),e.rationale&&D.push({about:c,rationale:e.rationale,by:f}),q.set(e.eventId,c);continue}B.push({cid:c,label:e.label,content:p}),y.push({ecid:k("DERIVES",i,c,m),type:N.DERIVES,src:i,dst:c,props:m}),e.rationale&&D.push({about:c,rationale:e.rationale,by:f});let g=ue(e.label,a=>X.has(a),s.names.keys());g!==null&&(X.add(g),G.push({cid:c,slug:g,by:f})),K.push({cid:c,...g!==null?{slug:g}:{}}),q.set(e.eventId,c)}if(d.length)return{record:null,errors:d};let ne=new Date().toISOString();for(let e of O){if(e.kind==="add"){let i=q.get(e.eventId);i&&J(E,{ts:ne,command:"extract-chat",id:i,verdict:"add",polarity:"preference",tag:e.label,by:f,event_id:e.eventId,target:i});continue}for(let i of ve(e,{ts:ne,command:"extract-chat",by:f}))J(E,i)}let ie=b.map(e=>e.eventId).sort(),$e=oe(E,{ts:new Date().toISOString(),proposal_id:null,nodes:B,edges:y,review:C,supersessions:$,...G.length>0?{names:G}:{},...D.length>0?{judgements:D}:{},event_ids:ie,...v.sid?{sid:v.sid}:{},source_head_moves:{}},{expectPrev:U,intent:{v:1,verb:"chat",args:de({ops:z,judgements:v.judgements??null,by:f,mintable:[...w],sid:v.sid??null}),pins:I},provenance:v.provenance}),W=ge(E),A=new Set;for(let e of $)if(e.kind==="node"){A.add(e.old);for(let i of W.edgesInto(e.old))A.add(i.src)}for(let e of K)A.add(e.cid);let Ie=[...A].map(e=>({cid:e,state:W.stale(W.tipOf(e))})).filter(e=>e.state!=="fresh");return{record:$e.record,errors:null,applied:ie,skipped:V,minted:K,staleDelta:Ie}}export{je as a};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{M as a,X as p,m as c}from"./chunk-3N6IAVD5.js";function v(t,e,s){let{ref:r,reason:o,by:i}=s;if(!o||o.trim().length===0)return{record:null,errors:[{code:"REASON_REQUIRED",detail:"archiving a node needs a reason \u2014 it becomes the tombstone's provenance"}]};let d=e.resolve(r);if(!d)return{record:null,errors:[{code:"UNKNOWN_REF",detail:`no node '${r}' in the graph`}]};let n=e.tipOf(d.cid);if(e.superseded.has(n))return{record:null,errors:[{code:"ALREADY_ARCHIVED",detail:`${r} is already superseded at its tip (${n.slice(0,19)}\u2026)`}]};let l=a(t,{ts:new Date().toISOString(),proposal_id:null,nodes:[],edges:[],review:[],supersessions:[{kind:"node",old:n,new:null,reason:o,by:i}],source_head_moves:{}},{expectPrev:e.latestHash,intent:{v:1,verb:"archive",args:c({ref:r,reason:o,by:i}),pins:{ref:n}},provenance:s.provenance});return p(t),{record:l.record,errors:null}}export{v as a};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as R}from"./chunk-
|
|
2
|
+
import{a as R}from"./chunk-YKYKOV6U.js";import{y as i}from"./chunk-HYTBEPC2.js";import{a as Y}from"./chunk-HCBYKLMW.js";import{a,b as l,i as X}from"./chunk-C44QQJR4.js";import{a as K}from"./chunk-6YGTRKDT.js";import{e as P}from"./chunk-UR6MHSHU.js";var x=P(K(),1);var e=P(Y(),1),f=5;function Z(t,S){if(!S)return t;let c=S.toLowerCase();return t.filter(B=>B.label.toLowerCase().includes(c))}function Q(t){let{title:S,items:c,loading:B=!1,loadingText:p,error:L=null,itemNoun:v="items",onSelect:O,onCancel:E,defaultActiveId:w,onTab:y,extraHint:H}=t,[g,s]=(0,x.useState)(0),[h,u]=(0,x.useState)(0),[d,A]=(0,x.useState)(""),[C,I]=(0,x.useState)(null),N=!t.onSearch&&d!=="";(0,x.useEffect)(()=>{if(c.length===0||N)return;if(t.preserveSelectionById&&C!==null){let o=c.findIndex(n=>n.id===C);if(o>=0){u(Math.floor(o/f)),s(o%f);return}}let r=w?c.findIndex(o=>o.id===w):c.findIndex(o=>o.isActive);r>=0?(u(Math.floor(r/f)),s(r%f),t.preserveSelectionById&&I(c[r].id)):t.preserveSelectionById&&(u(0),s(0),I(c[0]?.id??null))},[c,w,t.preserveSelectionById,C,N]),(0,x.useEffect)(()=>{if(!t.onSearch)return;let r=setTimeout(()=>t.onSearch(d),t.searchDebounceMs??250);return()=>clearTimeout(r)},[d,t.onSearch,t.searchDebounceMs]);let b=t.onSearch?c:Z(c,d),D=h*f,F=Math.min(D+f,b.length),M=Math.ceil(b.length/f),$=F-D,T=b.slice(D,F);return X((r,o)=>{if(L){o.escape&&E();return}if(o.escape){d?(A(""),s(0),u(0)):E();return}if(o.tab&&y){y();return}if(o.upArrow){if(g>0){let n=g-1;s(n),t.preserveSelectionById&&I(T[n]?.id??null)}else if(h>0){let n=h-1,m=f-1;u(n),s(m),t.preserveSelectionById&&I(b[n*f+m]?.id??null)}return}if(o.downArrow){if(g<$-1){let n=g+1;s(n),t.preserveSelectionById&&I(T[n]?.id??null)}else if(h<M-1){let n=h+1,m=0;u(n),s(m),t.preserveSelectionById&&I(b[n*f+m]?.id??null)}return}if(o.return&&T[g]){if(T[g].disabled)return;O(T[g]);return}if(o.backspace||o.delete){A(n=>n.slice(0,-1)),s(0),u(0);return}r&&!o.ctrl&&!o.meta&&(A(n=>n+r),s(0),u(0))},{isActive:!B}),B?(0,e.jsxs)(a,{flexDirection:"column",borderStyle:"round",borderColor:i.orange,paddingX:2,paddingY:1,children:[(0,e.jsx)(l,{color:i.orange,bold:!0,children:S}),(0,e.jsx)(a,{marginTop:1,children:(0,e.jsx)(l,{color:i.secondary,children:p??`Loading ${v}\u2026`})})]}):L?(0,e.jsxs)(a,{flexDirection:"column",borderStyle:"round",borderColor:i.red,paddingX:2,paddingY:1,children:[(0,e.jsx)(l,{color:i.red,bold:!0,children:S}),(0,e.jsx)(a,{marginTop:1,children:(0,e.jsx)(l,{color:i.red,children:L})}),(0,e.jsx)(R,{bindings:[]})]}):(0,e.jsxs)(a,{flexDirection:"column",borderStyle:"round",borderColor:i.orange,paddingX:2,paddingY:1,children:[(0,e.jsxs)(a,{children:[(0,e.jsx)(l,{color:i.orange,bold:!0,children:S}),(0,e.jsxs)(l,{color:i.dim,children:[" (",b.length,!t.onSearch&&d?`/${c.length}`:""," ",v,t.loadingMore?" \xB7 loading more":"",")"]})]}),(0,e.jsxs)(a,{marginTop:1,children:[(0,e.jsx)(l,{color:i.secondary,children:d?"filter: ":""}),d?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(l,{children:d}),(0,e.jsx)(l,{inverse:!0,children:" "})]}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)(l,{color:i.dim,children:["Search ",v,"\u2026"]}),(0,e.jsx)(l,{inverse:!0,children:" "})]})]}),(0,e.jsx)(a,{flexDirection:"column",marginTop:1,children:t.searching?(0,e.jsxs)(l,{color:i.secondary,children:["Searching ",v,"\u2026"]}):b.length===0?(0,e.jsxs)(l,{color:i.dim,children:["No ",v,' match "',d,'"']}):T.map((r,o)=>{let n=o===g,m=n?"\u276F ":" ",G=r.disabled?i.muted:r.isActive?i.green:n?i.orange:void 0;return(0,e.jsxs)(a,{flexDirection:"column",children:[(0,e.jsxs)(l,{color:G,children:[m,r.label,r.isActive&&!r.disabled?" \u25CF selected":""]}),n&&r.disabled&&r.disabledHint&&(0,e.jsxs)(l,{color:i.red,children:[" ",r.disabledHint]})]},r.id)})}),!t.searching&&M>1&&(0,e.jsx)(a,{marginTop:1,children:(0,e.jsxs)(l,{color:i.dim,children:["Page ",h+1,"/",M]})}),t.footer&&(0,e.jsx)(a,{marginTop:1,flexDirection:"column",children:t.footer}),(0,e.jsx)(R,{bindings:[{keys:"\u2191\u2193",label:"navigate"},{keys:"type",label:"to search"},{keys:"\u21B5",label:"select"},...y&&H?[{keys:"tab",label:H}]:[]],escBackLabel:d?"clear":"back to chat"})]})}export{Q as a};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{b as Me}from"./chunk-YZVR7ESF.js";import{c as Ft}from"./chunk-H6TNBKGR.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-SWTJMTBY.js";import{a as At,b as Pe,c as Ct,d as Tt}from"./chunk-IE3OO5GI.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{x as qt}from"./chunk-GP7WD4UY.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-3N6IAVD5.js";import{b as ne,c as bt,h as yt}from"./chunk-FQNQVC5O.js";import{a as ee}from"./chunk-AKX4VRRR.js";import{s as at,t as ct}from"./chunk-RSSOJ3L2.js";import{y as O}from"./chunk-HYTBEPC2.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-UFSCTIQQ.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};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{b as N}from"./chunk-L2TV4G56.js";import{b as y,c as E,d as $,f as O,g as A,h as V,i as I,j as T}from"./chunk-
|
|
2
|
+
import{b as N}from"./chunk-L2TV4G56.js";import{b as y,c as E,d as $,f as O,g as A,h as V,i as I,j as T}from"./chunk-CRZUBDJ3.js";import{d as x}from"./chunk-5LJRZI7S.js";import{H as P,p as C}from"./chunk-3N6IAVD5.js";var G={extract:e=>`kane-cli context extract --resume ${e}`,design:e=>`kane-cli design tests --resume ${e}`};function Q(e,n,s){if(e===void 0||e===n)return null;if(e==="extract"||e==="design"){let a=G[e](s);return{code:"WRONG_VERB",message:`error: session ${s} is a ${e} session \u2014 resume it with ${a}`,next:[{cmd:a,why:`this session belongs to a ${e} run`}]}}return{code:"WRONG_VERB",message:`error: session ${s} belongs to a ${e} run \u2014 this command cannot resume it`,next:[]}}import{existsSync as K}from"fs";import{join as M}from"path";function ne(e){return{id:e.id,text:e.question,risk:["high","med","low"].includes(e.risk)?e.risk:"med",rationale:e.rationale,options:e.options.map(n=>({label:n.label,detail:n.description??""})),recommended_index:e.recommendedOptionIndex,allow_free_text:e.allowFreeText,kind:e.kind,consequence:e.consequence,evidence_count:e.evidence_count,multi_select:e.multiSelect}}function B(e){return{id:e.id,header:e.kind??"question",question:e.text,kind:e.kind??"clarify",multiSelect:e.multi_select??!1,options:e.options.map((n,s)=>({id:`o${s}`,label:n.label,description:n.detail||void 0})),recommendedOptionIndex:e.recommended_index,risk:e.risk,rationale:e.rationale,consequence:e.consequence??"",evidence_count:e.evidence_count,allowFreeText:e.allow_free_text}}function se(e,n){e.save({agent_state:n.agent_state,pending:{questions:n.pending.questions.map(B),proposals:n.pending.proposals??[]},assumed:n.assumed.map(s=>({questionId:s.question_id,optionId:s.option_id,flagged:!0,eventId:`assumed:${n.sid}:${s.question_id}`}))}),e.release(),$(e.state.sid)}function te(e){return{persist(n){let s=e.seqBase(),a={seq:n.seq+s,turn_id:n.turn_id,at:n.at,agent_state_schema:n.agent_state_schema,delta_items:n.delta_items,binding:n.binding,usage_total:n.usage_total,...n.base_fingerprint!==void 0?{base_fingerprint:n.base_fingerprint}:{}},l={applied_events:[...new Set([...e.handle.state.applied_events,...V(e.contextDir,e.handle.state.sid)])].sort(),held_receipts:e.peekHeldReceipts?.()??[],pending:{questions:n.at!=="turn"?(n.pending_questions??[]).map(B):[],proposals:e.stagedProposals?.()??[]},parent_asks:[],read_basis:e.readBasis(),corpus_cursor:e.corpusCursor(),store_watermark:P(e.contextDir),...(()=>{let o=e.ingestRegistry?e.ingestRegistry():e.handle.state.ingest_registry??[],p=e.ingestSchedule?e.ingestSchedule():e.handle.state.ingest_schedule??[];return{...o.length?{ingest_registry:o}:{},...p.length?{ingest_schedule:p}:{}}})()};return O(e.contextDir,e.handle,a,l,{...e.onSoftCap?{onSoftCap:e.onSoftCap}:{},...e.onStat?{onStat:e.onStat}:{},...e.now?{now:e.now}:{}})}}}var m=class extends Error{constructor(s,a,l=[]){super(`${s}: ${a}`);this.code=s;this.next=l}};async function ie(e,n,s,a={}){let l=a.deps??{},o=x(e,n);try{let p=o.state.checkpoint??null,w=K(M(e,"sessions",n,y,E)),j=!p&&o.state.agent_state.items.length>0;if(!p&&!w||j)throw new m("SESSION_V1",`session ${n} predates durable checkpoints \u2014 this build cannot resume it; abandon it with kane-cli context sessions clean ${n} and start a fresh run (committed work is untouched)`,[{cmd:`kane-cli context sessions clean ${n}`,why:"abandon the pre-checkpoint session, then start a fresh run"}]);!p&&w&&l.onWarn?.(`session ${n}: checkpoint chain present with no pointer \u2014 recovering from the chain`);let c=A(e,n);c.orphans.length>0&&T(e,n,c.orphans),c.fallback&&l.onWarn?.(`session ${n}: chain truncated to checkpoint ${c.fallback.resumableAt} \u2014 ${c.fallback.turnsLost} turn(s) lost to a corrupt record`);let r=c.base;if(a.verb){let i=Q(r.verb,a.verb,n);if(i)throw new m("WRONG_VERB",i.message,i.next)}if(a.useCase!==void 0&&a.useCase!==r.use_case&&!await(l.confirmRetarget?.(r.use_case,a.useCase)??!1))throw new m("RESUME_RETARGET_DECLINED",r.use_case?`session ${n} was designing ${r.use_case}; resuming onto ${a.useCase} needs an explicit retarget`:`session ${n} has no recorded use-case; adopting ${a.useCase} needs an explicit retarget`,r.use_case?[{cmd:`kane-cli design tests --resume ${n}`,why:`continue on ${r.use_case} (the session's own subject)`}]:[]);let d=c.kane,f=[],H=d?.read_basis??Object.fromEntries(Object.entries(o.state.read_basis));for(let[i,t]of Object.entries(H)){let u=s.heads.get(i)??null;u!==t&&f.push({subject:i,pinned:t,live:u})}r.uc_tip!==void 0&&l.liveUcTip!==void 0&&l.liveUcTip!==r.uc_tip&&f.push({subject:r.use_case??"use-case",pinned:r.uc_tip,live:l.liveUcTip}),l.locks?.reacquire?.(n);let _={...r.run_config,checkpoints:!0};delete _.resume;let R;if(c.pointer===null||c.agent===null)R=_;else{if(!c.agent.base_fingerprint)throw new m("CHECKPOINT_PROTOCOL",`session ${n}: chain carries no base fingerprint \u2014 cannot attest the seed rebuild`);R={..._,resume:{schema:2,binding:c.agent.binding,base_fingerprint:c.agent.base_fingerprint,delta_items:c.agent.delta_items,last_seq:c.pointer.seq}}}let S=d?.pending.questions??[],b=i=>{let t=`resolveq:${n}:${i}`,u=`assumed:${n}:${i}`;return s.appliedEvents.has(t)||s.appliedEvents.has(u)||o.isApplied(t)||o.isApplied(u)},W=d&&S.length>0?S.filter(i=>!b(i.id)):o.state.pending.questions.filter(i=>!b(i.id)),v={redeliverReceipts:[],recommit:[]},h,k;if(d){let i={...d,applied_events:[...new Set([...d.applied_events,...o.state.applied_events])].sort()},t;try{t=I(e,n,i,s,{verb:r.verb==="design"?"design":"extract",...r.use_case?{ucRef:r.use_case}:{},composeReceipt:(g,q,D)=>N(g,q,D),onNote:l.onWarn})}catch(g){throw g instanceof C?new m("CHECKPOINT_PROTOCOL",`store reconciliation refused: ${g.message}`,[{cmd:`kane-cli context sessions clean ${n}`,why:"abandon the session if the store was rebuilt"}]):g}v={redeliverReceipts:t.redeliverReceipts,recommit:t.recommit},k=t.prunedPending;let u=d.pending.proposals??[];h=(u.length>0?u:o.state.pending.proposals).filter(g=>!(typeof g.event_id=="string"&&s.appliedEvents.has(g.event_id))),(t.newlyApplied.length>0||t.prunedPending.length>0)&&o.reconcileSave({appliedEvents:t.newlyApplied,heldReceipts:[...o.state.held_receipts??[],...t.redeliverReceipts],pending:{questions:o.state.pending.questions,proposals:h}})}else{let i=o.state.pending.proposals;k=i.filter(t=>typeof t.event_id=="string"&&s.appliedEvents.has(t.event_id)),h=i.filter(t=>!(typeof t.event_id=="string"&&s.appliedEvents.has(t.event_id)))}return{kind:"v2",handle:o,base:r,view:c,kane:d,spawnConfig:R,drift:f,reconcile:v,questions:W,represent:h,prunedPending:k}}catch(p){throw o.release(),p}}export{Q as a,ne as b,se as c,te as d,m as e,ie as f};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{b as B}from"./chunk-S3DAAAE5.js";import{a as g}from"./chunk-
|
|
2
|
+
import{b as B}from"./chunk-S3DAAAE5.js";import{a as g}from"./chunk-YGMUNNKH.js";import{y as s}from"./chunk-HYTBEPC2.js";import{a as w}from"./chunk-HCBYKLMW.js";import{a as x,b as t,c as h,i as P,j as S}from"./chunk-C44QQJR4.js";import{a as C}from"./chunk-6YGTRKDT.js";import{e as T}from"./chunk-UR6MHSHU.js";var o=T(C(),1);var e=T(w(),1);function D({defaultName:i,onSubmit:c}){let[d,p]=(0,o.useState)("confirm"),[f,a]=(0,o.useState)(""),[m,u]=(0,o.useState)(null),l=(0,o.useMemo)(()=>f.trim()||i,[f,i]);return P((n,r)=>{if(d==="confirm"){if(n==="y"||n==="Y"){a(i),p("name");return}if(n==="n"||n==="N"||r.escape||r.ctrl&&n==="c"){c(null);return}if(r.return){c(i);return}return}if(r.return){if(!B(l)){u(`name "${l}" is invalid; allowed: letters, digits, underscore, hyphen`);return}c(l);return}if(r.escape||r.ctrl&&n==="c"){c(null);return}if(r.backspace||r.delete){a(v=>v.slice(0,-1)),u(null);return}n&&!r.ctrl&&!r.meta&&(a(v=>v+n),u(null))}),d==="confirm"?(0,e.jsx)(g,{title:"Save session?",titleColor:"#ff9500",rows:[{label:"name",value:(0,e.jsx)(t,{color:s.orange,children:i})}],footer:(0,e.jsxs)(x,{flexDirection:"column",children:[(0,e.jsx)(t,{color:s.dim,children:"enter \u2014 save with this name"}),(0,e.jsx)(t,{color:s.dim,children:"Y \u2014 edit name"}),(0,e.jsx)(t,{color:s.dim,children:"N/esc \u2014 discard session"})]})}):(0,e.jsx)(g,{title:"Save session?",titleColor:"#ff9500",rows:[{label:"name",value:(0,e.jsxs)(x,{children:[(0,e.jsx)(t,{color:s.orange,children:f}),(0,e.jsx)(t,{inverse:!0,children:" "})]})}],footer:(0,e.jsxs)(x,{flexDirection:"column",children:[m&&(0,e.jsx)(t,{color:s.red,children:m}),(0,e.jsx)(t,{color:s.dim,children:"enter \u2014 save \xB7 esc \u2014 discard"})]})})}function V(){return new Date().toISOString().slice(0,19).replace(/:/g,"-")}async function Y(i){return new Promise(c=>{function d(){let{exit:a}=S(),[m,u]=(0,o.useState)(!1);return(0,o.useEffect)(()=>{if(m){let l=setTimeout(()=>a(),50);return()=>clearTimeout(l)}},[m,a]),(0,e.jsx)(D,{defaultName:i,onSubmit:l=>{c(l),u(!0)}})}let{waitUntilExit:p,unmount:f}=h((0,e.jsx)(d,{}),{stdout:process.stderr,exitOnCtrlC:!1});p().then(()=>{try{f()}catch{}})})}export{D as a,V as b,Y as c};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{a as ee,d as te,h as D,i as ne,j as re,k as U,l as ie,m as se,n as oe,o as R,p as ae,q as H,r as he,s as ge,t as _e}from"./chunk-SWTJMTBY.js";import{a as me}from"./chunk-CH273NAE.js";import{d as V}from"./chunk-CAOZKSQ3.js";import{C as $,e as pe,f as fe}from"./chunk-GP7WD4UY.js";import{H as M,M as T,P as le,X as O,c as de,m as L,u as ue,x as I,z as P}from"./chunk-3N6IAVD5.js";import{d as x,f as ce}from"./chunk-AKX4VRRR.js";import{appendFileSync as Ie,closeSync as Oe,existsSync as S,fsyncSync as Ce,openSync as Ne,readdirSync as je,readFileSync as k,renameSync as Fe,writeFileSync as J}from"fs";import{dirname as Q,isAbsolute as G,join as F,resolve as q}from"path";var Re=new Set(["inline","testmd","testrun"]),Le=new Set(["inferred","authored","runtime-derived"]),B=new Set(["passed","failed","broken","skipped"]);function ye(t,e,n){if(n.facts.length===0)return{record:null,errors:[{code:"EMPTY_EXECUTIONS",detail:"a run with no designed units attaches no facts \u2014 skip the call"}]};let o=e;for(let a=0;;a++){let c=M(t);if(o.latestHash!==c){if(a>=3)return{record:null,errors:[{code:"STALE_BASIS",detail:`graph opened at ${String(o.latestHash)} but chain head is ${String(c)} \u2014 retry budget exhausted`}]};o=$(t);continue}let d=Te(t,o,n);if(d!=="cas")return d;if(a>=3)return{record:null,errors:[{code:"STALE_BASIS",detail:"concurrent appends kept moving the head \u2014 retry budget exhausted"}]};o=$(t)}}function ve(t,e){return Re.has(t.mode)?B.has(t.verdict)?Le.has(t.oracle_mode)?typeof t.drift_flag!="boolean"||typeof t.stale_at_run!="boolean"?[{code:"MISSING_FIELD",detail:`${e}: drift_flag and stale_at_run are required booleans`}]:!t.execution_id||!t.started_at||!t.definition_id_at_run?[{code:"MISSING_FIELD",detail:`${e}: execution_id, started_at and definition_id_at_run are required`}]:[]:[{code:"BAD_ORACLE_MODE",detail:`${e}: oracle_mode '${t.oracle_mode}' not in inferred|authored|runtime-derived`}]:[{code:"BAD_VERDICT",detail:`${e}: verdict '${t.verdict}' not in ${[...B].join("|")}`}]:[{code:"BAD_MODE",detail:`${e}: mode '${t.mode}' not in inline|testmd|testrun`}]}function be(t,e,n,o){return{about:e,definition_id_at_run:t.definition_id_at_run,verdict:t.verdict,...n&&n.length?{per_ac:n}:{},drift_flag:t.drift_flag,oracle_mode:t.oracle_mode,stale_at_run:t.stale_at_run,...o.length?{unresolved_acs:o}:{},execution_id:t.execution_id,...t.evidence_id?{evidence_id:t.evidence_id}:{},...t.duration_ms!==void 0?{duration_ms:t.duration_ms}:{},started_at:t.started_at,mode:t.mode,local:t.local,...t.via_parent?{via_parent:t.via_parent}:{}}}function Ee(t,e,n={}){if(!Array.isArray(e.facts)||e.facts.length===0)return{record:null,errors:[{code:"EMPTY_EXECUTIONS",detail:"parked line carries no facts"}]};for(let o=0;;o++){let a=$(t),c=e.facts.filter(s=>a.appliedEvents.has(s.event_id)).map(s=>s.event_id),d=e.facts.filter(s=>!a.appliedEvents.has(s.event_id));if(d.length===0)return{record:null,errors:null,applied:[],skipped:c,rejected:[]};let l=[],i=[],g=[],m=[];for(let s of d){let r=`executions[${s.ref}]`,u=[];if(!s.about_cid||!a.hasNode(s.about_cid))u.push({code:"UNKNOWN_REF",detail:`${r}: about_cid '${String(s.about_cid)}' is not in the graph \u2014 the pinned run-time target is gone`});else if(a.nodeLabel.get(s.about_cid)!==x.TEST)u.push({code:"ILLEGAL_TARGET",detail:`${r}: execution facts attach to tests \u2014 '${s.about_cid}' is a ${a.nodeLabel.get(s.about_cid)}`});else if(!s.event_id)u.push({code:"MISSING_FIELD",detail:`${r}: parked facts require event_id`});else{u.push(...ve(s,r));for(let h of s.per_ac??[])B.has(h.verdict)||u.push({code:"BAD_VERDICT",detail:`${r}.per_ac['${h.ac_ref}']: verdict '${h.verdict}'`})}if(u.length>0){l.push({event_id:s.event_id??"",errors:u});continue}let p=[],f=[],_=[...s.unresolved_acs??[]];for(let h of s.per_ac??[]){let b=h.ac_cid&&a.hasNode(h.ac_cid)&&a.nodeLabel.get(h.ac_cid)===x.AC?h.ac_cid:null,y=b?null:a.resolve(h.ac_ref),E=b??(y?a.tipOf(y.cid):null);if(!E||!b&&(a.superseded.has(E)||a.nodeLabel.get(E)!==x.AC)){_.push(h.ac_ref);continue}p.push({ac_ref:a.nameOf.get(E)??h.ac_ref,ac_cid:E,verdict:h.verdict}),f.push(E)}i.push(be(s,s.about_cid,p,_)),m.push({about_cid:s.about_cid,per_ac:f}),g.push(s.event_id)}if(i.length===0)return{record:null,errors:null,applied:[],skipped:c,rejected:l};try{let s=T(t,{ts:new Date().toISOString(),proposal_id:null,nodes:[],edges:[],review:[],supersessions:[],executions:i,event_ids:[...g].sort(),source_head_moves:{}},{expectPrev:a.latestHash,intent:{v:1,verb:"parked",args:L({line:e}),pins:{facts:m}},busyRetry:{deadlineMs:5e3},provenance:n.provenance}),r;try{O(t)}catch(u){r=`parked facts committed, but the projection refresh failed (${u instanceof Error?u.message:String(u)}) \u2014 read state rebuilds on the next open`}return{record:s.record,errors:null,applied:g,skipped:c,rejected:l,...r?{warnings:[r]}:{}}}catch(s){if(!(s instanceof I))throw s;if(o>=3)return{record:null,errors:[{code:"STALE_BASIS",detail:"concurrent appends kept moving the head \u2014 parked replay retry budget exhausted (line stays queued)"}]}}}}function Te(t,e,n){let o=[],a=[],c=[];for(let i of n.facts){let g=`executions[${i.ref}]`,m=n.pinned?null:e.resolve(i.ref),s=n.pinned?i.about_cid&&e.hasNode(i.about_cid)?i.about_cid:null:m?e.tipOf(m.cid):null;if(!s||!n.pinned&&e.superseded.has(s)){o.push({code:"UNKNOWN_REF",detail:`${g}: '${n.pinned?String(i.about_cid):i.ref}' is not a ${n.pinned?"":"live "}committed node`});continue}if(e.nodeLabel.get(s)!==x.TEST){o.push({code:"ILLEGAL_TARGET",detail:`${g}: execution facts attach to tests \u2014 '${i.ref}' is a ${e.nodeLabel.get(s)}`});continue}let r=ve(i,g);if(r.length>0){o.push(...r);continue}let u=[],p=[];for(let f of i.per_ac??[]){let _=n.pinned?null:e.resolve(f.ac_ref),h=n.pinned?f.ac_cid&&e.hasNode(f.ac_cid)?f.ac_cid:null:_?e.tipOf(_.cid):null;if(!h||!n.pinned&&e.superseded.has(h)||e.nodeLabel.get(h)!==x.AC){o.push({code:"UNKNOWN_REF",detail:`${g}.per_ac: '${n.pinned?String(f.ac_cid):f.ac_ref}' is not a${n.pinned?"n":" live"} AC`});continue}if(!B.has(f.verdict)){o.push({code:"BAD_VERDICT",detail:`${g}.per_ac['${f.ac_ref}']: verdict '${f.verdict}'`});continue}u.push({ac_ref:e.nameOf.get(h)??h,ac_cid:h,verdict:f.verdict}),p.push(h)}a.push(be(i,s,u,i.unresolved_acs??[])),c.push({about_cid:s,per_ac:p})}if(o.length>0)return{record:null,errors:o};let d;try{d=T(t,{ts:new Date().toISOString(),proposal_id:null,nodes:[],edges:[],review:[],supersessions:[],executions:a,...n.eventIds&&n.eventIds.length>0?{event_ids:n.eventIds}:{},source_head_moves:{}},{expectPrev:e.latestHash,intent:{v:1,verb:"execution",args:L({facts:n.facts,by:n.by,eventIds:n.eventIds??null}),pins:{facts:c}},busyRetry:{deadlineMs:n.lockDeadlineMs??5e3},provenance:n.provenance})}catch(i){if(i instanceof I)return"cas";throw i}let l;try{O(t)}catch(i){l=`facts committed, but the projection refresh failed (${i instanceof Error?i.message:String(i)}) \u2014 read state rebuilds on the next open`}return{record:d.record,errors:null,...l?{warnings:[l]}:{}}}function pt(t){let e={failed:3,broken:2,skipped:1,passed:0},n=new Map;for(let o of t)for(let a of o.verifies??[]){let c=n.get(a);(c===void 0||(e[o.status]??0)>(e[c]??0))&&n.set(a,o.status)}return[...n.entries()].map(([o,a])=>({ref:o,verdict:a}))}function ft(t){let e=[],n=me(t.cwd);if(!S(n))return{synced:0,superseded:0,skipped:"no-context",warnings:e};let o=t.by??{kind:"ai",id:"exec-sync"},a=t.lockDeadlineMs;try{Pe(n,e,a)}catch(r){e.push(`sync: parked-facts replay failed (${r instanceof Error?r.message:String(r)}) \u2014 queue intact, retrying next sync`)}let c=$(n),d=[],l=0,i=new Set,g=new Set(t.members.map(r=>G(r.path)?r.path:q(t.cwd,r.path))),m=new Map;for(let r of t.members){let u=G(r.path)?r.path:q(t.cwd,r.path);if(!S(u)){e.push(`sync: member file missing: ${u} \u2014 skipped, no fact attached`);continue}for(let p of Me(u,e))if(!i.has(p.path))try{let f=p.path===u,_=!f&&g.has(p.path),h=f?void 0:R(k(u,"utf8"))?.id,b=k(p.path,"utf8"),y=R(b);if(!y?.id){i.add(p.path);continue}let E=c.resolve(y.id),w=E?c.tipOf(E.cid):null;if(!E||!w||c.superseded.has(w)){i.add(p.path),e.push(`sync: ${y.id} does not resolve to a live test \u2014 skipped (foreign store?)`);continue}let C=D(U(b,se(Q(p.path),c))),Ae=String(c.getNode(w)?.content.test_md_blob??""),N=D(U(Ae,ie(c))),A=!1,j=w;if(C===N)y.base!==N&&xe(p.path,b,N,e);else if(y.base===N){let v=Ge(n,c,w,b,C,Q(p.path),o);v.error?(e.push(`sync: could not supersede ${y.id}: ${v.error}`),A=!0):(l++,j=v.newCid,A=v.oracleTier,xe(p.path,k(p.path,"utf8"),C,e),c=$(n))}else A=!0,e.push(y.base?`sync: ${y.id} was edited from an older version \u2014 graph kept; reconcile via a redesign or maintain`:`sync: ${y.id} carries no base pin (hand-copied file?) \u2014 fact attached with drift flag`);if(_){A&&m.set(p.path,!0);continue}i.add(p.path);let K=c.getNode(j)?.content.check,z=f?r.acs??[]:[],X=z.filter(v=>Se(c,v.ref)),Y=z.filter(v=>!Se(c,v.ref)).map(v=>v.ref);d.push({ref:y.id,about_cid:j,definition_id_at_run:C,verdict:r.verdict,...X.length?{per_ac:X.map(v=>{let Z=we(c,v.ref);return{ac_ref:v.ref,...Z?{ac_cid:Z}:{},verdict:v.verdict}})}:{},drift_flag:A||m.get(p.path)===!0||f&&r.driftFlag===!0,oracle_mode:K?.expected_mode??(ee(K?.operand)?"runtime-derived":"inferred"),stale_at_run:c.stale(j)!=="fresh",...Y.length?{unresolved_acs:Y}:{},execution_id:r.executionId,...r.evidenceId?{evidence_id:r.evidenceId}:{},...r.durationMs!==void 0?{duration_ms:r.durationMs}:{},started_at:r.startedAt,mode:r.mode,local:r.local,...h?{via_parent:h}:{}})}catch(f){p.path!==u&&g.has(p.path)||i.add(p.path),e.push(`sync: ${p.path} failed to sync (${f instanceof Error?f.message:String(f)}) \u2014 skipped; other members unaffected`)}}if(d.length===0)return{synced:0,superseded:l,warnings:e};let s;try{s=ye(n,$(n),{facts:d,by:o,eventIds:d.map(r=>`exec-fact:${r.execution_id}:${r.ref}`),lockDeadlineMs:a})}catch(r){return e.push(`sync facts: commit threw: ${r instanceof Error?r.message:String(r)}`),$e(n,d,o,e,a),{synced:0,superseded:l,warnings:e}}return s.errors?($e(n,d,o,e,a),e.push(...s.errors.map(r=>`sync facts: ${r.code}: ${r.detail}`)),{synced:0,superseded:l,warnings:e}):(s.warnings&&e.push(...s.warnings.map(r=>`sync facts: ${r}`)),{synced:d.length,superseded:l,warnings:e})}var W=".pending-facts.bad";function $e(t,e,n,o,a){try{let c={by:n,ts:new Date().toISOString(),facts:e.map(i=>({...i,about_cid:i.about_cid??"",event_id:`exec-fact:${i.execution_id}:${i.ref}`}))},d=null;try{d=P(t,{deadlineMs:a??5e3})}catch{d=null}let l=F(t,H);try{if(d)Ie(l,JSON.stringify(c)+`
|
|
3
|
+
`);else{l=F(t,ge());let i=Ne(l,"wx");try{J(i,JSON.stringify(c)+`
|
|
4
|
+
`),Ce(i)}finally{Oe(i)}le(t),o.push(`sync facts: store lock busy \u2014 parked to ${l}; it drains on the next sync`)}}finally{d?.()}o.push(`sync facts: commit failed \u2014 ${e.length} fact(s) parked to ${l}; they replay on the next sync`)}catch(c){o.push(`sync facts: could not park the failed batch (${c instanceof Error?c.message:String(c)}) \u2014 this run's facts are LOST`)}}function Pe(t,e,n){let o=F(t,H);if(!S(o)&&!je(t).some(m=>he.test(m)))return;let a=ue(t);if(a){e.push(`sync: parked facts stay queued while rebase ${a.id} is open \u2014 they drain on the first sync after it is finished`);return}let c;{let m=P(t,{deadlineMs:n??5e3});try{_e(t),c=S(o)?k(o,"utf8"):""}finally{m()}}let d=c.split(`
|
|
5
|
+
`).filter(m=>m.trim()!=="");if(d.length===0)return;let l=new Set,i=[],g=[];for(let m of d){let s=null;try{let u=JSON.parse(m);u&&Array.isArray(u.facts)&&(s=u)}catch{}if(!s){i.push(m),l.add(m);continue}let r=Ee(t,s);if(r.errors){if(r.errors.some(u=>u.code==="STALE_BASIS")){e.push(`sync: parked facts replay deferred (${r.errors[0].detail}) \u2014 retrying next sync`);continue}i.push(m),l.add(m),e.push(`sync: parked facts line quarantined to ${F(t,W)} (${r.errors.map(u=>`${u.code}: ${u.detail}`).join("; ")})`);continue}for(let u of r.rejected){let p=s.facts.find(f=>f.event_id===u.event_id);g.push({parent:m,line:JSON.stringify({...p??{event_id:u.event_id},_reason:u.errors})})}r.rejected.length>0&&e.push(`sync: ${r.rejected.length} parked fact(s) quarantined to ${F(t,W)} (${r.rejected.map(u=>u.errors.map(p=>`${p.code}: ${p.detail}`).join("; ")).join(" | ")})`),l.add(m),r.warnings&&e.push(...r.warnings.map(u=>`sync: ${u}`)),r.applied.length>0&&e.push(`sync: replayed ${r.applied.length} parked fact(s) from a previous run`)}if(l.size!==0)try{let m=P(t,{deadlineMs:n??5e3});try{let r=(S(o)?k(o,"utf8"):"").split(`
|
|
6
|
+
`).filter(_=>_.trim()!==""),u=[...i.filter(_=>r.includes(_)),...g.filter(_=>r.includes(_.parent)).map(_=>_.line)];u.length>0&&Ie(F(t,W),u.map(_=>_+`
|
|
7
|
+
`).join(""));let p=r.filter(_=>!l.has(_)),f=`${o}.tmp.${process.pid}`;J(f,p.length>0?p.join(`
|
|
8
|
+
`)+`
|
|
9
|
+
`:""),Fe(f,o)}finally{m()}}catch(m){e.push(`sync: queue rewrite failed (${m instanceof Error?m.message:String(m)}) \u2014 already-applied lines dedupe next sync; bad lines re-quarantine then`)}}function Me(t,e){let n=[],o=new Set,a=c=>{if(o.has(c)||!S(c))return;o.add(c);let d;try{d=k(c,"utf8")}catch(l){e.push(`sync: unreadable unit ${c} (${l instanceof Error?l.message:String(l)}) \u2014 skipped`);return}for(let l of d.split(`
|
|
10
|
+
`)){let i=/^@import\s+(\S+)\s*$/.exec(l.trim());if(!i)continue;let g=G(i[1])?i[1]:q(Q(c),i[1]);if(!S(g))continue;let m;try{m=k(g,"utf8")}catch(s){e.push(`sync: unreadable import ${g} (${s instanceof Error?s.message:String(s)}) \u2014 skipped; importer continues`);continue}R(m)?.id&&a(g)}n.push({path:c})};return a(t),n}function Se(t,e){return we(t,e)!==null}function we(t,e){let n=t.resolve(e),o=n?t.tipOf(n.cid):null;return n&&o&&!t.superseded.has(o)&&t.nodeLabel.get(o)==="ac"?o:null}function Be(t,e,n,o){let a=t.split(`
|
|
11
|
+
`),c=re(a),d={};return{blob:a.map((i,g)=>{let m=ne.exec(i.trim());if(!m||c.has(g))return i;let s=m[1];if(o&&s in o){let _=n.tipOf(o[s]);d[s]=_;let h=n.displayNameOf(_);return h?`@import ${h}`:i}let r=n.resolve(s);if(r)return d[s]=r.tip,i;let u=G(s)?s:q(e,s);if(!S(u))return i;let p=R(k(u,"utf8"))?.id,f=p?n.resolve(p):null;return!p||!f?i:(d[s]=f.tip,`@import ${p}`)}).join(`
|
|
12
|
+
`),imports:d}}function Ge(t,e,n,o,a,c,d,l={}){let i=e.getNode(n);if(!i)return{oracleTier:!1,error:"tip unreadable"};let{blob:g,imports:m}=Be(ae(o),c,e,l.imports),s=String(i.content.test_md_blob??""),r=/^#\s+(.+?)\s*$/m.exec(g)?.[1]??String(i.content.title??""),u={...i.content,test_md_blob:g,definitionId:a,title:r};{let y=qe(g);y.target!==void 0?u.target=y.target:delete u.target,y.app!==void 0?u.app=y.app:delete u.app}let p=ce("test",u);if(p.length>0)return{oracleTier:!1,error:p.map(y=>y.detail).join("; ")};let f=de("test",u);if(f===n)return{newCid:n,oracleTier:!1};let _=ke(s)!==ke(g);if(pe(e,n,f))return{oracleTier:_,error:"file content reproduces an already-superseded version (supersession cycle guard) \u2014 graph kept; re-edit forward or redesign"};let h=fe({graph:e,oldTip:n,newCid:f,newLabel:"test",by:d,reason:`re-blessed onto ${f} (edited on disk, run sync)`});if(h.errors.length>0)return{oracleTier:_,error:`edge re-bless refused: ${h.errors.join("; ")}`};let b=M(t);if(e.latestHash!==b){if(l.throwTransient)throw new I(`store advanced under the sync (basis ${String(e.latestHash)} vs head ${String(b)})`);return{oracleTier:_,error:`store advanced under the sync (basis ${String(e.latestHash)} vs head ${String(b)}) \u2014 re-run to retry`}}try{T(t,{ts:new Date().toISOString(),proposal_id:null,nodes:[{cid:f,label:"test",content:u}],edges:h.edges,review:[{id:f,kind:"review-item",resolution:"edited",edit:null,reason:"edited on disk (run sync)",by:d}],supersessions:[{kind:"node",old:n,new:f,reason:"edited on disk (run sync)",by:d},...h.supersessions],source_head_moves:{}},{expectPrev:b,intent:{v:1,verb:"exec-supersede",args:L({tip:n,raw:o,fileId:a,by:d}),pins:{tip:n,imports:m}},provenance:l.provenance})}catch(y){if(l.throwTransient&&y instanceof I)throw y;return{oracleTier:_,error:y instanceof Error?y.message:String(y)}}return O(t),{newCid:f,oracleTier:_}}function qe(t){let e=te(t);return{...typeof e.target=="string"?{target:e.target}:{},...typeof e.app=="string"?{app:e.app}:{}}}function ke(t){let e=[],n=t.split(`
|
|
13
|
+
`),o=n.some(c=>/^##\s/.test(c)&&V.test(c)),a=!1;for(let c of n){if(/^##\s/.test(c)){let d=V.exec(c);a=o?d!==null:/\bassert\b/i.test(c),d&&e.push(`v:${d[1].trim()}`);continue}a&&c.trim()!==""&&e.push(c.trim())}return e.join(`
|
|
14
|
+
`)}var Ve=0;function xe(t,e,n,o){try{let a=e.split(`
|
|
15
|
+
`),c=-1;if(a[0]?.trim()==="---"){for(let i=1;i<a.length;i++)if(a[i].trim()==="---"){c=i;break}}if(c<0)return;let d=oe(a,c);if(!d)return;if(d.baseLine!==void 0){let i=a[d.baseLine].endsWith("\r")?"\r":"";a[d.baseLine]=`${d.childIndent}base: ${n}${d.baseComment?` ${d.baseComment}`:""}${i}`}else if(d.strayBase){o.push(`sync: ${t} has a base: line this scanner cannot confidently rewrite (unexpected indentation or key quoting) \u2014 pin refresh skipped (stale pin until the shape is fixed)`);return}else{let g=a[d.idLine??d.start].endsWith("\r")?"\r":"";a.splice((d.idLine??d.start)+1,0,`${d.childIndent??" "}base: ${n}${g}`)}let l=`${t}.tmp-sync.${process.pid}-${Ve++}`;J(l,a.join(`
|
|
16
|
+
`)),Fe(l,t)}catch(a){o.push(`sync: pin refresh failed for ${t} (${a instanceof Error?a.message:String(a)}) \u2014 next run self-heals`)}}export{ye as a,Ee as b,pt as c,ft as d,Ge as e};
|