@visulima/vis 1.0.0-alpha.36 → 1.0.0-alpha.38
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 +13 -0
- package/LICENSE.md +1 -503
- package/dist/bin.js +1 -1
- package/dist/binx.js +1 -1
- package/dist/config/index.d.ts +7 -0
- package/dist/packem_chunks/DEFAULT_CLEAN_KEEP.js +1 -0
- package/dist/packem_chunks/bin.js +302 -515
- package/dist/packem_chunks/bloom-sync.js +1 -1
- package/dist/packem_chunks/catalog-detector.js +1 -0
- package/dist/packem_chunks/detect.js +3 -0
- package/dist/packem_chunks/detect2.js +8 -0
- package/dist/packem_chunks/discord.js +4 -0
- package/dist/packem_chunks/dynamic-import.js +1 -0
- package/dist/packem_chunks/extra-files.js +3 -0
- package/dist/packem_chunks/fix.js +1 -1
- package/dist/packem_chunks/git.js +3 -0
- package/dist/packem_chunks/handler10.js +1 -1
- package/dist/packem_chunks/handler12.js +1 -1
- package/dist/packem_chunks/handler13.js +1 -1
- package/dist/packem_chunks/handler14.js +1 -1
- package/dist/packem_chunks/handler15.js +1 -1
- package/dist/packem_chunks/handler16.js +1 -1
- package/dist/packem_chunks/handler17.js +1 -1
- package/dist/packem_chunks/handler18.js +1 -1
- package/dist/packem_chunks/handler19.js +1 -1
- package/dist/packem_chunks/handler21.js +1 -1
- package/dist/packem_chunks/handler27.js +1 -1
- package/dist/packem_chunks/handler28.js +1 -1
- package/dist/packem_chunks/handler29.js +1 -1
- package/dist/packem_chunks/handler3.js +4 -4
- package/dist/packem_chunks/handler30.js +2 -7
- package/dist/packem_chunks/handler31.js +2 -33
- package/dist/packem_chunks/handler32.js +2 -3
- package/dist/packem_chunks/handler33.js +3 -8
- package/dist/packem_chunks/handler34.js +6 -4
- package/dist/packem_chunks/handler35.js +1 -1
- package/dist/packem_chunks/handler36.js +42 -5
- package/dist/packem_chunks/handler37.js +8 -11
- package/dist/packem_chunks/handler38.js +9 -3
- package/dist/packem_chunks/handler39.js +74 -21
- package/dist/packem_chunks/handler4.js +1 -1
- package/dist/packem_chunks/handler40.js +5 -61
- package/dist/packem_chunks/handler41.js +4 -3
- package/dist/packem_chunks/handler42.js +3 -6
- package/dist/packem_chunks/handler43.js +2 -24
- package/dist/packem_chunks/handler44.js +1 -25
- package/dist/packem_chunks/handler45.js +1 -153
- package/dist/packem_chunks/handler46.js +1 -10
- package/dist/packem_chunks/handler47.js +3 -24
- package/dist/packem_chunks/handler48.js +1 -322
- package/dist/packem_chunks/handler49.js +7 -708
- package/dist/packem_chunks/handler5.js +6 -6
- package/dist/packem_chunks/handler50.js +33 -48
- package/dist/packem_chunks/handler51.js +3 -27
- package/dist/packem_chunks/handler52.js +8 -3
- package/dist/packem_chunks/handler53.js +4 -200
- package/dist/packem_chunks/handler54.js +1 -38
- package/dist/packem_chunks/handler55.js +12 -0
- package/dist/packem_chunks/handler56.js +7 -0
- package/dist/packem_chunks/handler57.js +5 -0
- package/dist/packem_chunks/handler58.js +11 -0
- package/dist/packem_chunks/handler59.js +3 -0
- package/dist/packem_chunks/handler60.js +22 -0
- package/dist/packem_chunks/handler61.js +61 -0
- package/dist/packem_chunks/handler62.js +3 -0
- package/dist/packem_chunks/handler63.js +6 -0
- package/dist/packem_chunks/handler64.js +708 -0
- package/dist/packem_chunks/handler65.js +24 -0
- package/dist/packem_chunks/handler66.js +25 -0
- package/dist/packem_chunks/handler67.js +153 -0
- package/dist/packem_chunks/handler68.js +10 -0
- package/dist/packem_chunks/handler69.js +24 -0
- package/dist/packem_chunks/handler7.js +1 -1
- package/dist/packem_chunks/handler70.js +322 -0
- package/dist/packem_chunks/handler71.js +48 -0
- package/dist/packem_chunks/handler72.js +27 -0
- package/dist/packem_chunks/handler73.js +3 -0
- package/dist/packem_chunks/handler74.js +190 -0
- package/dist/packem_chunks/handler75.js +38 -0
- package/dist/packem_chunks/handler8.js +1 -1
- package/dist/packem_chunks/handler9.js +1 -1
- package/dist/packem_chunks/heal-accept.js +1 -1
- package/dist/packem_chunks/heal.js +1 -1
- package/dist/packem_chunks/help-command.js +1 -1
- package/dist/packem_chunks/index.js +1 -7
- package/dist/packem_chunks/index2.js +7 -0
- package/dist/packem_chunks/interface.js +2 -0
- package/dist/packem_chunks/keys-refresh.js +1 -1
- package/dist/packem_chunks/list.js +1 -1
- package/dist/packem_chunks/loader.js +1 -1
- package/dist/packem_chunks/orchestrator.js +39 -0
- package/dist/packem_chunks/pre-mode.js +2 -0
- package/dist/packem_chunks/print-config.js +2 -0
- package/dist/packem_chunks/prompts.js +7 -0
- package/dist/packem_chunks/publish-guards.js +1 -0
- package/dist/packem_chunks/registry.js +48 -0
- package/dist/packem_chunks/resolveFormatter.js +9 -0
- package/dist/packem_chunks/security.js +1 -0
- package/dist/packem_chunks/shell-runner.js +1 -0
- package/dist/packem_chunks/slack.js +2 -0
- package/dist/packem_chunks/snapshot.js +2 -0
- package/dist/packem_chunks/stage-publisher.js +1 -0
- package/dist/packem_chunks/staged-registry.js +2 -0
- package/dist/packem_chunks/state.js +3 -0
- package/dist/packem_chunks/success-walk.js +8 -0
- package/dist/packem_chunks/sync.js +1 -1
- package/dist/packem_chunks/sync2.js +1 -1
- package/dist/packem_chunks/tripwire.js +1 -1
- package/dist/packem_chunks/verify-lockfile.js +2 -2
- package/dist/packem_chunks/version-resolver.js +2 -0
- package/dist/packem_chunks/webhook.js +1 -0
- package/dist/packem_chunks/workflow-templates.js +167 -0
- package/dist/packem_chunks/workspace.js +2 -0
- package/dist/packem_shared/AfterAllProjectsVersioned-CAKI2nWf.js +1 -0
- package/dist/packem_shared/ReleaseClient-YHzBIxYS.js +1 -0
- package/dist/packem_shared/VisReleaseError-DMGRBTNO.js +1 -0
- package/dist/packem_shared/{ai-analysis-DT3bU-_M.js → ai-analysis-K-DKU3ZA.js} +1 -1
- package/dist/packem_shared/{ai-fix-BkNqd5nP.js → ai-fix-BPrYoCk8.js} +1 -1
- package/dist/packem_shared/api.d-BPftyU9r.d.ts +27 -0
- package/dist/packem_shared/createAdapter-bU4DIP3F.js +1 -0
- package/dist/packem_shared/createVersionActions-BK43SNDH.js +1 -0
- package/dist/packem_shared/{cyclonedx-86-DbHtf.js → cyclonedx-kYozDyxp.js} +3 -3
- package/dist/packem_shared/defineFormatter-D5dCp6Kv.js +1 -0
- package/dist/packem_shared/dependency-scan-anTuZB1t.js +1 -0
- package/dist/packem_shared/{docker-tNrDU3oK.js → docker-BMLrNtWm.js} +1 -1
- package/dist/packem_shared/{failure-log-Dwqt6_Ga.js → failure-log-CEWP3bP0.js} +1 -1
- package/dist/packem_shared/index-BJbpNthk.js +1 -0
- package/dist/packem_shared/index-CgcF6_wo.js +1 -0
- package/dist/packem_shared/{index-C0Vj3XF8.js → index-D1_fbGbj.js} +1 -1
- package/dist/packem_shared/interface.d-B7VK2rcH.d.ts +148 -0
- package/dist/packem_shared/interface.d-Cezzifoh.d.ts +106 -0
- package/dist/packem_shared/{missing-package-json-41VUWFBY.js → missing-package-json-BfWUxTGv.js} +1 -1
- package/dist/packem_shared/{native-config-sync-BKAZ0NIs.js → native-config-sync-BEkJW7g3.js} +8 -8
- package/dist/packem_shared/pm-runner-OGResYrA.js +1 -0
- package/dist/packem_shared/provenance-_CJjMKwu.js +1 -0
- package/dist/packem_shared/public-api-WqUCiyIe.js +131 -0
- package/dist/packem_shared/{registry-keys-Bf2zzlcZ.js → registry-keys-BfFto6vI.js} +1 -1
- package/dist/packem_shared/{resolve-explicit-jH0RKyMJ.js → resolve-explicit-CMDl55Nz.js} +2 -2
- package/dist/packem_shared/s1ngularity-Dhr3bPk0.js +1 -0
- package/dist/packem_shared/{scan-progress-JBbd9QeT.js → scan-progress-DG7_JmTV.js} +1 -1
- package/dist/packem_shared/{signatures-D1H6h6GH.js → signatures-C730vkyK.js} +2 -2
- package/dist/packem_shared/slug-DoueYuLo.js +1 -0
- package/dist/packem_shared/spinner-CV3WVJLv.js +1 -0
- package/dist/packem_shared/sticky-comment-D6_7-w8T.js +1 -0
- package/dist/packem_shared/{tabs-BqUepRaD.js → tabs-BuTy5gPV.js} +1 -1
- package/dist/packem_shared/{typosquats-C8qg1neE.js → typosquats-DN78xx1x.js} +1 -1
- package/dist/packem_shared/use-measured-height-_eVGWtWt.js +1 -0
- package/dist/packem_shared/verify-6WCmFmy8.js +1 -0
- package/dist/packem_shared/{vis-update-app-CTwRkNgj.js → vis-update-app-k3fDxech.js} +1 -1
- package/dist/release/core/changelog/index.d.ts +5 -0
- package/dist/release/core/changelog/index.js +1 -0
- package/dist/release/core/package-managers/index.d.ts +6 -0
- package/dist/release/core/package-managers/index.js +1 -0
- package/dist/release/core/version-actions/index.d.ts +14 -0
- package/dist/release/core/version-actions/index.js +1 -0
- package/dist/release/index.d.ts +196 -0
- package/dist/release/index.js +1 -0
- package/dist/release/plugin-sdk.d.ts +127 -0
- package/dist/release/plugin-sdk.js +1 -0
- package/dist/release/presets.d.ts +225 -0
- package/dist/release/presets.js +1 -0
- package/dist/release/types.d.ts +1377 -0
- package/dist/release/types.js +1 -0
- package/index.d.ts +201 -201
- package/index.js +578 -752
- package/package.json +53 -11
- package/schemas/vis-config.schema.json +1394 -6
- package/schemas/vis-release-config.schema.json +1390 -0
- package/dist/packem_shared/dependency-scan-BDTH898x.js +0 -1
- package/dist/packem_shared/index-CB4p298r.js +0 -1
- package/dist/packem_shared/index-DMefdF51.js +0 -1
- package/dist/packem_shared/pm-runner-pVihAfxV.js +0 -1
- package/dist/packem_shared/provenance-DMuEftgc.js +0 -1
- package/dist/packem_shared/s1ngularity-BkfgC6NO.js +0 -1
- package/dist/packem_shared/spinner-BXSl864p.js +0 -1
- package/dist/packem_shared/use-measured-height-BBJ9intr.js +0 -1
- package/dist/packem_shared/verify-Du7xZ2BJ.js +0 -1
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import{createRequire as er}from"node:module";import{m as ae,H as ys,J as sr,T as vs,v as rr,l as ir}from"../packem_shared/index-BDmTbWX1.js";import{buildEnhancedPath as nr,enforceProjectConstraints as or,expandTokensInString as qt,parsePartition as ar,TaskScheduler as cr,createTaskGraph as lr,reverseTaskGraph as dr,resolveTurboEnvCompat as ur,CompositeLifeCycle as zt,defaultTaskRunner as Ht,createLogReporter as hr,readLastRunSummary as fr,getLastRunSummaryPath as pr,runConcurrently as Qe,generateRunSummary as Ut,writeChromeTrace as gr,writeRunSummary as mr,TerminalBuffer as ft}from"@visulima/task-runner";import{bj as wr,s as U,a4 as i,a5 as m,m as c,h as pe,k as J,aE as xs,aG as yr,aD as vr,ae as Vt,aH as xr,aI as kr,$ as jr,Q as nt,S as pt,bk as br,M as $r,b as Sr,O as Tr,bl as Cr,bm as Ir,bn as Rr,r as Ve,aK as Er,bo as Mr,z as Ze,X as Fr,bp as Or,bq as Pr,br as Ar,bs as Dr,bt as Lr}from"./bin.js";import{d as Br,r as Nr}from"../packem_shared/lockfile-C8Q1_4KK.js";import{a as js}from"../packem_shared/public-api-WqUCiyIe.js";import{F as Vr}from"../packem_shared/failure-log-CEWP3bP0.js";import{r as Wr}from"../packem_shared/toolchain-pR7AJ-tB.js";import{i as Yr,r as Jr,s as Kr,a as Xr,c as Qr,d as Zr,e as ei,H as ti,f as si,b as ri}from"../packem_shared/lifecycle-4z9hHE5b.js";import{p as ii,r as ni,f as oi}from"../packem_shared/selectors-GCJIe342.js";import{T as bs,C as $s,D as ot,E as Ss}from"../packem_shared/symbols-DPTlrJ3B.js";import{V as lt,E as Jt,q as hi,j as fi}from"../packem_shared/Table-CcVkyULl-B_ef6zfS.js";import{parseStacktrace as pi,codeFrame as gi}from"@visulima/error";import{originalPositionFor as mi,sourceContentFor as wi,loadSourceMap as yi}from"@visulima/source-map";import{o as Ts}from"../packem_shared/spinner-CV3WVJLv.js";import{c as Kt,a as bi,s as Xt}from"../packem_shared/watch-BvIwLG4N.js";const tr=er(import.meta.url),Ue=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Me=s=>{if(typeof Ue<"u"&&Ue.versions&&Ue.versions.node){const[e,t]=Ue.versions.node.split(".").map(Number);if(e>22||e===22&&t>=3||e===20&&t>=16)return Ue.getBuiltinModule(s)}return tr(s)},{existsSync:Ae,mkdirSync:Gr,writeFileSync:gt,readFileSync:Ge,openSync:_r,statSync:Wt,readSync:qr,closeSync:zr,mkdtempSync:Hr}=Me("node:fs"),{createInterface:ks,emitKeypressEvents:Ur}=Me("node:readline"),{spawn:ai}=Me("node:child_process"),{isAbsolute:ci,resolve:Yt,dirname:li,relative:di}=Me("node:path"),{fileURLToPath:ui}=Me("node:url"),{createHash:vi}=Me("node:crypto"),{mkdir:xi,appendFile:at}=Me("node:fs/promises"),{platform:ki,homedir:mt,tmpdir:ji}=Me("node:os"),Qt=new WeakSet,$i=s=>{if(Qt.has(s))return;const e=["y","mo","w","d","h","m","s","ms","future","past"];for(const r of e)if(!Object.hasOwn(s,r))throw new TypeError(`Missing required property: ${r}`);if(typeof s.future!="string"||typeof s.past!="string")throw new TypeError("Properties future and past must be of type string");const t=["y","mo","w","d","h","m","s","ms"];for(const r of t)if(typeof s[r]!="string"&&typeof s[r]!="function")throw new TypeError(`Property ${r} must be of type string or function`);if(s.decimal&&typeof s.decimal!="string")throw new TypeError("Property decimal must be of type string");if(s.delimiter&&typeof s.delimiter!="string")throw new TypeError("Property delimiter must be of type string");if(s._digitReplacements&&!Array.isArray(s._digitReplacements))throw new TypeError("Property _digitReplacements must be an array");if(s._numberFirst&&typeof s._numberFirst!="boolean")throw new TypeError("Property _numberFirst must be of type boolean");if(s.unitMap&&typeof s.unitMap!="object")throw new TypeError("Property unitMap must be an object");if(s.unitMap&&Object.values(s.unitMap).some(r=>typeof r!="string"))throw new TypeError("All values in unitMap must be of type string");Qt.add(s)},Cs=(s,e)=>{e=e||-1;const t=new RegExp(String.raw`^-?\d+(?:\.\d{0,${String(e)}})?`).exec(s.toString());return t===null?s:Number.parseFloat(t[0])},Zt=({unitCount:s,unitName:e},t,r)=>{let{spacer:o}=r;const{maxDecimalPoints:a}=r;let n=".";r.decimal!==void 0?n=r.decimal:t.decimal!==void 0&&(n=t.decimal);let d;"digitReplacements"in r?d=r.digitReplacements:"_digitReplacements"in t&&(d=t._digitReplacements);let f,h=s;a!==void 0&&(h=Cs(s,a));const u=h.toString();if(!t._hideCountIf2||s!==2)if(d){f="";for(const S of u)f+=S==="."?n:d[S]}else f=u.replace(".",n);else f="";const g=t[e];let l=g;return typeof g=="function"&&(l=g(s)),t._hideCountIf2&&s===2&&(o=""),t._numberFirst?l+o+f:f+o+l},Si=(s,e)=>{const{units:t}=e;if(t.length===0)return[];const{unitMeasures:r}=e,o=e.largest??Number.POSITIVE_INFINITY,a={};let n,d,f,h=s;for(d=0;d<t.length;d++){n=t[d];const g=r[n];f=d===t.length-1?h/g:Math.floor(h/g),a[n]=f,h-=f*g}if(e.round){let g=o;for(d=0;d<t.length;d++)if(n=t[d],f=a[n],f!==0&&(g--,g===0)){for(let l=d+1;l<t.length;l++){const S=t[l],R=a[S];a[n]=(a[n]??0)+R*r[S]/r[n],a[S]=0}break}for(d=t.length-1;d>=0;d--){if(n=t[d],f=a[n],f===0)continue;const l=Math.round(f);if(a[n]=l,d===0)break;const S=t[d-1],R=r[S],B=Math.floor(l*r[n]/R);if(B)a[S]=(a[S]??0)+B,a[n]=0;else break}}const u=[];for(d=0;d<t.length&&u.length<o;d++){if(n=t[d],f=a[n],f&&!e.round&&u.length===o-1){let g,l=0;for(g=d+1,t.length;g<t.length;g++){const S=t[g];l+=a[S]*(e.unitMeasures[S]/e.unitMeasures[n])}f+=l,e.maxDecimalPoints!==void 0&&(f=Cs(f,e.maxDecimalPoints))}f&&u.push({unitCount:f,unitName:n})}return u},Ti=(s,e,t)=>{const{language:r,units:o}=e;if(s.length===0){const g=o.at(-1);return Zt({unitCount:0,unitName:g},r,e)}const{conjunction:a,serialComma:n}=e;let d=", ";e.delimiter!==void 0?d=e.delimiter:r.delimiter!==void 0&&(d=r.delimiter);let f="";e.timeAdverb&&t!==0&&(f=r.future??"",t<0&&(f=r.past??""));const h=s.map(g=>Zt(g,r,e));let u;return!a||s.length===1?u=h.join(d):s.length===2?u=h.join(a):u=h.slice(0,-1).join(d)+(n?",":"")+a+(h.at(-1)??""),f&&(u=f.replace("%s",u)),u},Ci=(s,e)=>{if(Number.isNaN(s))throw new TypeError("Expected a valid number");if(typeof s!="number")throw new TypeError("Expected a number for milliseconds input");const t={conjunction:"",language:wr,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};$i(t.language);const r=Math.abs(s),o=Si(r,t);return Ti(o,t,s)},Is=s=>s===155||s===157||s===144||s===152||s===158||s===159,Rs=(s,e)=>{for(let t=e;t<s.length;t+=1){const r=s.codePointAt(t);if(r>=64&&r<=126)return t}return-1},et=(s,e,t)=>{for(let r=e;r<s.length;r+=1){const o=s.codePointAt(r);if(o===156||t&&o===7)return r;if(o===27&&s.codePointAt(r+1)===92)return r+1}return-1},Ii=(s,e)=>{const t=s.codePointAt(e+1);return t===91?Rs(s,e+2):t===93?et(s,e+2,!0):t===80||t===88||t===94||t===95?et(s,e+2,!1):t!==void 0?e+1:-1},Ri=(s,e)=>{const t=s.codePointAt(e);return t===155?Rs(s,e+1):t===157?et(s,e+1,!0):t===144||t===152||t===158||t===159?et(s,e+1,!1):-1},Ei=s=>{if(s.includes(String.fromCodePoint(27)))return!0;for(let e=0;e<s.length;e+=1)if(Is(s.codePointAt(e)))return!0;return!1},Mi=s=>{if(!Ei(s))return s;let e="",t=0,r=0;const{length:o}=s;for(;r<o;){const a=s.codePointAt(r);let n;if(a===27)n=Ii(s,r);else if(Is(a))n=Ri(s,r);else{r+=1;continue}n===-1&&(n=o-1),e+=s.slice(t,r),t=n+1,r=n+1}return e+=s.slice(t),e},$e="@voidzero-dev/vite-task-client",wt="@visulima/task-runner-client",tt=`npm:${wt}@^1`,Es=ae(".vis",".vite-client-override-declined"),st="pnpm-workspace.yaml",Fi=["dependencies","devDependencies","optionalDependencies","peerDependencies"],Ms=s=>{try{return JSON.parse(Ge(s,"utf8"))}catch{return}},Oi=s=>{const e=ae(s,st);if(Ae(e))try{return js(Ge(e,"utf8")).toJS()?.overrides}catch{return}},Pi=s=>s==="pnpm"||s==="aube"?"pnpm.overrides":s==="yarn"?"resolutions":"overrides",Ai=s=>{const e=ae(s,st);try{const t=js(Ge(e,"utf8"));return t.setIn(["overrides",$e],tt),gt(e,t.toString()),!0}catch{return!1}},es=s=>s!==void 0&&Fi.some(e=>s[e]?.[$e]!==void 0),Di=(s,e)=>s!==void 0&&(s.pnpm?.overrides?.[$e]!==void 0||s.overrides?.[$e]!==void 0||s.resolutions?.[$e]!==void 0)||e?.[$e]!==void 0,Li=(s,e=[])=>{const t=Ms(ae(s,"package.json")),r=Ae(ae(s,"node_modules","@voidzero-dev","vite-task-client"));return{alreadyOverridden:Di(t,Oi(s)),declined:Ae(ae(s,Es)),manager:Br(s)?.manager,present:es(t)||r||e.some(o=>es(o))}},Bi=s=>{try{const e=ae(s,Es);Gr(ys(e),{recursive:!0}),gt(e,`Declined adding the ${$e} → ${wt} override.
|
|
2
|
+
Delete this file to be asked again.
|
|
3
|
+
`)}catch{}},Ni=(s,e="npm")=>{const t=`${e} install`;if((e==="pnpm"||e==="aube")&&Ae(ae(s,st))&&Ai(s))return{file:st,installCommand:t};const r=ae(s,"package.json"),o=Ms(r);if(!o)return;const a=Pi(e);a==="pnpm.overrides"?(o.pnpm??={},o.pnpm.overrides??={},o.pnpm.overrides[$e]=tt):(o[a]??={},o[a][$e]=tt);try{gt(r,`${JSON.stringify(o,void 0,4)}
|
|
4
|
+
`)}catch{return}return{file:"package.json",installCommand:t}},Gi=async(s,e)=>{const t=Li(s,e.projectManifests);if(!t.present||t.alreadyOverridden||t.declined)return!1;const r=ks({input:process.stdin,output:process.stdout});try{e.logger.info(`Detected ${$e}. Its cache hints no-op under @visulima/task-runner unless aliased to ${wt} (a drop-in replacement).`);const o=await new Promise(n=>{r.question("Add the override now? [y/N] ",n)});if(!/^y(?:es)?$/i.test(o.trim()))return Bi(s),e.logger.info("Skipped. Delete .vis/.vite-client-override-declined to be asked again."),!1;const a=Ni(s,t.manager);return a===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 "${$e}": "${tt}" to ${a.file}. Run \`${a.installCommand}\` to apply it.`),!0)}finally{r.close()}},_i=({interactive:s,taskPty:e,workspacePty:t})=>e===!0?!0:e===!1?!1:s&&t!==!1,qi=s=>s.split(",").map(e=>e.trim()).filter(e=>e!==""),zi=(s,e,t)=>{const r=new Set,o=[];if(s===void 0||s.trim()==="")return{skipTaskIds:r,unmatchedPatterns:o};const a=[...t],n=new Set(a),d=new Map;for(const f of a){const h=f.lastIndexOf(":");if(h===-1)continue;const u=f.slice(h+1),g=d.get(u);g===void 0?d.set(u,[f]):g.push(f)}for(const f of qi(s)){if(f.startsWith("~:"))throw new Error(`--skip-cache does not support the closest-project selector "~:" (received "${f}"). Use \`pkg:target\`, \`:target\`, or \`#tag:target\`.`);if(n.has(f)){r.add(f);continue}const h=ii(f);if(!h){o.push(f);continue}let u=!1;switch(h.kind){case"all":{const g=d.get(h.target)??[];for(const l of g)r.add(l),u=!0;break}case"project":{const g=h.projects?.[0];if(g!==void 0){const l=`${g}:${h.target}`;n.has(l)&&(r.add(l),u=!0)}break}case"tag":{const{tag:g}=h;if(g!==void 0){const l=d.get(h.target)??[];for(const S of l){const R=S.slice(0,S.lastIndexOf(":"));e.projects[R]?.tags?.includes(g)===!0&&(r.add(S),u=!0)}}break}}u||o.push(f)}return{skipTaskIds:r,unmatchedPatterns:o}},Hi=/\$(?:\{([A-Z_]\w*)(:-[^}]*)?\}|([A-Z_]\w*))/gi,Ui=new Set(["0","!","#","$","*","-","?","@","_"]),Vi=s=>{const e=new Map;for(const t of s.matchAll(Hi)){const r=t[1],o=t[3],a=t[2],n=r??o;if(n===void 0||Ui.has(n))continue;const d=a!==void 0,f=e.get(n);f===void 0?e.set(n,d):f&&!d&&e.set(n,!1)}return[...e.entries()].map(([t,r])=>({hasDefault:r,name:t}))},Wi=s=>{const{command:e,processEnv:t,taskEnv:r,taskId:o}=s,a=Vi(e);if(a.length===0)return;const n=[];for(const{hasDefault:d,name:f}of a){if(d)continue;const h=r[f],u=t[f];h===void 0&&u===void 0&&n.push(f)}if(n.length!==0)return{missing:n.toSorted(),taskId:o}},Yi=s=>{const e=s.missing.map(t=>`$${t}`).join(", ");return`Strict env: ${s.taskId} references unset variable${s.missing.length===1?"":"s"} ${e}. Set ${s.missing.length===1?"it":"them"} in the task env, an envFile, or the parent shell — or opt out with options.strictEnv: false.`},ts=s=>{const e=new Set;for(const t of Object.values(s.projects))for(const r of Object.keys(t.targets??{}))e.add(r);return[...e].sort()},Ji=s=>{const e=new Map;for(const t of s.values())for(const[r,o]of Object.entries(t))for(const a of o.aliases??[])e.has(a)||e.set(a,r);return e},Ki=(s,e)=>e.get(s)??s,Xi=(s,e)=>{if(s.length===0)return e.length;if(e.length===0)return s.length;const t=[];for(let r=0;r<=e.length;r++)t[r]=[r];for(let r=0;r<=s.length;r++)t[0][r]=r;for(let r=1;r<=e.length;r++)for(let o=1;o<=s.length;o++){const a=e[r-1]===s[o-1]?0:1;t[r][o]=Math.min(t[r-1][o]+1,t[r][o-1]+1,t[r-1][o-1]+a)}return t[e.length][s.length]},Qi=(s,e,t=3)=>Fs(s,e,1,t)[0],Fs=(s,e,t=3,r=3)=>{const o=[];for(const a of e){const n=Xi(s.toLowerCase(),a.toLowerCase());n<=r&&o.push({distance:n,name:a})}return o.sort((a,n)=>a.distance-n.distance||a.name.localeCompare(n.name)),o.slice(0,t).map(a=>a.name)},Zi=s=>s.length===0?" (no targets found)":s.map(e=>` - ${e}`).join(`
|
|
5
|
+
`),en=async s=>{if(s.length===0||!process.stdin.isTTY||!process.stdout.isTTY)return;const e=ks({input:process.stdin,output:process.stdout});try{process.stdout.write(`Available targets:
|
|
6
|
+
`);for(const[o,a]of s.entries())process.stdout.write(` ${String(o+1).padStart(2," ")}. ${a}
|
|
7
|
+
`);process.stdout.write(`
|
|
8
|
+
`);const t=(await new Promise(o=>{e.question("Select a target (number or name, blank to cancel): ",o)})).trim();if(t.length===0)return;const r=Number.parseInt(t,10);return Number.isFinite(r)&&r>=1&&r<=s.length?s[r-1]:s.includes(t)?t:Qi(t,s)}finally{e.close()}},tn=new RegExp("[\x1B]\\[[0-?]*[ -/]*[@-~]","g"),dt=s=>s.replaceAll(tn,"").replaceAll("\r","");class ss{#e=[];#r=new Set;#s=new Map;#i=new Map;constructor(e=[]){for(const t of e)this.#i.set(t,{id:t,status:"pending",tailLines:[]});this.#e=[...e],this.#n()}getSnapshot=()=>this.#s;subscribe=e=>(this.#r.add(e),()=>{this.#r.delete(e)});getIds(){return this.#e}getState(e){return this.#i.get(e)}getDockState(){let e=!1,t=!1;for(const r of this.#i.values())r.status==="crashed"||r.status==="failed"?e=!0:(r.status==="pending"||r.status==="starting")&&(t=!0);return e?"crash":t?"boot":"ready"}registerService(e){this.#i.has(e)||(this.#i.set(e,{id:e,status:"pending",tailLines:[]}),this.#e=[...this.#e,e],this.#o())}markStarting(e){this.#t(e,t=>({...t,errorMessage:void 0,startedAt:t.startedAt??Date.now(),status:"starting"}))}markStarted(e,t){this.#t(e,r=>({...r,startedAt:r.startedAt??Date.now(),status:r.status==="ready"?"ready":"starting"}))}markReady(e,t){this.#t(e,r=>({...r,errorMessage:void 0,port:t.port,readyAt:Date.now(),status:"ready"}))}markFailed(e,t,r){const o=r?.message;this.#t(e,a=>({...a,errorMessage:dt(o??t),status:"failed"}))}markCrashed(e,t){const r=t.slice(-256).map(o=>dt(o));this.#t(e,o=>({...o,errorMessage:r.length>0?r[r.length-1]:"process exited",status:"crashed",tailLines:r}))}appendLog(e,t){const r=t.split(`
|
|
9
|
+
`).map(o=>dt(o)).filter(o=>o.length>0);r.length!==0&&this.#t(e,o=>{const a=[...o.tailLines,...r];for(;a.length>256;)a.shift();let n=0;for(let d=a.length-1;d>=0;d--)if(n+=a[d].length+1,n>65536){a.splice(0,d+1);break}return{...o,lastLine:r[r.length-1],tailLines:a}})}abortBoot(e){let t=!1;const r=new Map(this.#i);for(const[o,a]of r)(a.status==="pending"||a.status==="starting")&&(r.set(o,{...a,errorMessage:e,status:"failed"}),t=!0);t&&(this.#i=r,this.#n(),this.#o())}#t(e,t){const r=this.#i.get(e);r&&(this.#i.set(e,t(r)),this.#n(),this.#o())}#n(){this.#s=new Map(this.#i)}#o(){for(const e of this.#r)try{e()}catch{}}}const sn=(s,e)=>{if(s===e)return!0;if(!s||!e||s.length!==e.length)return!1;for(const[t,r]of s.entries())if(!Object.is(r,e[t]))return!1;return!0},rs=({children:s,deps:e,onRender:t,style:r,width:o})=>{const a=U.useRef(null),n=U.useRef(!1),d=U.useRef(e),f=U.useRef(s),h=U.useRef(t);h.current=t;let u=!1;e!==void 0?sn(d.current,e)||(u=!0,d.current=e):s!==f.current&&(u=!0,f.current=s),u&&(n.current=!1,a.current&&(a.current.cachedRender=void 0)),U.useLayoutEffect(()=>{const l=a.current;l&&(l.internal_onRendered=()=>{n.current=!0,h.current?.(l)})}),U.useEffect(()=>()=>{const l=a.current;l&&(l.cachedRender=void 0,l.internal_onRendered=void 0)},[]);const g=U.useMemo(()=>({...r,width:o}),[r,o]);return i.jsx("ink-static-render",{ref:a,style:g,children:n.current?null:s()})},rn=s=>Array.isArray(s)?`[${s.join(",")}]`:typeof s=="object"&&s!==null?JSON.stringify(s):String(s),nn=(s,e,t)=>e==="_"?`${s}${Array.isArray(t)?t.join(" "):String(t)}`:`${s}--${e}=${rn(t)}`,yt=(s,e,t)=>{const r=new Set(new Set(t.map(l=>l.target.target))),o=new Set(new Set(t.map(l=>l.target.project))),a=e.filter(l=>r.has(l)),n=s.filter(l=>o.has(l)),d=t.length-n.length*a.length,f=a.length===1?"target":"targets",h=a.join(", "),u=n.length===1?`project ${n[0]}`:`${n.length} projects`;let g=`${f} ${h} for ${u}`;return d>0&&(g+=` and ${d} ${d===1?"task":"tasks"} ${d===1?"it depends":"they depend"} on`),g},on={error:"red",info:"white",success:"green"},ht=({children:s,title:e,variant:t})=>{const r=on[t];return i.jsxs(m,{flexDirection:"column",children:[i.jsxs(m,{gap:1,children:[i.jsx(c,{bold:!0,inverse:!0,children:" VIS "}),i.jsx(c,{bold:!0,color:r,children:"•"}),i.jsx(c,{children:e})]}),s]})},Os=({cached:s,failed:e,failedIds:t,projectNames:r,retriedIds:o,skippedIds:a,succeeded:n,targets:d,tasks:f,took:h})=>{const u=yt(r,d,f),g=o??[];if(e===0&&(!a||a.length===0)){const l=s>0?` (${s} read from cache)`:"";return i.jsx(rs,{children:()=>i.jsx(ht,{title:`Successfully ran ${u}`,variant:"success",children:i.jsxs(m,{flexDirection:"column",marginTop:1,paddingLeft:3,children:[i.jsxs(c,{children:[i.jsx(c,{color:"green",children:bs})," ",n+s," tasks completed",l?i.jsx(c,{dimColor:!0,children:l}):null,i.jsx(c,{dimColor:!0,children:` · Took ${h}`})]}),g.length>0&&i.jsxs(m,{flexDirection:"column",marginTop:1,children:[i.jsxs(c,{children:[i.jsx(c,{color:"yellow",children:"↻"})," ",i.jsx(c,{color:"yellow",children:String(g.length)})," task",g.length===1?"":"s"," succeeded after retry:"]}),g.map(S=>i.jsxs(c,{children:[" ",i.jsx(c,{color:"yellow",children:"↻"})," ",S]},S))]})]})})})}return i.jsx(rs,{children:()=>i.jsx(ht,{title:`Ran ${u}`,variant:"error",children:i.jsxs(m,{flexDirection:"column",marginTop:1,paddingLeft:3,children:[a&&a.length>0&&i.jsxs(m,{flexDirection:"column",children:[i.jsxs(c,{dimColor:!0,children:[a.length," ","task",a.length===1?"":"s"," ","skipped (dependency failed or --bail)"]}),a.map(l=>i.jsxs(c,{dimColor:!0,children:[" - ",l]},l)),i.jsx(c,{})]}),e>0&&i.jsxs(m,{flexDirection:"column",children:[i.jsxs(c,{children:[i.jsx(c,{color:"red",children:String(e)})," ","task",e===1?"":"s"," ","failed:"]}),t.map(l=>i.jsxs(c,{children:[" ",i.jsx(c,{color:"red",children:$s})," ",l]},l)),i.jsx(c,{})]}),g.length>0&&i.jsxs(m,{flexDirection:"column",children:[i.jsxs(c,{children:[i.jsx(c,{color:"yellow",children:String(g.length)})," ","task",g.length===1?"":"s"," ","finished after retry:"]}),g.map(l=>i.jsxs(c,{children:[" ",i.jsx(c,{color:"yellow",children:"↻"})," ",l]},l)),i.jsx(c,{})]}),i.jsx(c,{dimColor:!0,children:` Took ${h}`})]})})})};class rt{#e;#r=new Set;#s=new Map;constructor(e){this.#e={autoExitCountdown:null,cached:0,completed:0,done:!1,endTime:null,failed:0,filterActive:!1,filterText:"",focusedPanel:"tasks",interactiveMode:!1,outputs:new Map,pinnedTaskIds:[null,null],rerunRequested:!1,retriedIds:[],retryTaskId:null,rows:e.map(t=>({persistent:!!t.overrides.visOptions?.persistent,status:"pending",taskId:t.id})),selectedIndex:0,startTime:Date.now(),statusFilter:"all",succeeded:0,viewMode:"list"}}getSnapshot=()=>this.#e;subscribe=e=>(this.#r.add(e),()=>{this.#r.delete(e)});startTasks(e){const t=[...this.#e.rows];for(const r of e){const o=t.findIndex(a=>a.taskId===r.id);o!==-1&&(t[o]={...t[o],elapsed:0,status:"running"},this.#s.set(r.id,process.hrtime()))}this.#t({...this.#e,rows:t})}endTasks(e){const t=[...this.#e.rows];let{cached:r,completed:o,failed:a,succeeded:n}=this.#e;const d=new Map(this.#e.outputs),f=[...this.#e.retriedIds];for(const u of e){const g=t.findIndex(l=>l.taskId===u.task.id);switch(g!==-1&&(t[g]={...t[g],duration:u.startTime&&u.endTime?u.endTime-u.startTime:void 0,retryAttempts:u.retryAttempts,status:u.status}),u.retryAttempts&&u.retryAttempts>0&&f.push(u.task.id),o++,u.status){case"failure":{a++;break}case"local-cache":case"local-cache-kept-existing":case"remote-cache":{r++;break}case"success":{n++;break}}u.terminalOutput&&!d.has(u.task.id)&&d.set(u.task.id,u.terminalOutput),this.#s.delete(u.task.id)}let{selectedIndex:h}=this.#e;if(a>this.#e.failed){const u=t.findIndex(g=>g.status==="failure");u!==-1&&(h=u)}this.#t({...this.#e,cached:r,completed:o,failed:a,outputs:d,retriedIds:f,rows:t,selectedIndex:h,succeeded:n})}static#i=256*1024;addOutput(e,t){if(!t.trim())return;let r=(this.#e.outputs.get(e)??"")+t;r.length>rt.#i&&(r=r.slice(-rt.#i)),this.#e.outputs.set(e,r),this.#t({...this.#e})}setOutput(e,t){this.#e.outputs.set(e,t),this.#t({...this.#e})}markDone(){this.#t({...this.#e,done:!0,endTime:Date.now()})}unmarkDone(){this.#t({...this.#e,autoExitCountdown:null,done:!1,endTime:null})}tick(){if(this.#s.size===0)return;let e=!1;const t=[...this.#e.rows];for(let r=0;r<t.length;r++){const o=t[r];if(o.status==="running"){const a=this.#s.get(o.taskId);if(a){const n=process.hrtime(a),d=n[0]*1e3+n[1]/1e6;t[r]={...o,elapsed:d},e=!0}}}e&&this.#t({...this.#e,rows:t})}setSelectedIndex(e){e!==this.#e.selectedIndex&&this.#t({...this.#e,selectedIndex:e})}setFocusedPanel(e){e!==this.#e.focusedPanel&&this.#t({...this.#e,focusedPanel:e})}setFilter(e){this.#t({...this.#e,filterText:e,selectedIndex:0})}setFilterActive(e){e!==this.#e.filterActive&&this.#t({...this.#e,filterActive:e,filterText:e?this.#e.filterText:"",selectedIndex:0})}pinTask(e,t){const r=[...this.#e.pinnedTaskIds];r[e]=t,this.#t({...this.#e,pinnedTaskIds:r})}clearPins(){this.#t({...this.#e,pinnedTaskIds:[null,null]})}requestRetry(e){const t=[...this.#e.rows],r=t.findIndex(d=>d.taskId===e);let{completed:o,failed:a,succeeded:n}=this.#e;if(r!==-1){const d=t[r].status;d==="failure"?(a=Math.max(0,a-1),o=Math.max(0,o-1)):d==="success"&&(n=Math.max(0,n-1),o=Math.max(0,o-1)),t[r]={...t[r],elapsed:0,retryAttempts:void 0,status:"running"},this.#s.set(e,process.hrtime())}this.#t({...this.#e,completed:o,done:!1,endTime:null,failed:a,interactiveMode:!1,retriedIds:this.#e.retriedIds.filter(d=>d!==e),retryTaskId:e,rows:t,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})),startTime:Date.now(),succeeded:0,viewMode:"list"})}acknowledgeRerun(){this.#e.rerunRequested&&this.#t({...this.#e,rerunRequested:!1})}#t(e){this.#e=e;for(const t of this.#r)try{t()}catch{}}}const an=s=>Mi(s),cn=/^(?<name>(?:[A-Z][\w$]*)?(?:Error|Exception))(?::[ \t](?<message>.*))?$/,ln=/^\s*at\s+/,dn=s=>{const e=s.split(`
|
|
10
|
+
`);let t;for(let r=0;r<e.length;r++){const o=cn.exec(e[r].trim());if(!o)continue;const a=[];for(let n=r+1;n<e.length&&n<=r+200;n++){const d=e[n];if(ln.test(d))a.push(d.trim());else if(a.length>0||d.trim()!=="")break}if(a.length>0){const n=o.groups?.name??"Error",d=o.groups?.message??"";t={message:d,name:n,stack:`${n}: ${d}
|
|
11
|
+
${a.map(f=>` ${f}`).join(`
|
|
12
|
+
`)}`}}}return t},Ps=s=>{if(s.startsWith("file://"))try{return ui(s)}catch{return s}return s},un=s=>!s.includes("node_modules")&&!s.startsWith("node:")&&!s.startsWith("internal/"),hn=s=>{try{return yi(s)}catch{return}},fn=(s,e)=>{if(!s.file||s.line===void 0)return;const t=Ps(s.file),r=ci(t)?t:Yt(e,t);if(!un(r)||!Ae(r))return;const o=hn(r);if(o){const a=mi(o,{column:s.column===void 0?0:Math.max(0,s.column-1),line:s.line});if(a.source&&a.line!=null){const n=Yt(li(r),a.source),d=wi(o,a.source)??(Ae(n)?Ge(n,"utf8"):void 0);if(d!==void 0)return{column:a.column==null?void 0:a.column+1,file:n,line:a.line,source:d}}}return{column:s.column,file:r,line:s.line,source:Ge(r,"utf8")}},is=(s,e)=>{const t=di(e,s);return t&&!t.startsWith("..")?t:s},As=(s,e)=>{if(!s?.trim())return s;try{const t=dn(an(s));if(!t)return s;const r=new Error(t.message);r.name=t.name,r.stack=t.stack;const o=pi(r);if(o.length===0)return s;const a=e.color,n={dim:l=>a?Jt(l):l,head:l=>a?fi(lt(l)):l,loc:l=>a?hi(l):l};let d,f;for(const l of o){const S=fn(l,e.cwd);if(S){d=S,f=l;break}}const h=[n.head(`✖ ${t.name}${t.message?`: ${t.message}`:""}`)];if(d){const l=`${is(d.file,e.cwd)}:${d.line}${d.column?`:${d.column}`:""}`;h.push(` ${n.loc(l)}`,""),h.push(gi(d.source,{start:{column:d.column,line:d.line}},{color:a?{gutter:Jt,marker:lt,message:lt}:void 0,linesAbove:2,linesBelow:3}))}const u=o.filter(l=>l!==f).slice(0,8).map(l=>{const S=l.methodName??"<anonymous>",R=l.file?`${is(Ps(l.file),e.cwd)}${l.line?`:${l.line}`:""}`:"";return n.dim(` at ${S}${R?` (${R})`:""}`)});u.length>0&&h.push("",...u);const g=n.dim("─".repeat(40));return`${h.join(`
|
|
13
|
+
`)}
|
|
14
|
+
${g}
|
|
15
|
+
${s}`}catch{return s}},pn={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"]},De=s=>Ci(s,pn),Ne=s=>s==="local-cache"||s==="local-cache-kept-existing"||s==="remote-cache",_e=s=>{switch(s){case"failure":return{color:"red",icon:$s};case"local-cache":case"local-cache-kept-existing":case"remote-cache":case"success":return{color:"green",icon:bs};case"skipped":return{color:"gray",icon:ot};default:return{color:"gray",icon:"?"}}},We=s=>{const{color:e,icon:t}=_e(s);return pe(J.createElement(c,{color:e},t),{columns:10}).trim()},gn=s=>{const{color:e,icon:t}=_e(s);switch(s){case"local-cache":case"local-cache-kept-existing":case"remote-cache":return pe(J.createElement(c,null,J.createElement(c,{color:e},t)," ",J.createElement(c,{color:"cyan"},"[cache]")),{columns:30}).trim();case"skipped":return pe(J.createElement(c,null,J.createElement(c,{dimColor:!0},t)," ",J.createElement(c,{dimColor:!0},"[skipped]")),{columns:30}).trim();default:return pe(J.createElement(c,{color:e},t),{columns:10}).trim()}},mn=s=>s==="azure"||s==="buildkite"||s==="github"||s==="gitlab"||s==="off"?s: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",wn=s=>{const e=s.replaceAll(/\W+/g,"_"),t=vi("sha256").update(s).digest("hex").slice(0,6);return`${e}_${t}`},yn=(s,e,t,r="auto")=>{const o=t.trim();if(!o)return;const a=`
|
|
16
|
+
`,n=mn(r);if(n==="github"&&e!=="failure"){process.stdout.write(`::group::${We(e)} ${s}${a}`),process.stdout.write(o+a),process.stdout.write(`::endgroup::${a}`);return}if(n==="gitlab"&&e!=="failure"){const g=Math.floor(Date.now()/1e3),l=wn(s),S="\x1B[0K";process.stdout.write(`${S}section_start:${String(g)}:${l}[collapsed=true]\r${S}${We(e)} ${s}${a}`),process.stdout.write(o+a);const R=Math.floor(Date.now()/1e3);process.stdout.write(`${S}section_end:${String(R)}:${l}\r${S}${a}`);return}if(n==="buildkite"&&e!=="failure"){process.stdout.write(`--- ${We(e)} ${s}${a}`),process.stdout.write(o+a);return}if(n==="azure"&&e!=="failure"){process.stdout.write(`##[group]${We(e)} ${s}${a}`),process.stdout.write(o+a),process.stdout.write(`##[endgroup]${a}`);return}const d=process.stdout.columns||80,f=pe(J.createElement(c,{dimColor:!0},ot.repeat(d)),{columns:d}).trim(),h=gn(e),u=pe(J.createElement(c,{bold:!0},s),{columns:d}).trim();process.stdout.write(`${f}${a}`),process.stdout.write(`${h} ${u}${a}`),process.stdout.write(o+a),process.stdout.write(`${f}${a}`)},vn=s=>s==="running"?{color:"white",icon:"•"}:s==="pending"?{color:"gray",icon:"·"}:_e(s),xn=({autoScroll:s,focused:e,interactiveMode:t,showFullscreenHint:r,statusValue:o,supportsInteractive:a,taskId:n})=>{if(!n)return;if(t)return"Esc cancel | Enter send";const d=s?"":" PAUSED (f resume)",f=a?" i INPUT":"";return e&&o==="running"&&r?`⏎ FULLSCREEN${f} f FOLLOW${d}`:e&&o==="running"?`f FOLLOW${f}${d}`:e&&r?`<enter> full screen${d}`:e?d||void 0:"<tab> or <enter> to focus"},ns=({autoScroll:s=!0,duration:e,focused:t,interactiveMode:r,output:o,scrollRef:a,showFullscreenHint:n,status:d,supportsInteractive:f=!0,taskId:h})=>{const u=d??"pending",{icon:g}=vn(u),l=t?"bold":"single",S=u==="failure"?"red":u==="success"||Ne(u)?t?"green":"gray":u==="running"?t?"white":"cyan":t?"white":"gray",R=h?`${g} ${h}`:void 0,B=e===void 0?void 0:De(e),W=xn({autoScroll:s,focused:t,interactiveMode:r??!1,showFullscreenHint:n??!1,statusValue:u,supportsInteractive:f,taskId:h});if(!h)return i.jsxs(m,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",paddingX:2,paddingY:1,children:[i.jsx(c,{dimColor:!0,children:"Select a task to view output"}),i.jsx(c,{dimColor:!0,children:"Press Enter or 1/2 to pin"})]});const k=[];if(o)for(const x of o.split(`
|
|
17
|
+
`))k.push(x.endsWith("\r")?x.slice(0,-1):x);return!o&&(u==="running"||u==="pending")?i.jsx(m,{borderBottomTitle:W,borderColor:S,borderStyle:l,borderTopRightTitle:B,borderTopTitle:R,flexDirection:"column",flexGrow:1,paddingX:2,paddingY:1,children:i.jsx(m,{alignItems:"center",flexGrow:1,justifyContent:"center",children:i.jsx(c,{dimColor:!0,children:"Waiting for task output…"})})}):i.jsxs(m,{borderBottomTitle:W,borderColor:r?"yellow":S,borderStyle:l,borderTopRightTitle:B,borderTopTitle:R,flexDirection:"column",flexGrow:1,children:[i.jsx(m,{flexGrow:1,flexShrink:1,paddingY:1,children:i.jsx(xs,{flexGrow:1,followOutput:s,paddingX:2,ref:a,scrollbar:!0,scrollbarColor:"gray",scrollbarStyle:"block",children:i.jsx(c,{children:k.join(`
|
|
18
|
+
`)})})}),r&&i.jsx(m,{flexShrink:0,justifyContent:"center",paddingX:1,children:i.jsx(c,{bold:!0,color:"yellow",children:"INTERACTIVE | keystrokes forwarded to task | Esc to exit"})})]})},kn={crashed:"✖",failed:"✖",pending:"·",ready:"●",starting:"•"},Ds=s=>s==="ready"?"green":s==="crashed"||s==="failed"?"red":s==="starting"?"cyan":"gray",jn=({status:s})=>s==="starting"?i.jsx(c,{color:"cyan",children:i.jsx(Ts,{type:"dots"})}):i.jsx(c,{bold:!0,color:Ds(s),children:kn[s]}),bn=({active:s,focused:e,state:t})=>{const r=e&&s,o=r?">":" ",a=t.status==="ready"?t.port?`running, port ${String(t.port)}`:"running":t.status==="failed"||t.status==="crashed"?t.errorMessage??"exited":t.lastLine??"booting…";return i.jsxs(m,{flexDirection:"row",flexShrink:0,overflow:"hidden",children:[i.jsx(c,{children:o}),i.jsx(c,{children:" "}),i.jsx(m,{flexShrink:0,width:3,children:i.jsx(jn,{status:t.status})}),i.jsx(m,{flexGrow:0,flexShrink:0,width:28,children:i.jsx(c,{bold:r,inverse:r,children:t.id})}),i.jsx(m,{flexGrow:1,flexShrink:1,overflow:"hidden",children:i.jsxs(c,{color:Ds(t.status),dimColor:t.status!=="crashed"&&t.status!=="failed",wrap:"truncate-end",children:[" ",a]})})]})},$n=({states:s})=>{const e=[];for(const r of s)r.status==="ready"&&e.push(r.id);const t=e.join(", ");return i.jsxs(m,{paddingX:1,children:[i.jsxs(c,{bold:!0,color:"green",children:["● ","Services"]}),i.jsxs(c,{children:[" ",String(e.length)," / ",String(s.length)," running"]}),t.length>0&&i.jsxs(c,{dimColor:!0,children:[" ",t]}),i.jsx(c,{dimColor:!0,children:" [Tab ↓]"})]})},Sn=({states:s})=>{const e=s.find(t=>t.status==="crashed"||t.status==="failed");return e?i.jsxs(m,{flexDirection:"column",paddingX:1,children:[i.jsxs(c,{bold:!0,color:"red",children:["✖ ","Service crashed:"," ",e.id]}),e.tailLines.slice(-3).map((t,r)=>i.jsxs(c,{color:"red",dimColor:!0,children:[" ",t]},`crash-${String(r)}`))]}):i.jsx(i.Fragment,{})},Tn=({activeIndex:s,focused:e,store:t})=>{const r=U.useSyncExternalStore(t.subscribe,t.getSnapshot),o=t.getIds();if(o.length===0)return i.jsx(i.Fragment,{});const a=o.map(u=>r.get(u)).filter(u=>u!==void 0),n=t.getDockState(),d=n==="crash"?"red":n==="ready"?"gray":e?"white":"cyan",f=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?i.jsx(m,{borderColor:d,borderStyle:"single",flexDirection:"row",flexShrink:0,children:i.jsx($n,{states:a})}):i.jsxs(m,{borderBottomTitle:h,borderColor:d,borderStyle:e?"bold":"single",borderTopTitle:f,flexDirection:"column",flexGrow:2,flexShrink:0,minHeight:6,paddingX:1,children:[n==="crash"&&i.jsx(Sn,{states:a}),a.map((u,g)=>i.jsx(bn,{active:g===s,focused:e,state:u},u.id))]})},Ls=6,Bs=8,Ns=12,Cn=s=>s==="running"||s==="pending"?Ss:s==="local-cache"||s==="local-cache-kept-existing"?"Local":s==="remote-cache"?"Remote":ot,os=(s,e)=>e[0]===s?"[1]":e[1]===s?"[2]":"",as=({compact:s,focused:e,isSelected:t,pinLabel:r,row:o})=>{const{persistent:a,status:n,taskId:d}=o,f=e&&t,h=f?">":" ",u=n==="running"&&a===!0;let g;if(u)g=i.jsx(c,{bold:!0,color:"green",children:" ● "});else if(n==="running")g=i.jsxs(c,{bold:!0,color:"white",children:[" ",i.jsx(Ts,{type:"dots"})," "]});else if(n==="pending")g=i.jsx(c,{bold:!0,color:"gray",children:" · "});else{const{color:S,icon:R}=_e(n);g=i.jsxs(c,{bold:!0,color:S,children:[" ",R," "]})}let l=Ss;return u?l="running":n!=="running"&&n!=="pending"?l=o.duration===void 0?ot:De(o.duration):n==="running"&&o.elapsed!==void 0&&(l=De(o.elapsed)),i.jsxs(m,{children:[i.jsx(c,{children:h}),i.jsx(m,{width:Ls,children:g}),i.jsxs(m,{flexGrow:1,children:[i.jsx(c,{bold:f,inverse:f,children:d}),r?i.jsx(c,{dimColor:!0,children:` ${r}`}):null]}),!s&&i.jsx(m,{justifyContent:"flex-end",width:Bs,children:i.jsx(c,{dimColor:!Ne(n),children:Cn(n)})}),!s&&i.jsx(m,{justifyContent:"flex-end",width:Ns,children:i.jsx(c,{color:u?"green":void 0,dimColor:n==="pending"||u,children:l})})]})},cs=({compact:s,filterActive:e,filterText:t,focused:r,headerStatus:o,parallelSlots:a=3,pinnedTaskIds:n,rows:d,scrollRef:f,selectedIndex:h,title:u})=>{const g=o==="error"?"red":o==="success"?"green":r?"white":"gray",l=d[h]?.taskId,S=[];let R=0;for(const x of d)x.status==="running"?S.push(x):x.status==="pending"&&(R+=1);const B=Math.min(a,S.length+R),W=B>1,k=[];if(W)for(let x=0;x<B;x++){const F=S[x];F?k.push(i.jsx(as,{compact:s,focused:r,isSelected:F.taskId===l,pinLabel:os(F.taskId,n),row:F},`par-${F.taskId}`)):k.push(i.jsxs(m,{children:[i.jsx(c,{children:" "}),i.jsx(m,{width:Ls,children:i.jsx(c,{bold:!0,color:"gray",children:" · "})}),i.jsx(c,{dimColor:!0,children:"Waiting for task..."})]},`par-empty-${String(x)}`))}return i.jsxs(m,{borderColor:g,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[i.jsxs(m,{flexShrink:0,paddingX:1,children:[i.jsx(c,{bold:!0,inverse:!0,children:" VIS "}),i.jsx(c,{children:` ${u}`}),!s&&i.jsxs(m,{flexGrow:1,gap:0,justifyContent:"flex-end",children:[i.jsx(m,{justifyContent:"flex-end",width:Bs,children:i.jsx(c,{dimColor:!0,children:"Cache"})}),i.jsx(m,{justifyContent:"flex-end",width:Ns,children:i.jsx(c,{dimColor:!0,children:"Duration"})})]})]}),i.jsx(xs,{flexGrow:1,flexShrink:1,paddingX:1,paddingY:1,ref:f,scrollbar:!0,scrollbarColor:"gray",scrollbarStyle:"block",children:d.map(x=>i.jsx(as,{compact:s,focused:r,isSelected:x.taskId===l,pinLabel:os(x.taskId,n),row:x},x.taskId))}),W&&i.jsx(m,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",borderTop:!0,flexDirection:"column",flexShrink:0,paddingX:1,paddingY:1,children:k}),e&&i.jsxs(m,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",borderTop:!0,flexShrink:0,paddingX:1,children:[i.jsx(c,{bold:!0,color:"white",children:"/ "}),i.jsx(c,{children:t}),i.jsx(c,{inverse:!0,children:" "})]})]})},ls=40,ds=10,us=100,In=Object.freeze([]),Rn=({autoExitSeconds:s,onRetryService:e,parallelSlots:t,projectNames:r,serviceDockStore:o,stdinRegistry:a,store:n,targets:d,tasks:f})=>{const{exit:h}=yr(),{columns:u,rows:g}=vr(),l=U.useSyncExternalStore(n.subscribe,n.getSnapshot),S=U.useCallback($=>o?o.subscribe($):()=>{},[o]);U.useSyncExternalStore(S,()=>o?o.getDockState():"ready");const R=o?o.getIds():In,B=R.length>0,[W,k]=U.useState(0),[x,F]=U.useState(null),T=U.useSyncExternalStore(S,()=>x&&o?o.getState(x):void 0),[C,w]=U.useState(!1),j=U.useRef(null),A=U.useRef(null),O=U.useRef(null),[z,ie]=U.useState(!1),[Q,_]=U.useState(!0),Z=U.useRef({list:0,splitList:0,splitOutput:0}),xe=U.useCallback(()=>{l.viewMode==="list"?Z.current.list=A.current?.getScrollOffset()??0:l.viewMode==="split"&&(Z.current.splitList=A.current?.getScrollOffset()??0,Z.current.splitOutput=O.current?.getScrollOffset()??0)},[l.viewMode]),ee=U.useCallback($=>{setTimeout(()=>{if($==="list"){const v=Z.current.list;A.current?.scrollTo(v)}else if($==="split"){const v=Z.current.splitList;v>0?A.current?.scrollTo(v):A.current?.scrollTo(Math.max(0,n.getSnapshot().selectedIndex-2)),O.current?.scrollTo(Z.current.splitOutput)}},0)},[n]),ce=U.useRef(!1);U.useEffect(()=>{l.done&&!ce.current&&(ce.current=!0,s>0&&l.failed===0&&ie(!0)),!l.done&&ce.current&&(ce.current=!1,ie(!1))},[l.done,l.failed,s]);const le=U.useMemo(()=>{const $=R.length>0?new Set(R):null,v=l.filterText?l.filterText.toLowerCase():null,I=[];for(const te of l.rows)$?.has(te.taskId)||l.statusFilter==="failed"&&te.status!=="failure"||l.statusFilter==="running"&&te.status!=="running"&&te.status!=="pending"||l.statusFilter==="passed"&&te.status!=="success"&&!Ne(te.status)||v&&!te.taskId.toLowerCase().includes(v)||I.push(te);return I},[l.rows,l.filterText,l.statusFilter,R]),H=U.useMemo(()=>{let $=0;for(const v of l.rows)v.status==="running"&&($+=1);return $},[l.rows]),V=(le[l.selectedIndex]??null)?.taskId??null,oe=x?null:l.pinnedTaskIds[0]??V,se=oe?l.rows.find($=>$.taskId===oe):null,E=T??null,de=x?(E?.tailLines??[]).join(`
|
|
19
|
+
`):oe?l.outputs.get(oe)??"":"",Ie=U.useMemo(()=>se?.status==="failure"&&de?As(de,{color:!process.env.NO_COLOR,cwd:process.cwd()}):de,[se?.status,de]),Fe=x??oe,Le=x?E?.status==="crashed"||E?.status==="failed"?"failure":"running":se?.status,Oe=yt(r,d,f),X=l.done?`Completed ${Oe} (${De((l.endTime??Date.now())-l.startTime)})`:`Running ${Oe}...`,Re=l.done?l.failed>0?"error":"success":"running",Se=U.useCallback($=>{A.current?.scrollTo(Math.max(0,$-2))},[]);if(U.useEffect(()=>{l.interactiveMode&&se?.status!=="running"&&n.setInteractiveMode(!1)},[l.interactiveMode,se?.status,n]),U.useEffect(()=>{if(!oe)return;let $=u;l.viewMode==="split"&&u>=us?$=u-Math.floor(u*.4)-2:(l.viewMode==="split"||l.viewMode==="fullscreen")&&($=u-2);const v=Math.max(1,g-4);a.get(oe)?.resize?.($,v)},[u,g,l.viewMode,oe]),Vt(($,v)=>{if(v.escape){n.setInteractiveMode(!1);return}if(!oe)return;const I=a.get(oe);if(!I){n.setInteractiveMode(!1);return}if(v.return)I.write("\r");else if(v.upArrow)I.write("\x1B[A");else if(v.downArrow)I.write("\x1B[B");else if(v.rightArrow)I.write("\x1B[C");else if(v.leftArrow)I.write("\x1B[D");else if(v.backspace)I.write("");else if(v.delete)I.write("\x1B[3~");else if(v.tab)I.write(" ");else if(v.home)I.write("\x1B[H");else if(v.end)I.write("\x1B[F");else if(v.pageUp)I.write("\x1B[5~");else if(v.pageDown)I.write("\x1B[6~");else if(v.ctrl&&$){const te=$.toUpperCase().codePointAt(0);te!==void 0&&te>=65&&te<=90&&I.write(String.fromCodePoint(te-64))}else $&&I.write($)},{isActive:l.interactiveMode}),Vt(($,v)=>{if($==="c"&&v.ctrl){h();return}if(!z){if(C){v.escape||$==="?"?w(!1):$==="q"?(w(!1),ie(!0)):v.downArrow||$==="j"?j.current?.scrollBy(1):v.upArrow||$==="k"?j.current?.scrollBy(-1):v.pageDown?j.current?.scrollBy(5):v.pageUp?j.current?.scrollBy(-5):v.home?j.current?.scrollToTop():v.end&&j.current?.scrollToBottom();return}if($==="?"){w(!0);return}if($==="q"){ie(!0);return}if($==="r"&&l.done){n.requestRerun();return}if($==="R"&&l.done){const I=le[l.selectedIndex];I?.status==="failure"&&n.requestRetry(I.taskId);return}if($==="F"&&!l.filterActive){const I=["all","failed","running","passed"],te=I.indexOf(l.statusFilter);n.setStatusFilter(I[(te+1)%I.length]);return}if(l.filterActive){if(v.escape){n.setFilterActive(!1);return}if(v.return){n.setFilterActive(!1);return}if(v.backspace){n.setFilter(l.filterText.slice(0,-1));return}if($&&!v.ctrl&&!v.meta){n.setFilter(l.filterText+$);return}return}if($==="i"&&se?.status==="running"&&(l.viewMode==="fullscreen"||l.viewMode==="split"&&l.focusedPanel==="output")){n.setInteractiveMode(!0);return}if(l.viewMode==="fullscreen"){if(v.escape){n.setViewMode("split"),ee("split");return}if($==="f"){const I=!Q;_(I),I&&O.current?.scrollToBottom();return}if(v.downArrow||$==="j"){_(!1),O.current?.scrollBy(1);return}if(v.upArrow||$==="k"){_(!1),O.current?.scrollBy(-1);return}if(v.pageDown||v.ctrl&&$==="d"){_(!1),O.current?.scrollBy(12);return}if(v.pageUp||v.ctrl&&$==="u"){_(!1),O.current?.scrollBy(-12);return}if(v.home){_(!1),O.current?.scrollToTop();return}if(v.end){_(!0),O.current?.scrollToBottom();return}return}if(l.focusedPanel==="dock"&&B&&o){if(v.tab){F(null),n.setFocusedPanel("tasks");return}if(v.escape){n.setFocusedPanel("tasks"),F(null),l.viewMode==="split"&&(n.setViewMode("list"),ee("list"));return}if(v.downArrow||$==="j"){k(I=>Math.min(I+1,R.length-1));return}if(v.upArrow||$==="k"){k(I=>Math.max(I-1,0));return}if(v.return){const I=R[W];I&&(F(I),_(!0),xe(),Z.current.splitList=0,Z.current.splitOutput=0,n.setViewMode("split"),n.setFocusedPanel("output"),ee("split"));return}if(($==="r"||$==="R")&&e){const I=R[W],te=I?o.getState(I)?.status:void 0;if(I&&(te==="crashed"||te==="failed")){const he=e(I);he instanceof Promise&&he.catch(()=>{})}return}return}if(l.viewMode==="split"){if(v.tab){l.focusedPanel==="tasks"?n.setFocusedPanel("output"):B?n.setFocusedPanel("dock"):(F(null),n.setFocusedPanel("tasks"));return}if(l.focusedPanel==="output"){if(v.escape){if(x&&B){F(null),n.setViewMode("list"),n.setFocusedPanel("dock"),ee("list");return}F(null),n.setFocusedPanel("tasks");return}if(v.return){xe(),n.setViewMode("fullscreen");return}if($==="f"){const I=!Q;_(I),I&&O.current?.scrollToBottom();return}if(v.downArrow||$==="j"){_(!1),O.current?.scrollBy(1);return}if(v.upArrow||$==="k"){_(!1),O.current?.scrollBy(-1);return}if(v.pageDown||v.ctrl&&$==="d"){_(!1),O.current?.scrollBy(12);return}if(v.pageUp||v.ctrl&&$==="u"){_(!1),O.current?.scrollBy(-12);return}if(v.home){_(!1),O.current?.scrollToTop();return}if(v.end){_(!0),O.current?.scrollToBottom();return}return}if(v.escape){n.setViewMode("list"),ee("list");return}if(v.return){n.setFocusedPanel("output");return}}if(l.viewMode==="list"||l.viewMode==="split"&&l.focusedPanel==="tasks"){if(v.tab&&l.viewMode==="list"&&B){n.setFocusedPanel("dock");return}if(v.downArrow||$==="j"){const I=Math.min(l.selectedIndex+1,Math.max(0,le.length-1));n.setSelectedIndex(I),Se(I);return}if(v.upArrow||$==="k"){const I=Math.max(l.selectedIndex-1,0);n.setSelectedIndex(I),Se(I);return}if(v.return&&l.viewMode==="list"){_(!0),xe(),Z.current.splitList=0,Z.current.splitOutput=0,n.setViewMode("split"),n.setFocusedPanel("output"),ee("split");return}if($==="/"){n.setFilterActive(!0);return}if($==="1"&&V){n.pinTask(0,V);return}if($==="2"&&V){n.pinTask(1,V);return}if($==="0"){n.clearPins();return}v.escape&&l.filterText&&n.setFilter("")}}},{isActive:!l.interactiveMode}),u<ls||g<ds)return i.jsx(m,{alignItems:"center",height:g,justifyContent:"center",width:u,children:i.jsxs(c,{color:"yellow",children:["Terminal too small (",u,"x",g,"). Minimum:"," ",ls,"x",ds]})});const ke=i.jsxs(m,{gap:1,children:[l.succeeded>0&&i.jsxs(c,{bold:!0,color:"green",children:["✓"," ",l.succeeded]}),l.failed>0&&i.jsxs(c,{bold:!0,color:"red",children:["✗"," ",l.failed]}),H>0&&i.jsxs(c,{color:"cyan",children:["◷"," ",H]}),i.jsxs(c,{dimColor:!0,children:[l.rows.length," ","total"]}),l.statusFilter!=="all"&&i.jsxs(c,{color:"yellow",children:["[",l.statusFilter,"]"]})]});let ge;if(l.viewMode==="fullscreen")ge=[i.jsxs(m,{gap:1,children:[i.jsx(c,{bold:!0,color:"white",children:"Esc"}),i.jsx(c,{dimColor:!0,children:"BACK"})]},"esc"),i.jsxs(m,{gap:1,children:[i.jsx(c,{bold:!0,color:"white",children:"↑↓"}),i.jsx(c,{dimColor:!0,children:"SCROLL"})]},"scroll"),i.jsxs(m,{gap:1,children:[i.jsx(c,{bold:!0,color:"white",children:"^u ^d"}),i.jsx(c,{dimColor:!0,children:"PAGE"})]},"page"),...se?.status==="running"?[i.jsxs(m,{gap:1,children:[i.jsx(c,{bold:!0,color:"white",children:"i"}),i.jsx(c,{dimColor:!0,children:"INPUT"})]},"i")]:[],i.jsxs(m,{gap:1,children:[i.jsx(c,{bold:!0,color:"white",children:"q"}),i.jsx(c,{dimColor:!0,children:"QUIT"})]},"q")];else if(l.done){const $=le[l.selectedIndex]?.status==="failure";ge=[i.jsxs(m,{gap:1,children:[i.jsx(c,{bold:!0,color:"white",children:"q"}),i.jsx(c,{dimColor:!0,children:"QUIT"})]},"q"),i.jsxs(m,{gap:1,children:[i.jsx(c,{bold:!0,color:"white",children:"r"}),i.jsx(c,{dimColor:!0,children:"RERUN"})]},"r"),...$?[i.jsxs(m,{gap:1,children:[i.jsx(c,{bold:!0,color:"white",children:"R"}),i.jsx(c,{dimColor:!0,children:"RETRY"})]},"R")]:[],i.jsxs(m,{gap:1,children:[i.jsx(c,{bold:!0,color:"white",children:"?"}),i.jsx(c,{dimColor:!0,children:"HELP"})]},"?"),i.jsxs(m,{gap:1,children:[i.jsx(c,{bold:!0,color:"white",children:"↑↓"}),i.jsx(c,{dimColor:!0,children:"NAV"})]},"nav"),i.jsxs(m,{gap:1,children:[i.jsx(c,{bold:!0,color:"white",children:"F"}),i.jsx(c,{dimColor:!0,children:"FILTER"})]},"F"),i.jsxs(m,{gap:1,children:[i.jsx(c,{bold:!0,color:"white",children:"⏎"}),i.jsx(c,{dimColor:!0,children:l.viewMode==="list"?"OUTPUT":"FULLSCREEN"})]},"enter")]}else l.viewMode==="split"&&l.focusedPanel==="output"?ge=[i.jsxs(m,{gap:1,children:[i.jsx(c,{bold:!0,color:"white",children:"q"}),i.jsx(c,{dimColor:!0,children:"QUIT"})]},"q"),i.jsxs(m,{gap:1,children:[i.jsx(c,{bold:!0,color:"white",children:"Esc"}),i.jsx(c,{dimColor:!0,children:"BACK"})]},"esc"),i.jsxs(m,{gap:1,children:[i.jsx(c,{bold:!0,color:"white",children:"↑↓"}),i.jsx(c,{dimColor:!0,children:"SCROLL"})]},"scroll"),...se?.status==="running"?[i.jsxs(m,{gap:1,children:[i.jsx(c,{bold:!0,color:"white",children:"i"}),i.jsx(c,{dimColor:!0,children:"INPUT"})]},"i")]:[],i.jsxs(m,{gap:1,children:[i.jsx(c,{bold:!0,color:"white",children:"⏎"}),i.jsx(c,{dimColor:!0,children:"FULLSCREEN"})]},"enter"),i.jsxs(m,{gap:1,children:[i.jsx(c,{bold:!0,color:"white",children:"Tab"}),i.jsx(c,{dimColor:!0,children:"PANEL"})]},"tab"),i.jsxs(m,{gap:1,children:[i.jsx(c,{bold:!0,color:"white",children:"?"}),i.jsx(c,{dimColor:!0,children:"HELP"})]},"?")]:ge=[i.jsxs(m,{gap:1,children:[i.jsx(c,{bold:!0,color:"white",children:"q"}),i.jsx(c,{dimColor:!0,children:"QUIT"})]},"q"),i.jsxs(m,{gap:1,children:[i.jsx(c,{bold:!0,color:"white",children:"?"}),i.jsx(c,{dimColor:!0,children:"HELP"})]},"?"),i.jsxs(m,{gap:1,children:[i.jsx(c,{bold:!0,color:"white",children:"↑↓"}),i.jsx(c,{dimColor:!0,children:"NAV"})]},"nav"),i.jsxs(m,{gap:1,children:[i.jsx(c,{bold:!0,color:"white",children:"/"}),i.jsx(c,{dimColor:!0,children:"FILTER"})]},"/"),i.jsxs(m,{gap:1,children:[i.jsx(c,{bold:!0,color:"white",children:"F"}),i.jsx(c,{dimColor:!0,children:"STATUS"})]},"F"),i.jsxs(m,{gap:1,children:[i.jsx(c,{bold:!0,color:"white",children:"⏎"}),i.jsx(c,{dimColor:!0,children:l.viewMode==="list"?"OUTPUT":"FULLSCREEN"})]},"enter"),...l.viewMode==="split"?[i.jsxs(m,{gap:1,children:[i.jsx(c,{bold:!0,color:"white",children:"Tab"}),i.jsx(c,{dimColor:!0,children:"PANEL"})]},"tab")]:[]];const we=i.jsxs(m,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",flexShrink:0,justifyContent:"space-between",children:[i.jsx(m,{flexGrow:1,flexWrap:"wrap",gap:2,paddingX:1,children:ge}),i.jsx(m,{flexShrink:0,paddingX:1,children:ke})]}),Te=i.jsxs(xr,{backgroundColor:"#1e1e1e",footer:i.jsxs(c,{dimColor:!0,children:[i.jsx(c,{bold:!0,color:"white",children:"↑↓"})," ","scroll"," ",i.jsx(c,{bold:!0,color:"white",children:"?"}),"/",i.jsx(c,{bold:!0,color:"white",children:"Esc"})," ","close"]}),scrollRef:j,title:"KEYBOARD SHORTCUTS",visible:C,width:52,children:[i.jsxs(m,{flexDirection:"column",marginBottom:1,children:[i.jsxs(m,{marginBottom:1,children:[i.jsx(c,{dimColor:!0,children:"── "}),i.jsx(c,{bold:!0,color:"white",children:"NAVIGATION"})]}),i.jsxs(m,{children:[i.jsx(m,{width:24,children:i.jsxs(c,{children:[i.jsxs(c,{bold:!0,color:"white",children:[" ","↑","/k"]}),i.jsx(c,{dimColor:!0,children:" Move up"})]})}),i.jsxs(c,{children:[i.jsxs(c,{bold:!0,color:"white",children:[" ","↓","/j"]}),i.jsx(c,{dimColor:!0,children:" Move down"})]})]}),i.jsxs(c,{children:[i.jsxs(c,{bold:!0,color:"white",children:[" ","Tab"]}),i.jsx(c,{dimColor:!0,children:" Switch panel (split)"})]}),i.jsxs(c,{children:[i.jsxs(c,{bold:!0,color:"white",children:[" ","Esc"]}),i.jsx(c,{dimColor:!0,children:" Back / close"})]}),i.jsxs(c,{children:[i.jsxs(c,{bold:!0,color:"white",children:[" ","Enter"]}),i.jsx(c,{dimColor:!0,children:" Show output / fullscreen"})]})]}),i.jsxs(m,{flexDirection:"column",marginBottom:1,children:[i.jsxs(m,{marginBottom:1,children:[i.jsx(c,{dimColor:!0,children:"── "}),i.jsx(c,{bold:!0,color:"white",children:"VIEWS"})]}),i.jsxs(c,{children:[i.jsxs(c,{bold:!0,color:"white",children:[" ","Enter"]}),i.jsxs(c,{dimColor:!0,children:[" ","List"," ","→"," ","Split"," ","→"," ","Fullscreen"]})]}),i.jsxs(c,{children:[i.jsxs(c,{bold:!0,color:"white",children:[" ","Esc"]}),i.jsxs(c,{dimColor:!0,children:[" ","Fullscreen"," ","→"," ","Split"," ","→"," ","List"]})]})]}),i.jsxs(m,{flexDirection:"column",marginBottom:1,children:[i.jsxs(m,{marginBottom:1,children:[i.jsx(c,{dimColor:!0,children:"── "}),i.jsx(c,{bold:!0,color:"white",children:"ACTIONS"})]}),i.jsxs(m,{children:[i.jsx(m,{width:24,children:i.jsxs(c,{children:[i.jsxs(c,{bold:!0,color:"white",children:[" ","/"]}),i.jsx(c,{dimColor:!0,children:" Filter by text"})]})}),i.jsxs(c,{children:[i.jsxs(c,{bold:!0,color:"white",children:[" ","F"]}),i.jsx(c,{dimColor:!0,children:" Filter by status"})]})]}),i.jsxs(m,{children:[i.jsx(m,{width:24,children:i.jsxs(c,{children:[i.jsxs(c,{bold:!0,color:"white",children:[" ","1"]}),i.jsx(c,{dimColor:!0,children:"/"}),i.jsx(c,{bold:!0,color:"white",children:"2"}),i.jsx(c,{dimColor:!0,children:" Pin to output pane"})]})}),i.jsxs(c,{children:[i.jsxs(c,{bold:!0,color:"white",children:[" ","0"]}),i.jsx(c,{dimColor:!0,children:" Clear pins"})]})]}),i.jsxs(m,{children:[i.jsx(m,{width:24,children:i.jsxs(c,{children:[i.jsxs(c,{bold:!0,color:"white",children:[" ","r"]}),i.jsx(c,{dimColor:!0,children:" Rerun all (done)"})]})}),i.jsxs(c,{children:[i.jsxs(c,{bold:!0,color:"white",children:[" ","R"]}),i.jsx(c,{dimColor:!0,children:" Retry failed task"})]})]}),i.jsxs(c,{children:[i.jsxs(c,{bold:!0,color:"white",children:[" ","i"]}),i.jsx(c,{dimColor:!0,children:" Interactive input (running task)"})]})]}),i.jsxs(m,{flexDirection:"column",marginBottom:1,children:[i.jsxs(m,{marginBottom:1,children:[i.jsx(c,{dimColor:!0,children:"── "}),i.jsx(c,{bold:!0,color:"white",children:"SCROLLING"}),i.jsx(c,{dimColor:!0,children:" (output panel)"})]}),i.jsxs(m,{children:[i.jsx(m,{width:24,children:i.jsxs(c,{children:[i.jsxs(c,{bold:!0,color:"white",children:[" ","↑","/k"]}),i.jsx(c,{dimColor:!0,children:" Scroll up"})]})}),i.jsxs(c,{children:[i.jsxs(c,{bold:!0,color:"white",children:[" ","↓","/j"]}),i.jsx(c,{dimColor:!0,children:" Scroll down"})]})]}),i.jsxs(m,{children:[i.jsx(m,{width:24,children:i.jsxs(c,{children:[i.jsxs(c,{bold:!0,color:"white",children:[" ","^u"]}),i.jsx(c,{dimColor:!0,children:" Page up"})]})}),i.jsxs(c,{children:[i.jsxs(c,{bold:!0,color:"white",children:[" ","^d"]}),i.jsx(c,{dimColor:!0,children:" Page down"})]})]}),i.jsxs(m,{children:[i.jsx(m,{width:24,children:i.jsxs(c,{children:[i.jsxs(c,{bold:!0,color:"white",children:[" ","Home"]}),i.jsx(c,{dimColor:!0,children:" Top"})]})}),i.jsxs(c,{children:[i.jsxs(c,{bold:!0,color:"white",children:[" ","End"]}),i.jsx(c,{dimColor:!0,children:" Bottom (resume follow)"})]})]}),i.jsxs(c,{children:[i.jsxs(c,{bold:!0,color:"white",children:[" ","f"]}),i.jsx(c,{dimColor:!0,children:" Toggle auto-scroll (tail mode)"})]})]}),i.jsxs(m,{flexDirection:"column",children:[i.jsxs(m,{marginBottom:1,children:[i.jsx(c,{dimColor:!0,children:"── "}),i.jsx(c,{bold:!0,color:"white",children:"GENERAL"})]}),i.jsxs(m,{children:[i.jsx(m,{width:24,children:i.jsxs(c,{children:[i.jsxs(c,{bold:!0,color:"white",children:[" ","q"]}),i.jsx(c,{dimColor:!0,children:" Quit"})]})}),i.jsxs(c,{children:[i.jsxs(c,{bold:!0,color:"white",children:[" ","?"]}),i.jsx(c,{dimColor:!0,children:" Toggle help"})]})]})]})]}),Ce=i.jsx(kr,{autoExitSeconds:s>0?s:3,onCancel:()=>{ie(!1)},visible:z}),je=B&&o?i.jsx(Tn,{activeIndex:W,focused:l.focusedPanel==="dock",store:o}):null;if(l.viewMode==="fullscreen")return i.jsxs(m,{flexDirection:"column",height:g,width:u,children:[i.jsx(m,{flexGrow:1,children:i.jsx(ns,{autoScroll:Q,duration:se?.duration??se?.elapsed,focused:!0,interactiveMode:l.interactiveMode,output:Ie,scrollRef:O,status:Le,supportsInteractive:!x,taskId:Fe})}),je,we,Ce,Te]});if(l.viewMode==="split"){const $=u>=us,v=i.jsx(cs,{compact:!0,filterActive:l.filterActive,filterText:l.filterText,focused:l.focusedPanel==="tasks",headerStatus:Re,parallelSlots:t,pinnedTaskIds:l.pinnedTaskIds,rows:le,scrollRef:A,selectedIndex:l.selectedIndex,title:X}),I=i.jsx(ns,{autoScroll:Q,duration:se?.duration??se?.elapsed,focused:l.focusedPanel==="output",interactiveMode:l.interactiveMode,output:Ie,scrollRef:O,showFullscreenHint:!0,status:Le,supportsInteractive:!x,taskId:Fe});if($){const he=Math.floor(u*.4);return i.jsxs(m,{flexDirection:"column",height:g,width:u,children:[i.jsxs(m,{flexDirection:"row",flexGrow:1,children:[i.jsx(m,{width:he,children:v}),i.jsx(m,{flexGrow:1,children:I})]}),je,we,Ce,Te]})}const te=Math.floor(g*.45);return i.jsxs(m,{flexDirection:"column",height:g,width:u,children:[i.jsx(m,{height:te,children:v}),i.jsx(m,{flexGrow:1,children:I}),je,we,Ce,Te]})}return i.jsxs(m,{flexDirection:"column",height:g,width:u,children:[i.jsx(m,{flexGrow:1,children:i.jsx(cs,{filterActive:l.filterActive,filterText:l.filterText,focused:l.focusedPanel!=="dock",headerStatus:Re,parallelSlots:t,pinnedTaskIds:l.pinnedTaskIds,rows:le,scrollRef:A,selectedIndex:l.selectedIndex,title:X})}),je,we,Ce,Te]})},En=s=>{const{args:e,autoExit:t=!1,onRetryService:r,outputStyle:o="normal",projectNames:a,serviceDockStore:n,stdinRegistry:d,tasks:f}=s,h=new rt(f),u=typeof e.parallel=="number"?e.parallel:3,g=t===!0?3:typeof t=="number"?t:0;let l,S;const R=new Promise(j=>{S=j});let B;const W=()=>{B&&(clearInterval(B),B=void 0)},k=()=>{if(process.stdin.isTTY&&typeof process.stdin.setRawMode=="function")try{process.stdin.setRawMode(!1)}catch{}process.stdin.pause(),process.stdin.unref()},x=()=>{if(d){for(const j of d.values())j.kill?.();d.clear()}},F=()=>{W(),w(),x(),k(),process.stdout.write("\x1B[?1049l\x1B[?25h"),l?.cleanup(),process.exit(1)},T=()=>{const j=h.getSnapshot(),A=De(Date.now()-j.startTime),O=j.rows.filter(Q=>Q.status==="failure").map(Q=>Q.taskId),z=process.stdout.columns||80;process.stdout.write(`
|
|
20
|
+
`);for(const Q of j.rows){const{persistent:_,status:Z,taskId:xe}=Q,ee=Z==="running"||Z==="pending",ce=_e(Z),le=ee&&_?"■":ce.icon,H=ee&&_?"gray":ce.color;let V="";switch(Z){case"local-cache":case"local-cache-kept-existing":{V=" [local cache]";break}case"remote-cache":{V=" [remote cache]";break}case"skipped":{V=" [skipped]";break}default:{ee&&_?V=" [stopped]":ee&&(V=" [skipped]");break}}const oe=Q.retryAttempts&&Q.retryAttempts>0?` [retried ${Q.retryAttempts}x]`:"",se=pe(J.createElement(c,null," ",J.createElement(c,{color:H},le),` vis run ${xe}`,V?J.createElement(c,{dimColor:!0},` ${V}`):null,oe?J.createElement(c,{color:"yellow"},oe):null),{columns:z});process.stdout.write(`${se}
|
|
21
|
+
`)}process.stdout.write(`
|
|
22
|
+
`);const ie=pe(J.createElement(Os,{cached:j.cached,failed:j.failed,failedIds:O,projectNames:a,retriedIds:j.retriedIds.length>0?j.retriedIds:void 0,succeeded:j.succeeded,targets:e.targets,tasks:f,took:A}),{columns:z});if(process.stdout.write(`${ie}
|
|
23
|
+
`),o!=="quiet"){const Q=[...j.rows.filter(_=>_.status!=="failure"),...j.rows.filter(_=>_.status==="failure")];for(const _ of Q){if(_.status==="running"||_.status==="pending")continue;const Z=j.outputs.get(_.taskId);if(!Z?.trim())continue;const{color:xe,icon:ee}=_e(_.status),ce=pe(J.createElement(c,null,`
|
|
24
|
+
`,J.createElement(c,{bold:!0,color:xe},` ${ee} vis run ${_.taskId}`)),{columns:z});process.stdout.write(`${ce}
|
|
25
|
+
|
|
26
|
+
`);const le=Z.trim().split(`
|
|
27
|
+
`).map(H=>` ${H}`).join(`
|
|
28
|
+
`);process.stdout.write(`${le}
|
|
29
|
+
`)}}};let C;const w=()=>{C&&(clearInterval(C),C=void 0)};return{lifeCycle:{endCommand(){W(),h.markDone(),C||(C=setInterval(()=>{},1e3))},endTasks(j){h.endTasks(j)},printCacheDisabledByTask(j){h.addOutput(j.id,`ⓘ caching disabled by task via disableCache()
|
|
30
|
+
`)},printEmptyFingerprintWarning(j,A){h.addOutput(j.id,`ⓘ caching skipped — ${A}
|
|
31
|
+
`)},printSelfModifyingSkip(j,A){h.addOutput(j.id,`ⓘ caching skipped — task modified its own input${A.length===1?"":"s"} (${A.join(", ")})
|
|
32
|
+
`)},printTaskTerminalOutput(j,A,O){h.getSnapshot().outputs.has(j.id)||h.addOutput(j.id,O)},startCommand(){process.on("SIGINT",F),process.on("SIGTERM",F),C||(C=setInterval(()=>{},1e3)),l=jr(J.createElement(Rn,{autoExitSeconds:g,onRetryService:r,parallelSlots:u,projectNames:a,serviceDockStore:n,stdinRegistry:d??new Map,store:h,targets:e.targets,tasks:f}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}),l.waitUntilExit().then(()=>{w(),x(),k(),process.removeListener("SIGINT",F),process.removeListener("SIGTERM",F),T(),S()}).catch(()=>{w(),x(),k(),process.removeListener("SIGINT",F),process.removeListener("SIGTERM",F),S()})},startTasks(j){h.startTasks(j),B||(B=setInterval(()=>{h.tick()},100))}},renderIsDone:R,store:h}},Mn=s=>s==="quiet"?"quiet":"normal",Fn=(s,e)=>typeof s=="string"?Mn(s.toLowerCase()):e===!0?"quiet":"normal",On=(s,e)=>{const t=s.overrides.visOptions;return t?.outputStyle==="normal"||t?.outputStyle==="quiet"?t.outputStyle:e};class Pn{#e;#r;#s;#i=[];#t=[];#n=[];#o=new Map;#a;#c;#l;#u=0;constructor(e){this.#e=e.projectNames,this.#r=e.args.targets,this.#s=e.tasks,this.#a=e.logReporter,this.#c=e.outputStyle??"normal",this.#l=e.ciGrouping??"auto"}startCommand(){this.#u=Date.now();const e=process.stdout.columns||80,t=`Running ${yt(this.#e,this.#r,this.#s)}`,r=pe(J.createElement(ht,{title:t,variant:"info"}),{columns:e});process.stdout.write(r);const o=this.#s[0],a=o?.overrides?Object.entries(o.overrides).filter(([n])=>n!=="command"):[];if(a.length>0){process.stdout.write(`
|
|
33
|
+
With additional flags:
|
|
34
|
+
`);for(const[n,d]of a)process.stdout.write(`${nn(" ",n,d)}
|
|
35
|
+
`)}process.stdout.write(`
|
|
36
|
+
`)}startTasks(e){const t=process.stdout.columns||80;for(const r of e){const o=pe(J.createElement(c,null,J.createElement(c,{dimColor:!0},">"),` ${r.id}`),{columns:t});process.stdout.write(`${o}
|
|
37
|
+
`)}}endTasks(e){const t=process.stdout.columns||80;for(const r of e){this.#o.set(r.task.id,r),r.status==="failure"?this.#i.push(r):Ne(r.status)&&this.#t.push(r),r.retryAttempts&&r.retryAttempts>0&&this.#n.push(r);const o=We(r.status),a=r.startTime&&r.endTime?` (${De(r.endTime-r.startTime)})`:"",n=Ne(r.status)?" [cache]":"",d=r.retryAttempts&&r.retryAttempts>0?` [retried ${r.retryAttempts}x]`:"",f=pe(J.createElement(c,null,o,` ${r.task.id}`,n?J.createElement(c,{color:"cyan"},n):null,d?J.createElement(c,{color:"yellow"},d):null,a?J.createElement(c,{dimColor:!0},a):null),{columns:t});process.stdout.write(`${f}
|
|
38
|
+
`)}}#d(e){const t=process.stdout.columns||80,r=pe(J.createElement(c,{dimColor:!0},` ⓘ ${e}`),{columns:t});process.stdout.write(`${r}
|
|
39
|
+
`)}printCacheDisabledByTask(e){this.#d(`${e.id}: caching disabled by task via disableCache()`)}printSelfModifyingSkip(e,t){this.#d(`${e.id}: caching skipped — task modified its own input${t.length===1?"":"s"} (${t.join(", ")})`)}printEmptyFingerprintWarning(e,t){this.#d(`${e.id}: caching skipped — ${t}`)}printTaskTerminalOutput(e,t,r){if(On(e,this.#c)==="quiet"&&(t==="success"||Ne(t)))return;const o=t==="failure"?As(r,{color:!process.env.NO_COLOR,cwd:process.cwd()}):r;if(this.#a){this.#a.printTaskTerminalOutput(e,t,o);return}yn(e.id,t,o,this.#l)}endCommand(){const e=De(Date.now()-this.#u),t=this.#s.filter(a=>!this.#o.has(a.id)).map(a=>a.id);process.stdout.write(`
|
|
40
|
+
`);const r=process.stdout.columns||80,o=pe(J.createElement(Os,{cached:this.#t.length,failed:this.#i.length,failedIds:this.#i.map(a=>a.task.id),projectNames:this.#e,retriedIds:this.#n.length>0?this.#n.map(a=>a.task.id):void 0,skippedIds:t.length>0?t:void 0,succeeded:this.#o.size-this.#i.length-this.#t.length,targets:this.#r,tasks:this.#s,took:e}),{columns:r});process.stdout.write(`${o}
|
|
41
|
+
`)}}const An=async s=>{if(process.env.VIS_NO_SHELL_HISTORY)return;if(ki()==="win32"){try{await Bn(s)}catch{}return}const e=process.env.SHELL;if(!e)return;const t=sr(e);try{if(t==="zsh"){await Dn(s);return}if(t==="bash"){await Ln(s);return}t==="fish"&&await Nn(s)}catch{}},vt=s=>s.replaceAll(/[\u0000-\u001F\u007F]/gu," ").trimEnd(),Dn=async s=>{const e=process.env.HISTFILE??ae(process.env.ZDOTDIR??mt(),".zsh_history"),t=`: ${Math.floor(Date.now()/1e3)}:0;${vt(s)}
|
|
42
|
+
`;await at(e,t)},Ln=async s=>{const e=process.env.HISTFILE??ae(mt(),".bash_history");await at(e,`${vt(s)}
|
|
43
|
+
`)},Bn=async s=>{const e=process.env.VIS_PSREADLINE_HISTORY,t=process.env.APPDATA;if(e===void 0&&(t===void 0||t===""))return;const r=e??ae(t,"Microsoft","Windows","PowerShell","PSReadLine","ConsoleHost_history.txt");await xi(ys(r),{recursive:!0}),await at(r,`${vt(s)}\r
|
|
44
|
+
`)},Nn=async s=>{const e=ae(mt(),".local","share","fish","fish_history"),t=`- cmd: ${s.replaceAll("\\","\\\\").replaceAll(`
|
|
45
|
+
`,String.raw`\n`).replaceAll("\r",String.raw`\r`)}
|
|
46
|
+
when: ${Math.floor(Date.now()/1e3)}
|
|
47
|
+
`;await at(e,t)},Gn=s=>{const{killGracePeriodMs:e=5e3,onTimeout:t,sendSignal:r,timeoutMs:o}=s;if(o<=0)return{cancel:()=>{}};const a=Math.max(e,0);let n;const d=setTimeout(()=>{t?.(),r("SIGTERM"),a>0&&(n=setTimeout(()=>{r("SIGKILL")},a))},o);return{cancel:()=>{clearTimeout(d),n&&clearTimeout(n)}}},_n=(s,e)=>{const t=e?.trim();if(!t)return{filter:void 0,tasks:[...s]};const r=t.toLowerCase();return{filter:t,tasks:s.filter(o=>o.target.project.toLowerCase().includes(r))}},qn=[""," Watch keybinds:"," r, Enter rerun"," a rerun all (clear filter)"," p filter by project name"," q, Ctrl+C quit"," h, ? show this help",""].join(`
|
|
48
|
+
`),zn=s=>{s.write(`${qn}
|
|
49
|
+
`)},Hn=async(s,e)=>{e.write("filter projects (empty to cancel) > ");const t=s,r=t.isRaw===!0;if(r)try{t.setRawMode?.(!1)}catch{}return await new Promise(o=>{let a="";const n=d=>{a+=typeof d=="string"?d:d.toString("utf8");const f=a.indexOf(`
|
|
50
|
+
`);if(f===-1)return;const h=a.slice(0,f).replace(/\r$/,"").trim();if(s.off("data",n),r)try{t.setRawMode?.(!0)}catch{}o(h.length>0?h:void 0)};s.on("data",n)})},Un=s=>{const{handlers:e}=s,t=s.input??process.stdin,r=s.output??process.stdout,o=s.promptFilter??Hn;if(!t||t.isTTY===!1)return{close:()=>{}};Ur(t);const a=t.isRaw===!0;try{t.setRawMode?.(!0)}catch{return{close:()=>{}}}typeof t.resume=="function"&&t.resume();let n=!1;const d=async u=>{if(u.ctrl===!0&&u.name==="c"){await e.onQuit();return}if(!n)switch(u.name){case"?":case"h":{await e.onHelp();break}case"a":{await e.onClearFilter();break}case"p":{n=!0;try{const g=await o(t,r);g===void 0?r.write(`filter cancelled.
|
|
51
|
+
`):await e.onFilter(g)}finally{n=!1}break}case"q":{await e.onQuit();break}case"r":{await e.onRerun();break}case"return":{await e.onRerun();break}}},f=(u,g)=>{d(g).catch(l=>{r.write(`[vis watch] keybind handler failed: ${l.message}
|
|
52
|
+
`)})},h=t;return h.on("keypress",f),{close:()=>{if(h.off("keypress",f),!a)try{t.setRawMode?.(!1)}catch{}const u=t;if(typeof u.pause=="function")try{u.pause()}catch{}}}},Vn=s=>{const e=s.overrides.visOptions;return e&&typeof e=="object"?e:void 0},Wn=async s=>{const{initialTasks:e,probe:t,registeredEntries:r,taskGraph:o,visVersion:a}=s,n=new Map,d=new Map,f=new Map;for(const w of r)if(Yr(w.pid)){if(w.visVersion!==a){d.set(w.id,w);continue}n.set(w.id,w)}if(t){const w=[...n.values()],j=await Promise.all(w.map(async A=>{try{return[A.id,await t(A)]}catch{return[A.id,!1]}}));for(const[A,O]of j)if(!O){const z=n.get(A);n.delete(A),z&&f.set(A,z)}}const h=new Set(e.map(w=>w.id)),u=new Set,g=[],l=[],S=new Set;for(const w of Object.values(o.dependencies))for(const j of w)S.add(j);for(const[w,j]of Object.entries(o.tasks)){if(!Vn(j)?.service)continue;if(n.has(w)){u.add(w),l.push(n.get(w));continue}if(h.has(w)||!S.has(w))continue;const A=d.get(w),O=f.get(w);let z;A?z=`Service ${w} is registered with vis ${A.visVersion}, but this invocation is vis ${a}. Restart with \`vis service restart ${w}\` to pick up the new version.`:O?z=`Service ${w} is registered (PID ${String(O.pid)}) but failed its readiness probe — the wrapper process is alive but the underlying server is not responding. Run \`vis service restart ${w}\` to recover.`:z=`Target depends on the service ${w}, which is not running. Run \`vis service start ${w}\` first, or invoke \`${w}\` directly.`,g.push({message:z,targetId:w})}if(u.size===0)return{diagnostics:g,initialTasks:e,satisfiedServices:l,serviceDependentsByServiceId:new Map,serviceEnvByTaskId:new Map,taskGraph:o};const R=new Map,B=w=>{const j=new Set,A=[...o.dependencies[w]??[]],O=new Set;for(;A.length>0;){const z=A.pop();if(!O.has(z)){O.add(z),u.has(z)&&j.add(z);for(const ie of o.dependencies[z]??[])O.has(ie)||A.push(ie)}}return[...j].sort()},W=new Map;for(const w of Object.keys(o.dependencies)){if(u.has(w))continue;const j=B(w);if(j.length===0)continue;const A={};for(const O of j){const z=n.get(O);if(!z)continue;Object.assign(A,z.env);const ie=W.get(O);ie?ie.push(w):W.set(O,[w])}Object.keys(A).length>0&&R.set(w,A)}for(const w of W.values())w.sort();const k={};for(const[w,j]of Object.entries(o.tasks))u.has(w)||(k[w]=j);const x={};for(const[w,j]of Object.entries(o.dependencies))u.has(w)||(x[w]=j.filter(A=>!u.has(A)));const F=new Map;for(const w of Object.keys(k))F.set(w,0);for(const w of Object.values(x))for(const j of w)F.has(j)&&F.set(j,(F.get(j)??0)+1);const T=[];for(const w of o.roots)!u.has(w)&&k[w]&&T.push(w);for(const[w,j]of F)j===0&&!T.includes(w)&&k[w]&&T.push(w);const C=e.filter(w=>!u.has(w.id));return{diagnostics:g,initialTasks:C,satisfiedServices:l,serviceDependentsByServiceId:W,serviceEnvByTaskId:R,taskGraph:{dependencies:x,roots:T,tasks:k}}},Xe="[[VIS_BOOT]]",Yn=250,Jn=1e3,hs=3,Kn=s=>{try{return process.kill(s,0),!0}catch{return!1}},fs=s=>{try{const e=Ge(s,"utf8").trim(),t=Number.parseInt(e,10);return Number.isFinite(t)&&t>0?t:null}catch{return null}};class Xn{#e;#r;#s;#i;#t=new Map;#n=new Map;#o=new Map;#a=new Map;#c=new Set;constructor(e){this.#e=e.indexToId,this.#r=new Map(e.services),this.#s=e.sink,this.#i=e.workspaceRoot}onProcessEvent=e=>{if(e.kind!=="stdout"&&e.kind!=="stderr")return;const t=this.#e.get(e.index);t===void 0||e.text===void 0||this.onTaskOutput(t,e.text)};onTaskOutput(e,t){if(!this.#r.has(e))return;const r=((this.#t.get(e)??"")+t).split(`
|
|
53
|
+
`),o=r.pop()??"";this.#t.set(e,o);for(const a of r)this.#l(e,a)}notifyRegistryStarting(e){this.#s.starting(e)}notifyRegistryStarted(e,t){this.#s.started(e,t)}onRegistryTaskStarted(e){this.#r.get(e)?.mode==="registry"&&this.notifyRegistryStarting(e)}async onRegistryTaskClosed(e,t,r){if(this.#r.get(e)?.mode!=="registry")return;if(r||t!==0){this.notifyRegistryFailed(e,"exit-code",{exitCode:t,killed:r});return}const o=await Jr(this.#i,e);if(!o){this.notifyRegistryFailed(e,"missing-registry-entry");return}const{config:a}=o,n=a.readiness?.tcp?.port??a.port??0,d=a.readiness?.tcp?.host??"127.0.0.1";this.notifyRegistryReady(e,{host:d,logFile:o.logFile,pid:o.pid,port:n})}notifyRegistryReady(e,t){this.#s.ready(e,{host:t.host,port:t.port}),this.#f(e,t.logFile),t.pid!==null&&this.#p(e,t.pid)}notifyRegistryFailed(e,t,r){this.#s.failed(e,t,r)}async retry(e){const t=this.#r.get(e);if(t){if(this.#h(e),this.#t.delete(e),this.#n.delete(e),this.#s.starting(e),t.mode==="registry"){await this.#v(e,t.registry);return}t.mode==="ephemeral"&&this.#y(e,t.ephemeral)}}async dispose(){for(const e of[...this.#o.keys(),...this.#a.keys()])this.#h(e);this.#c.size>0&&(await Promise.race([Promise.all(this.#c),new Promise(e=>{setTimeout(e,2e3)})]),this.#c.clear()),this.#t.clear(),this.#n.clear()}#l(e,t){if(t.startsWith(Xe)){this.#u(e,t.slice(Xe.length));return}const r=this.#n.get(e)??[];r.push(t),r.length>hs&&r.shift(),this.#n.set(e,r),this.#s.log(e,`${t}
|
|
54
|
+
`)}#u(e,t){let r;try{r=JSON.parse(t)}catch{this.#s.log(e,`${Xe+t}
|
|
55
|
+
`);return}switch(r.event){case"failed":{const o=typeof r.reason=="string"?r.reason:"unknown",a={};for(const[n,d]of Object.entries(r))n!=="event"&&n!=="id"&&n!=="reason"&&(a[n]=d);this.#s.failed(e,o,a);break}case"ready":{const o=typeof r.host=="string"?r.host:"127.0.0.1",a=typeof r.port=="number"?r.port:0;this.#s.ready(e,{host:o,port:a}),this.#d(e);break}case"started":{const o=typeof r.pid=="number"?r.pid:null;this.#s.started(e,o);break}default:this.#s.log(e,`${Xe+t}
|
|
56
|
+
`)}}#d(e){const t=this.#r.get(e);if(t?.ephemeral===void 0)return;this.#f(e,t.ephemeral.logFile);const r=fs(t.ephemeral.pidFile);r!==null&&this.#p(e,r)}#f(e,t){if(this.#o.has(e)||!Ae(t))return;const r=_r(t,"r"),o=(()=>{try{return Wt(t).size}catch{return 0}})(),a={fd:r,logFile:t,pollTimer:setInterval(()=>{this.#m(e)},Yn),position:o};this.#o.set(e,a)}#m(e){const t=this.#o.get(e);if(t)try{const r=Wt(t.logFile);if(r.size<=t.position)return;const o=Buffer.alloc(r.size-t.position),a=qr(t.fd,o,0,o.length,t.position);if(a>0){t.position+=a;const n=o.subarray(0,a).toString("utf8");for(const d of n.split(`
|
|
57
|
+
`))d.length!==0&&this.#w(e,d);this.#s.log(e,n)}}catch{}}#w(e,t){const r=this.#n.get(e)??[];for(r.push(t);r.length>hs;)r.shift();this.#n.set(e,r)}#p(e,t){if(this.#a.has(e))return;const r={pid:t,timer:setInterval(()=>{if(!Kn(t)){const o=[...this.#n.get(e)??[]];this.#h(e),this.#s.crashed(e,o)}},Jn)};this.#a.set(e,r)}#h(e){const t=this.#o.get(e);if(t){clearInterval(t.pollTimer);try{zr(t.fd)}catch{}this.#o.delete(e)}const r=this.#a.get(e);r&&(clearInterval(r.timer),this.#a.delete(e))}#y(e,t){if(t===void 0)return;const r=fs(t.pidFile);if(r!==null)try{process.kill(-r,"SIGTERM")}catch{}const o=ai("node",[t.scriptPath,t.configFile],{cwd:t.cwd,stdio:["ignore","pipe","pipe"]});o.stdout.on("data",n=>{this.#g(e,n)}),o.stderr.on("data",n=>{this.#g(e,n)}),o.on("error",n=>{this.#s.failed(e,"respawn-error",{message:n.message})});const a=new Promise(n=>{const d=()=>{this.#c.delete(a),n()};o.once("exit",d),o.once("error",d)});this.#c.add(a)}#g(e,t){const r=((this.#t.get(e)??"")+t.toString("utf8")).split(`
|
|
58
|
+
`),o=r.pop()??"";this.#t.set(e,o);for(const a of r)this.#l(e,a)}async#v(e,t){if(t!==void 0){try{await Kr({id:e,workspaceRoot:this.#i})}catch{}try{const r=await Xr({command:t.command,config:t.config,cwd:t.cwd,env:t.env,id:e,workspaceRoot:this.#i}),o=t.config.readiness?.tcp?.port??t.config.port??0,a=t.config.readiness?.tcp?.host??"127.0.0.1";this.#s.started(e,r.entry.pid),this.notifyRegistryReady(e,{host:a,logFile:r.entry.logFile,pid:r.entry.pid,port:o})}catch(r){const o=r instanceof Error?r.message:String(r);this.#s.failed(e,"retry-failed",{message:o})}}}}const Qn=s=>{const e=s.overrides.visOptions;return e&&typeof e=="object"?e:void 0},Gs=(s,e,t)=>{const r=[],o=[];for(const a of e){const n=t.tasks[a];if(!n){o.push({id:a,reason:"task not in graph"});continue}const d=n.overrides.command;if(!d){o.push({id:a,reason:"no command resolved"});continue}const f=Qn(n);if(!f?.service){o.push({id:a,reason:"no service config"});continue}const h=nt(s,n.projectRoot,!!f.runFromWorkspaceRoot),{envFile:u}=f,g=u===void 0||u===!1?{}:pt(h,u),l=f.service.env??{};r.push({command:d,config:f.service,cwd:h,env:{...g,...l},id:a})}return{services:r,skipped:o}},Zn=(s,e)=>{const t=new Set(s),r=new Map;for(const n of s){const d=(e.dependencies[n]??[]).filter(f=>t.has(f));r.set(n,new Set(d))}const o=[],a=new Set;for(;r.size>0;){const n=[];for(const[d,f]of r){for(const h of f)a.has(h)&&f.delete(h);f.size===0&&n.push(d)}n.length===0&&n.push(...r.keys());for(const d of n)a.add(d),r.delete(d);n.sort(),o.push({ids:n})}return o},eo=(s,e)=>{const t=[];for(const r of Zn(s,e))t.push(...r.ids);return t},to=String.raw`import { spawn } from "node:child_process";
|
|
59
|
+
import { closeSync, openSync, readFileSync, readSync, statSync, writeFileSync } from "node:fs";
|
|
60
|
+
import { createConnection } from "node:net";
|
|
61
|
+
|
|
62
|
+
const cfgPath = process.argv[2];
|
|
63
|
+
|
|
64
|
+
if (!cfgPath) {
|
|
65
|
+
console.error("[vis-service-bootstrap] missing config path");
|
|
66
|
+
process.exit(2);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const cfg = JSON.parse(readFileSync(cfgPath, "utf8"));
|
|
70
|
+
|
|
71
|
+
// Structured marker for service-event-bridge.ts to consume. Plain
|
|
72
|
+
// process.stdout.write keeps the line atomic and on the same stream
|
|
73
|
+
// as the tailed child log, so the parser sees one stream.
|
|
74
|
+
const emit = (event) => {
|
|
75
|
+
process.stdout.write("[[VIS_BOOT]]" + JSON.stringify({ ...event, id: cfg.id }) + "\n");
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
// Spawn the child with its stdio bound to a real file descriptor on
|
|
79
|
+
// disk — NOT inherited from the bootstrap. If the child inherited
|
|
80
|
+
// our stdio, it would inherit vis run's task pipes, and vis run would
|
|
81
|
+
// block waiting for those pipes to close even after this bootstrap
|
|
82
|
+
// exits. The logfile gives the grandchild a stable target it can keep
|
|
83
|
+
// writing to long after this bootstrap is gone.
|
|
84
|
+
const childLogFd = openSync(cfg.logFile, "a");
|
|
85
|
+
|
|
86
|
+
const child = spawn(cfg.command, {
|
|
87
|
+
cwd: cfg.cwd,
|
|
88
|
+
detached: true,
|
|
89
|
+
env: { ...process.env, ...cfg.env },
|
|
90
|
+
shell: true,
|
|
91
|
+
stdio: ["ignore", childLogFd, childLogFd],
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
// Close the bootstrap's copy of the fd; the child kept its own.
|
|
95
|
+
closeSync(childLogFd);
|
|
96
|
+
|
|
97
|
+
if (child.pid !== undefined) {
|
|
98
|
+
try {
|
|
99
|
+
writeFileSync(cfg.pidFile, String(child.pid));
|
|
100
|
+
} catch (error) {
|
|
101
|
+
console.error("[vis] failed to write pid file: " + (error?.message ?? String(error)));
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
emit({ event: "started", pid: child.pid ?? null });
|
|
106
|
+
|
|
107
|
+
let exitedEarly = false;
|
|
108
|
+
|
|
109
|
+
child.once("exit", (code, signal) => {
|
|
110
|
+
exitedEarly = true;
|
|
111
|
+
emit({ code, event: "failed", reason: "exited-before-ready", signal });
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
// Forward new bytes from the logfile to our stdout while we're alive.
|
|
115
|
+
// Polling-based tail; preflight is short, ~200ms per cycle is fine.
|
|
116
|
+
let tailPos = 0;
|
|
117
|
+
const tailFd = openSync(cfg.logFile, "r");
|
|
118
|
+
|
|
119
|
+
const flushTail = () => {
|
|
120
|
+
try {
|
|
121
|
+
const stat = statSync(cfg.logFile);
|
|
122
|
+
if (stat.size <= tailPos) return;
|
|
123
|
+
const remaining = stat.size - tailPos;
|
|
124
|
+
const buf = Buffer.alloc(remaining);
|
|
125
|
+
const n = readSync(tailFd, buf, 0, remaining, tailPos);
|
|
126
|
+
if (n > 0) {
|
|
127
|
+
process.stdout.write(buf.subarray(0, n));
|
|
128
|
+
tailPos += n;
|
|
129
|
+
}
|
|
130
|
+
} catch {}
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
const probeOnce = () => new Promise((resolve) => {
|
|
134
|
+
const socket = createConnection({ host: cfg.host || "127.0.0.1", port: cfg.port });
|
|
135
|
+
let settled = false;
|
|
136
|
+
const finish = (ok) => {
|
|
137
|
+
if (settled) return;
|
|
138
|
+
settled = true;
|
|
139
|
+
try { socket.destroy(); } catch {}
|
|
140
|
+
resolve(ok);
|
|
141
|
+
};
|
|
142
|
+
socket.once("connect", () => finish(true));
|
|
143
|
+
socket.once("error", () => finish(false));
|
|
144
|
+
socket.setTimeout(1000, () => finish(false));
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
148
|
+
|
|
149
|
+
(async () => {
|
|
150
|
+
const deadline = Date.now() + (cfg.timeoutMs ?? 30000);
|
|
151
|
+
while (Date.now() < deadline) {
|
|
152
|
+
flushTail();
|
|
153
|
+
if (exitedEarly) {
|
|
154
|
+
try { closeSync(tailFd); } catch {}
|
|
155
|
+
process.exit(1);
|
|
156
|
+
}
|
|
157
|
+
if (await probeOnce()) {
|
|
158
|
+
flushTail();
|
|
159
|
+
emit({ event: "ready", host: cfg.host || "127.0.0.1", port: cfg.port });
|
|
160
|
+
try { closeSync(tailFd); } catch {}
|
|
161
|
+
child.unref();
|
|
162
|
+
process.exit(0);
|
|
163
|
+
}
|
|
164
|
+
await sleep(200);
|
|
165
|
+
}
|
|
166
|
+
flushTail();
|
|
167
|
+
emit({ event: "failed", reason: "timeout", timeoutMs: cfg.timeoutMs ?? 30000 });
|
|
168
|
+
try { closeSync(tailFd); } catch {}
|
|
169
|
+
try { process.kill(-child.pid, "SIGTERM"); } catch {}
|
|
170
|
+
process.exit(1);
|
|
171
|
+
})();
|
|
172
|
+
`,so=()=>{const s=Hr(ae(ji(),"vis-services-")),e=ae(s,"bootstrap.mjs");return vs(e,to),{runDir:s,scriptPath:e}},_s=(s,e,t)=>{const r=t.replaceAll(/[^\w-]/g,"_");return{configFile:ae(s,`${r}.json`),logFile:ae(s,`${r}.log`),pidFile:ae(s,`${r}.pid`),scriptPath:e}},ro=s=>{const{paths:e,service:t}=s,r=t.config.readiness?.tcp?.port??t.config.port;if(typeof r!="number")throw new TypeError(`Service ${t.id} has no TCP readiness port — declare \`service.port\` or \`service.readiness.tcp.port\`.`);const o={...t.env,PATH:nr(t.cwd,t.env)};return{command:t.command,cwd:t.cwd,env:o,host:t.config.readiness?.tcp?.host??"127.0.0.1",id:t.id,logFile:e.logFile,pidFile:e.pidFile,port:r,timeoutMs:t.config.readiness?.tcp?.timeoutMs??3e4}},io=s=>`node ${JSON.stringify(s.scriptPath)} ${JSON.stringify(s.configFile)}`,no=s=>{const{id:e,visBin:t,workspaceRoot:r}=s;return`node ${JSON.stringify(t)} service start ${JSON.stringify(e)} --cwd ${JSON.stringify(r)}`},oo=s=>{const{missingServiceIds:e,mode:t,taskGraph:r,visBin:o,workspaceRoot:a}=s,{services:n,skipped:d}=Gs(a,e,r);if(n.length===0)return{chain:[],ephemeralPidFiles:[],runDir:void 0,serviceEnvByTaskId:new Map,skipped:d};const f=eo(n.map(k=>k.id),r),h=new Map(n.map(k=>[k.id,k])),u=[],g=[];if(t==="ephemeral")for(const k of f){const x=h.get(k);x&&g.push({id:k,payload:ro({paths:{logFile:"",pidFile:""},service:x})})}let l;t==="ephemeral"&&(l=so());let S;for(const k of f){const x=h.get(k),F=r.tasks[k];if(!x||!F)continue;let T;if(t==="ephemeral"){const C=_s(l.runDir,l.scriptPath,k),w={...g.find(j=>j.id===k).payload,logFile:C.logFile,pidFile:C.pidFile};vs(C.configFile,JSON.stringify(w)),T=io(C),u.push(C.pidFile)}else T=no({id:k,visBin:o,workspaceRoot:a});if(F.overrides={...F.overrides,command:T},F.cache=!1,r.tasks[k]=F,S!==void 0){const C=r.dependencies[k]??[];C.includes(S)||(r.dependencies[k]=[...C,S])}S=k}const R=new Set(f),B=new Map,W=k=>{const x=new Set,F=[...r.dependencies[k]??[]],T=new Set;for(;F.length>0;){const C=F.pop();if(!T.has(C)){T.add(C),R.has(C)&&x.add(C);for(const w of r.dependencies[C]??[])T.has(w)||F.push(w)}}return[...x].sort()};for(const k of Object.keys(r.dependencies)){if(R.has(k))continue;const x=W(k);if(x.length===0)continue;const F={};for(const T of x){const C=h.get(T);C?.config.env&&Object.assign(F,C.config.env)}Object.keys(F).length>0&&B.set(k,F)}return{chain:f,ephemeralPidFiles:u,runDir:l?.runDir,serviceEnvByTaskId:B,skipped:d}},ao=new Set(["auto","ephemeral","off","persistent"]),co=s=>{const{cli:e,config:t,isCi:r,isPersistentTarget:o,isTty:a,target:n}=s;if(e!==void 0&&!ao.has(e))throw new Error(`--services: expected one of auto|ephemeral|persistent|off, got "${e}"`);const d=e??t??(a&&!r?"auto":"off");return d==="off"?"off":d==="ephemeral"?"ephemeral":d==="persistent"?"registry":o||n==="dev"?"ephemeral":"registry"},qs=s=>s.replace(/^--?/u,""),lo=new Set(["0","1","false","no","true","yes"]),uo=s=>!s.startsWith("-")||/^-(?:\d|\.\d)/u.test(s),ps=(s,e,t,r,o,a)=>{if(r!==void 0)return s.set(e,r),0;const n=o[a+1];return(t?.type??"string")==="boolean"?n!==void 0&&lo.has(n.toLowerCase())?(s.set(e,n.toLowerCase()),1):(s.set(e,"true"),0):n!==void 0&&uo(n)?(s.set(e,n),1):(s.set(e,"true"),0)},ho=(s,e)=>{const t=s.type??"string";if(t==="number"){const r=e.trim(),o=Number(r);return r===""||!Number.isFinite(o)?{error:`--${s.name} expects a number, got "${e}"`}:{value:o}}if(t==="boolean")return["1","true","yes"].includes(e.toLowerCase())?{value:!0}:["0","false","no"].includes(e.toLowerCase())?{value:!1}:{error:`--${s.name} expects a boolean, got "${e}"`};if(t==="enum"){const r=s.choices??[];return r.includes(e)?{value:e}:{error:`--${s.name} must be one of [${r.join(", ")}], got "${e}"`}}return{value:e}},fo=s=>{const e=[],t=new Set;for(const r of s){const o=r.name||"<unnamed>";(!r.name||!/^[a-zA-Z][\w-]*$/u.test(r.name))&&e.push(`argument name "${o}" is empty or invalid (start with a letter; use letters, digits, '-', '_')`),t.has(r.name)&&e.push(`duplicate argument name "${o}"`),t.add(r.name),r.alias!==void 0&&r.alias.length!==1&&e.push(`argument "${o}" alias "${r.alias}" must be a single character`);const a=r.type??"string";if(a==="enum"&&(r.choices===void 0||r.choices.length===0)&&e.push(`argument "${o}" has type "enum" but declares no choices`),r.default!==void 0){const n=typeof r.default;a==="number"&&n==="number"||a==="boolean"&&n==="boolean"||(a==="string"||a==="enum")&&n==="string"?a==="enum"&&r.choices&&!r.choices.includes(r.default)&&e.push(`argument "${o}" default "${String(r.default)}" is not one of its choices`):e.push(`argument "${o}" default ${JSON.stringify(r.default)} does not match type "${a}"`)}}return e},po=(s,e)=>{const t=new Map,r=new Map;for(const h of s)t.set(h.name,h),h.alias&&r.set(h.alias,h);const o=new Map,a=[];for(let h=0;h<e.length;h+=1){const u=e[h];if(u==="--"){a.push(...e.slice(h+1));break}if(u.startsWith("--no-")){o.set(qs(u.slice(5)),"false");continue}const g=/^--([^=]+)(?:=(.*))?$/su.exec(u);if(g){const R=g[1];h+=ps(o,R,t.get(R),g[2],e,h);continue}const l=/^-([^=-])(?:=(.*))?$/su.exec(u),S=l?.[1];if(l&&S!==void 0){const R=r.get(S);h+=ps(o,R?.name??S,R,l[2],e,h);continue}a.push(u)}const n={},d=[];let f=0;for(const h of s){let u=o.get(h.name);if(u===void 0&&h.positional&&f<a.length&&(u=a[f],f+=1),u===void 0){h.default!==void 0?n[h.name]=h.default:h.required&&d.push(`missing required argument --${h.name}`);continue}const{error:g,value:l}=ho(h,u);g?d.push(g):l!==void 0&&(n[h.name]=l)}return{errors:d,values:n}},go=s=>`VIS_ARG_${qs(s).replaceAll(/[^a-zA-Z0-9]+/gu,"_").toUpperCase()}`,mo=s=>{const e={};for(const[t,r]of Object.entries(s))e[go(t)]=String(r);return e},ut=(s,e,t)=>{const r=[`Usage: vis run ${s} [-- <args>]`];if(e&&r.push("",e),t.length===0)return r.join(`
|
|
173
|
+
`);r.push("","Arguments:");const o=t.map(n=>{const d=n.positional?`<${n.name}>`:`--${n.name}`,f=n.alias?`, -${n.alias}`:"";return{left:`${d}${f}`,right:n}}),a=Math.max(...o.map(n=>n.left.length));for(const{left:n,right:d}of o){const f=[],h=d.type??"string";f.push(h==="enum"?`enum(${(d.choices??[]).join("|")})`:h),d.required&&f.push("required"),d.default!==void 0&&f.push(`default: ${String(d.default)}`);const u=`${d.description??""}${d.description?" ":""}[${f.join(", ")}]`;r.push(` ${n.padEnd(a)} ${u}`)}return r.join(`
|
|
174
|
+
`)},wo=(s,e,t,r)=>{if(!t||t.length===0)return{env:{},kind:"ok"};const o=fo(t);if(o.length>0)return{errors:o.map(n=>`invalid \`arguments\` schema for "${s}": ${n}`),help:ut(s,e,t),kind:"invalid"};if(r.includes("--help")||r.includes("-h"))return{kind:"help",text:ut(s,e,t)};const a=po(t,r);return a.errors.length>0?{errors:a.errors,help:ut(s,e,t),kind:"invalid"}:{env:mo(a.values),kind:"ok"}},xt="VIS_AFFECTED_FILES",yo=2e3,gs=async(s,e,t,r,o,a)=>{const n=s.map(T=>{const C=T.overrides.command;if(!C)return;const w=T.overrides.visOptions,j=nt(e,T.projectRoot,!!w?.runFromWorkspaceRoot),A=w?.envFile?pt(j,w.envFile):{},O=t&&(w?.affectedFiles==="env"||w?.affectedFiles==="both")?{[xt]:t.join(`
|
|
175
|
+
`)}:{},z=a?.get(T.id)??{},ie=_i({interactive:!!o,taskPty:T.pty,workspacePty:w?.pty});return{command:C,cwd:j,env:{INIT_CWD:r,...A,...z,...O,...T.overrides[jt]},name:T.id,...ie?{ptySize:{cols:process.stdout.columns??80,rows:process.stdout.rows??24},stdin:"pty"}:{}}}).filter(T=>T!==void 0);if(n.length===0)return;if(!o){await Qe(n,{killOthers:["failure"],onEvent:()=>{}});return}const{abortSignal:d,lifeCycle:f,stdinRegistry:h,store:u}=o,g=n.map(T=>s.find(C=>C.id===T.name)).filter(Boolean),l=T=>n[T]?.stdin==="pty",S=new Map,R=T=>{if(!l(T))return;let C=S.get(T);return C||(C=new ft(it),S.set(T,C)),C};u.unmarkDone(),f.startTasks?.(g);const B=new Map,W=new Map;let k;const x=()=>{for(const T of W.values())try{T("SIGTERM")}catch{}k||(k=setTimeout(()=>{for(const T of W.values())try{T("SIGKILL")}catch{}W.clear()},2e3),k.unref?.())};let F;d&&(F=()=>{x()},d.then(()=>{F?.()}).catch(()=>{F?.()}));try{await Qe(n,{killOthers:["failure"],onEvent:T=>{const C=g[T.index];if(C)switch(T.kind){case"close":{const w=B.get(C.id)??Date.now(),j=T.killed||T.exitCode===0?"success":"failure";f.endTasks?.([{code:T.exitCode??0,endTime:Date.now(),startTime:w,status:j,task:C,terminalOutput:u.getSnapshot().outputs.get(C.id)??""}]),W.delete(T.index),h?.delete(C.id);break}case"error":{if(T.message){const w=R(T.index);w?(w.write(`${T.message}
|
|
176
|
+
`),u.setOutput(C.id,w.toString())):u.addOutput(C.id,`${T.message}
|
|
177
|
+
`)}break}case"started":{B.set(C.id,Date.now()),T.kill&&W.set(T.index,T.kill),T.write&&h&&h.set(C.id,{kill:T.kill,resize:T.resize,write:T.write});break}case"stderr":case"stdout":{if(T.text){const w=R(T.index);w?(w.write(T.text),u.setOutput(C.id,w.toString())):u.addOutput(C.id,`${T.text}
|
|
178
|
+
`)}break}}}})}finally{k&&(clearTimeout(k),k=void 0),u.markDone()}},ms=s=>{try{return process.kill(-s,0),!0}catch{try{return process.kill(s,0),!0}catch{return!1}}},vo=s=>{Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,s)},xo=s=>{const{extraPids:e=[],pidFiles:t,runDir:r}=s,o=[],a=n=>{try{process.kill(-n,"SIGTERM")}catch{try{process.kill(n,"SIGTERM")}catch{}}};for(const n of t){let d;try{const f=rr(n),h=Number.parseInt(f.trim(),10);d=Number.isFinite(h)&&h>0?h:void 0}catch{continue}d!==void 0&&(o.push(d),a(d))}for(const n of e)!Number.isFinite(n)||n<=0||(o.push(n),a(n));if(o.length>0){const n=Date.now()+1500;for(;Date.now()<n;){let d=!0;for(const f of o)if(ms(f)){d=!1;break}if(d)break;vo(100)}for(const d of o)if(ms(d))try{process.kill(-d,"SIGKILL")}catch{try{process.kill(d,"SIGKILL")}catch{}}}r&&ir(r)},it=256*1024;class ko{#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...]
|
|
179
|
+
${this.#r}`:this.#r}}const zs=s=>{const e=s.overrides.visOptions;if(e&&typeof e=="object")return e},jo=s=>`'${s.replaceAll("'",String.raw`'\''`)}'`,kt=s=>process.platform==="win32"?s.length>0&&!/[\s"&|<>^()%!]/.test(s)?s:`"${s.replaceAll('"','""')}"`:jo(s),bo=(s,e,t)=>{if(!e||e.length===0||t===!1||t===void 0)return s;if(t==="args"||t==="both"){const r=e.map(o=>kt(o)).join(" ");return`${s} ${r}`}return s},Hs="visForwardedArgs",jt="visTaskArgEnv",$o=(s,e)=>{const t=e.overrides[Hs];if(!Array.isArray(t)||t.length===0)return s;const r=t.map(o=>kt(o)).join(" ");return`${s} ${r}`},So=async(s,e,t)=>{if(!e)return t();const r=s.get(e)??Promise.resolve();let o;const a=new Promise(d=>{o=d}),n=r.then(()=>a);s.set(e,n),await r;try{return await t()}finally{o(),s.get(e)===n&&s.delete(e)}},To=s=>{let e=Math.max(0,Math.floor(s));return{claim(t){const r=Math.max(0,Math.min(t,e));return e-=r,r},get remaining(){return e}}},Co=(s,e,t)=>{const r=`${e}\0${typeof t=="string"?t:String(t)}`,o=s.get(r);if(o)return o;const a=pt(e,t);return s.set(r,a),a},ws=s=>{const e=new Map;return async(t,r)=>{const{affectedFiles:o,currentOs:a,hooks:n,initCwd:d,lifeCycle:f,mutexPool:h,onOutput:u,onOutputReplace:g,retryBudget:l,serviceEnvByTaskId:S,serviceEventBridge:R,stdinRegistry:B,strictEnv:W,workspaceRoot:k}=s,x=zs(t),F=nt(k,r.cwd??t.projectRoot,x?.runFromWorkspaceRoot===!0),T=t.overrides.command;if(!T)return{code:0,terminalOutput:`No command configured for ${t.target.project}:${t.target.target}`};const C=$o(T,t),w=bo(C,o,x?.affectedFiles),j=Lr(x,a),A=x?.shellArgs,O=A&&A.length>0?A.join(" "):"-c",z=j?`${j} ${O} ${kt(w)}`:w,ie=x?.envFile?Co(e,F,x.envFile):void 0,Q={};o&&o.length>0&&(x?.affectedFiles==="env"||x?.affectedFiles==="both")&&(Q[xt]=o.join(`
|
|
180
|
+
`));const _=S?.get(t.id),Z={INIT_CWD:d,...ie,..._,...r.env,...Q,...t.overrides[jt]};if(x?.strictEnv??W??!1){const E=Wi({command:w,processEnv:process.env,taskEnv:Z,taskId:t.id});if(E){const de=Yi(E);return f?.onTaskStderr?.(t,de),{code:1,terminalOutput:de}}}const xe=x?.pty===!0,ee=!!B,ce=t.pty===!0?!0:t.pty===!1?!1:ee||xe;ce&&(t.cache=!1);const le=ce?void 0:new ko(it),H=ce?new ft(it):void 0;let V;const oe=E=>{if(E.kind==="started"&&(V=E.kill,E.write&&B&&B.set(t.id,{kill:E.kill,resize:E.resize,write:E.write}),R?.onRegistryTaskStarted(t.id)),(E.kind==="stdout"||E.kind==="stderr")&&E.text!==void 0)if(E.kind==="stdout"?f?.onTaskStdout?.(t,E.text):f?.onTaskStderr?.(t,E.text),H)H.write(E.text),ee&&g?.(t.id,H.toString()),R&&R.onTaskOutput(t.id,E.text);else{const de=`${E.text}
|
|
181
|
+
`;le.append(de),u?.(t.id,de)}E.kind==="close"&&(B&&B.delete(t.id),R&&R.onRegistryTaskClosed(t.id,E.exitCode??0,!!E.killed).catch(()=>{}))},se=async()=>{const E=x?.retryCount??0,de=x?.retryDelay,Ie=l?l.claim(E):E,Fe=typeof x?.timeout=="number"&&x.timeout>0?x.timeout:0,Le=typeof x?.killGracePeriodMs=="number"&&x.killGracePeriodMs>=0?x.killGracePeriodMs:5e3;let Oe=!1,X=0;const Re=Gn({killGracePeriodMs:Le,onTimeout:()=>{Oe=!0},sendSignal:we=>{V?.(we)},timeoutMs:Fe});let Se;try{Se=await Qe([{command:z,cwd:F,env:Z,name:t.id,...ce?{ptySize:{cols:process.stdout.columns??80,rows:process.stdout.rows??24},stdin:"pty"}:{}}],{killOthers:["failure"],onEvent:oe,...Ie>0?{restart:{delay:de??"exponential",onRetry:async(we,Te,Ce)=>{X=we,n&&await n.callHook("task:retry",t,we,Ce)},tries:Ie}}:{}})}finally{Re.cancel()}const ke=Se.closeEvents[0],ge=H?H.toString():le.toString();return Oe?{code:124,retryAttempts:X,terminalOutput:`${ge}
|
|
182
|
+
[timeout] Task "${t.id}" exceeded ${Fe}ms budget.
|
|
183
|
+
`}:{code:ke?.exitCode??1,retryAttempts:X,terminalOutput:ge}};return h?So(h,x?.mutex,se):se()}},Io=s=>{if(!s||s.trim().length===0)return;const e=Number.parseFloat(s);return!Number.isFinite(e)||e<=0?{invalid:s}:{value:Math.floor(e)}},Ro=async(s,e)=>{const t=await fr(s,{dataDirectory:Ze(s)});if(!t){e.warn(`No previous run recorded yet. Run a task at least once to populate ${pr(s,{dataDirectory:Ze(s)})}.`);return}const r=(t.duration/1e3).toFixed(2);if(e.info(""),e.info(`Last run — ${t.startTime} (${r}s)`),e.info(""),e.info(` Total: ${String(t.stats.total)}`),e.info(` Succeeded: ${String(t.stats.succeeded)}`),e.info(` Cached: ${String(t.stats.cached)}`),e.info(` Failed: ${String(t.stats.failed)}`),e.info(` Skipped: ${String(t.stats.skipped)}`),e.info(""),t.stats.failed>0){const a=t.tasks.filter(n=>n.exitCode!==void 0&&n.exitCode!==0);e.info("Failed tasks:");for(const n of a){const d=n.duration??0;e.info(` × ${n.taskId} (exit ${String(n.exitCode??-1)}, ${d}ms)`)}e.info("")}const o=[...t.tasks].filter(a=>typeof a.duration=="number").sort((a,n)=>(n.duration??0)-(a.duration??0)).slice(0,5);if(o.length>0){e.info("Slowest tasks:");for(const a of o)e.info(` ${a.taskId.padEnd(40)} ${String(a.duration??0).padStart(6)}ms [${a.cacheStatus}]`);e.info("")}},Eo=s=>{if(!(s===void 0||s==="")){if(s!=="read"&&s!=="write"&&s!=="readwrite")throw new Error(`--cache-mode must be one of: read, write, readwrite (received "${s}")`);return s}},Mo=s=>{if(!(s===void 0||s==="")){if(s!=="http"&&s!=="reapi")throw new Error(`--cache-backend must be one of: http, reapi (received "${s}")`);return s}},Fo=s=>{if(!(s===void 0||s==="")){if(s!=="declared"&&s!=="trace")throw new Error(`--hash-mode must be one of: declared, trace (received "${s}")`);return s}},Jo=async({argument:s,logger:e,options:t,runtime:r,visConfig:o,workspaceRoot:a})=>{if(!a)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const n=a;if(br(n),t.lastDetails===!0){await Ro(n,e);return}const d=process.cwd(),f=await $r(n),{config:h,packageJsons:u,projectOptions:g,workspace:l}=Sr(n,o,f),S=Tr(n,l,u);let R=s[0];if(!R){const p=ts(l);if(process.stdout.isTTY&&process.stdin.isTTY){const y=await en(p);if(!y){e.info("No target selected.");return}R=y,await An(`vis run ${y}`)}else{e.info("Available targets:"),e.info(""),e.info(Zi(p)),e.info(""),e.info("Usage: vis run <target>");return}}if(h.constraints&&!t.skipConstraints){const p=or(S,h.constraints);if(p.length>0){for(const y of p)e.error(`[${y.rule}] ${y.message}`);throw new Error(`${p.length} project constraint violation(s) found. Use --skip-constraints to bypass.`)}}if(t.affected){const p=[R];t.parallel!==void 0&&p.push(`--parallel=${String(t.parallel)}`),t.cache||p.push("--no-cache"),t.query&&p.push(`--query=${String(t.query)}`),t.reverse&&p.push("--reverse"),typeof t.runnerTags=="string"&&t.runnerTags!==""&&p.push(`--runner-tags=${t.runnerTags}`),await r.runCommand("affected",{argv:p});return}const B=await ni(R,l,process.cwd(),n),W=Ji(g),k=Ki(B.target,W);k!==B.target&&e.debug?.(`Resolved alias "${B.target}" → "${k}"`);let x=B.projects;const F=s.slice(1).map(String);if(t.projects){const p=new Set(t.projects.split(",").map(y=>y.trim()));if(x=x.filter(y=>p.has(y)),x.length===0)throw new Error(`No matching projects found for: ${String(t.projects)}`)}if(t.query&&(x=oi(x,l,t.query),x.length===0)){e.info(`Query "${String(t.query)}" matched no projects.`);return}const T=Cr(),C=process.env[xt],w=C?C.split(`
|
|
184
|
+
`).filter(Boolean):void 0,j=(typeof t.runnerTags=="string"?t.runnerTags:process.env.VIS_RUNNER_TAGS)??void 0,A=j?new Set(j.split(",").map(p=>p.trim()).filter(Boolean)):void 0,O=[],z=new Map;for(const p of x){const y=g.get(p)?.[k];if(!y)continue;const b=y.options;if(!b?.internal){if(!Ir(b,!!Ve)){e.debug?.(`Skipping ${p}:${k} — runInCI filter`);continue}if(!Rr(b,A)){e.debug?.(`Skipping ${p}:${k} — runner-tags filter`);continue}O.push(p),z.set(p,y)}}if(O.length===0){const p=ts(l),y=Object.entries(l.projects).filter(([,b])=>b.targets?.[k]!==void 0).map(([b])=>b);if(e.error(`No projects have the "${k}" target.`),y.length>0){e.info(""),e.info(`Target "${k}" exists in these projects but was filtered out:`);for(const b of y.slice(0,5))e.info(` - ${b}`);y.length>5&&e.info(` …and ${y.length-5} more`)}else{const b=Fs(k,p,3);b.length>0&&(e.info(""),e.info(b.length===1?`Did you mean "${b[0]}"?`:`Did you mean one of: ${b.map(L=>`"${L}"`).join(", ")}?`)),e.info(""),e.info("Run `vis run` without arguments to see all available targets.")}return}const ie=t.pty===!0,Q=O.map(p=>({project:p,schema:z.get(p)?.arguments})).filter(p=>Array.isArray(p.schema)&&p.schema.length>0),_=new Map;for(const{project:p,schema:y}of Q){const b=JSON.stringify(y),L=_.get(b)??[];L.push(p),_.set(b,L)}if(_.size>1){const p=[..._.values()].map(y=>y.join(", ")).join(" | ");throw new Error(`Target "${k}" declares conflicting \`arguments\` schemas across projects (${p}). Run a single project (e.g. \`vis run ${Q[0]?.project}:${k}\` or --projects=<name>) so the argument contract is unambiguous.`)}const Z=Q[0]?.schema,xe=z.get(Q[0]?.project??O[0])?.description,ee=wo(k,xe,Z,F);if(ee.kind==="help"){e.info(ee.text);return}if(ee.kind==="invalid"){e.info(`Invalid arguments for "${k}":`);for(const p of ee.errors)e.info(` ✖ ${p}`);throw e.info(""),e.info(ee.help),new Error(`Invalid arguments for target "${k}"`)}const ce=ee.env,le=Fo(t.hashMode);let H=O.map(p=>{const y=l.projects[p],b=z.get(p),L={project:p,target:k},q=`${p}:${k}`,Y=ie?{...b.options,pty:b.options?.pty??!0}:b.options,D=b.command?qt(b.command,{affectedFiles:w,projectRoot:y?.root}):b.command,P=y?.root&&y.root.length>0?y.root:".",re=(b.outputs??[]).map(M=>typeof M!="string"?M:M.replaceAll("{projectRoot}",P).replaceAll("{projectName}",p));return{cache:b.cache,hashMode:le??b.hashMode,id:q,outputs:re,overrides:{command:D,...F.length>0?{[Hs]:F}:{},...Object.keys(ce).length>0?{[jt]:ce}:{},...Y?{visOptions:Y}:{}},parallelism:b.parallelism,projectRoot:y?.root,target:L}});const V=[],oe=[];for(const p of H)zs(p)?.persistent?(p.cache=!1,V.push(p)):oe.push(p);H=oe;const se=ar(t.partition);if(se&&(H=cr.partitionTasks(H,se),e.info(`Partition ${se.index}/${se.total}: running ${H.length} task(s)`),H.length===0)){e.info("No tasks assigned to this partition.");return}let E=lr([...H,...V],{onCycleBroken:p=>{e.warn(`Ignoring dev-only dependency cycle (build order is ambiguous): ${p.join(" → ")}`)},projectGraph:S,targetDefaults:h.tasks,workspace:l});for(const[p,y]of Object.entries(E.tasks)){const b=y.target.project,L=y.target.target,q=g.get(b)?.[L];if(!q)continue;const Y=l.projects[b];let D=!1;const P={...y.overrides};P.visOptions===void 0&&q.options&&(P.visOptions=q.options,D=!0),P.command===void 0&&q.command&&(P.command=qt(q.command,{affectedFiles:w,projectRoot:Y?.root}),D=!0),D&&(y.overrides=P,E.tasks[p]=y)}if(typeof t.skipCache=="string"&&t.skipCache.trim()!=="")if(t.cache){const p=zi(t.skipCache,l,Object.keys(E.tasks));for(const y of p.skipTaskIds){const b=E.tasks[y];b!==void 0&&(b.cache=!1)}p.unmatchedPatterns.length>0&&e.warn(`--skip-cache: no tasks matched ${p.unmatchedPatterns.map(y=>`"${y}"`).join(", ")}`),p.skipTaskIds.size>0&&e.debug?.(`--skip-cache: bypassing cache for ${String(p.skipTaskIds.size)} task(s)`)}else e.debug?.("--skip-cache ignored: --no-cache already disables caching for the whole run");await Wr(n,h.toolchain,{error:p=>{e.error(p)},info:p=>{e.info(p)},warn:p=>{e.warn(p)}},!!t.skipToolchain);const de=t.preflight!==!1&&h.preflight?.lockfile!==!1,Ie=Nr(n,Ve,{warn:p=>{e.warn(p)}},{skip:!de});if(!Ie.shouldContinue)throw new Error(`${Ie.formattedMessage??"preflight: lockfile drift detected"} (pass --no-preflight to bypass)`);de&&!Ve&&process.stdin.isTTY&&process.stdout.isTTY&&await Gi(n,{logger:{info:p=>{e.info(p)},warn:p=>{e.warn(p)}},projectManifests:[...u.values()]});const Fe=process.env.VIS_VERSION??"0.0.0",Le=t.dryRun?void 0:async p=>{try{return await ri(p.config,{timeoutMs:yo}),!0}catch{return!1}},Oe=await Qr(n),X=await Wn({initialTasks:[...H,...V],probe:Le,registeredEntries:Oe,taskGraph:E,visVersion:Fe}),Re=[];let Se,ke=0;const ge=[],we=new Map;let Te=[];const Ce=new Set;let je=null,$=null;if(X.diagnostics.length>0){const p=!!(process.stdout.isTTY&&process.stdin.isTTY),y=t.dryRun?"off":co({cli:t.services,config:h.run?.services,isCi:!!Ve,isPersistentTarget:V.length>0,isTty:p,target:k});if(y==="off"){for(const P of X.diagnostics)e.error(P.message);throw new Error(`${X.diagnostics.length} service dependency error(s) — start the missing services or invoke them directly.`)}const b=X.diagnostics.map(P=>P.targetId),L=y,q=L==="registry"?Gs(n,b,E):void 0,Y=process.argv[1]??"vis",D=oo({missingServiceIds:b,mode:L,taskGraph:E,visBin:Y,workspaceRoot:n});if(D.skipped.length>0){for(const{id:P,reason:re}of D.skipped)e.error(`Cannot auto-start ${P}: ${re}`);throw new Error(`${D.skipped.length} service(s) cannot be auto-started — invoke them directly or add a service config.`)}Re.push(...D.ephemeralPidFiles),Se=D.runDir,Te=D.chain;for(const P of D.chain)Ce.add(P);if(L==="registry"&&(ke=D.chain.length,ge.push(...D.chain)),D.chain.length>0){const P=new ss(D.chain),re=new Map;if(L==="ephemeral"&&D.runDir)for(const M of D.chain){const G=_s(D.runDir,`${D.runDir}/bootstrap.mjs`,M);re.set(M,{ephemeral:{configFile:G.configFile,cwd:n,logFile:G.logFile,pidFile:G.pidFile,scriptPath:G.scriptPath},mode:"ephemeral"})}else if(L==="registry"&&q)for(const M of q.services)re.set(M.id,{mode:"registry",registry:{command:M.command,config:M.config,cwd:M.cwd,env:M.env}});if(re.size>0){const M=new Xn({indexToId:new Map,services:re,sink:{crashed:(G,N)=>{P.markCrashed(G,N)},failed:(G,N,K)=>{P.markFailed(G,N,K)},log:(G,N)=>{P.appendLog(G,N)},ready:(G,N)=>{P.markReady(G,N)},started:(G,N)=>{P.markStarted(G,N),L==="registry"&&N!==null&&we.set(G,N)},starting:G=>{P.markStarting(G)}},workspaceRoot:n});je=P,$=M}}for(const[P,re]of D.serviceEnvByTaskId){const M=X.serviceEnvByTaskId.get(P)??{};X.serviceEnvByTaskId.set(P,{...M,...re})}}const v=new Set(V.map(p=>p.id));if(H=X.initialTasks.filter(p=>!v.has(p.id)),E=X.taskGraph,Te.length>0&&(H=[...Te.map(p=>E.tasks[p]).filter(p=>p!==void 0),...H]),V.length>0){const p=new Set(V.map(Y=>Y.id)),y={};for(const[Y,D]of Object.entries(E.tasks))p.has(Y)||(y[Y]=D);const b={};for(const[Y,D]of Object.entries(E.dependencies))p.has(Y)||(b[Y]=D.filter(P=>!p.has(P)));const L=new Set;for(const Y of Object.values(b))for(const D of Y)L.add(D);const q=Object.keys(y).filter(Y=>!L.has(Y));E={dependencies:b,roots:q,tasks:y}}const{serviceEnvByTaskId:I}=X;if(X.satisfiedServices.length>0){const p=X.satisfiedServices.map(y=>y.id).join(", ");if(e.debug?.(`Auto-attached to running services: ${p}`),je)for(const y of X.satisfiedServices)je.registerService(y.id);else je=new ss(X.satisfiedServices.map(y=>y.id));for(const y of X.satisfiedServices){const b=y.config.readiness?.tcp?.port??y.config.port??0,L=y.config.readiness?.tcp?.host??"127.0.0.1";je.markReady(y.id,{host:L,port:b})}}if(t.reverse&&(E=dr(E),e.debug?.(`Reversed task graph: ${String(E.roots.length)} new root(s) (originally leaves)`)),t.dryRun){const p=Object.keys(E.tasks).length,y=E.roots.length;e.info(`Execution plan (${String(p)} task(s), ${String(y)} root(s)):`),e.info("");const b=new Set,L=(q,Y)=>{if(b.has(q))return;b.add(q);for(const M of E.dependencies[q]??[])L(M,Y+1);const D=E.tasks[q],P=" ".repeat(Y+1),re=`${D?.cache===!1?" (no-cache)":""}${D?.hashMode==="trace"?" (trace)":""}`;e.info(`${P}${q}${re}`)};for(const q of E.roots)L(q,0);for(const q of Object.keys(E.tasks))L(q,0);V.length>0&&(e.info(""),e.info(` + ${String(V.length)} persistent task(s) (run after graph completes)`)),e.info("");return}const te=Date.now(),he=Zr(),bt=(p,y)=>{const b=y instanceof Error?y.message:String(y);e.warn(`Plugin error in ${p}: ${b}`)};await ei(he,h.plugins);const qe=typeof t.profile=="string"?t.profile:void 0,$t=async p=>{if(!qe)return;const y=Ut(p,E,te),b=qe.startsWith("/")?qe:`${n}/${qe}`;await gr(y,b),e.info(`Profile written to ${qe}`)},Ye=h.taskRunner??{},Us=Er(n,t.cacheDir,Ye.cacheDirectory,h.sharedWorktreeCache),Vs=Mr(Us,n,h.branchScopedCache),Be=Io(process.env.VIS_RUN_CONCURRENCY_LIMIT);Be&&"invalid"in Be&&e.warn(`VIS_RUN_CONCURRENCY_LIMIT=${Be.invalid} is not a positive number; falling back to default concurrency.`);const Ws=Be&&"value"in Be?Be.value:void 0,Ys=t.parallel??Ws??3,St=t.strictEnv??h.strictEnv??!1,Tt=new Set,Pe={dryRun:t.dryRun??!1,parallel:Ys,skipNxCache:!t.cache,summarize:t.summarize??!1,...Ye,cacheDirectory:Vs,dataDirectory:Ye.dataDirectory??Ze(n),namedInputs:h.namedInputs,onDiagnostic:(p,y)=>{Tt.has(p)||(Tt.add(p),e.warn(y))},onFingerprint:async(p,y)=>{await he.callHook("task:fingerprint",p,y)}},Ct=ur(Ye.remoteCache);if(Ct){const p=Eo(t.cacheMode),y=Mo(t.cacheBackend);if(Pe.remoteCache={...Ct,...p?{mode:p}:{},...y?{backend:y}:{}},Pe.remoteCache.attestation){const{expectedIdentity:b,requireOnDownload:L}=Pe.remoteCache.attestation;if(!(b!==void 0&&("github"in b&&typeof b.github?.ref=="string"&&typeof b.github.repo=="string"&&typeof b.github.workflow=="string"||"oidcIssuer"in b&&typeof b.oidcIssuer=="string"&&(typeof b.san=="string"||typeof b.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 b&&(!b.sanRegex.startsWith("^")||!b.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:q,isSigstoreInstalled:Y}=await import("./loader.js");Y()||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:
|
|
185
|
+
${q(n)}`);const{buildCacheAttestationHooks:D}=await import("./cache-attestation.js");Pe.remoteCache.attestation=D({expectedIdentity:b,onReject:(P,re)=>{e.warn(`[vis run] remote cache entry ${P.slice(0,12)} rejected: attestation ${re}. Treating as a cache miss.`)},onVerifyFailure:P=>{e.warn(`[vis run] attestation verification failed: ${P}`)},requireOnDownload:L,workspaceRoot:n})}}else(t.cacheMode||t.cacheBackend)&&e.warn("[vis run] --cache-mode and --cache-backend require a `remoteCache` block in vis.config.ts (or TURBO_API env); ignoring.");const Js=process.stdout.isTTY&&!Ve,Ks=o?.run?.quietOnSuccess===!0,Xs=h.tui?.autoExit??(Ks?3:!1),It={args:{parallel:Pe.parallel,targets:[k]},autoExit:Xs,projectNames:O,tasks:[...H,...V]},Rt=typeof t.retryBudget=="number"?t.retryBudget:void 0,Et=Rt===void 0?void 0:To(Rt),Mt=new ti(he,bt),Ft=new Vr(n),Ot=Fn(t.outputStyle,o?.run?.quietOnSuccess);if(X.satisfiedServices.length>0)for(const p of X.satisfiedServices){const y=X.serviceDependentsByServiceId.get(p.id)??[];try{await he.callHook("service:attach",p,y)}catch(b){bt("service:attach",b)}}await he.callHook("run:before",{tasks:H,workspaceRoot:n});const ze=t.stopServices===!0;let Pt=!1;const At=()=>{if(Pt)return;Pt=!0,$&&$.dispose().catch(()=>{});const p=ze?[...we.values()]:void 0;xo({extraPids:p,pidFiles:Re,runDir:Se})},Je=()=>{At()},Dt=Re.length>0||Se!==void 0||ze&&ge.length>0;Dt&&(process.on("SIGINT",Je),process.on("SIGTERM",Je));try{if(Js){const p=new Map,y=En({...It,onRetryService:$?M=>$.retry(M):void 0,outputStyle:Ot,serviceDockStore:je,stdinRegistry:p}),{lifeCycle:b,store:L}=y,q=new zt([b,Mt,Ft]),Y=ws({affectedFiles:w,currentOs:T,hooks:he,initCwd:d,lifeCycle:q,mutexPool:new Map,onOutput:(M,G)=>{$&&Ce.has(M)?$.onTaskOutput(M,G):L.addOutput(M,G)},onOutputReplace:(M,G)=>{L.setOutput(M,G)},retryBudget:Et,serviceEnvByTaskId:I,serviceEventBridge:$??void 0,stdinRegistry:p,strictEnv:St,workspaceRoot:n});let D="rerun",P=null,re=new Map;for(;D!=="quit";){if(D==="rerun"){if(re=await Ht(H,Pe,{lifeCycle:q,projectGraph:S,taskExecutor:Y,taskGraph:E,workspaceRoot:n}),V.length>0&&!t.failFast){const M=new Promise(G=>{const N=L.subscribe(()=>{const K=L.getSnapshot();(K.rerunRequested||K.retryTaskId)&&(N(),G())});y.renderIsDone.then(()=>{N(),G()}).catch(()=>{N(),G()})});await gs(V,n,w,d,{abortSignal:M,lifeCycle:q,stdinRegistry:p,store:L},I)}}else if(D==="retry"&&P){const M=H.find(N=>N.id===P),G=M?.overrides.command;if(M&&G){const N=nt(n,M.projectRoot,!1);q.startTasks?.([M]);const K=new ft(it),fe=(await Qe([{command:G,cwd:N,name:M.id,ptySize:{cols:process.stdout.columns??80,rows:process.stdout.rows??24},stdin:"pty"}],{onEvent:ne=>{ne.kind==="started"&&ne.write&&p.set(M.id,{kill:ne.kill,resize:ne.resize,write:ne.write}),(ne.kind==="stdout"||ne.kind==="stderr")&&ne.text&&(K.write(ne.text),L.setOutput(M.id,K.toString())),ne.kind==="close"&&p.delete(M.id)}})).closeEvents[0];q.endTasks?.([{code:fe?.exitCode??1,status:fe?.exitCode===0?"success":"failure",task:M,terminalOutput:L.getSnapshot().outputs.get(M.id)}])}else M&&q.endTasks?.([{code:1,status:"failure",task:M,terminalOutput:`No command configured for ${M.id}`}]);P=null,L.markDone()}D=await new Promise(M=>{const G=L.subscribe(()=>{const N=L.getSnapshot();N.rerunRequested&&(L.acknowledgeRerun(),G(),M("rerun")),N.retryTaskId&&(P=L.acknowledgeRetry(),G(),M("retry"))});y.renderIsDone.then(()=>{G(),M("quit")}).catch(()=>{G(),M("quit")})})}await y.renderIsDone,await he.callHook("run:after",re),await $t(re),ke>0&&(e.info(""),ze?e.info(`${String(ke)} service(s) stopped (--stop-services).`):e.info(`${String(ke)} service(s) started in the background. Run \`vis service stop --all\` to clean up.`))}else{const p=new Map,y=typeof t.log=="string"?t.log.toLowerCase():"",b=y==="labeled"||y==="grouped"||y==="interleaved"?y:void 0,L=b?hr(b):void 0,q=new zt([new Pn({...It,ciGrouping:o?.run?.ciGrouping??"auto",logReporter:L,outputStyle:Ot}),Mt,Ft]),Y=ws({affectedFiles:w,currentOs:T,hooks:he,initCwd:d,lifeCycle:q,mutexPool:p,retryBudget:Et,serviceEnvByTaskId:I,serviceEventBridge:$??void 0,strictEnv:St,workspaceRoot:n}),D=async()=>{const N=Date.now(),K=await Ht(H,Pe,{lifeCycle:q,projectGraph:S,taskExecutor:Y,taskGraph:E,workspaceRoot:n}),fe=Date.now()-N;if(t.summarize){const ve=Ut(K,E,te);await mr(ve,n,{dataDirectory:Ze(n)})}let ne=!1;for(const[,ve]of K)ve.status==="failure"&&(ne=!0);const ye=Pr(K,fe),be=Ar(n),Ee=Dr(n,fe,be);return e.info(""),e.info(` ${ye}${Ee?` ${Ee}`:""}`),{hasFailure:ne,results:K,runHistory:be}},P=await D();await he.callHook("run:after",P.results),await $t(P.results);const{hasFailure:re}=P;if(t.watch){const N=O.map(ue=>{const me=l.projects[ue]?.root;if(me)return me.startsWith("/")?me:`${n}/${me}`}).filter(ue=>ue!==void 0),K=H;let fe;const ne=ue=>{const me=_n(K,ue);return fe=me.filter,H=me.tasks,me.tasks.length};let ye=!1,be=P.results;const Ee=()=>{const ue=Kt(be,n);if(ue.directories.length>0&&ue.files.size>0){const me=bi(ue.files,n,ue.directories);return{handle:Xt({filter:me,onChange:Ke,paths:ue.directories}),mode:"tracked"}}return{handle:Xt({onChange:Ke,paths:N}),mode:"roots"}};let ve;const Ke=async ue=>{if(!ye){ye=!0;try{e.info(`Change detected in ${ue.length} file(s), rerunning…`),be=(await D()).results,ve?.close(),ve=Ee().handle}finally{ye=!1}}},Lt=Ee();ve=Lt.handle;const Qs=Lt.mode==="tracked"?`Watching ${String(Kt(be,n).files.size)} tracked file(s)`:`Watching ${String(N.length)} project root(s)`;e.info(`${Qs} — edit a file to rerun, press h for keybinds, q to quit.`);const ct=async()=>{if(!ye){ye=!0;try{if(H.length===0){e.info("No tasks match the active filter — press a to clear it.");return}be=(await D()).results,ve?.close(),ve=Ee().handle}finally{ye=!1}}};await new Promise(ue=>{let me=!1,Bt;const Nt=()=>{Gt()},Gt=()=>{me||(me=!0,Bt?.close(),process.off("SIGINT",Nt),ve?.close(),ue())};process.on("SIGINT",Nt),Bt=Un({handlers:{onClearFilter:async()=>{const He=ne(void 0);e.info(`Filter cleared — running ${String(He)} task(s).`),await ct()},onFilter:async He=>{const Zs=fe,_t=ne(He);if(_t===0){e.info(`Filter "${He}" matched no projects — keeping previous filter.`),ne(Zs);return}e.info(`Filter "${He}" matched ${String(_t)} task(s).`),await ct()},onHelp:()=>{zn(process.stdout)},onQuit:()=>{Gt()},onRerun:ct}})});return}if(t.flaky!==!1){const N=Fr(n,{minRuns:2},P.runHistory);if(N.length>0){e.info(""),e.info("Flaky tasks (based on historical runs):"),e.info("");for(const K of Or(N))e.info(` ${K}`);e.info("")}}const M=[];for(const[N,K]of P.results)K.retryAttempts&&K.retryAttempts>0&&M.push(N);const G=t.failOnRetry===!0&&M.length>0;if(G){const N=M.slice(0,5),K=M.length-N.length,fe=K>0?`${N.join(", ")}, and ${String(K)} more`:N.join(", ");e.warn(""),e.warn(`--fail-on-retry: ${String(M.length)} task(s) succeeded only after retry: ${fe}`)}if(re||G){const N=G&&!re?"Some tasks succeeded only after retry (--fail-on-retry).":"Some tasks failed.",K=2e3,fe=[];for(const[ne,ye]of P.results){if(ye.status!=="failure")continue;const be=ye.terminalOutput??"",Ee=be.length>K?`…${be.slice(-K)}`:be,ve=ye.code??"?";fe.push(` ${ne} (exit ${String(ve)}):
|
|
186
|
+
${Ee.split(`
|
|
187
|
+
`).map(Ke=>` ${Ke}`).join(`
|
|
188
|
+
`)}`)}throw new Error(fe.length>0?`${N}
|
|
189
|
+
${fe.join(`
|
|
190
|
+
`)}`:N)}V.length>0&&!t.failFast&&await gs(V,n,w,d,void 0,I),ke>0&&(e.info(""),ze?e.info(`${String(ke)} service(s) stopped (--stop-services).`):e.info(`${String(ke)} service(s) started in the background. Run \`vis service stop --all\` to clean up.`))}}finally{At(),Dt&&(process.off("SIGINT",Je),process.off("SIGTERM",Je)),ze&&ge.length>0&&await Promise.all(ge.map(async p=>{try{await si(n,p)}catch{}}))}};export{To as createRetryBudget,Jo as default};
|