@visulima/vis 1.0.0-alpha.17 → 1.0.0-alpha.19
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 +58 -0
- package/README.md +66 -26
- package/dist/config/index.d.ts +72 -28
- package/dist/packem_chunks/bin.js +255 -251
- package/dist/packem_chunks/doctor-probe.js +2 -2
- package/dist/packem_chunks/handler10.js +1 -1
- package/dist/packem_chunks/handler20.js +1 -1
- package/dist/packem_chunks/handler22.js +1 -1
- package/dist/packem_chunks/handler37.js +1 -1
- package/dist/packem_chunks/handler39.js +5 -22
- package/dist/packem_chunks/handler40.js +10 -5
- package/dist/packem_chunks/handler41.js +24 -10
- package/dist/packem_chunks/handler42.js +153 -24
- package/dist/packem_chunks/handler43.js +25 -153
- package/dist/packem_chunks/handler44.js +24 -25
- package/dist/packem_chunks/handler46.js +1 -1
- package/dist/packem_chunks/handler47.js +48 -48
- package/dist/packem_chunks/handler48.js +22 -22
- package/dist/packem_chunks/help-command.js +8 -8
- package/dist/packem_chunks/index.js +1 -1
- package/dist/packem_shared/{docker-B4i5yxtP.js → docker-B4s1fjiN.js} +26 -26
- package/dist/packem_shared/flakiness-DUtrm-wS.js +1 -0
- package/dist/packem_shared/{lifecycle-C7vfQmA3.js → lifecycle-CgK8pcfa.js} +2 -2
- package/index.js +57 -53
- package/package.json +12 -12
- package/schemas/vis-config.schema.json +85 -1
- package/dist/packem_shared/flakiness-Dzz-I3dB.js +0 -1
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
var Xr=Object.defineProperty;var _=(r,e)=>Xr(r,"name",{value:e,configurable:!0});import{createRequire as Qr}from"node:module";import{M as ye,Q as Zr,K as es,C as br,z as ts,B as Sr,$ as rs}from"./config.js";import{aJ as ss,p as Xt,Y as bt,Z as St,bb as is,bc as os,Q as it,bd as ns,X as as,y as cs,m as ls,be as ds,bf as us,s as Ze,bg as fs}from"./bin.js";import{runConcurrently as ot,TerminalBuffer as Tr,readLastRunSummary as hs,getLastRunSummaryPath as ps,enforceProjectConstraints as gs,expandTokensInString as Qt,parsePartition as ms,TaskScheduler as ws,createTaskGraph as vs,reverseTaskGraph as ys,generateRunSummary as Jt,writeChromeTrace as ks,CompositeLifeCycle as Zt,defaultTaskRunner as er,createLogReporter as bs,writeRunSummary as Ss}from"@visulima/task-runner";import{E as Ts,a as $s}from"../packem_shared/cache-directory-C_U1qsIw.js";import{F as Fs}from"../packem_shared/failure-log-CSC6KfcO.js";import{f as Ps,l as Os,c as js,a as Ds,b as Ls}from"../packem_shared/flakiness-Dzz-I3dB.js";import{r as As}from"../packem_shared/toolchain-B7dckBQ1.js";import{i as Bs,a as Ns,b as Gs,s as _s,d as qs,c as Hs,r as Vs,H as zs,f as Us,e as Ws}from"../packem_shared/lifecycle-C7vfQmA3.js";import{p as Ks,r as Ys,f as Xs}from"../packem_shared/selectors-B2ISH581.js";import{renderToString as he,render as Zs}from"@visulima/tui";import{Text as n}from"@visulima/tui/components/text";import J,{useSyncExternalStore as rt,useCallback as et,useState as ze,useRef as Ue,useEffect as pt,useMemo as tr}from"react";import{jsxs as u,jsx as c,Fragment as $r}from"react/jsx-runtime";import{Box as g}from"@visulima/tui/components/box";import{StaticRender as rr}from"@visulima/tui/components/static-render";import{T as Cr,C as $t,D as lt,E as Ir}from"../packem_shared/symbols-CQmER5MT.js";import{Dialog as ei}from"@visulima/tui/components/dialog";import{useApp as ti}from"@visulima/tui/hooks/use-app";import{useInput as sr}from"@visulima/tui/hooks/use-input";import{useWindowSize as ri}from"@visulima/tui/hooks/use-window-size";import{ScrollView as xr}from"@visulima/tui/components/scroll-view";import{Spinner as Mr}from"@visulima/tui/components/spinner";const Jr=Qr(import.meta.url),Ve=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,We=_(r=>{if(typeof Ve<"u"&&Ve.versions&&Ve.versions.node){const[e,t]=Ve.versions.node.split(".").map(Number);if(e>22||e===22&&t>=3||e===20&&t>=16)return Ve.getBuiltinModule(r)}return Jr(r)},"__cjs_getBuiltinModule"),{existsSync:Tt,statSync:nt,watch:Cs,openSync:Is,readSync:xs,closeSync:Ms,readFileSync:Rs,mkdtempSync:Es}=We("node:fs"),{createInterface:Qs,emitKeypressEvents:Js}=We("node:readline"),{appendFile:Ct}=We("node:fs/promises"),{platform:si,homedir:It,tmpdir:ii}=We("node:os"),{spawn:oi}=We("node:child_process");var ni=Object.defineProperty,ai=_((r,e)=>ni(r,"name",{value:e,configurable:!0}),"u$1"),ci=Object.defineProperty,li=ai((r,e)=>ci(r,"name",{value:e,configurable:!0}),"v"),di=Object.defineProperty,ui=li((r,e)=>di(r,"name",{value:e,configurable:!0}),"D");const fi=ui((r,e,t,s,o,a,i,d,f,h,p,w,l,$)=>{const E={d:s,h:o,m:a,mo:e,ms:d,s:i,w:t,y:r};return f!==void 0&&(E.future=f),h!==void 0&&(E.past=h),p!==void 0&&(E.decimal=p),w!==void 0&&(E.unitMap=w),l!==void 0&&(E.groupSeparator=l),$!==void 0&&(E.placeholderSeparator=$),E},"createDurationLanguage"),hi={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"},pi=fi(r=>`year${r===1?"":"s"}`,r=>`month${r===1?"":"s"}`,r=>`week${r===1?"":"s"}`,r=>`day${r===1?"":"s"}`,r=>`hour${r===1?"":"s"}`,r=>`minute${r===1?"":"s"}`,r=>`second${r===1?"":"s"}`,r=>`millisecond${r===1?"":"s"}`,"in %s","%s ago",".",hi,",","_");var gi=Object.defineProperty,mi=_((r,e)=>gi(r,"name",{value:e,configurable:!0}),"o$4"),wi=Object.defineProperty,vi=mi((r,e)=>wi(r,"name",{value:e,configurable:!0}),"o"),yi=Object.defineProperty,ki=vi((r,e)=>yi(r,"name",{value:e,configurable:!0}),"o");const bi=ki(r=>{const e=["y","mo","w","d","h","m","s","ms","future","past"];for(const s of e)if(!Object.hasOwn(r,s))throw new TypeError(`Missing required property: ${s}`);if(typeof r.future!="string"||typeof r.past!="string")throw new TypeError("Properties future and past must be of type string");const t=["y","mo","w","d","h","m","s","ms"];for(const s of t)if(typeof r[s]!="string"&&typeof r[s]!="function")throw new TypeError(`Property ${s} must be of type string or function`);if(r.decimal&&typeof r.decimal!="string")throw new TypeError("Property decimal must be of type string");if(r.delimiter&&typeof r.delimiter!="string")throw new TypeError("Property delimiter must be of type string");if(r._digitReplacements&&!Array.isArray(r._digitReplacements))throw new TypeError("Property _digitReplacements must be an array");if(r._numberFirst&&typeof r._numberFirst!="boolean")throw new TypeError("Property _numberFirst must be of type boolean");if(r.unitMap&&typeof r.unitMap!="object")throw new TypeError("Property unitMap must be an object");if(r.unitMap&&Object.values(r.unitMap).some(s=>typeof s!="string"))throw new TypeError("All values in unitMap must be of type string")},"validateDurationLanguage");var Si=Object.defineProperty,Ti=_((r,e)=>Si(r,"name",{value:e,configurable:!0}),"b$2"),$i=Object.defineProperty,Ci=Ti((r,e)=>$i(r,"name",{value:e,configurable:!0}),"b"),Ii=Object.defineProperty,Ke=Ci((r,e)=>Ii(r,"name",{value:e,configurable:!0}),"g");const Rr=Ke((r,e)=>{e=e||-1;const t=new RegExp(String.raw`^-?\d+(?:.\d{0,${String(e)}})?`).exec(r.toString());return t===null?r:Number.parseFloat(t[0])},"toFixed"),ir=Ke(({unitCount:r,unitName:e},t,s)=>{let{spacer:o}=s;const{maxDecimalPoints:a}=s;let i=".";s.decimal!==void 0?i=s.decimal:t.decimal!==void 0&&(i=t.decimal);let d;"digitReplacements"in s?d=s.digitReplacements:"_digitReplacements"in t&&(d=t._digitReplacements);let f,h=r;a!==void 0&&(h=Rr(r,a));const p=h.toString();if(!t._hideCountIf2||r!==2)if(d){f="";for(const $ of p)f+=$==="."?i:d[$]}else f=p.replace(".",i);else f="";const w=t[e];let l=w;return typeof w=="function"&&(l=w(r)),t._hideCountIf2&&r===2&&(o=""),t._numberFirst?l+o+f:f+o+l},"renderPiece"),xi=Ke((r,e)=>{const{units:t}=e;if(t.length===0)return[];const{unitMeasures:s}=e,o=e.largest??Number.POSITIVE_INFINITY,a={};let i,d,f,h=r;for(d=0;d<t.length;d++){i=t[d];const w=s[i];f=d===t.length-1?h/w:Math.floor(h/w),a[i]=f,h-=f*w}if(e.round){let w=o;for(d=0;d<t.length;d++)if(i=t[d],f=a[i],f!==0&&(w--,w===0)){for(let l=d+1;l<t.length;l++){const $=t[l],E=a[$];a[i]=(a[i]??0)+E*s[$]/s[i],a[$]=0}break}for(d=t.length-1;d>=0;d--){if(i=t[d],f=a[i],f===0)continue;const l=Math.round(f);if(a[i]=l,d===0)break;const $=t[d-1],E=s[$],L=Math.floor(l*s[i]/E);if(L)a[$]=(a[$]??0)+L,a[i]=0;else break}}const p=[];for(d=0;d<t.length&&p.length<o;d++){if(i=t[d],f=a[i],f&&!e.round&&p.length===o-1){let w,l=0;for(w=d+1,t.length;w<t.length;w++){const $=t[w];l+=a[$]*(e.unitMeasures[$]/e.unitMeasures[i])}f+=l,e.maxDecimalPoints!==void 0&&(f=Rr(f,e.maxDecimalPoints))}f&&p.push({unitCount:f,unitName:i})}return p},"getPieces"),Mi=Ke((r,e,t)=>{const{language:s,units:o}=e;if(r.length===0){const w=o.at(-1);return ir({unitCount:0,unitName:w},s,e)}const{conjunction:a,serialComma:i}=e;let d=", ";e.delimiter!==void 0?d=e.delimiter:s.delimiter!==void 0&&(d=s.delimiter);let f="";e.timeAdverb&&t!==0&&(f=s.future??"",t<0&&(f=s.past??""));const h=r.map(w=>ir(w,s,e));let p;return!a||r.length===1?p=h.join(d):r.length===2?p=h.join(a):p=h.slice(0,-1).join(d)+(i?",":"")+a+(h.at(-1)??""),f&&(p=f.replace("%s",p)),p},"formatPieces"),Er=Ke((r,e)=>{if(Number.isNaN(r))throw new TypeError("Expected a valid number");if(typeof r!="number")throw new TypeError("Expected a number for milliseconds input");const t={conjunction:"",language:pi,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};bi(t.language);const s=Math.abs(r),o=xi(s,t);return Mi(o,t,r)},"duration");var Ri=Object.defineProperty,dt=_((r,e)=>Ri(r,"name",{value:e,configurable:!0}),"s$2");const Ei={bun:["bun.lock","bun.lockb"],npm:["package-lock.json"],pnpm:["pnpm-lock.yaml"],yarn:["yarn.lock"]},Fi={bun:["node_modules/.bun-tag"],npm:["node_modules/.package-lock.json"],pnpm:["node_modules/.modules.yaml","node_modules/.pnpm/lock.yaml"],yarn:["node_modules/.yarn-integrity","node_modules/.yarn-state.yml",".yarn/install-state.gz"]},Pi={ci:{bun:"bun install --frozen-lockfile",npm:"npm ci",pnpm:"pnpm install --frozen-lockfile",yarn:"yarn install --immutable"},tty:{bun:"bun install",npm:"npm install",pnpm:"pnpm install",yarn:"yarn install"}},Oi=1e3,ji=dt(r=>{for(const[e,t]of Object.entries(Ei))for(const s of t)if(Tt(ye(r,s)))return{lockfileFile:s,manager:e}},"detectPackageManager"),Di=dt((r,e)=>{let t;for(const s of Fi[e]){const o=ye(r,s);if(!Tt(o))continue;const{mtimeMs:a}=nt(o);(!t||a>t.mtimeMs)&&(t={mtimeMs:a,path:s})}return t},"findFreshestMarker"),Li=dt((r,e={})=>{const t=ji(r);if(!t)return{checked:!1};const{lockfileFile:s,manager:o}=t,a=nt(ye(r,s)).mtimeMs,i=Di(r,o),d=Pi[e.inCi?"ci":"tty"][o],f={installMarkerMtimeMs:i?.mtimeMs,lockfileMtimeMs:a,lockfilePath:s,marker:i?.path,packageManager:o};return i?a>i.mtimeMs+Oi?{checked:!0,detail:f,failure:"stale-install",message:`${s} is newer than node_modules (${i.path}) — run \`${d}\` to sync.`}:{checked:!0,detail:f}:{checked:!0,detail:f,failure:"missing-install",message:`lockfile detected but node_modules looks uninitialised — run \`${d}\` before \`vis run\`.`}},"checkLockfileFreshness"),Ai=dt((r,e,t,s={})=>{if(s.skip)return{checked:!1,shouldContinue:!0};const o=Li(r,{inCi:e});if(!o.failure)return{...o,shouldContinue:!0};const a=`preflight: ${o.message??"lockfile drift detected"}`;return e&&!s.ciAsWarning?{...o,formattedMessage:a,shouldContinue:!1}:(t.warn(a),{...o,formattedMessage:a,shouldContinue:!0})},"runLockfilePreflight");var Bi=Object.defineProperty,Fr=_((r,e)=>Bi(r,"name",{value:e,configurable:!0}),"p$6");const Ni=Fr(r=>r.split(",").map(e=>e.trim()).filter(e=>e!==""),"splitPatterns"),Gi=Fr((r,e,t)=>{const s=new Set,o=[];if(r===void 0||r.trim()==="")return{skipTaskIds:s,unmatchedPatterns:o};const a=[...t],i=new Set(a),d=new Map;for(const f of a){const h=f.lastIndexOf(":");if(h===-1)continue;const p=f.slice(h+1),w=d.get(p);w===void 0?d.set(p,[f]):w.push(f)}for(const f of Ni(r)){if(f.startsWith("~:"))throw new Error(`--skip-cache does not support the closest-project selector "~:" (received "${f}"). Use \`pkg:target\`, \`:target\`, or \`#tag:target\`.`);if(i.has(f)){s.add(f);continue}const h=Ks(f);if(!h){o.push(f);continue}let p=!1;if(h.kind==="all"){const w=d.get(h.target)??[];for(const l of w)s.add(l),p=!0}else if(h.kind==="project"){const w=h.projects?.[0];if(w!==void 0){const l=`${w}:${h.target}`;i.has(l)&&(s.add(l),p=!0)}}else if(h.kind==="tag"){const w=h.tag;if(w!==void 0){const l=d.get(h.target)??[];for(const $ of l){const E=$.slice(0,$.lastIndexOf(":"));e.projects[E]?.tags?.includes(w)===!0&&(s.add($),p=!0)}}}p||o.push(f)}return{skipTaskIds:s,unmatchedPatterns:o}},"resolveSkipCachePatterns");var _i=Object.defineProperty,xt=_((r,e)=>_i(r,"name",{value:e,configurable:!0}),"a$1");const qi=/\$(?:\{([A-Z_]\w*)(:-[^}]*)?\}|([A-Z_]\w*))/gi,Hi=new Set(["0","!","#","$","*","-","?","@","_"]),Vi=xt(r=>{const e=new Map;for(const t of r.matchAll(qi)){const s=t[1],o=t[3],a=t[2],i=s??o;if(i===void 0||Hi.has(i))continue;const d=a!==void 0,f=e.get(i);f===void 0?e.set(i,d):f&&!d&&e.set(i,!1)}return[...e.entries()].map(([t,s])=>({hasDefault:s,name:t}))},"extractEnvReferences"),zi=xt(r=>{const{command:e,processEnv:t,taskEnv:s,taskId:o}=r,a=Vi(e);if(a.length===0)return;const i=[];for(const{hasDefault:d,name:f}of a){if(d)continue;const h=s[f],p=t[f];h===void 0&&p===void 0&&i.push(f)}if(i.length!==0)return{missing:i.toSorted(),taskId:o}},"checkStrictEnv"),Ui=xt(r=>{const e=r.missing.map(t=>`$${t}`).join(", ");return`Strict env: ${r.taskId} references unset variable${r.missing.length===1?"":"s"} ${e}. Set ${r.missing.length===1?"it":"them"} in the task env, an envFile, or the parent shell — or opt out with options.strictEnv: false.`},"formatStrictEnvError");var Wi=Object.defineProperty,Ee=_((r,e)=>Wi(r,"name",{value:e,configurable:!0}),"i$2");const or=Ee(r=>{const e=new Set;for(const t of Object.values(r.projects))for(const s of Object.keys(t.targets??{}))e.add(s);return[...e].sort()},"collectAvailableTargets"),Ki=Ee(r=>{const e=new Map;for(const t of r.values())for(const[s,o]of Object.entries(t))for(const a of o.aliases??[])e.has(a)||e.set(a,s);return e},"buildAliasMap"),Yi=Ee((r,e)=>e.get(r)??r,"resolveTargetAlias"),Xi=Ee((r,e)=>{if(r.length===0)return e.length;if(e.length===0)return r.length;const t=[];for(let s=0;s<=e.length;s++)t[s]=[s];for(let s=0;s<=r.length;s++)t[0][s]=s;for(let s=1;s<=e.length;s++)for(let o=1;o<=r.length;o++){const a=e[s-1]===r[o-1]?0:1;t[s][o]=Math.min(t[s-1][o]+1,t[s][o-1]+1,t[s-1][o-1]+a)}return t[e.length][r.length]},"levenshtein"),Qi=Ee((r,e,t=3)=>Pr(r,e,1,t)[0],"suggestTarget"),Pr=Ee((r,e,t=3,s=3)=>{const o=[];for(const a of e){const i=Xi(r.toLowerCase(),a.toLowerCase());i<=s&&o.push({distance:i,name:a})}return o.sort((a,i)=>a.distance-i.distance||a.name.localeCompare(i.name)),o.slice(0,t).map(a=>a.name)},"suggestTargets"),Ji=Ee(r=>r.length===0?" (no targets found)":r.map(e=>` - ${e}`).join(`
|
|
2
|
-
`),"formatTargetList"),
|
|
3
|
-
`);for(const[o,
|
|
1
|
+
var Zr=Object.defineProperty;var _=(r,e)=>Zr(r,"name",{value:e,configurable:!0});import{createRequire as es}from"node:module";import{M as ve,Q as rs,K as ss,C as Ir,z as is,B as Cr,$ as os}from"./config.js";import{aJ as ns,p as er,Y as Tt,Z as It,bb as as,bc as cs,Q as at,bd as ls,X as ds,y as us,m as hs,be as fs,bf as ps,s as rt,bg as gs}from"./bin.js";import{runConcurrently as ct,TerminalBuffer as xr,readLastRunSummary as ms,getLastRunSummaryPath as ws,enforceProjectConstraints as vs,expandTokensInString as tr,parsePartition as ys,TaskScheduler as ks,createTaskGraph as bs,reverseTaskGraph as Ss,generateRunSummary as rr,writeChromeTrace as $s,resolveTurboEnvCompat as Ts,CompositeLifeCycle as sr,defaultTaskRunner as ir,createLogReporter as Is,writeRunSummary as Cs}from"@visulima/task-runner";import{E as xs,a as Ms}from"../packem_shared/cache-directory-C_U1qsIw.js";import{F as Ds}from"../packem_shared/failure-log-CSC6KfcO.js";import{f as As,l as Ls,c as Bs,a as Ns,b as Gs}from"../packem_shared/flakiness-DUtrm-wS.js";import{r as _s}from"../packem_shared/toolchain-B7dckBQ1.js";import{i as qs,a as Hs,b as Vs,s as zs,d as Us,c as Ws,r as Ks,H as Ys,f as Xs,e as Js}from"../packem_shared/lifecycle-CgK8pcfa.js";import{p as Qs,r as Zs,f as ei}from"../packem_shared/selectors-B2ISH581.js";import{renderToString as fe,render as si}from"@visulima/tui";import{Text as a}from"@visulima/tui/components/text";import J,{useSyncExternalStore as ot,useCallback as st,useState as Ye,useRef as Xe,useEffect as wt,useMemo as or}from"react";import{jsxs as u,jsx as l,Fragment as Mr}from"react/jsx-runtime";import{Box as g}from"@visulima/tui/components/box";import{StaticRender as nr}from"@visulima/tui/components/static-render";import{T as Er,C as xt,D as ht,E as Rr}from"../packem_shared/symbols-CQmER5MT.js";import{Dialog as ii}from"@visulima/tui/components/dialog";import{useApp as oi}from"@visulima/tui/hooks/use-app";import{useInput as ar}from"@visulima/tui/hooks/use-input";import{useWindowSize as ni}from"@visulima/tui/hooks/use-window-size";import{ScrollView as Fr}from"@visulima/tui/components/scroll-view";import{Spinner as Or}from"@visulima/tui/components/spinner";const ts=es(import.meta.url),Ke=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Ve=_(r=>{if(typeof Ke<"u"&&Ke.versions&&Ke.versions.node){const[e,t]=Ke.versions.node.split(".").map(Number);if(e>22||e===22&&t>=3||e===20&&t>=16)return Ke.getBuiltinModule(r)}return ts(r)},"__cjs_getBuiltinModule"),{existsSync:Ct,statSync:lt,watch:Es,openSync:Rs,readSync:Fs,closeSync:Os,readFileSync:Ps,mkdtempSync:js}=Ve("node:fs"),{createInterface:ti,emitKeypressEvents:ri}=Ve("node:readline"),{createHash:ai}=Ve("node:crypto"),{appendFile:Mt}=Ve("node:fs/promises"),{platform:ci,homedir:Et,tmpdir:li}=Ve("node:os"),{spawn:di}=Ve("node:child_process");var ui=Object.defineProperty,hi=_((r,e)=>ui(r,"name",{value:e,configurable:!0}),"u$1"),fi=Object.defineProperty,pi=hi((r,e)=>fi(r,"name",{value:e,configurable:!0}),"v"),gi=Object.defineProperty,mi=pi((r,e)=>gi(r,"name",{value:e,configurable:!0}),"D");const wi=mi((r,e,t,s,o,n,i,d,f,p,h,m,c,$)=>{const E={d:s,h:o,m:n,mo:e,ms:d,s:i,w:t,y:r};return f!==void 0&&(E.future=f),p!==void 0&&(E.past=p),h!==void 0&&(E.decimal=h),m!==void 0&&(E.unitMap=m),c!==void 0&&(E.groupSeparator=c),$!==void 0&&(E.placeholderSeparator=$),E},"createDurationLanguage"),vi={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"},yi=wi(r=>`year${r===1?"":"s"}`,r=>`month${r===1?"":"s"}`,r=>`week${r===1?"":"s"}`,r=>`day${r===1?"":"s"}`,r=>`hour${r===1?"":"s"}`,r=>`minute${r===1?"":"s"}`,r=>`second${r===1?"":"s"}`,r=>`millisecond${r===1?"":"s"}`,"in %s","%s ago",".",vi,",","_");var ki=Object.defineProperty,bi=_((r,e)=>ki(r,"name",{value:e,configurable:!0}),"o$4"),Si=Object.defineProperty,$i=bi((r,e)=>Si(r,"name",{value:e,configurable:!0}),"o"),Ti=Object.defineProperty,Ii=$i((r,e)=>Ti(r,"name",{value:e,configurable:!0}),"o");const Ci=Ii(r=>{const e=["y","mo","w","d","h","m","s","ms","future","past"];for(const s of e)if(!Object.hasOwn(r,s))throw new TypeError(`Missing required property: ${s}`);if(typeof r.future!="string"||typeof r.past!="string")throw new TypeError("Properties future and past must be of type string");const t=["y","mo","w","d","h","m","s","ms"];for(const s of t)if(typeof r[s]!="string"&&typeof r[s]!="function")throw new TypeError(`Property ${s} must be of type string or function`);if(r.decimal&&typeof r.decimal!="string")throw new TypeError("Property decimal must be of type string");if(r.delimiter&&typeof r.delimiter!="string")throw new TypeError("Property delimiter must be of type string");if(r._digitReplacements&&!Array.isArray(r._digitReplacements))throw new TypeError("Property _digitReplacements must be an array");if(r._numberFirst&&typeof r._numberFirst!="boolean")throw new TypeError("Property _numberFirst must be of type boolean");if(r.unitMap&&typeof r.unitMap!="object")throw new TypeError("Property unitMap must be an object");if(r.unitMap&&Object.values(r.unitMap).some(s=>typeof s!="string"))throw new TypeError("All values in unitMap must be of type string")},"validateDurationLanguage");var xi=Object.defineProperty,Mi=_((r,e)=>xi(r,"name",{value:e,configurable:!0}),"b$2"),Ei=Object.defineProperty,Ri=Mi((r,e)=>Ei(r,"name",{value:e,configurable:!0}),"b"),Fi=Object.defineProperty,Qe=Ri((r,e)=>Fi(r,"name",{value:e,configurable:!0}),"g");const Pr=Qe((r,e)=>{e=e||-1;const t=new RegExp(String.raw`^-?\d+(?:.\d{0,${String(e)}})?`).exec(r.toString());return t===null?r:Number.parseFloat(t[0])},"toFixed"),cr=Qe(({unitCount:r,unitName:e},t,s)=>{let{spacer:o}=s;const{maxDecimalPoints:n}=s;let i=".";s.decimal!==void 0?i=s.decimal:t.decimal!==void 0&&(i=t.decimal);let d;"digitReplacements"in s?d=s.digitReplacements:"_digitReplacements"in t&&(d=t._digitReplacements);let f,p=r;n!==void 0&&(p=Pr(r,n));const h=p.toString();if(!t._hideCountIf2||r!==2)if(d){f="";for(const $ of h)f+=$==="."?i:d[$]}else f=h.replace(".",i);else f="";const m=t[e];let c=m;return typeof m=="function"&&(c=m(r)),t._hideCountIf2&&r===2&&(o=""),t._numberFirst?c+o+f:f+o+c},"renderPiece"),Oi=Qe((r,e)=>{const{units:t}=e;if(t.length===0)return[];const{unitMeasures:s}=e,o=e.largest??Number.POSITIVE_INFINITY,n={};let i,d,f,p=r;for(d=0;d<t.length;d++){i=t[d];const m=s[i];f=d===t.length-1?p/m:Math.floor(p/m),n[i]=f,p-=f*m}if(e.round){let m=o;for(d=0;d<t.length;d++)if(i=t[d],f=n[i],f!==0&&(m--,m===0)){for(let c=d+1;c<t.length;c++){const $=t[c],E=n[$];n[i]=(n[i]??0)+E*s[$]/s[i],n[$]=0}break}for(d=t.length-1;d>=0;d--){if(i=t[d],f=n[i],f===0)continue;const c=Math.round(f);if(n[i]=c,d===0)break;const $=t[d-1],E=s[$],D=Math.floor(c*s[i]/E);if(D)n[$]=(n[$]??0)+D,n[i]=0;else break}}const h=[];for(d=0;d<t.length&&h.length<o;d++){if(i=t[d],f=n[i],f&&!e.round&&h.length===o-1){let m,c=0;for(m=d+1,t.length;m<t.length;m++){const $=t[m];c+=n[$]*(e.unitMeasures[$]/e.unitMeasures[i])}f+=c,e.maxDecimalPoints!==void 0&&(f=Pr(f,e.maxDecimalPoints))}f&&h.push({unitCount:f,unitName:i})}return h},"getPieces"),Pi=Qe((r,e,t)=>{const{language:s,units:o}=e;if(r.length===0){const m=o.at(-1);return cr({unitCount:0,unitName:m},s,e)}const{conjunction:n,serialComma:i}=e;let d=", ";e.delimiter!==void 0?d=e.delimiter:s.delimiter!==void 0&&(d=s.delimiter);let f="";e.timeAdverb&&t!==0&&(f=s.future??"",t<0&&(f=s.past??""));const p=r.map(m=>cr(m,s,e));let h;return!n||r.length===1?h=p.join(d):r.length===2?h=p.join(n):h=p.slice(0,-1).join(d)+(i?",":"")+n+(p.at(-1)??""),f&&(h=f.replace("%s",h)),h},"formatPieces"),jr=Qe((r,e)=>{if(Number.isNaN(r))throw new TypeError("Expected a valid number");if(typeof r!="number")throw new TypeError("Expected a number for milliseconds input");const t={conjunction:"",language:yi,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};Ci(t.language);const s=Math.abs(r),o=Oi(s,t);return Pi(o,t,r)},"duration");var ji=Object.defineProperty,ft=_((r,e)=>ji(r,"name",{value:e,configurable:!0}),"s$2");const Di={bun:["bun.lock","bun.lockb"],npm:["package-lock.json"],pnpm:["pnpm-lock.yaml"],yarn:["yarn.lock"]},Ai={bun:["node_modules/.bun-tag"],npm:["node_modules/.package-lock.json"],pnpm:["node_modules/.modules.yaml","node_modules/.pnpm/lock.yaml"],yarn:["node_modules/.yarn-integrity","node_modules/.yarn-state.yml",".yarn/install-state.gz"]},Li={ci:{bun:"bun install --frozen-lockfile",npm:"npm ci",pnpm:"pnpm install --frozen-lockfile",yarn:"yarn install --immutable"},tty:{bun:"bun install",npm:"npm install",pnpm:"pnpm install",yarn:"yarn install"}},Bi=1e3,Ni=ft(r=>{for(const[e,t]of Object.entries(Di))for(const s of t)if(Ct(ve(r,s)))return{lockfileFile:s,manager:e}},"detectPackageManager"),Gi=ft((r,e)=>{let t;for(const s of Ai[e]){const o=ve(r,s);if(!Ct(o))continue;const{mtimeMs:n}=lt(o);(!t||n>t.mtimeMs)&&(t={mtimeMs:n,path:s})}return t},"findFreshestMarker"),_i=ft((r,e={})=>{const t=Ni(r);if(!t)return{checked:!1};const{lockfileFile:s,manager:o}=t,n=lt(ve(r,s)).mtimeMs,i=Gi(r,o),d=Li[e.inCi?"ci":"tty"][o],f={installMarkerMtimeMs:i?.mtimeMs,lockfileMtimeMs:n,lockfilePath:s,marker:i?.path,packageManager:o};return i?n>i.mtimeMs+Bi?{checked:!0,detail:f,failure:"stale-install",message:`${s} is newer than node_modules (${i.path}) — run \`${d}\` to sync.`}:{checked:!0,detail:f}:{checked:!0,detail:f,failure:"missing-install",message:`lockfile detected but node_modules looks uninitialised — run \`${d}\` before \`vis run\`.`}},"checkLockfileFreshness"),qi=ft((r,e,t,s={})=>{if(s.skip)return{checked:!1,shouldContinue:!0};const o=_i(r,{inCi:e});if(!o.failure)return{...o,shouldContinue:!0};const n=`preflight: ${o.message??"lockfile drift detected"}`;return e&&!s.ciAsWarning?{...o,formattedMessage:n,shouldContinue:!1}:(t.warn(n),{...o,formattedMessage:n,shouldContinue:!0})},"runLockfilePreflight");var Hi=Object.defineProperty,Dr=_((r,e)=>Hi(r,"name",{value:e,configurable:!0}),"f$6");const Vi=Dr(r=>r.split(",").map(e=>e.trim()).filter(e=>e!==""),"splitPatterns"),zi=Dr((r,e,t)=>{const s=new Set,o=[];if(r===void 0||r.trim()==="")return{skipTaskIds:s,unmatchedPatterns:o};const n=[...t],i=new Set(n),d=new Map;for(const f of n){const p=f.lastIndexOf(":");if(p===-1)continue;const h=f.slice(p+1),m=d.get(h);m===void 0?d.set(h,[f]):m.push(f)}for(const f of Vi(r)){if(f.startsWith("~:"))throw new Error(`--skip-cache does not support the closest-project selector "~:" (received "${f}"). Use \`pkg:target\`, \`:target\`, or \`#tag:target\`.`);if(i.has(f)){s.add(f);continue}const p=Qs(f);if(!p){o.push(f);continue}let h=!1;switch(p.kind){case"all":{const m=d.get(p.target)??[];for(const c of m)s.add(c),h=!0;break}case"project":{const m=p.projects?.[0];if(m!==void 0){const c=`${m}:${p.target}`;i.has(c)&&(s.add(c),h=!0)}break}case"tag":{const{tag:m}=p;if(m!==void 0){const c=d.get(p.target)??[];for(const $ of c){const E=$.slice(0,$.lastIndexOf(":"));e.projects[E]?.tags?.includes(m)===!0&&(s.add($),h=!0)}}break}}h||o.push(f)}return{skipTaskIds:s,unmatchedPatterns:o}},"resolveSkipCachePatterns");var Ui=Object.defineProperty,Rt=_((r,e)=>Ui(r,"name",{value:e,configurable:!0}),"a$1");const Wi=/\$(?:\{([A-Z_]\w*)(:-[^}]*)?\}|([A-Z_]\w*))/gi,Ki=new Set(["0","!","#","$","*","-","?","@","_"]),Yi=Rt(r=>{const e=new Map;for(const t of r.matchAll(Wi)){const s=t[1],o=t[3],n=t[2],i=s??o;if(i===void 0||Ki.has(i))continue;const d=n!==void 0,f=e.get(i);f===void 0?e.set(i,d):f&&!d&&e.set(i,!1)}return[...e.entries()].map(([t,s])=>({hasDefault:s,name:t}))},"extractEnvReferences"),Xi=Rt(r=>{const{command:e,processEnv:t,taskEnv:s,taskId:o}=r,n=Yi(e);if(n.length===0)return;const i=[];for(const{hasDefault:d,name:f}of n){if(d)continue;const p=s[f],h=t[f];p===void 0&&h===void 0&&i.push(f)}if(i.length!==0)return{missing:i.toSorted(),taskId:o}},"checkStrictEnv"),Ji=Rt(r=>{const e=r.missing.map(t=>`$${t}`).join(", ");return`Strict env: ${r.taskId} references unset variable${r.missing.length===1?"":"s"} ${e}. Set ${r.missing.length===1?"it":"them"} in the task env, an envFile, or the parent shell — or opt out with options.strictEnv: false.`},"formatStrictEnvError");var Qi=Object.defineProperty,Pe=_((r,e)=>Qi(r,"name",{value:e,configurable:!0}),"i$2");const lr=Pe(r=>{const e=new Set;for(const t of Object.values(r.projects))for(const s of Object.keys(t.targets??{}))e.add(s);return[...e].sort()},"collectAvailableTargets"),Zi=Pe(r=>{const e=new Map;for(const t of r.values())for(const[s,o]of Object.entries(t))for(const n of o.aliases??[])e.has(n)||e.set(n,s);return e},"buildAliasMap"),eo=Pe((r,e)=>e.get(r)??r,"resolveTargetAlias"),to=Pe((r,e)=>{if(r.length===0)return e.length;if(e.length===0)return r.length;const t=[];for(let s=0;s<=e.length;s++)t[s]=[s];for(let s=0;s<=r.length;s++)t[0][s]=s;for(let s=1;s<=e.length;s++)for(let o=1;o<=r.length;o++){const n=e[s-1]===r[o-1]?0:1;t[s][o]=Math.min(t[s-1][o]+1,t[s][o-1]+1,t[s-1][o-1]+n)}return t[e.length][r.length]},"levenshtein"),ro=Pe((r,e,t=3)=>Ar(r,e,1,t)[0],"suggestTarget"),Ar=Pe((r,e,t=3,s=3)=>{const o=[];for(const n of e){const i=to(r.toLowerCase(),n.toLowerCase());i<=s&&o.push({distance:i,name:n})}return o.sort((n,i)=>n.distance-i.distance||n.name.localeCompare(i.name)),o.slice(0,t).map(n=>n.name)},"suggestTargets"),so=Pe(r=>r.length===0?" (no targets found)":r.map(e=>` - ${e}`).join(`
|
|
2
|
+
`),"formatTargetList"),io=Pe(async r=>{if(r.length===0||!process.stdin.isTTY||!process.stdout.isTTY)return;const e=ti({input:process.stdin,output:process.stdout});try{process.stdout.write(`Available targets:
|
|
3
|
+
`);for(const[o,n]of r.entries())process.stdout.write(` ${String(o+1).padStart(2," ")}. ${n}
|
|
4
4
|
`);process.stdout.write(`
|
|
5
|
-
`);const t=(await new Promise(o=>{e.question("Select a target (number or name, blank to cancel): ",o)})).trim();if(t.length===0)return;const s=Number.parseInt(t,10);return Number.isFinite(s)&&s>=1&&s<=r.length?r[s-1]:r.includes(t)?t:
|
|
6
|
-
`).map(
|
|
7
|
-
|
|
8
|
-
`))S.push(y.endsWith("\r")?y.slice(0,-1):y);return!o&&(
|
|
9
|
-
`)})})}),s&&
|
|
10
|
-
`):B?l.outputs.get(B)??"":"",pe=y??B,be=y?ke?.status==="crashed"||ke?.status==="failed"?"failure":"running":z?.status,Fe=Rt(s,d,f),Ie=l.done?`Completed ${Fe} (${Le((l.endTime??Date.now())-l.startTime)})`:`Running ${Fe}...`,Pe=l.done?l.failed>0?"error":"success":"running",ge=et(T=>{H.current?.scrollTo(Math.max(0,T-2))},[]);if(pt(()=>{l.interactiveMode&&z?.status!=="running"&&i.setInteractiveMode(!1)},[l.interactiveMode,z?.status,i]),pt(()=>{if(!B)return;let T=p;l.viewMode==="split"&&p>=hr?T=p-Math.floor(p*.4)-2:(l.viewMode==="split"||l.viewMode==="fullscreen")&&(T=p-2);const k=Math.max(1,w-4);a.get(B)?.resize?.(T,k)},[p,w,l.viewMode,B]),sr((T,k)=>{if(k.escape){i.setInteractiveMode(!1);return}if(!B)return;const C=a.get(B);if(!C){i.setInteractiveMode(!1);return}if(k.return)C.write("\r");else if(k.upArrow)C.write("\x1B[A");else if(k.downArrow)C.write("\x1B[B");else if(k.rightArrow)C.write("\x1B[C");else if(k.leftArrow)C.write("\x1B[D");else if(k.backspace)C.write("");else if(k.delete)C.write("\x1B[3~");else if(k.tab)C.write(" ");else if(k.home)C.write("\x1B[H");else if(k.end)C.write("\x1B[F");else if(k.pageUp)C.write("\x1B[5~");else if(k.pageDown)C.write("\x1B[6~");else if(k.ctrl&&T){const ee=T.toUpperCase().codePointAt(0);ee!==void 0&&ee>=65&&ee<=90&&C.write(String.fromCodePoint(ee-64))}else T&&C.write(T)},{isActive:l.interactiveMode}),sr((T,k)=>{if(T==="c"&&k.ctrl){h();return}if(!Y){if(q){k.escape||T==="?"?v(!1):T==="q"?(v(!1),re(!0)):k.downArrow||T==="j"?x.current?.scrollBy(1):k.upArrow||T==="k"?x.current?.scrollBy(-1):k.pageDown?x.current?.scrollBy(5):k.pageUp?x.current?.scrollBy(-5):k.home?x.current?.scrollToTop():k.end&&x.current?.scrollToBottom();return}if(T==="?"){v(!0);return}if(T==="q"){re(!0);return}if(T==="r"&&l.done){i.requestRerun();return}if(T==="R"&&l.done){const C=le[l.selectedIndex];C?.status==="failure"&&i.requestRetry(C.taskId);return}if(T==="F"&&!l.filterActive){const C=["all","failed","running","passed"],ee=C.indexOf(l.statusFilter);i.setStatusFilter(C[(ee+1)%C.length]);return}if(l.filterActive){if(k.escape){i.setFilterActive(!1);return}if(k.return){i.setFilterActive(!1);return}if(k.backspace){i.setFilter(l.filterText.slice(0,-1));return}if(T&&!k.ctrl&&!k.meta){i.setFilter(l.filterText+T);return}return}if(T==="i"&&z?.status==="running"&&(l.viewMode==="fullscreen"||l.viewMode==="split"&&l.focusedPanel==="output")){i.setInteractiveMode(!0);return}if(l.viewMode==="fullscreen"){if(k.escape){i.setViewMode("split"),D("split");return}if(T==="f"){const C=!V;A(C),C&&O.current?.scrollToBottom();return}if(k.downArrow||T==="j"){A(!1),O.current?.scrollBy(1);return}if(k.upArrow||T==="k"){A(!1),O.current?.scrollBy(-1);return}if(k.pageDown||k.ctrl&&T==="d"){A(!1),O.current?.scrollBy(12);return}if(k.pageUp||k.ctrl&&T==="u"){A(!1),O.current?.scrollBy(-12);return}if(k.home){A(!1),O.current?.scrollToTop();return}if(k.end){A(!0),O.current?.scrollToBottom();return}return}if(l.focusedPanel==="dock"&&L&&o){if(k.tab){F(null),i.setFocusedPanel("tasks");return}if(k.escape){i.setFocusedPanel("tasks"),F(null),l.viewMode==="split"&&(i.setViewMode("list"),D("list"));return}if(k.downArrow||T==="j"){S(C=>Math.min(C+1,E.length-1));return}if(k.upArrow||T==="k"){S(C=>Math.max(C-1,0));return}if(k.return){const C=E[R];C&&(F(C),A(!0),se(),Z.current.splitList=0,Z.current.splitOutput=0,i.setViewMode("split"),i.setFocusedPanel("output"),D("split"));return}if((T==="r"||T==="R")&&e){const C=E[R],ee=C?o.getState(C)?.status:void 0;if(C&&(ee==="crashed"||ee==="failed")){const Ae=e(C);Ae instanceof Promise&&Ae.catch(()=>{})}return}return}if(l.viewMode==="split"){if(k.tab){l.focusedPanel==="tasks"?i.setFocusedPanel("output"):L?i.setFocusedPanel("dock"):(F(null),i.setFocusedPanel("tasks"));return}if(l.focusedPanel==="output"){if(k.escape){if(y&&L){F(null),i.setViewMode("list"),i.setFocusedPanel("dock"),D("list");return}F(null),i.setFocusedPanel("tasks");return}if(k.return){se(),i.setViewMode("fullscreen");return}if(T==="f"){const C=!V;A(C),C&&O.current?.scrollToBottom();return}if(k.downArrow||T==="j"){A(!1),O.current?.scrollBy(1);return}if(k.upArrow||T==="k"){A(!1),O.current?.scrollBy(-1);return}if(k.pageDown||k.ctrl&&T==="d"){A(!1),O.current?.scrollBy(12);return}if(k.pageUp||k.ctrl&&T==="u"){A(!1),O.current?.scrollBy(-12);return}if(k.home){A(!1),O.current?.scrollToTop();return}if(k.end){A(!0),O.current?.scrollToBottom();return}return}if(k.escape){i.setViewMode("list"),D("list");return}if(k.return){i.setFocusedPanel("output");return}}if(l.viewMode==="list"||l.viewMode==="split"&&l.focusedPanel==="tasks"){if(k.tab&&l.viewMode==="list"&&L){i.setFocusedPanel("dock");return}if(k.downArrow||T==="j"){const C=Math.min(l.selectedIndex+1,Math.max(0,le.length-1));i.setSelectedIndex(C),ge(C);return}if(k.upArrow||T==="k"){const C=Math.max(l.selectedIndex-1,0);i.setSelectedIndex(C),ge(C);return}if(k.return&&l.viewMode==="list"){A(!0),se(),Z.current.splitList=0,Z.current.splitOutput=0,i.setViewMode("split"),i.setFocusedPanel("output"),D("split");return}if(T==="/"){i.setFilterActive(!0);return}if(T==="1"&&te){i.pinTask(0,te);return}if(T==="2"&&te){i.pinTask(1,te);return}if(T==="0"){i.clearPins();return}k.escape&&l.filterText&&i.setFilter("")}}},{isActive:!l.interactiveMode}),p<ur||w<fr)return c(g,{alignItems:"center",height:w,justifyContent:"center",width:p,children:u(n,{color:"yellow",children:["Terminal too small (",p,"x",w,"). Minimum:"," ",ur,"x",fr]})});const ae=u(g,{gap:1,children:[l.succeeded>0&&u(n,{bold:!0,color:"green",children:["✓"," ",l.succeeded]}),l.failed>0&&u(n,{bold:!0,color:"red",children:["✗"," ",l.failed]}),Me>0&&u(n,{color:"cyan",children:["◷"," ",Me]}),u(n,{dimColor:!0,children:[l.rows.length," ","total"]}),l.statusFilter!=="all"&&u(n,{color:"yellow",children:["[",l.statusFilter,"]"]})]});let Re;if(l.viewMode==="fullscreen")Re=[u(g,{gap:1,children:[c(n,{bold:!0,color:"white",children:"Esc"}),c(n,{dimColor:!0,children:"BACK"})]},"esc"),u(g,{gap:1,children:[c(n,{bold:!0,color:"white",children:"↑↓"}),c(n,{dimColor:!0,children:"SCROLL"})]},"scroll"),u(g,{gap:1,children:[c(n,{bold:!0,color:"white",children:"^u ^d"}),c(n,{dimColor:!0,children:"PAGE"})]},"page"),...z?.status==="running"?[u(g,{gap:1,children:[c(n,{bold:!0,color:"white",children:"i"}),c(n,{dimColor:!0,children:"INPUT"})]},"i")]:[],u(g,{gap:1,children:[c(n,{bold:!0,color:"white",children:"q"}),c(n,{dimColor:!0,children:"QUIT"})]},"q")];else if(l.done){const T=le[l.selectedIndex]?.status==="failure";Re=[u(g,{gap:1,children:[c(n,{bold:!0,color:"white",children:"q"}),c(n,{dimColor:!0,children:"QUIT"})]},"q"),u(g,{gap:1,children:[c(n,{bold:!0,color:"white",children:"r"}),c(n,{dimColor:!0,children:"RERUN"})]},"r"),...T?[u(g,{gap:1,children:[c(n,{bold:!0,color:"white",children:"R"}),c(n,{dimColor:!0,children:"RETRY"})]},"R")]:[],u(g,{gap:1,children:[c(n,{bold:!0,color:"white",children:"?"}),c(n,{dimColor:!0,children:"HELP"})]},"?"),u(g,{gap:1,children:[c(n,{bold:!0,color:"white",children:"↑↓"}),c(n,{dimColor:!0,children:"NAV"})]},"nav"),u(g,{gap:1,children:[c(n,{bold:!0,color:"white",children:"F"}),c(n,{dimColor:!0,children:"FILTER"})]},"F"),u(g,{gap:1,children:[c(n,{bold:!0,color:"white",children:"⏎"}),c(n,{dimColor:!0,children:l.viewMode==="list"?"OUTPUT":"FULLSCREEN"})]},"enter")]}else l.viewMode==="split"&&l.focusedPanel==="output"?Re=[u(g,{gap:1,children:[c(n,{bold:!0,color:"white",children:"q"}),c(n,{dimColor:!0,children:"QUIT"})]},"q"),u(g,{gap:1,children:[c(n,{bold:!0,color:"white",children:"Esc"}),c(n,{dimColor:!0,children:"BACK"})]},"esc"),u(g,{gap:1,children:[c(n,{bold:!0,color:"white",children:"↑↓"}),c(n,{dimColor:!0,children:"SCROLL"})]},"scroll"),...z?.status==="running"?[u(g,{gap:1,children:[c(n,{bold:!0,color:"white",children:"i"}),c(n,{dimColor:!0,children:"INPUT"})]},"i")]:[],u(g,{gap:1,children:[c(n,{bold:!0,color:"white",children:"⏎"}),c(n,{dimColor:!0,children:"FULLSCREEN"})]},"enter"),u(g,{gap:1,children:[c(n,{bold:!0,color:"white",children:"Tab"}),c(n,{dimColor:!0,children:"PANEL"})]},"tab"),u(g,{gap:1,children:[c(n,{bold:!0,color:"white",children:"?"}),c(n,{dimColor:!0,children:"HELP"})]},"?")]:Re=[u(g,{gap:1,children:[c(n,{bold:!0,color:"white",children:"q"}),c(n,{dimColor:!0,children:"QUIT"})]},"q"),u(g,{gap:1,children:[c(n,{bold:!0,color:"white",children:"?"}),c(n,{dimColor:!0,children:"HELP"})]},"?"),u(g,{gap:1,children:[c(n,{bold:!0,color:"white",children:"↑↓"}),c(n,{dimColor:!0,children:"NAV"})]},"nav"),u(g,{gap:1,children:[c(n,{bold:!0,color:"white",children:"/"}),c(n,{dimColor:!0,children:"FILTER"})]},"/"),u(g,{gap:1,children:[c(n,{bold:!0,color:"white",children:"F"}),c(n,{dimColor:!0,children:"STATUS"})]},"F"),u(g,{gap:1,children:[c(n,{bold:!0,color:"white",children:"⏎"}),c(n,{dimColor:!0,children:l.viewMode==="list"?"OUTPUT":"FULLSCREEN"})]},"enter"),...l.viewMode==="split"?[u(g,{gap:1,children:[c(n,{bold:!0,color:"white",children:"Tab"}),c(n,{dimColor:!0,children:"PANEL"})]},"tab")]:[]];const we=u(g,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",flexShrink:0,justifyContent:"space-between",children:[c(g,{flexGrow:1,flexWrap:"wrap",gap:2,paddingX:1,children:Re}),c(g,{flexShrink:0,paddingX:1,children:ae})]}),Oe=u(ei,{backgroundColor:"#1e1e1e",footer:u(n,{dimColor:!0,children:[c(n,{bold:!0,color:"white",children:"↑↓"})," ","scroll"," ",c(n,{bold:!0,color:"white",children:"?"}),"/",c(n,{bold:!0,color:"white",children:"Esc"})," ","close"]}),scrollRef:x,title:"KEYBOARD SHORTCUTS",visible:q,width:52,children:[u(g,{flexDirection:"column",marginBottom:1,children:[u(g,{marginBottom:1,children:[c(n,{dimColor:!0,children:"── "}),c(n,{bold:!0,color:"white",children:"NAVIGATION"})]}),u(g,{children:[c(g,{width:24,children:u(n,{children:[u(n,{bold:!0,color:"white",children:[" ","↑","/k"]}),c(n,{dimColor:!0,children:" Move up"})]})}),u(n,{children:[u(n,{bold:!0,color:"white",children:[" ","↓","/j"]}),c(n,{dimColor:!0,children:" Move down"})]})]}),u(n,{children:[u(n,{bold:!0,color:"white",children:[" ","Tab"]}),c(n,{dimColor:!0,children:" Switch panel (split)"})]}),u(n,{children:[u(n,{bold:!0,color:"white",children:[" ","Esc"]}),c(n,{dimColor:!0,children:" Back / close"})]}),u(n,{children:[u(n,{bold:!0,color:"white",children:[" ","Enter"]}),c(n,{dimColor:!0,children:" Show output / fullscreen"})]})]}),u(g,{flexDirection:"column",marginBottom:1,children:[u(g,{marginBottom:1,children:[c(n,{dimColor:!0,children:"── "}),c(n,{bold:!0,color:"white",children:"VIEWS"})]}),u(n,{children:[u(n,{bold:!0,color:"white",children:[" ","Enter"]}),u(n,{dimColor:!0,children:[" ","List"," ","→"," ","Split"," ","→"," ","Fullscreen"]})]}),u(n,{children:[u(n,{bold:!0,color:"white",children:[" ","Esc"]}),u(n,{dimColor:!0,children:[" ","Fullscreen"," ","→"," ","Split"," ","→"," ","List"]})]})]}),u(g,{flexDirection:"column",marginBottom:1,children:[u(g,{marginBottom:1,children:[c(n,{dimColor:!0,children:"── "}),c(n,{bold:!0,color:"white",children:"ACTIONS"})]}),u(g,{children:[c(g,{width:24,children:u(n,{children:[u(n,{bold:!0,color:"white",children:[" ","/"]}),c(n,{dimColor:!0,children:" Filter by text"})]})}),u(n,{children:[u(n,{bold:!0,color:"white",children:[" ","F"]}),c(n,{dimColor:!0,children:" Filter by status"})]})]}),u(g,{children:[c(g,{width:24,children:u(n,{children:[u(n,{bold:!0,color:"white",children:[" ","1"]}),c(n,{dimColor:!0,children:"/"}),c(n,{bold:!0,color:"white",children:"2"}),c(n,{dimColor:!0,children:" Pin to output pane"})]})}),u(n,{children:[u(n,{bold:!0,color:"white",children:[" ","0"]}),c(n,{dimColor:!0,children:" Clear pins"})]})]}),u(g,{children:[c(g,{width:24,children:u(n,{children:[u(n,{bold:!0,color:"white",children:[" ","r"]}),c(n,{dimColor:!0,children:" Rerun all (done)"})]})}),u(n,{children:[u(n,{bold:!0,color:"white",children:[" ","R"]}),c(n,{dimColor:!0,children:" Retry failed task"})]})]}),u(n,{children:[u(n,{bold:!0,color:"white",children:[" ","i"]}),c(n,{dimColor:!0,children:" Interactive input (running task)"})]})]}),u(g,{flexDirection:"column",marginBottom:1,children:[u(g,{marginBottom:1,children:[c(n,{dimColor:!0,children:"── "}),c(n,{bold:!0,color:"white",children:"SCROLLING"}),c(n,{dimColor:!0,children:" (output panel)"})]}),u(g,{children:[c(g,{width:24,children:u(n,{children:[u(n,{bold:!0,color:"white",children:[" ","↑","/k"]}),c(n,{dimColor:!0,children:" Scroll up"})]})}),u(n,{children:[u(n,{bold:!0,color:"white",children:[" ","↓","/j"]}),c(n,{dimColor:!0,children:" Scroll down"})]})]}),u(g,{children:[c(g,{width:24,children:u(n,{children:[u(n,{bold:!0,color:"white",children:[" ","^u"]}),c(n,{dimColor:!0,children:" Page up"})]})}),u(n,{children:[u(n,{bold:!0,color:"white",children:[" ","^d"]}),c(n,{dimColor:!0,children:" Page down"})]})]}),u(g,{children:[c(g,{width:24,children:u(n,{children:[u(n,{bold:!0,color:"white",children:[" ","Home"]}),c(n,{dimColor:!0,children:" Top"})]})}),u(n,{children:[u(n,{bold:!0,color:"white",children:[" ","End"]}),c(n,{dimColor:!0,children:" Bottom (resume follow)"})]})]}),u(n,{children:[u(n,{bold:!0,color:"white",children:[" ","f"]}),c(n,{dimColor:!0,children:" Toggle auto-scroll (tail mode)"})]})]}),u(g,{flexDirection:"column",children:[u(g,{marginBottom:1,children:[c(n,{dimColor:!0,children:"── "}),c(n,{bold:!0,color:"white",children:"GENERAL"})]}),u(g,{children:[c(g,{width:24,children:u(n,{children:[u(n,{bold:!0,color:"white",children:[" ","q"]}),c(n,{dimColor:!0,children:" Quit"})]})}),u(n,{children:[u(n,{bold:!0,color:"white",children:[" ","?"]}),c(n,{dimColor:!0,children:" Toggle help"})]})]})]})]}),de=c(ss,{autoExitSeconds:r>0?r:3,onCancel:_(()=>{re(!1)},"onCancel"),visible:Y}),je=L&&o?c(Co,{activeIndex:R,focused:l.focusedPanel==="dock",store:o}):null;if(l.viewMode==="fullscreen")return u(g,{flexDirection:"column",height:w,width:p,children:[c(g,{flexGrow:1,children:c(ar,{autoScroll:V,duration:z?.duration??z?.elapsed,focused:!0,interactiveMode:l.interactiveMode,output:Ce,scrollRef:O,status:be,supportsInteractive:!y,taskId:pe})}),je,we,de,Oe]});if(l.viewMode==="split"){const T=p>=hr,k=c(dr,{compact:!0,filterActive:l.filterActive,filterText:l.filterText,focused:l.focusedPanel==="tasks",headerStatus:Pe,parallelSlots:t,pinnedTaskIds:l.pinnedTaskIds,rows:le,scrollRef:H,selectedIndex:l.selectedIndex,title:Ie}),C=c(ar,{autoScroll:V,duration:z?.duration??z?.elapsed,focused:l.focusedPanel==="output",interactiveMode:l.interactiveMode,output:Ce,scrollRef:O,showFullscreenHint:!0,status:be,supportsInteractive:!y,taskId:pe});if(T){const Ae=Math.floor(p*.4);return u(g,{flexDirection:"column",height:w,width:p,children:[u(g,{flexDirection:"row",flexGrow:1,children:[c(g,{width:Ae,children:k}),c(g,{flexGrow:1,children:C})]}),je,we,de,Oe]})}const ee=Math.floor(w*.45);return u(g,{flexDirection:"column",height:w,width:p,children:[c(g,{height:ee,children:k}),c(g,{flexGrow:1,children:C}),je,we,de,Oe]})}return u(g,{flexDirection:"column",height:w,width:p,children:[c(g,{flexGrow:1,children:c(dr,{filterActive:l.filterActive,filterText:l.filterText,focused:l.focusedPanel!=="dock",headerStatus:Pe,parallelSlots:t,pinnedTaskIds:l.pinnedTaskIds,rows:le,scrollRef:H,selectedIndex:l.selectedIndex,title:Ie})}),je,we,de,Oe]})},"VisTaskRunnerApp");var Po=Object.defineProperty,De=_((r,e)=>Po(r,"name",{value:e,configurable:!0}),"r$1");const Oo=De(r=>{const{args:e,autoExit:t=!1,onRetryService:s,outputStyle:o="normal",projectNames:a,serviceDockStore:i,stdinRegistry:d,tasks:f}=r,h=new at(f),p=typeof e.parallel=="number"?e.parallel:3,w=t===!0?3:typeof t=="number"?t:0;let l,$;const E=new Promise(x=>{$=x});let L;const R=De(()=>{L&&(clearInterval(L),L=void 0)},"cleanup"),S=De(()=>{if(process.stdin.isTTY&&typeof process.stdin.setRawMode=="function")try{process.stdin.setRawMode(!1)}catch{}process.stdin.pause(),process.stdin.unref()},"releaseStdin"),y=De(()=>{if(d){for(const x of d.values())x.kill?.();d.clear()}},"killAllPtyProcesses"),F=De(()=>{R(),v(),y(),S(),process.stdout.write("\x1B[?1049l\x1B[?25h"),l?.cleanup(),process.exit(1)},"onSignal"),X=De(()=>{const x=h.getSnapshot(),H=Le(Date.now()-x.startTime),O=x.rows.filter(V=>V.status==="failure").map(V=>V.taskId),Y=process.stdout.columns||80;process.stdout.write(`
|
|
11
|
-
`);for(const
|
|
5
|
+
`);const t=(await new Promise(o=>{e.question("Select a target (number or name, blank to cancel): ",o)})).trim();if(t.length===0)return;const s=Number.parseInt(t,10);return Number.isFinite(s)&&s>=1&&s<=r.length?r[s-1]:r.includes(t)?t:ro(t,r)}finally{e.close()}},"promptTargetInteractively");var oo=Object.defineProperty,nt=_((r,e)=>oo(r,"name",{value:e,configurable:!0}),"n$1");const no=new RegExp("[\x1B]\\[[0-?]*[ -/]*[@-~]","g"),vt=nt(r=>r.replaceAll(no,"").replaceAll("\r",""),"sanitizeLogLine");class dr{static{_(this,"ServiceDockStore")}static{nt(this,"ServiceDockStore")}#e=[];#s=new Set;#r=new Map;#i=new Map;constructor(e=[]){for(const t of e)this.#i.set(t,{id:t,status:"pending",tailLines:[]});this.#e=[...e],this.#o()}getSnapshot=nt(()=>this.#r,"getSnapshot");subscribe=nt(e=>(this.#s.add(e),()=>{this.#s.delete(e)}),"subscribe");getIds(){return this.#e}getState(e){return this.#i.get(e)}getDockState(){let e=!1,t=!1;for(const s of this.#i.values())s.status==="crashed"||s.status==="failed"?e=!0:(s.status==="pending"||s.status==="starting")&&(t=!0);return e?"crash":t?"boot":"ready"}registerService(e){this.#i.has(e)||(this.#i.set(e,{id:e,status:"pending",tailLines:[]}),this.#e=[...this.#e,e],this.#n())}markStarting(e){this.#t(e,t=>({...t,errorMessage:void 0,startedAt:t.startedAt??Date.now(),status:"starting"}))}markStarted(e,t){this.#t(e,s=>({...s,startedAt:s.startedAt??Date.now(),status:s.status==="ready"?"ready":"starting"}))}markReady(e,t){this.#t(e,s=>({...s,errorMessage:void 0,port:t.port,readyAt:Date.now(),status:"ready"}))}markFailed(e,t,s){const o=s?.message;this.#t(e,n=>({...n,errorMessage:vt(o??t),status:"failed"}))}markCrashed(e,t){const s=t.slice(-256).map(o=>vt(o));this.#t(e,o=>({...o,errorMessage:s.length>0?s[s.length-1]:"process exited",status:"crashed",tailLines:s}))}appendLog(e,t){const s=t.split(`
|
|
6
|
+
`).map(o=>vt(o)).filter(o=>o.length>0);s.length!==0&&this.#t(e,o=>{const n=[...o.tailLines,...s];for(;n.length>256;)n.shift();let i=0;for(let d=n.length-1;d>=0;d--)if(i+=n[d].length+1,i>65536){n.splice(0,d+1);break}return{...o,lastLine:s[s.length-1],tailLines:n}})}abortBoot(e){let t=!1;const s=new Map(this.#i);for(const[o,n]of s)(n.status==="pending"||n.status==="starting")&&(s.set(o,{...n,errorMessage:e,status:"failed"}),t=!0);t&&(this.#i=s,this.#o(),this.#n())}#t(e,t){const s=this.#i.get(e);s&&(this.#i.set(e,t(s)),this.#o(),this.#n())}#o(){this.#r=new Map(this.#i)}#n(){for(const e of this.#s)try{e()}catch{}}}var ao=Object.defineProperty,Ft=_((r,e)=>ao(r,"name",{value:e,configurable:!0}),"i$1");const co=Ft(r=>Array.isArray(r)?`[${r.join(",")}]`:typeof r=="object"&&r!==null?JSON.stringify(r):String(r),"formatValue"),lo=Ft((r,e,t)=>e==="_"?`${r}${Array.isArray(t)?t.join(" "):String(t)}`:`${r}--${e}=${co(t)}`,"formatFlags"),Ot=Ft((r,e,t)=>{const s=new Set(new Set(t.map(c=>c.target.target))),o=new Set(new Set(t.map(c=>c.target.project))),n=e.filter(c=>s.has(c)),i=r.filter(c=>o.has(c)),d=t.length-i.length*n.length,f=n.length===1?"target":"targets",p=n.join(", "),h=i.length===1?`project ${i[0]}`:`${i.length} projects`;let m=`${f} ${p} for ${h}`;return d>0&&(m+=` and ${d} ${d===1?"task":"tasks"} ${d===1?"it depends":"they depend"} on`),m},"formatTargetsAndProjects");var uo=Object.defineProperty,ho=_((r,e)=>uo(r,"name",{value:e,configurable:!0}),"c$3");const fo={error:"red",info:"white",success:"green"},bt=ho(({children:r,title:e,variant:t})=>{const s=fo[t];return u(g,{flexDirection:"column",children:[u(g,{gap:1,children:[l(a,{bold:!0,inverse:!0,children:" VIS "}),l(a,{bold:!0,color:s,children:"•"}),l(a,{children:e})]}),r]})},"Header");var po=Object.defineProperty,go=_((r,e)=>po(r,"name",{value:e,configurable:!0}),"T$3");const Lr=go(({cached:r,failed:e,failedIds:t,projectNames:s,retriedIds:o,skippedIds:n,succeeded:i,targets:d,tasks:f,took:p})=>{const h=Ot(s,d,f),m=o??[];if(e===0&&(!n||n.length===0)){const c=r>0?` (${r} read from cache)`:"";return l(nr,{children:_(()=>l(bt,{title:`Successfully ran ${h}`,variant:"success",children:u(g,{flexDirection:"column",marginTop:1,paddingLeft:3,children:[u(a,{children:[l(a,{color:"green",children:Er})," ",i+r," tasks completed",c?l(a,{dimColor:!0,children:c}):null,l(a,{dimColor:!0,children:` · Took ${p}`})]}),m.length>0&&u(g,{flexDirection:"column",marginTop:1,children:[u(a,{children:[l(a,{color:"yellow",children:"↻"})," ",l(a,{color:"yellow",children:String(m.length)})," task",m.length===1?"":"s"," succeeded after retry:"]}),m.map($=>u(a,{children:[" ",l(a,{color:"yellow",children:"↻"})," ",$]},$))]})]})}),"children")})}return l(nr,{children:_(()=>l(bt,{title:`Ran ${h}`,variant:"error",children:u(g,{flexDirection:"column",marginTop:1,paddingLeft:3,children:[n&&n.length>0&&u(g,{flexDirection:"column",children:[u(a,{dimColor:!0,children:[n.length," ","task",n.length===1?"":"s"," ","skipped (dependency failed or --bail)"]}),n.map(c=>u(a,{dimColor:!0,children:[" - ",c]},c)),l(a,{})]}),e>0&&u(g,{flexDirection:"column",children:[u(a,{children:[l(a,{color:"red",children:String(e)})," ","task",e===1?"":"s"," ","failed:"]}),t.map(c=>u(a,{children:[" ",l(a,{color:"red",children:xt})," ",c]},c)),l(a,{})]}),m.length>0&&u(g,{flexDirection:"column",children:[u(a,{children:[l(a,{color:"yellow",children:String(m.length)})," ","task",m.length===1?"":"s"," ","finished after retry:"]}),m.map(c=>u(a,{children:[" ",l(a,{color:"yellow",children:"↻"})," ",c]},c)),l(a,{})]}),l(a,{dimColor:!0,children:` Took ${p}`})]})}),"children")})},"CommandSummary");var mo=Object.defineProperty,yt=_((r,e)=>mo(r,"name",{value:e,configurable:!0}),"o$3");class dt{static{_(this,"TaskStore")}static{yt(this,"TaskStore")}#e;#s=new Set;#r=new Map;constructor(e){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(t=>({persistent:!!t.overrides.visOptions?.persistent,status:"pending",taskId:t.id})),selectedIndex:0,startTime:Date.now(),statusFilter:"all",succeeded:0,viewMode:"list"}}getSnapshot=yt(()=>this.#e,"getSnapshot");subscribe=yt(e=>(this.#s.add(e),()=>{this.#s.delete(e)}),"subscribe");startTasks(e){const t=[...this.#e.rows];for(const s of e){const o=t.findIndex(n=>n.taskId===s.id);o!==-1&&(t[o]={...t[o],elapsed:0,status:"running"},this.#r.set(s.id,process.hrtime()))}this.#t({...this.#e,rows:t})}endTasks(e){const t=[...this.#e.rows];let{cached:s,completed:o,failed:n,succeeded:i}=this.#e;const d=new Map(this.#e.outputs),f=[...this.#e.retriedIds];for(const h of e){const m=t.findIndex(c=>c.taskId===h.task.id);switch(m!==-1&&(t[m]={...t[m],duration:h.startTime&&h.endTime?h.endTime-h.startTime:void 0,retryAttempts:h.retryAttempts,status:h.status}),h.retryAttempts&&h.retryAttempts>0&&f.push(h.task.id),o++,h.status){case"failure":{n++;break}case"local-cache":case"local-cache-kept-existing":case"remote-cache":{s++;break}case"success":{i++;break}}h.terminalOutput&&!d.has(h.task.id)&&d.set(h.task.id,h.terminalOutput),this.#r.delete(h.task.id)}let{selectedIndex:p}=this.#e;if(n>this.#e.failed){const h=t.findIndex(m=>m.status==="failure");h!==-1&&(p=h)}this.#t({...this.#e,cached:s,completed:o,failed:n,outputs:d,retriedIds:f,rows:t,selectedIndex:p,succeeded:i})}static#i=256*1024;addOutput(e,t){if(!t.trim())return;let s=(this.#e.outputs.get(e)??"")+t;s.length>dt.#i&&(s=s.slice(-dt.#i)),this.#e.outputs.set(e,s),this.#t({...this.#e})}setOutput(e,t){this.#e.outputs.set(e,t),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.#r.size===0)return;let e=!1;const t=[...this.#e.rows];for(let s=0;s<t.length;s++){const o=t[s];if(o.status==="running"){const n=this.#r.get(o.taskId);if(n){const i=process.hrtime(n),d=i[0]*1e3+i[1]/1e6;t[s]={...o,elapsed:d},e=!0}}}e&&this.#t({...this.#e,rows:t})}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,t){const s=[...this.#e.pinnedTaskIds];s[e]=t,this.#t({...this.#e,pinnedTaskIds:s})}clearPins(){this.#t({...this.#e,pinnedTaskIds:[null,null]})}requestRetry(e){const t=[...this.#e.rows],s=t.findIndex(d=>d.taskId===e);let{completed:o,failed:n,succeeded:i}=this.#e;if(s!==-1){const d=t[s].status;d==="failure"?(n=Math.max(0,n-1),o=Math.max(0,o-1)):d==="success"&&(i=Math.max(0,i-1),o=Math.max(0,o-1)),t[s]={...t[s],elapsed:0,retryAttempts:void 0,status:"running"},this.#r.set(e,process.hrtime())}this.#t({...this.#e,completed:o,done:!1,endTime:null,failed:n,interactiveMode:!1,retriedIds:this.#e.retriedIds.filter(d=>d!==e),retryTaskId:e,rows:t,succeeded:i})}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.#r.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})),startTime:Date.now(),succeeded:0,viewMode:"list"})}acknowledgeRerun(){this.#e.rerunRequested&&this.#t({...this.#e,rerunRequested:!1})}#t(e){this.#e=e;for(const t of this.#s)try{t()}catch{}}}var wo=Object.defineProperty,Te=_((r,e)=>wo(r,"name",{value:e,configurable:!0}),"t");const Br={delimiter:" ",language:{d:Te(()=>" d","d"),future:"in %s",h:Te(()=>" h","h"),m:Te(()=>" m","m"),mo:Te(()=>" mo","mo"),ms:Te(()=>" ms","ms"),past:"%s ago",s:Te(()=>" s","s"),w:Te(()=>" w","w"),y:Te(()=>" y","y")},largest:2,round:!0,spacer:"",units:["h","m","s","ms"]};Te(r=>{const e=r[0]*1e3+r[1]/1e6;return jr(e,Br)},"formatHrtime");const Le=Te(r=>jr(r,Br),"formatMs");var vo=Object.defineProperty,Be=_((r,e)=>vo(r,"name",{value:e,configurable:!0}),"s$1");const qe=Be(r=>r==="local-cache"||r==="local-cache-kept-existing"||r==="remote-cache","isCacheStatus"),Ze=Be(r=>{switch(r){case"failure":return{color:"red",icon:xt};case"local-cache":case"local-cache-kept-existing":case"remote-cache":case"success":return{color:"green",icon:Er};case"skipped":return{color:"gray",icon:ht};default:return{color:"gray",icon:"?"}}},"getStatusInfo"),Je=Be(r=>{const{color:e,icon:t}=Ze(r);return fe(J.createElement(a,{color:e},t),{columns:10}).trim()},"getStatusIcon"),yo=Be(r=>{const{color:e,icon:t}=Ze(r);switch(r){case"local-cache":case"local-cache-kept-existing":case"remote-cache":return fe(J.createElement(a,null,J.createElement(a,{color:e},t)," ",J.createElement(a,{color:"cyan"},"[cache]")),{columns:30}).trim();case"skipped":return fe(J.createElement(a,null,J.createElement(a,{dimColor:!0},t)," ",J.createElement(a,{dimColor:!0},"[skipped]")),{columns:30}).trim();default:return fe(J.createElement(a,{color:e},t),{columns:10}).trim()}},"getStatusPrefix"),ko=Be(r=>r==="azure"||r==="buildkite"||r==="github"||r==="gitlab"||r==="off"?r: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","resolveCiGroupingMode"),bo=Be(r=>{const e=r.replaceAll(/\W+/g,"_"),t=ai("sha256").update(r).digest("hex").slice(0,6);return`${e}_${t}`},"toGitLabSectionKey"),So=Be((r,e,t,s="auto")=>{const o=t.trim();if(!o)return;const n=`
|
|
7
|
+
`,i=ko(s);if(i==="github"&&e!=="failure"){process.stdout.write(`::group::${Je(e)} ${r}${n}`),process.stdout.write(o+n),process.stdout.write(`::endgroup::${n}`);return}if(i==="gitlab"&&e!=="failure"){const m=Math.floor(Date.now()/1e3),c=bo(r),$="\x1B[0K";process.stdout.write(`${$}section_start:${String(m)}:${c}[collapsed=true]\r${$}${Je(e)} ${r}${n}`),process.stdout.write(o+n);const E=Math.floor(Date.now()/1e3);process.stdout.write(`${$}section_end:${String(E)}:${c}\r${$}${n}`);return}if(i==="buildkite"&&e!=="failure"){process.stdout.write(`--- ${Je(e)} ${r}${n}`),process.stdout.write(o+n);return}if(i==="azure"&&e!=="failure"){process.stdout.write(`##[group]${Je(e)} ${r}${n}`),process.stdout.write(o+n),process.stdout.write(`##[endgroup]${n}`);return}const d=process.stdout.columns||80,f=fe(J.createElement(a,{dimColor:!0},ht.repeat(d)),{columns:d}).trim(),p=yo(e),h=fe(J.createElement(a,{bold:!0},r),{columns:d}).trim();process.stdout.write(`${f}${n}`),process.stdout.write(`${p} ${h}${n}`),process.stdout.write(o+n),process.stdout.write(`${f}${n}`)},"logCommandOutputCI");var $o=Object.defineProperty,Pt=_((r,e)=>$o(r,"name",{value:e,configurable:!0}),"d$2");const To=Pt(r=>r==="running"?{color:"white",icon:"•"}:r==="pending"?{color:"gray",icon:"·"}:Ze(r),"getDisplayInfo"),Io=Pt(({autoScroll:r,focused:e,interactiveMode:t,showFullscreenHint:s,statusValue:o,supportsInteractive:n,taskId:i})=>{if(!i)return;if(t)return"Esc cancel | Enter send";const d=r?"":" PAUSED (f resume)",f=n?" i INPUT":"";return e&&o==="running"&&s?`⏎ FULLSCREEN${f} f FOLLOW${d}`:e&&o==="running"?`f FOLLOW${f}${d}`:e&&s?`<enter> full screen${d}`:e?d||void 0:"<tab> or <enter> to focus"},"deriveBottomTitle"),ur=Pt(({autoScroll:r=!0,duration:e,focused:t,interactiveMode:s,output:o,scrollRef:n,showFullscreenHint:i,status:d,supportsInteractive:f=!0,taskId:p})=>{const h=d??"pending",{icon:m}=To(h),c=t?"bold":"single",$=h==="failure"?"red":h==="success"||qe(h)?t?"green":"gray":h==="running"?t?"white":"cyan":t?"white":"gray",E=p?`${m} ${p}`:void 0,D=e===void 0?void 0:Le(e),R=Io({autoScroll:r,focused:t,interactiveMode:s??!1,showFullscreenHint:i??!1,statusValue:h,supportsInteractive:f,taskId:p});if(!p)return u(g,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",paddingX:2,paddingY:1,children:[l(a,{dimColor:!0,children:"Select a task to view output"}),l(a,{dimColor:!0,children:"Press Enter or 1/2 to pin"})]});const S=[];if(o)for(const y of o.split(`
|
|
8
|
+
`))S.push(y.endsWith("\r")?y.slice(0,-1):y);return!o&&(h==="running"||h==="pending")?l(g,{borderBottomTitle:R,borderColor:$,borderStyle:c,borderTopRightTitle:D,borderTopTitle:E,flexDirection:"column",flexGrow:1,paddingX:2,paddingY:1,children:l(g,{alignItems:"center",flexGrow:1,justifyContent:"center",children:l(a,{dimColor:!0,children:"Waiting for task output…"})})}):u(g,{borderBottomTitle:R,borderColor:s?"yellow":$,borderStyle:c,borderTopRightTitle:D,borderTopTitle:E,flexDirection:"column",flexGrow:1,children:[l(g,{flexGrow:1,flexShrink:1,paddingY:1,children:l(Fr,{flexGrow:1,followOutput:r,paddingX:2,ref:n,scrollbar:!0,scrollbarColor:"gray",scrollbarStyle:"block",children:l(a,{children:S.join(`
|
|
9
|
+
`)})})}),s&&l(g,{flexShrink:0,justifyContent:"center",paddingX:1,children:l(a,{bold:!0,color:"yellow",children:"INTERACTIVE | keystrokes forwarded to task | Esc to exit"})})]})},"OutputPanel");var Co=Object.defineProperty,ze=_((r,e)=>Co(r,"name",{value:e,configurable:!0}),"d$1");const xo={crashed:"✖",failed:"✖",pending:"·",ready:"●",starting:"•"},Nr=ze(r=>r==="ready"?"green":r==="crashed"||r==="failed"?"red":r==="starting"?"cyan":"gray","statusColor"),Mo=ze(({status:r})=>r==="starting"?l(a,{color:"cyan",children:l(Or,{type:"dots"})}):l(a,{bold:!0,color:Nr(r),children:xo[r]}),"StatusGlyph"),Eo=ze(({active:r,focused:e,state:t})=>{const s=e&&r,o=s?">":" ",n=t.status==="ready"?t.port?`running, port ${String(t.port)}`:"running":t.status==="failed"||t.status==="crashed"?t.errorMessage??"exited":t.lastLine??"booting…";return u(g,{flexDirection:"row",flexShrink:0,overflow:"hidden",children:[l(a,{children:o}),l(a,{children:" "}),l(g,{flexShrink:0,width:3,children:l(Mo,{status:t.status})}),l(g,{flexGrow:0,flexShrink:0,width:28,children:l(a,{bold:s,inverse:s,children:t.id})}),l(g,{flexGrow:1,flexShrink:1,overflow:"hidden",children:u(a,{color:Nr(t.status),dimColor:t.status!=="crashed"&&t.status!=="failed",wrap:"truncate-end",children:[" ",n]})})]})},"ServiceRow"),Ro=ze(({states:r})=>{const e=[];for(const s of r)s.status==="ready"&&e.push(s.id);const t=e.join(", ");return u(g,{paddingX:1,children:[u(a,{bold:!0,color:"green",children:["● ","Services"]}),u(a,{children:[" ",String(e.length)," / ",String(r.length)," running"]}),t.length>0&&u(a,{dimColor:!0,children:[" ",t]}),l(a,{dimColor:!0,children:" [Tab ↓]"})]})},"StatusPill"),Fo=ze(({states:r})=>{const e=r.find(t=>t.status==="crashed"||t.status==="failed");return e?u(g,{flexDirection:"column",paddingX:1,children:[u(a,{bold:!0,color:"red",children:["✖ ","Service crashed:"," ",e.id]}),e.tailLines.slice(-3).map((t,s)=>u(a,{color:"red",dimColor:!0,children:[" ",t]},`crash-${String(s)}`))]}):l(Mr,{})},"CrashHeader"),Oo=ze(({activeIndex:r,focused:e,store:t})=>{const s=ot(t.subscribe,t.getSnapshot),o=t.getIds();if(o.length===0)return l(Mr,{});const n=o.map(h=>s.get(h)).filter(h=>h!==void 0),i=t.getDockState(),d=i==="crash"?"red":i==="ready"?"gray":e?"white":"cyan";return i==="ready"&&!e?l(g,{borderColor:d,borderStyle:"single",flexDirection:"row",flexShrink:0,children:l(Ro,{states:n})}):u(g,{borderBottomTitle:e?i==="crash"?"↑↓ select Enter logs R retry Esc back":"↑↓ select Enter logs Esc back":"Tab to focus services",borderColor:d,borderStyle:e?"bold":"single",borderTopTitle:i==="crash"?"Services (crashed)":i==="ready"?"Services":"Services (starting)",flexDirection:"column",flexGrow:2,flexShrink:0,minHeight:6,paddingX:1,children:[i==="crash"&&l(Fo,{states:n}),n.map((h,m)=>l(Eo,{active:m===r,focused:e,state:h},h.id))]})},"ServiceDock");var Po=Object.defineProperty,pt=_((r,e)=>Po(r,"name",{value:e,configurable:!0}),"T$1");const Gr=6,_r=8,qr=12,jo=pt(r=>r==="running"||r==="pending"?Rr:r==="local-cache"||r==="local-cache-kept-existing"?"Local":r==="remote-cache"?"Remote":ht,"getCacheLabel"),hr=pt((r,e)=>e[0]===r?"[1]":e[1]===r?"[2]":"","getPinLabel"),fr=pt(({compact:r,focused:e,isSelected:t,pinLabel:s,row:o})=>{const{persistent:n,status:i,taskId:d}=o,f=e&&t,p=f?">":" ",h=i==="running"&&n===!0;let m;if(h)m=l(a,{bold:!0,color:"green",children:" ● "});else if(i==="running")m=u(a,{bold:!0,color:"white",children:[" ",l(Or,{type:"dots"})," "]});else if(i==="pending")m=l(a,{bold:!0,color:"gray",children:" · "});else{const{color:$,icon:E}=Ze(i);m=u(a,{bold:!0,color:$,children:[" ",E," "]})}let c=Rr;return h?c="running":i!=="running"&&i!=="pending"?c=o.duration===void 0?ht:Le(o.duration):i==="running"&&o.elapsed!==void 0&&(c=Le(o.elapsed)),u(g,{children:[l(a,{children:p}),l(g,{width:Gr,children:m}),u(g,{flexGrow:1,children:[l(a,{bold:f,inverse:f,children:d}),s?l(a,{dimColor:!0,children:` ${s}`}):null]}),!r&&l(g,{justifyContent:"flex-end",width:_r,children:l(a,{dimColor:!qe(i),children:jo(i)})}),!r&&l(g,{justifyContent:"flex-end",width:qr,children:l(a,{color:h?"green":void 0,dimColor:i==="pending"||h,children:c})})]})},"TaskListRow"),pr=pt(({compact:r,filterActive:e,filterText:t,focused:s,headerStatus:o,parallelSlots:n=3,pinnedTaskIds:i,rows:d,scrollRef:f,selectedIndex:p,title:h})=>{const m=o==="error"?"red":o==="success"?"green":s?"white":"gray",c=d[p]?.taskId,$=[];let E=0;for(const y of d)y.status==="running"?$.push(y):y.status==="pending"&&(E+=1);const D=Math.min(n,$.length+E),R=D>1,S=[];if(R)for(let y=0;y<D;y++){const F=$[y];F?S.push(l(fr,{compact:r,focused:s,isSelected:F.taskId===c,pinLabel:hr(F.taskId,i),row:F},`par-${F.taskId}`)):S.push(u(g,{children:[l(a,{children:" "}),l(g,{width:Gr,children:l(a,{bold:!0,color:"gray",children:" · "})}),l(a,{dimColor:!0,children:"Waiting for task..."})]},`par-empty-${String(y)}`))}return u(g,{borderColor:m,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[u(g,{flexShrink:0,paddingX:1,children:[l(a,{bold:!0,inverse:!0,children:" VIS "}),l(a,{children:` ${h}`}),!r&&u(g,{flexGrow:1,gap:0,justifyContent:"flex-end",children:[l(g,{justifyContent:"flex-end",width:_r,children:l(a,{dimColor:!0,children:"Cache"})}),l(g,{justifyContent:"flex-end",width:qr,children:l(a,{dimColor:!0,children:"Duration"})})]})]}),l(Fr,{flexGrow:1,flexShrink:1,paddingX:1,paddingY:1,ref:f,scrollbar:!0,scrollbarColor:"gray",scrollbarStyle:"block",children:d.map(y=>l(fr,{compact:r,focused:s,isSelected:y.taskId===c,pinLabel:hr(y.taskId,i),row:y},y.taskId))}),R&&l(g,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",borderTop:!0,flexDirection:"column",flexShrink:0,paddingX:1,paddingY:1,children:S}),e&&u(g,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",borderTop:!0,flexShrink:0,paddingX:1,children:[l(a,{bold:!0,color:"white",children:"/ "}),l(a,{children:t}),l(a,{inverse:!0,children:" "})]})]})},"TaskListPanel");var Do=Object.defineProperty,Ao=_((r,e)=>Do(r,"name",{value:e,configurable:!0}),"ne");const gr=40,mr=10,wr=100,Lo=Object.freeze([]),Bo=Ao(({autoExitSeconds:r,onRetryService:e,parallelSlots:t,projectNames:s,serviceDockStore:o,stdinRegistry:n,store:i,targets:d,tasks:f})=>{const{exit:p}=oi(),{columns:h,rows:m}=ni(),c=ot(i.subscribe,i.getSnapshot),$=st(T=>o?o.subscribe(T):()=>{},[o]);ot($,()=>o?o.getDockState():"ready");const E=o?o.getIds():Lo,D=E.length>0,[R,S]=Ye(0),[y,F]=Ye(null),X=ot($,()=>y&&o?o.getState(y):void 0),[z,v]=Ye(!1),I=Xe(null),U=Xe(null),P=Xe(null),[Y,ie]=Ye(!1),[N,A]=Ye(!0),Z=Xe({list:0,splitList:0,splitOutput:0}),oe=st(()=>{c.viewMode==="list"?Z.current.list=U.current?.getScrollOffset()??0:c.viewMode==="split"&&(Z.current.splitList=U.current?.getScrollOffset()??0,Z.current.splitOutput=P.current?.getScrollOffset()??0)},[c.viewMode]),j=st(T=>{setTimeout(()=>{if(T==="list"){const k=Z.current.list;U.current?.scrollTo(k)}else if(T==="split"){const k=Z.current.splitList;k>0?U.current?.scrollTo(k):U.current?.scrollTo(Math.max(0,i.getSnapshot().selectedIndex-2)),P.current?.scrollTo(Z.current.splitOutput)}},0)},[i]),ae=Xe(!1);wt(()=>{c.done&&!ae.current&&(ae.current=!0,r>0&&ie(!0)),!c.done&&ae.current&&(ae.current=!1,ie(!1))},[c.done,r]);const le=or(()=>{const T=E.length>0?new Set(E):null,k=c.filterText?c.filterText.toLowerCase():null,x=[];for(const ee of c.rows)T?.has(ee.taskId)||c.statusFilter==="failed"&&ee.status!=="failure"||c.statusFilter==="running"&&ee.status!=="running"&&ee.status!=="pending"||c.statusFilter==="passed"&&ee.status!=="success"&&!qe(ee.status)||k&&!ee.taskId.toLowerCase().includes(k)||x.push(ee);return x},[c.rows,c.filterText,c.statusFilter,E]),Re=or(()=>{let T=0;for(const k of c.rows)k.status==="running"&&(T+=1);return T},[c.rows]),se=(le[c.selectedIndex]??null)?.taskId??null,L=y?null:c.pinnedTaskIds[0]??se,q=L?c.rows.find(T=>T.taskId===L):null,ye=X??null,Ie=y?(ye?.tailLines??[]).join(`
|
|
10
|
+
`):L?c.outputs.get(L)??"":"",pe=y??L,ke=y?ye?.status==="crashed"||ye?.status==="failed"?"failure":"running":q?.status,Ce=Ot(s,d,f),Fe=c.done?`Completed ${Ce} (${Le((c.endTime??Date.now())-c.startTime)})`:`Running ${Ce}...`,Oe=c.done?c.failed>0?"error":"success":"running",we=st(T=>{U.current?.scrollTo(Math.max(0,T-2))},[]);if(wt(()=>{c.interactiveMode&&q?.status!=="running"&&i.setInteractiveMode(!1)},[c.interactiveMode,q?.status,i]),wt(()=>{if(!L)return;let T=h;c.viewMode==="split"&&h>=wr?T=h-Math.floor(h*.4)-2:(c.viewMode==="split"||c.viewMode==="fullscreen")&&(T=h-2);const k=Math.max(1,m-4);n.get(L)?.resize?.(T,k)},[h,m,c.viewMode,L]),ar((T,k)=>{if(k.escape){i.setInteractiveMode(!1);return}if(!L)return;const x=n.get(L);if(!x){i.setInteractiveMode(!1);return}if(k.return)x.write("\r");else if(k.upArrow)x.write("\x1B[A");else if(k.downArrow)x.write("\x1B[B");else if(k.rightArrow)x.write("\x1B[C");else if(k.leftArrow)x.write("\x1B[D");else if(k.backspace)x.write("");else if(k.delete)x.write("\x1B[3~");else if(k.tab)x.write(" ");else if(k.home)x.write("\x1B[H");else if(k.end)x.write("\x1B[F");else if(k.pageUp)x.write("\x1B[5~");else if(k.pageDown)x.write("\x1B[6~");else if(k.ctrl&&T){const ee=T.toUpperCase().codePointAt(0);ee!==void 0&&ee>=65&&ee<=90&&x.write(String.fromCodePoint(ee-64))}else T&&x.write(T)},{isActive:c.interactiveMode}),ar((T,k)=>{if(T==="c"&&k.ctrl){p();return}if(!Y){if(z){k.escape||T==="?"?v(!1):T==="q"?(v(!1),ie(!0)):k.downArrow||T==="j"?I.current?.scrollBy(1):k.upArrow||T==="k"?I.current?.scrollBy(-1):k.pageDown?I.current?.scrollBy(5):k.pageUp?I.current?.scrollBy(-5):k.home?I.current?.scrollToTop():k.end&&I.current?.scrollToBottom();return}if(T==="?"){v(!0);return}if(T==="q"){ie(!0);return}if(T==="r"&&c.done){i.requestRerun();return}if(T==="R"&&c.done){const x=le[c.selectedIndex];x?.status==="failure"&&i.requestRetry(x.taskId);return}if(T==="F"&&!c.filterActive){const x=["all","failed","running","passed"],ee=x.indexOf(c.statusFilter);i.setStatusFilter(x[(ee+1)%x.length]);return}if(c.filterActive){if(k.escape){i.setFilterActive(!1);return}if(k.return){i.setFilterActive(!1);return}if(k.backspace){i.setFilter(c.filterText.slice(0,-1));return}if(T&&!k.ctrl&&!k.meta){i.setFilter(c.filterText+T);return}return}if(T==="i"&&q?.status==="running"&&(c.viewMode==="fullscreen"||c.viewMode==="split"&&c.focusedPanel==="output")){i.setInteractiveMode(!0);return}if(c.viewMode==="fullscreen"){if(k.escape){i.setViewMode("split"),j("split");return}if(T==="f"){const x=!N;A(x),x&&P.current?.scrollToBottom();return}if(k.downArrow||T==="j"){A(!1),P.current?.scrollBy(1);return}if(k.upArrow||T==="k"){A(!1),P.current?.scrollBy(-1);return}if(k.pageDown||k.ctrl&&T==="d"){A(!1),P.current?.scrollBy(12);return}if(k.pageUp||k.ctrl&&T==="u"){A(!1),P.current?.scrollBy(-12);return}if(k.home){A(!1),P.current?.scrollToTop();return}if(k.end){A(!0),P.current?.scrollToBottom();return}return}if(c.focusedPanel==="dock"&&D&&o){if(k.tab){F(null),i.setFocusedPanel("tasks");return}if(k.escape){i.setFocusedPanel("tasks"),F(null),c.viewMode==="split"&&(i.setViewMode("list"),j("list"));return}if(k.downArrow||T==="j"){S(x=>Math.min(x+1,E.length-1));return}if(k.upArrow||T==="k"){S(x=>Math.max(x-1,0));return}if(k.return){const x=E[R];x&&(F(x),A(!0),oe(),Z.current.splitList=0,Z.current.splitOutput=0,i.setViewMode("split"),i.setFocusedPanel("output"),j("split"));return}if((T==="r"||T==="R")&&e){const x=E[R],ee=x?o.getState(x)?.status:void 0;if(x&&(ee==="crashed"||ee==="failed")){const Ne=e(x);Ne instanceof Promise&&Ne.catch(()=>{})}return}return}if(c.viewMode==="split"){if(k.tab){c.focusedPanel==="tasks"?i.setFocusedPanel("output"):D?i.setFocusedPanel("dock"):(F(null),i.setFocusedPanel("tasks"));return}if(c.focusedPanel==="output"){if(k.escape){if(y&&D){F(null),i.setViewMode("list"),i.setFocusedPanel("dock"),j("list");return}F(null),i.setFocusedPanel("tasks");return}if(k.return){oe(),i.setViewMode("fullscreen");return}if(T==="f"){const x=!N;A(x),x&&P.current?.scrollToBottom();return}if(k.downArrow||T==="j"){A(!1),P.current?.scrollBy(1);return}if(k.upArrow||T==="k"){A(!1),P.current?.scrollBy(-1);return}if(k.pageDown||k.ctrl&&T==="d"){A(!1),P.current?.scrollBy(12);return}if(k.pageUp||k.ctrl&&T==="u"){A(!1),P.current?.scrollBy(-12);return}if(k.home){A(!1),P.current?.scrollToTop();return}if(k.end){A(!0),P.current?.scrollToBottom();return}return}if(k.escape){i.setViewMode("list"),j("list");return}if(k.return){i.setFocusedPanel("output");return}}if(c.viewMode==="list"||c.viewMode==="split"&&c.focusedPanel==="tasks"){if(k.tab&&c.viewMode==="list"&&D){i.setFocusedPanel("dock");return}if(k.downArrow||T==="j"){const x=Math.min(c.selectedIndex+1,Math.max(0,le.length-1));i.setSelectedIndex(x),we(x);return}if(k.upArrow||T==="k"){const x=Math.max(c.selectedIndex-1,0);i.setSelectedIndex(x),we(x);return}if(k.return&&c.viewMode==="list"){A(!0),oe(),Z.current.splitList=0,Z.current.splitOutput=0,i.setViewMode("split"),i.setFocusedPanel("output"),j("split");return}if(T==="/"){i.setFilterActive(!0);return}if(T==="1"&&se){i.pinTask(0,se);return}if(T==="2"&&se){i.pinTask(1,se);return}if(T==="0"){i.clearPins();return}k.escape&&c.filterText&&i.setFilter("")}}},{isActive:!c.interactiveMode}),h<gr||m<mr)return l(g,{alignItems:"center",height:m,justifyContent:"center",width:h,children:u(a,{color:"yellow",children:["Terminal too small (",h,"x",m,"). Minimum:"," ",gr,"x",mr]})});const de=u(g,{gap:1,children:[c.succeeded>0&&u(a,{bold:!0,color:"green",children:["✓"," ",c.succeeded]}),c.failed>0&&u(a,{bold:!0,color:"red",children:["✗"," ",c.failed]}),Re>0&&u(a,{color:"cyan",children:["◷"," ",Re]}),u(a,{dimColor:!0,children:[c.rows.length," ","total"]}),c.statusFilter!=="all"&&u(a,{color:"yellow",children:["[",c.statusFilter,"]"]})]});let ge;if(c.viewMode==="fullscreen")ge=[u(g,{gap:1,children:[l(a,{bold:!0,color:"white",children:"Esc"}),l(a,{dimColor:!0,children:"BACK"})]},"esc"),u(g,{gap:1,children:[l(a,{bold:!0,color:"white",children:"↑↓"}),l(a,{dimColor:!0,children:"SCROLL"})]},"scroll"),u(g,{gap:1,children:[l(a,{bold:!0,color:"white",children:"^u ^d"}),l(a,{dimColor:!0,children:"PAGE"})]},"page"),...q?.status==="running"?[u(g,{gap:1,children:[l(a,{bold:!0,color:"white",children:"i"}),l(a,{dimColor:!0,children:"INPUT"})]},"i")]:[],u(g,{gap:1,children:[l(a,{bold:!0,color:"white",children:"q"}),l(a,{dimColor:!0,children:"QUIT"})]},"q")];else if(c.done){const T=le[c.selectedIndex]?.status==="failure";ge=[u(g,{gap:1,children:[l(a,{bold:!0,color:"white",children:"q"}),l(a,{dimColor:!0,children:"QUIT"})]},"q"),u(g,{gap:1,children:[l(a,{bold:!0,color:"white",children:"r"}),l(a,{dimColor:!0,children:"RERUN"})]},"r"),...T?[u(g,{gap:1,children:[l(a,{bold:!0,color:"white",children:"R"}),l(a,{dimColor:!0,children:"RETRY"})]},"R")]:[],u(g,{gap:1,children:[l(a,{bold:!0,color:"white",children:"?"}),l(a,{dimColor:!0,children:"HELP"})]},"?"),u(g,{gap:1,children:[l(a,{bold:!0,color:"white",children:"↑↓"}),l(a,{dimColor:!0,children:"NAV"})]},"nav"),u(g,{gap:1,children:[l(a,{bold:!0,color:"white",children:"F"}),l(a,{dimColor:!0,children:"FILTER"})]},"F"),u(g,{gap:1,children:[l(a,{bold:!0,color:"white",children:"⏎"}),l(a,{dimColor:!0,children:c.viewMode==="list"?"OUTPUT":"FULLSCREEN"})]},"enter")]}else c.viewMode==="split"&&c.focusedPanel==="output"?ge=[u(g,{gap:1,children:[l(a,{bold:!0,color:"white",children:"q"}),l(a,{dimColor:!0,children:"QUIT"})]},"q"),u(g,{gap:1,children:[l(a,{bold:!0,color:"white",children:"Esc"}),l(a,{dimColor:!0,children:"BACK"})]},"esc"),u(g,{gap:1,children:[l(a,{bold:!0,color:"white",children:"↑↓"}),l(a,{dimColor:!0,children:"SCROLL"})]},"scroll"),...q?.status==="running"?[u(g,{gap:1,children:[l(a,{bold:!0,color:"white",children:"i"}),l(a,{dimColor:!0,children:"INPUT"})]},"i")]:[],u(g,{gap:1,children:[l(a,{bold:!0,color:"white",children:"⏎"}),l(a,{dimColor:!0,children:"FULLSCREEN"})]},"enter"),u(g,{gap:1,children:[l(a,{bold:!0,color:"white",children:"Tab"}),l(a,{dimColor:!0,children:"PANEL"})]},"tab"),u(g,{gap:1,children:[l(a,{bold:!0,color:"white",children:"?"}),l(a,{dimColor:!0,children:"HELP"})]},"?")]:ge=[u(g,{gap:1,children:[l(a,{bold:!0,color:"white",children:"q"}),l(a,{dimColor:!0,children:"QUIT"})]},"q"),u(g,{gap:1,children:[l(a,{bold:!0,color:"white",children:"?"}),l(a,{dimColor:!0,children:"HELP"})]},"?"),u(g,{gap:1,children:[l(a,{bold:!0,color:"white",children:"↑↓"}),l(a,{dimColor:!0,children:"NAV"})]},"nav"),u(g,{gap:1,children:[l(a,{bold:!0,color:"white",children:"/"}),l(a,{dimColor:!0,children:"FILTER"})]},"/"),u(g,{gap:1,children:[l(a,{bold:!0,color:"white",children:"F"}),l(a,{dimColor:!0,children:"STATUS"})]},"F"),u(g,{gap:1,children:[l(a,{bold:!0,color:"white",children:"⏎"}),l(a,{dimColor:!0,children:c.viewMode==="list"?"OUTPUT":"FULLSCREEN"})]},"enter"),...c.viewMode==="split"?[u(g,{gap:1,children:[l(a,{bold:!0,color:"white",children:"Tab"}),l(a,{dimColor:!0,children:"PANEL"})]},"tab")]:[]];const be=u(g,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",flexShrink:0,justifyContent:"space-between",children:[l(g,{flexGrow:1,flexWrap:"wrap",gap:2,paddingX:1,children:ge}),l(g,{flexShrink:0,paddingX:1,children:de})]}),xe=u(ii,{backgroundColor:"#1e1e1e",footer:u(a,{dimColor:!0,children:[l(a,{bold:!0,color:"white",children:"↑↓"})," ","scroll"," ",l(a,{bold:!0,color:"white",children:"?"}),"/",l(a,{bold:!0,color:"white",children:"Esc"})," ","close"]}),scrollRef:I,title:"KEYBOARD SHORTCUTS",visible:z,width:52,children:[u(g,{flexDirection:"column",marginBottom:1,children:[u(g,{marginBottom:1,children:[l(a,{dimColor:!0,children:"── "}),l(a,{bold:!0,color:"white",children:"NAVIGATION"})]}),u(g,{children:[l(g,{width:24,children:u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","↑","/k"]}),l(a,{dimColor:!0,children:" Move up"})]})}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","↓","/j"]}),l(a,{dimColor:!0,children:" Move down"})]})]}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","Tab"]}),l(a,{dimColor:!0,children:" Switch panel (split)"})]}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","Esc"]}),l(a,{dimColor:!0,children:" Back / close"})]}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","Enter"]}),l(a,{dimColor:!0,children:" Show output / fullscreen"})]})]}),u(g,{flexDirection:"column",marginBottom:1,children:[u(g,{marginBottom:1,children:[l(a,{dimColor:!0,children:"── "}),l(a,{bold:!0,color:"white",children:"VIEWS"})]}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","Enter"]}),u(a,{dimColor:!0,children:[" ","List"," ","→"," ","Split"," ","→"," ","Fullscreen"]})]}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","Esc"]}),u(a,{dimColor:!0,children:[" ","Fullscreen"," ","→"," ","Split"," ","→"," ","List"]})]})]}),u(g,{flexDirection:"column",marginBottom:1,children:[u(g,{marginBottom:1,children:[l(a,{dimColor:!0,children:"── "}),l(a,{bold:!0,color:"white",children:"ACTIONS"})]}),u(g,{children:[l(g,{width:24,children:u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","/"]}),l(a,{dimColor:!0,children:" Filter by text"})]})}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","F"]}),l(a,{dimColor:!0,children:" Filter by status"})]})]}),u(g,{children:[l(g,{width:24,children:u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","1"]}),l(a,{dimColor:!0,children:"/"}),l(a,{bold:!0,color:"white",children:"2"}),l(a,{dimColor:!0,children:" Pin to output pane"})]})}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","0"]}),l(a,{dimColor:!0,children:" Clear pins"})]})]}),u(g,{children:[l(g,{width:24,children:u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","r"]}),l(a,{dimColor:!0,children:" Rerun all (done)"})]})}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","R"]}),l(a,{dimColor:!0,children:" Retry failed task"})]})]}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","i"]}),l(a,{dimColor:!0,children:" Interactive input (running task)"})]})]}),u(g,{flexDirection:"column",marginBottom:1,children:[u(g,{marginBottom:1,children:[l(a,{dimColor:!0,children:"── "}),l(a,{bold:!0,color:"white",children:"SCROLLING"}),l(a,{dimColor:!0,children:" (output panel)"})]}),u(g,{children:[l(g,{width:24,children:u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","↑","/k"]}),l(a,{dimColor:!0,children:" Scroll up"})]})}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","↓","/j"]}),l(a,{dimColor:!0,children:" Scroll down"})]})]}),u(g,{children:[l(g,{width:24,children:u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","^u"]}),l(a,{dimColor:!0,children:" Page up"})]})}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","^d"]}),l(a,{dimColor:!0,children:" Page down"})]})]}),u(g,{children:[l(g,{width:24,children:u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","Home"]}),l(a,{dimColor:!0,children:" Top"})]})}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","End"]}),l(a,{dimColor:!0,children:" Bottom (resume follow)"})]})]}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","f"]}),l(a,{dimColor:!0,children:" Toggle auto-scroll (tail mode)"})]})]}),u(g,{flexDirection:"column",children:[u(g,{marginBottom:1,children:[l(a,{dimColor:!0,children:"── "}),l(a,{bold:!0,color:"white",children:"GENERAL"})]}),u(g,{children:[l(g,{width:24,children:u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","q"]}),l(a,{dimColor:!0,children:" Quit"})]})}),u(a,{children:[u(a,{bold:!0,color:"white",children:[" ","?"]}),l(a,{dimColor:!0,children:" Toggle help"})]})]})]})]}),ue=l(ns,{autoExitSeconds:r>0?r:3,onCancel:_(()=>{ie(!1)},"onCancel"),visible:Y}),je=D&&o?l(Oo,{activeIndex:R,focused:c.focusedPanel==="dock",store:o}):null;if(c.viewMode==="fullscreen")return u(g,{flexDirection:"column",height:m,width:h,children:[l(g,{flexGrow:1,children:l(ur,{autoScroll:N,duration:q?.duration??q?.elapsed,focused:!0,interactiveMode:c.interactiveMode,output:Ie,scrollRef:P,status:ke,supportsInteractive:!y,taskId:pe})}),je,be,ue,xe]});if(c.viewMode==="split"){const T=h>=wr,k=l(pr,{compact:!0,filterActive:c.filterActive,filterText:c.filterText,focused:c.focusedPanel==="tasks",headerStatus:Oe,parallelSlots:t,pinnedTaskIds:c.pinnedTaskIds,rows:le,scrollRef:U,selectedIndex:c.selectedIndex,title:Fe}),x=l(ur,{autoScroll:N,duration:q?.duration??q?.elapsed,focused:c.focusedPanel==="output",interactiveMode:c.interactiveMode,output:Ie,scrollRef:P,showFullscreenHint:!0,status:ke,supportsInteractive:!y,taskId:pe});if(T){const Ne=Math.floor(h*.4);return u(g,{flexDirection:"column",height:m,width:h,children:[u(g,{flexDirection:"row",flexGrow:1,children:[l(g,{width:Ne,children:k}),l(g,{flexGrow:1,children:x})]}),je,be,ue,xe]})}const ee=Math.floor(m*.45);return u(g,{flexDirection:"column",height:m,width:h,children:[l(g,{height:ee,children:k}),l(g,{flexGrow:1,children:x}),je,be,ue,xe]})}return u(g,{flexDirection:"column",height:m,width:h,children:[l(g,{flexGrow:1,children:l(pr,{filterActive:c.filterActive,filterText:c.filterText,focused:c.focusedPanel!=="dock",headerStatus:Oe,parallelSlots:t,pinnedTaskIds:c.pinnedTaskIds,rows:le,scrollRef:U,selectedIndex:c.selectedIndex,title:Fe})}),je,be,ue,xe]})},"VisTaskRunnerApp");var No=Object.defineProperty,Ae=_((r,e)=>No(r,"name",{value:e,configurable:!0}),"r$1");const Go=Ae(r=>{const{args:e,autoExit:t=!1,onRetryService:s,outputStyle:o="normal",projectNames:n,serviceDockStore:i,stdinRegistry:d,tasks:f}=r,p=new dt(f),h=typeof e.parallel=="number"?e.parallel:3,m=t===!0?3:typeof t=="number"?t:0;let c,$;const E=new Promise(I=>{$=I});let D;const R=Ae(()=>{D&&(clearInterval(D),D=void 0)},"cleanup"),S=Ae(()=>{if(process.stdin.isTTY&&typeof process.stdin.setRawMode=="function")try{process.stdin.setRawMode(!1)}catch{}process.stdin.pause(),process.stdin.unref()},"releaseStdin"),y=Ae(()=>{if(d){for(const I of d.values())I.kill?.();d.clear()}},"killAllPtyProcesses"),F=Ae(()=>{R(),v(),y(),S(),process.stdout.write("\x1B[?1049l\x1B[?25h"),c?.cleanup(),process.exit(1)},"onSignal"),X=Ae(()=>{const I=p.getSnapshot(),U=Le(Date.now()-I.startTime),P=I.rows.filter(N=>N.status==="failure").map(N=>N.taskId),Y=process.stdout.columns||80;process.stdout.write(`
|
|
11
|
+
`);for(const N of I.rows){const{persistent:A,status:Z,taskId:oe}=N,j=Z==="running"||Z==="pending",ae=Ze(Z),le=j&&A?"■":ae.icon,Re=j&&A?"gray":ae.color;let se="";switch(Z){case"local-cache":case"local-cache-kept-existing":{se=" [local cache]";break}case"remote-cache":{se=" [remote cache]";break}case"skipped":{se=" [skipped]";break}default:{j&&A?se=" [stopped]":j&&(se=" [skipped]");break}}const L=N.retryAttempts&&N.retryAttempts>0?` [retried ${N.retryAttempts}x]`:"",q=fe(J.createElement(a,null," ",J.createElement(a,{color:Re},le),` vis run ${oe}`,se?J.createElement(a,{dimColor:!0},` ${se}`):null,L?J.createElement(a,{color:"yellow"},L):null),{columns:Y});process.stdout.write(`${q}
|
|
12
12
|
`)}process.stdout.write(`
|
|
13
|
-
`);const
|
|
14
|
-
`),
|
|
15
|
-
`,J.createElement(
|
|
16
|
-
|
|
17
|
-
`);const
|
|
18
|
-
`).map(
|
|
19
|
-
`);process.stdout.write(`${
|
|
20
|
-
`)}}},"printExitSummary");let
|
|
13
|
+
`);const ie=fe(J.createElement(Lr,{cached:I.cached,failed:I.failed,failedIds:P,projectNames:n,retriedIds:I.retriedIds.length>0?I.retriedIds:void 0,succeeded:I.succeeded,targets:e.targets,tasks:f,took:U}),{columns:Y});if(process.stdout.write(`${ie}
|
|
14
|
+
`),P.length>0&&o!=="quiet")for(const N of P){const A=I.outputs.get(N);if(A?.trim()){const Z=fe(J.createElement(a,null,`
|
|
15
|
+
`,J.createElement(a,{bold:!0,color:"red"},` ${xt} vis run ${N}`)),{columns:Y});process.stdout.write(`${Z}
|
|
16
|
+
|
|
17
|
+
`);const oe=A.trim().split(`
|
|
18
|
+
`).map(j=>` ${j}`).join(`
|
|
19
|
+
`);process.stdout.write(`${oe}
|
|
20
|
+
`)}}},"printExitSummary");let z;const v=Ae(()=>{z&&(clearInterval(z),z=void 0)},"clearKeepAlive");return{lifeCycle:{endCommand(){R(),p.markDone(),z||(z=setInterval(()=>{},1e3))},endTasks(I){p.endTasks(I)},printTaskTerminalOutput(I,U,P){p.getSnapshot().outputs.has(I.id)||p.addOutput(I.id,P)},startCommand(){process.on("SIGINT",F),process.on("SIGTERM",F),z||(z=setInterval(()=>{},1e3)),c=si(J.createElement(Bo,{autoExitSeconds:m,onRetryService:s,parallelSlots:h,projectNames:n,serviceDockStore:i,stdinRegistry:d??new Map,store:p,targets:e.targets,tasks:f}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}),c.waitUntilExit().then(()=>{v(),y(),S(),process.removeListener("SIGINT",F),process.removeListener("SIGTERM",F),X(),$()}).catch(()=>{v(),y(),S(),process.removeListener("SIGINT",F),process.removeListener("SIGTERM",F),$()})},startTasks(I){p.startTasks(I),D||(D=setInterval(()=>{p.tick()},100))}},renderIsDone:E,store:p}},"createDynamicOutputRenderer");var _o=Object.defineProperty,jt=_((r,e)=>_o(r,"name",{value:e,configurable:!0}),"c$2");const qo=jt(r=>r==="quiet"?"quiet":"normal","parseOutputStyle"),Ho=jt((r,e)=>{const t=r.overrides.visOptions;return t?.outputStyle==="normal"||t?.outputStyle==="quiet"?t.outputStyle:e},"resolveTaskOutputStyle");class Vo{static{_(this,"StaticOutputLifeCycle")}static{jt(this,"StaticOutputLifeCycle")}#e;#s;#r;#i=[];#t=[];#o=[];#n=new Map;#a;#c;#l;#d=0;constructor(e){this.#e=e.projectNames,this.#s=e.args.targets,this.#r=e.tasks,this.#a=e.logReporter,this.#c=e.outputStyle??"normal",this.#l=e.ciGrouping??"auto"}startCommand(){this.#d=Date.now();const e=process.stdout.columns||80,t=`Running ${Ot(this.#e,this.#s,this.#r)}`,s=fe(J.createElement(bt,{title:t,variant:"info"}),{columns:e});process.stdout.write(s);const o=this.#r[0],n=o?.overrides?Object.entries(o.overrides).filter(([i])=>i!=="command"):[];if(n.length>0){process.stdout.write(`
|
|
21
21
|
With additional flags:
|
|
22
|
-
`);for(const[i,d]of
|
|
22
|
+
`);for(const[i,d]of n)process.stdout.write(`${lo(" ",i,d)}
|
|
23
23
|
`)}process.stdout.write(`
|
|
24
|
-
`)}startTasks(e){const t=process.stdout.columns||80;for(const s of e){const o=
|
|
25
|
-
`)}}endTasks(e){const t=process.stdout.columns||80;for(const s of e){this.#
|
|
26
|
-
`)}}printTaskTerminalOutput(e,t,s){if(!(
|
|
27
|
-
`);const s=process.stdout.columns||80,o=
|
|
28
|
-
`)}}var
|
|
29
|
-
`;await
|
|
30
|
-
`)},"writeBashHistory"),
|
|
24
|
+
`)}startTasks(e){const t=process.stdout.columns||80;for(const s of e){const o=fe(J.createElement(a,null,J.createElement(a,{dimColor:!0},">"),` ${s.id}`),{columns:t});process.stdout.write(`${o}
|
|
25
|
+
`)}}endTasks(e){const t=process.stdout.columns||80;for(const s of e){this.#n.set(s.task.id,s),s.status==="failure"?this.#i.push(s):qe(s.status)&&this.#t.push(s),s.retryAttempts&&s.retryAttempts>0&&this.#o.push(s);const o=Je(s.status),n=s.startTime&&s.endTime?` (${Le(s.endTime-s.startTime)})`:"",i=qe(s.status)?" [cache]":"",d=s.retryAttempts&&s.retryAttempts>0?` [retried ${s.retryAttempts}x]`:"",f=fe(J.createElement(a,null,o,` ${s.task.id}`,i?J.createElement(a,{color:"cyan"},i):null,d?J.createElement(a,{color:"yellow"},d):null,n?J.createElement(a,{dimColor:!0},n):null),{columns:t});process.stdout.write(`${f}
|
|
26
|
+
`)}}printTaskTerminalOutput(e,t,s){if(!(Ho(e,this.#c)==="quiet"&&(t==="success"||qe(t)))){if(this.#a){this.#a.printTaskTerminalOutput(e,t,s);return}So(e.id,t,s,this.#l)}}endCommand(){const e=Le(Date.now()-this.#d),t=this.#r.filter(n=>!this.#n.has(n.id)).map(n=>n.id);process.stdout.write(`
|
|
27
|
+
`);const s=process.stdout.columns||80,o=fe(J.createElement(Lr,{cached:this.#t.length,failed:this.#i.length,failedIds:this.#i.map(n=>n.task.id),projectNames:this.#e,retriedIds:this.#o.length>0?this.#o.map(n=>n.task.id):void 0,skippedIds:t.length>0?t:void 0,succeeded:this.#n.size-this.#i.length-this.#t.length,targets:this.#s,tasks:this.#r,took:e}),{columns:s});process.stdout.write(`${o}
|
|
28
|
+
`)}}var zo=Object.defineProperty,gt=_((r,e)=>zo(r,"name",{value:e,configurable:!0}),"o$1");const Uo=gt(async r=>{if(process.env.VIS_NO_SHELL_HISTORY||ci()==="win32")return;const e=process.env.SHELL;if(!e)return;const t=rs(e);try{if(t==="zsh"){await Wo(r);return}if(t==="bash"){await Ko(r);return}t==="fish"&&await Yo(r)}catch{}},"appendToShellHistory"),Wo=gt(async r=>{const e=process.env.HISTFILE??ve(process.env.ZDOTDIR??Et(),".zsh_history"),t=`: ${Math.floor(Date.now()/1e3)}:0;${r}
|
|
29
|
+
`;await Mt(e,t)},"writeZshHistory"),Ko=gt(async r=>{const e=process.env.HISTFILE??ve(Et(),".bash_history");await Mt(e,`${r}
|
|
30
|
+
`)},"writeBashHistory"),Yo=gt(async r=>{const e=ve(Et(),".local","share","fish","fish_history"),t=`- cmd: ${r.replaceAll("\\","\\\\").replaceAll(`
|
|
31
31
|
`,String.raw`\n`)}
|
|
32
32
|
when: ${Math.floor(Date.now()/1e3)}
|
|
33
|
-
`;await
|
|
34
|
-
`),
|
|
35
|
-
`)},"writeHelp"),
|
|
36
|
-
`);if(f===-1)return;const
|
|
37
|
-
`):await e.onFilter(
|
|
38
|
-
`)})},"onKeypress"),
|
|
39
|
-
`),o=s.pop()??"";this.#t.set(e,o);for(const
|
|
40
|
-
`)}#
|
|
41
|
-
`);return}switch(s.event){case"failed":{const o=typeof s.reason=="string"?s.reason:"unknown",
|
|
42
|
-
`)}}#
|
|
43
|
-
`))d.length!==0&&this.#m(e,d);this.#r.log(e,i)}}catch{}}#m(e,t){const s=this.#o.get(e)??[];for(s.push(t);s.length>
|
|
44
|
-
`),o=s.pop()??"";this.#t.set(e,o);for(const
|
|
33
|
+
`;await Mt(e,t)},"writeFishHistory");var Xo=Object.defineProperty,kt=_((r,e)=>Xo(r,"name",{value:e,configurable:!0}),"e");const Jo=kt(r=>{const{killGracePeriodMs:e=5e3,onTimeout:t,sendSignal:s,timeoutMs:o}=r;if(o<=0)return{cancel:kt(()=>{},"cancel")};const n=Math.max(e,0);let i;const d=setTimeout(()=>{t?.(),s("SIGTERM"),n>0&&(i=setTimeout(()=>{s("SIGKILL")},n))},o);return{cancel:kt(()=>{clearTimeout(d),i&&clearTimeout(i)},"cancel")}},"scheduleTimeoutKill");var Qo=Object.defineProperty,He=_((r,e)=>Qo(r,"name",{value:e,configurable:!0}),"l$1");const Zo=[/node_modules(?:\/|$)/,/\.git(?:\/|$)/,/\.vis(?:\/|$)/],vr=He((r,e)=>{const t=new Set,s=new Set;for(const[,i]of r){const d=i.task.hashDetails?.nodes;if(d)for(const f of Object.keys(d))t.add(f),s.add(ss(Ir(e,f)))}const o=[...s].sort(),n=[];for(const i of o)n.some(d=>i===d||i.startsWith(`${d}/`))||n.push(i);return{directories:n,files:t}},"collectTrackedWatchTargets"),en=He((r,e,t)=>{const s=new Set;for(const o of r){const n=Ir(e,o);for(const i of t)if(n===i||n.startsWith(`${i}/`)){const d=is(i,n);d.length>0&&s.add(d)}}return o=>{const n=o.replaceAll("\\","/");return s.has(n)}},"createTrackedFileFilter"),tn=He(r=>{const e=r.replaceAll("\\","/");return Zo.some(t=>t.test(e))},"shouldIgnore"),yr=He(r=>{const{debounceMs:e=150,filter:t,onChange:s,paths:o}=r,n=[];let i=new Set,d;const f=He(()=>{d=void 0;const p=[...i];i=new Set,p.length!==0&&Promise.resolve(s(p)).catch(h=>{er.error("[vis watch] onChange handler failed:",h)})},"flush");for(const p of o)try{const h=Es(p,{recursive:!0},(m,c)=>{c&&(tn(c)||t&&!t(c)||(i.add(c),d&&clearTimeout(d),d=setTimeout(f,e)))});n.push(h)}catch(h){er.warn(`[vis watch] unable to watch ${p}: ${h.message}`)}return{close:He(()=>{d&&clearTimeout(d);for(const p of n)try{p.close()}catch{}},"close")}},"startWatcher");var rn=Object.defineProperty,sn=_((r,e)=>rn(r,"name",{value:e,configurable:!0}),"n");const on=sn((r,e)=>{const t=e?.trim();if(!t)return{filter:void 0,tasks:[...r]};const s=t.toLowerCase();return{filter:t,tasks:r.filter(o=>o.target.project.toLowerCase().includes(s))}},"applyProjectFilter");var nn=Object.defineProperty,Ee=_((r,e)=>nn(r,"name",{value:e,configurable:!0}),"a");const an=[""," Watch keybinds:"," r, Enter rerun"," a rerun all (clear filter)"," p filter by project name"," q, Ctrl+C quit"," h, ? show this help",""].join(`
|
|
34
|
+
`),cn=Ee(r=>{r.write(`${an}
|
|
35
|
+
`)},"writeHelp"),ln=Ee(async(r,e)=>{e.write("filter projects (empty to cancel) > ");const t=r,s=t.isRaw===!0;if(s)try{t.setRawMode?.(!1)}catch{}return await new Promise(o=>{let n="";const i=Ee(d=>{n+=typeof d=="string"?d:d.toString("utf8");const f=n.indexOf(`
|
|
36
|
+
`);if(f===-1)return;const p=n.slice(0,f).replace(/\r$/,"").trim();if(r.off("data",i),s)try{t.setRawMode?.(!0)}catch{}o(p.length>0?p:void 0)},"onData");r.on("data",i)})},"defaultPromptFilter"),dn=Ee(r=>{const{handlers:e}=r,t=r.input??process.stdin,s=r.output??process.stdout,o=r.promptFilter??ln;if(!t||t.isTTY===!1)return{close:Ee(()=>{},"close")};ri(t);const n=t.isRaw===!0;try{t.setRawMode?.(!0)}catch{return{close:Ee(()=>{},"close")}}typeof t.resume=="function"&&t.resume();let i=!1;const d=Ee(async h=>{if(h.ctrl===!0&&h.name==="c"){await e.onQuit();return}if(!i)switch(h.name){case"?":case"h":{await e.onHelp();break}case"a":{await e.onClearFilter();break}case"p":{i=!0;try{const m=await o(t,s);m===void 0?s.write(`filter cancelled.
|
|
37
|
+
`):await e.onFilter(m)}finally{i=!1}break}case"q":{await e.onQuit();break}case"r":{await e.onRerun();break}case"return":{await e.onRerun();break}}},"dispatch"),f=Ee((h,m)=>{d(m).catch(c=>{s.write(`[vis watch] keybind handler failed: ${c.message}
|
|
38
|
+
`)})},"onKeypress"),p=t;return p.on("keypress",f),{close:Ee(()=>{if(p.off("keypress",f),!n)try{t.setRawMode?.(!1)}catch{}const h=t;if(typeof h.pause=="function")try{h.pause()}catch{}},"close")}},"installKeybinds");var un=Object.defineProperty,St=_((r,e)=>un(r,"name",{value:e,configurable:!0}),"y");const hn=St(r=>{const e=r.overrides.visOptions;return e&&typeof e=="object"?e:void 0},"getVisOptions"),fn=St(async r=>{const{initialTasks:e,probe:t,registeredEntries:s,taskGraph:o,visVersion:n}=r,i=new Map,d=new Map,f=new Map;for(const v of s)if(qs(v.pid)){if(v.visVersion!==n){d.set(v.id,v);continue}i.set(v.id,v)}if(t){const v=[...i.values()],I=await Promise.all(v.map(async U=>{try{return[U.id,await t(U)]}catch{return[U.id,!1]}}));for(const[U,P]of I)if(!P){const Y=i.get(U);i.delete(U),Y&&f.set(U,Y)}}const p=new Set(e.map(v=>v.id)),h=new Set,m=[],c=[],$=new Set;for(const v of Object.values(o.dependencies))for(const I of v)$.add(I);for(const[v,I]of Object.entries(o.tasks)){if(!hn(I)?.service)continue;if(i.has(v)){h.add(v),c.push(i.get(v));continue}if(p.has(v)||!$.has(v))continue;const U=d.get(v),P=f.get(v);let Y;U?Y=`Service ${v} is registered with vis ${U.visVersion}, but this invocation is vis ${n}. Restart with \`vis service restart ${v}\` to pick up the new version.`:P?Y=`Service ${v} is registered (PID ${String(P.pid)}) but failed its readiness probe — the wrapper process is alive but the underlying server is not responding. Run \`vis service restart ${v}\` to recover.`:Y=`Target depends on the service ${v}, which is not running. Run \`vis service start ${v}\` first, or invoke \`${v}\` directly.`,m.push({message:Y,targetId:v})}if(h.size===0)return{diagnostics:m,initialTasks:e,satisfiedServices:c,serviceDependentsByServiceId:new Map,serviceEnvByTaskId:new Map,taskGraph:o};const E=new Map,D=St(v=>{const I=new Set,U=[...o.dependencies[v]??[]],P=new Set;for(;U.length>0;){const Y=U.pop();if(!P.has(Y)){P.add(Y),h.has(Y)&&I.add(Y);for(const ie of o.dependencies[Y]??[])P.has(ie)||U.push(ie)}}return[...I].sort()},"collectTransitiveServices"),R=new Map;for(const v of Object.keys(o.dependencies)){if(h.has(v))continue;const I=D(v);if(I.length===0)continue;const U={};for(const P of I){const Y=i.get(P);if(!Y)continue;Object.assign(U,Y.env);const ie=R.get(P);ie?ie.push(v):R.set(P,[v])}Object.keys(U).length>0&&E.set(v,U)}for(const v of R.values())v.sort();const S={};for(const[v,I]of Object.entries(o.tasks))h.has(v)||(S[v]=I);const y={};for(const[v,I]of Object.entries(o.dependencies))h.has(v)||(y[v]=I.filter(U=>!h.has(U)));const F=new Map;for(const v of Object.keys(S))F.set(v,0);for(const v of Object.values(y))for(const I of v)F.has(I)&&F.set(I,(F.get(I)??0)+1);const X=[];for(const v of o.roots)!h.has(v)&&S[v]&&X.push(v);for(const[v,I]of F)I===0&&!X.includes(v)&&S[v]&&X.push(v);const z=e.filter(v=>!h.has(v.id));return{diagnostics:m,initialTasks:z,satisfiedServices:c,serviceDependentsByServiceId:R,serviceEnvByTaskId:E,taskGraph:{dependencies:y,roots:X,tasks:S}}},"applyServiceRegistry");var pn=Object.defineProperty,ut=_((r,e)=>pn(r,"name",{value:e,configurable:!0}),"c");const it="[[VIS_BOOT]]",gn=250,mn=1e3,kr=3,wn=ut(r=>{try{return process.kill(r,0),!0}catch{return!1}},"isAlive"),br=ut(r=>{try{const e=Ps(r,"utf8").trim(),t=Number.parseInt(e,10);return Number.isFinite(t)&&t>0?t:null}catch{return null}},"readPidFile");class vn{static{_(this,"ServiceEventBridge")}static{ut(this,"ServiceEventBridge")}#e;#s;#r;#i;#t=new Map;#o=new Map;#n=new Map;#a=new Map;constructor(e){this.#e=e.indexToId,this.#s=new Map(e.services),this.#r=e.sink,this.#i=e.workspaceRoot}onProcessEvent=ut(e=>{if(e.kind!=="stdout"&&e.kind!=="stderr")return;const t=this.#e.get(e.index);t===void 0||e.text===void 0||this.onTaskOutput(t,e.text)},"onProcessEvent");onTaskOutput(e,t){if(!this.#s.has(e))return;const s=((this.#t.get(e)??"")+t).split(`
|
|
39
|
+
`),o=s.pop()??"";this.#t.set(e,o);for(const n of s)this.#c(e,n)}notifyRegistryStarting(e){this.#r.starting(e)}notifyRegistryStarted(e,t){this.#r.started(e,t)}onRegistryTaskStarted(e){this.#s.get(e)?.mode==="registry"&&this.notifyRegistryStarting(e)}async onRegistryTaskClosed(e,t,s){if(this.#s.get(e)?.mode!=="registry")return;if(s||t!==0){this.notifyRegistryFailed(e,"exit-code",{exitCode:t,killed:s});return}const o=await Hs(this.#i,e);if(!o){this.notifyRegistryFailed(e,"missing-registry-entry");return}const{config:n}=o,i=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:i})}notifyRegistryReady(e,t){this.#r.ready(e,{host:t.host,port:t.port}),this.#h(e,t.logFile),t.pid!==null&&this.#f(e,t.pid)}notifyRegistryFailed(e,t,s){this.#r.failed(e,t,s)}async retry(e){const t=this.#s.get(e);if(t){if(this.#u(e),this.#t.delete(e),this.#o.delete(e),this.#r.starting(e),t.mode==="registry"){await this.#v(e,t.registry);return}t.mode==="ephemeral"&&this.#w(e,t.ephemeral)}}async dispose(){for(const e of[...this.#n.keys(),...this.#a.keys()])this.#u(e);this.#t.clear(),this.#o.clear()}#c(e,t){if(t.startsWith(it)){this.#l(e,t.slice(it.length));return}const s=this.#o.get(e)??[];s.push(t),s.length>kr&&s.shift(),this.#o.set(e,s),this.#r.log(e,`${t}
|
|
40
|
+
`)}#l(e,t){let s;try{s=JSON.parse(t)}catch{this.#r.log(e,`${it+t}
|
|
41
|
+
`);return}switch(s.event){case"failed":{const o=typeof s.reason=="string"?s.reason:"unknown",n={};for(const[i,d]of Object.entries(s))i!=="event"&&i!=="id"&&i!=="reason"&&(n[i]=d);this.#r.failed(e,o,n);break}case"ready":{const o=typeof s.host=="string"?s.host:"127.0.0.1",n=typeof s.port=="number"?s.port:0;this.#r.ready(e,{host:o,port:n}),this.#d(e);break}case"started":{const o=typeof s.pid=="number"?s.pid:null;this.#r.started(e,o);break}default:this.#r.log(e,`${it+t}
|
|
42
|
+
`)}}#d(e){const t=this.#s.get(e);if(t?.ephemeral===void 0)return;this.#h(e,t.ephemeral.logFile);const s=br(t.ephemeral.pidFile);s!==null&&this.#f(e,s)}#h(e,t){if(this.#n.has(e)||!Ct(t))return;const s=Rs(t,"r"),o=(()=>{try{return lt(t).size}catch{return 0}})(),n={fd:s,logFile:t,pollTimer:setInterval(()=>{this.#g(e)},gn),position:o};this.#n.set(e,n)}#g(e){const t=this.#n.get(e);if(t)try{const s=lt(t.logFile);if(s.size<=t.position)return;const o=Buffer.alloc(s.size-t.position),n=Fs(t.fd,o,0,o.length,t.position);if(n>0){t.position+=n;const i=o.subarray(0,n).toString("utf8");for(const d of i.split(`
|
|
43
|
+
`))d.length!==0&&this.#m(e,d);this.#r.log(e,i)}}catch{}}#m(e,t){const s=this.#o.get(e)??[];for(s.push(t);s.length>kr;)s.shift();this.#o.set(e,s)}#f(e,t){if(this.#a.has(e))return;const s={pid:t,timer:setInterval(()=>{if(!wn(t)){const o=[...this.#o.get(e)??[]];this.#u(e),this.#r.crashed(e,o)}},mn)};this.#a.set(e,s)}#u(e){const t=this.#n.get(e);if(t){clearInterval(t.pollTimer);try{Os(t.fd)}catch{}this.#n.delete(e)}const s=this.#a.get(e);s&&(clearInterval(s.timer),this.#a.delete(e))}#w(e,t){if(t===void 0)return;const s=br(t.pidFile);if(s!==null)try{process.kill(-s,"SIGTERM")}catch{}const o=di("node",[t.scriptPath,t.configFile],{cwd:t.cwd,stdio:["ignore","pipe","pipe"]});o.stdout.on("data",n=>{this.#p(e,n)}),o.stderr.on("data",n=>{this.#p(e,n)}),o.on("error",n=>{this.#r.failed(e,"respawn-error",{message:n.message})})}#p(e,t){const s=((this.#t.get(e)??"")+t.toString("utf8")).split(`
|
|
44
|
+
`),o=s.pop()??"";this.#t.set(e,o);for(const n of s)this.#c(e,n)}async#v(e,t){if(t!==void 0){try{await Vs({id:e,workspaceRoot:this.#i})}catch{}try{const s=await zs({command:t.command,config:t.config,cwd:t.cwd,env:t.env,id:e,workspaceRoot:this.#i}),o=t.config.readiness?.tcp?.port??t.config.port??0,n=t.config.readiness?.tcp?.host??"127.0.0.1";this.#r.started(e,s.entry.pid),this.notifyRegistryReady(e,{host:n,logFile:s.entry.logFile,pid:s.entry.pid,port:o})}catch(s){const o=s instanceof Error?s.message:String(s);this.#r.failed(e,"retry-failed",{message:o})}}}}var yn=Object.defineProperty,me=_((r,e)=>yn(r,"name",{value:e,configurable:!0}),"p");const kn=me(r=>{const e=r.overrides.visOptions;return e&&typeof e=="object"?e:void 0},"getVisOptions"),Hr=me((r,e,t)=>{const s=[],o=[];for(const n of e){const i=t.tasks[n];if(!i){o.push({id:n,reason:"task not in graph"});continue}const d=i.overrides.command;if(!d){o.push({id:n,reason:"no command resolved"});continue}const f=kn(i);if(!f?.service){o.push({id:n,reason:"no service config"});continue}const p=Tt(r,i.projectRoot,!!f.runFromWorkspaceRoot),{envFile:h}=f,m=h===void 0||h===!1?{}:It(p,h),c=f.service.env??{};s.push({command:d,config:f.service,cwd:p,env:{...m,...c},id:n})}return{services:s,skipped:o}},"extractPreflightTasks"),bn=me((r,e)=>{const t=new Set(r),s=new Map;for(const i of r){const d=(e.dependencies[i]??[]).filter(f=>t.has(f));s.set(i,new Set(d))}const o=[],n=new Set;for(;s.size>0;){const i=[];for(const[d,f]of s){for(const p of f)n.has(p)&&f.delete(p);f.size===0&&i.push(d)}i.length===0&&i.push(...s.keys());for(const d of i)n.add(d),s.delete(d);i.sort(),o.push({ids:i})}return o},"planTopoLevels"),Sn=me((r,e)=>{const t=[];for(const s of bn(r,e))t.push(...s.ids);return t},"linearize"),$n=String.raw`import { spawn } from "node:child_process";
|
|
45
45
|
import { closeSync, openSync, readFileSync, readSync, statSync, writeFileSync } from "node:fs";
|
|
46
46
|
import { createConnection } from "node:net";
|
|
47
47
|
|
|
@@ -155,13 +155,13 @@ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
|
155
155
|
try { process.kill(-child.pid, "SIGTERM"); } catch {}
|
|
156
156
|
process.exit(1);
|
|
157
157
|
})();
|
|
158
|
-
`,
|
|
159
|
-
`)}:{},v=
|
|
160
|
-
`);break}case"started":{
|
|
161
|
-
`);break}}},"onEvent")})}finally{$&&(clearTimeout($),$=void 0),
|
|
162
|
-
${this.#s}`:this.#s}}const
|
|
163
|
-
`));const
|
|
164
|
-
`;
|
|
165
|
-
[timeout] Task "${t.id}" exceeded ${
|
|
166
|
-
`}:{code:
|
|
167
|
-
`).filter(Boolean):void 0,x=(typeof t.runnerTags=="string"?t.runnerTags:process.env.VIS_RUNNER_TAGS)??void 0,H=x?new Set(x.split(",").map(m=>m.trim()).filter(Boolean)):void 0,O=[],Y=new Map;for(const m of y){const b=w.get(m)?.[S];if(!b)continue;const M=b.options;if(!M?.internal){if(!us(M,!!Ze)){e.debug?.(`Skipping ${m}:${S} — runInCI filter`);continue}if(!fs(M,H)){e.debug?.(`Skipping ${m}:${S} — runner-tags filter`);continue}O.push(m),Y.set(m,b)}}if(O.length===0){const m=or(l),b=Object.entries(l.projects).filter(([,M])=>M.targets?.[S]!==void 0).map(([M])=>M);if(e.error(`No projects have the "${S}" target.`),b.length>0){e.info(""),e.info(`Target "${S}" exists in these projects but was filtered out:`);for(const M of b.slice(0,5))e.info(` - ${M}`);b.length>5&&e.info(` …and ${b.length-5} more`)}else{const M=Pr(S,m,3);M.length>0&&(e.info(""),e.info(M.length===1?`Did you mean "${M[0]}"?`:`Did you mean one of: ${M.map(U=>`"${U}"`).join(", ")}?`)),e.info(""),e.info("Run `vis run` without arguments to see all available targets.")}return}const re=t.pty===!0;let V=O.map(m=>{const b=l.projects[m],M=Y.get(m),U={project:m,target:S},W=`${m}:${S}`,Q=re?{...M.options,pty:M.options?.pty??!0}:M.options,N=M.command?Qt(M.command,{affectedFiles:v,projectRoot:b?.root}):M.command;return{cache:M.cache,id:W,outputs:M.outputs??[],overrides:{command:N,...F.length>0?{[Hr]:F}:{},...Q?{visOptions:Q}:{}},parallelism:M.parallelism,projectRoot:b?.root,target:U}});const A=[],Z=[];for(const m of V)qr(m)?.persistent?(m.cache=!1,A.push(m)):Z.push(m);V=Z;const se=ms(t.partition);if(se&&(V=ws.partitionTasks(V,se),e.info(`Partition ${se.index}/${se.total}: running ${V.length} task(s)`),V.length===0)){e.info("No tasks assigned to this partition.");return}let D=vs([...V,...A],{projectGraph:$,targetDefaults:h.targetDefaults,workspace:l});for(const[m,b]of Object.entries(D.tasks)){const M=b.target.project,U=b.target.target,W=w.get(M)?.[U];if(!W)continue;const Q=l.projects[M];let N=!1;const G={...b.overrides};G.visOptions===void 0&&W.options&&(G.visOptions=W.options,N=!0),G.command===void 0&&W.command&&(G.command=Qt(W.command,{affectedFiles:v,projectRoot:Q?.root}),N=!0),N&&(b.overrides=G,D.tasks[m]=b)}if(typeof t.skipCache=="string"&&t.skipCache.trim()!=="")if(t.cache){const m=Gi(t.skipCache,l,Object.keys(D.tasks));for(const b of m.skipTaskIds){const M=D.tasks[b];M!==void 0&&(M.cache=!1)}m.unmatchedPatterns.length>0&&e.warn(`--skip-cache: no tasks matched ${m.unmatchedPatterns.map(b=>`"${b}"`).join(", ")}`),m.skipTaskIds.size>0&&e.debug?.(`--skip-cache: bypassing cache for ${String(m.skipTaskIds.size)} task(s)`)}else e.debug?.("--skip-cache ignored: --no-cache already disables caching for the whole run");await As(i,h.toolchain,{error:I(m=>{e.error(m)},"error"),info:I(m=>{e.info(m)},"info"),warn:I(m=>{e.warn(m)},"warn")},!!t.skipToolchain);const ne=t.preflight!==!1&&h.preflight?.lockfile!==!1,le=Ai(i,Ze,{warn:I(m=>{e.warn(m)},"warn")},{skip:!ne});if(!le.shouldContinue)throw new Error(`${le.formattedMessage??"preflight: lockfile drift detected"} (pass --no-preflight to bypass)`);const Me=process.env.VIS_VERSION??"0.0.0",te=t.dryRun?void 0:async m=>{try{return await Ws(m.config,{timeoutMs:Cn}),!0}catch{return!1}},B=await qs(i),z=await nn({initialTasks:[...V,...A],probe:te,registeredEntries:B,taskGraph:D,visVersion:Me}),ke=[];let Ce,pe=0;const be=[],Fe=new Map;let Ie=[];const Pe=new Set;let ge=null,ae=null;if(z.diagnostics.length>0){const m=!!(process.stdout.isTTY&&process.stdin.isTTY),b=t.dryRun?"off":Tn({cli:t.services,config:h.run?.services,isCi:!!Ze,isPersistentTarget:A.length>0,isTty:m,target:S});if(b==="off"){for(const G of z.diagnostics)e.error(G.message);throw new Error(`${z.diagnostics.length} service dependency error(s) — start the missing services or invoke them directly.`)}const M=z.diagnostics.map(G=>G.targetId),U=b,W=U==="registry"?Gr(i,M,D):void 0,Q=process.argv[1]??"vis",N=bn({missingServiceIds:M,mode:U,taskGraph:D,visBin:Q,workspaceRoot:i});if(N.skipped.length>0){for(const{id:G,reason:oe}of N.skipped)e.error(`Cannot auto-start ${G}: ${oe}`);throw new Error(`${N.skipped.length} service(s) cannot be auto-started — invoke them directly or add a service config.`)}ke.push(...N.ephemeralPidFiles),Ce=N.runDir,Ie=N.chain;for(const G of N.chain)Pe.add(G);if(U==="registry"&&(pe=N.chain.length,be.push(...N.chain)),N.chain.length>0){const G=new nr(N.chain),oe=new Map;if(U==="ephemeral"&&N.runDir)for(const P of N.chain){const j=_r(N.runDir,`${N.runDir}/bootstrap.mjs`,P);oe.set(P,{ephemeral:{configFile:j.configFile,cwd:i,logFile:j.logFile,pidFile:j.pidFile,scriptPath:j.scriptPath},mode:"ephemeral"})}else if(U==="registry"&&W)for(const P of W.services)oe.set(P.id,{mode:"registry",registry:{command:P.command,config:P.config,cwd:P.cwd,env:P.env}});if(oe.size>0){const P=new un({indexToId:new Map,services:oe,sink:{crashed:I((j,K)=>{G.markCrashed(j,K)},"crashed"),failed:I((j,K,ue)=>{G.markFailed(j,K,ue)},"failed"),log:I((j,K)=>{G.appendLog(j,K)},"log"),ready:I((j,K)=>{G.markReady(j,K)},"ready"),started:I((j,K)=>{G.markStarted(j,K),U==="registry"&&K!==null&&Fe.set(j,K)},"started"),starting:I(j=>{G.markStarting(j)},"starting")},workspaceRoot:i});ge=G,ae=P}}for(const[G,oe]of N.serviceEnvByTaskId){const P=z.serviceEnvByTaskId.get(G)??{};z.serviceEnvByTaskId.set(G,{...P,...oe})}}const Re=new Set(A.map(m=>m.id));if(V=z.initialTasks.filter(m=>!Re.has(m.id)),D=z.taskGraph,Ie.length>0&&(V=[...Ie.map(m=>D.tasks[m]).filter(m=>m!==void 0),...V]),A.length>0){const m=new Set(A.map(Q=>Q.id)),b={};for(const[Q,N]of Object.entries(D.tasks))m.has(Q)||(b[Q]=N);const M={};for(const[Q,N]of Object.entries(D.dependencies))m.has(Q)||(M[Q]=N.filter(G=>!m.has(G)));const U=new Set;for(const Q of Object.values(M))for(const N of Q)U.add(N);const W=Object.keys(b).filter(Q=>!U.has(Q));D={dependencies:M,roots:W,tasks:b}}const{serviceEnvByTaskId:we}=z;if(z.satisfiedServices.length>0){const m=z.satisfiedServices.map(b=>b.id).join(", ");if(e.debug?.(`Auto-attached to running services: ${m}`),!ge)ge=new nr(z.satisfiedServices.map(b=>b.id));else for(const b of z.satisfiedServices)ge.registerService(b.id);for(const b of z.satisfiedServices){const M=b.config.readiness?.tcp?.port??b.config.port??0,U=b.config.readiness?.tcp?.host??"127.0.0.1";ge.markReady(b.id,{host:U,port:M})}}if(t.reverse&&(D=ys(D),e.debug?.(`Reversed task graph: ${String(D.roots.length)} new root(s) (originally leaves)`)),t.dryRun){const m=Object.keys(D.tasks).length,b=D.roots.length;e.info(`Execution plan (${String(m)} task(s), ${String(b)} root(s)):`),e.info("");const M=new Set,U=I((W,Q)=>{if(M.has(W))return;M.add(W);for(const oe of D.dependencies[W]??[])U(oe,Q+1);const N=D.tasks[W],G=" ".repeat(Q+1);e.info(`${G}${W}${N?.cache===!1?" (no-cache)":""}`)},"walkPlan");for(const W of D.roots)U(W,0);for(const W of Object.keys(D.tasks))U(W,0);A.length>0&&(e.info(""),e.info(` + ${String(A.length)} persistent task(s) (run after graph completes)`)),e.info("");return}const Oe=Date.now(),de=Hs(),je=I((m,b)=>{const M=b instanceof Error?b.message:String(b);e.warn(`Plugin error in ${m}: ${M}`)},"onHookError");await Vs(de,h.plugins);const T=typeof t.profile=="string"?t.profile:void 0,k=I(async m=>{if(!T)return;const b=Jt(m,D,Oe),M=T.startsWith("/")?T:`${i}/${T}`;await ks(b,M),e.info(`Profile written to ${T}`)},"maybeWriteProfile"),C=h.taskRunnerOptions??{},ee=Ts(i,t.cacheDir,C.cacheDirectory,h.sharedWorktreeCache),Ae=$s(ee,i,h.branchScopedCache),Be=jn(process.env.VIS_RUN_CONCURRENCY_LIMIT);Be&&"invalid"in Be&&e.warn(`VIS_RUN_CONCURRENCY_LIMIT=${Be.invalid} is not a positive number; falling back to default concurrency.`);const Vr=Be&&"value"in Be?Be.value:void 0,zr=t.parallel??Vr??3,jt=t.strictEnv??h.strictEnv??!1,Qe={dryRun:t.dryRun??!1,parallel:zr,skipNxCache:!t.cache,summarize:t.summarize??!1,...C,cacheDirectory:Ae,dataDirectory:C.dataDirectory??it(i),onFingerprint:I(async(m,b)=>{await de.callHook("task:fingerprint",m,b)},"onFingerprint")};if(C.remoteCache){const m=Ln(t.cacheMode),b=An(t.cacheBackend);(m||b)&&(Qe.remoteCache={...C.remoteCache,...m?{mode:m}:{},...b?{backend:b}:{}})}else(t.cacheMode||t.cacheBackend)&&e.warn("[vis run] --cache-mode and --cache-backend require a `remoteCache` block in vis.config.ts; ignoring.");const Ur=process.stdout.isTTY&&!Ze,Wr=h.tui?.autoExit??!1,Dt={args:{parallel:Qe.parallel,targets:[S]},autoExit:Wr,projectNames:O,tasks:[...V,...A]},Lt=typeof t.retryBudget=="number"?t.retryBudget:void 0,At=Lt===void 0?void 0:Pn(Lt),Bt=new zs(de,je),Nt=new Fs(i),Gt=Do(typeof t.outputStyle=="string"?t.outputStyle.toLowerCase():void 0);if(z.satisfiedServices.length>0)for(const m of z.satisfiedServices){const b=z.serviceDependentsByServiceId.get(m.id)??[];try{await de.callHook("service:attach",m,b)}catch(M){je("service:attach",M)}}await de.callHook("run:before",{tasks:V,workspaceRoot:i});const qe=t.stopServices===!0;let _t=!1;const qt=I(()=>{if(_t)return;_t=!0,ae&&ae.dispose().catch(()=>{});const m=qe?[...Fe.values()]:void 0;xn({extraPids:m,pidFiles:ke,runDir:Ce})},"runCleanupOnce"),Je=I(()=>{qt()},"onCleanupSignal"),Ht=ke.length>0||Ce!==void 0||qe&&be.length>0;Ht&&(process.on("SIGINT",Je),process.on("SIGTERM",Je));try{if(Ur){const m=new Map,b=Oo({...Dt,onRetryService:ae?P=>ae.retry(P):void 0,outputStyle:Gt,serviceDockStore:ge,stdinRegistry:m}),{lifeCycle:M,store:U}=b,W=new Zt([M,Bt,Nt]),Q=kr({affectedFiles:v,currentOs:X,hooks:de,initCwd:d,lifeCycle:W,mutexPool:new Map,onOutput:I((P,j)=>{ae&&Pe.has(P)?ae.onTaskOutput(P,j):U.addOutput(P,j)},"onOutput"),onOutputReplace:I((P,j)=>{U.setOutput(P,j)},"onOutputReplace"),retryBudget:At,serviceEnvByTaskId:we,serviceEventBridge:ae??void 0,stdinRegistry:m,strictEnv:jt,workspaceRoot:i});let N="rerun",G=null,oe=new Map;for(;N!=="quit";){if(N==="rerun"){if(oe=await er(V,Qe,{lifeCycle:W,projectGraph:$,taskExecutor:Q,taskGraph:D,workspaceRoot:i}),A.length>0&&!t.failFast){const P=new Promise(j=>{const K=U.subscribe(()=>{const ue=U.getSnapshot();(ue.rerunRequested||ue.retryTaskId)&&(K(),j())});b.renderIsDone.then(()=>{K(),j()}).catch(()=>{K(),j()})});await vr(A,i,v,d,{abortSignal:P,lifeCycle:W,store:U},we)}}else if(N==="retry"&&G){const P=V.find(K=>K.id===G),j=P?.overrides.command;if(P&&j){const K=P.projectRoot??i,ue=K.startsWith("/")?K:`${i}/${K}`;W.startTasks?.([P]);const ve=new Tr(kt),Se=(await ot([{command:j,cwd:ue,name:P.id,ptySize:{cols:process.stdout.columns??80,rows:process.stdout.rows??24},stdin:"pty"}],{onEvent:I(ie=>{ie.kind==="started"&&ie.write&&m.set(P.id,{kill:ie.kill,resize:ie.resize,write:ie.write}),(ie.kind==="stdout"||ie.kind==="stderr")&&ie.text&&(ve.write(ie.text),U.setOutput(P.id,ve.toString())),ie.kind==="close"&&m.delete(P.id)},"onEvent")})).closeEvents[0];W.endTasks?.([{code:Se?.exitCode??1,status:Se?.exitCode===0?"success":"failure",task:P,terminalOutput:U.getSnapshot().outputs.get(P.id)}])}else P&&W.endTasks?.([{code:1,status:"failure",task:P,terminalOutput:`No command configured for ${P.id}`}]);G=null,U.markDone()}N=await new Promise(P=>{const j=U.subscribe(()=>{const K=U.getSnapshot();K.rerunRequested&&(U.acknowledgeRerun(),j(),P("rerun")),K.retryTaskId&&(G=U.acknowledgeRetry(),j(),P("retry"))});b.renderIsDone.then(()=>{j(),P("quit")}).catch(()=>{j(),P("quit")})})}await b.renderIsDone,await de.callHook("run:after",oe),await k(oe),pe>0&&(e.info(""),qe?e.info(`${String(pe)} service(s) stopped (--stop-services).`):e.info(`${String(pe)} service(s) started in the background. Run \`vis service stop --all\` to clean up.`))}else{const m=new Map,b=typeof t.log=="string"?t.log.toLowerCase():"",M=b==="labeled"||b==="grouped"||b==="interleaved"?b:void 0,U=M?bs(M):void 0,W=new Zt([new Ao({...Dt,logReporter:U,outputStyle:Gt}),Bt,Nt]),Q=kr({affectedFiles:v,currentOs:X,hooks:de,initCwd:d,lifeCycle:W,mutexPool:m,retryBudget:At,serviceEnvByTaskId:we,serviceEventBridge:ae??void 0,strictEnv:jt,workspaceRoot:i}),N=I(async()=>{const P=Date.now(),j=await er(V,Qe,{lifeCycle:W,projectGraph:$,taskExecutor:Q,taskGraph:D,workspaceRoot:i}),K=Date.now()-P;if(t.summarize){const Te=Jt(j,D,Oe);await Ss(Te,i,{dataDirectory:it(i)})}let ue=!1;for(const[,Te]of j)Te.status==="failure"&&(ue=!0);const ve=Ps(j,K),Se=Os(i),ie=js(i,K,Se);return e.info(""),e.info(` ${ve}${ie?` ${ie}`:""}`),{hasFailure:ue,results:j,runHistory:Se}},"runOnce"),G=await N();await de.callHook("run:after",G.results),await k(G.results);const{hasFailure:oe}=G;if(t.watch){const P=O.map(ce=>{const fe=l.projects[ce]?.root;if(fe)return fe.startsWith("/")?fe:`${i}/${fe}`}).filter(ce=>ce!==void 0),j=V;let K;const ue=I(ce=>{const fe=Qo(j,ce);return K=fe.filter,V=fe.tasks,fe.tasks.length},"applyFilter");let ve=!1,Se=G.results;const ie=I(()=>{const ce=pr(Se,i);if(ce.directories.length>0&&ce.files.size>0){const fe=Wo(ce.files,i,ce.directories);return{handle:gr({filter:fe,onChange:Vt,paths:ce.directories}),mode:"tracked"}}return{handle:gr({onChange:Vt,paths:P}),mode:"roots"}},"buildHandle");let Te;const Vt=I(async ce=>{if(!ve){ve=!0;try{e.info(`Change detected in ${ce.length} file(s), rerunning…`),Se=(await N()).results,Te?.close(),Te=ie().handle}finally{ve=!1}}},"onChangeHandler"),zt=ie();Te=zt.handle;const Kr=zt.mode==="tracked"?`Watching ${String(pr(Se,i).files.size)} tracked file(s)`:`Watching ${String(P.length)} project root(s)`;e.info(`${Kr} — edit a file to rerun, press h for keybinds, q to quit.`);const ht=I(async()=>{if(!ve){ve=!0;try{if(V.length===0){e.info("No tasks match the active filter — press a to clear it.");return}Se=(await N()).results,Te?.close(),Te=ie().handle}finally{ve=!1}}},"triggerRerun");await new Promise(ce=>{let fe=!1,Ut;const Wt=I(()=>{Kt()},"onSigint"),Kt=I(()=>{fe||(fe=!0,Ut?.close(),process.off("SIGINT",Wt),Te?.close(),ce())},"exit");process.on("SIGINT",Wt),Ut=rn({handlers:{onClearFilter:I(async()=>{const He=ue(void 0);e.info(`Filter cleared — running ${String(He)} task(s).`),await ht()},"onClearFilter"),onFilter:I(async He=>{const Yr=K,Yt=ue(He);if(Yt===0){e.info(`Filter "${He}" matched no projects — keeping previous filter.`),ue(Yr);return}e.info(`Filter "${He}" matched ${String(Yt)} task(s).`),await ht()},"onFilter"),onHelp:I(()=>{en(process.stdout)},"onHelp"),onQuit:I(()=>{Kt()},"onQuit"),onRerun:ht}})});return}if(oe){if(t.flaky!==!1){const P=Ds(i,{minRuns:2},G.runHistory);if(P.length>0){e.info(""),e.info("Flaky tasks (based on historical runs):"),e.info("");for(const j of Ls(P))e.info(` ${j}`);e.info("")}}throw new Error("Some tasks failed.")}A.length>0&&!t.failFast&&await vr(A,i,v,d,void 0,we),pe>0&&(e.info(""),qe?e.info(`${String(pe)} service(s) stopped (--stop-services).`):e.info(`${String(pe)} service(s) started in the background. Run \`vis service stop --all\` to clean up.`))}}finally{qt(),Ht&&(process.off("SIGINT",Je),process.off("SIGTERM",Je)),qe&&be.length>0&&await Promise.all(be.map(async m=>{try{await Us(i,m)}catch{}}))}},"execute");export{Pn as createRetryBudget,ca as default};
|
|
158
|
+
`,Tn=me(()=>{const r=js(ve(li(),"vis-services-")),e=ve(r,"bootstrap.mjs");return Cr(e,$n),{runDir:r,scriptPath:e}},"prepareBootstrap"),Vr=me((r,e,t)=>{const s=t.replaceAll(/[^\w-]/g,"_");return{configFile:ve(r,`${s}.json`),logFile:ve(r,`${s}.log`),pidFile:ve(r,`${s}.pid`),scriptPath:e}},"buildBootstrapPaths"),In=me(r=>{const{paths:e,service:t}=r,s=t.config.readiness?.tcp?.port??t.config.port;if(typeof s!="number")throw new TypeError(`Service ${t.id} has no TCP readiness port — declare \`service.port\` or \`service.readiness.tcp.port\`.`);return{command:t.command,cwd:t.cwd,env:t.env,host:t.config.readiness?.tcp?.host??"127.0.0.1",id:t.id,logFile:e.logFile,pidFile:e.pidFile,port:s,timeoutMs:t.config.readiness?.tcp?.timeoutMs??3e4}},"buildEphemeralConfig"),Cn=me(r=>`node ${JSON.stringify(r.scriptPath)} ${JSON.stringify(r.configFile)}`,"buildEphemeralCommand"),xn=me(r=>{const{id:e,visBin:t,workspaceRoot:s}=r;return`node ${JSON.stringify(t)} service start ${JSON.stringify(e)} --cwd ${JSON.stringify(s)}`},"buildRegistryCommand"),Mn=me(r=>{const{missingServiceIds:e,mode:t,taskGraph:s,visBin:o,workspaceRoot:n}=r,{services:i,skipped:d}=Hr(n,e,s);if(i.length===0)return{chain:[],ephemeralPidFiles:[],runDir:void 0,serviceEnvByTaskId:new Map,skipped:d};const f=Sn(i.map(S=>S.id),s),p=new Map(i.map(S=>[S.id,S])),h=[],m=[];if(t==="ephemeral")for(const S of f){const y=p.get(S);y&&m.push({id:S,payload:In({paths:{logFile:"",pidFile:""},service:y})})}let c;t==="ephemeral"&&(c=Tn());let $;for(const S of f){const y=p.get(S),F=s.tasks[S];if(!y||!F)continue;let X;if(t==="ephemeral"){const z=Vr(c.runDir,c.scriptPath,S),v={...m.find(I=>I.id===S).payload,logFile:z.logFile,pidFile:z.pidFile};Cr(z.configFile,JSON.stringify(v)),X=Cn(z),h.push(z.pidFile)}else X=xn({id:S,visBin:o,workspaceRoot:n});if(F.overrides={...F.overrides,command:X},F.cache=!1,s.tasks[S]=F,$!==void 0){const z=s.dependencies[S]??[];z.includes($)||(s.dependencies[S]=[...z,$])}$=S}const E=new Set(f),D=new Map,R=me(S=>{const y=new Set,F=[...s.dependencies[S]??[]],X=new Set;for(;F.length>0;){const z=F.pop();if(!X.has(z)){X.add(z),E.has(z)&&y.add(z);for(const v of s.dependencies[z]??[])X.has(v)||F.push(v)}}return[...y].sort()},"collectTransitive");for(const S of Object.keys(s.dependencies)){if(E.has(S))continue;const y=R(S);if(y.length===0)continue;const F={};for(const X of y){const z=p.get(X);z?.config.env&&Object.assign(F,z.config.env)}Object.keys(F).length>0&&D.set(S,F)}return{chain:f,ephemeralPidFiles:h,runDir:c?.runDir,serviceEnvByTaskId:D,skipped:d}},"injectServiceTasks"),En=new Set(["auto","ephemeral","off","persistent"]),Rn=me(r=>{const{cli:e,config:t,isCi:s,isPersistentTarget:o,isTty:n,target:i}=r;if(e!==void 0&&!En.has(e))throw new Error(`--services: expected one of auto|ephemeral|persistent|off, got "${e}"`);const d=e??t??(n&&!s?"auto":"off");return d==="off"?"off":d==="ephemeral"?"ephemeral":d==="persistent"?"registry":o||i==="dev"?"ephemeral":"registry"},"resolveServicesPolicy");var Fn=Object.defineProperty,C=_((r,e)=>Fn(r,"name",{value:e,configurable:!0}),"o");const Dt="VIS_AFFECTED_FILES",On=2e3,Sr=C(async(r,e,t,s,o,n)=>{const i=r.map(R=>{const S=R.overrides.command;if(!S)return;const y=R.overrides.visOptions,F=Tt(e,R.projectRoot,!!y?.runFromWorkspaceRoot),X=y?.envFile?It(F,y.envFile):{},z=t&&(y?.affectedFiles==="env"||y?.affectedFiles==="both")?{[Dt]:t.join(`
|
|
159
|
+
`)}:{},v=n?.get(R.id)??{};return{command:S,cwd:F,env:{INIT_CWD:s,...X,...v,...z},name:R.id}}).filter(R=>R!==void 0);if(i.length===0)return;if(!o){await ct(i,{killOthers:["failure"],onEvent:C(()=>{},"onEvent")});return}const{abortSignal:d,lifeCycle:f,store:p}=o,h=i.map(R=>r.find(S=>S.id===R.name)).filter(Boolean);p.unmarkDone(),f.startTasks?.(h);const m=new Map,c=new Map;let $;const E=C(()=>{for(const R of c.values())try{R("SIGTERM")}catch{}$||($=setTimeout(()=>{for(const R of c.values())try{R("SIGKILL")}catch{}c.clear()},2e3),$.unref?.())},"killAll");let D;d&&(D=C(()=>{E()},"abortListener"),d.then(()=>{D?.()}).catch(()=>{D?.()}));try{await ct(i,{killOthers:["failure"],onEvent:C(R=>{const S=h[R.index];if(S)switch(R.kind){case"close":{const y=m.get(S.id)??Date.now(),F=R.killed||R.exitCode===0?"success":"failure";f.endTasks?.([{code:R.exitCode??0,endTime:Date.now(),startTime:y,status:F,task:S,terminalOutput:p.getSnapshot().outputs.get(S.id)??""}]),c.delete(R.index);break}case"error":{R.message&&p.addOutput(S.id,`${R.message}
|
|
160
|
+
`);break}case"started":{m.set(S.id,Date.now()),R.kill&&c.set(R.index,R.kill);break}case"stderr":case"stdout":{R.text&&p.addOutput(S.id,`${R.text}
|
|
161
|
+
`);break}}},"onEvent")})}finally{$&&(clearTimeout($),$=void 0),p.markDone()}},"runPersistentTasks"),$r=C(r=>{try{return process.kill(-r,0),!0}catch{try{return process.kill(r,0),!0}catch{return!1}}},"isPidAlive"),Pn=C(r=>{Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,r)},"sleepSyncMs"),jn=C(r=>{const{extraPids:e=[],pidFiles:t,runDir:s}=r,o=[],n=C(i=>{try{process.kill(-i,"SIGTERM")}catch{try{process.kill(i,"SIGTERM")}catch{}}},"sendSigterm");for(const i of t){let d;try{const f=os(i),p=Number.parseInt(f.trim(),10);d=Number.isFinite(p)&&p>0?p:void 0}catch{continue}d!==void 0&&(o.push(d),n(d))}for(const i of e)!Number.isFinite(i)||i<=0||(o.push(i),n(i));if(o.length>0){const i=Date.now()+1500;for(;Date.now()<i;){let d=!0;for(const f of o)if($r(f)){d=!1;break}if(d)break;Pn(100)}for(const d of o)if($r(d))try{process.kill(-d,"SIGKILL")}catch{try{process.kill(d,"SIGKILL")}catch{}}}s&&as(s)},"cleanupEphemeralServices"),$t=256*1024;class Dn{static{_(this,"Bn")}static{C(this,"OutputRingBuffer")}#e;#s="";#r=!1;constructor(e){this.#e=e}append(e){this.#s+=e,this.#s.length>this.#e&&(this.#s=this.#s.slice(-this.#e),this.#r=!0)}toString(){return this.#r?`[...output truncated, showing last ${Math.round(this.#e/1024)}KB...]
|
|
162
|
+
${this.#s}`:this.#s}}const zr=C(r=>{const e=r.overrides.visOptions;if(e&&typeof e=="object")return e},"getTaskOptions"),At=C(r=>`'${r.replaceAll("'",String.raw`'\''`)}'`,"singleQuoteEscape"),An=C((r,e,t)=>{if(!e||e.length===0||t===!1||t===void 0)return r;if(t==="args"||t==="both"){const s=e.map(o=>At(o)).join(" ");return`${r} ${s}`}return r},"buildAffectedFilesArgs"),Ur="visForwardedArgs",Ln=C((r,e)=>{const t=e.overrides[Ur];if(!Array.isArray(t)||t.length===0)return r;const s=t.map(o=>At(o)).join(" ");return`${r} ${s}`},"appendForwardedArgs"),Bn=C(async(r,e,t)=>{if(!e)return t();const s=r.get(e)??Promise.resolve();let o;const n=new Promise(d=>{o=d}),i=s.then(()=>n);r.set(e,i),await s;try{return await t()}finally{o(),r.get(e)===i&&r.delete(e)}},"withMutex"),Nn=C(r=>{let e=Math.max(0,Math.floor(r));return{claim(t){const s=Math.max(0,Math.min(t,e));return e-=s,s},get remaining(){return e}}},"createRetryBudget"),Gn=C((r,e,t)=>{const s=`${e}\0${typeof t=="string"?t:String(t)}`,o=r.get(s);if(o)return o;const n=It(e,t);return r.set(s,n),n},"loadEnvFileCached"),Tr=C(r=>{const e=new Map;return async(t,s)=>{const{affectedFiles:o,currentOs:n,hooks:i,initCwd:d,lifeCycle:f,mutexPool:p,onOutput:h,onOutputReplace:m,retryBudget:c,serviceEnvByTaskId:$,serviceEventBridge:E,stdinRegistry:D,strictEnv:R,workspaceRoot:S}=r,y=zr(t),F=Tt(S,s.cwd??t.projectRoot,y?.runFromWorkspaceRoot===!0),X=t.overrides.command;if(!X)return{code:0,terminalOutput:`No command configured for ${t.target.project}:${t.target.target}`};const z=Ln(X,t),v=An(z,o,y?.affectedFiles),I=cs(y,n),U=I?`${I} -c ${At(v)}`:v,P=y?.envFile?Gn(e,F,y.envFile):void 0,Y={};o&&o.length>0&&(y?.affectedFiles==="env"||y?.affectedFiles==="both")&&(Y[Dt]=o.join(`
|
|
163
|
+
`));const ie=$?.get(t.id),N={INIT_CWD:d,...P,...ie,...s.env,...Y};if(y?.strictEnv??R??!1){const L=Xi({command:v,processEnv:process.env,taskEnv:N,taskId:t.id});if(L){const q=Ji(L);return f?.onTaskStderr?.(t,q),{code:1,terminalOutput:q}}}const A=y?.pty===!0,Z=!!D,oe=Z||A;oe&&(t.cache=!1);const j=oe?void 0:new Dn($t),ae=oe?new xr($t):void 0;let le;const Re=C(L=>{if(L.kind==="started"&&(le=L.kill,L.write&&D&&D.set(t.id,{kill:L.kill,resize:L.resize,write:L.write}),E?.onRegistryTaskStarted(t.id)),(L.kind==="stdout"||L.kind==="stderr")&&L.text!==void 0)if(L.kind==="stdout"?f?.onTaskStdout?.(t,L.text):f?.onTaskStderr?.(t,L.text),ae)ae.write(L.text),Z&&m?.(t.id,ae.toString()),E&&E.onTaskOutput(t.id,L.text);else{const q=`${L.text}
|
|
164
|
+
`;j.append(q),h?.(t.id,q)}L.kind==="close"&&(D&&D.delete(t.id),E&&E.onRegistryTaskClosed(t.id,L.exitCode??0,!!L.killed).catch(()=>{}))},"onEvent"),se=C(async()=>{const L=y?.retryCount??0,q=y?.retryDelay,ye=c?c.claim(L):L,Ie=typeof y?.timeout=="number"&&y.timeout>0?y.timeout:0,pe=typeof y?.killGracePeriodMs=="number"&&y.killGracePeriodMs>=0?y.killGracePeriodMs:5e3;let ke=!1,Ce=0;const Fe=Jo({killGracePeriodMs:pe,onTimeout:C(()=>{ke=!0},"onTimeout"),sendSignal:C(ge=>{le?.(ge)},"sendSignal"),timeoutMs:Ie});let Oe;try{Oe=await ct([{command:U,cwd:F,env:N,name:t.id,...oe?{ptySize:{cols:process.stdout.columns??80,rows:process.stdout.rows??24},stdin:"pty"}:{}}],{killOthers:["failure"],onEvent:Re,...ye>0?{restart:{delay:q??"exponential",onRetry:C(async(ge,be,xe)=>{Ce=ge,i&&await i.callHook("task:retry",t,ge,xe)},"onRetry"),tries:ye}}:{}})}finally{Fe.cancel()}const we=Oe.closeEvents[0],de=ae?ae.toString():j.toString();return ke?{code:124,retryAttempts:Ce,terminalOutput:`${de}
|
|
165
|
+
[timeout] Task "${t.id}" exceeded ${Ie}ms budget.
|
|
166
|
+
`}:{code:we?.exitCode??1,retryAttempts:Ce,terminalOutput:de}},"runOnce");return p?Bn(p,y?.mutex,se):se()}},"createConcurrentExecutor"),_n=C(r=>{if(!r||r.trim().length===0)return;const e=Number.parseFloat(r);return!Number.isFinite(e)||e<=0?{invalid:r}:{value:Math.floor(e)}},"parseEnvConcurrency"),qn=C(async(r,e)=>{const t=await ms(r,{dataDirectory:at(r)});if(!t){e.warn(`No previous run recorded yet. Run a task at least once to populate ${ws(r,{dataDirectory:at(r)})}.`);return}const s=(t.duration/1e3).toFixed(2);if(e.info(""),e.info(`Last run — ${t.startTime} (${s}s)`),e.info(""),e.info(` Total: ${String(t.stats.total)}`),e.info(` Succeeded: ${String(t.stats.succeeded)}`),e.info(` Cached: ${String(t.stats.cached)}`),e.info(` Failed: ${String(t.stats.failed)}`),e.info(` Skipped: ${String(t.stats.skipped)}`),e.info(""),t.stats.failed>0){const n=t.tasks.filter(i=>i.exitCode!==void 0&&i.exitCode!==0);e.info("Failed tasks:");for(const i of n){const d=i.duration??0;e.info(` × ${i.taskId} (exit ${String(i.exitCode??-1)}, ${d}ms)`)}e.info("")}const o=[...t.tasks].filter(n=>typeof n.duration=="number").sort((n,i)=>(i.duration??0)-(n.duration??0)).slice(0,5);if(o.length>0){e.info("Slowest tasks:");for(const n of o)e.info(` ${n.taskId.padEnd(40)} ${String(n.duration??0).padStart(6)}ms [${n.cacheStatus}]`);e.info("")}},"renderLastRunSummary"),Hn=C(r=>{if(!(r===void 0||r==="")){if(r!=="read"&&r!=="write"&&r!=="readwrite")throw new Error(`--cache-mode must be one of: read, write, readwrite (received "${r}")`);return r}},"parseCacheMode"),Vn=C(r=>{if(!(r===void 0||r==="")){if(r!=="http"&&r!=="reapi")throw new Error(`--cache-backend must be one of: http, reapi (received "${r}")`);return r}},"parseCacheBackend"),ga=C(async({argument:r,logger:e,options:t,runtime:s,visConfig:o,workspaceRoot:n})=>{if(!n)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const i=n;if(ls(i),t.lastDetails===!0){await qn(i,e);return}const d=process.cwd(),f=await ds(i),{config:p,packageJsons:h,projectOptions:m,workspace:c}=us(i,o,f),$=hs(i,c,h);let E=r[0];if(!E){const w=lr(c);if(process.stdout.isTTY&&process.stdin.isTTY){const b=await io(w);if(!b){e.info("No target selected.");return}E=b,await Uo(`vis run ${b}`)}else{e.info("Available targets:"),e.info(""),e.info(so(w)),e.info(""),e.info("Usage: vis run <target>");return}}if(p.constraints&&!t.skipConstraints){const w=vs($,p.constraints);if(w.length>0){for(const b of w)e.error(`[${b.rule}] ${b.message}`);throw new Error(`${w.length} project constraint violation(s) found. Use --skip-constraints to bypass.`)}}if(t.affected){const w=[E];t.parallel!==void 0&&w.push(`--parallel=${String(t.parallel)}`),t.cache||w.push("--no-cache"),t.query&&w.push(`--query=${String(t.query)}`),t.reverse&&w.push("--reverse"),typeof t.runnerTags=="string"&&t.runnerTags!==""&&w.push(`--runner-tags=${t.runnerTags}`),await s.runCommand("affected",{argv:w});return}const D=await Zs(E,c,process.cwd(),i),R=Zi(m),S=eo(D.target,R);S!==D.target&&e.debug?.(`Resolved alias "${D.target}" → "${S}"`);let y=D.projects;const F=r.slice(1).map(String);if(t.projects){const w=new Set(t.projects.split(",").map(b=>b.trim()));if(y=y.filter(b=>w.has(b)),y.length===0)throw new Error(`No matching projects found for: ${String(t.projects)}`)}if(t.query&&(y=ei(y,c,t.query),y.length===0)){e.info(`Query "${String(t.query)}" matched no projects.`);return}const X=fs(),z=process.env[Dt],v=z?z.split(`
|
|
167
|
+
`).filter(Boolean):void 0,I=(typeof t.runnerTags=="string"?t.runnerTags:process.env.VIS_RUNNER_TAGS)??void 0,U=I?new Set(I.split(",").map(w=>w.trim()).filter(Boolean)):void 0,P=[],Y=new Map;for(const w of y){const b=m.get(w)?.[S];if(!b)continue;const M=b.options;if(!M?.internal){if(!ps(M,!!rt)){e.debug?.(`Skipping ${w}:${S} — runInCI filter`);continue}if(!gs(M,U)){e.debug?.(`Skipping ${w}:${S} — runner-tags filter`);continue}P.push(w),Y.set(w,b)}}if(P.length===0){const w=lr(c),b=Object.entries(c.projects).filter(([,M])=>M.targets?.[S]!==void 0).map(([M])=>M);if(e.error(`No projects have the "${S}" target.`),b.length>0){e.info(""),e.info(`Target "${S}" exists in these projects but was filtered out:`);for(const M of b.slice(0,5))e.info(` - ${M}`);b.length>5&&e.info(` …and ${b.length-5} more`)}else{const M=Ar(S,w,3);M.length>0&&(e.info(""),e.info(M.length===1?`Did you mean "${M[0]}"?`:`Did you mean one of: ${M.map(W=>`"${W}"`).join(", ")}?`)),e.info(""),e.info("Run `vis run` without arguments to see all available targets.")}return}const ie=t.pty===!0;let N=P.map(w=>{const b=c.projects[w],M=Y.get(w),W={project:w,target:S},K=`${w}:${S}`,Q=ie?{...M.options,pty:M.options?.pty??!0}:M.options,G=M.command?tr(M.command,{affectedFiles:v,projectRoot:b?.root}):M.command;return{cache:M.cache,id:K,outputs:M.outputs??[],overrides:{command:G,...F.length>0?{[Ur]:F}:{},...Q?{visOptions:Q}:{}},parallelism:M.parallelism,projectRoot:b?.root,target:W}});const A=[],Z=[];for(const w of N)zr(w)?.persistent?(w.cache=!1,A.push(w)):Z.push(w);N=Z;const oe=ys(t.partition);if(oe&&(N=ks.partitionTasks(N,oe),e.info(`Partition ${oe.index}/${oe.total}: running ${N.length} task(s)`),N.length===0)){e.info("No tasks assigned to this partition.");return}let j=bs([...N,...A],{projectGraph:$,targetDefaults:p.targetDefaults,workspace:c});for(const[w,b]of Object.entries(j.tasks)){const M=b.target.project,W=b.target.target,K=m.get(M)?.[W];if(!K)continue;const Q=c.projects[M];let G=!1;const B={...b.overrides};B.visOptions===void 0&&K.options&&(B.visOptions=K.options,G=!0),B.command===void 0&&K.command&&(B.command=tr(K.command,{affectedFiles:v,projectRoot:Q?.root}),G=!0),G&&(b.overrides=B,j.tasks[w]=b)}if(typeof t.skipCache=="string"&&t.skipCache.trim()!=="")if(t.cache){const w=zi(t.skipCache,c,Object.keys(j.tasks));for(const b of w.skipTaskIds){const M=j.tasks[b];M!==void 0&&(M.cache=!1)}w.unmatchedPatterns.length>0&&e.warn(`--skip-cache: no tasks matched ${w.unmatchedPatterns.map(b=>`"${b}"`).join(", ")}`),w.skipTaskIds.size>0&&e.debug?.(`--skip-cache: bypassing cache for ${String(w.skipTaskIds.size)} task(s)`)}else e.debug?.("--skip-cache ignored: --no-cache already disables caching for the whole run");await _s(i,p.toolchain,{error:C(w=>{e.error(w)},"error"),info:C(w=>{e.info(w)},"info"),warn:C(w=>{e.warn(w)},"warn")},!!t.skipToolchain);const ae=t.preflight!==!1&&p.preflight?.lockfile!==!1,le=qi(i,rt,{warn:C(w=>{e.warn(w)},"warn")},{skip:!ae});if(!le.shouldContinue)throw new Error(`${le.formattedMessage??"preflight: lockfile drift detected"} (pass --no-preflight to bypass)`);const Re=process.env.VIS_VERSION??"0.0.0",se=t.dryRun?void 0:async w=>{try{return await Js(w.config,{timeoutMs:On}),!0}catch{return!1}},L=await Us(i),q=await fn({initialTasks:[...N,...A],probe:se,registeredEntries:L,taskGraph:j,visVersion:Re}),ye=[];let Ie,pe=0;const ke=[],Ce=new Map;let Fe=[];const Oe=new Set;let we=null,de=null;if(q.diagnostics.length>0){const w=!!(process.stdout.isTTY&&process.stdin.isTTY),b=t.dryRun?"off":Rn({cli:t.services,config:p.run?.services,isCi:!!rt,isPersistentTarget:A.length>0,isTty:w,target:S});if(b==="off"){for(const B of q.diagnostics)e.error(B.message);throw new Error(`${q.diagnostics.length} service dependency error(s) — start the missing services or invoke them directly.`)}const M=q.diagnostics.map(B=>B.targetId),W=b,K=W==="registry"?Hr(i,M,j):void 0,Q=process.argv[1]??"vis",G=Mn({missingServiceIds:M,mode:W,taskGraph:j,visBin:Q,workspaceRoot:i});if(G.skipped.length>0){for(const{id:B,reason:ne}of G.skipped)e.error(`Cannot auto-start ${B}: ${ne}`);throw new Error(`${G.skipped.length} service(s) cannot be auto-started — invoke them directly or add a service config.`)}ye.push(...G.ephemeralPidFiles),Ie=G.runDir,Fe=G.chain;for(const B of G.chain)Oe.add(B);if(W==="registry"&&(pe=G.chain.length,ke.push(...G.chain)),G.chain.length>0){const B=new dr(G.chain),ne=new Map;if(W==="ephemeral"&&G.runDir)for(const O of G.chain){const H=Vr(G.runDir,`${G.runDir}/bootstrap.mjs`,O);ne.set(O,{ephemeral:{configFile:H.configFile,cwd:i,logFile:H.logFile,pidFile:H.pidFile,scriptPath:H.scriptPath},mode:"ephemeral"})}else if(W==="registry"&&K)for(const O of K.services)ne.set(O.id,{mode:"registry",registry:{command:O.command,config:O.config,cwd:O.cwd,env:O.env}});if(ne.size>0){const O=new vn({indexToId:new Map,services:ne,sink:{crashed:C((H,V)=>{B.markCrashed(H,V)},"crashed"),failed:C((H,V,te)=>{B.markFailed(H,V,te)},"failed"),log:C((H,V)=>{B.appendLog(H,V)},"log"),ready:C((H,V)=>{B.markReady(H,V)},"ready"),started:C((H,V)=>{B.markStarted(H,V),W==="registry"&&V!==null&&Ce.set(H,V)},"started"),starting:C(H=>{B.markStarting(H)},"starting")},workspaceRoot:i});we=B,de=O}}for(const[B,ne]of G.serviceEnvByTaskId){const O=q.serviceEnvByTaskId.get(B)??{};q.serviceEnvByTaskId.set(B,{...O,...ne})}}const ge=new Set(A.map(w=>w.id));if(N=q.initialTasks.filter(w=>!ge.has(w.id)),j=q.taskGraph,Fe.length>0&&(N=[...Fe.map(w=>j.tasks[w]).filter(w=>w!==void 0),...N]),A.length>0){const w=new Set(A.map(Q=>Q.id)),b={};for(const[Q,G]of Object.entries(j.tasks))w.has(Q)||(b[Q]=G);const M={};for(const[Q,G]of Object.entries(j.dependencies))w.has(Q)||(M[Q]=G.filter(B=>!w.has(B)));const W=new Set;for(const Q of Object.values(M))for(const G of Q)W.add(G);const K=Object.keys(b).filter(Q=>!W.has(Q));j={dependencies:M,roots:K,tasks:b}}const{serviceEnvByTaskId:be}=q;if(q.satisfiedServices.length>0){const w=q.satisfiedServices.map(b=>b.id).join(", ");if(e.debug?.(`Auto-attached to running services: ${w}`),we)for(const b of q.satisfiedServices)we.registerService(b.id);else we=new dr(q.satisfiedServices.map(b=>b.id));for(const b of q.satisfiedServices){const M=b.config.readiness?.tcp?.port??b.config.port??0,W=b.config.readiness?.tcp?.host??"127.0.0.1";we.markReady(b.id,{host:W,port:M})}}if(t.reverse&&(j=Ss(j),e.debug?.(`Reversed task graph: ${String(j.roots.length)} new root(s) (originally leaves)`)),t.dryRun){const w=Object.keys(j.tasks).length,b=j.roots.length;e.info(`Execution plan (${String(w)} task(s), ${String(b)} root(s)):`),e.info("");const M=new Set,W=C((K,Q)=>{if(M.has(K))return;M.add(K);for(const ne of j.dependencies[K]??[])W(ne,Q+1);const G=j.tasks[K],B=" ".repeat(Q+1);e.info(`${B}${K}${G?.cache===!1?" (no-cache)":""}`)},"walkPlan");for(const K of j.roots)W(K,0);for(const K of Object.keys(j.tasks))W(K,0);A.length>0&&(e.info(""),e.info(` + ${String(A.length)} persistent task(s) (run after graph completes)`)),e.info("");return}const xe=Date.now(),ue=Ws(),je=C((w,b)=>{const M=b instanceof Error?b.message:String(b);e.warn(`Plugin error in ${w}: ${M}`)},"onHookError");await Ks(ue,p.plugins);const T=typeof t.profile=="string"?t.profile:void 0,k=C(async w=>{if(!T)return;const b=rr(w,j,xe),M=T.startsWith("/")?T:`${i}/${T}`;await $s(b,M),e.info(`Profile written to ${T}`)},"maybeWriteProfile"),x=p.taskRunnerOptions??{},ee=xs(i,t.cacheDir,x.cacheDirectory,p.sharedWorktreeCache),Ne=Ms(ee,i,p.branchScopedCache),Ge=_n(process.env.VIS_RUN_CONCURRENCY_LIMIT);Ge&&"invalid"in Ge&&e.warn(`VIS_RUN_CONCURRENCY_LIMIT=${Ge.invalid} is not a positive number; falling back to default concurrency.`);const Wr=Ge&&"value"in Ge?Ge.value:void 0,Kr=t.parallel??Wr??3,Lt=t.strictEnv??p.strictEnv??!1,et={dryRun:t.dryRun??!1,parallel:Kr,skipNxCache:!t.cache,summarize:t.summarize??!1,...x,cacheDirectory:Ne,dataDirectory:x.dataDirectory??at(i),onFingerprint:C(async(w,b)=>{await ue.callHook("task:fingerprint",w,b)},"onFingerprint")},Bt=Ts(x.remoteCache);if(Bt){const w=Hn(t.cacheMode),b=Vn(t.cacheBackend);et.remoteCache={...Bt,...w?{mode:w}:{},...b?{backend:b}:{}}}else(t.cacheMode||t.cacheBackend)&&e.warn("[vis run] --cache-mode and --cache-backend require a `remoteCache` block in vis.config.ts (or TURBO_API env); ignoring.");const Yr=process.stdout.isTTY&&!rt,Xr=p.tui?.autoExit??!1,Nt={args:{parallel:et.parallel,targets:[S]},autoExit:Xr,projectNames:P,tasks:[...N,...A]},Gt=typeof t.retryBudget=="number"?t.retryBudget:void 0,_t=Gt===void 0?void 0:Nn(Gt),qt=new Ys(ue,je),Ht=new Ds(i),Vt=qo(typeof t.outputStyle=="string"?t.outputStyle.toLowerCase():void 0);if(q.satisfiedServices.length>0)for(const w of q.satisfiedServices){const b=q.serviceDependentsByServiceId.get(w.id)??[];try{await ue.callHook("service:attach",w,b)}catch(M){je("service:attach",M)}}await ue.callHook("run:before",{tasks:N,workspaceRoot:i});const Ue=t.stopServices===!0;let zt=!1;const Ut=C(()=>{if(zt)return;zt=!0,de&&de.dispose().catch(()=>{});const w=Ue?[...Ce.values()]:void 0;jn({extraPids:w,pidFiles:ye,runDir:Ie})},"runCleanupOnce"),tt=C(()=>{Ut()},"onCleanupSignal"),Wt=ye.length>0||Ie!==void 0||Ue&&ke.length>0;Wt&&(process.on("SIGINT",tt),process.on("SIGTERM",tt));try{if(Yr){const w=new Map,b=Go({...Nt,onRetryService:de?O=>de.retry(O):void 0,outputStyle:Vt,serviceDockStore:we,stdinRegistry:w}),{lifeCycle:M,store:W}=b,K=new sr([M,qt,Ht]),Q=Tr({affectedFiles:v,currentOs:X,hooks:ue,initCwd:d,lifeCycle:K,mutexPool:new Map,onOutput:C((O,H)=>{de&&Oe.has(O)?de.onTaskOutput(O,H):W.addOutput(O,H)},"onOutput"),onOutputReplace:C((O,H)=>{W.setOutput(O,H)},"onOutputReplace"),retryBudget:_t,serviceEnvByTaskId:be,serviceEventBridge:de??void 0,stdinRegistry:w,strictEnv:Lt,workspaceRoot:i});let G="rerun",B=null,ne=new Map;for(;G!=="quit";){if(G==="rerun"){if(ne=await ir(N,et,{lifeCycle:K,projectGraph:$,taskExecutor:Q,taskGraph:j,workspaceRoot:i}),A.length>0&&!t.failFast){const O=new Promise(H=>{const V=W.subscribe(()=>{const te=W.getSnapshot();(te.rerunRequested||te.retryTaskId)&&(V(),H())});b.renderIsDone.then(()=>{V(),H()}).catch(()=>{V(),H()})});await Sr(A,i,v,d,{abortSignal:O,lifeCycle:K,store:W},be)}}else if(G==="retry"&&B){const O=N.find(V=>V.id===B),H=O?.overrides.command;if(O&&H){const V=O.projectRoot??i,te=V.startsWith("/")?V:`${i}/${V}`;K.startTasks?.([O]);const Se=new xr($t),Me=(await ct([{command:H,cwd:te,name:O.id,ptySize:{cols:process.stdout.columns??80,rows:process.stdout.rows??24},stdin:"pty"}],{onEvent:C(re=>{re.kind==="started"&&re.write&&w.set(O.id,{kill:re.kill,resize:re.resize,write:re.write}),(re.kind==="stdout"||re.kind==="stderr")&&re.text&&(Se.write(re.text),W.setOutput(O.id,Se.toString())),re.kind==="close"&&w.delete(O.id)},"onEvent")})).closeEvents[0];K.endTasks?.([{code:Me?.exitCode??1,status:Me?.exitCode===0?"success":"failure",task:O,terminalOutput:W.getSnapshot().outputs.get(O.id)}])}else O&&K.endTasks?.([{code:1,status:"failure",task:O,terminalOutput:`No command configured for ${O.id}`}]);B=null,W.markDone()}G=await new Promise(O=>{const H=W.subscribe(()=>{const V=W.getSnapshot();V.rerunRequested&&(W.acknowledgeRerun(),H(),O("rerun")),V.retryTaskId&&(B=W.acknowledgeRetry(),H(),O("retry"))});b.renderIsDone.then(()=>{H(),O("quit")}).catch(()=>{H(),O("quit")})})}await b.renderIsDone,await ue.callHook("run:after",ne),await k(ne),pe>0&&(e.info(""),Ue?e.info(`${String(pe)} service(s) stopped (--stop-services).`):e.info(`${String(pe)} service(s) started in the background. Run \`vis service stop --all\` to clean up.`))}else{const w=new Map,b=typeof t.log=="string"?t.log.toLowerCase():"",M=b==="labeled"||b==="grouped"||b==="interleaved"?b:void 0,W=M?Is(M):void 0,K=new sr([new Vo({...Nt,ciGrouping:o?.run?.ciGrouping??"auto",logReporter:W,outputStyle:Vt}),qt,Ht]),Q=Tr({affectedFiles:v,currentOs:X,hooks:ue,initCwd:d,lifeCycle:K,mutexPool:w,retryBudget:_t,serviceEnvByTaskId:be,serviceEventBridge:de??void 0,strictEnv:Lt,workspaceRoot:i}),G=C(async()=>{const V=Date.now(),te=await ir(N,et,{lifeCycle:K,projectGraph:$,taskExecutor:Q,taskGraph:j,workspaceRoot:i}),Se=Date.now()-V;if(t.summarize){const $e=rr(te,j,xe);await Cs($e,i,{dataDirectory:at(i)})}let Me=!1;for(const[,$e]of te)$e.status==="failure"&&(Me=!0);const re=As(te,Se),De=Ls(i),_e=Bs(i,Se,De);return e.info(""),e.info(` ${re}${_e?` ${_e}`:""}`),{hasFailure:Me,results:te,runHistory:De}},"runOnce"),B=await G();await ue.callHook("run:after",B.results),await k(B.results);const{hasFailure:ne}=B;if(t.watch){const V=P.map(ce=>{const he=c.projects[ce]?.root;if(he)return he.startsWith("/")?he:`${i}/${he}`}).filter(ce=>ce!==void 0),te=N;let Se;const Me=C(ce=>{const he=on(te,ce);return Se=he.filter,N=he.tasks,he.tasks.length},"applyFilter");let re=!1,De=B.results;const _e=C(()=>{const ce=vr(De,i);if(ce.directories.length>0&&ce.files.size>0){const he=en(ce.files,i,ce.directories);return{handle:yr({filter:he,onChange:Kt,paths:ce.directories}),mode:"tracked"}}return{handle:yr({onChange:Kt,paths:V}),mode:"roots"}},"buildHandle");let $e;const Kt=C(async ce=>{if(!re){re=!0;try{e.info(`Change detected in ${ce.length} file(s), rerunning…`),De=(await G()).results,$e?.close(),$e=_e().handle}finally{re=!1}}},"onChangeHandler"),Yt=_e();$e=Yt.handle;const Jr=Yt.mode==="tracked"?`Watching ${String(vr(De,i).files.size)} tracked file(s)`:`Watching ${String(V.length)} project root(s)`;e.info(`${Jr} — edit a file to rerun, press h for keybinds, q to quit.`);const mt=C(async()=>{if(!re){re=!0;try{if(N.length===0){e.info("No tasks match the active filter — press a to clear it.");return}De=(await G()).results,$e?.close(),$e=_e().handle}finally{re=!1}}},"triggerRerun");await new Promise(ce=>{let he=!1,Xt;const Jt=C(()=>{Qt()},"onSigint"),Qt=C(()=>{he||(he=!0,Xt?.close(),process.off("SIGINT",Jt),$e?.close(),ce())},"exit");process.on("SIGINT",Jt),Xt=dn({handlers:{onClearFilter:C(async()=>{const We=Me(void 0);e.info(`Filter cleared — running ${String(We)} task(s).`),await mt()},"onClearFilter"),onFilter:C(async We=>{const Qr=Se,Zt=Me(We);if(Zt===0){e.info(`Filter "${We}" matched no projects — keeping previous filter.`),Me(Qr);return}e.info(`Filter "${We}" matched ${String(Zt)} task(s).`),await mt()},"onFilter"),onHelp:C(()=>{cn(process.stdout)},"onHelp"),onQuit:C(()=>{Qt()},"onQuit"),onRerun:mt}})});return}if(t.flaky!==!1){const V=Ns(i,{minRuns:2},B.runHistory);if(V.length>0){e.info(""),e.info("Flaky tasks (based on historical runs):"),e.info("");for(const te of Gs(V))e.info(` ${te}`);e.info("")}}const O=[];for(const[V,te]of B.results)te.retryAttempts&&te.retryAttempts>0&&O.push(V);const H=t.failOnRetry===!0&&O.length>0;if(H){const V=O.slice(0,5),te=O.length-V.length,Se=te>0?`${V.join(", ")}, and ${String(te)} more`:V.join(", ");e.warn(""),e.warn(`--fail-on-retry: ${String(O.length)} task(s) succeeded only after retry: ${Se}`)}if(ne||H)throw new Error(H&&!ne?"Some tasks succeeded only after retry (--fail-on-retry).":"Some tasks failed.");A.length>0&&!t.failFast&&await Sr(A,i,v,d,void 0,be),pe>0&&(e.info(""),Ue?e.info(`${String(pe)} service(s) stopped (--stop-services).`):e.info(`${String(pe)} service(s) started in the background. Run \`vis service stop --all\` to clean up.`))}}finally{Ut(),Wt&&(process.off("SIGINT",tt),process.off("SIGTERM",tt)),Ue&&ke.length>0&&await Promise.all(ke.map(async w=>{try{await Xs(i,w)}catch{}}))}},"execute");export{Nn as createRetryBudget,ga as default};
|