@visulima/vis 1.0.0-alpha.16 → 1.0.0-alpha.17

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