@visulima/vis 6.1.0 → 6.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +43 -0
- package/dist/bin.js +1 -1
- package/dist/binx.js +1 -1
- package/dist/config/index.d.ts +1226 -1216
- package/dist/packem_chunks/bloom-sync.js +1 -1
- package/dist/packem_chunks/cargo-lock.js +5 -0
- package/dist/packem_chunks/cargo-plan.js +3 -3
- package/dist/packem_chunks/catalog-detector.js +1 -1
- package/dist/packem_chunks/catalog.js +1 -94
- package/dist/packem_chunks/catalog2.js +11 -0
- package/dist/packem_chunks/cli-exec.js +1 -1
- package/dist/packem_chunks/cli-main.js +156 -174
- package/dist/packem_chunks/context.js +8 -0
- package/dist/packem_chunks/fix.js +1 -1
- package/dist/packem_chunks/handler10.js +1 -1
- package/dist/packem_chunks/handler12.js +1 -1
- package/dist/packem_chunks/handler13.js +1 -1
- package/dist/packem_chunks/handler14.js +1 -1
- package/dist/packem_chunks/handler15.js +1 -1
- package/dist/packem_chunks/handler19.js +5 -5
- package/dist/packem_chunks/handler2.js +1 -1
- package/dist/packem_chunks/handler20.js +1 -1
- package/dist/packem_chunks/handler21.js +1 -1
- package/dist/packem_chunks/handler23.js +1 -1
- package/dist/packem_chunks/handler24.js +1 -1
- package/dist/packem_chunks/handler25.js +1 -1
- package/dist/packem_chunks/handler28.js +1 -1
- package/dist/packem_chunks/handler3.js +1 -1
- package/dist/packem_chunks/handler31.js +1 -1
- package/dist/packem_chunks/handler32.js +1 -1
- package/dist/packem_chunks/handler33.js +1 -1
- package/dist/packem_chunks/handler34.js +3 -3
- package/dist/packem_chunks/handler35.js +1 -1
- package/dist/packem_chunks/handler36.js +1 -1
- package/dist/packem_chunks/handler38.js +2 -2
- package/dist/packem_chunks/handler39.js +5 -5
- package/dist/packem_chunks/handler4.js +4 -4
- package/dist/packem_chunks/handler40.js +1 -1
- package/dist/packem_chunks/handler41.js +1 -1
- package/dist/packem_chunks/handler42.js +1 -1
- package/dist/packem_chunks/handler43.js +1 -1
- package/dist/packem_chunks/handler44.js +1 -1
- package/dist/packem_chunks/handler45.js +1 -1
- package/dist/packem_chunks/handler46.js +1 -1
- package/dist/packem_chunks/handler47.js +1 -1
- package/dist/packem_chunks/handler48.js +1 -1
- package/dist/packem_chunks/handler49.js +1 -1
- package/dist/packem_chunks/handler5.js +4 -4
- package/dist/packem_chunks/handler50.js +5 -5
- package/dist/packem_chunks/handler52.js +1 -1
- package/dist/packem_chunks/handler54.js +2 -2
- package/dist/packem_chunks/handler55.js +1 -1
- package/dist/packem_chunks/handler56.js +3 -3
- package/dist/packem_chunks/handler57.js +4 -4
- package/dist/packem_chunks/handler58.js +4 -4
- package/dist/packem_chunks/handler59.js +2 -2
- package/dist/packem_chunks/handler6.js +7 -7
- package/dist/packem_chunks/handler60.js +1 -1
- package/dist/packem_chunks/handler61.js +2 -2
- package/dist/packem_chunks/handler62.js +1 -1
- package/dist/packem_chunks/handler63.js +3 -3
- package/dist/packem_chunks/handler64.js +3 -3
- package/dist/packem_chunks/handler65.js +2 -2
- package/dist/packem_chunks/handler66.js +2 -2
- package/dist/packem_chunks/handler67.js +5 -5
- package/dist/packem_chunks/handler68.js +12 -25
- package/dist/packem_chunks/handler69.js +25 -22
- package/dist/packem_chunks/handler70.js +22 -10
- package/dist/packem_chunks/handler71.js +10 -133
- package/dist/packem_chunks/handler72.js +133 -23
- package/dist/packem_chunks/handler73.js +23 -323
- package/dist/packem_chunks/handler74.js +274 -659
- package/dist/packem_chunks/handler75.js +708 -48
- package/dist/packem_chunks/handler76.js +48 -27
- package/dist/packem_chunks/handler77.js +27 -3
- package/dist/packem_chunks/handler78.js +3 -191
- package/dist/packem_chunks/handler79.js +191 -0
- package/dist/packem_chunks/handler8.js +1 -1
- package/dist/packem_chunks/heal.js +2 -2
- package/dist/packem_chunks/help-command.js +1 -1
- package/dist/packem_chunks/index2.js +3 -58
- package/dist/packem_chunks/index3.js +40 -3
- package/dist/packem_chunks/index6.js +135 -7
- package/dist/packem_chunks/index7.js +7 -135
- package/dist/packem_chunks/keys-refresh.js +1 -1
- package/dist/packem_chunks/list.js +2 -2
- package/dist/packem_chunks/prune.js +1 -1
- package/dist/packem_chunks/python-plan.js +3 -3
- package/dist/packem_chunks/python-projects.js +1 -1
- package/dist/packem_chunks/python.js +1 -0
- package/dist/packem_chunks/run.js +1 -1
- package/dist/packem_chunks/snapshot.js +2 -2
- package/dist/packem_chunks/state.js +2 -2
- package/dist/packem_chunks/status.js +1 -1
- package/dist/packem_chunks/sync.js +1 -1
- package/dist/packem_chunks/verify-lockfile.js +1 -1
- package/dist/packem_chunks/version-resolver.js +1 -1
- package/dist/packem_chunks/workspace.js +2 -2
- package/dist/packem_shared/ReleaseClient-CWD9BC5w.js +1 -0
- package/dist/packem_shared/advisories-BodWQ5DQ.js +1 -0
- package/dist/packem_shared/{affected-selection-DGb6Xu5K.js → affected-selection-QaMUnFqe.js} +1 -1
- package/dist/packem_shared/{ai-analysis-pldoS_N4.js → ai-analysis-D7jlbJky.js} +3 -3
- package/dist/packem_shared/ai-cache-iSIyY3So.js +1 -0
- package/dist/packem_shared/{ai-fix-D9MxigBQ.js → ai-fix-CgCyO65Q.js} +6 -6
- package/dist/packem_shared/apply-DoeQAAGm.js +6 -0
- package/dist/packem_shared/apply-release-plan-BalHtK-g.js +15 -0
- package/dist/packem_shared/{bin-AZQv95jh.js → bin-LyW9KY0i.js} +1 -1
- package/dist/packem_shared/clean-package-json-rutwkKl-.js +1 -0
- package/dist/packem_shared/createAdapter-DMK4bBET.js +1 -0
- package/dist/packem_shared/createVersionActions-DXo4z8VN.js +1 -0
- package/dist/packem_shared/dependency-scan-DFnt1mni.js +1 -0
- package/dist/packem_shared/{ecosystem-gate-DiqQj0LJ.js → ecosystem-gate-Bdz-gK_Y.js} +1 -1
- package/dist/packem_shared/env-BSXG3QKH.js +4 -0
- package/dist/packem_shared/failure-log-DIsKBKaI.js +2 -0
- package/dist/packem_shared/formatBytes-_HvjOy8a-iHCer6uX.js +1 -0
- package/dist/packem_shared/glob-Cyk1H9ZL-DRlUeuow.js +1 -0
- package/dist/packem_shared/{index-JRb5wabN.js → index-B1ZsG3oa.js} +1 -1
- package/dist/packem_shared/index-CgNfNk12.js +1 -0
- package/dist/packem_shared/lifecycle-CQjeMPY0.js +2 -0
- package/dist/packem_shared/missing-package-json-dtwl6w-S.js +1 -0
- package/dist/packem_shared/multi-eco-lockfiles-CyIfYw4u.js +1 -0
- package/dist/packem_shared/npmrc-CHsOyMvA.js +2 -0
- package/dist/packem_shared/osv-C53WUoSW.js +1 -0
- package/dist/packem_shared/{package-version-KLwH0Ivy.js → package-version-DqYSd_ia.js} +1 -1
- package/dist/packem_shared/packument-CbTmbHU4.js +1 -0
- package/dist/packem_shared/{project-name-filter-B1ZCsbOW.js → project-name-filter-mwTJC1IK.js} +1 -1
- package/dist/packem_shared/{provenance-L1M2FPy_.js → provenance-SX1MxPUZ.js} +1 -1
- package/dist/packem_shared/publish-Dc0XGH3K.js +34 -0
- package/dist/packem_shared/registry-CkoaWkjP.js +81 -0
- package/dist/packem_shared/registry-keys-z038Ecb4.js +1 -0
- package/dist/packem_shared/removeSync-g1D5kONg-LbjATA8v.js +1 -0
- package/dist/packem_shared/renderToString-DR0zDUjh-C7p-L6AO.js +3 -0
- package/dist/packem_shared/{resolve-explicit-CQa37JSq.js → resolve-explicit-D9kdTNvl.js} +1 -1
- package/dist/packem_shared/{run-D-uVGHQ4.js → run-DLvd3RIZ.js} +1 -1
- package/dist/packem_shared/run-summary-utils-CMeURYtS.js +1 -0
- package/dist/packem_shared/s1ngularity-BuU9Cxpy.js +1 -0
- package/dist/packem_shared/{scaffold-files-DVyfB0yz.js → scaffold-files-Bje3_Ixv.js} +1 -1
- package/dist/packem_shared/scan-progress-D8ojNcKt.js +2 -0
- package/dist/packem_shared/{signatures-DIqFUOfs.js → signatures-CeL0bOEo.js} +1 -1
- package/dist/packem_shared/spinner-Bqjpz3i4.js +1 -0
- package/dist/packem_shared/table-DDAJalPF.js +1 -0
- package/dist/packem_shared/tabs-CC0GJLww.js +1 -0
- package/dist/packem_shared/{task-env-DzR4RkOj.js → task-env-C2lmxvzA.js} +1 -1
- package/dist/packem_shared/typosquats-BFKus_aM.js +1 -0
- package/dist/packem_shared/use-measured-height-_nYuZ-Au.js +1 -0
- package/dist/packem_shared/vis-update-app-Ba5ce8Jd.js +1 -0
- package/dist/packem_shared/{vis-user-error-CRmrBaD1.js → vis-user-error-D_ekz9rF.js} +1 -1
- package/dist/packem_shared/{watch-loop-D1_e-qIl.js → watch-loop-DWr41vHM.js} +1 -1
- package/dist/packem_shared/xxh3-BLHlvhgT.js +1 -0
- package/dist/release/core/package-managers/index.js +1 -1
- package/dist/release/core/version-actions/index.js +1 -1
- package/dist/release/index.js +1 -1
- package/index.js +26 -26
- package/package.json +9 -9
- package/dist/packem_chunks/orchestrator.js +0 -46
- package/dist/packem_shared/ReleaseClient-DAvbxCdo.js +0 -1
- package/dist/packem_shared/createAdapter-F7GidOzU.js +0 -1
- package/dist/packem_shared/createVersionActions-ByaJ1Nbv.js +0 -1
- package/dist/packem_shared/dependency-scan-CawAKoU_.js +0 -1
- package/dist/packem_shared/failure-log-BP-gCUb5.js +0 -2
- package/dist/packem_shared/formatBytes-_HvjOy8a-B_qQr4Hw.js +0 -4
- package/dist/packem_shared/glob-Cyk1H9ZL-Dxlf9Swz.js +0 -1
- package/dist/packem_shared/index-CDHP1kby.js +0 -1
- package/dist/packem_shared/lifecycle-DvmDIRbb.js +0 -2
- package/dist/packem_shared/missing-package-json-Cu5YVAot.js +0 -1
- package/dist/packem_shared/multi-eco-lockfiles-B2X3yhyo.js +0 -1
- package/dist/packem_shared/packument-zb18Jnlw.js +0 -1
- package/dist/packem_shared/registry-keys-DxdqMzyp.js +0 -1
- package/dist/packem_shared/s1ngularity-CO5GkkqX.js +0 -1
- package/dist/packem_shared/scan-progress-RwCRxJdX.js +0 -2
- package/dist/packem_shared/spinner-BJjbNl1F.js +0 -1
- package/dist/packem_shared/tabs--uxJGL8N.js +0 -1
- package/dist/packem_shared/typosquats-D4DEHhFy.js +0 -1
- package/dist/packem_shared/use-measured-height-DUZyyias.js +0 -1
- package/dist/packem_shared/vis-update-app-9b2kSk9f.js +0 -1
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import{createRequire as ss}from"node:module";import{readLastRunSummary as is,getLastRunSummaryPath as os,runConcurrently as $e,TerminalBuffer as We,CompositeLifeCycle as jt,defaultTaskRunner as St,resolveTurboEnvCompat as cs,pickChildParentEnv as as,generateRunSummary as kt,writeChromeTrace as ls,expandAffected as ds,getChangedFiles as us,enforceProjectConstraints as fs,buildEnhancedPath as hs,createLogReporter as ps,writeRunSummary as ms,reverseTaskGraph as gs,splitCompoundTasks as ws,createTaskGraph as vs,expandTokensInString as bt,parsePartition as ys,TaskScheduler as xs}from"@visulima/task-runner";import{r as V,j as c,X as v,O as u,R as X,o as js,d as Ss,b as ks}from"../packem_shared/registry-CkoaWkjP.js";import{r as bs}from"../packem_shared/command-runtime-HSsYGCQd.js";import{d as Ce,S as Ts}from"../packem_shared/env-BSXG3QKH.js";import{f as $s,d as Cs,e as Is,H as Es,i as Rs,r as Ps,s as Ms,a as Fs,b as Os,c as As}from"../packem_shared/lifecycle-CQjeMPY0.js";import{z as Ls,e as ne,m as Tt,$ as Ds,a as Bs}from"../packem_shared/index-BzhrR_iC.js";import{a as $t,d as Ct,r as He,s as _s,m as Ns,l as Gs}from"../packem_shared/target-options-DsHFmRZH.js";import{g as je,r as ke,b as Ws,e as Hs,A as qs,T as Vs,d as Us}from"../packem_shared/task-env-C2lmxvzA.js";import{f as zs}from"../packem_shared/removeSync-g1D5kONg-LbjATA8v.js";import{K as It,M as Ys,J as Ks,C as Je,N as Xs,Q as Js,q as Qs,P as Zs,Z as er,h as tr,aj as sr,ak as rr,al as nr,am as ir}from"./cli-main.js";import{O as ce}from"../packem_shared/renderToString-DR0zDUjh-C7p-L6AO.js";import{T as Et,C as Rt,D as Fe,E as Pt}from"../packem_shared/symbols-BXDZ_sKt.js";import{q as mr,j as gr,X as Ae,F as et}from"../packem_shared/index.server-Ca_EEVfw.js";import{parseStacktrace as wr,codeFrame as vr}from"@visulima/error";import{originalPositionFor as yr,sourceContentFor as xr,loadSourceMap as jr}from"@visulima/source-map";import{l as Mt}from"../packem_shared/spinner-Bqjpz3i4.js";import{i as Se}from"../packem_shared/index-BjdW45xX.js";import{d as kr,r as br}from"../packem_shared/lockfile-CiUtEbnt.js";import{y as Ft}from"../packem_shared/index-BisalDCf.js";import{r as Cr}from"../packem_shared/toolchain-CP79HNVy.js";import{F as Ir}from"../packem_shared/failure-log-DIsKBKaI.js";import{V as pe}from"../packem_shared/vis-user-error-D_ekz9rF.js";import{s as Er}from"../packem_shared/affected-selection-QaMUnFqe.js";import{c as Ot,s as Rr,p as Pr,a as Mr,b as Fr,r as Or,f as Ar}from"../packem_shared/project-name-filter-mwTJC1IK.js";import{r as Lr,f as Dr,a as Br,p as _r}from"../packem_shared/selectors-edwcgNl3.js";import Be from"./index.js";import{U as At}from"../packem_shared/writeFileSync-DJoHk3Ks-BPRoepNw.js";import{c as tt,a as qr,s as st}from"../packem_shared/watch-CcTketln.js";let rs;const ns=t=>(rs??=ss(import.meta.url))(t),ye=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,fe=t=>{if(typeof ye<"u"&&ye.versions&&ye.versions.node){const[e,s]=ye.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return ye.getBuiltinModule(t)}return ns(t)},{existsSync:he,readFileSync:we,mkdirSync:or,writeFileSync:qe,openSync:cr,statSync:Qe,readSync:ar,closeSync:lr,mkdtempSync:dr}=fe("node:fs"),{isAbsolute:ur,resolve:Ze,dirname:fr,relative:hr}=fe("node:path"),{fileURLToPath:pr}=fe("node:url"),{createHash:Sr}=fe("node:crypto"),{createInterface:Tr,emitKeypressEvents:$r}=fe("node:readline"),{mkdir:Nr,appendFile:Oe}=fe("node:fs/promises"),{platform:Gr,homedir:Ve,tmpdir:Wr}=fe("node:os"),{spawn:Hr}=fe("node:child_process"),Vr=(t,e,s,r,i,o,n,l,d,h,f,p,a,m)=>{const w={d:r,h:i,m:o,mo:e,ms:l,s:n,w:s,y:t};return w.future=d,w.past=h,w.decimal=f,p!==void 0&&(w.unitMap=p),w.groupSeparator=a,w.placeholderSeparator=m,w},Ur={d:"d",day:"d",days:"d",h:"h",hour:"h",hours:"h",hr:"h",hrs:"h",m:"m",millisecond:"ms",milliseconds:"ms",min:"m",mins:"m",minute:"m",minutes:"m",mo:"mo",month:"mo",months:"mo",ms:"ms",s:"s",sec:"s",second:"s",seconds:"s",secs:"s",w:"w",week:"w",weeks:"w",y:"y",year:"y",years:"y",yr:"y",yrs:"y"},zr=Vr(t=>`year${t===1?"":"s"}`,t=>`month${t===1?"":"s"}`,t=>`week${t===1?"":"s"}`,t=>`day${t===1?"":"s"}`,t=>`hour${t===1?"":"s"}`,t=>`minute${t===1?"":"s"}`,t=>`second${t===1?"":"s"}`,t=>`millisecond${t===1?"":"s"}`,"in %s","%s ago",".",Ur,",","_"),rt=new WeakSet,Yr=t=>{if(rt.has(t))return;const e=["y","mo","w","d","h","m","s","ms"];for(const r of e)if(!Object.hasOwn(t,r))throw new TypeError(`Missing required property: ${r}`);if(t.future!==void 0&&typeof t.future!="string")throw new TypeError("Properties future and past must be of type string");if(t.past!==void 0&&typeof t.past!="string")throw new TypeError("Properties future and past must be of type string");const s=["y","mo","w","d","h","m","s","ms"];for(const r of s)if(typeof t[r]!="string"&&typeof t[r]!="function")throw new TypeError(`Property ${r} must be of type string or function`);if(t.decimal&&typeof t.decimal!="string")throw new TypeError("Property decimal must be of type string");if(t.delimiter&&typeof t.delimiter!="string")throw new TypeError("Property delimiter must be of type string");if(t._digitReplacements&&!Array.isArray(t._digitReplacements))throw new TypeError("Property _digitReplacements must be an array");if(t._numberFirst&&typeof t._numberFirst!="boolean")throw new TypeError("Property _numberFirst must be of type boolean");if(t.unitMap&&typeof t.unitMap!="object")throw new TypeError("Property unitMap must be an object");if(t.unitMap&&Object.values(t.unitMap).some(r=>typeof r!="string"))throw new TypeError("All values in unitMap must be of type string");rt.add(t)},Lt=(t,e)=>{if(!Number.isFinite(t)||e<0||Number.isInteger(t))return t;const s=10**e,r=Number((t*s).toPrecision(15));return Math.trunc(r)/s},nt=({unitCount:t,unitName:e},s,r)=>{let{spacer:i}=r;const{maxDecimalPoints:o}=r;let n=".";r.decimal!==void 0?n=r.decimal:s.decimal!==void 0&&(n=s.decimal);let l;"digitReplacements"in r?l=r.digitReplacements:"_digitReplacements"in s&&(l=s._digitReplacements);let d,h=t;o!==void 0&&(h=Lt(t,o));const f=h.toString();if(!s._hideCountIf2||t!==2)if(l){d="";for(const m of f)d+=m==="."?n:l[m]}else d=f.replace(".",n);else d="";const p=s[e];let a=p;return typeof p=="function"&&(a=p(t)),s._hideCountIf2&&t===2&&(i=""),s._numberFirst?a+i+d:d+i+a},Kr=(t,e)=>{const{units:s}=e;if(s.length===0)return[];const{unitMeasures:r}=e,i=e.largest??Number.POSITIVE_INFINITY,o={};let n,l,d,h=t;for(l=0;l<s.length;l++){n=s[l];const p=r[n];d=l===s.length-1?h/p:Math.floor(h/p),o[n]=d,h-=d*p}if(e.round){let p=i;for(l=0;l<s.length;l++)if(n=s[l],d=o[n],d!==0&&(p--,p===0)){for(let a=l+1;a<s.length;a++){const m=s[a],w=o[m];o[n]=(o[n]??0)+w*r[m]/r[n],o[m]=0}break}for(l=s.length-1;l>=0;l--){if(n=s[l],d=o[n],d===0)continue;const a=Math.round(d);if(o[n]=a,l===0)break;const m=s[l-1],w=r[m],j=Math.floor(a*r[n]/w);if(j)o[m]=(o[m]??0)+j,o[n]=0;else break}}const f=[];for(l=0;l<s.length&&f.length<i;l++){if(n=s[l],d=o[n],d&&!e.round&&f.length===i-1){let p,a=0;for(p=l+1,s.length;p<s.length;p++){const m=s[p];a+=o[m]*(e.unitMeasures[m]/e.unitMeasures[n])}d+=a,e.maxDecimalPoints!==void 0&&(d=Lt(d,e.maxDecimalPoints))}d&&f.push({unitCount:d,unitName:n})}return f},Xr=(t,e,s)=>{const{language:r,units:i}=e;if(t.length===0){const p=i.at(-1);return nt({unitCount:0,unitName:p},r,e)}const{conjunction:o,serialComma:n}=e;let l=", ";e.delimiter!==void 0?l=e.delimiter:r.delimiter!==void 0&&(l=r.delimiter);let d="";e.timeAdverb&&s!==0&&(d=r.future??"",s<0&&(d=r.past??""));const h=t.map(p=>nt(p,r,e));let f;return!o||t.length===1?f=h.join(l):t.length===2?f=h.join(o):f=h.slice(0,-1).join(l)+(n?",":"")+o+(h.at(-1)??""),d&&(f=d.replace("%s",f)),f},Jr=(t,e)=>{if(Number.isNaN(t))throw new TypeError("Expected a valid number");if(typeof t!="number")throw new TypeError("Expected a number for milliseconds input");const s={conjunction:"",language:zr,round:!1,serialComma:!0,spacer:" ",timeAdverb:!1,unitMeasures:{d:864e5,h:36e5,m:6e4,mo:2629746e3,ms:1,s:1e3,w:6048e5,y:31556952e3},units:["w","d","h","m","s"],...e};Yr(s.language);const r=Math.abs(t),i=Kr(r,s);return Xr(i,s,t)},Ie=256*1024;class Qr{#e;#r="";#s=!1;constructor(e){this.#e=e}append(e){this.#r+=e,this.#r.length>this.#e&&(this.#r=this.#r.slice(-this.#e),this.#s=!0)}toString(){return this.#s?`[...output truncated, showing last ${Math.round(this.#e/1024)}KB...]
|
|
2
|
+
${this.#r}`:this.#r}}const Zr=t=>{if(!t||t.trim().length===0)return;const e=Number.parseFloat(t);return!Number.isFinite(e)||e<=0?{invalid:t}:{value:Math.floor(e)}},en=async(t,e)=>{const s=await is(t,{dataDirectory:Ce(t)});if(!s){e.warn(`No previous run recorded yet. Run a task at least once to populate ${os(t,{dataDirectory:Ce(t)})}.`);return}const r=(s.duration/1e3).toFixed(2);if(e.info(""),e.info(`Last run — ${s.startTime} (${r}s)`),e.info(""),e.info(` Total: ${String(s.stats.total)}`),e.info(` Succeeded: ${String(s.stats.succeeded)}`),e.info(` Cached: ${String(s.stats.cached)}`),e.info(` Failed: ${String(s.stats.failed)}`),e.info(` Skipped: ${String(s.stats.skipped)}`),e.info(""),s.stats.failed>0){const o=s.tasks.filter(n=>n.exitCode!==void 0&&n.exitCode!==0);e.info("Failed tasks:");for(const n of o){const l=n.duration??0;e.info(` × ${n.taskId} (exit ${String(n.exitCode??-1)}, ${l}ms)`)}e.info("")}const i=[...s.tasks].filter(o=>typeof o.duration=="number").sort((o,n)=>(n.duration??0)-(o.duration??0)).slice(0,5);if(i.length>0){e.info("Slowest tasks:");for(const o of i)e.info(` ${o.taskId.padEnd(40)} ${String(o.duration??0).padStart(6)}ms [${o.cacheStatus}]`);e.info("")}},tn=t=>{if(!(t===void 0||t==="")){if(t!=="read"&&t!=="write"&&t!=="readwrite")throw new Error(`--cache-mode must be one of: read, write, readwrite (received "${t}")`);return t}},sn=t=>{if(!(t===void 0||t==="")){if(t!=="http"&&t!=="reapi")throw new Error(`--cache-backend must be one of: http, reapi (received "${t}")`);return t}},rn=t=>{if(!(t===void 0||t==="")){if(t!=="declared"&&t!=="trace")throw new Error(`--hash-mode must be one of: declared, trace (received "${t}")`);return t}},nn=({interactive:t,taskPty:e,workspacePty:s})=>e===!0?!0:e===!1?!1:t&&s!==!1,on=t=>`'${t.replaceAll("'",String.raw`'\''`)}'`,Ue=t=>process.platform==="win32"?t.length>0&&!/[\s"&|<>^()%!]/.test(t)?t:`"${t.replaceAll('"','""')}"`:on(t),cn=(t,e,s)=>{if(!e||e.length===0||s===!1||s===void 0)return t;if(s==="args"||s==="both"){const r=e.map(i=>Ue(i)).join(" ");return`${t} ${r}`}return t},Dt="visForwardedArgs",an=(t,e)=>{const s=e.overrides[Dt];if(!Array.isArray(s)||s.length===0)return t;const r=s.map(i=>Ue(i)).join(" ");return`${t} ${r}`},ze=(t,e,s)=>{const r=t.overrides.command;if(!r)return;const i=je(t),o=t.segment!==void 0&&t.segment.index<t.segment.count,n=o?r:an(r,t),l=o?n:cn(n,e,i?.affectedFiles),d=$t(i,s),h=i?.shellArgs,f=h&&h.length>0?h.join(" "):"-c";return d?`${d} ${f} ${Ue(l)}`:l},ln=2e3,Bt=async(t,e,s)=>{const{workspaceRoot:r}=e,i=t.map(g=>{const k=ze(g,e.affectedFiles,Ct());if(!k)return;const P=g.overrides.visOptions,C=He(r,g.projectRoot,!!P?.runFromWorkspaceRoot),y=nn({interactive:!!s,taskPty:g.pty,workspacePty:P?.pty}),E=ke(e,g);return{command:k,cwd:C,env:E.env,inheritEnv:E.inheritEnv,name:g.id,...y?{ptySize:{cols:process.stdout.columns??80,rows:process.stdout.rows??24},stdin:"pty"}:{}}}).filter(g=>g!==void 0);if(i.length===0)return;if(!s){await $e(i,{killOthers:["failure"],onEvent:()=>{}});return}const{abortSignal:o,lifeCycle:n,stdinRegistry:l,store:d}=s,h=i.map(g=>t.find(k=>k.id===g.name)).filter(Boolean),f=g=>i[g]?.stdin==="pty",p=new Map,a=g=>{if(!f(g))return;let k=p.get(g);return k||(k=new We(Ie),p.set(g,k)),k};d.unmarkDone(),n.startTasks?.(h);const m=new Map,w=new Map;let j;const M=()=>{for(const g of w.values())try{g("SIGTERM")}catch{}j||(j=setTimeout(()=>{for(const g of w.values())try{g("SIGKILL")}catch{}w.clear()},2e3),j.unref?.())};let x;o&&(x=()=>{M()},o.then(()=>{x?.()}).catch(()=>{x?.()}));try{await $e(i,{killOthers:["failure"],onEvent:g=>{const k=h[g.index];if(k)switch(g.kind){case"close":{const P=m.get(k.id)??Date.now(),C=g.killed||g.exitCode===0?"success":"failure";n.endTasks?.([{code:g.exitCode??0,endTime:Date.now(),startTime:P,status:C,task:k,terminalOutput:d.getSnapshot().outputs.get(k.id)??""}]),w.delete(g.index),l?.delete(k.id);break}case"error":{if(g.message){const P=a(g.index);P?(P.write(`${g.message}
|
|
3
|
+
`),d.setOutput(k.id,P.toString())):d.addOutput(k.id,`${g.message}
|
|
4
|
+
`)}break}case"started":{m.set(k.id,Date.now()),g.kill&&w.set(g.index,g.kill),g.write&&l&&l.set(k.id,{kill:g.kill,resize:g.resize,write:g.write});break}case"stderr":case"stdout":{if(g.text){const P=a(g.index);P?(P.write(g.text),d.setOutput(k.id,P.toString())):d.addOutput(k.id,`${g.text}
|
|
5
|
+
`)}break}default:}}})}finally{j&&(clearTimeout(j),j=void 0),d.markDone()}},it=t=>{try{return process.kill(-t,0),!0}catch{try{return process.kill(t,0),!0}catch{return!1}}},dn=t=>{Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,t)},un=t=>{const{extraPids:e=[],pidFiles:s,runDir:r}=t,i=[],o=n=>{try{process.kill(-n,"SIGTERM")}catch{try{process.kill(n,"SIGTERM")}catch{}}};for(const n of s){let l;try{const d=Ls(n),h=Number.parseInt(d.trim(),10);l=Number.isFinite(h)&&h>0?h:void 0}catch{continue}l!==void 0&&(i.push(l),o(l))}for(const n of e)!Number.isFinite(n)||n<=0||(i.push(n),o(n));if(i.length>0){const d=Date.now()+1500;for(;Date.now()<d;){let h=!0;for(const f of i)if(it(f)){h=!1;break}if(h)break;dn(100)}for(const h of i)if(it(h))try{process.kill(-h,"SIGKILL")}catch{try{process.kill(h,"SIGKILL")}catch{}}}r&&zs(r)},fn=({ephemeralPidFiles:t,registryStartedIds:e,registryStartedPids:s,serviceEventBridge:r,serviceRunDir:i,stopServicesOnExit:o,workspaceRoot:n})=>{let l=!1;const d=()=>{if(l)return;l=!0,r&&r.dispose().catch(()=>{});const p=o?[...s.values()]:void 0;un({extraPids:p,pidFiles:t,runDir:i})},h=()=>{d()},f=t.length>0||i!==void 0||o&&e.length>0;return{finish:async()=>{d(),f&&(process.off("SIGINT",h),process.off("SIGTERM",h)),o&&e.length>0&&await Promise.all(e.map(async p=>{try{await $s(n,p)}catch{}}))},install:()=>{f&&(process.on("SIGINT",h),process.on("SIGTERM",h))}}},hn=({config:t,logger:e,persistentTasks:s,taskGraph:r})=>{const i=Object.keys(r.tasks).length,o=r.roots.length;e.info(`Execution plan (${String(i)} task(s), ${String(o)} root(s)):`),e.info("");const n=new Set,l=(d,h)=>{if(n.has(d))return;n.add(d);for(const j of r.dependencies[d]??[])l(j,h+1);const f=r.tasks[d],p=" ".repeat(h+1),a=f?.segment?` (segment ${String(f.segment.index)}/${String(f.segment.count)}: ${String(f.overrides.command)})`:"",m=f?.hashMode==="trace"||t.taskRunner?.autoFingerprint===!0,w=`${f?.cache===!1?" (no-cache)":""}${m?" (trace)":""}${a}`;e.info(`${p}${d}${w}`)};for(const d of r.roots)l(d,0);for(const d of Object.keys(r.tasks))l(d,0);s.length>0&&(e.info(""),e.info(` + ${String(s.length)} persistent task(s) (run after graph completes)`)),e.info("")},pn=(t,e)=>{if(t===e)return!0;if(!t||!e||t.length!==e.length)return!1;for(const[s,r]of t.entries())if(!Object.is(r,e[s]))return!1;return!0},ot=({children:t,deps:e,onRender:s,style:r,width:i})=>{const o=V.useRef(null),n=V.useRef(!1),l=V.useRef(e),d=V.useRef(t),h=V.useRef(s);h.current=s;let f=!1;e!==void 0?pn(l.current,e)||(f=!0,l.current=e):t!==d.current&&(f=!0,d.current=t),f&&(n.current=!1,o.current&&(o.current.cachedRender=void 0)),V.useLayoutEffect(()=>{const a=o.current;a&&(a.internal_onRendered=()=>{n.current=!0,h.current?.(a)})}),V.useEffect(()=>()=>{const a=o.current;a&&(a.cachedRender=void 0,a.internal_onRendered=void 0)},[]);const p=V.useMemo(()=>({...r,width:i}),[r,i]);return c.jsx("ink-static-render",{ref:o,style:p,children:n.current?null:t()})},mn=t=>Array.isArray(t)?`[${t.join(",")}]`:typeof t=="object"&&t!==null?JSON.stringify(t):String(t),gn=(t,e,s)=>e==="_"?`${t}${Array.isArray(s)?s.join(" "):String(s)}`:`${t}--${e}=${mn(s)}`,Ye=(t,e,s)=>{const r=new Set(new Set(s.map(a=>a.target.target))),i=new Set(new Set(s.map(a=>a.target.project))),o=e.filter(a=>r.has(a)),n=t.filter(a=>i.has(a)),l=s.length-n.length*o.length,d=o.length===1?"target":"targets",h=o.join(", "),f=n.length===1?`project ${n[0]}`:`${n.length} projects`;let p=`${d} ${h} for ${f}`;return l>0&&(p+=` and ${l} ${l===1?"task":"tasks"} ${l===1?"it depends":"they depend"} on`),p},wn={error:"red",info:"white",success:"green"},_e=({children:t,title:e,variant:s})=>{const r=wn[s];return c.jsxs(v,{flexDirection:"column",children:[c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,inverse:!0,children:" VIS "}),c.jsx(u,{bold:!0,color:r,children:"•"}),c.jsx(u,{children:e})]}),t]})},_t=({cached:t,failed:e,failedIds:s,projectNames:r,retriedIds:i,skippedIds:o,succeeded:n,targets:l,tasks:d,took:h})=>{const f=Ye(r,l,d),p=i??[];if(e===0&&(!o||o.length===0)){const a=t>0?` (${t} read from cache)`:"";return c.jsx(ot,{children:()=>c.jsx(_e,{title:`Successfully ran ${f}`,variant:"success",children:c.jsxs(v,{flexDirection:"column",marginTop:1,paddingLeft:3,children:[c.jsxs(u,{children:[c.jsx(u,{color:"green",children:Et})," ",n+t," tasks completed",a?c.jsx(u,{dimColor:!0,children:a}):null,c.jsx(u,{dimColor:!0,children:` · Took ${h}`})]}),p.length>0&&c.jsxs(v,{flexDirection:"column",marginTop:1,children:[c.jsxs(u,{children:[c.jsx(u,{color:"yellow",children:"↻"})," ",c.jsx(u,{color:"yellow",children:String(p.length)})," task",p.length===1?"":"s"," succeeded after retry:"]}),p.map(m=>c.jsxs(u,{children:[" ",c.jsx(u,{color:"yellow",children:"↻"})," ",m]},m))]})]})})})}return c.jsx(ot,{children:()=>c.jsx(_e,{title:`Ran ${f}`,variant:"error",children:c.jsxs(v,{flexDirection:"column",marginTop:1,paddingLeft:3,children:[o&&o.length>0&&c.jsxs(v,{flexDirection:"column",children:[c.jsxs(u,{dimColor:!0,children:[o.length," ","task",o.length===1?"":"s"," ","skipped (dependency failed or --bail)"]}),o.map(a=>c.jsxs(u,{dimColor:!0,children:[" - ",a]},a)),c.jsx(u,{})]}),e>0&&c.jsxs(v,{flexDirection:"column",children:[c.jsxs(u,{children:[c.jsx(u,{color:"red",children:String(e)})," ","task",e===1?"":"s"," ","failed:"]}),s.map(a=>c.jsxs(u,{children:[" ",c.jsx(u,{color:"red",children:Rt})," ",a]},a)),c.jsx(u,{})]}),p.length>0&&c.jsxs(v,{flexDirection:"column",children:[c.jsxs(u,{children:[c.jsx(u,{color:"yellow",children:String(p.length)})," ","task",p.length===1?"":"s"," ","finished after retry:"]}),p.map(a=>c.jsxs(u,{children:[" ",c.jsx(u,{color:"yellow",children:"↻"})," ",a]},a)),c.jsx(u,{})]}),c.jsx(u,{dimColor:!0,children:` Took ${h}`})]})})})};class Ee{#e;#r=new Set;#s=new Map;constructor(e,s){this.#e={autoExitCountdown:null,cached:0,completed:0,done:!1,endTime:null,failed:0,filterActive:!1,filterText:"",focusedPanel:"tasks",interactiveMode:!1,outputs:new Map,pinnedTaskIds:[null,null],rerunRequested:!1,retriedIds:[],retryTaskId:null,rows:e.map(r=>({persistent:!!r.overrides.visOptions?.persistent,status:"pending",taskId:r.id})),running:0,selectedIndex:0,startTime:Date.now(),statusFilter:"all",succeeded:0,totalTasks:s??e.length,viewMode:"list"}}getSnapshot=()=>this.#e;subscribe=e=>(this.#r.add(e),()=>{this.#r.delete(e)});startTasks(e){const s=[...this.#e.rows];for(const r of e){const i=s.findIndex(o=>o.taskId===r.id);i!==-1&&(s[i]={...s[i],elapsed:0,status:"running"},this.#s.set(r.id,process.hrtime()))}this.#t({...this.#e,rows:s,running:this.#e.running+e.length})}endTasks(e){const s=[...this.#e.rows];let{cached:r,completed:i,failed:o,succeeded:n}=this.#e;const l=new Map(this.#e.outputs),d=[...this.#e.retriedIds];for(const p of e){const a=s.findIndex(m=>m.taskId===p.task.id);switch(a!==-1&&(s[a]={...s[a],duration:p.startTime&&p.endTime?p.endTime-p.startTime:void 0,retryAttempts:p.retryAttempts,status:p.status}),p.retryAttempts&&p.retryAttempts>0&&d.push(p.task.id),i++,p.status){case"failure":{o++;break}case"local-cache":case"local-cache-kept-existing":case"remote-cache":{r++;break}case"success":{n++;break}}p.terminalOutput&&!l.has(p.task.id)&&l.set(p.task.id,p.terminalOutput),this.#s.delete(p.task.id)}let{selectedIndex:h}=this.#e;if(o>this.#e.failed){const p=s.findIndex(a=>a.status==="failure");p!==-1&&(h=p)}const f=Math.max(0,this.#e.running-e.length);this.#t({...this.#e,cached:r,completed:i,failed:o,outputs:l,retriedIds:d,rows:s,running:f,selectedIndex:h,succeeded:n})}static#n=256*1024;addOutput(e,s){if(!s.trim())return;let r=(this.#e.outputs.get(e)??"")+s;r.length>Ee.#n&&(r=r.slice(-Ee.#n)),this.#e.outputs.set(e,r),this.#t({...this.#e})}setOutput(e,s){this.#e.outputs.set(e,s),this.#t({...this.#e})}markDone(){this.#t({...this.#e,done:!0,endTime:Date.now()})}unmarkDone(){this.#t({...this.#e,autoExitCountdown:null,done:!1,endTime:null})}tick(){if(this.#s.size===0)return;let e=!1;const s=[...this.#e.rows];for(let r=0;r<s.length;r++){const i=s[r];if(i.status==="running"){const o=this.#s.get(i.taskId);if(o){const n=process.hrtime(o),l=n[0]*1e3+n[1]/1e6;s[r]={...i,elapsed:l},e=!0}}}e&&this.#t({...this.#e,rows:s})}setSelectedIndex(e){e!==this.#e.selectedIndex&&this.#t({...this.#e,selectedIndex:e})}setFocusedPanel(e){e!==this.#e.focusedPanel&&this.#t({...this.#e,focusedPanel:e})}setFilter(e){this.#t({...this.#e,filterText:e,selectedIndex:0})}setFilterActive(e){e!==this.#e.filterActive&&this.#t({...this.#e,filterActive:e,filterText:e?this.#e.filterText:"",selectedIndex:0})}pinTask(e,s){const r=[...this.#e.pinnedTaskIds];r[e]=s,this.#t({...this.#e,pinnedTaskIds:r})}clearPins(){this.#t({...this.#e,pinnedTaskIds:[null,null]})}requestRetry(e){const s=[...this.#e.rows],r=s.findIndex(l=>l.taskId===e);let{completed:i,failed:o,succeeded:n}=this.#e;if(r!==-1){const l=s[r].status;l==="failure"?(o=Math.max(0,o-1),i=Math.max(0,i-1)):l==="success"&&(n=Math.max(0,n-1),i=Math.max(0,i-1)),s[r]={...s[r],elapsed:0,retryAttempts:void 0,status:"running"},this.#s.set(e,process.hrtime())}this.#t({...this.#e,completed:i,done:!1,endTime:null,failed:o,interactiveMode:!1,retriedIds:this.#e.retriedIds.filter(l=>l!==e),retryTaskId:e,rows:s,succeeded:n})}acknowledgeRetry(){const e=this.#e.retryTaskId;return e&&this.#t({...this.#e,retryTaskId:null}),e}setInteractiveMode(e){e!==this.#e.interactiveMode&&this.#t({...this.#e,interactiveMode:e})}setViewMode(e){e!==this.#e.viewMode&&this.#t({...this.#e,viewMode:e})}setStatusFilter(e){this.#t({...this.#e,selectedIndex:0,statusFilter:e})}requestRerun(){this.#s.clear(),this.#t({...this.#e,autoExitCountdown:null,cached:0,completed:0,done:!1,endTime:null,failed:0,interactiveMode:!1,outputs:new Map,rerunRequested:!0,retriedIds:[],rows:this.#e.rows.map(e=>({persistent:e.persistent,status:"pending",taskId:e.taskId})),running:0,startTime:Date.now(),succeeded:0,viewMode:"list"})}acknowledgeRerun(){this.#e.rerunRequested&&this.#t({...this.#e,rerunRequested:!1})}#t(e){this.#e=e;for(const s of this.#r)try{s()}catch{}}}const vn=27,yn={95:"apc",80:"dcs",94:"pm",88:"sos"},xn={159:"apc",144:"dcs",158:"pm",152:"sos"},Nt=t=>t===155||t===157||t===144||t===152||t===158||t===159,Gt=(t,e)=>{for(let s=e;s<t.length;s+=1){const r=t.codePointAt(s);if(r>=64&&r<=126)return s}return-1},Re=(t,e,s)=>{for(let r=e;r<t.length;r+=1){const i=t.codePointAt(r);if(i===156||s&&i===7)return r;if(i===27&&t.codePointAt(r+1)===92)return r+1}return-1},jn=(t,e)=>{const s=t.codePointAt(e+1);if(s===91){const r=Gt(t,e+2);return r===-1?void 0:{end:r,kind:"csi"}}if(s===93){const r=Re(t,e+2,!0);return r===-1?void 0:{end:r,kind:"osc"}}if(s===80||s===88||s===94||s===95){const r=Re(t,e+2,!1),i=yn[s];return r===-1?void 0:{end:r,kind:i}}return s===void 0?void 0:{end:e+1,kind:"escape"}},Sn=(t,e)=>{const s=t.codePointAt(e);if(s===155){const r=Gt(t,e+1);return r===-1?void 0:{end:r,kind:"csi"}}if(s===157){const r=Re(t,e+1,!0);return r===-1?void 0:{end:r,kind:"osc"}}if(s===144||s===152||s===158||s===159){const r=Re(t,e+1,!1),i=xn[s];return r===-1?void 0:{end:r,kind:i}}},kn=t=>{if(t.includes(String.fromCodePoint(27)))return!0;for(let e=0;e<t.length;e+=1)if(Nt(t.codePointAt(e)))return!0;return!1},bn=t=>{if(!kn(t))return t;let e="",s=0,r=0;const{length:i}=t;for(;r<i;){const o=t.codePointAt(r);let n;if(o===vn)n=jn(t,r);else if(Nt(o))n=Sn(t,r);else{r+=1;continue}const l=n===void 0?i-1:n.end;e+=t.slice(s,r),s=l+1,r=l+1}return e+=t.slice(s),e},Tn=t=>bn(t),$n=/^(?<name>(?:[A-Z][\w$]*)?(?:Error|Exception))(?::[ \t](?<message>.*))?$/,Cn=/^\s*at\s+/,In=t=>{const e=t.split(`
|
|
6
|
+
`);let s;for(let r=0;r<e.length;r++){const i=$n.exec(e[r].trim());if(!i)continue;const o=[];for(let n=r+1;n<e.length&&n<=r+200;n++){const l=e[n];if(Cn.test(l))o.push(l.trim());else{if(o.length>0)break;if(l.trim()!=="")break}}if(o.length>0){const n=i.groups?.name??"Error",l=i.groups?.message??"";s={message:l,name:n,stack:`${n}: ${l}
|
|
7
|
+
${o.map(d=>` ${d}`).join(`
|
|
8
|
+
`)}`}}}return s},Wt=t=>{if(t.startsWith("file://"))try{return pr(t)}catch{return t}return t},En=t=>!t.includes("node_modules")&&!t.startsWith("node:")&&!t.startsWith("internal/"),Rn=t=>{try{return jr(t)}catch{return}},Pn=(t,e)=>{if(!t.file||t.line===void 0)return;const s=Wt(t.file),r=ur(s)?s:Ze(e,s);if(!En(r)||!he(r))return;const i=Rn(r);if(i){const o=yr(i,{column:t.column===void 0?0:Math.max(0,t.column-1),line:t.line});if(o.source&&o.line!=null){const n=Ze(fr(r),o.source),d=xr(i,o.source)??(he(n)?we(n,"utf8"):void 0);if(d!==void 0)return{column:o.column==null?void 0:o.column+1,file:n,line:o.line,source:d}}}return{column:t.column,file:r,line:t.line,source:we(r,"utf8")}},ct=(t,e)=>{const s=hr(e,t);return s&&!s.startsWith("..")?s:t},Ht=(t,e)=>{if(!t?.trim())return t;try{const s=In(Tn(t));if(!s)return t;const r=new Error(s.message);r.name=s.name,r.stack=s.stack;const i=wr(r);if(i.length===0)return t;const o=e.color,n={dim:a=>o?et(a):a,head:a=>o?gr(Ae(a)):a,loc:a=>o?mr(a):a};let l,d;for(const a of i){const m=Pn(a,e.cwd);if(m){l=m,d=a;break}}const h=[n.head(`✖ ${s.name}${s.message?`: ${s.message}`:""}`)];if(l){const a=`${ct(l.file,e.cwd)}:${l.line}${l.column?`:${l.column}`:""}`;h.push(` ${n.loc(a)}`,""),h.push(vr(l.source,{start:{column:l.column,line:l.line}},{color:o?{gutter:et,marker:Ae,message:Ae}:void 0,linesAbove:2,linesBelow:3}))}const f=i.filter(a=>a!==d).slice(0,8).map(a=>{const m=a.methodName??"<anonymous>",w=a.file?`${ct(Wt(a.file),e.cwd)}${a.line?`:${a.line}`:""}`:"";return n.dim(` at ${m}${w?` (${w})`:""}`)});f.length>0&&h.push("",...f);const p=n.dim("─".repeat(40));return`${h.join(`
|
|
9
|
+
`)}
|
|
10
|
+
${p}
|
|
11
|
+
${t}`}catch{return t}},Mn={delimiter:" ",language:{d:()=>" d",future:"in %s",h:()=>" h",m:()=>" m",mo:()=>" mo",ms:()=>" ms",past:"%s ago",s:()=>" s",w:()=>" w",y:()=>" y"},largest:2,round:!0,spacer:"",units:["h","m","s","ms"]},me=t=>Jr(t,Mn),ge=t=>t==="local-cache"||t==="local-cache-kept-existing"||t==="remote-cache",ve=t=>{switch(t){case"failure":return{color:"red",icon:Rt};case"local-cache":case"local-cache-kept-existing":case"remote-cache":case"success":return{color:"green",icon:Et};case"skipped":return{color:"gray",icon:Fe};default:return{color:"gray",icon:"?"}}},xe=t=>{const{color:e,icon:s}=ve(t);return ce(X.createElement(u,{color:e},s),{columns:10}).trim()},Fn=t=>{const{color:e,icon:s}=ve(t);switch(t){case"local-cache":case"local-cache-kept-existing":case"remote-cache":return ce(X.createElement(u,null,X.createElement(u,{color:e},s)," ",X.createElement(u,{color:"cyan"},"[cache]")),{columns:30}).trim();case"skipped":return ce(X.createElement(u,null,X.createElement(u,{dimColor:!0},s)," ",X.createElement(u,{dimColor:!0},"[skipped]")),{columns:30}).trim();default:return ce(X.createElement(u,{color:e},s),{columns:10}).trim()}},On=t=>t==="azure"||t==="buildkite"||t==="github"||t==="gitlab"||t==="off"?t:process.env.GITHUB_ACTIONS==="true"?"github":process.env.GITLAB_CI==="true"?"gitlab":process.env.BUILDKITE==="true"?"buildkite":process.env.TF_BUILD?.toLowerCase()==="true"?"azure":"off",An=t=>{const e=t.replaceAll(/\W+/g,"_"),s=Sr("sha256").update(t).digest("hex").slice(0,6);return`${e}_${s}`},Ln=(t,e,s,r="auto")=>{const i=s.trim();if(!i)return;const o=`
|
|
12
|
+
`,n=On(r);if(n==="github"){process.stdout.write(`::group::${xe(e)} ${t}${o}`),process.stdout.write(i+o),process.stdout.write(`::endgroup::${o}`);return}if(n==="gitlab"){const p=Math.floor(Date.now()/1e3),a=An(t),m=e==="failure"?"":"[collapsed=true]",w="\x1B[0K";process.stdout.write(`${w}section_start:${String(p)}:${a}${m}\r${w}${xe(e)} ${t}${o}`),process.stdout.write(i+o);const j=Math.floor(Date.now()/1e3);process.stdout.write(`${w}section_end:${String(j)}:${a}\r${w}${o}`);return}if(n==="buildkite"){const p=e==="failure"?"+++":"---";process.stdout.write(`${p} ${xe(e)} ${t}${o}`),process.stdout.write(i+o);return}if(n==="azure"){process.stdout.write(`##[group]${xe(e)} ${t}${o}`),process.stdout.write(i+o),process.stdout.write(`##[endgroup]${o}`);return}const l=process.stdout.columns||80,d=ce(X.createElement(u,{dimColor:!0},Fe.repeat(l)),{columns:l}).trim(),h=Fn(e),f=ce(X.createElement(u,{bold:!0},t),{columns:l}).trim();process.stdout.write(`${d}${o}`),process.stdout.write(`${h} ${f}${o}`),process.stdout.write(i+o),process.stdout.write(`${d}${o}`)},Dn=t=>t==="running"?{color:"white",icon:"•"}:t==="pending"?{color:"gray",icon:"·"}:ve(t),Bn=({autoScroll:t,focused:e,interactiveMode:s,showFullscreenHint:r,statusValue:i,supportsInteractive:o,taskId:n})=>{if(!n)return;if(s)return"Esc cancel | Enter send";const l=t?"":" PAUSED (f resume)",d=o?" i INPUT":"";return e&&i==="running"&&r?`⏎ FULLSCREEN${d} f FOLLOW${l}`:e&&i==="running"?`f FOLLOW${d}${l}`:e&&r?`<enter> full screen${l}`:e?l||void 0:"<tab> or <enter> to focus"},at=({autoScroll:t=!0,duration:e,focused:s,interactiveMode:r,output:i,scrollRef:o,showFullscreenHint:n,status:l,supportsInteractive:d=!0,taskId:h})=>{const f=l??"pending",{icon:p}=Dn(f),a=s?"bold":"single",m=f==="failure"?"red":f==="success"||ge(f)?s?"green":"gray":f==="running"?s?"white":"cyan":s?"white":"gray",w=h?`${p} ${h}`:void 0,j=e===void 0?void 0:me(e),M=Bn({autoScroll:t,focused:s,interactiveMode:r??!1,showFullscreenHint:n??!1,statusValue:f,supportsInteractive:d,taskId:h});if(!h)return c.jsxs(v,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",paddingX:2,paddingY:1,children:[c.jsx(u,{dimColor:!0,children:"Select a task to view output"}),c.jsx(u,{dimColor:!0,children:"Press Enter or 1/2 to pin"})]});const x=[];if(i)for(const g of i.split(`
|
|
13
|
+
`))x.push(g.endsWith("\r")?g.slice(0,-1):g);return!i&&(f==="running"||f==="pending")?c.jsx(v,{borderBottomTitle:M,borderColor:m,borderStyle:a,borderTopRightTitle:j,borderTopTitle:w,flexDirection:"column",flexGrow:1,paddingX:2,paddingY:1,children:c.jsx(v,{alignItems:"center",flexGrow:1,justifyContent:"center",children:c.jsx(u,{dimColor:!0,children:"Waiting for task output…"})})}):c.jsxs(v,{borderBottomTitle:M,borderColor:r?"yellow":m,borderStyle:a,borderTopRightTitle:j,borderTopTitle:w,flexDirection:"column",flexGrow:1,children:[c.jsx(v,{flexGrow:1,flexShrink:1,paddingY:1,children:c.jsx(It,{flexGrow:1,followOutput:t,paddingX:2,ref:o,scrollbar:!0,scrollbarColor:"gray",scrollbarStyle:"block",children:c.jsx(u,{children:x.join(`
|
|
14
|
+
`)})})}),r&&c.jsx(v,{flexShrink:0,justifyContent:"center",paddingX:1,children:c.jsx(u,{bold:!0,color:"yellow",children:"INTERACTIVE | keystrokes forwarded to task | Esc to exit"})})]})},_n={crashed:"✖",failed:"✖",pending:"·",ready:"●",starting:"•"},qt=t=>t==="ready"?"green":t==="crashed"||t==="failed"?"red":t==="starting"?"cyan":"gray",Nn=({status:t})=>t==="starting"?c.jsx(u,{color:"cyan",children:c.jsx(Mt,{type:"dots"})}):c.jsx(u,{bold:!0,color:qt(t),children:_n[t]}),Gn=({active:t,focused:e,state:s})=>{const r=e&&t,i=r?">":" ",o=s.status==="ready"?s.port?`running, port ${String(s.port)}`:"running":s.status==="failed"||s.status==="crashed"?s.errorMessage??"exited":s.lastLine??"booting…";return c.jsxs(v,{flexDirection:"row",flexShrink:0,overflow:"hidden",children:[c.jsx(u,{children:i}),c.jsx(u,{children:" "}),c.jsx(v,{flexShrink:0,width:3,children:c.jsx(Nn,{status:s.status})}),c.jsx(v,{flexGrow:0,flexShrink:0,width:28,children:c.jsx(u,{bold:r,inverse:r,children:s.id})}),c.jsx(v,{flexGrow:1,flexShrink:1,overflow:"hidden",children:c.jsxs(u,{color:qt(s.status),dimColor:s.status!=="crashed"&&s.status!=="failed",wrap:"truncate-end",children:[" ",o]})})]})},Wn=({states:t})=>{const e=[];for(const r of t)r.status==="ready"&&e.push(r.id);const s=e.join(", ");return c.jsxs(v,{paddingX:1,children:[c.jsxs(u,{bold:!0,color:"green",children:["● ","Services"]}),c.jsxs(u,{children:[" ",String(e.length)," / ",String(t.length)," running"]}),s.length>0&&c.jsxs(u,{dimColor:!0,children:[" ",s]}),c.jsx(u,{dimColor:!0,children:" [Tab ↓]"})]})},Hn=({states:t})=>{const e=t.find(s=>s.status==="crashed"||s.status==="failed");return e?c.jsxs(v,{flexDirection:"column",paddingX:1,children:[c.jsxs(u,{bold:!0,color:"red",children:["✖ ","Service crashed:"," ",e.id]}),e.tailLines.slice(-3).map((s,r)=>c.jsxs(u,{color:"red",dimColor:!0,children:[" ",s]},`crash-${String(r)}`))]}):c.jsx(c.Fragment,{})},qn=({activeIndex:t,focused:e,store:s})=>{const r=V.useSyncExternalStore(s.subscribe,s.getSnapshot),i=s.getIds();if(i.length===0)return c.jsx(c.Fragment,{});const o=i.map(f=>r.get(f)).filter(f=>f!==void 0),n=s.getDockState(),l=n==="crash"?"red":n==="ready"?"gray":e?"white":"cyan",d=n==="crash"?"Services (crashed)":n==="ready"?"Services":"Services (starting)",h=e?n==="crash"?"↑↓ select Enter logs R retry Esc back":"↑↓ select Enter logs Esc back":"Tab to focus services";return n==="ready"&&!e?c.jsx(v,{borderColor:l,borderStyle:"single",flexDirection:"row",flexShrink:0,children:c.jsx(Wn,{states:o})}):c.jsxs(v,{borderBottomTitle:h,borderColor:l,borderStyle:e?"bold":"single",borderTopTitle:d,flexDirection:"column",flexGrow:2,flexShrink:0,minHeight:6,paddingX:1,children:[n==="crash"&&c.jsx(Hn,{states:o}),o.map((f,p)=>c.jsx(Gn,{active:p===t,focused:e,state:f},f.id))]})},Vt=6,Ut=8,zt=12,Vn=t=>t==="running"||t==="pending"?Pt:t==="local-cache"||t==="local-cache-kept-existing"?"Local":t==="remote-cache"?"Remote":Fe,lt=(t,e)=>e[0]===t?"[1]":e[1]===t?"[2]":"",dt=({compact:t,focused:e,isSelected:s,pinLabel:r,row:i})=>{const{persistent:o,status:n,taskId:l}=i,d=e&&s,h=d?">":" ",f=n==="running"&&o===!0;let p;if(f)p=c.jsx(u,{bold:!0,color:"green",children:" ● "});else if(n==="running")p=c.jsxs(u,{bold:!0,color:"white",children:[" ",c.jsx(Mt,{type:"dots"})," "]});else if(n==="pending")p=c.jsx(u,{bold:!0,color:"gray",children:" · "});else{const{color:m,icon:w}=ve(n);p=c.jsxs(u,{bold:!0,color:m,children:[" ",w," "]})}let a=Pt;return f?a="running":n!=="running"&&n!=="pending"?a=i.duration===void 0?Fe:me(i.duration):n==="running"&&i.elapsed!==void 0&&(a=me(i.elapsed)),c.jsxs(v,{children:[c.jsx(u,{children:h}),c.jsx(v,{width:Vt,children:p}),c.jsxs(v,{flexGrow:1,children:[c.jsx(u,{bold:d,inverse:d,children:l}),r?c.jsx(u,{dimColor:!0,children:` ${r}`}):null]}),!t&&c.jsx(v,{justifyContent:"flex-end",width:Ut,children:c.jsx(u,{dimColor:!ge(n),children:Vn(n)})}),!t&&c.jsx(v,{justifyContent:"flex-end",width:zt,children:c.jsx(u,{color:f?"green":void 0,dimColor:n==="pending"||f,children:a})})]})},ut=({compact:t,filterActive:e,filterText:s,focused:r,headerStatus:i,parallelSlots:o=3,pinnedTaskIds:n,rows:l,scrollRef:d,selectedIndex:h,title:f})=>{const p=i==="error"?"red":i==="success"?"green":r?"white":"gray",a=l[h]?.taskId,m=[];let w=0;for(const g of l)g.status==="running"?m.push(g):g.status==="pending"&&(w+=1);const j=Math.min(o,m.length+w),M=j>1,x=[];if(M)for(let g=0;g<j;g++){const k=m[g];k?x.push(c.jsx(dt,{compact:t,focused:r,isSelected:k.taskId===a,pinLabel:lt(k.taskId,n),row:k},`par-${k.taskId}`)):x.push(c.jsxs(v,{children:[c.jsx(u,{children:" "}),c.jsx(v,{width:Vt,children:c.jsx(u,{bold:!0,color:"gray",children:" · "})}),c.jsx(u,{dimColor:!0,children:"Waiting for task..."})]},`par-empty-${String(g)}`))}return c.jsxs(v,{borderColor:p,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[c.jsxs(v,{flexShrink:0,paddingX:1,children:[c.jsx(u,{bold:!0,inverse:!0,children:" VIS "}),c.jsx(u,{children:` ${f}`}),!t&&c.jsxs(v,{flexGrow:1,gap:0,justifyContent:"flex-end",children:[c.jsx(v,{justifyContent:"flex-end",width:Ut,children:c.jsx(u,{dimColor:!0,children:"Cache"})}),c.jsx(v,{justifyContent:"flex-end",width:zt,children:c.jsx(u,{dimColor:!0,children:"Duration"})})]})]}),c.jsx(It,{flexGrow:1,flexShrink:1,paddingX:1,paddingY:1,ref:d,scrollbar:!0,scrollbarColor:"gray",scrollbarStyle:"block",children:l.map(g=>c.jsx(dt,{compact:t,focused:r,isSelected:g.taskId===a,pinLabel:lt(g.taskId,n),row:g},g.taskId))}),M&&c.jsx(v,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",borderTop:!0,flexDirection:"column",flexShrink:0,paddingX:1,paddingY:1,children:x}),e&&c.jsxs(v,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",borderTop:!0,flexShrink:0,paddingX:1,children:[c.jsx(u,{bold:!0,color:"white",children:"/ "}),c.jsx(u,{children:s}),c.jsx(u,{inverse:!0,children:" "})]})]})},ft=40,ht=10,pt=100,Un=Object.freeze([]),zn=({autoExitSeconds:t,onRetryService:e,parallelSlots:s,projectNames:r,serviceDockStore:i,stdinRegistry:o,store:n,targets:l,tasks:d})=>{const{exit:h}=Ys(),{columns:f,rows:p}=Ks(),a=V.useSyncExternalStore(n.subscribe,n.getSnapshot),m=V.useCallback(I=>i?i.subscribe(I):()=>{},[i]);V.useSyncExternalStore(m,()=>i?i.getDockState():"ready");const w=i?i.getIds():Un,j=w.length>0,[M,x]=V.useState(0),[g,k]=V.useState(null),P=V.useSyncExternalStore(m,()=>g&&i?i.getState(g):void 0),[C,y]=V.useState(!1),E=V.useRef(null),R=V.useRef(null),$=V.useRef(null),[O,T]=V.useState(!1),[b,_]=V.useState(!0),D=V.useRef({list:0,splitList:0,splitOutput:0}),G=V.useCallback(()=>{a.viewMode==="list"?D.current.list=R.current?.getScrollOffset()??0:a.viewMode==="split"&&(D.current.splitList=R.current?.getScrollOffset()??0,D.current.splitOutput=$.current?.getScrollOffset()??0)},[a.viewMode]),A=V.useCallback(I=>{setTimeout(()=>{if(I==="list"){const S=D.current.list;R.current?.scrollTo(S)}else if(I==="split"){const S=D.current.splitList;S>0?R.current?.scrollTo(S):R.current?.scrollTo(Math.max(0,n.getSnapshot().selectedIndex-2)),$.current?.scrollTo(D.current.splitOutput)}},0)},[n]),L=V.useRef(!1);V.useEffect(()=>{a.done&&!L.current&&(L.current=!0,t>0&&a.failed===0&&T(!0)),!a.done&&L.current&&(L.current=!1,T(!1))},[a.done,a.failed,t]);const W=V.useMemo(()=>{const I=w.length>0?new Set(w):null,S=a.filterText?a.filterText.toLowerCase():null,F=[];for(const ee of a.rows)I?.has(ee.taskId)||a.statusFilter==="failed"&&ee.status!=="failure"||a.statusFilter==="running"&&ee.status!=="running"&&ee.status!=="pending"||a.statusFilter==="passed"&&ee.status!=="success"&&!ge(ee.status)||S&&!ee.taskId.toLowerCase().includes(S)||F.push(ee);return F},[a.rows,a.filterText,a.statusFilter,w]),B=(W[a.selectedIndex]??null)?.taskId??null,Y=g?null:a.pinnedTaskIds[0]??B,U=Y?a.rows.find(I=>I.taskId===Y):null,Q=P??null,J=g?(Q?.tailLines??[]).join(`
|
|
15
|
+
`):Y?a.outputs.get(Y)??"":"",te=V.useMemo(()=>U?.status==="failure"&&J?Ht(J,{color:!process.env.NO_COLOR,cwd:process.cwd()}):J,[U?.status,J]),re=g??Y,N=g?Q?.status==="crashed"||Q?.status==="failed"?"failure":"running":U?.status,z=Ye(r,l,d),H=a.done?`Completed ${z} (${me((a.endTime??Date.now())-a.startTime)})`:`Running ${z}...`,oe=a.done?a.failed>0?"error":"success":"running",ae=V.useCallback(I=>{R.current?.scrollTo(Math.max(0,I-2))},[]);if(V.useEffect(()=>{a.interactiveMode&&U?.status!=="running"&&n.setInteractiveMode(!1)},[a.interactiveMode,U?.status,n]),V.useEffect(()=>{if(!Y)return;let I=f;a.viewMode==="split"&&f>=pt?I=f-Math.floor(f*.4)-2:(a.viewMode==="split"||a.viewMode==="fullscreen")&&(I=f-2);const S=Math.max(1,p-4);o.get(Y)?.resize?.(I,S)},[f,p,a.viewMode,Y]),Je((I,S)=>{if(S.escape){n.setInteractiveMode(!1);return}if(!Y)return;const F=o.get(Y);if(!F){n.setInteractiveMode(!1);return}if(S.return)F.write("\r");else if(S.upArrow)F.write("\x1B[A");else if(S.downArrow)F.write("\x1B[B");else if(S.rightArrow)F.write("\x1B[C");else if(S.leftArrow)F.write("\x1B[D");else if(S.backspace)F.write("");else if(S.delete)F.write("\x1B[3~");else if(S.tab)F.write(" ");else if(S.home)F.write("\x1B[H");else if(S.end)F.write("\x1B[F");else if(S.pageUp)F.write("\x1B[5~");else if(S.pageDown)F.write("\x1B[6~");else if(S.ctrl&&I){const ee=I.toUpperCase().codePointAt(0);ee!==void 0&&ee>=65&&ee<=90&&F.write(String.fromCodePoint(ee-64))}else I&&F.write(I)},{isActive:a.interactiveMode}),Je((I,S)=>{if(I==="c"&&S.ctrl){h();return}if(!O){if(C){S.escape||I==="?"?y(!1):I==="q"?(y(!1),T(!0)):S.downArrow||I==="j"?E.current?.scrollBy(1):S.upArrow||I==="k"?E.current?.scrollBy(-1):S.pageDown?E.current?.scrollBy(5):S.pageUp?E.current?.scrollBy(-5):S.home?E.current?.scrollToTop():S.end&&E.current?.scrollToBottom();return}if(I==="?"){y(!0);return}if(I==="q"){T(!0);return}if(I==="r"&&a.done){n.requestRerun();return}if(I==="R"&&a.done){const F=W[a.selectedIndex];F?.status==="failure"&&n.requestRetry(F.taskId);return}if(I==="F"&&!a.filterActive){const F=["all","failed","running","passed"],ee=F.indexOf(a.statusFilter);n.setStatusFilter(F[(ee+1)%F.length]);return}if(a.filterActive){if(S.escape){n.setFilterActive(!1);return}if(S.return){n.setFilterActive(!1);return}if(S.backspace){n.setFilter(a.filterText.slice(0,-1));return}if(I&&!S.ctrl&&!S.meta){n.setFilter(a.filterText+I);return}return}if(I==="i"&&U?.status==="running"&&(a.viewMode==="fullscreen"||a.viewMode==="split"&&a.focusedPanel==="output")){n.setInteractiveMode(!0);return}if(a.viewMode==="fullscreen"){if(S.escape){n.setViewMode("split"),A("split");return}if(I==="f"){const F=!b;_(F),F&&$.current?.scrollToBottom();return}if(S.downArrow||I==="j"){_(!1),$.current?.scrollBy(1);return}if(S.upArrow||I==="k"){_(!1),$.current?.scrollBy(-1);return}if(S.pageDown||S.ctrl&&I==="d"){_(!1),$.current?.scrollBy(12);return}if(S.pageUp||S.ctrl&&I==="u"){_(!1),$.current?.scrollBy(-12);return}if(S.home){_(!1),$.current?.scrollToTop();return}if(S.end){_(!0),$.current?.scrollToBottom();return}return}if(a.focusedPanel==="dock"&&j&&i){if(S.tab){k(null),n.setFocusedPanel("tasks");return}if(S.escape){n.setFocusedPanel("tasks"),k(null),a.viewMode==="split"&&(n.setViewMode("list"),A("list"));return}if(S.downArrow||I==="j"){x(F=>Math.min(F+1,w.length-1));return}if(S.upArrow||I==="k"){x(F=>Math.max(F-1,0));return}if(S.return){const F=w[M];F&&(k(F),_(!0),G(),D.current.splitList=0,D.current.splitOutput=0,n.setViewMode("split"),n.setFocusedPanel("output"),A("split"));return}if((I==="r"||I==="R")&&e){const F=w[M],ee=F?i.getState(F)?.status:void 0;if(F&&(ee==="crashed"||ee==="failed")){const be=e(F);be instanceof Promise&&be.catch(()=>{})}return}return}if(a.viewMode==="split"){if(S.tab){a.focusedPanel==="tasks"?n.setFocusedPanel("output"):j?n.setFocusedPanel("dock"):(k(null),n.setFocusedPanel("tasks"));return}if(a.focusedPanel==="output"){if(S.escape){if(g&&j){k(null),n.setViewMode("list"),n.setFocusedPanel("dock"),A("list");return}k(null),n.setFocusedPanel("tasks");return}if(S.return){G(),n.setViewMode("fullscreen");return}if(I==="f"){const F=!b;_(F),F&&$.current?.scrollToBottom();return}if(S.downArrow||I==="j"){_(!1),$.current?.scrollBy(1);return}if(S.upArrow||I==="k"){_(!1),$.current?.scrollBy(-1);return}if(S.pageDown||S.ctrl&&I==="d"){_(!1),$.current?.scrollBy(12);return}if(S.pageUp||S.ctrl&&I==="u"){_(!1),$.current?.scrollBy(-12);return}if(S.home){_(!1),$.current?.scrollToTop();return}if(S.end){_(!0),$.current?.scrollToBottom();return}return}if(S.escape){n.setViewMode("list"),A("list");return}if(S.return){n.setFocusedPanel("output");return}}if(a.viewMode==="list"||a.viewMode==="split"&&a.focusedPanel==="tasks"){if(S.tab&&a.viewMode==="list"&&j){n.setFocusedPanel("dock");return}if(S.downArrow||I==="j"){const F=Math.min(a.selectedIndex+1,Math.max(0,W.length-1));n.setSelectedIndex(F),ae(F);return}if(S.upArrow||I==="k"){const F=Math.max(a.selectedIndex-1,0);n.setSelectedIndex(F),ae(F);return}if(S.return&&a.viewMode==="list"){_(!0),G(),D.current.splitList=0,D.current.splitOutput=0,n.setViewMode("split"),n.setFocusedPanel("output"),A("split");return}if(I==="/"){n.setFilterActive(!0);return}if(I==="1"&&B){n.pinTask(0,B);return}if(I==="2"&&B){n.pinTask(1,B);return}if(I==="0"){n.clearPins();return}S.escape&&a.filterText&&n.setFilter("")}}},{isActive:!a.interactiveMode}),f<ft||p<ht)return c.jsx(v,{alignItems:"center",height:p,justifyContent:"center",width:f,children:c.jsxs(u,{color:"yellow",children:["Terminal too small (",f,"x",p,"). Minimum:"," ",ft,"x",ht]})});const de=c.jsxs(v,{gap:1,children:[a.succeeded>0&&c.jsxs(u,{bold:!0,color:"green",children:["✓"," ",a.succeeded]}),a.cached>0&&c.jsxs(u,{dimColor:!0,children:["✓"," ",a.cached]}),a.failed>0&&c.jsxs(u,{bold:!0,color:"red",children:["✗"," ",a.failed]}),a.running>0&&c.jsxs(u,{color:"cyan",children:["◷"," ",a.running]}),c.jsxs(u,{dimColor:!0,children:[a.totalTasks," ","total"]}),a.statusFilter!=="all"&&c.jsxs(u,{color:"yellow",children:["[",a.statusFilter,"]"]})]});let K;if(a.viewMode==="fullscreen")K=[c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"Esc"}),c.jsx(u,{dimColor:!0,children:"BACK"})]},"esc"),c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"↑↓"}),c.jsx(u,{dimColor:!0,children:"SCROLL"})]},"scroll"),c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"^u ^d"}),c.jsx(u,{dimColor:!0,children:"PAGE"})]},"page"),...U?.status==="running"?[c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"i"}),c.jsx(u,{dimColor:!0,children:"INPUT"})]},"i")]:[],c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"q"}),c.jsx(u,{dimColor:!0,children:"QUIT"})]},"q")];else if(a.done){const I=W[a.selectedIndex]?.status==="failure";K=[c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"q"}),c.jsx(u,{dimColor:!0,children:"QUIT"})]},"q"),c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"r"}),c.jsx(u,{dimColor:!0,children:"RERUN"})]},"r"),...I?[c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"R"}),c.jsx(u,{dimColor:!0,children:"RETRY"})]},"R")]:[],c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"?"}),c.jsx(u,{dimColor:!0,children:"HELP"})]},"?"),c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"↑↓"}),c.jsx(u,{dimColor:!0,children:"NAV"})]},"nav"),c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"F"}),c.jsx(u,{dimColor:!0,children:"FILTER"})]},"F"),c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"⏎"}),c.jsx(u,{dimColor:!0,children:a.viewMode==="list"?"OUTPUT":"FULLSCREEN"})]},"enter")]}else a.viewMode==="split"&&a.focusedPanel==="output"?K=[c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"q"}),c.jsx(u,{dimColor:!0,children:"QUIT"})]},"q"),c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"Esc"}),c.jsx(u,{dimColor:!0,children:"BACK"})]},"esc"),c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"↑↓"}),c.jsx(u,{dimColor:!0,children:"SCROLL"})]},"scroll"),...U?.status==="running"?[c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"i"}),c.jsx(u,{dimColor:!0,children:"INPUT"})]},"i")]:[],c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"⏎"}),c.jsx(u,{dimColor:!0,children:"FULLSCREEN"})]},"enter"),c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"Tab"}),c.jsx(u,{dimColor:!0,children:"PANEL"})]},"tab"),c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"?"}),c.jsx(u,{dimColor:!0,children:"HELP"})]},"?")]:K=[c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"q"}),c.jsx(u,{dimColor:!0,children:"QUIT"})]},"q"),c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"?"}),c.jsx(u,{dimColor:!0,children:"HELP"})]},"?"),c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"↑↓"}),c.jsx(u,{dimColor:!0,children:"NAV"})]},"nav"),c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"/"}),c.jsx(u,{dimColor:!0,children:"FILTER"})]},"/"),c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"F"}),c.jsx(u,{dimColor:!0,children:"STATUS"})]},"F"),c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"⏎"}),c.jsx(u,{dimColor:!0,children:a.viewMode==="list"?"OUTPUT":"FULLSCREEN"})]},"enter"),...a.viewMode==="split"?[c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"Tab"}),c.jsx(u,{dimColor:!0,children:"PANEL"})]},"tab")]:[]];const Z=c.jsxs(v,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",flexShrink:0,justifyContent:"space-between",children:[c.jsx(v,{flexGrow:1,flexWrap:"wrap",gap:2,paddingX:1,children:K}),c.jsx(v,{flexShrink:0,paddingX:1,children:de})]}),se=c.jsxs(Xs,{backgroundColor:"#1e1e1e",footer:c.jsxs(u,{dimColor:!0,children:[c.jsx(u,{bold:!0,color:"white",children:"↑↓"})," ","scroll"," ",c.jsx(u,{bold:!0,color:"white",children:"?"}),"/",c.jsx(u,{bold:!0,color:"white",children:"Esc"})," ","close"]}),scrollRef:E,title:"KEYBOARD SHORTCUTS",visible:C,width:52,children:[c.jsxs(v,{flexDirection:"column",marginBottom:1,children:[c.jsxs(v,{marginBottom:1,children:[c.jsx(u,{dimColor:!0,children:"── "}),c.jsx(u,{bold:!0,color:"white",children:"NAVIGATION"})]}),c.jsxs(v,{children:[c.jsx(v,{width:24,children:c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","↑","/k"]}),c.jsx(u,{dimColor:!0,children:" Move up"})]})}),c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","↓","/j"]}),c.jsx(u,{dimColor:!0,children:" Move down"})]})]}),c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","Tab"]}),c.jsx(u,{dimColor:!0,children:" Switch panel (split)"})]}),c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","Esc"]}),c.jsx(u,{dimColor:!0,children:" Back / close"})]}),c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","Enter"]}),c.jsx(u,{dimColor:!0,children:" Show output / fullscreen"})]})]}),c.jsxs(v,{flexDirection:"column",marginBottom:1,children:[c.jsxs(v,{marginBottom:1,children:[c.jsx(u,{dimColor:!0,children:"── "}),c.jsx(u,{bold:!0,color:"white",children:"VIEWS"})]}),c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","Enter"]}),c.jsxs(u,{dimColor:!0,children:[" ","List"," ","→"," ","Split"," ","→"," ","Fullscreen"]})]}),c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","Esc"]}),c.jsxs(u,{dimColor:!0,children:[" ","Fullscreen"," ","→"," ","Split"," ","→"," ","List"]})]})]}),c.jsxs(v,{flexDirection:"column",marginBottom:1,children:[c.jsxs(v,{marginBottom:1,children:[c.jsx(u,{dimColor:!0,children:"── "}),c.jsx(u,{bold:!0,color:"white",children:"ACTIONS"})]}),c.jsxs(v,{children:[c.jsx(v,{width:24,children:c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","/"]}),c.jsx(u,{dimColor:!0,children:" Filter by text"})]})}),c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","F"]}),c.jsx(u,{dimColor:!0,children:" Filter by status"})]})]}),c.jsxs(v,{children:[c.jsx(v,{width:24,children:c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","1"]}),c.jsx(u,{dimColor:!0,children:"/"}),c.jsx(u,{bold:!0,color:"white",children:"2"}),c.jsx(u,{dimColor:!0,children:" Pin to output pane"})]})}),c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","0"]}),c.jsx(u,{dimColor:!0,children:" Clear pins"})]})]}),c.jsxs(v,{children:[c.jsx(v,{width:24,children:c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","r"]}),c.jsx(u,{dimColor:!0,children:" Rerun all (done)"})]})}),c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","R"]}),c.jsx(u,{dimColor:!0,children:" Retry failed task"})]})]}),c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","i"]}),c.jsx(u,{dimColor:!0,children:" Interactive input (running task)"})]})]}),c.jsxs(v,{flexDirection:"column",marginBottom:1,children:[c.jsxs(v,{marginBottom:1,children:[c.jsx(u,{dimColor:!0,children:"── "}),c.jsx(u,{bold:!0,color:"white",children:"SCROLLING"}),c.jsx(u,{dimColor:!0,children:" (output panel)"})]}),c.jsxs(v,{children:[c.jsx(v,{width:24,children:c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","↑","/k"]}),c.jsx(u,{dimColor:!0,children:" Scroll up"})]})}),c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","↓","/j"]}),c.jsx(u,{dimColor:!0,children:" Scroll down"})]})]}),c.jsxs(v,{children:[c.jsx(v,{width:24,children:c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","^u"]}),c.jsx(u,{dimColor:!0,children:" Page up"})]})}),c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","^d"]}),c.jsx(u,{dimColor:!0,children:" Page down"})]})]}),c.jsxs(v,{children:[c.jsx(v,{width:24,children:c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","Home"]}),c.jsx(u,{dimColor:!0,children:" Top"})]})}),c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","End"]}),c.jsx(u,{dimColor:!0,children:" Bottom (resume follow)"})]})]}),c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","f"]}),c.jsx(u,{dimColor:!0,children:" Toggle auto-scroll (tail mode)"})]})]}),c.jsxs(v,{flexDirection:"column",children:[c.jsxs(v,{marginBottom:1,children:[c.jsx(u,{dimColor:!0,children:"── "}),c.jsx(u,{bold:!0,color:"white",children:"GENERAL"})]}),c.jsxs(v,{children:[c.jsx(v,{width:24,children:c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","q"]}),c.jsx(u,{dimColor:!0,children:" Quit"})]})}),c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","?"]}),c.jsx(u,{dimColor:!0,children:" Toggle help"})]})]})]})]}),ie=c.jsx(Js,{autoExitSeconds:t>0?t:3,onCancel:()=>{T(!1)},visible:O}),ue=j&&i?c.jsx(qn,{activeIndex:M,focused:a.focusedPanel==="dock",store:i}):null;if(a.viewMode==="fullscreen")return c.jsxs(v,{flexDirection:"column",height:p,width:f,children:[c.jsx(v,{flexGrow:1,children:c.jsx(at,{autoScroll:b,duration:U?.duration??U?.elapsed,focused:!0,interactiveMode:a.interactiveMode,output:te,scrollRef:$,status:N,supportsInteractive:!g,taskId:re})}),ue,Z,ie,se]});if(a.viewMode==="split"){const I=f>=pt,S=c.jsx(ut,{compact:!0,filterActive:a.filterActive,filterText:a.filterText,focused:a.focusedPanel==="tasks",headerStatus:oe,parallelSlots:s,pinnedTaskIds:a.pinnedTaskIds,rows:W,scrollRef:R,selectedIndex:a.selectedIndex,title:H}),F=c.jsx(at,{autoScroll:b,duration:U?.duration??U?.elapsed,focused:a.focusedPanel==="output",interactiveMode:a.interactiveMode,output:te,scrollRef:$,showFullscreenHint:!0,status:N,supportsInteractive:!g,taskId:re});if(I){const be=Math.floor(f*.4);return c.jsxs(v,{flexDirection:"column",height:p,width:f,children:[c.jsxs(v,{flexDirection:"row",flexGrow:1,children:[c.jsx(v,{width:be,children:S}),c.jsx(v,{flexGrow:1,children:F})]}),ue,Z,ie,se]})}const ee=Math.floor(p*.45);return c.jsxs(v,{flexDirection:"column",height:p,width:f,children:[c.jsx(v,{height:ee,children:S}),c.jsx(v,{flexGrow:1,children:F}),ue,Z,ie,se]})}return c.jsxs(v,{flexDirection:"column",height:p,width:f,children:[c.jsx(v,{flexGrow:1,children:c.jsx(ut,{filterActive:a.filterActive,filterText:a.filterText,focused:a.focusedPanel!=="dock",headerStatus:oe,parallelSlots:s,pinnedTaskIds:a.pinnedTaskIds,rows:W,scrollRef:R,selectedIndex:a.selectedIndex,title:H})}),ue,Z,ie,se]})},Yn=t=>t==="quiet"?"quiet":"normal",Kn=(t,e)=>typeof t=="string"?Yn(t.toLowerCase()):e===!0?"quiet":"normal",Ne=(t,e)=>{const s=t.overrides.visOptions;return s?.outputStyle==="normal"||s?.outputStyle==="quiet"?s.outputStyle:e},Yt=t=>`${t.id}: tracker saw no workspace access; cached on declared inputs`;class Xn{#e;#r;#s;#n=[];#t=[];#i=[];#o=new Map;#c;#a;#d;#u=0;constructor(e){this.#e=e.projectNames,this.#r=e.args.targets,this.#s=e.tasks,this.#c=e.logReporter,this.#a=e.outputStyle??"normal",this.#d=e.ciGrouping??"auto"}startCommand(){this.#u=Date.now();const e=process.stdout.columns||80,s=`Running ${Ye(this.#e,this.#r,this.#s)}`,r=ce(X.createElement(_e,{title:s,variant:"info"}),{columns:e});process.stdout.write(r);const i=this.#s[0],o=i?.overrides?Object.entries(i.overrides).filter(([n])=>n!=="command"):[];if(o.length>0){process.stdout.write(`
|
|
16
|
+
With additional flags:
|
|
17
|
+
`);for(const[n,l]of o)process.stdout.write(`${gn(" ",n,l)}
|
|
18
|
+
`)}process.stdout.write(`
|
|
19
|
+
`)}startTasks(e){const s=process.stdout.columns||80;for(const r of e){const i=ce(X.createElement(u,null,X.createElement(u,{dimColor:!0},">"),` ${r.id}`),{columns:s});process.stdout.write(`${i}
|
|
20
|
+
`)}}endTasks(e){const s=process.stdout.columns||80;for(const r of e){this.#o.set(r.task.id,r),r.status==="failure"?this.#n.push(r):ge(r.status)&&this.#t.push(r),r.retryAttempts&&r.retryAttempts>0&&this.#i.push(r);const i=xe(r.status),o=r.startTime&&r.endTime?` (${me(r.endTime-r.startTime)})`:"",n=ge(r.status)?" [cache]":"",l=r.retryAttempts&&r.retryAttempts>0?` [retried ${r.retryAttempts}x]`:"",d=ce(X.createElement(u,null,i,` ${r.task.id}`,n?X.createElement(u,{color:"cyan"},n):null,l?X.createElement(u,{color:"yellow"},l):null,o?X.createElement(u,{dimColor:!0},o):null),{columns:s});process.stdout.write(`${d}
|
|
21
|
+
`)}}#l(e){const s=process.stdout.columns||80,r=ce(X.createElement(u,{dimColor:!0},` ⓘ ${e}`),{columns:s});process.stdout.write(`${r}
|
|
22
|
+
`)}printCacheDisabledByTask(e){this.#l(`${e.id}: caching disabled by task via disableCache()`)}printSelfModifyingSkip(e,s){this.#l(`${e.id}: caching skipped — task modified its own input${s.length===1?"":"s"} (${s.join(", ")})`)}printDeclaredFallback(e){Ne(e,this.#a)!=="quiet"&&this.#l(Yt(e))}printEmptyFingerprintWarning(e,s){this.#l(`${e.id}: caching skipped — ${s}`)}printTaskTerminalOutput(e,s,r){if(Ne(e,this.#a)==="quiet"&&(s==="success"||ge(s)))return;const i=s==="failure"?Ht(r,{color:!process.env.NO_COLOR,cwd:process.cwd()}):r;if(this.#c){this.#c.printTaskTerminalOutput(e,s,i);return}Ln(e.id,s,i,this.#d)}endCommand(){const e=me(Date.now()-this.#u),s=this.#s.filter(o=>!this.#o.has(o.id)).map(o=>o.id);process.stdout.write(`
|
|
23
|
+
`);const r=process.stdout.columns||80,i=ce(X.createElement(_t,{cached:this.#t.length,failed:this.#n.length,failedIds:this.#n.map(o=>o.task.id),projectNames:this.#e,retriedIds:this.#i.length>0?this.#i.map(o=>o.task.id):void 0,skippedIds:s.length>0?s:void 0,succeeded:this.#o.size-this.#n.length-this.#t.length,targets:this.#r,tasks:this.#s,took:e}),{columns:r});process.stdout.write(`${i}
|
|
24
|
+
`)}}const Jn=t=>{const{args:e,autoExit:s=!1,onRetryService:r,outputStyle:i="normal",projectNames:o,serviceDockStore:n,stdinRegistry:l,tasks:d,totalTaskCount:h}=t,f=new Ee(d,h),p=typeof e.parallel=="number"?e.parallel:3,a=s===!0?3:typeof s=="number"?s:0,m=new Map,w=(T,b)=>{const _=m.get(T);_?_.push(b):m.set(T,[b])};let j,M;const x=new Promise(T=>{M=T});let g;const k=()=>{g&&(clearInterval(g),g=void 0)},P=()=>{if(process.stdin.isTTY&&typeof process.stdin.setRawMode=="function")try{process.stdin.setRawMode(!1)}catch{}process.stdin.pause(),process.stdin.unref()},C=()=>{if(l){for(const T of l.values())T.kill?.();l.clear()}},y=()=>{k(),$(),C(),P(),process.stdout.write("\x1B[?1049l\x1B[?25h"),j?.cleanup(),process.exit(1)},E=()=>{const T=f.getSnapshot(),b=me(Date.now()-T.startTime),_=T.rows.filter(A=>A.status==="failure").map(A=>A.taskId),D=process.stdout.columns||80;process.stdout.write(`
|
|
25
|
+
`);for(const A of T.rows){const{persistent:L,status:W,taskId:q}=A,B=W==="running"||W==="pending",Y=ve(W),U=B&&L?"■":Y.icon,Q=B&&L?"gray":Y.color;let J="";switch(W){case"local-cache":case"local-cache-kept-existing":{J=" [local cache]";break}case"remote-cache":{J=" [remote cache]";break}case"skipped":{J=" [skipped]";break}default:{B&&L?J=" [stopped]":B&&(J=" [skipped]");break}}const te=A.retryAttempts&&A.retryAttempts>0?` [retried ${A.retryAttempts}x]`:"",re=ce(X.createElement(u,null," ",X.createElement(u,{color:Q},U),` vis run ${q}`,J?X.createElement(u,{dimColor:!0},` ${J}`):null,te?X.createElement(u,{color:"yellow"},te):null),{columns:D});process.stdout.write(`${re}
|
|
26
|
+
`)}process.stdout.write(`
|
|
27
|
+
`);const G=ce(X.createElement(_t,{cached:T.cached,failed:T.failed,failedIds:_,projectNames:o,retriedIds:T.retriedIds.length>0?T.retriedIds:void 0,succeeded:T.succeeded,targets:e.targets,tasks:d,took:b}),{columns:D});if(process.stdout.write(`${G}
|
|
28
|
+
`),i!=="quiet"){const A=[...T.rows.filter(L=>L.status!=="failure"),...T.rows.filter(L=>L.status==="failure")];for(const L of A){if(L.status==="running"||L.status==="pending")continue;const W=T.outputs.get(L.taskId);if(!W?.trim())continue;const{color:q,icon:B}=ve(L.status),Y=ce(X.createElement(u,null,`
|
|
29
|
+
`,X.createElement(u,{bold:!0,color:q},` ${B} vis run ${L.taskId}`)),{columns:D});process.stdout.write(`${Y}
|
|
30
|
+
|
|
31
|
+
`);const U=W.trim().split(`
|
|
32
|
+
`).map(Q=>` ${Q}`).join(`
|
|
33
|
+
`);process.stdout.write(`${U}
|
|
34
|
+
`)}}};let R;const $=()=>{R&&(clearInterval(R),R=void 0)};return{lifeCycle:{endCommand(){k(),f.markDone(),R||(R=setInterval(()=>{},1e3))},endTasks(T){f.endTasks(T);for(const b of T){const _=m.get(b.task.id);if(_){m.delete(b.task.id);for(const D of _)f.addOutput(b.task.id,D)}}},printCacheDisabledByTask(T){w(T.id,`ⓘ caching disabled by task via disableCache()
|
|
35
|
+
`)},printDeclaredFallback(T){Ne(T,i)!=="quiet"&&w(T.id,`ⓘ ${Yt(T)}
|
|
36
|
+
`)},printEmptyFingerprintWarning(T,b){w(T.id,`ⓘ caching skipped — ${b}
|
|
37
|
+
`)},printSelfModifyingSkip(T,b){w(T.id,`ⓘ caching skipped — task modified its own input${b.length===1?"":"s"} (${b.join(", ")})
|
|
38
|
+
`)},printTaskTerminalOutput(T,b,_){f.getSnapshot().outputs.has(T.id)||f.addOutput(T.id,_)},startCommand(){process.on("SIGINT",y),process.on("SIGTERM",y),R||(R=setInterval(()=>{},1e3)),j=Qs(X.createElement(zn,{autoExitSeconds:a,onRetryService:r,parallelSlots:p,projectNames:o,serviceDockStore:n,stdinRegistry:l??new Map,store:f,targets:e.targets,tasks:d}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}),j.waitUntilExit().then(()=>{$(),C(),P(),process.removeListener("SIGINT",y),process.removeListener("SIGTERM",y),E(),M()}).catch(()=>{$(),C(),P(),process.removeListener("SIGINT",y),process.removeListener("SIGTERM",y),M()})},startTasks(T){f.startTasks(T),g||(g=setInterval(()=>{f.tick()},100))}},renderIsDone:x,store:f}},Qn=t=>{const{killGracePeriodMs:e=5e3,onTimeout:s,sendSignal:r,timeoutMs:i}=t;if(i<=0)return{cancel:()=>{}};const o=Math.max(e,0);let n;const l=setTimeout(()=>{s?.(),r("SIGTERM"),o>0&&(n=setTimeout(()=>{r("SIGKILL")},o))},i);return{cancel:()=>{clearTimeout(l),n&&clearTimeout(n)}}},Zn=async(t,e,s)=>{if(!e)return s();const r=t.get(e)??Promise.resolve();let i;const o=new Promise(l=>{i=l}),n=r.then(()=>o);t.set(e,n),await r;try{return await s()}finally{i(),t.get(e)===n&&t.delete(e)}},ei=t=>{let e=Math.max(0,Math.floor(t));return{claim(s){const r=Math.max(0,Math.min(s,e));return e-=r,r},get remaining(){return e}}},Kt=t=>async(e,s)=>{const{hooks:r,lifeCycle:i,mutexPool:o,onOutput:n,onOutputReplace:l,resolveCommand:d,retryBudget:h,serviceEventBridge:f,spawnContext:p,stdinRegistry:a,strictEnvFailure:m,workspaceRoot:w}=t,j=je(e),M=He(w,s.cwd??e.projectRoot,j?.runFromWorkspaceRoot===!0),x=d(e);if(!x)return{code:0,terminalOutput:`No command configured for ${e.target.project}:${e.target.target}`};const g=ke(p,e,s),k=m(e,x,s);if(k!==void 0)return i?.onTaskStderr?.(e,k),{code:1,terminalOutput:k};const P=j?.pty===!0,C=!!a,y=e.pty===!0?!0:e.pty===!1?!1:C||P;y&&(e.cache=!1);const E=y?void 0:new Qr(Ie),R=y?new We(Ie):void 0;let $;const O=b=>{if(b.kind==="started"&&($=b.kill,b.write&&a&&a.set(e.id,{kill:b.kill,resize:b.resize,write:b.write}),f?.onRegistryTaskStarted(e.id)),(b.kind==="stdout"||b.kind==="stderr")&&b.text!==void 0)if(b.kind==="stdout"?i?.onTaskStdout?.(e,b.text):i?.onTaskStderr?.(e,b.text),R)R.write(b.text),C&&l?.(e.id,R.toString()),f&&f.onTaskOutput(e.id,b.text);else{const _=`${b.text}
|
|
39
|
+
`;E.append(_),n?.(e.id,_)}b.kind==="close"&&(a&&a.delete(e.id),f&&f.onRegistryTaskClosed(e.id,b.exitCode??0,!!b.killed).catch(()=>{}))},T=async()=>{const b=j?.retryCount??0,_=j?.retryDelay,D=h?h.claim(b):b,G=typeof j?.timeout=="number"&&j.timeout>0?j.timeout:0,A=typeof j?.killGracePeriodMs=="number"&&j.killGracePeriodMs>=0?j.killGracePeriodMs:5e3;let L=!1,W=0;const q=Qn({killGracePeriodMs:A,onTimeout:()=>{L=!0},sendSignal:Q=>{$?.(Q)},timeoutMs:G});let B;try{B=await $e([{command:x,cwd:M,env:g.env,inheritEnv:g.inheritEnv,name:e.id,...y?{ptySize:{cols:process.stdout.columns??80,rows:process.stdout.rows??24},stdin:"pty"}:{}}],{killOthers:["failure"],onEvent:O,...D>0?{restart:{delay:_??"exponential",onRetry:async(Q,J,te)=>{W=Q,r&&await r.callHook("task:retry",e,Q,te)},tries:D}}:{}})}finally{q.cancel()}const Y=B.closeEvents[0],U=R?R.toString():E.toString();return L?{code:124,retryAttempts:W,terminalOutput:`${U}
|
|
40
|
+
[timeout] Task "${e.id}" exceeded ${G}ms budget.
|
|
41
|
+
`}:{code:Y?.exitCode??1,retryAttempts:W,terminalOutput:U}};return o?Zn(o,j?.mutex,T):T()},ti=({injectedServiceIdSet:t,runtime:e,serviceDockStore:s,serviceEventBridge:r,workspaceRoot:i})=>{const{failureLogLifeCycle:o,hookLifeCycle:n,hooks:l,lifecycleOptions:d,outputStyle:h,resolveCommand:f,sharedRetryBudget:p,spawnContext:a,strictEnvFailure:m}=e,w=new Map,j=Jn({...d,onRetryService:r?C=>r.retry(C):void 0,outputStyle:h,serviceDockStore:s,stdinRegistry:w}),{lifeCycle:M,store:x}=j,g=new jt([M,n,o]),P=Kt({hooks:l,lifeCycle:g,mutexPool:new Map,onOutput:(C,y)=>{r&&t.has(C)?r.onTaskOutput(C,y):x.addOutput(C,y)},onOutputReplace:(C,y)=>{x.setOutput(C,y)},resolveCommand:f,retryBudget:p,serviceEventBridge:r??void 0,spawnContext:a,stdinRegistry:w,strictEnvFailure:m,workspaceRoot:i});return{dynamic:j,lifeCycle:g,stdinRegistry:w,store:x,taskExecutor:P}},si=async({dynamic:t,initialTasks:e,lifeCycle:s,options:r,persistentTasks:i,projectGraph:o,runtime:n,stdinRegistry:l,store:d,taskExecutor:h,taskGraph:f,workspaceRoot:p})=>{const{childEnvPolicyFor:a,preTraceCheck:m,resolveCommand:w,runnerOptions:j,spawnContext:M}=n,x=await St(e,j,{childEnvPolicy:a,lifeCycle:s,preTraceCheck:m,projectGraph:o,resolveChildEnv:(g,k)=>ke(M,g,k),resolveCommand:w,taskExecutor:h,taskGraph:f,workspaceRoot:p});if(i.length>0&&!r.failFast){const g=new Promise(k=>{const P=d.subscribe(()=>{const C=d.getSnapshot();(C.rerunRequested||C.retryTaskId)&&(P(),k())});t.renderIsDone.then(()=>{P(),k()}).catch(()=>{P(),k()})});await Bt(i,M,{abortSignal:g,lifeCycle:s,stdinRegistry:l,store:d})}return x},ri=async({dynamic:t,store:e})=>{let s=null;return{action:await new Promise(i=>{const o=e.subscribe(()=>{const n=e.getSnapshot();n.rerunRequested&&(e.acknowledgeRerun(),o(),i("rerun")),n.retryTaskId&&(s=e.acknowledgeRetry(),o(),i("retry"))});t.renderIsDone.then(()=>{o(),i("quit")}).catch(()=>{o(),i("quit")})}),retryTaskId:s}},le="@voidzero-dev/vite-task-client",Ke="@visulima/task-runner-client",Pe=`npm:${Ke}@^1`,Xt=ne(".vis",".vite-client-override-declined"),Me="pnpm-workspace.yaml",ni=["dependencies","devDependencies","optionalDependencies","peerDependencies"],Jt=t=>{try{return JSON.parse(we(t,"utf8"))}catch{return}},ii=t=>{const e=ne(t,Me);if(he(e))try{return Ft(we(e,"utf8")).toJS()?.overrides}catch{return}},oi=t=>t==="pnpm"||t==="aube"?"pnpm.overrides":t==="yarn"?"resolutions":"overrides",ci=t=>{const e=ne(t,Me);try{const s=Ft(we(e,"utf8"));return s.setIn(["overrides",le],Pe),qe(e,s.toString()),!0}catch{return!1}},mt=t=>t!==void 0&&ni.some(e=>t[e]?.[le]!==void 0),ai=(t,e)=>t!==void 0&&(t.pnpm?.overrides?.[le]!==void 0||t.overrides?.[le]!==void 0||t.resolutions?.[le]!==void 0)||e?.[le]!==void 0,li=(t,e=[])=>{const s=Jt(ne(t,"package.json")),r=he(ne(t,"node_modules","@voidzero-dev","vite-task-client"));return{alreadyOverridden:ai(s,ii(t)),declined:he(ne(t,Xt)),manager:kr(t)?.manager,present:mt(s)||r||e.some(i=>mt(i))}},di=t=>{try{const e=ne(t,Xt);or(Tt(e),{recursive:!0}),qe(e,`Declined adding the ${le} → ${Ke} override.
|
|
42
|
+
Delete this file to be asked again.
|
|
43
|
+
`)}catch{}},ui=(t,e="npm")=>{const s=`${e} install`;if((e==="pnpm"||e==="aube")&&he(ne(t,Me))&&ci(t))return{file:Me,installCommand:s};const r=ne(t,"package.json"),i=Jt(r);if(!i)return;const o=oi(e);o==="pnpm.overrides"?(i.pnpm??={},i.pnpm.overrides??={},i.pnpm.overrides[le]=Pe):(i[o]??={},i[o][le]=Pe);try{qe(r,`${JSON.stringify(i,void 0,4)}
|
|
44
|
+
`)}catch{return}return{file:"package.json",installCommand:s}},fi=async(t,e)=>{const s=li(t,e.projectManifests);if(!s.present||s.alreadyOverridden||s.declined)return!1;const r=Tr({input:process.stdin,output:process.stdout});try{e.logger.info(`Detected ${le}. Its cache hints no-op under @visulima/task-runner unless aliased to ${Ke} (a drop-in replacement).`);const i=await new Promise(n=>{r.question("Add the override now? [y/N] ",n)});if(!/^y(?:es)?$/i.test(i.trim()))return di(t),e.logger.info("Skipped. Delete .vis/.vite-client-override-declined to be asked again."),!1;const o=ui(t,s.manager);return o===void 0?(e.logger.warn("Could not write the override automatically — add it manually (see @visulima/task-runner-client README)."),!1):(e.logger.info(`Added "${le}": "${Pe}" to ${o.file}. Run \`${o.installCommand}\` to apply it.`),!0)}finally{r.close()}},hi=async({config:t,logger:e,options:s,packageJsons:r,workspaceRoot:i})=>{await Cr(i,t.toolchain,{error:l=>{e.error(l)},info:l=>{e.info(l)},warn:l=>{e.warn(l)}},!!s.skipToolchain);const o=s.preflight!==!1&&t.preflight?.lockfile!==!1,n=br(i,Se,{warn:l=>{e.warn(l)}},{skip:!o});if(!n.shouldContinue)throw new Error(`${n.formattedMessage??"preflight: lockfile drift detected"} (pass --no-preflight to bypass)`);o&&!Se&&process.stdin.isTTY&&process.stdout.isTTY&&await fi(i,{interactive:!0,logger:{info:l=>{e.info(l)},warn:l=>{e.warn(l)}},projectManifests:[...r.values()]})},pi=/\$(?:\{([A-Z_]\w*)(:-[^}]*)?\}|([A-Z_]\w*))/gi,mi=new Set(["0","!","#","$","*","-","?","@","_"]),gi=t=>{const e=new Map;for(const s of t.matchAll(pi)){const r=s[1],i=s[3],o=s[2],n=r??i;if(n===void 0||mi.has(n))continue;const l=o!==void 0,d=e.get(n);d===void 0?e.set(n,l):d&&!l&&e.set(n,!1)}return[...e.entries()].map(([s,r])=>({hasDefault:r,name:s}))},wi=t=>{const{command:e,processEnv:s,taskEnv:r,taskId:i}=t,o=gi(e);if(o.length===0)return;const n=[];for(const{hasDefault:l,name:d}of o){if(l)continue;const h=r[d],f=s[d];h===void 0&&f===void 0&&n.push(d)}if(n.length!==0)return{missing:n.toSorted(),taskId:i}},vi=t=>{const e=t.missing.map(s=>`$${s}`).join(", ");return`Strict env: ${t.taskId} references unset variable${t.missing.length===1?"":"s"} ${e}. Set ${t.missing.length===1?"it":"them"} in the task env, an envFile, or the parent shell — or opt out with options.strictEnv: false.`},yi=async({configTaskRunner:t,logger:e,options:s,runnerOptions:r,workspaceRoot:i})=>{const o=cs(t.remoteCache);if(o){const n=tn(s.cacheMode),l=sn(s.cacheBackend);if(r.remoteCache={...o,...n?{mode:n}:{},...l?{backend:l}:{}},r.remoteCache.attestation){const{expectedIdentity:d,requireOnDownload:h}=r.remoteCache.attestation;if(!(d!==void 0&&("github"in d&&typeof d.github?.ref=="string"&&typeof d.github.repo=="string"&&typeof d.github.workflow=="string"||"oidcIssuer"in d&&typeof d.oidcIssuer=="string"&&(typeof d.san=="string"||typeof d.sanRegex=="string"))))throw new Error("[vis run] remoteCache.attestation requires a pinned keyless signer via `expectedIdentity`. Use one of:\n • { github: { repo, workflow, ref } } (GitHub Actions — recommended)\n • { oidcIssuer, san } (literal identity; vis regex-escapes + anchors it)\n • { oidcIssuer, sanRegex } (advanced: raw regex, you own anchoring)\nWithout it, verification is integrity-only — use `remoteCache.signing` (HMAC) for that instead.");"sanRegex"in d&&(!d.sanRegex.startsWith("^")||!d.sanRegex.endsWith("$"))&&e.warn("[vis run] remoteCache.attestation.expectedIdentity.sanRegex is not anchored (^…$). sigstore matches it as a regex; an unanchored value is substring-matched and weakens the identity pin. Prefer the literal `san` form unless you need a pattern.");const{installCommandFor:p,isSigstoreInstalled:a}=await import("./loader.js");a()||e.warn(`[vis run] remoteCache.attestation is configured but the optional \`sigstore\` package is not installed. Cache uploads will be unsigned and signed entries can't be verified until you install it:
|
|
45
|
+
${p(i)}`);const{buildCacheAttestationHooks:m}=await import("./cache-attestation.js");r.remoteCache.attestation=m({expectedIdentity:d,onReject:(w,j)=>{e.warn(`[vis run] remote cache entry ${w.slice(0,12)} rejected: attestation ${j}. Treating as a cache miss.`)},onVerifyFailure:w=>{e.warn(`[vis run] attestation verification failed: ${w}`)},requireOnDownload:h,workspaceRoot:i})}}else(s.cacheMode||s.cacheBackend)&&e.warn("[vis run] --cache-mode and --cache-backend require a `remoteCache` block in vis.config.ts (or TURBO_API env); ignoring.")},xi=async({affectedFiles:t,config:e,currentOs:s,initialTasks:r,invocationCwd:i,logger:o,options:n,persistentTasks:l,projectsWithTarget:d,serviceEnvByTaskId:h,serviceResult:f,target:p,taskGraph:a,visConfig:m,workspaceRoot:w})=>{const j=Date.now(),M=Cs(),x=(N,z)=>{const H=z instanceof Error?z.message:String(z);o.warn(`Plugin error in ${N}: ${H}`)};await Is(M,e.plugins);const g=typeof n.profile=="string"?n.profile:void 0,k=async N=>{if(!g)return;const z=kt(N,a,j),H=g.startsWith("/")?g:`${w}/${g}`;await ls(z,H),o.info(`Profile written to ${g}`)},P=e.taskRunner??{},C=Zs(w,n.cacheDir,P.cacheDirectory,e.sharedWorktreeCache),y=er(C,w,e.branchScopedCache),E=Zr(process.env.VIS_RUN_CONCURRENCY_LIMIT);E&&"invalid"in E&&o.warn(`VIS_RUN_CONCURRENCY_LIMIT=${E.invalid} is not a positive number; falling back to default concurrency.`);const R=E&&"value"in E?E.value:void 0,$=n.parallel??R??3,O=n.strictEnv??e.strictEnv??!1,T=new Set,b={dryRun:n.dryRun??!1,parallel:$,skipNxCache:!n.cache,summarize:n.summarize??!1,...P,cacheDirectory:y,dataDirectory:P.dataDirectory??Ce(w),namedInputs:e.namedInputs,onDiagnostic:(N,z)=>{T.has(N)||(T.add(N),o.warn(z))},onFingerprint:async(N,z)=>{await M.callHook("task:fingerprint",N,z)}},_=N=>Hs(b.env,je(N)?.env),D=Ws({affectedFiles:t,childEnvPolicy:_,initCwd:i,serviceEnvByTaskId:h,taskSlots:$,workspaceRoot:w}),G=N=>ze(N,t,s),A=(N,z,H)=>{if(!(je(N)?.strictEnv??O))return;const ae=ke(D,N,H),de=D.childEnvPolicy(N),K=wi({command:z,processEnv:de.mode==="clean"?as(process.env,de):process.env,taskEnv:ae.env,taskId:N.id});return K?vi(K):void 0},L=(N,z)=>{const H=G(N);return H===void 0?void 0:A(N,H,z)};await yi({configTaskRunner:P,logger:o,options:n,runnerOptions:b,workspaceRoot:w});const W=process.stdout.isTTY&&!Se,q=m?.run?.quietOnSuccess===!0,B=e.tui?.autoExit??(q?3:!1),Y={args:{parallel:b.parallel,targets:[p]},autoExit:B,projectNames:d,tasks:[...r,...l].flatMap(N=>{const z=Object.values(a.tasks).filter(H=>H.segment!==void 0&&H.id.startsWith(`${N.id}#`));return z.length>0?z:[N]}),totalTaskCount:Object.keys(a.tasks).length+l.length},U=typeof n.retryBudget=="number"?n.retryBudget:void 0,Q=U===void 0?void 0:ei(U),J=new Es(M,x),te=new Ir(w),re=Kn(n.outputStyle,m?.run?.quietOnSuccess);if(f.satisfiedServices.length>0)for(const N of f.satisfiedServices){const z=f.serviceDependentsByServiceId.get(N.id)??[];try{await M.callHook("service:attach",N,z)}catch(H){x("service:attach",H)}}return{childEnvPolicyFor:_,failureLogLifeCycle:te,hookLifeCycle:J,hooks:M,isTTY:W,lifecycleOptions:Y,maybeWriteProfile:k,outputStyle:re,preTraceCheck:L,resolveCommand:G,runnerOptions:b,sharedRetryBudget:Q,spawnContext:D,startTime:j,strictEnvFailure:A}},ji=async t=>{if(process.env.VIS_NO_SHELL_HISTORY)return;if(Gr()==="win32"){try{await bi(t)}catch{}return}const e=process.env.SHELL;if(!e)return;const s=Ds(e);try{if(s==="zsh"){await Si(t);return}if(s==="bash"){await ki(t);return}s==="fish"&&await Ti(t)}catch{}},Xe=t=>t.replaceAll(/[\u0000-\u001F\u007F]/gu," ").trimEnd(),Si=async t=>{const e=process.env.HISTFILE??ne(process.env.ZDOTDIR??Ve(),".zsh_history"),s=`: ${Math.floor(Date.now()/1e3)}:0;${Xe(t)}
|
|
46
|
+
`;await Oe(e,s)},ki=async t=>{const e=process.env.HISTFILE??ne(Ve(),".bash_history");await Oe(e,`${Xe(t)}
|
|
47
|
+
`)},bi=async t=>{const e=process.env.VIS_PSREADLINE_HISTORY,s=process.env.APPDATA;if(e===void 0&&(s===void 0||s===""))return;const r=e??ne(s,"Microsoft","Windows","PowerShell","PSReadLine","ConsoleHost_history.txt");await Nr(Tt(r),{recursive:!0}),await Oe(r,`${Xe(t)}\r
|
|
48
|
+
`)},Ti=async t=>{const e=ne(Ve(),".local","share","fish","fish_history"),r=`- cmd: ${t.replaceAll("\\","\\\\").replaceAll(`
|
|
49
|
+
`,String.raw`\n`).replaceAll("\r",String.raw`\r`)}
|
|
50
|
+
when: ${Math.floor(Date.now()/1e3)}
|
|
51
|
+
`;await Oe(e,r)},$i=t=>t.startsWith("./")||t.startsWith("../")||t.startsWith("/")||t.startsWith("**"),Ci=t=>{let e=t.trim();if(e==="")return;let s=!1,r=!1,i=!1;e.startsWith("...")&&(s=!0,e=e.slice(3),e.startsWith("^")&&(i=!0,e=e.slice(1))),e.endsWith("...")&&(r=!0,e=e.slice(0,-3),e.endsWith("^")&&(i=!0,e=e.slice(0,-1)));let o;const n=/\[([^\]]*)\]$/.exec(e);n&&(o=n[1]??"",e=e.slice(0,n.index));let l=e.trim(),d=!1;return l.startsWith("{")&&l.endsWith("}")&&l.length>=2?(l=l.slice(1,-1),d=!0):$i(l)&&(d=!0),{changedSince:o,excludeSelf:i,includeDependencies:r,includeDependents:s,isPath:d,pattern:l}},Ge=t=>{let e=t.replaceAll("\\","/");return e.startsWith("./")&&(e=e.slice(2)),e.length>1&&e.endsWith("/")&&(e=e.slice(0,-1)),e},Ii=(t,e,s)=>t===""?!1:Be(t,e)?!0:s!==void 0&&Be(t,s),Ei=(t,e)=>{if(e===void 0||e==="")return!1;const s=Ge(t),r=Ge(e);return Be(s,r)},Ri=(t,e,s)=>{const{affected:r,downstream:i,upstream:o}=ds(t,s,{downstream:e.includeDependents?"deep":"none",upstream:e.includeDependencies?"deep":"none"});if(!e.excludeSelf)return r;const n=new Set([...i,...o]);for(const l of t)n.delete(l);return n},Pi=async(t,e)=>{const{packageNameByProject:s,projectGraph:r}=e,i=Object.keys(r.nodes);let o=new Set;if(t.pattern!=="")for(const n of i)t.isPath?Ei(t.pattern,r.nodes[n]?.data.root)&&o.add(n):Ii(t.pattern,n,s?.get(n))&&o.add(n);if(t.changedSince!==void 0){const n=t.changedSince===""?e.defaultBase??"main":t.changedSince,l=e.changedProjectsForRef??Mi(e),d=new Set(await l(n));o=t.pattern===""?d:new Set([...o].filter(h=>d.has(h)))}return!t.includeDependents&&!t.includeDependencies?o:Ri(o,t,r)},Mi=t=>async e=>{const{projectGraph:s,workspaceRoot:r}=t;if(!r)return[];let i;try{i=await us(r,e,"HEAD")}catch(n){const l=n instanceof Error?n.message:String(n);throw new Error(`vis run --filter: invalid changed-since ref "${e}" (${l})`,{cause:n})}const o=new Set;for(const[n,l]of Object.entries(s.nodes)){const d=Ge(l.data.root??n);if(!(d===""||d==="."))for(const h of i){const f=Bs(r,h).replaceAll("\\","/");if(f===d||f.startsWith(`${d}/`)){o.add(n);break}}}return[...o]},Fi=async(t,e)=>{const s=new Set;for(const r of t)for(const i of await Pi(r,e))s.add(i);return[...s]},Oi=async(t,e)=>{const s=[];for(const r of t){const i=Ci(r);i&&s.push(i)}return Fi(s,e)},Ai=({logger:t,options:e,projectNames:s,projectOptions:r,target:i,workspace:o})=>{const n=(typeof e.runnerTags=="string"?e.runnerTags:process.env.VIS_RUNNER_TAGS)??void 0,l=n?new Set(n.split(",").map(f=>f.trim()).filter(Boolean)):void 0,d=[],h=new Map;for(const f of s){const a=r.get(f)?.[i];if(!a)continue;const m=a.options;if(!m?.internal){if(!_s(m,!!Se)){t.debug?.(`Skipping ${f}:${i} — runInCI filter`);continue}if(!Ns(m,l)){t.debug?.(`Skipping ${f}:${i} — runner-tags filter`);continue}d.push(f),h.set(f,a)}}if(d.length===0){if(e.ifPresent){t.info(`No projects have the "${i}" target; skipping (--if-present).`);return}const f=Ot(o),p=Object.entries(o.projects).filter(([,m])=>m.targets?.[i]!==void 0).map(([m])=>m),a=[`No projects have the "${i}" target.`];if(p.length>0)a.push("",`Target "${i}" exists in these projects but was filtered out:`,...p.slice(0,5).map(m=>` - ${m}`)),p.length>5&&a.push(` …and ${p.length-5} more`);else{const m=Rr(i,f,3);m.length>0&&a.push("",m.length===1?`Did you mean "${m[0]}"?`:`Did you mean one of: ${m.map(w=>`"${w}"`).join(", ")}?`),a.push("","Run `vis run` without arguments to see all available targets, or pass --if-present to skip when no project has the target.")}throw new pe(a.join(`
|
|
52
|
+
`))}return{projectsWithTarget:d,projectTargetIndex:h}},Li=async({argument:t,logger:e,workspace:s})=>{let r=t[0];if(!r){const i=Ot(s);if(process.stdout.isTTY&&process.stdin.isTTY){const o=await Pr(i);if(!o){e.info("No target selected.");return}r=o,await ji(`vis run ${o}`)}else throw e.info("Available targets:"),e.info(""),e.info(Mr(i)),e.info(""),new pe("Missing target. Usage: vis run <target>")}return r},Di=({config:t,logger:e,options:s,projectGraph:r})=>{if(t.constraints&&!s.skipConstraints){const i=fs(r,t.constraints);if(i.length>0){for(const o of i)e.error(`[${o.rule}] ${o.message}`);throw new Error(`${i.length} project constraint violation(s) found. Use --skip-constraints to bypass.`)}}},Bi=({options:t,rawSelector:e})=>{if(!t.affected){const s=t.uncommitted?"--uncommitted":"--no-uncommitted",r=[["--base",t.base],["--head",t.head],["--downstream",t.downstream],["--upstream",t.upstream],[s,t.uncommitted]].filter(([,i])=>i!==void 0).map(([i])=>i);if(r.length>0)throw new pe(`${r.join(", ")} ${r.length===1?"requires":"require"} --affected.
|
|
53
|
+
Did you mean: vis run ${e} --affected ${r.map(i=>i.includes("uncommitted")?i:`${i}=…`).join(" ")}
|
|
54
|
+
Or use the dedicated command: vis affected ${e} …`)}},_i=async({logger:t,options:e,packageJsons:s,projectGraph:r,projectOptions:i,rawSelector:o,visConfig:n,workspace:l,workspaceRoot:d})=>{const h=await Lr(o,l,process.cwd(),d),f=Fr(i),p=Or(h.target,f);p!==h.target&&t.debug?.(`Resolved alias "${h.target}" → "${p}"`);let a=h.projects;e.projects!==void 0&&(a=Ar(a,String(e.projects),Object.keys(l.projects)));const m=w=>{if(e.ifPresent){t.info(`${w}; skipping (--if-present).`);return}throw new pe(`${w}.
|
|
55
|
+
|
|
56
|
+
Pass --if-present to skip quietly when nothing matches.`)};if(e.filter&&e.filter.length>0){const w=new Map;for(const[x,g]of s)w.set(x,g.name);const j=await Oi(e.filter,{defaultBase:n?.defaultBase,packageNameByProject:w,projectGraph:r,workspaceRoot:d}),M=new Set(j);if(a=a.filter(x=>M.has(x)),a.length===0){m(`Filter ${e.filter.map(x=>`"${x}"`).join(", ")} matched no projects`);return}}if(e.query&&(a=Dr(a,l,e.query),a.length===0)){m(`Query "${String(e.query)}" matched no projects`);return}if(e.tag&&e.tag.length>0&&(a=Br(a,l,e.tag),a.length===0)){m(`Tag filter ${e.tag.map(w=>`"${w}"`).join(", ")} matched no projects`);return}return{projectNames:a,target:p}},Ni=async({fileOwners:t,logger:e,options:s,projectGraph:r,projectNames:i,visConfig:o,workspace:n,workspaceRoot:l})=>{let d=i,h;if(s.affected){const f=await Er({base:s.base,downstream:s.downstream,head:s.head,uncommitted:s.uncommitted,upstream:s.upstream},{fileOwners:t,projectGraph:r,projects:n.projects,workspaceRoot:l},{affectedIgnore:o?.affectedIgnore,defaultBase:o?.defaultBase});for(const m of f.notes)e.info(`▸ ${m}`);if(f.changedFiles.length===0){e.info("No files changed. Nothing to run.");return}const p=new Set(f.affectedProjects);if(d=d.filter(m=>p.has(m)),d.length===0){e.info("No projects affected by the changes.");return}const a=new Set(f.ignoredFiles);h=f.changedFiles.filter(m=>!a.has(m)),e.info(`Affected projects: ${d.join(", ")}`)}return{affectedChangedFiles:h,projectNames:d}},Gi=async({argument:t,config:e,fileOwners:s,logger:r,options:i,packageJsons:o,projectGraph:n,projectOptions:l,visConfig:d,workspace:h,workspaceRoot:f})=>{const p=await Li({argument:t,logger:r,workspace:h});if(p===void 0)return;Di({config:e,logger:r,options:i,projectGraph:n}),Bi({options:i,rawSelector:p});const a=await _i({logger:r,options:i,packageJsons:o,projectGraph:n,projectOptions:l,rawSelector:p,visConfig:d,workspace:h,workspaceRoot:f});if(!a)return;const{target:m}=a,w=t.slice(1).map(String),j=await Ni({fileOwners:s,logger:r,options:i,projectGraph:n,projectNames:a.projectNames,visConfig:d,workspace:h,workspaceRoot:f});if(!j)return;const{affectedChangedFiles:M,projectNames:x}=j,g=Ct(),k=process.env[qs],P=M??(k?k.split(`
|
|
57
|
+
`).filter(Boolean):void 0),C=Ai({logger:r,options:i,projectNames:x,projectOptions:l,target:m,workspace:h});if(!C)return;const{projectsWithTarget:y,projectTargetIndex:E}=C;return{affectedFiles:P,currentOs:g,forwardedArgs:w,projectsWithTarget:y,projectTargetIndex:E,target:m}},Wi=64*1024,gt=256,Hi=new RegExp("[\x1B]\\[[0-?]*[ -/]*[@-~]","g"),Le=t=>t.replaceAll(Hi,"").replaceAll("\r","");class wt{#e=[];#r=new Set;#s=new Map;#n=new Map;constructor(e=[]){for(const s of e)this.#n.set(s,{id:s,status:"pending",tailLines:[]});this.#e=[...e],this.#i()}getSnapshot=()=>this.#s;subscribe=e=>(this.#r.add(e),()=>{this.#r.delete(e)});getIds(){return this.#e}getState(e){return this.#n.get(e)}getDockState(){let e=!1,s=!1;for(const r of this.#n.values())r.status==="crashed"||r.status==="failed"?e=!0:(r.status==="pending"||r.status==="starting")&&(s=!0);return e?"crash":s?"boot":"ready"}registerService(e){this.#n.has(e)||(this.#n.set(e,{id:e,status:"pending",tailLines:[]}),this.#e=[...this.#e,e],this.#o())}markStarting(e){this.#t(e,s=>({...s,errorMessage:void 0,startedAt:s.startedAt??Date.now(),status:"starting"}))}markStarted(e,s){this.#t(e,r=>({...r,startedAt:r.startedAt??Date.now(),status:r.status==="ready"?"ready":"starting"}))}markReady(e,s){this.#t(e,r=>({...r,errorMessage:void 0,port:s.port,readyAt:Date.now(),status:"ready"}))}markFailed(e,s,r){const i=r?.message;this.#t(e,o=>({...o,errorMessage:Le(i??s),status:"failed"}))}markCrashed(e,s){const r=s.slice(-gt).map(i=>Le(i));this.#t(e,i=>({...i,errorMessage:r.length>0?r[r.length-1]:"process exited",status:"crashed",tailLines:r}))}appendLog(e,s){const r=s.split(`
|
|
58
|
+
`).map(i=>Le(i)).filter(i=>i.length>0);r.length!==0&&this.#t(e,i=>{const o=[...i.tailLines,...r];for(;o.length>gt;)o.shift();let n=0;for(let l=o.length-1;l>=0;l--)if(n+=o[l].length+1,n>Wi){o.splice(0,l+1);break}return{...i,lastLine:r[r.length-1],tailLines:o}})}abortBoot(e){let s=!1;const r=new Map(this.#n);for(const[i,o]of r)(o.status==="pending"||o.status==="starting")&&(r.set(i,{...o,errorMessage:e,status:"failed"}),s=!0);s&&(this.#n=r,this.#i(),this.#o())}#t(e,s){const r=this.#n.get(e);r&&(this.#n.set(e,s(r)),this.#i(),this.#o())}#i(){this.#s=new Map(this.#n)}#o(){for(const e of this.#r)try{e()}catch{}}}const qi=t=>{const e=t.overrides.visOptions;return e&&typeof e=="object"?e:void 0},Vi=async t=>{const{initialTasks:e,probe:s,registeredEntries:r,taskGraph:i,visVersion:o}=t,n=new Map,l=new Map,d=new Map;for(const y of r)if(Rs(y.pid)){if(y.visVersion!==o){l.set(y.id,y);continue}n.set(y.id,y)}if(s){const y=[...n.values()],E=await Promise.all(y.map(async R=>{try{return[R.id,await s(R)]}catch{return[R.id,!1]}}));for(const[R,$]of E)if(!$){const O=n.get(R);n.delete(R),O&&d.set(R,O)}}const h=new Set(e.map(y=>y.id)),f=new Set,p=[],a=[],m=new Set;for(const y of Object.values(i.dependencies))for(const E of y)m.add(E);for(const[y,E]of Object.entries(i.tasks)){if(!qi(E)?.service)continue;if(n.has(y)){f.add(y),a.push(n.get(y));continue}if(h.has(y)||!m.has(y))continue;const O=l.get(y),T=d.get(y);let b;O?b=`Service ${y} is registered with vis ${O.visVersion}, but this invocation is vis ${o}. Restart with \`vis service restart ${y}\` to pick up the new version.`:T?b=`Service ${y} is registered (PID ${String(T.pid)}) but failed its readiness probe — the wrapper process is alive but the underlying server is not responding. Run \`vis service restart ${y}\` to recover.`:b=`Target depends on the service ${y}, which is not running. Run \`vis service start ${y}\` first, or invoke \`${y}\` directly.`,p.push({message:b,targetId:y})}if(f.size===0)return{diagnostics:p,initialTasks:e,satisfiedServices:a,serviceDependentsByServiceId:new Map,serviceEnvByTaskId:new Map,taskGraph:i};const w=new Map,j=y=>{const E=new Set,R=[...i.dependencies[y]??[]],$=new Set;for(;R.length>0;){const O=R.pop();if(!$.has(O)){$.add(O),f.has(O)&&E.add(O);for(const T of i.dependencies[O]??[])$.has(T)||R.push(T)}}return[...E].sort()},M=new Map;for(const y of Object.keys(i.dependencies)){if(f.has(y))continue;const E=j(y);if(E.length===0)continue;const R={};for(const $ of E){const O=n.get($);if(!O)continue;Object.assign(R,O.env);const T=M.get($);T?T.push(y):M.set($,[y])}Object.keys(R).length>0&&w.set(y,R)}for(const y of M.values())y.sort();const x={};for(const[y,E]of Object.entries(i.tasks))f.has(y)||(x[y]=E);const g={};for(const[y,E]of Object.entries(i.dependencies))f.has(y)||(g[y]=E.filter(R=>!f.has(R)));const k=new Map;for(const y of Object.keys(x))k.set(y,0);for(const y of Object.values(g))for(const E of y)k.has(E)&&k.set(E,(k.get(E)??0)+1);const P=[];for(const y of i.roots)!f.has(y)&&x[y]&&P.push(y);for(const[y,E]of k)E===0&&!P.includes(y)&&x[y]&&P.push(y);const C=e.filter(y=>!f.has(y.id));return{diagnostics:p,initialTasks:C,satisfiedServices:a,serviceDependentsByServiceId:M,serviceEnvByTaskId:w,taskGraph:{dependencies:g,roots:P,tasks:x}}},Te="[[VIS_BOOT]]",Ui=250,zi=1e3,vt=3,Yi=t=>{try{return process.kill(t,0),!0}catch{return!1}},yt=t=>{try{const e=we(t,"utf8").trim(),s=Number.parseInt(e,10);return Number.isFinite(s)&&s>0?s:null}catch{return null}};class Ki{#e;#r;#s;#n;#t=new Map;#i=new Map;#o=new Map;#c=new Map;#a=new Set;constructor(e){this.#e=e.indexToId,this.#r=new Map(e.services),this.#s=e.sink,this.#n=e.workspaceRoot}onProcessEvent=e=>{if(e.kind!=="stdout"&&e.kind!=="stderr")return;const s=this.#e.get(e.index);s===void 0||e.text===void 0||this.onTaskOutput(s,e.text)};onTaskOutput(e,s){if(!this.#r.has(e))return;const o=((this.#t.get(e)??"")+s).split(`
|
|
59
|
+
`),n=o.pop()??"";this.#t.set(e,n);for(const l of o)this.#d(e,l)}notifyRegistryStarting(e){this.#s.starting(e)}notifyRegistryStarted(e,s){this.#s.started(e,s)}onRegistryTaskStarted(e){this.#r.get(e)?.mode==="registry"&&this.notifyRegistryStarting(e)}async onRegistryTaskClosed(e,s,r){if(this.#r.get(e)?.mode!=="registry")return;if(r||s!==0){this.notifyRegistryFailed(e,"exit-code",{exitCode:s,killed:r});return}const o=await Ps(this.#n,e);if(!o){this.notifyRegistryFailed(e,"missing-registry-entry");return}const{config:n}=o,l=n.readiness?.tcp?.port??n.port??0,d=n.readiness?.tcp?.host??"127.0.0.1";this.notifyRegistryReady(e,{host:d,logFile:o.logFile,pid:o.pid,port:l})}notifyRegistryReady(e,s){this.#s.ready(e,{host:s.host,port:s.port}),this.#h(e,s.logFile),s.pid!==null&&this.#p(e,s.pid)}notifyRegistryFailed(e,s,r){this.#s.failed(e,s,r)}async retry(e){const s=this.#r.get(e);if(s){if(this.#f(e),this.#t.delete(e),this.#i.delete(e),this.#s.starting(e),s.mode==="registry"){await this.#y(e,s.registry);return}s.mode==="ephemeral"&&this.#v(e,s.ephemeral)}}async dispose(){for(const e of[...this.#o.keys(),...this.#c.keys()])this.#f(e);this.#a.size>0&&(await Promise.race([Promise.all(this.#a),new Promise(e=>{setTimeout(e,2e3)})]),this.#a.clear()),this.#t.clear(),this.#i.clear()}#d(e,s){if(s.startsWith(Te)){this.#u(e,s.slice(Te.length));return}const r=this.#i.get(e)??[];r.push(s),r.length>vt&&r.shift(),this.#i.set(e,r),this.#s.log(e,`${s}
|
|
60
|
+
`)}#u(e,s){let r;try{r=JSON.parse(s)}catch{this.#s.log(e,`${Te+s}
|
|
61
|
+
`);return}switch(r.event){case"failed":{const i=typeof r.reason=="string"?r.reason:"unknown",o={};for(const[n,l]of Object.entries(r))n!=="event"&&n!=="id"&&n!=="reason"&&(o[n]=l);this.#s.failed(e,i,o);break}case"ready":{const i=typeof r.host=="string"?r.host:"127.0.0.1",o=typeof r.port=="number"?r.port:0;this.#s.ready(e,{host:i,port:o}),this.#l(e);break}case"started":{const i=typeof r.pid=="number"?r.pid:null;this.#s.started(e,i);break}default:this.#s.log(e,`${Te+s}
|
|
62
|
+
`)}}#l(e){const s=this.#r.get(e);if(s?.ephemeral===void 0)return;this.#h(e,s.ephemeral.logFile);const r=yt(s.ephemeral.pidFile);r!==null&&this.#p(e,r)}#h(e,s){if(this.#o.has(e)||!he(s))return;const r=cr(s,"r"),i=(()=>{try{return Qe(s).size}catch{return 0}})(),o={fd:r,logFile:s,pollTimer:setInterval(()=>{this.#g(e)},Ui),position:i};this.#o.set(e,o)}#g(e){const s=this.#o.get(e);if(s)try{const r=Qe(s.logFile);if(r.size<=s.position)return;const i=Buffer.alloc(r.size-s.position),o=ar(s.fd,i,0,i.length,s.position);if(o>0){s.position+=o;const n=i.subarray(0,o).toString("utf8");for(const l of n.split(`
|
|
63
|
+
`))l.length!==0&&this.#w(e,l);this.#s.log(e,n)}}catch{}}#w(e,s){const r=this.#i.get(e)??[];for(r.push(s);r.length>vt;)r.shift();this.#i.set(e,r)}#p(e,s){if(this.#c.has(e))return;const r={pid:s,timer:setInterval(()=>{if(!Yi(s)){const i=[...this.#i.get(e)??[]];this.#f(e),this.#s.crashed(e,i)}},zi)};this.#c.set(e,r)}#f(e){const s=this.#o.get(e);if(s){clearInterval(s.pollTimer);try{lr(s.fd)}catch{}this.#o.delete(e)}const r=this.#c.get(e);r&&(clearInterval(r.timer),this.#c.delete(e))}#v(e,s){if(s===void 0)return;const r=yt(s.pidFile);if(r!==null)try{process.kill(-r,"SIGTERM")}catch{}const i=Hr("node",[s.scriptPath,s.configFile],{cwd:s.cwd,stdio:["ignore","pipe","pipe"]});i.stdout.on("data",n=>{this.#m(e,n)}),i.stderr.on("data",n=>{this.#m(e,n)}),i.on("error",n=>{this.#s.failed(e,"respawn-error",{message:n.message})});const o=new Promise(n=>{const l=()=>{this.#a.delete(o),n()};i.once("exit",l),i.once("error",l)});this.#a.add(o)}#m(e,s){const o=((this.#t.get(e)??"")+s.toString("utf8")).split(`
|
|
64
|
+
`),n=o.pop()??"";this.#t.set(e,n);for(const l of o)this.#d(e,l)}async#y(e,s){if(s!==void 0){try{await Ms({id:e,workspaceRoot:this.#n})}catch{}try{const r=await Fs({command:s.command,config:s.config,cwd:s.cwd,env:s.env,id:e,workspaceRoot:this.#n}),i=s.config.readiness?.tcp?.port??s.config.port??0,o=s.config.readiness?.tcp?.host??"127.0.0.1";this.#s.started(e,r.entry.pid),this.notifyRegistryReady(e,{host:o,logFile:r.entry.logFile,pid:r.entry.pid,port:i})}catch(r){const i=r instanceof Error?r.message:String(r);this.#s.failed(e,"retry-failed",{message:i})}}}}const Xi=t=>{const e=t.overrides.visOptions;return e&&typeof e=="object"?e:void 0},Qt=(t,e,s)=>{const r=[],i=[];for(const o of e){const n=s.tasks[o];if(!n){i.push({id:o,reason:"task not in graph"});continue}const l=n.overrides.command;if(!l){i.push({id:o,reason:"no command resolved"});continue}const d=Xi(n);if(!d?.service){i.push({id:o,reason:"no service config"});continue}const h=He(t,n.projectRoot,!!d.runFromWorkspaceRoot),{envFile:f}=d,p=f===void 0||f===!1?{}:Gs(h,f),a=d.service.env??{};r.push({command:l,config:d.service,cwd:h,env:{...p,...a},id:o})}return{services:r,skipped:i}},Ji=(t,e)=>{const s=new Set(t),r=new Map;for(const n of t){const l=(e.dependencies[n]??[]).filter(d=>s.has(d));r.set(n,new Set(l))}const i=[],o=new Set;for(;r.size>0;){const n=[];for(const[l,d]of r){for(const h of d)o.has(h)&&d.delete(h);d.size===0&&n.push(l)}n.length===0&&n.push(...r.keys());for(const l of n)o.add(l),r.delete(l);n.sort(),i.push({ids:n})}return i},Qi=(t,e)=>{const s=[];for(const r of Ji(t,e))s.push(...r.ids);return s},Zi=String.raw`import { spawn } from "node:child_process";
|
|
65
|
+
import { closeSync, openSync, readFileSync, readSync, statSync, writeFileSync } from "node:fs";
|
|
66
|
+
import { createConnection } from "node:net";
|
|
67
|
+
|
|
68
|
+
const cfgPath = process.argv[2];
|
|
69
|
+
|
|
70
|
+
if (!cfgPath) {
|
|
71
|
+
console.error("[vis-service-bootstrap] missing config path");
|
|
72
|
+
process.exit(2);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const cfg = JSON.parse(readFileSync(cfgPath, "utf8"));
|
|
76
|
+
|
|
77
|
+
// Structured marker for service-event-bridge.ts to consume. Plain
|
|
78
|
+
// process.stdout.write keeps the line atomic and on the same stream
|
|
79
|
+
// as the tailed child log, so the parser sees one stream.
|
|
80
|
+
const emit = (event) => {
|
|
81
|
+
process.stdout.write("[[VIS_BOOT]]" + JSON.stringify({ ...event, id: cfg.id }) + "\n");
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
// Spawn the child with its stdio bound to a real file descriptor on
|
|
85
|
+
// disk — NOT inherited from the bootstrap. If the child inherited
|
|
86
|
+
// our stdio, it would inherit vis run's task pipes, and vis run would
|
|
87
|
+
// block waiting for those pipes to close even after this bootstrap
|
|
88
|
+
// exits. The logfile gives the grandchild a stable target it can keep
|
|
89
|
+
// writing to long after this bootstrap is gone.
|
|
90
|
+
const childLogFd = openSync(cfg.logFile, "a");
|
|
91
|
+
|
|
92
|
+
const child = spawn(cfg.command, {
|
|
93
|
+
cwd: cfg.cwd,
|
|
94
|
+
detached: true,
|
|
95
|
+
env: { ...process.env, ...cfg.env },
|
|
96
|
+
shell: true,
|
|
97
|
+
stdio: ["ignore", childLogFd, childLogFd],
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
// Close the bootstrap's copy of the fd; the child kept its own.
|
|
101
|
+
closeSync(childLogFd);
|
|
102
|
+
|
|
103
|
+
if (child.pid !== undefined) {
|
|
104
|
+
try {
|
|
105
|
+
writeFileSync(cfg.pidFile, String(child.pid));
|
|
106
|
+
} catch (error) {
|
|
107
|
+
console.error("[vis] failed to write pid file: " + (error?.message ?? String(error)));
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
emit({ event: "started", pid: child.pid ?? null });
|
|
112
|
+
|
|
113
|
+
let exitedEarly = false;
|
|
114
|
+
|
|
115
|
+
child.once("exit", (code, signal) => {
|
|
116
|
+
exitedEarly = true;
|
|
117
|
+
emit({ code, event: "failed", reason: "exited-before-ready", signal });
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
// Forward new bytes from the logfile to our stdout while we're alive.
|
|
121
|
+
// Polling-based tail; preflight is short, ~200ms per cycle is fine.
|
|
122
|
+
let tailPos = 0;
|
|
123
|
+
const tailFd = openSync(cfg.logFile, "r");
|
|
124
|
+
|
|
125
|
+
const flushTail = () => {
|
|
126
|
+
try {
|
|
127
|
+
const stat = statSync(cfg.logFile);
|
|
128
|
+
if (stat.size <= tailPos) return;
|
|
129
|
+
const remaining = stat.size - tailPos;
|
|
130
|
+
const buf = Buffer.alloc(remaining);
|
|
131
|
+
const n = readSync(tailFd, buf, 0, remaining, tailPos);
|
|
132
|
+
if (n > 0) {
|
|
133
|
+
process.stdout.write(buf.subarray(0, n));
|
|
134
|
+
tailPos += n;
|
|
135
|
+
}
|
|
136
|
+
} catch {}
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
const probeOnce = () => new Promise((resolve) => {
|
|
140
|
+
const socket = createConnection({ host: cfg.host || "127.0.0.1", port: cfg.port });
|
|
141
|
+
let settled = false;
|
|
142
|
+
const finish = (ok) => {
|
|
143
|
+
if (settled) return;
|
|
144
|
+
settled = true;
|
|
145
|
+
try { socket.destroy(); } catch {}
|
|
146
|
+
resolve(ok);
|
|
147
|
+
};
|
|
148
|
+
socket.once("connect", () => finish(true));
|
|
149
|
+
socket.once("error", () => finish(false));
|
|
150
|
+
socket.setTimeout(1000, () => finish(false));
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
154
|
+
|
|
155
|
+
(async () => {
|
|
156
|
+
const deadline = Date.now() + (cfg.timeoutMs ?? 30000);
|
|
157
|
+
while (Date.now() < deadline) {
|
|
158
|
+
flushTail();
|
|
159
|
+
if (exitedEarly) {
|
|
160
|
+
try { closeSync(tailFd); } catch {}
|
|
161
|
+
process.exit(1);
|
|
162
|
+
}
|
|
163
|
+
if (await probeOnce()) {
|
|
164
|
+
flushTail();
|
|
165
|
+
emit({ event: "ready", host: cfg.host || "127.0.0.1", port: cfg.port });
|
|
166
|
+
try { closeSync(tailFd); } catch {}
|
|
167
|
+
child.unref();
|
|
168
|
+
process.exit(0);
|
|
169
|
+
}
|
|
170
|
+
await sleep(200);
|
|
171
|
+
}
|
|
172
|
+
flushTail();
|
|
173
|
+
emit({ event: "failed", reason: "timeout", timeoutMs: cfg.timeoutMs ?? 30000 });
|
|
174
|
+
try { closeSync(tailFd); } catch {}
|
|
175
|
+
try { process.kill(-child.pid, "SIGTERM"); } catch {}
|
|
176
|
+
process.exit(1);
|
|
177
|
+
})();
|
|
178
|
+
`,eo=()=>{const t=dr(ne(Wr(),"vis-services-")),e=ne(t,"bootstrap.mjs");return At(e,Zi),{runDir:t,scriptPath:e}},Zt=(t,e,s)=>{const r=s.replaceAll(/[^\w-]/g,"_");return{configFile:ne(t,`${r}.json`),logFile:ne(t,`${r}.log`),pidFile:ne(t,`${r}.pid`),scriptPath:e}},to=t=>{const{paths:e,service:s}=t,r=s.config.readiness?.tcp?.port??s.config.port;if(typeof r!="number")throw new TypeError(`Service ${s.id} has no TCP readiness port — declare \`service.port\` or \`service.readiness.tcp.port\`.`);const i={...s.env,PATH:hs(s.cwd,s.env)};return{command:s.command,cwd:s.cwd,env:i,host:s.config.readiness?.tcp?.host??"127.0.0.1",id:s.id,logFile:e.logFile,pidFile:e.pidFile,port:r,timeoutMs:s.config.readiness?.tcp?.timeoutMs??3e4}},so=t=>`node ${JSON.stringify(t.scriptPath)} ${JSON.stringify(t.configFile)}`,ro=t=>{const{id:e,visBin:s,workspaceRoot:r}=t;return`node ${JSON.stringify(s)} service start ${JSON.stringify(e)} --cwd ${JSON.stringify(r)}`},no=t=>{const{missingServiceIds:e,mode:s,taskGraph:r,visBin:i,workspaceRoot:o}=t,{services:n,skipped:l}=Qt(o,e,r);if(n.length===0)return{chain:[],ephemeralPidFiles:[],runDir:void 0,serviceEnvByTaskId:new Map,skipped:l};const d=Qi(n.map(x=>x.id),r),h=new Map(n.map(x=>[x.id,x])),f=[],p=[];if(s==="ephemeral")for(const x of d){const g=h.get(x);g&&p.push({id:x,payload:to({paths:{logFile:"",pidFile:""},service:g})})}let a;s==="ephemeral"&&(a=eo());let m;for(const x of d){const g=h.get(x),k=r.tasks[x];if(!g||!k)continue;let P;if(s==="ephemeral"){const C=Zt(a.runDir,a.scriptPath,x),E={...p.find(R=>R.id===x).payload,logFile:C.logFile,pidFile:C.pidFile};At(C.configFile,JSON.stringify(E)),P=so(C),f.push(C.pidFile)}else P=ro({id:x,visBin:i,workspaceRoot:o});if(k.overrides={...k.overrides,command:P},k.cache=!1,r.tasks[x]=k,m!==void 0){const C=r.dependencies[x]??[];C.includes(m)||(r.dependencies[x]=[...C,m])}m=x}const w=new Set(d),j=new Map,M=x=>{const g=new Set,k=[...r.dependencies[x]??[]],P=new Set;for(;k.length>0;){const C=k.pop();if(!P.has(C)){P.add(C),w.has(C)&&g.add(C);for(const y of r.dependencies[C]??[])P.has(y)||k.push(y)}}return[...g].sort()};for(const x of Object.keys(r.dependencies)){if(w.has(x))continue;const g=M(x);if(g.length===0)continue;const k={};for(const P of g){const C=h.get(P);C?.config.env&&Object.assign(k,C.config.env)}Object.keys(k).length>0&&j.set(x,k)}return{chain:d,ephemeralPidFiles:f,runDir:a?.runDir,serviceEnvByTaskId:j,skipped:l}},io=new Set(["auto","ephemeral","off","persistent"]),oo=t=>t.cli!==void 0?"cli":t.config===void 0?"default":"config",co=t=>{const{cli:e,config:s,isCi:r,isPersistentTarget:i,isTty:o,target:n}=t;if(e!==void 0&&!io.has(e))throw new Error(`--services: expected one of auto|ephemeral|persistent|off, got "${e}"`);const l=e??s??(o&&!r?"auto":"off");return l==="off"?"off":l==="ephemeral"?"ephemeral":l==="persistent"?"registry":i||n==="dev"?"ephemeral":"registry"},ao=async({config:t,initialTasks:e,logger:s,options:r,persistentTasks:i,target:o,taskGraph:n,workspaceRoot:l})=>{let d=e,h=n;const f=process.env.VIS_VERSION??"0.0.0",p=r.dryRun?void 0:async $=>{try{return await Os($.config,{timeoutMs:ln}),!0}catch{return!1}},a=await As(l),m=await Vi({initialTasks:[...d,...i],probe:p,registeredEntries:a,taskGraph:h,visVersion:f}),w=[];let j,M=0;const x=[],g=new Map;let k=[];const P=new Set;let C=null,y=null;if(m.diagnostics.length>0){const $=!!(process.stdout.isTTY&&process.stdin.isTTY),O=r.dryRun?"off":co({cli:r.services,config:t.run?.services,isCi:!!Se,isPersistentTarget:i.length>0,isTty:$,target:o});if(O==="off"){for(const W of m.diagnostics)s.error(W.message);const A=oo({cli:r.services,config:t.run?.services}),L=[];throw r.dryRun?L.push("`--dry-run` never starts services; drop it to let vis boot them."):A==="default"?L.push("vis only auto-starts service deps in an interactive terminal by default (this run is CI or non-TTY).","Pass `--services=ephemeral` to boot them for this run, or set `run.services` in vis.config.ts."):A==="cli"?L.push("`--services=off` was passed; use `--services=ephemeral` to boot them for this run."):L.push('`run.services: "off"` is set in vis.config.ts; override it with `--services=ephemeral`.'),new pe([`${m.diagnostics.length} service dependency error(s) — start the missing services or invoke them directly.`,...L].join(`
|
|
179
|
+
`))}const T=m.diagnostics.map(A=>A.targetId),b=O,_=b==="registry"?Qt(l,T,h):void 0,D=process.argv[1]??"vis",G=no({missingServiceIds:T,mode:b,taskGraph:h,visBin:D,workspaceRoot:l});if(G.skipped.length>0){for(const{id:A,reason:L}of G.skipped)s.error(`Cannot auto-start ${A}: ${L}`);throw new pe(`${G.skipped.length} service(s) cannot be auto-started — invoke them directly or add a service config.`)}w.push(...G.ephemeralPidFiles),j=G.runDir,k=G.chain;for(const A of G.chain)P.add(A);if(b==="registry"&&(M=G.chain.length,x.push(...G.chain)),G.chain.length>0){const A=new wt(G.chain),L=new Map;if(b==="ephemeral"&&G.runDir)for(const W of G.chain){const q=Zt(G.runDir,`${G.runDir}/bootstrap.mjs`,W);L.set(W,{ephemeral:{configFile:q.configFile,cwd:l,logFile:q.logFile,pidFile:q.pidFile,scriptPath:q.scriptPath},mode:"ephemeral"})}else if(b==="registry"&&_)for(const W of _.services)L.set(W.id,{mode:"registry",registry:{command:W.command,config:W.config,cwd:W.cwd,env:W.env}});if(L.size>0){const W=new Ki({indexToId:new Map,services:L,sink:{crashed:(q,B)=>{A.markCrashed(q,B)},failed:(q,B,Y)=>{A.markFailed(q,B,Y)},log:(q,B)=>{A.appendLog(q,B)},ready:(q,B)=>{A.markReady(q,B)},started:(q,B)=>{A.markStarted(q,B),b==="registry"&&B!==null&&g.set(q,B)},starting:q=>{A.markStarting(q)}},workspaceRoot:l});C=A,y=W}}for(const[A,L]of G.serviceEnvByTaskId){const W=m.serviceEnvByTaskId.get(A)??{};m.serviceEnvByTaskId.set(A,{...W,...L})}}const E=new Set(i.map($=>$.id));if(d=m.initialTasks.filter($=>!E.has($.id)),h=m.taskGraph,k.length>0&&(d=[...k.map(O=>h.tasks[O]).filter(O=>O!==void 0),...d]),i.length>0){const $=new Set(i.map(D=>D.id)),O={};for(const[D,G]of Object.entries(h.tasks))$.has(D)||(O[D]=G);const T={};for(const[D,G]of Object.entries(h.dependencies))$.has(D)||(T[D]=G.filter(A=>!$.has(A)));const b=new Set;for(const D of Object.values(T))for(const G of D)b.add(G);const _=Object.keys(O).filter(D=>!b.has(D));h={dependencies:T,roots:_,tasks:O}}const{serviceEnvByTaskId:R}=m;if(m.satisfiedServices.length>0){const $=m.satisfiedServices.map(O=>O.id).join(", ");if(s.debug?.(`Auto-attached to running services: ${$}`),C)for(const O of m.satisfiedServices)C.registerService(O.id);else C=new wt(m.satisfiedServices.map(O=>O.id));for(const O of m.satisfiedServices){const T=O.config.readiness?.tcp?.port??O.config.port??0,b=O.config.readiness?.tcp?.host??"127.0.0.1";C.markReady(O.id,{host:b,port:T})}}return{ephemeralPidFiles:w,initialTasks:d,injectedServiceIdSet:P,registryStartedCount:M,registryStartedIds:x,registryStartedPids:g,serviceDockStore:C,serviceEnvByTaskId:R,serviceEventBridge:y,serviceResult:m,serviceRunDir:j,taskGraph:h}},lo=(t,e)=>{const s=e?.trim();if(!s)return{filter:void 0,tasks:[...t]};const r=s.toLowerCase();return{filter:s,tasks:t.filter(i=>i.target.project.toLowerCase().includes(r))}},uo=[""," Watch keybinds:"," r, Enter rerun"," a rerun all (clear filter)"," p filter by project name"," q, Ctrl+C quit"," h, ? show this help",""].join(`
|
|
180
|
+
`),fo=t=>{t.write(`${uo}
|
|
181
|
+
`)},ho=async(t,e)=>{e.write("filter projects (empty to cancel) > ");const s=t,r=s.isRaw===!0;if(r)try{s.setRawMode?.(!1)}catch{}return await new Promise(i=>{let o="";const n=l=>{o+=typeof l=="string"?l:l.toString("utf8");const d=o.indexOf(`
|
|
182
|
+
`);if(d===-1)return;const h=o.slice(0,d).replace(/\r$/,"").trim();if(t.off("data",n),r)try{s.setRawMode?.(!0)}catch{}i(h.length>0?h:void 0)};t.on("data",n)})},po=t=>{const{handlers:e}=t,s=t.input??process.stdin,r=t.output??process.stdout,i=t.promptFilter??ho;if(!s||s.isTTY===!1)return{close:()=>{}};$r(s);const o=s.isRaw===!0;try{s.setRawMode?.(!0)}catch{return{close:()=>{}}}typeof s.resume=="function"&&s.resume();let n=!1;const l=async f=>{if(f.ctrl===!0&&f.name==="c"){await e.onQuit();return}if(!n)switch(f.name){case"?":case"h":{await e.onHelp();break}case"a":{await e.onClearFilter();break}case"p":{n=!0;try{const p=await i(s,r);p===void 0?r.write(`filter cancelled.
|
|
183
|
+
`):await e.onFilter(p)}finally{n=!1}break}case"q":{await e.onQuit();break}case"r":{await e.onRerun();break}case"return":{await e.onRerun();break}}},d=(f,p)=>{l(p).catch(a=>{r.write(`[vis watch] keybind handler failed: ${a.message}
|
|
184
|
+
`)})},h=s;return h.on("keypress",d),{close:()=>{if(h.off("keypress",d),!o)try{s.setRawMode?.(!1)}catch{}const f=s;if(typeof f.pause=="function")try{f.pause()}catch{}}}},mo=({firstRun:t,hasFailure:e,logger:s,options:r,workspaceRoot:i})=>{if(r.flaky){const l=tr(i,{minRuns:2},t.runHistory);if(l.length>0){s.info(""),s.info("Flaky tasks (based on historical runs):"),s.info("");for(const d of sr(l))s.info(` ${d}`);s.info("")}}const o=[];for(const[l,d]of t.results)d.retryAttempts&&d.retryAttempts>0&&o.push(l);const n=r.failOnRetry&&o.length>0;if(n){const d=o.slice(0,5),h=o.length-d.length,f=h>0?`${d.join(", ")}, and ${String(h)} more`:d.join(", ");s.warn(""),s.warn(`--fail-on-retry: ${String(o.length)} task(s) succeeded only after retry: ${f}`)}if(e||n){const l=n&&!e?"Some tasks succeeded only after retry (--fail-on-retry).":"Some tasks failed.",d=2e3,h=[];for(const[f,p]of t.results){if(p.status!=="failure")continue;const a=p.terminalOutput??"",m=a.length>d?`…${a.slice(-d)}`:a,w=p.code??"?";h.push(` ${f} (exit ${String(w)}):
|
|
185
|
+
${m.split(`
|
|
186
|
+
`).map(j=>` ${j}`).join(`
|
|
187
|
+
`)}`)}throw new pe(h.length>0?`${l}
|
|
188
|
+
${h.join(`
|
|
189
|
+
`)}`:l)}},es=({logger:t,registryStartedCount:e,stopServicesOnExit:s})=>{e>0&&(t.info(""),s?t.info(`${String(e)} service(s) stopped (--stop-services).`):t.info(`${String(e)} service(s) started in the background. Run \`vis service stop --all\` to clean up.`))},go=async({initialTasks:t,logger:e,options:s,persistentTasks:r,projectGraph:i,projectsWithTarget:o,registryStartedCount:n,runtime:l,serviceEventBridge:d,stopServicesOnExit:h,taskGraph:f,visConfig:p,workspace:a,workspaceRoot:m})=>{const{childEnvPolicyFor:w,failureLogLifeCycle:j,hookLifeCycle:M,hooks:x,lifecycleOptions:g,maybeWriteProfile:k,outputStyle:P,preTraceCheck:C,resolveCommand:y,runnerOptions:E,sharedRetryBudget:R,spawnContext:$,startTime:O,strictEnvFailure:T}=l;let b=t;const _=new Map,D=typeof s.log=="string"?s.log.toLowerCase():"",G=D==="labeled"||D==="grouped"||D==="interleaved"?D:void 0,A=G?ps(G):void 0,L=new jt([new Xn({...g,ciGrouping:p?.run?.ciGrouping??"auto",logReporter:A,outputStyle:P}),M,j]),W=Kt({hooks:x,lifeCycle:L,mutexPool:_,resolveCommand:y,retryBudget:R,serviceEventBridge:d??void 0,spawnContext:$,strictEnvFailure:T,workspaceRoot:m}),q=async()=>{const U=Date.now(),Q=await St(b,E,{childEnvPolicy:w,lifeCycle:L,preTraceCheck:C,projectGraph:i,resolveChildEnv:(H,oe)=>ke($,H,oe),resolveCommand:y,taskExecutor:W,taskGraph:f,workspaceRoot:m}),J=Date.now()-U;if(s.summarize){const H=kt(Q,f,O);await ms(H,m,{dataDirectory:Ce(m)})}let te=!1;for(const[,H]of Q)H.status==="failure"&&(te=!0);const re=rr(Q,J),N=nr(m),z=ir(m,J,N);return e.info(""),e.info(` ${re}${z?` ${z}`:""}`),{hasFailure:te,results:Q,runHistory:N}},B=await q();await x.callHook("run:after",B.results),await k(B.results);const{hasFailure:Y}=B;if(s.watch){const U=o.map(Z=>{const ie=a.projects[Z]?.root;if(ie)return ie.startsWith("/")?ie:`${m}/${ie}`}).filter(Z=>Z!==void 0),Q=b;let J;const te=Z=>{const se=lo(Q,Z);return J=se.filter,b=se.tasks,se.tasks.length};let re=!1,N=B.results;const z=()=>{const Z=tt(N,m);if(Z.directories.length>0&&Z.files.size>0){const se=qr(Z.files,m,Z.directories);return{handle:st({filter:se,onChange:oe,paths:Z.directories}),mode:"tracked"}}return{handle:st({onChange:oe,paths:U}),mode:"roots"}};let H;const oe=async Z=>{if(!re){re=!0;try{e.info(`Change detected in ${Z.length} file(s), rerunning…`),N=(await q()).results,H?.close(),H=z().handle}finally{re=!1}}},ae=z();H=ae.handle;const de=ae.mode==="tracked"?`Watching ${String(tt(N,m).files.size)} tracked file(s)`:`Watching ${String(U.length)} project root(s)`;e.info(`${de} — edit a file to rerun, press h for keybinds, q to quit.`);const K=async()=>{if(!re){re=!0;try{if(b.length===0){e.info("No tasks match the active filter — press a to clear it.");return}N=(await q()).results,H?.close(),H=z().handle}finally{re=!1}}};await new Promise(Z=>{let se=!1,ie;const ue=()=>{I()},I=()=>{se||(se=!0,ie?.close(),process.off("SIGINT",ue),H?.close(),Z())};process.on("SIGINT",ue),ie=po({handlers:{onClearFilter:async()=>{const S=te(void 0);e.info(`Filter cleared — running ${String(S)} task(s).`),await K()},onFilter:async S=>{const F=J,ee=te(S);if(ee===0){e.info(`Filter "${S}" matched no projects — keeping previous filter.`),te(F);return}e.info(`Filter "${S}" matched ${String(ee)} task(s).`),await K()},onHelp:()=>{fo(process.stdout)},onQuit:()=>{I()},onRerun:K}})});return}mo({firstRun:B,hasFailure:Y,logger:e,options:s,workspaceRoot:m}),r.length>0&&!s.failFast&&await Bt(r,$,void 0),es({logger:e,registryStartedCount:n,stopServicesOnExit:h})},wo=t=>t.split(",").map(e=>e.trim()).filter(e=>e!==""),vo=(t,e,s)=>{const r=new Set,i=[];if(t===void 0||t.trim()==="")return{skipTaskIds:r,unmatchedPatterns:i};const o=[...s],n=new Set(o),l=new Map;for(const d of o){const h=d.lastIndexOf(":");if(h===-1)continue;const f=d.slice(h+1),p=l.get(f);p===void 0?l.set(f,[d]):p.push(d)}for(const d of wo(t)){if(d.startsWith("~:"))throw new Error(`--skip-cache does not support the closest-project selector "~:" (received "${d}"). Use \`pkg:target\`, \`:target\`, or \`#tag:target\`.`);if(n.has(d)){r.add(d);continue}const h=_r(d);if(!h){i.push(d);continue}let f=!1;switch(h.kind){case"all":{const p=l.get(h.target)??[];for(const a of p)r.add(a),f=!0;break}case"project":{const p=h.projects?.[0];if(p!==void 0){const a=`${p}:${h.target}`;n.has(a)&&(r.add(a),f=!0)}break}case"tag":{const{tag:p}=h;if(p!==void 0){const a=l.get(h.target)??[];for(const m of a){const w=m.slice(0,m.lastIndexOf(":"));e.projects[w]?.tags?.includes(p)===!0&&(r.add(m),f=!0)}}break}}f||i.push(d)}return{skipTaskIds:r,unmatchedPatterns:i}},yo=({affectedFiles:t,config:e,initialTasks:s,logger:r,options:i,persistentTasks:o,projectGraph:n,projectOptions:l,workspace:d})=>{const h=new Set([...s,...o].map(p=>p.id)),f=vs([...s,...o],{onCycleBroken:p=>{r.warn(`Ignoring dev-only dependency cycle (build order is ambiguous): ${p.join(" → ")}`)},onUnmatchedProjectSelector:p=>{r.warn(`dependsOn.projects entry "${p}" matched no project — that dependency edge was not created.`)},projectGraph:n,targetDefaults:e.tasks,workspace:d});for(const[p,a]of Object.entries(f.tasks)){const m=a.target.project,w=a.target.target,j=l.get(m)?.[w];if(!j){h.has(p)||r.warn(`${w} required via dependsOn but no command is configured for ${m} — skipping (no-op).`);continue}const M=d.projects[m];let x=!1;const g={...a.overrides};g.visOptions===void 0&&j.options&&(g.visOptions=j.options,x=!0),g.command===void 0&&j.command&&(g.command=bt(j.command,{affectedFiles:t,projectRoot:M?.root}),x=!0),x&&(a.overrides=g,f.tasks[p]=a)}if(typeof i.skipCache=="string"&&i.skipCache.trim()!=="")if(i.cache){const p=vo(i.skipCache,d,Object.keys(f.tasks));for(const a of p.skipTaskIds){const m=f.tasks[a];m!==void 0&&(m.cache=!1)}p.unmatchedPatterns.length>0&&r.warn(`--skip-cache: no tasks matched ${p.unmatchedPatterns.map(a=>`"${a}"`).join(", ")}`),p.skipTaskIds.size>0&&r.debug?.(`--skip-cache: bypassing cache for ${String(p.skipTaskIds.size)} task(s)`)}else r.debug?.("--skip-cache ignored: --no-cache already disables caching for the whole run");return f},xo=({logger:t,options:e,projectOptions:s,taskGraph:r})=>{let i=r;e.reverse&&(i=gs(i),t.debug?.(`Reversed task graph: ${String(i.roots.length)} new root(s) (originally leaves)`));for(const o of Object.values(i.tasks)){const n=s.get(o.target.project)?.[o.target.target]?.options;o.splitCompound&&$t(n)!==void 0&&(t.warn(`splitCompound ignored for ${o.id}: it uses a custom shell. Running the command as one unit.`),o.splitCompound=void 0)}return i=ws(i,{commandOf:o=>o.overrides.command,onDiagnostic:(o,n)=>{t.warn(n)}}),i},ts=t=>t.replace(/^--?/u,""),jo=new Set(["0","1","false","no","true","yes"]),So=t=>!t.startsWith("-")||/^-(?:\d|\.\d)/u.test(t),xt=(t,e,s,r,i,o)=>{if(r!==void 0)return t.set(e,r),0;const n=i[o+1];return(s?.type??"string")==="boolean"?n!==void 0&&jo.has(n.toLowerCase())?(t.set(e,n.toLowerCase()),1):(t.set(e,"true"),0):n!==void 0&&So(n)?(t.set(e,n),1):(t.set(e,"true"),0)},ko=(t,e)=>{const s=t.type??"string";if(s==="number"){const r=e.trim(),i=Number(r);return r===""||!Number.isFinite(i)?{error:`--${t.name} expects a number, got "${e}"`}:{value:i}}if(s==="boolean")return["1","true","yes"].includes(e.toLowerCase())?{value:!0}:["0","false","no"].includes(e.toLowerCase())?{value:!1}:{error:`--${t.name} expects a boolean, got "${e}"`};if(s==="enum"){const r=t.choices??[];return r.includes(e)?{value:e}:{error:`--${t.name} must be one of [${r.join(", ")}], got "${e}"`}}return{value:e}},bo=t=>{const e=[],s=new Set;for(const r of t){const i=r.name||"<unnamed>";(!r.name||!/^[a-zA-Z][\w-]*$/u.test(r.name))&&e.push(`argument name "${i}" is empty or invalid (start with a letter; use letters, digits, '-', '_')`),s.has(r.name)&&e.push(`duplicate argument name "${i}"`),s.add(r.name),r.alias!==void 0&&r.alias.length!==1&&e.push(`argument "${i}" alias "${r.alias}" must be a single character`);const o=r.type??"string";if(o==="enum"&&(r.choices===void 0||r.choices.length===0)&&e.push(`argument "${i}" has type "enum" but declares no choices`),r.default!==void 0){const n=typeof r.default;o==="number"&&n==="number"||o==="boolean"&&n==="boolean"||(o==="string"||o==="enum")&&n==="string"?o==="enum"&&r.choices&&!r.choices.includes(r.default)&&e.push(`argument "${i}" default "${String(r.default)}" is not one of its choices`):e.push(`argument "${i}" default ${JSON.stringify(r.default)} does not match type "${o}"`)}}return e},To=(t,e)=>{const s=new Map,r=new Map;for(const h of t)s.set(h.name,h),h.alias&&r.set(h.alias,h);const i=new Map,o=[];for(let h=0;h<e.length;h+=1){const f=e[h];if(f==="--"){o.push(...e.slice(h+1));break}if(f.startsWith("--no-")){i.set(ts(f.slice(5)),"false");continue}const p=/^--([^=]+)(?:=(.*))?$/su.exec(f);if(p){const w=p[1];h+=xt(i,w,s.get(w),p[2],e,h);continue}const a=/^-([^=-])(?:=(.*))?$/su.exec(f),m=a?.[1];if(a&&m!==void 0){const w=r.get(m);h+=xt(i,w?.name??m,w,a[2],e,h);continue}o.push(f)}const n={},l=[];let d=0;for(const h of t){let f=i.get(h.name);if(f===void 0&&h.positional&&d<o.length&&(f=o[d],d+=1),f===void 0){h.default!==void 0?n[h.name]=h.default:h.required&&l.push(`missing required argument --${h.name}`);continue}const{error:p,value:a}=ko(h,f);p?l.push(p):a!==void 0&&(n[h.name]=a)}return{errors:l,values:n}},$o=t=>`VIS_ARG_${ts(t).replaceAll(/[^a-zA-Z0-9]+/gu,"_").toUpperCase()}`,Co=t=>{const e={};for(const[s,r]of Object.entries(t))e[$o(s)]=String(r);return e},De=(t,e,s)=>{const r=[`Usage: vis run ${t} [-- <args>]`];if(e&&r.push("",e),s.length===0)return r.join(`
|
|
190
|
+
`);r.push("","Arguments:");const i=s.map(n=>{const l=n.positional?`<${n.name}>`:`--${n.name}`,d=n.alias?`, -${n.alias}`:"";return{left:`${l}${d}`,right:n}}),o=Math.max(...i.map(n=>n.left.length));for(const{left:n,right:l}of i){const d=[],h=l.type??"string";d.push(h==="enum"?`enum(${(l.choices??[]).join("|")})`:h),l.required&&d.push("required"),l.default!==void 0&&d.push(`default: ${String(l.default)}`);const f=`${l.description??""}${l.description?" ":""}[${d.join(", ")}]`;r.push(` ${n.padEnd(o)} ${f}`)}return r.join(`
|
|
191
|
+
`)},Io=(t,e,s,r)=>{if(!s||s.length===0)return{env:{},kind:"ok"};const i=bo(s);if(i.length>0)return{errors:i.map(n=>`invalid \`arguments\` schema for "${t}": ${n}`),help:De(t,e,s),kind:"invalid"};if(r.includes("--help")||r.includes("-h"))return{kind:"help",text:De(t,e,s)};const o=To(s,r);return o.errors.length>0?{errors:o.errors,help:De(t,e,s),kind:"invalid"}:{env:Co(o.values),kind:"ok"}},Eo=({forwardedArgs:t,logger:e,projectsWithTarget:s,projectTargetIndex:r,target:i})=>{const o=s.map(f=>({project:f,schema:r.get(f)?.arguments})).filter(f=>Array.isArray(f.schema)&&f.schema.length>0),n=new Map;for(const{project:f,schema:p}of o){const a=JSON.stringify(p),m=n.get(a)??[];m.push(f),n.set(a,m)}if(n.size>1){const f=[...n.values()].map(p=>p.join(", ")).join(" | ");throw new Error(`Target "${i}" declares conflicting \`arguments\` schemas across projects (${f}). Run a single project (e.g. \`vis run ${o[0]?.project}:${i}\` or --projects=<name>) so the argument contract is unambiguous.`)}const l=o[0]?.schema,d=r.get(o[0]?.project??s[0])?.description,h=Io(i,d,l,t);if(h.kind==="help"){e.info(h.text);return}if(h.kind==="invalid"){e.info(`Invalid arguments for "${i}":`);for(const f of h.errors)e.info(` ✖ ${f}`);throw e.info(""),e.info(h.help),new Error(`Invalid arguments for target "${i}"`)}return{env:h.env}},Ro=new Set(["cache","command","dependsOn","fingerprintEnv","hashMode","inputs","outputs","parallelism","splitCompound","untrackedEnv"]),Po=t=>t?Object.keys(t).filter(e=>Ro.has(e)).toSorted():[],Mo=(t,e)=>`${t}: ${e.map(s=>`"${s}"`).join(", ")} ${e.length===1?"is a target property, not an option":"are target properties, not options"}, so ${e.length===1?"it is":"they are"} ignored under "options". Move ${e.length===1?"it":"them"} next to "command".`,Fo=({affectedFiles:t,forwardedArgs:e,logger:s,options:r,projectsWithTarget:i,projectTargetIndex:o,target:n,taskArgumentEnvVars:l,workspace:d})=>{const h=r.pty,f=rn(r.hashMode);let p=i.map(j=>{const M=d.projects[j],x=o.get(j),g={project:j,target:n},k=`${j}:${n}`,P=h?{...x.options,pty:x.options?.pty??!0}:x.options,C=x.command?bt(x.command,{affectedFiles:t,projectRoot:M?.root}):x.command,y=M?.root&&M.root.length>0?M.root:".",E=(x.outputs??[]).map($=>typeof $!="string"?$:$.replaceAll("{projectRoot}",y).replaceAll("{projectName}",j)),R=Po(x.options);return R.length>0&&s.warn(Mo(k,R)),{cache:x.cache,declaresInputs:x.inputs!==void 0,fingerprintEnv:x.fingerprintEnv,hashMode:f??x.hashMode,id:k,outputs:E,overrides:{command:C,...e.length>0?{[Dt]:e}:{},...Object.keys(l).length>0?{[Vs]:l}:{},...P?{visOptions:P}:{}},parallelism:x.parallelism,projectRoot:M?.root,splitCompound:x.splitCompound,target:g,untrackedEnv:x.untrackedEnv}});const a=[],m=[];for(const j of p)je(j)?.persistent?(j.cache=!1,a.push(j)):m.push(j);p=m;const w=ys(r.partition);if(w&&(p=xs.partitionTasks(p,w),s.info(`Partition ${w.index}/${w.total}: running ${p.length} task(s)`),p.length===0)){s.info("No tasks assigned to this partition.");return}return{initialTasks:p,persistentTasks:a}},Oo=({affectedFiles:t,config:e,forwardedArgs:s,logger:r,options:i,projectGraph:o,projectOptions:n,projectsWithTarget:l,projectTargetIndex:d,target:h,workspace:f})=>{const p=Eo({forwardedArgs:s,logger:r,projectsWithTarget:l,projectTargetIndex:d,target:h});if(!p)return;const a=Fo({affectedFiles:t,forwardedArgs:s,logger:r,options:i,projectsWithTarget:l,projectTargetIndex:d,target:h,taskArgumentEnvVars:p.env,workspace:f});if(!a)return;const{persistentTasks:m}=a,{initialTasks:w}=a,j=yo({affectedFiles:t,config:e,initialTasks:w,logger:r,options:i,persistentTasks:m,projectGraph:o,projectOptions:n,workspace:f});return{initialTasks:w,persistentTasks:m,taskGraph:j}},dc=async({argument:t,logger:e,options:s,visConfig:r,workspaceRoot:i})=>{if(!i)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const o=i;if(bs({options:s,visConfig:r},o),Ts(o),s.lastDetails){await en(o,e);return}const n=process.cwd(),l=await js(o,r),{config:d,fileOwners:h,packageJsons:f,projectOptions:p,workspace:a}=Ss(o,r,l),m=ks(o,a,f),w=await Gi({argument:t,config:d,fileOwners:h,logger:e,options:s,packageJsons:f,projectGraph:m,projectOptions:p,visConfig:r,workspace:a,workspaceRoot:o});if(!w)return;const{affectedFiles:j,currentOs:M,forwardedArgs:x,projectsWithTarget:g,projectTargetIndex:k,target:P}=w,C=Oo({affectedFiles:j,config:d,forwardedArgs:x,logger:e,options:s,projectGraph:m,projectOptions:p,projectsWithTarget:g,projectTargetIndex:k,target:P,workspace:a});if(!C)return;const{persistentTasks:y}=C;let{initialTasks:E,taskGraph:R}=C;await hi({config:d,logger:e,options:s,packageJsons:f,workspaceRoot:o});const $=await ao({config:d,initialTasks:E,logger:e,options:s,persistentTasks:y,target:P,taskGraph:R,workspaceRoot:o});E=$.initialTasks,R=$.taskGraph;const{ephemeralPidFiles:O,injectedServiceIdSet:T,registryStartedCount:b,registryStartedIds:_,registryStartedPids:D,serviceDockStore:G,serviceEnvByTaskId:A,serviceEventBridge:L,serviceResult:W,serviceRunDir:q}=$;if(R=xo({logger:e,options:s,projectOptions:p,taskGraph:R}),s.dryRun){hn({config:d,logger:e,persistentTasks:y,taskGraph:R});return}const B=await xi({affectedFiles:j,config:d,currentOs:M,initialTasks:E,invocationCwd:n,logger:e,options:s,persistentTasks:y,projectsWithTarget:g,serviceEnvByTaskId:A,serviceResult:W,target:P,taskGraph:R,visConfig:r,workspaceRoot:o});await B.hooks.callHook("run:before",{tasks:E,workspaceRoot:o});const Y=s.stopServices,U=fn({ephemeralPidFiles:O,registryStartedIds:_,registryStartedPids:D,serviceEventBridge:L,serviceRunDir:q,stopServicesOnExit:Y,workspaceRoot:o});U.install();try{if(B.isTTY){const{spawnContext:Q}=B,{dynamic:J,lifeCycle:te,stdinRegistry:re,store:N,taskExecutor:z}=ti({injectedServiceIdSet:T,runtime:B,serviceDockStore:G,serviceEventBridge:L,workspaceRoot:o});let H="rerun",oe=null,ae=new Map;for(;H!=="quit";){if(H==="rerun")ae=await si({dynamic:J,initialTasks:E,lifeCycle:te,options:s,persistentTasks:y,projectGraph:m,runtime:B,stdinRegistry:re,store:N,taskExecutor:z,taskGraph:R,workspaceRoot:o});else if(H==="retry"&&oe){const K=R.tasks[oe]??E.find(se=>se.id===oe),Z=K?ze(K,Q.affectedFiles,M):void 0;if(K&&Z){te.startTasks?.([K]);const se=new We(Ie),ie=Us(Q,K),I=(await $e([{command:Z,cwd:ie.cwd,env:ie.env,inheritEnv:ie.inheritEnv,name:K.id,ptySize:{cols:process.stdout.columns??80,rows:process.stdout.rows??24},stdin:"pty"}],{onEvent:S=>{S.kind==="started"&&S.write&&re.set(K.id,{kill:S.kill,resize:S.resize,write:S.write}),(S.kind==="stdout"||S.kind==="stderr")&&S.text&&(se.write(S.text),N.setOutput(K.id,se.toString())),S.kind==="close"&&re.delete(K.id)}})).closeEvents[0];te.endTasks?.([{code:I?.exitCode??1,status:I?.exitCode===0?"success":"failure",task:K,terminalOutput:N.getSnapshot().outputs.get(K.id)}])}else K&&te.endTasks?.([{code:1,status:"failure",task:K,terminalOutput:`No command configured for ${K.id}`}]);oe=null,N.markDone()}const de=await ri({dynamic:J,store:N});H=de.action,oe=de.retryTaskId}await J.renderIsDone,await B.hooks.callHook("run:after",ae),await B.maybeWriteProfile(ae),es({logger:e,registryStartedCount:b,stopServicesOnExit:Y})}else await go({initialTasks:E,logger:e,options:s,persistentTasks:y,projectGraph:m,projectsWithTarget:g,registryStartedCount:b,runtime:B,serviceEventBridge:L,stopServicesOnExit:Y,taskGraph:R,visConfig:r,workspace:a,workspaceRoot:o})}finally{await U.finish()}};export{dc as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createRequire as v}from"node:module";import{e as m}from"../packem_shared/index-BzhrR_iC.js";import{cleanWorkspace as E}from"#native";import{l as S}from"../packem_shared/missing-package-json-
|
|
1
|
+
import{createRequire as v}from"node:module";import{e as m}from"../packem_shared/index-BzhrR_iC.js";import{cleanWorkspace as E}from"#native";import{l as S}from"../packem_shared/missing-package-json-dtwl6w-S.js";import{p as c}from"./cli-main.js";import{e as p}from"../packem_shared/utils-DQFHJn72.js";import{y as P}from"../packem_shared/isAccessibleSync-DYKTrrvc-C-_5cgwu.js";let g;const _=e=>(g??=v(import.meta.url))(e),u=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,R=e=>{if(typeof u<"u"&&u.versions&&u.versions.node){const[r,t]=u.versions.node.split(".").map(Number);if(r>22||r===22&&t>=3||r===20&&t>=16)return u.getBuiltinModule(e)}return _(e)},{readdirSync:h,lstatSync:$,rmSync:b}=R("node:fs"),j=e=>{const r=[],t=[e];for(;t.length>0;){const o=t.pop();let i;try{i=h(o)}catch{continue}for(const l of i){const s=m(o,l);try{const n=$(s);if(n.isSymbolicLink()||!n.isDirectory())continue}catch{continue}l==="node_modules"?r.push(s):l!==".git"&&l!==".hg"&&t.push(s)}}return r},w=["pnpm-lock.yaml","package-lock.json","npm-shrinkwrap.json","yarn.lock","bun.lock","bun.lockb"],D=(e,r,t)=>{let o=0,i=!1;for(const l of w){const s=m(e,l);if(P(s)){t.info(` ${s}`),o++;continue}}return{hadError:i,removed:o}},L=new Set([".cache",".turbo","dist","node_modules"]),k=e=>{for(const r of h(e,{withFileTypes:!0})){const t=m(e,r.name);if(!r.isDirectory())return t;if(!L.has(r.name)){const o=k(t);if(o!==void 0)return o}}},y=(e,r,t)=>{let o=0,i=!1;for(const{packageDir:l}of S(e)){const s=m(e,l);let n;try{n=k(s)}catch(a){c.error(`${s}: ${p(a)}`),i=!0;continue}if(n!==void 0){c.warn(`Skipping ${s}: not empty (contains ${n})`);continue}if(r){t.info(` ${s}`),o++;continue}try{b(s,{force:!0,recursive:!0}),c.success(`Removed empty package ${s}`),o++}catch(a){c.error(`${s}: ${p(a)}`),i=!0}}return{hadError:i,removed:o}},x=async({logger:e,options:r,workspaceRoot:t})=>{const o=t??process.cwd(),i=r.lockfile||!1,l=r.emptyPackages||!1;if(r.dryRun||!1){const f=j(o);if(f.length>0){c.info("Would remove:");for(const d of f)e.info(` ${d}`)}else c.info("No node_modules directories found.");i&&D(o,!0,e),l&&(c.info("Would remove empty packages:"),y(o,!0,e));return}const n=E(o,i);for(const f of n.removed)c.success(`Removed ${f}`);for(const f of n.lockfilesRemoved)c.success(`Removed ${f}`);for(const f of n.errors)c.error(f);n.removed.length===0&&n.lockfilesRemoved.length===0?c.info("No node_modules directories found."):c.info(`Cleaned ${n.removed.length} node_modules director${n.removed.length===1?"y":"ies"}`);let a=!1;if(l){const{hadError:f,removed:d}=y(o,!1,e);a=f,d>0&&c.info(`Cleaned ${d} empty package director${d===1?"y":"ies"}`)}(n.errors.length>0||a)&&(process.exitCode=1)};export{x as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{createRequire as E}from"node:module";import{b as U,j as x,F as g,X as A,J as L}from"../packem_shared/index.server-Ca_EEVfw.js";import{a as O}from"../packem_shared/index-BzhrR_iC.js";import{readLastRunSummary as G}from"@visulima/task-runner";import{a as j,r as F,b as D,c as K}from"../packem_shared/ai-fix-
|
|
1
|
+
import{createRequire as E}from"node:module";import{b as U,j as x,F as g,X as A,J as L}from"../packem_shared/index.server-Ca_EEVfw.js";import{a as O}from"../packem_shared/index-BzhrR_iC.js";import{readLastRunSummary as G}from"@visulima/task-runner";import{a as j,r as F,b as D,c as K}from"../packem_shared/ai-fix-CgCyO65Q.js";import{p}from"./cli-main.js";import{r as H}from"../packem_shared/run-summary-utils-CMeURYtS.js";let B;const P=e=>(B??=E(import.meta.url))(e),m=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,I=e=>{if(typeof m<"u"&&m.versions&&m.versions.node){const[t,o]=m.versions.node.split(".").map(Number);if(t>22||t===22&&o>=3||t===20&&o>=16)return m.getBuiltinModule(e)}return P(e)},{spawn:h}=I("node:child_process"),{readFile:M}=I("node:fs/promises"),V=e=>{if(!e)return;const t=/^refs\/pull\/(\d+)\//.exec(e);return t?Number.parseInt(t[1],10):void 0},J=async e=>{if(!e)return{prNumber:void 0,sha:void 0};try{const t=await M(e,"utf8"),o=JSON.parse(t),r=o.pull_request?.number??o.issue?.number??o.number,s=o.pull_request?.head?.sha;return{prNumber:r,sha:s}}catch{return{prNumber:void 0,sha:void 0}}},q=async e=>{const t=V(e.GITHUB_REF),{prNumber:o,sha:r}=t===void 0?await J(e.GITHUB_EVENT_PATH):{prNumber:t,sha:void 0};return{apiBaseUrl:void 0,buildId:void 0,buildNumber:void 0,prNumber:t??o,provider:"github-actions",repo:e.GITHUB_REPOSITORY,sha:r??e.GITHUB_SHA,token:e.GITHUB_TOKEN}},z=e=>{const t=e.CI_MERGE_REQUEST_IID,o=t!==void 0&&t!==""?Number.parseInt(t,10):void 0,r=e.CI_API_V4_URL,s=e.GITLAB_TOKEN??e.CI_TOKEN;return{apiBaseUrl:r,buildId:void 0,buildNumber:void 0,prNumber:Number.isFinite(o)?o:void 0,provider:"gitlab-ci",repo:e.CI_PROJECT_ID??e.CI_PROJECT_PATH,sha:e.CI_COMMIT_SHA,token:s}},X=e=>{const t=e.BUILDKITE_PULL_REQUEST,o=t!==void 0&&t!==""&&t!=="false"?Number.parseInt(t,10):void 0,r=e.BUILDKITE_BUILD_NUMBER,s=r!==void 0&&r!==""?Number.parseInt(r,10):void 0,n=e.BUILDKITE_ORGANIZATION_SLUG,i=e.BUILDKITE_PIPELINE_SLUG,a=n!==void 0&&n!==""&&i!==void 0&&i!==""?`${n}/${i}`:void 0;return{apiBaseUrl:(e.BUILDKITE_API_BASE_URL??"https://api.buildkite.com").replace(/\/+$/,""),buildId:e.BUILDKITE_BUILD_ID,buildNumber:Number.isFinite(s)?s:void 0,prNumber:Number.isFinite(o)?o:void 0,provider:"buildkite",repo:a,sha:e.BUILDKITE_COMMIT,token:e.BUILDKITE_API_TOKEN}},Y=async(e=process.env)=>e.GITHUB_ACTIONS==="true"?await q(e):e.GITLAB_CI==="true"?z(e):e.BUILDKITE==="true"?X(e):{apiBaseUrl:void 0,buildId:void 0,buildNumber:void 0,prNumber:void 0,provider:"unknown",repo:void 0,sha:void 0,token:void 0},Q=(e,t,o,r)=>new Promise(s=>{const n=["pr","comment",String(t),"--body-file","-"];r&&n.push("--repo",r);const i=h(e,n,{stdio:["pipe","ignore","pipe"]});let a="";i.stderr?.setEncoding("utf8"),i.stderr?.on("data",d=>{a+=d}),i.once("error",()=>{s({exitCode:127,stderr:a})}),i.once("close",d=>{s({exitCode:d??-1,stderr:a})}),i.stdin?.on("error",()=>{}),i.stdin?.end(o)}),Z=async(e,t,o,r,s)=>{const n=`https://api.github.com/repos/${t}/issues/${String(o)}/comments`;try{const i=await e(n,{body:JSON.stringify({body:r}),headers:{Accept:"application/vnd.github+json",Authorization:`Bearer ${s}`,"Content-Type":"application/json","X-GitHub-Api-Version":"2022-11-28"},method:"POST"});if(!i.ok){const a=await i.text().catch(()=>"");return{error:`GitHub REST returned ${String(i.status)}: ${a.slice(0,500)}`,ok:!1}}return{ok:!0}}catch(i){return{error:i instanceof Error?i.message:String(i),ok:!1}}},W=async(e,t,o,r,s,n)=>{const i=encodeURIComponent(o),a=`${t.replace(/\/+$/,"")}/projects/${i}/merge_requests/${String(r)}/notes`;try{const d=await e(a,{body:JSON.stringify({body:s}),headers:{"Content-Type":"application/json","PRIVATE-TOKEN":n},method:"POST"});if(!d.ok){const c=await d.text().catch(()=>"");return{error:`GitLab REST returned ${String(d.status)}: ${c.slice(0,500)}`,ok:!1}}return{ok:!0}}catch(d){return{error:d instanceof Error?d.message:String(d),ok:!1}}},tt=(e,t,o,r)=>new Promise(s=>{const i=h(e,["annotate","--style",o,"--context",r],{stdio:["pipe","ignore","pipe"]});let a="";i.stderr?.setEncoding("utf8"),i.stderr?.on("data",d=>{a+=d}),i.once("error",()=>{s({exitCode:127,stderr:a})}),i.once("close",d=>{s({exitCode:d??-1,stderr:a})}),i.stdin?.on("error",()=>{}),i.stdin?.end(t)}),et=async(e,t,o,r,s,n,i,a)=>{const[d,c]=o.split("/",2);if(!d||!c)return{error:`Buildkite repo identifier \`${o}\` is not in {org}/{pipeline} form.`,ok:!1};const f=`${t}/v2/organizations/${encodeURIComponent(d)}/pipelines/${encodeURIComponent(c)}/builds/${String(r)}/annotations`;try{const u=await e(f,{body:JSON.stringify({body:s,context:i,style:n}),headers:{Authorization:`Bearer ${a}`,"Content-Type":"application/json"},method:"POST"});if(!u.ok){const l=await u.text().catch(()=>"");return{error:`Buildkite REST returned ${String(u.status)}: ${l.slice(0,500)}`,ok:!1}}return{ok:!0}}catch(u){return{error:u instanceof Error?u.message:String(u),ok:!1}}},ot=async(e,t,o,r)=>{const s=t.buildId?`vis-ai-heal-${t.buildId}`:"vis-ai-heal",n="info",i=await tt(o,e,n,s);if(i.exitCode===0)return{method:"buildkite-cli",posted:!0};if(!t.apiBaseUrl||!t.repo||t.buildNumber===void 0||!t.token){const d=[];return t.repo||d.push("BUILDKITE_ORGANIZATION_SLUG / BUILDKITE_PIPELINE_SLUG"),t.buildNumber===void 0&&d.push("BUILDKITE_BUILD_NUMBER"),t.token||d.push("BUILDKITE_API_TOKEN (with `write_build_annotations` scope)"),{error:`buildkite-agent annotate exited ${String(i.exitCode)} (${i.stderr.trim().slice(0,200)}); cannot fall back to REST without ${d.join(", ")}`,method:"buildkite-cli",posted:!1}}const a=await et(r,t.apiBaseUrl,t.repo,t.buildNumber,e,n,s,t.token);return a.ok?{method:"rest",posted:!0}:{error:`buildkite-agent annotate exited ${String(i.exitCode)}; REST fallback also failed: ${a.error??"unknown"}`,method:"rest",posted:!1}},rt=async(e,t,o,r)=>{if(t.prNumber===void 0)return{method:"skipped",posted:!1};const s=await Q(o,t.prNumber,e,t.repo);if(s.exitCode===0)return{method:"gh-cli",posted:!0};if(!t.repo||!t.token)return{error:`gh exited ${String(s.exitCode)} (${s.stderr.trim().slice(0,200)}); cannot fall back to REST without GITHUB_REPOSITORY + GITHUB_TOKEN`,method:"gh-cli",posted:!1};const n=await Z(r,t.repo,t.prNumber,e,t.token);return n.ok?{method:"rest",posted:!0}:{error:`gh exited ${String(s.exitCode)}; REST fallback also failed: ${n.error??"unknown"}`,method:"rest",posted:!1}},it=async(e,t,o)=>{if(t.prNumber===void 0)return{method:"skipped",posted:!1};if(!t.apiBaseUrl||!t.repo)return{error:"GitLab CI context is missing CI_API_V4_URL or CI_PROJECT_ID; cannot post note.",method:"rest",posted:!1};if(!t.token)return{error:"GitLab CI context has no token. CI_JOB_TOKEN cannot post MR notes — set GITLAB_TOKEN to a personal/project access token with `api` scope.",method:"rest",posted:!1};const r=await W(o,t.apiBaseUrl,t.repo,t.prNumber,e,t.token);return r.ok?{method:"rest",posted:!0}:{error:r.error,method:"rest",posted:!1}},nt=async e=>{const{body:t,buildkiteAgentBin:o="buildkite-agent",context:r,fetchImpl:s=globalThis.fetch,ghBin:n="gh"}=e;return r.provider==="github-actions"?await rt(t,r,n,s):r.provider==="gitlab-ci"?await it(t,r,s):r.provider==="buildkite"?await ot(t,r,o,s):{method:"skipped",posted:!1}},b=e=>{let t=0,o=0;for(const r of e)r.status==="applied"?t+=1:o+=1;return{applied:t,failed:o}},k=(e,t,o)=>{const r=K(e,t,o),s=O(e,r);return s===""||s.startsWith("..")?r:s},st=(e,t,o,r)=>new Promise(s=>{const n=process.argv[1];if(!n){s({exitCode:-1,stderr:"Cannot locate vis bin (process.argv[1] missing).",stdout:""});return}const i=[n,"run",o,"--projects",t,"--no-cache","--summarize","--fail-fast"],a=h(process.execPath,i,{cwd:e,env:{...process.env,NO_COLOR:"1"},stdio:["ignore","pipe","pipe"]});let d="",c="";const f=setTimeout(()=>{a.kill("SIGTERM"),setTimeout(()=>a.kill("SIGKILL"),2e3).unref()},r);a.stdout?.setEncoding("utf8"),a.stdout?.on("data",u=>{d+=u}),a.stderr?.setEncoding("utf8"),a.stderr?.on("data",u=>{c+=u}),a.once("error",u=>{clearTimeout(f),s({exitCode:-1,stderr:u.message,stdout:d})}),a.once("close",u=>{clearTimeout(f),s({exitCode:u??-1,stderr:c,stdout:d})})}),at=6e4,T=e=>{let t=0;const o=e.match(/`{3,}/g);if(o)for(const r of o)t=Math.max(t,r.length);return"`".repeat(Math.max(3,t+1))},_=(e,t,o)=>{if(e.patches.length===0)return"_No patches proposed._";const r=[];for(const[s,n]of e.patches.entries()){const i=k(t,o,n.file),a=[`**[${String(s+1)}] \`${i}\`**`];n.reason&&a.push(`_${n.reason}_`);const d=T(`${n.oldString}
|
|
2
2
|
${n.newString}`);a.push(`${d}diff`);for(const c of n.oldString.split(`
|
|
3
3
|
`))a.push(`- ${c}`);for(const c of n.newString.split(`
|
|
4
4
|
`))a.push(`+ ${c}`);a.push(d),r.push(a.join(`
|
|
@@ -11,4 +11,4 @@ ${n.newString}`);a.push(`${d}diff`);for(const c of n.oldString.split(`
|
|
|
11
11
|
`))r.push(L(` + ${i}`))}return r.join(`
|
|
12
12
|
`)},ct=async(e,t)=>{const o=t===void 0?await G(e):await H(e,t);if(o){for(const r of o.tasks)if(r.exitCode!==void 0&&r.exitCode!==0)return{project:r.target?.project,runId:o.id,target:r.target?.target,taskId:r.taskId}}},ut=1800*1e3,C=async(e,t)=>{const o=await ct(e,t);if(!o)return{outcome:"no-failed-task"};if(!o.project||!o.target)return{failedTask:o,outcome:"missing-metadata"};const r=await j(e,o.taskId,{runId:o.runId});return r?{failedTask:{project:o.project,runId:o.runId,target:o.target,taskId:o.taskId},failureContext:r,outcome:"ready"}:{failedTask:{project:o.project,runId:o.runId,target:o.target,taskId:o.taskId},outcome:"no-failure-context"}},$=async(e,t)=>{const{logger:o,options:r,visConfig:s,workspaceRoot:n}=e,i=n??process.cwd(),a=r.dryRun===!0,d=s?.ai,c=await F(t.failureContext,o,{cache:r.cache!==!1,config:d});if(!c)return{outcome:"no-proposal"};if(c.cannotFix)return{detail:c.cannotFix,outcome:"cannot-fix",proposal:c};if(c.patches.length===0)return{outcome:"empty-patches",proposal:c};if(a)return{outcome:"dry-run",proposal:c};const f=await D(i,t.failureContext.cwd,c);return b(f).applied===0?{applyResults:f,outcome:"no-patches-applied",proposal:c}:{applyResults:f,outcome:"applied",proposal:c}},N=async(e,t,o={})=>{const r=e.workspaceRoot??process.cwd(),s=e.options.validationTimeout===void 0?ut:e.options.validationTimeout*1e3;return await(o.validate??((i,a)=>st(r,i,a,s)))(t.failedTask.project,t.failedTask.target)},v=async(e,t,o,r={})=>{const n=await(r.detectCi??Y)(),i=n.provider==="gitlab-ci"?"MR":n.provider==="buildkite"?"annotation":"PR";if(n.provider==="unknown")return{ciContext:n,outcome:"no-ci",surface:i};const a=y(t,o,e,n.sha),c=await(r.postComment??(async(f,u)=>nt({body:f,context:u})))(a,n);return c.posted?{ciContext:n,method:c.method,outcome:"posted",surface:i}:c.method==="skipped"?{ciContext:n,outcome:"no-pr",surface:i}:{ciContext:n,error:c.error,method:c.method,outcome:"post-failed",surface:i}},w=async(e,t={})=>{const{logger:o,workspaceRoot:r}=e,s=r??process.cwd(),n=await C(s,e.options.run);if(n.outcome==="no-failed-task"){p.info("No failed tasks found in the latest run summary. Nothing to heal.");return}if(n.outcome==="missing-metadata"){p.error(`Failed task ${n.failedTask.taskId} is missing project/target metadata in the run summary; cannot validate a fix.`),process.exitCode=1;return}if(n.outcome==="no-failure-context"){p.error(`No failure log or run summary found for ${n.failedTask.taskId}.`),process.exitCode=1;return}const i={failedTask:n.failedTask,failureContext:n.failureContext};p.info(`Healing ${i.failedTask.taskId} (run ${i.failedTask.runId??"unknown"})`),i.failureContext.terminalOutputCaptured||p.warn(`No captured terminal output for ${i.failedTask.taskId}; the AI proposal will be weaker without it.`);const a=await $(e,i);if(a.outcome==="no-proposal"){p.error("AI fix proposal failed or no provider available."),process.exitCode=1;return}if(a.outcome==="cannot-fix"){p.warn(`AI declined to fix: ${a.detail??"(no reason)"}`);return}if(a.outcome==="empty-patches"){p.warn("AI returned an empty patch set.");return}const d=a.proposal;if(o.info(dt(d,s,i.failureContext.cwd)),a.outcome==="dry-run"){p.info("Dry run: skipping apply, validation, and PR comment.");return}const c=a.applyResults??[],f=b(c);if(p.info(`Applied ${String(f.applied)}/${String(c.length)} patches.`),a.outcome==="no-patches-applied"){p.error("No patches could be applied (all failed validation)."),process.exitCode=1;return}p.info(`Re-running ${i.failedTask.taskId} to validate the fix...`);const u=await N(e,i,{validate:t.validate});if(u.exitCode!==0){p.error(`Validation failed (exit ${String(u.exitCode)}). Patch is not posted.`),u.stderr.trim().length>0&&(o.info(U("--- validation stderr (tail) ---")),o.info(u.stderr.split(`
|
|
13
13
|
`).slice(-20).join(`
|
|
14
|
-
`))),process.exitCode=1;return}p.success("Validation passed.");const l=await v(s,d,i.failureContext,{detectCi:t.detectCi,postComment:t.postComment});if(l.outcome==="no-ci"){p.notice("Not running in a recognised CI provider; skipping PR comment. Patch was applied + validated locally.");return}if(l.outcome==="posted"){const S=l.surface==="annotation"?`build #${String(l.ciContext.buildNumber??"?")}`:`${l.surface} #${String(l.ciContext.prNumber)}`;p.success(`Posted fix proposal to ${S} via ${l.method??"unknown"}.`);return}if(l.outcome==="no-pr"){p.notice(`No ${l.surface} number detected (push-event run); skipping comment.`);return}const R=l.surface==="annotation"?"annotation":`${l.surface} comment`;p.error(`Failed to post ${R}: ${l.error??"unknown error"}`)},pt=async e=>{await w(e)},
|
|
14
|
+
`))),process.exitCode=1;return}p.success("Validation passed.");const l=await v(s,d,i.failureContext,{detectCi:t.detectCi,postComment:t.postComment});if(l.outcome==="no-ci"){p.notice("Not running in a recognised CI provider; skipping PR comment. Patch was applied + validated locally.");return}if(l.outcome==="posted"){const S=l.surface==="annotation"?`build #${String(l.ciContext.buildNumber??"?")}`:`${l.surface} #${String(l.ciContext.prNumber)}`;p.success(`Posted fix proposal to ${S} via ${l.method??"unknown"}.`);return}if(l.outcome==="no-pr"){p.notice(`No ${l.surface} number detected (push-event run); skipping comment.`);return}const R=l.surface==="annotation"?"annotation":`${l.surface} comment`;p.error(`Failed to post ${R}: ${l.error??"unknown error"}`)},pt=async e=>{await w(e)},kt=Object.defineProperty({__proto__:null,aiHeal:pt,findHealCandidate:C,pickFenceForTesting:T,postHealComment:v,proposeAndApply:$,renderCommentBodyForTesting:y,renderProposalDiffForTesting:_,runHealForTesting:w,validateAppliedFix:N},Symbol.toStringTag,{value:"Module"});export{nt as a,Y as d,C as f,kt as h,$ as p,N as v};
|