@testmuai/kane-cli 0.8.1 → 0.8.2
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-B3ULYDYC.js +8 -0
- package/dist/{ChromeProfilePicker-AUU7JF6F.js → ChromeProfilePicker-T77E7ZSC.js} +1 -1
- package/dist/{CliFeedbackPrompt-4W74Y3UF.js → CliFeedbackPrompt-FQ2XV5DZ.js} +1 -1
- package/dist/{CliUploadProgress-6HL7WTEX.js → CliUploadProgress-TZ55LONO.js} +1 -1
- package/dist/{ConfigView-6BSCZP5Y.js → ConfigView-WWQMH36G.js} +1 -1
- package/dist/EvidenceViewOffer-L5FVBQNK.js +2 -0
- package/dist/FolderPicker-6Z3CYSHF.js +2 -0
- package/dist/{HelpView-TU7ED43J.js → HelpView-XXPCPJNF.js} +1 -1
- package/dist/{InfoBox-JLTMKVDE.js → InfoBox-SHBRHQX5.js} +1 -1
- package/dist/{LinksBox-LREUUJDV.js → LinksBox-ENNF7TDJ.js} +1 -1
- package/dist/{ProfilesView-W3GX2N2E.js → ProfilesView-CNF2FXF3.js} +1 -1
- package/dist/{ProjectPicker-SYQUJK2J.js → ProjectPicker-PVPLS642.js} +1 -1
- package/dist/{SaveSessionPrompt-MR5NJMRP.js → SaveSessionPrompt-4QP4GNGO.js} +1 -1
- package/dist/SingleShotApp-M3HNSUMZ.js +2 -0
- package/dist/{SummaryBox-UAYSVFB7.js → SummaryBox-HYNINDNN.js} +1 -1
- package/dist/TestMdRunView-ISOVQ7YP.js +2 -0
- package/dist/{WhoamiView-2YU76ASQ.js → WhoamiView-NN2HOK6H.js} +1 -1
- package/dist/app-client-ZCCNE3RV.js +2 -0
- package/dist/{app-download-AEEFQ63M.js → app-download-5UJMXPF3.js} +1 -1
- package/dist/{auth-HET3TBRI.js → auth-QKBTOWQX.js} +1 -1
- package/dist/{bind-STKXOUYI.js → bind-LVGP5KHO.js} +2 -2
- package/dist/bootstrap-RUJBMB2P.js +2 -0
- package/dist/bridge-QDPBIIOW.js +2 -0
- package/dist/{changelog-7OWRHFHZ.js → changelog-HBPBPR2O.js} +1 -1
- package/dist/{chat-controller-T2FAI55V.js → chat-controller-R4THYYPU.js} +1 -1
- package/dist/chunk-2E3ZWGIK.js +12 -0
- package/dist/{chunk-ZVHCQMJ6.js → chunk-2KH2JUGL.js} +2 -2
- package/dist/{chunk-ZIUAOEUC.js → chunk-2TYCUPCN.js} +1 -1
- package/dist/{chunk-FEJXWJ3L.js → chunk-2ZZDNPFN.js} +1 -1
- package/dist/{chunk-KFSUPQAG.js → chunk-3654GK6O.js} +43 -43
- package/dist/{chunk-RFR4ZKIC.js → chunk-3NHO5R4P.js} +2 -2
- package/dist/{chunk-3LJWYRAA.js → chunk-4II6VDXG.js} +1 -1
- package/dist/chunk-4J6DQFPC.js +4 -0
- package/dist/{chunk-SDPRO2LE.js → chunk-4U4OSOA4.js} +1 -1
- package/dist/chunk-5NIYYD7O.js +2 -0
- package/dist/{chunk-L7MXYCD7.js → chunk-5SNT2MK5.js} +1 -1
- package/dist/chunk-6J5T5FEY.js +2 -0
- package/dist/chunk-6N726QLP.js +349 -0
- package/dist/chunk-7F2ZV46B.js +2 -0
- package/dist/{chunk-BRHNRCEZ.js → chunk-7S3JZ6FQ.js} +1 -1
- package/dist/chunk-A2SQD2AY.js +4 -0
- package/dist/{chunk-AW2XUHH4.js → chunk-AJQT4IWZ.js} +1 -1
- package/dist/{chunk-6XX4LEVJ.js → chunk-AN2ZPHCE.js} +1 -1
- package/dist/{chunk-3POR47RC.js → chunk-ATGRRKEV.js} +2 -2
- package/dist/chunk-AXTPNZPX.js +2 -0
- package/dist/{chunk-RC52N7PC.js → chunk-BKVDAZEJ.js} +1 -1
- package/dist/{chunk-2WVKOZ6W.js → chunk-BPMSNGXQ.js} +1 -1
- package/dist/{chunk-UV462FZR.js → chunk-BSYX225I.js} +1 -1
- package/dist/{chunk-DZGCXKKI.js → chunk-CAMO26QU.js} +1 -1
- package/dist/chunk-ECZMYPLJ.js +19 -0
- package/dist/{chunk-65ZTD5SJ.js → chunk-FNS2EAA5.js} +2 -2
- package/dist/{chunk-7BZSCUPP.js → chunk-GNIFMQNK.js} +3 -3
- package/dist/chunk-GUVM6SZF.js +2 -0
- package/dist/{chunk-2BGUUWNF.js → chunk-HFFPPCZO.js} +2 -2
- package/dist/{chunk-T5Y6MOLM.js → chunk-HRZOFTV7.js} +1 -1
- package/dist/chunk-HWH3UYD6.js +4 -0
- package/dist/{chunk-EDSZJZFG.js → chunk-I7RQS65W.js} +1 -1
- package/dist/chunk-IUEEFGEW.js +11 -0
- package/dist/{chunk-DO5HAO3H.js → chunk-IV76ZXCY.js} +1 -1
- package/dist/{chunk-UXDL4XDL.js → chunk-IZ2FJYHG.js} +1 -1
- package/dist/{chunk-766WGMBU.js → chunk-J7KT44IC.js} +1 -1
- package/dist/{chunk-QW6EZC53.js → chunk-JEDLXUO5.js} +1 -1
- package/dist/chunk-JGOZUAMC.js +2 -0
- package/dist/{chunk-XO5ZH3ZR.js → chunk-JHKM7W5X.js} +1 -1
- package/dist/{chunk-IOFZSQAA.js → chunk-JJN76EXE.js} +1 -1
- package/dist/{chunk-YFYCCTSL.js → chunk-JUVQQP42.js} +1 -1
- package/dist/chunk-KKRNTSLL.js +6 -0
- package/dist/{chunk-IP2O264K.js → chunk-LDCLZR2U.js} +1 -1
- package/dist/chunk-LQQXPY5B.js +4 -0
- package/dist/{chunk-FMRSMN34.js → chunk-LVCY5IYI.js} +1 -1
- package/dist/{chunk-G7VQCS4J.js → chunk-LVN6VHFN.js} +1 -1
- package/dist/chunk-MMBBQ4OZ.js +2 -0
- package/dist/{chunk-QSDH5P7C.js → chunk-MTIC65NK.js} +1 -1
- package/dist/chunk-NHBYZCSX.js +4 -0
- package/dist/{chunk-GZPK6FRP.js → chunk-NRUD56FY.js} +1 -1
- package/dist/{chunk-GKYPNSQP.js → chunk-NXFAEDHV.js} +2 -2
- package/dist/{chunk-ELM6MXGJ.js → chunk-NXXJ56QA.js} +1 -1
- package/dist/{chunk-JJHG3BWO.js → chunk-O3AHFP3K.js} +1 -1
- package/dist/{chunk-FQLIW3LM.js → chunk-OAVPM6YJ.js} +1 -1
- package/dist/{chunk-QRZRSAZH.js → chunk-OJTCIZDK.js} +1 -1
- package/dist/{chunk-YJELGSKJ.js → chunk-OOEPLMKA.js} +1 -1
- package/dist/{chunk-6O3DDOP2.js → chunk-PXCMEI73.js} +1 -1
- package/dist/{chunk-C7HSWZP6.js → chunk-R4UCBA5R.js} +1 -1
- package/dist/chunk-RKXHVP2Z.js +2 -0
- package/dist/{chunk-KU6IXFGZ.js → chunk-RN4PKQFR.js} +1 -1
- package/dist/chunk-RUCSRS4C.js +5 -0
- package/dist/chunk-TAOHYWEO.js +2 -0
- package/dist/{chunk-TFPPEOAK.js → chunk-U5GHOGLM.js} +1 -1
- package/dist/chunk-UJZZDPDY.js +2 -0
- package/dist/{chunk-EWCAFKLX.js → chunk-UODLRQQ4.js} +1 -1
- package/dist/chunk-VK3NU742.js +21 -0
- package/dist/{chunk-DCY6R5DP.js → chunk-VPRNGWIY.js} +1 -1
- package/dist/{chunk-NX7TM662.js → chunk-WOEQDUJ6.js} +1 -1
- package/dist/{chunk-OMQCD3KR.js → chunk-WQPQNL4S.js} +1 -1
- package/dist/{chunk-HMYMSRA4.js → chunk-WV27D55O.js} +1 -1
- package/dist/{chunk-GCBKDX2J.js → chunk-WVCH66YH.js} +1 -1
- package/dist/{chunk-7JWKHKFU.js → chunk-YCLG3T5E.js} +1 -1
- package/dist/chunk-YGMC3FGJ.js +26 -0
- package/dist/{chunk-TKGUT425.js → chunk-YHYTCENI.js} +1 -1
- package/dist/{chunk-UDIQOJEL.js → chunk-YSSYT5F5.js} +1 -1
- package/dist/{chunk-OTTGS2TE.js → chunk-YTDSQAYN.js} +1 -1
- package/dist/{chunk-HCKH44I2.js → chunk-ZEDAPY7M.js} +1 -1
- package/dist/chunk-ZI6UIJUN.js +11 -0
- package/dist/{config-RS47F5SC.js → config-RLDXM5ZH.js} +1 -1
- package/dist/{credentials-OH6AVI6N.js → credentials-CALNKQMN.js} +1 -1
- package/dist/deps-bundle-GVHIMZ5E.js +2 -0
- package/dist/{deps-resolve-XC5S53DG.js → deps-resolve-T6P4EACP.js} +1 -1
- package/dist/{dispatch-SE5GY3Z2.js → dispatch-ECUEAMXS.js} +1 -1
- package/dist/doctor-SIBHJVGC.js +2 -0
- package/dist/evidence-ZVQHPELX.js +2 -0
- package/dist/evolve-cmd-JGCFTXWA.js +2 -0
- package/dist/extract-bind-EXW32RUY.js +10 -0
- package/dist/{extract-cmd-UZMEZMGP.js → extract-cmd-7IOLJJCL.js} +1 -1
- package/dist/gaps-cmd-WPCJPLGB.js +3 -0
- package/dist/{generate-headless-D3SVQ2AI.js → generate-headless-U4GTG234.js} +2 -2
- package/dist/index.js +61 -60
- package/dist/{ingest-cmd-EAE7N5RC.js → ingest-cmd-YYNAKI2U.js} +1 -1
- package/dist/interactive-bind-Y65XV4Y5.js +25 -0
- package/dist/{list-commands-MRXL5HGS.js → list-commands-3EROWJWV.js} +1 -1
- package/dist/login-flow-TRINUSBB.js +2 -0
- package/dist/mobile-prompts-TP3ODM5M.js +2 -0
- package/dist/{persist-recorded-session-TLDQ5HKP.js → persist-recorded-session-EHYT3PVN.js} +1 -1
- package/dist/{phase-seed-VFHIH6FL.js → phase-seed-DIRETNU6.js} +1 -1
- package/dist/{pipeline-UOM4LNAI.js → pipeline-5GOS2KV2.js} +1 -1
- package/dist/prepare-target-BUEOZVJV.js +2 -0
- package/dist/reconcile-cmd-TY3MWZL3.js +2 -0
- package/dist/reconcile-deps-6KTJHBMJ.js +4 -0
- package/dist/reconcile-engine-O7QEZVX6.js +2 -0
- package/dist/{recording-banner-4M7XHVGI.js → recording-banner-BWWFOJCR.js} +1 -1
- package/dist/registry-KXEDLM6X.js +2 -0
- package/dist/{require-project-folder-4UPQNEBJ.js → require-project-folder-CXDRRWEQ.js} +1 -1
- package/dist/resolve-run-intent-PZXEQTHC.js +7 -0
- package/dist/{resolver-UBOZLFFE.js → resolver-FTU5KO7H.js} +1 -1
- package/dist/{run-URPGHOQM.js → run-CMFBSYWF.js} +1 -1
- package/dist/run-WKHPVWUN.js +2 -0
- package/dist/{run-test-md-76ZPKXO6.js → run-test-md-7HGOZJSU.js} +2 -2
- package/dist/session-items-2ATN7VXG.js +2 -0
- package/dist/{skill-installer-CIS6GAYF.js → skill-installer-QNUDLGPD.js} +1 -1
- package/dist/{spawner-J67QR4QP.js → spawner-DQZRJIE6.js} +1 -1
- package/dist/tcg-generate-XKSTMCOG.js +2 -0
- package/dist/{testmd-actions-77ELR5UU.js → testmd-actions-IFRW7NGG.js} +1 -1
- package/dist/{tms-client-VD3B3SMU.js → tms-client-V3TR4QW3.js} +1 -1
- package/dist/token-refresh-FP6JFLXB.js +2 -0
- package/dist/{validate-basic-2GVSQ2R5.js → validate-basic-3CNUDDH7.js} +1 -1
- package/dist/{verdicts-TRSTJLCL.js → verdicts-NYCSBWUC.js} +1 -1
- package/dist/{version-check-O6PYTI4T.js → version-check-7TSAVA6V.js} +1 -1
- package/dist/walk-session-AINBHZKB.js +2 -0
- package/dist/with-telemetry-3DL7ZEZL.js +2 -0
- package/package.json +11 -11
- package/dist/ChatSurface-U37VZDCW.js +0 -8
- package/dist/EvidenceViewOffer-62XHEEGW.js +0 -2
- package/dist/FolderPicker-S7U2EN2M.js +0 -2
- package/dist/SingleShotApp-XOKVOM7C.js +0 -2
- package/dist/TestMdRunView-7UVSDAF4.js +0 -2
- package/dist/app-client-OEXESV4U.js +0 -2
- package/dist/bootstrap-44YKVWWE.js +0 -2
- package/dist/bridge-5Z3BIB77.js +0 -2
- package/dist/chunk-27U4PLPX.js +0 -2
- package/dist/chunk-2KDGIZED.js +0 -4
- package/dist/chunk-3PECJD6S.js +0 -11
- package/dist/chunk-7Q6M6P4X.js +0 -26
- package/dist/chunk-CTW2VQKS.js +0 -6
- package/dist/chunk-FNH55WSR.js +0 -19
- package/dist/chunk-GPG3FIN3.js +0 -21
- package/dist/chunk-HEAIJCGZ.js +0 -2
- package/dist/chunk-KCCSWEGA.js +0 -4
- package/dist/chunk-MA34UWKX.js +0 -4
- package/dist/chunk-MBF3FP5P.js +0 -5
- package/dist/chunk-MXHHMIO2.js +0 -349
- package/dist/chunk-QGKPLOUI.js +0 -2
- package/dist/chunk-RLRNLIRS.js +0 -2
- package/dist/chunk-TYLYFERW.js +0 -10
- package/dist/chunk-V2R3LCA3.js +0 -12
- package/dist/chunk-VGFTNLQQ.js +0 -2
- package/dist/chunk-W2JFDDIB.js +0 -2
- package/dist/chunk-YRFMPIU2.js +0 -4
- package/dist/doctor-FSECFZUU.js +0 -2
- package/dist/evidence-OYPHZUKI.js +0 -2
- package/dist/evolve-cmd-BCPNXAMV.js +0 -2
- package/dist/extract-bind-LLEASZAK.js +0 -10
- package/dist/gaps-cmd-IVXFPFAQ.js +0 -3
- package/dist/interactive-bind-ORMN2REX.js +0 -25
- package/dist/login-flow-QJQM3RHT.js +0 -2
- package/dist/mobile-prompts-TOX35ER6.js +0 -2
- package/dist/prepare-target-QYWIJIVQ.js +0 -2
- package/dist/reconcile-cmd-3H34KVVD.js +0 -2
- package/dist/reconcile-deps-XIH75ZLY.js +0 -4
- package/dist/reconcile-engine-UKWPG2LV.js +0 -2
- package/dist/registry-PYOTKZYZ.js +0 -2
- package/dist/resolve-run-intent-X72V3KJA.js +0 -7
- package/dist/run-2COODVX2.js +0 -2
- package/dist/tcg-generate-BDTRKY2A.js +0 -2
- package/dist/token-refresh-4BPAPXKK.js +0 -2
- package/dist/walk-session-CHJXHZMO.js +0 -2
- package/dist/with-telemetry-CQCWLVOC.js +0 -2
- /package/dist/{lifecycle-cmd-O2324GN6.js → lifecycle-cmd-HO5VL7AM.js} +0 -0
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{homedir as a}from"os";import{join as t}from"path";var m="0.8.2",d="kane-cli",e=t(a(),".testmuai","kaneai"),g=t(e,"profiles"),h=t(e,"tui-config.json"),b=t(e,"media"),A="https://registry.npmjs.org/@testmuai/kane-cli",_="https://api.github.com/repos/LambdaTest/kane-cli/releases",n="@testmuai/kane-cli-skill",L=`https://registry.npmjs.org/${n}`,r="kane-cli",x=[{dir:t(a(),".claude","skills",r),agent:"Claude Code"},{dir:t(a(),".agents","skills",r),agent:"Codex CLI"},{dir:t(a(),".gemini","skills",r),agent:"Gemini CLI"}],U="https://dd-proxy.lambdatest.com/intake/kane-cli",u="https://kaneai-playground.lambdatest.io",R=9222,I=9230,E=t(e,"chrome-profiles"),o=t(e,"hints"),C=t(o,"state.json");function T(s){return t(o,`catalog-${s}.json`)}var c="127.0.0.1",S=18392,f=18400,i="/callback";function B(s){return`http://${c}:${s}${i}`}var N="KANE CLI",P="*",O={prod:{authBaseUrl:"https://auth.lambdatest.com",consentUrl:"https://accounts.lambdatest.com",controllerBaseUrl:"https://kaneai-api.lambdatest.com/v16-controller/v1",tmsBaseUrl:"https://test-manager-api.lambdatest.com/api",testGeneratorBaseUrl:"https://test-manager-api.lambdatest.com",secretsBaseUrl:"https://api-hyperexecute.lambdatest.com",testManagerUiUrl:"https://test-manager.lambdatest.com",shareApiBaseUrl:"https://api.lambdatest.com",v16ServerHost:"https://kaneai-api.lambdatest.com/v16-server",evidenceViewerUrl:"https://evidence.lambdatest.com",mediaArtefactsHost:"prod-mobile-artefacts.lambdatest.com",mobileAppBaseUrl:"https://api.lambdatest.com"},stage:{authBaseUrl:"https://stage-auth.lambdatestinternal.com",consentUrl:"https://stage-accounts.lambdatestinternal.com",controllerBaseUrl:"https://auteur-stage-automind.lambdatestinternal.com/v16-controller/v1",tmsBaseUrl:"https://stage-test-manager-api.lambdatestinternal.com/api",testGeneratorBaseUrl:"https://stage-test-manager-api.lambdatestinternal.com",secretsBaseUrl:"https://api-stage-hyperexecute.lambdatestinternal.com",testManagerUiUrl:"https://stage-test-manager.lambdatestinternal.com",shareApiBaseUrl:"https://stage-api.lambdatestinternal.com",v16ServerHost:"https://auteur-stage-automind.lambdatestinternal.com/v16-server",evidenceViewerUrl:"https://stage-evidence.lambdatestinternal.com",mediaArtefactsHost:"stage-mobile-artefacts.lambdatestinternal.com",mobileAppBaseUrl:"https://stage-api.lambdatestinternal.com"}},k={orange:"#ff9500",generateAccent:"#0d9488",assuranceAccent:"#b388ff",purple:"#b388ff",secondary:"#888888",dim:"#666666",muted:"#444444",green:"#4ade80",red:"#ef4444",amber:"#fbbf24"};export{m as a,d as b,e as c,h as d,b as e,A as f,_ as g,n as h,x as i,U as j,u as k,R as l,I as m,E as n,C as o,T as p,c as q,S as r,f as s,i as t,B as u,N as v,P as w,O as x,k as y};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{d as X}from"./chunk-BB2W35TW.js";import{a as $}from"./chunk-YKTYVJBN.js";import{A as T,l as z,m as Y,n as H}from"./chunk-TH47OOBV.js";import{b as q,g as N}from"./chunk-DUAXZYAD.js";import{a as W,d as S,f as L}from"./chunk-DBIBROYW.js";import{c as C}from"./chunk-UD7KKHPW.js";import{a as K,c as J}from"./chunk-
|
|
2
|
+
import{d as X}from"./chunk-BB2W35TW.js";import{a as $}from"./chunk-YKTYVJBN.js";import{A as T,l as z,m as Y,n as H}from"./chunk-TH47OOBV.js";import{b as q,g as N}from"./chunk-DUAXZYAD.js";import{a as W,d as S,f as L}from"./chunk-DBIBROYW.js";import{c as C}from"./chunk-UD7KKHPW.js";import{a as K,c as J}from"./chunk-7F2ZV46B.js";var ce=3,de=1e4,Q=()=>new Promise(r=>setTimeout(r,25+Math.floor(Math.random()*50))),Z=r=>r==="design"||r==="maintain"?"session":r==="revert"||r==="shape-op"?"exclusive":"commit";function le(r,e,o){for(let s of r){for(let t of s.supersessions)if(t.kind==="node"&&(o.has(t.old)||t.new!==null&&o.has(t.new)))return!0;for(let t of s.nodes)if(t.label==="usecase"&&e.newBuCandidates.length>0||o.has(t.cid))return!0;if(s.design_generation&&e.generationTicket&&s.design_generation.uc_root===e.generationTicket.uc_root)return!0;for(let t of e.sourcePins)if(Object.prototype.hasOwnProperty.call(s.source_head_moves,t.source_id))return!0}return!1}async function De(r,e,o){let{contextDir:s,locks:t,probe:a}=r,m=r.sid??r.rootSid,f=e.newBuCandidates.map(b=>({tempRef:b.tempRef,probeText:b.probeText})),k=0,g=!0,p={hits:[],degraded:!1,probeBasis:null};for(;;){g&&(f.length>0&&(p=await a.batchSimilar(T(s),f)),g=!1);let b=T(s),_={seq:b.lastSeq,hash:b.latestHash},P=new Map,w=[],v=[],R=new Set;for(let d of e.ucTargets){let c=H(b,d.ref);if(c===null)return{ok:!1,kind:"validation",errors:[{code:"UNKNOWN_REF",detail:`${d.ref}: names no living node (unknown or tombstoned chain)`}]};d.expectedTip!==void 0&&d.expectedTip!==c.cid&&P.set(d.expectedTip,c.cid),R.add(c.cid),v.push(L(b,d.ref).key)}(e.verb==="revert"||e.verb==="shape-op")&&(v.length=0,v.push({kind:"context",mode:"exclusive"}));let y;try{y=t.acquire(S(v),{hold:Z(e.verb),verb:e.verb})}catch(d){if(d instanceof W&&(d.code==="UC_HELD"||d.code==="CONTEXT_HELD"))return{ok:!1,kind:"contended",err:d};throw d}let V=!1,M=!1;try{let d=await t.withKeySerialized(v,async()=>{let c=T(s),O=_.hash===c.latestHash?[]:N(s,_.seq,_.hash).records;for(let n of e.ucTargets){let i=H(c,n.ref);if(i===null){w.push({kind:"supersession",ref:n.ref,detail:`${n.ref} was retired while this commit staged \u2014 re-ground or abandon`});continue}for(let l of R)c.superseded.has(l)&&c.tipOf(l)===i.cid&&P.set(l,i.cid)}for(let n of e.sourcePins){let i=c.heads.get(n.source_id);i!=null&&i!==n.source_cid&&w.push({kind:"pin",ref:n.source_id,detail:`source '${n.source_id}' moved (pinned ${n.source_cid.slice(0,19)}, head ${i.slice(0,19)}) \u2014 re-ground or abandon`})}if(w.length>0)return{ok:!1,kind:"drifted",asks:w};if(e.generationTicket){let n=X(c,e.generationTicket);if(n!==null)return{ok:!1,kind:"validation",errors:[n]}}if(f.length>0&&O.length>0){let n=new Set(p.hits.map(u=>u.candidateCid)),i=a.recheckLocal(c,f,p.probeBasis,O);if(i.hits.some(u=>!n.has(u.candidateCid))||i.uncachedNewNodes.length>0)return M=!0,"restart"}if(e.verb!=="revert"&&e.verb!=="shape-op"){let n=S(e.ucTargets.map(u=>L(c,u.ref).key)),i=S(v);if(!(n.length===i.length&&n.every((u,h)=>JSON.stringify(u)===JSON.stringify(i[h]))))return"restart"}if(e.eventIds&&e.eventIds.length>0&&e.eventIds.every(n=>c.appliedEvents.has(n)))return{ok:!0,skipped:"already-applied"};let ae=Date.now()+de,j=c.latestHash,E=c;for(;;){let n={graph:E,expectPrev:j,redirects:P,probeHits:p.hits,degradedProbe:p.degraded,sid:m,eventIds:(l,u)=>{if(e.eventIds&&e.eventIds.length>0)return e.eventIds.slice(0,u);let h=Y(E,r.rootSid,l,u),U=r.reservedEventIds??[];if(U.length===0)return h;let D=`${r.rootSid}:${l}:`,A=0;for(let F of U){if(!F.startsWith(D))continue;let x=F.slice(D.length);/^\d+$/.test(x)&&(A=Math.max(A,Number.parseInt(x,10)))}if(A===0)return h;let G=Number.parseInt(h[0].slice(D.length),10);return!Number.isInteger(G)||G>A?h:Array.from({length:u},(F,x)=>z(r.rootSid,l,A+1+x))},assertLocks:()=>y.assertHeld()};if(r.revalidate){let l=r.revalidate(n);if(l.length>0)return{ok:!1,kind:"validation",errors:l}}y.assertHeld();let i;try{i=o(n)}catch(l){if(l instanceof q){let u=T(s),h=N(s,E.lastSeq,E.latestHash).records;if(!le(h,e,R)&&Date.now()<ae){await Q(),E=u,j=u.latestHash;continue}return"restart"}throw l}return"errors"in i?{ok:!1,kind:"validation",errors:i.errors}:(Z(e.verb)==="session"&&y.touch(),{ok:!0,result:i.result,record:i.record})}});if(d==="restart")V=!0;else return d}finally{y.release()}if(V){if(k+=1,k>=ce)return{ok:!1,kind:"unsettled",attempts:k};M&&(g=!0),await Q();continue}}}import{readFileSync as ue,writeFileSync as fe,renameSync as me,mkdirSync as pe}from"fs";import{dirname as he,join as ge}from"path";var B=1,be=720*60*1e3;function I(r){return ge(J,"embeddings",`alias-${r}.json`)}function ee(r,e=Date.now()){return r!==null&&e-r.fetchedAt<be}function re(r){try{let e=JSON.parse(ue(r,"utf-8"));return e.wrapperVersion!==B||typeof e.purposes!="object"||e.purposes===null?null:{wrapperVersion:B,writtenByVersion:String(e.writtenByVersion??""),purposes:e.purposes}}catch{return null}}function te(r,e,o=I(r)){let t=re(o)?.purposes?.[e];return!t||typeof t.alias!="string"||typeof t.dims!="number"||typeof t.fetchedAt!="number"?null:{alias:t.alias,dims:t.dims,fetchedAt:t.fetchedAt}}function se(r,e,o,s=I(r)){try{pe(he(s),{recursive:!0});let a=re(s)?.purposes??{};a[e]={alias:o.alias,dims:o.dims,fetchedAt:Date.now()};let m={wrapperVersion:B,writtenByVersion:K,purposes:a},f=`${s}.tmp`;fe(f,JSON.stringify(m,null,2)+`
|
|
3
3
|
`),me(f,s)}catch(t){C(`[embed] Failed to save alias cache: ${t instanceof Error?t.message:String(t)}`,"EMBED_CACHE_WRITE_FAILED")}}function ve(r){return r.TESTMUAI_ENV==="stage"?"stage":"prod"}function oe(r){let e=r.env??process.env,o=r.auth?.TESTMUAI_BASIC_AUTH||e.TESTMUAI_BASIC_AUTH;if(o)return{authorization:`Basic ${o}`};let s=r.auth?.TESTMUAI_API_KEY||e.TESTMUAI_API_KEY;return s?{authorization:`Bearer ${s}`}:{}}async function Oe(r,e={}){let o=e.env??process.env,s=ve(o),t=e.aliasCacheFile??I(s),a=e.now??Date.now,m=te(s,r,t);if(ee(m,a()))return{alias:m.alias,dims:m.dims};let k=`${$(o)}/assurance/embed/alias?purpose=${encodeURIComponent(r)}`,g=await(e.fetchImpl??fetch)(k,{method:"GET",headers:oe(e)});if(!g.ok)throw new Error(`embed alias resolve failed: ${g.status}`);let p=await g.json();return se(s,r,{alias:p.alias,dims:p.dims},t),{alias:p.alias,dims:p.dims}}async function je(r,e,o={}){let s=o.env??process.env,t=$(s),a=await(o.fetchImpl??fetch)(`${t}/assurance/embed`,{method:"POST",headers:{...oe(o),"content-type":"application/json"},body:JSON.stringify({purpose:r,input:e})});if(!a.ok)throw new Error(`embed failed: ${a.status}`);return await a.json()}import{readFileSync as ke,writeFileSync as ye,renameSync as Ee,mkdirSync as Ae}from"fs";import{dirname as Te,join as ne}from"path";function we(r){return ne(r,"embeddings")}function xe(r){let e=r.indexOf(":");return e>=0?r.slice(e+1):r}function ie(r,e,o){let s=xe(o);return ne(we(r),e,s.slice(0,2),`${s.slice(2)}.f32`)}function We(r,e,o){try{let s=ke(ie(r,e,o)),t=new Float32Array(Math.floor(s.length/4));for(let a=0;a<t.length;a++)t[a]=s.readFloatLE(a*4);return t}catch{return null}}function qe(r,e,o,s){try{let t=ie(r,e,o);Ae(Te(t),{recursive:!0});let a=Buffer.alloc(s.length*4);for(let f=0;f<s.length;f++)a.writeFloatLE(s[f],f*4);let m=`${t}.tmp`;ye(m,a),Ee(m,t)}catch(t){C(`[embed] Failed to cache vector: ${t instanceof Error?t.message:String(t)}`,"EMBED_CACHE_WRITE_FAILED")}}export{De as a,Oe as b,je as c,We as d,qe as e};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
var r={complete:"complete",paused:"paused",interrupted:"interrupted",crashed:"crashed","walk-paused":"walk paused"};function t(e){return[`session summary \u2014 ${r[e.state]}${e.reason?` (${e.reason})`:""}`,...e.facts.map(s=>` ${s}`),...e.resume?[` resume: ${e.resume}`]:[],...e.resumeMessage?[` or with a message: ${e.resumeMessage}`]:[],...e.tracePath?[` trace: ${e.tracePath}`]:[]]}function n(e){process.stdout.write(t(e).join(`
|
|
3
|
+
`)+`
|
|
4
|
+
`)}export{n as a};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{
|
|
2
|
+
import{h as w}from"./chunk-TAOHYWEO.js";import{a as h}from"./chunk-RZ4F3BHX.js";import{c as f}from"./chunk-7F2ZV46B.js";import{mkdtemp as O,rm as $}from"fs/promises";import{createWriteStream as R}from"fs";import{Readable as U}from"stream";import{pipeline as F}from"stream/promises";import{tmpdir as T}from"os";import{basename as z,join as A}from"path";import{access as x,cp as P,mkdir as g,readdir as y,readFile as S,rename as I,rm as k,stat as b,writeFile as v}from"fs/promises";import{basename as D,join as d}from"path";function u(){return d(f,"mobile","apps")}function m(){return d(u(),"index.json")}function C(){return{readIndex:async()=>{try{let e=JSON.parse(await S(m(),"utf8"));return{apps:Array.isArray(e.apps)?e.apps:[]}}catch{return{apps:[]}}},writeIndex:async r=>{await g(u(),{recursive:!0});let e=`${m()}.tmp`;await v(e,JSON.stringify(r,null,2)),await I(e,m())},exists:async r=>{try{return await x(r),!0}catch{return!1}},copy:(r,e)=>P(r,e,{recursive:!0,force:!0}),remove:r=>k(r,{recursive:!0,force:!0}),sizeOf:async r=>{try{return(await b(r)).size}catch{return}},now:()=>new Date}}var c=class{deps;constructor(e={}){this.deps={...C(),...e}}async list(){let{apps:e}=await this.deps.readIndex();return[...e].sort((t,s)=>s.lastUsedAt.localeCompare(t.lastUsedAt))}async find(e){return(await this.deps.readIndex()).apps.find(t=>t.key===e)}async put(e){let t=await this.deps.readIndex(),s=t.apps.find(n=>n.key===e.key),a=this.deps.now().toISOString();if(s&&await this.deps.exists(s.path))return s.lastUsedAt=a,await this.deps.writeIndex(t),s;s&&(t.apps=t.apps.filter(n=>n.key!==e.key));let l=D(e.name??e.sourcePath),o=d(u(),e.key),p=d(o,l);await g(o,{recursive:!0}),await this.deps.copy(e.sourcePath,p);let i={key:e.key,path:p,name:l,source:e.source,...e.source==="local"?{originPath:e.sourcePath}:{},addedAt:a,lastUsedAt:a,...await this.deps.sizeOf(p).then(n=>n?{bytes:n}:{})};return t.apps=[...t.apps.filter(n=>n.key!==e.key),i],await this.deps.writeIndex(t),i}async exists(e){if(await this.deps.sizeOf(e.path)!==void 0)return!0;try{return await y(e.path),!0}catch{return!1}}async forget(e){let t=await this.deps.readIndex(),s=t.apps.find(a=>a.key===e);s&&(await this.deps.remove(s.path),t.apps=t.apps.filter(a=>a.key!==e),await this.deps.writeIndex(t))}async prune(){let e=await this.deps.readIndex(),t=[];for(let s of e.apps)if(await this.deps.sizeOf(s.path)!==void 0)t.push(s);else try{await y(s.path),t.push(s)}catch{}return t.length!==e.apps.length&&await this.deps.writeIndex({apps:t}),t}};var E=30*6e4,j=/^APP\d{6,}$/;function Y(r){return!!r&&j.test(r.trim())}function _(){return{store:new c,client:(r,e)=>new w(r,e),fetchToFile:async(r,e)=>{let t=await h(r,{method:"GET",signal:AbortSignal.timeout(E)});if(!t.ok)throw new Error(`Downloading the app failed: ${t.status} ${t.statusText}`);if(!t.body)throw new Error("Downloading the app failed: empty response body");await F(U.fromWeb(t.body),R(e))}}}async function Z(r,e={}){let t={..._(),...e},s=r.appId.trim(),a=await t.store.find(s);if(a&&await t.store.exists(a))return r.onProgress?.(`using the copy of ${a.name} already on this machine`),await t.store.put({key:s,sourcePath:a.path,source:"cloud",name:a.name}),{path:a.path,name:a.name,fromStore:!0};r.onProgress?.(`looking up ${s}\u2026`);let o=await t.client(r.baseUrl,r.auth).details(s);if(r.accepts&&!r.accepts.some(i=>o.name.toLowerCase().endsWith(i)))throw new Error(`${o.name} cannot run on this device \u2014 expected ${r.accepts.join(" or ")}.`);r.onProgress?.(`downloading ${o.name} \u2014 this can take a while, please wait\u2026`);let p=await O(A(T(),"kane-app-dl-"));try{let i=A(p,z(o.name));await t.fetchToFile(o.url,i);let n=await t.store.put({key:s,sourcePath:i,source:"cloud",name:o.name});return r.onProgress?.(`${o.name} is ready`),{path:n.path,name:n.name,fromStore:!1,details:o}}finally{await $(p,{recursive:!0,force:!0})}}export{c as a,Y as b,Z as c};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as C}from"./chunk-
|
|
2
|
+
import{a as C}from"./chunk-UODLRQQ4.js";import{f as Z}from"./chunk-GUVM6SZF.js";import{a as D}from"./chunk-YCCUBQY4.js";import{a as O}from"./chunk-5SNT2MK5.js";import{a as M}from"./chunk-ECZMYPLJ.js";import{b as W}from"./chunk-AJQT4IWZ.js";import{a as B}from"./chunk-U5GHOGLM.js";import{y as o}from"./chunk-7F2ZV46B.js";import{a as v}from"./chunk-HCBYKLMW.js";import{a as n,b as t,i as N}from"./chunk-C44QQJR4.js";import{a as L}from"./chunk-6YGTRKDT.js";import{e as g}from"./chunk-UR6MHSHU.js";var h=g(v(),1);function oe(e){let i=e.kind==="simulator";switch(e.state){case"ready":return i?"Booted":"Running";case"stopped":return i?"Shutdown":"Stopped";case"unauthorized":return"UNAUTHORIZED";case"offline":return"Offline"}}function te(e){switch(e.state){case"unauthorized":return"accept the authorisation prompt on the device, then reopen this list";case"offline":return e.kind==="simulator"?"not responding \u2014 open Simulator.app to inspect it":"not responding \u2014 reconnect it, or restart the emulator";default:return}}function re(e,i){let c=M(i.id);return e.platform===i.platform&&e.kind===i.kind&&(M(e.id)===c||e.virtualName!==void 0&&M(e.virtualName)===c)}function ne(e,i){let c=e.state==="ready"||e.state==="stopped",m=te(e);return{id:e.id,label:`${e.displayName} \xB7 ${oe(e)}`,...i&&re(e,i)?{isActive:!0}:{},...c?{}:{disabled:!0},...!c&&m?{disabledHint:m}:{}}}function ie(e){return e==="emulator"?"No Android emulator found. Make sure an emulator exists on this machine (Android Studio \u2192 Device Manager), then reopen this list.":e==="simulator"?"No iOS simulator found. Make sure a simulator exists on this machine (Xcode \u2192 Windows \u2192 Devices and Simulators), then reopen this list.":"No emulator or simulator found. Make sure one exists on this machine, then reopen this list."}function ge({targets:e,preselectedTarget:i,preselectedId:c,busyMessage:m,onSelect:S,onCancel:f,kind:l}){if(m)return(0,h.jsxs)(n,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,h.jsx)(t,{color:o.orange,bold:!0,children:"Device"}),(0,h.jsxs)(n,{marginTop:1,children:[(0,h.jsx)(C,{}),(0,h.jsxs)(t,{color:o.secondary,children:[" ",m]})]})]});if(e.length===0)return(0,h.jsxs)(n,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,h.jsx)(t,{color:o.orange,bold:!0,children:"Device"}),(0,h.jsx)(n,{marginTop:1,children:(0,h.jsx)(t,{color:o.dim,children:ie(l)})})]});let d=e.map(r=>ne(r,i)),p=i?d.find(r=>r.isActive)?.id??null:c?e.find(r=>r.id===c||r.virtualName===c)?.id??null:null,a=new Map(e.map(r=>[r.id,r]));return(0,h.jsx)(O,{title:"Device",items:d,itemNoun:"devices",defaultActiveId:p,preserveSelectionById:!0,onSelect:r=>{let y=a.get(r.id);y&&S(y)},onCancel:f})}var b=g(L(),1);var u=g(v(),1),q=50,G=500;function ae(e){return`${e.name} (${e.appId})`}function ve({kind:e,listApps:i,onSelect:c,onManualEntry:m,onCancel:S,busyMessage:f}){let[l,d]=(0,b.useState)([]),[p,a]=(0,b.useState)(!0),[r,y]=(0,b.useState)(!1),[Q,E]=(0,b.useState)(!1),[w,H]=(0,b.useState)(null),[$,V]=(0,b.useState)(""),[J,U]=(0,b.useState)(!1),X=(0,b.useRef)(!0),R=(0,b.useRef)(0);if((0,b.useEffect)(()=>{let x=++R.current,k=$.trim();X.current?a(!0):k&&E(!0),y(!0),H(null),U(!1),(async()=>{let I=[];try{for(let P=0;;P+=q){let z=await i({limit:q,offset:P,search:k});if(x!==R.current)return;if(I.push(...z.apps),d([...I]),X.current&&(a(!1),X.current=!1),E(!1),z.apps.length===0||I.length>=z.total)break;if(I.length>=G){U(!0);break}}}catch(P){if(x!==R.current)return;H(P instanceof Error?P.message:String(P)),a(!1),E(!1)}finally{x===R.current&&y(!1)}})()},[$,i]),N((x,k)=>{if(k.tab){m();return}k.escape&&S()},{isActive:!!w&&!f}),f)return(0,u.jsxs)(n,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,u.jsx)(t,{color:o.orange,bold:!0,children:"App under test"}),(0,u.jsxs)(n,{marginTop:1,children:[(0,u.jsx)(C,{}),(0,u.jsxs)(t,{color:o.secondary,children:[" ",f]})]})]});if(w)return(0,u.jsxs)(n,{flexDirection:"column",borderStyle:"round",borderColor:o.red,paddingX:2,paddingY:1,children:[(0,u.jsx)(t,{color:o.red,bold:!0,children:"App under test"}),(0,u.jsx)(n,{marginTop:1,children:(0,u.jsx)(t,{color:o.red,children:"Could not load your uploads."})}),(0,u.jsx)(n,{marginTop:1,children:(0,u.jsx)(t,{color:o.dim,children:w})}),(0,u.jsx)(B,{bindings:[{keys:"tab",label:"tab to enter an app id"}],escBackLabel:"back to chat"})]});let j=new Map(l.map(x=>[x.appId,x])),ee=l.map(x=>({id:x.appId,label:ae(x)})),_=!p&&!r&&l.length===0&&!$.trim()?e==="simulator"?"No simulator builds uploaded to this account yet \u2014 press Tab to enter an app id.":"No emulator builds uploaded to this account yet \u2014 press Tab to enter an app id.":null;return(0,u.jsx)(O,{title:"App under test",items:ee,loading:p,loadingText:"Loading your uploads\u2026",loadingMore:r,searching:Q,itemNoun:"uploads",preserveSelectionById:!0,onSearch:V,onTab:m,extraHint:"tab to enter an id",footer:_?(0,u.jsx)(t,{color:o.dim,children:_}):J?(0,u.jsx)(t,{color:o.dim,children:`Showing the first ${G} \u2014 type to search the rest.`}):void 0,onSelect:x=>{let k=j.get(x.id);k&&c({appId:k.appId,name:k.name})},onCancel:S})}var Y=g(L(),1);var T=g(v(),1),le={emulator:["apk"],simulator:["zip"]};function pe(e){return Z(e.trim())}function Ne({kind:e,onBack:i,onSelect:c,onCancel:m}){let[S,f]=(0,Y.useState)(""),[l,d]=(0,Y.useState)(null),p=e==="emulator"?".apk":".zip";return(0,T.jsxs)(n,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,T.jsx)(t,{color:o.orange,bold:!0,children:"App under test"}),(0,T.jsx)(n,{marginTop:1,children:(0,T.jsx)(t,{color:o.dim,children:`Path to a build (${p}): `})}),(0,T.jsxs)(n,{marginTop:1,children:[(0,T.jsx)(t,{color:o.dim,children:" "}),(0,T.jsx)(D,{value:S,onChange:a=>{f(a),l&&d(null)},onSubmit:a=>{let r=pe(a);if(!r){d(a.trim()?`Not a build \u2014 expected ${p}.`:"Enter the path to a build.");return}if(!le[e].includes(r.kind)){d(`${r.kind} builds don't run on a ${e} \u2014 expected ${p}.`);return}d(null),c(r).then(y=>{!y.ok&&y.error&&d(y.error)})},onCancel:i,placeholder:e==="emulator"?"/path/to/app-debug.apk":"/path/to/MyApp.zip"})]}),l&&(0,T.jsx)(n,{marginTop:1,children:(0,T.jsx)(t,{color:o.red,children:l})}),(0,T.jsx)(B,{bindings:[{keys:"\u21B5",label:"use this build"}],escBackLabel:"back"})]})}var F=g(L(),1);var A=g(v(),1);function se(e){return[{value:"local",label:"Local build",hint:e==="emulator"?".apk":".zip",available:!0},{value:"uploaded",label:"Uploaded app",hint:"an app id from your cloud uploads",available:!0}]}function $e({kind:e,onSelect:i,onCancel:c}){let m=se(e),[S,f]=(0,F.useState)(0),[l,d]=(0,F.useState)(null);return N((p,a)=>{if(a.escape){c();return}if(a.upArrow&&f(r=>Math.max(0,r-1)),a.downArrow&&f(r=>Math.min(m.length-1,r+1)),a.return){let r=m[S];if(!r.available){d("That source isn't available \u2014 choose a local build for now.");return}d(null),i(r.value)}}),(0,A.jsxs)(n,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,A.jsx)(t,{color:o.orange,bold:!0,children:"App under test"}),(0,A.jsx)(n,{marginTop:1,flexDirection:"column",children:m.map((p,a)=>{let r=a===S,y=p.available?r?o.orange:void 0:o.muted;return(0,A.jsxs)(n,{children:[(0,A.jsxs)(t,{color:y,children:[r?"\u276F ":" ",p.label]}),(0,A.jsxs)(t,{color:o.dim,children:[" ",p.hint]})]},p.value)})}),l&&(0,A.jsx)(n,{marginTop:1,children:(0,A.jsx)(t,{color:o.red,children:l})}),(0,A.jsx)(B,{bindings:[{keys:"\u2191\u2193",label:"navigate"},{keys:"\u21B5",label:"select"}],escBackLabel:"back"})]})}var K=g(L(),1);var s=g(v(),1);function We({busyMessage:e,onSubmit:i,onBack:c}){let[m,S]=(0,K.useState)(""),[f,l]=(0,K.useState)(null);return e?(0,s.jsxs)(n,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,s.jsx)(t,{color:o.orange,bold:!0,children:"App under test"}),(0,s.jsxs)(n,{marginTop:1,children:[(0,s.jsx)(C,{}),(0,s.jsxs)(t,{color:o.secondary,children:[" ",e]})]})]}):(0,s.jsxs)(n,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,s.jsx)(t,{color:o.orange,bold:!0,children:"App under test"}),(0,s.jsx)(n,{marginTop:1,children:(0,s.jsx)(t,{color:o.dim,children:"App id from your cloud uploads:"})}),(0,s.jsxs)(n,{marginTop:1,children:[(0,s.jsx)(t,{color:o.dim,children:" "}),(0,s.jsx)(D,{value:m,onChange:d=>{S(d),f&&l(null)},onSubmit:d=>{let p=d.trim();if(!p){l("Enter an app id.");return}if(!W(p)){l("That doesn't look like an app id \u2014 they start with APP.");return}l(null),i(p).then(a=>{!a.ok&&a.error&&l(a.error)})},onCancel:c,placeholder:"APP1016032231178585590501450"})]}),f&&(0,s.jsxs)(n,{marginTop:1,flexDirection:"column",children:[(0,s.jsx)(t,{color:o.red,children:f}),(0,s.jsx)(t,{color:o.dim,children:"Enter a valid app id \u2014 copy it from your cloud uploads."})]}),(0,s.jsx)(B,{bindings:[{keys:"\u21B5",label:"use this app"}],escBackLabel:"back"})]})}export{ge as a,ve as b,Ne as c,$e as d,We as e};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{
|
|
2
|
+
import{b as K}from"./chunk-JGOZUAMC.js";import{a as B,b as U,c as Y}from"./chunk-AFPHLUQ5.js";import{a as j}from"./chunk-DNNZ353O.js";import{d as F}from"./chunk-XWKUZJCP.js";import{A as k,a as L,b as V,k as G,o as N}from"./chunk-TH47OOBV.js";import{d as I}from"./chunk-DUAXZYAD.js";import{d as v,e as x,g as H}from"./chunk-WXHQYYD5.js";function ee(t,e,n,i,s){let f=n.rows.filter(u=>{let d=i.get(u.temp_ref);return d!==void 0&&d!=="reject"});if(f.length===0)return{record:null,errors:null};let o={version:1,read_basis:e.latestHash,source:{source_id:n.source_id,source_cid:e.heads.get(n.source_id)??""},use_cases:f.map(u=>u.uc)},p=new Map;for(let u of f){let d=i.get(u.temp_ref);typeof d=="object"?p.set(u.temp_ref,{resolution:"edited",edit:d.edited}):p.set(u.temp_ref,{resolution:u.uc.matches_existing&&u.uc.changed?"edited":"approved"})}let g=Y(o,e,n.staged_source_cid);if(g.errors!==null)return{record:null,errors:g.errors};let r=g.proposal,l=o.source.source_cid?D(t,e,o.source.source_cid):null;if(l!==null){r=U(r,l);let u=G(r,B(l),e);if(u.length>0)return{record:null,errors:[{code:"HELD_CITES_STALE",detail:"the source moved after this plan staged \u2014 its quotes no longer verify against the current head; re-run kane-cli maintain reconcile to re-stage"},...u]}}let m=`held-${(e.latestHash??"root").slice(-12)}-${f.length}`;return N({contextDir:t,graph:e,proposal:r,proposalId:m,verdicts:p,by:s,autoName:!0})}function W(t,e,n=[]){let i=K(t,e),s=new Set,f=[],o=l=>{!l||s.has(l)||(s.add(l),f.push(y(t,l)))};for(let l of i.pairs)o(l.scenario),o(l.test);for(let[l,m]of i.verifies){o(l);for(let u of m)o(u)}if(n.length===0)return{stale_refs:f};let p=l=>`${String(l.props.source_id)}\0${String(l.props.anchor)}`,g=new Set;for(let{cid:l}of t.byLabel(v.USECASE))if(t.tipOf(l)===e)for(let m of t.edgesInto(l)){if(m.type!==x.DERIVES)continue;let u=m.props.claim;typeof u=="string"&&n.includes(u)&&g.add(p(m))}if(g.size===0)return{stale_refs:f};let r=new Set;for(let[l,m]of i.verifies)if(t.edgesInto(l).some(d=>d.type===x.DERIVES&&g.has(p(d)))){r.add(y(t,l));for(let d of m)r.add(y(t,d))}return{stale_refs:f,...r.size>0?{direct_refs:[...r]}:{}}}var q="this release plans changes only \u2014 blast-radius impact and drift meaning-checks are not measured, and REMOVE rows are never executed automatically",te="suite untouched; graph updated";function M(t,e){return!t.superseded.has(e)&&t.trust.get(e)!=="archived"}function y(t,e,n=new Set){let i=t.nameOf.get(e);if(i!==void 0)return i;if(n.has(e))return e;n.add(e);for(let[s,f]of t.superseded){if(f!==e)continue;let o=y(t,s,n);if(o!==s)return o}return e}function C(t){return String(t).slice(0,19)}function A(t,e,n){let i=t.edgesFrom(e).find(s=>s.type===n);return i?t.tipOf(i.dst):null}function X(t,e){let n=t.nodeLabel.get(e);if(n===v.USECASE)return e;if(n===v.SCENARIO)return A(t,e,x.BELONGS_TO);if(n===v.AC){let i=A(t,e,x.SCOPED_TO);return i?t.nodeLabel.get(i)===v.USECASE?i:A(t,i,x.BELONGS_TO):null}if(n===v.TEST){let i=A(t,e,x.AUTOMATES);return i?A(t,i,x.BELONGS_TO):null}return null}function z(t,e){let n=[],i=new Map;for(let s of t.derivesInto(e))i.set(String(s.props.source_id),s);for(let[s,f]of i){let o=t.heads.get(s);if(o==null){n.push(`DERIVES pin ${s} @ ${C(f.props.source_cid)} \u2014 source retired`);continue}if(o!==f.props.source_cid){let p=t.convChains.get(s)?.chain;if(p&&p.includes(String(f.props.source_cid)))continue;n.push(`DERIVES pin ${s} @ ${C(f.props.source_cid)} \u2014 source head moved to ${C(o)}`)}}for(let s of t.edgesFrom(e))H(s.type)?.pin?.comparesTo==="dst_tip"&&t.superseded.has(s.dst)&&n.push(`${s.type} pin \u2192 ${y(t,s.dst)} \u2014 target superseded`);return n.join("; ")||"structural pin broken"}var ne=new Set([v.USECASE,v.SCENARIO,v.AC,v.TEST]);function $(t,e){return t.ref<e.ref?-1:t.ref>e.ref?1:0}function D(t,e,n){let i=j(t,e,n);return i===null?null:i.toString("utf8")}function se(t,e,n,i,s){let f=n.props.quote;if(typeof f=="string"&&f.length>0)return i.includes(f);let o=String(n.props.source_cid);s.has(o)||s.set(o,D(t,e,o));let p=s.get(o);if(p===null)return!1;let g=V(p,String(n.props.anchor));return g===null?!1:g.split(`
|
|
3
3
|
`).some(r=>r.trim().length>0&&i.includes(r.trim()))}function oe(t,e,n){let i=L(String(e.props.anchor));if(i?.kind!=="img-part")return!1;let f=(t.mediaOf(String(e.props.source_cid)).images??[]).find(r=>r.ref===i.ref),o=f?.blob;if(o===void 0)return!1;let p=t.mediaOf(n).images??[];if(p.some(r=>r.blob===o))return!0;let g=f?.appearance;return g!==void 0&&p.filter(r=>r.appearance===g).length===1}var J=128*1024,Q=64*1024;function re(t,e){let n=t.split(`
|
|
4
4
|
`),i=e.split(`
|
|
5
5
|
`),s=0;for(;s<n.length&&s<i.length&&n[s]===i[s];)s++;let f=n.length,o=i.length;for(;f>s&&o>s&&n[f-1]===i[o-1];)f--,o--;if(f===s&&o===s)return"";let p=n.slice(s,f),g=i.slice(s,o),l=ie(p,g,2e3),m=[];if(l===null)m.push(`@@ old L${s+1}-L${f} \u2192 new L${s+1}-L${o} @@`,...p.map(u=>`- ${u}`),...g.map(u=>`+ ${u}`));else{let u=l.map((a,h)=>a.op==="="?-1:h).filter(a=>a>=0),d=0;for(;d<u.length;){let a=d;for(;a+1<u.length&&u[a+1]-u[a]<=3;)a++;let h=Math.max(u[d]-1,0),R=Math.min(u[a]+1,l.length-1),b=l.slice(h,R+1),S=s+(b[0].ai??0)+1,_=s+(b[0].bi??0)+1,c=b.filter(E=>E.op!=="+").length,w=b.filter(E=>E.op!=="-").length;m.push(`@@ old L${S}-L${S+Math.max(c-1,0)} \u2192 new L${_}-L${_+Math.max(w-1,0)} @@`);for(let E of b)m.push(E.op==="="?` ${E.line}`:`${E.op} ${E.line}`);d=a+1}}return m.join(`
|
|
6
6
|
`)}function ie(t,e,n){let i=t.length,s=e.length,f=Math.min(i+s,n),o=new Map([[1,0]]),p=[],g=!1;for(let u=0;u<=f&&!g;u++){p.push(new Map(o));for(let d=-u;d<=u;d+=2){let a=d===-u||d!==u&&(o.get(d-1)??0)<(o.get(d+1)??0)?o.get(d+1)??0:(o.get(d-1)??0)+1,h=a-d;for(;a<i&&h<s&&t[a]===e[h];)a++,h++;if(o.set(d,a),a>=i&&h>=s){g=!0;break}}}if(!g)return null;let r=i,l=s,m=[];for(let u=p.length-1;u>0;u--){let d=p[u],a=r-l,h=a===-u||a!==u&&(d.get(a-1)??0)<(d.get(a+1)??0)?a+1:a-1,R=d.get(h)??0,b=R-h;for(;r>R&&l>b;)m.push({op:"=",line:t[r-1],ai:r-1,bi:l-1}),r--,l--;u>0&&(r===R?(m.push({op:"+",line:e[l-1],ai:r,bi:l-1}),l--):(m.push({op:"-",line:t[r-1],ai:r-1,bi:l}),r--))}for(;r>0&&l>0;)m.push({op:"=",line:t[r-1],ai:r-1,bi:l-1}),r--,l--;for(;r>0;)m.push({op:"-",line:t[r-1],ai:r-1,bi:0}),r--;for(;l>0;)m.push({op:"+",line:e[l-1],ai:0,bi:l-1}),l--;return m.reverse()}function ce(t){let e=Buffer.byteLength(t,"utf8");if(e<=J+Q)return{diff:t,truncated:!1};let n=Buffer.from(t,"utf8"),i=J;for(;i>0&&(n[i]&192)===128;)i--;let s=e-Q;for(;s<e&&(n[s]&192)===128;)s++;let f=n.subarray(0,i).toString("utf8"),o=n.subarray(s).toString("utf8");return{diff:`${f}
|
|
7
7
|
\u2026 [diff truncated: ${e-i-(e-s)} bytes omitted] \u2026
|
|
8
|
-
${o}`,truncated:!0}}function ae(t,e){let n=k(t),i=n.heads.get(e);if(typeof i!="string")return null;let s=[];for(let d of I(t).records){let a=d.source_head_moves?.[e];a!==void 0&&a!==s[s.length-1]&&s.push(a)}let f=s.lastIndexOf(i),o=f>0?s[f-1]:null;if(typeof o!="string"||o===i)return null;let p=D(t,n,o),g=D(t,n,i);if(p===null||g===null)return null;let{diff:r,truncated:l}=ce(re(p,g)),m=new Set,u=[];for(let d of n.edgesFrom(o))d.type!==x.DERIVES||n.nodeLabel.get(d.dst)!==v.USECASE||m.has(d.dst)||(m.add(d.dst),u.push({id:d.dst,title:String(n.getNode(d.dst)?.content.title??"")}));return{source_id:e,old_head:o,new_head:i,diff:r,...l?{truncated:!0}:{},prior_ucs:u}}function de(t,e,n){let i=t.getNode(e)?.content??{},s=t.getNode(n)?.content??{},o=[...new Set([...Object.keys(i),...Object.keys(s)])].sort().filter(p=>JSON.stringify(i[p])!==JSON.stringify(s[p]));return o.length>0?`updated: ${o.join(", ")}`:"updated"}function le(t,e,n,i,s,f,o){let p=new Set((o?.rows??[]).map(a=>a.matched_cid).filter(a=>!!a)),g=[];for(let[a,h]of n.superseded)h===null||a===h||e.superseded.has(a)||n.nodeLabel.get(a)===v.USECASE&&g.push({kind:"MODIFY",ref:y(n,a),old_cid:a,new_cid:h,summary:de(n,a,h)});let r=f.map(a=>({kind:"ADD",ref:y(n,a),cid:a}));for(let a of o?.rows??[])a.kind==="MODIFY"&&a.matched_cid?g.push({kind:"MODIFY",ref:y(n,a.matched_cid),old_cid:a.matched_cid,new_cid:null,summary:`${a.why} (staged)`}):a.kind==="ADD"&&r.push({kind:"ADD",ref:a.title,cid:null});let l=[],m=D(t,n,s),u=new Map;for(let{cid:a}of n.byLabel(v.USECASE)){if(!M(n,a)||p.has(a))continue;let h=n.derivesInto(a),R=h.filter(_=>String(_.props.source_id)===i);R.length===0||R.some(_=>_.props.source_cid===s)||R.some(_=>{let c=String(_.props.anchor),w=L(c);return w?.kind==="img-whole"?!1:w?.kind==="img-part"?oe(n,_,s):m!==null&&se(t,n,_,m,u)})||h.some(_=>{let c=String(_.props.source_id);if(c===i)return!1;let w=n.heads.get(c);return w!=null})||l.push({kind:"ARCHIVE",ref:y(n,a),cid:a,why:`evidence decayed: no quote from ${i} relocates into @${C(s)}, no other live source, no fresh evidence this run`,impact:W(n,n.tipOf(a))})}let d=(a,h)=>a.ref<h.ref?-1:a.ref>h.ref?1:0;return[...g.sort(d),...r.sort(d),...l.sort(d)]}function Ee(t,e,n,i,s){let f=e.rows.find(d=>d.temp_ref===n);if(!f)return{ok:!1,message:`held item ${n} missing from the plan artifact`};let o=f,p=k(t);if(o.matched_cid){let d=p.tipOf(o.matched_cid);if(p.superseded.get(d)===null)return{ok:!1,message:`use-case for "${o.title}" was retired meanwhile \u2014 nothing to update`};d!==o.matched_cid&&(o={...o,matched_cid:d,uc:{...o.uc,matches_existing:{cid:d}}})}let g=s?{edited:s}:"approve",r=ee(t,p,{source_id:e.source_id,...e.staged_source_cid!==void 0?{staged_source_cid:e.staged_source_cid}:{},rows:[o]},new Map([[o.temp_ref,g]]),i);if(r.errors)return{ok:!1,message:r.errors.map(d=>`${d.code}: ${d.detail}`).join("; ")};let l=k(t),m=o.matched_cid?l.tipOf(o.matched_cid):r.record?.nodes.find(d=>d.label==="usecase")?.cid??r.record?.review[0]?.id;return{ok:!0,ref:m?y(l,m):o.title,kind:o.kind}}async function Re(t,e,n,i={}){let s=k(t),f=s.heads.get(e)??null,o=new Set(s.staleList().filter(c=>c.state==="stale").map(c=>c.cid)),p=await n.reingest(e);if(p.status==="unchanged"&&!i.resumeHeld)return{source_id:e,changed:!1,head:{status:p.status,before:f,after:p.cid},note:`nothing to reconcile \u2014 ${e} is unchanged`,skipped_arms:q,changeset:[],rows:[]};let g=i.resumeHeld?{minted:[],matched:[],held:i.resumeHeld}:await n.reextract(e),r=k(t),l=g.minted.map(c=>{let w=y(r,c);return{kind:"ADD",origin:"content-change",ref:w,reason:`new use-case extracted from ${e}`,provenance:`extraction commit \u2014 DERIVES ${e} @ ${C(p.cid)}`,action:`kane-cli design tests --use-case ${w}`}}),m=r.staleList().filter(c=>c.state==="stale"&&!o.has(c.cid)&&M(r,c.cid)).map(c=>c.cid),u=m.map(c=>{let w=y(r,c),E=ne.has(r.nodeLabel.get(c)??"");return{kind:"MODIFY",origin:"structural-stale",ref:w,reason:"stale (structural)",provenance:z(r,c),action:E?`kane-cli maintain evolve ${w}`:`kane-cli design explain ${w}`}}),d=[],a=[];for(let c of g.held?.rows??[])if(c.kind==="ADD")d.push({kind:"ADD",origin:"content-change",ref:c.title,held_ref:c.temp_ref,reason:`${c.why} (staged \u2014 commits on approval)`,provenance:`staged extraction of ${e} @ ${C(p.cid)}`,action:"approve to commit + design"});else{let w=c.matched_cid?r.tipOf(c.matched_cid):null,E=w?r.getNode(w)?.content.criteria??[]:[],T=(c.uc.updated?.criteria??[]).map(O=>typeof O=="string"?O:O.text),Z=[...T.filter(O=>!E.includes(O)),...c.uc.updated?.criteria!==void 0?E.filter(O=>!T.includes(O)):[]],P=w?W(r,w,Z):void 0;a.push({kind:"MODIFY",origin:"content-change",ref:c.matched_cid?y(r,c.matched_cid):c.title,held_ref:c.temp_ref,reason:`${c.why} (staged \u2014 commits on approval)`,provenance:`staged extraction of ${e} @ ${C(p.cid)}`,action:"approve to commit the updated version (old\u2192new redirect)",...P?{impact:P}:{}})}let h=new Set;for(let c of[...g.minted,...g.matched])h.add(r.tipOf(c));for(let c of g.held?.rows??[])c.matched_cid&&h.add(r.tipOf(c.matched_cid));for(let c of m){let w=X(r,r.tipOf(c));w&&r.nodeLabel.get(w)===v.USECASE&&h.add(r.tipOf(w))}let R=[];for(let c of await F(r,"design")){if(c.kind!=="no-verifies")continue;let w=r.resolve(c.ref);if(!w)continue;let E=X(r,w.tip);!E||!h.has(r.tipOf(E))||R.push({kind:"ADD",origin:"content-change",ref:c.ref,reason:c.why,provenance:`gaps engine (design) \u2014 uncovered AC of touched use-case ${y(r,E)}`,action:c.ready_command})}let b=[];for(let{cid:c}of r.byLabel(v.USECASE))M(r,c)&&r.stale(c)==="orphaned"&&b.push({kind:"REMOVE",ref:y(r,c),reason:"orphaned \u2014 no live source evidences this use-case",provenance:z(r,c),action:"plan-only \u2014 REMOVE is not executed in this release"});let S=new Set,_=[...l.sort($),...d.sort($),...R.sort($),...a.sort($),...u.sort($),...b.sort($)].filter(c=>{let w=`${c.kind}\0${c.ref}`;return S.has(w)?!1:(S.add(w),!0)});return{source_id:e,changed:!0,head:{status:p.status,before:f,after:p.cid},note:te,skipped_arms:q,changeset:le(t,s,r,e,p.cid,g.minted,g.held),rows:_,...g.held?{held:g.held}:{}}}function ye(t,e){return async n=>{let{ingestFile:i}=await import("./ingest-EX72IEQT.js"),{convertPdf:s}=await import("./pdf-convert-OZIRUADA.js"),{convertDocx:f}=await import("./docx-convert-JMUMT5C4.js"),o=await i({contextDir:t,filePath:e,asId:n,converters:{pdf:s,docx:f}});return{status:o.status,cid:o.cid}}}function be(t,e,n,i){return async()=>{let f=(i??(await import("./dispatch-
|
|
8
|
+
${o}`,truncated:!0}}function ae(t,e){let n=k(t),i=n.heads.get(e);if(typeof i!="string")return null;let s=[];for(let d of I(t).records){let a=d.source_head_moves?.[e];a!==void 0&&a!==s[s.length-1]&&s.push(a)}let f=s.lastIndexOf(i),o=f>0?s[f-1]:null;if(typeof o!="string"||o===i)return null;let p=D(t,n,o),g=D(t,n,i);if(p===null||g===null)return null;let{diff:r,truncated:l}=ce(re(p,g)),m=new Set,u=[];for(let d of n.edgesFrom(o))d.type!==x.DERIVES||n.nodeLabel.get(d.dst)!==v.USECASE||m.has(d.dst)||(m.add(d.dst),u.push({id:d.dst,title:String(n.getNode(d.dst)?.content.title??"")}));return{source_id:e,old_head:o,new_head:i,diff:r,...l?{truncated:!0}:{},prior_ucs:u}}function de(t,e,n){let i=t.getNode(e)?.content??{},s=t.getNode(n)?.content??{},o=[...new Set([...Object.keys(i),...Object.keys(s)])].sort().filter(p=>JSON.stringify(i[p])!==JSON.stringify(s[p]));return o.length>0?`updated: ${o.join(", ")}`:"updated"}function le(t,e,n,i,s,f,o){let p=new Set((o?.rows??[]).map(a=>a.matched_cid).filter(a=>!!a)),g=[];for(let[a,h]of n.superseded)h===null||a===h||e.superseded.has(a)||n.nodeLabel.get(a)===v.USECASE&&g.push({kind:"MODIFY",ref:y(n,a),old_cid:a,new_cid:h,summary:de(n,a,h)});let r=f.map(a=>({kind:"ADD",ref:y(n,a),cid:a}));for(let a of o?.rows??[])a.kind==="MODIFY"&&a.matched_cid?g.push({kind:"MODIFY",ref:y(n,a.matched_cid),old_cid:a.matched_cid,new_cid:null,summary:`${a.why} (staged)`}):a.kind==="ADD"&&r.push({kind:"ADD",ref:a.title,cid:null});let l=[],m=D(t,n,s),u=new Map;for(let{cid:a}of n.byLabel(v.USECASE)){if(!M(n,a)||p.has(a))continue;let h=n.derivesInto(a),R=h.filter(_=>String(_.props.source_id)===i);R.length===0||R.some(_=>_.props.source_cid===s)||R.some(_=>{let c=String(_.props.anchor),w=L(c);return w?.kind==="img-whole"?!1:w?.kind==="img-part"?oe(n,_,s):m!==null&&se(t,n,_,m,u)})||h.some(_=>{let c=String(_.props.source_id);if(c===i)return!1;let w=n.heads.get(c);return w!=null})||l.push({kind:"ARCHIVE",ref:y(n,a),cid:a,why:`evidence decayed: no quote from ${i} relocates into @${C(s)}, no other live source, no fresh evidence this run`,impact:W(n,n.tipOf(a))})}let d=(a,h)=>a.ref<h.ref?-1:a.ref>h.ref?1:0;return[...g.sort(d),...r.sort(d),...l.sort(d)]}function Ee(t,e,n,i,s){let f=e.rows.find(d=>d.temp_ref===n);if(!f)return{ok:!1,message:`held item ${n} missing from the plan artifact`};let o=f,p=k(t);if(o.matched_cid){let d=p.tipOf(o.matched_cid);if(p.superseded.get(d)===null)return{ok:!1,message:`use-case for "${o.title}" was retired meanwhile \u2014 nothing to update`};d!==o.matched_cid&&(o={...o,matched_cid:d,uc:{...o.uc,matches_existing:{cid:d}}})}let g=s?{edited:s}:"approve",r=ee(t,p,{source_id:e.source_id,...e.staged_source_cid!==void 0?{staged_source_cid:e.staged_source_cid}:{},rows:[o]},new Map([[o.temp_ref,g]]),i);if(r.errors)return{ok:!1,message:r.errors.map(d=>`${d.code}: ${d.detail}`).join("; ")};let l=k(t),m=o.matched_cid?l.tipOf(o.matched_cid):r.record?.nodes.find(d=>d.label==="usecase")?.cid??r.record?.review[0]?.id;return{ok:!0,ref:m?y(l,m):o.title,kind:o.kind}}async function Re(t,e,n,i={}){let s=k(t),f=s.heads.get(e)??null,o=new Set(s.staleList().filter(c=>c.state==="stale").map(c=>c.cid)),p=await n.reingest(e);if(p.status==="unchanged"&&!i.resumeHeld)return{source_id:e,changed:!1,head:{status:p.status,before:f,after:p.cid},note:`nothing to reconcile \u2014 ${e} is unchanged`,skipped_arms:q,changeset:[],rows:[]};let g=i.resumeHeld?{minted:[],matched:[],held:i.resumeHeld}:await n.reextract(e),r=k(t),l=g.minted.map(c=>{let w=y(r,c);return{kind:"ADD",origin:"content-change",ref:w,reason:`new use-case extracted from ${e}`,provenance:`extraction commit \u2014 DERIVES ${e} @ ${C(p.cid)}`,action:`kane-cli design tests --use-case ${w}`}}),m=r.staleList().filter(c=>c.state==="stale"&&!o.has(c.cid)&&M(r,c.cid)).map(c=>c.cid),u=m.map(c=>{let w=y(r,c),E=ne.has(r.nodeLabel.get(c)??"");return{kind:"MODIFY",origin:"structural-stale",ref:w,reason:"stale (structural)",provenance:z(r,c),action:E?`kane-cli maintain evolve ${w}`:`kane-cli design explain ${w}`}}),d=[],a=[];for(let c of g.held?.rows??[])if(c.kind==="ADD")d.push({kind:"ADD",origin:"content-change",ref:c.title,held_ref:c.temp_ref,reason:`${c.why} (staged \u2014 commits on approval)`,provenance:`staged extraction of ${e} @ ${C(p.cid)}`,action:"approve to commit + design"});else{let w=c.matched_cid?r.tipOf(c.matched_cid):null,E=w?r.getNode(w)?.content.criteria??[]:[],T=(c.uc.updated?.criteria??[]).map(O=>typeof O=="string"?O:O.text),Z=[...T.filter(O=>!E.includes(O)),...c.uc.updated?.criteria!==void 0?E.filter(O=>!T.includes(O)):[]],P=w?W(r,w,Z):void 0;a.push({kind:"MODIFY",origin:"content-change",ref:c.matched_cid?y(r,c.matched_cid):c.title,held_ref:c.temp_ref,reason:`${c.why} (staged \u2014 commits on approval)`,provenance:`staged extraction of ${e} @ ${C(p.cid)}`,action:"approve to commit the updated version (old\u2192new redirect)",...P?{impact:P}:{}})}let h=new Set;for(let c of[...g.minted,...g.matched])h.add(r.tipOf(c));for(let c of g.held?.rows??[])c.matched_cid&&h.add(r.tipOf(c.matched_cid));for(let c of m){let w=X(r,r.tipOf(c));w&&r.nodeLabel.get(w)===v.USECASE&&h.add(r.tipOf(w))}let R=[];for(let c of await F(r,"design")){if(c.kind!=="no-verifies")continue;let w=r.resolve(c.ref);if(!w)continue;let E=X(r,w.tip);!E||!h.has(r.tipOf(E))||R.push({kind:"ADD",origin:"content-change",ref:c.ref,reason:c.why,provenance:`gaps engine (design) \u2014 uncovered AC of touched use-case ${y(r,E)}`,action:c.ready_command})}let b=[];for(let{cid:c}of r.byLabel(v.USECASE))M(r,c)&&r.stale(c)==="orphaned"&&b.push({kind:"REMOVE",ref:y(r,c),reason:"orphaned \u2014 no live source evidences this use-case",provenance:z(r,c),action:"plan-only \u2014 REMOVE is not executed in this release"});let S=new Set,_=[...l.sort($),...d.sort($),...R.sort($),...a.sort($),...u.sort($),...b.sort($)].filter(c=>{let w=`${c.kind}\0${c.ref}`;return S.has(w)?!1:(S.add(w),!0)});return{source_id:e,changed:!0,head:{status:p.status,before:f,after:p.cid},note:te,skipped_arms:q,changeset:le(t,s,r,e,p.cid,g.minted,g.held),rows:_,...g.held?{held:g.held}:{}}}function ye(t,e){return async n=>{let{ingestFile:i}=await import("./ingest-EX72IEQT.js"),{convertPdf:s}=await import("./pdf-convert-OZIRUADA.js"),{convertDocx:f}=await import("./docx-convert-JMUMT5C4.js"),o=await i({contextDir:t,filePath:e,asId:n,converters:{pdf:s,docx:f}});return{status:o.status,cid:o.cid}}}function be(t,e,n,i){return async()=>{let f=(i??(await import("./dispatch-ECUEAMXS.js")).findProvider)(e);if(!f)throw new Error(`the remote re-ingest failed \u2014 no provider matches '${e}'`);let o=await f.ingest(e,void 0,{out:n.out,err:n.err,confirm:async()=>!0,isTTY:!1},t,void 0);if(o.code!==0||!o.result)throw new Error("the remote re-ingest failed \u2014 fix the reported problem and re-run");return{status:o.result.status,cid:o.result.source_cid}}}function xe(t,e={}){return async n=>{let i=[],[{runExtract:s},{resolveAgentAuthEnv:f},{runAgent:o},{preflightTurn:p}]=await Promise.all([import("./run-CMFBSYWF.js"),import("./spawner-DQZRJIE6.js"),import("./bridge-QDPBIIOW.js"),import("./turn-preflight-JGYT7LXP.js")]),g=await f(),r=new Set(k(t).byLabel(v.USECASE).map(S=>S.cid)),l=ae(t,n)??void 0,m=0,u=await s({mode:"override",source:n,...l?{changeContext:l}:{}},{contextDir:t,agent:o,preflightTurn:()=>p(g),ask:async()=>[],review:async S=>{if(!e.stage)return new Map(S.map(c=>[c.temp_ref,{resolution:c.matches_existing&&c.changed?"edited":"skipped"}]));let _=new Map;for(let c of S){if(c.matches_existing&&!c.changed){_.set(c.temp_ref,{resolution:"skipped"});continue}i.push({kind:c.matches_existing?"MODIFY":"ADD",temp_ref:c.temp_ref,title:c.title,why:c.matches_existing?`updated: ${Object.keys(c.updated??{}).join(", ")||"content"}`:`newly extracted from ${n}`,...c.matches_existing?{matched_cid:c.matches_existing.cid,updated:c.updated}:{},uc:c}),_.set(c.temp_ref,{resolution:"rejected"})}return _},confirmStale:async()=>!1,out:S=>e.hostOut?.(S),progress:S=>e.hostProgress?.(S),emit:S=>{S.type==="commit"&&typeof S.assumed=="number"&&(m+=S.assumed),e.hostEmit?.(S)},isTTY:!1,auth:g});if(u!==0)throw new Error(`reconcile: re-extract of ${n} failed (exit ${u})`);let d=k(t),a=d.heads.get(n),h=[],R=[];if(typeof a=="string"){let S=new Set;for(let _ of d.edgesFrom(a))_.type!==x.DERIVES||d.nodeLabel.get(_.dst)!==v.USECASE||S.has(_.dst)||(S.add(_.dst),!(e.stage&&d.trust.get(_.dst)==="archived")&&(r.has(_.dst)?R:h).push(_.dst))}let b=k(t).heads.get(n);return{minted:h,matched:R,defaultsTaken:m,...e.stage?{held:{source_id:n,...b!=null?{staged_source_cid:b}:{},rows:i}}:{}}}}export{ee as a,W as b,q as c,te as d,M as e,X as f,ne as g,re as h,ce as i,ae as j,Ee as k,Re as l,ye as m,be as n,xe as o};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
var g={graph_search_similar:"search graph",graph_get_node:"read node",graph_get_edges:"read edges",graph_match_by_type:"match by type",graph_find_by_provenance:"trace provenance",graph_stale_nodes:"check stale",ask_user:"ask",finalize_proposal:"propose use-cases",chat_turn:"apply changes",read_image:"read image",source_read:"read source",source_grep:"search source",finalize_design:"propose design",expand_bva:"expand boundaries",covering_array:"combine classes",dedupe_candidates:"dedupe",budget_cut:"trim to budget",source_list:"list sources",graph_search_similar_batch:"search graph",graph_history:"read history"};function d(t){let e=g[t.name],n=t.status==="error"||t.status==="aborted"?" \u2717":"",a=t.detail?` \u2014 ${t.detail}`:"";return e?`\u2692 ${e}${a}${n}`:`\u2692 working\u2026${a}${n}`}function l(t){return d(t).replace(/^\S+ /,"")}function h(t){let e=Math.floor(t/60);return e>0?`${e}m ${String(t%60).padStart(2,"0")}s`:`${t}s`}function k(t,e,n){let a=h(t),o=new Map;for(let i of n){let r=g[i.name]??"working\u2026";o.set(r,(o.get(r)??0)+i.n)}let s=[...o.entries()],p=s.slice(0,4).map(([i,r])=>r>1?`${i} \xD7${r}`:i),c=s.length-4,u=[...p,...c>0?[`+${c} more`]:[]].join(" \xB7 ");return`worked ${a} \u2014 ${e} tool call${e===1?"":"s"}${u?` \xB7 ${u}`:""}`}function T(){return{currentAttempt:null,liveThinking:"",thinkingLog:[],activity:[]}}var m={dedup_candidate:"checking a possible duplicate",ambiguity:"asking to resolve an ambiguity",validation_repair:"repairing a validation failure",finalize:"finalizing the proposal",terminal_call:"putting the result together",validation_failed:"fixing a validation issue",no_tool_calls:"nudging a stalled turn",evidence_readback:"reading the evidence back",evidence_search:"searching the evidence",provenance_check:"checking provenance"};function _(t){return m[t.reason_code]??t.reason_code.replace(/_/g," ")}function v(t){let e=l({name:t.name});return t.status==="started"?`\u2192 ${e}\u2026`:t.status==="error"||t.status==="aborted"?`\u2717 ${e}`:`\u2713 ${e}`}function f(t,e){return e.turn_id!==t.turn_id?e.turn_id<t.turn_id:e.attempt<t.attempt}function $(t,e){let n=t.currentAttempt;if(n===null||n.turn_id!==e.turn_id||n.attempt!==e.attempt){if(n!==null&&f(n,e))return t;t={...t,currentAttempt:{turn_id:e.turn_id,attempt:e.attempt},liveThinking:""}}switch(e.type){case"reasoning_delta":return{...t,liveThinking:t.liveThinking+e.text};case"reasoning_done":return e.present?{...t,thinkingLog:[...t.thinkingLog,{text:t.liveThinking,tookMs:e.took_ms}],liveThinking:""}:{...t,liveThinking:""};case"tool_activity":return{...t,activity:[...t.activity,{name:e.name,status:e.status,label:v(e)}]};case"decision_activity":return{...t,activity:[...t.activity,{name:e.action,status:"decision",label:_(e)}]}}}export{l as a,h as b,k as c,T as d,$ as e};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as b}from"./chunk-
|
|
2
|
+
import{a as b}from"./chunk-U5GHOGLM.js";import{n as d,y as o}from"./chunk-7F2ZV46B.js";import{a as L}from"./chunk-HCBYKLMW.js";import{a as u,b as c,i as A}from"./chunk-C44QQJR4.js";import{a as D}from"./chunk-6YGTRKDT.js";import{e as h}from"./chunk-UR6MHSHU.js";var x=h(D(),1);import{readdirSync as N,mkdirSync as B,statSync as k}from"fs";import{join as P}from"path";var r=h(L(),1);function O(n){try{return N(n).filter(l=>{try{return k(P(n,l)).isDirectory()}catch{return!1}})}catch{return[]}}function E(n,l,f,v){return{name:n,path:l,label:n,isActive:v}}function H({currentPath:n,onSelect:l,onCancel:f}){let s=O(d).map(i=>{let e=P(d,i);return E(i,e,n,e===n)}),p=!n,R=s.length+2,[a,C]=(0,x.useState)(()=>{if(p)return 0;let i=s.findIndex(e=>e.isActive);return i>=0?i+1:0}),[T,I]=(0,x.useState)(!1),[S,g]=(0,x.useState)("");return A((i,e)=>{if(T){if(e.escape){I(!1),g("");return}if(e.return){let t=S.trim();if(t){let m=P(d,t);B(m,{recursive:!0}),l(m),f()}return}if(e.backspace||e.delete){g(t=>t.slice(0,-1));return}i&&!e.ctrl&&!e.meta&&g(t=>t+i);return}if(e.escape){f();return}if(e.upArrow){C(t=>Math.max(0,t-1));return}if(e.downArrow){C(t=>Math.min(R-1,t+1));return}if(e.return){if(a===0){p||l(""),f();return}if(a===s.length+1){B(d,{recursive:!0}),I(!0),g("");return}let t=s[a-1];t&&!t.isActive&&l(t.path),f();return}}),T?(0,r.jsxs)(u,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,r.jsx)(c,{color:o.orange,bold:!0,children:"Chrome Profile \u203A New"}),(0,r.jsxs)(u,{marginTop:1,children:[(0,r.jsx)(c,{color:o.secondary,children:"Name: "}),(0,r.jsx)(c,{children:S}),(0,r.jsx)(c,{color:o.dim,children:"\u2588"})]}),(0,r.jsx)(b,{bindings:[{keys:"\u21B5",label:"create"}],escBackLabel:"back"})]}):(0,r.jsxs)(u,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,r.jsx)(c,{color:o.orange,bold:!0,children:"Chrome Profile"}),(0,r.jsxs)(u,{flexDirection:"column",marginTop:1,children:[(0,r.jsxs)(c,{color:p?o.green:a===0?o.orange:o.dim,children:[a===0?"\u276F ":" ","Use temporary (no profile)",p?" \u25CF active":""]}),s.map((i,e)=>{let m=e+1===a,w=m?"\u276F ":" ",y=i.isActive?o.green:m?o.orange:void 0;return(0,r.jsxs)(c,{color:y,children:[w,i.label,i.isActive?" \u25CF active":""]},i.name)}),(0,r.jsxs)(c,{color:a===s.length+1?o.orange:o.dim,children:[a===s.length+1?"\u276F ":" ","+ Create new"]})]}),(0,r.jsx)(b,{bindings:[{keys:"\u2191\u2193",label:"navigate"},{keys:"\u21B5",label:"select"}],escBackLabel:"back"})]})}export{O as a,E as b,H as c};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{b as u}from"./chunk-NLCCBXXV.js";import{a as n}from"./chunk-RZ4F3BHX.js";var f=class extends u{constructor(e,t,s){super(e,{username:t,accessKey:s})}async listProjects(e){let t=[],s=!1;for await(let r of this.listProjectsStream({log:e})){if(e&&!s&&r.projects.length>0){let o=r.projects[0];e("info","PROJECT_SAMPLE","Project list sample",{project_id:o.project_id,name:o.name}),s=!0}t.push(...r.projects)}return t}async*listProjectsStream(e){let t=e?.perPage??200,s=e?.maxPages??100,r=e?.signal,o=e?.log,d=e?.name?.trim(),a=0;for(let i=1;i<=s;i++){if(r?.aborted)return;let g=`${this.baseUrl}/v1/projects?page=${i}&per_page=${t}&sort=created_at`;d&&(g+=`&filter[name]=${encodeURIComponent(d)}`);let p=AbortSignal.timeout(15e3),
|
|
2
|
+
import{b as u}from"./chunk-NLCCBXXV.js";import{a as n}from"./chunk-RZ4F3BHX.js";var f=class extends u{constructor(e,t,s){super(e,{username:t,accessKey:s})}async listProjects(e){let t=[],s=!1;for await(let r of this.listProjectsStream({log:e})){if(e&&!s&&r.projects.length>0){let o=r.projects[0];e("info","PROJECT_SAMPLE","Project list sample",{project_id:o.project_id,name:o.name}),s=!0}t.push(...r.projects)}return t}async*listProjectsStream(e){let t=e?.perPage??200,s=e?.maxPages??100,r=e?.signal,o=e?.log,d=e?.name?.trim(),a=0;for(let i=1;i<=s;i++){if(r?.aborted)return;let g=`${this.baseUrl}/v1/projects?page=${i}&per_page=${t}&sort=created_at`;d&&(g+=`&filter[name]=${encodeURIComponent(d)}`);let p=AbortSignal.timeout(15e3),y=r?AbortSignal.any([r,p]):p,c;try{c=await n(g,{method:"GET",headers:this.headers(),signal:y})}catch(l){if(r?.aborted)return;if(i===1)throw l;o?.("warn","PROJECTS_STREAM_PARTIAL","stream stopped mid-page",{page:i,total_loaded:a,error:l instanceof Error?l.message:String(l)}),yield{page:i,projects:[],totalLoaded:a,done:!0};return}if(!c.ok){if(i===1)throw new Error(`listProjects ${c.status}: ${await c.text()}`);o?.("warn","PROJECTS_STREAM_PARTIAL","stream stopped on non-OK response",{page:i,status:c.status,total_loaded:a}),yield{page:i,projects:[],totalLoaded:a,done:!0};return}let m=(await c.json()).data??[];a+=m.length;let h=m.length<t;if(yield{page:i,projects:m,totalLoaded:a,done:h},h)return}o?.("warn","PROJECTS_STREAM_MAXPAGES","max pages reached",{max_pages:s,total_loaded:a}),yield{page:s,projects:[],totalLoaded:a,done:!0}}async getDefaultFolder(e){let t=await n(`${this.baseUrl}/v1/projects/${e}/folder/default`,{method:"GET",headers:this.headers()});if(!t.ok)throw new Error(`Get default folder failed: ${t.status} ${await t.text()}`);return(await t.json()).id}async listFolders(e){let t=await n(`${this.baseUrl}/v1/folder/entity/${e}`,{method:"GET",headers:this.headers()});if(!t.ok)throw new Error(`List folders failed: ${t.status} ${await t.text()}`);return(await t.json()).data??[]}async validateProjectFolder(e,t){let s;try{s=await n(`${this.baseUrl}/v1/folder/entity/${e}`,{method:"GET",headers:this.headers()})}catch{return{project:"error",folder:"error"}}if(s.status>=400&&s.status<500)return{project:"missing",folder:"missing"};if(!s.ok)return{project:"error",folder:"error"};let r;try{r=await s.json()}catch{return{project:"error",folder:"error"}}return{project:"ok",folder:(r.data??[]).some(a=>a.id===t)?"ok":"missing"}}async createProject(e,t=""){let s=await n(`${this.baseUrl}/v1/projects`,{method:"POST",headers:{...this.headers(),"Content-Type":"application/json"},body:JSON.stringify({name:e,description:t,tags:[],source:"KTM"})});if(!s.ok)throw new Error(`Create project failed: ${s.status} ${await s.text()}`);return{id:(await s.json()).id,name:e}}async createFolder(e,t,s=""){let r=await n(`${this.baseUrl}/v1/folder`,{method:"POST",headers:{...this.headers(),"Content-Type":"application/json"},body:JSON.stringify({folders:[{name:t,description:s,entity_id:e,entity_type:"project"}]})});if(!r.ok)throw new Error(`Create folder failed: ${r.status} ${await r.text()}`);return{id:(await r.json()).id,name:t}}async createAtmTest(e,t){let s=t?`Bearer ${t}`:this.authHeader,r=await n(`${this.baseUrl}/kane-cli/v1/test`,{method:"POST",headers:{Authorization:s,"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(e)});if(!r.ok)throw new Error(`Create ATM test failed: ${r.status} ${await r.text()}`);let o=await r.json();if(!o.test_id)throw new Error("Create ATM test returned no test_id");return o.test_id}async createMobileAtmTest(e,t){let s=t?`Bearer ${t}`:this.authHeader,r=await n(`${this.baseUrl}/kane-cli/v1/mobile/test`,{method:"POST",headers:{Authorization:s,"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(e)});if(!r.ok)throw new Error(`Create mobile ATM test failed: ${r.status} ${await r.text()}`);let o=await r.json();if(!o.test_id)throw new Error("Create mobile ATM test returned no test_id");return o.test_id}async endTest(e,t,s){let r=s?`Bearer ${s}`:this.authHeader,o=new URLSearchParams({commit_id:t.commit_id,time_taken:String(t.time_taken),steps_count:String(t.steps_count),commit_message:t.commit_message}),d={};t.objectives&&t.objectives.length>0&&(d.objectives=t.objectives);let a=await n(`${this.baseUrl}/kane-cli/v1/test/${e}?${o.toString()}`,{method:"DELETE",headers:{Authorization:r,"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(d)});if(!a.ok)throw new Error(`End test failed: ${a.status} ${await a.text()}`);let i=await a.json();return{testcase_id:i.data?.testcase_id??"",test_id:i.data?.test_id??e,project_id:i.data?.project_id??""}}async submitFeedback(e,t){let s=t?`Bearer ${t}`:this.authHeader,r={instruction_id:e.instruction_id,test_id:e.test_id,feedback_type:e.feedback_type,mode:e.mode??"human"};e.details&&(r.details=e.details);let o=await n(`${this.baseUrl}/atm/v1/generative-feedback`,{method:"POST",headers:{Authorization:s,"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(r)});if(!o.ok)throw new Error(`Submit feedback failed: ${o.status} ${await o.text()}`);return await o.json()}async ingestEvidence(e,t){let s=await n(`${this.baseUrl}/kane-cli/v1/evidence/ingest`,{method:"POST",headers:{Authorization:this.authHeader,"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({evidence_id:e,project_id:t})});if(!s.ok)throw new Error(`Evidence ingest failed: ${s.status} ${await s.text()}`)}};export{f as a};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as f}from"./chunk-
|
|
2
|
+
import{a as f}from"./chunk-UODLRQQ4.js";import{y as t}from"./chunk-7F2ZV46B.js";import{a as x}from"./chunk-HCBYKLMW.js";import{a,b as n}from"./chunk-C44QQJR4.js";import{a as R}from"./chunk-6YGTRKDT.js";import{e as c}from"./chunk-UR6MHSHU.js";var p=c(R(),1);var e=c(x(),1);function v(){return[{name:"convert",label:"Converting session data",status:"pending"},{name:"zip",label:"Compressing artifacts",status:"pending"},{name:"presign",label:"Requesting upload URLs",status:"pending"},{name:"upload",label:"Uploading to KaneAI",status:"pending"},{name:"atomic_replace",label:"Replacing local output",status:"pending"},{name:"commit_lock",label:"Committing to TMS",status:"pending"},{name:"finalize",label:"Finalizing test case",status:"pending"},{name:"code_export",label:"Downloading test code",status:"pending"}]}function U(s,o,d,i){return s.map(l=>l.name===o?{...l,status:d,detail:i}:l)}function D(s){let o=s/1e3;if(o<60)return`${o.toFixed(1)}s`;let d=Math.floor(o/60),i=Math.round(o%60);return`${d}m ${i}s`}function w(s){let[o,d]=(0,p.useState)(0),i=p.default.useRef(Date.now());return(0,p.useEffect)(()=>{if(!s)return;i.current=Date.now();let l=setInterval(()=>{d(Date.now()-i.current)},100);return()=>clearInterval(l)},[s]),o}function h({steps:s,status:o,testUrl:d,error:i}){let l=w(o==="uploading");return o==="uploading"?(0,e.jsxs)(a,{flexDirection:"column",paddingX:1,paddingY:1,children:[(0,e.jsxs)(a,{children:[(0,e.jsx)(n,{color:t.orange,children:"\u2601 "}),(0,e.jsx)(n,{color:t.orange,bold:!0,children:"Saving to KaneAI"}),(0,e.jsxs)(n,{color:t.dim,children:[" ",D(l)]})]}),(0,e.jsx)(a,{flexDirection:"column",marginTop:1,children:s.filter(r=>r.status!=="skipped"||r.detail).map((r,S,T)=>{let b=S===T.length-1?"\u2514\u2500":"\u251C\u2500",u=r.status==="done",m=r.status==="running",g=r.status==="failed",B=r.status==="skipped";return(0,e.jsxs)(a,{children:[(0,e.jsxs)(n,{color:t.dim,children:[" ",b," "]}),(0,e.jsx)(a,{width:3,children:m?(0,e.jsx)(f,{}):u?(0,e.jsx)(n,{color:t.green,children:"\u2713"}):g?(0,e.jsx)(n,{color:t.red,children:"\u2717"}):B?(0,e.jsx)(n,{color:t.muted,children:"\u2013"}):(0,e.jsx)(n,{color:t.muted,children:"\u25CB"})}),(0,e.jsx)(n,{color:u?t.dim:m?void 0:g?t.red:t.muted,children:r.label}),r.detail&&(0,e.jsxs)(n,{color:t.dim,children:[" ",r.detail]})]},r.name)})}),(0,e.jsx)(a,{marginTop:1,children:(0,e.jsx)(n,{color:t.muted,children:" press Ctrl+C twice to force exit"})})]}):o==="success"?(0,e.jsx)(e.Fragment,{}):(0,e.jsxs)(a,{flexDirection:"column",paddingX:1,paddingY:1,children:[(0,e.jsxs)(a,{children:[(0,e.jsx)(n,{color:t.red,children:"\u2601 "}),(0,e.jsx)(n,{color:t.red,bold:!0,children:"Save failed"})]}),i&&(0,e.jsxs)(a,{marginTop:0,children:[(0,e.jsx)(n,{color:t.dim,children:" "}),(0,e.jsx)(n,{color:t.dim,children:i})]})]})}export{v as a,U as b,h as c};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as g}from"./chunk-
|
|
2
|
+
import{a as g}from"./chunk-BPMSNGXQ.js";import{b as f,c as j}from"./chunk-VE3SUJMA.js";import{a as m}from"./chunk-LVN6VHFN.js";var _="KaneAI Generated",E="Untitled";async function p(e){let r=e.config.load(),d=new g(m(e.env).tmsBaseUrl,e.tmsCreds.username,e.tmsCreds.access_key),n=e.projectName??_,o=e.folderName??E,t=r.project_id??null,s=r.project_name??null;if(!t){let a=(await d.listProjects()).find(l=>l.name===n);if(a)t=a.project_id,s=a.name,e.log("info","ENSURE_PROJECT_FOUND","Found default project",{project_id:t,name:s});else{let l=await d.createProject(n);t=l.id,s=l.name,e.log("info","ENSURE_PROJECT_CREATED","Created default project",{project_id:t,name:s})}f(e.creds,e.config,e.profile,e.env,{projectId:t,projectName:s})}let c=r.folder_id??null,i=r.folder_name??null,u=!r.project_id;if(!c||u){let a=(await d.listFolders(t)).find(l=>l.name===o);if(a)c=a.id,i=a.name,e.log("info","ENSURE_FOLDER_FOUND","Found default folder",{folder_id:c,name:i});else{let l=await d.createFolder(t,o);c=l.id,i=l.name,e.log("info","ENSURE_FOLDER_CREATED","Created default folder",{folder_id:c,name:i})}f(e.creds,e.config,e.profile,e.env,{folderId:c,folderName:i})}return{projectId:t,projectName:s??n,folderId:c,folderName:i??o}}function A(e,r,d){let n=e.loadProfileConfig(r,d)??{};return{projectId:n.project_id??null,folderId:n.folder_id??null}}function N(e,r){return e.projectId===null||e.folderId===null||r===null?"needs-picker":r.project==="ok"&&r.folder==="ok"?"ok":r.project==="error"&&r.folder==="error"?"ok-tms-degraded":"needs-picker"}var k=(e,r)=>`error: profile "${e}" (${r}) has no project/folder configured AND no TMS credentials were available to auto-configure one.
|
|
3
3
|
|
|
4
4
|
discover IDs:
|
|
5
5
|
kane-cli projects list --search "<keyword>" --limit 10
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{a as G}from"./chunk-MMBBQ4OZ.js";import{j as N}from"./chunk-IUEEFGEW.js";import{d as I,e as z}from"./chunk-4JOD47QI.js";import{a as X}from"./chunk-RZ4F3BHX.js";import{spawn as Pe}from"child_process";import{existsSync as Me}from"fs";import{homedir as _e}from"os";import{dirname as Q,join as P}from"path";import{access as ge,mkdir as W,readFile as he}from"fs/promises";import{homedir as ve}from"os";import{arch as be,platform as we}from"process";import{join as D}from"path";var ye=35,Ae="google_apis",xe="KaneCLI_Pixel_API35",Se="KaneAI_Pixel_API35";function ht(t){return t===Se?xe:t}var ke=1;function Te(t,e){return t==="darwin"&&e==="arm64"?"arm64-v8a":"x86_64"}function De(){return{home:ve(),os:we,arch:be}}async function Y(t){try{return await ge(t),!0}catch{return!1}}var j=class{deps;constructor(e={}){this.deps={...De(),...e}}paths(){let e=D(this.deps.home,".testmuai","kaneai","mobile"),n=D(e,"android-sdk");return{root:n,emulatorDir:D(n,"emulator"),systemImageDir:D(n,"system-images",`android-${ye}`,Ae,Te(this.deps.os,this.deps.arch)),avdHome:D(e,"avd"),manifest:D(n,"sdk-manifest.json")}}environment(){let e=this.paths();return{ANDROID_HOME:e.root,ANDROID_SDK_ROOT:e.root,ANDROID_AVD_HOME:e.avdHome}}async ensureSdkRootMarkers(){let e=this.paths().root;await W(D(e,"platforms"),{recursive:!0}),await W(D(e,"platform-tools"),{recursive:!0})}async status(){let e=this.paths(),n=null;try{n=JSON.parse(await he(e.manifest,"utf8"))}catch{}if(!n||n.schemaVersion!==ke)return{emulator:!1,systemImage:!1};let o=this.deps.os==="win32"?"emulator.exe":"emulator";return{emulator:!!n.components.emulator&&await Y(D(e.emulatorDir,o)),systemImage:!!n.components.systemImage&&await Y(D(e.systemImageDir,"system.img"))}}},Z;function L(){return Z??=new j,Z}var H="android",$e="http://127.0.0.1:4723/status",Ie=2e3,ee=12e4,Ne=1e3,Ee=3e5;var Oe=5,te="Run `kane-cli doctor --target emulator --install` to install the managed Appium tree.",Re={device:"ready",unauthorized:"unauthorized",offline:"offline"};function Ce(t){let e={};for(let n of t){let o=n.indexOf(":");o<=0||(e[n.slice(0,o)]=n.slice(o+1))}return e}function Le(t){let e=[];for(let n of t.split(`
|
|
3
|
+
`)){let o=n.trim();if(!o||o.startsWith("*"))continue;let u=o.toLowerCase();if(u.startsWith("list of devices")||u.startsWith("adb server"))continue;let f=o.split(/\s+/),p=f[0],b=f[1];if(!p||!b||!p.startsWith("emulator-"))continue;let h=Ce(f.slice(2)),v=h.model?h.model.replace(/_/g," "):void 0;e.push({platform:H,kind:"emulator",id:p,displayName:v??p,state:Re[b]??"offline"})}return e}function ie(t){let e=[];for(let n of t.split(`
|
|
4
|
+
`)){let o=n.trim();o&&/^[A-Za-z0-9._-]+$/.test(o)&&(e.includes(o)||e.push(o))}return e}function Fe(t){for(let e of t.split(`
|
|
5
|
+
`)){let n=e.trim();if(!(!n||n==="OK"))return n}}function Be(t){let e=/^Version\s+(\S+)/m.exec(t);return e?.[1]?e[1].split("-")[0]:/Android Debug Bridge version\s+(\S+)/.exec(t)?.[1]}function Ue(t){let e=[];for(let n of t.split(`
|
|
6
|
+
`)){let o=n.trim();if(!o.startsWith("package:"))continue;let u=o.slice(8).trim();u&&!e.includes(u)&&e.push(u)}return e.sort()}function qe(t){let e=Number(t.trim());return Number.isInteger(e)&&e>0?e:void 0}function je(t){return[...new Set(t.split(",").map(e=>e.trim()).filter(Boolean))]}var He=[{match:/INSTALL_FAILED_VERIFICATION|verif(?:ier|ication)/i,hint:`Package verification blocked the install. Disable it for adb installs:
|
|
7
|
+
adb -s <device> shell settings put global verifier_verify_adb_installs 0`},{match:/INSTALL_FAILED_UPDATE_INCOMPATIBLE|INSTALL_FAILED_VERSION_DOWNGRADE|signatures do not match/i,hint:`A different build of this package is already installed. Uninstall it first:
|
|
8
|
+
adb -s <device> uninstall <package>`},{match:/INSUFFICIENT_STORAGE/i,hint:"The device is out of storage. Free space on the device and retry."}];function Ve(t){for(let{match:e,hint:n}of He)if(e.test(t))return n}function V(t,e,n=Oe){let o=t.toLowerCase(),u=e.filter(b=>b.toLowerCase().includes(o)),f=Math.max(6,Math.floor(o.length/2)),p=e.filter(b=>!u.includes(b)&&Je(b.toLowerCase(),o)>=f);return[...u,...p].slice(0,n)}function Je(t,e){let n=Math.min(t.length,e.length),o=0;for(;o<n&&t[o]===e[o];)o++;return o}function Ke(){return X($e,{signal:AbortSignal.timeout(Ie)}).then(t=>t.ok,()=>!1)}function Xe(t,e,n){Pe(t,e,{stdio:"ignore",detached:!0,...n?{env:{...process.env,...n}}:{}}).unref()}function ze(){return{exec:I,spawnDetached:Xe,fileExists:Me,env:process.env,home:_e(),os:process.platform,probeAppiumServer:Ke,now:()=>Date.now(),sleep:z,mobileDeps:{status:t=>N().status(t),environment:t=>N().environment(t)},sdkSuite:{status:()=>L().status(),environment:()=>L().environment(),emulatorPath:()=>{let t=L().paths().emulatorDir;return P(t,process.platform==="win32"?"emulator.exe":"emulator")},ensureSdkRootMarkers:()=>L().ensureSdkRootMarkers()}}}function re(t={}){let e={...ze(),...t},n={},o=new Set;function u(i){return e.os==="win32"?`${i}.exe`:i}function f(){return e.os==="win32"?"appium.cmd":"appium"}function p(){let i=[];for(let r of["ANDROID_HOME","ANDROID_SDK_ROOT"]){let s=e.env[r];s&&s.trim()!==""&&i.push(s.trim())}return e.os==="darwin"?i.push(P(e.home,"Library","Android","sdk")):e.os==="win32"?i.push(P(e.home,"AppData","Local","Android","Sdk")):i.push(P(e.home,"Android","Sdk")),i}function b(i){let r=i==="adb"?"platform-tools":"emulator";return p().map(s=>P(s,r,u(i)))}async function h(i){let r=e.os==="win32"?"where":"which",s=await e.exec(r,[u(i)],{timeoutMs:5e3});if(s.code!==0)return null;let a=s.stdout.split(`
|
|
9
|
+
`)[0]?.trim();return a&&a!==""?a:null}async function v(i){if(i==="adb"){let s=G(e.env);if(s){let c=P(s.platformToolsDir,u("adb"));if(e.fileExists(c)){let m={path:c,source:"sdk"};return n[i]=m,m}return delete n[i],null}if((await e.mobileDeps.status("emulator")).installed){let c=await e.mobileDeps.environment("emulator");if(c.platformToolsDir){let m={path:P(c.platformToolsDir,u("adb")),source:"local"};return n[i]=m,m}}return delete n[i],null}if(i==="emulator"&&(await e.sdkSuite.status()).emulator){let a={path:e.sdkSuite.emulatorPath(),source:"local"};return n[i]=a,a}let r=await h(i);if(r){let s={path:r,source:"sdk"};return n[i]=s,s}for(let s of b(i))if(e.fileExists(s)){let a={path:s,source:"sdk"};return n[i]=a,a}return delete n[i],null}async function $(){let i=await v("adb");if(!i)throw new Error("Managed adb is not installed.\nRun `kane-cli doctor --target emulator --install` to install the pinned Android platform-tools.");return i.path}async function O(i){let r=await e.exec(i,["devices","-l"],{timeoutMs:2e4});return Le(r.stdout)}async function d(i,r){let s=await e.exec(i,["-s",r,"shell","getprop","ro.boot.qemu.avd_name"],{timeoutMs:1e4});if(s.code===0){let c=s.stdout.split(`
|
|
10
|
+
`)[0]?.trim();if(c)return c}let a=await e.exec(i,["-s",r,"emu","avd","name"],{timeoutMs:1e4});if(a.code===0)return Fe(a.stdout)}async function l(i){let r=await v("emulator");if(!r)return[];let s=await e.exec(r.path,["-list-avds"],{timeoutMs:2e4}),a=s.code===0?ie(s.stdout):[];if(o.clear(),(await e.sdkSuite.status()).emulator){let m=await e.exec(r.path,["-list-avds"],{timeoutMs:2e4,env:{...e.env,...e.sdkSuite.environment()}});if(m.code===0)for(let A of ie(m.stdout))o.add(A),a.includes(A)||a.push(A)}return a.filter(m=>!i.has(m)).map(m=>({platform:H,kind:"emulator",id:m,displayName:m,state:"stopped",virtualName:m}))}async function g(){let i=await v("adb");if(!i)return[];let r=await O(i.path),s=new Set;for(let c of r){if(c.kind!=="emulator"||c.state!=="ready")continue;let m=await d(i.path,c.id);m&&(c.virtualName=m,c.displayName=m,s.add(m))}let a=await l(s);return[...r,...a]}function w(i,r){return[`${i} did not finish booting within ${ee/1e3}s.`,r?`It attached as ${r} but never reported sys.boot_completed=1.`:"It never attached to adb.","The emulator process is still running \u2014 check its window for errors.","Common causes: no hardware acceleration (install the Android Emulator","hypervisor driver / enable KVM), or a corrupt AVD (recreate it in","Android Studio's Device Manager)."].join(`
|
|
11
|
+
`)}async function S(i,r,s){let a=await v("emulator");if(!a)throw new Error("The Android `emulator` binary was not found, so AVDs cannot be booted.\nInstall it via Android Studio's SDK Manager (Android Emulator) and set ANDROID_HOME.");let c=new Set((await O(i)).map(F=>F.id)),m=o.has(r);m&&await e.sdkSuite.ensureSdkRootMarkers();let A=m?{...e.env,...e.sdkSuite.environment()}:void 0;e.spawnDetached(a.path,["-avd",r],A),s?.(`booting ${r}\u2026`);let T=e.now()+ee,x;for(;e.now()<T;){if(await e.sleep(Ne),!x){let _=(await O(i)).find(C=>C.kind==="emulator"&&!c.has(C.id));_&&(x=_.id,s?.(`${r} attached as ${x}, waiting for boot\u2026`));continue}if((await e.exec(i,["-s",x,"shell","getprop","sys.boot_completed"],{timeoutMs:1e4})).stdout.trim()==="1")return x}throw new Error(w(r,x))}async function y(i,r){let s=await $();if(i.state==="ready")return M(i,s);if(i.state==="unauthorized")throw new Error(`${i.displayName} (${i.id}) is UNAUTHORIZED. Accept the USB-debugging prompt on the device, then retry.`);if(i.state==="offline")throw new Error(`${i.displayName} (${i.id}) is offline. Reconnect it (USB) or re-run \`adb connect ${i.id}\` (wireless), then retry.`);let a=i.virtualName??i.id,c=await S(s,a,r);return M({...i,kind:"emulator",id:c,displayName:a,state:"ready",virtualName:a},s)}async function M(i,r){let[s,a,c,m]=await Promise.all([e.exec(r,["-s",i.id,"shell","getprop","ro.build.version.sdk"],{timeoutMs:1e4}),e.exec(r,["-s",i.id,"shell","getprop","ro.build.version.release"],{timeoutMs:1e4}),e.exec(r,["-s",i.id,"shell","getprop","ro.product.cpu.abilist"],{timeoutMs:1e4}),e.exec(r,["-s",i.id,"shell","getprop","ro.product.cpu.abi"],{timeoutMs:1e4})]),A=s.code===0?qe(s.stdout):void 0,T=a.code===0?a.stdout.trim():"",x=je(c.code===0&&c.stdout.trim()!==""?c.stdout:m.stdout);return{...i,...A!==void 0?{androidApiLevel:A}:{},...T!==""?{osVersion:T}:{},...x.length>0?{androidAbis:x}:{}}}async function k(i){let r=await $(),s=await e.exec(r,["-s",i.id,"shell","pm","list","packages","-3"],{timeoutMs:3e4});if(s.code!==0)throw new Error(`Could not list installed packages on ${i.id}: ${s.stderr.trim()||`adb exited ${s.code}`}`);return Ue(s.stdout)}async function R(i){let r;try{let{default:s}=await import("./adbkit-apkreader-ORZBGCJQ.js");r=(await(await s.open(i)).readManifest())?.package}catch(s){let a=s instanceof Error?s.message:String(s);throw new Error(`Could not read the package name from ${i} (${a}).
|
|
12
|
+
Pass the package name explicitly with --app <package>.`)}if(typeof r!="string"||r.trim()==="")throw new Error(`${i} has no package name in its manifest.
|
|
13
|
+
Pass the package name explicitly with --app <package>.`);return r.trim()}async function U(i,r,s){let a=await $();s?.(`installing ${r} on ${i.id}\u2026`);let c=await e.exec(a,["-s",i.id,"install","-r",r],{timeoutMs:Ee}),m=`${c.stdout}
|
|
14
|
+
${c.stderr}`;if(c.code===0&&!/\bFailure\b/i.test(m))return;let A=Ve(m),T=[`Installing ${r} on ${i.id} failed (adb exited ${c.code}).`,m.trim()];throw A&&T.push("",A),new Error(T.filter(x=>x!=="").join(`
|
|
15
|
+
`))}async function ue(i,r,s){if(r.kind==="package"){let a=await k(i);if(a.includes(r.value))return r.value;let c=V(r.value,a),m=[`${r.value} is not installed on ${i.displayName} (${i.id}).`];throw c.length>0?m.push("Close matches:",...c.map(A=>` ${A}`)):m.push("Pass a local .apk path to --app to install it instead."),new Error(m.join(`
|
|
16
|
+
`))}if(r.kind!=="apk"){let a=r.kind==="aab"?"Android app bundles are not directly installable; build an APK first.":r.kind==="apks"?"Split bundles are not supported yet.":`${r.kind} artifacts are not installable on Android.`;throw new Error(a)}return await U(i,r.value,s),R(r.value)}async function ce(){let i=await e.mobileDeps.status("emulator");return i.installed?{status:i,env:await e.mobileDeps.environment("emulator")}:null}async function me(i={}){let r=[],s=await ce(),a=await e.mobileDeps.status("emulator"),c=await v("adb");if(c){let _=await e.exec(c.path,["version"],{timeoutMs:1e4}),C=Be(_.stdout);r.push({id:"android.adb",fixedByBundle:!0,label:"adb",required:!0,status:"pass",detail:C?`platform-tools ${C} \xB7 ${c.path}`:c.path})}else r.push({id:"android.adb",fixedByBundle:!0,label:"adb",required:!0,status:"fail",detail:a.corrupt??"managed mobile dependencies are not installed",fixText:"Run `kane-cli doctor --target emulator --install` to download the managed mobile deps bundle under ~/.testmuai/kaneai/mobile."});let m=!i.appiumUrl;s?.env.appiumHome?r.push({id:"android.appium",fixedByBundle:!0,label:"Appium",required:m,status:"pass",detail:P(Q(s.env.appiumHome),"appium","node_modules",".bin",f())}):r.push({id:"android.appium",fixedByBundle:!0,label:"Appium",required:m,status:m?"fail":"info",detail:i.appiumUrl?`managed Appium not required because --appium-url is set (${i.appiumUrl})`:a.corrupt??"managed Appium is not installed",...m?{fixText:te}:{}}),r.push({id:"android.uiautomator2",fixedByBundle:!0,label:"uiautomator2 driver",required:m,status:s?"pass":m?"fail":"info",detail:s?"bundled in the managed mobile deps":i.appiumUrl?"managed driver not required because --appium-url is set":"not installed in the managed deps tree",...s||!m?{}:{fixText:te}});let A=P(e.home,".testmuai","kaneai","mobile","trees");e.fileExists(A)&&r.push({id:"android.legacy-trees",label:"legacy toolchain trees",required:!1,status:"info",detail:`${A} predates the deps bundle \u2014 removed automatically by the next bundle install`});let T=await h("adb");T&&r.push({id:"android.system-adb",label:"system adb",required:!1,status:"info",detail:`${T} (ignored; managed adb always wins and may restart its server)`});let x=await h("appium");x&&r.push({id:"android.system-appium",label:"system Appium",required:!1,status:"info",detail:`${x} (ignored; managed Appium always wins)`});let F=await e.sdkSuite.status(),q=await v("emulator");if(F.emulator?r.push({id:"android.emulator",label:"emulator",required:!1,status:"pass",detail:`managed emulator \xB7 ${e.sdkSuite.emulatorPath()}`}):q?r.push({id:"android.emulator",label:"emulator",required:!1,status:"info",detail:`${q.path} (system install)`}):r.push({id:"android.emulator",label:"emulator",required:!1,status:"info",detail:"not installed, so stopped AVDs are not listed. Install it with the Android SDK (Android Studio \u2192 SDK Manager \u2192 Android Emulator)."}),e.os==="darwin"){let _=await e.exec("sysctl",["-n","kern.hv_support"],{timeoutMs:5e3});r.push({id:"android.virtualization",label:"virtualization",required:!1,status:"info",detail:_.code===0&&_.stdout.trim()==="1"?"Hypervisor.framework available":"Hypervisor.framework not reported \u2014 emulator boots may hang"})}else e.os==="linux"?r.push({id:"android.virtualization",label:"virtualization",required:!1,status:"info",detail:e.fileExists("/dev/kvm")?"/dev/kvm present":"/dev/kvm missing \u2014 enable KVM or emulator boots will hang"}):r.push({id:"android.virtualization",label:"virtualization",required:!1,status:"info",detail:"not checked on this host"});return r}async function pe(i){let r=await e.mobileDeps.environment("emulator"),s=[...r.dirs],a=n.emulator,c=a?.source==="sdk"?Q(a.path):void 0;return c&&!s.includes(c)&&s.push(c),{...r,dirs:s}}async function fe(i,r){let s=await $(),a=[];return r.appPackage&&a.push({label:`closing ${r.appPackage}`,file:s,args:["-s",i.id,"shell","am","force-stop",r.appPackage]}),r.shutdown&&a.push({label:`shutting down ${i.displayName}`,file:s,args:["-s",i.id,"emu","kill"]}),a}return{platform:H,available:()=>!0,checks:me,discover:g,prepare:y,listApps:k,ensureApp:ue,teardownPlan:fe,toolEnv:pe}}import{mkdtemp as ne,readdir as Ge,rm as se,writeFile as We}from"fs/promises";import{tmpdir as oe}from"os";import{join as E}from"path";var ae="ios",Ye=12e4,Ze=3e5,Qe="an .ipa cannot be installed on a simulator \u2014 use a .zip of the .app build";function et(t){let e=/\.iOS-(\d+)-(\d+)$/.exec(t);return e?`${e[1]}.${e[2]}`:void 0}function tt(t){let e;try{e=JSON.parse(t)}catch{return[]}let n=[];for(let[o,u]of Object.entries(e.devices??{})){let f=et(o);for(let p of u??[]){let b=typeof p.udid=="string"?p.udid:void 0,h=typeof p.name=="string"?p.name:void 0;if(!b||!h)continue;let v=p.state==="Booted"?"ready":p.state==="Shutdown"?"stopped":"offline";n.push({platform:ae,kind:"simulator",id:b,displayName:f?`${h} (iOS ${f})`:h,state:v,virtualName:h,...f?{osVersion:f}:{}})}}return n}function it(t){let e;try{e=JSON.parse(t)}catch{return[]}let n=[];for(let[o,u]of Object.entries(e)){if(u?.ApplicationType!=="User")continue;let f=u.CFBundleIdentifier??o;n.includes(f)||n.push(f)}return n.sort()}function rt(t){let e;try{e=JSON.parse(t)}catch{return[]}let n=[];for(let[o,u]of Object.entries(e)){let f=u?.CFBundleIdentifier??o;f&&!n.includes(f)&&n.push(f)}return n.sort()}var J=16;function nt(t){return/^Xcode (\d+(?:\.\d+)*)/m.exec(t)?.[1]}async function st(t){let e=await ne(E(oe(),"kane-app-unzip-")),n=()=>se(e,{recursive:!0,force:!0}),o=await I("unzip",["-q",t,"-d",e],{timeoutMs:10*6e4});if(o.code!==0)throw await n(),new Error(`Could not unpack ${t}: ${o.stderr.trim()||`unzip exited ${o.code}`}`);for(let u of[e,E(e,"Payload")]){let f;try{f=await Ge(u)}catch{continue}let p=f.find(b=>b.toLowerCase().endsWith(".app"));if(p)return{appPath:E(u,p),cleanup:n}}throw await n(),new Error(`${t} does not contain a .app bundle.`)}async function ot(t){let e=await ne(E(oe(),"kane-plist-"));try{let n=E(e,"input.plist");await We(n,t);let o=await I("plutil",["-convert","json","-o","-",n],{timeoutMs:15e3});if(o.code!==0)throw new Error(`plutil could not convert simctl output: ${o.stderr.trim()}`);return o.stdout}finally{await se(e,{recursive:!0,force:!0})}}function at(){return{exec:I,os:process.platform,convertPlistToJson:ot,mobileDeps:{status:()=>N().status("simulator"),environment:()=>N().environment("simulator")}}}function de(t={}){let e={...at(),...t};async function n(d,l=3e4){return e.exec("xcrun",["simctl",...d],{timeoutMs:l})}async function o(){let d=await n(["list","devices","available","--json"]);return d.code!==0?[]:tt(d.stdout)}async function u(){return o()}async function f(d,l){let g=await e.exec("open",["-a","Simulator","--args","-CurrentDeviceUDID",d],{timeoutMs:15e3});g.code!==0&&l?.(`could not open Simulator.app (${g.stderr.trim()||`exit ${g.code}`}); the device is booted and the run continues headless`)}async function p(d,l){if(d.state!=="ready"&&d.state!=="stopped")throw new Error(`${d.displayName} (${d.id}) is ${d.state}; open Simulator.app to inspect it, then retry.`);d.kind==="simulator"&&await f(d.id,l),d.state==="stopped"&&l?.(`booting ${d.displayName}\u2026`);let g=await n(["bootstatus",d.id,"-b"],Ye);if(g.code!==0)throw new Error(`Could not boot ${d.displayName}: ${g.stderr.trim()||g.stdout.trim()||`simctl bootstatus exited ${g.code}`}`);let w=(await o()).find(S=>S.id===d.id);if(w?.state==="ready")return w;throw new Error(`${d.displayName} finished booting but simctl still reports it as ${w?.state??"missing"}.`)}async function b(d){let l=await n(["listapps",d.id]);if(l.code!==0)throw new Error(`Could not list apps on ${d.displayName}: ${l.stderr.trim()||`simctl exited ${l.code}`}`);return it(await e.convertPlistToJson(l.stdout))}async function h(d){let l=E(d,"Info.plist"),g=await e.exec("plutil",["-convert","json","-o","-",l],{timeoutMs:15e3});if(g.code!==0)throw new Error(`${d} Info.plist could not be read: ${g.stderr.trim()||`plutil exited ${g.code}`}`);let w;try{w=JSON.parse(g.stdout)}catch{throw new Error(`${d} Info.plist did not contain valid JSON from plutil.`)}if(!w.CFBundleIdentifier)throw new Error(`${d} has no CFBundleIdentifier in its Info.plist.`);return w.CFBundleIdentifier}async function v(d,l,g){if(l.kind==="package"){let y=await n(["listapps",d.id]);if(y.code!==0)throw new Error(`Could not list apps on ${d.displayName}: ${y.stderr.trim()||`simctl exited ${y.code}`}`);let M=rt(await e.convertPlistToJson(y.stdout));if(M.includes(l.value))return l.value;let k=V(l.value,M),R=[`${l.value} is not installed on ${d.displayName} (${d.id}).`];throw k.length>0?R.push("Close matches:",...k.map(U=>` ${U}`)):R.push("Pass a .zip of the .app bundle to install it instead."),new Error(R.join(`
|
|
17
|
+
`))}if(l.kind==="ipa")throw new Error(`${Qe}.`);if(l.kind!=="app"&&l.kind!=="zip")throw new Error(`${l.kind} artifacts are Android-only and not installable on iOS.`);let w=l.value,S;if(l.kind==="zip"){g?.(`unpacking ${l.value}\u2026`);let y=await st(l.value);w=y.appPath,S=y.cleanup}g?.(`installing ${w} on ${d.displayName}\u2026`);try{let y=await n(["install",d.id,w],Ze);if(y.code!==0)throw new Error(`Installing ${l.value} on ${d.displayName} failed: ${y.stderr.trim()||y.stdout.trim()}`);return await h(w)}finally{await S?.()}}async function $(d={}){let l=[],g=await e.exec("xcode-select",["-p"],{timeoutMs:1e4});if(g.code===0&&g.stdout.trim()!==""){let M=await e.exec("xcodebuild",["-version"],{timeoutMs:3e4}),k=M.code===0?nt(M.stdout):void 0;k?Number(k.split(".")[0])<J?l.push({id:"ios.xcode",label:"Xcode",required:!0,status:"fail",detail:`Xcode ${k} is older than the required Xcode ${J}`,fixText:`Update Xcode to ${J} or newer from the App Store.`}):l.push({id:"ios.xcode",label:"Xcode",required:!0,status:"pass",detail:`Xcode ${k} \xB7 ${g.stdout.trim()}`}):l.push({id:"ios.xcode",label:"Xcode",required:!0,status:"fail",detail:`${g.stdout.trim()} has no usable xcodebuild (Command Line Tools only?)`,fixText:"Install full Xcode from the App Store, then run `sudo xcode-select -s /Applications/Xcode.app/Contents/Developer`."})}else l.push({id:"ios.xcode",label:"Xcode",required:!0,status:"fail",detail:"xcode-select reports no developer directory",fixText:"Install Xcode from the App Store, then run `xcode-select --install`."});let w=await e.exec("xcrun",["simctl","help"],{timeoutMs:15e3});l.push(w.code===0?{id:"ios.xcrun",label:"xcrun",required:!0,status:"pass",detail:"simctl reachable"}:{id:"ios.xcrun",label:"xcrun",required:!0,status:"fail",detail:`xcrun cannot run simctl: ${w.stderr.trim()||w.stdout.trim()||`exit ${w.code}`}`,fixText:"Run `xcode-select --install`, then confirm with `xcrun simctl list devices`. If Xcode is installed, `sudo xcode-select -s /Applications/Xcode.app/Contents/Developer` repoints it."});let S=!d.appiumUrl,y=await e.mobileDeps.status();return l.push({id:"ios.xcuitest",fixedByBundle:!0,label:"xcuitest driver",required:S,status:y.installed?"pass":S?"fail":"info",detail:y.installed?"bundled in the managed mobile deps (with prebuilt WDA)":d.appiumUrl?"managed driver not required because --appium-url is set":y.corrupt??"the simulator deps bundle is not installed",...y.installed||!S?{}:{fixText:"Run `kane-cli doctor --target simulator --install` to download the simulator deps bundle."}}),l}async function O(d,l){let g=[];return l.appPackage&&g.push({label:`closing ${l.appPackage}`,file:"xcrun",args:["simctl","terminate",d.id,l.appPackage]}),l.shutdown&&g.push({label:`shutting down ${d.displayName}`,file:"xcrun",args:["simctl","shutdown",d.id]}),g}return{platform:ae,available:()=>e.os==="darwin",checks:$,discover:u,prepare:p,listApps:b,ensureApp:v,teardownPlan:O,toolEnv:()=>e.mobileDeps.environment()}}var le=[re(),de()];function B(){return le.filter(t=>t.available())}function Ft(){return B().map(t=>t.platform)}function Bt(){return le.map(t=>t.platform)}function dt(t){let e=t.toLowerCase();return B().find(n=>n.platform.toLowerCase()===e)}async function lt(t){let e=t?B().filter(o=>o.platform.toLowerCase()===t.toLowerCase()):B(),n=[];for(let o of e)try{n.push(...await o.discover())}catch{}return n}function ut(t,e){let n=e.toLowerCase();return t.id.toLowerCase()===n||t.virtualName?.toLowerCase()===n}function ct(t){let e=t.virtualName&&t.virtualName!==t.id?`${t.displayName} (${t.virtualName})`:t.displayName;return`${t.id} \u2014 ${e} [${t.platform} \xB7 ${t.kind} \xB7 ${t.state}]`}function K(t){return t.length===0?"":`
|
|
18
|
+
${t.map(e=>` ${ct(e)}`).join(`
|
|
19
|
+
`)}`}async function Ut(t,e={}){let n=e.discover??lt,o=e.providerFor??dt,u=await n(t.platform),f=h=>{let v=o(h.platform);return v?{ok:!0,target:h,provider:v}:{ok:!1,reason:"not-found",candidates:u,message:`No provider is registered for platform '${h.platform}'.`}};if(t.device){let h=u.filter(v=>ut(v,t.device));return h.length===0?{ok:!1,reason:"not-found",candidates:u,message:`No target matches --device '${t.device}'.`+(u.length>0?` Available:${K(u)}`:" No targets were found \u2014 run `kane-cli doctor --target <emulator|simulator>`.")}:f(h.find(v=>v.state==="ready")??h[0])}let p=t.defaultTarget;if(p&&(!t.platform||t.platform.toLowerCase()===p.platform.toLowerCase())){let h=u.find(v=>v.platform===p.platform&&v.kind===p.kind&&(v.id===p.id||v.virtualName===p.id));return h?f(h):{ok:!1,reason:t.interactive?"needs-picker":"not-found",candidates:u,message:`The saved default target '${p.id}' (${p.platform} \xB7 ${p.kind}) is not connected. `+(t.interactive?"Pick a target to bind this run.":"Pass --device <id> explicitly \u2014 kane-cli never binds a different device on its own.")+(u.length>0?` Available:${K(u)}`:"")}}if(u.length===0)return{ok:!1,reason:"none-found",candidates:[],message:"No emulator or simulator found. Start an Android emulator or boot an iOS simulator, then run `kane-cli devices list --target <emulator|simulator>`."};let b=u.filter(h=>h.state==="ready");return b.length===1?f(b[0]):t.interactive?{ok:!1,reason:"needs-picker",candidates:u,message:b.length===0?"No target is ready \u2014 pick one to prepare it.":"More than one target is ready \u2014 pick one."}:{ok:!1,reason:"ambiguous",candidates:u,message:(b.length===0?"No target is ready.":`${b.length} targets are ready.`)+` Pass --device <id>:${K(u)}`}}export{ht as a,Ft as b,Bt as c,dt as d,lt as e,Ut as f};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as C,b as k,c as R,d as D}from"./chunk-
|
|
2
|
+
import{a as C,b as k,c as R,d as D}from"./chunk-GNIFMQNK.js";import{g as T,h as $,i as b}from"./chunk-W4B5LOEX.js";import{g as E}from"./chunk-R7QAS6LZ.js";import{i as S}from"./chunk-KRKGZ2ZW.js";import{c as y}from"./chunk-5DT7PIGB.js";import{a as O}from"./chunk-CH273NAE.js";import{A as _}from"./chunk-TH47OOBV.js";import{existsSync as H}from"fs";import{basename as q}from"path";import{appendFileSync as L,mkdirSync as U}from"fs";import{homedir as F}from"os";import{dirname as G,join as j}from"path";function P(c,s){let n=/^(DOCX_[A-Z_]+):/.exec(s)?.[1];if(n)try{let u=process.env.KANE_CONTEXT_REFUSAL_LOG??j(F(),".testmuai","kaneai","context-refusals.log");U(G(u),{recursive:!0}),L(u,`${new Date().toISOString()} ${n} ${c}
|
|
3
3
|
`)}catch{}}async function w(c,s,n,u=process.cwd(),p){let l=O(u),g=[];if(s.as!==void 0&&c.length>1)return(n.err??n.out)(`error: --as names ONE source identity \u2014 pass a single file (got ${c.length})`,"AS_SINGLE_SOURCE"),{code:2,results:g};for(let o of c){if(R(o)){let a=D(o);if(a===null)return(n.err??n.out)(`error: ${o}: unsupported remote URL \u2014 supported: ${k.map(d=>d.hint).join("; ")}`,"UNSUPPORTED_URL"),{code:1,results:g};let r=await a.ingest(o,s.as,n,l,p);if(r.code!==0)return{code:r.code,results:g};r.result&&g.push({status:r.result.status==="versioned"?"versioned":r.result.status==="unchanged"?"unchanged":"created",source_id:r.result.source_id,source_cid:r.result.source_cid});continue}let f=s.as,v;if(f===void 0&&H(l)){let a=T(o),r=$(a);if(r){let d=_(l);d.heads.get(r)!=null&&d.heads.get(a)==null&&(v=r,n.isTTY&&await n.confirm(`${a} looks like a new version of existing source '${r}' \u2014 ingest as '${r}' (replaces the current version; items built on it go stale)?`)&&(f=r))}}let e;try{e=await b({contextDir:l,filePath:o,asId:f,confirmSameSource:n.isTTY?a=>n.confirm(`identical bytes already ingested as ${a} \u2014 treat as the same source?`):void 0,converters:{pdf:E,docx:S}})}catch(a){let r=a instanceof Error?a.message:String(a);return P(o,r),(n.err??n.out)(`error: ${o}: ${r}`,"INGEST_FAILED"),{code:1,results:g}}n.out(C(n.isTTY,e,q(o)));for(let a of e.warnings??[])n.out(`warning: ${a}`);if(e.composite&&(e.composite.delivered>0||e.composite.omitted>0)){let a=e.composite.pages!==void 0?` ${e.composite.pages} pages,`:"";n.out(`${e.source_id}: ${e.composite.kind},${a} ${e.composite.delivered} images delivered (${e.composite.omitted} omitted)`)}let m;if(!n.isTTY&&e.status==="created"){let a=_(l);for(let[r,d]of a.heads.entries())if(!(r===e.source_id||d==null)&&a.getNode(d)?.content.blob===e.blob){m=r,n.out(`hint: identical bytes already ingested as ${r} \u2014 merged later via review`);break}}g.push({status:e.status,source_id:e.source_id,source_cid:e.cid,...e.warnings?.length?{warnings:e.warnings}:{},...e.composite?{media:{kind:e.composite.kind,...e.composite.pages!==void 0?{pages:e.composite.pages}:{},delivered:e.composite.delivered,omitted:e.composite.omitted}}:{},...m?{duplicate_of:m}:{},...v&&f===void 0?{lineage_candidate:v}:{}})}return{code:0,results:g}}async function se(c,s,n,u=process.cwd(),p){return(await w(c,s,n,u,p)).code}async function ie(c,s){if(s.mode!=null&&!["interactive","agent","ci","override"].includes(s.mode)){let{makeHeadlessIO:t,agentRefusal:i}=await import("./headless-io-66RG5NN5.js");return i(t("ndjson","extract"),`ingest: --mode must be interactive | agent | ci | override, got '${s.mode}'`,"MODE_USAGE")}let n=y();if(s.mode==="interactive"&&!n)return process.stderr.write(`ingest: --mode interactive needs a TTY on stdin and stdout (use --mode agent|ci|override headless)
|
|
4
4
|
`),2;let u=s.mode??(n?"interactive":void 0),p=u==="interactive"||u==="agent"||u==="override";if(!p&&(s.plan||s.force||s.trust!==void 0))return process.stderr.write(`ingest: --plan/--force/--trust steer the extraction \u2014 not available when only landing (use --mode agent to extract headless)
|
|
5
5
|
`),2;let{createInterface:l}=await import("readline/promises"),g=u==="agent",o=g?(await import("./headless-io-66RG5NN5.js")).makeHeadlessIO("ndjson","extract"):null,f=[],v=()=>{for(let t of f.splice(0))o.event({type:"error",message:t.message,...t.code?{code:t.code}:{}})},e=t=>{for(let i of t)o.event({type:"ingested",source_id:i.source_id,status:i.status,cid:i.source_cid,...i.warnings?.length?{warnings:i.warnings}:{},...i.media?{media:i.media}:{},...i.duplicate_of?{duplicate_of:i.duplicate_of}:{},...i.lineage_candidate?{lineage_candidate:i.lineage_candidate}:{}})},m=o?{out:()=>{},err:(t,i)=>f.push({message:t.replace(/^error: /,""),...i?{code:i}:{}}),isTTY:!1,confirm:async()=>!1}:{out:t=>process.stdout.write(t+`
|
|
6
6
|
`),err:t=>process.stderr.write(t+`
|
|
7
|
-
`),isTTY:n,confirm:async t=>{let i=l({input:process.stdin,output:process.stdout});try{let h=await i.question(`${t} [Y/n] `);return!/^n(o)?$/i.test(h.trim())}finally{i.close()}}};if(!p){let{withTelemetry:t}=await import("./with-telemetry-
|
|
7
|
+
`),isTTY:n,confirm:async t=>{let i=l({input:process.stdin,output:process.stdout});try{let h=await i.question(`${t} [Y/n] `);return!/^n(o)?$/i.test(h.trim())}finally{i.close()}}};if(!p){let{withTelemetry:t}=await import("./with-telemetry-3DL7ZEZL.js");return t("ingest",async()=>{let{code:i,results:h}=await w(c,{as:s.as},m,void 0,void 0);if(i!==0)return i;let I=h.filter(Y=>Y.status!=="unchanged").length;return I>0&&(m.err??m.out)(`landed ${I} source(s) \u2014 run kane-cli context extract to extract them`),0},{write:!0})}let a;try{a=o?await(await import("./run-channel-RGH4WIQX.js")).runWithChannel({event:o.event},()=>w(c,{as:s.as},m,void 0,void 0)):await w(c,{as:s.as},m,void 0,void 0)}catch(t){if(o)return v(),o.event({type:"error",message:t instanceof Error?t.message:String(t),code:"INGEST_FAILED"}),o.done(1,"error");throw t}let{code:r,results:d}=a;if(r!==0)return o?(e(d),v(),o.done(r,r===2?"refused":"error")):r;if(d.length===0)return o?o.done(0):0;let{extractCommand:A}=await import("./extract-cmd-7IOLJJCL.js"),N=[...new Set(d.map(t=>t.source_id))],x=await A({...s.mode!==void 0?{mode:s.mode}:{},...s.plan?{plan:!0}:{},...s.force?{force:!0}:{},...s.trust!==void 0?{trust:s.trust}:{},sources:N,landed:d});if(x===2&&!g){let t=d.filter(i=>i.status!=="unchanged").length;t>0&&(m.err??m.out)(`note: the ${t} landed source(s) are safe \u2014 extract later with kane-cli context extract`)}return x}export{w as a,se as b,ie as c};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as U,b as te,c as ne,j as x}from"./chunk-W4B5LOEX.js";import{a as M,b as J}from"./chunk-2UIHS2FH.js";import{a as B}from"./chunk-N2P4MI32.js";import{b as j,d as ee}from"./chunk-NVGBE2DR.js";import{A as Q}from"./chunk-TH47OOBV.js";import{x as q}from"./chunk-
|
|
2
|
+
import{a as U,b as te,c as ne,j as x}from"./chunk-W4B5LOEX.js";import{a as M,b as J}from"./chunk-2UIHS2FH.js";import{a as B}from"./chunk-N2P4MI32.js";import{b as j,d as ee}from"./chunk-NVGBE2DR.js";import{A as Q}from"./chunk-TH47OOBV.js";import{x as q}from"./chunk-7F2ZV46B.js";var w="https://integrations.lambdatest.com",g=class extends Error{constructor(e,r){super(r);this.code=e;this.name="LisError"}};function he(t){let n=t.TESTMUAI_ENV==="stage"?"stage":"prod";return`${q[n].shareApiBaseUrl}/lis/api/v1`}function ye(t){let n=t.env??process.env,e=t.auth?.TESTMUAI_BASIC_AUTH||n.TESTMUAI_BASIC_AUTH;if(e)return{authorization:`Basic ${e}`};let r=t.auth?.TESTMUAI_API_KEY||n.TESTMUAI_API_KEY;return r?{authorization:`Bearer ${r}`}:{}}function $(t){let n=t.split(`
|
|
3
3
|
`,1)[0].replace(/[\u0000-\u001f\u007f-\u009f]/g,"");return n.length>200?`${n.slice(0,200)}\u2026`:n}function Ee(t,n,e="the issue"){return t===401||t===403?new g("LIS_AUTH","credentials rejected \u2014 run `kane-cli login` and retry"):t>=500?new g("LIS_UNAVAILABLE",`the integrations service returned an error (HTTP ${t}) \u2014 retry later`):new g("JIRA_ISSUE_UNAVAILABLE",`could not fetch ${e}: ${$(n)||`HTTP ${t}`}`)}function P(t){try{return JSON.parse(t.bytes.toString("utf8"))}catch{throw new g("LIS_UNAVAILABLE","the integrations service returned a malformed response \u2014 retry later")}}function Z(t){try{return JSON.parse(t.bytes.toString("utf8"))}catch{return{}}}function re(t){return Z(t).code}function C(t,n="the issue"){let e=Z(t);switch(e.code){case"TOKEN_EXPIRED":return new g("LIS_SETUP",`your Atlassian connection needs a resync \u2014 reconnect at ${w} and retry`);case"NOT_INSTALLED":return new g("LIS_SETUP",`no Atlassian connection for this account \u2014 create one at ${w} and retry`);case"SCOPE_MISSING":return new g("LIS_SETUP",`the connection has no Confluence access \u2014 reconnect with Confluence at ${w} and retry`);case"FORBIDDEN":return new g("LIS_FORBIDDEN",`you don't have access to ${n}`);case"NOT_FOUND":return new g("JIRA_ISSUE_UNAVAILABLE",`could not fetch ${n}: ${$(e.message??"")||"not found"}`);case"PAYLOAD_TOO_LARGE":return new g("ATTACHMENT_TOO_LARGE","the attachment exceeds the integrations service's size cap");case"INVALID_PAYLOAD":return new g("LIS_UNAVAILABLE",`the integrations service rejected the request (${$(e.message??"")||"invalid payload"}) \u2014 retry later`);case"NOT_SUPPORTED":return new g("LIS_UNAVAILABLE","the integrations service does not support this operation yet");case"UPSTREAM_ERROR":case"UPSTREAM_TIMEOUT":return new g("LIS_UNAVAILABLE","Atlassian is not responding through the integrations service \u2014 retry later");default:return Ee(t.status,e.message??"",n)}}var be=3e4,_e=5;async function N(t,n,e){let r=e.env??process.env,d=e.fetchImpl??fetch;for(let o=0;;o++){let h=new AbortController,E=setTimeout(()=>h.abort(),be);try{let s=await d(`${he(r)}${t}`,{...n,headers:{"content-type":"application/json",...ye(e),...n.headers??{}},signal:h.signal}),u=await Promise.race([s.arrayBuffer(),new Promise((c,l)=>{h.signal.addEventListener("abort",()=>l(new DOMException("aborted","AbortError")),{once:!0})})]),a={status:s.status,ok:s.ok,headers:s.headers,bytes:Buffer.from(u)};if(a.status===429){if(o>0)throw new g("LIS_RATE_LIMITED","the integrations service is busy \u2014 try again in a moment");let c=Z(a).data?.retry_after_sec,l=Math.min(Math.max(typeof c=="number"&&Number.isFinite(c)?c:1,0),_e);clearTimeout(E),await new Promise(y=>setTimeout(y,l*1e3));continue}return a}catch(s){throw s instanceof g?s:h.signal.aborted?new g("LIS_UNAVAILABLE","the integrations service did not respond within 30 seconds \u2014 retry later"):new g("LIS_UNAVAILABLE",`could not reach the integrations service (${$(s instanceof Error?s.message:String(s))}) \u2014 check your connection and retry`)}finally{clearTimeout(E)}}}function D(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 k(t={}){let n=await N("/jira/info",{method:"GET"},t);if(!n.ok)throw C(n);let e=P(n),r=(e.data?.SELECTED_PROJECTS??[]).map(d=>d?.key).filter(d=>typeof d=="string"&&d.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 F(t,n={}){let e=await N("/jira/issue?details=true",{method:"POST",body:JSON.stringify({plugin_code:"jira",issueKey:t})},n);if(!e.ok)throw C(e);let r=P(e);if(r.type==="error"||!r.data)throw new g("JIRA_ISSUE_UNAVAILABLE",`could not fetch the issue: ${$(r.message??"")||"issue not found or not accessible"}`);return r.data}var se=100,Ae=5e3,Ie=60;async function V(t,n={}){let e=[],r=new Set,d=null,o=0;for(let h=0;;h++){if(h>=Ie)throw new g("LIS_UNAVAILABLE","the integrations service kept returning comment pages without finishing \u2014 retry later");let E=await N("/jira/issue/comments",{method:"POST",body:JSON.stringify({resource_id:t,max_results:se,cursor:d,start_at:o,order_by:"created",fetch_all:!1})},n);if(!E.ok)throw C(E,"the issue's comments");let s=P(E);if(s.type==="error"||!s.data)throw new g("JIRA_ISSUE_UNAVAILABLE",`could not fetch the issue's comments: ${$(s.message??"")||"unavailable"}`);for(let R of s.data.comments??[]){let m=String(R.id);r.has(m)||(r.add(m),e.push(R))}let u=s.data.pagination;if(!u?.has_more)return e;if(e.length>=Ae)throw new g("JIRA_ISSUE_UNAVAILABLE","the issue has more comments than can be ingested \u2014 cannot build a complete identity");let a=u.next_cursor??null,c=u.next_start_at!=null,l=c?u.next_start_at:o+se;if(!(a!=null&&a!==d||a==null&&c&&l!==o))throw new g("LIS_UNAVAILABLE","the integrations service returned a non-advancing comments page \u2014 retry later");d=a,o=l}}async function G(t,n={}){let e=await N("/jira/attachment",{method:"POST",body:JSON.stringify({attachment_id:t})},n);if(!e.ok){if(re(e)===void 0){if(e.status===413)throw new g("ATTACHMENT_TOO_LARGE","the attachment exceeds the integrations service's size cap");if(e.status===404)throw new g("JIRA_NOT_CONNECTED",`Jira is not connected for this account \u2014 connect it at ${w} and retry`)}throw C(e,`attachment ${t}`)}return D(e)}var K="kane.source.jira/2";function oe(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(oe).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 ie(t,n,e){let r=[],d={},o=t.additional_fields??{};for(let a of Object.keys(o).sort()){let c=oe(o[a]);if(c===null){r.push(`field "${a}" has no stable text form \u2014 dropped from the envelope`);continue}d[a]=c}let h=[...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,c)=>{let l=Number(a.id),y=Number(c.id);return Number.isFinite(l)&&Number.isFinite(y)?l-y:a.id<c.id?-1:a.id>c.id?1:0}),E=e.map(a=>({id:String(a.id),author:a.author?.display_name??"",body:a.body??"",created:a.created??""})).sort((a,c)=>{if(a.created!==c.created)return a.created<c.created?-1:1;let l=Number(a.id),y=Number(c.id);return Number.isFinite(l)&&Number.isFinite(y)&&l!==y?l-y:a.id<c.id?-1:a.id>c.id?1:0}),s=t.key;if(!/^[A-Za-z][A-Za-z0-9_]*-\d+$/.test(s))throw new Error(`cannot build a stable identity for issue key "${s}" \u2014 expected a PROJECT-NUMBER key`);let u={schema:K,site:n,project:s.slice(0,s.lastIndexOf("-")),issue:{id:t.id,key:s},content:{summary:t.summary??"",description:t.description??"",fields:d},attachments:h,comments:E};return{bytes:Buffer.from(JSON.stringify(u),"utf8"),envelope:u,warnings:r}}var ae=64,Le=16,we=6e6,Se=5e7,Re=12e6,ve={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"},$e=new Set(["png","jpeg","webp"]);function ce(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!==K)throw new Error(`JIRA_ENVELOPE_SCHEMA: unknown envelope schema "${e.schema}" \u2014 this CLI understands ${K}`);let r=[],d=new Map,o=[],h=0,E=new Map,s=[];for(let c=0;c<e.attachments.length;c++){let l=e.attachments[c],y=`i${c+1}`,R=`attachment:${l.filename}`,m=I=>`[img#${y}] ${l.filename} (${l.media_type}, ${l.size} bytes${I?"":" \u2014 not delivered"})`,p=(I,L,T)=>{r.push({ref:y,loc:R,media_type:I,...T?.blob?{blob:T.blob}:{},...T?.appearance?{appearance:T.appearance}:{},delivery:L,...T?.duplicate_of?{duplicate_of:T.duplicate_of}:{}})};if(!l.media_type.startsWith("image/")){p(l.media_type,"unsupported-vision-media-type"),s.push(m(!1));continue}let S;try{S=await t.fetchAttachment(l.id)}catch{p(l.media_type,"external-image-not-fetched"),s.push(m(!1));continue}let f=S.bytes,i=M(f),b=ve[i.format],_=j(f);if(d.set(_,f),!$e.has(i.format)){let I=i.format==="gif"||i.format==="bmp"||i.format==="tiff"?"unsupported-vision-media-type":"unsupported-image-kind";p(b,I,{blob:_}),s.push(m(!1));continue}if(i.width===void 0||i.height===void 0||i.width*i.height>Se){p(b,"undecodable",{blob:_}),s.push(m(!1));continue}let A;if(i.format==="png"||i.format==="jpeg"){let I=J(f,i.format);if(I===null){p(b,"undecodable",{blob:_}),s.push(m(!1));continue}A=B(I.data,{width:I.width,height:I.height,channels:I.channels})}if(i.width<ae||i.height<ae){p(b,"below-dimension-floor",{blob:_,appearance:A}),s.push(m(!1));continue}let v=E.get(_);if(v!==void 0){p(b,"duplicate",{blob:_,appearance:A,duplicate_of:v}),s.push(m(!1));continue}if(f.byteLength>we){p(b,"image-too-large",{blob:_,appearance:A}),s.push(m(!1));continue}if(h+f.byteLength>Re){p(b,"vision-byte-budget-reached",{blob:_,appearance:A}),s.push(m(!1));continue}if(o.length>=Le){p(b,"image-cap-reached",{blob:_,appearance:A}),s.push(m(!1));continue}E.set(_,y),h+=f.byteLength,o.push(y),p(b,"selected",{blob:_,appearance:A}),s.push(m(!0))}let u=[];u.push(`${e.issue.key} \xB7 ${e.site}/${e.project}`,`Summary: ${e.content.summary}`),e.content.description!==""&&u.push("",...e.content.description.split(`
|
|
4
4
|
`));let a=Object.keys(e.content.fields);return a.length>0&&u.push("","--- fields ---",...a.map(c=>`${c}: ${e.content.fields[c]}`)),s.length>0&&u.push("","--- attachments ---",...s),e.comments.length>0&&(u.push("","--- comments ---"),e.comments.forEach((c,l)=>{l>0&&u.push(""),u.push(`[${l+1}] ${c.author} \xB7 ${c.created}`,...c.body.split(`
|
|
5
5
|
`))})),{projection:u.join(`
|
|
6
6
|
`)+`
|
|
7
|
-
`,inventory:r,blobs:d,delivered:o,converter:{name:"jira-convert",version:"2",policy:"v1"}}}}var Te=/^[A-Za-z][A-Za-z0-9_]*-\d+$/;function Y(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 d=e[r+1];return Te.test(d)?{site:n.hostname,issueKey:d.toUpperCase()}:null}function H(t,n){let e=Q(t),r=e.heads.get(n);if(r==null)return null;let d=e.getNode(r)?.content?.blob;if(typeof d!="string")return null;let o=ee(t,d);if(o===null)return null;try{let h=JSON.parse(o.toString("utf8"));return typeof h.site=="string"&&h.site.length>0?h.site:null}catch{return null}}async function Ce(t,n,e,r,d){let o=Y(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 h=d?.lis??{jiraInfo:k,jiraIssue:F,jiraAttachment:G,jiraComments:V};try{let s={auth:await(d?.authEnv??(await import("./auth-
|
|
7
|
+
`,inventory:r,blobs:d,delivered:o,converter:{name:"jira-convert",version:"2",policy:"v1"}}}}var Te=/^[A-Za-z][A-Za-z0-9_]*-\d+$/;function Y(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 d=e[r+1];return Te.test(d)?{site:n.hostname,issueKey:d.toUpperCase()}:null}function H(t,n){let e=Q(t),r=e.heads.get(n);if(r==null)return null;let d=e.getNode(r)?.content?.blob;if(typeof d!="string")return null;let o=ee(t,d);if(o===null)return null;try{let h=JSON.parse(o.toString("utf8"));return typeof h.site=="string"&&h.site.length>0?h.site:null}catch{return null}}async function Ce(t,n,e,r,d){let o=Y(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 h=d?.lis??{jiraInfo:k,jiraIssue:F,jiraAttachment:G,jiraComments:V};try{let s={auth:await(d?.authEnv??(await import("./auth-QKBTOWQX.js")).resolveLisAuthEnv)(),env:process.env},u=await h.jiraInfo(s);if(!u.installed)return(e.err??e.out)(`error: ${t}: no Atlassian connection for this account \u2014 create one at ${w} and retry`),{code:1};if(u.capabilities.comments===!1)return(e.err??e.out)(`error: ${t}: the connection cannot read issue comments yet \u2014 resync it at ${w} and retry`),{code:1};let a=o.issueKey.slice(0,o.issueKey.lastIndexOf("-"));if(!u.selectAll&&u.selectedProjects.length>0&&!u.selectedProjects.includes(a))return(e.err??e.out)(`error: ${t}: project ${a} is not in the integration's selected projects (${u.selectedProjects.join(", ")}) \u2014 add it at ${w}`),{code:1};let c=await h.jiraIssue(o.issueKey,s),l=await h.jiraComments(o.issueKey,s),y=o.site;if(c.host)try{y=new URL(c.host).hostname}catch{y=c.host.replace(/^https?:\/\//,"").replace(/[/:].*$/,"")}let{bytes:R,warnings:m}=ie(c,y,l),p=n??o.issueKey.toLowerCase();U(p);let S=H(r,p);if(S!==null&&S!==y)return(e.err??e.out)(`error: ${t}: source '${p}' was ingested from ${S}, but this read serves ${y} \u2014 retire it first (kane-cli context retire ${p}) or ingest under a different id with --as`),{code:1};let f=await x({contextDir:r,bytes:R,media:te,sourceId:p,label:t,confirmSameSource:e.isTTY?i=>e.confirm(`identical content already ingested as ${i} \u2014 treat as the same source?`):void 0,converters:{jira:ce({fetchAttachment:i=>h.jiraAttachment(i,s)})}});e.out(z(e.isTTY,f,o.issueKey));for(let i of m)e.out(`warning: ${i}`);for(let i of f.warnings??[])e.out(`warning: ${i}`);if(f.composite){let i=f.composite.delivered+f.composite.omitted;e.out(`${f.source_id}: jira, ${i} attachments, ${f.composite.delivered} images delivered (${f.composite.omitted} omitted)`)}return{code:0,result:{status:f.status,source_id:f.source_id,source_cid:f.cid}}}catch(E){return E instanceof g?((e.err??e.out)(`error: ${t}: ${E.message}`),{code:1}):((e.err??e.out)(`error: ${t}: ${Ne(E instanceof Error?E.message:String(E))}`),{code:1})}}function Ne(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 ue={name:"jira",hint:"Jira issue URLs (https://<site>/browse/KEY-123)",match:t=>Y(t)!==null,ingest:Ce,sourceIdFor:t=>{let n=Y(t);return n?n.issueKey.toLowerCase():null}};async function le(t,n={}){let e=await N("/jira/document",{method:"POST",body:JSON.stringify({resource_id:t,format:"markdown"})},n);if(!e.ok)throw C(e,"the page");let r=P(e);if(r.type==="error"||!r.data)throw new g("JIRA_ISSUE_UNAVAILABLE",`could not fetch the page: ${$(r.message??"")||"page not found or not accessible"}`);return r.data}async function de(t,n={}){let e=await N("/jira/attachment",{method:"POST",body:JSON.stringify({source:"confluence",download:t})},n);if(!e.ok)throw C(e,"the page's attachment");return{bytes:D(e).bytes}}var W="kane.source.confluence/1";function me(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,h)=>o.id<h.id?-1:o.id>h.id?1:0),d={schema:W,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(d),"utf8"),envelope:d,warnings:[]}}var pe=64,Oe=16,Pe=6e6,je=5e7,Ue=12e6,xe={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"},Be=new Set(["png","jpeg","webp"]);function fe(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!==W)throw new Error(`CONFLUENCE_ENVELOPE_SCHEMA: unknown envelope schema "${r.schema}" \u2014 this CLI understands ${W}`);let d=[],o=new Map,h=[],E=0,s=new Map,u=[];for(let c=0;c<r.attachments.length;c++){let l=r.attachments[c],y=`i${c+1}`,R=`attachment:${l.filename}`,m=L=>`[img#${y}] ${l.filename} (${l.media_type}, ${l.size} bytes${L?"":" \u2014 not delivered"})`,p=(L,T,O)=>{d.push({ref:y,loc:R,media_type:L,...O?.blob?{blob:O.blob}:{},...O?.appearance?{appearance:O.appearance}:{},delivery:T,...O?.duplicate_of?{duplicate_of:O.duplicate_of}:{}})};if(!l.media_type.startsWith("image/")){p(l.media_type,"unsupported-vision-media-type"),u.push(m(!1));continue}let S=n.get(l.id);if(!S){p(l.media_type,"external-image-not-fetched"),u.push(m(!1));continue}let f;try{f=await t.fetchAttachment({id:l.id,download:S})}catch{p(l.media_type,"external-image-not-fetched"),u.push(m(!1));continue}let i=f.bytes,b=M(i),_=xe[b.format],A=j(i);if(o.set(A,i),!Be.has(b.format)){let L=b.format==="gif"||b.format==="bmp"||b.format==="tiff"?"unsupported-vision-media-type":"unsupported-image-kind";p(_,L,{blob:A}),u.push(m(!1));continue}if(b.width===void 0||b.height===void 0||b.width*b.height>je){p(_,"undecodable",{blob:A}),u.push(m(!1));continue}let v;if(b.format==="png"||b.format==="jpeg"){let L=J(i,b.format);if(L===null){p(_,"undecodable",{blob:A}),u.push(m(!1));continue}v=B(L.data,{width:L.width,height:L.height,channels:L.channels})}if(b.width<pe||b.height<pe){p(_,"below-dimension-floor",{blob:A,appearance:v}),u.push(m(!1));continue}let I=s.get(A);if(I!==void 0){p(_,"duplicate",{blob:A,appearance:v,duplicate_of:I}),u.push(m(!1));continue}if(i.byteLength>Pe){p(_,"image-too-large",{blob:A,appearance:v}),u.push(m(!1));continue}if(E+i.byteLength>Ue){p(_,"vision-byte-budget-reached",{blob:A,appearance:v}),u.push(m(!1));continue}if(h.length>=Oe){p(_,"image-cap-reached",{blob:A,appearance:v}),u.push(m(!1));continue}s.set(A,y),E+=i.byteLength,h.push(y),p(_,"selected",{blob:A,appearance:v}),u.push(m(!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
|
`)),u.length>0&&a.push("","--- attachments ---",...u),{projection:a.join(`
|
|
9
9
|
`)+`
|
|
10
|
-
`,inventory:d,blobs:o,delivered:h,converter:{name:"confluence-convert",version:"1",policy:"v1"}}}}var Me=/^[A-Za-z0-9~][A-Za-z0-9._~-]*$/;function X(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 d=e[r+2],o=e[r+4];return d===void 0||o===void 0||!Me.test(d)||!/^\d+$/.test(o)?null:{site:n.hostname,spaceKey:d,pageId:o}}async function Je(t,n,e,r,d){let o=X(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 h=d?.lis??{jiraInfo:k,jiraIssue:F,jiraAttachment:G,jiraComments:V},E=d?.confluence??{confluenceDocument:le,confluenceAttachment:de};try{let u={auth:await(d?.authEnv??(await import("./auth-
|
|
10
|
+
`,inventory:d,blobs:o,delivered:h,converter:{name:"confluence-convert",version:"1",policy:"v1"}}}}var Me=/^[A-Za-z0-9~][A-Za-z0-9._~-]*$/;function X(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 d=e[r+2],o=e[r+4];return d===void 0||o===void 0||!Me.test(d)||!/^\d+$/.test(o)?null:{site:n.hostname,spaceKey:d,pageId:o}}async function Je(t,n,e,r,d){let o=X(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 h=d?.lis??{jiraInfo:k,jiraIssue:F,jiraAttachment:G,jiraComments:V},E=d?.confluence??{confluenceDocument:le,confluenceAttachment:de};try{let u={auth:await(d?.authEnv??(await import("./auth-QKBTOWQX.js")).resolveLisAuthEnv)(),env:process.env},a=await h.jiraInfo(u);if(!a.installed)return(e.err??e.out)(`error: ${t}: no Atlassian connection for this account \u2014 create one at ${w} 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 ${w} and retry`),{code:1};let c=await E.confluenceDocument(o.pageId,u),l=o.site;if(c.url)try{l=new URL(c.url).hostname}catch{}let{bytes:y,warnings:R}=me(c,l),m=n??`page-${o.pageId}`;U(m);let p=H(r,m);if(p!==null&&p!==l)return(e.err??e.out)(`error: ${t}: source '${m}' was ingested from ${p}, but this read serves ${l} \u2014 retire it first (kane-cli context retire ${m}) or ingest under a different id with --as`),{code:1};let S=Object.fromEntries((c.attachments??[]).filter(i=>typeof i.download=="string"&&i.download.length>0).map(i=>[String(i.id),i.download])),f=await x({contextDir:r,bytes:y,media:ne,sourceId:m,label:t,confirmSameSource:e.isTTY?i=>e.confirm(`identical content already ingested as ${i} \u2014 treat as the same source?`):void 0,converters:{confluence:fe({downloads:S,fetchAttachment:i=>E.confluenceAttachment(i.download,u)})}});e.out(z(e.isTTY,f,`${o.spaceKey}/${o.pageId}`));for(let i of R)e.out(`warning: ${i}`);for(let i of f.warnings??[])e.out(`warning: ${i}`);if(f.composite){let i=f.composite.delivered+f.composite.omitted;e.out(`${f.source_id}: confluence, ${i} attachments, ${f.composite.delivered} images delivered (${f.composite.omitted} omitted)`)}return{code:0,result:{status:f.status,source_id:f.source_id,source_cid:f.cid}}}catch(s){return s instanceof g?((e.err??e.out)(`error: ${t}: ${s.message}`),{code:1}):((e.err??e.out)(`error: ${t}: ${De(s instanceof Error?s.message:String(s))}`),{code:1})}}function De(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 ge={name:"confluence",hint:"Confluence page URLs (https://<site>/wiki/spaces/<KEY>/pages/<id>/\u2026)",match:t=>X(t)!==null,ingest:Je,sourceIdFor:t=>{let n=X(t);return n?`page-${n.pageId}`:null}};function z(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 ke=[ue,ge];function xt(t){return/^https?:\/\/.+/i.test(t)}function Bt(t){return ke.find(n=>n.match(t))??null}export{z as a,ke as b,xt as c,Bt as d};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{d as Y,f as q,h as H}from"./chunk-NHBYZCSX.js";import{a as O,b as j,c as z}from"./chunk-HWH3UYD6.js";import{d as B,f as R}from"./chunk-ECZMYPLJ.js";import{b as N,c as _,j as M}from"./chunk-IUEEFGEW.js";import{a as L}from"./chunk-TZXXJWHA.js";import{m as b}from"./chunk-56PAQAX5.js";import{a as K,b as C,c as G}from"./chunk-AJQT4IWZ.js";import{h as J}from"./chunk-TAOHYWEO.js";import{a as F,b as $}from"./chunk-BRIEBB2U.js";import{c as E}from"./chunk-7F2ZV46B.js";import{createHash as be}from"crypto";import{readdir as Ce,stat as Te}from"fs/promises";import{basename as f,extname as Ie,join as Ae,relative as ke}from"path";import{createHash as de}from"crypto";import{createReadStream as le}from"fs";import{mkdir as ce,readFile as ue,rename as fe,writeFile as ge}from"fs/promises";import{dirname as me,join as he}from"path";var we=60,ve=5;function V(){return{entries:[]}}function X(){return he(E,"mobile","app-cache.json")}async function T(e){let r=de("sha256");for await(let t of le(e))r.update(t);return r.digest("hex")}function ye(){return{readFile:e=>ue(e,"utf8"),writeFile:async(e,r)=>{await ce(me(e),{recursive:!0});let t=`${e}.tmp`;await ge(t,r),await fe(t,e)},hashFile:T,now:()=>new Date}}function I(e){if(!e)return;let r=/\/(\d{4})\/(\d{2})\/(\d{2})\//.exec(e);if(!r)return;let[,t,o,s]=r,n=new Date(`${t}-${o}-${s}T00:00:00Z`);return Number.isNaN(n.getTime())?void 0:n.toISOString()}function Pe(e,r){if(!e.storedAt)return!0;let t=new Date(e.storedAt).getTime();return Number.isNaN(t)?!0:(r.getTime()-t)/864e5>=we-ve}var u=class{deps;constructor(r={}){this.deps={...ye(),...r}}async read(){try{let r=JSON.parse(await this.deps.readFile(X()));if(!r||typeof r!="object")return V();let t=r;return{entries:Array.isArray(t.entries)?t.entries:[]}}catch{return V()}}async write(r){await this.deps.writeFile(X(),JSON.stringify(r,null,2))}async hashOf(r){return this.deps.hashFile(r)}async lookup(r){return(await this.read()).entries.find(o=>o.sha256===r.sha256&&o.env===r.env&&o.orgId===r.orgId&&o.type===r.type)}async remember(r){let t=await this.read();t.entries=[...t.entries.filter(o=>!(o.sha256===r.sha256&&o.env===r.env&&o.orgId===r.orgId&&o.type===r.type)),r],await this.write(t)}async forget(r){let t=await this.read(),o=t.entries.length;t.entries=t.entries.filter(s=>!(s.sha256===r.sha256&&s.env===r.env&&s.orgId===r.orgId&&s.type===r.type)),t.entries.length!==o&&await this.write(t)}isNearExpiry(r){return Pe(r,this.deps.now())}};var Z={emulator:[".apk"],simulator:[".zip"]};function Q(e){return e.skipped===!0}function De(e,r){let t=Ie(e).toLowerCase();return t===".ipa"?`${f(e)} is a device build \u2014 .ipa is not accepted for ${r} runs.`:Z[r].includes(t)?null:`${f(e)} cannot be uploaded for a ${r} run \u2014 expected one of ${Z[r].join(", ")}.`}async function A(e,r){if(!(await Te(e)).isDirectory())return r.hashOf(e);let o=[],s=async i=>{for(let a of await Ce(i,{withFileTypes:!0})){let p=Ae(i,a.name);a.isDirectory()?await s(p):a.isFile()&&o.push(p)}};await s(e),o.sort();let n=be("sha256");for(let i of o)n.update(ke(e,i)),n.update("\0"),n.update(await T(i)),n.update("\0");return n.digest("hex")}async function W(e){let r=De(e.path,e.type);if(r)return{skipped:!0,reason:r};let t=e.cache??new u,o=e.client??new J(e.baseUrl,{...e.auth,orgId:e.orgId}),s;try{s=await A(e.path,t)}catch(a){return{skipped:!0,reason:`could not read ${f(e.path)}: ${a.message}`}}let n={sha256:s,env:e.env,orgId:e.orgId,type:e.type},i=await t.lookup(n);if(i){if(await o.liveness(i.appId)!=="gone")return{appId:i.appId,...i.appUrl?{appUrl:i.appUrl}:{},fromCache:!0};e.onProgress?.(`${i.appId} is no longer in the cloud \u2014 uploading again`),await t.forget(n)}try{e.onProgress?.(`uploading ${f(e.path)}\u2026`);let a=await o.upload(e.path,e.type);return await t.remember({sha256:s,env:e.env,orgId:e.orgId,type:e.type,appId:a.appId,...a.appUrl?{appUrl:a.appUrl}:{},...I(a.url)?{storedAt:I(a.url)}:{},sourcePath:e.path}),e.onProgress?.(a.cached?`${f(e.path)} already in the cloud (${a.appId})`:`${f(e.path)} uploaded (${a.appId})`),{appId:a.appId,...a.appUrl?{appUrl:a.appUrl}:{},fromCache:!1}}catch(a){return{skipped:!0,reason:a.message}}}function h(e){return`${e.platform}|${F(e)}`}var g=new Map,ee=new Set;function re(e){return ee.has(h(e))}function We(e,r,t){r.state==="stopped"&&(g.has(h(r))||oe(e,r,t))}async function te(e,r,t){let o=g.get(h(r));return o?(t?.(`waiting for ${r.displayName} to finish booting\u2026`),o):oe(e,r,t)}function oe(e,r,t){let o=h(r),s=e.prepare(r,t);g.set(o,s),r.state==="stopped"&&s.then(()=>ee.add(o),()=>{});let n=()=>{g.get(o)===s&&g.delete(o)};return s.then(n,n),s.catch(()=>{}),s}import{basename as xe}from"path";import{spawnSync as Ue}from"child_process";async function Se(e,r,t){if(!e.teardownPlan||!t.appPackage&&!t.shutdown)return;let o;try{o=await e.teardownPlan(r,t)}catch{return}o.length!==0&&b(`device:${r.id}`,()=>{Y({udid:r.id,displayName:r.displayName});for(let s of o)try{Ue(s.file,s.args,{timeout:3e4,stdio:"ignore"})}catch{}})}var ae={emulator:[".apk"],simulator:[".zip"]};async function Ee(e,r,t,o){if(e.kind==="package")return e;if(e.kind==="app_id"){let s=r.cloudUpload;if(!s)throw new Error(`${e.value} is an app id, which needs an account to download it. Log in, or pass a path to a local build instead.`);let n=await G({appId:e.value,baseUrl:s.baseUrl,auth:s.auth,...ae[t]?{accepts:ae[t]}:{},...o?{onProgress:o}:{}}),i=D(n.path);if(!i||i.kind==="app_id")throw new Error(`${n.name} is not a build this CLI can install (from ${e.value}).`);return i}try{let s=new u,n=await A(e.value,s),i=new K;await i.find(n)||o?.(`copying ${xe(e.value)} into the local app store\u2026`);let p=await i.put({key:n,sourcePath:e.value,source:"local"});return{...e,value:p.path}}catch{return e}}function Fe(e){b(`appium:${e}`,()=>{H({deviceClass:e,owner:process.pid})})}var k=class extends Error{constructor(r){super(r),this.name="MobileHostUnsupportedError"}},w=class extends Error{constructor(t,o){super(t);this.doctorText=o;this.name="MobilePreflightError"}};async function $e(e,r,t){let o=t.cloudUpload,s=await W({path:e,type:r,env:o.env,orgId:o.orgId,userId:o.userId,auth:o.auth,baseUrl:o.baseUrl,...t.onProgress?{onProgress:t.onProgress}:{}});if(Q(s)){t.onProgress?.(`app not uploaded \u2014 ${s.reason}`);return}return s.appId}var Ne="app must be a build (.apk for an emulator, .zip of the .app bundle for a simulator) or an app id from your cloud uploads \u2014 a package id names something already installed on one device, so it cannot be uploaded, exported as code, or run anywhere else.",se=/\.(apk|zip)$/i;function D(e){let r=e.trim();if(C(r))return{kind:"app_id",value:r};let t=se.exec(r)?.[1]?.toLowerCase();return t?{kind:t,value:r}:null}function _e(e){return!!e&&(se.test(e)||C(e.trim()))}function Me(e){return e.filter(r=>r.required&&r.status==="fail")}function Be(e,r){return!!r&&e.platform===r.platform&&e.kind===r.kind&&(e.id===r.id||e.virtualName===r.id)}async function mr(e){let r=L();if(!r.supported)throw new k(r.reason);let t=e.appiumUrl??e.defaults?.appium_url,o=!!(e.agent||!e.interactive),s=M();o&&e.platform?.toLowerCase()!=="ios"&&((await s.status("emulator")).installed||await s.ensure("emulator",{automatic:!0,onProgress:e.onProgress}));let n=await O(e.platform,{appiumUrl:t});if(z(n)){let d=n.sections.flatMap(P=>Me(P.checks)).map(P=>P.label).join(", ");throw new w(`Mobile toolchain not ready (${d}). Run \`kane-cli doctor --target ${e.platform?.toLowerCase()==="ios"?"simulator":e.platform?.toLowerCase()==="android"?"emulator":"<emulator|simulator>"}\` for details.`,j(n))}let i=await R({device:e.device,platform:e.platform,defaultTarget:e.defaults?.default_target,interactive:e.interactive}),a;if(i.ok)a=i.target;else if(i.reason==="needs-picker"&&e.pickTarget){let d=await e.pickTarget(i.candidates);if(!d)throw new Error("Target selection cancelled");a=d}else throw new Error(i.message);let p=B(a.platform);if(!p)throw new Error(`No provider for platform "${a.platform}"`);let l=N(a);if(!l)throw new Error(`No managed dependencies serve ${a.platform} ${a.kind} targets yet.`);try{await s.ensure(l,{automatic:o,onProgress:e.onProgress})}catch(d){throw d instanceof _?new w(d.message,d.message):d}let ie=a.state!=="ready"||re(a);a=await te(p,a,e.onProgress);let ne=await q(l,{...t?{appiumUrl:t}:{},device:{udid:a.id,displayName:a.displayName},onProgress:e.onProgress});Fe(l);let x=Be(a,e.defaults?.default_target)?e.defaults?.default_app:void 0,m=e.app??(_e(x)?x:void 0);if(e.app&&!D(e.app))throw new Error(`${e.app}: ${Ne}`);let c=m?D(m):null,U=c?await Ee(c,e,l,e.onProgress):null,v=U?await p.ensureApp(a,U,e.onProgress):void 0,y=c?.kind==="app_id"?c.value:e.cloudUpload&&c&&m?await $e(c.value,l,e):void 0;await Se(p,a,{shutdown:ie,...v?{appPackage:v}:{}});let pe=$(a,v,{noReset:e.noReset??e.defaults?.no_reset,appiumUrl:ne.url}),S=y??m;return{device:pe,target:a,provider:p,...y?{appId:y}:{},...S?{appRef:S}:{}}}export{We as a,te as b,k as c,w as d,Ne as e,D as f,_e as g,mr as h};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as k}from"./chunk-
|
|
2
|
+
import{a as k}from"./chunk-YTDSQAYN.js";import{a as m}from"./chunk-BPMSNGXQ.js";import{p as a}from"./chunk-56PAQAX5.js";import{a as y}from"./chunk-LVN6VHFN.js";import{a as h}from"./chunk-PXCMEI73.js";var $=10,u=200,N=1e4,S=1e6;function T(t,e,r="streaming"){let n=r==="full-fetch"?S:N,o=$,i=0;if(t!==void 0){let s=Number(t);if(!Number.isInteger(s)||s<1||s>u)return{error:`--limit must be an integer in [1, ${u}] (got "${t}")`};o=s}if(e!==void 0){let s=Number(e);if(!Number.isInteger(s)||s<0||s>n)return{error:`--offset must be an integer in [0, ${n}] (got "${e}")`};i=s}return{limit:o,offset:i}}function C(t,e){if(!e)return t;let r=e.toLowerCase();return t.filter(n=>n.name.toLowerCase().includes(r))}function j(t,{limit:e,offset:r}){let n=t.slice(r,r+e),o=t.length>r+e;return{slice:n,hasMore:o}}function v(t,e,r=n=>process.stdout.write(`${n}
|
|
3
3
|
`)){for(let n of t)r(JSON.stringify(n));r(JSON.stringify({_meta:"page",limit:e.limit,offset:e.offset,returned:t.length,has_more:e.has_more}))}function b(t,e,r=n=>process.stdout.write(`${n}
|
|
4
|
-
`)){if(t.length===0){r("(no results)");return}let n=Math.max(2,...t.map(s=>s.id.length)),o=`${"ID".padEnd(n)} NAME`;r(o),r(`${"-".repeat(n)} ----`);for(let s of t)r(`${s.id.padEnd(n)} ${s.name}`);r("");let i=e.offset+t.length;if(e.hasMore){let s=e.totalIsLowerBound?`${e.total}+`:`${e.total}`;r(`${i} of ${s} \u2014 next: --offset ${e.offset+e.limit}`)}else r(`${t.length} shown (${e.total} total)`)}async function B(t,e,r){if(r.username&&r.accessKey)return{ok:!0,creds:{username:r.username,access_key:r.accessKey}};let n=new h,o=n.loadBasicAuth(t,e);if(o)return{ok:!0,creds:{username:o.username,access_key:o.access_key}};let i=n.loadCredentials(t,e);if(!i)return{ok:!1,reason:"no_credentials"};let s=i.access_token;try{let{refreshOAuthToken:d}=await import("./token-refresh-
|
|
4
|
+
`)){if(t.length===0){r("(no results)");return}let n=Math.max(2,...t.map(s=>s.id.length)),o=`${"ID".padEnd(n)} NAME`;r(o),r(`${"-".repeat(n)} ----`);for(let s of t)r(`${s.id.padEnd(n)} ${s.name}`);r("");let i=e.offset+t.length;if(e.hasMore){let s=e.totalIsLowerBound?`${e.total}+`:`${e.total}`;r(`${i} of ${s} \u2014 next: --offset ${e.offset+e.limit}`)}else r(`${t.length} shown (${e.total} total)`)}async function B(t,e,r){if(r.username&&r.accessKey)return{ok:!0,creds:{username:r.username,access_key:r.accessKey}};let n=new h,o=n.loadBasicAuth(t,e);if(o)return{ok:!0,creds:{username:o.username,access_key:o.access_key}};let i=n.loadCredentials(t,e);if(!i)return{ok:!1,reason:"no_credentials"};let s=i.access_token;try{let{refreshOAuthToken:d}=await import("./token-refresh-FP6JFLXB.js"),w=await d({creds:n,profile:t,env:e,credentials:i});w&&(s=w.accessToken)}catch(d){return{ok:!1,reason:"refresh_failed",detail:d instanceof Error?d.message:String(d)}}let c=y(e),f=await new k(c.controllerBaseUrl,async()=>s,null).resolve();return f?{ok:!0,creds:{username:f.username,access_key:f.access_key}}:{ok:!1,reason:"exchange_failed"}}function E(t,e,r){switch(r.reason){case"no_credentials":return{message:`error: no credentials for profile "${t}" [${e}]. Run \`kane-cli login\` or pass --username/--access-key.
|
|
5
5
|
`,exitCode:2};case"refresh_failed":return{message:`error: OAuth token refresh failed for profile "${t}" [${e}]${r.detail?`: ${r.detail}`:""}. Run \`kane-cli login\` to re-auth.
|
|
6
6
|
`,exitCode:2};case"exchange_failed":return{message:`error: TMS credential exchange failed for profile "${t}" [${e}]. Token may be revoked \u2014 try \`kane-cli login\`; if the problem persists, TMS may be down.
|
|
7
7
|
`,exitCode:2}}}function O(t){return{id:t.project_id,name:t.name}}function M(t){return{id:t.id,name:t.name}}async function P(t,e,r,n){let o=r+n+1,i=[],s=!0;for await(let c of t.listProjectsStream({name:e})){if(i.push(...c.projects),c.done){s=!0;break}if(i.length>=o){s=!1;break}}return{items:i,doneStreaming:s}}function g(t){return!!t.agent||!process.stdin.isTTY||!process.stdout.isTTY}function _(t,e=r=>process.stdout.write(`${r}
|