@visulima/vis 6.1.2 → 6.1.3
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 +6 -0
- package/dist/bin.js +1 -1
- package/dist/binx.js +1 -1
- package/dist/packem_chunks/bloom-sync.js +1 -1
- package/dist/packem_chunks/catalog2.js +1 -1
- package/dist/packem_chunks/cli-exec.js +1 -1
- package/dist/packem_chunks/cli-main.js +1 -1
- package/dist/packem_chunks/fix.js +1 -1
- package/dist/packem_chunks/handler12.js +1 -1
- package/dist/packem_chunks/handler15.js +1 -1
- package/dist/packem_chunks/handler2.js +1 -1
- package/dist/packem_chunks/handler20.js +1 -1
- package/dist/packem_chunks/handler21.js +1 -1
- package/dist/packem_chunks/handler23.js +1 -1
- package/dist/packem_chunks/handler24.js +1 -1
- package/dist/packem_chunks/handler25.js +1 -1
- package/dist/packem_chunks/handler28.js +1 -1
- package/dist/packem_chunks/handler3.js +1 -1
- package/dist/packem_chunks/handler32.js +1 -1
- package/dist/packem_chunks/handler4.js +1 -1
- package/dist/packem_chunks/handler46.js +1 -1
- package/dist/packem_chunks/handler5.js +1 -1
- package/dist/packem_chunks/handler50.js +1 -1
- package/dist/packem_chunks/handler52.js +1 -1
- package/dist/packem_chunks/handler54.js +1 -1
- package/dist/packem_chunks/handler55.js +1 -1
- package/dist/packem_chunks/handler56.js +1 -1
- package/dist/packem_chunks/handler58.js +1 -1
- package/dist/packem_chunks/handler59.js +1 -1
- package/dist/packem_chunks/handler6.js +1 -1
- package/dist/packem_chunks/handler60.js +1 -1
- package/dist/packem_chunks/handler61.js +1 -1
- package/dist/packem_chunks/handler62.js +1 -1
- package/dist/packem_chunks/handler63.js +1 -1
- package/dist/packem_chunks/handler64.js +1 -1
- package/dist/packem_chunks/handler65.js +1 -1
- package/dist/packem_chunks/handler68.js +1 -1
- package/dist/packem_chunks/handler69.js +1 -1
- package/dist/packem_chunks/handler70.js +1 -1
- package/dist/packem_chunks/handler71.js +1 -1
- package/dist/packem_chunks/handler72.js +1 -1
- package/dist/packem_chunks/handler73.js +1 -1
- package/dist/packem_chunks/handler74.js +1 -1
- package/dist/packem_chunks/handler75.js +1 -1
- package/dist/packem_chunks/handler76.js +1 -1
- package/dist/packem_chunks/handler77.js +1 -1
- package/dist/packem_chunks/handler78.js +1 -1
- package/dist/packem_chunks/handler79.js +27 -27
- package/dist/packem_chunks/handler8.js +1 -1
- package/dist/packem_chunks/heal.js +1 -1
- package/dist/packem_chunks/help-command.js +1 -1
- package/dist/packem_chunks/index7.js +1 -1
- package/dist/packem_chunks/prune.js +1 -1
- package/dist/packem_chunks/status.js +1 -1
- package/dist/packem_chunks/sync.js +1 -1
- package/dist/packem_chunks/verify-lockfile.js +1 -1
- package/dist/packem_shared/{ReleaseClient-CWD9BC5w.js → ReleaseClient-CRuCHDsT.js} +1 -1
- package/dist/packem_shared/{advisories-DO-P0V1_.js → advisories-BKsh48bi.js} +1 -1
- package/dist/packem_shared/{affected-selection-CeeZo7Uy.js → affected-selection-C7rvg_xC.js} +1 -1
- package/dist/packem_shared/{ai-analysis-BCJ1kuDM.js → ai-analysis-qdksWsn1.js} +1 -1
- package/dist/packem_shared/{ai-fix-DIMErSws.js → ai-fix-DEwd0QKC.js} +1 -1
- package/dist/packem_shared/{bin-BcLTer1k.js → bin-BND-N6AL.js} +1 -1
- package/dist/packem_shared/{dependency-scan-D_v3KM59.js → dependency-scan-B1CU6P9M.js} +1 -1
- package/dist/packem_shared/{ecosystem-gate-CwsTc7YW.js → ecosystem-gate-InIAzSPA.js} +1 -1
- package/dist/packem_shared/glob-Cyk1H9ZL-DlsGNNhY.js +1 -0
- package/dist/packem_shared/{index-BS6A9QR_.js → index-BS3mFsh-.js} +1 -1
- package/dist/packem_shared/{index-9Ot7jTd4.js → index-BtVOr8mn.js} +1 -1
- package/dist/packem_shared/{missing-package-json-1BIoWQq0.js → missing-package-json-DDVQ_scH.js} +1 -1
- package/dist/packem_shared/{multi-eco-lockfiles-fgkpeHJv.js → multi-eco-lockfiles-h_HBOpPX.js} +1 -1
- package/dist/packem_shared/{osv-Do9PMOea.js → osv-BLj4LauP.js} +1 -1
- package/dist/packem_shared/{package-version-Bq6Cne_7.js → package-version-D0b8b41D.js} +1 -1
- package/dist/packem_shared/{project-name-filter-ZQaLgytG.js → project-name-filter-C6ObyhZ4.js} +1 -1
- package/dist/packem_shared/publish-DkgvB2Lk.js +34 -0
- package/dist/packem_shared/{registry-Dg9XI6RT.js → registry-B6LWRK9T.js} +1 -1
- package/dist/packem_shared/{renderToString-DR0zDUjh-DXppT6AM.js → renderToString-DR0zDUjh-5WQEQBtg.js} +1 -1
- package/dist/packem_shared/{scaffold-files-DJlz36Mu.js → scaffold-files-02tUvEKC.js} +1 -1
- package/dist/packem_shared/{scan-progress-DymX71_5.js → scan-progress-D_POj2sy.js} +1 -1
- package/dist/packem_shared/{spinner-CPoBymcv.js → spinner-8fJUI_wl.js} +1 -1
- package/dist/packem_shared/{table-oA7p7-yP.js → table-bf3rvDd-.js} +1 -1
- package/dist/packem_shared/{tabs-BiSifphV.js → tabs-CvrVM8BU.js} +1 -1
- package/dist/packem_shared/{use-measured-height-BHm-HiSF.js → use-measured-height-CQ-qYCmz.js} +1 -1
- package/dist/packem_shared/{vis-update-app-6QOYxnNx.js → vis-update-app-a93HLRLX.js} +1 -1
- package/dist/packem_shared/{vis-user-error-3YS7sPYy.js → vis-user-error-Cpb0P6VA.js} +1 -1
- package/dist/packem_shared/{watch-loop-CGi66Fs0.js → watch-loop-CGPe21AK.js} +1 -1
- package/dist/release/index.js +1 -1
- package/index.js +26 -26
- package/package.json +9 -9
- package/dist/packem_shared/glob-Cyk1H9ZL-CL9optrn.js +0 -1
- package/dist/packem_shared/publish-Dc0XGH3K.js +0 -34
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
import{createRequire as ss}from"node:module";import{readLastRunSummary as is,getLastRunSummaryPath as os,runConcurrently as $e,TerminalBuffer as We,CompositeLifeCycle as jt,defaultTaskRunner as St,resolveTurboEnvCompat as cs,pickChildParentEnv as as,generateRunSummary as kt,writeChromeTrace as ls,expandAffected as ds,getChangedFiles as us,enforceProjectConstraints as fs,buildEnhancedPath as hs,createLogReporter as ps,writeRunSummary as ms,reverseTaskGraph as gs,splitCompoundTasks as ws,createTaskGraph as vs,expandTokensInString as bt,parsePartition as ys,TaskScheduler as xs}from"@visulima/task-runner";import{r as
|
|
1
|
+
import{createRequire as ss}from"node:module";import{readLastRunSummary as is,getLastRunSummaryPath as os,runConcurrently as $e,TerminalBuffer as We,CompositeLifeCycle as jt,defaultTaskRunner as St,resolveTurboEnvCompat as cs,pickChildParentEnv as as,generateRunSummary as kt,writeChromeTrace as ls,expandAffected as ds,getChangedFiles as us,enforceProjectConstraints as fs,buildEnhancedPath as hs,createLogReporter as ps,writeRunSummary as ms,reverseTaskGraph as gs,splitCompoundTasks as ws,createTaskGraph as vs,expandTokensInString as bt,parsePartition as ys,TaskScheduler as xs}from"@visulima/task-runner";import{r as U,j as c,X as v,O as u,R as K,o as js,d as Ss,b as ks}from"../packem_shared/registry-B6LWRK9T.js";import{r as bs}from"../packem_shared/command-runtime-HSsYGCQd.js";import{d as Ce,S as Ts}from"../packem_shared/env-BSXG3QKH.js";import{f as $s,d as Cs,e as Is,H as Es,i as Rs,r as Ps,s as Ms,a as Fs,b as Os,c as As}from"../packem_shared/lifecycle-CQjeMPY0.js";import{z as Ls,e as ne,m as Tt,$ as Ds,a as Bs}from"../packem_shared/index-BzhrR_iC.js";import{a as $t,d as Ct,r as He,s as _s,m as Ns,l as Gs}from"../packem_shared/target-options-DsHFmRZH.js";import{g as je,r as ke,b as Ws,e as Hs,A as qs,T as Vs,d as Us}from"../packem_shared/task-env-C2lmxvzA.js";import{f as zs}from"../packem_shared/removeSync-g1D5kONg-LbjATA8v.js";import{K as It,M as Ys,J as Ks,C as Je,N as Xs,Q as Js,q as Qs,P as Zs,Z as er,h as tr,aj as sr,ak as rr,al as nr,am as ir}from"./cli-main.js";import{O as ce}from"../packem_shared/renderToString-DR0zDUjh-5WQEQBtg.js";import{T as Et,C as Rt,D as Fe,E as Pt}from"../packem_shared/symbols-BXDZ_sKt.js";import{q as mr,j as gr,X as Ae,F as et}from"../packem_shared/index.server-Ca_EEVfw.js";import{parseStacktrace as wr,codeFrame as vr}from"@visulima/error";import{originalPositionFor as yr,sourceContentFor as xr,loadSourceMap as jr}from"@visulima/source-map";import{l as Mt}from"../packem_shared/spinner-8fJUI_wl.js";import{i as Se}from"../packem_shared/index-BjdW45xX.js";import{d as kr,r as br}from"../packem_shared/lockfile-CiUtEbnt.js";import{y as Ft}from"../packem_shared/index-BisalDCf.js";import{r as Cr}from"../packem_shared/toolchain-CP79HNVy.js";import{F as Ir}from"../packem_shared/failure-log-DIsKBKaI.js";import{V as pe}from"../packem_shared/vis-user-error-Cpb0P6VA.js";import{s as Er}from"../packem_shared/affected-selection-C7rvg_xC.js";import{c as Ot,s as Rr,p as Pr,a as Mr,b as Fr,r as Or,f as Ar}from"../packem_shared/project-name-filter-C6ObyhZ4.js";import{r as Lr,f as Dr,a as Br,p as _r}from"../packem_shared/selectors-edwcgNl3.js";import Be from"./index.js";import{U as At}from"../packem_shared/writeFileSync-DJoHk3Ks-BPRoepNw.js";import{c as tt,a as qr,s as st}from"../packem_shared/watch-CcTketln.js";let rs;const ns=t=>(rs??=ss(import.meta.url))(t),ye=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,fe=t=>{if(typeof ye<"u"&&ye.versions&&ye.versions.node){const[e,s]=ye.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return ye.getBuiltinModule(t)}return ns(t)},{existsSync:he,readFileSync:we,mkdirSync:or,writeFileSync:qe,openSync:cr,statSync:Qe,readSync:ar,closeSync:lr,mkdtempSync:dr}=fe("node:fs"),{isAbsolute:ur,resolve:Ze,dirname:fr,relative:hr}=fe("node:path"),{fileURLToPath:pr}=fe("node:url"),{createHash:Sr}=fe("node:crypto"),{createInterface:Tr,emitKeypressEvents:$r}=fe("node:readline"),{mkdir:Nr,appendFile:Oe}=fe("node:fs/promises"),{platform:Gr,homedir:Ve,tmpdir:Wr}=fe("node:os"),{spawn:Hr}=fe("node:child_process"),Vr=(t,e,s,r,i,o,n,l,d,h,f,p,a,m)=>{const w={d:r,h:i,m:o,mo:e,ms:l,s:n,w:s,y:t};return w.future=d,w.past=h,w.decimal=f,p!==void 0&&(w.unitMap=p),w.groupSeparator=a,w.placeholderSeparator=m,w},Ur={d:"d",day:"d",days:"d",h:"h",hour:"h",hours:"h",hr:"h",hrs:"h",m:"m",millisecond:"ms",milliseconds:"ms",min:"m",mins:"m",minute:"m",minutes:"m",mo:"mo",month:"mo",months:"mo",ms:"ms",s:"s",sec:"s",second:"s",seconds:"s",secs:"s",w:"w",week:"w",weeks:"w",y:"y",year:"y",years:"y",yr:"y",yrs:"y"},zr=Vr(t=>`year${t===1?"":"s"}`,t=>`month${t===1?"":"s"}`,t=>`week${t===1?"":"s"}`,t=>`day${t===1?"":"s"}`,t=>`hour${t===1?"":"s"}`,t=>`minute${t===1?"":"s"}`,t=>`second${t===1?"":"s"}`,t=>`millisecond${t===1?"":"s"}`,"in %s","%s ago",".",Ur,",","_"),rt=new WeakSet,Yr=t=>{if(rt.has(t))return;const e=["y","mo","w","d","h","m","s","ms"];for(const r of e)if(!Object.hasOwn(t,r))throw new TypeError(`Missing required property: ${r}`);if(t.future!==void 0&&typeof t.future!="string")throw new TypeError("Properties future and past must be of type string");if(t.past!==void 0&&typeof t.past!="string")throw new TypeError("Properties future and past must be of type string");const s=["y","mo","w","d","h","m","s","ms"];for(const r of s)if(typeof t[r]!="string"&&typeof t[r]!="function")throw new TypeError(`Property ${r} must be of type string or function`);if(t.decimal&&typeof t.decimal!="string")throw new TypeError("Property decimal must be of type string");if(t.delimiter&&typeof t.delimiter!="string")throw new TypeError("Property delimiter must be of type string");if(t._digitReplacements&&!Array.isArray(t._digitReplacements))throw new TypeError("Property _digitReplacements must be an array");if(t._numberFirst&&typeof t._numberFirst!="boolean")throw new TypeError("Property _numberFirst must be of type boolean");if(t.unitMap&&typeof t.unitMap!="object")throw new TypeError("Property unitMap must be an object");if(t.unitMap&&Object.values(t.unitMap).some(r=>typeof r!="string"))throw new TypeError("All values in unitMap must be of type string");rt.add(t)},Lt=(t,e)=>{if(!Number.isFinite(t)||e<0||Number.isInteger(t))return t;const s=10**e,r=Number((t*s).toPrecision(15));return Math.trunc(r)/s},nt=({unitCount:t,unitName:e},s,r)=>{let{spacer:i}=r;const{maxDecimalPoints:o}=r;let n=".";r.decimal!==void 0?n=r.decimal:s.decimal!==void 0&&(n=s.decimal);let l;"digitReplacements"in r?l=r.digitReplacements:"_digitReplacements"in s&&(l=s._digitReplacements);let d,h=t;o!==void 0&&(h=Lt(t,o));const f=h.toString();if(!s._hideCountIf2||t!==2)if(l){d="";for(const m of f)d+=m==="."?n:l[m]}else d=f.replace(".",n);else d="";const p=s[e];let a=p;return typeof p=="function"&&(a=p(t)),s._hideCountIf2&&t===2&&(i=""),s._numberFirst?a+i+d:d+i+a},Kr=(t,e)=>{const{units:s}=e;if(s.length===0)return[];const{unitMeasures:r}=e,i=e.largest??Number.POSITIVE_INFINITY,o={};let n,l,d,h=t;for(l=0;l<s.length;l++){n=s[l];const p=r[n];d=l===s.length-1?h/p:Math.floor(h/p),o[n]=d,h-=d*p}if(e.round){let p=i;for(l=0;l<s.length;l++)if(n=s[l],d=o[n],d!==0&&(p--,p===0)){for(let a=l+1;a<s.length;a++){const m=s[a],w=o[m];o[n]=(o[n]??0)+w*r[m]/r[n],o[m]=0}break}for(l=s.length-1;l>=0;l--){if(n=s[l],d=o[n],d===0)continue;const a=Math.round(d);if(o[n]=a,l===0)break;const m=s[l-1],w=r[m],j=Math.floor(a*r[n]/w);if(j)o[m]=(o[m]??0)+j,o[n]=0;else break}}const f=[];for(l=0;l<s.length&&f.length<i;l++){if(n=s[l],d=o[n],d&&!e.round&&f.length===i-1){let p,a=0;for(p=l+1,s.length;p<s.length;p++){const m=s[p];a+=o[m]*(e.unitMeasures[m]/e.unitMeasures[n])}d+=a,e.maxDecimalPoints!==void 0&&(d=Lt(d,e.maxDecimalPoints))}d&&f.push({unitCount:d,unitName:n})}return f},Xr=(t,e,s)=>{const{language:r,units:i}=e;if(t.length===0){const p=i.at(-1);return nt({unitCount:0,unitName:p},r,e)}const{conjunction:o,serialComma:n}=e;let l=", ";e.delimiter!==void 0?l=e.delimiter:r.delimiter!==void 0&&(l=r.delimiter);let d="";e.timeAdverb&&s!==0&&(d=r.future??"",s<0&&(d=r.past??""));const h=t.map(p=>nt(p,r,e));let f;return!o||t.length===1?f=h.join(l):t.length===2?f=h.join(o):f=h.slice(0,-1).join(l)+(n?",":"")+o+(h.at(-1)??""),d&&(f=d.replace("%s",f)),f},Jr=(t,e)=>{if(Number.isNaN(t))throw new TypeError("Expected a valid number");if(typeof t!="number")throw new TypeError("Expected a number for milliseconds input");const s={conjunction:"",language:zr,round:!1,serialComma:!0,spacer:" ",timeAdverb:!1,unitMeasures:{d:864e5,h:36e5,m:6e4,mo:2629746e3,ms:1,s:1e3,w:6048e5,y:31556952e3},units:["w","d","h","m","s"],...e};Yr(s.language);const r=Math.abs(t),i=Kr(r,s);return Xr(i,s,t)},Ie=256*1024;class Qr{#e;#r="";#s=!1;constructor(e){this.#e=e}append(e){this.#r+=e,this.#r.length>this.#e&&(this.#r=this.#r.slice(-this.#e),this.#s=!0)}toString(){return this.#s?`[...output truncated, showing last ${Math.round(this.#e/1024)}KB...]
|
|
2
2
|
${this.#r}`:this.#r}}const Zr=t=>{if(!t||t.trim().length===0)return;const e=Number.parseFloat(t);return!Number.isFinite(e)||e<=0?{invalid:t}:{value:Math.floor(e)}},en=async(t,e)=>{const s=await is(t,{dataDirectory:Ce(t)});if(!s){e.warn(`No previous run recorded yet. Run a task at least once to populate ${os(t,{dataDirectory:Ce(t)})}.`);return}const r=(s.duration/1e3).toFixed(2);if(e.info(""),e.info(`Last run — ${s.startTime} (${r}s)`),e.info(""),e.info(` Total: ${String(s.stats.total)}`),e.info(` Succeeded: ${String(s.stats.succeeded)}`),e.info(` Cached: ${String(s.stats.cached)}`),e.info(` Failed: ${String(s.stats.failed)}`),e.info(` Skipped: ${String(s.stats.skipped)}`),e.info(""),s.stats.failed>0){const o=s.tasks.filter(n=>n.exitCode!==void 0&&n.exitCode!==0);e.info("Failed tasks:");for(const n of o){const l=n.duration??0;e.info(` × ${n.taskId} (exit ${String(n.exitCode??-1)}, ${l}ms)`)}e.info("")}const i=[...s.tasks].filter(o=>typeof o.duration=="number").sort((o,n)=>(n.duration??0)-(o.duration??0)).slice(0,5);if(i.length>0){e.info("Slowest tasks:");for(const o of i)e.info(` ${o.taskId.padEnd(40)} ${String(o.duration??0).padStart(6)}ms [${o.cacheStatus}]`);e.info("")}},tn=t=>{if(!(t===void 0||t==="")){if(t!=="read"&&t!=="write"&&t!=="readwrite")throw new Error(`--cache-mode must be one of: read, write, readwrite (received "${t}")`);return t}},sn=t=>{if(!(t===void 0||t==="")){if(t!=="http"&&t!=="reapi")throw new Error(`--cache-backend must be one of: http, reapi (received "${t}")`);return t}},rn=t=>{if(!(t===void 0||t==="")){if(t!=="declared"&&t!=="trace")throw new Error(`--hash-mode must be one of: declared, trace (received "${t}")`);return t}},nn=({interactive:t,taskPty:e,workspacePty:s})=>e===!0?!0:e===!1?!1:t&&s!==!1,on=t=>`'${t.replaceAll("'",String.raw`'\''`)}'`,Ue=t=>process.platform==="win32"?t.length>0&&!/[\s"&|<>^()%!]/.test(t)?t:`"${t.replaceAll('"','""')}"`:on(t),cn=(t,e,s)=>{if(!e||e.length===0||s===!1||s===void 0)return t;if(s==="args"||s==="both"){const r=e.map(i=>Ue(i)).join(" ");return`${t} ${r}`}return t},Dt="visForwardedArgs",an=(t,e)=>{const s=e.overrides[Dt];if(!Array.isArray(s)||s.length===0)return t;const r=s.map(i=>Ue(i)).join(" ");return`${t} ${r}`},ze=(t,e,s)=>{const r=t.overrides.command;if(!r)return;const i=je(t),o=t.segment!==void 0&&t.segment.index<t.segment.count,n=o?r:an(r,t),l=o?n:cn(n,e,i?.affectedFiles),d=$t(i,s),h=i?.shellArgs,f=h&&h.length>0?h.join(" "):"-c";return d?`${d} ${f} ${Ue(l)}`:l},ln=2e3,Bt=async(t,e,s)=>{const{workspaceRoot:r}=e,i=t.map(g=>{const k=ze(g,e.affectedFiles,Ct());if(!k)return;const P=g.overrides.visOptions,C=He(r,g.projectRoot,!!P?.runFromWorkspaceRoot),y=nn({interactive:!!s,taskPty:g.pty,workspacePty:P?.pty}),E=ke(e,g);return{command:k,cwd:C,env:E.env,inheritEnv:E.inheritEnv,name:g.id,...y?{ptySize:{cols:process.stdout.columns??80,rows:process.stdout.rows??24},stdin:"pty"}:{}}}).filter(g=>g!==void 0);if(i.length===0)return;if(!s){await $e(i,{killOthers:["failure"],onEvent:()=>{}});return}const{abortSignal:o,lifeCycle:n,stdinRegistry:l,store:d}=s,h=i.map(g=>t.find(k=>k.id===g.name)).filter(Boolean),f=g=>i[g]?.stdin==="pty",p=new Map,a=g=>{if(!f(g))return;let k=p.get(g);return k||(k=new We(Ie),p.set(g,k)),k};d.unmarkDone(),n.startTasks?.(h);const m=new Map,w=new Map;let j;const M=()=>{for(const g of w.values())try{g("SIGTERM")}catch{}j||(j=setTimeout(()=>{for(const g of w.values())try{g("SIGKILL")}catch{}w.clear()},2e3),j.unref?.())};let x;o&&(x=()=>{M()},o.then(()=>{x?.()}).catch(()=>{x?.()}));try{await $e(i,{killOthers:["failure"],onEvent:g=>{const k=h[g.index];if(k)switch(g.kind){case"close":{const P=m.get(k.id)??Date.now(),C=g.killed||g.exitCode===0?"success":"failure";n.endTasks?.([{code:g.exitCode??0,endTime:Date.now(),startTime:P,status:C,task:k,terminalOutput:d.getSnapshot().outputs.get(k.id)??""}]),w.delete(g.index),l?.delete(k.id);break}case"error":{if(g.message){const P=a(g.index);P?(P.write(`${g.message}
|
|
3
3
|
`),d.setOutput(k.id,P.toString())):d.addOutput(k.id,`${g.message}
|
|
4
4
|
`)}break}case"started":{m.set(k.id,Date.now()),g.kill&&w.set(g.index,g.kill),g.write&&l&&l.set(k.id,{kill:g.kill,resize:g.resize,write:g.write});break}case"stderr":case"stdout":{if(g.text){const P=a(g.index);P?(P.write(g.text),d.setOutput(k.id,P.toString())):d.addOutput(k.id,`${g.text}
|
|
5
|
-
`)}break}default:}}})}finally{j&&(clearTimeout(j),j=void 0),d.markDone()}},it=t=>{try{return process.kill(-t,0),!0}catch{try{return process.kill(t,0),!0}catch{return!1}}},dn=t=>{Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,t)},un=t=>{const{extraPids:e=[],pidFiles:s,runDir:r}=t,i=[],o=n=>{try{process.kill(-n,"SIGTERM")}catch{try{process.kill(n,"SIGTERM")}catch{}}};for(const n of s){let l;try{const d=Ls(n),h=Number.parseInt(d.trim(),10);l=Number.isFinite(h)&&h>0?h:void 0}catch{continue}l!==void 0&&(i.push(l),o(l))}for(const n of e)!Number.isFinite(n)||n<=0||(i.push(n),o(n));if(i.length>0){const d=Date.now()+1500;for(;Date.now()<d;){let h=!0;for(const f of i)if(it(f)){h=!1;break}if(h)break;dn(100)}for(const h of i)if(it(h))try{process.kill(-h,"SIGKILL")}catch{try{process.kill(h,"SIGKILL")}catch{}}}r&&zs(r)},fn=({ephemeralPidFiles:t,registryStartedIds:e,registryStartedPids:s,serviceEventBridge:r,serviceRunDir:i,stopServicesOnExit:o,workspaceRoot:n})=>{let l=!1;const d=()=>{if(l)return;l=!0,r&&r.dispose().catch(()=>{});const p=o?[...s.values()]:void 0;un({extraPids:p,pidFiles:t,runDir:i})},h=()=>{d()},f=t.length>0||i!==void 0||o&&e.length>0;return{finish:async()=>{d(),f&&(process.off("SIGINT",h),process.off("SIGTERM",h)),o&&e.length>0&&await Promise.all(e.map(async p=>{try{await $s(n,p)}catch{}}))},install:()=>{f&&(process.on("SIGINT",h),process.on("SIGTERM",h))}}},hn=({config:t,logger:e,persistentTasks:s,taskGraph:r})=>{const i=Object.keys(r.tasks).length,o=r.roots.length;e.info(`Execution plan (${String(i)} task(s), ${String(o)} root(s)):`),e.info("");const n=new Set,l=(d,h)=>{if(n.has(d))return;n.add(d);for(const j of r.dependencies[d]??[])l(j,h+1);const f=r.tasks[d],p=" ".repeat(h+1),a=f?.segment?` (segment ${String(f.segment.index)}/${String(f.segment.count)}: ${String(f.overrides.command)})`:"",m=f?.hashMode==="trace"||t.taskRunner?.autoFingerprint===!0,w=`${f?.cache===!1?" (no-cache)":""}${m?" (trace)":""}${a}`;e.info(`${p}${d}${w}`)};for(const d of r.roots)l(d,0);for(const d of Object.keys(r.tasks))l(d,0);s.length>0&&(e.info(""),e.info(` + ${String(s.length)} persistent task(s) (run after graph completes)`)),e.info("")},pn=(t,e)=>{if(t===e)return!0;if(!t||!e||t.length!==e.length)return!1;for(const[s,r]of t.entries())if(!Object.is(r,e[s]))return!1;return!0},ot=({children:t,deps:e,onRender:s,style:r,width:i})=>{const o=V.useRef(null),n=V.useRef(!1),l=V.useRef(e),d=V.useRef(t),h=V.useRef(s);h.current=s;let f=!1;e!==void 0?pn(l.current,e)||(f=!0,l.current=e):t!==d.current&&(f=!0,d.current=t),f&&(n.current=!1,o.current&&(o.current.cachedRender=void 0)),V.useLayoutEffect(()=>{const a=o.current;a&&(a.internal_onRendered=()=>{n.current=!0,h.current?.(a)})}),V.useEffect(()=>()=>{const a=o.current;a&&(a.cachedRender=void 0,a.internal_onRendered=void 0)},[]);const p=V.useMemo(()=>({...r,width:i}),[r,i]);return c.jsx("ink-static-render",{ref:o,style:p,children:n.current?null:t()})},mn=t=>Array.isArray(t)?`[${t.join(",")}]`:typeof t=="object"&&t!==null?JSON.stringify(t):String(t),gn=(t,e,s)=>e==="_"?`${t}${Array.isArray(s)?s.join(" "):String(s)}`:`${t}--${e}=${mn(s)}`,Ye=(t,e,s)=>{const r=new Set(new Set(s.map(a=>a.target.target))),i=new Set(new Set(s.map(a=>a.target.project))),o=e.filter(a=>r.has(a)),n=t.filter(a=>i.has(a)),l=s.length-n.length*o.length,d=o.length===1?"target":"targets",h=o.join(", "),f=n.length===1?`project ${n[0]}`:`${n.length} projects`;let p=`${d} ${h} for ${f}`;return l>0&&(p+=` and ${l} ${l===1?"task":"tasks"} ${l===1?"it depends":"they depend"} on`),p},wn={error:"red",info:"white",success:"green"},_e=({children:t,title:e,variant:s})=>{const r=wn[s];return c.jsxs(v,{flexDirection:"column",children:[c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,inverse:!0,children:" VIS "}),c.jsx(u,{bold:!0,color:r,children:"•"}),c.jsx(u,{children:e})]}),t]})},_t=({cached:t,failed:e,failedIds:s,projectNames:r,retriedIds:i,skippedIds:o,succeeded:n,targets:l,tasks:d,took:h})=>{const f=Ye(r,l,d),p=i??[];if(e===0&&(!o||o.length===0)){const a=t>0?` (${t} read from cache)`:"";return c.jsx(ot,{children:()=>c.jsx(_e,{title:`Successfully ran ${f}`,variant:"success",children:c.jsxs(v,{flexDirection:"column",marginTop:1,paddingLeft:3,children:[c.jsxs(u,{children:[c.jsx(u,{color:"green",children:Et})," ",n+t," tasks completed",a?c.jsx(u,{dimColor:!0,children:a}):null,c.jsx(u,{dimColor:!0,children:` · Took ${h}`})]}),p.length>0&&c.jsxs(v,{flexDirection:"column",marginTop:1,children:[c.jsxs(u,{children:[c.jsx(u,{color:"yellow",children:"↻"})," ",c.jsx(u,{color:"yellow",children:String(p.length)})," task",p.length===1?"":"s"," succeeded after retry:"]}),p.map(m=>c.jsxs(u,{children:[" ",c.jsx(u,{color:"yellow",children:"↻"})," ",m]},m))]})]})})})}return c.jsx(ot,{children:()=>c.jsx(_e,{title:`Ran ${f}`,variant:"error",children:c.jsxs(v,{flexDirection:"column",marginTop:1,paddingLeft:3,children:[o&&o.length>0&&c.jsxs(v,{flexDirection:"column",children:[c.jsxs(u,{dimColor:!0,children:[o.length," ","task",o.length===1?"":"s"," ","skipped (dependency failed or --bail)"]}),o.map(a=>c.jsxs(u,{dimColor:!0,children:[" - ",a]},a)),c.jsx(u,{})]}),e>0&&c.jsxs(v,{flexDirection:"column",children:[c.jsxs(u,{children:[c.jsx(u,{color:"red",children:String(e)})," ","task",e===1?"":"s"," ","failed:"]}),s.map(a=>c.jsxs(u,{children:[" ",c.jsx(u,{color:"red",children:Rt})," ",a]},a)),c.jsx(u,{})]}),p.length>0&&c.jsxs(v,{flexDirection:"column",children:[c.jsxs(u,{children:[c.jsx(u,{color:"yellow",children:String(p.length)})," ","task",p.length===1?"":"s"," ","finished after retry:"]}),p.map(a=>c.jsxs(u,{children:[" ",c.jsx(u,{color:"yellow",children:"↻"})," ",a]},a)),c.jsx(u,{})]}),c.jsx(u,{dimColor:!0,children:` Took ${h}`})]})})})};class Ee{#e;#r=new Set;#s=new Map;constructor(e,s){this.#e={autoExitCountdown:null,cached:0,completed:0,done:!1,endTime:null,failed:0,filterActive:!1,filterText:"",focusedPanel:"tasks",interactiveMode:!1,outputs:new Map,pinnedTaskIds:[null,null],rerunRequested:!1,retriedIds:[],retryTaskId:null,rows:e.map(r=>({persistent:!!r.overrides.visOptions?.persistent,status:"pending",taskId:r.id})),running:0,selectedIndex:0,startTime:Date.now(),statusFilter:"all",succeeded:0,totalTasks:s??e.length,viewMode:"list"}}getSnapshot=()=>this.#e;subscribe=e=>(this.#r.add(e),()=>{this.#r.delete(e)});startTasks(e){const s=[...this.#e.rows];for(const r of e){const i=s.findIndex(o=>o.taskId===r.id);i!==-1&&(s[i]={...s[i],elapsed:0,status:"running"},this.#s.set(r.id,process.hrtime()))}this.#t({...this.#e,rows:s,running:this.#e.running+e.length})}endTasks(e){const s=[...this.#e.rows];let{cached:r,completed:i,failed:o,succeeded:n}=this.#e;const l=new Map(this.#e.outputs),d=[...this.#e.retriedIds];for(const p of e){const a=s.findIndex(m=>m.taskId===p.task.id);switch(a!==-1&&(s[a]={...s[a],duration:p.startTime&&p.endTime?p.endTime-p.startTime:void 0,retryAttempts:p.retryAttempts,status:p.status}),p.retryAttempts&&p.retryAttempts>0&&d.push(p.task.id),i++,p.status){case"failure":{o++;break}case"local-cache":case"local-cache-kept-existing":case"remote-cache":{r++;break}case"success":{n++;break}}p.terminalOutput&&!l.has(p.task.id)&&l.set(p.task.id,p.terminalOutput),this.#s.delete(p.task.id)}let{selectedIndex:h}=this.#e;if(o>this.#e.failed){const p=s.findIndex(a=>a.status==="failure");p!==-1&&(h=p)}const f=Math.max(0,this.#e.running-e.length);this.#t({...this.#e,cached:r,completed:i,failed:o,outputs:l,retriedIds:d,rows:s,running:f,selectedIndex:h,succeeded:n})}static#n=256*1024;addOutput(e,s){if(!s.trim())return;let r=(this.#e.outputs.get(e)??"")+s;r.length>Ee.#n&&(r=r.slice(-Ee.#n)),this.#e.outputs.set(e,r),this.#t({...this.#e})}setOutput(e,s){this.#e.outputs.set(e,s),this.#t({...this.#e})}markDone(){this.#t({...this.#e,done:!0,endTime:Date.now()})}unmarkDone(){this.#t({...this.#e,autoExitCountdown:null,done:!1,endTime:null})}tick(){if(this.#s.size===0)return;let e=!1;const s=[...this.#e.rows];for(let r=0;r<s.length;r++){const i=s[r];if(i.status==="running"){const o=this.#s.get(i.taskId);if(o){const n=process.hrtime(o),l=n[0]*1e3+n[1]/1e6;s[r]={...i,elapsed:l},e=!0}}}e&&this.#t({...this.#e,rows:s})}setSelectedIndex(e){e!==this.#e.selectedIndex&&this.#t({...this.#e,selectedIndex:e})}setFocusedPanel(e){e!==this.#e.focusedPanel&&this.#t({...this.#e,focusedPanel:e})}setFilter(e){this.#t({...this.#e,filterText:e,selectedIndex:0})}setFilterActive(e){e!==this.#e.filterActive&&this.#t({...this.#e,filterActive:e,filterText:e?this.#e.filterText:"",selectedIndex:0})}pinTask(e,s){const r=[...this.#e.pinnedTaskIds];r[e]=s,this.#t({...this.#e,pinnedTaskIds:r})}clearPins(){this.#t({...this.#e,pinnedTaskIds:[null,null]})}requestRetry(e){const s=[...this.#e.rows],r=s.findIndex(l=>l.taskId===e);let{completed:i,failed:o,succeeded:n}=this.#e;if(r!==-1){const l=s[r].status;l==="failure"?(o=Math.max(0,o-1),i=Math.max(0,i-1)):l==="success"&&(n=Math.max(0,n-1),i=Math.max(0,i-1)),s[r]={...s[r],elapsed:0,retryAttempts:void 0,status:"running"},this.#s.set(e,process.hrtime())}this.#t({...this.#e,completed:i,done:!1,endTime:null,failed:o,interactiveMode:!1,retriedIds:this.#e.retriedIds.filter(l=>l!==e),retryTaskId:e,rows:s,succeeded:n})}acknowledgeRetry(){const e=this.#e.retryTaskId;return e&&this.#t({...this.#e,retryTaskId:null}),e}setInteractiveMode(e){e!==this.#e.interactiveMode&&this.#t({...this.#e,interactiveMode:e})}setViewMode(e){e!==this.#e.viewMode&&this.#t({...this.#e,viewMode:e})}setStatusFilter(e){this.#t({...this.#e,selectedIndex:0,statusFilter:e})}requestRerun(){this.#s.clear(),this.#t({...this.#e,autoExitCountdown:null,cached:0,completed:0,done:!1,endTime:null,failed:0,interactiveMode:!1,outputs:new Map,rerunRequested:!0,retriedIds:[],rows:this.#e.rows.map(e=>({persistent:e.persistent,status:"pending",taskId:e.taskId})),running:0,startTime:Date.now(),succeeded:0,viewMode:"list"})}acknowledgeRerun(){this.#e.rerunRequested&&this.#t({...this.#e,rerunRequested:!1})}#t(e){this.#e=e;for(const s of this.#r)try{s()}catch{}}}const vn=27,yn={95:"apc",80:"dcs",94:"pm",88:"sos"},xn={159:"apc",144:"dcs",158:"pm",152:"sos"},Nt=t=>t===155||t===157||t===144||t===152||t===158||t===159,Gt=(t,e)=>{for(let s=e;s<t.length;s+=1){const r=t.codePointAt(s);if(r>=64&&r<=126)return s}return-1},Re=(t,e,s)=>{for(let r=e;r<t.length;r+=1){const i=t.codePointAt(r);if(i===156||s&&i===7)return r;if(i===27&&t.codePointAt(r+1)===92)return r+1}return-1},jn=(t,e)=>{const s=t.codePointAt(e+1);if(s===91){const r=Gt(t,e+2);return r===-1?void 0:{end:r,kind:"csi"}}if(s===93){const r=Re(t,e+2,!0);return r===-1?void 0:{end:r,kind:"osc"}}if(s===80||s===88||s===94||s===95){const r=Re(t,e+2,!1),i=yn[s];return r===-1?void 0:{end:r,kind:i}}return s===void 0?void 0:{end:e+1,kind:"escape"}},Sn=(t,e)=>{const s=t.codePointAt(e);if(s===155){const r=Gt(t,e+1);return r===-1?void 0:{end:r,kind:"csi"}}if(s===157){const r=Re(t,e+1,!0);return r===-1?void 0:{end:r,kind:"osc"}}if(s===144||s===152||s===158||s===159){const r=Re(t,e+1,!1),i=xn[s];return r===-1?void 0:{end:r,kind:i}}},kn=t=>{if(t.includes(String.fromCodePoint(27)))return!0;for(let e=0;e<t.length;e+=1)if(Nt(t.codePointAt(e)))return!0;return!1},bn=t=>{if(!kn(t))return t;let e="",s=0,r=0;const{length:i}=t;for(;r<i;){const o=t.codePointAt(r);let n;if(o===vn)n=jn(t,r);else if(Nt(o))n=Sn(t,r);else{r+=1;continue}const l=n===void 0?i-1:n.end;e+=t.slice(s,r),s=l+1,r=l+1}return e+=t.slice(s),e},Tn=t=>bn(t),$n=/^(?<name>(?:[A-Z][\w$]*)?(?:Error|Exception))(?::[ \t](?<message>.*))?$/,Cn=/^\s*at\s+/,In=t=>{const e=t.split(`
|
|
5
|
+
`)}break}default:}}})}finally{j&&(clearTimeout(j),j=void 0),d.markDone()}},it=t=>{try{return process.kill(-t,0),!0}catch{try{return process.kill(t,0),!0}catch{return!1}}},dn=t=>{Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,t)},un=t=>{const{extraPids:e=[],pidFiles:s,runDir:r}=t,i=[],o=n=>{try{process.kill(-n,"SIGTERM")}catch{try{process.kill(n,"SIGTERM")}catch{}}};for(const n of s){let l;try{const d=Ls(n),h=Number.parseInt(d.trim(),10);l=Number.isFinite(h)&&h>0?h:void 0}catch{continue}l!==void 0&&(i.push(l),o(l))}for(const n of e)!Number.isFinite(n)||n<=0||(i.push(n),o(n));if(i.length>0){const d=Date.now()+1500;for(;Date.now()<d;){let h=!0;for(const f of i)if(it(f)){h=!1;break}if(h)break;dn(100)}for(const h of i)if(it(h))try{process.kill(-h,"SIGKILL")}catch{try{process.kill(h,"SIGKILL")}catch{}}}r&&zs(r)},fn=({ephemeralPidFiles:t,registryStartedIds:e,registryStartedPids:s,serviceEventBridge:r,serviceRunDir:i,stopServicesOnExit:o,workspaceRoot:n})=>{let l=!1;const d=()=>{if(l)return;l=!0,r&&r.dispose().catch(()=>{});const p=o?[...s.values()]:void 0;un({extraPids:p,pidFiles:t,runDir:i})},h=()=>{d()},f=t.length>0||i!==void 0||o&&e.length>0;return{finish:async()=>{d(),f&&(process.off("SIGINT",h),process.off("SIGTERM",h)),o&&e.length>0&&await Promise.all(e.map(async p=>{try{await $s(n,p)}catch{}}))},install:()=>{f&&(process.on("SIGINT",h),process.on("SIGTERM",h))}}},hn=({config:t,logger:e,persistentTasks:s,taskGraph:r})=>{const i=Object.keys(r.tasks).length,o=r.roots.length;e.info(`Execution plan (${String(i)} task(s), ${String(o)} root(s)):`),e.info("");const n=new Set,l=(d,h)=>{if(n.has(d))return;n.add(d);for(const j of r.dependencies[d]??[])l(j,h+1);const f=r.tasks[d],p=" ".repeat(h+1),a=f?.segment?` (segment ${String(f.segment.index)}/${String(f.segment.count)}: ${String(f.overrides.command)})`:"",m=f?.hashMode==="trace"||t.taskRunner?.autoFingerprint===!0,w=`${f?.cache===!1?" (no-cache)":""}${m?" (trace)":""}${a}`;e.info(`${p}${d}${w}`)};for(const d of r.roots)l(d,0);for(const d of Object.keys(r.tasks))l(d,0);s.length>0&&(e.info(""),e.info(` + ${String(s.length)} persistent task(s) (run after graph completes)`)),e.info("")},pn=(t,e)=>{if(t===e)return!0;if(!t||!e||t.length!==e.length)return!1;for(const[s,r]of t.entries())if(!Object.is(r,e[s]))return!1;return!0},ot=({children:t,deps:e,onRender:s,style:r,width:i})=>{const o=U.useRef(null),n=U.useRef(!1),l=U.useRef(e),d=U.useRef(t),h=U.useRef(s);h.current=s;let f=!1;e!==void 0?pn(l.current,e)||(f=!0,l.current=e):t!==d.current&&(f=!0,d.current=t),f&&(n.current=!1,o.current&&(o.current.cachedRender=void 0)),U.useLayoutEffect(()=>{const a=o.current;a&&(a.internal_onRendered=()=>{n.current=!0,h.current?.(a)})}),U.useEffect(()=>()=>{const a=o.current;a&&(a.cachedRender=void 0,a.internal_onRendered=void 0)},[]);const p=U.useMemo(()=>({...r,width:i}),[r,i]);return c.jsx("ink-static-render",{ref:o,style:p,children:n.current?null:t()})},mn=t=>Array.isArray(t)?`[${t.join(",")}]`:typeof t=="object"&&t!==null?JSON.stringify(t):String(t),gn=(t,e,s)=>e==="_"?`${t}${Array.isArray(s)?s.join(" "):String(s)}`:`${t}--${e}=${mn(s)}`,Ye=(t,e,s)=>{const r=new Set(new Set(s.map(a=>a.target.target))),i=new Set(new Set(s.map(a=>a.target.project))),o=e.filter(a=>r.has(a)),n=t.filter(a=>i.has(a)),l=s.length-n.length*o.length,d=o.length===1?"target":"targets",h=o.join(", "),f=n.length===1?`project ${n[0]}`:`${n.length} projects`;let p=`${d} ${h} for ${f}`;return l>0&&(p+=` and ${l} ${l===1?"task":"tasks"} ${l===1?"it depends":"they depend"} on`),p},wn={error:"red",info:"white",success:"green"},_e=({children:t,title:e,variant:s})=>{const r=wn[s];return c.jsxs(v,{flexDirection:"column",children:[c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,inverse:!0,children:" VIS "}),c.jsx(u,{bold:!0,color:r,children:"•"}),c.jsx(u,{children:e})]}),t]})},_t=({cached:t,failed:e,failedIds:s,projectNames:r,retriedIds:i,skippedIds:o,succeeded:n,targets:l,tasks:d,took:h})=>{const f=Ye(r,l,d),p=i??[];if(e===0&&(!o||o.length===0)){const a=t>0?` (${t} read from cache)`:"";return c.jsx(ot,{children:()=>c.jsx(_e,{title:`Successfully ran ${f}`,variant:"success",children:c.jsxs(v,{flexDirection:"column",marginTop:1,paddingLeft:3,children:[c.jsxs(u,{children:[c.jsx(u,{color:"green",children:Et})," ",n+t," tasks completed",a?c.jsx(u,{dimColor:!0,children:a}):null,c.jsx(u,{dimColor:!0,children:` · Took ${h}`})]}),p.length>0&&c.jsxs(v,{flexDirection:"column",marginTop:1,children:[c.jsxs(u,{children:[c.jsx(u,{color:"yellow",children:"↻"})," ",c.jsx(u,{color:"yellow",children:String(p.length)})," task",p.length===1?"":"s"," succeeded after retry:"]}),p.map(m=>c.jsxs(u,{children:[" ",c.jsx(u,{color:"yellow",children:"↻"})," ",m]},m))]})]})})})}return c.jsx(ot,{children:()=>c.jsx(_e,{title:`Ran ${f}`,variant:"error",children:c.jsxs(v,{flexDirection:"column",marginTop:1,paddingLeft:3,children:[o&&o.length>0&&c.jsxs(v,{flexDirection:"column",children:[c.jsxs(u,{dimColor:!0,children:[o.length," ","task",o.length===1?"":"s"," ","skipped (dependency failed or --bail)"]}),o.map(a=>c.jsxs(u,{dimColor:!0,children:[" - ",a]},a)),c.jsx(u,{})]}),e>0&&c.jsxs(v,{flexDirection:"column",children:[c.jsxs(u,{children:[c.jsx(u,{color:"red",children:String(e)})," ","task",e===1?"":"s"," ","failed:"]}),s.map(a=>c.jsxs(u,{children:[" ",c.jsx(u,{color:"red",children:Rt})," ",a]},a)),c.jsx(u,{})]}),p.length>0&&c.jsxs(v,{flexDirection:"column",children:[c.jsxs(u,{children:[c.jsx(u,{color:"yellow",children:String(p.length)})," ","task",p.length===1?"":"s"," ","finished after retry:"]}),p.map(a=>c.jsxs(u,{children:[" ",c.jsx(u,{color:"yellow",children:"↻"})," ",a]},a)),c.jsx(u,{})]}),c.jsx(u,{dimColor:!0,children:` Took ${h}`})]})})})};class Ee{#e;#r=new Set;#s=new Map;constructor(e,s){this.#e={autoExitCountdown:null,cached:0,completed:0,done:!1,endTime:null,failed:0,filterActive:!1,filterText:"",focusedPanel:"tasks",interactiveMode:!1,outputs:new Map,pinnedTaskIds:[null,null],rerunRequested:!1,retriedIds:[],retryTaskId:null,rows:e.map(r=>({persistent:!!r.overrides.visOptions?.persistent,status:"pending",taskId:r.id})),running:0,selectedIndex:0,startTime:Date.now(),statusFilter:"all",succeeded:0,totalTasks:s??e.length,viewMode:"list"}}getSnapshot=()=>this.#e;subscribe=e=>(this.#r.add(e),()=>{this.#r.delete(e)});startTasks(e){const s=[...this.#e.rows];for(const r of e){const i=s.findIndex(o=>o.taskId===r.id);i!==-1&&(s[i]={...s[i],elapsed:0,status:"running"},this.#s.set(r.id,process.hrtime()))}this.#t({...this.#e,rows:s,running:this.#e.running+e.length})}endTasks(e){const s=[...this.#e.rows];let{cached:r,completed:i,failed:o,succeeded:n}=this.#e;const l=new Map(this.#e.outputs),d=[...this.#e.retriedIds];for(const p of e){const a=s.findIndex(m=>m.taskId===p.task.id);switch(a!==-1&&(s[a]={...s[a],duration:p.startTime&&p.endTime?p.endTime-p.startTime:void 0,retryAttempts:p.retryAttempts,status:p.status}),p.retryAttempts&&p.retryAttempts>0&&d.push(p.task.id),i++,p.status){case"failure":{o++;break}case"local-cache":case"local-cache-kept-existing":case"remote-cache":{r++;break}case"success":{n++;break}}p.terminalOutput&&!l.has(p.task.id)&&l.set(p.task.id,p.terminalOutput),this.#s.delete(p.task.id)}let{selectedIndex:h}=this.#e;if(o>this.#e.failed){const p=s.findIndex(a=>a.status==="failure");p!==-1&&(h=p)}const f=Math.max(0,this.#e.running-e.length);this.#t({...this.#e,cached:r,completed:i,failed:o,outputs:l,retriedIds:d,rows:s,running:f,selectedIndex:h,succeeded:n})}static#n=256*1024;addOutput(e,s){if(!s.trim())return;let r=(this.#e.outputs.get(e)??"")+s;r.length>Ee.#n&&(r=r.slice(-Ee.#n)),this.#e.outputs.set(e,r),this.#t({...this.#e})}setOutput(e,s){this.#e.outputs.set(e,s),this.#t({...this.#e})}markDone(){this.#t({...this.#e,done:!0,endTime:Date.now()})}unmarkDone(){this.#t({...this.#e,autoExitCountdown:null,done:!1,endTime:null})}tick(){if(this.#s.size===0)return;let e=!1;const s=[...this.#e.rows];for(let r=0;r<s.length;r++){const i=s[r];if(i.status==="running"){const o=this.#s.get(i.taskId);if(o){const n=process.hrtime(o),l=n[0]*1e3+n[1]/1e6;s[r]={...i,elapsed:l},e=!0}}}e&&this.#t({...this.#e,rows:s})}setSelectedIndex(e){e!==this.#e.selectedIndex&&this.#t({...this.#e,selectedIndex:e})}setFocusedPanel(e){e!==this.#e.focusedPanel&&this.#t({...this.#e,focusedPanel:e})}setFilter(e){this.#t({...this.#e,filterText:e,selectedIndex:0})}setFilterActive(e){e!==this.#e.filterActive&&this.#t({...this.#e,filterActive:e,filterText:e?this.#e.filterText:"",selectedIndex:0})}pinTask(e,s){const r=[...this.#e.pinnedTaskIds];r[e]=s,this.#t({...this.#e,pinnedTaskIds:r})}clearPins(){this.#t({...this.#e,pinnedTaskIds:[null,null]})}requestRetry(e){const s=[...this.#e.rows],r=s.findIndex(l=>l.taskId===e);let{completed:i,failed:o,succeeded:n}=this.#e;if(r!==-1){const l=s[r].status;l==="failure"?(o=Math.max(0,o-1),i=Math.max(0,i-1)):l==="success"&&(n=Math.max(0,n-1),i=Math.max(0,i-1)),s[r]={...s[r],elapsed:0,retryAttempts:void 0,status:"running"},this.#s.set(e,process.hrtime())}this.#t({...this.#e,completed:i,done:!1,endTime:null,failed:o,interactiveMode:!1,retriedIds:this.#e.retriedIds.filter(l=>l!==e),retryTaskId:e,rows:s,succeeded:n})}acknowledgeRetry(){const e=this.#e.retryTaskId;return e&&this.#t({...this.#e,retryTaskId:null}),e}setInteractiveMode(e){e!==this.#e.interactiveMode&&this.#t({...this.#e,interactiveMode:e})}setViewMode(e){e!==this.#e.viewMode&&this.#t({...this.#e,viewMode:e})}setStatusFilter(e){this.#t({...this.#e,selectedIndex:0,statusFilter:e})}requestRerun(){this.#s.clear(),this.#t({...this.#e,autoExitCountdown:null,cached:0,completed:0,done:!1,endTime:null,failed:0,interactiveMode:!1,outputs:new Map,rerunRequested:!0,retriedIds:[],rows:this.#e.rows.map(e=>({persistent:e.persistent,status:"pending",taskId:e.taskId})),running:0,startTime:Date.now(),succeeded:0,viewMode:"list"})}acknowledgeRerun(){this.#e.rerunRequested&&this.#t({...this.#e,rerunRequested:!1})}#t(e){this.#e=e;for(const s of this.#r)try{s()}catch{}}}const vn=27,yn={95:"apc",80:"dcs",94:"pm",88:"sos"},xn={159:"apc",144:"dcs",158:"pm",152:"sos"},Nt=t=>t===155||t===157||t===144||t===152||t===158||t===159,Gt=(t,e)=>{for(let s=e;s<t.length;s+=1){const r=t.codePointAt(s);if(r>=64&&r<=126)return s}return-1},Re=(t,e,s)=>{for(let r=e;r<t.length;r+=1){const i=t.codePointAt(r);if(i===156||s&&i===7)return r;if(i===27&&t.codePointAt(r+1)===92)return r+1}return-1},jn=(t,e)=>{const s=t.codePointAt(e+1);if(s===91){const r=Gt(t,e+2);return r===-1?void 0:{end:r,kind:"csi"}}if(s===93){const r=Re(t,e+2,!0);return r===-1?void 0:{end:r,kind:"osc"}}if(s===80||s===88||s===94||s===95){const r=Re(t,e+2,!1),i=yn[s];return r===-1?void 0:{end:r,kind:i}}return s===void 0?void 0:{end:e+1,kind:"escape"}},Sn=(t,e)=>{const s=t.codePointAt(e);if(s===155){const r=Gt(t,e+1);return r===-1?void 0:{end:r,kind:"csi"}}if(s===157){const r=Re(t,e+1,!0);return r===-1?void 0:{end:r,kind:"osc"}}if(s===144||s===152||s===158||s===159){const r=Re(t,e+1,!1),i=xn[s];return r===-1?void 0:{end:r,kind:i}}},kn=t=>{if(t.includes(String.fromCodePoint(27)))return!0;for(let e=0;e<t.length;e+=1)if(Nt(t.codePointAt(e)))return!0;return!1},bn=t=>{if(!kn(t))return t;let e="",s=0,r=0;const{length:i}=t;for(;r<i;){const o=t.codePointAt(r);let n;if(o===vn)n=jn(t,r);else if(Nt(o))n=Sn(t,r);else{r+=1;continue}const l=n===void 0?i-1:n.end;e+=t.slice(s,r),s=l+1,r=l+1}return e+=t.slice(s),e},Tn=t=>bn(t),$n=/^(?<name>(?:[A-Z][\w$]*)?(?:Error|Exception))(?::[ \t](?<message>.*))?$/,Cn=/^\s*at\s+/,In=t=>{const e=t.split(`
|
|
6
6
|
`);let s;for(let r=0;r<e.length;r++){const i=$n.exec(e[r].trim());if(!i)continue;const o=[];for(let n=r+1;n<e.length&&n<=r+200;n++){const l=e[n];if(Cn.test(l))o.push(l.trim());else{if(o.length>0)break;if(l.trim()!=="")break}}if(o.length>0){const n=i.groups?.name??"Error",l=i.groups?.message??"";s={message:l,name:n,stack:`${n}: ${l}
|
|
7
7
|
${o.map(d=>` ${d}`).join(`
|
|
8
8
|
`)}`}}}return s},Wt=t=>{if(t.startsWith("file://"))try{return pr(t)}catch{return t}return t},En=t=>!t.includes("node_modules")&&!t.startsWith("node:")&&!t.startsWith("internal/"),Rn=t=>{try{return jr(t)}catch{return}},Pn=(t,e)=>{if(!t.file||t.line===void 0)return;const s=Wt(t.file),r=ur(s)?s:Ze(e,s);if(!En(r)||!he(r))return;const i=Rn(r);if(i){const o=yr(i,{column:t.column===void 0?0:Math.max(0,t.column-1),line:t.line});if(o.source&&o.line!=null){const n=Ze(fr(r),o.source),d=xr(i,o.source)??(he(n)?we(n,"utf8"):void 0);if(d!==void 0)return{column:o.column==null?void 0:o.column+1,file:n,line:o.line,source:d}}}return{column:t.column,file:r,line:t.line,source:we(r,"utf8")}},ct=(t,e)=>{const s=hr(e,t);return s&&!s.startsWith("..")?s:t},Ht=(t,e)=>{if(!t?.trim())return t;try{const s=In(Tn(t));if(!s)return t;const r=new Error(s.message);r.name=s.name,r.stack=s.stack;const i=wr(r);if(i.length===0)return t;const o=e.color,n={dim:a=>o?et(a):a,head:a=>o?gr(Ae(a)):a,loc:a=>o?mr(a):a};let l,d;for(const a of i){const m=Pn(a,e.cwd);if(m){l=m,d=a;break}}const h=[n.head(`✖ ${s.name}${s.message?`: ${s.message}`:""}`)];if(l){const a=`${ct(l.file,e.cwd)}:${l.line}${l.column?`:${l.column}`:""}`;h.push(` ${n.loc(a)}`,""),h.push(vr(l.source,{start:{column:l.column,line:l.line}},{color:o?{gutter:et,marker:Ae,message:Ae}:void 0,linesAbove:2,linesBelow:3}))}const f=i.filter(a=>a!==d).slice(0,8).map(a=>{const m=a.methodName??"<anonymous>",w=a.file?`${ct(Wt(a.file),e.cwd)}${a.line?`:${a.line}`:""}`:"";return n.dim(` at ${m}${w?` (${w})`:""}`)});f.length>0&&h.push("",...f);const p=n.dim("─".repeat(40));return`${h.join(`
|
|
9
9
|
`)}
|
|
10
10
|
${p}
|
|
11
|
-
${t}`}catch{return t}},Mn={delimiter:" ",language:{d:()=>" d",future:"in %s",h:()=>" h",m:()=>" m",mo:()=>" mo",ms:()=>" ms",past:"%s ago",s:()=>" s",w:()=>" w",y:()=>" y"},largest:2,round:!0,spacer:"",units:["h","m","s","ms"]},me=t=>Jr(t,Mn),ge=t=>t==="local-cache"||t==="local-cache-kept-existing"||t==="remote-cache",ve=t=>{switch(t){case"failure":return{color:"red",icon:Rt};case"local-cache":case"local-cache-kept-existing":case"remote-cache":case"success":return{color:"green",icon:Et};case"skipped":return{color:"gray",icon:Fe};default:return{color:"gray",icon:"?"}}},xe=t=>{const{color:e,icon:s}=ve(t);return ce(
|
|
12
|
-
`,n=On(r);if(n==="github"){process.stdout.write(`::group::${xe(e)} ${t}${o}`),process.stdout.write(i+o),process.stdout.write(`::endgroup::${o}`);return}if(n==="gitlab"){const p=Math.floor(Date.now()/1e3),a=An(t),m=e==="failure"?"":"[collapsed=true]",w="\x1B[0K";process.stdout.write(`${w}section_start:${String(p)}:${a}${m}\r${w}${xe(e)} ${t}${o}`),process.stdout.write(i+o);const j=Math.floor(Date.now()/1e3);process.stdout.write(`${w}section_end:${String(j)}:${a}\r${w}${o}`);return}if(n==="buildkite"){const p=e==="failure"?"+++":"---";process.stdout.write(`${p} ${xe(e)} ${t}${o}`),process.stdout.write(i+o);return}if(n==="azure"){process.stdout.write(`##[group]${xe(e)} ${t}${o}`),process.stdout.write(i+o),process.stdout.write(`##[endgroup]${o}`);return}const l=process.stdout.columns||80,d=ce(
|
|
11
|
+
${t}`}catch{return t}},Mn={delimiter:" ",language:{d:()=>" d",future:"in %s",h:()=>" h",m:()=>" m",mo:()=>" mo",ms:()=>" ms",past:"%s ago",s:()=>" s",w:()=>" w",y:()=>" y"},largest:2,round:!0,spacer:"",units:["h","m","s","ms"]},me=t=>Jr(t,Mn),ge=t=>t==="local-cache"||t==="local-cache-kept-existing"||t==="remote-cache",ve=t=>{switch(t){case"failure":return{color:"red",icon:Rt};case"local-cache":case"local-cache-kept-existing":case"remote-cache":case"success":return{color:"green",icon:Et};case"skipped":return{color:"gray",icon:Fe};default:return{color:"gray",icon:"?"}}},xe=t=>{const{color:e,icon:s}=ve(t);return ce(K.createElement(u,{color:e},s),{columns:10}).trim()},Fn=t=>{const{color:e,icon:s}=ve(t);switch(t){case"local-cache":case"local-cache-kept-existing":case"remote-cache":return ce(K.createElement(u,null,K.createElement(u,{color:e},s)," ",K.createElement(u,{color:"cyan"},"[cache]")),{columns:30}).trim();case"skipped":return ce(K.createElement(u,null,K.createElement(u,{dimColor:!0},s)," ",K.createElement(u,{dimColor:!0},"[skipped]")),{columns:30}).trim();default:return ce(K.createElement(u,{color:e},s),{columns:10}).trim()}},On=t=>t==="azure"||t==="buildkite"||t==="github"||t==="gitlab"||t==="off"?t:process.env.GITHUB_ACTIONS==="true"?"github":process.env.GITLAB_CI==="true"?"gitlab":process.env.BUILDKITE==="true"?"buildkite":process.env.TF_BUILD?.toLowerCase()==="true"?"azure":"off",An=t=>{const e=t.replaceAll(/\W+/g,"_"),s=Sr("sha256").update(t).digest("hex").slice(0,6);return`${e}_${s}`},Ln=(t,e,s,r="auto")=>{const i=s.trim();if(!i)return;const o=`
|
|
12
|
+
`,n=On(r);if(n==="github"){process.stdout.write(`::group::${xe(e)} ${t}${o}`),process.stdout.write(i+o),process.stdout.write(`::endgroup::${o}`);return}if(n==="gitlab"){const p=Math.floor(Date.now()/1e3),a=An(t),m=e==="failure"?"":"[collapsed=true]",w="\x1B[0K";process.stdout.write(`${w}section_start:${String(p)}:${a}${m}\r${w}${xe(e)} ${t}${o}`),process.stdout.write(i+o);const j=Math.floor(Date.now()/1e3);process.stdout.write(`${w}section_end:${String(j)}:${a}\r${w}${o}`);return}if(n==="buildkite"){const p=e==="failure"?"+++":"---";process.stdout.write(`${p} ${xe(e)} ${t}${o}`),process.stdout.write(i+o);return}if(n==="azure"){process.stdout.write(`##[group]${xe(e)} ${t}${o}`),process.stdout.write(i+o),process.stdout.write(`##[endgroup]${o}`);return}const l=process.stdout.columns||80,d=ce(K.createElement(u,{dimColor:!0},Fe.repeat(l)),{columns:l}).trim(),h=Fn(e),f=ce(K.createElement(u,{bold:!0},t),{columns:l}).trim();process.stdout.write(`${d}${o}`),process.stdout.write(`${h} ${f}${o}`),process.stdout.write(i+o),process.stdout.write(`${d}${o}`)},Dn=t=>t==="running"?{color:"white",icon:"•"}:t==="pending"?{color:"gray",icon:"·"}:ve(t),Bn=({autoScroll:t,focused:e,interactiveMode:s,showFullscreenHint:r,statusValue:i,supportsInteractive:o,taskId:n})=>{if(!n)return;if(s)return"Esc cancel | Enter send";const l=t?"":" PAUSED (f resume)",d=o?" i INPUT":"";return e&&i==="running"&&r?`⏎ FULLSCREEN${d} f FOLLOW${l}`:e&&i==="running"?`f FOLLOW${d}${l}`:e&&r?`<enter> full screen${l}`:e?l||void 0:"<tab> or <enter> to focus"},at=({autoScroll:t=!0,duration:e,focused:s,interactiveMode:r,output:i,scrollRef:o,showFullscreenHint:n,status:l,supportsInteractive:d=!0,taskId:h})=>{const f=l??"pending",{icon:p}=Dn(f),a=s?"bold":"single",m=f==="failure"?"red":f==="success"||ge(f)?s?"green":"gray":f==="running"?s?"white":"cyan":s?"white":"gray",w=h?`${p} ${h}`:void 0,j=e===void 0?void 0:me(e),M=Bn({autoScroll:t,focused:s,interactiveMode:r??!1,showFullscreenHint:n??!1,statusValue:f,supportsInteractive:d,taskId:h});if(!h)return c.jsxs(v,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",paddingX:2,paddingY:1,children:[c.jsx(u,{dimColor:!0,children:"Select a task to view output"}),c.jsx(u,{dimColor:!0,children:"Press Enter or 1/2 to pin"})]});const x=[];if(i)for(const g of i.split(`
|
|
13
13
|
`))x.push(g.endsWith("\r")?g.slice(0,-1):g);return!i&&(f==="running"||f==="pending")?c.jsx(v,{borderBottomTitle:M,borderColor:m,borderStyle:a,borderTopRightTitle:j,borderTopTitle:w,flexDirection:"column",flexGrow:1,paddingX:2,paddingY:1,children:c.jsx(v,{alignItems:"center",flexGrow:1,justifyContent:"center",children:c.jsx(u,{dimColor:!0,children:"Waiting for task output…"})})}):c.jsxs(v,{borderBottomTitle:M,borderColor:r?"yellow":m,borderStyle:a,borderTopRightTitle:j,borderTopTitle:w,flexDirection:"column",flexGrow:1,children:[c.jsx(v,{flexGrow:1,flexShrink:1,paddingY:1,children:c.jsx(It,{flexGrow:1,followOutput:t,paddingX:2,ref:o,scrollbar:!0,scrollbarColor:"gray",scrollbarStyle:"block",children:c.jsx(u,{children:x.join(`
|
|
14
|
-
`)})})}),r&&c.jsx(v,{flexShrink:0,justifyContent:"center",paddingX:1,children:c.jsx(u,{bold:!0,color:"yellow",children:"INTERACTIVE | keystrokes forwarded to task | Esc to exit"})})]})},_n={crashed:"✖",failed:"✖",pending:"·",ready:"●",starting:"•"},qt=t=>t==="ready"?"green":t==="crashed"||t==="failed"?"red":t==="starting"?"cyan":"gray",Nn=({status:t})=>t==="starting"?c.jsx(u,{color:"cyan",children:c.jsx(Mt,{type:"dots"})}):c.jsx(u,{bold:!0,color:qt(t),children:_n[t]}),Gn=({active:t,focused:e,state:s})=>{const r=e&&t,i=r?">":" ",o=s.status==="ready"?s.port?`running, port ${String(s.port)}`:"running":s.status==="failed"||s.status==="crashed"?s.errorMessage??"exited":s.lastLine??"booting…";return c.jsxs(v,{flexDirection:"row",flexShrink:0,overflow:"hidden",children:[c.jsx(u,{children:i}),c.jsx(u,{children:" "}),c.jsx(v,{flexShrink:0,width:3,children:c.jsx(Nn,{status:s.status})}),c.jsx(v,{flexGrow:0,flexShrink:0,width:28,children:c.jsx(u,{bold:r,inverse:r,children:s.id})}),c.jsx(v,{flexGrow:1,flexShrink:1,overflow:"hidden",children:c.jsxs(u,{color:qt(s.status),dimColor:s.status!=="crashed"&&s.status!=="failed",wrap:"truncate-end",children:[" ",o]})})]})},Wn=({states:t})=>{const e=[];for(const r of t)r.status==="ready"&&e.push(r.id);const s=e.join(", ");return c.jsxs(v,{paddingX:1,children:[c.jsxs(u,{bold:!0,color:"green",children:["● ","Services"]}),c.jsxs(u,{children:[" ",String(e.length)," / ",String(t.length)," running"]}),s.length>0&&c.jsxs(u,{dimColor:!0,children:[" ",s]}),c.jsx(u,{dimColor:!0,children:" [Tab ↓]"})]})},Hn=({states:t})=>{const e=t.find(s=>s.status==="crashed"||s.status==="failed");return e?c.jsxs(v,{flexDirection:"column",paddingX:1,children:[c.jsxs(u,{bold:!0,color:"red",children:["✖ ","Service crashed:"," ",e.id]}),e.tailLines.slice(-3).map((s,r)=>c.jsxs(u,{color:"red",dimColor:!0,children:[" ",s]},`crash-${String(r)}`))]}):c.jsx(c.Fragment,{})},qn=({activeIndex:t,focused:e,store:s})=>{const r=
|
|
15
|
-
`):Y?a.outputs.get(Y)??"":"",te=V.useMemo(()=>U?.status==="failure"&&J?Ht(J,{color:!process.env.NO_COLOR,cwd:process.cwd()}):J,[U?.status,J]),re=g??Y,N=g?Q?.status==="crashed"||Q?.status==="failed"?"failure":"running":U?.status,z=Ye(r,l,d),H=a.done?`Completed ${z} (${me((a.endTime??Date.now())-a.startTime)})`:`Running ${z}...`,oe=a.done?a.failed>0?"error":"success":"running",ae=V.useCallback(I=>{R.current?.scrollTo(Math.max(0,I-2))},[]);if(V.useEffect(()=>{a.interactiveMode&&U?.status!=="running"&&n.setInteractiveMode(!1)},[a.interactiveMode,U?.status,n]),V.useEffect(()=>{if(!Y)return;let I=f;a.viewMode==="split"&&f>=pt?I=f-Math.floor(f*.4)-2:(a.viewMode==="split"||a.viewMode==="fullscreen")&&(I=f-2);const S=Math.max(1,p-4);o.get(Y)?.resize?.(I,S)},[f,p,a.viewMode,Y]),Je((I,S)=>{if(S.escape){n.setInteractiveMode(!1);return}if(!Y)return;const F=o.get(Y);if(!F){n.setInteractiveMode(!1);return}if(S.return)F.write("\r");else if(S.upArrow)F.write("\x1B[A");else if(S.downArrow)F.write("\x1B[B");else if(S.rightArrow)F.write("\x1B[C");else if(S.leftArrow)F.write("\x1B[D");else if(S.backspace)F.write("");else if(S.delete)F.write("\x1B[3~");else if(S.tab)F.write(" ");else if(S.home)F.write("\x1B[H");else if(S.end)F.write("\x1B[F");else if(S.pageUp)F.write("\x1B[5~");else if(S.pageDown)F.write("\x1B[6~");else if(S.ctrl&&I){const ee=I.toUpperCase().codePointAt(0);ee!==void 0&&ee>=65&&ee<=90&&F.write(String.fromCodePoint(ee-64))}else I&&F.write(I)},{isActive:a.interactiveMode}),Je((I,S)=>{if(I==="c"&&S.ctrl){h();return}if(!O){if(C){S.escape||I==="?"?y(!1):I==="q"?(y(!1),T(!0)):S.downArrow||I==="j"?E.current?.scrollBy(1):S.upArrow||I==="k"?E.current?.scrollBy(-1):S.pageDown?E.current?.scrollBy(5):S.pageUp?E.current?.scrollBy(-5):S.home?E.current?.scrollToTop():S.end&&E.current?.scrollToBottom();return}if(I==="?"){y(!0);return}if(I==="q"){T(!0);return}if(I==="r"&&a.done){n.requestRerun();return}if(I==="R"&&a.done){const F=W[a.selectedIndex];F?.status==="failure"&&n.requestRetry(F.taskId);return}if(I==="F"&&!a.filterActive){const F=["all","failed","running","passed"],ee=F.indexOf(a.statusFilter);n.setStatusFilter(F[(ee+1)%F.length]);return}if(a.filterActive){if(S.escape){n.setFilterActive(!1);return}if(S.return){n.setFilterActive(!1);return}if(S.backspace){n.setFilter(a.filterText.slice(0,-1));return}if(I&&!S.ctrl&&!S.meta){n.setFilter(a.filterText+I);return}return}if(I==="i"&&U?.status==="running"&&(a.viewMode==="fullscreen"||a.viewMode==="split"&&a.focusedPanel==="output")){n.setInteractiveMode(!0);return}if(a.viewMode==="fullscreen"){if(S.escape){n.setViewMode("split"),A("split");return}if(I==="f"){const F=!b;_(F),F&&$.current?.scrollToBottom();return}if(S.downArrow||I==="j"){_(!1),$.current?.scrollBy(1);return}if(S.upArrow||I==="k"){_(!1),$.current?.scrollBy(-1);return}if(S.pageDown||S.ctrl&&I==="d"){_(!1),$.current?.scrollBy(12);return}if(S.pageUp||S.ctrl&&I==="u"){_(!1),$.current?.scrollBy(-12);return}if(S.home){_(!1),$.current?.scrollToTop();return}if(S.end){_(!0),$.current?.scrollToBottom();return}return}if(a.focusedPanel==="dock"&&j&&i){if(S.tab){k(null),n.setFocusedPanel("tasks");return}if(S.escape){n.setFocusedPanel("tasks"),k(null),a.viewMode==="split"&&(n.setViewMode("list"),A("list"));return}if(S.downArrow||I==="j"){x(F=>Math.min(F+1,w.length-1));return}if(S.upArrow||I==="k"){x(F=>Math.max(F-1,0));return}if(S.return){const F=w[M];F&&(k(F),_(!0),G(),D.current.splitList=0,D.current.splitOutput=0,n.setViewMode("split"),n.setFocusedPanel("output"),A("split"));return}if((I==="r"||I==="R")&&e){const F=w[M],ee=F?i.getState(F)?.status:void 0;if(F&&(ee==="crashed"||ee==="failed")){const be=e(F);be instanceof Promise&&be.catch(()=>{})}return}return}if(a.viewMode==="split"){if(S.tab){a.focusedPanel==="tasks"?n.setFocusedPanel("output"):j?n.setFocusedPanel("dock"):(k(null),n.setFocusedPanel("tasks"));return}if(a.focusedPanel==="output"){if(S.escape){if(g&&j){k(null),n.setViewMode("list"),n.setFocusedPanel("dock"),A("list");return}k(null),n.setFocusedPanel("tasks");return}if(S.return){G(),n.setViewMode("fullscreen");return}if(I==="f"){const F=!b;_(F),F&&$.current?.scrollToBottom();return}if(S.downArrow||I==="j"){_(!1),$.current?.scrollBy(1);return}if(S.upArrow||I==="k"){_(!1),$.current?.scrollBy(-1);return}if(S.pageDown||S.ctrl&&I==="d"){_(!1),$.current?.scrollBy(12);return}if(S.pageUp||S.ctrl&&I==="u"){_(!1),$.current?.scrollBy(-12);return}if(S.home){_(!1),$.current?.scrollToTop();return}if(S.end){_(!0),$.current?.scrollToBottom();return}return}if(S.escape){n.setViewMode("list"),A("list");return}if(S.return){n.setFocusedPanel("output");return}}if(a.viewMode==="list"||a.viewMode==="split"&&a.focusedPanel==="tasks"){if(S.tab&&a.viewMode==="list"&&j){n.setFocusedPanel("dock");return}if(S.downArrow||I==="j"){const F=Math.min(a.selectedIndex+1,Math.max(0,W.length-1));n.setSelectedIndex(F),ae(F);return}if(S.upArrow||I==="k"){const F=Math.max(a.selectedIndex-1,0);n.setSelectedIndex(F),ae(F);return}if(S.return&&a.viewMode==="list"){_(!0),G(),D.current.splitList=0,D.current.splitOutput=0,n.setViewMode("split"),n.setFocusedPanel("output"),A("split");return}if(I==="/"){n.setFilterActive(!0);return}if(I==="1"&&B){n.pinTask(0,B);return}if(I==="2"&&B){n.pinTask(1,B);return}if(I==="0"){n.clearPins();return}S.escape&&a.filterText&&n.setFilter("")}}},{isActive:!a.interactiveMode}),f<ft||p<ht)return c.jsx(v,{alignItems:"center",height:p,justifyContent:"center",width:f,children:c.jsxs(u,{color:"yellow",children:["Terminal too small (",f,"x",p,"). Minimum:"," ",ft,"x",ht]})});const de=c.jsxs(v,{gap:1,children:[a.succeeded>0&&c.jsxs(u,{bold:!0,color:"green",children:["✓"," ",a.succeeded]}),a.cached>0&&c.jsxs(u,{dimColor:!0,children:["✓"," ",a.cached]}),a.failed>0&&c.jsxs(u,{bold:!0,color:"red",children:["✗"," ",a.failed]}),a.running>0&&c.jsxs(u,{color:"cyan",children:["◷"," ",a.running]}),c.jsxs(u,{dimColor:!0,children:[a.totalTasks," ","total"]}),a.statusFilter!=="all"&&c.jsxs(u,{color:"yellow",children:["[",a.statusFilter,"]"]})]});let K;if(a.viewMode==="fullscreen")K=[c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"Esc"}),c.jsx(u,{dimColor:!0,children:"BACK"})]},"esc"),c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"↑↓"}),c.jsx(u,{dimColor:!0,children:"SCROLL"})]},"scroll"),c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"^u ^d"}),c.jsx(u,{dimColor:!0,children:"PAGE"})]},"page"),...U?.status==="running"?[c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"i"}),c.jsx(u,{dimColor:!0,children:"INPUT"})]},"i")]:[],c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"q"}),c.jsx(u,{dimColor:!0,children:"QUIT"})]},"q")];else if(a.done){const I=W[a.selectedIndex]?.status==="failure";K=[c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"q"}),c.jsx(u,{dimColor:!0,children:"QUIT"})]},"q"),c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"r"}),c.jsx(u,{dimColor:!0,children:"RERUN"})]},"r"),...I?[c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"R"}),c.jsx(u,{dimColor:!0,children:"RETRY"})]},"R")]:[],c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"?"}),c.jsx(u,{dimColor:!0,children:"HELP"})]},"?"),c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"↑↓"}),c.jsx(u,{dimColor:!0,children:"NAV"})]},"nav"),c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"F"}),c.jsx(u,{dimColor:!0,children:"FILTER"})]},"F"),c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"⏎"}),c.jsx(u,{dimColor:!0,children:a.viewMode==="list"?"OUTPUT":"FULLSCREEN"})]},"enter")]}else a.viewMode==="split"&&a.focusedPanel==="output"?K=[c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"q"}),c.jsx(u,{dimColor:!0,children:"QUIT"})]},"q"),c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"Esc"}),c.jsx(u,{dimColor:!0,children:"BACK"})]},"esc"),c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"↑↓"}),c.jsx(u,{dimColor:!0,children:"SCROLL"})]},"scroll"),...U?.status==="running"?[c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"i"}),c.jsx(u,{dimColor:!0,children:"INPUT"})]},"i")]:[],c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"⏎"}),c.jsx(u,{dimColor:!0,children:"FULLSCREEN"})]},"enter"),c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"Tab"}),c.jsx(u,{dimColor:!0,children:"PANEL"})]},"tab"),c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"?"}),c.jsx(u,{dimColor:!0,children:"HELP"})]},"?")]:K=[c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"q"}),c.jsx(u,{dimColor:!0,children:"QUIT"})]},"q"),c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"?"}),c.jsx(u,{dimColor:!0,children:"HELP"})]},"?"),c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"↑↓"}),c.jsx(u,{dimColor:!0,children:"NAV"})]},"nav"),c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"/"}),c.jsx(u,{dimColor:!0,children:"FILTER"})]},"/"),c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"F"}),c.jsx(u,{dimColor:!0,children:"STATUS"})]},"F"),c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"⏎"}),c.jsx(u,{dimColor:!0,children:a.viewMode==="list"?"OUTPUT":"FULLSCREEN"})]},"enter"),...a.viewMode==="split"?[c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"Tab"}),c.jsx(u,{dimColor:!0,children:"PANEL"})]},"tab")]:[]];const Z=c.jsxs(v,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",flexShrink:0,justifyContent:"space-between",children:[c.jsx(v,{flexGrow:1,flexWrap:"wrap",gap:2,paddingX:1,children:K}),c.jsx(v,{flexShrink:0,paddingX:1,children:de})]}),se=c.jsxs(Xs,{backgroundColor:"#1e1e1e",footer:c.jsxs(u,{dimColor:!0,children:[c.jsx(u,{bold:!0,color:"white",children:"↑↓"})," ","scroll"," ",c.jsx(u,{bold:!0,color:"white",children:"?"}),"/",c.jsx(u,{bold:!0,color:"white",children:"Esc"})," ","close"]}),scrollRef:E,title:"KEYBOARD SHORTCUTS",visible:C,width:52,children:[c.jsxs(v,{flexDirection:"column",marginBottom:1,children:[c.jsxs(v,{marginBottom:1,children:[c.jsx(u,{dimColor:!0,children:"── "}),c.jsx(u,{bold:!0,color:"white",children:"NAVIGATION"})]}),c.jsxs(v,{children:[c.jsx(v,{width:24,children:c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","↑","/k"]}),c.jsx(u,{dimColor:!0,children:" Move up"})]})}),c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","↓","/j"]}),c.jsx(u,{dimColor:!0,children:" Move down"})]})]}),c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","Tab"]}),c.jsx(u,{dimColor:!0,children:" Switch panel (split)"})]}),c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","Esc"]}),c.jsx(u,{dimColor:!0,children:" Back / close"})]}),c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","Enter"]}),c.jsx(u,{dimColor:!0,children:" Show output / fullscreen"})]})]}),c.jsxs(v,{flexDirection:"column",marginBottom:1,children:[c.jsxs(v,{marginBottom:1,children:[c.jsx(u,{dimColor:!0,children:"── "}),c.jsx(u,{bold:!0,color:"white",children:"VIEWS"})]}),c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","Enter"]}),c.jsxs(u,{dimColor:!0,children:[" ","List"," ","→"," ","Split"," ","→"," ","Fullscreen"]})]}),c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","Esc"]}),c.jsxs(u,{dimColor:!0,children:[" ","Fullscreen"," ","→"," ","Split"," ","→"," ","List"]})]})]}),c.jsxs(v,{flexDirection:"column",marginBottom:1,children:[c.jsxs(v,{marginBottom:1,children:[c.jsx(u,{dimColor:!0,children:"── "}),c.jsx(u,{bold:!0,color:"white",children:"ACTIONS"})]}),c.jsxs(v,{children:[c.jsx(v,{width:24,children:c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","/"]}),c.jsx(u,{dimColor:!0,children:" Filter by text"})]})}),c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","F"]}),c.jsx(u,{dimColor:!0,children:" Filter by status"})]})]}),c.jsxs(v,{children:[c.jsx(v,{width:24,children:c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","1"]}),c.jsx(u,{dimColor:!0,children:"/"}),c.jsx(u,{bold:!0,color:"white",children:"2"}),c.jsx(u,{dimColor:!0,children:" Pin to output pane"})]})}),c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","0"]}),c.jsx(u,{dimColor:!0,children:" Clear pins"})]})]}),c.jsxs(v,{children:[c.jsx(v,{width:24,children:c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","r"]}),c.jsx(u,{dimColor:!0,children:" Rerun all (done)"})]})}),c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","R"]}),c.jsx(u,{dimColor:!0,children:" Retry failed task"})]})]}),c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","i"]}),c.jsx(u,{dimColor:!0,children:" Interactive input (running task)"})]})]}),c.jsxs(v,{flexDirection:"column",marginBottom:1,children:[c.jsxs(v,{marginBottom:1,children:[c.jsx(u,{dimColor:!0,children:"── "}),c.jsx(u,{bold:!0,color:"white",children:"SCROLLING"}),c.jsx(u,{dimColor:!0,children:" (output panel)"})]}),c.jsxs(v,{children:[c.jsx(v,{width:24,children:c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","↑","/k"]}),c.jsx(u,{dimColor:!0,children:" Scroll up"})]})}),c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","↓","/j"]}),c.jsx(u,{dimColor:!0,children:" Scroll down"})]})]}),c.jsxs(v,{children:[c.jsx(v,{width:24,children:c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","^u"]}),c.jsx(u,{dimColor:!0,children:" Page up"})]})}),c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","^d"]}),c.jsx(u,{dimColor:!0,children:" Page down"})]})]}),c.jsxs(v,{children:[c.jsx(v,{width:24,children:c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","Home"]}),c.jsx(u,{dimColor:!0,children:" Top"})]})}),c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","End"]}),c.jsx(u,{dimColor:!0,children:" Bottom (resume follow)"})]})]}),c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","f"]}),c.jsx(u,{dimColor:!0,children:" Toggle auto-scroll (tail mode)"})]})]}),c.jsxs(v,{flexDirection:"column",children:[c.jsxs(v,{marginBottom:1,children:[c.jsx(u,{dimColor:!0,children:"── "}),c.jsx(u,{bold:!0,color:"white",children:"GENERAL"})]}),c.jsxs(v,{children:[c.jsx(v,{width:24,children:c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","q"]}),c.jsx(u,{dimColor:!0,children:" Quit"})]})}),c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","?"]}),c.jsx(u,{dimColor:!0,children:" Toggle help"})]})]})]})]}),ie=c.jsx(Js,{autoExitSeconds:t>0?t:3,onCancel:()=>{T(!1)},visible:O}),ue=j&&i?c.jsx(qn,{activeIndex:M,focused:a.focusedPanel==="dock",store:i}):null;if(a.viewMode==="fullscreen")return c.jsxs(v,{flexDirection:"column",height:p,width:f,children:[c.jsx(v,{flexGrow:1,children:c.jsx(at,{autoScroll:b,duration:U?.duration??U?.elapsed,focused:!0,interactiveMode:a.interactiveMode,output:te,scrollRef:$,status:N,supportsInteractive:!g,taskId:re})}),ue,Z,ie,se]});if(a.viewMode==="split"){const I=f>=pt,S=c.jsx(ut,{compact:!0,filterActive:a.filterActive,filterText:a.filterText,focused:a.focusedPanel==="tasks",headerStatus:oe,parallelSlots:s,pinnedTaskIds:a.pinnedTaskIds,rows:W,scrollRef:R,selectedIndex:a.selectedIndex,title:H}),F=c.jsx(at,{autoScroll:b,duration:U?.duration??U?.elapsed,focused:a.focusedPanel==="output",interactiveMode:a.interactiveMode,output:te,scrollRef:$,showFullscreenHint:!0,status:N,supportsInteractive:!g,taskId:re});if(I){const be=Math.floor(f*.4);return c.jsxs(v,{flexDirection:"column",height:p,width:f,children:[c.jsxs(v,{flexDirection:"row",flexGrow:1,children:[c.jsx(v,{width:be,children:S}),c.jsx(v,{flexGrow:1,children:F})]}),ue,Z,ie,se]})}const ee=Math.floor(p*.45);return c.jsxs(v,{flexDirection:"column",height:p,width:f,children:[c.jsx(v,{height:ee,children:S}),c.jsx(v,{flexGrow:1,children:F}),ue,Z,ie,se]})}return c.jsxs(v,{flexDirection:"column",height:p,width:f,children:[c.jsx(v,{flexGrow:1,children:c.jsx(ut,{filterActive:a.filterActive,filterText:a.filterText,focused:a.focusedPanel!=="dock",headerStatus:oe,parallelSlots:s,pinnedTaskIds:a.pinnedTaskIds,rows:W,scrollRef:R,selectedIndex:a.selectedIndex,title:H})}),ue,Z,ie,se]})},Yn=t=>t==="quiet"?"quiet":"normal",Kn=(t,e)=>typeof t=="string"?Yn(t.toLowerCase()):e===!0?"quiet":"normal",Ne=(t,e)=>{const s=t.overrides.visOptions;return s?.outputStyle==="normal"||s?.outputStyle==="quiet"?s.outputStyle:e},Yt=t=>`${t.id}: tracker saw no workspace access; cached on declared inputs`;class Xn{#e;#r;#s;#n=[];#t=[];#i=[];#o=new Map;#c;#a;#d;#u=0;constructor(e){this.#e=e.projectNames,this.#r=e.args.targets,this.#s=e.tasks,this.#c=e.logReporter,this.#a=e.outputStyle??"normal",this.#d=e.ciGrouping??"auto"}startCommand(){this.#u=Date.now();const e=process.stdout.columns||80,s=`Running ${Ye(this.#e,this.#r,this.#s)}`,r=ce(X.createElement(_e,{title:s,variant:"info"}),{columns:e});process.stdout.write(r);const i=this.#s[0],o=i?.overrides?Object.entries(i.overrides).filter(([n])=>n!=="command"):[];if(o.length>0){process.stdout.write(`
|
|
14
|
+
`)})})}),r&&c.jsx(v,{flexShrink:0,justifyContent:"center",paddingX:1,children:c.jsx(u,{bold:!0,color:"yellow",children:"INTERACTIVE | keystrokes forwarded to task | Esc to exit"})})]})},_n={crashed:"✖",failed:"✖",pending:"·",ready:"●",starting:"•"},qt=t=>t==="ready"?"green":t==="crashed"||t==="failed"?"red":t==="starting"?"cyan":"gray",Nn=({status:t})=>t==="starting"?c.jsx(u,{color:"cyan",children:c.jsx(Mt,{type:"dots"})}):c.jsx(u,{bold:!0,color:qt(t),children:_n[t]}),Gn=({active:t,focused:e,state:s})=>{const r=e&&t,i=r?">":" ",o=s.status==="ready"?s.port?`running, port ${String(s.port)}`:"running":s.status==="failed"||s.status==="crashed"?s.errorMessage??"exited":s.lastLine??"booting…";return c.jsxs(v,{flexDirection:"row",flexShrink:0,overflow:"hidden",children:[c.jsx(u,{children:i}),c.jsx(u,{children:" "}),c.jsx(v,{flexShrink:0,width:3,children:c.jsx(Nn,{status:s.status})}),c.jsx(v,{flexGrow:0,flexShrink:0,width:28,children:c.jsx(u,{bold:r,inverse:r,children:s.id})}),c.jsx(v,{flexGrow:1,flexShrink:1,overflow:"hidden",children:c.jsxs(u,{color:qt(s.status),dimColor:s.status!=="crashed"&&s.status!=="failed",wrap:"truncate-end",children:[" ",o]})})]})},Wn=({states:t})=>{const e=[];for(const r of t)r.status==="ready"&&e.push(r.id);const s=e.join(", ");return c.jsxs(v,{paddingX:1,children:[c.jsxs(u,{bold:!0,color:"green",children:["● ","Services"]}),c.jsxs(u,{children:[" ",String(e.length)," / ",String(t.length)," running"]}),s.length>0&&c.jsxs(u,{dimColor:!0,children:[" ",s]}),c.jsx(u,{dimColor:!0,children:" [Tab ↓]"})]})},Hn=({states:t})=>{const e=t.find(s=>s.status==="crashed"||s.status==="failed");return e?c.jsxs(v,{flexDirection:"column",paddingX:1,children:[c.jsxs(u,{bold:!0,color:"red",children:["✖ ","Service crashed:"," ",e.id]}),e.tailLines.slice(-3).map((s,r)=>c.jsxs(u,{color:"red",dimColor:!0,children:[" ",s]},`crash-${String(r)}`))]}):c.jsx(c.Fragment,{})},qn=({activeIndex:t,focused:e,store:s})=>{const r=U.useSyncExternalStore(s.subscribe,s.getSnapshot),i=s.getIds();if(i.length===0)return c.jsx(c.Fragment,{});const o=i.map(f=>r.get(f)).filter(f=>f!==void 0),n=s.getDockState(),l=n==="crash"?"red":n==="ready"?"gray":e?"white":"cyan",d=n==="crash"?"Services (crashed)":n==="ready"?"Services":"Services (starting)",h=e?n==="crash"?"↑↓ select Enter logs R retry Esc back":"↑↓ select Enter logs Esc back":"Tab to focus services";return n==="ready"&&!e?c.jsx(v,{borderColor:l,borderStyle:"single",flexDirection:"row",flexShrink:0,children:c.jsx(Wn,{states:o})}):c.jsxs(v,{borderBottomTitle:h,borderColor:l,borderStyle:e?"bold":"single",borderTopTitle:d,flexDirection:"column",flexGrow:2,flexShrink:0,minHeight:6,paddingX:1,children:[n==="crash"&&c.jsx(Hn,{states:o}),o.map((f,p)=>c.jsx(Gn,{active:p===t,focused:e,state:f},f.id))]})},Vt=6,Ut=8,zt=12,Vn=t=>t==="running"||t==="pending"?Pt:t==="local-cache"||t==="local-cache-kept-existing"?"Local":t==="remote-cache"?"Remote":Fe,lt=(t,e)=>e[0]===t?"[1]":e[1]===t?"[2]":"",dt=({compact:t,focused:e,isSelected:s,pinLabel:r,row:i})=>{const{persistent:o,status:n,taskId:l}=i,d=e&&s,h=d?">":" ",f=n==="running"&&o===!0;let p;if(f)p=c.jsx(u,{bold:!0,color:"green",children:" ● "});else if(n==="running")p=c.jsxs(u,{bold:!0,color:"white",children:[" ",c.jsx(Mt,{type:"dots"})," "]});else if(n==="pending")p=c.jsx(u,{bold:!0,color:"gray",children:" · "});else{const{color:m,icon:w}=ve(n);p=c.jsxs(u,{bold:!0,color:m,children:[" ",w," "]})}let a=Pt;return f?a="running":n!=="running"&&n!=="pending"?a=i.duration===void 0?Fe:me(i.duration):n==="running"&&i.elapsed!==void 0&&(a=me(i.elapsed)),c.jsxs(v,{children:[c.jsx(u,{children:h}),c.jsx(v,{width:Vt,children:p}),c.jsxs(v,{flexGrow:1,children:[c.jsx(u,{bold:d,inverse:d,children:l}),r?c.jsx(u,{dimColor:!0,children:` ${r}`}):null]}),!t&&c.jsx(v,{justifyContent:"flex-end",width:Ut,children:c.jsx(u,{dimColor:!ge(n),children:Vn(n)})}),!t&&c.jsx(v,{justifyContent:"flex-end",width:zt,children:c.jsx(u,{color:f?"green":void 0,dimColor:n==="pending"||f,children:a})})]})},ut=({compact:t,filterActive:e,filterText:s,focused:r,headerStatus:i,parallelSlots:o=3,pinnedTaskIds:n,rows:l,scrollRef:d,selectedIndex:h,title:f})=>{const p=i==="error"?"red":i==="success"?"green":r?"white":"gray",a=l[h]?.taskId,m=[];let w=0;for(const g of l)g.status==="running"?m.push(g):g.status==="pending"&&(w+=1);const j=Math.min(o,m.length+w),M=j>1,x=[];if(M)for(let g=0;g<j;g++){const k=m[g];k?x.push(c.jsx(dt,{compact:t,focused:r,isSelected:k.taskId===a,pinLabel:lt(k.taskId,n),row:k},`par-${k.taskId}`)):x.push(c.jsxs(v,{children:[c.jsx(u,{children:" "}),c.jsx(v,{width:Vt,children:c.jsx(u,{bold:!0,color:"gray",children:" · "})}),c.jsx(u,{dimColor:!0,children:"Waiting for task..."})]},`par-empty-${String(g)}`))}return c.jsxs(v,{borderColor:p,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[c.jsxs(v,{flexShrink:0,paddingX:1,children:[c.jsx(u,{bold:!0,inverse:!0,children:" VIS "}),c.jsx(u,{children:` ${f}`}),!t&&c.jsxs(v,{flexGrow:1,gap:0,justifyContent:"flex-end",children:[c.jsx(v,{justifyContent:"flex-end",width:Ut,children:c.jsx(u,{dimColor:!0,children:"Cache"})}),c.jsx(v,{justifyContent:"flex-end",width:zt,children:c.jsx(u,{dimColor:!0,children:"Duration"})})]})]}),c.jsx(It,{flexGrow:1,flexShrink:1,paddingX:1,paddingY:1,ref:d,scrollbar:!0,scrollbarColor:"gray",scrollbarStyle:"block",children:l.map(g=>c.jsx(dt,{compact:t,focused:r,isSelected:g.taskId===a,pinLabel:lt(g.taskId,n),row:g},g.taskId))}),M&&c.jsx(v,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",borderTop:!0,flexDirection:"column",flexShrink:0,paddingX:1,paddingY:1,children:x}),e&&c.jsxs(v,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",borderTop:!0,flexShrink:0,paddingX:1,children:[c.jsx(u,{bold:!0,color:"white",children:"/ "}),c.jsx(u,{children:s}),c.jsx(u,{inverse:!0,children:" "})]})]})},ft=40,ht=10,pt=100,Un=Object.freeze([]),zn=({autoExitSeconds:t,onRetryService:e,parallelSlots:s,projectNames:r,serviceDockStore:i,stdinRegistry:o,store:n,targets:l,tasks:d})=>{const{exit:h}=Ys(),{columns:f,rows:p}=Ks(),a=U.useSyncExternalStore(n.subscribe,n.getSnapshot),m=U.useCallback(I=>i?i.subscribe(I):()=>{},[i]);U.useSyncExternalStore(m,()=>i?i.getDockState():"ready");const w=i?i.getIds():Un,j=w.length>0,[M,x]=U.useState(0),[g,k]=U.useState(null),P=U.useSyncExternalStore(m,()=>g&&i?i.getState(g):void 0),[C,y]=U.useState(!1),E=U.useRef(null),R=U.useRef(null),$=U.useRef(null),[O,T]=U.useState(!1),[b,B]=U.useState(!0),D=U.useRef({list:0,splitList:0,splitOutput:0}),N=U.useCallback(()=>{a.viewMode==="list"?D.current.list=R.current?.getScrollOffset()??0:a.viewMode==="split"&&(D.current.splitList=R.current?.getScrollOffset()??0,D.current.splitOutput=$.current?.getScrollOffset()??0)},[a.viewMode]),A=U.useCallback(I=>{setTimeout(()=>{if(I==="list"){const S=D.current.list;R.current?.scrollTo(S)}else if(I==="split"){const S=D.current.splitList;S>0?R.current?.scrollTo(S):R.current?.scrollTo(Math.max(0,n.getSnapshot().selectedIndex-2)),$.current?.scrollTo(D.current.splitOutput)}},0)},[n]),L=U.useRef(!1);U.useEffect(()=>{a.done&&!L.current&&(L.current=!0,t>0&&a.failed===0&&T(!0)),!a.done&&L.current&&(L.current=!1,T(!1))},[a.done,a.failed,t]);const G=U.useMemo(()=>{const I=w.length>0?new Set(w):null,S=a.filterText?a.filterText.toLowerCase():null,F=[];for(const ee of a.rows)I?.has(ee.taskId)||a.statusFilter==="failed"&&ee.status!=="failure"||a.statusFilter==="running"&&ee.status!=="running"&&ee.status!=="pending"||a.statusFilter==="passed"&&ee.status!=="success"&&!ge(ee.status)||S&&!ee.taskId.toLowerCase().includes(S)||F.push(ee);return F},[a.rows,a.filterText,a.statusFilter,w]),W=(G[a.selectedIndex]??null)?.taskId??null,X=g?null:a.pinnedTaskIds[0]??W,H=X?a.rows.find(I=>I.taskId===X):null,Q=P??null,J=g?(Q?.tailLines??[]).join(`
|
|
15
|
+
`):X?a.outputs.get(X)??"":"",te=U.useMemo(()=>H?.status==="failure"&&J?Ht(J,{color:!process.env.NO_COLOR,cwd:process.cwd()}):J,[H?.status,J]),re=g??X,_=g?Q?.status==="crashed"||Q?.status==="failed"?"failure":"running":H?.status,z=Ye(r,l,d),q=a.done?`Completed ${z} (${me((a.endTime??Date.now())-a.startTime)})`:`Running ${z}...`,oe=a.done?a.failed>0?"error":"success":"running",ae=U.useCallback(I=>{R.current?.scrollTo(Math.max(0,I-2))},[]);if(U.useEffect(()=>{a.interactiveMode&&H?.status!=="running"&&n.setInteractiveMode(!1)},[a.interactiveMode,H?.status,n]),U.useEffect(()=>{if(!X)return;let I=f;a.viewMode==="split"&&f>=pt?I=f-Math.floor(f*.4)-2:(a.viewMode==="split"||a.viewMode==="fullscreen")&&(I=f-2);const S=Math.max(1,p-4);o.get(X)?.resize?.(I,S)},[f,p,a.viewMode,X]),Je((I,S)=>{if(S.escape){n.setInteractiveMode(!1);return}if(!X)return;const F=o.get(X);if(!F){n.setInteractiveMode(!1);return}if(S.return)F.write("\r");else if(S.upArrow)F.write("\x1B[A");else if(S.downArrow)F.write("\x1B[B");else if(S.rightArrow)F.write("\x1B[C");else if(S.leftArrow)F.write("\x1B[D");else if(S.backspace)F.write("");else if(S.delete)F.write("\x1B[3~");else if(S.tab)F.write(" ");else if(S.home)F.write("\x1B[H");else if(S.end)F.write("\x1B[F");else if(S.pageUp)F.write("\x1B[5~");else if(S.pageDown)F.write("\x1B[6~");else if(S.ctrl&&I){const ee=I.toUpperCase().codePointAt(0);ee!==void 0&&ee>=65&&ee<=90&&F.write(String.fromCodePoint(ee-64))}else I&&F.write(I)},{isActive:a.interactiveMode}),Je((I,S)=>{if(I==="c"&&S.ctrl){h();return}if(!O){if(C){S.escape||I==="?"?y(!1):I==="q"?(y(!1),T(!0)):S.downArrow||I==="j"?E.current?.scrollBy(1):S.upArrow||I==="k"?E.current?.scrollBy(-1):S.pageDown?E.current?.scrollBy(5):S.pageUp?E.current?.scrollBy(-5):S.home?E.current?.scrollToTop():S.end&&E.current?.scrollToBottom();return}if(I==="?"){y(!0);return}if(I==="q"){T(!0);return}if(I==="r"&&a.done){n.requestRerun();return}if(I==="R"&&a.done){const F=G[a.selectedIndex];F?.status==="failure"&&n.requestRetry(F.taskId);return}if(I==="F"&&!a.filterActive){const F=["all","failed","running","passed"],ee=F.indexOf(a.statusFilter);n.setStatusFilter(F[(ee+1)%F.length]);return}if(a.filterActive){if(S.escape){n.setFilterActive(!1);return}if(S.return){n.setFilterActive(!1);return}if(S.backspace){n.setFilter(a.filterText.slice(0,-1));return}if(I&&!S.ctrl&&!S.meta){n.setFilter(a.filterText+I);return}return}if(I==="i"&&H?.status==="running"&&(a.viewMode==="fullscreen"||a.viewMode==="split"&&a.focusedPanel==="output")){n.setInteractiveMode(!0);return}if(a.viewMode==="fullscreen"){if(S.escape){n.setViewMode("split"),A("split");return}if(I==="f"){const F=!b;B(F),F&&$.current?.scrollToBottom();return}if(S.downArrow||I==="j"){B(!1),$.current?.scrollBy(1);return}if(S.upArrow||I==="k"){B(!1),$.current?.scrollBy(-1);return}if(S.pageDown||S.ctrl&&I==="d"){B(!1),$.current?.scrollBy(12);return}if(S.pageUp||S.ctrl&&I==="u"){B(!1),$.current?.scrollBy(-12);return}if(S.home){B(!1),$.current?.scrollToTop();return}if(S.end){B(!0),$.current?.scrollToBottom();return}return}if(a.focusedPanel==="dock"&&j&&i){if(S.tab){k(null),n.setFocusedPanel("tasks");return}if(S.escape){n.setFocusedPanel("tasks"),k(null),a.viewMode==="split"&&(n.setViewMode("list"),A("list"));return}if(S.downArrow||I==="j"){x(F=>Math.min(F+1,w.length-1));return}if(S.upArrow||I==="k"){x(F=>Math.max(F-1,0));return}if(S.return){const F=w[M];F&&(k(F),B(!0),N(),D.current.splitList=0,D.current.splitOutput=0,n.setViewMode("split"),n.setFocusedPanel("output"),A("split"));return}if((I==="r"||I==="R")&&e){const F=w[M],ee=F?i.getState(F)?.status:void 0;if(F&&(ee==="crashed"||ee==="failed")){const be=e(F);be instanceof Promise&&be.catch(()=>{})}return}return}if(a.viewMode==="split"){if(S.tab){a.focusedPanel==="tasks"?n.setFocusedPanel("output"):j?n.setFocusedPanel("dock"):(k(null),n.setFocusedPanel("tasks"));return}if(a.focusedPanel==="output"){if(S.escape){if(g&&j){k(null),n.setViewMode("list"),n.setFocusedPanel("dock"),A("list");return}k(null),n.setFocusedPanel("tasks");return}if(S.return){N(),n.setViewMode("fullscreen");return}if(I==="f"){const F=!b;B(F),F&&$.current?.scrollToBottom();return}if(S.downArrow||I==="j"){B(!1),$.current?.scrollBy(1);return}if(S.upArrow||I==="k"){B(!1),$.current?.scrollBy(-1);return}if(S.pageDown||S.ctrl&&I==="d"){B(!1),$.current?.scrollBy(12);return}if(S.pageUp||S.ctrl&&I==="u"){B(!1),$.current?.scrollBy(-12);return}if(S.home){B(!1),$.current?.scrollToTop();return}if(S.end){B(!0),$.current?.scrollToBottom();return}return}if(S.escape){n.setViewMode("list"),A("list");return}if(S.return){n.setFocusedPanel("output");return}}if(a.viewMode==="list"||a.viewMode==="split"&&a.focusedPanel==="tasks"){if(S.tab&&a.viewMode==="list"&&j){n.setFocusedPanel("dock");return}if(S.downArrow||I==="j"){const F=Math.min(a.selectedIndex+1,Math.max(0,G.length-1));n.setSelectedIndex(F),ae(F);return}if(S.upArrow||I==="k"){const F=Math.max(a.selectedIndex-1,0);n.setSelectedIndex(F),ae(F);return}if(S.return&&a.viewMode==="list"){B(!0),N(),D.current.splitList=0,D.current.splitOutput=0,n.setViewMode("split"),n.setFocusedPanel("output"),A("split");return}if(I==="/"){n.setFilterActive(!0);return}if(I==="1"&&W){n.pinTask(0,W);return}if(I==="2"&&W){n.pinTask(1,W);return}if(I==="0"){n.clearPins();return}S.escape&&a.filterText&&n.setFilter("")}}},{isActive:!a.interactiveMode}),f<ft||p<ht)return c.jsx(v,{alignItems:"center",height:p,justifyContent:"center",width:f,children:c.jsxs(u,{color:"yellow",children:["Terminal too small (",f,"x",p,"). Minimum:"," ",ft,"x",ht]})});const de=c.jsxs(v,{gap:1,children:[a.succeeded>0&&c.jsxs(u,{bold:!0,color:"green",children:["✓"," ",a.succeeded]}),a.cached>0&&c.jsxs(u,{dimColor:!0,children:["✓"," ",a.cached]}),a.failed>0&&c.jsxs(u,{bold:!0,color:"red",children:["✗"," ",a.failed]}),a.running>0&&c.jsxs(u,{color:"cyan",children:["◷"," ",a.running]}),c.jsxs(u,{dimColor:!0,children:[a.totalTasks," ","total"]}),a.statusFilter!=="all"&&c.jsxs(u,{color:"yellow",children:["[",a.statusFilter,"]"]})]});let Y;if(a.viewMode==="fullscreen")Y=[c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"Esc"}),c.jsx(u,{dimColor:!0,children:"BACK"})]},"esc"),c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"↑↓"}),c.jsx(u,{dimColor:!0,children:"SCROLL"})]},"scroll"),c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"^u ^d"}),c.jsx(u,{dimColor:!0,children:"PAGE"})]},"page"),...H?.status==="running"?[c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"i"}),c.jsx(u,{dimColor:!0,children:"INPUT"})]},"i")]:[],c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"q"}),c.jsx(u,{dimColor:!0,children:"QUIT"})]},"q")];else if(a.done){const I=G[a.selectedIndex]?.status==="failure";Y=[c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"q"}),c.jsx(u,{dimColor:!0,children:"QUIT"})]},"q"),c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"r"}),c.jsx(u,{dimColor:!0,children:"RERUN"})]},"r"),...I?[c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"R"}),c.jsx(u,{dimColor:!0,children:"RETRY"})]},"R")]:[],c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"?"}),c.jsx(u,{dimColor:!0,children:"HELP"})]},"?"),c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"↑↓"}),c.jsx(u,{dimColor:!0,children:"NAV"})]},"nav"),c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"F"}),c.jsx(u,{dimColor:!0,children:"FILTER"})]},"F"),c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"⏎"}),c.jsx(u,{dimColor:!0,children:a.viewMode==="list"?"OUTPUT":"FULLSCREEN"})]},"enter")]}else a.viewMode==="split"&&a.focusedPanel==="output"?Y=[c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"q"}),c.jsx(u,{dimColor:!0,children:"QUIT"})]},"q"),c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"Esc"}),c.jsx(u,{dimColor:!0,children:"BACK"})]},"esc"),c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"↑↓"}),c.jsx(u,{dimColor:!0,children:"SCROLL"})]},"scroll"),...H?.status==="running"?[c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"i"}),c.jsx(u,{dimColor:!0,children:"INPUT"})]},"i")]:[],c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"⏎"}),c.jsx(u,{dimColor:!0,children:"FULLSCREEN"})]},"enter"),c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"Tab"}),c.jsx(u,{dimColor:!0,children:"PANEL"})]},"tab"),c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"?"}),c.jsx(u,{dimColor:!0,children:"HELP"})]},"?")]:Y=[c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"q"}),c.jsx(u,{dimColor:!0,children:"QUIT"})]},"q"),c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"?"}),c.jsx(u,{dimColor:!0,children:"HELP"})]},"?"),c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"↑↓"}),c.jsx(u,{dimColor:!0,children:"NAV"})]},"nav"),c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"/"}),c.jsx(u,{dimColor:!0,children:"FILTER"})]},"/"),c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"F"}),c.jsx(u,{dimColor:!0,children:"STATUS"})]},"F"),c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"⏎"}),c.jsx(u,{dimColor:!0,children:a.viewMode==="list"?"OUTPUT":"FULLSCREEN"})]},"enter"),...a.viewMode==="split"?[c.jsxs(v,{gap:1,children:[c.jsx(u,{bold:!0,color:"white",children:"Tab"}),c.jsx(u,{dimColor:!0,children:"PANEL"})]},"tab")]:[]];const Z=c.jsxs(v,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",flexShrink:0,justifyContent:"space-between",children:[c.jsx(v,{flexGrow:1,flexWrap:"wrap",gap:2,paddingX:1,children:Y}),c.jsx(v,{flexShrink:0,paddingX:1,children:de})]}),se=c.jsxs(Xs,{backgroundColor:"#1e1e1e",footer:c.jsxs(u,{dimColor:!0,children:[c.jsx(u,{bold:!0,color:"white",children:"↑↓"})," ","scroll"," ",c.jsx(u,{bold:!0,color:"white",children:"?"}),"/",c.jsx(u,{bold:!0,color:"white",children:"Esc"})," ","close"]}),scrollRef:E,title:"KEYBOARD SHORTCUTS",visible:C,width:52,children:[c.jsxs(v,{flexDirection:"column",marginBottom:1,children:[c.jsxs(v,{marginBottom:1,children:[c.jsx(u,{dimColor:!0,children:"── "}),c.jsx(u,{bold:!0,color:"white",children:"NAVIGATION"})]}),c.jsxs(v,{children:[c.jsx(v,{width:24,children:c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","↑","/k"]}),c.jsx(u,{dimColor:!0,children:" Move up"})]})}),c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","↓","/j"]}),c.jsx(u,{dimColor:!0,children:" Move down"})]})]}),c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","Tab"]}),c.jsx(u,{dimColor:!0,children:" Switch panel (split)"})]}),c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","Esc"]}),c.jsx(u,{dimColor:!0,children:" Back / close"})]}),c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","Enter"]}),c.jsx(u,{dimColor:!0,children:" Show output / fullscreen"})]})]}),c.jsxs(v,{flexDirection:"column",marginBottom:1,children:[c.jsxs(v,{marginBottom:1,children:[c.jsx(u,{dimColor:!0,children:"── "}),c.jsx(u,{bold:!0,color:"white",children:"VIEWS"})]}),c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","Enter"]}),c.jsxs(u,{dimColor:!0,children:[" ","List"," ","→"," ","Split"," ","→"," ","Fullscreen"]})]}),c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","Esc"]}),c.jsxs(u,{dimColor:!0,children:[" ","Fullscreen"," ","→"," ","Split"," ","→"," ","List"]})]})]}),c.jsxs(v,{flexDirection:"column",marginBottom:1,children:[c.jsxs(v,{marginBottom:1,children:[c.jsx(u,{dimColor:!0,children:"── "}),c.jsx(u,{bold:!0,color:"white",children:"ACTIONS"})]}),c.jsxs(v,{children:[c.jsx(v,{width:24,children:c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","/"]}),c.jsx(u,{dimColor:!0,children:" Filter by text"})]})}),c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","F"]}),c.jsx(u,{dimColor:!0,children:" Filter by status"})]})]}),c.jsxs(v,{children:[c.jsx(v,{width:24,children:c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","1"]}),c.jsx(u,{dimColor:!0,children:"/"}),c.jsx(u,{bold:!0,color:"white",children:"2"}),c.jsx(u,{dimColor:!0,children:" Pin to output pane"})]})}),c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","0"]}),c.jsx(u,{dimColor:!0,children:" Clear pins"})]})]}),c.jsxs(v,{children:[c.jsx(v,{width:24,children:c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","r"]}),c.jsx(u,{dimColor:!0,children:" Rerun all (done)"})]})}),c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","R"]}),c.jsx(u,{dimColor:!0,children:" Retry failed task"})]})]}),c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","i"]}),c.jsx(u,{dimColor:!0,children:" Interactive input (running task)"})]})]}),c.jsxs(v,{flexDirection:"column",marginBottom:1,children:[c.jsxs(v,{marginBottom:1,children:[c.jsx(u,{dimColor:!0,children:"── "}),c.jsx(u,{bold:!0,color:"white",children:"SCROLLING"}),c.jsx(u,{dimColor:!0,children:" (output panel)"})]}),c.jsxs(v,{children:[c.jsx(v,{width:24,children:c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","↑","/k"]}),c.jsx(u,{dimColor:!0,children:" Scroll up"})]})}),c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","↓","/j"]}),c.jsx(u,{dimColor:!0,children:" Scroll down"})]})]}),c.jsxs(v,{children:[c.jsx(v,{width:24,children:c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","^u"]}),c.jsx(u,{dimColor:!0,children:" Page up"})]})}),c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","^d"]}),c.jsx(u,{dimColor:!0,children:" Page down"})]})]}),c.jsxs(v,{children:[c.jsx(v,{width:24,children:c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","Home"]}),c.jsx(u,{dimColor:!0,children:" Top"})]})}),c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","End"]}),c.jsx(u,{dimColor:!0,children:" Bottom (resume follow)"})]})]}),c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","f"]}),c.jsx(u,{dimColor:!0,children:" Toggle auto-scroll (tail mode)"})]})]}),c.jsxs(v,{flexDirection:"column",children:[c.jsxs(v,{marginBottom:1,children:[c.jsx(u,{dimColor:!0,children:"── "}),c.jsx(u,{bold:!0,color:"white",children:"GENERAL"})]}),c.jsxs(v,{children:[c.jsx(v,{width:24,children:c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","q"]}),c.jsx(u,{dimColor:!0,children:" Quit"})]})}),c.jsxs(u,{children:[c.jsxs(u,{bold:!0,color:"white",children:[" ","?"]}),c.jsx(u,{dimColor:!0,children:" Toggle help"})]})]})]})]}),ie=c.jsx(Js,{autoExitSeconds:t>0?t:3,onCancel:()=>{T(!1)},visible:O}),ue=j&&i?c.jsx(qn,{activeIndex:M,focused:a.focusedPanel==="dock",store:i}):null;if(a.viewMode==="fullscreen")return c.jsxs(v,{flexDirection:"column",height:p,width:f,children:[c.jsx(v,{flexGrow:1,children:c.jsx(at,{autoScroll:b,duration:H?.duration??H?.elapsed,focused:!0,interactiveMode:a.interactiveMode,output:te,scrollRef:$,status:_,supportsInteractive:!g,taskId:re})}),ue,Z,ie,se]});if(a.viewMode==="split"){const I=f>=pt,S=c.jsx(ut,{compact:!0,filterActive:a.filterActive,filterText:a.filterText,focused:a.focusedPanel==="tasks",headerStatus:oe,parallelSlots:s,pinnedTaskIds:a.pinnedTaskIds,rows:G,scrollRef:R,selectedIndex:a.selectedIndex,title:q}),F=c.jsx(at,{autoScroll:b,duration:H?.duration??H?.elapsed,focused:a.focusedPanel==="output",interactiveMode:a.interactiveMode,output:te,scrollRef:$,showFullscreenHint:!0,status:_,supportsInteractive:!g,taskId:re});if(I){const be=Math.floor(f*.4);return c.jsxs(v,{flexDirection:"column",height:p,width:f,children:[c.jsxs(v,{flexDirection:"row",flexGrow:1,children:[c.jsx(v,{width:be,children:S}),c.jsx(v,{flexGrow:1,children:F})]}),ue,Z,ie,se]})}const ee=Math.floor(p*.45);return c.jsxs(v,{flexDirection:"column",height:p,width:f,children:[c.jsx(v,{height:ee,children:S}),c.jsx(v,{flexGrow:1,children:F}),ue,Z,ie,se]})}return c.jsxs(v,{flexDirection:"column",height:p,width:f,children:[c.jsx(v,{flexGrow:1,children:c.jsx(ut,{filterActive:a.filterActive,filterText:a.filterText,focused:a.focusedPanel!=="dock",headerStatus:oe,parallelSlots:s,pinnedTaskIds:a.pinnedTaskIds,rows:G,scrollRef:R,selectedIndex:a.selectedIndex,title:q})}),ue,Z,ie,se]})},Yn=t=>t==="quiet"?"quiet":"normal",Kn=(t,e)=>typeof t=="string"?Yn(t.toLowerCase()):e===!0?"quiet":"normal",Ne=(t,e)=>{const s=t.overrides.visOptions;return s?.outputStyle==="normal"||s?.outputStyle==="quiet"?s.outputStyle:e},Yt=t=>`${t.id}: tracker saw no workspace access; cached on declared inputs`;class Xn{#e;#r;#s;#n=[];#t=[];#i=[];#o=new Map;#c;#a;#d;#u=0;constructor(e){this.#e=e.projectNames,this.#r=e.args.targets,this.#s=e.tasks,this.#c=e.logReporter,this.#a=e.outputStyle??"normal",this.#d=e.ciGrouping??"auto"}startCommand(){this.#u=Date.now();const e=process.stdout.columns||80,s=`Running ${Ye(this.#e,this.#r,this.#s)}`,r=ce(K.createElement(_e,{title:s,variant:"info"}),{columns:e});process.stdout.write(r);const i=this.#s[0],o=i?.overrides?Object.entries(i.overrides).filter(([n])=>n!=="command"):[];if(o.length>0){process.stdout.write(`
|
|
16
16
|
With additional flags:
|
|
17
17
|
`);for(const[n,l]of o)process.stdout.write(`${gn(" ",n,l)}
|
|
18
18
|
`)}process.stdout.write(`
|
|
19
|
-
`)}startTasks(e){const s=process.stdout.columns||80;for(const r of e){const i=ce(
|
|
20
|
-
`)}}endTasks(e){const s=process.stdout.columns||80;for(const r of e){this.#o.set(r.task.id,r),r.status==="failure"?this.#n.push(r):ge(r.status)&&this.#t.push(r),r.retryAttempts&&r.retryAttempts>0&&this.#i.push(r);const i=xe(r.status),o=r.startTime&&r.endTime?` (${me(r.endTime-r.startTime)})`:"",n=ge(r.status)?" [cache]":"",l=r.retryAttempts&&r.retryAttempts>0?` [retried ${r.retryAttempts}x]`:"",d=ce(
|
|
21
|
-
`)}}#l(e){const s=process.stdout.columns||80,r=ce(
|
|
19
|
+
`)}startTasks(e){const s=process.stdout.columns||80;for(const r of e){const i=ce(K.createElement(u,null,K.createElement(u,{dimColor:!0},">"),` ${r.id}`),{columns:s});process.stdout.write(`${i}
|
|
20
|
+
`)}}endTasks(e){const s=process.stdout.columns||80;for(const r of e){this.#o.set(r.task.id,r),r.status==="failure"?this.#n.push(r):ge(r.status)&&this.#t.push(r),r.retryAttempts&&r.retryAttempts>0&&this.#i.push(r);const i=xe(r.status),o=r.startTime&&r.endTime?` (${me(r.endTime-r.startTime)})`:"",n=ge(r.status)?" [cache]":"",l=r.retryAttempts&&r.retryAttempts>0?` [retried ${r.retryAttempts}x]`:"",d=ce(K.createElement(u,null,i,` ${r.task.id}`,n?K.createElement(u,{color:"cyan"},n):null,l?K.createElement(u,{color:"yellow"},l):null,o?K.createElement(u,{dimColor:!0},o):null),{columns:s});process.stdout.write(`${d}
|
|
21
|
+
`)}}#l(e){const s=process.stdout.columns||80,r=ce(K.createElement(u,{dimColor:!0},` ⓘ ${e}`),{columns:s});process.stdout.write(`${r}
|
|
22
22
|
`)}printCacheDisabledByTask(e){this.#l(`${e.id}: caching disabled by task via disableCache()`)}printSelfModifyingSkip(e,s){this.#l(`${e.id}: caching skipped — task modified its own input${s.length===1?"":"s"} (${s.join(", ")})`)}printDeclaredFallback(e){Ne(e,this.#a)!=="quiet"&&this.#l(Yt(e))}printEmptyFingerprintWarning(e,s){this.#l(`${e.id}: caching skipped — ${s}`)}printTaskTerminalOutput(e,s,r){if(Ne(e,this.#a)==="quiet"&&(s==="success"||ge(s)))return;const i=s==="failure"?Ht(r,{color:!process.env.NO_COLOR,cwd:process.cwd()}):r;if(this.#c){this.#c.printTaskTerminalOutput(e,s,i);return}Ln(e.id,s,i,this.#d)}endCommand(){const e=me(Date.now()-this.#u),s=this.#s.filter(o=>!this.#o.has(o.id)).map(o=>o.id);process.stdout.write(`
|
|
23
|
-
`);const r=process.stdout.columns||80,i=ce(
|
|
24
|
-
`)}}const Jn=t=>{const{args:e,autoExit:s=!1,onRetryService:r,outputStyle:i="normal",projectNames:o,serviceDockStore:n,stdinRegistry:l,tasks:d,totalTaskCount:h}=t,f=new Ee(d,h),p=typeof e.parallel=="number"?e.parallel:3,a=s===!0?3:typeof s=="number"?s:0,m=new Map,w=(T,b)=>{const
|
|
25
|
-
`);for(const A of T.rows){const{persistent:L,status:
|
|
23
|
+
`);const r=process.stdout.columns||80,i=ce(K.createElement(_t,{cached:this.#t.length,failed:this.#n.length,failedIds:this.#n.map(o=>o.task.id),projectNames:this.#e,retriedIds:this.#i.length>0?this.#i.map(o=>o.task.id):void 0,skippedIds:s.length>0?s:void 0,succeeded:this.#o.size-this.#n.length-this.#t.length,targets:this.#r,tasks:this.#s,took:e}),{columns:r});process.stdout.write(`${i}
|
|
24
|
+
`)}}const Jn=t=>{const{args:e,autoExit:s=!1,onRetryService:r,outputStyle:i="normal",projectNames:o,serviceDockStore:n,stdinRegistry:l,tasks:d,totalTaskCount:h}=t,f=new Ee(d,h),p=typeof e.parallel=="number"?e.parallel:3,a=s===!0?3:typeof s=="number"?s:0,m=new Map,w=(T,b)=>{const B=m.get(T);B?B.push(b):m.set(T,[b])};let j,M;const x=new Promise(T=>{M=T});let g;const k=()=>{g&&(clearInterval(g),g=void 0)},P=()=>{if(process.stdin.isTTY&&typeof process.stdin.setRawMode=="function")try{process.stdin.setRawMode(!1)}catch{}process.stdin.pause(),process.stdin.unref()},C=()=>{if(l){for(const T of l.values())T.kill?.();l.clear()}},y=()=>{k(),$(),C(),P(),process.stdout.write("\x1B[?1049l\x1B[?25h"),j?.cleanup(),process.exit(1)},E=()=>{const T=f.getSnapshot(),b=me(Date.now()-T.startTime),B=T.rows.filter(A=>A.status==="failure").map(A=>A.taskId),D=process.stdout.columns||80;process.stdout.write(`
|
|
25
|
+
`);for(const A of T.rows){const{persistent:L,status:G,taskId:V}=A,W=G==="running"||G==="pending",X=ve(G),H=W&&L?"■":X.icon,Q=W&&L?"gray":X.color;let J="";switch(G){case"local-cache":case"local-cache-kept-existing":{J=" [local cache]";break}case"remote-cache":{J=" [remote cache]";break}case"skipped":{J=" [skipped]";break}default:{W&&L?J=" [stopped]":W&&(J=" [skipped]");break}}const te=A.retryAttempts&&A.retryAttempts>0?` [retried ${A.retryAttempts}x]`:"",re=ce(K.createElement(u,null," ",K.createElement(u,{color:Q},H),` vis run ${V}`,J?K.createElement(u,{dimColor:!0},` ${J}`):null,te?K.createElement(u,{color:"yellow"},te):null),{columns:D});process.stdout.write(`${re}
|
|
26
26
|
`)}process.stdout.write(`
|
|
27
|
-
`);const
|
|
28
|
-
`),i!=="quiet"){const A=[...T.rows.filter(L=>L.status!=="failure"),...T.rows.filter(L=>L.status==="failure")];for(const L of A){if(L.status==="running"||L.status==="pending")continue;const
|
|
29
|
-
`,
|
|
27
|
+
`);const N=ce(K.createElement(_t,{cached:T.cached,failed:T.failed,failedIds:B,projectNames:o,retriedIds:T.retriedIds.length>0?T.retriedIds:void 0,succeeded:T.succeeded,targets:e.targets,tasks:d,took:b}),{columns:D});if(process.stdout.write(`${N}
|
|
28
|
+
`),i!=="quiet"){const A=[...T.rows.filter(L=>L.status!=="failure"),...T.rows.filter(L=>L.status==="failure")];for(const L of A){if(L.status==="running"||L.status==="pending")continue;const G=T.outputs.get(L.taskId);if(!G?.trim())continue;const{color:V,icon:W}=ve(L.status),X=ce(K.createElement(u,null,`
|
|
29
|
+
`,K.createElement(u,{bold:!0,color:V},` ${W} vis run ${L.taskId}`)),{columns:D});process.stdout.write(`${X}
|
|
30
30
|
|
|
31
|
-
`);const
|
|
31
|
+
`);const H=G.trim().split(`
|
|
32
32
|
`).map(Q=>` ${Q}`).join(`
|
|
33
|
-
`);process.stdout.write(`${
|
|
34
|
-
`)}}};let R;const $=()=>{R&&(clearInterval(R),R=void 0)};return{lifeCycle:{endCommand(){k(),f.markDone(),R||(R=setInterval(()=>{},1e3))},endTasks(T){f.endTasks(T);for(const b of T){const
|
|
33
|
+
`);process.stdout.write(`${H}
|
|
34
|
+
`)}}};let R;const $=()=>{R&&(clearInterval(R),R=void 0)};return{lifeCycle:{endCommand(){k(),f.markDone(),R||(R=setInterval(()=>{},1e3))},endTasks(T){f.endTasks(T);for(const b of T){const B=m.get(b.task.id);if(B){m.delete(b.task.id);for(const D of B)f.addOutput(b.task.id,D)}}},printCacheDisabledByTask(T){w(T.id,`ⓘ caching disabled by task via disableCache()
|
|
35
35
|
`)},printDeclaredFallback(T){Ne(T,i)!=="quiet"&&w(T.id,`ⓘ ${Yt(T)}
|
|
36
36
|
`)},printEmptyFingerprintWarning(T,b){w(T.id,`ⓘ caching skipped — ${b}
|
|
37
37
|
`)},printSelfModifyingSkip(T,b){w(T.id,`ⓘ caching skipped — task modified its own input${b.length===1?"":"s"} (${b.join(", ")})
|
|
38
|
-
`)},printTaskTerminalOutput(T,b,
|
|
39
|
-
`;E.append(
|
|
40
|
-
[timeout] Task "${e.id}" exceeded ${
|
|
41
|
-
`}:{code:
|
|
38
|
+
`)},printTaskTerminalOutput(T,b,B){f.getSnapshot().outputs.has(T.id)||f.addOutput(T.id,B)},startCommand(){process.on("SIGINT",y),process.on("SIGTERM",y),R||(R=setInterval(()=>{},1e3)),j=Qs(K.createElement(zn,{autoExitSeconds:a,onRetryService:r,parallelSlots:p,projectNames:o,serviceDockStore:n,stdinRegistry:l??new Map,store:f,targets:e.targets,tasks:d}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}),j.waitUntilExit().then(()=>{$(),C(),P(),process.removeListener("SIGINT",y),process.removeListener("SIGTERM",y),E(),M()}).catch(()=>{$(),C(),P(),process.removeListener("SIGINT",y),process.removeListener("SIGTERM",y),M()})},startTasks(T){f.startTasks(T),g||(g=setInterval(()=>{f.tick()},100))}},renderIsDone:x,store:f}},Qn=t=>{const{killGracePeriodMs:e=5e3,onTimeout:s,sendSignal:r,timeoutMs:i}=t;if(i<=0)return{cancel:()=>{}};const o=Math.max(e,0);let n;const l=setTimeout(()=>{s?.(),r("SIGTERM"),o>0&&(n=setTimeout(()=>{r("SIGKILL")},o))},i);return{cancel:()=>{clearTimeout(l),n&&clearTimeout(n)}}},Zn=async(t,e,s)=>{if(!e)return s();const r=t.get(e)??Promise.resolve();let i;const o=new Promise(l=>{i=l}),n=r.then(()=>o);t.set(e,n),await r;try{return await s()}finally{i(),t.get(e)===n&&t.delete(e)}},ei=t=>{let e=Math.max(0,Math.floor(t));return{claim(s){const r=Math.max(0,Math.min(s,e));return e-=r,r},get remaining(){return e}}},Kt=t=>async(e,s)=>{const{hooks:r,lifeCycle:i,mutexPool:o,onOutput:n,onOutputReplace:l,resolveCommand:d,retryBudget:h,serviceEventBridge:f,spawnContext:p,stdinRegistry:a,strictEnvFailure:m,workspaceRoot:w}=t,j=je(e),M=He(w,s.cwd??e.projectRoot,j?.runFromWorkspaceRoot===!0),x=d(e);if(!x)return{code:0,terminalOutput:`No command configured for ${e.target.project}:${e.target.target}`};const g=ke(p,e,s),k=m(e,x,s);if(k!==void 0)return i?.onTaskStderr?.(e,k),{code:1,terminalOutput:k};const P=j?.pty===!0,C=!!a,y=e.pty===!0?!0:e.pty===!1?!1:C||P;y&&(e.cache=!1);const E=y?void 0:new Qr(Ie),R=y?new We(Ie):void 0;let $;const O=b=>{if(b.kind==="started"&&($=b.kill,b.write&&a&&a.set(e.id,{kill:b.kill,resize:b.resize,write:b.write}),f?.onRegistryTaskStarted(e.id)),(b.kind==="stdout"||b.kind==="stderr")&&b.text!==void 0)if(b.kind==="stdout"?i?.onTaskStdout?.(e,b.text):i?.onTaskStderr?.(e,b.text),R)R.write(b.text),C&&l?.(e.id,R.toString()),f&&f.onTaskOutput(e.id,b.text);else{const B=`${b.text}
|
|
39
|
+
`;E.append(B),n?.(e.id,B)}b.kind==="close"&&(a&&a.delete(e.id),f&&f.onRegistryTaskClosed(e.id,b.exitCode??0,!!b.killed).catch(()=>{}))},T=async()=>{const b=j?.retryCount??0,B=j?.retryDelay,D=h?h.claim(b):b,N=typeof j?.timeout=="number"&&j.timeout>0?j.timeout:0,A=typeof j?.killGracePeriodMs=="number"&&j.killGracePeriodMs>=0?j.killGracePeriodMs:5e3;let L=!1,G=0;const V=Qn({killGracePeriodMs:A,onTimeout:()=>{L=!0},sendSignal:Q=>{$?.(Q)},timeoutMs:N});let W;try{W=await $e([{command:x,cwd:M,env:g.env,inheritEnv:g.inheritEnv,name:e.id,...y?{ptySize:{cols:process.stdout.columns??80,rows:process.stdout.rows??24},stdin:"pty"}:{}}],{killOthers:["failure"],onEvent:O,...D>0?{restart:{delay:B??"exponential",onRetry:async(Q,J,te)=>{G=Q,r&&await r.callHook("task:retry",e,Q,te)},tries:D}}:{}})}finally{V.cancel()}const X=W.closeEvents[0],H=R?R.toString():E.toString();return L?{code:124,retryAttempts:G,terminalOutput:`${H}
|
|
40
|
+
[timeout] Task "${e.id}" exceeded ${N}ms budget.
|
|
41
|
+
`}:{code:X?.exitCode??1,retryAttempts:G,terminalOutput:H}};return o?Zn(o,j?.mutex,T):T()},ti=({injectedServiceIdSet:t,runtime:e,serviceDockStore:s,serviceEventBridge:r,workspaceRoot:i})=>{const{failureLogLifeCycle:o,hookLifeCycle:n,hooks:l,lifecycleOptions:d,outputStyle:h,resolveCommand:f,sharedRetryBudget:p,spawnContext:a,strictEnvFailure:m}=e,w=new Map,j=Jn({...d,onRetryService:r?C=>r.retry(C):void 0,outputStyle:h,serviceDockStore:s,stdinRegistry:w}),{lifeCycle:M,store:x}=j,g=new jt([M,n,o]),P=Kt({hooks:l,lifeCycle:g,mutexPool:new Map,onOutput:(C,y)=>{r&&t.has(C)?r.onTaskOutput(C,y):x.addOutput(C,y)},onOutputReplace:(C,y)=>{x.setOutput(C,y)},resolveCommand:f,retryBudget:p,serviceEventBridge:r??void 0,spawnContext:a,stdinRegistry:w,strictEnvFailure:m,workspaceRoot:i});return{dynamic:j,lifeCycle:g,stdinRegistry:w,store:x,taskExecutor:P}},si=async({dynamic:t,initialTasks:e,lifeCycle:s,options:r,persistentTasks:i,projectGraph:o,runtime:n,stdinRegistry:l,store:d,taskExecutor:h,taskGraph:f,workspaceRoot:p})=>{const{childEnvPolicyFor:a,preTraceCheck:m,resolveCommand:w,runnerOptions:j,spawnContext:M}=n,x=await St(e,j,{childEnvPolicy:a,lifeCycle:s,preTraceCheck:m,projectGraph:o,resolveChildEnv:(g,k)=>ke(M,g,k),resolveCommand:w,taskExecutor:h,taskGraph:f,workspaceRoot:p});if(i.length>0&&!r.failFast){const g=new Promise(k=>{const P=d.subscribe(()=>{const C=d.getSnapshot();(C.rerunRequested||C.retryTaskId)&&(P(),k())});t.renderIsDone.then(()=>{P(),k()}).catch(()=>{P(),k()})});await Bt(i,M,{abortSignal:g,lifeCycle:s,stdinRegistry:l,store:d})}return x},ri=async({dynamic:t,store:e})=>{let s=null;return{action:await new Promise(i=>{const o=e.subscribe(()=>{const n=e.getSnapshot();n.rerunRequested&&(e.acknowledgeRerun(),o(),i("rerun")),n.retryTaskId&&(s=e.acknowledgeRetry(),o(),i("retry"))});t.renderIsDone.then(()=>{o(),i("quit")}).catch(()=>{o(),i("quit")})}),retryTaskId:s}},le="@voidzero-dev/vite-task-client",Ke="@visulima/task-runner-client",Pe=`npm:${Ke}@^1`,Xt=ne(".vis",".vite-client-override-declined"),Me="pnpm-workspace.yaml",ni=["dependencies","devDependencies","optionalDependencies","peerDependencies"],Jt=t=>{try{return JSON.parse(we(t,"utf8"))}catch{return}},ii=t=>{const e=ne(t,Me);if(he(e))try{return Ft(we(e,"utf8")).toJS()?.overrides}catch{return}},oi=t=>t==="pnpm"||t==="aube"?"pnpm.overrides":t==="yarn"?"resolutions":"overrides",ci=t=>{const e=ne(t,Me);try{const s=Ft(we(e,"utf8"));return s.setIn(["overrides",le],Pe),qe(e,s.toString()),!0}catch{return!1}},mt=t=>t!==void 0&&ni.some(e=>t[e]?.[le]!==void 0),ai=(t,e)=>t!==void 0&&(t.pnpm?.overrides?.[le]!==void 0||t.overrides?.[le]!==void 0||t.resolutions?.[le]!==void 0)||e?.[le]!==void 0,li=(t,e=[])=>{const s=Jt(ne(t,"package.json")),r=he(ne(t,"node_modules","@voidzero-dev","vite-task-client"));return{alreadyOverridden:ai(s,ii(t)),declined:he(ne(t,Xt)),manager:kr(t)?.manager,present:mt(s)||r||e.some(i=>mt(i))}},di=t=>{try{const e=ne(t,Xt);or(Tt(e),{recursive:!0}),qe(e,`Declined adding the ${le} → ${Ke} override.
|
|
42
42
|
Delete this file to be asked again.
|
|
43
43
|
`)}catch{}},ui=(t,e="npm")=>{const s=`${e} install`;if((e==="pnpm"||e==="aube")&&he(ne(t,Me))&&ci(t))return{file:Me,installCommand:s};const r=ne(t,"package.json"),i=Jt(r);if(!i)return;const o=oi(e);o==="pnpm.overrides"?(i.pnpm??={},i.pnpm.overrides??={},i.pnpm.overrides[le]=Pe):(i[o]??={},i[o][le]=Pe);try{qe(r,`${JSON.stringify(i,void 0,4)}
|
|
44
44
|
`)}catch{return}return{file:"package.json",installCommand:s}},fi=async(t,e)=>{const s=li(t,e.projectManifests);if(!s.present||s.alreadyOverridden||s.declined)return!1;const r=Tr({input:process.stdin,output:process.stdout});try{e.logger.info(`Detected ${le}. Its cache hints no-op under @visulima/task-runner unless aliased to ${Ke} (a drop-in replacement).`);const i=await new Promise(n=>{r.question("Add the override now? [y/N] ",n)});if(!/^y(?:es)?$/i.test(i.trim()))return di(t),e.logger.info("Skipped. Delete .vis/.vite-client-override-declined to be asked again."),!1;const o=ui(t,s.manager);return o===void 0?(e.logger.warn("Could not write the override automatically — add it manually (see @visulima/task-runner-client README)."),!1):(e.logger.info(`Added "${le}": "${Pe}" to ${o.file}. Run \`${o.installCommand}\` to apply it.`),!0)}finally{r.close()}},hi=async({config:t,logger:e,options:s,packageJsons:r,workspaceRoot:i})=>{await Cr(i,t.toolchain,{error:l=>{e.error(l)},info:l=>{e.info(l)},warn:l=>{e.warn(l)}},!!s.skipToolchain);const o=s.preflight!==!1&&t.preflight?.lockfile!==!1,n=br(i,Se,{warn:l=>{e.warn(l)}},{skip:!o});if(!n.shouldContinue)throw new Error(`${n.formattedMessage??"preflight: lockfile drift detected"} (pass --no-preflight to bypass)`);o&&!Se&&process.stdin.isTTY&&process.stdout.isTTY&&await fi(i,{interactive:!0,logger:{info:l=>{e.info(l)},warn:l=>{e.warn(l)}},projectManifests:[...r.values()]})},pi=/\$(?:\{([A-Z_]\w*)(:-[^}]*)?\}|([A-Z_]\w*))/gi,mi=new Set(["0","!","#","$","*","-","?","@","_"]),gi=t=>{const e=new Map;for(const s of t.matchAll(pi)){const r=s[1],i=s[3],o=s[2],n=r??i;if(n===void 0||mi.has(n))continue;const l=o!==void 0,d=e.get(n);d===void 0?e.set(n,l):d&&!l&&e.set(n,!1)}return[...e.entries()].map(([s,r])=>({hasDefault:r,name:s}))},wi=t=>{const{command:e,processEnv:s,taskEnv:r,taskId:i}=t,o=gi(e);if(o.length===0)return;const n=[];for(const{hasDefault:l,name:d}of o){if(l)continue;const h=r[d],f=s[d];h===void 0&&f===void 0&&n.push(d)}if(n.length!==0)return{missing:n.toSorted(),taskId:i}},vi=t=>{const e=t.missing.map(s=>`$${s}`).join(", ");return`Strict env: ${t.taskId} references unset variable${t.missing.length===1?"":"s"} ${e}. Set ${t.missing.length===1?"it":"them"} in the task env, an envFile, or the parent shell — or opt out with options.strictEnv: false.`},yi=async({configTaskRunner:t,logger:e,options:s,runnerOptions:r,workspaceRoot:i})=>{const o=cs(t.remoteCache);if(o){const n=tn(s.cacheMode),l=sn(s.cacheBackend);if(r.remoteCache={...o,...n?{mode:n}:{},...l?{backend:l}:{}},r.remoteCache.attestation){const{expectedIdentity:d,requireOnDownload:h}=r.remoteCache.attestation;if(!(d!==void 0&&("github"in d&&typeof d.github?.ref=="string"&&typeof d.github.repo=="string"&&typeof d.github.workflow=="string"||"oidcIssuer"in d&&typeof d.oidcIssuer=="string"&&(typeof d.san=="string"||typeof d.sanRegex=="string"))))throw new Error("[vis run] remoteCache.attestation requires a pinned keyless signer via `expectedIdentity`. Use one of:\n • { github: { repo, workflow, ref } } (GitHub Actions — recommended)\n • { oidcIssuer, san } (literal identity; vis regex-escapes + anchors it)\n • { oidcIssuer, sanRegex } (advanced: raw regex, you own anchoring)\nWithout it, verification is integrity-only — use `remoteCache.signing` (HMAC) for that instead.");"sanRegex"in d&&(!d.sanRegex.startsWith("^")||!d.sanRegex.endsWith("$"))&&e.warn("[vis run] remoteCache.attestation.expectedIdentity.sanRegex is not anchored (^…$). sigstore matches it as a regex; an unanchored value is substring-matched and weakens the identity pin. Prefer the literal `san` form unless you need a pattern.");const{installCommandFor:p,isSigstoreInstalled:a}=await import("./loader.js");a()||e.warn(`[vis run] remoteCache.attestation is configured but the optional \`sigstore\` package is not installed. Cache uploads will be unsigned and signed entries can't be verified until you install it:
|
|
45
|
-
${p(i)}`);const{buildCacheAttestationHooks:m}=await import("./cache-attestation.js");r.remoteCache.attestation=m({expectedIdentity:d,onReject:(w,j)=>{e.warn(`[vis run] remote cache entry ${w.slice(0,12)} rejected: attestation ${j}. Treating as a cache miss.`)},onVerifyFailure:w=>{e.warn(`[vis run] attestation verification failed: ${w}`)},requireOnDownload:h,workspaceRoot:i})}}else(s.cacheMode||s.cacheBackend)&&e.warn("[vis run] --cache-mode and --cache-backend require a `remoteCache` block in vis.config.ts (or TURBO_API env); ignoring.")},xi=async({affectedFiles:t,config:e,currentOs:s,initialTasks:r,invocationCwd:i,logger:o,options:n,persistentTasks:l,projectsWithTarget:d,serviceEnvByTaskId:h,serviceResult:f,target:p,taskGraph:a,visConfig:m,workspaceRoot:w})=>{const j=Date.now(),M=Cs(),x=(
|
|
45
|
+
${p(i)}`);const{buildCacheAttestationHooks:m}=await import("./cache-attestation.js");r.remoteCache.attestation=m({expectedIdentity:d,onReject:(w,j)=>{e.warn(`[vis run] remote cache entry ${w.slice(0,12)} rejected: attestation ${j}. Treating as a cache miss.`)},onVerifyFailure:w=>{e.warn(`[vis run] attestation verification failed: ${w}`)},requireOnDownload:h,workspaceRoot:i})}}else(s.cacheMode||s.cacheBackend)&&e.warn("[vis run] --cache-mode and --cache-backend require a `remoteCache` block in vis.config.ts (or TURBO_API env); ignoring.")},xi=async({affectedFiles:t,config:e,currentOs:s,initialTasks:r,invocationCwd:i,logger:o,options:n,persistentTasks:l,projectsWithTarget:d,serviceEnvByTaskId:h,serviceResult:f,target:p,taskGraph:a,visConfig:m,workspaceRoot:w})=>{const j=Date.now(),M=Cs(),x=(_,z)=>{const q=z instanceof Error?z.message:String(z);o.warn(`Plugin error in ${_}: ${q}`)};await Is(M,e.plugins);const g=typeof n.profile=="string"?n.profile:void 0,k=async _=>{if(!g)return;const z=kt(_,a,j),q=g.startsWith("/")?g:`${w}/${g}`;await ls(z,q),o.info(`Profile written to ${g}`)},P=e.taskRunner??{},C=Zs(w,n.cacheDir,P.cacheDirectory,e.sharedWorktreeCache),y=er(C,w,e.branchScopedCache),E=Zr(process.env.VIS_RUN_CONCURRENCY_LIMIT);E&&"invalid"in E&&o.warn(`VIS_RUN_CONCURRENCY_LIMIT=${E.invalid} is not a positive number; falling back to default concurrency.`);const R=E&&"value"in E?E.value:void 0,$=n.parallel??R??3,O=n.strictEnv??e.strictEnv??!1,T=new Set,b={dryRun:n.dryRun??!1,parallel:$,skipNxCache:!n.cache,summarize:n.summarize??!1,...P,cacheDirectory:y,dataDirectory:P.dataDirectory??Ce(w),namedInputs:e.namedInputs,onDiagnostic:(_,z)=>{T.has(_)||(T.add(_),o.warn(z))},onFingerprint:async(_,z)=>{await M.callHook("task:fingerprint",_,z)}},B=_=>Hs(b.env,je(_)?.env),D=Ws({affectedFiles:t,childEnvPolicy:B,initCwd:i,serviceEnvByTaskId:h,taskSlots:$,workspaceRoot:w}),N=_=>ze(_,t,s),A=(_,z,q)=>{if(!(je(_)?.strictEnv??O))return;const ae=ke(D,_,q),de=D.childEnvPolicy(_),Y=wi({command:z,processEnv:de.mode==="clean"?as(process.env,de):process.env,taskEnv:ae.env,taskId:_.id});return Y?vi(Y):void 0},L=(_,z)=>{const q=N(_);return q===void 0?void 0:A(_,q,z)};await yi({configTaskRunner:P,logger:o,options:n,runnerOptions:b,workspaceRoot:w});const G=process.stdout.isTTY&&!Se,V=m?.run?.quietOnSuccess===!0,W=e.tui?.autoExit??(V?3:!1),X={args:{parallel:b.parallel,targets:[p]},autoExit:W,projectNames:d,tasks:[...r,...l].flatMap(_=>{const z=Object.values(a.tasks).filter(q=>q.segment!==void 0&&q.id.startsWith(`${_.id}#`));return z.length>0?z:[_]}),totalTaskCount:Object.keys(a.tasks).length+l.length},H=typeof n.retryBudget=="number"?n.retryBudget:void 0,Q=H===void 0?void 0:ei(H),J=new Es(M,x),te=new Ir(w),re=Kn(n.outputStyle,m?.run?.quietOnSuccess);if(f.satisfiedServices.length>0)for(const _ of f.satisfiedServices){const z=f.serviceDependentsByServiceId.get(_.id)??[];try{await M.callHook("service:attach",_,z)}catch(q){x("service:attach",q)}}return{childEnvPolicyFor:B,failureLogLifeCycle:te,hookLifeCycle:J,hooks:M,isTTY:G,lifecycleOptions:X,maybeWriteProfile:k,outputStyle:re,preTraceCheck:L,resolveCommand:N,runnerOptions:b,sharedRetryBudget:Q,spawnContext:D,startTime:j,strictEnvFailure:A}},ji=async t=>{if(process.env.VIS_NO_SHELL_HISTORY)return;if(Gr()==="win32"){try{await bi(t)}catch{}return}const e=process.env.SHELL;if(!e)return;const s=Ds(e);try{if(s==="zsh"){await Si(t);return}if(s==="bash"){await ki(t);return}s==="fish"&&await Ti(t)}catch{}},Xe=t=>t.replaceAll(/[\u0000-\u001F\u007F]/gu," ").trimEnd(),Si=async t=>{const e=process.env.HISTFILE??ne(process.env.ZDOTDIR??Ve(),".zsh_history"),s=`: ${Math.floor(Date.now()/1e3)}:0;${Xe(t)}
|
|
46
46
|
`;await Oe(e,s)},ki=async t=>{const e=process.env.HISTFILE??ne(Ve(),".bash_history");await Oe(e,`${Xe(t)}
|
|
47
47
|
`)},bi=async t=>{const e=process.env.VIS_PSREADLINE_HISTORY,s=process.env.APPDATA;if(e===void 0&&(s===void 0||s===""))return;const r=e??ne(s,"Microsoft","Windows","PowerShell","PSReadLine","ConsoleHost_history.txt");await Nr(Tt(r),{recursive:!0}),await Oe(r,`${Xe(t)}\r
|
|
48
48
|
`)},Ti=async t=>{const e=ne(Ve(),".local","share","fish","fish_history"),r=`- cmd: ${t.replaceAll("\\","\\\\").replaceAll(`
|
|
@@ -175,8 +175,8 @@ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
|
175
175
|
try { process.kill(-child.pid, "SIGTERM"); } catch {}
|
|
176
176
|
process.exit(1);
|
|
177
177
|
})();
|
|
178
|
-
`,eo=()=>{const t=dr(ne(Wr(),"vis-services-")),e=ne(t,"bootstrap.mjs");return At(e,Zi),{runDir:t,scriptPath:e}},Zt=(t,e,s)=>{const r=s.replaceAll(/[^\w-]/g,"_");return{configFile:ne(t,`${r}.json`),logFile:ne(t,`${r}.log`),pidFile:ne(t,`${r}.pid`),scriptPath:e}},to=t=>{const{paths:e,service:s}=t,r=s.config.readiness?.tcp?.port??s.config.port;if(typeof r!="number")throw new TypeError(`Service ${s.id} has no TCP readiness port — declare \`service.port\` or \`service.readiness.tcp.port\`.`);const i={...s.env,PATH:hs(s.cwd,s.env)};return{command:s.command,cwd:s.cwd,env:i,host:s.config.readiness?.tcp?.host??"127.0.0.1",id:s.id,logFile:e.logFile,pidFile:e.pidFile,port:r,timeoutMs:s.config.readiness?.tcp?.timeoutMs??3e4}},so=t=>`node ${JSON.stringify(t.scriptPath)} ${JSON.stringify(t.configFile)}`,ro=t=>{const{id:e,visBin:s,workspaceRoot:r}=t;return`node ${JSON.stringify(s)} service start ${JSON.stringify(e)} --cwd ${JSON.stringify(r)}`},no=t=>{const{missingServiceIds:e,mode:s,taskGraph:r,visBin:i,workspaceRoot:o}=t,{services:n,skipped:l}=Qt(o,e,r);if(n.length===0)return{chain:[],ephemeralPidFiles:[],runDir:void 0,serviceEnvByTaskId:new Map,skipped:l};const d=Qi(n.map(x=>x.id),r),h=new Map(n.map(x=>[x.id,x])),f=[],p=[];if(s==="ephemeral")for(const x of d){const g=h.get(x);g&&p.push({id:x,payload:to({paths:{logFile:"",pidFile:""},service:g})})}let a;s==="ephemeral"&&(a=eo());let m;for(const x of d){const g=h.get(x),k=r.tasks[x];if(!g||!k)continue;let P;if(s==="ephemeral"){const C=Zt(a.runDir,a.scriptPath,x),E={...p.find(R=>R.id===x).payload,logFile:C.logFile,pidFile:C.pidFile};At(C.configFile,JSON.stringify(E)),P=so(C),f.push(C.pidFile)}else P=ro({id:x,visBin:i,workspaceRoot:o});if(k.overrides={...k.overrides,command:P},k.cache=!1,r.tasks[x]=k,m!==void 0){const C=r.dependencies[x]??[];C.includes(m)||(r.dependencies[x]=[...C,m])}m=x}const w=new Set(d),j=new Map,M=x=>{const g=new Set,k=[...r.dependencies[x]??[]],P=new Set;for(;k.length>0;){const C=k.pop();if(!P.has(C)){P.add(C),w.has(C)&&g.add(C);for(const y of r.dependencies[C]??[])P.has(y)||k.push(y)}}return[...g].sort()};for(const x of Object.keys(r.dependencies)){if(w.has(x))continue;const g=M(x);if(g.length===0)continue;const k={};for(const P of g){const C=h.get(P);C?.config.env&&Object.assign(k,C.config.env)}Object.keys(k).length>0&&j.set(x,k)}return{chain:d,ephemeralPidFiles:f,runDir:a?.runDir,serviceEnvByTaskId:j,skipped:l}},io=new Set(["auto","ephemeral","off","persistent"]),oo=t=>t.cli!==void 0?"cli":t.config===void 0?"default":"config",co=t=>{const{cli:e,config:s,isCi:r,isPersistentTarget:i,isTty:o,target:n}=t;if(e!==void 0&&!io.has(e))throw new Error(`--services: expected one of auto|ephemeral|persistent|off, got "${e}"`);const l=e??s??(o&&!r?"auto":"off");return l==="off"?"off":l==="ephemeral"?"ephemeral":l==="persistent"?"registry":i||n==="dev"?"ephemeral":"registry"},ao=async({config:t,initialTasks:e,logger:s,options:r,persistentTasks:i,target:o,taskGraph:n,workspaceRoot:l})=>{let d=e,h=n;const f=process.env.VIS_VERSION??"0.0.0",p=r.dryRun?void 0:async $=>{try{return await Os($.config,{timeoutMs:ln}),!0}catch{return!1}},a=await As(l),m=await Vi({initialTasks:[...d,...i],probe:p,registeredEntries:a,taskGraph:h,visVersion:f}),w=[];let j,M=0;const x=[],g=new Map;let k=[];const P=new Set;let C=null,y=null;if(m.diagnostics.length>0){const $=!!(process.stdout.isTTY&&process.stdin.isTTY),O=r.dryRun?"off":co({cli:r.services,config:t.run?.services,isCi:!!Se,isPersistentTarget:i.length>0,isTty:$,target:o});if(O==="off"){for(const
|
|
179
|
-
`))}const T=m.diagnostics.map(A=>A.targetId),b=O,
|
|
178
|
+
`,eo=()=>{const t=dr(ne(Wr(),"vis-services-")),e=ne(t,"bootstrap.mjs");return At(e,Zi),{runDir:t,scriptPath:e}},Zt=(t,e,s)=>{const r=s.replaceAll(/[^\w-]/g,"_");return{configFile:ne(t,`${r}.json`),logFile:ne(t,`${r}.log`),pidFile:ne(t,`${r}.pid`),scriptPath:e}},to=t=>{const{paths:e,service:s}=t,r=s.config.readiness?.tcp?.port??s.config.port;if(typeof r!="number")throw new TypeError(`Service ${s.id} has no TCP readiness port — declare \`service.port\` or \`service.readiness.tcp.port\`.`);const i={...s.env,PATH:hs(s.cwd,s.env)};return{command:s.command,cwd:s.cwd,env:i,host:s.config.readiness?.tcp?.host??"127.0.0.1",id:s.id,logFile:e.logFile,pidFile:e.pidFile,port:r,timeoutMs:s.config.readiness?.tcp?.timeoutMs??3e4}},so=t=>`node ${JSON.stringify(t.scriptPath)} ${JSON.stringify(t.configFile)}`,ro=t=>{const{id:e,visBin:s,workspaceRoot:r}=t;return`node ${JSON.stringify(s)} service start ${JSON.stringify(e)} --cwd ${JSON.stringify(r)}`},no=t=>{const{missingServiceIds:e,mode:s,taskGraph:r,visBin:i,workspaceRoot:o}=t,{services:n,skipped:l}=Qt(o,e,r);if(n.length===0)return{chain:[],ephemeralPidFiles:[],runDir:void 0,serviceEnvByTaskId:new Map,skipped:l};const d=Qi(n.map(x=>x.id),r),h=new Map(n.map(x=>[x.id,x])),f=[],p=[];if(s==="ephemeral")for(const x of d){const g=h.get(x);g&&p.push({id:x,payload:to({paths:{logFile:"",pidFile:""},service:g})})}let a;s==="ephemeral"&&(a=eo());let m;for(const x of d){const g=h.get(x),k=r.tasks[x];if(!g||!k)continue;let P;if(s==="ephemeral"){const C=Zt(a.runDir,a.scriptPath,x),E={...p.find(R=>R.id===x).payload,logFile:C.logFile,pidFile:C.pidFile};At(C.configFile,JSON.stringify(E)),P=so(C),f.push(C.pidFile)}else P=ro({id:x,visBin:i,workspaceRoot:o});if(k.overrides={...k.overrides,command:P},k.cache=!1,r.tasks[x]=k,m!==void 0){const C=r.dependencies[x]??[];C.includes(m)||(r.dependencies[x]=[...C,m])}m=x}const w=new Set(d),j=new Map,M=x=>{const g=new Set,k=[...r.dependencies[x]??[]],P=new Set;for(;k.length>0;){const C=k.pop();if(!P.has(C)){P.add(C),w.has(C)&&g.add(C);for(const y of r.dependencies[C]??[])P.has(y)||k.push(y)}}return[...g].sort()};for(const x of Object.keys(r.dependencies)){if(w.has(x))continue;const g=M(x);if(g.length===0)continue;const k={};for(const P of g){const C=h.get(P);C?.config.env&&Object.assign(k,C.config.env)}Object.keys(k).length>0&&j.set(x,k)}return{chain:d,ephemeralPidFiles:f,runDir:a?.runDir,serviceEnvByTaskId:j,skipped:l}},io=new Set(["auto","ephemeral","off","persistent"]),oo=t=>t.cli!==void 0?"cli":t.config===void 0?"default":"config",co=t=>{const{cli:e,config:s,isCi:r,isPersistentTarget:i,isTty:o,target:n}=t;if(e!==void 0&&!io.has(e))throw new Error(`--services: expected one of auto|ephemeral|persistent|off, got "${e}"`);const l=e??s??(o&&!r?"auto":"off");return l==="off"?"off":l==="ephemeral"?"ephemeral":l==="persistent"?"registry":i||n==="dev"?"ephemeral":"registry"},ao=async({config:t,initialTasks:e,logger:s,options:r,persistentTasks:i,target:o,taskGraph:n,workspaceRoot:l})=>{let d=e,h=n;const f=process.env.VIS_VERSION??"0.0.0",p=r.dryRun?void 0:async $=>{try{return await Os($.config,{timeoutMs:ln}),!0}catch{return!1}},a=await As(l),m=await Vi({initialTasks:[...d,...i],probe:p,registeredEntries:a,taskGraph:h,visVersion:f}),w=[];let j,M=0;const x=[],g=new Map;let k=[];const P=new Set;let C=null,y=null;if(m.diagnostics.length>0){const $=!!(process.stdout.isTTY&&process.stdin.isTTY),O=r.dryRun?"off":co({cli:r.services,config:t.run?.services,isCi:!!Se,isPersistentTarget:i.length>0,isTty:$,target:o});if(O==="off"){for(const G of m.diagnostics)s.error(G.message);const A=oo({cli:r.services,config:t.run?.services}),L=[];throw r.dryRun?L.push("`--dry-run` never starts services; drop it to let vis boot them."):A==="default"?L.push("vis only auto-starts service deps in an interactive terminal by default (this run is CI or non-TTY).","Pass `--services=ephemeral` to boot them for this run, or set `run.services` in vis.config.ts."):A==="cli"?L.push("`--services=off` was passed; use `--services=ephemeral` to boot them for this run."):L.push('`run.services: "off"` is set in vis.config.ts; override it with `--services=ephemeral`.'),new pe([`${m.diagnostics.length} service dependency error(s) — start the missing services or invoke them directly.`,...L].join(`
|
|
179
|
+
`))}const T=m.diagnostics.map(A=>A.targetId),b=O,B=b==="registry"?Qt(l,T,h):void 0,D=process.argv[1]??"vis",N=no({missingServiceIds:T,mode:b,taskGraph:h,visBin:D,workspaceRoot:l});if(N.skipped.length>0){for(const{id:A,reason:L}of N.skipped)s.error(`Cannot auto-start ${A}: ${L}`);throw new pe(`${N.skipped.length} service(s) cannot be auto-started — invoke them directly or add a service config.`)}w.push(...N.ephemeralPidFiles),j=N.runDir,k=N.chain;for(const A of N.chain)P.add(A);if(b==="registry"&&(M=N.chain.length,x.push(...N.chain)),N.chain.length>0){const A=new wt(N.chain),L=new Map;if(b==="ephemeral"&&N.runDir)for(const G of N.chain){const V=Zt(N.runDir,`${N.runDir}/bootstrap.mjs`,G);L.set(G,{ephemeral:{configFile:V.configFile,cwd:l,logFile:V.logFile,pidFile:V.pidFile,scriptPath:V.scriptPath},mode:"ephemeral"})}else if(b==="registry"&&B)for(const G of B.services)L.set(G.id,{mode:"registry",registry:{command:G.command,config:G.config,cwd:G.cwd,env:G.env}});if(L.size>0){const G=new Ki({indexToId:new Map,services:L,sink:{crashed:(V,W)=>{A.markCrashed(V,W)},failed:(V,W,X)=>{A.markFailed(V,W,X)},log:(V,W)=>{A.appendLog(V,W)},ready:(V,W)=>{A.markReady(V,W)},started:(V,W)=>{A.markStarted(V,W),b==="registry"&&W!==null&&g.set(V,W)},starting:V=>{A.markStarting(V)}},workspaceRoot:l});C=A,y=G}}for(const[A,L]of N.serviceEnvByTaskId){const G=m.serviceEnvByTaskId.get(A)??{};m.serviceEnvByTaskId.set(A,{...G,...L})}}const E=new Set(i.map($=>$.id));if(d=m.initialTasks.filter($=>!E.has($.id)),h=m.taskGraph,k.length>0&&(d=[...k.map(O=>h.tasks[O]).filter(O=>O!==void 0),...d]),i.length>0){const $=new Set(i.map(D=>D.id)),O={};for(const[D,N]of Object.entries(h.tasks))$.has(D)||(O[D]=N);const T={};for(const[D,N]of Object.entries(h.dependencies))$.has(D)||(T[D]=N.filter(A=>!$.has(A)));const b=new Set;for(const D of Object.values(T))for(const N of D)b.add(N);const B=Object.keys(O).filter(D=>!b.has(D));h={dependencies:T,roots:B,tasks:O}}const{serviceEnvByTaskId:R}=m;if(m.satisfiedServices.length>0){const $=m.satisfiedServices.map(O=>O.id).join(", ");if(s.debug?.(`Auto-attached to running services: ${$}`),C)for(const O of m.satisfiedServices)C.registerService(O.id);else C=new wt(m.satisfiedServices.map(O=>O.id));for(const O of m.satisfiedServices){const T=O.config.readiness?.tcp?.port??O.config.port??0,b=O.config.readiness?.tcp?.host??"127.0.0.1";C.markReady(O.id,{host:b,port:T})}}return{ephemeralPidFiles:w,initialTasks:d,injectedServiceIdSet:P,registryStartedCount:M,registryStartedIds:x,registryStartedPids:g,serviceDockStore:C,serviceEnvByTaskId:R,serviceEventBridge:y,serviceResult:m,serviceRunDir:j,taskGraph:h}},lo=(t,e)=>{const s=e?.trim();if(!s)return{filter:void 0,tasks:[...t]};const r=s.toLowerCase();return{filter:s,tasks:t.filter(i=>i.target.project.toLowerCase().includes(r))}},uo=[""," Watch keybinds:"," r, Enter rerun"," a rerun all (clear filter)"," p filter by project name"," q, Ctrl+C quit"," h, ? show this help",""].join(`
|
|
180
180
|
`),fo=t=>{t.write(`${uo}
|
|
181
181
|
`)},ho=async(t,e)=>{e.write("filter projects (empty to cancel) > ");const s=t,r=s.isRaw===!0;if(r)try{s.setRawMode?.(!1)}catch{}return await new Promise(i=>{let o="";const n=l=>{o+=typeof l=="string"?l:l.toString("utf8");const d=o.indexOf(`
|
|
182
182
|
`);if(d===-1)return;const h=o.slice(0,d).replace(/\r$/,"").trim();if(t.off("data",n),r)try{s.setRawMode?.(!0)}catch{}i(h.length>0?h:void 0)};t.on("data",n)})},po=t=>{const{handlers:e}=t,s=t.input??process.stdin,r=t.output??process.stdout,i=t.promptFilter??ho;if(!s||s.isTTY===!1)return{close:()=>{}};$r(s);const o=s.isRaw===!0;try{s.setRawMode?.(!0)}catch{return{close:()=>{}}}typeof s.resume=="function"&&s.resume();let n=!1;const l=async f=>{if(f.ctrl===!0&&f.name==="c"){await e.onQuit();return}if(!n)switch(f.name){case"?":case"h":{await e.onHelp();break}case"a":{await e.onClearFilter();break}case"p":{n=!0;try{const p=await i(s,r);p===void 0?r.write(`filter cancelled.
|
|
@@ -186,6 +186,6 @@ ${m.split(`
|
|
|
186
186
|
`).map(j=>` ${j}`).join(`
|
|
187
187
|
`)}`)}throw new pe(h.length>0?`${l}
|
|
188
188
|
${h.join(`
|
|
189
|
-
`)}`:l)}},es=({logger:t,registryStartedCount:e,stopServicesOnExit:s})=>{e>0&&(t.info(""),s?t.info(`${String(e)} service(s) stopped (--stop-services).`):t.info(`${String(e)} service(s) started in the background. Run \`vis service stop --all\` to clean up.`))},go=async({initialTasks:t,logger:e,options:s,persistentTasks:r,projectGraph:i,projectsWithTarget:o,registryStartedCount:n,runtime:l,serviceEventBridge:d,stopServicesOnExit:h,taskGraph:f,visConfig:p,workspace:a,workspaceRoot:m})=>{const{childEnvPolicyFor:w,failureLogLifeCycle:j,hookLifeCycle:M,hooks:x,lifecycleOptions:g,maybeWriteProfile:k,outputStyle:P,preTraceCheck:C,resolveCommand:y,runnerOptions:E,sharedRetryBudget:R,spawnContext:$,startTime:O,strictEnvFailure:T}=l;let b=t;const
|
|
189
|
+
`)}`:l)}},es=({logger:t,registryStartedCount:e,stopServicesOnExit:s})=>{e>0&&(t.info(""),s?t.info(`${String(e)} service(s) stopped (--stop-services).`):t.info(`${String(e)} service(s) started in the background. Run \`vis service stop --all\` to clean up.`))},go=async({initialTasks:t,logger:e,options:s,persistentTasks:r,projectGraph:i,projectsWithTarget:o,registryStartedCount:n,runtime:l,serviceEventBridge:d,stopServicesOnExit:h,taskGraph:f,visConfig:p,workspace:a,workspaceRoot:m})=>{const{childEnvPolicyFor:w,failureLogLifeCycle:j,hookLifeCycle:M,hooks:x,lifecycleOptions:g,maybeWriteProfile:k,outputStyle:P,preTraceCheck:C,resolveCommand:y,runnerOptions:E,sharedRetryBudget:R,spawnContext:$,startTime:O,strictEnvFailure:T}=l;let b=t;const B=new Map,D=typeof s.log=="string"?s.log.toLowerCase():"",N=D==="labeled"||D==="grouped"||D==="interleaved"?D:void 0,A=N?ps(N):void 0,L=new jt([new Xn({...g,ciGrouping:p?.run?.ciGrouping??"auto",logReporter:A,outputStyle:P}),M,j]),G=Kt({hooks:x,lifeCycle:L,mutexPool:B,resolveCommand:y,retryBudget:R,serviceEventBridge:d??void 0,spawnContext:$,strictEnvFailure:T,workspaceRoot:m}),V=async()=>{const H=Date.now(),Q=await St(b,E,{childEnvPolicy:w,lifeCycle:L,preTraceCheck:C,projectGraph:i,resolveChildEnv:(q,oe)=>ke($,q,oe),resolveCommand:y,taskExecutor:G,taskGraph:f,workspaceRoot:m}),J=Date.now()-H;if(s.summarize){const q=kt(Q,f,O);await ms(q,m,{dataDirectory:Ce(m)})}let te=!1;for(const[,q]of Q)q.status==="failure"&&(te=!0);const re=rr(Q,J),_=nr(m),z=ir(m,J,_);return e.info(""),e.info(` ${re}${z?` ${z}`:""}`),{hasFailure:te,results:Q,runHistory:_}},W=await V();await x.callHook("run:after",W.results),await k(W.results);const{hasFailure:X}=W;if(s.watch){const H=o.map(Z=>{const ie=a.projects[Z]?.root;if(ie)return ie.startsWith("/")?ie:`${m}/${ie}`}).filter(Z=>Z!==void 0),Q=b;let J;const te=Z=>{const se=lo(Q,Z);return J=se.filter,b=se.tasks,se.tasks.length};let re=!1,_=W.results;const z=()=>{const Z=tt(_,m);if(Z.directories.length>0&&Z.files.size>0){const se=qr(Z.files,m,Z.directories);return{handle:st({filter:se,onChange:oe,paths:Z.directories}),mode:"tracked"}}return{handle:st({onChange:oe,paths:H}),mode:"roots"}};let q;const oe=async Z=>{if(!re){re=!0;try{e.info(`Change detected in ${Z.length} file(s), rerunning…`),_=(await V()).results,q?.close(),q=z().handle}finally{re=!1}}},ae=z();q=ae.handle;const de=ae.mode==="tracked"?`Watching ${String(tt(_,m).files.size)} tracked file(s)`:`Watching ${String(H.length)} project root(s)`;e.info(`${de} — edit a file to rerun, press h for keybinds, q to quit.`);const Y=async()=>{if(!re){re=!0;try{if(b.length===0){e.info("No tasks match the active filter — press a to clear it.");return}_=(await V()).results,q?.close(),q=z().handle}finally{re=!1}}};await new Promise(Z=>{let se=!1,ie;const ue=()=>{I()},I=()=>{se||(se=!0,ie?.close(),process.off("SIGINT",ue),q?.close(),Z())};process.on("SIGINT",ue),ie=po({handlers:{onClearFilter:async()=>{const S=te(void 0);e.info(`Filter cleared — running ${String(S)} task(s).`),await Y()},onFilter:async S=>{const F=J,ee=te(S);if(ee===0){e.info(`Filter "${S}" matched no projects — keeping previous filter.`),te(F);return}e.info(`Filter "${S}" matched ${String(ee)} task(s).`),await Y()},onHelp:()=>{fo(process.stdout)},onQuit:()=>{I()},onRerun:Y}})});return}mo({firstRun:W,hasFailure:X,logger:e,options:s,workspaceRoot:m}),r.length>0&&!s.failFast&&await Bt(r,$,void 0),es({logger:e,registryStartedCount:n,stopServicesOnExit:h})},wo=t=>t.split(",").map(e=>e.trim()).filter(e=>e!==""),vo=(t,e,s)=>{const r=new Set,i=[];if(t===void 0||t.trim()==="")return{skipTaskIds:r,unmatchedPatterns:i};const o=[...s],n=new Set(o),l=new Map;for(const d of o){const h=d.lastIndexOf(":");if(h===-1)continue;const f=d.slice(h+1),p=l.get(f);p===void 0?l.set(f,[d]):p.push(d)}for(const d of wo(t)){if(d.startsWith("~:"))throw new Error(`--skip-cache does not support the closest-project selector "~:" (received "${d}"). Use \`pkg:target\`, \`:target\`, or \`#tag:target\`.`);if(n.has(d)){r.add(d);continue}const h=_r(d);if(!h){i.push(d);continue}let f=!1;switch(h.kind){case"all":{const p=l.get(h.target)??[];for(const a of p)r.add(a),f=!0;break}case"project":{const p=h.projects?.[0];if(p!==void 0){const a=`${p}:${h.target}`;n.has(a)&&(r.add(a),f=!0)}break}case"tag":{const{tag:p}=h;if(p!==void 0){const a=l.get(h.target)??[];for(const m of a){const w=m.slice(0,m.lastIndexOf(":"));e.projects[w]?.tags?.includes(p)===!0&&(r.add(m),f=!0)}}break}}f||i.push(d)}return{skipTaskIds:r,unmatchedPatterns:i}},yo=({affectedFiles:t,config:e,initialTasks:s,logger:r,options:i,persistentTasks:o,projectGraph:n,projectOptions:l,workspace:d})=>{const h=new Set([...s,...o].map(p=>p.id)),f=vs([...s,...o],{onCycleBroken:p=>{r.warn(`Ignoring dev-only dependency cycle (build order is ambiguous): ${p.join(" → ")}`)},onUnmatchedProjectSelector:p=>{r.warn(`dependsOn.projects entry "${p}" matched no project — that dependency edge was not created.`)},projectGraph:n,targetDefaults:e.tasks,workspace:d});for(const[p,a]of Object.entries(f.tasks)){const m=a.target.project,w=a.target.target,j=l.get(m)?.[w];if(!j){h.has(p)||r.warn(`${w} required via dependsOn but no command is configured for ${m} — skipping (no-op).`);continue}const M=d.projects[m];let x=!1;const g={...a.overrides};g.visOptions===void 0&&j.options&&(g.visOptions=j.options,x=!0),g.command===void 0&&j.command&&(g.command=bt(j.command,{affectedFiles:t,projectRoot:M?.root}),x=!0),x&&(a.overrides=g,f.tasks[p]=a)}if(typeof i.skipCache=="string"&&i.skipCache.trim()!=="")if(i.cache){const p=vo(i.skipCache,d,Object.keys(f.tasks));for(const a of p.skipTaskIds){const m=f.tasks[a];m!==void 0&&(m.cache=!1)}p.unmatchedPatterns.length>0&&r.warn(`--skip-cache: no tasks matched ${p.unmatchedPatterns.map(a=>`"${a}"`).join(", ")}`),p.skipTaskIds.size>0&&r.debug?.(`--skip-cache: bypassing cache for ${String(p.skipTaskIds.size)} task(s)`)}else r.debug?.("--skip-cache ignored: --no-cache already disables caching for the whole run");return f},xo=({logger:t,options:e,projectOptions:s,taskGraph:r})=>{let i=r;e.reverse&&(i=gs(i),t.debug?.(`Reversed task graph: ${String(i.roots.length)} new root(s) (originally leaves)`));for(const o of Object.values(i.tasks)){const n=s.get(o.target.project)?.[o.target.target]?.options;o.splitCompound&&$t(n)!==void 0&&(t.warn(`splitCompound ignored for ${o.id}: it uses a custom shell. Running the command as one unit.`),o.splitCompound=void 0)}return i=ws(i,{commandOf:o=>o.overrides.command,onDiagnostic:(o,n)=>{t.warn(n)}}),i},ts=t=>t.replace(/^--?/u,""),jo=new Set(["0","1","false","no","true","yes"]),So=t=>!t.startsWith("-")||/^-(?:\d|\.\d)/u.test(t),xt=(t,e,s,r,i,o)=>{if(r!==void 0)return t.set(e,r),0;const n=i[o+1];return(s?.type??"string")==="boolean"?n!==void 0&&jo.has(n.toLowerCase())?(t.set(e,n.toLowerCase()),1):(t.set(e,"true"),0):n!==void 0&&So(n)?(t.set(e,n),1):(t.set(e,"true"),0)},ko=(t,e)=>{const s=t.type??"string";if(s==="number"){const r=e.trim(),i=Number(r);return r===""||!Number.isFinite(i)?{error:`--${t.name} expects a number, got "${e}"`}:{value:i}}if(s==="boolean")return["1","true","yes"].includes(e.toLowerCase())?{value:!0}:["0","false","no"].includes(e.toLowerCase())?{value:!1}:{error:`--${t.name} expects a boolean, got "${e}"`};if(s==="enum"){const r=t.choices??[];return r.includes(e)?{value:e}:{error:`--${t.name} must be one of [${r.join(", ")}], got "${e}"`}}return{value:e}},bo=t=>{const e=[],s=new Set;for(const r of t){const i=r.name||"<unnamed>";(!r.name||!/^[a-zA-Z][\w-]*$/u.test(r.name))&&e.push(`argument name "${i}" is empty or invalid (start with a letter; use letters, digits, '-', '_')`),s.has(r.name)&&e.push(`duplicate argument name "${i}"`),s.add(r.name),r.alias!==void 0&&r.alias.length!==1&&e.push(`argument "${i}" alias "${r.alias}" must be a single character`);const o=r.type??"string";if(o==="enum"&&(r.choices===void 0||r.choices.length===0)&&e.push(`argument "${i}" has type "enum" but declares no choices`),r.default!==void 0){const n=typeof r.default;o==="number"&&n==="number"||o==="boolean"&&n==="boolean"||(o==="string"||o==="enum")&&n==="string"?o==="enum"&&r.choices&&!r.choices.includes(r.default)&&e.push(`argument "${i}" default "${String(r.default)}" is not one of its choices`):e.push(`argument "${i}" default ${JSON.stringify(r.default)} does not match type "${o}"`)}}return e},To=(t,e)=>{const s=new Map,r=new Map;for(const h of t)s.set(h.name,h),h.alias&&r.set(h.alias,h);const i=new Map,o=[];for(let h=0;h<e.length;h+=1){const f=e[h];if(f==="--"){o.push(...e.slice(h+1));break}if(f.startsWith("--no-")){i.set(ts(f.slice(5)),"false");continue}const p=/^--([^=]+)(?:=(.*))?$/su.exec(f);if(p){const w=p[1];h+=xt(i,w,s.get(w),p[2],e,h);continue}const a=/^-([^=-])(?:=(.*))?$/su.exec(f),m=a?.[1];if(a&&m!==void 0){const w=r.get(m);h+=xt(i,w?.name??m,w,a[2],e,h);continue}o.push(f)}const n={},l=[];let d=0;for(const h of t){let f=i.get(h.name);if(f===void 0&&h.positional&&d<o.length&&(f=o[d],d+=1),f===void 0){h.default!==void 0?n[h.name]=h.default:h.required&&l.push(`missing required argument --${h.name}`);continue}const{error:p,value:a}=ko(h,f);p?l.push(p):a!==void 0&&(n[h.name]=a)}return{errors:l,values:n}},$o=t=>`VIS_ARG_${ts(t).replaceAll(/[^a-zA-Z0-9]+/gu,"_").toUpperCase()}`,Co=t=>{const e={};for(const[s,r]of Object.entries(t))e[$o(s)]=String(r);return e},De=(t,e,s)=>{const r=[`Usage: vis run ${t} [-- <args>]`];if(e&&r.push("",e),s.length===0)return r.join(`
|
|
190
190
|
`);r.push("","Arguments:");const i=s.map(n=>{const l=n.positional?`<${n.name}>`:`--${n.name}`,d=n.alias?`, -${n.alias}`:"";return{left:`${l}${d}`,right:n}}),o=Math.max(...i.map(n=>n.left.length));for(const{left:n,right:l}of i){const d=[],h=l.type??"string";d.push(h==="enum"?`enum(${(l.choices??[]).join("|")})`:h),l.required&&d.push("required"),l.default!==void 0&&d.push(`default: ${String(l.default)}`);const f=`${l.description??""}${l.description?" ":""}[${d.join(", ")}]`;r.push(` ${n.padEnd(o)} ${f}`)}return r.join(`
|
|
191
|
-
`)},Io=(t,e,s,r)=>{if(!s||s.length===0)return{env:{},kind:"ok"};const i=bo(s);if(i.length>0)return{errors:i.map(n=>`invalid \`arguments\` schema for "${t}": ${n}`),help:De(t,e,s),kind:"invalid"};if(r.includes("--help")||r.includes("-h"))return{kind:"help",text:De(t,e,s)};const o=To(s,r);return o.errors.length>0?{errors:o.errors,help:De(t,e,s),kind:"invalid"}:{env:Co(o.values),kind:"ok"}},Eo=({forwardedArgs:t,logger:e,projectsWithTarget:s,projectTargetIndex:r,target:i})=>{const o=s.map(f=>({project:f,schema:r.get(f)?.arguments})).filter(f=>Array.isArray(f.schema)&&f.schema.length>0),n=new Map;for(const{project:f,schema:p}of o){const a=JSON.stringify(p),m=n.get(a)??[];m.push(f),n.set(a,m)}if(n.size>1){const f=[...n.values()].map(p=>p.join(", ")).join(" | ");throw new Error(`Target "${i}" declares conflicting \`arguments\` schemas across projects (${f}). Run a single project (e.g. \`vis run ${o[0]?.project}:${i}\` or --projects=<name>) so the argument contract is unambiguous.`)}const l=o[0]?.schema,d=r.get(o[0]?.project??s[0])?.description,h=Io(i,d,l,t);if(h.kind==="help"){e.info(h.text);return}if(h.kind==="invalid"){e.info(`Invalid arguments for "${i}":`);for(const f of h.errors)e.info(` ✖ ${f}`);throw e.info(""),e.info(h.help),new Error(`Invalid arguments for target "${i}"`)}return{env:h.env}},Ro=new Set(["cache","command","dependsOn","fingerprintEnv","hashMode","inputs","outputs","parallelism","splitCompound","untrackedEnv"]),Po=t=>t?Object.keys(t).filter(e=>Ro.has(e)).toSorted():[],Mo=(t,e)=>`${t}: ${e.map(s=>`"${s}"`).join(", ")} ${e.length===1?"is a target property, not an option":"are target properties, not options"}, so ${e.length===1?"it is":"they are"} ignored under "options". Move ${e.length===1?"it":"them"} next to "command".`,Fo=({affectedFiles:t,forwardedArgs:e,logger:s,options:r,projectsWithTarget:i,projectTargetIndex:o,target:n,taskArgumentEnvVars:l,workspace:d})=>{const h=r.pty,f=rn(r.hashMode);let p=i.map(j=>{const M=d.projects[j],x=o.get(j),g={project:j,target:n},k=`${j}:${n}`,P=h?{...x.options,pty:x.options?.pty??!0}:x.options,C=x.command?bt(x.command,{affectedFiles:t,projectRoot:M?.root}):x.command,y=M?.root&&M.root.length>0?M.root:".",E=(x.outputs??[]).map($=>typeof $!="string"?$:$.replaceAll("{projectRoot}",y).replaceAll("{projectName}",j)),R=Po(x.options);return R.length>0&&s.warn(Mo(k,R)),{cache:x.cache,declaresInputs:x.inputs!==void 0,fingerprintEnv:x.fingerprintEnv,hashMode:f??x.hashMode,id:k,outputs:E,overrides:{command:C,...e.length>0?{[Dt]:e}:{},...Object.keys(l).length>0?{[Vs]:l}:{},...P?{visOptions:P}:{}},parallelism:x.parallelism,projectRoot:M?.root,splitCompound:x.splitCompound,target:g,untrackedEnv:x.untrackedEnv}});const a=[],m=[];for(const j of p)je(j)?.persistent?(j.cache=!1,a.push(j)):m.push(j);p=m;const w=ys(r.partition);if(w&&(p=xs.partitionTasks(p,w),s.info(`Partition ${w.index}/${w.total}: running ${p.length} task(s)`),p.length===0)){s.info("No tasks assigned to this partition.");return}return{initialTasks:p,persistentTasks:a}},Oo=({affectedFiles:t,config:e,forwardedArgs:s,logger:r,options:i,projectGraph:o,projectOptions:n,projectsWithTarget:l,projectTargetIndex:d,target:h,workspace:f})=>{const p=Eo({forwardedArgs:s,logger:r,projectsWithTarget:l,projectTargetIndex:d,target:h});if(!p)return;const a=Fo({affectedFiles:t,forwardedArgs:s,logger:r,options:i,projectsWithTarget:l,projectTargetIndex:d,target:h,taskArgumentEnvVars:p.env,workspace:f});if(!a)return;const{persistentTasks:m}=a,{initialTasks:w}=a,j=yo({affectedFiles:t,config:e,initialTasks:w,logger:r,options:i,persistentTasks:m,projectGraph:o,projectOptions:n,workspace:f});return{initialTasks:w,persistentTasks:m,taskGraph:j}},dc=async({argument:t,logger:e,options:s,visConfig:r,workspaceRoot:i})=>{if(!i)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const o=i;if(bs({options:s,visConfig:r},o),Ts(o),s.lastDetails){await en(o,e);return}const n=process.cwd(),l=await js(o,r),{config:d,fileOwners:h,packageJsons:f,projectOptions:p,workspace:a}=Ss(o,r,l),m=ks(o,a,f),w=await Gi({argument:t,config:d,fileOwners:h,logger:e,options:s,packageJsons:f,projectGraph:m,projectOptions:p,visConfig:r,workspace:a,workspaceRoot:o});if(!w)return;const{affectedFiles:j,currentOs:M,forwardedArgs:x,projectsWithTarget:g,projectTargetIndex:k,target:P}=w,C=Oo({affectedFiles:j,config:d,forwardedArgs:x,logger:e,options:s,projectGraph:m,projectOptions:p,projectsWithTarget:g,projectTargetIndex:k,target:P,workspace:a});if(!C)return;const{persistentTasks:y}=C;let{initialTasks:E,taskGraph:R}=C;await hi({config:d,logger:e,options:s,packageJsons:f,workspaceRoot:o});const $=await ao({config:d,initialTasks:E,logger:e,options:s,persistentTasks:y,target:P,taskGraph:R,workspaceRoot:o});E=$.initialTasks,R=$.taskGraph;const{ephemeralPidFiles:O,injectedServiceIdSet:T,registryStartedCount:b,registryStartedIds:
|
|
191
|
+
`)},Io=(t,e,s,r)=>{if(!s||s.length===0)return{env:{},kind:"ok"};const i=bo(s);if(i.length>0)return{errors:i.map(n=>`invalid \`arguments\` schema for "${t}": ${n}`),help:De(t,e,s),kind:"invalid"};if(r.includes("--help")||r.includes("-h"))return{kind:"help",text:De(t,e,s)};const o=To(s,r);return o.errors.length>0?{errors:o.errors,help:De(t,e,s),kind:"invalid"}:{env:Co(o.values),kind:"ok"}},Eo=({forwardedArgs:t,logger:e,projectsWithTarget:s,projectTargetIndex:r,target:i})=>{const o=s.map(f=>({project:f,schema:r.get(f)?.arguments})).filter(f=>Array.isArray(f.schema)&&f.schema.length>0),n=new Map;for(const{project:f,schema:p}of o){const a=JSON.stringify(p),m=n.get(a)??[];m.push(f),n.set(a,m)}if(n.size>1){const f=[...n.values()].map(p=>p.join(", ")).join(" | ");throw new Error(`Target "${i}" declares conflicting \`arguments\` schemas across projects (${f}). Run a single project (e.g. \`vis run ${o[0]?.project}:${i}\` or --projects=<name>) so the argument contract is unambiguous.`)}const l=o[0]?.schema,d=r.get(o[0]?.project??s[0])?.description,h=Io(i,d,l,t);if(h.kind==="help"){e.info(h.text);return}if(h.kind==="invalid"){e.info(`Invalid arguments for "${i}":`);for(const f of h.errors)e.info(` ✖ ${f}`);throw e.info(""),e.info(h.help),new Error(`Invalid arguments for target "${i}"`)}return{env:h.env}},Ro=new Set(["cache","command","dependsOn","fingerprintEnv","hashMode","inputs","outputs","parallelism","splitCompound","untrackedEnv"]),Po=t=>t?Object.keys(t).filter(e=>Ro.has(e)).toSorted():[],Mo=(t,e)=>`${t}: ${e.map(s=>`"${s}"`).join(", ")} ${e.length===1?"is a target property, not an option":"are target properties, not options"}, so ${e.length===1?"it is":"they are"} ignored under "options". Move ${e.length===1?"it":"them"} next to "command".`,Fo=({affectedFiles:t,forwardedArgs:e,logger:s,options:r,projectsWithTarget:i,projectTargetIndex:o,target:n,taskArgumentEnvVars:l,workspace:d})=>{const h=r.pty,f=rn(r.hashMode);let p=i.map(j=>{const M=d.projects[j],x=o.get(j),g={project:j,target:n},k=`${j}:${n}`,P=h?{...x.options,pty:x.options?.pty??!0}:x.options,C=x.command?bt(x.command,{affectedFiles:t,projectRoot:M?.root}):x.command,y=M?.root&&M.root.length>0?M.root:".",E=(x.outputs??[]).map($=>typeof $!="string"?$:$.replaceAll("{projectRoot}",y).replaceAll("{projectName}",j)),R=Po(x.options);return R.length>0&&s.warn(Mo(k,R)),{cache:x.cache,declaresInputs:x.inputs!==void 0,fingerprintEnv:x.fingerprintEnv,hashMode:f??x.hashMode,id:k,outputs:E,overrides:{command:C,...e.length>0?{[Dt]:e}:{},...Object.keys(l).length>0?{[Vs]:l}:{},...P?{visOptions:P}:{}},parallelism:x.parallelism,projectRoot:M?.root,splitCompound:x.splitCompound,target:g,untrackedEnv:x.untrackedEnv}});const a=[],m=[];for(const j of p)je(j)?.persistent?(j.cache=!1,a.push(j)):m.push(j);p=m;const w=ys(r.partition);if(w&&(p=xs.partitionTasks(p,w),s.info(`Partition ${w.index}/${w.total}: running ${p.length} task(s)`),p.length===0)){s.info("No tasks assigned to this partition.");return}return{initialTasks:p,persistentTasks:a}},Oo=({affectedFiles:t,config:e,forwardedArgs:s,logger:r,options:i,projectGraph:o,projectOptions:n,projectsWithTarget:l,projectTargetIndex:d,target:h,workspace:f})=>{const p=Eo({forwardedArgs:s,logger:r,projectsWithTarget:l,projectTargetIndex:d,target:h});if(!p)return;const a=Fo({affectedFiles:t,forwardedArgs:s,logger:r,options:i,projectsWithTarget:l,projectTargetIndex:d,target:h,taskArgumentEnvVars:p.env,workspace:f});if(!a)return;const{persistentTasks:m}=a,{initialTasks:w}=a,j=yo({affectedFiles:t,config:e,initialTasks:w,logger:r,options:i,persistentTasks:m,projectGraph:o,projectOptions:n,workspace:f});return{initialTasks:w,persistentTasks:m,taskGraph:j}},dc=async({argument:t,logger:e,options:s,visConfig:r,workspaceRoot:i})=>{if(!i)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const o=i;if(bs({options:s,visConfig:r},o),Ts(o),s.lastDetails){await en(o,e);return}const n=process.cwd(),l=await js(o,r),{config:d,fileOwners:h,packageJsons:f,projectOptions:p,workspace:a}=Ss(o,r,l),m=ks(o,a,f),w=await Gi({argument:t,config:d,fileOwners:h,logger:e,options:s,packageJsons:f,projectGraph:m,projectOptions:p,visConfig:r,workspace:a,workspaceRoot:o});if(!w)return;const{affectedFiles:j,currentOs:M,forwardedArgs:x,projectsWithTarget:g,projectTargetIndex:k,target:P}=w,C=Oo({affectedFiles:j,config:d,forwardedArgs:x,logger:e,options:s,projectGraph:m,projectOptions:p,projectsWithTarget:g,projectTargetIndex:k,target:P,workspace:a});if(!C)return;const{persistentTasks:y}=C;let{initialTasks:E,taskGraph:R}=C;await hi({config:d,logger:e,options:s,packageJsons:f,workspaceRoot:o});const $=await ao({config:d,initialTasks:E,logger:e,options:s,persistentTasks:y,target:P,taskGraph:R,workspaceRoot:o});E=$.initialTasks,R=$.taskGraph;const{ephemeralPidFiles:O,injectedServiceIdSet:T,registryStartedCount:b,registryStartedIds:B,registryStartedPids:D,serviceDockStore:N,serviceEnvByTaskId:A,serviceEventBridge:L,serviceResult:G,serviceRunDir:V}=$,W=s.stopServices,X=fn({ephemeralPidFiles:O,registryStartedIds:B,registryStartedPids:D,serviceEventBridge:L,serviceRunDir:V,stopServicesOnExit:W,workspaceRoot:o});X.install();try{if(R=xo({logger:e,options:s,projectOptions:p,taskGraph:R}),s.dryRun){hn({config:d,logger:e,persistentTasks:y,taskGraph:R});return}const H=await xi({affectedFiles:j,config:d,currentOs:M,initialTasks:E,invocationCwd:n,logger:e,options:s,persistentTasks:y,projectsWithTarget:g,serviceEnvByTaskId:A,serviceResult:G,target:P,taskGraph:R,visConfig:r,workspaceRoot:o});if(await H.hooks.callHook("run:before",{tasks:E,workspaceRoot:o}),H.isTTY){const{spawnContext:Q}=H,{dynamic:J,lifeCycle:te,stdinRegistry:re,store:_,taskExecutor:z}=ti({injectedServiceIdSet:T,runtime:H,serviceDockStore:N,serviceEventBridge:L,workspaceRoot:o});let q="rerun",oe=null,ae=new Map;for(;q!=="quit";){if(q==="rerun")ae=await si({dynamic:J,initialTasks:E,lifeCycle:te,options:s,persistentTasks:y,projectGraph:m,runtime:H,stdinRegistry:re,store:_,taskExecutor:z,taskGraph:R,workspaceRoot:o});else if(q==="retry"&&oe){const Y=R.tasks[oe]??E.find(se=>se.id===oe),Z=Y?ze(Y,Q.affectedFiles,M):void 0;if(Y&&Z){te.startTasks?.([Y]);const se=new We(Ie),ie=Us(Q,Y),I=(await $e([{command:Z,cwd:ie.cwd,env:ie.env,inheritEnv:ie.inheritEnv,name:Y.id,ptySize:{cols:process.stdout.columns??80,rows:process.stdout.rows??24},stdin:"pty"}],{onEvent:S=>{S.kind==="started"&&S.write&&re.set(Y.id,{kill:S.kill,resize:S.resize,write:S.write}),(S.kind==="stdout"||S.kind==="stderr")&&S.text&&(se.write(S.text),_.setOutput(Y.id,se.toString())),S.kind==="close"&&re.delete(Y.id)}})).closeEvents[0];te.endTasks?.([{code:I?.exitCode??1,status:I?.exitCode===0?"success":"failure",task:Y,terminalOutput:_.getSnapshot().outputs.get(Y.id)}])}else Y&&te.endTasks?.([{code:1,status:"failure",task:Y,terminalOutput:`No command configured for ${Y.id}`}]);oe=null,_.markDone()}const de=await ri({dynamic:J,store:_});q=de.action,oe=de.retryTaskId}await J.renderIsDone,await H.hooks.callHook("run:after",ae),await H.maybeWriteProfile(ae),es({logger:e,registryStartedCount:b,stopServicesOnExit:W})}else await go({initialTasks:E,logger:e,options:s,persistentTasks:y,projectGraph:m,projectsWithTarget:g,registryStartedCount:b,runtime:H,serviceEventBridge:L,stopServicesOnExit:W,taskGraph:R,visConfig:r,workspace:a,workspaceRoot:o})}finally{await X.finish()}};export{dc as default};
|