@testmuai/kane-cli 0.8.10 → 0.8.11
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-OWGOCHG3.js → ChatSurface-YFJDAXOG.js} +1 -1
- package/dist/{ChromeProfilePicker-QIMCWPPI.js → ChromeProfilePicker-PUCZN6WU.js} +1 -1
- package/dist/{CliFeedbackPrompt-34E2AXS4.js → CliFeedbackPrompt-JAIB5MHS.js} +1 -1
- package/dist/{CliUploadProgress-TRKOSED7.js → CliUploadProgress-53LQMQJD.js} +1 -1
- package/dist/{ConfigView-XVKR7ATN.js → ConfigView-7HFP4OXS.js} +1 -1
- package/dist/EvidenceViewOffer-2T2ZGHIF.js +2 -0
- package/dist/FolderPicker-LTQW4YNR.js +2 -0
- package/dist/{InfoBox-QM5YEBMH.js → InfoBox-62YG3YNQ.js} +1 -1
- package/dist/{LinksBox-CSEDEZGU.js → LinksBox-6NS3GHWO.js} +1 -1
- package/dist/{ProfilesView-CZVPREIS.js → ProfilesView-HIKK2HPC.js} +1 -1
- package/dist/{ProjectPicker-F6FEWNMY.js → ProjectPicker-2CJMO5TD.js} +1 -1
- package/dist/{SaveSessionPrompt-RUSFOLBZ.js → SaveSessionPrompt-4DTPZSXD.js} +1 -1
- package/dist/SingleShotApp-KXZF5ZJM.js +2 -0
- package/dist/{SummaryBox-KOJXTZVZ.js → SummaryBox-A6LKKQXJ.js} +1 -1
- package/dist/TestMdRunView-6X6W5YAP.js +2 -0
- package/dist/{TestrunEvidenceTable-KGVBX76H.js → TestrunEvidenceTable-7SCCTZPH.js} +1 -1
- package/dist/{WhoamiView-IOTBOCGK.js → WhoamiView-PDMQ6F5N.js} +1 -1
- package/dist/{app-download-7AF6QL2C.js → app-download-K2ELUXWR.js} +1 -1
- package/dist/{auth-2HTDCT7X.js → auth-5WJSFLCP.js} +1 -1
- package/dist/{binary-NKX3NEK7.js → binary-QVQRWQFK.js} +1 -1
- package/dist/{bind-IMBQFRKT.js → bind-5WELCZ4S.js} +3 -3
- package/dist/{bootstrap-TNFANHSS.js → bootstrap-3LNHRDQH.js} +1 -1
- package/dist/bridge-WFSSMJ57.js +2 -0
- package/dist/{changelog-SQVLSCYO.js → changelog-TK6DWFVW.js} +1 -1
- package/dist/{chat-committer-K3NOTLOU.js → chat-committer-MAW25ICC.js} +1 -1
- package/dist/chat-controller-6GW2HSJP.js +2 -0
- package/dist/{chunk-EH3YMGQ7.js → chunk-2E55VQYA.js} +1 -1
- package/dist/{chunk-PCVTSFIX.js → chunk-2KQF6WLX.js} +4 -4
- package/dist/{chunk-5EKTQY2S.js → chunk-2QSG5ZG6.js} +1 -1
- package/dist/{chunk-BG2AZQLI.js → chunk-2ZBY2GME.js} +1 -1
- package/dist/{chunk-54JZ6VEW.js → chunk-3D7VYEDP.js} +1 -1
- package/dist/{chunk-LTNMOEHT.js → chunk-3FJNTRAS.js} +1 -1
- package/dist/{chunk-HE3ZKFRC.js → chunk-3PMEHGH3.js} +1 -1
- package/dist/chunk-47WY2637.js +84 -0
- package/dist/{chunk-YUA2VDWH.js → chunk-4AZ7IG2A.js} +1 -1
- package/dist/{chunk-HNNVVK2O.js → chunk-4FXSDPQW.js} +1 -1
- package/dist/{chunk-ZXTVP4WX.js → chunk-4SXJKDHO.js} +2 -2
- package/dist/{chunk-6S3Z3WPF.js → chunk-4VYWTTT4.js} +2 -2
- package/dist/{chunk-XTUSDGAB.js → chunk-4VZRBBLF.js} +1 -1
- package/dist/{chunk-SAFETUCL.js → chunk-5LEO463W.js} +1 -1
- package/dist/{chunk-KUAFVRSR.js → chunk-5NBT5IVT.js} +1 -1
- package/dist/{chunk-ZFZB4CGJ.js → chunk-6DOS5CJ5.js} +1 -1
- package/dist/{chunk-N7Z7BQYO.js → chunk-6GH4DRKR.js} +1 -1
- package/dist/{chunk-RP7FW23G.js → chunk-7B7OSHPX.js} +1 -1
- package/dist/{chunk-NJQNHD5P.js → chunk-7HUJVIMO.js} +1 -1
- package/dist/{chunk-2ULZVQZV.js → chunk-7KRCBN6X.js} +1 -1
- package/dist/{chunk-USUFF3S6.js → chunk-7P3JGF2X.js} +1 -1
- package/dist/{chunk-WAI5UHW3.js → chunk-A4BDLZOD.js} +1 -1
- package/dist/{chunk-LUTRUSIV.js → chunk-A76UL3EN.js} +1 -1
- package/dist/{chunk-YXPWGIQ2.js → chunk-ASK4AZFC.js} +1 -1
- package/dist/{chunk-RJ4YFH7K.js → chunk-AXW3WDFO.js} +1 -1
- package/dist/{chunk-IVQX3AKL.js → chunk-B7K5WOOU.js} +1 -1
- package/dist/{chunk-P3UGM74Z.js → chunk-B7TJIUKZ.js} +1 -1
- package/dist/{chunk-FOP6CJAM.js → chunk-BE4FBVKY.js} +1 -1
- package/dist/chunk-BHSHGWBL.js +2 -0
- package/dist/chunk-CABRAZOL.js +5 -0
- package/dist/{chunk-W7PBJXLJ.js → chunk-CBLUNSF4.js} +1 -1
- package/dist/{chunk-5Q3W3SX7.js → chunk-CL3AMEK6.js} +1 -1
- package/dist/{chunk-ZDAO5D6D.js → chunk-CQKKDIKA.js} +1 -1
- package/dist/{chunk-2BIPFAGX.js → chunk-CRPBARFG.js} +1 -1
- package/dist/{chunk-WEJA3EVI.js → chunk-DEUDRSU7.js} +1 -1
- package/dist/{chunk-GHL2A273.js → chunk-DHWS7SLT.js} +2 -2
- package/dist/{chunk-NYQOYOBA.js → chunk-DJJO4IHY.js} +1 -1
- package/dist/{chunk-C33E5XQM.js → chunk-DLJIML73.js} +1 -1
- package/dist/{chunk-EV64VI66.js → chunk-DP7GPS6S.js} +1 -1
- package/dist/chunk-F7R6A6P5.js +4 -0
- package/dist/{chunk-EKOL4WCC.js → chunk-FIODM24X.js} +1 -1
- package/dist/{chunk-SU3QKERU.js → chunk-FQRWYXFG.js} +1 -1
- package/dist/{chunk-6FCPS2VT.js → chunk-FYLMTZ3J.js} +1 -1
- package/dist/{chunk-YHL5NA43.js → chunk-G5ZGEZCA.js} +1 -1
- package/dist/{chunk-AWEUKXZQ.js → chunk-GMXM4WHF.js} +1 -1
- package/dist/{chunk-CSCJLGIY.js → chunk-GSNGC7HI.js} +1 -1
- package/dist/{chunk-HXSOZWFL.js → chunk-GV5BX2IQ.js} +1 -1
- package/dist/{chunk-5YBKKWJA.js → chunk-HFRMJP2P.js} +1 -1
- package/dist/chunk-HJBORIFP.js +26 -0
- package/dist/{chunk-WIAZN7G4.js → chunk-HULEZ3D3.js} +1 -1
- package/dist/{chunk-NDKHC6KL.js → chunk-IX4FH5W6.js} +1 -1
- package/dist/{chunk-CKNVMB4E.js → chunk-JAO7TZBV.js} +1 -1
- package/dist/{chunk-LKUWEQ5M.js → chunk-JJJREAFQ.js} +1 -1
- package/dist/{chunk-ESHDTCSZ.js → chunk-K6BWPGBO.js} +1 -1
- package/dist/chunk-KRL2BDI5.js +8 -0
- package/dist/{chunk-ML2E3JGK.js → chunk-M3Q7IQMS.js} +1 -1
- package/dist/{chunk-FH6EDP77.js → chunk-M7CGNE2D.js} +4 -4
- package/dist/{chunk-M6SFFAAQ.js → chunk-NBXYL2JT.js} +6 -6
- package/dist/chunk-NGASEXVA.js +27 -0
- package/dist/{chunk-WXJQDLXX.js → chunk-NLSR2IFN.js} +1 -1
- package/dist/{chunk-H4WIA4IP.js → chunk-NP3VGFZM.js} +1 -1
- package/dist/{chunk-BUM367KV.js → chunk-NVRXDLJN.js} +1 -1
- package/dist/{chunk-SAKUG4KE.js → chunk-NYUMJDCE.js} +1 -1
- package/dist/chunk-O7RB4X6I.js +21 -0
- package/dist/{chunk-QJNQN6ND.js → chunk-OC7TJTQG.js} +1 -1
- package/dist/{chunk-GOF5PQ5T.js → chunk-OGJ6ZSLC.js} +1 -1
- package/dist/{chunk-EEFZXZTZ.js → chunk-OKBEMFAW.js} +1 -1
- package/dist/{chunk-CXKWVHZK.js → chunk-OKCULEBD.js} +1 -1
- package/dist/{chunk-XMTSHHYQ.js → chunk-OXHMUZJV.js} +1 -1
- package/dist/chunk-OZMYKG6E.js +6 -0
- package/dist/{chunk-5G22NOZK.js → chunk-QHSF2CXK.js} +1 -1
- package/dist/{chunk-BZCVLCMG.js → chunk-QIRZBOKA.js} +1 -1
- package/dist/{chunk-W3Z7AZNT.js → chunk-R4EGL7VM.js} +1 -1
- package/dist/{chunk-KAZGHWGK.js → chunk-S63XGGBE.js} +1 -1
- package/dist/{chunk-JGZWR3CR.js → chunk-SNKFWPEM.js} +2 -2
- package/dist/chunk-T4OJX2GZ.js +15 -0
- package/dist/chunk-TB2CCKL7.js +2 -0
- package/dist/{chunk-TI7MR3PB.js → chunk-TSW5A7W3.js} +1 -1
- package/dist/{chunk-UH2ZTX4E.js → chunk-TYRTD5DD.js} +1 -1
- package/dist/{chunk-RSNG5PBN.js → chunk-URLZULC7.js} +1 -1
- package/dist/{chunk-BQSLPF5M.js → chunk-VGLY4HWA.js} +1 -1
- package/dist/{chunk-D6566A2X.js → chunk-VUOAFV27.js} +1 -1
- package/dist/{chunk-WAWMIKSI.js → chunk-W4IRHQGO.js} +9 -9
- package/dist/{chunk-OSRRMY6M.js → chunk-W7NI6JCF.js} +1 -1
- package/dist/chunk-WD52ZNQY.js +2 -0
- package/dist/chunk-WRVDIZAI.js +6 -0
- package/dist/{chunk-PMOUXVUC.js → chunk-X6WB2QTT.js} +1 -1
- package/dist/{chunk-B4CYIZP5.js → chunk-XB7EMX6J.js} +1 -1
- package/dist/{chunk-KRKGZ2ZW.js → chunk-XS2LZFCH.js} +1 -1
- package/dist/{chunk-UEANTGQS.js → chunk-XYSFPVJX.js} +1 -1
- package/dist/{chunk-47OUD76M.js → chunk-Y4ODYIOP.js} +1 -1
- package/dist/{chunk-O5U6EAL3.js → chunk-YELGHSVH.js} +1 -1
- package/dist/{chunk-DF3DUGJS.js → chunk-YQ4MRF57.js} +4 -4
- package/dist/{chunk-NYSFEZUR.js → chunk-YSNBXUM6.js} +1 -1
- package/dist/{chunk-KGKJU27A.js → chunk-Z4QLCWLB.js} +1 -1
- package/dist/{chunk-SXX7ZE6L.js → chunk-Z6GMZOVL.js} +3 -3
- package/dist/{chunk-IWVA37B6.js → chunk-ZES42R57.js} +1 -1
- package/dist/{chunk-ETIQJIDI.js → chunk-ZMJD3CI7.js} +1 -1
- package/dist/{committer-C6UCDYMC.js → committer-42AFWMEX.js} +1 -1
- package/dist/{config-UF635MC4.js → config-KU2UICMC.js} +1 -1
- package/dist/{cover-cmd-5LPHIOSI.js → cover-cmd-HAOBK2IC.js} +1 -1
- package/dist/{credentials-3KBLEVJH.js → credentials-BEC4I5SE.js} +1 -1
- package/dist/{deps-bundle-WGF4YYGO.js → deps-bundle-EY5T7OH3.js} +1 -1
- package/dist/{deps-resolve-DVJPU4YX.js → deps-resolve-MPLFFCZZ.js} +1 -1
- package/dist/design-committer-2BQVZPO4.js +2 -0
- package/dist/dispatch-NE35HS5F.js +2 -0
- package/dist/{doctor-2KRK42L2.js → doctor-JBXA6WNL.js} +1 -1
- package/dist/{docx-convert-JMUMT5C4.js → docx-convert-BIV5T7F5.js} +1 -1
- package/dist/{dossier-Y6TJWFZU.js → dossier-WSWXZAPL.js} +1 -1
- package/dist/effective-decisions-UNE2TFVA.js +2 -0
- package/dist/{evidence-CDCFEYS7.js → evidence-MJV3PY2J.js} +1 -1
- package/dist/evolve-cmd-I4Z6IPIM.js +2 -0
- package/dist/explain-O3A2HZWD.js +2 -0
- package/dist/{explain-cmd-RMJPXD4U.js → explain-cmd-BXFR5DB6.js} +1 -1
- package/dist/{explain-cmd-XCRO4AS6.js → explain-cmd-IRQ2YX5L.js} +1 -1
- package/dist/{extract-bind-VFQWACVO.js → extract-bind-PPMY4FFA.js} +3 -3
- package/dist/{extract-cmd-2OFQBBJ4.js → extract-cmd-RHVLPNQB.js} +2 -2
- package/dist/{feeder-IOR3XRNF.js → feeder-52VBZY3R.js} +1 -1
- package/dist/{gaps-cmd-JIUM5YDY.js → gaps-cmd-MSDGU6OU.js} +1 -1
- package/dist/{generate-headless-B35UUR5A.js → generate-headless-NSK32S53.js} +2 -2
- package/dist/index.js +115 -115
- package/dist/ingest-WTPY2VLS.js +2 -0
- package/dist/ingest-cmd-GOPW3SNF.js +2 -0
- package/dist/install-BDHZVEY4.js +2 -0
- package/dist/{interactive-bind-OWASLPBQ.js → interactive-bind-4FNW3OYT.js} +4 -4
- package/dist/{lifecycle-cmd-KSMETBPP.js → lifecycle-cmd-HYNG5KH6.js} +1 -1
- package/dist/{list-cmd-V3HJ5K4O.js → list-cmd-Y4WEOT3E.js} +1 -1
- package/dist/{list-commands-SLQDF6AT.js → list-commands-CJCEW7MQ.js} +1 -1
- package/dist/{logical-ids-MLXAH45L.js → logical-ids-N3UZACB4.js} +1 -1
- package/dist/login-flow-DLG2WHSZ.js +2 -0
- package/dist/{maintenance-cmd-VFYGKY3X.js → maintenance-cmd-UJNH47SG.js} +1 -1
- package/dist/{mobile-prompts-6MGOXIKX.js → mobile-prompts-SJZVJWSB.js} +1 -1
- package/dist/persist-recorded-session-FWBAOQEF.js +3 -0
- package/dist/{phase-seed-BMOSAA74.js → phase-seed-2WI7KUYO.js} +1 -1
- package/dist/pipeline-B2TYZBMB.js +2 -0
- package/dist/prepare-target-JGVB7OKC.js +2 -0
- package/dist/readmodel-YDLGQDMH.js +2 -0
- package/dist/reconcile-cmd-6ILIXD3U.js +2 -0
- package/dist/{reconcile-deps-RYO67ZXY.js → reconcile-deps-GMQA6ULT.js} +2 -2
- package/dist/{reconcile-engine-PRH6YIAZ.js → reconcile-engine-XLLYS5ZB.js} +1 -1
- package/dist/{recording-banner-CH2SZ4IU.js → recording-banner-CQBXZMT3.js} +1 -1
- package/dist/{records-JLS63SDI.js → records-EW4PIJ5W.js} +1 -1
- package/dist/registry-AA5YIO5Y.js +2 -0
- package/dist/{replay-policy-CVQ6OJX5.js → replay-policy-A62KXE6Y.js} +1 -1
- package/dist/{require-project-folder-XY77JKAQ.js → require-project-folder-K3E3QIOZ.js} +1 -1
- package/dist/{resolve-run-intent-JFIGIF72.js → resolve-run-intent-3CENNCF3.js} +1 -1
- package/dist/{resolver-6VDNZ6KP.js → resolver-PSNP72H4.js} +1 -1
- package/dist/{revert-PRR3D4XM.js → revert-RXHWWUMQ.js} +1 -1
- package/dist/{review-cmd-SAGIKWEW.js → review-cmd-JUOWTME4.js} +1 -1
- package/dist/run-6CMGGU2W.js +2 -0
- package/dist/run-PZIYMD35.js +2 -0
- package/dist/{run-test-md-OLGWTC4I.js → run-test-md-XBM6RMCI.js} +2 -2
- package/dist/{sessions-cmd-VDQGRBEM.js → sessions-cmd-PGE6LP2W.js} +1 -1
- package/dist/{skill-installer-NT7ZT6O4.js → skill-installer-FBOPYFYS.js} +1 -1
- package/dist/{spawner-YQSAPZR4.js → spawner-URQ5OAY7.js} +1 -1
- package/dist/{structured-answers-YAVW65G4.js → structured-answers-BZWJUX22.js} +1 -1
- package/dist/tcg-generate-BPLQ7WJ5.js +2 -0
- package/dist/testmd-actions-WJS2YM7B.js +2 -0
- package/dist/testmd-sync-TPUBEORI.js +2 -0
- package/dist/token-refresh-IT4LVE2H.js +2 -0
- package/dist/{validate-basic-OMAFYHME.js → validate-basic-BXBHTTTO.js} +1 -1
- package/dist/verdicts-J5MJHUGG.js +2 -0
- package/dist/{version-check-FRVZSYNF.js → version-check-BGHE3LAK.js} +1 -1
- package/dist/{view-cmd-SXXNDZIC.js → view-cmd-XD5ENSML.js} +1 -1
- package/dist/{walk-session-LNFOCPJ6.js → walk-session-EYBUURRA.js} +1 -1
- package/dist/{with-telemetry-4ATZC6IR.js → with-telemetry-L3SO6J3L.js} +1 -1
- package/package.json +11 -11
- package/dist/EvidenceViewOffer-M2TGMSNE.js +0 -2
- package/dist/FolderPicker-WZTNQ5IV.js +0 -2
- package/dist/SingleShotApp-WBFVUZFP.js +0 -2
- package/dist/TestMdRunView-BEXL7TIN.js +0 -2
- package/dist/bridge-SXYWYZDO.js +0 -2
- package/dist/chat-controller-YJCNU76T.js +0 -2
- package/dist/chunk-724NYDMU.js +0 -27
- package/dist/chunk-CPGUTSUD.js +0 -6
- package/dist/chunk-EKCGZXZE.js +0 -2
- package/dist/chunk-I3OVXNBW.js +0 -7
- package/dist/chunk-I5KYZHJ5.js +0 -71
- package/dist/chunk-IPEA7ZOF.js +0 -8
- package/dist/chunk-SXUQBPQ6.js +0 -2
- package/dist/chunk-TGPI7VDR.js +0 -21
- package/dist/chunk-VIJUT5AR.js +0 -26
- package/dist/chunk-WHEWZR2C.js +0 -15
- package/dist/chunk-XIGTZTFP.js +0 -5
- package/dist/design-committer-UPC6NZUF.js +0 -2
- package/dist/dispatch-YTIJKX6C.js +0 -2
- package/dist/effective-decisions-DRM3JSR4.js +0 -2
- package/dist/evolve-cmd-L3JIBYP5.js +0 -2
- package/dist/explain-3HAZY7Q6.js +0 -2
- package/dist/ingest-TTUQ7UDK.js +0 -2
- package/dist/ingest-cmd-LAUSXSI3.js +0 -2
- package/dist/install-ENSOEMSX.js +0 -2
- package/dist/login-flow-YKQUXP75.js +0 -2
- package/dist/persist-recorded-session-RKG7HOEW.js +0 -3
- package/dist/pipeline-M25AR7RM.js +0 -2
- package/dist/prepare-target-UGACDQEJ.js +0 -2
- package/dist/readmodel-TDRFVDVI.js +0 -2
- package/dist/reconcile-cmd-MR2MSVZ5.js +0 -2
- package/dist/registry-ARR5ITIQ.js +0 -2
- package/dist/run-GTBYWSLW.js +0 -2
- package/dist/run-UETW72YU.js +0 -2
- package/dist/tcg-generate-D73BMKOE.js +0 -2
- package/dist/testmd-actions-XPYXS36F.js +0 -2
- package/dist/token-refresh-2XVSIFRM.js +0 -2
- package/dist/verdicts-KEBSV2NL.js +0 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as Y,b as Z,c as nn,d as en,e as tn}from"./chunk-
|
|
2
|
+
import{a as Y,b as Z,c as nn,d as en,e as tn}from"./chunk-AXW3WDFO.js";import{b as rn,c as sn}from"./chunk-P7YZ3PU3.js";import{n as X,p as P}from"./chunk-RSSOJ3L2.js";import{a as jn}from"./chunk-6YGTRKDT.js";import{e as Pn}from"./chunk-UR6MHSHU.js";function on(i){return{command:"start",...i}}function an(i,e,o){return{command:"run",run_id:i,kind:e,...o}}function un(i){return{command:"cancel",...i?{run_id:i}:{}}}function dn(i){return{command:"ask_user_response",answer:i}}function ln(){return{command:"shutdown"}}var z=Symbol("run-queue-end"),G=class{items=[];waiting=null;ended=!1;error=null;push(e){if(this.waiting){let{resolve:o}=this.waiting;this.waiting=null,o(e)}else this.items.push(e)}end(){if(this.ended=!0,this.waiting){let{resolve:e}=this.waiting;this.waiting=null,e(z)}}fail(e){if(this.error=e,this.waiting){let{reject:o}=this.waiting;this.waiting=null,o(e)}}next(){return this.items.length>0?Promise.resolve(this.items.shift()):this.error?Promise.reject(this.error):this.ended?Promise.resolve(z):new Promise((e,o)=>{this.waiting={resolve:e,reject:o}})}},D=class{env;runner;log;sessionId;spawnFn;proc=null;activeRun=null;pendingReady=null;shuttingDown=!1;finalized=!1;exitInfo=null;exitedUnexpectedly=!1;exitResolve;exited;constructor(e){this.env=e.env,this.runner=e.runner,this.log=e.log,this.sessionId=e.sessionId,this.spawnFn=e.spawn??Z;let o;this.exited=new Promise(c=>{o=c}),this.exitResolve=o}async start(e){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 o=new Promise((c,g)=>{this.pendingReady={resolve:c,reject:g}});this.writeCommand(on(e)),await o}async*run(e,o,c){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 '${e}'`);if(this.activeRun)throw new Error(`PersistentRunner.run overlap: '${this.activeRun.runId}' still in flight`);let g=new G,w={runId:e,queue:g};this.activeRun=w,this.writeCommand(an(e,o,c));try{for(;;){let v=await g.next();if(v===z||(yield v,v.type==="run_end"&&(v.run_id===void 0||v.run_id===e)))break}}finally{this.activeRun===w&&(this.activeRun=null)}}sendUserResponse(e){this.writeCommand(dn(e))}cancel(e){this.writeCommand(un(e))}kill(){this.proc?.child.kill("SIGTERM")}async shutdown(){this.shuttingDown=!0,this.proc&&(this.writeCommand(ln()),await this.exited)}get stderr(){return this.proc?.getStderr()??""}get diedUnexpectedly(){return this.exitedUnexpectedly}writeCommand(e){let o=JSON.stringify(e)+`
|
|
3
3
|
`;try{this.proc?.child.stdin?.write(o)}catch{}}async consume(){if(!this.proc)return;try{for await(let c of this.proc.events){if(c.type==="ready"){this.onReady();continue}this.routeEvent(c)}}catch(c){this.log?.("error","PERSISTENT_RUNNER_STREAM_ERROR","Runner stdout stream errored",{error:c instanceof Error?c.message:String(c)})}let{code:e,signal:o}=await this.proc.exited;this.onExit(e,o)}onReady(){if(this.pendingReady){let{resolve:e}=this.pendingReady;this.pendingReady=null,e()}}routeEvent(e){let o=this.activeRun;if(!o){this.log?.("warn","PERSISTENT_RUNNER_ORPHAN_EVENT","Runner event with no active run",{event_type:e.type});return}o.queue.push(e)}onExit(e,o){if(!this.finalized){if(this.finalized=!0,this.exitInfo={code:e,signal:o},this.shuttingDown||(this.exitedUnexpectedly=!0),this.exitResolve({code:e,signal:o}),this.pendingReady){let{reject:c}=this.pendingReady;this.pendingReady=null,c(new Error(`v16-runner exited before ready (code=${e}, signal=${o??"none"})`))}if(this.activeRun){let{queue:c}=this.activeRun;if(this.activeRun=null,this.shuttingDown)c.end();else{let g=this.proc?.getStderr()?.slice(-500)??"";c.fail(new Error(`v16-runner exited unexpectedly mid-run (code=${e}, signal=${o??"none"})${g?`
|
|
4
4
|
${g}`:""}`))}}}}};var p=Pn(jn(),1);function cn(i){let e={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&&(e.device=i.device),i.auth&&(e.auth=i.auth),i.disable_ask_user&&(e.disable_ask_user=!0),i.username&&(e.username=i.username),i.access_key&&(e.access_key=i.access_key),e}function j(i,e){let o=null,c=(g,w)=>{for(let v=0;v<g.length;v++){let _=g[v],h=[...w,v];e(_)&&(o===null||h.length>o.length)&&(o=h),_.children&&_.children.length>0&&c(_.children,h)}};return c(i,[]),o}function N(i,e,o){if(e.length===0)return[...i];let c=e[0],g=[...i],w=g[c];if(e.length===1)g[c]=o(w);else{let v=e.slice(1),_=N(w.children??[],v,o);g[c]={...w,children:_}}return g}function pn(){return{steps:[],maxOrdinal:0}}function Nn(i,e){if(e.type==="run_start"&&e.child_id)return e.environment?.resolution?{...i,resolution:e.environment.resolution}:i;if(e.type==="run_start"){let o=sn(i.runnerEnvironment,rn(e.environment));if(o)return{...i,runnerEnvironment:o,...o.resolution?{resolution:o.resolution}:{}}}if(e.type==="step_end"&&typeof e.ordinal=="number"&&e.id){let o={id:e.id,ordinal:e.ordinal,status:e.status,...e.kind?{kind:e.kind}:{},...typeof e.duration=="number"?{duration_ms:Math.round(e.duration*1e3)}:{},...typeof e.action_id=="string"&&e.action_id?{action_id:e.action_id}:{}};return{...i,steps:[...i.steps,o],maxOrdinal:Math.max(i.maxOrdinal,e.ordinal)}}return i}function V(i){let e=i.indexOf(": ");return e>0&&e<15?i.slice(e+2):i}function W(i){return i.map(e=>{let o=e.children?W(e.children):e.children;return e.status==="running"?{...e,status:"stopped",phase:void 0,children:o}:o!==e.children?{...e,children:o}:e})}function Gn(i,e,o,c,g){let[w,v]=(0,p.useState)(!1),[_,h]=(0,p.useState)([]),[hn,T]=(0,p.useState)(null),[fn,B]=(0,p.useState)(null),[mn,k]=(0,p.useState)(null),[vn,J]=(0,p.useState)(null),[gn,H]=(0,p.useState)([]),[Rn,K]=(0,p.useState)(null),[Sn,yn]=(0,p.useState)(void 0),[wn,$]=(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)(pn()),O=(0,p.useRef)(null),xn=(0,p.useCallback)(async(m,x)=>{let Q=O.current;if(Q)try{await Q}catch{}h([]),T(null),B(null),k(null),J(null),H([]),K(null),yn(m.max_steps),v(!0),S.current=null,b.current=0,U.current=pn();let I=y.current;if(I&&E.current!==m.session_id){try{I.kill()}catch{}y.current=null,E.current=null,$(n=>n+1),I=null}if(!I){let n=Y();if(!n){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=en({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 nn(d,m.device);let u=new D({env:d,runner:n,log:x?.log,sessionId:m.session_id});y.current=u,E.current=m.session_id,I=u,X("runner",()=>{try{u.kill()}catch{}});let s=cn(m);try{await u.start(s)}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,tn(M,{environment:x?.environment});let In=`run-${m.run_index}`,Cn=m.mode==="replay"?"replay":"author",L=I,q=(async()=>{F.current=!1;for await(let n of L.run(In,Cn,M)){if(F.current)break;switch(U.current=Nn(U.current,n),n.type){case"run_start":if(n.child_id)break;if(S.current&&!S.current.isSingleFlow){let d=b.current;b.current++,h(u=>u.map((s,a)=>a===d?{...s,status:"running"}:s.status==="running"&&!s.children?.some(t=>t.status==="running")?{...s,status:s.children?.some(t=>t.status==="failed")?"failed":"passed"}:s))}break;case"bifurcation":{let d=n.flows??[],u=n.count??d.length,s={flows:d,isSingleFlow:n.is_single_flow??u<=1};J(s),S.current=s,b.current=0,h(d.map((a,t)=>({index:t+1,objective:a??`Flow ${t+1}`,status:"pending"})));break}case"step_start":{e?.("STEP_START",`Step ${n.index} started`,{index:n.index,objective:n.objective,child_id:n.child_id});let d=n.index,u=n.objective??`Step ${d}`,s=n.child_id,a=S.current&&!S.current.isSingleFlow;if(s)h(t=>{let r=j(t,l=>l.branchChildId===s)??j(t,l=>l.status==="running");return r?N(t,r,l=>{let f=(l.children??[]).map(R=>R.status==="running"&&R.childId===s?{...R,status:"stopped",phase:void 0}:R);return f.push({index:d,objective:u,status:"running",childId:s}),{...l,children:f}}):t});else if(a){let t=Math.max(0,b.current-1);h(r=>{let l=[...r];if(t>=l.length)return r;let f={...l[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",l[t]=f,l})}else h(t=>{let r=W(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":{e?.("STEP_EVENT",`Step ${n.index} ${n.event}`,{index:n.index,phase:n.event,action_type:n.action_type,detail:n.detail,child_id:n.child_id});let d=n.child_id,u=S.current&&!S.current.isSingleFlow;if(n.event==="cm_init"&&n.checkpoint_count!=null){H(s=>[...s,n.checkpoint_count]);break}if(n.event==="replay_started"){K({recordingLength:n.recording_length??0});break}if(n.event==="reasoning"&&n.detail&&n.detail!=="reasoning"&&o?.(n.detail),d){let s=t=>{if(t.index!==n.index||t.childId!==d)return t;let r={phase:n.event};return n.event==="reasoning"&&n.detail&&n.detail!=="reasoning"&&(r.objective=n.detail),n.action_type&&(r.actionType=n.action_type),{...t,...r}},a=t=>t.map(r=>{let l=s(r);return l!==r?l: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 s=Math.max(0,b.current-1);h(a=>{let t=[...a];if(s>=t.length)return a;let r={...t[s]},l=[...r.children??[]];if(!l.some(R=>R.index===n.index&&R.childId===void 0))l.push({index:n.index,objective:`Step ${n.index}`,status:"running",phase:n.event,actionType:n.action_type});else for(let R=0;R<l.length;R++){if(l[R].index!==n.index||l[R].childId!==void 0)continue;let C={phase:n.event};n.event==="reasoning"&&n.detail&&n.detail!=="reasoning"&&(C.objective=n.detail),n.action_type&&(C.actionType=n.action_type),l[R]={...l[R],...C}}return r.children=l,t[s]=r,t})}else h(s=>s.some(t=>t.index===n.index)?s.map(t=>{if(t.index!==n.index)return t;let r={phase:n.event};return n.event==="reasoning"&&n.detail&&n.detail!=="reasoning"&&(r.objective=n.detail),n.action_type&&(r.actionType=n.action_type),{...t,...r}}):[...W(s),{index:n.index,objective:`Step ${n.index}`,status:"running",phase:n.event,actionType:n.action_type}]);break}case"step_end":{e?.("STEP_END",`Step ${n.index} ${n.status}`,{index:n.index,status:n.status,duration:n.duration,summary:n.summary,child_id:n.child_id}),c?.();let d=n.child_id,u=S.current&&!S.current.isSingleFlow;if(d){let s=t=>t.index===n.index&&t.childId===d?{...t,status:n.status,duration:n.duration,phase:void 0,objective:t.objective.startsWith("Step ")?V(n.summary||t.objective):t.objective}:t,a=t=>t.map(r=>{let l=s(r);return l!==r?l: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 s=Math.max(0,b.current-1);h(a=>{let t=[...a];if(s>=t.length)return a;let r={...t[s]},l=(r.children??[]).map(f=>f.index===n.index&&f.childId===void 0?{...f,status:n.status,duration:n.duration,phase:void 0,objective:f.objective.startsWith("Step ")?V(n.summary||f.objective):f.objective}:f);return r.children=l,t[s]=r,t})}else h(s=>s.map(a=>a.index===n.index?{...a,status:n.status,duration:n.duration,phase:void 0,objective:a.objective.startsWith("Step ")?V(n.summary||a.objective):a.objective}:a));{let a=S.current&&!S.current.isSingleFlow?Math.max(0,b.current-1):0,t=typeof n.ordinal=="number"&&n.id?{ordinal:n.ordinal,id:n.id}:void 0;i?.(n.index,a,n.child_id,t)}break}case"child_agent_start":{let d=n.objective??"",u=n.child_id;h(s=>{let a=j(s,t=>t.status==="running");return a?N(s,a,t=>({...t,objective:`${d} (branch)`,phase:`child: ${d.slice(0,50)}`,branchObjective:d,branchChildId:u})):s});break}case"child_agent_end":{let d=n.child_id,u=`child ${n.success?"done":"failed"}`;h(s=>{let a=j(s,t=>t.branchChildId===d);return a?N(s,a,t=>({...t,phase:u})):s.map(t=>t.phase?.startsWith("child:")?{...t,phase:u}:t)});break}case"describe_trigger":g?.(n);break;case"ask_user":T(n.question??"");break;case"run_end":h(d=>d.map(u=>u.status==="running"?{...u,status:n.status,phase:void 0}:u)),v(!1),B(n);break;case"error":v(!1),k(n.message??"Runner error"),h(d=>d.map(u=>u.status==="running"?{...u,status:"failed",phase:void 0}:u));break}}})().catch(n=>{if(y.current!==L)return;let u=[n instanceof Error?n.message:String(n)],s=L.stderr;s&&!u.join(`
|
|
5
5
|
`).includes(s)&&u.push(s),k(u.join(`
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{A as r}from"./chunk-
|
|
2
|
+
import{A as r}from"./chunk-R4EGL7VM.js";function i(t){return r.test(t)?t.toUpperCase():t}export{i as a};
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as J,b as F}from"./chunk-2UIHS2FH.js";import{a as we}from"./chunk-YKTYVJBN.js";import{a as N,b as he,c as ye,d as be,e as Ee,f as _e,m as T}from"./chunk-
|
|
2
|
+
import{a as J,b as F}from"./chunk-2UIHS2FH.js";import{a as M}from"./chunk-N2P4MI32.js";import{a as we}from"./chunk-YKTYVJBN.js";import{a as N,b as he,c as ye,d as be,e as Ee,f as _e,m as T}from"./chunk-3D7VYEDP.js";import{b as B,d as W}from"./chunk-NVGBE2DR.js";import{C as j}from"./chunk-R4EGL7VM.js";import{w as ge}from"./chunk-DEUDRSU7.js";var A="https://integrations.lambdatest.com",E=class extends Error{constructor(e,r){super(r);this.code=e;this.name="LisError"}};function ft(t){let n=t.TESTMUAI_ENV==="stage"?"stage":"prod";return`${ge[n].shareApiBaseUrl}/lis/api/v1`}function gt(t){let n=t.env??process.env,e=t.auth?.TESTMUAI_BASIC_AUTH||n.TESTMUAI_BASIC_AUTH;if(e)return{authorization:`Basic ${e}`};let r=t.auth?.TESTMUAI_API_KEY||n.TESTMUAI_API_KEY;return r?{authorization:`Bearer ${r}`}:{}}function k(t){let n=t.split(`
|
|
3
3
|
`,1)[0].replace(/[\u0000-\u001f\u007f-\u009f]/g,"");return n.length>200?`${n.slice(0,200)}\u2026`:n}function ht(t,n,e="the issue"){return t===401||t===403?new E("LIS_AUTH","credentials rejected \u2014 run `kane-cli login` and retry"):t>=500?new E("LIS_UNAVAILABLE",`the integrations service returned an error (HTTP ${t}) \u2014 retry later`):new E("JIRA_ISSUE_UNAVAILABLE",`could not fetch ${e}: ${k(n)||`HTTP ${t}`}`)}function C(t){try{return JSON.parse(t.bytes.toString("utf8"))}catch{throw new E("LIS_UNAVAILABLE","the integrations service returned a malformed response \u2014 retry later")}}function ce(t){try{return JSON.parse(t.bytes.toString("utf8"))}catch{return{}}}function Le(t){return ce(t).code}function S(t,n="the issue",e="Atlassian"){let r=ce(t),s=e==="Atlassian"?"Confluence":e;switch(r.code){case"TOKEN_EXPIRED":return new E("LIS_SETUP",`your ${e} connection needs a resync \u2014 reconnect at ${A} and retry`);case"NOT_INSTALLED":return new E("LIS_SETUP",`no ${e} connection for this account \u2014 create one at ${A} and retry`);case"SCOPE_MISSING":return new E("LIS_SETUP",`the connection has no ${s} access \u2014 reconnect with ${s} at ${A} and retry`);case"FORBIDDEN":return new E("LIS_FORBIDDEN",`you don't have access to ${n}`);case"NOT_FOUND":return new E("JIRA_ISSUE_UNAVAILABLE",`could not fetch ${n}: ${k(r.message??"")||"not found"}`);case"PAYLOAD_TOO_LARGE":return new E("ATTACHMENT_TOO_LARGE","the attachment exceeds the integrations service's size cap");case"INVALID_PAYLOAD":return new E("LIS_UNAVAILABLE",`the integrations service rejected the request (${k(r.message??"")||"invalid payload"}) \u2014 retry later`);case"NOT_SUPPORTED":return new E("LIS_UNAVAILABLE","the integrations service does not support this operation yet");case"UPSTREAM_ERROR":case"UPSTREAM_TIMEOUT":return new E("LIS_UNAVAILABLE",`${e} is not responding through the integrations service \u2014 retry later`);default:return ht(t.status,r.message??"",n)}}var yt=3e4,bt=5;async function $(t,n,e){let r=e.env??process.env,s=e.fetchImpl??fetch;for(let o=0;;o++){let l=new AbortController,u=setTimeout(()=>l.abort(),yt);try{let i=await s(`${ft(r)}${t}`,{...n,headers:{"content-type":"application/json",...gt(e),...n.headers??{}},signal:l.signal}),c=await Promise.race([i.arrayBuffer(),new Promise((d,p)=>{l.signal.addEventListener("abort",()=>p(new DOMException("aborted","AbortError")),{once:!0})})]),a={status:i.status,ok:i.ok,headers:i.headers,bytes:Buffer.from(c)};if(a.status===429){if(o>0)throw new E("LIS_RATE_LIMITED","the integrations service is busy \u2014 try again in a moment");let d=ce(a).data?.retry_after_sec,p=Math.min(Math.max(typeof d=="number"&&Number.isFinite(d)?d:1,0),bt);clearTimeout(u),await new Promise(y=>setTimeout(y,p*1e3));continue}return a}catch(i){throw i instanceof E?i:l.signal.aborted?new E("LIS_UNAVAILABLE","the integrations service did not respond within 30 seconds \u2014 retry later"):new E("LIS_UNAVAILABLE",`could not reach the integrations service (${k(i instanceof Error?i.message:String(i))}) \u2014 check your connection and retry`)}finally{clearTimeout(u)}}}function V(t){let n=t.headers.get("content-type")??"application/octet-stream";if(n.includes("json"))try{let e=JSON.parse(t.bytes.toString("utf8")),r=e.content??e.data?.content;if(typeof r=="string")return{bytes:Buffer.from(r,"base64"),mediaType:e.mime_type??e.data?.mime_type??"application/octet-stream"}}catch{}return{bytes:t.bytes,mediaType:n}}async function H(t={}){let n=await $("/jira/info",{method:"GET"},t);if(!n.ok)throw S(n);let e=C(n),r=(e.data?.SELECTED_PROJECTS??[]).map(s=>s?.key).filter(s=>typeof s=="string"&&s.length>0);return{installed:e.data?.INSTALLED==="YES",selectAll:e.data?.SELECT_ALL===!0,selectedProjects:r,capabilities:{document:e.data?.capabilities?.document===!0,comments:e.data?.capabilities?.comments===!0}}}async function z(t,n={}){let e=await $("/jira/issue?details=true",{method:"POST",body:JSON.stringify({plugin_code:"jira",issueKey:t})},n);if(!e.ok)throw S(e);let r=C(e);if(r.type==="error"||!r.data)throw new E("JIRA_ISSUE_UNAVAILABLE",`could not fetch the issue: ${k(r.message??"")||"issue not found or not accessible"}`);return r.data}var Ie=100,Et=5e3,_t=60;async function X(t,n={}){let e=[],r=new Set,s=null,o=0;for(let l=0;;l++){if(l>=_t)throw new E("LIS_UNAVAILABLE","the integrations service kept returning comment pages without finishing \u2014 retry later");let u=await $("/jira/issue/comments",{method:"POST",body:JSON.stringify({resource_id:t,max_results:Ie,cursor:s,start_at:o,order_by:"created",fetch_all:!1})},n);if(!u.ok)throw S(u,"the issue's comments");let i=C(u);if(i.type==="error"||!i.data)throw new E("JIRA_ISSUE_UNAVAILABLE",`could not fetch the issue's comments: ${k(i.message??"")||"unavailable"}`);for(let w of i.data.comments??[]){let f=String(w.id);r.has(f)||(r.add(f),e.push(w))}let c=i.data.pagination;if(!c?.has_more)return e;if(e.length>=Et)throw new E("JIRA_ISSUE_UNAVAILABLE","the issue has more comments than can be ingested \u2014 cannot build a complete identity");let a=c.next_cursor??null,d=c.next_start_at!=null,p=d?c.next_start_at:o+Ie;if(!(a!=null&&a!==s||a==null&&d&&p!==o))throw new E("LIS_UNAVAILABLE","the integrations service returned a non-advancing comments page \u2014 retry later");s=a,o=p}}async function Z(t,n={}){let e=await $("/jira/attachment",{method:"POST",body:JSON.stringify({attachment_id:t})},n);if(!e.ok){if(Le(e)===void 0){if(e.status===413)throw new E("ATTACHMENT_TOO_LARGE","the attachment exceeds the integrations service's size cap");if(e.status===404)throw new E("JIRA_NOT_CONNECTED",`Jira is not connected for this account \u2014 connect it at ${A} and retry`)}throw S(e,`attachment ${t}`)}return V(e)}var q="kane.source.jira/2";function Ae(t){if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return String(t);if(Array.isArray(t)){let n=t.map(Ae).filter(e=>e!==null);return n.length===0?null:n.join(", ")}if(t!==null&&typeof t=="object"){let n=t;for(let e of["name","value","displayName"])if(typeof n[e]=="string")return n[e];return null}return null}function ve(t,n,e){let r=[],s={},o=t.additional_fields??{};for(let a of Object.keys(o).sort()){let d=Ae(o[a]);if(d===null){r.push(`field "${a}" has no stable text form \u2014 dropped from the envelope`);continue}s[a]=d}let l=[...t.attachments??[]].map(a=>({id:String(a.id),filename:a.filename??"",media_type:a.mime_type??"application/octet-stream",size:a.size??0})).sort((a,d)=>{let p=Number(a.id),y=Number(d.id);return Number.isFinite(p)&&Number.isFinite(y)?p-y:a.id<d.id?-1:a.id>d.id?1:0}),u=e.map(a=>({id:String(a.id),author:a.author?.display_name??"",body:a.body??"",created:a.created??""})).sort((a,d)=>{if(a.created!==d.created)return a.created<d.created?-1:1;let p=Number(a.id),y=Number(d.id);return Number.isFinite(p)&&Number.isFinite(y)&&p!==y?p-y:a.id<d.id?-1:a.id>d.id?1:0}),i=t.key;if(!/^[A-Za-z][A-Za-z0-9_]*-\d+$/.test(i))throw new Error(`cannot build a stable identity for issue key "${i}" \u2014 expected a PROJECT-NUMBER key`);let c={schema:q,site:n,project:i.slice(0,i.lastIndexOf("-")),issue:{id:t.id,key:i},content:{summary:t.summary??"",description:t.description??"",fields:s},attachments:l,comments:u};return{bytes:Buffer.from(JSON.stringify(c),"utf8"),envelope:c,warnings:r}}var Se=64,wt=16,Lt=6e6,It=5e7,At=12e6,vt={png:"image/png",jpeg:"image/jpeg",webp:"image/webp",gif:"image/gif",bmp:"image/bmp",tiff:"image/tiff",emf:"image/emf",wmf:"image/wmf",unknown:"application/octet-stream"},St=new Set(["png","jpeg","webp"]);function $e(t){return async n=>{let e;try{e=JSON.parse(n.toString("utf8"))}catch{throw new Error("JIRA_ENVELOPE_SCHEMA: source bytes are not a kane jira envelope")}if(e.schema!==q)throw new Error(`JIRA_ENVELOPE_SCHEMA: unknown envelope schema "${e.schema}" \u2014 this CLI understands ${q}`);let r=[],s=new Map,o=[],l=0,u=new Map,i=[];for(let d=0;d<e.attachments.length;d++){let p=e.attachments[d],y=`i${d+1}`,w=`attachment:${p.filename}`,f=v=>`[img#${y}] ${p.filename} (${p.media_type}, ${p.size} bytes${v?"":" \u2014 not delivered"})`,h=(v,R,x)=>{r.push({ref:y,loc:w,media_type:v,...x?.blob?{blob:x.blob}:{},...x?.appearance?{appearance:x.appearance}:{},delivery:R,...x?.duplicate_of?{duplicate_of:x.duplicate_of}:{}})};if(!p.media_type.startsWith("image/")){h(p.media_type,"unsupported-vision-media-type"),i.push(f(!1));continue}let _;try{_=await t.fetchAttachment(p.id)}catch{h(p.media_type,"external-image-not-fetched"),i.push(f(!1));continue}let b=_.bytes,g=J(b),m=vt[g.format],I=B(b);if(s.set(I,b),!St.has(g.format)){let v=g.format==="gif"||g.format==="bmp"||g.format==="tiff"?"unsupported-vision-media-type":"unsupported-image-kind";h(m,v,{blob:I}),i.push(f(!1));continue}if(g.width===void 0||g.height===void 0||g.width*g.height>It){h(m,"undecodable",{blob:I}),i.push(f(!1));continue}let L;if(g.format==="png"||g.format==="jpeg"){let v=F(b,g.format);if(v===null){h(m,"undecodable",{blob:I}),i.push(f(!1));continue}L=M(v.data,{width:v.width,height:v.height,channels:v.channels})}if(g.width<Se||g.height<Se){h(m,"below-dimension-floor",{blob:I,appearance:L}),i.push(f(!1));continue}let O=u.get(I);if(O!==void 0){h(m,"duplicate",{blob:I,appearance:L,duplicate_of:O}),i.push(f(!1));continue}if(b.byteLength>Lt){h(m,"image-too-large",{blob:I,appearance:L}),i.push(f(!1));continue}if(l+b.byteLength>At){h(m,"vision-byte-budget-reached",{blob:I,appearance:L}),i.push(f(!1));continue}if(o.length>=wt){h(m,"image-cap-reached",{blob:I,appearance:L}),i.push(f(!1));continue}u.set(I,y),l+=b.byteLength,o.push(y),h(m,"selected",{blob:I,appearance:L}),i.push(f(!0))}let c=[];c.push(`${e.issue.key} \xB7 ${e.site}/${e.project}`,`Summary: ${e.content.summary}`),e.content.description!==""&&c.push("",...e.content.description.split(`
|
|
4
4
|
`));let a=Object.keys(e.content.fields);return a.length>0&&c.push("","--- fields ---",...a.map(d=>`${d}: ${e.content.fields[d]}`)),i.length>0&&c.push("","--- attachments ---",...i),e.comments.length>0&&(c.push("","--- comments ---"),e.comments.forEach((d,p)=>{p>0&&c.push(""),c.push(`[${p+1}] ${d.author} \xB7 ${d.created}`,...d.body.split(`
|
|
5
5
|
`))})),{projection:c.join(`
|
|
6
6
|
`)+`
|
|
7
|
-
`,inventory:r,blobs:s,delivered:o,converter:{name:"jira-convert",version:"2",policy:"v1"}}}}var $t=/^[A-Za-z][A-Za-z0-9_]*-\d+$/;function Q(t){if(!/^https?:\/\/.+/i.test(t))return null;let n;try{n=new URL(t)}catch{return null}let e=n.pathname.split("/").filter(Boolean),r=e.lastIndexOf("browse");if(r===-1||r+1>=e.length)return null;let s=e[r+1];return $t.test(s)?{site:n.hostname,issueKey:s.toUpperCase()}:null}function ee(t,n){let e=j(t),r=e.heads.get(n);return r==null?null:Ce(t,e,r)}function te(t,n){let r=ee(t,n)?.site;return typeof r=="string"&&r.length>0?r:null}function ke(t,n,e,r){let s=j(t);for(let[o,l]of s.heads){if(l==null||s.mediaOf(l).format!==n)continue;let u=Ce(t,s,l);if(u===null)continue;let i=u;for(let c of e){if(i===null||typeof i!="object"){i=void 0;break}i=i[c]}if(i===r)return o}return null}function Ce(t,n,e){let r=n.getNode(e)?.content?.blob;if(typeof r!="string")return null;let s=W(t,r);if(s===null)return null;try{let o=JSON.parse(s.toString("utf8"));return o!==null&&typeof o=="object"?o:null}catch{return null}}var Re={jira:"a jira issue source",confluence:"a confluence page source",linear:"a linear issue source","linear-doc":"a linear document source",web:"a web page source"};function P(t,n,e){let r=j(t),s=r.heads.get(n);if(s==null)return null;let o=r.mediaOf(s).format;if(o===e)return null;let l=Re[o]??`${o} content`;return`source '${n}' is already backed by ${l}, not ${Re[e]??e} \u2014 retire it first (kane-cli context retire ${n}) or ingest under a different id with --as`}async function Rt(t,n,e,r,s){let o=Q(t);if(o===null)return(e.err??e.out)(`error: ${t}: unsupported remote URL \u2014 expected a Jira issue URL (https://<site>/browse/KEY-123)`),{code:1};let l=s?.lis??{jiraInfo:H,jiraIssue:z,jiraAttachment:Z,jiraComments:X};try{let i={auth:await(s?.authEnv??(await import("./auth-
|
|
7
|
+
`,inventory:r,blobs:s,delivered:o,converter:{name:"jira-convert",version:"2",policy:"v1"}}}}var $t=/^[A-Za-z][A-Za-z0-9_]*-\d+$/;function Q(t){if(!/^https?:\/\/.+/i.test(t))return null;let n;try{n=new URL(t)}catch{return null}let e=n.pathname.split("/").filter(Boolean),r=e.lastIndexOf("browse");if(r===-1||r+1>=e.length)return null;let s=e[r+1];return $t.test(s)?{site:n.hostname,issueKey:s.toUpperCase()}:null}function ee(t,n){let e=j(t),r=e.heads.get(n);return r==null?null:Ce(t,e,r)}function te(t,n){let r=ee(t,n)?.site;return typeof r=="string"&&r.length>0?r:null}function ke(t,n,e,r){let s=j(t);for(let[o,l]of s.heads){if(l==null||s.mediaOf(l).format!==n)continue;let u=Ce(t,s,l);if(u===null)continue;let i=u;for(let c of e){if(i===null||typeof i!="object"){i=void 0;break}i=i[c]}if(i===r)return o}return null}function Ce(t,n,e){let r=n.getNode(e)?.content?.blob;if(typeof r!="string")return null;let s=W(t,r);if(s===null)return null;try{let o=JSON.parse(s.toString("utf8"));return o!==null&&typeof o=="object"?o:null}catch{return null}}var Re={jira:"a jira issue source",confluence:"a confluence page source",linear:"a linear issue source","linear-doc":"a linear document source",web:"a web page source"};function P(t,n,e){let r=j(t),s=r.heads.get(n);if(s==null)return null;let o=r.mediaOf(s).format;if(o===e)return null;let l=Re[o]??`${o} content`;return`source '${n}' is already backed by ${l}, not ${Re[e]??e} \u2014 retire it first (kane-cli context retire ${n}) or ingest under a different id with --as`}async function Rt(t,n,e,r,s){let o=Q(t);if(o===null)return(e.err??e.out)(`error: ${t}: unsupported remote URL \u2014 expected a Jira issue URL (https://<site>/browse/KEY-123)`),{code:1};let l=s?.lis??{jiraInfo:H,jiraIssue:z,jiraAttachment:Z,jiraComments:X};try{let i={auth:await(s?.authEnv??(await import("./auth-5WJSFLCP.js")).resolveLisAuthEnv)(),env:process.env},c=await l.jiraInfo(i);if(!c.installed)return(e.err??e.out)(`error: ${t}: no Atlassian connection for this account \u2014 create one at ${A} and retry`),{code:1};if(c.capabilities.comments===!1)return(e.err??e.out)(`error: ${t}: the connection cannot read issue comments yet \u2014 resync it at ${A} and retry`),{code:1};let a=o.issueKey.slice(0,o.issueKey.lastIndexOf("-"));if(!c.selectAll&&c.selectedProjects.length>0&&!c.selectedProjects.includes(a))return(e.err??e.out)(`error: ${t}: project ${a} is not in the integration's selected projects (${c.selectedProjects.join(", ")}) \u2014 add it at ${A}`),{code:1};let d=await l.jiraIssue(o.issueKey,i),p=await l.jiraComments(o.issueKey,i),y=o.site;if(d.host)try{y=new URL(d.host).hostname}catch{y=d.host.replace(/^https?:\/\//,"").replace(/[/:].*$/,"")}let{bytes:w,warnings:f}=ve(d,y,p),h=n??o.issueKey.toLowerCase();N(h);let _=P(r,h,"jira");if(_!==null)return(e.err??e.out)(`error: ${t}: ${_}`),{code:1};let b=te(r,h);if(b!==null&&b!==y)return(e.err??e.out)(`error: ${t}: source '${h}' was ingested from ${b}, but this read serves ${y} \u2014 retire it first (kane-cli context retire ${h}) or ingest under a different id with --as`),{code:1};let g=await T({contextDir:r,bytes:w,media:he,sourceId:h,label:t,confirmSameSource:e.isTTY?m=>e.confirm(`identical content already ingested as ${m} \u2014 treat as the same source?`):void 0,converters:{jira:$e({fetchAttachment:m=>l.jiraAttachment(m,i)})}});e.out(U(e.isTTY,g,o.issueKey));for(let m of f)e.out(`warning: ${m}`);for(let m of g.warnings??[])e.out(`warning: ${m}`);if(g.composite){let m=g.composite.delivered+g.composite.omitted;e.out(`${g.source_id}: jira, ${m} attachments, ${g.composite.delivered} images delivered (${g.composite.omitted} omitted)`)}return{code:0,result:{status:g.status,source_id:g.source_id,source_cid:g.cid}}}catch(u){return u instanceof E?((e.err??e.out)(`error: ${t}: ${u.message}`),{code:1}):((e.err??e.out)(`error: ${t}: ${kt(u instanceof Error?u.message:String(u))}`),{code:1})}}function kt(t){let n=t.match(/too large — ([\d.]+ [KM]B), the limit for .+ is ([\d.]+ [KM]B) \[FILE_TOO_LARGE\]/);return n?`the issue's content is too large to ingest (${n[1]}; the limit is ${n[2]}) \u2014 trim the description or attachments in Jira and retry`:t.startsWith("PROJECTION_TOO_LARGE:")?"the issue's text is too large to ingest \u2014 trim the description in Jira and retry":t}var Oe={name:"jira",hint:"Jira issue URLs (https://<site>/browse/KEY-123)",match:t=>Q(t)!==null,ingest:Rt,sourceIdFor:t=>{let n=Q(t);return n?n.issueKey.toLowerCase():null}};async function Ne(t,n={}){let e=await $("/jira/document",{method:"POST",body:JSON.stringify({resource_id:t,format:"markdown"})},n);if(!e.ok)throw S(e,"the page");let r=C(e);if(r.type==="error"||!r.data)throw new E("JIRA_ISSUE_UNAVAILABLE",`could not fetch the page: ${k(r.message??"")||"page not found or not accessible"}`);return r.data}async function Te(t,n={}){let e=await $("/jira/attachment",{method:"POST",body:JSON.stringify({source:"confluence",download:t})},n);if(!e.ok)throw S(e,"the page's attachment");return{bytes:V(e).bytes}}var ne="kane.source.confluence/1";function Pe(t,n){if(typeof t.id!="string"||t.id==="")throw new Error("cannot build a stable identity for this page \u2014 the integrations service returned no page id");let e=[...t.labels??[]].filter(o=>typeof o=="string").sort(),r=[...t.attachments??[]].map(o=>({id:String(o.id),filename:o.filename??"",media_type:o.mime_type??"application/octet-stream",size:o.size??0})).sort((o,l)=>o.id<l.id?-1:o.id>l.id?1:0),s={schema:ne,site:n,page:{id:t.id},space:{key:t.space?.key??""},title:t.title??"",labels:e,content:{body:t.body??""},attachments:r};return{bytes:Buffer.from(JSON.stringify(s),"utf8"),envelope:s,warnings:[]}}var Ue=64,Ct=16,Ot=6e6,Nt=5e7,Tt=12e6,Pt={png:"image/png",jpeg:"image/jpeg",webp:"image/webp",gif:"image/gif",bmp:"image/bmp",tiff:"image/tiff",emf:"image/emf",wmf:"image/wmf",unknown:"application/octet-stream"},Ut=new Set(["png","jpeg","webp"]);function xe(t){let n=new Map(Object.entries(t.downloads));return async e=>{let r;try{r=JSON.parse(e.toString("utf8"))}catch{throw new Error("CONFLUENCE_ENVELOPE_SCHEMA: source bytes are not a kane confluence envelope")}if(r.schema!==ne)throw new Error(`CONFLUENCE_ENVELOPE_SCHEMA: unknown envelope schema "${r.schema}" \u2014 this CLI understands ${ne}`);let s=[],o=new Map,l=[],u=0,i=new Map,c=[];for(let d=0;d<r.attachments.length;d++){let p=r.attachments[d],y=`i${d+1}`,w=`attachment:${p.filename}`,f=R=>`[img#${y}] ${p.filename} (${p.media_type}, ${p.size} bytes${R?"":" \u2014 not delivered"})`,h=(R,x,D)=>{s.push({ref:y,loc:w,media_type:R,...D?.blob?{blob:D.blob}:{},...D?.appearance?{appearance:D.appearance}:{},delivery:x,...D?.duplicate_of?{duplicate_of:D.duplicate_of}:{}})};if(!p.media_type.startsWith("image/")){h(p.media_type,"unsupported-vision-media-type"),c.push(f(!1));continue}let _=n.get(p.id);if(!_){h(p.media_type,"external-image-not-fetched"),c.push(f(!1));continue}let b;try{b=await t.fetchAttachment({id:p.id,download:_})}catch{h(p.media_type,"external-image-not-fetched"),c.push(f(!1));continue}let g=b.bytes,m=J(g),I=Pt[m.format],L=B(g);if(o.set(L,g),!Ut.has(m.format)){let R=m.format==="gif"||m.format==="bmp"||m.format==="tiff"?"unsupported-vision-media-type":"unsupported-image-kind";h(I,R,{blob:L}),c.push(f(!1));continue}if(m.width===void 0||m.height===void 0||m.width*m.height>Nt){h(I,"undecodable",{blob:L}),c.push(f(!1));continue}let O;if(m.format==="png"||m.format==="jpeg"){let R=F(g,m.format);if(R===null){h(I,"undecodable",{blob:L}),c.push(f(!1));continue}O=M(R.data,{width:R.width,height:R.height,channels:R.channels})}if(m.width<Ue||m.height<Ue){h(I,"below-dimension-floor",{blob:L,appearance:O}),c.push(f(!1));continue}let v=i.get(L);if(v!==void 0){h(I,"duplicate",{blob:L,appearance:O,duplicate_of:v}),c.push(f(!1));continue}if(g.byteLength>Ot){h(I,"image-too-large",{blob:L,appearance:O}),c.push(f(!1));continue}if(u+g.byteLength>Tt){h(I,"vision-byte-budget-reached",{blob:L,appearance:O}),c.push(f(!1));continue}if(l.length>=Ct){h(I,"image-cap-reached",{blob:L,appearance:O}),c.push(f(!1));continue}i.set(L,y),u+=g.byteLength,l.push(y),h(I,"selected",{blob:L,appearance:O}),c.push(f(!0))}let a=[];return a.push(`${r.title} \xB7 ${r.site} \xB7 ${r.space.key}`),r.labels.length>0&&a.push(`labels: ${r.labels.join(", ")}`),r.content.body!==""&&a.push("",...r.content.body.split(`
|
|
8
8
|
`)),c.length>0&&a.push("","--- attachments ---",...c),{projection:a.join(`
|
|
9
9
|
`)+`
|
|
10
|
-
`,inventory:s,blobs:o,delivered:l,converter:{name:"confluence-convert",version:"1",policy:"v1"}}}}var xt=/^[A-Za-z0-9~][A-Za-z0-9._~-]*$/;function re(t){if(!/^https?:\/\/.+/i.test(t))return null;let n;try{n=new URL(t)}catch{return null}let e=n.pathname.split("/").filter(Boolean),r=e.indexOf("wiki");if(r===-1||e[r+1]!=="spaces"||e[r+3]!=="pages")return null;let s=e[r+2],o=e[r+4];return s===void 0||o===void 0||!xt.test(s)||!/^\d+$/.test(o)?null:{site:n.hostname,spaceKey:s,pageId:o}}async function Dt(t,n,e,r,s){let o=re(t);if(o===null)return(e.err??e.out)(`error: ${t}: unsupported remote URL \u2014 expected a Confluence page URL (https://<site>/wiki/spaces/<KEY>/pages/<id>/\u2026)`),{code:1};let l=s?.lis??{jiraInfo:H,jiraIssue:z,jiraAttachment:Z,jiraComments:X},u=s?.confluence??{confluenceDocument:Ne,confluenceAttachment:Te};try{let c={auth:await(s?.authEnv??(await import("./auth-2HTDCT7X.js")).resolveLisAuthEnv)(),env:process.env},a=await l.jiraInfo(c);if(!a.installed)return(e.err??e.out)(`error: ${t}: no Atlassian connection for this account \u2014 create one at ${A} and retry`),{code:1};if(a.capabilities.document===!1)return(e.err??e.out)(`error: ${t}: the connection has no Confluence access \u2014 reconnect with Confluence at ${A} and retry`),{code:1};let d=await u.confluenceDocument(o.pageId,c),p=o.site;if(d.url)try{p=new URL(d.url).hostname}catch{}let{bytes:y,warnings:w}=Pe(d,p),f=n??`page-${o.pageId}`;N(f);let h=P(r,f,"confluence");if(h!==null)return(e.err??e.out)(`error: ${t}: ${h}`),{code:1};let _=te(r,f);if(_!==null&&_!==p)return(e.err??e.out)(`error: ${t}: source '${f}' was ingested from ${_}, but this read serves ${p} \u2014 retire it first (kane-cli context retire ${f}) or ingest under a different id with --as`),{code:1};let b=Object.fromEntries((d.attachments??[]).filter(m=>typeof m.download=="string"&&m.download.length>0).map(m=>[String(m.id),m.download])),g=await T({contextDir:r,bytes:y,media:ye,sourceId:f,label:t,confirmSameSource:e.isTTY?m=>e.confirm(`identical content already ingested as ${m} \u2014 treat as the same source?`):void 0,converters:{confluence:xe({downloads:b,fetchAttachment:m=>u.confluenceAttachment(m.download,c)})}});e.out(U(e.isTTY,g,`${o.spaceKey}/${o.pageId}`));for(let m of w)e.out(`warning: ${m}`);for(let m of g.warnings??[])e.out(`warning: ${m}`);if(g.composite){let m=g.composite.delivered+g.composite.omitted;e.out(`${g.source_id}: confluence, ${m} attachments, ${g.composite.delivered} images delivered (${g.composite.omitted} omitted)`)}return{code:0,result:{status:g.status,source_id:g.source_id,source_cid:g.cid}}}catch(i){return i instanceof E?((e.err??e.out)(`error: ${t}: ${i.message}`),{code:1}):((e.err??e.out)(`error: ${t}: ${jt(i instanceof Error?i.message:String(i))}`),{code:1})}}function jt(t){let n=t.match(/too large — ([\d.]+ [KM]B), the limit for .+ is ([\d.]+ [KM]B) \[FILE_TOO_LARGE\]/);return n?`the page's content is too large to ingest (${n[1]}; the limit is ${n[2]}) \u2014 trim the page in Confluence and retry`:t.startsWith("PROJECTION_TOO_LARGE:")?"the page's text is too large to ingest \u2014 trim the page in Confluence and retry":t}var De={name:"confluence",hint:"Confluence page URLs (https://<site>/wiki/spaces/<KEY>/pages/<id>/\u2026)",match:t=>re(t)!==null,ingest:Dt,sourceIdFor:t=>{let n=re(t);return n?`page-${n.pageId}`:null}};async function je(t={}){let n=await $("/linear-app/info",{method:"GET"},t);if(!n.ok)throw S(n,"the connection","Linear");let e=C(n);return{installed:e.data?.INSTALLED==="YES",capabilities:{issue:e.data?.capabilities?.issue===!0,comments:e.data?.capabilities?.comments===!0,document:e.data?.capabilities?.document===!0}}}async function Be(t,n={}){let e=await $("/linear-app/issue?details=true",{method:"POST",body:JSON.stringify({plugin_code:"linear-app",issueKey:t})},n);if(!e.ok)throw S(e,"the issue","Linear");let r=C(e);if(r.type==="error"||!r.data)throw new E("JIRA_ISSUE_UNAVAILABLE",`could not fetch the issue: ${k(r.message??"")||"issue not found or not accessible"}`);return r.data}var Bt=100,Mt=5e3,Jt=60;async function Me(t,n={}){let e=[],r=new Set,s=null;for(let o=0;;o++){if(o>=Jt)throw new E("LIS_UNAVAILABLE","the integrations service kept returning comment pages without finishing \u2014 retry later");let l=await $("/linear-app/issue/comments",{method:"POST",body:JSON.stringify({resource_id:t,max_results:Bt,...s===null?{}:{cursor:s},fetch_all:!1})},n);if(!l.ok)throw S(l,"the issue's comments","Linear");let u=C(l);if(u.type==="error"||!u.data)throw new E("JIRA_ISSUE_UNAVAILABLE",`could not fetch the issue's comments: ${k(u.message??"")||"unavailable"}`);if(u.data.partial)throw new E("JIRA_ISSUE_UNAVAILABLE","the integrations service returned an incomplete comment set \u2014 retry later");for(let a of u.data.comments??[]){if(typeof a.id!="string"||a.id==="")throw new E("JIRA_ISSUE_UNAVAILABLE","the integrations service returned an incomplete comment set \u2014 a comment row has no comment id");r.has(a.id)||(r.add(a.id),e.push(a))}let i=u.data.pagination;if(!i?.has_more)return e;if(e.length>=Mt)throw new E("JIRA_ISSUE_UNAVAILABLE","the issue has more comments than can be ingested \u2014 cannot build a complete identity");let c=i.next_cursor??null;if(c==null||c===s)throw new E("LIS_UNAVAILABLE","the integrations service returned a non-advancing comments page \u2014 retry later");s=c}}async function Je(t,n={}){let e=await $("/linear-app/document",{method:"POST",body:JSON.stringify({resource_id:t,format:"markdown"})},n);if(!e.ok)throw S(e,"the document","Linear");let r=C(e);if(r.type==="error"||!r.data)throw new E("JIRA_ISSUE_UNAVAILABLE",`could not fetch the document: ${k(r.message??"")||"document not found or not accessible"}`);return r.data}async function Fe(t,n={}){let e=await $("/linear-app/attachment",{method:"POST",body:JSON.stringify({attachment_id:t})},n);if(!e.ok)throw S(e,"the attachment","Linear");return{bytes:V(e).bytes}}var oe="kane.source.linear/1",ie="kane.source.linear-doc/1",Ft=/https:\/\/uploads\.linear\.app\/[^\s)"'`]+/g;function G(t){return t.replace(Ft,n=>{let e=n.indexOf("?");return e===-1?n:n.slice(0,e)})}function Ve(t,n){return t.id<n.id?-1:t.id>n.id?1:0}function Vt(t,n){return Ve(t,n)||(t.filename<n.filename?-1:t.filename>n.filename?1:0)||(t.url<n.url?-1:t.url>n.url?1:0)}function Ge(t,n,e){if(typeof t.id!="string"||t.id==="")throw new Error("cannot build a stable identity for this issue \u2014 the integrations service returned no issue id");let r=t.key;if(!/^[A-Za-z][A-Za-z0-9]*-\d+$/.test(r)){let c=String(r).replace(/[\u0000-\u001f\u007f-\u009f]/g,"").slice(0,80);throw new Error(`cannot build a stable identity for issue key "${c}" \u2014 expected a TEAM-NUMBER key`)}let s={},o=[...t.labels??[]].filter(c=>typeof c=="string").sort();o.length>0&&(s.labels=o.join(", ")),typeof t.priority=="string"&&t.priority!==""&&(s.priority=t.priority),typeof t.project=="string"&&t.project!==""&&(s.project=t.project),typeof t.status=="string"&&t.status!==""&&(s.status=t.status);let l=(t.attachments??[]).map(c=>({id:c.id!=null&&String(c.id)!==""?String(c.id):G(c.download??""),filename:c.filename??"",url:G(c.download??"")})).sort(Vt),u=n.map(c=>({id:String(c.id),author:c.author?.display_name??"",body:G(c.body??""),created:c.created??""})).sort((c,a)=>c.created!==a.created?c.created<a.created?-1:1:Ve(c,a)),i={schema:oe,site:e,team:r.slice(0,r.lastIndexOf("-")),issue:{uuid:t.id,key:r},content:{title:t.summary??"",description:G(t.description??""),fields:s},attachments:l,comments:u};return{bytes:Buffer.from(JSON.stringify(i),"utf8"),envelope:i,warnings:[]}}function Ye(t,n,e){if(typeof t.id!="string"||t.id==="")throw new Error("cannot build a stable identity for this document \u2014 the integrations service returned no document id");let r=(t.attachments??[]).map(o=>({url:G(o.download??String(o.id??"")),filename:o.filename??""})).sort((o,l)=>o.url<l.url?-1:o.url>l.url?1:0),s={schema:ie,site:n,document:{uuid:t.id,slug_id:e},project:{id:t.space?.key??""},title:t.title??"",content:{body:G(t.body??"")},attachments:r};return{bytes:Buffer.from(JSON.stringify(s),"utf8"),envelope:s,warnings:[]}}var Ke=64,Gt=16,Yt=6e6,Kt=5e7,Wt=12e6,se=64,We="https://uploads.linear.app/",Ht=/https:\/\/uploads\.linear\.app\/[^\s)"'`]+/g,zt={png:"image/png",jpeg:"image/jpeg",webp:"image/webp",gif:"image/gif",bmp:"image/bmp",tiff:"image/tiff",emf:"image/emf",wmf:"image/wmf",unknown:"application/octet-stream"},Xt=new Set(["png","jpeg","webp"]);async function He(t,n){let e=[],r=new Map,s=[],o=0,l=new Map,u=[];for(let i=0;i<t.length;i++){let c=t[i],a=`i${i+1}`,d=m=>`[img#${a}] ${c.label}${m?"":" \u2014 not delivered"}`,p=(m,I,L)=>{e.push({ref:a,loc:c.loc,media_type:m,...L?.blob?{blob:L.blob}:{},...L?.appearance?{appearance:L.appearance}:{},delivery:I,...L?.duplicate_of?{duplicate_of:L.duplicate_of}:{}})},y;try{y=await n(c.url)}catch{p("application/octet-stream","external-image-not-fetched"),u.push(d(!1));continue}let w=y.bytes,f=J(w),h=zt[f.format],_=B(w);if(r.set(_,w),!Xt.has(f.format)){let m=f.format==="gif"||f.format==="bmp"||f.format==="tiff"?"unsupported-vision-media-type":"unsupported-image-kind";p(h,m,{blob:_}),u.push(d(!1));continue}if(f.width===void 0||f.height===void 0||f.width*f.height>Kt){p(h,"undecodable",{blob:_}),u.push(d(!1));continue}let b;if(f.format==="png"||f.format==="jpeg"){let m=F(w,f.format);if(m===null){p(h,"undecodable",{blob:_}),u.push(d(!1));continue}b=M(m.data,{width:m.width,height:m.height,channels:m.channels})}if(f.width<Ke||f.height<Ke){p(h,"below-dimension-floor",{blob:_,appearance:b}),u.push(d(!1));continue}let g=l.get(_);if(g!==void 0){p(h,"duplicate",{blob:_,appearance:b,duplicate_of:g}),u.push(d(!1));continue}if(w.byteLength>Yt){p(h,"image-too-large",{blob:_,appearance:b}),u.push(d(!1));continue}if(o+w.byteLength>Wt){p(h,"vision-byte-budget-reached",{blob:_,appearance:b}),u.push(d(!1));continue}if(s.length>=Gt){p(h,"image-cap-reached",{blob:_,appearance:b}),u.push(d(!1));continue}l.set(_,a),o+=w.byteLength,s.push(a),p(h,"selected",{blob:_,appearance:b}),u.push(d(!0))}return{inventory:e,blobs:r,delivered:s,lines:u}}function Zt(t){let n=new Set,e=[];for(let r of t.match(Ht)??[])n.has(r)||(n.add(r),e.push(r));return e}function ze(t){return async n=>{let e;try{e=JSON.parse(n.toString("utf8"))}catch{throw new Error("LINEAR_ENVELOPE_SCHEMA: source bytes are not a kane linear envelope")}if(e.schema!==oe)throw new Error(`LINEAR_ENVELOPE_SCHEMA: unknown envelope schema "${e.schema}" \u2014 this CLI understands ${oe}`);let r=[],s=new Set;for(let a of Zt(e.content.description))s.add(a),r.push({url:a,label:a,loc:`body:${a}`});let o=[];for(let a of e.attachments)if(a.url.startsWith(We)){if(s.has(a.url)){if(a.filename!==""){let d=r.find(p=>p.url===a.url);d!==void 0&&d.label===d.url&&(d.label=a.filename)}continue}s.add(a.url),r.push({url:a.url,label:a.filename||a.url,loc:`attachment:${a.filename||a.url}`})}else a.url!==""&&o.push(`[${o.length+1}] ${a.filename||a.url} \u2014 ${a.url}`);let l=Math.max(0,r.length-se),u=await He(r.slice(0,se),t.fetchAttachment);l>0&&u.lines.push(`${l} more upload links not examined`);let i=[];i.push(`${e.issue.key} \xB7 ${e.site}`,`Title: ${e.content.title}`),e.content.description!==""&&i.push("",...e.content.description.split(`
|
|
10
|
+
`,inventory:s,blobs:o,delivered:l,converter:{name:"confluence-convert",version:"1",policy:"v1"}}}}var xt=/^[A-Za-z0-9~][A-Za-z0-9._~-]*$/;function re(t){if(!/^https?:\/\/.+/i.test(t))return null;let n;try{n=new URL(t)}catch{return null}let e=n.pathname.split("/").filter(Boolean),r=e.indexOf("wiki");if(r===-1||e[r+1]!=="spaces"||e[r+3]!=="pages")return null;let s=e[r+2],o=e[r+4];return s===void 0||o===void 0||!xt.test(s)||!/^\d+$/.test(o)?null:{site:n.hostname,spaceKey:s,pageId:o}}async function Dt(t,n,e,r,s){let o=re(t);if(o===null)return(e.err??e.out)(`error: ${t}: unsupported remote URL \u2014 expected a Confluence page URL (https://<site>/wiki/spaces/<KEY>/pages/<id>/\u2026)`),{code:1};let l=s?.lis??{jiraInfo:H,jiraIssue:z,jiraAttachment:Z,jiraComments:X},u=s?.confluence??{confluenceDocument:Ne,confluenceAttachment:Te};try{let c={auth:await(s?.authEnv??(await import("./auth-5WJSFLCP.js")).resolveLisAuthEnv)(),env:process.env},a=await l.jiraInfo(c);if(!a.installed)return(e.err??e.out)(`error: ${t}: no Atlassian connection for this account \u2014 create one at ${A} and retry`),{code:1};if(a.capabilities.document===!1)return(e.err??e.out)(`error: ${t}: the connection has no Confluence access \u2014 reconnect with Confluence at ${A} and retry`),{code:1};let d=await u.confluenceDocument(o.pageId,c),p=o.site;if(d.url)try{p=new URL(d.url).hostname}catch{}let{bytes:y,warnings:w}=Pe(d,p),f=n??`page-${o.pageId}`;N(f);let h=P(r,f,"confluence");if(h!==null)return(e.err??e.out)(`error: ${t}: ${h}`),{code:1};let _=te(r,f);if(_!==null&&_!==p)return(e.err??e.out)(`error: ${t}: source '${f}' was ingested from ${_}, but this read serves ${p} \u2014 retire it first (kane-cli context retire ${f}) or ingest under a different id with --as`),{code:1};let b=Object.fromEntries((d.attachments??[]).filter(m=>typeof m.download=="string"&&m.download.length>0).map(m=>[String(m.id),m.download])),g=await T({contextDir:r,bytes:y,media:ye,sourceId:f,label:t,confirmSameSource:e.isTTY?m=>e.confirm(`identical content already ingested as ${m} \u2014 treat as the same source?`):void 0,converters:{confluence:xe({downloads:b,fetchAttachment:m=>u.confluenceAttachment(m.download,c)})}});e.out(U(e.isTTY,g,`${o.spaceKey}/${o.pageId}`));for(let m of w)e.out(`warning: ${m}`);for(let m of g.warnings??[])e.out(`warning: ${m}`);if(g.composite){let m=g.composite.delivered+g.composite.omitted;e.out(`${g.source_id}: confluence, ${m} attachments, ${g.composite.delivered} images delivered (${g.composite.omitted} omitted)`)}return{code:0,result:{status:g.status,source_id:g.source_id,source_cid:g.cid}}}catch(i){return i instanceof E?((e.err??e.out)(`error: ${t}: ${i.message}`),{code:1}):((e.err??e.out)(`error: ${t}: ${jt(i instanceof Error?i.message:String(i))}`),{code:1})}}function jt(t){let n=t.match(/too large — ([\d.]+ [KM]B), the limit for .+ is ([\d.]+ [KM]B) \[FILE_TOO_LARGE\]/);return n?`the page's content is too large to ingest (${n[1]}; the limit is ${n[2]}) \u2014 trim the page in Confluence and retry`:t.startsWith("PROJECTION_TOO_LARGE:")?"the page's text is too large to ingest \u2014 trim the page in Confluence and retry":t}var De={name:"confluence",hint:"Confluence page URLs (https://<site>/wiki/spaces/<KEY>/pages/<id>/\u2026)",match:t=>re(t)!==null,ingest:Dt,sourceIdFor:t=>{let n=re(t);return n?`page-${n.pageId}`:null}};async function je(t={}){let n=await $("/linear-app/info",{method:"GET"},t);if(!n.ok)throw S(n,"the connection","Linear");let e=C(n);return{installed:e.data?.INSTALLED==="YES",capabilities:{issue:e.data?.capabilities?.issue===!0,comments:e.data?.capabilities?.comments===!0,document:e.data?.capabilities?.document===!0}}}async function Be(t,n={}){let e=await $("/linear-app/issue?details=true",{method:"POST",body:JSON.stringify({plugin_code:"linear-app",issueKey:t})},n);if(!e.ok)throw S(e,"the issue","Linear");let r=C(e);if(r.type==="error"||!r.data)throw new E("JIRA_ISSUE_UNAVAILABLE",`could not fetch the issue: ${k(r.message??"")||"issue not found or not accessible"}`);return r.data}var Bt=100,Mt=5e3,Jt=60;async function Me(t,n={}){let e=[],r=new Set,s=null;for(let o=0;;o++){if(o>=Jt)throw new E("LIS_UNAVAILABLE","the integrations service kept returning comment pages without finishing \u2014 retry later");let l=await $("/linear-app/issue/comments",{method:"POST",body:JSON.stringify({resource_id:t,max_results:Bt,...s===null?{}:{cursor:s},fetch_all:!1})},n);if(!l.ok)throw S(l,"the issue's comments","Linear");let u=C(l);if(u.type==="error"||!u.data)throw new E("JIRA_ISSUE_UNAVAILABLE",`could not fetch the issue's comments: ${k(u.message??"")||"unavailable"}`);if(u.data.partial)throw new E("JIRA_ISSUE_UNAVAILABLE","the integrations service returned an incomplete comment set \u2014 retry later");for(let a of u.data.comments??[]){if(typeof a.id!="string"||a.id==="")throw new E("JIRA_ISSUE_UNAVAILABLE","the integrations service returned an incomplete comment set \u2014 a comment row has no comment id");r.has(a.id)||(r.add(a.id),e.push(a))}let i=u.data.pagination;if(!i?.has_more)return e;if(e.length>=Mt)throw new E("JIRA_ISSUE_UNAVAILABLE","the issue has more comments than can be ingested \u2014 cannot build a complete identity");let c=i.next_cursor??null;if(c==null||c===s)throw new E("LIS_UNAVAILABLE","the integrations service returned a non-advancing comments page \u2014 retry later");s=c}}async function Je(t,n={}){let e=await $("/linear-app/document",{method:"POST",body:JSON.stringify({resource_id:t,format:"markdown"})},n);if(!e.ok)throw S(e,"the document","Linear");let r=C(e);if(r.type==="error"||!r.data)throw new E("JIRA_ISSUE_UNAVAILABLE",`could not fetch the document: ${k(r.message??"")||"document not found or not accessible"}`);return r.data}async function Fe(t,n={}){let e=await $("/linear-app/attachment",{method:"POST",body:JSON.stringify({attachment_id:t})},n);if(!e.ok)throw S(e,"the attachment","Linear");return{bytes:V(e).bytes}}var oe="kane.source.linear/1",ie="kane.source.linear-doc/1",Ft=/https:\/\/uploads\.linear\.app\/[^\s)"'`]+/g;function G(t){return t.replace(Ft,n=>{let e=n.indexOf("?");return e===-1?n:n.slice(0,e)})}function Ve(t,n){return t.id<n.id?-1:t.id>n.id?1:0}function Vt(t,n){return Ve(t,n)||(t.filename<n.filename?-1:t.filename>n.filename?1:0)||(t.url<n.url?-1:t.url>n.url?1:0)}function Ge(t,n,e){if(typeof t.id!="string"||t.id==="")throw new Error("cannot build a stable identity for this issue \u2014 the integrations service returned no issue id");let r=t.key;if(!/^[A-Za-z][A-Za-z0-9]*-\d+$/.test(r)){let c=String(r).replace(/[\u0000-\u001f\u007f-\u009f]/g,"").slice(0,80);throw new Error(`cannot build a stable identity for issue key "${c}" \u2014 expected a TEAM-NUMBER key`)}let s={},o=[...t.labels??[]].filter(c=>typeof c=="string").sort();o.length>0&&(s.labels=o.join(", ")),typeof t.priority=="string"&&t.priority!==""&&(s.priority=t.priority),typeof t.project=="string"&&t.project!==""&&(s.project=t.project),typeof t.status=="string"&&t.status!==""&&(s.status=t.status);let l=(t.attachments??[]).map(c=>({id:c.id!=null&&String(c.id)!==""?String(c.id):G(c.download??""),filename:c.filename??"",url:G(c.download??"")})).sort(Vt),u=n.map(c=>({id:String(c.id),author:c.author?.display_name??"",body:G(c.body??""),created:c.created??""})).sort((c,a)=>c.created!==a.created?c.created<a.created?-1:1:Ve(c,a)),i={schema:oe,site:e,team:r.slice(0,r.lastIndexOf("-")),issue:{uuid:t.id,key:r},content:{title:t.summary??"",description:G(t.description??""),fields:s},attachments:l,comments:u};return{bytes:Buffer.from(JSON.stringify(i),"utf8"),envelope:i,warnings:[]}}function Ye(t,n,e){if(typeof t.id!="string"||t.id==="")throw new Error("cannot build a stable identity for this document \u2014 the integrations service returned no document id");let r=(t.attachments??[]).map(o=>({url:G(o.download??String(o.id??"")),filename:o.filename??""})).sort((o,l)=>o.url<l.url?-1:o.url>l.url?1:0),s={schema:ie,site:n,document:{uuid:t.id,slug_id:e},project:{id:t.space?.key??""},title:t.title??"",content:{body:G(t.body??"")},attachments:r};return{bytes:Buffer.from(JSON.stringify(s),"utf8"),envelope:s,warnings:[]}}var Ke=64,Gt=16,Yt=6e6,Kt=5e7,Wt=12e6,se=64,We="https://uploads.linear.app/",Ht=/https:\/\/uploads\.linear\.app\/[^\s)"'`]+/g,zt={png:"image/png",jpeg:"image/jpeg",webp:"image/webp",gif:"image/gif",bmp:"image/bmp",tiff:"image/tiff",emf:"image/emf",wmf:"image/wmf",unknown:"application/octet-stream"},Xt=new Set(["png","jpeg","webp"]);async function He(t,n){let e=[],r=new Map,s=[],o=0,l=new Map,u=[];for(let i=0;i<t.length;i++){let c=t[i],a=`i${i+1}`,d=m=>`[img#${a}] ${c.label}${m?"":" \u2014 not delivered"}`,p=(m,I,L)=>{e.push({ref:a,loc:c.loc,media_type:m,...L?.blob?{blob:L.blob}:{},...L?.appearance?{appearance:L.appearance}:{},delivery:I,...L?.duplicate_of?{duplicate_of:L.duplicate_of}:{}})},y;try{y=await n(c.url)}catch{p("application/octet-stream","external-image-not-fetched"),u.push(d(!1));continue}let w=y.bytes,f=J(w),h=zt[f.format],_=B(w);if(r.set(_,w),!Xt.has(f.format)){let m=f.format==="gif"||f.format==="bmp"||f.format==="tiff"?"unsupported-vision-media-type":"unsupported-image-kind";p(h,m,{blob:_}),u.push(d(!1));continue}if(f.width===void 0||f.height===void 0||f.width*f.height>Kt){p(h,"undecodable",{blob:_}),u.push(d(!1));continue}let b;if(f.format==="png"||f.format==="jpeg"){let m=F(w,f.format);if(m===null){p(h,"undecodable",{blob:_}),u.push(d(!1));continue}b=M(m.data,{width:m.width,height:m.height,channels:m.channels})}if(f.width<Ke||f.height<Ke){p(h,"below-dimension-floor",{blob:_,appearance:b}),u.push(d(!1));continue}let g=l.get(_);if(g!==void 0){p(h,"duplicate",{blob:_,appearance:b,duplicate_of:g}),u.push(d(!1));continue}if(w.byteLength>Yt){p(h,"image-too-large",{blob:_,appearance:b}),u.push(d(!1));continue}if(o+w.byteLength>Wt){p(h,"vision-byte-budget-reached",{blob:_,appearance:b}),u.push(d(!1));continue}if(s.length>=Gt){p(h,"image-cap-reached",{blob:_,appearance:b}),u.push(d(!1));continue}l.set(_,a),o+=w.byteLength,s.push(a),p(h,"selected",{blob:_,appearance:b}),u.push(d(!0))}return{inventory:e,blobs:r,delivered:s,lines:u}}function Zt(t){let n=new Set,e=[];for(let r of t.match(Ht)??[])n.has(r)||(n.add(r),e.push(r));return e}function ze(t){return async n=>{let e;try{e=JSON.parse(n.toString("utf8"))}catch{throw new Error("LINEAR_ENVELOPE_SCHEMA: source bytes are not a kane linear envelope")}if(e.schema!==oe)throw new Error(`LINEAR_ENVELOPE_SCHEMA: unknown envelope schema "${e.schema}" \u2014 this CLI understands ${oe}`);let r=[],s=new Set;for(let a of Zt(e.content.description))s.add(a),r.push({url:a,label:a,loc:`body:${a}`});let o=[];for(let a of e.attachments)if(a.url.startsWith(We)){if(s.has(a.url)){if(a.filename!==""){let d=r.find(p=>p.url===a.url);d!==void 0&&d.label===d.url&&(d.label=a.filename)}continue}s.add(a.url),r.push({url:a.url,label:a.filename||a.url,loc:`attachment:${a.filename||a.url}`})}else a.url!==""&&o.push(`[${o.length+1}] ${a.filename||a.url} \u2014 ${a.url}`);let l=Math.max(0,r.length-se),u=await He(r.slice(0,se),t.fetchAttachment);l>0&&u.lines.push(`${l} more upload links not examined`);let i=[];i.push(`${e.issue.key} \xB7 ${e.site}`,`Title: ${e.content.title}`),e.content.description!==""&&i.push("",...e.content.description.split(`
|
|
11
11
|
`));let c=Object.keys(e.content.fields);return c.length>0&&i.push("","--- fields ---",...c.map(a=>`${a}: ${e.content.fields[a]}`)),u.lines.length>0&&i.push("","--- images ---",...u.lines),o.length>0&&i.push("","--- links ---",...o),e.comments.length>0&&(i.push("","--- comments ---"),e.comments.forEach((a,d)=>{d>0&&i.push(""),i.push(`[${d+1}] ${a.author} \xB7 ${a.created}`,...a.body.split(`
|
|
12
12
|
`))})),{projection:i.join(`
|
|
13
13
|
`)+`
|
|
14
14
|
`,inventory:u.inventory,blobs:u.blobs,delivered:u.delivered,converter:{name:"linear-convert",version:"1",policy:"v1"}}}}function Xe(t){return async n=>{let e;try{e=JSON.parse(n.toString("utf8"))}catch{throw new Error("LINEAR_DOC_ENVELOPE_SCHEMA: source bytes are not a kane linear document envelope")}if(e.schema!==ie)throw new Error(`LINEAR_DOC_ENVELOPE_SCHEMA: unknown envelope schema "${e.schema}" \u2014 this CLI understands ${ie}`);let r=new Set,s=[];for(let i of e.attachments)!i.url.startsWith(We)||r.has(i.url)||(r.add(i.url),s.push({url:i.url,label:i.filename||i.url,loc:`body:${i.url}`}));let o=Math.max(0,s.length-se),l=await He(s.slice(0,se),t.fetchAttachment);o>0&&l.lines.push(`${o} more upload links not examined`);let u=[];return u.push(`${e.title} \xB7 ${e.site}`),e.content.body!==""&&u.push("",...e.content.body.split(`
|
|
15
15
|
`)),l.lines.length>0&&u.push("","--- images ---",...l.lines),{projection:u.join(`
|
|
16
16
|
`)+`
|
|
17
|
-
`,inventory:l.inventory,blobs:l.blobs,delivered:l.delivered,converter:{name:"linear-doc-convert",version:"1",policy:"v1"}}}}var qt=/^[A-Za-z][A-Za-z0-9]*-\d+$/,Qt=/-([0-9a-f]{12})$/;function ue(t){if(!/^https?:\/\/.+/i.test(t))return null;let n;try{n=new URL(t)}catch{return null}return n.hostname.toLowerCase()!=="linear.app"?null:n.pathname.split("/").filter(Boolean)}function Ze(t){let n=ue(t);return n===null||n.length<3?null:{workspace:n[0],segs:n}}function Y(t){let n=Ze(t);if(n===null||n.segs[1]!=="issue")return null;let e=n.segs[2];return qt.test(e)?{workspace:n.workspace,key:e}:null}function K(t){let n=Ze(t);if(n===null||n.segs[1]!=="document")return null;let e=n.segs[2].match(Qt);return e===null?null:{workspace:n.workspace,slugId:e[1]}}var en=new Set(["project","team","view","initiative","cycle","roadmap","inbox","triage","my-issues"]),qe=new Set(["docs","features","method","blog","customers","pricing","integrations","developers","changelog","about","careers","security","download","contact","now","switch","homepage"]);function le(t){let n=ue(t);return n===null||n.length<2||!en.has(n[1])||qe.has(n[0].toLowerCase())?null:{workspace:n[0],section:n[1]}}function de(t){let n=ue(t);return n===null||n.length<2||n[1]!=="issue"&&n[1]!=="document"||qe.has(n[0].toLowerCase())||Y(t)!==null||K(t)!==null?null:{workspace:n[0],section:n[1]}}function Qe(t){let n=Y(t);return n?n.key.toLowerCase():null}function et(t){let n=K(t);return n?`doc-${n.slugId}`:null}var tt={linearInfo:je,linearIssue:Be,linearComments:Me,linearDocument:Je,linearAttachment:Fe};function nt(t,n){if(t)try{let e=new URL(t).pathname.split("/").filter(Boolean)[0];if(e)return`linear.app/${e.toLowerCase()}`}catch{}return`linear.app/${n.toLowerCase()}`}function rt(t,n,e,r,s,o){let l=ee(t,r);if(l!==null&&typeof l.schema=="string"&&l.schema.startsWith(`kane.source.${n}/`)){let i=l;for(let c of e)i=i!==null&&typeof i=="object"?i[c]:void 0;if(typeof i=="string"&&i!==""&&i!==s)return`source '${r}' was ingested from a different ${o} that used this key \u2014 the key was recycled; retire it first (kane-cli context retire ${r}) or ingest under a different id with --as`}let u=ke(t,n,e,s);return u!==null&&u!==r?`this ${o} is already ingested as '${u}' (its key changed) \u2014 reconcile that source, or retire it to re-ingest under the new key`:null}function ot(t,n,e,r){let s=ee(t,e);if(s===null||typeof s.schema!="string"||!s.schema.startsWith(`kane.source.${n}/`))return null;let o=s.site;return typeof o!="string"||o.length===0||o===r?null:`source '${e}' was ingested from ${o}, but this read serves ${r} \u2014 retire it first (kane-cli context retire ${e}) or ingest under a different id with --as`}async function tn(t,n,e,r,s){let o=Y(t);if(o===null)return(e.err??e.out)(`error: ${t}: unsupported remote URL \u2014 expected a Linear issue URL (https://linear.app/<workspace>/issue/KEY-123)`),{code:1};let l=s?.linear??tt;try{let i={auth:await(s?.authEnv??(await import("./auth-2HTDCT7X.js")).resolveLisAuthEnv)(),env:process.env},c=await l.linearInfo(i);if(!c.installed)return(e.err??e.out)(`error: ${t}: no Linear connection for this account \u2014 create one at ${A} and retry`),{code:1};if(c.capabilities.issue===!1||c.capabilities.comments===!1)return(e.err??e.out)(`error: ${t}: the connection cannot read issues or their comments yet \u2014 resync it at ${A} and retry`),{code:1};let a=await l.linearIssue(o.key,i),d=await l.linearComments(o.key,i),p=nt(a.host,o.workspace),{bytes:y,envelope:w,warnings:f}=Ge(a,d,p),h=n??o.key.toLowerCase();N(h);let _=rt(r,"linear",["issue","uuid"],h,w.issue.uuid,"issue")??P(r,h,"linear")??ot(r,"linear",h,p);if(_!==null)return(e.err??e.out)(`error: ${t}: ${_}`),{code:1};let b=await T({contextDir:r,bytes:y,media:Ee,sourceId:h,label:t,confirmSameSource:e.isTTY?g=>e.confirm(`identical content already ingested as ${g} \u2014 treat as the same source?`):void 0,converters:{linear:ze({fetchAttachment:g=>l.linearAttachment(g,i)})}});e.out(U(e.isTTY,b,w.issue.key));for(let g of f)e.out(`warning: ${g}`);for(let g of b.warnings??[])e.out(`warning: ${g}`);if(b.composite){let g=b.composite.delivered+b.composite.omitted;e.out(`${b.source_id}: linear, ${g} images, ${b.composite.delivered} delivered (${b.composite.omitted} omitted)`)}return{code:0,result:{status:b.status,source_id:b.source_id,source_cid:b.cid}}}catch(u){return u instanceof E?((e.err??e.out)(`error: ${t}: ${u.message}`),{code:1}):((e.err??e.out)(`error: ${t}: ${it(u instanceof Error?u.message:String(u),"issue","Linear")}`),{code:1})}}async function nn(t,n,e,r,s){let o=K(t);if(o===null)return(e.err??e.out)(`error: ${t}: unsupported remote URL \u2014 expected a Linear document URL (https://linear.app/<workspace>/document/<slug>)`),{code:1};let l=s?.linear??tt;try{let i={auth:await(s?.authEnv??(await import("./auth-2HTDCT7X.js")).resolveLisAuthEnv)(),env:process.env},c=await l.linearInfo(i);if(!c.installed)return(e.err??e.out)(`error: ${t}: no Linear connection for this account \u2014 create one at ${A} and retry`),{code:1};if(c.capabilities.document===!1)return(e.err??e.out)(`error: ${t}: the connection cannot read documents yet \u2014 resync it at ${A} and retry`),{code:1};let a=await l.linearDocument(o.slugId,i),d=nt(a.url,o.workspace),{bytes:p,envelope:y,warnings:w}=Ye(a,d,o.slugId),f=n??`doc-${o.slugId}`;N(f);let h=rt(r,"linear-doc",["document","uuid"],f,y.document.uuid,"document")??P(r,f,"linear-doc")??ot(r,"linear-doc",f,d);if(h!==null)return(e.err??e.out)(`error: ${t}: ${h}`),{code:1};let _=await T({contextDir:r,bytes:p,media:_e,sourceId:f,label:t,confirmSameSource:e.isTTY?b=>e.confirm(`identical content already ingested as ${b} \u2014 treat as the same source?`):void 0,converters:{linearDoc:Xe({fetchAttachment:b=>l.linearAttachment(b,i)})}});e.out(U(e.isTTY,_,y.title||`document ${o.slugId}`));for(let b of w)e.out(`warning: ${b}`);for(let b of _.warnings??[])e.out(`warning: ${b}`);if(_.composite){let b=_.composite.delivered+_.composite.omitted;e.out(`${_.source_id}: linear document, ${b} images, ${_.composite.delivered} delivered (${_.composite.omitted} omitted)`)}return{code:0,result:{status:_.status,source_id:_.source_id,source_cid:_.cid}}}catch(u){return u instanceof E?((e.err??e.out)(`error: ${t}: ${u.message}`),{code:1}):((e.err??e.out)(`error: ${t}: ${it(u instanceof Error?u.message:String(u),"document","Linear")}`),{code:1})}}function it(t,n,e){let r=t.match(/too large — ([\d.]+ [KM]B), the limit for .+ is ([\d.]+ [KM]B) \[FILE_TOO_LARGE\]/);return r?`the ${n}'s content is too large to ingest (${r[1]}; the limit is ${r[2]}) \u2014 trim the ${n} in ${e} and retry`:t.startsWith("PROJECTION_TOO_LARGE:")?`the ${n}'s text is too large to ingest \u2014 trim the ${n} in ${e} and retry`:t}var st={name:"linear",hint:"Linear issue URLs (https://linear.app/<workspace>/issue/KEY-123)",match:t=>Y(t)!==null,ingest:tn,sourceIdFor:Qe},at={name:"linear-doc",hint:"Linear document URLs (https://linear.app/<workspace>/document/<slug>)",match:t=>K(t)!==null,ingest:nn,sourceIdFor:et},ct={name:"linear-page",hint:"Linear issue or document URLs (other linear.app pages are not ingestable)",match:t=>le(t)!==null||de(t)!==null,ingest:async(t,n,e)=>{let r=le(t);if(r===null){let s=de(t);return s!==null?((e.err??e.out)(`error: ${t}: this Linear ${s.section} link is incomplete or malformed \u2014 use the full form (https://linear.app/${s.workspace}/issue/KEY-123 or https://linear.app/${s.workspace}/document/<slug>-<id>)`),{code:1}):((e.err??e.out)(`error: ${t}: unsupported remote URL \u2014 expected a Linear workspace page`),{code:1})}return(e.err??e.out)(`error: ${t}: this Linear page can't be ingested \u2014 only issue and document URLs are supported; ingest the project's issues or documents individually (https://linear.app/${r.workspace}/issue/KEY-123)`),{code:1}},sourceIdFor:()=>null};var rn=new Set(["invalid_url","target_disallowed","page_not_found","page_access_blocked","page_paywalled","unsupported_content_type","page_too_large","page_timeout","scrape_unavailable","scrape_rate_limited","internal_error","credit_denied"]);async function ut(t,n){let e=n.env??process.env,r=n.fetchImpl??fetch,s=we(e),o={"Content-Type":"application/json"},l=await n.authEnv(),u=l.TESTMUAI_BASIC_AUTH??e.TESTMUAI_BASIC_AUTH,i=l.TESTMUAI_API_KEY??e.TESTMUAI_API_KEY;u?o.Authorization=`Basic ${u}`:i&&(o.Authorization=`Bearer ${i}`);let c;try{c=await r(`${s}/assurance/web/scrape`,{method:"POST",headers:o,body:JSON.stringify({url:t}),signal:AbortSignal.timeout(n.timeoutMs??55e3)})}catch{return{ok:!1,kind:"transport_unreachable"}}if(c.status===401)return{ok:!1,kind:"auth_rejected"};let a;try{a=await c.json()}catch{return{ok:!1,kind:c.status===404?"route_missing":"malformed_response"}}if(c.ok){let p=a.page;return p===void 0||typeof p.markdown!="string"||p.markdown===""||typeof p.final_url!="string"||p.final_url===""||typeof p.projection?.kind!="string"||typeof p.projection?.version!="string"?{ok:!1,kind:"malformed_response"}:{ok:!0,page:p}}let d=a.code;return typeof d=="string"&&rn.has(d)?{ok:!1,kind:d}:c.status===404?{ok:!1,kind:"route_missing"}:c.status===403?{ok:!1,kind:"auth_rejected"}:{ok:!1,kind:"malformed_response"}}var pe="kane.source.web/1";function lt(t,n,e){if(e==="")throw new Error("cannot build a web source from an empty page projection");if(n.kind===""||n.version==="")throw new Error("cannot build a stable identity without a server-reported projection kind/version");let r={schema:pe,url:t,projection:{kind:n.kind,version:n.version},content:{markdown:e}};return{bytes:Buffer.from(JSON.stringify(r),"utf8"),envelope:r}}var on=new Set(["markdown"]);function dt(){return async t=>{let n;try{n=JSON.parse(t.toString("utf8"))}catch{throw new Error("this web source's stored envelope is not readable \u2014 re-ingest the page")}if(n.schema!==pe)throw new Error(`unknown web envelope schema '${String(n.schema)}' \u2014 re-ingest the page with this CLI version`);if(!on.has(n.projection?.kind??""))throw new Error(`unknown web projection kind '${String(n.projection?.kind)}' \u2014 update kane-cli to read this source`);if(typeof n.content?.markdown!="string"||n.content.markdown==="")throw new Error("this web source's stored envelope carries no content \u2014 re-ingest the page");return{projection:n.content.markdown,inventory:[],blobs:new Map,delivered:[],converter:{name:"web-convert",version:"1",policy:"markdown-passthrough"}}}}import{createHash as sn}from"crypto";function pt(t){return ae(t)!==null}function ae(t){if(!/^https?:\/\//i.test(t))return null;let n;try{n=new URL(t)}catch{return null}return n.hostname===""?null:(n.hash="",n.username="",n.password="",n.toString())}function me(t){let n=ae(t);if(n===null)return null;let e=new URL(n),r=(e.hostname+e.pathname).toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,40).replace(/-+$/,""),s=sn("sha256").update(n,"utf8").digest("hex").slice(0,8);return`${r||"page"}-${s}`}function an(t,n){let e=j(t),r=e.heads.get(n);if(r==null)return null;let s=e.getNode(r)?.content?.blob;if(typeof s!="string")return null;let o=W(t,s);if(o===null)return null;try{let l=JSON.parse(o.toString("utf8"));return l.schema!=="kane.source.web/1"?null:typeof l.url=="string"&&l.url.length>0?l.url:null}catch{return null}}function fe(t){switch(t){case"invalid_url":return"this is not a valid public HTTP or HTTPS page URL \u2014 check the address and try again";case"target_disallowed":return"that address cannot be fetched because it does not point to an allowed public web page";case"page_not_found":return"the page could not be found \u2014 check that the URL is correct and that the page still exists";case"page_access_blocked":return"the page refused automated access, so its contents could not be ingested \u2014 use a publicly accessible version of the page";case"page_paywalled":return"the page is behind a paywall or sign-in screen, so its full contents could not be ingested \u2014 use a publicly accessible copy";case"unsupported_content_type":return"the URL does not point to an HTML web page \u2014 download the document and ingest the supported file instead";case"page_too_large":return"the page contains too much text to ingest as a single source \u2014 use a narrower page or trim the content first";case"page_timeout":return"the page took too long to load \u2014 try again later";case"scrape_unavailable":case"scrape_rate_limited":case"internal_error":return"the page ingest service is temporarily unavailable \u2014 try again later";case"credit_denied":return"the page could not be ingested \u2014 your organization is out of credits";case"auth_rejected":return"your credentials were rejected \u2014 run `kane-cli login` and retry";case"route_missing":return"ingesting web pages is not available in your environment yet \u2014 nothing is wrong with the URL; try again later";case"transport_unreachable":return"the page ingest service could not be reached \u2014 check your connection and try again";case"malformed_response":return"the page ingest service returned a response that could not be read safely \u2014 try again later"}}function cn(t){let n=t.match(/too large — ([\d.]+ [KM]B), the limit for .+ is ([\d.]+ [KM]B) \[FILE_TOO_LARGE\]/);return n?`the page contains too much text to ingest as a single source (${n[1]}; the limit is ${n[2]}) \u2014 use a narrower page or trim the content first`:t.startsWith("PROJECTION_TOO_LARGE:")?"the page contains too much text to ingest as a single source \u2014 use a narrower page or trim the content first":t}async function un(t,n,e,r,s){let o=ae(t);if(o===null)return(e.err??e.out)(`error: ${t}: ${fe("invalid_url")}`),{code:1};let l=me(t),u=n??l;if(u===null)return(e.err??e.out)(`error: ${t}: ${fe("invalid_url")}`),{code:1};try{N(u)}catch(y){return(e.err??e.out)(`error: ${t}: ${y instanceof Error?y.message:String(y)}`),{code:1}}let i=P(r,u,"web");if(i!==null)return(e.err??e.out)(`error: ${t}: ${i}`),{code:1};let c=an(r,u);if(c!==null&&c!==o){if(!e.isTTY)return(e.err??e.out)(`error: ${t}: source '${u}' was ingested from ${c} \u2014 re-run on a TTY to adopt the new URL as its next version, or ingest under a different id with --as`),{code:1};if(!await e.confirm(`source '${u}' was ingested from ${c} \u2014 treat ${o} as its new version (replaces the current version; items built on it go stale)?`))return e.out(`skipped ${t} \u2014 ingest under a different id with --as to keep both pages`),{code:1}}let a=s?.web?.scrape??ut,d=s?.authEnv??(async()=>(await import("./spawner-YQSAPZR4.js")).resolveAgentAuthEnv()),p=await a(o,{authEnv:d});if(!p.ok)return(e.err??e.out)(`error: ${t}: ${fe(p.kind)}`),{code:1};try{let{bytes:y}=lt(o,p.page.projection,p.page.markdown),w=await T({contextDir:r,bytes:y,media:be,sourceId:u,label:o,confirmSameSource:e.isTTY?h=>e.confirm(`identical content already ingested as ${h} \u2014 treat as the same source?`):void 0,converters:{web:dt()}}),f=new URL(o).hostname+new URL(o).pathname;e.out(U(e.isTTY,w,f));for(let h of w.warnings??[])e.out(`warning: ${h}`);return e.isTTY&&p.page.title&&e.out(` title: ${p.page.title}`),{code:0,result:{status:w.status,source_id:w.source_id,source_cid:w.cid}}}catch(y){return(e.err??e.out)(`error: ${t}: ${cn(y instanceof Error?y.message:String(y))}`),{code:1}}}var mt={name:"web",hint:"any public web page URL (https://\u2026)",match:pt,ingest:un,sourceIdFor:me};function U(t,n,e){return t?n.status==="created"?`landed ${n.source_id} (${e}) \u2014 new source`:n.status==="versioned"?`landed ${n.source_id} (${e}) \u2014 new version; dependents go stale`:`${n.source_id} unchanged \u2014 already landed`:`${n.status} ${n.source_id} source ${n.cid} blob ${n.blob}`}var ln=[Oe,De,st,at,ct,mt];function Kr(t){return/^https?:\/\/.+/i.test(t)}function Wr(t){return ln.find(n=>n.match(t))??null}export{U as a,ln as b,Kr as c,Wr as d};
|
|
17
|
+
`,inventory:l.inventory,blobs:l.blobs,delivered:l.delivered,converter:{name:"linear-doc-convert",version:"1",policy:"v1"}}}}var qt=/^[A-Za-z][A-Za-z0-9]*-\d+$/,Qt=/-([0-9a-f]{12})$/;function ue(t){if(!/^https?:\/\/.+/i.test(t))return null;let n;try{n=new URL(t)}catch{return null}return n.hostname.toLowerCase()!=="linear.app"?null:n.pathname.split("/").filter(Boolean)}function Ze(t){let n=ue(t);return n===null||n.length<3?null:{workspace:n[0],segs:n}}function Y(t){let n=Ze(t);if(n===null||n.segs[1]!=="issue")return null;let e=n.segs[2];return qt.test(e)?{workspace:n.workspace,key:e}:null}function K(t){let n=Ze(t);if(n===null||n.segs[1]!=="document")return null;let e=n.segs[2].match(Qt);return e===null?null:{workspace:n.workspace,slugId:e[1]}}var en=new Set(["project","team","view","initiative","cycle","roadmap","inbox","triage","my-issues"]),qe=new Set(["docs","features","method","blog","customers","pricing","integrations","developers","changelog","about","careers","security","download","contact","now","switch","homepage"]);function le(t){let n=ue(t);return n===null||n.length<2||!en.has(n[1])||qe.has(n[0].toLowerCase())?null:{workspace:n[0],section:n[1]}}function de(t){let n=ue(t);return n===null||n.length<2||n[1]!=="issue"&&n[1]!=="document"||qe.has(n[0].toLowerCase())||Y(t)!==null||K(t)!==null?null:{workspace:n[0],section:n[1]}}function Qe(t){let n=Y(t);return n?n.key.toLowerCase():null}function et(t){let n=K(t);return n?`doc-${n.slugId}`:null}var tt={linearInfo:je,linearIssue:Be,linearComments:Me,linearDocument:Je,linearAttachment:Fe};function nt(t,n){if(t)try{let e=new URL(t).pathname.split("/").filter(Boolean)[0];if(e)return`linear.app/${e.toLowerCase()}`}catch{}return`linear.app/${n.toLowerCase()}`}function rt(t,n,e,r,s,o){let l=ee(t,r);if(l!==null&&typeof l.schema=="string"&&l.schema.startsWith(`kane.source.${n}/`)){let i=l;for(let c of e)i=i!==null&&typeof i=="object"?i[c]:void 0;if(typeof i=="string"&&i!==""&&i!==s)return`source '${r}' was ingested from a different ${o} that used this key \u2014 the key was recycled; retire it first (kane-cli context retire ${r}) or ingest under a different id with --as`}let u=ke(t,n,e,s);return u!==null&&u!==r?`this ${o} is already ingested as '${u}' (its key changed) \u2014 reconcile that source, or retire it to re-ingest under the new key`:null}function ot(t,n,e,r){let s=ee(t,e);if(s===null||typeof s.schema!="string"||!s.schema.startsWith(`kane.source.${n}/`))return null;let o=s.site;return typeof o!="string"||o.length===0||o===r?null:`source '${e}' was ingested from ${o}, but this read serves ${r} \u2014 retire it first (kane-cli context retire ${e}) or ingest under a different id with --as`}async function tn(t,n,e,r,s){let o=Y(t);if(o===null)return(e.err??e.out)(`error: ${t}: unsupported remote URL \u2014 expected a Linear issue URL (https://linear.app/<workspace>/issue/KEY-123)`),{code:1};let l=s?.linear??tt;try{let i={auth:await(s?.authEnv??(await import("./auth-5WJSFLCP.js")).resolveLisAuthEnv)(),env:process.env},c=await l.linearInfo(i);if(!c.installed)return(e.err??e.out)(`error: ${t}: no Linear connection for this account \u2014 create one at ${A} and retry`),{code:1};if(c.capabilities.issue===!1||c.capabilities.comments===!1)return(e.err??e.out)(`error: ${t}: the connection cannot read issues or their comments yet \u2014 resync it at ${A} and retry`),{code:1};let a=await l.linearIssue(o.key,i),d=await l.linearComments(o.key,i),p=nt(a.host,o.workspace),{bytes:y,envelope:w,warnings:f}=Ge(a,d,p),h=n??o.key.toLowerCase();N(h);let _=rt(r,"linear",["issue","uuid"],h,w.issue.uuid,"issue")??P(r,h,"linear")??ot(r,"linear",h,p);if(_!==null)return(e.err??e.out)(`error: ${t}: ${_}`),{code:1};let b=await T({contextDir:r,bytes:y,media:Ee,sourceId:h,label:t,confirmSameSource:e.isTTY?g=>e.confirm(`identical content already ingested as ${g} \u2014 treat as the same source?`):void 0,converters:{linear:ze({fetchAttachment:g=>l.linearAttachment(g,i)})}});e.out(U(e.isTTY,b,w.issue.key));for(let g of f)e.out(`warning: ${g}`);for(let g of b.warnings??[])e.out(`warning: ${g}`);if(b.composite){let g=b.composite.delivered+b.composite.omitted;e.out(`${b.source_id}: linear, ${g} images, ${b.composite.delivered} delivered (${b.composite.omitted} omitted)`)}return{code:0,result:{status:b.status,source_id:b.source_id,source_cid:b.cid}}}catch(u){return u instanceof E?((e.err??e.out)(`error: ${t}: ${u.message}`),{code:1}):((e.err??e.out)(`error: ${t}: ${it(u instanceof Error?u.message:String(u),"issue","Linear")}`),{code:1})}}async function nn(t,n,e,r,s){let o=K(t);if(o===null)return(e.err??e.out)(`error: ${t}: unsupported remote URL \u2014 expected a Linear document URL (https://linear.app/<workspace>/document/<slug>)`),{code:1};let l=s?.linear??tt;try{let i={auth:await(s?.authEnv??(await import("./auth-5WJSFLCP.js")).resolveLisAuthEnv)(),env:process.env},c=await l.linearInfo(i);if(!c.installed)return(e.err??e.out)(`error: ${t}: no Linear connection for this account \u2014 create one at ${A} and retry`),{code:1};if(c.capabilities.document===!1)return(e.err??e.out)(`error: ${t}: the connection cannot read documents yet \u2014 resync it at ${A} and retry`),{code:1};let a=await l.linearDocument(o.slugId,i),d=nt(a.url,o.workspace),{bytes:p,envelope:y,warnings:w}=Ye(a,d,o.slugId),f=n??`doc-${o.slugId}`;N(f);let h=rt(r,"linear-doc",["document","uuid"],f,y.document.uuid,"document")??P(r,f,"linear-doc")??ot(r,"linear-doc",f,d);if(h!==null)return(e.err??e.out)(`error: ${t}: ${h}`),{code:1};let _=await T({contextDir:r,bytes:p,media:_e,sourceId:f,label:t,confirmSameSource:e.isTTY?b=>e.confirm(`identical content already ingested as ${b} \u2014 treat as the same source?`):void 0,converters:{linearDoc:Xe({fetchAttachment:b=>l.linearAttachment(b,i)})}});e.out(U(e.isTTY,_,y.title||`document ${o.slugId}`));for(let b of w)e.out(`warning: ${b}`);for(let b of _.warnings??[])e.out(`warning: ${b}`);if(_.composite){let b=_.composite.delivered+_.composite.omitted;e.out(`${_.source_id}: linear document, ${b} images, ${_.composite.delivered} delivered (${_.composite.omitted} omitted)`)}return{code:0,result:{status:_.status,source_id:_.source_id,source_cid:_.cid}}}catch(u){return u instanceof E?((e.err??e.out)(`error: ${t}: ${u.message}`),{code:1}):((e.err??e.out)(`error: ${t}: ${it(u instanceof Error?u.message:String(u),"document","Linear")}`),{code:1})}}function it(t,n,e){let r=t.match(/too large — ([\d.]+ [KM]B), the limit for .+ is ([\d.]+ [KM]B) \[FILE_TOO_LARGE\]/);return r?`the ${n}'s content is too large to ingest (${r[1]}; the limit is ${r[2]}) \u2014 trim the ${n} in ${e} and retry`:t.startsWith("PROJECTION_TOO_LARGE:")?`the ${n}'s text is too large to ingest \u2014 trim the ${n} in ${e} and retry`:t}var st={name:"linear",hint:"Linear issue URLs (https://linear.app/<workspace>/issue/KEY-123)",match:t=>Y(t)!==null,ingest:tn,sourceIdFor:Qe},at={name:"linear-doc",hint:"Linear document URLs (https://linear.app/<workspace>/document/<slug>)",match:t=>K(t)!==null,ingest:nn,sourceIdFor:et},ct={name:"linear-page",hint:"Linear issue or document URLs (other linear.app pages are not ingestable)",match:t=>le(t)!==null||de(t)!==null,ingest:async(t,n,e)=>{let r=le(t);if(r===null){let s=de(t);return s!==null?((e.err??e.out)(`error: ${t}: this Linear ${s.section} link is incomplete or malformed \u2014 use the full form (https://linear.app/${s.workspace}/issue/KEY-123 or https://linear.app/${s.workspace}/document/<slug>-<id>)`),{code:1}):((e.err??e.out)(`error: ${t}: unsupported remote URL \u2014 expected a Linear workspace page`),{code:1})}return(e.err??e.out)(`error: ${t}: this Linear page can't be ingested \u2014 only issue and document URLs are supported; ingest the project's issues or documents individually (https://linear.app/${r.workspace}/issue/KEY-123)`),{code:1}},sourceIdFor:()=>null};var rn=new Set(["invalid_url","target_disallowed","page_not_found","page_access_blocked","page_paywalled","unsupported_content_type","page_too_large","page_timeout","scrape_unavailable","scrape_rate_limited","internal_error","credit_denied"]);async function ut(t,n){let e=n.env??process.env,r=n.fetchImpl??fetch,s=we(e),o={"Content-Type":"application/json"},l=await n.authEnv(),u=l.TESTMUAI_BASIC_AUTH??e.TESTMUAI_BASIC_AUTH,i=l.TESTMUAI_API_KEY??e.TESTMUAI_API_KEY;u?o.Authorization=`Basic ${u}`:i&&(o.Authorization=`Bearer ${i}`);let c;try{c=await r(`${s}/assurance/web/scrape`,{method:"POST",headers:o,body:JSON.stringify({url:t}),signal:AbortSignal.timeout(n.timeoutMs??55e3)})}catch{return{ok:!1,kind:"transport_unreachable"}}if(c.status===401)return{ok:!1,kind:"auth_rejected"};let a;try{a=await c.json()}catch{return{ok:!1,kind:c.status===404?"route_missing":"malformed_response"}}if(c.ok){let p=a.page;return p===void 0||typeof p.markdown!="string"||p.markdown===""||typeof p.final_url!="string"||p.final_url===""||typeof p.projection?.kind!="string"||typeof p.projection?.version!="string"?{ok:!1,kind:"malformed_response"}:{ok:!0,page:p}}let d=a.code;return typeof d=="string"&&rn.has(d)?{ok:!1,kind:d}:c.status===404?{ok:!1,kind:"route_missing"}:c.status===403?{ok:!1,kind:"auth_rejected"}:{ok:!1,kind:"malformed_response"}}var pe="kane.source.web/1";function lt(t,n,e){if(e==="")throw new Error("cannot build a web source from an empty page projection");if(n.kind===""||n.version==="")throw new Error("cannot build a stable identity without a server-reported projection kind/version");let r={schema:pe,url:t,projection:{kind:n.kind,version:n.version},content:{markdown:e}};return{bytes:Buffer.from(JSON.stringify(r),"utf8"),envelope:r}}var on=new Set(["markdown"]);function dt(){return async t=>{let n;try{n=JSON.parse(t.toString("utf8"))}catch{throw new Error("this web source's stored envelope is not readable \u2014 re-ingest the page")}if(n.schema!==pe)throw new Error(`unknown web envelope schema '${String(n.schema)}' \u2014 re-ingest the page with this CLI version`);if(!on.has(n.projection?.kind??""))throw new Error(`unknown web projection kind '${String(n.projection?.kind)}' \u2014 update kane-cli to read this source`);if(typeof n.content?.markdown!="string"||n.content.markdown==="")throw new Error("this web source's stored envelope carries no content \u2014 re-ingest the page");return{projection:n.content.markdown,inventory:[],blobs:new Map,delivered:[],converter:{name:"web-convert",version:"1",policy:"markdown-passthrough"}}}}import{createHash as sn}from"crypto";function pt(t){return ae(t)!==null}function ae(t){if(!/^https?:\/\//i.test(t))return null;let n;try{n=new URL(t)}catch{return null}return n.hostname===""?null:(n.hash="",n.username="",n.password="",n.toString())}function me(t){let n=ae(t);if(n===null)return null;let e=new URL(n),r=(e.hostname+e.pathname).toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,40).replace(/-+$/,""),s=sn("sha256").update(n,"utf8").digest("hex").slice(0,8);return`${r||"page"}-${s}`}function an(t,n){let e=j(t),r=e.heads.get(n);if(r==null)return null;let s=e.getNode(r)?.content?.blob;if(typeof s!="string")return null;let o=W(t,s);if(o===null)return null;try{let l=JSON.parse(o.toString("utf8"));return l.schema!=="kane.source.web/1"?null:typeof l.url=="string"&&l.url.length>0?l.url:null}catch{return null}}function fe(t){switch(t){case"invalid_url":return"this is not a valid public HTTP or HTTPS page URL \u2014 check the address and try again";case"target_disallowed":return"that address cannot be fetched because it does not point to an allowed public web page";case"page_not_found":return"the page could not be found \u2014 check that the URL is correct and that the page still exists";case"page_access_blocked":return"the page refused automated access, so its contents could not be ingested \u2014 use a publicly accessible version of the page";case"page_paywalled":return"the page is behind a paywall or sign-in screen, so its full contents could not be ingested \u2014 use a publicly accessible copy";case"unsupported_content_type":return"the URL does not point to an HTML web page \u2014 download the document and ingest the supported file instead";case"page_too_large":return"the page contains too much text to ingest as a single source \u2014 use a narrower page or trim the content first";case"page_timeout":return"the page took too long to load \u2014 try again later";case"scrape_unavailable":case"scrape_rate_limited":case"internal_error":return"the page ingest service is temporarily unavailable \u2014 try again later";case"credit_denied":return"the page could not be ingested \u2014 your organization is out of credits";case"auth_rejected":return"your credentials were rejected \u2014 run `kane-cli login` and retry";case"route_missing":return"ingesting web pages is not available in your environment yet \u2014 nothing is wrong with the URL; try again later";case"transport_unreachable":return"the page ingest service could not be reached \u2014 check your connection and try again";case"malformed_response":return"the page ingest service returned a response that could not be read safely \u2014 try again later"}}function cn(t){let n=t.match(/too large — ([\d.]+ [KM]B), the limit for .+ is ([\d.]+ [KM]B) \[FILE_TOO_LARGE\]/);return n?`the page contains too much text to ingest as a single source (${n[1]}; the limit is ${n[2]}) \u2014 use a narrower page or trim the content first`:t.startsWith("PROJECTION_TOO_LARGE:")?"the page contains too much text to ingest as a single source \u2014 use a narrower page or trim the content first":t}async function un(t,n,e,r,s){let o=ae(t);if(o===null)return(e.err??e.out)(`error: ${t}: ${fe("invalid_url")}`),{code:1};let l=me(t),u=n??l;if(u===null)return(e.err??e.out)(`error: ${t}: ${fe("invalid_url")}`),{code:1};try{N(u)}catch(y){return(e.err??e.out)(`error: ${t}: ${y instanceof Error?y.message:String(y)}`),{code:1}}let i=P(r,u,"web");if(i!==null)return(e.err??e.out)(`error: ${t}: ${i}`),{code:1};let c=an(r,u);if(c!==null&&c!==o){if(!e.isTTY)return(e.err??e.out)(`error: ${t}: source '${u}' was ingested from ${c} \u2014 re-run on a TTY to adopt the new URL as its next version, or ingest under a different id with --as`),{code:1};if(!await e.confirm(`source '${u}' was ingested from ${c} \u2014 treat ${o} as its new version (replaces the current version; items built on it go stale)?`))return e.out(`skipped ${t} \u2014 ingest under a different id with --as to keep both pages`),{code:1}}let a=s?.web?.scrape??ut,d=s?.authEnv??(async()=>(await import("./spawner-URQ5OAY7.js")).resolveAgentAuthEnv()),p=await a(o,{authEnv:d});if(!p.ok)return(e.err??e.out)(`error: ${t}: ${fe(p.kind)}`),{code:1};try{let{bytes:y}=lt(o,p.page.projection,p.page.markdown),w=await T({contextDir:r,bytes:y,media:be,sourceId:u,label:o,confirmSameSource:e.isTTY?h=>e.confirm(`identical content already ingested as ${h} \u2014 treat as the same source?`):void 0,converters:{web:dt()}}),f=new URL(o).hostname+new URL(o).pathname;e.out(U(e.isTTY,w,f));for(let h of w.warnings??[])e.out(`warning: ${h}`);return e.isTTY&&p.page.title&&e.out(` title: ${p.page.title}`),{code:0,result:{status:w.status,source_id:w.source_id,source_cid:w.cid}}}catch(y){return(e.err??e.out)(`error: ${t}: ${cn(y instanceof Error?y.message:String(y))}`),{code:1}}}var mt={name:"web",hint:"any public web page URL (https://\u2026)",match:pt,ingest:un,sourceIdFor:me};function U(t,n,e){return t?n.status==="created"?`landed ${n.source_id} (${e}) \u2014 new source`:n.status==="versioned"?`landed ${n.source_id} (${e}) \u2014 new version; dependents go stale`:`${n.source_id} unchanged \u2014 already landed`:`${n.status} ${n.source_id} source ${n.cid} blob ${n.blob}`}var ln=[Oe,De,st,at,ct,mt];function Kr(t){return/^https?:\/\/.+/i.test(t)}function Wr(t){return ln.find(n=>n.match(t))??null}export{U as a,ln as b,Kr as c,Wr as d};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as h}from"./chunk-
|
|
2
|
+
import{a as h}from"./chunk-5NBT5IVT.js";import{x as l}from"./chunk-DEUDRSU7.js";import{a as A}from"./chunk-HCBYKLMW.js";import{a as c,b as f,i as P}from"./chunk-C44QQJR4.js";import{a as B}from"./chunk-6YGTRKDT.js";import{e as x}from"./chunk-UR6MHSHU.js";var L=x(B(),1);var n=x(A(),1);function S(r,d,s,u,m){let p=s==="basic"&&u?`basic (${u})`:s,i=20,a=`${r} [${d}]`,g="\xB7".repeat(Math.max(2,i-a.length+3));return{label:`${a} ${g} ${p}`,profile:r,env:d,isActive:m}}function M({creds:r,onSwitch:d,onCancel:s}){let u=r.listProfiles(),m=r.getActiveProfile(),p=r.getDefaultEnv(),i=u.map(e=>{let o=r.loadBasicAuth(e.profile,e.env),t=r.loadCredentials(e.profile,e.env)!==null,v=o?"basic":t?"oauth":"none",b=o?o.username:null,w=e.profile===m&&e.env===p;return S(e.profile,e.env,v,b,w)}),[a,g]=(0,L.useState)(()=>{let e=i.findIndex(o=>o.isActive);return e>=0?e:0});return P((e,o)=>{if(o.escape){s();return}if(o.upArrow){g(t=>Math.max(0,t-1));return}if(o.downArrow){g(t=>Math.min(i.length-1,t+1));return}if(o.return&&i[a]){let t=i[a];t.isActive||d(t.profile,t.env),s();return}}),i.length===0?(0,n.jsxs)(c,{flexDirection:"column",borderStyle:"round",borderColor:l.orange,paddingX:2,paddingY:1,children:[(0,n.jsx)(f,{color:l.orange,bold:!0,children:"Profiles"}),(0,n.jsx)(c,{marginTop:1,children:(0,n.jsx)(f,{color:l.dim,children:"No profiles \u2014 use Login to create one"})}),(0,n.jsx)(h,{bindings:[],escBackLabel:"back"})]}):(0,n.jsxs)(c,{flexDirection:"column",borderStyle:"round",borderColor:l.orange,paddingX:2,paddingY:1,children:[(0,n.jsx)(f,{color:l.orange,bold:!0,children:"Profiles"}),(0,n.jsx)(c,{flexDirection:"column",marginTop:1,children:i.map((e,o)=>{let t=o===a,v=t?"\u276F ":" ",b=e.isActive?l.green:t?l.orange:void 0;return(0,n.jsxs)(f,{color:b,children:[v,e.label,e.isActive?" \u25CF active":""]},`${e.profile}-${e.env}`)})}),(0,n.jsx)(h,{bindings:[{keys:"\u2191\u2193",label:"navigate"},{keys:"\u21B5",label:"switch"}],escBackLabel:"back"})]})}export{S as a,M as b};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as b,b as $}from"./chunk-
|
|
2
|
+
import{a as b,b as $}from"./chunk-R4EGL7VM.js";function C(n){return n.replace(/\n$/,"").split(`
|
|
3
3
|
`).map((l,o)=>`${String(o+1).padStart(4,"0")}| ${l}`).join(`
|
|
4
4
|
`)}function S(n,d,l){if(!n.quote)return n;let o=$(l,n.anchor);if(o!==null&&o.includes(n.quote))return n;let a=d.indexOf(n.quote);if(a===-1||d.indexOf(n.quote,a+1)!==-1)return"gone-or-ambiguous";let t=d.slice(0,a).split(`
|
|
5
5
|
`).length,r=t+n.quote.replace(/\n$/,"").split(`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{j as Re,k as oe,l as se,m as _e,n as $e,o as ae}from"./chunk-ZXTVP4WX.js";import{a as te,c as re,d as ye,f as ie}from"./chunk-5YBKKWJA.js";import{a as P,b as we,d as ke}from"./chunk-OS4VSIHT.js";import{d as ve}from"./chunk-6J5T5FEY.js";import{a as S}from"./chunk-O5U6EAL3.js";import{a as X,b as N,c as ee,d as W,e as he,g as O,h as ne}from"./chunk-W5TTF7GB.js";import{a as ge}from"./chunk-BZAGVBCX.js";import{b as Z,c as J,d as Q}from"./chunk-DF3DUGJS.js";import{h as me,j as pe}from"./chunk-54JZ6VEW.js";import{C as I}from"./chunk-W3Z7AZNT.js";import{g as T}from"./chunk-XMTSHHYQ.js";import{existsSync as Oe,statSync as Ue}from"fs";import{basename as G,resolve as q}from"path";function Ee(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 ce(e,n){let t=[...e.rows.filter(a=>a.kind!=="REMOVE").map(a=>[a.kind,S(a.ref),a.reason,Ee(a.impact)]),...e.archive.map(a=>["ARCHIVE",S(a.ref),a.why,Ee(a.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(...ve(["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 xe=new Set(["interactive","agent","ci","override"]);function Ae(e,n){if(e.mode!==void 0&&!xe.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 Pe(e){let{makeHeadlessIO:n,agentRefusal:t}=await import("./headless-io-66RG5NN5.js");return t(n("ndjson","reconcile"),e,"MODE_USAGE")}function Me(e,n,t,r){if(J(t)){let v=Q(t),s=v?.sourceIdFor(t)??null;if(v===null||s===null)return{error:`--from '${t}' is not a supported remote URL \u2014 supported: ${Z.map(u=>u.hint).join("; ")}`};if(r!==void 0&&r!==s)return{error:`--source-id '${r}' does not match this URL's own identity '${s}' \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(s))return{error:`unknown source '${s}' \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(s)==null)return{error:`source '${s}' is retired \u2014 restore it first with \`kane-cli context revert\`, then reconcile`};let _=z(e,s,{remoteUrl:t});return _!==null?{error:_}:{sourceId:s,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=q(n,t);if(!Oe(i)||!Ue(i).isFile())return{error:`--from '${t}' is not a file \u2014 pass the changed source document`};let a=me(i);if(!a.ok)return{error:`--from '${t}' is not an ingestable document \u2014 allowed: ${a.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 f=null;try{f=pe(i)}catch{}return f!==null&&f!==r&&o.heads.get(f)!=null?{error:`'${G(i)}' already backs live source '${f}' \u2014 did you mean --source-id ${f}? To truly move these bytes under '${r}', retire '${f}' first`}:{sourceId:r,filePath:i}}function C(e){return e==null?"(none)":e.slice(0,19)}function Y(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 a=n.changeset??[],o=(f,v)=>{let s=a.filter(c=>c.kind===f).length;return s>0?`${s} ${v}`:null},w=[o("ADD","add"),o("MODIFY","modify"),o("ARCHIVE","archive")].filter(Boolean);n.changed&&e.out(`changeset: ${a.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 a=n.changeset??[];e.out(`changeset: ${a.length} item(s)`);for(let o of a)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=le(o.impact,"retiring drops");w&&e.out(` ${w}`)}}e.out(`plan: ${n.rows.length} row(s)`);for(let a of n.rows){e.out(` [${a.kind}] ${S(a.ref)} \u2014 ${a.reason}`);let o=le(a.impact,"approving marks");o&&e.out(` ${o}`),e.out(` provenance: ${a.provenance}`),e.out(` action: ${a.action}`)}}function De(e,n){return ce({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 le(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 M(e,n,t,r,i,a,o=[],w="override",f,v,s,c,_,u,E){let m;try{m=ne(e)}catch(d){return P(r,d instanceof Error?d.message:String(d)),1}try{if(!t){let{runWalkSession:d}=await import("./walk-session-LNFOCPJ6.js"),{telemetryEnvName:R}=await import("./bootstrap-TNFANHSS.js");return await d({dir:e,rows:n,archive:o,held:f??null,childMode:w,runDesign:c??null,mark:a,markA:s,...v?{archiveState:v}:{},...u?{meta:{verb:"reconcile",sid:u,env:R()}}:{},...E?{resumeCmd:E}:{},signals:b=>U(e,b.ref,b.verdict,b.reason),..._?{script:_}:{}})}return await Te(e,n,t,r,i,a,o,w,f,v)}finally{m()}}var H=(e,n)=>e?`kane-cli maintain reconcile --from ${e} --source-id ${n}`:void 0,He=e=>e===null?void 0:"filePath"in e?e.filePath:e.remoteUrl,V=e=>`${e} high-risk item(s) need a human \u2014 ci mode won't guess. Walk interactively or use --mode agent.`;function F(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 de(e={}){return{type:"reconcile_summary",applied:0,skipped:0,deferred:0,plan_only:0,failed:0,paused:0,stale_created:0,...e}}var L=de();async function j(e,n,t,r,i,a,o,w,f){F(i,n,t);let v=n.changeset.filter(_=>_.kind==="ARCHIVE"&&f?.[_.ref]===void 0),s=n.rows,c;try{c=ne(e)}catch(_){return i({type:"error",message:_ instanceof Error?_.message:String(_)}),i(de()),2}try{return await Fe(e,n,t,r,i,a,o,s,v,w)}finally{c()}}async function Fe(e,n,t,r,i,a,o,w,f,v){let s=0,c=0,_=0,u=0,E=0,m=0,d=0,R=new Set,b=(h,p)=>{try{v?.(h,p)}catch{}};for(let[h,p]of w.entries()){i({type:"reconcile_row_start",kind:p.kind,ref:p.ref,...p.impact?{stale:p.impact.stale_refs.length,direct:p.impact.direct_refs?.length??0}:{}});let g=(l,$,x)=>i({type:"reconcile_row_end",kind:p.kind,ref:p.ref,outcome:l,...$!==void 0?{exit_code:$}:{},...x?{detail:x}:{}});if(p.applied){c++,g("skipped");continue}if(p.kind==="REMOVE"){E++,g("plan-only");continue}if(p.held_ref&&n.held){let l=new Set;if(p.kind==="MODIFY"&&p.impact){let x=I(e);for(let A of p.impact.stale_refs){let K=x.resolve(A);K&&x.stale(K.tip)==="fresh"&&l.add(A)}}let $=oe(e,n.held,p.held_ref,ue);if(!$.ok){_++,d===0&&(d=1),g("failed",1,$.message);continue}if($.kind==="ADD"){let x=await r($.ref,{yes:!0,mode:o});if(x!==0){x===3?(u++,d===0&&(d=3),g("paused",3)):(_++,d===0&&(d=1),g("failed",x));continue}}s++,$.kind!=="ADD"&&p.impact&&(m+=l.size),b(h,"approved"),U(e,p.ref,$.kind==="ADD"?"gap-resolved-create":"gap-resolved-evolve"),g("applied");continue}let y=te(I(e),p.ref);if(!y.ok){c++,g("skipped");continue}let k=y.target;if(R.has(k.ucTip)){c++,g("skipped");continue}if(p.kind==="ADD"){let l=await r(k.seamRef,{yes:!0,mode:o});if(l===3){u++,d===0&&(d=3),g("paused",3);continue}if(l!==0){_++,d===0&&(d=1),g("failed",l);continue}R.add(k.ucTip),s++,b(h,"approved"),U(e,p.ref,"gap-resolved-create"),g("applied")}else{let l=await re(e,k,{yes:!0,mode:o},a,r,"batch");l.outcome==="evolved"?(R.add(k.ucTip),s++,b(h,"approved"),U(e,p.ref,"gap-resolved-evolve"),g("applied")):l.outcome==="paused"?(u++,d===0&&(d=l.code),g("paused",l.code)):l.outcome==="failed"?(_++,d===0&&(d=1),g("failed",l.code)):(c++,g("skipped"))}}return f.length>0&&(i({type:"reconcile_paused",plan_path:t,pending:f.map(h=>({ref:h.ref,why:h.why}))}),u+=f.length,d===0&&(d=3)),i(de({applied:s,skipped:c,plan_only:E,failed:_,paused:u,stale_created:m})),d}var ue={kind:"human",id:process.env.USER??"operator"};function U(e,n,t,r){ge(e,{ts:new Date().toISOString(),command:"reconcile-walk",id:n,verdict:t,polarity:"preference",by:ue,target:n,...r!==void 0?{reason:r}:{}})}async function Te(e,n,t,r,i,a,o=[],w="override",f,v){let s=0,c=0,_=0,u=0,E=0,m=0,d=0,R=new Set;for(let[b,h]of n.entries()){if(h.applied){r.out(`skipped ${h.ref} \u2014 already applied (${h.applied.outcome} at ${h.applied.at})`),c++;continue}let p=l=>{try{a?.(b,l)}catch($){P(r,`could not record applied state for ${h.ref}: ${$ instanceof Error?$.message:String($)}`)}};if(h.kind==="REMOVE"){r.out(`REMOVE ${h.ref} \u2014 plan-only in this release (not executed)`),u++;continue}if(h.held_ref&&f){let l=oe(e,f,h.held_ref,ue);if(!l.ok){P(r,`held ${h.ref}: ${l.message}`),E++,d===0&&(d=1);continue}if(r.out(`committed ${l.ref} (${h.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`),m++,d===0&&(d=3),p("approved");continue}if($!==0){P(r,`design run for ${l.ref} ended with exit code ${$}`),E++,d===0&&(d=1),p("approved");continue}}s++,p("approved"),U(e,h.ref,h.kind==="ADD"?"gap-resolved-create":"gap-resolved-evolve");continue}let g=I(e),y=te(g,h.ref);if(!y.ok){r.out(`skipped ${h.ref} \u2014 ${y.message}`),c++;continue}let k=y.target;if(R.has(k.ucTip)){r.out(`skipped ${h.ref} \u2014 use-case ${k.display} already handled in this walk`),c++;continue}if(h.kind==="ADD"){let l=await i(k.seamRef,{yes:t,mode:w});if(l===3){r.out(`design session for ${k.display} paused \u2014 resume with the "kane-cli design tests --resume <session>" command printed above; this row lands when that session completes`),m++,d===0&&(d=3);continue}if(l!==0){P(r,`design run for ${k.display} ended with exit code ${l}`),E++,d===0&&(d=1);continue}R.add(k.ucTip),s++,p("approved"),U(e,h.ref,"gap-resolved-create")}else{let l=await re(e,k,{yes:!0,mode:w},r,i,"batch");l.outcome==="evolved"?(R.add(k.ucTip),s++,p("approved"),U(e,h.ref,"gap-resolved-evolve")):l.outcome==="paused"?(m++,d===0&&(d=l.code)):l.outcome==="failed"?(E++,d===0&&(d=l.code)):c++}}for(let b of o)if(b.kind==="ARCHIVE"&&v?.[b.ref]===void 0){r.out(`[ARCHIVE] ${b.ref} \u2014 ${b.why}`);{let h=le(b.impact,"retiring drops");h&&r.out(` ${h}`)}r.out(" plan-only \u2014 retire belongs to the interactive session (never headless)"),u++}return r.out(`reconcile walk: ${s} applied, ${c} skipped, ${_} deferred, ${u} plan-only`+(E>0?`, ${E} failed`:"")+(m>0?`, ${m} paused`:"")),d}var Be=new Set(Z.map(e=>e.name));function z(e,n,t){let r=I(e),i=r.heads.get(n);if(i==null)return null;let a=r.mediaOf(i);if("remoteUrl"in t){let o=Q(t.remoteUrl)?.name??"remote";return a.format!==o?`source '${n}' is backed by ${a.format} content, not a ${o} source \u2014 reconcile it with the --from it was originally ingested from`:null}return Be.has(a.format)?`source '${n}' is a remote ${a.format} source \u2014 pass its URL to --from, not a file`:null}function fe(e,n,t,r){return"remoteUrl"in n?$e(e,n.remoteUrl,{out:t.out,err:t.err},r.remoteFindProvider):_e(e,n.filePath)}function Ie(e){return e.remote_url!==void 0?{remoteUrl:e.remote_url}:e.backing_path!==void 0?{filePath:e.backing_path}:null}async function Se(e,n,t,r,i,a=!1,o=!1){let w=i.seams??{reingest:fe(e,t,r,i),reextract:ae(e,{stage:a,hostOut:c=>r.out(c),hostEmit:c=>{c.type!=="run_start"&&i.emitEvent?.(c)},...i.emitEvent?{}:{hostProgress:c=>process.stderr.write(c+`
|
|
3
|
-
`)}})},f=null,v={reingest:w.reingest,reextract:async c=>f=await w.reextract(c)},s;try{r.out(`reconciling ${n}: re-reading the source and comparing against the graph\u2026`),s=await(i.buildPlan??se)(e,n,v)}catch(c){return P(r,`reconcile failed: ${c instanceof Error?c.message:String(c)}`),null}if(s.changed)if(o)for(let c of De(s,f))r.out(c);else Y(r,s,f,!1,i.emitEvent);return s}async function Ve(e){let[{render:n},t,{ScrollbackProvider:r},{ChatSurface:i},{makeChatController:a},{makeReconcileDeps:o}]=await Promise.all([import("./build-JIKYOZUH.js"),import("./react-QWOAB3TB.js"),import("./scrollback-JLPJR25X.js"),import("./ChatSurface-
|
|
4
|
-
`)}})},u;try{u=await(r.buildPlan??se)(e,n.source_id,_,{resumeHeld:v})}catch(g){return P(t,`reconcile failed: ${g instanceof Error?g.message:String(g)}`),1}if(i==="interactive"&&!o)for(let g of De(u,null))t.out(g);else Y(t,u,null,!1,r.emitEvent);let E=T(e),m=null;if(E!=null){let g={},y=new Set(u.changeset.filter(k=>k.kind==="ARCHIVE").map(k=>k.ref));for(let[k,l]of Object.entries(n.archive_state??{}))y.has(k)&&(g[k]=l);m=X(e,{version:2,source_id:u.source_id,...n.remote_url!==void 0?{remote_url:n.remote_url}:{backing_path:n.backing_path},head_pin:E,created:new Date().toISOString().replace(/[:.]/g,"-"),skipped_arms:u.skipped_arms,note:u.note,changeset:u.changeset,rows:u.rows,...u.held?{held:u.held}:{},...Object.keys(g).length>0?{archive_state:g}:{}}),t.out(`plan stored: ${m}`)}if(o){if(i==="agent"){let g=r.emitEvent??(()=>{});F(g,u,m),g({...L})}return 0}let d=r.emitEvent??(()=>{}),R=m?N(e,m).plan.archive_state:void 0,b=m?(g,y)=>O(m,g,y):void 0,h=m?(g,y)=>W(m,g,y):void 0;if(i==="agent")return j(e,u,m,a,d,t,D(i),b,R);let p=u.changeset.filter(g=>g.kind==="ARCHIVE"&&R?.[g.ref]===void 0);return i==="ci"&&p.length>0?(P(t,V(p.length)),2):M(e,u.rows,i==="override"||i==="ci",t,a,b,u.changeset,D(i),u.held,R,h,w,f,u.source_id,H(n.backing_path??n.remote_url,u.source_id))}async function be(e,n,t={},r=process.cwd()){let{telemetryBootstrap:i,telemetryEnvName:a}=await import("./bootstrap-
|
|
2
|
+
import{j as Re,k as oe,l as se,m as _e,n as $e,o as ae}from"./chunk-4SXJKDHO.js";import{a as te,c as re,d as ye,f as ie}from"./chunk-HFRMJP2P.js";import{a as P,b as we,d as ke}from"./chunk-OS4VSIHT.js";import{a as X,b as N,c as ee,d as W,e as he,g as O,h as ne}from"./chunk-W5TTF7GB.js";import{a as ge}from"./chunk-BZAGVBCX.js";import{d as ve}from"./chunk-6J5T5FEY.js";import{a as S}from"./chunk-YELGHSVH.js";import{b as Z,c as J,d as Q}from"./chunk-YQ4MRF57.js";import{h as me,j as pe}from"./chunk-3D7VYEDP.js";import{C as I}from"./chunk-R4EGL7VM.js";import{g as T}from"./chunk-OXHMUZJV.js";import{existsSync as Oe,statSync as Ue}from"fs";import{basename as G,resolve as q}from"path";function Ee(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 ce(e,n){let t=[...e.rows.filter(a=>a.kind!=="REMOVE").map(a=>[a.kind,S(a.ref),a.reason,Ee(a.impact)]),...e.archive.map(a=>["ARCHIVE",S(a.ref),a.why,Ee(a.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(...ve(["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 xe=new Set(["interactive","agent","ci","override"]);function Ae(e,n){if(e.mode!==void 0&&!xe.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 Pe(e){let{makeHeadlessIO:n,agentRefusal:t}=await import("./headless-io-66RG5NN5.js");return t(n("ndjson","reconcile"),e,"MODE_USAGE")}function Me(e,n,t,r){if(J(t)){let v=Q(t),s=v?.sourceIdFor(t)??null;if(v===null||s===null)return{error:`--from '${t}' is not a supported remote URL \u2014 supported: ${Z.map(u=>u.hint).join("; ")}`};if(r!==void 0&&r!==s)return{error:`--source-id '${r}' does not match this URL's own identity '${s}' \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(s))return{error:`unknown source '${s}' \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(s)==null)return{error:`source '${s}' is retired \u2014 restore it first with \`kane-cli context revert\`, then reconcile`};let _=z(e,s,{remoteUrl:t});return _!==null?{error:_}:{sourceId:s,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=q(n,t);if(!Oe(i)||!Ue(i).isFile())return{error:`--from '${t}' is not a file \u2014 pass the changed source document`};let a=me(i);if(!a.ok)return{error:`--from '${t}' is not an ingestable document \u2014 allowed: ${a.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 f=null;try{f=pe(i)}catch{}return f!==null&&f!==r&&o.heads.get(f)!=null?{error:`'${G(i)}' already backs live source '${f}' \u2014 did you mean --source-id ${f}? To truly move these bytes under '${r}', retire '${f}' first`}:{sourceId:r,filePath:i}}function C(e){return e==null?"(none)":e.slice(0,19)}function Y(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 a=n.changeset??[],o=(f,v)=>{let s=a.filter(c=>c.kind===f).length;return s>0?`${s} ${v}`:null},w=[o("ADD","add"),o("MODIFY","modify"),o("ARCHIVE","archive")].filter(Boolean);n.changed&&e.out(`changeset: ${a.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 a=n.changeset??[];e.out(`changeset: ${a.length} item(s)`);for(let o of a)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=le(o.impact,"retiring drops");w&&e.out(` ${w}`)}}e.out(`plan: ${n.rows.length} row(s)`);for(let a of n.rows){e.out(` [${a.kind}] ${S(a.ref)} \u2014 ${a.reason}`);let o=le(a.impact,"approving marks");o&&e.out(` ${o}`),e.out(` provenance: ${a.provenance}`),e.out(` action: ${a.action}`)}}function De(e,n){return ce({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 le(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 M(e,n,t,r,i,a,o=[],w="override",f,v,s,c,_,u,E){let m;try{m=ne(e)}catch(d){return P(r,d instanceof Error?d.message:String(d)),1}try{if(!t){let{runWalkSession:d}=await import("./walk-session-EYBUURRA.js"),{telemetryEnvName:R}=await import("./bootstrap-3LNHRDQH.js");return await d({dir:e,rows:n,archive:o,held:f??null,childMode:w,runDesign:c??null,mark:a,markA:s,...v?{archiveState:v}:{},...u?{meta:{verb:"reconcile",sid:u,env:R()}}:{},...E?{resumeCmd:E}:{},signals:b=>U(e,b.ref,b.verdict,b.reason),..._?{script:_}:{}})}return await Te(e,n,t,r,i,a,o,w,f,v)}finally{m()}}var H=(e,n)=>e?`kane-cli maintain reconcile --from ${e} --source-id ${n}`:void 0,He=e=>e===null?void 0:"filePath"in e?e.filePath:e.remoteUrl,V=e=>`${e} high-risk item(s) need a human \u2014 ci mode won't guess. Walk interactively or use --mode agent.`;function F(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 de(e={}){return{type:"reconcile_summary",applied:0,skipped:0,deferred:0,plan_only:0,failed:0,paused:0,stale_created:0,...e}}var L=de();async function j(e,n,t,r,i,a,o,w,f){F(i,n,t);let v=n.changeset.filter(_=>_.kind==="ARCHIVE"&&f?.[_.ref]===void 0),s=n.rows,c;try{c=ne(e)}catch(_){return i({type:"error",message:_ instanceof Error?_.message:String(_)}),i(de()),2}try{return await Fe(e,n,t,r,i,a,o,s,v,w)}finally{c()}}async function Fe(e,n,t,r,i,a,o,w,f,v){let s=0,c=0,_=0,u=0,E=0,m=0,d=0,R=new Set,b=(h,p)=>{try{v?.(h,p)}catch{}};for(let[h,p]of w.entries()){i({type:"reconcile_row_start",kind:p.kind,ref:p.ref,...p.impact?{stale:p.impact.stale_refs.length,direct:p.impact.direct_refs?.length??0}:{}});let g=(l,$,x)=>i({type:"reconcile_row_end",kind:p.kind,ref:p.ref,outcome:l,...$!==void 0?{exit_code:$}:{},...x?{detail:x}:{}});if(p.applied){c++,g("skipped");continue}if(p.kind==="REMOVE"){E++,g("plan-only");continue}if(p.held_ref&&n.held){let l=new Set;if(p.kind==="MODIFY"&&p.impact){let x=I(e);for(let A of p.impact.stale_refs){let K=x.resolve(A);K&&x.stale(K.tip)==="fresh"&&l.add(A)}}let $=oe(e,n.held,p.held_ref,ue);if(!$.ok){_++,d===0&&(d=1),g("failed",1,$.message);continue}if($.kind==="ADD"){let x=await r($.ref,{yes:!0,mode:o});if(x!==0){x===3?(u++,d===0&&(d=3),g("paused",3)):(_++,d===0&&(d=1),g("failed",x));continue}}s++,$.kind!=="ADD"&&p.impact&&(m+=l.size),b(h,"approved"),U(e,p.ref,$.kind==="ADD"?"gap-resolved-create":"gap-resolved-evolve"),g("applied");continue}let y=te(I(e),p.ref);if(!y.ok){c++,g("skipped");continue}let k=y.target;if(R.has(k.ucTip)){c++,g("skipped");continue}if(p.kind==="ADD"){let l=await r(k.seamRef,{yes:!0,mode:o});if(l===3){u++,d===0&&(d=3),g("paused",3);continue}if(l!==0){_++,d===0&&(d=1),g("failed",l);continue}R.add(k.ucTip),s++,b(h,"approved"),U(e,p.ref,"gap-resolved-create"),g("applied")}else{let l=await re(e,k,{yes:!0,mode:o},a,r,"batch");l.outcome==="evolved"?(R.add(k.ucTip),s++,b(h,"approved"),U(e,p.ref,"gap-resolved-evolve"),g("applied")):l.outcome==="paused"?(u++,d===0&&(d=l.code),g("paused",l.code)):l.outcome==="failed"?(_++,d===0&&(d=1),g("failed",l.code)):(c++,g("skipped"))}}return f.length>0&&(i({type:"reconcile_paused",plan_path:t,pending:f.map(h=>({ref:h.ref,why:h.why}))}),u+=f.length,d===0&&(d=3)),i(de({applied:s,skipped:c,plan_only:E,failed:_,paused:u,stale_created:m})),d}var ue={kind:"human",id:process.env.USER??"operator"};function U(e,n,t,r){ge(e,{ts:new Date().toISOString(),command:"reconcile-walk",id:n,verdict:t,polarity:"preference",by:ue,target:n,...r!==void 0?{reason:r}:{}})}async function Te(e,n,t,r,i,a,o=[],w="override",f,v){let s=0,c=0,_=0,u=0,E=0,m=0,d=0,R=new Set;for(let[b,h]of n.entries()){if(h.applied){r.out(`skipped ${h.ref} \u2014 already applied (${h.applied.outcome} at ${h.applied.at})`),c++;continue}let p=l=>{try{a?.(b,l)}catch($){P(r,`could not record applied state for ${h.ref}: ${$ instanceof Error?$.message:String($)}`)}};if(h.kind==="REMOVE"){r.out(`REMOVE ${h.ref} \u2014 plan-only in this release (not executed)`),u++;continue}if(h.held_ref&&f){let l=oe(e,f,h.held_ref,ue);if(!l.ok){P(r,`held ${h.ref}: ${l.message}`),E++,d===0&&(d=1);continue}if(r.out(`committed ${l.ref} (${h.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`),m++,d===0&&(d=3),p("approved");continue}if($!==0){P(r,`design run for ${l.ref} ended with exit code ${$}`),E++,d===0&&(d=1),p("approved");continue}}s++,p("approved"),U(e,h.ref,h.kind==="ADD"?"gap-resolved-create":"gap-resolved-evolve");continue}let g=I(e),y=te(g,h.ref);if(!y.ok){r.out(`skipped ${h.ref} \u2014 ${y.message}`),c++;continue}let k=y.target;if(R.has(k.ucTip)){r.out(`skipped ${h.ref} \u2014 use-case ${k.display} already handled in this walk`),c++;continue}if(h.kind==="ADD"){let l=await i(k.seamRef,{yes:t,mode:w});if(l===3){r.out(`design session for ${k.display} paused \u2014 resume with the "kane-cli design tests --resume <session>" command printed above; this row lands when that session completes`),m++,d===0&&(d=3);continue}if(l!==0){P(r,`design run for ${k.display} ended with exit code ${l}`),E++,d===0&&(d=1);continue}R.add(k.ucTip),s++,p("approved"),U(e,h.ref,"gap-resolved-create")}else{let l=await re(e,k,{yes:!0,mode:w},r,i,"batch");l.outcome==="evolved"?(R.add(k.ucTip),s++,p("approved"),U(e,h.ref,"gap-resolved-evolve")):l.outcome==="paused"?(m++,d===0&&(d=l.code)):l.outcome==="failed"?(E++,d===0&&(d=l.code)):c++}}for(let b of o)if(b.kind==="ARCHIVE"&&v?.[b.ref]===void 0){r.out(`[ARCHIVE] ${b.ref} \u2014 ${b.why}`);{let h=le(b.impact,"retiring drops");h&&r.out(` ${h}`)}r.out(" plan-only \u2014 retire belongs to the interactive session (never headless)"),u++}return r.out(`reconcile walk: ${s} applied, ${c} skipped, ${_} deferred, ${u} plan-only`+(E>0?`, ${E} failed`:"")+(m>0?`, ${m} paused`:"")),d}var Be=new Set(Z.map(e=>e.name));function z(e,n,t){let r=I(e),i=r.heads.get(n);if(i==null)return null;let a=r.mediaOf(i);if("remoteUrl"in t){let o=Q(t.remoteUrl)?.name??"remote";return a.format!==o?`source '${n}' is backed by ${a.format} content, not a ${o} source \u2014 reconcile it with the --from it was originally ingested from`:null}return Be.has(a.format)?`source '${n}' is a remote ${a.format} source \u2014 pass its URL to --from, not a file`:null}function fe(e,n,t,r){return"remoteUrl"in n?$e(e,n.remoteUrl,{out:t.out,err:t.err},r.remoteFindProvider):_e(e,n.filePath)}function Ie(e){return e.remote_url!==void 0?{remoteUrl:e.remote_url}:e.backing_path!==void 0?{filePath:e.backing_path}:null}async function Se(e,n,t,r,i,a=!1,o=!1){let w=i.seams??{reingest:fe(e,t,r,i),reextract:ae(e,{stage:a,hostOut:c=>r.out(c),hostEmit:c=>{c.type!=="run_start"&&i.emitEvent?.(c)},...i.emitEvent?{}:{hostProgress:c=>process.stderr.write(c+`
|
|
3
|
+
`)}})},f=null,v={reingest:w.reingest,reextract:async c=>f=await w.reextract(c)},s;try{r.out(`reconciling ${n}: re-reading the source and comparing against the graph\u2026`),s=await(i.buildPlan??se)(e,n,v)}catch(c){return P(r,`reconcile failed: ${c instanceof Error?c.message:String(c)}`),null}if(s.changed)if(o)for(let c of De(s,f))r.out(c);else Y(r,s,f,!1,i.emitEvent);return s}async function Ve(e){let[{render:n},t,{ScrollbackProvider:r},{ChatSurface:i},{makeChatController:a},{makeReconcileDeps:o}]=await Promise.all([import("./build-JIKYOZUH.js"),import("./react-QWOAB3TB.js"),import("./scrollback-JLPJR25X.js"),import("./ChatSurface-YFJDAXOG.js"),import("./chat-controller-6GW2HSJP.js"),import("./reconcile-deps-GMQA6ULT.js")]),w=t.default??t,f=a(),v=o({contextDir:e,note:s=>f.note(s)});return new Promise(s=>{let c=n(w.createElement(r,null,w.createElement(i,{controller:f,verb:"extract",reconcile:v,autoReview:!0,onReviewExit:()=>{c.unmount(),s(0)},onCtrlC:()=>{c.unmount(),s(v.pending()?3:0)}})),{exitOnCtrlC:!1})})}async function Le(e,n,t,r,i){let a=N(e,n);if("error"in a)return P(r,a.error),2;let{plan:o,path:w}=a,f=t==="override"||t==="ci";if(n===void 0&&t==="interactive"&&r.isTTY&&!await r.confirm(`apply plan ${G(w)} for ${o.source_id} (created ${o.created})?`))return r.out(`not applying ${G(w)}`),0;let v=i.runDesignForUc??ie,s=i.runDesignForUc??null,c=i.sessionScript,_=(h,p)=>O(w,h,p),u=(h,p)=>W(w,h,p),E=T(e);if(E===o.head_pin){if(t==="agent"){let p=i.emitEvent??(()=>{});return j(e,B(o),w,v,p,r,D(t),_,o.archive_state)}let h=ee(o);if(t==="ci"&&h.length>0)return P(r,V(h.length)),2;if(r.out(`applying stored plan ${G(w)} for ${o.source_id} (${o.rows.length} row(s))`),!f)for(let p of ce({source_id:o.source_id,head:{status:"stored plan"},rows:o.rows,archive:(o.changeset??[]).filter(g=>g.kind==="ARCHIVE"),changed:!1,held:!!o.held},process.stdout.columns))r.out(p);return M(e,o.rows,f,r,v,_,o.changeset??[],D(t),o.held,o.archive_state,u,s,c,o.source_id,H(o.backing_path??o.remote_url,o.source_id))}if(r.out(`graph moved since this plan (${C(o.head_pin)} \u2192 ${C(E)}) \u2014 recomputing`),o.held)return Ce(e,o,r,i,t,v,!1);let m=Ie(o);if(m===null)return P(r,`stored plan for ${o.source_id} names no backing file or URL \u2014 re-run reconcile --from`),2;let d=z(e,o.source_id,m);if(d!==null)return P(r,`stored plan cannot replay: ${d}`),2;let R=await Se(e,o.source_id,m,r,i,!1,t==="interactive");if(!R)return 1;if(!R.changed)return Y(r,R,null,!1,i.emitEvent),0;if(t==="agent"){let h=i.emitEvent??(()=>{});return j(e,R,null,v,h,r,D(t))}let b=R.changeset.filter(h=>h.kind==="ARCHIVE");return t==="ci"&&b.length>0?(P(r,V(b.length)),2):M(e,R.rows,f,r,v,void 0,R.changeset,D(t),R.held,void 0,void 0,s,c,R.source_id,H(He(m),R.source_id))}function B(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 je(e,n,t,r,i,a,o){let w=r.runDesignForUc??null,f=r.sessionScript,v=he(e,n);if(v===null)return null;if("error"in v)return P(t,v.error),2;let{plan:s,path:c}=v,_=s.rows.filter(d=>d.applied===void 0),u=ee(s),E=r.emitEvent??(()=>{});if(_.length===0&&u.length===0){t.out(`already reconciled \u2014 plan ${s.created} applied ${s.rows.length} row(s)`);let d=ye(I(e)).staleCount;return d>0&&(t.out(`${d} item(s) still stale \u2014 kane-cli maintain evolve --from-stale`),E({type:"stale_debt",count:d})),i==="agent"&&(F(E,B(s),c),E({...L})),0}let m=T(e);return m!==s.head_pin?(t.out(`plan ${s.created} superseded \u2014 graph moved (${C(s.head_pin)} \u2192 ${C(m)}); recomputing`),Ce(e,s,t,r,i,a,o)):(t.out(`resuming plan ${s.created} \u2014 ${_.length} pending row(s)${u.length>0?`, ${u.length} undecided archive item(s)`:""}`),o?(Y(t,B(s),null,!1,r.emitEvent),t.out(`plan stored: ${c}`),i==="agent"&&(F(E,B(s),c),E({...L})),0):i==="agent"?j(e,B(s),c,a,E,t,D(i),(d,R)=>O(c,d,R),s.archive_state):i==="ci"&&u.length>0?(P(t,V(u.length)),2):M(e,s.rows,i==="override"||i==="ci",t,a,(d,R)=>O(c,d,R),s.changeset??[],D(i),s.held,s.archive_state,(d,R)=>W(c,d,R),w,f,s.source_id,H(s.backing_path??s.remote_url,s.source_id)))}async function Ce(e,n,t,r,i,a,o){let w=r.runDesignForUc??null,f=r.sessionScript,v;if(n.held){let g=I(e),y=new Set(n.rows.filter(l=>l.held_ref!==void 0&&l.applied!==void 0).map(l=>l.held_ref)),k=[];for(let l of n.held.rows){if(y.has(l.temp_ref))continue;if(!l.matched_cid){k.push(l);continue}let $=g.tipOf(l.matched_cid);if(g.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}k.push($===l.matched_cid?l:{...l,matched_cid:$,uc:{...l.uc,matches_existing:{cid:$}}})}v={source_id:n.held.source_id,rows:k}}let s=Ie(n);if(s===null)return P(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,s);if(c!==null)return P(t,`stored plan cannot replay: ${c}`),2;let _=r.seams??{reingest:fe(e,s,t,r),reextract:ae(e,{stage:v!==void 0,hostOut:g=>t.out(g),hostEmit:g=>{g.type!=="run_start"&&r.emitEvent?.(g)},...r.emitEvent?{}:{hostProgress:g=>process.stderr.write(g+`
|
|
4
|
+
`)}})},u;try{u=await(r.buildPlan??se)(e,n.source_id,_,{resumeHeld:v})}catch(g){return P(t,`reconcile failed: ${g instanceof Error?g.message:String(g)}`),1}if(i==="interactive"&&!o)for(let g of De(u,null))t.out(g);else Y(t,u,null,!1,r.emitEvent);let E=T(e),m=null;if(E!=null){let g={},y=new Set(u.changeset.filter(k=>k.kind==="ARCHIVE").map(k=>k.ref));for(let[k,l]of Object.entries(n.archive_state??{}))y.has(k)&&(g[k]=l);m=X(e,{version:2,source_id:u.source_id,...n.remote_url!==void 0?{remote_url:n.remote_url}:{backing_path:n.backing_path},head_pin:E,created:new Date().toISOString().replace(/[:.]/g,"-"),skipped_arms:u.skipped_arms,note:u.note,changeset:u.changeset,rows:u.rows,...u.held?{held:u.held}:{},...Object.keys(g).length>0?{archive_state:g}:{}}),t.out(`plan stored: ${m}`)}if(o){if(i==="agent"){let g=r.emitEvent??(()=>{});F(g,u,m),g({...L})}return 0}let d=r.emitEvent??(()=>{}),R=m?N(e,m).plan.archive_state:void 0,b=m?(g,y)=>O(m,g,y):void 0,h=m?(g,y)=>W(m,g,y):void 0;if(i==="agent")return j(e,u,m,a,d,t,D(i),b,R);let p=u.changeset.filter(g=>g.kind==="ARCHIVE"&&R?.[g.ref]===void 0);return i==="ci"&&p.length>0?(P(t,V(p.length)),2):M(e,u.rows,i==="override"||i==="ci",t,a,b,u.changeset,D(i),u.held,R,h,w,f,u.source_id,H(n.backing_path??n.remote_url,u.source_id))}async function be(e,n,t={},r=process.cwd()){let{telemetryBootstrap:i,telemetryEnvName:a}=await import("./bootstrap-3LNHRDQH.js"),o=i({verb:"reconcile",mode:typeof e.mode=="string"?e.mode:"interactive",contextRoot:q(r,".context"),env:a(),applyPlanPath:typeof e.apply=="string"?q(r,e.apply):void 0,write:!0,longSession:!0});e.mode==="agent"&&t.emitEvent?.({type:"run_start",session:o.ids.session_id});let w=await Ye(e,n,t,r);return w===1&&e.mode!=="agent"&&(n.err??n.out)(o.supportFooter()),await o.end({exit_code:w}),w}async function Ye(e,n,t={},r=process.cwd()){let i=e.apply!==void 0&&e.apply!==!1,a=typeof e.apply=="string"?e.apply:void 0;if(e.plan&&i)return P(n,"pass --plan OR --apply, not both"),2;let o=e.from!==void 0||!i,w=e.from!==void 0&&J(e.from);if(o&&(!e.from||!e.sourceId&&!w))return P(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&&a!==void 0)return P(n,"pass --from OR --apply <path>, not both \u2014 a stored plan names its own source"),2;let f=we(r,n);if(!f)return 2;if(e.mode!==void 0&&!xe.has(e.mode))return Pe(`--mode must be interactive | agent | ci | override, got '${e.mode}'`);let v=e.mode==="agent"||e.mode==="ci"||e.mode==="override";if(i&&!v&&!n.isTTY)return P(n,"refusing to apply without a TTY to confirm \u2014 pass --mode override|ci"),2;let s=!e.plan,c="override";if(e.from){let y=Ae(e,n.isTTY);if(typeof y=="object")return y.code==="MODE_USAGE"?Pe(y.error):(P(n,y.error),2);c=y}let _=c==="override"||c==="ci";if(i&&!e.from){let{makeReconcileDeps:y}=await import("./reconcile-deps-GMQA6ULT.js"),k=a===void 0?y({contextDir:f}).pending():null;if(k?.kind==="cards"){let $=e.mode??"interactive";return!n.isTTY||$!=="interactive"?(P(n,`a held changeset for ${k.source} awaits review (${k.count} change(s)) \u2014 resume in a terminal: kane-cli maintain reconcile --apply [HELD_REVIEW]`),2):(t.cardApplyMount??Ve)(f)}let l=e.mode??"interactive";return Le(f,a===void 0?void 0:q(r,a),l,n,t)}let u=Me(f,r,e.from,e.sourceId);if("error"in u)return P(n,u.error),2;if(!i){let{sessionsHoldingSource:y}=await import("./sessions-GIEXOCE4.js"),{holders:k,corrupt:l}=y(f,u.sourceId);if(l>0)return P(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(k.length>0)return P(n,`session ${k[0]} holds item(s) for review pinned to ${u.sourceId} \u2014 finish that review first: kane-cli context extract --resume ${k[0]} [SOURCE_HELD]`),2}if(c==="interactive"&&!e.plan&&!i){let y=t.seams?.reingest??fe(f,u,n,t),k;try{k=await y(u.sourceId)}catch($){return P(n,$ instanceof Error?$.message:String($)),1}let l=k.status==="unchanged"?null:Re(f,u.sourceId);if(k.status!=="unchanged"&&!l)return n.out(`${u.sourceId} landed for the first time \u2014 extract it: kane-cli context extract --source ${u.sourceId}`),0;if(l){let x=await(t.chatMount??(async A=>{let{bindExtractInteractive:K}=await import("./extract-bind-PPMY4FFA.js");return K(A)}))({mode:"interactive",posture:"reconcile",source:u.sourceId,changeContext:l});if(x===3){let{sessionsHoldingSource:A}=await import("./sessions-GIEXOCE4.js");if(A(f,u.sourceId).holders.length===0)return 0}return x}}let E="remoteUrl"in u?{remoteUrl:u.remoteUrl}:{filePath:u.filePath},m=await Se(f,u.sourceId,E,n,t,!!e.plan||c==="interactive",c==="interactive"&&!e.plan);if(!m)return 1;let d=t.runDesignForUc??ie,R=t.runDesignForUc??null,b=t.sessionScript;if(!m.changed){let y=await je(f,u.sourceId,n,t,c,d,!!e.plan);if(y!==null)return y;if(Y(n,m,null,!1,t.emitEvent),c==="agent"){let k=t.emitEvent??(()=>{});F(k,m,null),k({...L})}return 0}let h=T(f),p=null;if(h!=null?p=X(f,{version:2,source_id:m.source_id,..."remoteUrl"in E?{remote_url:E.remoteUrl}:{backing_path:E.filePath},head_pin:h,created:new Date().toISOString().replace(/[:.]/g,"-"),skipped_arms:m.skipped_arms,note:m.note,changeset:m.changeset,rows:m.rows,...m.held?{held:m.held}:{}}):P(n,"no chain head after extract \u2014 plan not stored"),c==="agent"){let y=t.emitEvent??(()=>{});if(!s)return F(y,m,p),y({...L}),0;let k=p?(l,$)=>O(p,l,$):void 0;return j(f,m,p,d,y,n,D(c),k)}if(!s)return p&&n.out(`plan stored: ${p}`),0;let g=m.changeset.filter(y=>y.kind==="ARCHIVE");if(c==="ci"&&g.length>0)return p&&n.out(`plan stored: ${p}`),P(n,V(g.length)),2;if(p){n.out(`plan stored: ${p}`);let y=p;return M(f,Ke(f,y)??m.rows,_,n,d,(k,l)=>O(y,k,l),m.changeset,D(c),m.held,void 0,void 0,R,b,m.source_id,H(e.from,m.source_id))}return M(f,m.rows,_,n,d,void 0,m.changeset,D(c),m.held,void 0,void 0,R,b,m.source_id,H(e.from,m.source_id))}function Ke(e,n){let t=N(e,n);return"error"in t?null:t.plan.rows}async function dn(e,n={},t,r=process.cwd()){if(e.mode==="agent"){let{makeHeadlessIO:i}=await import("./headless-io-66RG5NN5.js"),a=t?i("ndjson","reconcile",t):i("ndjson","reconcile"),o={out:a.out,err:v=>a.event({type:"error",message:v}),isTTY:!1,confirm:async()=>!1,ask:async()=>""},{runWithChannel:w}=await import("./run-channel-RGH4WIQX.js"),f=2;try{f=await w({event:v=>a.event(v)},()=>be(e,o,{...n,emitEvent:v=>a.event(v)},r))}catch(v){f=1,a.event({type:"error",message:v instanceof Error?v.message:String(v)})}return a.done(f)}return be(e,ke(),n,r)}export{Ae as a,Me as b,D as c,U as d,be as e,dn as f};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{d as ae,e as ce}from"./chunk-AXTPNZPX.js";import{a as oe}from"./chunk-L2TV4G56.js";import{b as V,d as se}from"./chunk-
|
|
2
|
+
import{d as ae,e as ce}from"./chunk-AXTPNZPX.js";import{a as oe}from"./chunk-L2TV4G56.js";import{b as V,d as se}from"./chunk-B7K5WOOU.js";import{d as ie}from"./chunk-NVGBE2DR.js";var pe=new Set(["approve","edit","reject"]),de=new Set(["approve","edit","reject","add","enhance","retract"]);function fe(i,t){return`chatop:${t}:${i.target??"new"}:${i.op}:${i.seq}`}function me(i,t,w,y){let l=fe(i,t),g=i.payload;switch(i.op){case"approve":return{kind:"approve",target:i.target,expectedCid:i.expected_cid,eventId:l};case"edit":{let{reason:s,...x}=g;return{kind:"edit",target:i.target,expectedCid:i.expected_cid,edit:x,reason:s,eventId:l}}case"enhance":return{kind:"enhance",target:i.target,expectedCid:i.expected_cid,edges:g.edges??[],eventId:l};case"retract":{let s=typeof g.reason=="string"?g.reason.trim():"";if(!s)throw new Error("INVALID_RETRACT: a retract needs a non-empty reason");let x=g.edge_ecid!==void 0&&g.edge_ecid!==null,a=g.edge!==void 0&&g.edge!==null;if(x&&a)throw new Error("INVALID_RETRACT: both edge_ecid and edge were sent \u2014 give exactly one");if(!x&&!a)throw new Error("INVALID_RETRACT: neither edge {type, dst, src?} (display refs) nor edge_ecid was sent \u2014 give exactly one");let f={kind:"retract",target:i.target,expectedCid:i.expected_cid,reason:s};if(x){if(typeof g.edge_ecid!="string"||!g.edge_ecid)throw new Error("INVALID_RETRACT: edge_ecid must be a non-empty string");return{...f,edgeEcid:g.edge_ecid,eventId:`chatop:${t}:${i.target}:retract:e:${g.edge_ecid}:${i.seq}`}}let p=g.edge;if(typeof p!="object"||typeof p.type!="string"||!p.type||typeof p.dst!="string"||!p.dst)throw new Error("INVALID_RETRACT: edge needs {type, dst} (src optional), all display refs");if(p.src!==void 0&&p.src!==null&&(typeof p.src!="string"||!p.src))throw new Error("INVALID_RETRACT: edge.src, when given, must be a non-empty display ref");let v=typeof p.src=="string"?p.src:void 0;return{...f,edgeRef:{type:p.type,dst:p.dst,...v!==void 0?{src:v}:{}},eventId:`chatop:${t}:${i.target}:retract:t:${p.type}:${p.dst}:${v??"-"}:${i.seq}`}}case"reject":return{kind:"reject",target:i.target,expectedCid:i.expected_cid,reason:g.reason??"",redirectTo:g.redirect_to,eventId:l};case"add":{let s=g.proposal_item??{},x=String(s.label??"");if(!w.mint_gate.includes(x))throw new Error(`GATED_LABEL: cannot mint "${x}" (gate: ${w.mint_gate.join(", ")})`);let a=s.cite??{},f=s.conv_source_id??y;if(!f||typeof a.turn!="number"||!a.quote)throw new Error("INVALID_ADD: a chat add requires a conversation cite {turn, quote} and conv_source_id");let p=s.content,v=p&&typeof p=="object"&&!Array.isArray(p)&&Object.keys(p).length>0?p:null,C=new Set(["label","cite","conv_source_id","content","rationale","edges"]),_=v??Object.fromEntries(Object.entries(s).filter(([$])=>!C.has($)));return{kind:"add",label:x,content:_,cite:{turn:a.turn,quote:a.quote},convSourceId:f,rationale:s.rationale,eventId:l}}}}function le(i,t,w={}){let y=w.turn??0,l=[],g=[];for(let a of i){if(!de.has(a.op))throw new Error(`UNKNOWN_OP: "${a.op}" is not a chat op (accepted: ${[...de].join(", ")})`);if(a.op!=="add"&&!a.target)throw new Error(`MISSING_TARGET: a ${a.op} op needs a target ref`)}for(let a of i)(a.op==="add"||a.op==="enhance"||a.op==="retract")&&g.push(a);let s=new Map;for(let a of i){if(!pe.has(a.op)||!a.target)continue;let f=s.get(a.target)??[];f.push(a),s.set(a.target,f)}for(let[a,f]of s){let p=Math.max(...f.map(C=>C.seq)),v=f.filter(C=>C.seq===p);if(v.length>1){l.push({target:a,seq:p,kinds:v.map(C=>C.op)});continue}g.push(v[0])}return{chatOps:g.sort((a,f)=>a.seq-f.seq).map(a=>me(a,y,t,w.convSourceId)),ambiguous:l}}function he(i){let t=[];return i.questions.forEach((w,y)=>{if(i.resolution[y])return;let l=w.recommended_index!=null?w.options[w.recommended_index]?.label:void 0;l!=null&&t.push(w.risk==="high"?`${l} \u203C`:l)}),t.length>3?`${t.slice(0,3).join(" \xB7 ")} \xB7 +${t.length-3} more`:t.join(" \xB7 ")}function ue(i){let t=i.text.replace(/\?+\s*$/,"");return t.length<=36?t:`${t.slice(0,33)}\u2026`}function ke(i){return i.use_cases??[]}var be={acs:"acceptance criteria",scenarios:"scenarios",exercises:"exercises",tests:"tests",gaps:"gaps"};function xe(i){let t=[],w=[],y=(s,x)=>{x.length!==0&&(w.push(s),t.push(...x))},l=s=>typeof s=="string"&&/^[a-z]{1,4}\d{1,4}$/i.test(s)?s:null,g=s=>{let x=l(s.automates)??"1 scenario",a=s.verifies??[],f=a.map(l).filter(C=>C!==null).slice(0,2),p=a.length-f.length,v=f.length?`${f.join(" ")}${p>0?` +${p}`:""}`:`${a.length} ACs`;return`covers ${x} \xB7 verifies ${v}`};return y("acs",(i.acs??[]).map(s=>({temp_ref:s.temp_ref,title:s.text,kind:"ac",badge:String(s.kind),extra:{...s.expected_answer?{expects:`${String(s.expected_answer.operator??"")} \xB7 ${String(s.expected_answer.operand??"")}`}:{},"scoped to":s.scoped_to??"(use-case)"}}))),y("scenarios",(i.scenarios??[]).map(s=>({temp_ref:s.temp_ref,title:s.title,kind:"scenario",badge:s.case_type,why:s.intent,depends_on_hint:s.depends_on??[],extra:{technique:s.technique_notes}}))),y("exercises",(i.exercises??[]).map(s=>({temp_ref:l(s.scenario)??"wiring",title:`${l(s.scenario)??"scenario"} exercises ${l(s.ac)??"1 AC"}`,kind:"exercise",badge:"wires",why:s.rationale}))),y("tests",(i.tests??[]).map(s=>({temp_ref:s.temp_ref,title:s.title,kind:"test",why:g(s),depends_on_hint:s.reuses??[],extra:{automates:String(s.automates??"?"),verifies:(s.verifies??[]).join(", "),check:s.check?`${String(s.check.kind)} vs ${String(s.check.verified_against)}`:"?"}}))),y("gaps",(i.gaps??[]).map(s=>({temp_ref:s.temp_ref??s.ref??"?",title:String(s.question?.header??s.kind),kind:"gap",badge:s.kind,why:s.risk_rationale}))),{items:t,heading:w.join(" + ")||"design"}}function Ae(i={}){let t={turns:[],thinking:ae(),pending:null,confirm:null,status:"idle",ledger:[],activeTurn:null,stream:null,checkpoint:!1},w=e=>{let n=[],r=e.minted.map(c=>c.slug).filter(Boolean);r.length&&n.push(`added ${r.join(", ")}`);let o=e.applied.length-e.minted.length;return o>0&&n.push(`${o} change${o===1?"":"s"} applied`),e.staleDelta.length&&n.push(`stales ${e.staleDelta.length}`),n.join(" \xB7 ")||"no changes"},y=[];i.onRender&&y.push(i.onRender);let l=0,g=0,s=null,x=null,a=null,f=[],p=0,v=e=>{if(!(!a||!i.contextDir||!e.trim()))try{let n=i.refreshGraph?.()??i.graph;if(!n)return;se({contextDir:i.contextDir,graph:n,sourceId:a,text:e,by:i.by??{kind:"human",id:"owner"}})}catch{}},C=e=>{if(!a||!i.contextDir)return;let n=i.refreshGraph?.()??i.graph,r=n?.heads.get(a),o=n?.convChains.get(a);if(!n||typeof r!="string"||!o)return;let c=n.getNode(r)?.content?.blob,d=typeof c=="string"?ie(i.contextDir,c)?.toString("utf8")??"":"";if(d)for(let b of e){if(b.kind!=="add"||b.convSourceId!==a)continue;let F=V(d,b.cite.turn);if(!(F!==null&&F.includes(b.cite.quote)))for(let R=o.turns;R>=1;R--){let G=V(d,R);if(G!==null&&G.includes(b.cite.quote)){b.cite={...b.cite,turn:R};break}}}},_={startedAt:null,thinkMs:0,toolCalls:0,tools:new Map},$=()=>{_.startedAt??=Date.now()},A=()=>{if(_.toolCalls>0){let e=_.startedAt!=null?Math.max(1,Math.round((Date.now()-_.startedAt)/1e3)):Math.max(1,Math.round(_.thinkMs/1e3));m({kind:"worked",durS:e,toolCalls:_.toolCalls,tools:[..._.tools.entries()].map(([n,r])=>({name:n,n:r}))})}_.startedAt=null,_.thinkMs=0,_.toolCalls=0,_.tools.clear()},E=null,U=new Map,K=e=>JSON.stringify([e.id,e.text,e.options.map(n=>n.label)]),O=null,J=new Map,z=new Map,Y=null,h=()=>{q&&(clearTimeout(q),q=null);for(let e of y)e()},q=null,X=()=>{q||(q=setTimeout(()=>{q=null;for(let e of y)e()},80))},Q=0,m=e=>{e.kind==="childClose"&&Q>0&&(Q-=1),Q>0&&e.kind!=="childOpen"&&e.kind!=="childBack"&&(e.era=Q),e.kind==="childOpen"&&(Q+=1),t.ledger.push(e)},j=null,B=!1,N=(e=!1)=>{j?m({kind:"agent",text:j}):e&&B&&m({kind:"note",text:'chat to refine ("looks good" approves; /done finishes)'}),j=null,B=!1},ge=()=>{j=null,B=!1},L=null,H=e=>{if(L){if(e)for(let n of L.items){let r=e.get(n.temp_ref);r&&(n.logical_id=r)}m({kind:"turn",...L}),L=null}},T=()=>{H(),t.activeTurn&&(t.activeTurn=null)},Z=(e,n)=>n.choice||(n.selected_index!=null?e.options[n.selected_index]?.label??"?":"?"),P=()=>{let e=t.pending;if(!e)return;if(!e.resolution.every(Boolean)){e.cursor=e.resolution.findIndex(o=>o===null);return}let n=e.questions.map((o,c)=>{let d=e.resolution[c];return d.form==="deferred"?{id:o.id,selected_index:null,free_text:null}:{id:o.id,selected_index:d.selected_index,free_text:d.free_text}});t.pending=null,t.status=t.status==="pausing"?"pausing":"streaming",t.status==="streaming"&&(t.busySince=Date.now());let r=E;E=null,r?.(n)},D=(e,n)=>{let r=t.pending,o=r.questions[e],c=r.resolution[e];r.resolution[e]=n;let d=ue(o);c?m({kind:"answer",receipt:{form:"changed",qNum:e+1,stub:d,choice:Z(o,n),prev:c.choice}}):n.form==="deferred"?m({kind:"answer",receipt:{form:"deferred",qNum:e+1,stub:d}}):m({kind:"answer",receipt:{form:n.form,qNum:e+1,stub:d,choice:Z(o,n)}})},ee=()=>{let e=t.pending;e&&(e.questions.forEach((n,r)=>{e.resolution[r]||D(r,{form:"deferred",selected_index:null,free_text:null,choice:""})}),P())},W=new Map,te=e=>{W.clear();let n={high:0,med:1,low:2};return e=e.map((r,o)=>({q:r,i:o})).sort((r,o)=>(n[r.q.risk]??3)-(n[o.q.risk]??3)||r.i-o.i).map(({q:r})=>r),{questions:e,cursor:0,resolution:e.map(()=>null)}};return{state:t,explainLines(e){if(!i.explain||!i.graph||i.contextDir===void 0)return null;let n=i.explain(i.contextDir,i.graph,e);return n.target?[`${n.target.label} ${n.target.slug??n.target.cid.slice(0,19)}:`,...n.entries.map(r=>` [${r.kind}] ${r.rationale??r.detail}`)]:null},explainRef(e){if(!i.explain||!i.graph||i.contextDir===void 0){m({kind:"note",text:"explain isn't available here"}),h();return}let n=i.explain(i.contextDir,i.graph,e),r=n.target?[`${n.target.label} ${n.target.slug??n.target.cid.slice(0,19)}:`,...n.entries.map(o=>` [${o.kind}] ${o.rationale??o.detail}`)].join(`
|
|
3
3
|
`):`unknown ref: ${e}`;m({kind:"note",text:r}),h()},subscribe(e){return y.push(e),()=>{let n=y.indexOf(e);n>=0&&y.splice(n,1)}},submit(e){if(t.confirm&&(t.confirm=null),!t.pending){if(!s){t.turns.push({role:"user",text:e}),m({kind:"user",text:e}),t.notice="the agent isn't running \u2014 nothing sent",h();return}for(t.notice=void 0,t.checkpoint=!1,N(),t.turns.push({role:"user",text:e}),m({kind:"user",text:e}),v(e),t.status="streaming",t.busySince=Date.now(),$(),t.error=void 0,g+=1;f.length>0;)g+=1,s({type:"user_message",message_id:`u${g}-receipt`,text:f.shift()});s({type:"user_message",message_id:`u${g}`,text:e}),h()}},attachSender(e){let n=s;return s=e,()=>{s=n}},attachOnCommitted(e){x=e},attachConversationSource(e){a=e},attachSession(e){i.session=e},holdReceipt(e){f.push(e),t.checkpoint=!0,h()},drainHeldReceipts(){return f.splice(0,f.length)},peekHeldReceipts(){return[...f]},submitAnswer(e,n){let r=t.pending,o=r?.questions[e],c=o?.options[n]?.label;!r||!o||c==null||(D(e,{form:"answered",selected_index:n,free_text:null,choice:c}),P(),h())},submitFreeText(e,n){let r=t.pending,o=r?.questions[e],c=n.trim();!r||!o||!c||(D(e,{form:"answered",selected_index:null,free_text:c,choice:c}),P(),h())},deferBatch(e){let n=t.pending;if(!n||!E)return;n.questions.forEach((o,c)=>{let d=n.resolution[c];d&&d.form==="answered"&&U.set(K(o),d)}),t.pending=null,t.status=t.status==="pausing"?"pausing":"streaming",t.status==="streaming"&&(t.busySince=Date.now()),m({kind:"note",text:`questions set aside \u2014 source ${e.source_id} landed; the agent reads it next`});let r=E;E=null,r({deferred:!0,ingested:e}),h()},submitAnswerWithText(e,n,r){let o=t.pending,c=o?.questions[e],d=c?.options[n]?.label;if(!o||!c||d==null)return;let b=r.trim();D(e,{form:"answered",selected_index:n,free_text:b||null,choice:b?`${d} \u2014 ${b}`:d}),P(),h()},toggleOption(e,n){let r=t.pending?.questions[e];if(!r||r.options[n]==null)return;let o=W.get(e)??new Set;o.has(n)?o.delete(n):o.add(n),W.set(e,o),h()},multiSelection(e){return[...W.get(e)??[]].sort((n,r)=>n-r)},confirmMulti(e){let n=t.pending,r=n?.questions[e];if(!n||!r)return;let o=[...W.get(e)??[]].sort((d,b)=>d-b).map(d=>r.options[d]?.label).filter(d=>d!=null);if(o.length===0)return;W.delete(e);let c=o.join(", ");D(e,{form:"answered",selected_index:null,free_text:c,choice:c}),P(),h()},goWithRecommendations(){let e=t.pending;if(!e)return{picks:""};let n=he(e),r=null;return e.questions.forEach((o,c)=>{if(e.resolution[c])return;let d=o.recommended_index,b=d!=null?o.options[d]?.label:void 0;if(b==null){r===null&&(r=c);return}D(c,{form:"assumed",selected_index:d,free_text:null,choice:b})}),r!==null?(e.cursor=r,h(),{blocked:r}):(P(),h(),{picks:n})},reopenQuestion(){let e=t.pending;if(!e)return;let n=e.cursor<0?e.questions.length:e.cursor;for(let r=n-1;r>=0;r--)if(e.resolution[r]){e.cursor=r,h();return}},continueParked(){if(s){for(t.checkpoint=!1,m({kind:"continued"});f.length>0;)g+=1,s({type:"user_message",message_id:`u${g}-receipt`,text:f.shift()});g+=1,s({type:"user_message",message_id:`u${g}`,text:"continue"}),t.status="streaming",t.busySince=Date.now(),$(),h()}},note(e){m({kind:"note",text:e}),h()},finalizeForExit(){T(),A(),N(),t.stream=null,h()},aliasOf(e){return z.get(e)},registerAliases(e){for(let n of e)z.set(n.ref,n.cid);H(new Map(e.filter(n=>n.id).map(n=>[n.ref,n.id]))),h()},setWorking(e){if(e!=null){if(t.status!=="idle"&&t.status!=="working")return;t.status==="idle"&&(t.busySince=Date.now()),$(),t.status="working",t.workingLabel=e}else{if(t.status!=="working")return;t.status="idle",t.workingLabel=void 0,t.busySince=void 0}h()},ledger(e){e.kind==="commit"&&H(),e.kind==="error"&&(T(),A(),N()),m(e),e.kind==="commit"&&(e.ok?N(!0):ge()),h()},senderAlive(){return s!=null},completeSession(){ee(),s?.({type:"session_complete"}),t.status="idle",t.busySince=void 0,h()},requestPause(){ee(),t.status="pausing",t.busySince=void 0;let e=s;Promise.resolve().then(()=>e?.({type:"pause"})),h()},ask(e){t.pending=te(e),J=new Map(e.map((r,o)=>[r.id,o+1])),t.status="awaiting-input",t.busySince=void 0;let n=new Promise(r=>{E=r});if(U.size>0){let r=0;e.forEach((o,c)=>{let d=K(o),b=U.get(d);b&&(U.delete(d),D(c,{...b}),r+=1)}),r>0&&m({kind:"note",text:`your earlier answer${r>1?"s are":" is"} pre-filled \u2014 press enter to send, or pick a different answer`})}return h(),n},attachIngest(e){let n=O;return O=e,()=>{O===e&&(O=n)}},canIngest(){return O!==null},async ingestAttach(e){let n=O,r=e.trim();if(!n||!r)return;let o;try{o=await n(r)}catch(c){o={ok:!1,error:c instanceof Error?c.message:String(c)}}o.ok||(m({kind:"note",text:o.error??"the source could not be ingested"}),h())},noteCoercion(e,n){m({kind:"answer",receipt:{form:"assumed",qNum:J.get(e.id)??0,stub:ue(e),choice:n,note:"your typed answer couldn't be used here"}}),h()},onAgentEvent(e){switch(e.type){case"reasoning_delta":case"reasoning_done":case"tool_activity":case"decision_activity":{let n=t.thinking;if(t.thinking=ce(n,e),t.thinking!==n&&(e.type==="reasoning_done"&&e.present?($(),_.thinkMs+=e.took_ms):e.type==="tool_activity"&&e.status!=="started"&&($(),_.toolCalls+=1,_.tools.set(e.name,(_.tools.get(e.name)??0)+1))),e.type==="reasoning_delta"){X();return}break}case"usage":t.credits={turn:e.credits,total:e.total_credits};break;case"text_delta":{let n=Y;if(n&&(e.turn_id<n.turn_id||e.turn_id===n.turn_id&&e.attempt<n.attempt))return;(!n||n.turn_id!==e.turn_id||n.attempt!==e.attempt)&&(Y={turn_id:e.turn_id,attempt:e.attempt},t.stream={text:""}),t.stream={text:(t.stream?.text??"")+e.text},X();return}case"progress":break;case"proposal":{l+=1,T(),t.stream=null,t.busySince=void 0,A();let n=ke(e.proposal),r=i.dedupFlags?.(e.proposal);if(r)for(let o of n){let c=r.get(o.temp_ref);c&&(o.matches_existing=c)}t.turns.push({role:"agent",turnIndex:l,items:n,text:e.narrative}),j=e.narrative??null,B=!0,t.activeTurn={turnIndex:l,heading:"use-cases",items:n},L={turnIndex:l,heading:"use-cases",items:n},(t.status==="streaming"||t.status==="working")&&(t.status="idle"),t.workingLabel=void 0;break}case"design":{l+=1,T(),t.stream=null,t.busySince=void 0,A();let{items:n,heading:r}=xe(e.design),o=e.design.phase==="wiring"?"acceptance criteria + exercises":r.split(" + ").map(c=>be[c]??c).join(" + ");m({kind:"banner",text:`designing: ${o}`}),t.turns.push({role:"agent",turnIndex:l,items:n,itemsHeading:r,text:e.narrative}),j=e.narrative??null,B=!0,t.activeTurn={turnIndex:l,heading:r,items:n},L={turnIndex:l,heading:r,items:n},(t.status==="streaming"||t.status==="working")&&(t.status="idle"),t.workingLabel=void 0;break}case"ask_user":A(),t.pending=te(e.questions),t.status="awaiting-input",t.busySince=void 0;break;case"chat_ops":{l+=1,T(),A(),t.stream=null,(t.status==="streaming"||t.status==="working")&&(t.status="idle",t.busySince=void 0,t.workingLabel=void 0);let n=e.chat_ops??e,r=Array.isArray(n.ops)?n.ops:[],o=n.text??e.text??"",c=i.refreshGraph?.()??i.graph,d=u=>z.get(u)??u,b=r.map(u=>{if(!u.target)return u;let k=d(u.target),S=u.expected_cid;if(S==null&&c){let re=c.resolve(k);re&&(S=c.tipOf(re.cid))}let I=u.payload?.redirect_to,M=I&&d(I);return k===u.target&&S===u.expected_cid&&M===I?u:{...u,target:k,expected_cid:S,...M!==I?{payload:{...u.payload,redirect_to:M}}:{}}}),F;try{if(!Array.isArray(n.ops))throw new Error("the agent sent an unreadable change set (no ops array) \u2014 say it again in different words");F=le(b,i.descriptor??{mint_gate:[]},{turn:l,...a?{convSourceId:a}:{}})}catch(u){t.error=u instanceof Error?u.message:String(u),t.turns.push({role:"agent",turnIndex:l,text:o,narration:t.error}),o&&m({kind:"agent",text:o}),m({kind:"error",title:t.error,detail:[]}),f.push(`OPS REJECTED (did not compile) \u2014 nothing landed; do not assume any of your last ops applied.
|
|
4
4
|
- `+t.error);break}let{chatOps:R,ambiguous:G}=F;if(G.length>0){let u=G[0];t.confirm={kind:"ambiguity-confirm",prompt:`did you mean edit or ${u.kinds.filter(k=>k!=="edit").join("/")} on ${u.target}?`},t.turns.push({role:"agent",turnIndex:l,text:o}),o&&m({kind:"agent",text:o});break}if(C(R),i.commitChatTurn&&R.length>0){let u;try{u=i.commitChatTurn({contextDir:i.contextDir??"",graph:i.refreshGraph?.()??i.graph,ops:R,by:i.by??{kind:"human",id:"owner"},...i.descriptor?.mint_gate?{mintable:i.descriptor.mint_gate}:{},...i.session?.state?.sid?{sid:i.session.state.sid}:{}})}catch(k){u={record:null,errors:[{code:"COMMIT_THREW",detail:k instanceof Error?k.message:String(k)}]}}if(u.errors)t.error=u.errors.map(k=>k.detail).join("; "),t.turns.push({role:"agent",turnIndex:l,text:o}),m({kind:"commit",ok:!1,line:"commit failed \u2014 nothing landed",warnings:u.errors.map(k=>`${k.code}: ${k.detail}`)}),f.push(["COMMIT FAILED (chat turn) \u2014 nothing landed; do not assume any of your last ops applied.",...u.errors.map(k=>`- ${k.code}: ${k.detail}`),...u.errors.some(k=>k.code==="UNKNOWN_FIELD")?["If you were changing citations or matched-existing content, that is proposal territory (approve/re-propose) \u2014 a chat edit can only replace a node's own schema fields."]:[]].join(`
|
|
5
5
|
`)),o&&m({kind:"agent",text:o});else{u.applied.length>0&&i.session?.markApplied(u.applied);let k=w(u);t.turns.push({role:"agent",turnIndex:l,text:o,narration:k}),m({kind:"commit",ok:!0,line:k});let S=i.refreshGraph?.();if(S&&x&&x(S),S)try{p+=1;let ne=i.descriptor?.mint_gate?.includes("usecase")?"extract":"design",I=oe({verb:ne,commitN:p,phase:"chat",committed:u.minted.map(M=>({cid:M.cid,...M.slug?{logical_id:M.slug}:{}}))},S);f.push(I.text)}catch{}o&&m({kind:"agent",text:o})}}else t.turns.push({role:"agent",turnIndex:l,text:o}),o&&m({kind:"agent",text:o});v(o);break}case"done":case"session_complete":T(),A(),N(),t.status="idle",t.busySince=void 0,s=null;break;case"error":T(),A(),N(),t.stream=null,t.status="idle",t.busySince=void 0,t.error=e.message,s=null,m({kind:"error",title:e.message,detail:[]});break;case"session_paused":break;default:break}h()}}}export{he as a,ue as b,Ae as c};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{b as t}from"./chunk-
|
|
2
|
+
import{b as t}from"./chunk-DEUDRSU7.js";import{join as i}from"path";function e(n=t){return i(n,"plugins")}function g(n,r=t){return i(e(r),n)}function c(n,r,o=t){return i(g(n,o),r)}function f(n,r=t){return i(g(n,r),"current")}function x(n,r=t){return i(g(n,r),"config.json")}function l(n,r=t){return i(g(n,r),".jobs")}function s(n=t){return i(n,"bin")}function h(n=t){return i(s(n),"hyperexecute")}export{e as a,g as b,c,f as d,x as e,l as f,s as g,h};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{g as b,h as c,i as d,j as e,k as f,l as g,m as h,n as i,o as j,p as k,q as l,r as m,s as n,t as o,u as p,v as q,w as r}from"./chunk-
|
|
2
|
+
import{g as b,h as c,i as d,j as e,k as f,l as g,m as h,n as i,o as j,p as k,q as l,r as m,s as n,t as o,u as p,v as q,w as r}from"./chunk-R4EGL7VM.js";import"./chunk-JQW2QFSX.js";import"./chunk-FYLMTZ3J.js";import"./chunk-TYRTD5DD.js";import{i as a}from"./chunk-OXHMUZJV.js";import"./chunk-DBIBROYW.js";import"./chunk-IAHKTEET.js";import"./chunk-AKX4VRRR.js";import"./chunk-UD7KKHPW.js";import"./chunk-UR6MHSHU.js";export{b as SLUG_RE,c as checkAcyclic,d as checkCardinality,e as citesOf,q as commitDeferGap,o as commitNames,n as commitPairMerge,l as commitProposal,p as commitRetire,m as commitReviewFacts,f as criteriaShape,i as mintEventId,j as nextEventIds,a as recordsSince,r as resolveDeferGaps,k as resolveLivingTip,g as validateCriterionOps,h as validateProposal};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a}from"./chunk-
|
|
2
|
+
import{a}from"./chunk-BE4FBVKY.js";import"./chunk-DEUDRSU7.js";import"./chunk-UR6MHSHU.js";export{a as getEnvironment};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{b as O}from"./chunk-DYW5C6II.js";import{a as g,b as S,d as G}from"./chunk-OS4VSIHT.js";import"./chunk-5DT7PIGB.js";import{e as w,f as $}from"./chunk-5GUD3CIH.js";import{d as x}from"./chunk-YMLC55J4.js";import{e as k}from"./chunk-EHN5HTUD.js";import"./chunk-CH273NAE.js";import{b}from"./chunk-VZ7KXRXB.js";import{C as R}from"./chunk-
|
|
2
|
+
import{b as O}from"./chunk-DYW5C6II.js";import{a as g,b as S,d as G}from"./chunk-OS4VSIHT.js";import"./chunk-5DT7PIGB.js";import{e as w,f as $}from"./chunk-5GUD3CIH.js";import{d as x}from"./chunk-YMLC55J4.js";import{e as k}from"./chunk-EHN5HTUD.js";import"./chunk-CH273NAE.js";import{b}from"./chunk-VZ7KXRXB.js";import{C as R}from"./chunk-R4EGL7VM.js";import"./chunk-JQW2QFSX.js";import"./chunk-FYLMTZ3J.js";import"./chunk-TYRTD5DD.js";import"./chunk-OXHMUZJV.js";import"./chunk-DBIBROYW.js";import"./chunk-IAHKTEET.js";import"./chunk-AKX4VRRR.js";import"./chunk-UD7KKHPW.js";import"./chunk-UR6MHSHU.js";import{basename as h}from"path";import{statSync as A}from"fs";function C(t,e){if(!t)return 1;let o=t.resolve(e);return!o||o.superseded?1:t.getNode(o.tip)?.content.risk==="high"?3:1}function D(t,e){return t.usecases.map(o=>{let s=o.acceptance_criteria??[],a=s.filter(n=>(n.covered_by??[]).length>0),l=s.filter(n=>n.execution==="passed"),i=s.filter(n=>n.execution==="failed"),u=s.filter(n=>n.execution==="blocked"),d=0,m=0;for(let n of s){let f=C(e,n.id);d+=f,n.execution==="passed"&&(m+=f)}let r=d===0?0:Math.round(100*m/d),p=a.length===0?"uncovered":s.length===l.length?"covered":u.length>0&&i.length===0?"blocked":"partial";return{id:o.id,title:o.title,status:p,pct:r,acs:{total:s.length,covered:a.length,passed:l.length,failed:i.length,blocked:u.length},stale:s.filter(n=>n.fresh==="stale").map(n=>n.id)}})}async function P(t){let e=await w(t);return e.length===0?null:e.map(o=>({p:o,m:A(o).mtimeMs})).sort((o,s)=>s.m-o.m)[0].p}var N={covered:"\u2714",partial:"\u25D0",uncovered:"\u2716",blocked:"\u23F8"};function _(t){let e=Math.round(t/10);return"\u2588".repeat(e)+"\u2591".repeat(10-e)}async function I(t,e=G(),o=process.cwd()){if(t.mode!==void 0&&t.mode!=="agent"&&t.mode!=="ci"&&t.mode!=="interactive")return g(e,`--mode must be interactive | agent | ci, got '${t.mode}'`),2;if(t.mode==="agent"||t.mode==="ci"){let{makeHeadlessIO:r,agentRefusal:p}=await import("./headless-io-66RG5NN5.js"),n=r("ndjson","cover",{stdout:c=>e.out(c.replace(/\n$/,"")),stderr:c=>(e.err??e.out)(c.replace(/\n$/,""))}),f=[],v=[],j={out:c=>f.push(c),err:c=>v.push(c),confirm:async()=>!1,isTTY:!1};if(await I({...t,json:!0,mode:void 0},j,o)!==0)return p(n,v.join("; ")||"cover refused");let y=JSON.parse(f.join(`
|
|
3
3
|
`));return n.event({type:"coverage",...y}),n.done(0,void 0,M(y.completeness??[]))}let s=S(o,e);if(!s)return 2;let a=t.from?await $(t.from,o):await P(o);if(!a)return g(e,t.from?`no evidence pack at '${t.from}'`:"no evidence pack in .testmuai/evidence \u2014 run a test first, or pass --from <pack>"),2;let l=await k(a,"coverage/usecases.yaml");if(l==null)return g(e,`${h(a)} carries no coverage/usecases.yaml \u2014 the pack predates coverage or its project had no .context at seal time`),2;let i=b(l);if(!i||!Array.isArray(i.usecases))return g(e,`${h(a)}: coverage/usecases.yaml is not a usecases document`),2;let u=R(s),d=D(i,u),m=await x(u,"design");if(t.json)return e.out(JSON.stringify({pack:a,depth:d,completeness:m},null,2)),0;e.out(`coverage \u2014 ${h(a)}`),e.out(""),e.out("depth (proven by the pack):");for(let r of d){let p=r.stale.length?` \xB7 ${r.stale.length} stale`:"";e.out(` ${N[r.status]} ${_(r.pct)} ${String(r.pct).padStart(3)}% ${r.id} \u2014 ${r.status} (${r.acs.passed}/${r.acs.total} ACs proven${r.acs.failed?`, ${r.acs.failed} failed`:""}${r.acs.blocked?`, ${r.acs.blocked} blocked`:""})${p}`)}e.out(""),e.out("completeness (live graph):"),m.length===0&&e.out(" no design gaps \u2014 every AC verified, every use-case scenarioed");for(let r of m)e.out(` [${r.risk}] ${r.tag} ${r.ref} \u2014 ${r.why}`),e.out(` \u2192 ${r.ready_command}`);return 0}function M(t){return t.filter(e=>e.ready_command.startsWith("kane-cli ")&&O(e.ready_command)).slice(0,4).map(e=>({cmd:e.ready_command,why:e.why}))}export{I as coverCommand,M as coverNext,D as depthRows};
|