@testmuai/kane-cli 0.8.20 → 0.8.21
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-757LHEYF.js → ChatSurface-U3Y3WUMS.js} +1 -1
- package/dist/{ChromeProfilePicker-UAMRJG2H.js → ChromeProfilePicker-E6I6K2HO.js} +1 -1
- package/dist/{CliFeedbackPrompt-NAPKBEOP.js → CliFeedbackPrompt-MPQVZM6J.js} +1 -1
- package/dist/{CliUploadProgress-R6FHYXP5.js → CliUploadProgress-CADDDCS6.js} +1 -1
- package/dist/{ConfigView-CKYIRJBS.js → ConfigView-IFXESQBB.js} +1 -1
- package/dist/EvidenceViewOffer-GW7XLM45.js +2 -0
- package/dist/FolderPicker-XILMCQE5.js +2 -0
- package/dist/{InfoBox-WKFPWFII.js → InfoBox-CQWRYU6P.js} +1 -1
- package/dist/{LinksBox-MQOD3X3E.js → LinksBox-ZFXUQZ2D.js} +1 -1
- package/dist/{ProfilesView-PLO2SBGI.js → ProfilesView-OBN423WX.js} +1 -1
- package/dist/{ProjectPicker-QT2IENIZ.js → ProjectPicker-FG3VJ22U.js} +1 -1
- package/dist/{SaveSessionPrompt-BRNUVO5J.js → SaveSessionPrompt-SNFSJUGW.js} +1 -1
- package/dist/SingleShotApp-BTBHN35J.js +2 -0
- package/dist/{SummaryBox-7OBZAVJU.js → SummaryBox-V7XVROAD.js} +1 -1
- package/dist/TestMdRunView-NQMTHTK6.js +2 -0
- package/dist/{TestrunEvidenceTable-PKFPTUZX.js → TestrunEvidenceTable-R3UQQI67.js} +1 -1
- package/dist/{WhoamiView-CINKGNTV.js → WhoamiView-IGIALZNC.js} +1 -1
- package/dist/agent-parse-2MLJOJTH.js +2 -0
- package/dist/{app-download-KLCWIQWJ.js → app-download-VXEW7EI7.js} +1 -1
- package/dist/{auth-L7PFZJBY.js → auth-CSYBNMIH.js} +1 -1
- package/dist/{binary-25KA3XAX.js → binary-QLRLXZ6K.js} +1 -1
- package/dist/{bind-N5QZUUUU.js → bind-URA64IPV.js} +9 -9
- package/dist/{bootstrap-545GY5CC.js → bootstrap-PYBM5YT2.js} +1 -1
- package/dist/bridge-Z5PPK6CD.js +2 -0
- package/dist/{changelog-ABQ5HREB.js → changelog-FMT3SSEI.js} +1 -1
- package/dist/chunk-2KVECC36.js +2 -0
- package/dist/{chunk-Q5PQ7U3W.js → chunk-2R55Y3X4.js} +1 -1
- package/dist/chunk-45GRUU6A.js +27 -0
- package/dist/{chunk-CXXTQ4C5.js → chunk-47MLKCMG.js} +1 -1
- package/dist/{chunk-R6RK32R2.js → chunk-4HPJ4S6H.js} +1 -1
- package/dist/{chunk-ARCYAF37.js → chunk-4XYPIPYO.js} +1 -1
- package/dist/chunk-5LLXVZXW.js +7 -0
- package/dist/chunk-5UY2JMFC.js +8 -0
- package/dist/chunk-5ZFOKYFB.js +5 -0
- package/dist/{chunk-K4D5BB63.js → chunk-6WOGVXQV.js} +1 -1
- package/dist/{chunk-IHVIIRW5.js → chunk-6ZHEIBI5.js} +2 -2
- package/dist/{chunk-PN4EL4JN.js → chunk-7EVSM4V7.js} +1 -1
- package/dist/{chunk-EPVK2NMQ.js → chunk-ASJPV3O7.js} +1 -1
- package/dist/chunk-BL5QHONU.js +2 -0
- package/dist/{chunk-SHXJQ73O.js → chunk-C3366X5X.js} +1 -1
- package/dist/{chunk-DCLMFWCF.js → chunk-CP2TVGKB.js} +1 -1
- package/dist/{chunk-5WZ2WOOM.js → chunk-DGQKGGCB.js} +1 -1
- package/dist/{chunk-UVR7MESH.js → chunk-DRVZE2XJ.js} +1 -1
- package/dist/{chunk-7BKOTLIL.js → chunk-ETFRGYOT.js} +13 -11
- package/dist/{chunk-ZXP2TJEJ.js → chunk-EXSFOB4X.js} +4 -4
- package/dist/{chunk-AXJ47YFH.js → chunk-EZKC2LFH.js} +1 -1
- package/dist/{chunk-RTD27WRG.js → chunk-F3BN7Z3Z.js} +1 -1
- package/dist/chunk-FGRDGMJP.js +9 -0
- package/dist/{chunk-FYW7USQY.js → chunk-FHH7AFSC.js} +1 -1
- package/dist/{chunk-LPVAOUAC.js → chunk-FLGQXY65.js} +1 -1
- package/dist/{chunk-BNWU7JOW.js → chunk-FPGSEOG6.js} +1 -1
- package/dist/{chunk-X77AR3IL.js → chunk-FQVK46L7.js} +1 -1
- package/dist/{chunk-K3EN7O5N.js → chunk-FRSS6LMZ.js} +17 -17
- package/dist/{chunk-Y67FYNLP.js → chunk-FY7WTTDQ.js} +1 -1
- package/dist/{chunk-NFQ67CQO.js → chunk-GGOOD6KP.js} +3 -3
- package/dist/{chunk-SBSANJ2T.js → chunk-H2VMZL7J.js} +2 -2
- package/dist/{chunk-YL5J3SNK.js → chunk-HJBTALBX.js} +1 -1
- package/dist/{chunk-CVXVFF2G.js → chunk-HX2HTIOQ.js} +1 -1
- package/dist/{chunk-YV6CSSWA.js → chunk-ICPCU7AL.js} +1 -1
- package/dist/{chunk-G5Q4EJAT.js → chunk-IDQYOWKL.js} +1 -1
- package/dist/{chunk-4L45IQNU.js → chunk-IXJ33HYF.js} +1 -1
- package/dist/{chunk-R54VY272.js → chunk-J4Z34AZN.js} +5 -5
- package/dist/{chunk-56UYK35Z.js → chunk-JD3OZ5H7.js} +1 -1
- package/dist/{chunk-UUT7EHLT.js → chunk-JH5RLIAH.js} +1 -1
- package/dist/chunk-JVQI3EVW.js +2 -0
- package/dist/{chunk-E6MW25UV.js → chunk-JW7M3ENB.js} +1 -1
- package/dist/{chunk-JKQX7DUC.js → chunk-K7WJFQJU.js} +1 -1
- package/dist/{chunk-PY4BWRR6.js → chunk-KMMOJDN4.js} +1 -1
- package/dist/{chunk-FNJJGQUI.js → chunk-KXGZLYUF.js} +1 -1
- package/dist/chunk-LDPLJFCV.js +2 -0
- package/dist/{chunk-OGWYTILK.js → chunk-LEWESZ24.js} +4 -4
- package/dist/chunk-LGJ7JMCR.js +2 -0
- package/dist/{chunk-XSZH2K3E.js → chunk-LO6WSBLS.js} +1 -1
- package/dist/{chunk-VKFLER7N.js → chunk-LXRZ5SM4.js} +1 -1
- package/dist/{chunk-T7UACVWW.js → chunk-MFOEJ2RX.js} +1 -1
- package/dist/{chunk-OWPQZP4C.js → chunk-MI6UFDRC.js} +1 -1
- package/dist/chunk-MZPLTQVK.js +9 -0
- package/dist/{chunk-U7WMRB5V.js → chunk-N5ZEI42N.js} +1 -1
- package/dist/{chunk-UFWG6VMI.js → chunk-N6J2YUDC.js} +1 -1
- package/dist/{chunk-47ZPSTT6.js → chunk-NLEFCLLY.js} +1 -1
- package/dist/{chunk-LJ5O7DZ7.js → chunk-NPFG4T7Q.js} +2 -2
- package/dist/chunk-ODU2JSMA.js +8 -0
- package/dist/{chunk-3Q5IQXOI.js → chunk-OTTGA3LT.js} +1 -1
- package/dist/{chunk-ISBISZUE.js → chunk-P6PNLVNS.js} +1 -1
- package/dist/{chunk-4ZVGZF2L.js → chunk-P7PDRCQR.js} +1 -1
- package/dist/chunk-P7URFYFG.js +5 -0
- package/dist/{chunk-DVYQVSNS.js → chunk-PQ63VSMO.js} +1 -1
- package/dist/{chunk-FD5TFGJX.js → chunk-PZJJIH4T.js} +1 -1
- package/dist/chunk-Q6AHSGOE.js +5 -0
- package/dist/{chunk-PP4I2Z6M.js → chunk-QG5OZHRH.js} +1 -1
- package/dist/{chunk-TFGGJSTI.js → chunk-QXIY5WRL.js} +2 -2
- package/dist/{chunk-IPQAKIJO.js → chunk-RGRFL7XG.js} +1 -1
- package/dist/{chunk-2TNMV4BX.js → chunk-RH4QTLEG.js} +1 -1
- package/dist/{chunk-QBU5B4GH.js → chunk-RN2PEWDD.js} +1 -1
- package/dist/{chunk-RV3KMXUX.js → chunk-RSN4EHDN.js} +1 -1
- package/dist/{chunk-I3NUTW6U.js → chunk-SRJCAJYM.js} +1 -1
- package/dist/{chunk-PCBCEXYO.js → chunk-SYKBHHAJ.js} +1 -1
- package/dist/{chunk-H6TNBKGR.js → chunk-T2ONUKTL.js} +1 -1
- package/dist/{chunk-RPJUE54T.js → chunk-TEYEMBS7.js} +1 -1
- package/dist/{chunk-L45HDSJ7.js → chunk-TI5JQZ7J.js} +1 -1
- package/dist/{chunk-5FCXFSAO.js → chunk-UUV5VP5T.js} +1 -1
- package/dist/chunk-UXCXU6P4.js +8 -0
- package/dist/{chunk-T27HVHZA.js → chunk-VL3NGTTK.js} +1 -1
- package/dist/{chunk-UYTBGBT4.js → chunk-VLBUZOGF.js} +1 -1
- package/dist/{chunk-M5V464PU.js → chunk-VNWRMLJ2.js} +2 -2
- package/dist/{chunk-U2LDPUDZ.js → chunk-WJR2FU7S.js} +1 -1
- package/dist/{chunk-IYOL2FUH.js → chunk-WSHADDNC.js} +1 -1
- package/dist/{chunk-RMLC3QWX.js → chunk-WTRUUT4E.js} +1 -1
- package/dist/{chunk-TEJG5H2O.js → chunk-X3ULX7LO.js} +1 -1
- package/dist/chunk-X3YTLBZR.js +2 -0
- package/dist/{chunk-N3MZALFQ.js → chunk-X5FZCQVO.js} +1 -1
- package/dist/{chunk-6V4ANMW4.js → chunk-XWUK7FDE.js} +1 -1
- package/dist/chunk-YFQGOOF7.js +2 -0
- package/dist/{chunk-6MTKXDTH.js → chunk-YJUWYQIO.js} +1 -1
- package/dist/chunk-YY6RXHIL.js +98 -0
- package/dist/{chunk-SA7ORQHP.js → chunk-YZZJUMKN.js} +1 -1
- package/dist/{chunk-7SV2NQZV.js → chunk-Z4DH3J7O.js} +1 -1
- package/dist/{chunk-CLLLLX4F.js → chunk-ZIYSW2F4.js} +1 -1
- package/dist/{chunk-R5UVQMMP.js → chunk-ZUWU7LJ6.js} +1 -1
- package/dist/{config-A6MBUY54.js → config-7ZZAHUGW.js} +1 -1
- package/dist/{cover-cmd-TIY53OMC.js → cover-cmd-ASKH4ZPV.js} +1 -1
- package/dist/{credentials-GXICFDVV.js → credentials-DAYWXKP3.js} +1 -1
- package/dist/{deps-bundle-RDGQAIGD.js → deps-bundle-KPOXT7E7.js} +1 -1
- package/dist/{deps-resolve-52BOL7G6.js → deps-resolve-LKA4VWF2.js} +1 -1
- package/dist/device-env-CAW6YN75.js +2 -0
- package/dist/{dispatch-GJ7RVYPK.js → dispatch-DCQVGUGM.js} +1 -1
- package/dist/{doctor-XNI2NZZJ.js → doctor-4FHKGRTC.js} +1 -1
- package/dist/evidence-QCDPTFG3.js +2 -0
- package/dist/evolve-cmd-YBQCNBL6.js +2 -0
- package/dist/{explain-cmd-ENSJNQK7.js → explain-cmd-JAOHSI4F.js} +1 -1
- package/dist/{explain-cmd-LQ5CHHNY.js → explain-cmd-XFMMVUKV.js} +1 -1
- package/dist/{extract-bind-NWA4PSTU.js → extract-bind-AHNYCTPX.js} +3 -3
- package/dist/{extract-cmd-Q5PZS626.js → extract-cmd-7ZBAPANP.js} +3 -3
- package/dist/{gaps-cmd-UKMO7KYX.js → gaps-cmd-PITBOXQK.js} +1 -1
- package/dist/{generate-headless-CLKY4IAU.js → generate-headless-CDOH5LDS.js} +2 -2
- package/dist/{headless-io-3A3BZVQ5.js → headless-io-75HUMWZB.js} +1 -1
- package/dist/index.js +142 -140
- package/dist/{ingest-cmd-JZNVRFFS.js → ingest-cmd-T2LTILCD.js} +1 -1
- package/dist/install-XDQH2EM3.js +2 -0
- package/dist/{interactive-bind-7JMBM3OK.js → interactive-bind-SOLR3JCP.js} +3 -3
- package/dist/{lifecycle-cmd-VMZKHC2Y.js → lifecycle-cmd-MXYNJ55S.js} +1 -1
- package/dist/{list-cmd-3XDCASJH.js → list-cmd-SDXYRMO3.js} +1 -1
- package/dist/{list-commands-QURMKZZH.js → list-commands-S4FMWRUU.js} +1 -1
- package/dist/login-flow-XJARBECG.js +2 -0
- package/dist/{maintenance-cmd-MQ4GCVDU.js → maintenance-cmd-EGWCWSBX.js} +1 -1
- package/dist/{mobile-prompts-VXNHSCAH.js → mobile-prompts-5XLY7R4U.js} +1 -1
- package/dist/{next-TRSKMBO5.js → next-KZXH4UA4.js} +1 -1
- package/dist/{objective-variable-gate-BDSG2BEA.js → objective-variable-gate-L25PM6IM.js} +1 -1
- package/dist/{open-provider-ZYBUD6JW.js → open-provider-STFAULQU.js} +1 -1
- package/dist/{persist-recorded-session-NV2ULVPH.js → persist-recorded-session-WJCW7M5R.js} +1 -1
- package/dist/{phase-seed-H7KXNQO6.js → phase-seed-MKHEWUN6.js} +1 -1
- package/dist/pipeline-SBSLJEQT.js +2 -0
- package/dist/prepare-target-KJ2P2BC7.js +2 -0
- package/dist/reconcile-cmd-YPSGEA5W.js +2 -0
- package/dist/reconcile-deps-N32E7NQU.js +4 -0
- package/dist/reconcile-engine-CEWZQPFK.js +2 -0
- package/dist/{recording-banner-WZECSZJM.js → recording-banner-NW5J3XKA.js} +1 -1
- package/dist/registry-RV2NWZD6.js +2 -0
- package/dist/{require-project-folder-OFA4F2T5.js → require-project-folder-7DEBG4MC.js} +1 -1
- package/dist/{resolve-run-intent-M7EXFU7E.js → resolve-run-intent-A77ZCVXW.js} +1 -1
- package/dist/{resolver-TZAQGCFJ.js → resolver-NFGCIGX5.js} +1 -1
- package/dist/{review-cmd-RXD2RWKN.js → review-cmd-ZXTE7J6C.js} +1 -1
- package/dist/{run-DVBOAY7S.js → run-2AVVCSQ2.js} +1 -1
- package/dist/run-DGVXRJEG.js +2 -0
- package/dist/{run-test-md-Z75BGXRK.js → run-test-md-QBQ5PYV4.js} +2 -2
- package/dist/{skill-installer-FEOJ4KX3.js → skill-installer-IK7AVGLZ.js} +1 -1
- package/dist/{spawner-XHE7OXNW.js → spawner-YSJNIMNY.js} +1 -1
- package/dist/{store-guard-HIBKFC2T.js → store-guard-ZNNZGLQE.js} +1 -1
- package/dist/structured-answers-ZI2B6JJE.js +2 -0
- package/dist/sync-cmd-EJL5UMHU.js +2 -0
- package/dist/{sync-setup-WGYN6ZTI.js → sync-setup-6MUOKQ2U.js} +1 -1
- package/dist/tcg-generate-UO4I35AT.js +2 -0
- package/dist/testmd-actions-R34VVDEL.js +2 -0
- package/dist/testmd-sync-L4ZFKGFZ.js +2 -0
- package/dist/{tms-client-V3TR4QW3.js → tms-client-KU6HCA23.js} +1 -1
- package/dist/token-refresh-LS3PRAT5.js +2 -0
- package/dist/{validate-basic-GBA5PHIK.js → validate-basic-X46S6YL2.js} +1 -1
- package/dist/{variable-receipt-WMV33LAD.js → variable-receipt-KAS4JVFJ.js} +1 -1
- package/dist/{verdicts-34ZGB67K.js → verdicts-K7NEM446.js} +1 -1
- package/dist/{version-check-BHRM4PN4.js → version-check-LFAPVUOE.js} +1 -1
- package/dist/{view-cmd-FJGT5KZO.js → view-cmd-BMIT3223.js} +1 -1
- package/dist/walk-session-WFINXPLQ.js +2 -0
- package/dist/{with-telemetry-AIPWSH4P.js → with-telemetry-CETNH2F6.js} +1 -1
- package/package.json +11 -11
- package/dist/EvidenceViewOffer-M3DAU4YU.js +0 -2
- package/dist/FolderPicker-I2E2EJON.js +0 -2
- package/dist/SingleShotApp-CQWGPSLT.js +0 -2
- package/dist/TestMdRunView-GIOPBTA6.js +0 -2
- package/dist/agent-parse-XMWVKCRD.js +0 -2
- package/dist/bridge-VNFL4T6K.js +0 -2
- package/dist/chunk-4K44ZIC4.js +0 -2
- package/dist/chunk-5UCXN56I.js +0 -2
- package/dist/chunk-7XC5IQN6.js +0 -95
- package/dist/chunk-A55WPXDZ.js +0 -2
- package/dist/chunk-ALK3OUGN.js +0 -27
- package/dist/chunk-BPMSNGXQ.js +0 -2
- package/dist/chunk-CAOZKSQ3.js +0 -8
- package/dist/chunk-DFHVZZI3.js +0 -7
- package/dist/chunk-DYW5C6II.js +0 -2
- package/dist/chunk-EV3EU2MT.js +0 -9
- package/dist/chunk-HS7OIRGU.js +0 -5
- package/dist/chunk-P6HK7GSS.js +0 -9
- package/dist/chunk-P7YZ3PU3.js +0 -2
- package/dist/chunk-VL7LPZVI.js +0 -8
- package/dist/chunk-YKYHVRM2.js +0 -5
- package/dist/evidence-QYJ7SQR6.js +0 -2
- package/dist/evolve-cmd-2LM6NKMY.js +0 -2
- package/dist/install-FLC6WLPZ.js +0 -2
- package/dist/login-flow-BPT46DCE.js +0 -2
- package/dist/pipeline-STTNBJC4.js +0 -2
- package/dist/prepare-target-CRO3BGAP.js +0 -2
- package/dist/reconcile-cmd-VQTFUGEJ.js +0 -2
- package/dist/reconcile-deps-SE6COSXQ.js +0 -4
- package/dist/reconcile-engine-GLKGQEVR.js +0 -2
- package/dist/registry-GQEYUEQJ.js +0 -2
- package/dist/run-VF2MBI6M.js +0 -2
- package/dist/structured-answers-3C2DCFFF.js +0 -5
- package/dist/sync-cmd-MZYM5IE6.js +0 -2
- package/dist/tcg-generate-Y2UMDGPL.js +0 -2
- package/dist/testmd-actions-UDNH6W2Z.js +0 -2
- package/dist/testmd-sync-4BXMEIJ3.js +0 -2
- package/dist/token-refresh-KYIQ7LZL.js +0 -2
- package/dist/walk-session-CTZ5475S.js +0 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{h as w}from"./chunk-TAOHYWEO.js";import{a as h}from"./chunk-RZ4F3BHX.js";import{b as f}from"./chunk-
|
|
2
|
+
import{h as w}from"./chunk-TAOHYWEO.js";import{a as h}from"./chunk-RZ4F3BHX.js";import{b as f}from"./chunk-MI6UFDRC.js";import{mkdtemp as O,rm as $}from"fs/promises";import{createWriteStream as R}from"fs";import{Readable as U}from"stream";import{pipeline as F}from"stream/promises";import{tmpdir as T}from"os";import{basename as z,join as A}from"path";import{access as x,cp as P,mkdir as g,readdir as y,readFile as S,rename as I,rm as k,stat as b,writeFile as v}from"fs/promises";import{basename as D,join as d}from"path";function u(){return d(f,"mobile","apps")}function m(){return d(u(),"index.json")}function C(){return{readIndex:async()=>{try{let e=JSON.parse(await S(m(),"utf8"));return{apps:Array.isArray(e.apps)?e.apps:[]}}catch{return{apps:[]}}},writeIndex:async r=>{await g(u(),{recursive:!0});let e=`${m()}.tmp`;await v(e,JSON.stringify(r,null,2)),await I(e,m())},exists:async r=>{try{return await x(r),!0}catch{return!1}},copy:(r,e)=>P(r,e,{recursive:!0,force:!0}),remove:r=>k(r,{recursive:!0,force:!0}),sizeOf:async r=>{try{return(await b(r)).size}catch{return}},now:()=>new Date}}var c=class{deps;constructor(e={}){this.deps={...C(),...e}}async list(){let{apps:e}=await this.deps.readIndex();return[...e].sort((t,s)=>s.lastUsedAt.localeCompare(t.lastUsedAt))}async find(e){return(await this.deps.readIndex()).apps.find(t=>t.key===e)}async put(e){let t=await this.deps.readIndex(),s=t.apps.find(n=>n.key===e.key),a=this.deps.now().toISOString();if(s&&await this.deps.exists(s.path))return s.lastUsedAt=a,await this.deps.writeIndex(t),s;s&&(t.apps=t.apps.filter(n=>n.key!==e.key));let l=D(e.name??e.sourcePath),o=d(u(),e.key),p=d(o,l);await g(o,{recursive:!0}),await this.deps.copy(e.sourcePath,p);let i={key:e.key,path:p,name:l,source:e.source,...e.source==="local"?{originPath:e.sourcePath}:{},addedAt:a,lastUsedAt:a,...await this.deps.sizeOf(p).then(n=>n?{bytes:n}:{})};return t.apps=[...t.apps.filter(n=>n.key!==e.key),i],await this.deps.writeIndex(t),i}async exists(e){if(await this.deps.sizeOf(e.path)!==void 0)return!0;try{return await y(e.path),!0}catch{return!1}}async forget(e){let t=await this.deps.readIndex(),s=t.apps.find(a=>a.key===e);s&&(await this.deps.remove(s.path),t.apps=t.apps.filter(a=>a.key!==e),await this.deps.writeIndex(t))}async prune(){let e=await this.deps.readIndex(),t=[];for(let s of e.apps)if(await this.deps.sizeOf(s.path)!==void 0)t.push(s);else try{await y(s.path),t.push(s)}catch{}return t.length!==e.apps.length&&await this.deps.writeIndex({apps:t}),t}};var E=30*6e4,j=/^APP\d{6,}$/;function Y(r){return!!r&&j.test(r.trim())}function _(){return{store:new c,client:(r,e)=>new w(r,e),fetchToFile:async(r,e)=>{let t=await h(r,{method:"GET",signal:AbortSignal.timeout(E)});if(!t.ok)throw new Error(`Downloading the app failed: ${t.status} ${t.statusText}`);if(!t.body)throw new Error("Downloading the app failed: empty response body");await F(U.fromWeb(t.body),R(e))}}}async function Z(r,e={}){let t={..._(),...e},s=r.appId.trim(),a=await t.store.find(s);if(a&&await t.store.exists(a))return r.onProgress?.(`using the copy of ${a.name} already on this machine`),await t.store.put({key:s,sourcePath:a.path,source:"cloud",name:a.name}),{path:a.path,name:a.name,fromStore:!0};r.onProgress?.(`looking up ${s}\u2026`);let o=await t.client(r.baseUrl,r.auth).details(s);if(r.accepts&&!r.accepts.some(i=>o.name.toLowerCase().endsWith(i)))throw new Error(`${o.name} cannot run on this device \u2014 expected ${r.accepts.join(" or ")}.`);r.onProgress?.(`downloading ${o.name} \u2014 this can take a while, please wait\u2026`);let p=await O(A(T(),"kane-app-dl-"));try{let i=A(p,z(o.name));await t.fetchToFile(o.url,i);let n=await t.store.put({key:s,sourcePath:i,source:"cloud",name:o.name});return r.onProgress?.(`${o.name} is ready`),{path:n.path,name:n.name,fromStore:!1,details:o}}finally{await $(p,{recursive:!0,force:!0})}}export{c as a,Y as b,Z as c};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{j as be,k as se,l as ae,m as xe,n as De,o as ce}from"./chunk-TFGGJSTI.js";import{a as re,c as ie,d as Pe,f as oe}from"./chunk-A55WPXDZ.js";import{d as Ee}from"./chunk-6J5T5FEY.js";import{a as S}from"./chunk-RRY5IXOB.js";import{a as ee,b as W,c as ne,d as G,e as $e,g as O,h as te}from"./chunk-W5TTF7GB.js";import{a as _e}from"./chunk-BZAGVBCX.js";import{b as J,c as Q,d as X}from"./chunk-ZXP2TJEJ.js";import{j as ke,l as Re}from"./chunk-7N6OCHPC.js";import{P as E,Q as ge,S as he,U as ve,V as we,W as ye,X as Z}from"./chunk-SBSANJ2T.js";import{z as I}from"./chunk-IICT4VOU.js";import{H as B,t as pe}from"./chunk-RDHWNSDP.js";import{existsSync as Oe,statSync as Te}from"fs";import{basename as q,resolve as U}from"path";function Ie(e){if(!e||e.stale_refs.length===0)return"\u2014";let n=e.direct_refs??[];return`${e.stale_refs.length} stale${n.length>0?` \xB7 ${n.length} direct`:""}`}function le(e,n){let t=[...e.rows.filter(s=>s.kind!=="REMOVE").map(s=>[s.kind,S(s.ref),s.reason,Ie(s.impact)]),...e.archive.map(s=>["ARCHIVE",S(s.ref),s.why,Ie(s.impact)])],r=Math.max(40,n??100),i=[`reconcile ${e.source_id} \u2014 head ${e.head.status} \xB7 ${t.length} decision${t.length===1?"":"s"}`];return t.length>0&&i.push(...Ee(["kind","ref","why","impact"],t,r,2)),e.changed&&i.push(e.held?`extract ran in override mode; ${e.defaultsTaken??0} default(s) auto-taken; matched-but-changed and new proposals HELD for your verdict (staged \u2014 nothing committed)`:`extract ran in override mode; ${e.defaultsTaken??0} default(s) auto-taken; matched-but-changed proposals auto-committed as edits`),i.push("each row becomes a card below \u2014 verdicts commit as they land"),e.planPath&&i.push(`plan: ${e.planPath}`),i}var Ue=new Set(["interactive","agent","ci","override"]);function Be(e,n){if(e.mode!==void 0&&!Ue.has(e.mode))return{error:`--mode must be interactive | agent | ci | override, got '${e.mode}'`,code:"MODE_USAGE"};let t=e.mode,r="reconcile without a TTY needs an explicit mode \u2014 pass --mode agent|ci|override, or --plan for a preview";return t==="interactive"&&!n?{error:r}:t||(n?"interactive":e.plan?"override":{error:r})}async function Se(e){let{makeHeadlessIO:n,agentRefusal:t}=await import("./headless-io-3A3BZVQ5.js");return t(n("ndjson","reconcile"),e,"MODE_USAGE")}function Ve(e,n,t,r){if(Q(t)){let m=X(t),a=m?.sourceIdFor(t)??null;if(m===null||a===null)return{error:`--from '${t}' is not a supported remote URL \u2014 supported: ${J.map(f=>f.hint).join("; ")}`};if(r!==void 0&&r!==a)return{error:`--source-id '${r}' does not match this URL's own identity '${a}' \u2014 re-run without --source-id. A source adopted with --as updates by re-running context ingest with the same --as; reconcile follows only the URL's own id`};let c=I(e);if(!c.heads.has(a))return{error:`unknown source '${a}' \u2014 see \`kane-cli context list --type source\`. If this URL was ingested under a custom id, update it by re-running context ingest with the same --as`};if(c.heads.get(a)==null)return{error:`source '${a}' is retired \u2014 restore it first with \`kane-cli context revert\`, then reconcile`};let _=z(e,a,{remoteUrl:t});return _!==null?{error:_}:{sourceId:a,remoteUrl:t}}if(r===void 0)return{error:"reconcile needs --from <file> AND --source-id <id> \u2014 see `kane-cli context list --type source` for ids"};let i=U(n,t);if(!Oe(i)||!Te(i).isFile())return{error:`--from '${t}' is not a file \u2014 pass the changed source document`};let s=ke(i);if(!s.ok)return{error:`--from '${t}' is not an ingestable document \u2014 allowed: ${s.allowlist.join(", ")}`};let o=I(e);if(!o.heads.has(r))return{error:`unknown source '${r}' \u2014 see \`kane-cli context list --type source\``};if(o.heads.get(r)==null)return{error:`source '${r}' is retired \u2014 restore it first with \`kane-cli context revert\`, then reconcile`};let w=z(e,r,{filePath:i});if(w!==null)return{error:w};let d=null;try{d=Re(i)}catch{}return d!==null&&d!==r&&o.heads.get(d)!=null?{error:`'${q(i)}' already backs live source '${d}' \u2014 did you mean --source-id ${d}? To truly move these bytes under '${r}', retire '${d}' first`}:{sourceId:r,filePath:i}}function C(e){return e==null?"(none)":e.slice(0,19)}function K(e,n,t,r=!1,i){if(e.out(`reconcile ${n.source_id}: head ${n.head.status} \u2014 ${C(n.head.before)} \u2192 ${C(n.head.after)}`),r||(e.out(`note: ${n.note}`),e.out(`skipped arms: ${n.skipped_arms}`)),n.changed&&(e.out(n.held?`extract ran in override mode; ${t?.defaultsTaken??0} default(s) auto-taken; matched-but-changed and new proposals HELD for your verdict (staged \u2014 nothing committed)`:`extract ran in override mode; ${t?.defaultsTaken??0} default(s) auto-taken; matched-but-changed proposals auto-committed as edits`),i?.({type:"defaults_taken",count:t?.defaultsTaken??0})),r){let s=n.changeset??[],o=(d,m)=>{let a=s.filter(c=>c.kind===d).length;return a>0?`${a} ${m}`:null},w=[o("ADD","add"),o("MODIFY","modify"),o("ARCHIVE","archive")].filter(Boolean);n.changed&&e.out(`changeset: ${s.length} item(s)${w.length?` \u2014 ${w.join(" \xB7 ")}`:""}`),e.out(`plan: ${n.rows.length} row(s) \u2014 each gets a card below`);return}if(n.changed){let s=n.changeset??[];e.out(`changeset: ${s.length} item(s)`);for(let o of s)if(o.kind==="MODIFY")e.out(` [MODIFY] ${S(o.ref)} \u2014 ${o.summary} (${C(o.old_cid)} \u2192 ${o.new_cid===null?"(staged)":C(o.new_cid)})`);else if(o.kind==="ADD")e.out(` [ADD] ${S(o.ref)}`);else{e.out(` [ARCHIVE] ${S(o.ref)} \u2014 ${o.why}`);let w=de(o.impact,"retiring drops");w&&e.out(` ${w}`)}}e.out(`plan: ${n.rows.length} row(s)`);for(let s of n.rows){e.out(` [${s.kind}] ${S(s.ref)} \u2014 ${s.reason}`);let o=de(s.impact,"approving marks");o&&e.out(` ${o}`),e.out(` provenance: ${s.provenance}`),e.out(` action: ${s.action}`)}}function Ae(e,n){return le({source_id:e.source_id,head:{status:e.head.status},rows:e.rows,archive:(e.changeset??[]).filter(t=>t.kind==="ARCHIVE"),changed:e.changed,held:!!e.held,defaultsTaken:n?.defaultsTaken},process.stdout.columns)}function de(e,n){if(!e||e.stale_refs.length===0)return null;let t=e.direct_refs??[];return`impact: ${n} ${e.stale_refs.length} item(s) stale`+(t.length>0?` \u2014 ${t.length} directly touched: ${t.join(", ")}`:"")}function D(e){return e==="interactive"?"override":e}async function H(e,n,t,r,i,s,o=[],w="override",d,m,a,c,_,f,P){let p;try{p=te(e)}catch(u){return E(r,u instanceof Error?u.message:String(u)),1}try{if(!t){let{runWalkSession:u}=await import("./walk-session-CTZ5475S.js"),{telemetryEnvName:R}=await import("./bootstrap-545GY5CC.js");return await u({dir:e,rows:n,archive:o,held:d??null,childMode:w,runDesign:c??null,mark:s,markA:a,...m?{archiveState:m}:{},...f?{meta:{verb:"reconcile",sid:f,env:R()}}:{},...P?{resumeCmd:P}:{},signals:b=>A(e,b.ref,b.verdict,b.reason),..._?{script:_}:{}})}return await Ye(e,n,t,r,i,s,o,w,d,m)}finally{p()}}var F=(e,n)=>e?`kane-cli maintain reconcile --from ${e} --source-id ${n}`:void 0,Le=e=>e===null?void 0:"filePath"in e?e.filePath:e.remoteUrl,L=e=>`${e} high-risk item(s) need a human \u2014 ci mode won't guess. Walk interactively or use --mode agent.`;function T(e,n,t){let r=n.rows;e({type:"reconcile_plan",source_id:n.source_id,plan_path:t,rows:r.map(i=>({kind:i.kind,ref:i.ref,why:i.reason})),archive:n.changeset.filter(i=>i.kind==="ARCHIVE").map(i=>({ref:i.ref,why:i.why}))})}function ue(e={}){return{type:"reconcile_summary",applied:0,skipped:0,deferred:0,plan_only:0,failed:0,paused:0,stale_created:0,...e}}var j=ue();async function Y(e,n,t,r,i,s,o,w,d){T(i,n,t);let m=n.changeset.filter(_=>_.kind==="ARCHIVE"&&d?.[_.ref]===void 0),a=n.rows,c;try{c=te(e)}catch(_){return i({type:"error",message:_ instanceof Error?_.message:String(_)}),i(ue()),2}try{return await je(e,n,t,r,i,s,o,a,m,w)}finally{c()}}async function je(e,n,t,r,i,s,o,w,d,m){let a=0,c=0,_=0,f=0,P=0,p=0,u=0,R=new Set,b=(v,g)=>{try{m?.(v,g)}catch{}};for(let[v,g]of w.entries()){i({type:"reconcile_row_start",kind:g.kind,ref:g.ref,...g.impact?{stale:g.impact.stale_refs.length,direct:g.impact.direct_refs?.length??0}:{}});let h=(l,$,x)=>i({type:"reconcile_row_end",kind:g.kind,ref:g.ref,outcome:l,...$!==void 0?{exit_code:$}:{},...x?{detail:x}:{}});if(g.applied){c++,h("skipped");continue}if(g.kind==="REMOVE"){P++,h("plan-only");continue}if(g.held_ref&&n.held){let l=new Set;if(g.kind==="MODIFY"&&g.impact){let x=I(e);for(let M of g.impact.stale_refs){let N=x.resolve(M);N&&x.stale(N.tip)==="fresh"&&l.add(M)}}let $=se(e,n.held,g.held_ref,fe);if(!$.ok){_++,u===0&&(u=1),h("failed",1,$.message);continue}if($.kind==="ADD"){let x=await r($.ref,{yes:!0,mode:o});if(x!==0){x===3?(f++,u===0&&(u=3),h("paused",3)):(_++,u===0&&(u=1),h("failed",x));continue}}a++,$.kind!=="ADD"&&g.impact&&(p+=l.size),b(v,"approved"),A(e,g.ref,$.kind==="ADD"?"gap-resolved-create":"gap-resolved-evolve"),h("applied");continue}let k=re(I(e),g.ref);if(!k.ok){c++,h("skipped");continue}let y=k.target;if(R.has(y.ucTip)){c++,h("skipped");continue}if(g.kind==="ADD"){let l=await r(y.seamRef,{yes:!0,mode:o});if(l===3){f++,u===0&&(u=3),h("paused",3);continue}if(l!==0){_++,u===0&&(u=1),h("failed",l);continue}R.add(y.ucTip),a++,b(v,"approved"),A(e,g.ref,"gap-resolved-create"),h("applied")}else{let l=await ie(e,y,{yes:!0,mode:o},s,r,"batch");l.outcome==="evolved"?(R.add(y.ucTip),a++,b(v,"approved"),A(e,g.ref,"gap-resolved-evolve"),h("applied")):l.outcome==="paused"?(f++,u===0&&(u=l.code),h("paused",l.code)):l.outcome==="failed"?(_++,u===0&&(u=1),h("failed",l.code)):(c++,h("skipped"))}}return d.length>0&&(i({type:"reconcile_paused",plan_path:t,pending:d.map(v=>({ref:v.ref,why:v.why}))}),f+=d.length,u===0&&(u=3)),i(ue({applied:a,skipped:c,plan_only:P,failed:_,paused:f,stale_created:p})),u}var fe={kind:"human",id:process.env.USER??"operator"};function A(e,n,t,r){_e(e,{ts:new Date().toISOString(),command:"reconcile-walk",id:n,verdict:t,polarity:"preference",by:fe,target:n,...r!==void 0?{reason:r}:{}})}async function Ye(e,n,t,r,i,s,o=[],w="override",d,m){let a=0,c=0,_=0,f=0,P=0,p=0,u=0,R=new Set;for(let[b,v]of n.entries()){if(v.applied){r.out(`skipped ${v.ref} \u2014 already applied (${v.applied.outcome} at ${v.applied.at})`),c++;continue}let g=l=>{try{s?.(b,l)}catch($){E(r,`could not record applied state for ${v.ref}: ${$ instanceof Error?$.message:String($)}`)}};if(v.kind==="REMOVE"){r.out(`REMOVE ${v.ref} \u2014 plan-only in this release (not executed)`),f++;continue}if(v.held_ref&&d){let l=se(e,d,v.held_ref,fe);if(!l.ok){E(r,`held ${v.ref}: ${l.message}`),P++,u===0&&(u=1);continue}if(r.out(`committed ${l.ref} (${v.kind==="ADD"?"minted":"updated \u2014 old\u2192new redirect"})`),l.kind==="ADD"){let $=await i(l.ref,{yes:t,mode:w});if($===3){r.out(`design session for ${l.ref} paused \u2014 resume with the "kane-cli design tests --resume <session>" command printed above`),p++,u===0&&(u=3),g("approved");continue}if($!==0){E(r,`design run for ${l.ref} ended with exit code ${$}`),P++,u===0&&(u=1),g("approved");continue}}a++,g("approved"),A(e,v.ref,v.kind==="ADD"?"gap-resolved-create":"gap-resolved-evolve");continue}let h=I(e),k=re(h,v.ref);if(!k.ok){r.out(`skipped ${v.ref} \u2014 ${k.message}`),c++;continue}let y=k.target;if(R.has(y.ucTip)){r.out(`skipped ${v.ref} \u2014 use-case ${y.display} already handled in this walk`),c++;continue}if(v.kind==="ADD"){let l=await i(y.seamRef,{yes:t,mode:w});if(l===3){r.out(`design session for ${y.display} paused \u2014 resume with the "kane-cli design tests --resume <session>" command printed above; this row lands when that session completes`),p++,u===0&&(u=3);continue}if(l!==0){E(r,`design run for ${y.display} ended with exit code ${l}`),P++,u===0&&(u=1);continue}R.add(y.ucTip),a++,g("approved"),A(e,v.ref,"gap-resolved-create")}else{let l=await ie(e,y,{yes:!0,mode:w},r,i,"batch");l.outcome==="evolved"?(R.add(y.ucTip),a++,g("approved"),A(e,v.ref,"gap-resolved-evolve")):l.outcome==="paused"?(p++,u===0&&(u=l.code)):l.outcome==="failed"?(P++,u===0&&(u=l.code)):c++}}for(let b of o)if(b.kind==="ARCHIVE"&&m?.[b.ref]===void 0){r.out(`[ARCHIVE] ${b.ref} \u2014 ${b.why}`);{let v=de(b.impact,"retiring drops");v&&r.out(` ${v}`)}r.out(" plan-only \u2014 retire belongs to the interactive session (never headless)"),f++}return r.out(`reconcile walk: ${a} applied, ${c} skipped, ${_} deferred, ${f} plan-only`+(P>0?`, ${P} failed`:"")+(p>0?`, ${p} paused`:"")),u}var Ke=new Set(J.map(e=>e.name));function z(e,n,t){let r=I(e),i=r.heads.get(n);if(i==null)return null;let s=r.mediaOf(i);if("remoteUrl"in t){let o=X(t.remoteUrl)?.name??"remote";return s.format!==o?`source '${n}' is backed by ${s.format} content, not a ${o} source \u2014 reconcile it with the --from it was originally ingested from`:null}return Ke.has(s.format)?`source '${n}' is a remote ${s.format} source \u2014 pass its URL to --from, not a file`:null}function me(e,n,t,r){return"remoteUrl"in n?De(e,n.remoteUrl,{out:t.out,err:t.err},r.remoteFindProvider):xe(e,n.filePath)}function Me(e){return e.remote_url!==void 0?{remoteUrl:e.remote_url}:e.backing_path!==void 0?{filePath:e.backing_path}:null}async function He(e,n,t,r,i,s=!1,o=!1){let w=i.seams??{reingest:me(e,t,r,i),reextract:ce(e,{stage:s,hostOut:c=>r.out(c),hostEmit:c=>{c.type!=="run_start"&&i.emitEvent?.(c)},...i.emitEvent?{}:{hostProgress:c=>process.stderr.write(c+`
|
|
3
|
-
`)}})},d=null,m={reingest:w.reingest,reextract:async c=>d=await w.reextract(c)},a;try{r.out(`reconciling ${n}: re-reading the source and comparing against the graph\u2026`),a=await(i.buildPlan??ae)(e,n,m)}catch(c){return E(r,`reconcile failed: ${c instanceof Error?c.message:String(c)}`),null}if(a.changed)if(o)for(let c of Ae(a,d))r.out(c);else K(r,a,d,!1,i.emitEvent);return a}async function Ne(e){let[{render:n},t,{ScrollbackProvider:r},{ChatSurface:i},{makeChatController:s},{makeReconcileDeps:o}]=await Promise.all([import("./build-JIKYOZUH.js"),import("./react-QWOAB3TB.js"),import("./scrollback-JLPJR25X.js"),import("./ChatSurface-
|
|
4
|
-
`)}})},f;try{f=await(r.buildPlan??ae)(e,n.source_id,_,{resumeHeld:m})}catch(h){return E(t,`reconcile failed: ${h instanceof Error?h.message:String(h)}`),1}if(i==="interactive"&&!o)for(let h of Ae(f,null))t.out(h);else K(t,f,null,!1,r.emitEvent);let P=B(e),p=null;if(P!=null){let h={},k=new Set(f.changeset.filter(y=>y.kind==="ARCHIVE").map(y=>y.ref));for(let[y,l]of Object.entries(n.archive_state??{}))k.has(y)&&(h[y]=l);p=ee(e,{version:2,source_id:f.source_id,...n.remote_url!==void 0?{remote_url:n.remote_url}:{backing_path:n.backing_path},head_pin:P,created:new Date().toISOString().replace(/[:.]/g,"-"),skipped_arms:f.skipped_arms,note:f.note,changeset:f.changeset,rows:f.rows,...f.held?{held:f.held}:{},...Object.keys(h).length>0?{archive_state:h}:{}}),t.out(`plan stored: ${p}`)}if(o){if(i==="agent"){let h=r.emitEvent??(()=>{});T(h,f,p),h({...j})}return 0}let u=r.emitEvent??(()=>{}),R=p?W(e,p).plan.archive_state:void 0,b=p?(h,k)=>O(p,h,k):void 0,v=p?(h,k)=>G(p,h,k):void 0;if(i==="agent")return Y(e,f,p,s,u,t,D(i),b,R);let g=f.changeset.filter(h=>h.kind==="ARCHIVE"&&R?.[h.ref]===void 0);return i==="ci"&&g.length>0?(E(t,L(g.length)),2):H(e,f.rows,i==="override"||i==="ci",t,s,b,f.changeset,D(i),f.held,R,v,w,d,f.source_id,F(n.backing_path??n.remote_url,f.source_id))}async function Ce(e,n,t={},r=process.cwd()){let{telemetryBootstrap:i,telemetryEnvName:s}=await import("./bootstrap-
|
|
2
|
+
import{j as be,k as se,l as ae,m as xe,n as De,o as ce}from"./chunk-QXIY5WRL.js";import{a as re,c as ie,d as Pe,i as oe}from"./chunk-5UY2JMFC.js";import{d as Ee}from"./chunk-6J5T5FEY.js";import{a as S}from"./chunk-RRY5IXOB.js";import{a as ee,b as W,c as ne,d as G,e as $e,g as O,h as te}from"./chunk-W5TTF7GB.js";import{a as _e}from"./chunk-BZAGVBCX.js";import{b as J,c as Q,d as X}from"./chunk-EXSFOB4X.js";import{j as ke,l as Re}from"./chunk-7N6OCHPC.js";import{P as E,Q as ge,S as he,U as ve,V as we,W as ye,X as Z}from"./chunk-H2VMZL7J.js";import{z as I}from"./chunk-IICT4VOU.js";import{H as B,t as pe}from"./chunk-RDHWNSDP.js";import{existsSync as Oe,statSync as Te}from"fs";import{basename as q,resolve as U}from"path";function Ie(e){if(!e||e.stale_refs.length===0)return"\u2014";let n=e.direct_refs??[];return`${e.stale_refs.length} stale${n.length>0?` \xB7 ${n.length} direct`:""}`}function le(e,n){let t=[...e.rows.filter(s=>s.kind!=="REMOVE").map(s=>[s.kind,S(s.ref),s.reason,Ie(s.impact)]),...e.archive.map(s=>["ARCHIVE",S(s.ref),s.why,Ie(s.impact)])],r=Math.max(40,n??100),i=[`reconcile ${e.source_id} \u2014 head ${e.head.status} \xB7 ${t.length} decision${t.length===1?"":"s"}`];return t.length>0&&i.push(...Ee(["kind","ref","why","impact"],t,r,2)),e.changed&&i.push(e.held?`extract ran in override mode; ${e.defaultsTaken??0} default(s) auto-taken; matched-but-changed and new proposals HELD for your verdict (staged \u2014 nothing committed)`:`extract ran in override mode; ${e.defaultsTaken??0} default(s) auto-taken; matched-but-changed proposals auto-committed as edits`),i.push("each row becomes a card below \u2014 verdicts commit as they land"),e.planPath&&i.push(`plan: ${e.planPath}`),i}var Ue=new Set(["interactive","agent","ci","override"]);function Be(e,n){if(e.mode!==void 0&&!Ue.has(e.mode))return{error:`--mode must be interactive | agent | ci | override, got '${e.mode}'`,code:"MODE_USAGE"};let t=e.mode,r="reconcile without a TTY needs an explicit mode \u2014 pass --mode agent|ci|override, or --plan for a preview";return t==="interactive"&&!n?{error:r}:t||(n?"interactive":e.plan?"override":{error:r})}async function Se(e){let{makeHeadlessIO:n,agentRefusal:t}=await import("./headless-io-75HUMWZB.js");return t(n("ndjson","reconcile"),e,"MODE_USAGE")}function Ve(e,n,t,r){if(Q(t)){let m=X(t),a=m?.sourceIdFor(t)??null;if(m===null||a===null)return{error:`--from '${t}' is not a supported remote URL \u2014 supported: ${J.map(f=>f.hint).join("; ")}`};if(r!==void 0&&r!==a)return{error:`--source-id '${r}' does not match this URL's own identity '${a}' \u2014 re-run without --source-id. A source adopted with --as updates by re-running context ingest with the same --as; reconcile follows only the URL's own id`};let c=I(e);if(!c.heads.has(a))return{error:`unknown source '${a}' \u2014 see \`kane-cli context list --type source\`. If this URL was ingested under a custom id, update it by re-running context ingest with the same --as`};if(c.heads.get(a)==null)return{error:`source '${a}' is retired \u2014 restore it first with \`kane-cli context revert\`, then reconcile`};let _=z(e,a,{remoteUrl:t});return _!==null?{error:_}:{sourceId:a,remoteUrl:t}}if(r===void 0)return{error:"reconcile needs --from <file> AND --source-id <id> \u2014 see `kane-cli context list --type source` for ids"};let i=U(n,t);if(!Oe(i)||!Te(i).isFile())return{error:`--from '${t}' is not a file \u2014 pass the changed source document`};let s=ke(i);if(!s.ok)return{error:`--from '${t}' is not an ingestable document \u2014 allowed: ${s.allowlist.join(", ")}`};let o=I(e);if(!o.heads.has(r))return{error:`unknown source '${r}' \u2014 see \`kane-cli context list --type source\``};if(o.heads.get(r)==null)return{error:`source '${r}' is retired \u2014 restore it first with \`kane-cli context revert\`, then reconcile`};let w=z(e,r,{filePath:i});if(w!==null)return{error:w};let d=null;try{d=Re(i)}catch{}return d!==null&&d!==r&&o.heads.get(d)!=null?{error:`'${q(i)}' already backs live source '${d}' \u2014 did you mean --source-id ${d}? To truly move these bytes under '${r}', retire '${d}' first`}:{sourceId:r,filePath:i}}function C(e){return e==null?"(none)":e.slice(0,19)}function K(e,n,t,r=!1,i){if(e.out(`reconcile ${n.source_id}: head ${n.head.status} \u2014 ${C(n.head.before)} \u2192 ${C(n.head.after)}`),r||(e.out(`note: ${n.note}`),e.out(`skipped arms: ${n.skipped_arms}`)),n.changed&&(e.out(n.held?`extract ran in override mode; ${t?.defaultsTaken??0} default(s) auto-taken; matched-but-changed and new proposals HELD for your verdict (staged \u2014 nothing committed)`:`extract ran in override mode; ${t?.defaultsTaken??0} default(s) auto-taken; matched-but-changed proposals auto-committed as edits`),i?.({type:"defaults_taken",count:t?.defaultsTaken??0})),r){let s=n.changeset??[],o=(d,m)=>{let a=s.filter(c=>c.kind===d).length;return a>0?`${a} ${m}`:null},w=[o("ADD","add"),o("MODIFY","modify"),o("ARCHIVE","archive")].filter(Boolean);n.changed&&e.out(`changeset: ${s.length} item(s)${w.length?` \u2014 ${w.join(" \xB7 ")}`:""}`),e.out(`plan: ${n.rows.length} row(s) \u2014 each gets a card below`);return}if(n.changed){let s=n.changeset??[];e.out(`changeset: ${s.length} item(s)`);for(let o of s)if(o.kind==="MODIFY")e.out(` [MODIFY] ${S(o.ref)} \u2014 ${o.summary} (${C(o.old_cid)} \u2192 ${o.new_cid===null?"(staged)":C(o.new_cid)})`);else if(o.kind==="ADD")e.out(` [ADD] ${S(o.ref)}`);else{e.out(` [ARCHIVE] ${S(o.ref)} \u2014 ${o.why}`);let w=de(o.impact,"retiring drops");w&&e.out(` ${w}`)}}e.out(`plan: ${n.rows.length} row(s)`);for(let s of n.rows){e.out(` [${s.kind}] ${S(s.ref)} \u2014 ${s.reason}`);let o=de(s.impact,"approving marks");o&&e.out(` ${o}`),e.out(` provenance: ${s.provenance}`),e.out(` action: ${s.action}`)}}function Ae(e,n){return le({source_id:e.source_id,head:{status:e.head.status},rows:e.rows,archive:(e.changeset??[]).filter(t=>t.kind==="ARCHIVE"),changed:e.changed,held:!!e.held,defaultsTaken:n?.defaultsTaken},process.stdout.columns)}function de(e,n){if(!e||e.stale_refs.length===0)return null;let t=e.direct_refs??[];return`impact: ${n} ${e.stale_refs.length} item(s) stale`+(t.length>0?` \u2014 ${t.length} directly touched: ${t.join(", ")}`:"")}function D(e){return e==="interactive"?"override":e}async function H(e,n,t,r,i,s,o=[],w="override",d,m,a,c,_,f,P){let p;try{p=te(e)}catch(u){return E(r,u instanceof Error?u.message:String(u)),1}try{if(!t){let{runWalkSession:u}=await import("./walk-session-WFINXPLQ.js"),{telemetryEnvName:R}=await import("./bootstrap-PYBM5YT2.js");return await u({dir:e,rows:n,archive:o,held:d??null,childMode:w,runDesign:c??null,mark:s,markA:a,...m?{archiveState:m}:{},...f?{meta:{verb:"reconcile",sid:f,env:R()}}:{},...P?{resumeCmd:P}:{},signals:b=>A(e,b.ref,b.verdict,b.reason),..._?{script:_}:{}})}return await Ye(e,n,t,r,i,s,o,w,d,m)}finally{p()}}var F=(e,n)=>e?`kane-cli maintain reconcile --from ${e} --source-id ${n}`:void 0,Le=e=>e===null?void 0:"filePath"in e?e.filePath:e.remoteUrl,L=e=>`${e} high-risk item(s) need a human \u2014 ci mode won't guess. Walk interactively or use --mode agent.`;function T(e,n,t){let r=n.rows;e({type:"reconcile_plan",source_id:n.source_id,plan_path:t,rows:r.map(i=>({kind:i.kind,ref:i.ref,why:i.reason})),archive:n.changeset.filter(i=>i.kind==="ARCHIVE").map(i=>({ref:i.ref,why:i.why}))})}function ue(e={}){return{type:"reconcile_summary",applied:0,skipped:0,deferred:0,plan_only:0,failed:0,paused:0,stale_created:0,...e}}var j=ue();async function Y(e,n,t,r,i,s,o,w,d){T(i,n,t);let m=n.changeset.filter(_=>_.kind==="ARCHIVE"&&d?.[_.ref]===void 0),a=n.rows,c;try{c=te(e)}catch(_){return i({type:"error",message:_ instanceof Error?_.message:String(_)}),i(ue()),2}try{return await je(e,n,t,r,i,s,o,a,m,w)}finally{c()}}async function je(e,n,t,r,i,s,o,w,d,m){let a=0,c=0,_=0,f=0,P=0,p=0,u=0,R=new Set,b=(v,g)=>{try{m?.(v,g)}catch{}};for(let[v,g]of w.entries()){i({type:"reconcile_row_start",kind:g.kind,ref:g.ref,...g.impact?{stale:g.impact.stale_refs.length,direct:g.impact.direct_refs?.length??0}:{}});let h=(l,$,x)=>i({type:"reconcile_row_end",kind:g.kind,ref:g.ref,outcome:l,...$!==void 0?{exit_code:$}:{},...x?{detail:x}:{}});if(g.applied){c++,h("skipped");continue}if(g.kind==="REMOVE"){P++,h("plan-only");continue}if(g.held_ref&&n.held){let l=new Set;if(g.kind==="MODIFY"&&g.impact){let x=I(e);for(let M of g.impact.stale_refs){let N=x.resolve(M);N&&x.stale(N.tip)==="fresh"&&l.add(M)}}let $=se(e,n.held,g.held_ref,fe);if(!$.ok){_++,u===0&&(u=1),h("failed",1,$.message);continue}if($.kind==="ADD"){let x=await r($.ref,{yes:!0,mode:o});if(x!==0){x===3?(f++,u===0&&(u=3),h("paused",3)):(_++,u===0&&(u=1),h("failed",x));continue}}a++,$.kind!=="ADD"&&g.impact&&(p+=l.size),b(v,"approved"),A(e,g.ref,$.kind==="ADD"?"gap-resolved-create":"gap-resolved-evolve"),h("applied");continue}let k=re(I(e),g.ref);if(!k.ok){c++,h("skipped");continue}let y=k.target;if(R.has(y.ucTip)){c++,h("skipped");continue}if(g.kind==="ADD"){let l=await r(y.seamRef,{yes:!0,mode:o});if(l===3){f++,u===0&&(u=3),h("paused",3);continue}if(l!==0){_++,u===0&&(u=1),h("failed",l);continue}R.add(y.ucTip),a++,b(v,"approved"),A(e,g.ref,"gap-resolved-create"),h("applied")}else{let l=await ie(e,y,{yes:!0,mode:o},s,r,"batch");l.outcome==="evolved"?(R.add(y.ucTip),a++,b(v,"approved"),A(e,g.ref,"gap-resolved-evolve"),h("applied")):l.outcome==="paused"?(f++,u===0&&(u=l.code),h("paused",l.code)):l.outcome==="failed"?(_++,u===0&&(u=1),h("failed",l.code)):(c++,h("skipped"))}}return d.length>0&&(i({type:"reconcile_paused",plan_path:t,pending:d.map(v=>({ref:v.ref,why:v.why}))}),f+=d.length,u===0&&(u=3)),i(ue({applied:a,skipped:c,plan_only:P,failed:_,paused:f,stale_created:p})),u}var fe={kind:"human",id:process.env.USER??"operator"};function A(e,n,t,r){_e(e,{ts:new Date().toISOString(),command:"reconcile-walk",id:n,verdict:t,polarity:"preference",by:fe,target:n,...r!==void 0?{reason:r}:{}})}async function Ye(e,n,t,r,i,s,o=[],w="override",d,m){let a=0,c=0,_=0,f=0,P=0,p=0,u=0,R=new Set;for(let[b,v]of n.entries()){if(v.applied){r.out(`skipped ${v.ref} \u2014 already applied (${v.applied.outcome} at ${v.applied.at})`),c++;continue}let g=l=>{try{s?.(b,l)}catch($){E(r,`could not record applied state for ${v.ref}: ${$ instanceof Error?$.message:String($)}`)}};if(v.kind==="REMOVE"){r.out(`REMOVE ${v.ref} \u2014 plan-only in this release (not executed)`),f++;continue}if(v.held_ref&&d){let l=se(e,d,v.held_ref,fe);if(!l.ok){E(r,`held ${v.ref}: ${l.message}`),P++,u===0&&(u=1);continue}if(r.out(`committed ${l.ref} (${v.kind==="ADD"?"minted":"updated \u2014 old\u2192new redirect"})`),l.kind==="ADD"){let $=await i(l.ref,{yes:t,mode:w});if($===3){r.out(`design session for ${l.ref} paused \u2014 resume with the "kane-cli design tests --resume <session>" command printed above`),p++,u===0&&(u=3),g("approved");continue}if($!==0){E(r,`design run for ${l.ref} ended with exit code ${$}`),P++,u===0&&(u=1),g("approved");continue}}a++,g("approved"),A(e,v.ref,v.kind==="ADD"?"gap-resolved-create":"gap-resolved-evolve");continue}let h=I(e),k=re(h,v.ref);if(!k.ok){r.out(`skipped ${v.ref} \u2014 ${k.message}`),c++;continue}let y=k.target;if(R.has(y.ucTip)){r.out(`skipped ${v.ref} \u2014 use-case ${y.display} already handled in this walk`),c++;continue}if(v.kind==="ADD"){let l=await i(y.seamRef,{yes:t,mode:w});if(l===3){r.out(`design session for ${y.display} paused \u2014 resume with the "kane-cli design tests --resume <session>" command printed above; this row lands when that session completes`),p++,u===0&&(u=3);continue}if(l!==0){E(r,`design run for ${y.display} ended with exit code ${l}`),P++,u===0&&(u=1);continue}R.add(y.ucTip),a++,g("approved"),A(e,v.ref,"gap-resolved-create")}else{let l=await ie(e,y,{yes:!0,mode:w},r,i,"batch");l.outcome==="evolved"?(R.add(y.ucTip),a++,g("approved"),A(e,v.ref,"gap-resolved-evolve")):l.outcome==="paused"?(p++,u===0&&(u=l.code)):l.outcome==="failed"?(P++,u===0&&(u=l.code)):c++}}for(let b of o)if(b.kind==="ARCHIVE"&&m?.[b.ref]===void 0){r.out(`[ARCHIVE] ${b.ref} \u2014 ${b.why}`);{let v=de(b.impact,"retiring drops");v&&r.out(` ${v}`)}r.out(" plan-only \u2014 retire belongs to the interactive session (never headless)"),f++}return r.out(`reconcile walk: ${a} applied, ${c} skipped, ${_} deferred, ${f} plan-only`+(P>0?`, ${P} failed`:"")+(p>0?`, ${p} paused`:"")),u}var Ke=new Set(J.map(e=>e.name));function z(e,n,t){let r=I(e),i=r.heads.get(n);if(i==null)return null;let s=r.mediaOf(i);if("remoteUrl"in t){let o=X(t.remoteUrl)?.name??"remote";return s.format!==o?`source '${n}' is backed by ${s.format} content, not a ${o} source \u2014 reconcile it with the --from it was originally ingested from`:null}return Ke.has(s.format)?`source '${n}' is a remote ${s.format} source \u2014 pass its URL to --from, not a file`:null}function me(e,n,t,r){return"remoteUrl"in n?De(e,n.remoteUrl,{out:t.out,err:t.err},r.remoteFindProvider):xe(e,n.filePath)}function Me(e){return e.remote_url!==void 0?{remoteUrl:e.remote_url}:e.backing_path!==void 0?{filePath:e.backing_path}:null}async function He(e,n,t,r,i,s=!1,o=!1){let w=i.seams??{reingest:me(e,t,r,i),reextract:ce(e,{stage:s,hostOut:c=>r.out(c),hostEmit:c=>{c.type!=="run_start"&&i.emitEvent?.(c)},...i.emitEvent?{}:{hostProgress:c=>process.stderr.write(c+`
|
|
3
|
+
`)}})},d=null,m={reingest:w.reingest,reextract:async c=>d=await w.reextract(c)},a;try{r.out(`reconciling ${n}: re-reading the source and comparing against the graph\u2026`),a=await(i.buildPlan??ae)(e,n,m)}catch(c){return E(r,`reconcile failed: ${c instanceof Error?c.message:String(c)}`),null}if(a.changed)if(o)for(let c of Ae(a,d))r.out(c);else K(r,a,d,!1,i.emitEvent);return a}async function Ne(e){let[{render:n},t,{ScrollbackProvider:r},{ChatSurface:i},{makeChatController:s},{makeReconcileDeps:o}]=await Promise.all([import("./build-JIKYOZUH.js"),import("./react-QWOAB3TB.js"),import("./scrollback-JLPJR25X.js"),import("./ChatSurface-U3Y3WUMS.js"),import("./chat-controller-UJQ6Z4RE.js"),import("./reconcile-deps-N32E7NQU.js")]),w=t.default??t,d=s(),m=o({contextDir:e,note:a=>d.note(a)});return new Promise(a=>{let c=n(w.createElement(r,null,w.createElement(i,{controller:d,verb:"extract",reconcile:m,autoReview:!0,onReviewExit:()=>{c.unmount(),a(0)},onCtrlC:()=>{c.unmount(),a(m.pending()?3:0)}})),{exitOnCtrlC:!1})})}async function We(e,n,t,r,i){let s=W(e,n);if("error"in s)return E(r,s.error),2;let{plan:o,path:w}=s,d=t==="override"||t==="ci";if(n===void 0&&t==="interactive"&&r.isTTY&&!await r.confirm(`apply plan ${q(w)} for ${o.source_id} (created ${o.created})?`))return r.out(`not applying ${q(w)}`),0;let m=i.runDesignForUc??oe,a=i.runDesignForUc??null,c=i.sessionScript,_=(v,g)=>O(w,v,g),f=(v,g)=>G(w,v,g),P=B(e);if(P===o.head_pin){if(t==="agent"){let g=i.emitEvent??(()=>{});return Y(e,V(o),w,m,g,r,D(t),_,o.archive_state)}let v=ne(o);if(t==="ci"&&v.length>0)return E(r,L(v.length)),2;if(r.out(`applying stored plan ${q(w)} for ${o.source_id} (${o.rows.length} row(s))`),!d)for(let g of le({source_id:o.source_id,head:{status:"stored plan"},rows:o.rows,archive:(o.changeset??[]).filter(h=>h.kind==="ARCHIVE"),changed:!1,held:!!o.held},process.stdout.columns))r.out(g);return H(e,o.rows,d,r,m,_,o.changeset??[],D(t),o.held,o.archive_state,f,a,c,o.source_id,F(o.backing_path??o.remote_url,o.source_id))}if(r.out(`graph moved since this plan (${C(o.head_pin)} \u2192 ${C(P)}) \u2014 recomputing`),o.held)return Fe(e,o,r,i,t,m,!1);let p=Me(o);if(p===null)return E(r,`stored plan for ${o.source_id} names no backing file or URL \u2014 re-run reconcile --from`),2;let u=z(e,o.source_id,p);if(u!==null)return E(r,`stored plan cannot replay: ${u}`),2;let R=await He(e,o.source_id,p,r,i,!1,t==="interactive");if(!R)return 1;if(!R.changed)return K(r,R,null,!1,i.emitEvent),0;if(t==="agent"){let v=i.emitEvent??(()=>{});return Y(e,R,null,m,v,r,D(t))}let b=R.changeset.filter(v=>v.kind==="ARCHIVE");return t==="ci"&&b.length>0?(E(r,L(b.length)),2):H(e,R.rows,d,r,m,void 0,R.changeset,D(t),R.held,void 0,void 0,a,c,R.source_id,F(Le(p),R.source_id))}function V(e,n=!1){return{source_id:e.source_id,changed:!0,head:{status:"unchanged",before:e.head_pin,after:e.head_pin},note:e.note,skipped_arms:e.skipped_arms,changeset:e.changeset??[],rows:n?e.rows.filter(t=>t.applied===void 0):e.rows,...e.held?{held:e.held}:{}}}async function Ge(e,n,t,r,i,s,o){let w=r.runDesignForUc??null,d=r.sessionScript,m=$e(e,n);if(m===null)return null;if("error"in m)return E(t,m.error),2;let{plan:a,path:c}=m,_=a.rows.filter(u=>u.applied===void 0),f=ne(a),P=r.emitEvent??(()=>{});if(_.length===0&&f.length===0){t.out(`already reconciled \u2014 plan ${a.created} applied ${a.rows.length} row(s)`);let u=Pe(I(e)).staleCount;return u>0&&(t.out(`${u} item(s) still stale \u2014 kane-cli maintain evolve --from-stale`),P({type:"stale_debt",count:u})),i==="agent"&&(T(P,V(a),c),P({...j})),0}let p=B(e);return p!==a.head_pin?(t.out(`plan ${a.created} superseded \u2014 graph moved (${C(a.head_pin)} \u2192 ${C(p)}); recomputing`),Fe(e,a,t,r,i,s,o)):(t.out(`resuming plan ${a.created} \u2014 ${_.length} pending row(s)${f.length>0?`, ${f.length} undecided archive item(s)`:""}`),o?(K(t,V(a),null,!1,r.emitEvent),t.out(`plan stored: ${c}`),i==="agent"&&(T(P,V(a),c),P({...j})),0):i==="agent"?Y(e,V(a),c,s,P,t,D(i),(u,R)=>O(c,u,R),a.archive_state):i==="ci"&&f.length>0?(E(t,L(f.length)),2):H(e,a.rows,i==="override"||i==="ci",t,s,(u,R)=>O(c,u,R),a.changeset??[],D(i),a.held,a.archive_state,(u,R)=>G(c,u,R),w,d,a.source_id,F(a.backing_path??a.remote_url,a.source_id)))}async function Fe(e,n,t,r,i,s,o){let w=r.runDesignForUc??null,d=r.sessionScript,m;if(n.held){let h=I(e),k=new Set(n.rows.filter(l=>l.held_ref!==void 0&&l.applied!==void 0).map(l=>l.held_ref)),y=[];for(let l of n.held.rows){if(k.has(l.temp_ref))continue;if(!l.matched_cid){y.push(l);continue}let $=h.tipOf(l.matched_cid);if(h.superseded.get($)===null){t.out(`dropped held "${l.title}" \u2014 its use-case was retired meanwhile`),r.emitEvent?.({type:"held_dropped",ref:l.temp_ref,title:l.title,reason:"target_retired"});continue}y.push($===l.matched_cid?l:{...l,matched_cid:$,uc:{...l.uc,matches_existing:{cid:$}}})}m={source_id:n.held.source_id,rows:y}}let a=Me(n);if(a===null)return E(t,`stored plan for ${n.source_id} names no backing file or URL \u2014 re-run reconcile --from`),2;let c=z(e,n.source_id,a);if(c!==null)return E(t,`stored plan cannot replay: ${c}`),2;let _=r.seams??{reingest:me(e,a,t,r),reextract:ce(e,{stage:m!==void 0,hostOut:h=>t.out(h),hostEmit:h=>{h.type!=="run_start"&&r.emitEvent?.(h)},...r.emitEvent?{}:{hostProgress:h=>process.stderr.write(h+`
|
|
4
|
+
`)}})},f;try{f=await(r.buildPlan??ae)(e,n.source_id,_,{resumeHeld:m})}catch(h){return E(t,`reconcile failed: ${h instanceof Error?h.message:String(h)}`),1}if(i==="interactive"&&!o)for(let h of Ae(f,null))t.out(h);else K(t,f,null,!1,r.emitEvent);let P=B(e),p=null;if(P!=null){let h={},k=new Set(f.changeset.filter(y=>y.kind==="ARCHIVE").map(y=>y.ref));for(let[y,l]of Object.entries(n.archive_state??{}))k.has(y)&&(h[y]=l);p=ee(e,{version:2,source_id:f.source_id,...n.remote_url!==void 0?{remote_url:n.remote_url}:{backing_path:n.backing_path},head_pin:P,created:new Date().toISOString().replace(/[:.]/g,"-"),skipped_arms:f.skipped_arms,note:f.note,changeset:f.changeset,rows:f.rows,...f.held?{held:f.held}:{},...Object.keys(h).length>0?{archive_state:h}:{}}),t.out(`plan stored: ${p}`)}if(o){if(i==="agent"){let h=r.emitEvent??(()=>{});T(h,f,p),h({...j})}return 0}let u=r.emitEvent??(()=>{}),R=p?W(e,p).plan.archive_state:void 0,b=p?(h,k)=>O(p,h,k):void 0,v=p?(h,k)=>G(p,h,k):void 0;if(i==="agent")return Y(e,f,p,s,u,t,D(i),b,R);let g=f.changeset.filter(h=>h.kind==="ARCHIVE"&&R?.[h.ref]===void 0);return i==="ci"&&g.length>0?(E(t,L(g.length)),2):H(e,f.rows,i==="override"||i==="ci",t,s,b,f.changeset,D(i),f.held,R,v,w,d,f.source_id,F(n.backing_path??n.remote_url,f.source_id))}async function Ce(e,n,t={},r=process.cwd()){let{telemetryBootstrap:i,telemetryEnvName:s}=await import("./bootstrap-PYBM5YT2.js"),o=i({verb:"reconcile",mode:typeof e.mode=="string"?e.mode:"interactive",contextRoot:U(r,".context"),env:s(),applyPlanPath:typeof e.apply=="string"?U(r,e.apply):void 0,write:!0,longSession:!0});e.mode==="agent"&&t.emitEvent?.({type:"run_start",session:o.ids.session_id});{let m=Oe(U(r,".context"))?ye(U(r,".context")):null;if(m)return e.mode==="agent"?t.emitEvent?.(Z(m)):(E(n,m.text),(n.err??n.out)(`next: ${m.remedy}`)),await o.end({exit_code:2}),2}let w=await ve(U(r,".context"));w&&(e.mode==="agent"?t.emitEvent?.(we(w)):(n.err??n.out)(w.text));let d=await qe(e,n,t,r);return d===1&&e.mode!=="agent"&&(n.err??n.out)(o.supportFooter()),await o.end({exit_code:d}),d}async function qe(e,n,t={},r=process.cwd()){let i=e.apply!==void 0&&e.apply!==!1,s=typeof e.apply=="string"?e.apply:void 0;if(e.plan&&i)return E(n,"pass --plan OR --apply, not both"),2;let o=e.from!==void 0||!i,w=e.from!==void 0&&Q(e.from);if(o&&(!e.from||!e.sourceId&&!w))return E(n,"reconcile needs --from <file|url> AND --source-id <id> (files only \u2014 a URL derives its own id) \u2014 see `kane-cli context list --type source` for ids"),2;if(e.from&&s!==void 0)return E(n,"pass --from OR --apply <path>, not both \u2014 a stored plan names its own source"),2;let d=ge(r,n);if(!d)return 2;if(e.mode!==void 0&&!Ue.has(e.mode))return Se(`--mode must be interactive | agent | ci | override, got '${e.mode}'`);let m=e.mode==="agent"||e.mode==="ci"||e.mode==="override";if(i&&!m&&!n.isTTY)return E(n,"refusing to apply without a TTY to confirm \u2014 pass --mode override|ci"),2;let a=!e.plan,c="override";if(e.from){let k=Be(e,n.isTTY);if(typeof k=="object")return k.code==="MODE_USAGE"?Se(k.error):(E(n,k.error),2);c=k}let _=c==="override"||c==="ci";if(i&&!e.from){let{makeReconcileDeps:k}=await import("./reconcile-deps-N32E7NQU.js"),y=s===void 0?k({contextDir:d}).pending():null;if(y?.kind==="cards"){let $=e.mode??"interactive";return!n.isTTY||$!=="interactive"?(E(n,`a held changeset for ${y.source} awaits review (${y.count} change(s)) \u2014 resume in a terminal: kane-cli maintain reconcile --apply [HELD_REVIEW]`),2):(t.cardApplyMount??Ne)(d)}let l=e.mode??"interactive";return We(d,s===void 0?void 0:U(r,s),l,n,t)}let f=Ve(d,r,e.from,e.sourceId);if("error"in f)return E(n,f.error),2;if(!i){let{sessionsHoldingSource:k}=await import("./sessions-NH7WQWMX.js"),{holders:y,corrupt:l}=k(d,f.sourceId);if(l>0)return E(n,`cannot verify review holds \u2014 ${l} session file(s) unreadable; inspect with kane-cli context sessions list, clean with kane-cli context sessions clean, then retry [SESSIONS_UNREADABLE]`),2;if(y.length>0)return E(n,`session ${y[0]} holds item(s) for review pinned to ${f.sourceId} \u2014 finish that review first: kane-cli context extract --resume ${y[0]} [SOURCE_HELD]`),2}if(c==="interactive"&&!e.plan&&!i){let k=t.seams?.reingest??me(d,f,n,t),y;try{y=await k(f.sourceId)}catch($){return E(n,$ instanceof Error?$.message:String($)),1}let l=y.status==="unchanged"?null:be(d,f.sourceId);if(y.status!=="unchanged"&&!l)return n.out(`${f.sourceId} landed for the first time \u2014 extract it: kane-cli context extract --source ${f.sourceId}`),0;if(l){let x=await(t.chatMount??(async M=>{let{bindExtractInteractive:N}=await import("./extract-bind-AHNYCTPX.js");return N(M)}))({mode:"interactive",posture:"reconcile",source:f.sourceId,changeContext:l});if(x===3){let{sessionsHoldingSource:M}=await import("./sessions-NH7WQWMX.js");if(M(d,f.sourceId).holders.length===0)return 0}return x}}let P="remoteUrl"in f?{remoteUrl:f.remoteUrl}:{filePath:f.filePath},p=await He(d,f.sourceId,P,n,t,!!e.plan||c==="interactive",c==="interactive"&&!e.plan);if(!p)return 1;let u=t.runDesignForUc??oe,R=t.runDesignForUc??null,b=t.sessionScript;if(!p.changed){let k=await Ge(d,f.sourceId,n,t,c,u,!!e.plan);if(k!==null)return k;if(K(n,p,null,!1,t.emitEvent),c==="agent"){let y=t.emitEvent??(()=>{});T(y,p,null),y({...j})}return 0}let v=B(d),g=null;if(v!=null?g=ee(d,{version:2,source_id:p.source_id,..."remoteUrl"in P?{remote_url:P.remoteUrl}:{backing_path:P.filePath},head_pin:v,created:new Date().toISOString().replace(/[:.]/g,"-"),skipped_arms:p.skipped_arms,note:p.note,changeset:p.changeset,rows:p.rows,...p.held?{held:p.held}:{}}):E(n,"no chain head after extract \u2014 plan not stored"),c==="agent"){let k=t.emitEvent??(()=>{});if(!a)return T(k,p,g),k({...j}),0;let y=g?(l,$)=>O(g,l,$):void 0;return Y(d,p,g,u,k,n,D(c),y)}if(!a)return g&&n.out(`plan stored: ${g}`),0;let h=p.changeset.filter(k=>k.kind==="ARCHIVE");if(c==="ci"&&h.length>0)return g&&n.out(`plan stored: ${g}`),E(n,L(h.length)),2;if(g){n.out(`plan stored: ${g}`);let k=g;return H(d,ze(d,k)??p.rows,_,n,u,(y,l)=>O(k,y,l),p.changeset,D(c),p.held,void 0,void 0,R,b,p.source_id,F(e.from,p.source_id))}return H(d,p.rows,_,n,u,void 0,p.changeset,D(c),p.held,void 0,void 0,R,b,p.source_id,F(e.from,p.source_id))}function ze(e,n){let t=W(e,n);return"error"in t?null:t.plan.rows}async function hn(e,n={},t,r=process.cwd()){if(e.mode==="agent"){let{makeHeadlessIO:i}=await import("./headless-io-75HUMWZB.js"),s=t?i("ndjson","reconcile",t):i("ndjson","reconcile"),o={out:s.out,err:m=>s.event({type:"error",message:m}),isTTY:!1,confirm:async()=>!1,ask:async()=>""},{runWithChannel:w}=await import("./run-channel-RGH4WIQX.js"),d=2;try{d=await w({event:m=>s.event(m)},()=>Ce(e,o,{...n,emitEvent:m=>s.event(m)},r))}catch(m){m instanceof pe?(d=2,s.event(Z({code:m.code,text:m.message,remedy:m.remedy}))):(d=1,s.event({type:"error",message:m instanceof Error?m.message:String(m)}))}return s.done(d)}return Ce(e,he(),n,r)}export{Be as a,Ve as b,D as c,A as d,Ce as e,hn as f};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{b as Me}from"./chunk-
|
|
2
|
+
import{b as Me}from"./chunk-YJUWYQIO.js";import{c as Ft}from"./chunk-T2ONUKTL.js";import{a as Jt}from"./chunk-66MOZKD2.js";import{a as g,c as Mt,d as Bt,e as _,f as Le,g as Fe,h as Wt,i as Je,j as Ht}from"./chunk-YLQHY4A7.js";import{h as ut,k as ft,m as ht,o as _e,r as Pt,t as Lt}from"./chunk-RGRFL7XG.js";import{a as At,b as Pe,c as Ct,d as Tt}from"./chunk-VVOKM2VO.js";import{u as qt}from"./chunk-IICT4VOU.js";import{a as Nt}from"./chunk-CH273NAE.js";import{b as dt}from"./chunk-5LJRZI7S.js";import{a as lt}from"./chunk-BKM2LWU2.js";import{B as re,D as Ie,E as Et,F as xt,G as L,I as qe,J as he,K as Ot,O as $,P as y,Q as Ae,R as _t,S as Ce,U as Te,V as It,W as Ne,X as se,a as pt,b as fe,h as te,i as mt,j as gt,n as wt,p as x,r as St,s as $t,t as kt,v as Rt,x as vt,z as Y}from"./chunk-RDHWNSDP.js";import{b as ne,c as bt,h as yt}from"./chunk-FQNQVC5O.js";import{a as ee}from"./chunk-XLSOQLVT.js";import{s as at,t as ct}from"./chunk-RSSOJ3L2.js";import{y as O}from"./chunk-MI6UFDRC.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
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
4
|
id: ${e}
|
|
5
5
|
base: ${n}
|
|
@@ -32,4 +32,4 @@ ${s}`}function fr(t,e){let n=`${t}.tmp-mint`;lr(n,e),dr(n,t)}function oo(t){let{
|
|
|
32
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
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
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-
|
|
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-STFAULQU.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{a as b}from"./chunk-
|
|
2
|
+
import{a as b}from"./chunk-KMMOJDN4.js";import{m as d,y as o}from"./chunk-MI6UFDRC.js";import{a as L}from"./chunk-HCBYKLMW.js";import{a as u,b as c,i as A}from"./chunk-C44QQJR4.js";import{a as D}from"./chunk-6YGTRKDT.js";import{e as h}from"./chunk-UR6MHSHU.js";var x=h(D(),1);import{readdirSync as N,mkdirSync as B,statSync as k}from"fs";import{join as P}from"path";var r=h(L(),1);function O(n){try{return N(n).filter(l=>{try{return k(P(n,l)).isDirectory()}catch{return!1}})}catch{return[]}}function E(n,l,f,v){return{name:n,path:l,label:n,isActive:v}}function H({currentPath:n,onSelect:l,onCancel:f}){let s=O(d).map(i=>{let e=P(d,i);return E(i,e,n,e===n)}),p=!n,R=s.length+2,[a,C]=(0,x.useState)(()=>{if(p)return 0;let i=s.findIndex(e=>e.isActive);return i>=0?i+1:0}),[T,I]=(0,x.useState)(!1),[S,g]=(0,x.useState)("");return A((i,e)=>{if(T){if(e.escape){I(!1),g("");return}if(e.return){let t=S.trim();if(t){let m=P(d,t);B(m,{recursive:!0}),l(m),f()}return}if(e.backspace||e.delete){g(t=>t.slice(0,-1));return}i&&!e.ctrl&&!e.meta&&g(t=>t+i);return}if(e.escape){f();return}if(e.upArrow){C(t=>Math.max(0,t-1));return}if(e.downArrow){C(t=>Math.min(R-1,t+1));return}if(e.return){if(a===0){p||l(""),f();return}if(a===s.length+1){B(d,{recursive:!0}),I(!0),g("");return}let t=s[a-1];t&&!t.isActive&&l(t.path),f();return}}),T?(0,r.jsxs)(u,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,r.jsx)(c,{color:o.orange,bold:!0,children:"Chrome Profile \u203A New"}),(0,r.jsxs)(u,{marginTop:1,children:[(0,r.jsx)(c,{color:o.secondary,children:"Name: "}),(0,r.jsx)(c,{children:S}),(0,r.jsx)(c,{color:o.dim,children:"\u2588"})]}),(0,r.jsx)(b,{bindings:[{keys:"\u21B5",label:"create"}],escBackLabel:"back"})]}):(0,r.jsxs)(u,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,r.jsx)(c,{color:o.orange,bold:!0,children:"Chrome Profile"}),(0,r.jsxs)(u,{flexDirection:"column",marginTop:1,children:[(0,r.jsxs)(c,{color:p?o.green:a===0?o.orange:o.dim,children:[a===0?"\u276F ":" ","Use temporary (no profile)",p?" \u25CF active":""]}),s.map((i,e)=>{let m=e+1===a,w=m?"\u276F ":" ",y=i.isActive?o.green:m?o.orange:void 0;return(0,r.jsxs)(c,{color:y,children:[w,i.label,i.isActive?" \u25CF active":""]},i.name)}),(0,r.jsxs)(c,{color:a===s.length+1?o.orange:o.dim,children:[a===s.length+1?"\u276F ":" ","+ Create new"]})]}),(0,r.jsx)(b,{bindings:[{keys:"\u2191\u2193",label:"navigate"},{keys:"\u21B5",label:"select"}],escBackLabel:"back"})]})}export{O as a,E as b,H as c};
|
|
@@ -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,p as y,r as z,t as U}from"./chunk-
|
|
2
|
+
import{b as N,c as O,e as S,f as D,j as T,p as y,r as z,t as U}from"./chunk-TI5JQZ7J.js";import{a as Y,b as M}from"./chunk-NBXYL2JT.js";import{a as F}from"./chunk-ODU2JSMA.js";import{a as R}from"./chunk-DHJSM5DT.js";import{a as A}from"./chunk-MI6UFDRC.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,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as u,b as x}from"./chunk-
|
|
2
|
+
import{a as u,b as x}from"./chunk-4HPJ4S6H.js";import{y as m}from"./chunk-MI6UFDRC.js";import{a as f}from"./chunk-HCBYKLMW.js";import{a as r,b as i}from"./chunk-C44QQJR4.js";import{e as n}from"./chunk-UR6MHSHU.js";var e=n(f(),1);function C({title:B,titleColor:c,borderColor:d,variant:p,rows:s,footer:t,labelWidth:l=14,marginBottom:b=1}){return(0,e.jsxs)(u,{title:B,titleColor:c,borderColor:d,variant:p,marginBottom:b,children:[s.map((o,a)=>typeof o.value=="string"?(0,e.jsx)(x,{label:o.label,value:o.value,valueColor:o.valueColor,labelWidth:l},`${o.label}-${a}`):(0,e.jsxs)(r,{children:[(0,e.jsx)(r,{width:l,children:(0,e.jsx)(i,{color:m.dim,children:o.label})}),o.value]},`${o.label}-${a}`)),t&&(0,e.jsx)(r,{marginTop:1,children:t})]})}export{C 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-CP2TVGKB.js";import{k as Z}from"./chunk-LGJ7JMCR.js";import{a as D}from"./chunk-YCCUBQY4.js";import{a as M}from"./chunk-QG5OZHRH.js";import{a as z}from"./chunk-IXJ33HYF.js";import{b as W}from"./chunk-FY7WTTDQ.js";import{a as B}from"./chunk-KMMOJDN4.js";import{e as V}from"./chunk-Z7S3IWUX.js";import{y as o}from"./chunk-MI6UFDRC.js";import{a as A}from"./chunk-HCBYKLMW.js";import{a as n,b as t,i as L}from"./chunk-C44QQJR4.js";import{a as N}from"./chunk-6YGTRKDT.js";import{e as g}from"./chunk-UR6MHSHU.js";var T=g(A(),1);function te(e){let i=e.kind==="simulator";switch(e.state){case"ready":return i?"Booted":"Running";case"stopped":return i?"Shutdown":"Stopped";case"unauthorized":return"UNAUTHORIZED";case"offline":return"Offline"}}function re(e){switch(e.state){case"unauthorized":return"accept the authorisation prompt on the device, then reopen this list";case"offline":return e.kind==="simulator"?"not responding \u2014 open Simulator.app to inspect it":"not responding \u2014 reconnect it, or restart the emulator";default:return}}function ne(e,i){let m=i.id!==void 0?{...i,id:z(i.id)}:i,c=e.virtualName!==void 0?{...e,virtualName:z(e.virtualName)}:e;return V(c,m)}function ie(e){return e.virtualName??e.displayName}function ae(e,i){let m=e.state==="ready"||e.state==="stopped",c=re(e),b=e.osVersion?` (${e.osVersion})`:"";return{id:e.id,label:`${ie(e)}${b} \xB7 ${te(e)}`,...i&&ne(e,i)?{isActive:!0}:{},...m?{}:{disabled:!0},...!m&&c?{disabledHint:c}:{}}}function le(e){return e==="emulator"?"No Android emulator found. Make sure an emulator exists on this machine (Android Studio \u2192 Device Manager), then reopen this list.":e==="simulator"?"No iOS simulator found. Make sure a simulator exists on this machine (Xcode \u2192 Windows \u2192 Devices and Simulators), then reopen this list.":"No emulator or simulator found. Make sure one exists on this machine, then reopen this list."}function he({targets:e,preselectedTarget:i,preselectedId:m,busyMessage:c,onSelect:b,onCancel:f,kind:l}){if(c)return(0,T.jsxs)(n,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,T.jsx)(t,{color:o.orange,bold:!0,children:"Device"}),(0,T.jsxs)(n,{marginTop:1,children:[(0,T.jsx)(C,{}),(0,T.jsxs)(t,{color:o.secondary,children:[" ",c]})]})]});if(e.length===0)return(0,T.jsxs)(n,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,T.jsx)(t,{color:o.orange,bold:!0,children:"Device"}),(0,T.jsx)(n,{marginTop:1,children:(0,T.jsx)(t,{color:o.dim,children:le(l)})})]});let d=e.map(r=>ae(r,i)),p=i?d.find(r=>r.isActive)?.id??null:m?e.find(r=>r.id===m||r.virtualName===m)?.id??null:null,a=new Map(e.map(r=>[r.id,r]));return(0,T.jsx)(M,{title:"Device",items:d,itemNoun:"devices",defaultActiveId:p,preserveSelectionById:!0,onSelect:r=>{let y=a.get(r.id);y&&b(y)},onCancel:f})}var x=g(N(),1);var u=g(A(),1),q=50,G=500;function pe(e){return`${e.name} (${e.appId})`}function Pe({kind:e,listApps:i,onSelect:m,onManualEntry:c,onCancel:b,busyMessage:f}){let[l,d]=(0,x.useState)([]),[p,a]=(0,x.useState)(!0),[r,y]=(0,x.useState)(!1),[Q,O]=(0,x.useState)(!1),[E,H]=(0,x.useState)(null),[w,J]=(0,x.useState)(""),[j,U]=(0,x.useState)(!1),$=(0,x.useRef)(!0),R=(0,x.useRef)(0);if((0,x.useEffect)(()=>{let h=++R.current,k=w.trim();$.current?a(!0):k&&O(!0),y(!0),H(null),U(!1),(async()=>{let I=[];try{for(let P=0;;P+=q){let X=await i({limit:q,offset:P,search:k});if(h!==R.current)return;if(I.push(...X.apps),d([...I]),$.current&&(a(!1),$.current=!1),O(!1),X.apps.length===0||I.length>=X.total)break;if(I.length>=G){U(!0);break}}}catch(P){if(h!==R.current)return;H(P instanceof Error?P.message:String(P)),a(!1),O(!1)}finally{h===R.current&&y(!1)}})()},[w,i]),L((h,k)=>{if(k.tab){c();return}k.escape&&b()},{isActive:!!E&&!f}),f)return(0,u.jsxs)(n,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,u.jsx)(t,{color:o.orange,bold:!0,children:"App under test"}),(0,u.jsxs)(n,{marginTop:1,children:[(0,u.jsx)(C,{}),(0,u.jsxs)(t,{color:o.secondary,children:[" ",f]})]})]});if(E)return(0,u.jsxs)(n,{flexDirection:"column",borderStyle:"round",borderColor:o.red,paddingX:2,paddingY:1,children:[(0,u.jsx)(t,{color:o.red,bold:!0,children:"App under test"}),(0,u.jsx)(n,{marginTop:1,children:(0,u.jsx)(t,{color:o.red,children:"Could not load your uploads."})}),(0,u.jsx)(n,{marginTop:1,children:(0,u.jsx)(t,{color:o.dim,children:E})}),(0,u.jsx)(B,{bindings:[{keys:"tab",label:"tab to enter an app id"}],escBackLabel:"back to chat"})]});let ee=new Map(l.map(h=>[h.appId,h])),oe=l.map(h=>({id:h.appId,label:pe(h)})),_=!p&&!r&&l.length===0&&!w.trim()?e==="simulator"?"No simulator builds uploaded to this account yet \u2014 press Tab to enter an app id.":"No emulator builds uploaded to this account yet \u2014 press Tab to enter an app id.":null;return(0,u.jsx)(M,{title:"App under test",items:oe,loading:p,loadingText:"Loading your uploads\u2026",loadingMore:r,searching:Q,itemNoun:"uploads",preserveSelectionById:!0,onSearch:J,onTab:c,extraHint:"tab to enter an id",footer:_?(0,u.jsx)(t,{color:o.dim,children:_}):j?(0,u.jsx)(t,{color:o.dim,children:`Showing the first ${G} \u2014 type to search the rest.`}):void 0,onSelect:h=>{let k=ee.get(h.id);k&&m({appId:k.appId,name:k.name})},onCancel:b})}var Y=g(N(),1);var S=g(A(),1),se={emulator:["apk"],simulator:["zip"]};function ce(e){return Z(e.trim())}function Oe({kind:e,onBack:i,onSelect:m,onCancel:c}){let[b,f]=(0,Y.useState)(""),[l,d]=(0,Y.useState)(null),p=e==="emulator"?".apk":".zip";return(0,S.jsxs)(n,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,S.jsx)(t,{color:o.orange,bold:!0,children:"App under test"}),(0,S.jsx)(n,{marginTop:1,children:(0,S.jsx)(t,{color:o.dim,children:`Path to a build (${p}): `})}),(0,S.jsxs)(n,{marginTop:1,children:[(0,S.jsx)(t,{color:o.dim,children:" "}),(0,S.jsx)(D,{value:b,onChange:a=>{f(a),l&&d(null)},onSubmit:a=>{let r=ce(a);if(!r){d(a.trim()?`Not a build \u2014 expected ${p}.`:"Enter the path to a build.");return}if(!se[e].includes(r.kind)){d(`${r.kind} builds don't run on a ${e} \u2014 expected ${p}.`);return}d(null),m(r).then(y=>{!y.ok&&y.error&&d(y.error)})},onCancel:i,placeholder:e==="emulator"?"/path/to/app-debug.apk":"/path/to/MyApp.zip"})]}),l&&(0,S.jsx)(n,{marginTop:1,children:(0,S.jsx)(t,{color:o.red,children:l})}),(0,S.jsx)(B,{bindings:[{keys:"\u21B5",label:"use this build"}],escBackLabel:"back"})]})}var F=g(N(),1);var v=g(A(),1);function de(e){return[{value:"local",label:"Local build",hint:e==="emulator"?".apk":".zip",available:!0},{value:"uploaded",label:"Uploaded app",hint:"an app id from your cloud uploads",available:!0}]}function Ye({kind:e,onSelect:i,onCancel:m}){let c=de(e),[b,f]=(0,F.useState)(0),[l,d]=(0,F.useState)(null);return L((p,a)=>{if(a.escape){m();return}if(a.upArrow&&f(r=>Math.max(0,r-1)),a.downArrow&&f(r=>Math.min(c.length-1,r+1)),a.return){let r=c[b];if(!r.available){d("That source isn't available \u2014 choose a local build for now.");return}d(null),i(r.value)}}),(0,v.jsxs)(n,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,v.jsx)(t,{color:o.orange,bold:!0,children:"App under test"}),(0,v.jsx)(n,{marginTop:1,flexDirection:"column",children:c.map((p,a)=>{let r=a===b,y=p.available?r?o.orange:void 0:o.muted;return(0,v.jsxs)(n,{children:[(0,v.jsxs)(t,{color:y,children:[r?"\u276F ":" ",p.label]}),(0,v.jsxs)(t,{color:o.dim,children:[" ",p.hint]})]},p.value)})}),l&&(0,v.jsx)(n,{marginTop:1,children:(0,v.jsx)(t,{color:o.red,children:l})}),(0,v.jsx)(B,{bindings:[{keys:"\u2191\u2193",label:"navigate"},{keys:"\u21B5",label:"select"}],escBackLabel:"back"})]})}var K=g(N(),1);var s=g(A(),1);function qe({busyMessage:e,onSubmit:i,onBack:m}){let[c,b]=(0,K.useState)(""),[f,l]=(0,K.useState)(null);return e?(0,s.jsxs)(n,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,s.jsx)(t,{color:o.orange,bold:!0,children:"App under test"}),(0,s.jsxs)(n,{marginTop:1,children:[(0,s.jsx)(C,{}),(0,s.jsxs)(t,{color:o.secondary,children:[" ",e]})]})]}):(0,s.jsxs)(n,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,s.jsx)(t,{color:o.orange,bold:!0,children:"App under test"}),(0,s.jsx)(n,{marginTop:1,children:(0,s.jsx)(t,{color:o.dim,children:"App id from your cloud uploads:"})}),(0,s.jsxs)(n,{marginTop:1,children:[(0,s.jsx)(t,{color:o.dim,children:" "}),(0,s.jsx)(D,{value:c,onChange:d=>{b(d),f&&l(null)},onSubmit:d=>{let p=d.trim();if(!p){l("Enter an app id.");return}if(!W(p)){l("That doesn't look like an app id \u2014 they start with APP.");return}l(null),i(p).then(a=>{!a.ok&&a.error&&l(a.error)})},onCancel:m,placeholder:"APP1016032231178585590501450"})]}),f&&(0,s.jsxs)(n,{marginTop:1,flexDirection:"column",children:[(0,s.jsx)(t,{color:o.red,children:f}),(0,s.jsx)(t,{color:o.dim,children:"Enter a valid app id \u2014 copy it from your cloud uploads."})]}),(0,s.jsx)(B,{bindings:[{keys:"\u21B5",label:"use this app"}],escBackLabel:"back"})]})}export{he as a,Pe as b,Oe as c,Ye as d,qe as e};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as ae}from"./chunk-MMBBQ4OZ.js";import{j as R}from"./chunk-
|
|
2
|
+
import{a as ae}from"./chunk-MMBBQ4OZ.js";import{j as R}from"./chunk-6ZHEIBI5.js";import{c as ie,e as ne,i as re,j as K}from"./chunk-Z7S3IWUX.js";import{d as $,e as oe}from"./chunk-4JOD47QI.js";import{a as se}from"./chunk-RZ4F3BHX.js";import{spawn as ze}from"child_process";import{closeSync as Xe,existsSync as Ge,mkdirSync as We,openSync as Ye,readFileSync as Ze,rmSync as Qe}from"fs";import{homedir as ge}from"os";import{dirname as X,join as S}from"path";import{access as Re,mkdir as de,readFile as Le}from"fs/promises";import{homedir as Ce}from"os";import{arch as Fe,platform as Be}from"process";import{join as M}from"path";var Ue=35,qe="google_apis",Ve="KaneCLI_Pixel_API35",He="KaneAI_Pixel_API35";function Ht(t){return t===He?Ve:t}var je=1;function Ke(t,e){return t==="darwin"&&e==="arm64"?"arm64-v8a":"x86_64"}function Je(){return{home:Ce(),os:Be,arch:Fe}}async function le(t){try{return await Re(t),!0}catch{return!1}}var J=class{deps;constructor(e={}){this.deps={...Je(),...e}}paths(){let e=M(this.deps.home,".testmuai","kaneai","mobile"),r=M(e,"android-sdk");return{root:r,emulatorDir:M(r,"emulator"),systemImageDir:M(r,"system-images",`android-${Ue}`,qe,Ke(this.deps.os,this.deps.arch)),avdHome:M(e,"avd"),manifest:M(r,"sdk-manifest.json")}}environment(){let e=this.paths();return{ANDROID_HOME:e.root,ANDROID_SDK_ROOT:e.root,ANDROID_AVD_HOME:e.avdHome}}async ensureSdkRootMarkers(){let e=this.paths().root;await de(M(e,"platforms"),{recursive:!0}),await de(M(e,"platform-tools"),{recursive:!0})}async status(){let e=this.paths(),r=null;try{r=JSON.parse(await Le(e.manifest,"utf8"))}catch{}if(!r||r.schemaVersion!==je)return{emulator:!1,systemImage:!1};let o=this.deps.os==="win32"?"emulator.exe":"emulator";return{emulator:!!r.components.emulator&&await le(M(e.emulatorDir,o)),systemImage:!!r.components.systemImage&&await le(M(e.systemImageDir,"system.img"))}}},ue;function B(){return ue??=new J,ue}var G="android",et="http://127.0.0.1:4723/status",tt=2e3,z=(()=>{let t=Number(process.env.KANE_CLI_EMULATOR_BOOT_TIMEOUT_MS);return Number.isFinite(t)&&t>=3e4?t:3e5})(),it=1e3,nt=3e5;var rt=5,ce="Run `kane-cli doctor --target emulator --install` to install the managed Appium tree.",st={device:"ready",unauthorized:"unauthorized",offline:"offline"};function ot(t){let e={};for(let r of t){let o=r.indexOf(":");o<=0||(e[r.slice(0,o)]=r.slice(o+1))}return e}function at(t){let e=[];for(let r of t.split(`
|
|
3
3
|
`)){let o=r.trim();if(!o||o.startsWith("*"))continue;let u=o.toLowerCase();if(u.startsWith("list of devices")||u.startsWith("adb server"))continue;let g=o.split(/\s+/),p=g[0],w=g[1];if(!p||!w)continue;let v=ot(g.slice(2)),x=/^(localhost|127\.0\.0\.1):\d{1,5}$/.test(p),P=/^[A-Za-z0-9._-]+:\d{1,5}$/.test(p),C=/^sdk_/.test(v.product??"")||/^sdk_/.test(v.model??"")||/^emu/.test(v.device??"");if(!p.startsWith("emulator-")&&!x&&!(P&&C))continue;let l=v.model?v.model.replace(/_/g," "):void 0;e.push({platform:G,kind:"emulator",id:p,displayName:l??p,state:st[w]??"offline"})}return e}function me(t){let e=[];for(let r of t.split(`
|
|
4
4
|
`)){let o=r.trim();o&&/^[A-Za-z0-9._-]+$/.test(o)&&(e.includes(o)||e.push(o))}return e}function dt(t){for(let e of t.split(`
|
|
5
5
|
`)){let r=e.trim();if(!(!r||r==="OK"))return r}}function lt(t){let e=/^Version\s+(\S+)/m.exec(t);return e?.[1]?e[1].split("-")[0]:/Android Debug Bridge version\s+(\S+)/.exec(t)?.[1]}function ut(t){let e=[];for(let r of t.split(`
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as Y,b as Z,c as ee,d as ne,e as te}from"./chunk-
|
|
3
|
-
`;try{this.proc?.child.stdin?.write(
|
|
4
|
-
${g}`:""}`))}}}}};var p=Ce(Pe(),1);function le(i){let n={cdp_endpoint:i.cdp_endpoint,ws_endpoint:i.ws_endpoint,width:i.width,height:i.height,headless:i.headless,model:i.model,max_steps:i.max_steps,network_ws:i.network_ws,network_sse:i.network_sse,session_id:i.session_id};return i.device&&(n.device=i.device),i.auth&&(n.auth=i.auth),i.project_id&&(n.project_id=i.project_id),i.disable_ask_user&&(n.disable_ask_user=!0),i.username&&(n.username=i.username),i.access_key&&(n.access_key=i.access_key),n}function j(i,n){let
|
|
5
|
-
`).includes(
|
|
6
|
-
`)),v(!1),h(a=>a.map(t=>t.status==="running"?{...t,status:"failed",phase:void 0}:t)),P("runner","Runner died mid-run"),y.current=null,E.current=null,$(a=>a+1)});O.current=q,q.finally(()=>{O.current===q&&(O.current=null)})},[i,n,
|
|
2
|
+
import{a as Y,b as Z,c as ee,d as ne,e as te}from"./chunk-5LLXVZXW.js";import{b as ie,c as re}from"./chunk-YFQGOOF7.js";import{n as X,p as P}from"./chunk-RSSOJ3L2.js";import{a as Pe}from"./chunk-6YGTRKDT.js";import{e as Ce}from"./chunk-UR6MHSHU.js";function se(i){return{command:"start",...i}}function oe(i,n,s){return{command:"run",run_id:i,kind:n,...s}}function ae(i){return{command:"cancel",...i?{run_id:i}:{}}}function ue(i){return{command:"ask_user_response",answer:i}}function de(i={}){return{command:"shutdown",...i.testStatus?{test_status:i.testStatus,remark:i.remark??""}:{}}}var z=Symbol("run-queue-end"),G=class{items=[];waiting=null;ended=!1;error=null;push(n){if(this.waiting){let{resolve:s}=this.waiting;this.waiting=null,s(n)}else this.items.push(n)}end(){if(this.ended=!0,this.waiting){let{resolve:n}=this.waiting;this.waiting=null,n(z)}}fail(n){if(this.error=n,this.waiting){let{reject:s}=this.waiting;this.waiting=null,s(n)}}next(){return this.items.length>0?Promise.resolve(this.items.shift()):this.error?Promise.reject(this.error):this.ended?Promise.resolve(z):new Promise((n,s)=>{this.waiting={resolve:n,reject:s}})}},D=class{env;runner;log;sessionId;spawnFn;proc=null;activeRun=null;pendingReady=null;shuttingDown=!1;finalized=!1;exitInfo=null;exitedUnexpectedly=!1;exitResolve;exited;constructor(n){this.env=n.env,this.runner=n.runner,this.log=n.log,this.sessionId=n.sessionId,this.spawnFn=n.spawn??Z;let s;this.exited=new Promise(l=>{s=l}),this.exitResolve=s}async start(n){if(this.proc)throw new Error("PersistentRunner.start called twice");this.proc=this.spawnFn({env:this.env,runner:this.runner,log:this.log,sessionId:this.sessionId}),this.consume();let s=new Promise((l,g)=>{this.pendingReady={resolve:l,reject:g}});this.writeCommand(se(n)),await s}async*run(n,s,l){if(!this.proc)throw new Error("PersistentRunner.run called before start");if(this.finalized)throw new Error(`v16-runner is not running (exited code=${this.exitInfo?.code??"null"}, signal=${this.exitInfo?.signal??"none"}) \u2014 cannot start run '${n}'`);if(this.activeRun)throw new Error(`PersistentRunner.run overlap: '${this.activeRun.runId}' still in flight`);let g=new G,w={runId:n,queue:g};this.activeRun=w,this.writeCommand(oe(n,s,l));try{for(;;){let v=await g.next();if(v===z||(yield v,v.type==="run_end"&&(v.run_id===void 0||v.run_id===n)))break}}finally{this.activeRun===w&&(this.activeRun=null)}}sendUserResponse(n){this.writeCommand(ue(n))}cancel(n){this.writeCommand(ae(n))}kill(){this.proc?.child.kill("SIGTERM")}async shutdown(n={}){this.shuttingDown=!0,this.proc&&(this.writeCommand(de(n)),await this.exited)}get stderr(){return this.proc?.getStderr()??""}get diedUnexpectedly(){return this.exitedUnexpectedly}writeCommand(n){let s=JSON.stringify(n)+`
|
|
3
|
+
`;try{this.proc?.child.stdin?.write(s)}catch{}}async consume(){if(!this.proc)return;try{for await(let l of this.proc.events){if(l.type==="ready"){this.onReady();continue}if(l.type==="error"&&this.pendingReady){this.onStartError(l.message);continue}this.routeEvent(l)}}catch(l){this.log?.("error","PERSISTENT_RUNNER_STREAM_ERROR","Runner stdout stream errored",{error:l instanceof Error?l.message:String(l)})}let{code:n,signal:s}=await this.proc.exited;this.onExit(n,s)}onReady(){if(this.pendingReady){let{resolve:n}=this.pendingReady;this.pendingReady=null,n()}}onStartError(n){if(!this.pendingReady)return;let{reject:s}=this.pendingReady;this.pendingReady=null,s(new Error(`failed to start: ${n??"unknown error"}`))}routeEvent(n){let s=this.activeRun;if(!s){this.log?.("warn","PERSISTENT_RUNNER_ORPHAN_EVENT","Runner event with no active run",{event_type:n.type});return}s.queue.push(n)}onExit(n,s){if(!this.finalized){if(this.finalized=!0,this.exitInfo={code:n,signal:s},this.shuttingDown||(this.exitedUnexpectedly=!0),this.exitResolve({code:n,signal:s}),this.pendingReady){let{reject:l}=this.pendingReady;this.pendingReady=null,l(new Error(`v16-runner exited before ready (code=${n}, signal=${s??"none"})`))}if(this.activeRun){let{queue:l}=this.activeRun;if(this.activeRun=null,this.shuttingDown)l.end();else{let g=this.proc?.getStderr()?.slice(-500)??"";l.fail(new Error(`v16-runner exited unexpectedly mid-run (code=${n}, signal=${s??"none"})${g?`
|
|
4
|
+
${g}`:""}`))}}}}};var p=Ce(Pe(),1);function le(i){let n={cdp_endpoint:i.cdp_endpoint,ws_endpoint:i.ws_endpoint,width:i.width,height:i.height,headless:i.headless,model:i.model,max_steps:i.max_steps,network_ws:i.network_ws,network_sse:i.network_sse,session_id:i.session_id};return i.device&&(n.device=i.device),i.auth&&(n.auth=i.auth),i.project_id&&(n.project_id=i.project_id),i.disable_ask_user&&(n.disable_ask_user=!0),i.username&&(n.username=i.username),i.access_key&&(n.access_key=i.access_key),n}function j(i,n){let s=null,l=(g,w)=>{for(let v=0;v<g.length;v++){let _=g[v],h=[...w,v];n(_)&&(s===null||h.length>s.length)&&(s=h),_.children&&_.children.length>0&&l(_.children,h)}};return l(i,[]),s}function N(i,n,s){if(n.length===0)return[...i];let l=n[0],g=[...i],w=g[l];if(n.length===1)g[l]=s(w);else{let v=n.slice(1),_=N(w.children??[],v,s);g[l]={...w,children:_}}return g}function ce(){return{steps:[],maxOrdinal:0}}function je(i,n){if(n.type==="run_start"&&n.child_id)return n.environment?.resolution?{...i,resolution:n.environment.resolution}:i;if(n.type==="run_start"){let s=re(i.runnerEnvironment,ie(n.environment));if(s)return{...i,runnerEnvironment:s,...s.resolution?{resolution:s.resolution}:{}}}if(n.type==="step_end"&&typeof n.ordinal=="number"&&n.id){let s={id:n.id,ordinal:n.ordinal,status:n.status,...n.kind?{kind:n.kind}:{},...typeof n.duration=="number"?{duration_ms:Math.round(n.duration*1e3)}:{},...typeof n.action_id=="string"&&n.action_id?{action_id:n.action_id}:{}};return{...i,steps:[...i.steps,s],maxOrdinal:Math.max(i.maxOrdinal,n.ordinal)}}return i}function K(i){let n=i.indexOf(": ");return n>0&&n<15?i.slice(n+2):i}function V(i){return i.map(n=>{let s=n.children?V(n.children):n.children;return n.status==="running"?{...n,status:"stopped",phase:void 0,children:s}:s!==n.children?{...n,children:s}:n})}function ze(i,n,s,l,g){let[w,v]=(0,p.useState)(!1),[_,h]=(0,p.useState)([]),[pe,T]=(0,p.useState)(null),[he,B]=(0,p.useState)(null),[fe,k]=(0,p.useState)(null),[me,W]=(0,p.useState)(null),[ve,J]=(0,p.useState)([]),[ge,H]=(0,p.useState)(null),[Re,Se]=(0,p.useState)(void 0),[ye,$]=(0,p.useState)(0),y=(0,p.useRef)(null),E=(0,p.useRef)(null),S=(0,p.useRef)(null),b=(0,p.useRef)(0),F=(0,p.useRef)(!1),U=(0,p.useRef)(ce()),O=(0,p.useRef)(null),we=(0,p.useCallback)(async(m,x)=>{let Q=O.current;if(Q)try{await Q}catch{}h([]),T(null),B(null),k(null),W(null),J([]),H(null),Se(m.max_steps),v(!0),S.current=null,b.current=0,U.current=ce();let I=y.current;if(I&&E.current!==m.session_id){try{I.kill()}catch{}y.current=null,E.current=null,$(e=>e+1),I=null}if(!I){let e=Y();if(!e){k("v16-runner not found. Build the binary with `cd v16-runner && python build.py` or ensure Python is available."),v(!1);return}let d=ne({environment:x?.environment,mode:x?.mode,assertionMode:x?.assertionMode,finalValidation:x?.finalValidation,username:m.username,accessKey:m.access_key,sessionId:m.session_id});m.device?.platform&&await ee(d,m.device);let u=new D({env:d,runner:e,log:x?.log,sessionId:m.session_id});y.current=u,E.current=m.session_id,I=u,X("runner",()=>{try{u.kill()}catch{}});let o=le(m);try{await u.start(o)}catch(a){k(a instanceof Error?a.message:String(a)),v(!1),P("runner","Runner start failed"),y.current=null,E.current=null,$(t=>t+1);return}}let M={...m};delete M.run_id,te(M,{environment:x?.environment});let ke=`run-${m.run_index}`,Ie=m.mode==="replay"?"replay":"author",L=I,q=(async()=>{F.current=!1;for await(let e of L.run(ke,Ie,M)){if(F.current)break;switch(U.current=je(U.current,e),e.type){case"run_start":if(e.child_id)break;if(S.current&&!S.current.isSingleFlow){let d=b.current;b.current++,h(u=>u.map((o,a)=>a===d?{...o,status:"running"}:o.status==="running"&&!o.children?.some(t=>t.status==="running")?{...o,status:o.children?.some(t=>t.status==="failed")?"failed":"passed"}:o))}break;case"bifurcation":{let d=e.flows??[],u=e.count??d.length,o={flows:d,isSingleFlow:e.is_single_flow??u<=1};W(o),S.current=o,b.current=0,h(d.map((a,t)=>({index:t+1,objective:a??`Flow ${t+1}`,status:"pending"})));break}case"step_start":{n?.("STEP_START",`Step ${e.index} started`,{index:e.index,objective:e.objective,child_id:e.child_id});let d=e.index,u=e.objective??`Step ${d}`,o=e.child_id,a=S.current&&!S.current.isSingleFlow;if(o)h(t=>{let r=j(t,c=>c.branchChildId===o)??j(t,c=>c.status==="running");return r?N(t,r,c=>{let f=(c.children??[]).map(R=>R.status==="running"&&R.childId===o?{...R,status:"stopped",phase:void 0}:R);return f.push({index:d,objective:u,status:"running",childId:o}),{...c,children:f}}):t});else if(a){let t=Math.max(0,b.current-1);h(r=>{let c=[...r];if(t>=c.length)return r;let f={...c[t]},C=[...f.children??[]].map(A=>A.status==="running"&&A.childId===void 0?{...A,status:"stopped",phase:void 0}:A);return C.push({index:d,objective:u,status:"running"}),f.children=C,f.status="running",c[t]=f,c})}else h(t=>{let r=V(t);return r.some(f=>f.index===d)?r.map(f=>f.index===d?{...f,status:"running",objective:u}:f):[...r,{index:d,objective:u,status:"running"}]});break}case"step_event":{n?.("STEP_EVENT",`Step ${e.index} ${e.event}`,{index:e.index,phase:e.event,action_type:e.action_type,detail:e.detail,child_id:e.child_id});let d=e.child_id,u=S.current&&!S.current.isSingleFlow;if(e.event==="cm_init"&&e.checkpoint_count!=null){J(o=>[...o,e.checkpoint_count]);break}if(e.event==="replay_started"){H({recordingLength:e.recording_length??0});break}if(e.event==="reasoning"&&e.detail&&e.detail!=="reasoning"&&s?.(e.detail),d){let o=t=>{if(t.index!==e.index||t.childId!==d)return t;let r={phase:e.event};return e.event==="reasoning"&&e.detail&&e.detail!=="reasoning"&&(r.objective=e.detail),e.action_type&&(r.actionType=e.action_type),{...t,...r}},a=t=>t.map(r=>{let c=o(r);return c!==r?c:r.children&&r.children.length>0?{...r,children:a(r.children)}:r});h(t=>t.map(r=>r.children?{...r,children:a(r.children)}:r))}else if(u){let o=Math.max(0,b.current-1);h(a=>{let t=[...a];if(o>=t.length)return a;let r={...t[o]},c=[...r.children??[]];if(!c.some(R=>R.index===e.index&&R.childId===void 0))c.push({index:e.index,objective:`Step ${e.index}`,status:"running",phase:e.event,actionType:e.action_type});else for(let R=0;R<c.length;R++){if(c[R].index!==e.index||c[R].childId!==void 0)continue;let C={phase:e.event};e.event==="reasoning"&&e.detail&&e.detail!=="reasoning"&&(C.objective=e.detail),e.action_type&&(C.actionType=e.action_type),c[R]={...c[R],...C}}return r.children=c,t[o]=r,t})}else h(o=>o.some(t=>t.index===e.index)?o.map(t=>{if(t.index!==e.index)return t;let r={phase:e.event};return e.event==="reasoning"&&e.detail&&e.detail!=="reasoning"&&(r.objective=e.detail),e.action_type&&(r.actionType=e.action_type),{...t,...r}}):[...V(o),{index:e.index,objective:`Step ${e.index}`,status:"running",phase:e.event,actionType:e.action_type}]);break}case"step_end":{n?.("STEP_END",`Step ${e.index} ${e.status}`,{index:e.index,status:e.status,duration:e.duration,summary:e.summary,child_id:e.child_id}),l?.();let d=e.child_id,u=S.current&&!S.current.isSingleFlow;if(d){let o=t=>t.index===e.index&&t.childId===d?{...t,status:e.status,duration:e.duration,phase:void 0,objective:t.objective.startsWith("Step ")?K(e.summary||t.objective):t.objective}:t,a=t=>t.map(r=>{let c=o(r);return c!==r?c:r.children&&r.children.length>0?{...r,children:a(r.children)}:r});h(t=>t.map(r=>r.children?{...r,children:a(r.children)}:r))}else if(u){let o=Math.max(0,b.current-1);h(a=>{let t=[...a];if(o>=t.length)return a;let r={...t[o]},c=(r.children??[]).map(f=>f.index===e.index&&f.childId===void 0?{...f,status:e.status,duration:e.duration,phase:void 0,objective:f.objective.startsWith("Step ")?K(e.summary||f.objective):f.objective}:f);return r.children=c,t[o]=r,t})}else h(o=>o.map(a=>a.index===e.index?{...a,status:e.status,duration:e.duration,phase:void 0,objective:a.objective.startsWith("Step ")?K(e.summary||a.objective):a.objective}:a));{let a=S.current&&!S.current.isSingleFlow?Math.max(0,b.current-1):0,t=typeof e.ordinal=="number"&&e.id?{ordinal:e.ordinal,id:e.id}:void 0;i?.(e.index,a,e.child_id,t)}break}case"child_agent_start":{let d=e.objective??"",u=e.child_id;h(o=>{let a=j(o,t=>t.status==="running");return a?N(o,a,t=>({...t,objective:`${d} (branch)`,phase:`child: ${d.slice(0,50)}`,branchObjective:d,branchChildId:u})):o});break}case"child_agent_end":{let d=e.child_id,u=`child ${e.success?"done":"failed"}`;h(o=>{let a=j(o,t=>t.branchChildId===d);return a?N(o,a,t=>({...t,phase:u})):o.map(t=>t.phase?.startsWith("child:")?{...t,phase:u}:t)});break}case"describe_trigger":g?.(e);break;case"ask_user":T(e.question??"");break;case"run_end":h(d=>d.map(u=>u.status==="running"?{...u,status:e.status,phase:void 0}:u)),v(!1),B(e);break;case"error":v(!1),k(e.message??"Runner error"),h(d=>d.map(u=>u.status==="running"?{...u,status:"failed",phase:void 0}:u));break}}})().catch(e=>{if(y.current!==L)return;let u=[e instanceof Error?e.message:String(e)],o=L.stderr;o&&!u.join(`
|
|
5
|
+
`).includes(o)&&u.push(o),k(u.join(`
|
|
6
|
+
`)),v(!1),h(a=>a.map(t=>t.status==="running"?{...t,status:"failed",phase:void 0}:t)),P("runner","Runner died mid-run"),y.current=null,E.current=null,$(a=>a+1)});O.current=q,q.finally(()=>{O.current===q&&(O.current=null)})},[i,n,s,l,g]),xe=(0,p.useCallback)(m=>{y.current?.sendUserResponse(m),T(null)},[]),_e=(0,p.useCallback)(()=>{let m=y.current;m&&(m.cancel(),v(!1),T(null))},[]),be=(0,p.useCallback)(async()=>{let m=y.current;if(m){try{await Promise.race([m.shutdown(),new Promise(x=>setTimeout(x,5e3))])}catch{}P("runner","Runner shut down"),y.current=null,E.current=null,$(x=>x+1)}},[]),Ee=(0,p.useCallback)(()=>{h([]),B(null),k(null)},[]);return(0,p.useEffect)(()=>()=>{F.current=!0,P("runner","Component unmounted"),y.current=null,E.current=null},[]),{isRunning:w,steps:_,askingUser:pe,lastRunEnd:he,runError:fe,bifurcationInfo:me,cmInitCounts:ve,replayInfo:ge,maxSteps:Re,sessionGen:ye,startRun:we,sendAnswer:xe,cancelRun:_e,shutdownRunner:be,clearLastRun:Ee,getEvidenceState:()=>U.current}}export{D as a,le as b,ce as c,je as d,ze as e};
|
|
@@ -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-ICPCU7AL.js";import{y as s}from"./chunk-MI6UFDRC.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};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{g as o,h as a}from"./chunk-
|
|
2
|
+
import{g as o,h as a}from"./chunk-TEYEMBS7.js";import{mkdirSync as p,writeFileSync as f,chmodSync as d,existsSync as m}from"fs";var y={darwin:"https://downloads.lambdatest.com/hyperexecute/darwin/hyperexecute",linux:"https://downloads.lambdatest.com/hyperexecute/linux/hyperexecute",win32:"https://downloads.lambdatest.com/hyperexecute/windows/hyperexecute.exe"};function h(s){let t=y[s];if(!t)throw new Error(`unsupported platform for hyperexecute: ${s}`);return t}async function g(s,t={}){let i=t.platform??process.platform,u=t.existsImpl??m,c=t.fetchImpl??(r=>fetch(r)),e=a(s);if(u(e))return{status:"present",path:e};try{let r=h(i),n=await c(r);if(!n.ok)return{status:"failed",path:e,error:`download failed: HTTP ${n.status}`};let l=Buffer.from(await n.arrayBuffer());return p(o(s),{recursive:!0}),f(e,l),d(e,493),{status:"downloaded",path:e}}catch(r){return{status:"failed",path:e,error:r instanceof Error?r.message:String(r)}}}export{h as a,g as b};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{b as V,c as H,d as W,e as ie,f as se}from"./chunk-SRJCAJYM.js";import{a as le}from"./chunk-FHH7AFSC.js";import{e as ee}from"./chunk-7EVSM4V7.js";import{a as te}from"./chunk-YZZJUMKN.js";import{a as oe}from"./chunk-P6PNLVNS.js";import{a as re}from"./chunk-X3YTLBZR.js";import{b as Y}from"./chunk-X3ULX7LO.js";import{b as Z}from"./chunk-N5ZEI42N.js";import{a as I}from"./chunk-2KVECC36.js";import{a as T,b as j,d as ne}from"./chunk-VE3SUJMA.js";import{b as Q}from"./chunk-TZXXJWHA.js";import{r as b}from"./chunk-RSSOJ3L2.js";import{i as J}from"./chunk-Z7S3IWUX.js";import{a as D}from"./chunk-DGQKGGCB.js";import{a as B,e as K}from"./chunk-EYOCNMUM.js";import{a as z}from"./chunk-WTRUUT4E.js";import{a as q}from"./chunk-HCBYKLMW.js";import{a as c,b as u,i as L,j as G}from"./chunk-C44QQJR4.js";import{a as ve}from"./chunk-6YGTRKDT.js";import{e as F}from"./chunk-UR6MHSHU.js";var s=F(ve(),1);var o=F(q(),1);function Xe({resultRef:x,mode:g="singleshot",loginCompleteRef:d}){let{exit:p}=G(),A=(0,s.useRef)(new z),E=(0,s.useRef)(new te),v=(0,s.useRef)(new ee),n=A.current,l=E.current,O=v.current,ae=V(),[h,f]=(0,s.useState)(g==="login"?"login":"gate"),[M,ce]=(0,s.useState)(null),[xe,R]=(0,s.useState)(null),[Pe,$]=(0,s.useState)(null),[N,ue]=(0,s.useState)(null),[X,S]=(0,s.useState)([]),P=(0,s.useCallback)((e,t,i,r)=>O.log(e,t,i,r),[O]),we=(0,s.useCallback)((e,t)=>{e?T(n,l,e,t):l.save({project_id:null,project_name:null,folder_id:null,folder_name:null})},[n,l]),C=(0,s.useCallback)(()=>{if(g==="login")d&&(d.current=!0),p();else{let e=l.load().mobile,t=B(e?.tui_target,e?.default_target?.kind),i=(t.kind==="unset"||t.kind==="choose-mobile")&&Q();f(i?"target":"input")}},[g,p,d,l]),k=(0,s.useCallback)((e,t)=>{let i=T(n,l,e,t);if(g==="login"){f("ensure-project");return}ne(i)?C():i.projectId?f("ensure-folder"):f("ensure-project")},[n,l,C,g]);L((e,t)=>{t.ctrl&&e==="c"&&b(0,"Ctrl+C exit")});let U=(0,s.useRef)(!1);s.default.useEffect(()=>{U.current||(U.current=!0,g!=="login"&&se(n,P).then(e=>{ce(e),e.status==="authenticated"?k(e.result.profile,e.result.env):e.status==="needs_pick"?f("pick"):(R(e.profile??null),$(e.env??null),f("login"))}).catch(e=>{ue(`Auth check failed: ${e instanceof Error?e.message:String(e)}`)}))},[n,P]);let fe=(0,s.useCallback)(e=>{x.current={objective:e},p()},[x,p]),de=(0,s.useCallback)(async(e,t)=>{n.setActiveProfile(e),n.setDefaultEnv(t),(await ie(n,e,t,P)).status==="authenticated"?k(e,t):(R(e),$(t),f("login"))},[n,P,k]),w=(0,s.useCallback)(()=>{let e=n.getActiveProfile(),t=n.getDefaultEnv();if(!e)return null;let i=D(t),r=n.loadBasicAuth(e,t);return new oe(i.controllerBaseUrl,async()=>n.loadCredentials(e,t)?.access_token??null,r,P)},[n,P]),ge=(0,s.useCallback)(async()=>{let e=w();if(!e)return null;let t=e.cached??await e.resolve();if(!t)return null;let i=D(n.getDefaultEnv()),r=new I(i.tmsBaseUrl,t.username,t.access_key);try{let m=(await r.listProjects()).find(_=>_.name==="KaneAI Generated");if(m)return{id:m.project_id,name:m.name};let y=await r.createProject("KaneAI Generated");return{id:y.id,name:y.name}}catch{return null}},[w,n]),me=(0,s.useCallback)(async e=>{let t=w();if(!t)return null;let i=t.cached??await t.resolve();if(!i)return null;let r=D(n.getDefaultEnv()),a=new I(r.tmsBaseUrl,i.username,i.access_key);try{let y=(await a.listFolders(e)).find(pe=>pe.name==="Untitled");if(y)return{id:y.id,name:y.name};let _=await a.createFolder(e,"Untitled");return{id:_.id,name:_.name}}catch{return null}},[w,n]);if(h==="gate")return(0,o.jsx)(c,{paddingX:1,children:(0,o.jsx)(u,{color:"yellow",children:"Checking authentication..."})});if(N)return(0,o.jsxs)(c,{flexDirection:"column",paddingX:1,children:[(0,o.jsx)(u,{color:"red",children:N}),(0,o.jsx)(u,{color:"gray",children:"Press Ctrl+C to exit."})]});if(h==="pick"&&M?.status==="needs_pick")return(0,o.jsx)(he,{profiles:M.profiles,onSelect:de});if(h==="login")return(0,o.jsx)(W,{devMode:process.env.KANE_DEV_MODE==="1",profiles:n.listProfiles(),onBasicLogin:async(e,t,i,r)=>{let{validateBasicAuth:a}=await import("./validate-basic-X46S6YL2.js");await a(t,i,r),n.saveBasicAuth(e,t,{username:i,access_key:r}),n.setActiveProfile(e),n.setDefaultEnv(t)},onOAuthLogin:async(e,t)=>{let{LoginFlow:i}=await import("./login-flow-XJARBECG.js");n.setDefaultEnv(t),n.setActiveProfile(e),await new i(e,t,n).login()},onComplete:(e,t)=>{R(e),$(t),n.setActiveProfile(e),n.setDefaultEnv(t),k(e,t)},onCancel:()=>{b(0,"Login cancelled")}});if(h==="ensure-project"){let e=n.getActiveProfile()??"default",t=n.getDefaultEnv(),i=()=>{if(g==="login"){f("ensure-folder");return}T(n,l,e,t).folderId?C():f("ensure-folder")};return(0,o.jsxs)(c,{flexDirection:"column",children:[(0,o.jsx)(c,{paddingX:1,marginBottom:1,children:(0,o.jsx)(u,{color:"yellow",children:"Project & folder are required to save tests \xB7 Esc to use defaults \xB7 Ctrl+C to exit"})}),(0,o.jsx)(Y,{resolver:w(),currentProjectId:l.load().project_id,env:t,onSelect:(r,a)=>{j(n,l,e,t,{projectId:r,projectName:a}),S(m=>[...m,`\u2713 Project: ${a} (${r})`]),i()},onCancel:async()=>{let r=await ge();r&&(j(n,l,e,t,{projectId:r.id,projectName:r.name}),S(a=>[...a,`\u2713 Default project: ${r.name} (${r.id})`]),i())}})]})}if(h==="ensure-folder"){let e=n.getActiveProfile()??"default",t=n.getDefaultEnv(),i=n.loadProfileConfig(e,t);return(0,o.jsxs)(c,{flexDirection:"column",children:[(0,o.jsx)(c,{paddingX:1,marginBottom:1,children:(0,o.jsx)(u,{color:"yellow",children:"Project & folder are required to save tests \xB7 Esc to use defaults \xB7 Ctrl+C to exit"})}),(0,o.jsx)(Z,{resolver:w(),projectId:i?.project_id??"",currentFolderId:l.load().folder_id,env:t,onSelect:(r,a)=>{j(n,l,e,t,{folderId:r,folderName:a}),S(m=>[...m,`\u2713 Folder: ${a} (${r})`]),C()},onCancel:async()=>{if(!i?.project_id)return;let r=await me(i.project_id);r&&(j(n,l,e,t,{folderId:r.id,folderName:r.name}),S(a=>[...a,`\u2713 Default folder: ${r.name} (${r.id})`]),C())}})]})}if(h==="target"){let e=B(l.load().mobile?.tui_target,l.load().mobile?.default_target?.kind).kind==="choose-mobile";return(0,o.jsx)(c,{paddingX:1,children:(0,o.jsx)(le,{mode:e?"mobile-only":"all",onSelect:t=>{l.setMobile({tui_target:t}),f("input")},onCancel:()=>f("input")})})}if(h==="input"){let e=l.load().mobile,t=B(e?.tui_target,e?.default_target?.kind),i=(()=>{if(t.kind==="emulator"||t.kind==="simulator"){let r=J(e?.default_target)??"(no device)",a=re(e?.default_app)??"(no app)";return`Config: ${K(t.kind)} \xB7 ${r} \xB7 ${a}`}return"Config: Desktop \xB7 Chrome"})();return(0,o.jsxs)(c,{flexDirection:"column",children:[X.length>0&&(0,o.jsx)(c,{flexDirection:"column",paddingX:1,marginBottom:1,children:X.map((r,a)=>(0,o.jsx)(u,{color:"green",children:r},a))}),(0,o.jsx)(c,{paddingX:1,children:(0,o.jsx)(u,{color:"gray",children:i})}),(0,o.jsx)(H,{onSubmit:fe,onEscape:()=>b(0,"User pressed Escape"),history:ae,placeholder:"Type an objective..."})]})}return(0,o.jsx)(o.Fragment,{})}function he({profiles:x,onSelect:g}){let[d,p]=(0,s.useState)(0),[A,E]=(0,s.useState)(!1);return L((v,n)=>{if(!A){if(n.escape){b(0,"Profile picker cancelled");return}if(n.upArrow&&d>0&&p(l=>l-1),n.downArrow&&d<x.length-1&&p(l=>l+1),n.return){E(!0);let l=x[d];g(l.profile,l.env).catch(()=>E(!1))}}}),(0,o.jsxs)(c,{flexDirection:"column",paddingX:1,children:[(0,o.jsx)(u,{color:"#ff9500",bold:!0,children:"Select a profile:"}),(0,o.jsx)(c,{marginTop:1,flexDirection:"column",children:x.map((v,n)=>(0,o.jsxs)(u,{children:[n===d?"\u276F ":" ",(0,o.jsx)(u,{color:n===d?"#ff9500":"white",bold:n===d,children:v.profile}),(0,o.jsxs)(u,{color:"gray",children:[" [",v.env,"]"]})]},`${v.profile}-${v.env}`))}),A&&(0,o.jsx)(c,{marginTop:1,children:(0,o.jsx)(u,{color:"yellow",children:"Validating credentials..."})})]})}export{Xe as a};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as y}from"./chunk-
|
|
2
|
+
import{a as y}from"./chunk-DGQKGGCB.js";import{createServer as b}from"http";import{createReadStream as C,promises as S}from"fs";import{randomBytes as R}from"crypto";var u="127.0.0.1";function A(n,e){if(!n)return null;let o=/^bytes=(\d*)-(\d*)$/.exec(n.trim());if(!o)return null;let[,a,r]=o;if(a===""&&r==="")return null;if(a===""){let i=Number(r);return i===0||e===0?"unsatisfiable":{start:Math.max(0,e-i),end:e-1}}let t=Number(a);if(t>=e)return"unsatisfiable";let c=r===""?e-1:Math.min(Number(r),e-1);return c<t?null:{start:t,end:c}}async function I(n){let e=R(16).toString("hex"),o=b((r,t)=>{H(r,t,n,e).catch(()=>t.destroy())});await new Promise((r,t)=>{o.once("error",t),o.listen(n.port??0,u,()=>{o.removeListener("error",t),r()})});let a=o.address().port;return{port:a,urlFor:r=>`http://${u}:${a}/${e}/${encodeURIComponent(r)}`,close:()=>new Promise(r=>{o.close(()=>r()),o.closeAllConnections()})}}async function H(n,e,o,a){let r=n.url??"/",t=s=>{try{o.log?.("warn","EVIDENCE_SERVE_DENIED",{reason:s,path:r})}catch{}};if(n.headers.host!==`${u}:${n.socket.localPort}`){t("host_mismatch"),e.writeHead(403).end();return}let c=n.headers.origin;if(c!==void 0&&!o.allowedOrigins.includes(c)){t("origin_denied"),e.writeHead(403).end();return}let i=c?{"Access-Control-Allow-Origin":c,Vary:"Origin","Access-Control-Expose-Headers":"Content-Range, Content-Length"}:{};if(n.method==="OPTIONS"){let s={...i,"Access-Control-Allow-Methods":"GET, HEAD, OPTIONS","Access-Control-Allow-Headers":"range","Access-Control-Max-Age":"86400"};n.headers["access-control-request-private-network"]==="true"&&(s["Access-Control-Allow-Private-Network"]="true"),e.writeHead(204,s).end();return}if(n.method!=="GET"&&n.method!=="HEAD"){e.writeHead(405,i).end();return}let v;try{let s=new URL(n.url??"/",`http://${u}`).pathname.split("/");if(s.length!==3||s[1]!==a){t("bad_token"),e.writeHead(404,i).end();return}v=decodeURIComponent(s[2])}catch{t("not_found"),e.writeHead(404,i).end();return}let g=o.packs.get(v);if(!g){t("not_found"),e.writeHead(404,i).end();return}let d;try{let s=await S.stat(g);if(!s.isFile())throw new Error("not a file");d=s.size}catch{t("not_found"),e.writeHead(404,i).end();return}let h={...i,"Accept-Ranges":"bytes","Content-Type":"application/zip","Cache-Control":"no-store"};if(n.method==="HEAD"){e.writeHead(200,{...h,"Content-Length":String(d)}).end();return}let l=A(n.headers.range,d);if(l==="unsatisfiable"){t("unsatisfiable"),e.writeHead(416,{...i,"Content-Range":`bytes */${d}`}).end();return}let[m,p,w]=l===null?[0,d-1,200]:[l.start,l.end,206],E={...h,"Content-Length":String(p-m+1)};if(w===206&&(E["Content-Range"]=`bytes ${m}-${p}/${d}`),e.writeHead(w,E),d===0){e.end();return}let f=C(g,{start:m,end:p});f.on("error",()=>e.destroy()),e.on("close",()=>f.destroy()),f.pipe(e)}function O(n,e){return(e??y(n).evidenceViewerUrl).replace(/\/+$/,"")}function k(n,e){return`${e}/?pack=${encodeURIComponent(n)}`}function P(n){return`evidence: view locally with \`kane-cli evidence serve ${n}\``}export{A as a,I as b,O as c,k as d,P as e};
|