@visulima/vis 1.0.0-alpha.15 → 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.
- package/CHANGELOG.md +64 -0
- package/LICENSE.md +44 -233
- package/dist/bin.js +1 -1
- package/dist/config/index.d.ts +200 -94
- package/dist/config/index.js +1 -1
- package/dist/packem_chunks/bin.js +271 -271
- package/dist/packem_chunks/config.js +18 -0
- package/dist/packem_chunks/fix.js +1 -1
- package/dist/packem_chunks/handler.js +1 -1
- package/dist/packem_chunks/handler10.js +1 -1
- package/dist/packem_chunks/handler11.js +1 -1
- package/dist/packem_chunks/handler12.js +1 -1
- package/dist/packem_chunks/handler13.js +1 -1
- package/dist/packem_chunks/handler14.js +4 -4
- package/dist/packem_chunks/handler15.js +1 -1
- package/dist/packem_chunks/handler16.js +1 -1
- package/dist/packem_chunks/handler17.js +1 -1
- package/dist/packem_chunks/handler18.js +1 -1
- package/dist/packem_chunks/handler19.js +5 -5
- package/dist/packem_chunks/handler2.js +1 -1
- package/dist/packem_chunks/handler20.js +2 -1
- package/dist/packem_chunks/handler21.js +18 -1
- package/dist/packem_chunks/handler22.js +1 -5
- package/dist/packem_chunks/handler23.js +1 -1
- package/dist/packem_chunks/handler24.js +5 -3
- package/dist/packem_chunks/handler25.js +1 -1
- package/dist/packem_chunks/handler26.js +3 -1
- package/dist/packem_chunks/handler27.js +1 -7
- package/dist/packem_chunks/handler28.js +1 -23
- package/dist/packem_chunks/handler29.js +7 -3
- package/dist/packem_chunks/handler3.js +1 -1
- package/dist/packem_chunks/handler30.js +23 -18
- package/dist/packem_chunks/handler31.js +3 -1
- package/dist/packem_chunks/handler32.js +1 -2
- package/dist/packem_chunks/handler33.js +2 -25
- package/dist/packem_chunks/handler34.js +25 -2
- package/dist/packem_chunks/handler35.js +2 -2
- package/dist/packem_chunks/handler36.js +8 -8
- package/dist/packem_chunks/handler37.js +3 -3
- package/dist/packem_chunks/handler38.js +3 -3
- package/dist/packem_chunks/handler39.js +1 -1
- package/dist/packem_chunks/handler40.js +5 -5
- package/dist/packem_chunks/handler41.js +9 -9
- package/dist/packem_chunks/handler42.js +9 -9
- package/dist/packem_chunks/handler43.js +1 -1
- package/dist/packem_chunks/handler44.js +5 -5
- package/dist/packem_chunks/handler45.js +3 -3
- package/dist/packem_chunks/handler46.js +9 -9
- package/dist/packem_chunks/handler47.js +161 -36
- package/dist/packem_chunks/handler48.js +1 -1
- package/dist/packem_chunks/handler5.js +5 -5
- package/dist/packem_chunks/handler6.js +1 -1
- package/dist/packem_chunks/handler7.js +1 -1
- package/dist/packem_chunks/handler8.js +1 -1
- package/dist/packem_chunks/handler9.js +1 -1
- package/dist/packem_chunks/heal-accept.js +2 -2
- package/dist/packem_chunks/heal.js +1 -1
- package/dist/packem_chunks/help-command.js +16 -16
- package/dist/packem_chunks/index.js +1 -1
- package/dist/packem_chunks/loader.js +1 -1
- package/dist/packem_shared/{ai-analysis-CGVjqwdc.js → ai-analysis-C_GpXikx.js} +3 -3
- package/dist/packem_shared/ai-cache-DrCLD4gc.js +1 -0
- package/dist/packem_shared/ai-fix-CWOz12Om.js +43 -0
- package/dist/packem_shared/applyDefaults-DLY94gWA.js +1 -0
- package/dist/packem_shared/cache-directory-C_U1qsIw.js +1 -0
- package/dist/packem_shared/definePlugin-CWm4Dv_t.js +1 -0
- package/dist/packem_shared/dependency-scan-YdgNVvoz.js +2 -0
- package/dist/packem_shared/docker-B4i5yxtP.js +60 -0
- package/dist/packem_shared/failure-log-CSC6KfcO.js +2 -0
- package/dist/packem_shared/flakiness-Dzz-I3dB.js +1 -0
- package/dist/packem_shared/lifecycle-C7vfQmA3.js +2 -0
- package/dist/packem_shared/{lockfile-B7JJzxnL.js → lockfile-i-qvq_k8.js} +1 -1
- package/dist/packem_shared/otelPlugin-CJR2T_lk.js +1 -0
- package/dist/packem_shared/{readTomlSync-1fKo0R52-DAKNI1Me.js → readTomlSync-1fKo0R52-DtxWULlF.js} +1 -1
- package/dist/packem_shared/run-summary-utils-CJv75pla.js +1 -0
- package/dist/packem_shared/runtime-check-CBU6W8qG.js +1 -0
- package/dist/packem_shared/{selectors-Sem2CTYA.js → selectors-B2ISH581.js} +1 -1
- package/dist/packem_shared/toolchain-B7dckBQ1.js +5 -0
- package/dist/packem_shared/typosquats-B3A38-qx.js +1 -0
- package/dist/packem_shared/verify-WDStBFvK.js +1 -0
- package/dist/packem_shared/vis-update-app-D0uL3eO5.js +1 -0
- package/package.json +13 -13
- package/schemas/project.schema.json +12 -2
- package/schemas/vis-config.schema.json +248 -3
- package/dist/packem_chunks/applyDefaults.js +0 -2
- package/dist/packem_shared/ai-cache-BdPgSfg2.js +0 -1
- package/dist/packem_shared/ai-fix-iHtGLkJS.js +0 -43
- package/dist/packem_shared/cache-directory-DTfMSzT9.js +0 -1
- package/dist/packem_shared/dependency-scan-SQeRzrpJ.js +0 -2
- package/dist/packem_shared/docker-D5p9mRPU.js +0 -2
- package/dist/packem_shared/failure-log-CElcbnb9.js +0 -2
- package/dist/packem_shared/flakiness-C4t4_NoA.js +0 -1
- package/dist/packem_shared/otel-CO8UEfTa.js +0 -17
- package/dist/packem_shared/otelPlugin-DTynZDWh.js +0 -1
- package/dist/packem_shared/registry-D04iOQ5H.js +0 -2
- package/dist/packem_shared/run-summary-utils-BPraMTcm.js +0 -1
- package/dist/packem_shared/runtime-check-l4qFpo08.js +0 -1
- package/dist/packem_shared/toolchain-BhZNts--.js +0 -5
- package/dist/packem_shared/typosquats-Dr7VIL2B.js +0 -1
- package/dist/packem_shared/verify-C6NNOhTA.js +0 -1
- package/dist/packem_shared/vis-update-app-DGiMc5kb.js +0 -1
|
@@ -1,42 +1,167 @@
|
|
|
1
|
-
var Cr=Object.defineProperty;var S=(r,e)=>Cr(r,"name",{value:e,configurable:!0});import{createRequire as xr}from"node:module";import{runConcurrently as tt,TerminalBuffer as Vt,readLastRunSummary as Mr,enforceProjectConstraints as Er,expandTokensInString as jr,parsePartition as Rr,TaskScheduler as Or,createTaskGraph as Pr,reverseTaskGraph as _r,generateRunSummary as St,writeChromeTrace as Fr,CompositeLifeCycle as Ct,defaultTaskRunner as xt,createLogReporter as Ar,writeRunSummary as Lr}from"@visulima/task-runner";import{aG as Dr,p as It,aB as zt,b6 as Br,aA as Hr,y as Nr,m as Gr,b7 as qr,b8 as Wr,s as ze,b9 as Ur}from"./bin.js";import{E as Vr,a as zr}from"../packem_shared/cache-directory-DTfMSzT9.js";import{M as Ce,Q as Kr,a as Qr,C as Qt,z as Xr}from"../packem_shared/otel-CO8UEfTa.js";import{F as Zr}from"../packem_shared/failure-log-CElcbnb9.js";import{f as Jr,l as eo,c as to,a as ro,b as oo}from"../packem_shared/flakiness-C4t4_NoA.js";import{r as so}from"../packem_shared/toolchain-BhZNts--.js";import{i as no,c as io,b as ao}from"../packem_shared/registry-D04iOQ5H.js";import{p as co,r as lo,f as uo}from"../packem_shared/selectors-Sem2CTYA.js";import{Box as p,Text as n,StaticRender as Mt,renderToString as re,ScrollView as Xt,Spinner as po,useApp as mo,useWindowSize as go,useInput as Et,Dialog as wo,render as ko}from"@visulima/tui";import N,{useSyncExternalStore as vo,useState as jt,useRef as Ee,useCallback as Ye,useEffect as Ke,useMemo as Rt}from"react";import{jsxs as u,jsx as l}from"react/jsx-runtime";import{T as Zt,C as rt,D as Be,E as Jt}from"../packem_shared/symbols-CQmER5MT.js";const Ir=xr(import.meta.url),Me=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,De=S(r=>{if(typeof Me<"u"&&Me.versions&&Me.versions.node){const[e,t]=Me.versions.node.split(".").map(Number);if(e>22||e===22&&t>=3||e===20&&t>=16)return Me.getBuiltinModule(r)}return Ir(r)},"__cjs_getBuiltinModule"),{existsSync:Yt,statSync:Kt,watch:Yr}=De("node:fs"),{createInterface:ho,emitKeypressEvents:fo}=De("node:readline"),{appendFile:ot}=De("node:fs/promises"),{platform:yo,homedir:st}=De("node:os");var bo=Object.defineProperty,$o=S((r,e)=>bo(r,"name",{value:e,configurable:!0}),"u$3"),To=Object.defineProperty,So=$o((r,e)=>To(r,"name",{value:e,configurable:!0}),"v"),Co=Object.defineProperty,xo=So((r,e)=>Co(r,"name",{value:e,configurable:!0}),"D");const Io=xo((r,e,t,o,s,a,c,d,h,f,i,k,v,$)=>{const M={d:o,h:s,m:a,mo:e,ms:d,s:c,w:t,y:r};return h!==void 0&&(M.future=h),f!==void 0&&(M.past=f),i!==void 0&&(M.decimal=i),k!==void 0&&(M.unitMap=k),v!==void 0&&(M.groupSeparator=v),$!==void 0&&(M.placeholderSeparator=$),M},"createDurationLanguage"),Mo={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"},Eo=Io(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",".",Mo,",","_");var jo=Object.defineProperty,Ro=S((r,e)=>jo(r,"name",{value:e,configurable:!0}),"o$3"),Oo=Object.defineProperty,Po=Ro((r,e)=>Oo(r,"name",{value:e,configurable:!0}),"o"),_o=Object.defineProperty,Fo=Po((r,e)=>_o(r,"name",{value:e,configurable:!0}),"o");const Ao=Fo(r=>{const e=["y","mo","w","d","h","m","s","ms","future","past"];for(const o of e)if(!Object.hasOwn(r,o))throw new TypeError(`Missing required property: ${o}`);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 o of t)if(typeof r[o]!="string"&&typeof r[o]!="function")throw new TypeError(`Property ${o} 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(o=>typeof o!="string"))throw new TypeError("All values in unitMap must be of type string")},"validateDurationLanguage");var Lo=Object.defineProperty,Do=S((r,e)=>Lo(r,"name",{value:e,configurable:!0}),"b$3"),Bo=Object.defineProperty,Ho=Do((r,e)=>Bo(r,"name",{value:e,configurable:!0}),"b"),No=Object.defineProperty,Re=Ho((r,e)=>No(r,"name",{value:e,configurable:!0}),"g");const er=Re((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"),Ot=Re(({unitCount:r,unitName:e},t,o)=>{let{spacer:s}=o;const{maxDecimalPoints:a}=o;let c=".";o.decimal!==void 0?c=o.decimal:t.decimal!==void 0&&(c=t.decimal);let d;"digitReplacements"in o?d=o.digitReplacements:"_digitReplacements"in t&&(d=t._digitReplacements);let h,f=r;a!==void 0&&(f=er(r,a));const i=f.toString();if(!t._hideCountIf2||r!==2)if(d){h="";for(const $ of i)h+=$==="."?c:d[$]}else h=i.replace(".",c);else h="";const k=t[e];let v=k;return typeof k=="function"&&(v=k(r)),t._hideCountIf2&&r===2&&(s=""),t._numberFirst?v+s+h:h+s+v},"renderPiece"),Go=Re((r,e)=>{const{units:t}=e;if(t.length===0)return[];const{unitMeasures:o}=e,s=e.largest??Number.POSITIVE_INFINITY,a={};let c,d,h,f=r;for(d=0;d<t.length;d++){c=t[d];const k=o[c];h=d===t.length-1?f/k:Math.floor(f/k),a[c]=h,f-=h*k}if(e.round){let k=s;for(d=0;d<t.length;d++)if(c=t[d],h=a[c],h!==0&&(k--,k===0)){for(let v=d+1;v<t.length;v++){const $=t[v],M=a[$];a[c]=(a[c]??0)+M*o[$]/o[c],a[$]=0}break}for(d=t.length-1;d>=0;d--){if(c=t[d],h=a[c],h===0)continue;const v=Math.round(h);if(a[c]=v,d===0)break;const $=t[d-1],M=o[$],R=Math.floor(v*o[c]/M);if(R)a[$]=(a[$]??0)+R,a[c]=0;else break}}const i=[];for(d=0;d<t.length&&i.length<s;d++){if(c=t[d],h=a[c],h&&!e.round&&i.length===s-1){let k,v=0;for(k=d+1,t.length;k<t.length;k++){const $=t[k];v+=a[$]*(e.unitMeasures[$]/e.unitMeasures[c])}h+=v,e.maxDecimalPoints!==void 0&&(h=er(h,e.maxDecimalPoints))}h&&i.push({unitCount:h,unitName:c})}return i},"getPieces"),qo=Re((r,e,t)=>{const{language:o,units:s}=e;if(r.length===0){const k=s.at(-1);return Ot({unitCount:0,unitName:k},o,e)}const{conjunction:a,serialComma:c}=e;let d=", ";e.delimiter!==void 0?d=e.delimiter:o.delimiter!==void 0&&(d=o.delimiter);let h="";e.timeAdverb&&t!==0&&(h=o.future??"",t<0&&(h=o.past??""));const f=r.map(k=>Ot(k,o,e));let i;return!a||r.length===1?i=f.join(d):r.length===2?i=f.join(a):i=f.slice(0,-1).join(d)+(c?",":"")+a+(f.at(-1)??""),h&&(i=h.replace("%s",i)),i},"formatPieces"),tr=Re((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:Eo,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};Ao(t.language);const o=Math.abs(r),s=Go(o,t);return qo(s,t,r)},"duration");var Wo=Object.defineProperty,He=S((r,e)=>Wo(r,"name",{value:e,configurable:!0}),"s$2");const Uo={bun:["bun.lock","bun.lockb"],npm:["package-lock.json"],pnpm:["pnpm-lock.yaml"],yarn:["yarn.lock"]},Vo={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"]},zo={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"}},Yo=1e3,Ko=He(r=>{for(const[e,t]of Object.entries(Uo))for(const o of t)if(Yt(Ce(r,o)))return{lockfileFile:o,manager:e}},"detectPackageManager"),Qo=He((r,e)=>{let t;for(const o of Vo[e]){const s=Ce(r,o);if(!Yt(s))continue;const{mtimeMs:a}=Kt(s);(!t||a>t.mtimeMs)&&(t={mtimeMs:a,path:o})}return t},"findFreshestMarker"),Xo=He((r,e={})=>{const t=Ko(r);if(!t)return{checked:!1};const{lockfileFile:o,manager:s}=t,a=Kt(Ce(r,o)).mtimeMs,c=Qo(r,s),d=zo[e.inCi?"ci":"tty"][s],h={installMarkerMtimeMs:c?.mtimeMs,lockfileMtimeMs:a,lockfilePath:o,marker:c?.path,packageManager:s};return c?a>c.mtimeMs+Yo?{checked:!0,detail:h,failure:"stale-install",message:`${o} is newer than node_modules (${c.path}) — run \`${d}\` to sync.`}:{checked:!0,detail:h}:{checked:!0,detail:h,failure:"missing-install",message:`lockfile detected but node_modules looks uninitialised — run \`${d}\` before \`vis run\`.`}},"checkLockfileFreshness"),Zo=He((r,e,t,o={})=>{if(o.skip)return{checked:!1,shouldContinue:!0};const s=Xo(r,{inCi:e});if(!s.failure)return{...s,shouldContinue:!0};const a=`preflight: ${s.message??"lockfile drift detected"}`;return e&&!o.ciAsWarning?{...s,formattedMessage:a,shouldContinue:!1}:(t.warn(a),{...s,formattedMessage:a,shouldContinue:!0})},"runLockfilePreflight");var Jo=Object.defineProperty,rr=S((r,e)=>Jo(r,"name",{value:e,configurable:!0}),"p$5");const es=rr(r=>r.split(",").map(e=>e.trim()).filter(e=>e!==""),"splitPatterns"),ts=rr((r,e,t)=>{const o=new Set,s=[];if(r===void 0||r.trim()==="")return{skipTaskIds:o,unmatchedPatterns:s};const a=[...t],c=new Set(a),d=new Map;for(const h of a){const f=h.lastIndexOf(":");if(f===-1)continue;const i=h.slice(f+1),k=d.get(i);k===void 0?d.set(i,[h]):k.push(h)}for(const h of es(r)){if(h.startsWith("~:"))throw new Error(`--skip-cache does not support the closest-project selector "~:" (received "${h}"). Use \`pkg:target\`, \`:target\`, or \`#tag:target\`.`);if(c.has(h)){o.add(h);continue}const f=co(h);if(!f){s.push(h);continue}let i=!1;if(f.kind==="all"){const k=d.get(f.target)??[];for(const v of k)o.add(v),i=!0}else if(f.kind==="project"){const k=f.projects?.[0];if(k!==void 0){const v=`${k}:${f.target}`;c.has(v)&&(o.add(v),i=!0)}}else if(f.kind==="tag"){const k=f.tag;if(k!==void 0){const v=d.get(f.target)??[];for(const $ of v){const M=$.slice(0,$.lastIndexOf(":"));e.projects[M]?.tags?.includes(k)===!0&&(o.add($),i=!0)}}}i||s.push(h)}return{skipTaskIds:o,unmatchedPatterns:s}},"resolveSkipCachePatterns");var rs=Object.defineProperty,nt=S((r,e)=>rs(r,"name",{value:e,configurable:!0}),"a$2");const os=/\$(?:\{([A-Z_]\w*)(:-[^}]*)?\}|([A-Z_]\w*))/gi,ss=new Set(["0","!","#","$","*","-","?","@","_"]),ns=nt(r=>{const e=new Map;for(const t of r.matchAll(os)){const o=t[1],s=t[3],a=t[2],c=o??s;if(c===void 0||ss.has(c))continue;const d=a!==void 0,h=e.get(c);h===void 0?e.set(c,d):h&&!d&&e.set(c,!1)}return[...e.entries()].map(([t,o])=>({hasDefault:o,name:t}))},"extractEnvReferences"),is=nt(r=>{const{command:e,processEnv:t,taskEnv:o,taskId:s}=r,a=ns(e);if(a.length===0)return;const c=[];for(const{hasDefault:d,name:h}of a){if(d)continue;const f=o[h],i=t[h];f===void 0&&i===void 0&&c.push(h)}if(c.length!==0)return{missing:c.toSorted(),taskId:s}},"checkStrictEnv"),as=nt(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 cs=Object.defineProperty,we=S((r,e)=>cs(r,"name",{value:e,configurable:!0}),"i$2");const Pt=we(r=>{const e=new Set;for(const t of Object.values(r.projects))for(const o of Object.keys(t.targets??{}))e.add(o);return[...e].sort()},"collectAvailableTargets"),ls=we(r=>{const e=new Map;for(const t of r.values())for(const[o,s]of Object.entries(t))for(const a of s.aliases??[])e.has(a)||e.set(a,o);return e},"buildAliasMap"),ds=we((r,e)=>e.get(r)??r,"resolveTargetAlias"),us=we((r,e)=>{if(r.length===0)return e.length;if(e.length===0)return r.length;const t=[];for(let o=0;o<=e.length;o++)t[o]=[o];for(let o=0;o<=r.length;o++)t[0][o]=o;for(let o=1;o<=e.length;o++)for(let s=1;s<=r.length;s++){const a=e[o-1]===r[s-1]?0:1;t[o][s]=Math.min(t[o-1][s]+1,t[o][s-1]+1,t[o-1][s-1]+a)}return t[e.length][r.length]},"levenshtein"),hs=we((r,e,t=3)=>or(r,e,1,t)[0],"suggestTarget"),or=we((r,e,t=3,o=3)=>{const s=[];for(const a of e){const c=us(r.toLowerCase(),a.toLowerCase());c<=o&&s.push({distance:c,name:a})}return s.sort((a,c)=>a.distance-c.distance||a.name.localeCompare(c.name)),s.slice(0,t).map(a=>a.name)},"suggestTargets"),fs=we(r=>r.length===0?" (no targets found)":r.map(e=>` - ${e}`).join(`
|
|
2
|
-
`),"formatTargetList"),
|
|
3
|
-
`);for(const[
|
|
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(
|
|
6
|
-
|
|
7
|
-
`).map(T=>T.replace(/\r$/,"")):[];return!o&&(h==="running"||h==="pending")?l(p,{borderBottomTitle:M,borderColor:k,borderStyle:i,borderTopRightTitle:$,borderTopTitle:v,flexDirection:"column",flexGrow:1,paddingX:2,paddingY:1,children:l(p,{alignItems:"center",flexGrow:1,justifyContent:"center",children:l(n,{dimColor:!0,children:"Waiting for task output..."})})}):u(p,{borderBottomTitle:M,borderColor:t?"yellow":k,borderStyle:i,borderTopRightTitle:$,borderTopTitle:v,flexDirection:"column",flexGrow:1,children:[l(p,{flexGrow:1,flexShrink:1,paddingY:1,children:l(Xt,{flexGrow:1,followOutput:!0,paddingX:2,ref:s,scrollbar:!0,scrollbarColor:"gray",scrollbarStyle:"block",children:R.map((T,O)=>l(n,{children:T},String(O)))})}),t&&l(p,{flexShrink:0,justifyContent:"center",paddingX:1,children:l(n,{bold:!0,color:"yellow",children:"INTERACTIVE — keystrokes forwarded to task — Esc to exit"})})]})},"OutputPanel");var js=Object.defineProperty,Ne=S((r,e)=>js(r,"name",{value:e,configurable:!0}),"x$1");const cr=6,lr=8,dr=10,Rs=Ne(r=>r==="running"||r==="pending"?Jt:r==="local-cache"||r==="local-cache-kept-existing"?"Local":r==="remote-cache"?"Remote":Be,"getCacheLabel"),Ft=Ne((r,e)=>e[0]===r?"[1]":e[1]===r?"[2]":"","getPinLabel"),At=Ne(({compact:r,isSelected:e,pinLabel:t,row:o})=>{const{status:s,taskId:a}=o,c=e?">":" ";let d;if(s==="running")d=u(n,{bold:!0,color:"white",children:[" ",l(po,{type:"dots"})," "]});else if(s==="pending")d=l(n,{bold:!0,color:"gray",children:" · "});else{const{color:f,icon:i}=Pe(s);d=u(n,{bold:!0,color:f,children:[" ",i," "]})}let h=Jt;return s!=="running"&&s!=="pending"?h=o.duration===void 0?Be:ve(o.duration):s==="running"&&o.elapsed!==void 0&&(h=ve(o.elapsed)),u(p,{children:[l(n,{children:c}),l(p,{width:cr,children:d}),u(p,{flexGrow:1,children:[l(n,{bold:e,inverse:e,children:a}),t?l(n,{dimColor:!0,children:` ${t}`}):null]}),!r&&l(p,{justifyContent:"flex-end",width:lr,children:l(n,{dimColor:!Te(s),children:Rs(s)})}),!r&&l(p,{justifyContent:"flex-end",width:dr,children:l(n,{dimColor:s==="pending",children:h})})]})},"TaskListRow"),Lt=Ne(({compact:r,filterActive:e,filterText:t,focused:o,headerStatus:s,parallelSlots:a=3,pinnedTaskIds:c,rows:d,scrollRef:h,selectedIndex:f,title:i})=>{const k=s==="error"?"red":s==="success"?"green":o?"white":"gray",v=d[f]?.taskId,$=d.filter(T=>T.status==="running"),M=$.length>0||d.some(T=>T.status==="pending"),R=[];if(M)for(let T=0;T<a;T++){const O=$[T];O?R.push(l(At,{compact:r,isSelected:O.taskId===v,pinLabel:Ft(O.taskId,c),row:O},`par-${O.taskId}`)):R.push(u(p,{children:[l(n,{children:" "}),l(p,{width:cr,children:l(n,{bold:!0,color:"gray",children:" · "})}),l(n,{dimColor:!0,children:"Waiting for task..."})]},`par-empty-${String(T)}`))}return u(p,{borderColor:k,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[u(p,{flexShrink:0,gap:1,paddingX:1,children:[l(n,{bold:!0,inverse:!0,children:" VIS "}),l(n,{children:i}),!r&&u(p,{flexGrow:1,gap:0,justifyContent:"flex-end",children:[l(p,{justifyContent:"flex-end",width:lr,children:l(n,{dimColor:!0,children:"Cache"})}),l(p,{justifyContent:"flex-end",width:dr,children:l(n,{dimColor:!0,children:"Duration"})})]})]}),l(Xt,{flexGrow:1,flexShrink:1,paddingLeft:1,paddingY:1,ref:h,scrollbar:!0,scrollbarColor:"gray",scrollbarStyle:"block",children:d.map(T=>l(At,{compact:r,isSelected:T.taskId===v,pinLabel:Ft(T.taskId,c),row:T},T.taskId))}),M&&l(p,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",borderTop:!0,flexDirection:"column",flexShrink:0,paddingLeft:1,paddingY:1,children:R}),e&&u(p,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",borderTop:!0,flexShrink:0,paddingX:1,children:[l(n,{bold:!0,color:"white",children:"/ "}),l(n,{children:t}),l(n,{inverse:!0,children:" "})]})]})},"TaskListPanel");var Os=Object.defineProperty,Ps=S((r,e)=>Os(r,"name",{value:e,configurable:!0}),"y$2");const Dt=40,Bt=10,Ht=100,_s=Ps(({autoExitSeconds:r,parallelSlots:e,projectNames:t,stdinRegistry:o,store:s,targets:a,tasks:c})=>{const{exit:d}=mo(),{columns:h,rows:f}=go(),i=vo(s.subscribe,s.getSnapshot),[k,v]=jt(!1),$=Ee(null),M=Ee(null),R=Ee(null),[T,O]=jt(!1),P=Ee({list:0,splitList:0,splitOutput:0}),Q=Ye(()=>{i.viewMode==="list"?P.current.list=M.current?.getScrollOffset()??0:i.viewMode==="split"&&(P.current.splitList=M.current?.getScrollOffset()??0,P.current.splitOutput=R.current?.getScrollOffset()??0)},[i.viewMode]),F=Ye(y=>{setTimeout(()=>{if(y==="list"){const m=P.current.list;M.current?.scrollTo(m)}else if(y==="split"){const m=P.current.splitList;m>0?M.current?.scrollTo(m):M.current?.scrollTo(Math.max(0,s.getSnapshot().selectedIndex-2)),R.current?.scrollTo(P.current.splitOutput)}},0)},[s]),w=Ee(!1);Ke(()=>{i.done&&!w.current&&(w.current=!0,r>0&&O(!0)),!i.done&&w.current&&(w.current=!1,O(!1))},[i.done,r]);const I=Rt(()=>{let y=i.rows;if(i.statusFilter!=="all"&&(y=y.filter(m=>i.statusFilter==="failed"?m.status==="failure":i.statusFilter==="running"?m.status==="running"||m.status==="pending":i.statusFilter==="passed"?m.status==="success"||Te(m.status):!0)),i.filterText){const m=i.filterText.toLowerCase();y=y.filter(x=>x.taskId.toLowerCase().includes(m))}return y},[i.rows,i.filterText,i.statusFilter]),_=Rt(()=>i.rows.filter(y=>y.status==="running").length,[i.rows]),G=(I[i.selectedIndex]??null)?.taskId??null,C=i.pinnedTaskIds[0]??G,B=C?i.rows.find(y=>y.taskId===C):null,ie=C?i.outputs.get(C)??"":"",L=at(t,a,c),q=i.done?`Completed ${L} (${ve((i.endTime??Date.now())-i.startTime)})`:`Running ${L}...`,ae=i.done?i.failed>0?"error":"success":"running",J=Ye(y=>{M.current?.scrollTo(Math.max(0,y-2))},[]);if(Ke(()=>{i.interactiveMode&&B?.status!=="running"&&s.setInteractiveMode(!1)},[i.interactiveMode,B?.status,s]),Ke(()=>{if(!C)return;let y=h;i.viewMode==="split"&&h>=Ht?y=h-Math.floor(h*.4)-2:(i.viewMode==="split"||i.viewMode==="fullscreen")&&(y=h-2);const m=Math.max(1,f-4);o.get(C)?.resize?.(y,m)},[h,f,i.viewMode,C]),Et((y,m)=>{if(m.escape){s.setInteractiveMode(!1);return}if(!C)return;const x=o.get(C);if(!x){s.setInteractiveMode(!1);return}if(m.return)x.write("\r");else if(m.upArrow)x.write("\x1B[A");else if(m.downArrow)x.write("\x1B[B");else if(m.rightArrow)x.write("\x1B[C");else if(m.leftArrow)x.write("\x1B[D");else if(m.backspace)x.write("");else if(m.delete)x.write("\x1B[3~");else if(m.tab)x.write(" ");else if(m.home)x.write("\x1B[H");else if(m.end)x.write("\x1B[F");else if(m.pageUp)x.write("\x1B[5~");else if(m.pageDown)x.write("\x1B[6~");else if(m.ctrl&&y){const ee=y.toUpperCase().codePointAt(0);ee!==void 0&&ee>=65&&ee<=90&&x.write(String.fromCodePoint(ee-64))}else y&&x.write(y)},{isActive:i.interactiveMode}),Et((y,m)=>{if(y==="c"&&m.ctrl){d();return}if(!T){if(k){m.escape||y==="?"?v(!1):y==="q"?(v(!1),O(!0)):m.downArrow||y==="j"?$.current?.scrollBy(1):m.upArrow||y==="k"?$.current?.scrollBy(-1):m.pageDown?$.current?.scrollBy(5):m.pageUp?$.current?.scrollBy(-5):m.home?$.current?.scrollToTop():m.end&&$.current?.scrollToBottom();return}if(y==="?"){v(!0);return}if(y==="q"){O(!0);return}if(y==="r"&&i.done){s.requestRerun();return}if(y==="R"&&i.done){const x=I[i.selectedIndex];x?.status==="failure"&&s.requestRetry(x.taskId);return}if(y==="F"&&!i.filterActive){const x=["all","failed","running","passed"],ee=x.indexOf(i.statusFilter);s.setStatusFilter(x[(ee+1)%x.length]);return}if(i.filterActive){if(m.escape){s.setFilterActive(!1);return}if(m.return){s.setFilterActive(!1);return}if(m.backspace){s.setFilter(i.filterText.slice(0,-1));return}if(y&&!m.ctrl&&!m.meta){s.setFilter(i.filterText+y);return}return}if(y==="i"&&B?.status==="running"&&(i.viewMode==="fullscreen"||i.viewMode==="split"&&i.focusedPanel==="output")){s.setInteractiveMode(!0);return}if(i.viewMode==="fullscreen"){if(m.escape){s.setViewMode("split"),F("split");return}if(m.downArrow||y==="j"){R.current?.scrollBy(1);return}if(m.upArrow||y==="k"){R.current?.scrollBy(-1);return}if(m.pageDown||m.ctrl&&y==="d"){R.current?.scrollBy(12);return}if(m.pageUp||m.ctrl&&y==="u"){R.current?.scrollBy(-12);return}if(m.home){R.current?.scrollToTop();return}if(m.end){R.current?.scrollToBottom();return}return}if(i.viewMode==="split"){if(m.tab){const x=i.focusedPanel==="tasks"?"output":"tasks";s.setFocusedPanel(x);return}if(i.focusedPanel==="output"){if(m.escape){s.setFocusedPanel("tasks");return}if(m.return){Q(),s.setViewMode("fullscreen");return}if(m.downArrow||y==="j"){R.current?.scrollBy(1);return}if(m.upArrow||y==="k"){R.current?.scrollBy(-1);return}if(m.pageDown||m.ctrl&&y==="d"){R.current?.scrollBy(12);return}if(m.pageUp||m.ctrl&&y==="u"){R.current?.scrollBy(-12);return}if(m.home){R.current?.scrollToTop();return}if(m.end){R.current?.scrollToBottom();return}return}if(m.escape){s.setViewMode("list"),F("list");return}if(m.return){s.setFocusedPanel("output");return}}if(i.viewMode==="list"||i.viewMode==="split"&&i.focusedPanel==="tasks"){if(m.downArrow||y==="j"){const x=Math.min(i.selectedIndex+1,Math.max(0,I.length-1));s.setSelectedIndex(x),J(x);return}if(m.upArrow||y==="k"){const x=Math.max(i.selectedIndex-1,0);s.setSelectedIndex(x),J(x);return}if(m.return&&i.viewMode==="list"){Q(),P.current.splitList=0,P.current.splitOutput=0,s.setViewMode("split"),s.setFocusedPanel("output"),F("split");return}if(y==="/"){s.setFilterActive(!0);return}if(y==="1"&&G){s.pinTask(0,G);return}if(y==="2"&&G){s.pinTask(1,G);return}if(y==="0"){s.clearPins();return}m.escape&&i.filterText&&s.setFilter("")}}},{isActive:!i.interactiveMode}),h<Dt||f<Bt)return l(p,{alignItems:"center",height:f,justifyContent:"center",width:h,children:u(n,{color:"yellow",children:["Terminal too small (",h,"x",f,"). Minimum:"," ",Dt,"x",Bt]})});const H=u(p,{gap:1,children:[i.succeeded>0&&u(n,{bold:!0,color:"green",children:["✓"," ",i.succeeded]}),i.failed>0&&u(n,{bold:!0,color:"red",children:["✗"," ",i.failed]}),_>0&&u(n,{color:"cyan",children:["◷"," ",_]}),u(n,{dimColor:!0,children:[i.rows.length," ","total"]}),i.statusFilter!=="all"&&u(n,{color:"yellow",children:["[",i.statusFilter,"]"]})]});let he;if(i.viewMode==="fullscreen")he=[u(p,{gap:1,children:[l(n,{bold:!0,color:"white",children:"Esc"}),l(n,{dimColor:!0,children:"BACK"})]},"esc"),u(p,{gap:1,children:[l(n,{bold:!0,color:"white",children:"↑↓"}),l(n,{dimColor:!0,children:"SCROLL"})]},"scroll"),u(p,{gap:1,children:[l(n,{bold:!0,color:"white",children:"^u ^d"}),l(n,{dimColor:!0,children:"PAGE"})]},"page"),...B?.status==="running"?[u(p,{gap:1,children:[l(n,{bold:!0,color:"white",children:"i"}),l(n,{dimColor:!0,children:"INPUT"})]},"i")]:[],u(p,{gap:1,children:[l(n,{bold:!0,color:"white",children:"q"}),l(n,{dimColor:!0,children:"QUIT"})]},"q")];else if(i.done){const y=I[i.selectedIndex]?.status==="failure";he=[u(p,{gap:1,children:[l(n,{bold:!0,color:"white",children:"q"}),l(n,{dimColor:!0,children:"QUIT"})]},"q"),u(p,{gap:1,children:[l(n,{bold:!0,color:"white",children:"r"}),l(n,{dimColor:!0,children:"RERUN"})]},"r"),...y?[u(p,{gap:1,children:[l(n,{bold:!0,color:"white",children:"R"}),l(n,{dimColor:!0,children:"RETRY"})]},"R")]:[],u(p,{gap:1,children:[l(n,{bold:!0,color:"white",children:"?"}),l(n,{dimColor:!0,children:"HELP"})]},"?"),u(p,{gap:1,children:[l(n,{bold:!0,color:"white",children:"↑↓"}),l(n,{dimColor:!0,children:"NAV"})]},"nav"),u(p,{gap:1,children:[l(n,{bold:!0,color:"white",children:"F"}),l(n,{dimColor:!0,children:"FILTER"})]},"F"),u(p,{gap:1,children:[l(n,{bold:!0,color:"white",children:"⏎"}),l(n,{dimColor:!0,children:i.viewMode==="list"?"OUTPUT":"FULLSCREEN"})]},"enter")]}else i.viewMode==="split"&&i.focusedPanel==="output"?he=[u(p,{gap:1,children:[l(n,{bold:!0,color:"white",children:"q"}),l(n,{dimColor:!0,children:"QUIT"})]},"q"),u(p,{gap:1,children:[l(n,{bold:!0,color:"white",children:"Esc"}),l(n,{dimColor:!0,children:"BACK"})]},"esc"),u(p,{gap:1,children:[l(n,{bold:!0,color:"white",children:"↑↓"}),l(n,{dimColor:!0,children:"SCROLL"})]},"scroll"),...B?.status==="running"?[u(p,{gap:1,children:[l(n,{bold:!0,color:"white",children:"i"}),l(n,{dimColor:!0,children:"INPUT"})]},"i")]:[],u(p,{gap:1,children:[l(n,{bold:!0,color:"white",children:"⏎"}),l(n,{dimColor:!0,children:"FULLSCREEN"})]},"enter"),u(p,{gap:1,children:[l(n,{bold:!0,color:"white",children:"Tab"}),l(n,{dimColor:!0,children:"PANEL"})]},"tab"),u(p,{gap:1,children:[l(n,{bold:!0,color:"white",children:"?"}),l(n,{dimColor:!0,children:"HELP"})]},"?")]:he=[u(p,{gap:1,children:[l(n,{bold:!0,color:"white",children:"q"}),l(n,{dimColor:!0,children:"QUIT"})]},"q"),u(p,{gap:1,children:[l(n,{bold:!0,color:"white",children:"?"}),l(n,{dimColor:!0,children:"HELP"})]},"?"),u(p,{gap:1,children:[l(n,{bold:!0,color:"white",children:"↑↓"}),l(n,{dimColor:!0,children:"NAV"})]},"nav"),u(p,{gap:1,children:[l(n,{bold:!0,color:"white",children:"/"}),l(n,{dimColor:!0,children:"FILTER"})]},"/"),u(p,{gap:1,children:[l(n,{bold:!0,color:"white",children:"F"}),l(n,{dimColor:!0,children:"STATUS"})]},"F"),u(p,{gap:1,children:[l(n,{bold:!0,color:"white",children:"⏎"}),l(n,{dimColor:!0,children:i.viewMode==="list"?"OUTPUT":"FULLSCREEN"})]},"enter"),...i.viewMode==="split"?[u(p,{gap:1,children:[l(n,{bold:!0,color:"white",children:"Tab"}),l(n,{dimColor:!0,children:"PANEL"})]},"tab")]:[]];const ce=u(p,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",flexShrink:0,justifyContent:"space-between",children:[l(p,{flexGrow:1,flexWrap:"wrap",gap:2,paddingX:1,children:he}),l(p,{flexShrink:0,paddingX:1,children:H})]}),D=u(wo,{backgroundColor:"#1e1e1e",footer:u(n,{dimColor:!0,children:[l(n,{bold:!0,color:"white",children:"↑↓"})," ","scroll"," ",l(n,{bold:!0,color:"white",children:"?"}),"/",l(n,{bold:!0,color:"white",children:"Esc"})," ","close"]}),scrollRef:$,title:"KEYBOARD SHORTCUTS",visible:k,width:52,children:[u(p,{flexDirection:"column",marginBottom:1,children:[u(p,{marginBottom:1,children:[l(n,{dimColor:!0,children:"── "}),l(n,{bold:!0,color:"white",children:"NAVIGATION"})]}),u(p,{children:[l(p,{width:24,children:u(n,{children:[u(n,{bold:!0,color:"white",children:[" ","↑","/k"]}),l(n,{dimColor:!0,children:" Move up"})]})}),u(n,{children:[u(n,{bold:!0,color:"white",children:[" ","↓","/j"]}),l(n,{dimColor:!0,children:" Move down"})]})]}),u(n,{children:[u(n,{bold:!0,color:"white",children:[" ","Tab"]}),l(n,{dimColor:!0,children:" Switch panel (split)"})]}),u(n,{children:[u(n,{bold:!0,color:"white",children:[" ","Esc"]}),l(n,{dimColor:!0,children:" Back / close"})]}),u(n,{children:[u(n,{bold:!0,color:"white",children:[" ","Enter"]}),l(n,{dimColor:!0,children:" Show output / fullscreen"})]})]}),u(p,{flexDirection:"column",marginBottom:1,children:[u(p,{marginBottom:1,children:[l(n,{dimColor:!0,children:"── "}),l(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(p,{flexDirection:"column",marginBottom:1,children:[u(p,{marginBottom:1,children:[l(n,{dimColor:!0,children:"── "}),l(n,{bold:!0,color:"white",children:"ACTIONS"})]}),u(p,{children:[l(p,{width:24,children:u(n,{children:[u(n,{bold:!0,color:"white",children:[" ","/"]}),l(n,{dimColor:!0,children:" Filter by text"})]})}),u(n,{children:[u(n,{bold:!0,color:"white",children:[" ","F"]}),l(n,{dimColor:!0,children:" Filter by status"})]})]}),u(p,{children:[l(p,{width:24,children:u(n,{children:[u(n,{bold:!0,color:"white",children:[" ","1"]}),l(n,{dimColor:!0,children:"/"}),l(n,{bold:!0,color:"white",children:"2"}),l(n,{dimColor:!0,children:" Pin to output pane"})]})}),u(n,{children:[u(n,{bold:!0,color:"white",children:[" ","0"]}),l(n,{dimColor:!0,children:" Clear pins"})]})]}),u(p,{children:[l(p,{width:24,children:u(n,{children:[u(n,{bold:!0,color:"white",children:[" ","r"]}),l(n,{dimColor:!0,children:" Rerun all (done)"})]})}),u(n,{children:[u(n,{bold:!0,color:"white",children:[" ","R"]}),l(n,{dimColor:!0,children:" Retry failed task"})]})]}),u(n,{children:[u(n,{bold:!0,color:"white",children:[" ","i"]}),l(n,{dimColor:!0,children:" Interactive input (running task)"})]})]}),u(p,{flexDirection:"column",marginBottom:1,children:[u(p,{marginBottom:1,children:[l(n,{dimColor:!0,children:"── "}),l(n,{bold:!0,color:"white",children:"SCROLLING"}),l(n,{dimColor:!0,children:" (output panel)"})]}),u(p,{children:[l(p,{width:24,children:u(n,{children:[u(n,{bold:!0,color:"white",children:[" ","↑","/k"]}),l(n,{dimColor:!0,children:" Scroll up"})]})}),u(n,{children:[u(n,{bold:!0,color:"white",children:[" ","↓","/j"]}),l(n,{dimColor:!0,children:" Scroll down"})]})]}),u(p,{children:[l(p,{width:24,children:u(n,{children:[u(n,{bold:!0,color:"white",children:[" ","^u"]}),l(n,{dimColor:!0,children:" Page up"})]})}),u(n,{children:[u(n,{bold:!0,color:"white",children:[" ","^d"]}),l(n,{dimColor:!0,children:" Page down"})]})]}),u(p,{children:[l(p,{width:24,children:u(n,{children:[u(n,{bold:!0,color:"white",children:[" ","Home"]}),l(n,{dimColor:!0,children:" Top"})]})}),u(n,{children:[u(n,{bold:!0,color:"white",children:[" ","End"]}),l(n,{dimColor:!0,children:" Bottom"})]})]})]}),u(p,{flexDirection:"column",children:[u(p,{marginBottom:1,children:[l(n,{dimColor:!0,children:"── "}),l(n,{bold:!0,color:"white",children:"GENERAL"})]}),u(p,{children:[l(p,{width:24,children:u(n,{children:[u(n,{bold:!0,color:"white",children:[" ","q"]}),l(n,{dimColor:!0,children:" Quit"})]})}),u(n,{children:[u(n,{bold:!0,color:"white",children:[" ","?"]}),l(n,{dimColor:!0,children:" Toggle help"})]})]})]})]}),U=l(Dr,{autoExitSeconds:r>0?r:3,onCancel:S(()=>{O(!1)},"onCancel"),visible:T});if(i.viewMode==="fullscreen")return u(p,{flexDirection:"column",height:f,width:h,children:[l(p,{flexGrow:1,children:l(_t,{duration:B?.duration??B?.elapsed,focused:!0,interactiveMode:i.interactiveMode,output:ie,scrollRef:R,status:B?.status,taskId:C})}),ce,U,D]});if(i.viewMode==="split"){const y=h>=Ht,m=l(Lt,{compact:!0,filterActive:i.filterActive,filterText:i.filterText,focused:i.focusedPanel==="tasks",headerStatus:ae,parallelSlots:e,pinnedTaskIds:i.pinnedTaskIds,rows:I,scrollRef:M,selectedIndex:i.selectedIndex,title:q}),x=l(_t,{duration:B?.duration??B?.elapsed,focused:i.focusedPanel==="output",interactiveMode:i.interactiveMode,output:ie,scrollRef:R,showFullscreenHint:!0,status:B?.status,taskId:C});if(y){const fe=Math.floor(h*.4);return u(p,{flexDirection:"column",height:f,width:h,children:[u(p,{flexDirection:"row",flexGrow:1,children:[l(p,{width:fe,children:m}),l(p,{flexGrow:1,children:x})]}),ce,U,D]})}const ee=Math.floor(f*.45);return u(p,{flexDirection:"column",height:f,width:h,children:[l(p,{height:ee,children:m}),l(p,{flexGrow:1,children:x}),ce,U,D]})}return u(p,{flexDirection:"column",height:f,width:h,children:[l(p,{flexGrow:1,children:l(Lt,{filterActive:i.filterActive,filterText:i.filterText,focused:!0,headerStatus:ae,parallelSlots:e,pinnedTaskIds:i.pinnedTaskIds,rows:I,scrollRef:M,selectedIndex:i.selectedIndex,title:q})}),ce,U,D]})},"VisTaskRunnerApp");var Fs=Object.defineProperty,$e=S((r,e)=>Fs(r,"name",{value:e,configurable:!0}),"n$2");const As=$e(r=>{const{args:e,autoExit:t=!1,outputStyle:o="normal",projectNames:s,stdinRegistry:a,tasks:c}=r,d=new Le(c),h=typeof e.parallel=="number"?e.parallel:3,f=t===!0?3:typeof t=="number"?t:0;let i,k;const v=new Promise(F=>{k=F});let $;const M=$e(()=>{$&&(clearInterval($),$=void 0)},"cleanup"),R=$e(()=>{if(a){for(const F of a.values())F.kill?.();a.clear()}},"killAllPtyProcesses"),T=$e(()=>{M(),Q(),R(),process.stdout.write("\x1B[?1049l\x1B[?25h"),i?.cleanup(),process.exit(1)},"onSignal"),O=$e(()=>{const F=d.getSnapshot(),w=ve(Date.now()-F.startTime),I=F.rows.filter(C=>C.status==="failure").map(C=>C.taskId),_=process.stdout.columns||80;process.stdout.write(`
|
|
8
|
-
`)
|
|
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}
|
|
9
12
|
`)}process.stdout.write(`
|
|
10
|
-
`);const
|
|
11
|
-
`),
|
|
12
|
-
`,
|
|
13
|
-
|
|
14
|
-
`);const
|
|
15
|
-
`).map(
|
|
16
|
-
`);process.stdout.write(`${
|
|
17
|
-
`)}}},"printExitSummary");let
|
|
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(`
|
|
18
21
|
With additional flags:
|
|
19
|
-
`);for(const[
|
|
22
|
+
`);for(const[i,d]of a)process.stdout.write(`${io(" ",i,d)}
|
|
20
23
|
`)}process.stdout.write(`
|
|
21
|
-
`)}startTasks(e){const t=process.stdout.columns||80;for(const
|
|
22
|
-
`)}}endTasks(e){const t=process.stdout.columns||80;for(const
|
|
23
|
-
`)}}printTaskTerminalOutput(e,t,
|
|
24
|
-
`);const
|
|
25
|
-
`)}}var
|
|
26
|
-
`;await
|
|
27
|
-
`)},"writeBashHistory"),
|
|
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(`
|
|
28
31
|
`,String.raw`\n`)}
|
|
29
32
|
when: ${Math.floor(Date.now()/1e3)}
|
|
30
|
-
`;await
|
|
31
|
-
`),
|
|
32
|
-
`)},"writeHelp"),
|
|
33
|
-
`);if(
|
|
34
|
-
`):await e.onFilter(
|
|
35
|
-
`)})},"onKeypress"),
|
|
36
|
-
`)
|
|
37
|
-
|
|
38
|
-
`)
|
|
39
|
-
|
|
40
|
-
[
|
|
41
|
-
`
|
|
42
|
-
`).filter(Boolean):void 0,_=(typeof t.runnerTags=="string"?t.runnerTags:process.env.VIS_RUNNER_TAGS)??void 0,G=_?new Set(_.split(",").map(g=>g.trim()).filter(Boolean)):void 0,C=[],B=new Map;for(const g of P){const b=k.get(g)?.[O];if(!b)continue;const E=b.options;if(!E?.internal){if(!Wr(E,!!ze)){e.debug?.(`Skipping ${g}:${O} — runInCI filter`);continue}if(!Ur(E,G)){e.debug?.(`Skipping ${g}:${O} — runner-tags filter`);continue}C.push(g),B.set(g,b)}}if(C.length===0){const g=Pt(v),b=Object.entries(v.projects).filter(([,E])=>E.targets?.[O]!==void 0).map(([E])=>E);if(e.error(`No projects have the "${O}" target.`),b.length>0){e.info(""),e.info(`Target "${O}" exists in these projects but was filtered out:`);for(const E of b.slice(0,5))e.info(` - ${E}`);b.length>5&&e.info(` …and ${b.length-5} more`)}else{const E=or(O,g,3);E.length>0&&(e.info(""),e.info(E.length===1?`Did you mean "${E[0]}"?`:`Did you mean one of: ${E.map(V=>`"${V}"`).join(", ")}?`)),e.info(""),e.info("Run `vis run` without arguments to see all available targets.")}return}const ie=t.pty===!0;let L=C.map(g=>{const b=v.projects[g],E=B.get(g),V={project:g,target:O},W=`${g}:${O}`,pe=ie?{...E.options,pty:E.options?.pty??!0}:E.options,oe=E.command?jr(E.command,{affectedFiles:I,projectRoot:b?.root}):E.command;return{cache:E.cache,id:W,outputs:E.outputs??[],overrides:{command:oe,...Q.length>0?{[kr]:Q}:{},...pe?{visOptions:pe}:{}},parallelism:E.parallelism,projectRoot:b?.root,target:V}});const q=[],ae=[];for(const g of L)wr(g)?.persistent?(g.cache=!1,q.push(g)):ae.push(g);L=ae;const J=Rr(t.partition);if(J&&(L=Or.partitionTasks(L,J),e.info(`Partition ${J.index}/${J.total}: running ${L.length} task(s)`),L.length===0)){e.info("No tasks assigned to this partition.");return}let H=Pr(L,{projectGraph:$,targetDefaults:f.targetDefaults,workspace:v});for(const[g,b]of Object.entries(H.tasks)){if(b.overrides.visOptions!==void 0)continue;const E=b.target.project,V=b.target.target,W=k.get(E)?.[V];W?.options&&(b.overrides={...b.overrides,visOptions:W.options},H.tasks[g]=b)}if(typeof t.skipCache=="string"&&t.skipCache.trim()!=="")if(t.cache){const g=ts(t.skipCache,v,Object.keys(H.tasks));for(const b of g.skipTaskIds){const E=H.tasks[b];E!==void 0&&(E.cache=!1)}g.unmatchedPatterns.length>0&&e.warn(`--skip-cache: no tasks matched ${g.unmatchedPatterns.map(b=>`"${b}"`).join(", ")}`),g.skipTaskIds.size>0&&e.debug?.(`--skip-cache: bypassing cache for ${String(g.skipTaskIds.size)} task(s)`)}else e.debug?.("--skip-cache ignored: --no-cache already disables caching for the whole run");await so(c,f.toolchain,{error:j(g=>{e.error(g)},"error"),info:j(g=>{e.info(g)},"info"),warn:j(g=>{e.warn(g)},"warn")},!!t.skipToolchain);const he=t.preflight!==!1&&f.preflight?.lockfile!==!1,ce=Zo(c,ze,{warn:j(g=>{e.warn(g)},"warn")},{skip:!he});if(!ce.shouldContinue)throw new Error(`${ce.formattedMessage??"preflight: lockfile drift detected"} (pass --no-preflight to bypass)`);const D=await io(c),U=await yn({initialTasks:L,probe:t.dryRun?void 0:async g=>{try{return await ao(g.config,{timeoutMs:$n}),!0}catch{return!1}},registeredEntries:D,taskGraph:H,visVersion:process.env.VIS_VERSION??"0.0.0"});if(U.diagnostics.length>0){for(const g of U.diagnostics)e.error(g.message);throw new Error(`${U.diagnostics.length} service dependency error(s) — start the missing services or invoke them directly.`)}L=U.initialTasks,H=U.taskGraph;const{serviceEnvByTaskId:y}=U;if(U.satisfiedServices.length>0){const g=U.satisfiedServices.map(b=>b.id).join(", ");e.debug?.(`Auto-attached to running services: ${g}`)}if(t.reverse&&(H=_r(H),e.debug?.(`Reversed task graph: ${String(H.roots.length)} new root(s) (originally leaves)`)),t.dryRun){const g=Object.keys(H.tasks).length,b=H.roots.length;e.info(`Execution plan (${String(g)} task(s), ${String(b)} root(s)):`),e.info("");const E=new Set,V=j((W,pe)=>{if(E.has(W))return;E.add(W);for(const ke of H.dependencies[W]??[])V(ke,pe+1);const oe=H.tasks[W],se=" ".repeat(pe+1);e.info(`${se}${W}${oe?.cache===!1?" (no-cache)":""}`)},"walkPlan");for(const W of H.roots)V(W,0);for(const W of Object.keys(H.tasks))V(W,0);q.length>0&&(e.info(""),e.info(` + ${String(q.length)} persistent task(s) (run after graph completes)`)),e.info("");return}const m=Date.now(),x=Ys(),ee=j((g,b)=>{const E=b instanceof Error?b.message:String(b);e.warn(`Plugin error in ${g}: ${E}`)},"onHookError");await Ks(x,f.plugins);const fe=typeof t.profile=="string"?t.profile:void 0,xe=j(async g=>{if(!fe)return;const b=St(g,H,m),E=fe.startsWith("/")?fe:`${c}/${fe}`;await Fr(b,E),e.info(`Profile written to ${fe}`)},"maybeWriteProfile"),ye=f.taskRunnerOptions??{},_e=Vr(c,t.cacheDir,ye.cacheDirectory,f.sharedWorktreeCache),Ue=zr(_e,c,f.branchScopedCache),be=En(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,yr=t.parallel??vr??3,ut=t.strictEnv??f.strictEnv??!1,Fe={dryRun:t.dryRun??!1,parallel:yr,skipNxCache:!t.cache,summarize:t.summarize??!1,...ye,cacheDirectory:Ue};if(ye.remoteCache){const g=Rn(t.cacheMode),b=On(t.cacheBackend);(g||b)&&(Fe.remoteCache={...ye.remoteCache,...g?{mode:g}:{},...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 br=process.stdout.isTTY&&!ze,$r=f.tui?.autoExit??!1,ht={args:{parallel:Fe.parallel,targets:[O]},autoExit:$r,projectNames:C,tasks:L},ft=typeof t.retryBudget=="number"?t.retryBudget:void 0,pt=ft===void 0?void 0:In(ft),mt=new Qs(x,ee),gt=new Zr(c),wt=Ds(typeof t.outputStyle=="string"?t.outputStyle.toLowerCase():void 0);if(await x.callHook("run:before",{tasks:L,workspaceRoot:c}),br){const g=new Map,b=As({...ht,outputStyle:wt,stdinRegistry:g}),{lifeCycle:E,store:V}=b,W=new Ct([E,mt,gt]),pe=Ut({affectedFiles:I,currentOs:F,initCwd:d,lifeCycle:W,mutexPool:new Map,onOutput:j((A,z)=>{V.addOutput(A,z)},"onOutput"),onOutputReplace:j((A,z)=>{V.setOutput(A,z)},"onOutputReplace"),retryBudget:pt,serviceEnvByTaskId:y,stdinRegistry:g,strictEnv:ut,workspaceRoot:c});let oe="rerun",se=null,ke=new Map;for(;oe!=="quit";){if(oe==="rerun")ke=await xt(L,Fe,{lifeCycle:W,projectGraph:$,taskExecutor:pe,taskGraph:H,workspaceRoot:c});else if(oe==="retry"&&se){const A=L.find(Z=>Z.id===se),z=A?.overrides.command;if(A&&z){const Z=A.projectRoot??c,ge=Z.startsWith("/")?Z:`${c}/${Z}`;W.startTasks?.([A]);const ne=new Vt(et),le=(await tt([{command:z,cwd:ge,name:A.id,ptySize:{cols:process.stdout.columns??80,rows:process.stdout.rows??24},stdin:"pty"}],{onEvent:j(K=>{K.kind==="started"&&K.write&&g.set(A.id,{kill:K.kill,resize:K.resize,write:K.write}),(K.kind==="stdout"||K.kind==="stderr")&&K.text&&(ne.write(K.text),V.setOutput(A.id,ne.toString())),K.kind==="close"&&g.delete(A.id)},"onEvent")})).closeEvents[0];W.endTasks?.([{code:le?.exitCode??1,status:le?.exitCode===0?"success":"failure",task:A,terminalOutput:V.getSnapshot().outputs.get(A.id)}])}else A&&W.endTasks?.([{code:1,status:"failure",task:A,terminalOutput:`No command configured for ${A.id}`}]);se=null,V.markDone()}oe=await new Promise(A=>{const z=V.subscribe(()=>{const Z=V.getSnapshot();Z.rerunRequested&&(V.acknowledgeRerun(),z(),A("rerun")),Z.retryTaskId&&(se=V.acknowledgeRetry(),z(),A("retry"))});b.renderIsDone.then(()=>{z(),A("quit")}).catch(()=>{z(),A("quit")})})}await b.renderIsDone,await x.callHook("run:after",ke),await xe(ke),q.length>0&&!t.failFast&&await Wt(q,c,I,d)}else{const g=new Map,b=typeof t.log=="string"?t.log.toLowerCase():"",E=b==="labeled"||b==="grouped"||b==="interleaved"?b:void 0,V=E?Ar(E):void 0,W=new Ct([new Hs({...ht,logReporter:V,outputStyle:wt}),mt,gt]),pe=Ut({affectedFiles:I,currentOs:F,initCwd:d,lifeCycle:W,mutexPool:g,retryBudget:pt,serviceEnvByTaskId:y,strictEnv:ut,workspaceRoot:c}),oe=j(async()=>{const A=Date.now(),z=await xt(L,Fe,{lifeCycle:W,projectGraph:$,taskExecutor:pe,taskGraph:H,workspaceRoot:c}),Z=Date.now()-A;if(t.summarize){const de=St(z,H,m);await Lr(de,c)}let ge=!1;for(const[,de]of z)de.status==="failure"&&(ge=!0);const ne=Jr(z,Z),le=eo(c),K=to(c,Z,le);return e.info(""),e.info(` ${ne}${K?` ${K}`:""}`),{hasFailure:ge,results:z,runHistory:le}},"runOnce"),se=await oe();await x.callHook("run:after",se.results),await xe(se.results);const{hasFailure:ke}=se;if(t.watch){const A=C.map(X=>{const te=v.projects[X]?.root;if(te)return te.startsWith("/")?te:`${c}/${te}`}).filter(X=>X!==void 0),z=L;let Z;const ge=j(X=>{const te=hn(z,X);return Z=te.filter,L=te.tasks,te.tasks.length},"applyFilter");let ne=!1,le=se.results;const K=j(()=>{const X=Gt(le,c);if(X.directories.length>0&&X.files.size>0){const te=cn(X.files,c,X.directories);return{handle:qt({filter:te,onChange:kt,paths:X.directories}),mode:"tracked"}}return{handle:qt({onChange:kt,paths:A}),mode:"roots"}},"buildHandle");let de;const kt=j(async X=>{if(!ne){ne=!0;try{e.info(`Change detected in ${X.length} file(s), rerunning…`),le=(await oe()).results,de?.close(),de=K().handle}finally{ne=!1}}},"onChangeHandler"),vt=K();de=vt.handle;const Tr=vt.mode==="tracked"?`Watching ${String(Gt(le,c).files.size)} tracked file(s)`:`Watching ${String(A.length)} project root(s)`;e.info(`${Tr} — edit a file to rerun, press h for keybinds, q to quit.`);const Ve=j(async()=>{if(!ne){ne=!0;try{if(L.length===0){e.info("No tasks match the active filter — press a to clear it.");return}le=(await oe()).results,de?.close(),de=K().handle}finally{ne=!1}}},"triggerRerun");await new Promise(X=>{let te=!1,yt;const bt=j(()=>{$t()},"onSigint"),$t=j(()=>{te||(te=!0,yt?.close(),process.off("SIGINT",bt),de?.close(),X())},"exit");process.on("SIGINT",bt),yt=wn({handlers:{onClearFilter:j(async()=>{const Ie=ge(void 0);e.info(`Filter cleared — running ${String(Ie)} task(s).`),await Ve()},"onClearFilter"),onFilter:j(async Ie=>{const Sr=Z,Tt=ge(Ie);if(Tt===0){e.info(`Filter "${Ie}" matched no projects — keeping previous filter.`),ge(Sr);return}e.info(`Filter "${Ie}" matched ${String(Tt)} task(s).`),await Ve()},"onFilter"),onHelp:j(()=>{mn(process.stdout)},"onHelp"),onQuit:j(()=>{$t()},"onQuit"),onRerun:Ve}})});return}if(ke){if(t.flaky!==!1){const A=ro(c,{minRuns:2},se.runHistory);if(A.length>0){e.info(""),e.info("Flaky tasks (based on historical runs):"),e.info("");for(const z of oo(A))e.info(` ${z}`);e.info("")}}throw new Error("Some tasks failed.")}q.length>0&&!t.failFast&&await Wt(q,c,I,d)}},"execute");export{In as createRetryBudget,Kn as default};
|
|
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
|
+
import { closeSync, openSync, readFileSync, readSync, statSync, writeFileSync } from "node:fs";
|
|
46
|
+
import { createConnection } from "node:net";
|
|
47
|
+
|
|
48
|
+
const cfgPath = process.argv[2];
|
|
49
|
+
|
|
50
|
+
if (!cfgPath) {
|
|
51
|
+
console.error("[vis-service-bootstrap] missing config path");
|
|
52
|
+
process.exit(2);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const cfg = JSON.parse(readFileSync(cfgPath, "utf8"));
|
|
56
|
+
|
|
57
|
+
// Structured marker for service-event-bridge.ts to consume. Plain
|
|
58
|
+
// process.stdout.write keeps the line atomic and on the same stream
|
|
59
|
+
// as the tailed child log, so the parser sees one stream.
|
|
60
|
+
const emit = (event) => {
|
|
61
|
+
process.stdout.write("[[VIS_BOOT]]" + JSON.stringify({ ...event, id: cfg.id }) + "\n");
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
// Spawn the child with its stdio bound to a real file descriptor on
|
|
65
|
+
// disk — NOT inherited from the bootstrap. If the child inherited
|
|
66
|
+
// our stdio, it would inherit vis run's task pipes, and vis run would
|
|
67
|
+
// block waiting for those pipes to close even after this bootstrap
|
|
68
|
+
// exits. The logfile gives the grandchild a stable target it can keep
|
|
69
|
+
// writing to long after this bootstrap is gone.
|
|
70
|
+
const childLogFd = openSync(cfg.logFile, "a");
|
|
71
|
+
|
|
72
|
+
const child = spawn(cfg.command, {
|
|
73
|
+
cwd: cfg.cwd,
|
|
74
|
+
detached: true,
|
|
75
|
+
env: { ...process.env, ...cfg.env },
|
|
76
|
+
shell: true,
|
|
77
|
+
stdio: ["ignore", childLogFd, childLogFd],
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
// Close the bootstrap's copy of the fd; the child kept its own.
|
|
81
|
+
closeSync(childLogFd);
|
|
82
|
+
|
|
83
|
+
if (child.pid !== undefined) {
|
|
84
|
+
try {
|
|
85
|
+
writeFileSync(cfg.pidFile, String(child.pid));
|
|
86
|
+
} catch (error) {
|
|
87
|
+
console.error("[vis] failed to write pid file: " + (error?.message ?? String(error)));
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
emit({ event: "started", pid: child.pid ?? null });
|
|
92
|
+
|
|
93
|
+
let exitedEarly = false;
|
|
94
|
+
|
|
95
|
+
child.once("exit", (code, signal) => {
|
|
96
|
+
exitedEarly = true;
|
|
97
|
+
emit({ code, event: "failed", reason: "exited-before-ready", signal });
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
// Forward new bytes from the logfile to our stdout while we're alive.
|
|
101
|
+
// Polling-based tail; preflight is short, ~200ms per cycle is fine.
|
|
102
|
+
let tailPos = 0;
|
|
103
|
+
const tailFd = openSync(cfg.logFile, "r");
|
|
104
|
+
|
|
105
|
+
const flushTail = () => {
|
|
106
|
+
try {
|
|
107
|
+
const stat = statSync(cfg.logFile);
|
|
108
|
+
if (stat.size <= tailPos) return;
|
|
109
|
+
const remaining = stat.size - tailPos;
|
|
110
|
+
const buf = Buffer.alloc(remaining);
|
|
111
|
+
const n = readSync(tailFd, buf, 0, remaining, tailPos);
|
|
112
|
+
if (n > 0) {
|
|
113
|
+
process.stdout.write(buf.subarray(0, n));
|
|
114
|
+
tailPos += n;
|
|
115
|
+
}
|
|
116
|
+
} catch {}
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
const probeOnce = () => new Promise((resolve) => {
|
|
120
|
+
const socket = createConnection({ host: cfg.host || "127.0.0.1", port: cfg.port });
|
|
121
|
+
let settled = false;
|
|
122
|
+
const finish = (ok) => {
|
|
123
|
+
if (settled) return;
|
|
124
|
+
settled = true;
|
|
125
|
+
try { socket.destroy(); } catch {}
|
|
126
|
+
resolve(ok);
|
|
127
|
+
};
|
|
128
|
+
socket.once("connect", () => finish(true));
|
|
129
|
+
socket.once("error", () => finish(false));
|
|
130
|
+
socket.setTimeout(1000, () => finish(false));
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
134
|
+
|
|
135
|
+
(async () => {
|
|
136
|
+
const deadline = Date.now() + (cfg.timeoutMs ?? 30000);
|
|
137
|
+
while (Date.now() < deadline) {
|
|
138
|
+
flushTail();
|
|
139
|
+
if (exitedEarly) {
|
|
140
|
+
try { closeSync(tailFd); } catch {}
|
|
141
|
+
process.exit(1);
|
|
142
|
+
}
|
|
143
|
+
if (await probeOnce()) {
|
|
144
|
+
flushTail();
|
|
145
|
+
emit({ event: "ready", host: cfg.host || "127.0.0.1", port: cfg.port });
|
|
146
|
+
try { closeSync(tailFd); } catch {}
|
|
147
|
+
child.unref();
|
|
148
|
+
process.exit(0);
|
|
149
|
+
}
|
|
150
|
+
await sleep(200);
|
|
151
|
+
}
|
|
152
|
+
flushTail();
|
|
153
|
+
emit({ event: "failed", reason: "timeout", timeoutMs: cfg.timeoutMs ?? 30000 });
|
|
154
|
+
try { closeSync(tailFd); } catch {}
|
|
155
|
+
try { process.kill(-child.pid, "SIGTERM"); } catch {}
|
|
156
|
+
process.exit(1);
|
|
157
|
+
})();
|
|
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};
|