@visulima/vis 7.1.0-next.6 → 7.1.0-next.7
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 +59 -0
- package/README.md +1 -1
- package/dist/bin.js +1 -1
- package/dist/binx.js +1 -1
- package/dist/config/index.d.ts +227 -12
- package/dist/packem_chunks/CONFIG_FILES.js +1 -1
- package/dist/packem_chunks/bloom-sync.js +1 -1
- package/dist/packem_chunks/catalog.js +1 -1
- package/dist/packem_chunks/cli-exec.js +1 -1
- package/dist/packem_chunks/cli-main.js +57 -57
- package/dist/packem_chunks/detect.js +4 -4
- package/dist/packem_chunks/dispatch.js +1 -1
- package/dist/packem_chunks/fix.js +1 -1
- package/dist/packem_chunks/handler.js +1 -1
- package/dist/packem_chunks/handler10.js +1 -1
- package/dist/packem_chunks/handler11.js +1 -1
- package/dist/packem_chunks/handler12.js +1 -1
- package/dist/packem_chunks/handler13.js +1 -1
- package/dist/packem_chunks/handler14.js +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/handler2.js +1 -1
- package/dist/packem_chunks/handler20.js +1 -1
- package/dist/packem_chunks/handler21.js +1 -1
- package/dist/packem_chunks/handler22.js +1 -1
- package/dist/packem_chunks/handler23.js +1 -1
- package/dist/packem_chunks/handler24.js +1 -1
- package/dist/packem_chunks/handler25.js +1 -1
- package/dist/packem_chunks/handler26.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 +2 -2
- package/dist/packem_chunks/handler30.js +1 -1
- package/dist/packem_chunks/handler4.js +1 -1
- package/dist/packem_chunks/handler5.js +1 -1
- package/dist/packem_chunks/handler50.js +1 -1
- package/dist/packem_chunks/handler51.js +1 -1
- package/dist/packem_chunks/handler52.js +1 -1
- package/dist/packem_chunks/handler53.js +1 -1
- package/dist/packem_chunks/handler54.js +1 -1
- package/dist/packem_chunks/handler55.js +1 -1
- package/dist/packem_chunks/handler58.js +1 -1
- package/dist/packem_chunks/handler59.js +1 -1
- package/dist/packem_chunks/handler6.js +1 -1
- package/dist/packem_chunks/handler60.js +1 -1
- package/dist/packem_chunks/handler61.js +22 -3
- package/dist/packem_chunks/handler62.js +2 -22
- package/dist/packem_chunks/handler63.js +6 -2
- package/dist/packem_chunks/handler64.js +8 -61
- package/dist/packem_chunks/handler65.js +2 -6
- package/dist/packem_chunks/handler66.js +12 -8
- package/dist/packem_chunks/handler67.js +5 -2
- package/dist/packem_chunks/handler68.js +25 -12
- package/dist/packem_chunks/handler69.js +50 -25
- package/dist/packem_chunks/handler7.js +1 -1
- package/dist/packem_chunks/handler70.js +153 -50
- package/dist/packem_chunks/handler71.js +1 -1
- package/dist/packem_chunks/handler72.js +1 -1
- package/dist/packem_chunks/handler73.js +1 -1
- package/dist/packem_chunks/handler74.js +1 -1
- package/dist/packem_chunks/handler75.js +1 -1
- package/dist/packem_chunks/handler76.js +1 -1
- package/dist/packem_chunks/handler77.js +1 -1
- package/dist/packem_chunks/handler78.js +1 -1
- package/dist/packem_chunks/handler79.js +64 -64
- 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/index7.js +1 -1
- package/dist/packem_chunks/keys-refresh.js +1 -1
- package/dist/packem_chunks/lean.js +1 -1
- package/dist/packem_chunks/list.js +1 -1
- package/dist/packem_chunks/loader.js +1 -1
- package/dist/packem_chunks/prune.js +1 -1
- package/dist/packem_chunks/status.js +1 -1
- package/dist/packem_chunks/sync.js +1 -1
- package/dist/packem_chunks/sync2.js +1 -1
- package/dist/packem_chunks/tripwire.js +1 -1
- package/dist/packem_chunks/ts-loader.js +2 -2
- package/dist/packem_chunks/verify-lockfile.js +1 -1
- package/dist/packem_chunks/workflow-templates.js +29 -32
- package/dist/packem_shared/{advisories-BnFPhsl1.js → advisories-CyXUdibZ.js} +1 -1
- package/dist/packem_shared/{affected-selection-Bd03KJU3.js → affected-selection-CJnDzyIK.js} +1 -1
- package/dist/packem_shared/affected-shas-CJLirD2O.js +1 -0
- package/dist/packem_shared/{ai-analysis-GjV2rF4U.js → ai-analysis-DHlzow2O.js} +1 -1
- package/dist/packem_shared/{ai-cache-DFKUyj11.js → ai-cache-D-BSLcuJ.js} +1 -1
- package/dist/packem_shared/{ai-fix-DpBEXHZT.js → ai-fix-CyExJC_c.js} +1 -1
- package/dist/packem_shared/{augment-BSeqaai8.js → augment-Ub6PCwbh.js} +1 -1
- package/dist/packem_shared/{bin-D1zq7wxi.js → bin-BaReRSyo.js} +1 -1
- package/dist/packem_shared/{build-scripts-mKGcgTzp.js → build-scripts-BeJkep8z.js} +1 -1
- package/dist/packem_shared/ci-commands-4W9d2six.js +1 -0
- package/dist/packem_shared/{command-runtime-DG49t2MT.js → command-runtime-DdnpiUmN.js} +1 -1
- package/dist/packem_shared/{dependency-scan-BGKZYS_i.js → dependency-scan-CyByCwef.js} +1 -1
- package/dist/packem_shared/{detect-CaA92iu_.js → detect-xqoTANJb.js} +1 -1
- package/dist/packem_shared/{docker-Cs174Imq.js → docker-CJXAt5Au.js} +1 -1
- package/dist/packem_shared/{ecosystem-gate-DcpvfgEi.js → ecosystem-gate-DEnubRcS.js} +1 -1
- package/dist/packem_shared/{env-sb3SOT-b.js → env-NauRSSEC.js} +1 -1
- package/dist/packem_shared/{env-consistency-nSuzisQe.js → env-consistency-Cl1Rg65z.js} +1 -1
- package/dist/packem_shared/{failure-log-AtaeZOrx.js → failure-log-DwroazKs.js} +1 -1
- package/dist/packem_shared/glob-Cyk1H9ZL-BtN6Zzwg.js +1 -0
- package/dist/packem_shared/{index-CclzWrJ5.js → index-BCEhCrLl.js} +1 -1
- package/dist/packem_shared/{index-C_7lOmB0.js → index-OmE1O0Ys.js} +1 -1
- package/dist/packem_shared/{index-0dnGN3GP.js → index-zq6Ehql6.js} +1 -1
- package/dist/packem_shared/{isAccessibleSync-DYKTrrvc-CBsMZhj-.js → isAccessibleSync-DYKTrrvc-CKahNmLy.js} +1 -1
- package/dist/packem_shared/{lifecycle-BzenugED.js → lifecycle-Cn1mSP5f.js} +1 -1
- package/dist/packem_shared/{lockfile-DEWjBrlY.js → lockfile-Cx2Ny3um.js} +1 -1
- package/dist/packem_shared/{manifests-DPwVdkqB.js → manifests-BEGTH1ZG.js} +1 -1
- package/dist/packem_shared/{min-release-age-BH4JKSXA.js → min-release-age-DLAERxRt.js} +1 -1
- package/dist/packem_shared/{missing-package-json-ByjsDBbk.js → missing-package-json-w74qGfyh.js} +1 -1
- package/dist/packem_shared/{multi-eco-lockfiles-Bz9ViPBV.js → multi-eco-lockfiles-SATPXx6-.js} +1 -1
- package/dist/packem_shared/{native-config-sync-DI7_xs-Q.js → native-config-sync-DDFn6Zsf.js} +1 -1
- package/dist/packem_shared/{npmrc-CIvOb61L.js → npmrc-DONprxrc.js} +1 -1
- package/dist/packem_shared/{osv-DaMZpVWl.js → osv-dvIA_vX3.js} +1 -1
- package/dist/packem_shared/{package-version-VdULnxr1.js → package-version-BOK3IncQ.js} +2 -2
- package/dist/packem_shared/{packument-zeKEhTaX.js → packument-B678kHJO.js} +1 -1
- package/dist/packem_shared/{pm-runner-BXRi4ZM9.js → pm-runner-CYsiSHYa.js} +1 -1
- package/dist/packem_shared/{project-name-filter-BklluD5Y.js → project-name-filter-CBEoY08a.js} +1 -1
- package/dist/packem_shared/{provenance-CwyZDw8A.js → provenance-D4ioWGBq.js} +1 -1
- package/dist/packem_shared/reachable-DX8FPErP.js +1 -0
- package/dist/packem_shared/{registry-TXpTtpgS.js → registry-ClmannRw.js} +2 -2
- package/dist/packem_shared/{registry-keys-B4CNE38T.js → registry-keys-CF45rOur.js} +1 -1
- package/dist/packem_shared/{removeSync-g1D5kONg-jOsRSIIv.js → removeSync-g1D5kONg-DcG75b0G.js} +1 -1
- package/dist/packem_shared/{renderToString-DR0zDUjh-CdBv7J9a.js → renderToString-DR0zDUjh-CBDmAXxb.js} +1 -1
- package/dist/packem_shared/{resolve-explicit-Cg3eqSqr.js → resolve-explicit-C5-y-xEU.js} +1 -1
- package/dist/packem_shared/{resolve-runtime-D8rxuo3J.js → resolve-runtime-DBDozrmt.js} +1 -1
- package/dist/packem_shared/{run-file-D1mlOnd8.js → run-file-BKXvoVj2.js} +1 -1
- package/dist/packem_shared/{run-summary-utils-CZ2pIIOZ.js → run-summary-utils-75paIrLB.js} +1 -1
- package/dist/packem_shared/{runtime-check-By5NHR00.js → runtime-check-Yl8-Awkf.js} +1 -1
- package/dist/packem_shared/{s1ngularity-CXTWGOvX.js → s1ngularity-B2bqwE0C.js} +1 -1
- package/dist/packem_shared/{scaffold-files-CC1M9Gje.js → scaffold-files-UiCBBCT5.js} +1 -1
- package/dist/packem_shared/{scan-progress-BaCJp5nr.js → scan-progress-Dws7Gif1.js} +1 -1
- package/dist/packem_shared/{selectors-DdvjAetv.js → selectors-DZ4HDnlD.js} +1 -1
- package/dist/packem_shared/{signatures-Bm-ySKmD.js → signatures-DNqgsRp7.js} +1 -1
- package/dist/packem_shared/{spinner-D8Eugb6Y.js → spinner-BQ9mLz8X.js} +1 -1
- package/dist/packem_shared/{table-Dc3wOjzc.js → table-D1CpySxU.js} +1 -1
- package/dist/packem_shared/{tabs-Ch5hj2ow.js → tabs-BYtpIN5b.js} +1 -1
- package/dist/packem_shared/{target-options-rIthWS4M.js → target-options-CsevVc7U.js} +1 -1
- package/dist/packem_shared/{task-env-Cl4jNMCR.js → task-env-BftNOR00.js} +1 -1
- package/dist/packem_shared/{toolchain-DQIOCPht.js → toolchain-BvluBdrw.js} +1 -1
- package/dist/packem_shared/{typosquats-Dw02Q55Q.js → typosquats-XrArH9TO.js} +1 -1
- package/dist/packem_shared/{use-measured-height-wtekNTLa.js → use-measured-height-hHis1NaB.js} +1 -1
- package/dist/packem_shared/{verify-3WE9U_Bv.js → verify-Dic2G0nQ.js} +1 -1
- package/dist/packem_shared/{vis-update-app-it6zkxW1.js → vis-update-app-BNnbDZ--.js} +1 -1
- package/dist/packem_shared/{vis-user-error-6sSghaC9.js → vis-user-error-DhgW3DzD.js} +2 -2
- package/dist/packem_shared/{watch-C-9-PD2m.js → watch-BLHtUgfb.js} +1 -1
- package/dist/packem_shared/{watch-loop-q7f9ukDX.js → watch-loop-Dh4GHUVS.js} +7 -7
- package/dist/runtime/preload.js +1 -1
- package/index.js +54 -54
- package/package.json +11 -10
- package/schemas/vis-config.schema.json +1419 -80
- package/dist/packem_shared/affected-shas-CycHU3nr.js +0 -1
- package/dist/packem_shared/glob-Cyk1H9ZL-QtJl508G.js +0 -1
|
@@ -1,69 +1,69 @@
|
|
|
1
|
-
import{createRequire as
|
|
2
|
-
${this.#
|
|
3
|
-
`),d.setOutput(
|
|
4
|
-
`)}break}case"started":{m.set(
|
|
5
|
-
`)}break}default:}}})}finally{j&&(clearTimeout(j),j=void 0),d.markDone()}},ot=t=>{try{return process.kill(-t,0),!0}catch{try{return process.kill(t,0),!0}catch{return!1}}},xn=t=>{Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,t)},jn=t=>{const{extraPids:e=[],pidFiles:s,runDir:r}=t,n=[],o=i=>{try{process.kill(-i,"SIGTERM")}catch{try{process.kill(i,"SIGTERM")}catch{}}};for(const i of s){let l;try{const d=Qs(i),h=Number.parseInt(d.trim(),10);l=Number.isFinite(h)&&h>0?h:void 0}catch{continue}l!==void 0&&(n.push(l),o(l))}for(const i of e)!Number.isFinite(i)||i<=0||(n.push(i),o(i));if(n.length>0){const d=Date.now()+1500;for(;Date.now()<d;){let h=!0;for(const u of n)if(ot(u)){h=!1;break}if(h)break;xn(100)}for(const h of n)if(ot(h))try{process.kill(-h,"SIGKILL")}catch{try{process.kill(h,"SIGKILL")}catch{}}}r&&lr(r)},Sn=({ephemeralPidFiles:t,registryStartedIds:e,registryStartedPids:s,serviceEventBridge:r,serviceRunDir:n,stopServicesOnExit:o,workspaceRoot:i})=>{let l=!1;const d=()=>{if(l)return;l=!0,r&&r.dispose().catch(()=>{});const p=o?[...s.values()]:void 0;jn({extraPids:p,pidFiles:t,runDir:n})},h=()=>{d()},u=t.length>0||n!==void 0||o&&e.length>0;return{finish:async()=>{d(),u&&(process.off("SIGINT",h),process.off("SIGTERM",h)),o&&e.length>0&&await Promise.all(e.map(async p=>{try{await Gs(i,p)}catch{}}))},install:()=>{u&&(process.on("SIGINT",h),process.on("SIGTERM",h))}}},kn=({config:t,logger:e,persistentTasks:s,taskGraph:r})=>{const n=Object.keys(r.tasks).length,o=r.roots.length;e.info(`Execution plan (${String(n)} task(s), ${String(o)} root(s)):`),e.info("");const i=new Set,l=(d,h)=>{if(i.has(d))return;i.add(d);for(const j of r.dependencies[d]??[])l(j,h+1);const u=r.tasks[d],p=" ".repeat(h+1),a=u?.segment?` (segment ${String(u.segment.index)}/${String(u.segment.count)}: ${String(u.overrides.command)})`:"",m=u?.hashMode==="trace"||t.taskRunner?.autoFingerprint===!0,w=`${u?.cache===!1?" (no-cache)":""}${m?" (trace)":""}${a}`;e.info(`${p}${d}${w}`)};for(const d of r.roots)l(d,0);for(const d of Object.keys(r.tasks))l(d,0);s.length>0&&(e.info(""),e.info(` + ${String(s.length)} persistent task(s) (run after graph completes)`)),e.info("")},bn=(t,e)=>{if(t===e)return!0;if(!t||!e||t.length!==e.length)return!1;for(const[s,r]of t.entries())if(!Object.is(r,e[s]))return!1;return!0},ct=({children:t,deps:e,onRender:s,style:r,width:n})=>{const o=U.useRef(null),i=U.useRef(!1),l=U.useRef(e),d=U.useRef(t),h=U.useRef(s);h.current=s;let u=!1;e!==void 0?bn(l.current,e)||(u=!0,l.current=e):t!==d.current&&(u=!0,d.current=t),u&&(i.current=!1,o.current&&(o.current.cachedRender=void 0)),U.useLayoutEffect(()=>{const a=o.current;a&&(a.internal_onRendered=()=>{i.current=!0,h.current?.(a)})}),U.useEffect(()=>()=>{const a=o.current;a&&(a.cachedRender=void 0,a.internal_onRendered=void 0)},[]);const p=U.useMemo(()=>({...r,width:n}),[r,n]);return c.jsx("ink-static-render",{ref:o,style:p,children:i.current?null:t()})},Tn=t=>Array.isArray(t)?`[${t.join(",")}]`:typeof t=="object"&&t!==null?JSON.stringify(t):String(t),$n=(t,e,s)=>e==="_"?`${t}${Array.isArray(s)?s.join(" "):String(s)}`:`${t}--${e}=${Tn(s)}`,Ke=(t,e,s)=>{const r=new Set(new Set(s.map(a=>a.target.target))),n=new Set(new Set(s.map(a=>a.target.project))),o=e.filter(a=>r.has(a)),i=t.filter(a=>n.has(a)),l=s.length-i.length*o.length,d=o.length===1?"target":"targets",h=o.join(", "),u=i.length===1?`project ${i[0]}`:`${i.length} projects`;let p=`${d} ${h} for ${u}`;return l>0&&(p+=` and ${l} ${l===1?"task":"tasks"} ${l===1?"it depends":"they depend"} on`),p},Cn={error:"red",info:"white",success:"green"},Ne=({children:t,title:e,variant:s})=>{const r=Cn[s];return c.jsxs(x,{flexDirection:"column",children:[c.jsxs(x,{gap:1,children:[c.jsx(f,{bold:!0,inverse:!0,children:" VIS "}),c.jsx(f,{bold:!0,color:r,children:"•"}),c.jsx(f,{children:e})]}),t]})},Ht=({cached:t,failed:e,failedIds:s,projectNames:r,retriedIds:n,skippedIds:o,succeeded:i,targets:l,tasks:d,took:h})=>{const u=Ke(r,l,d),p=n??[];if(e===0&&(!o||o.length===0)){const a=t>0?` (${t} read from cache)`:"";return c.jsx(ct,{children:()=>c.jsx(Ne,{title:`Successfully ran ${u}`,variant:"success",children:c.jsxs(x,{flexDirection:"column",marginTop:1,paddingLeft:3,children:[c.jsxs(f,{children:[c.jsx(f,{color:"green",children:Mt})," ",i+t," tasks completed",a?c.jsx(f,{dimColor:!0,children:a}):null,c.jsx(f,{dimColor:!0,children:` · Took ${h}`})]}),p.length>0&&c.jsxs(x,{flexDirection:"column",marginTop:1,children:[c.jsxs(f,{children:[c.jsx(f,{color:"yellow",children:"↻"})," ",c.jsx(f,{color:"yellow",children:String(p.length)})," task",p.length===1?"":"s"," succeeded after retry:"]}),p.map(m=>c.jsxs(f,{children:[" ",c.jsx(f,{color:"yellow",children:"↻"})," ",m]},m))]})]})})})}return c.jsx(ct,{children:()=>c.jsx(Ne,{title:`Ran ${u}`,variant:"error",children:c.jsxs(x,{flexDirection:"column",marginTop:1,paddingLeft:3,children:[o&&o.length>0&&c.jsxs(x,{flexDirection:"column",children:[c.jsxs(f,{dimColor:!0,children:[o.length," ","task",o.length===1?"":"s"," ","skipped (dependency failed or --bail)"]}),o.map(a=>c.jsxs(f,{dimColor:!0,children:[" - ",a]},a)),c.jsx(f,{})]}),e>0&&c.jsxs(x,{flexDirection:"column",children:[c.jsxs(f,{children:[c.jsx(f,{color:"red",children:String(e)})," ","task",e===1?"":"s"," ","failed:"]}),s.map(a=>c.jsxs(f,{children:[" ",c.jsx(f,{color:"red",children:Ft})," ",a]},a)),c.jsx(f,{})]}),p.length>0&&c.jsxs(x,{flexDirection:"column",children:[c.jsxs(f,{children:[c.jsx(f,{color:"yellow",children:String(p.length)})," ","task",p.length===1?"":"s"," ","finished after retry:"]}),p.map(a=>c.jsxs(f,{children:[" ",c.jsx(f,{color:"yellow",children:"↻"})," ",a]},a)),c.jsx(f,{})]}),c.jsx(f,{dimColor:!0,children:` Took ${h}`})]})})})};class Pe{#e;#r=new Set;#s=new Map;constructor(e,s){this.#e={autoExitCountdown:null,cached:0,completed:0,done:!1,endTime:null,failed:0,filterActive:!1,filterText:"",focusedPanel:"tasks",interactiveMode:!1,outputs:new Map,pinnedTaskIds:[null,null],rerunRequested:!1,retriedIds:[],retryTaskId:null,rows:e.map(r=>({persistent:!!r.overrides.visOptions?.persistent,status:"pending",taskId:r.id})),running:0,selectedIndex:0,startTime:Date.now(),statusFilter:"all",succeeded:0,totalTasks:s??e.length,viewMode:"list"}}getSnapshot=()=>this.#e;subscribe=e=>(this.#r.add(e),()=>{this.#r.delete(e)});startTasks(e){const s=[...this.#e.rows];for(const r of e){const n=s.findIndex(o=>o.taskId===r.id);n!==-1&&(s[n]={...s[n],elapsed:0,status:"running"},this.#s.set(r.id,process.hrtime()))}this.#t({...this.#e,rows:s,running:this.#e.running+e.length})}endTasks(e){const s=[...this.#e.rows];let{cached:r,completed:n,failed:o,succeeded:i}=this.#e;const l=new Map(this.#e.outputs),d=[...this.#e.retriedIds];for(const p of e){const a=s.findIndex(m=>m.taskId===p.task.id);switch(a!==-1&&(s[a]={...s[a],duration:p.startTime&&p.endTime?p.endTime-p.startTime:void 0,retryAttempts:p.retryAttempts,status:p.status}),p.retryAttempts&&p.retryAttempts>0&&d.push(p.task.id),n++,p.status){case"failure":{o++;break}case"local-cache":case"local-cache-kept-existing":case"remote-cache":{r++;break}case"success":{i++;break}}p.terminalOutput&&!l.has(p.task.id)&&l.set(p.task.id,p.terminalOutput),this.#s.delete(p.task.id)}let{selectedIndex:h}=this.#e;if(o>this.#e.failed){const p=s.findIndex(a=>a.status==="failure");p!==-1&&(h=p)}const u=Math.max(0,this.#e.running-e.length);this.#t({...this.#e,cached:r,completed:n,failed:o,outputs:l,retriedIds:d,rows:s,running:u,selectedIndex:h,succeeded:i})}static#n=256*1024;addOutput(e,s){if(!s.trim())return;let r=(this.#e.outputs.get(e)??"")+s;r.length>Pe.#n&&(r=r.slice(-Pe.#n)),this.#e.outputs.set(e,r),this.#t({...this.#e})}setOutput(e,s){this.#e.outputs.set(e,s),this.#t({...this.#e})}markDone(){this.#t({...this.#e,done:!0,endTime:Date.now()})}unmarkDone(){this.#t({...this.#e,autoExitCountdown:null,done:!1,endTime:null})}tick(){if(this.#s.size===0)return;let e=!1;const s=[...this.#e.rows];for(let r=0;r<s.length;r++){const n=s[r];if(n.status==="running"){const o=this.#s.get(n.taskId);if(o){const i=process.hrtime(o),l=i[0]*1e3+i[1]/1e6;s[r]={...n,elapsed:l},e=!0}}}e&&this.#t({...this.#e,rows:s})}setSelectedIndex(e){e!==this.#e.selectedIndex&&this.#t({...this.#e,selectedIndex:e})}setFocusedPanel(e){e!==this.#e.focusedPanel&&this.#t({...this.#e,focusedPanel:e})}setFilter(e){this.#t({...this.#e,filterText:e,selectedIndex:0})}setFilterActive(e){e!==this.#e.filterActive&&this.#t({...this.#e,filterActive:e,filterText:e?this.#e.filterText:"",selectedIndex:0})}pinTask(e,s){const r=[...this.#e.pinnedTaskIds];r[e]=s,this.#t({...this.#e,pinnedTaskIds:r})}clearPins(){this.#t({...this.#e,pinnedTaskIds:[null,null]})}requestRetry(e){const s=[...this.#e.rows],r=s.findIndex(l=>l.taskId===e);let{completed:n,failed:o,succeeded:i}=this.#e;if(r!==-1){const l=s[r].status;l==="failure"?(o=Math.max(0,o-1),n=Math.max(0,n-1)):l==="success"&&(i=Math.max(0,i-1),n=Math.max(0,n-1)),s[r]={...s[r],elapsed:0,retryAttempts:void 0,status:"running"},this.#s.set(e,process.hrtime())}this.#t({...this.#e,completed:n,done:!1,endTime:null,failed:o,interactiveMode:!1,retriedIds:this.#e.retriedIds.filter(l=>l!==e),retryTaskId:e,rows:s,succeeded:i})}acknowledgeRetry(){const e=this.#e.retryTaskId;return e&&this.#t({...this.#e,retryTaskId:null}),e}setInteractiveMode(e){e!==this.#e.interactiveMode&&this.#t({...this.#e,interactiveMode:e})}setViewMode(e){e!==this.#e.viewMode&&this.#t({...this.#e,viewMode:e})}setStatusFilter(e){this.#t({...this.#e,selectedIndex:0,statusFilter:e})}requestRerun(){this.#s.clear(),this.#t({...this.#e,autoExitCountdown:null,cached:0,completed:0,done:!1,endTime:null,failed:0,interactiveMode:!1,outputs:new Map,rerunRequested:!0,retriedIds:[],rows:this.#e.rows.map(e=>({persistent:e.persistent,status:"pending",taskId:e.taskId})),running:0,startTime:Date.now(),succeeded:0,viewMode:"list"})}acknowledgeRerun(){this.#e.rerunRequested&&this.#t({...this.#e,rerunRequested:!1})}#t(e){this.#e=e;for(const s of this.#r)try{s()}catch{}}}const In=t=>en(t),En=/^(?<name>(?:[A-Z][\w$]*)?(?:Error|Exception))(?::[ \t](?<message>.*))?$/,Rn=/^\s*at\s+/,Pn=t=>{const e=t.split(`
|
|
6
|
-
`);let s;for(let
|
|
1
|
+
import{createRequire as cs}from"node:module";import{readLastRunSummary as ds,getLastRunSummaryPath as us,runConcurrently as Ce,TerminalBuffer as He,CompositeLifeCycle as $t,defaultTaskRunner as Ct,resolveTurboEnvCompat as fs,pickChildParentEnv as hs,generateRunSummary as It,writeChromeTrace as ps,expandAffected as ms,getChangedFiles as gs,enforceProjectConstraints as ws,buildEnhancedPath as ys,createLogReporter as vs,writeRunSummary as xs,reverseTaskGraph as js,splitCompoundTasks as ks,createTaskGraph as Ss,expandTokensInString as Et,parsePartition as qe,TaskScheduler as bs}from"@visulima/task-runner";import{M as Rt,P as Ts,L as $s,C as et,Q as Cs,R as Is,q as Es,j as Rs,an as Ps,ao as Ms,ap as Os,aq as Fs,r as As}from"./cli-main.js";import{r as U,j as c,X as j,O as f,R as X,o as Ds,d as Ls,b as Bs}from"../packem_shared/registry-ClmannRw.js";import{r as _s}from"../packem_shared/command-runtime-DdnpiUmN.js";import{s as Ns,p as Ws,i as Gs}from"../packem_shared/affected-selection-CJnDzyIK.js";import{d as Ie,U as Pt,a1 as Hs}from"../packem_shared/env-NauRSSEC.js";import{f as qs,d as Us,e as Vs,H as zs,i as Ys,r as Ks,s as Xs,a as Js,b as Qs,c as Zs}from"../packem_shared/lifecycle-Cn1mSP5f.js";import{z as en,e as ie,m as Mt,$ as tn,a as sn}from"../packem_shared/index-zq6Ehql6.js";import{a as Ot,d as Ft,r as Ue,s as nn,m as rn,l as on}from"../packem_shared/target-options-CsevVc7U.js";import{g as Se,r as Te,b as cn,e as an,A as ln,T as dn,d as un}from"../packem_shared/task-env-BftNOR00.js";import{f as fn}from"../packem_shared/removeSync-g1D5kONg-DcG75b0G.js";import{O as le}from"../packem_shared/renderToString-DR0zDUjh-CBDmAXxb.js";import{T as At,C as Dt,D as Fe,E as Lt}from"../packem_shared/symbols-BXDZ_sKt.js";import{q as kn,j as Sn,X as De,F as nt}from"../packem_shared/index.server-Ca_EEVfw.js";import{parseStacktrace as bn,codeFrame as Tn}from"@visulima/error";import{originalPositionFor as $n,sourceContentFor as Cn,loadSourceMap as In}from"@visulima/source-map";import{l as Bt}from"../packem_shared/spinner-BQ9mLz8X.js";import{i as be}from"../packem_shared/index-BjdW45xX.js";import{d as Rn,r as Pn}from"../packem_shared/lockfile-Cx2Ny3um.js";import{y as _t}from"../packem_shared/index-BisalDCf.js";import{r as Fn}from"../packem_shared/toolchain-BvluBdrw.js";import{F as An}from"../packem_shared/failure-log-DwroazKs.js";import{V as fe}from"../packem_shared/vis-user-error-DhgW3DzD.js";import{c as Nt,s as Dn,p as Ln,a as Bn,b as _n,r as Nn,f as Wn}from"../packem_shared/project-name-filter-CBEoY08a.js";import{r as Gn,f as Hn,a as qn,p as Un}from"../packem_shared/selectors-DZ4HDnlD.js";import _e from"./index.js";import{c as rt,a as Xn,s as it}from"../packem_shared/watch-BLHtUgfb.js";import{r as ot}from"../packem_shared/reachable-DX8FPErP.js";let as;const ls=t=>(as??=cs(import.meta.url))(t),je=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,me=t=>{if(typeof je<"u"&&je.versions&&je.versions.node){const[e,s]=je.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return je.getBuiltinModule(t)}return ls(t)},{existsSync:ge,readFileSync:ve,mkdirSync:hn,writeFileSync:Ve,openSync:pn,statSync:tt,readSync:mn,closeSync:gn,mkdtempSync:wn}=me("node:fs"),{isAbsolute:yn,resolve:st,dirname:vn,relative:xn}=me("node:path"),{fileURLToPath:jn}=me("node:url"),{createHash:En}=me("node:crypto"),{createInterface:Mn,emitKeypressEvents:On}=me("node:readline"),{mkdir:Vn,appendFile:Ae}=me("node:fs/promises"),{platform:zn,homedir:ze,tmpdir:Yn}=me("node:os"),{spawn:Kn}=me("node:child_process"),Jn=27,Qn={95:"apc",80:"dcs",94:"pm",88:"sos"},Zn={159:"apc",144:"dcs",158:"pm",152:"sos"},Wt=t=>t===155||t===157||t===144||t===152||t===158||t===159,Gt=(t,e)=>{for(let s=e;s<t.length;s+=1){const n=t.codePointAt(s);if(n>=64&&n<=126)return s}return-1},Ee=(t,e,s)=>{for(let n=e;n<t.length;n+=1){const r=t.codePointAt(n);if(r===156||s&&r===7)return n;if(r===27&&t.codePointAt(n+1)===92)return n+1}return-1},er=(t,e)=>{const s=t.codePointAt(e+1);if(s===91){const n=Gt(t,e+2);return n===-1?void 0:{end:n,kind:"csi"}}if(s===93){const n=Ee(t,e+2,!0);return n===-1?void 0:{end:n,kind:"osc"}}if(s===80||s===88||s===94||s===95){const n=Ee(t,e+2,!1),r=Qn[s];return n===-1?void 0:{end:n,kind:r}}return s===void 0?void 0:{end:e+1,kind:"escape"}},tr=(t,e)=>{const s=t.codePointAt(e);if(s===155){const n=Gt(t,e+1);return n===-1?void 0:{end:n,kind:"csi"}}if(s===157){const n=Ee(t,e+1,!0);return n===-1?void 0:{end:n,kind:"osc"}}if(s===144||s===152||s===158||s===159){const n=Ee(t,e+1,!1),r=Zn[s];return n===-1?void 0:{end:n,kind:r}}},sr=t=>{if(t.includes(String.fromCodePoint(27)))return!0;for(let e=0;e<t.length;e+=1)if(Wt(t.codePointAt(e)))return!0;return!1},nr=t=>{if(!sr(t))return t;let e="",s=0,n=0;const{length:r}=t;for(;n<r;){const o=t.codePointAt(n);let i;if(o===Jn)i=er(t,n);else if(Wt(o))i=tr(t,n);else{n+=1;continue}const l=i===void 0?r-1:i.end;e+=t.slice(s,n),s=l+1,n=l+1}return e+=t.slice(s),e},rr=(t,e,s,n,r,o,i,l,d,h,u,p,a,m)=>{const y={d:n,h:r,m:o,mo:e,ms:l,s:i,w:s,y:t};return y.future=d,y.past=h,y.decimal=u,p!==void 0&&(y.unitMap=p),y.groupSeparator=a,y.placeholderSeparator=m,y},ir={d:"d",day:"d",days:"d",h:"h",hour:"h",hours:"h",hr:"h",hrs:"h",m:"m",millisecond:"ms",milliseconds:"ms",min:"m",mins:"m",minute:"m",minutes:"m",mo:"mo",month:"mo",months:"mo",ms:"ms",s:"s",sec:"s",second:"s",seconds:"s",secs:"s",w:"w",week:"w",weeks:"w",y:"y",year:"y",years:"y",yr:"y",yrs:"y"},or=rr(t=>`year${t===1?"":"s"}`,t=>`month${t===1?"":"s"}`,t=>`week${t===1?"":"s"}`,t=>`day${t===1?"":"s"}`,t=>`hour${t===1?"":"s"}`,t=>`minute${t===1?"":"s"}`,t=>`second${t===1?"":"s"}`,t=>`millisecond${t===1?"":"s"}`,"in %s","%s ago",".",ir,",","_"),ct=new WeakSet,cr=t=>{if(ct.has(t))return;const e=["y","mo","w","d","h","m","s","ms"];for(const n of e)if(!Object.hasOwn(t,n))throw new TypeError(`Missing required property: ${n}`);if(t.future!==void 0&&typeof t.future!="string")throw new TypeError("Properties future and past must be of type string");if(t.past!==void 0&&typeof t.past!="string")throw new TypeError("Properties future and past must be of type string");const s=["y","mo","w","d","h","m","s","ms"];for(const n of s)if(typeof t[n]!="string"&&typeof t[n]!="function")throw new TypeError(`Property ${n} must be of type string or function`);if(t.decimal&&typeof t.decimal!="string")throw new TypeError("Property decimal must be of type string");if(t.delimiter&&typeof t.delimiter!="string")throw new TypeError("Property delimiter must be of type string");if(t._digitReplacements&&!Array.isArray(t._digitReplacements))throw new TypeError("Property _digitReplacements must be an array");if(t._numberFirst&&typeof t._numberFirst!="boolean")throw new TypeError("Property _numberFirst must be of type boolean");if(t.unitMap&&typeof t.unitMap!="object")throw new TypeError("Property unitMap must be an object");if(t.unitMap&&Object.values(t.unitMap).some(n=>typeof n!="string"))throw new TypeError("All values in unitMap must be of type string");ct.add(t)},Ht=(t,e)=>{if(!Number.isFinite(t)||e<0||Number.isInteger(t))return t;const s=10**e,n=Number((t*s).toPrecision(15));return Math.trunc(n)/s},at=({unitCount:t,unitName:e},s,n)=>{let{spacer:r}=n;const{maxDecimalPoints:o}=n;let i=".";n.decimal!==void 0?i=n.decimal:s.decimal!==void 0&&(i=s.decimal);let l;"digitReplacements"in n?l=n.digitReplacements:"_digitReplacements"in s&&(l=s._digitReplacements);let d,h=t;o!==void 0&&(h=Ht(t,o));const u=h.toString();if(!s._hideCountIf2||t!==2)if(l){d="";for(const m of u)d+=m==="."?i:l[m]}else d=u.replace(".",i);else d="";const p=s[e];let a=p;return typeof p=="function"&&(a=p(t)),s._hideCountIf2&&t===2&&(r=""),s._numberFirst?a+r+d:d+r+a},ar=(t,e)=>{const{units:s}=e;if(s.length===0)return[];const{unitMeasures:n}=e,r=e.largest??Number.POSITIVE_INFINITY,o={};let i,l,d,h=t;for(l=0;l<s.length;l++){i=s[l];const p=n[i];d=l===s.length-1?h/p:Math.floor(h/p),o[i]=d,h-=d*p}if(e.round){let p=r;for(l=0;l<s.length;l++)if(i=s[l],d=o[i],d!==0&&(p--,p===0)){for(let a=l+1;a<s.length;a++){const m=s[a],y=o[m];o[i]=(o[i]??0)+y*n[m]/n[i],o[m]=0}break}for(l=s.length-1;l>=0;l--){if(i=s[l],d=o[i],d===0)continue;const a=Math.round(d);if(o[i]=a,l===0)break;const m=s[l-1],y=n[m],g=Math.floor(a*n[i]/y);if(g)o[m]=(o[m]??0)+g,o[i]=0;else break}}const u=[];for(l=0;l<s.length&&u.length<r;l++){if(i=s[l],d=o[i],d&&!e.round&&u.length===r-1){let p,a=0;for(p=l+1,s.length;p<s.length;p++){const m=s[p];a+=o[m]*(e.unitMeasures[m]/e.unitMeasures[i])}d+=a,e.maxDecimalPoints!==void 0&&(d=Ht(d,e.maxDecimalPoints))}d&&u.push({unitCount:d,unitName:i})}return u},lr=(t,e,s)=>{const{language:n,units:r}=e;if(t.length===0){const p=r.at(-1);return at({unitCount:0,unitName:p},n,e)}const{conjunction:o,serialComma:i}=e;let l=", ";e.delimiter!==void 0?l=e.delimiter:n.delimiter!==void 0&&(l=n.delimiter);let d="";e.timeAdverb&&s!==0&&(d=n.future??"",s<0&&(d=n.past??""));const h=t.map(p=>at(p,n,e));let u;return!o||t.length===1?u=h.join(l):t.length===2?u=h.join(o):u=h.slice(0,-1).join(l)+(i?",":"")+o+(h.at(-1)??""),d&&(u=d.replace("%s",u)),u},dr=(t,e)=>{if(Number.isNaN(t))throw new TypeError("Expected a valid number");if(typeof t!="number")throw new TypeError("Expected a number for milliseconds input");const s={conjunction:"",language:or,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};cr(s.language);const n=Math.abs(t),r=ar(n,s);return lr(r,s,t)},Re=256*1024;class ur{#e;#n="";#s=!1;constructor(e){this.#e=e}append(e){this.#n+=e,this.#n.length>this.#e&&(this.#n=this.#n.slice(-this.#e),this.#s=!0)}toString(){return this.#s?`[...output truncated, showing last ${Math.round(this.#e/1024)}KB...]
|
|
2
|
+
${this.#n}`:this.#n}}const fr=t=>{if(!t||t.trim().length===0)return;const e=Number.parseFloat(t);return!Number.isFinite(e)||e<=0?{invalid:t}:{value:Math.floor(e)}},hr=async(t,e)=>{const s=await ds(t,{dataDirectory:Ie(t)});if(!s){e.warn(`No previous run recorded yet. Run a task at least once to populate ${us(t,{dataDirectory:Ie(t)})}.`);return}const n=(s.duration/1e3).toFixed(2);if(e.info(""),e.info(`Last run — ${s.startTime} (${n}s)`),e.info(""),e.info(` Total: ${String(s.stats.total)}`),e.info(` Succeeded: ${String(s.stats.succeeded)}`),e.info(` Cached: ${String(s.stats.cached)}`),e.info(` Failed: ${String(s.stats.failed)}`),e.info(` Skipped: ${String(s.stats.skipped)}`),e.info(""),s.stats.failed>0){const o=s.tasks.filter(i=>i.exitCode!==void 0&&i.exitCode!==0);e.info("Failed tasks:");for(const i of o){const l=i.duration??0;e.info(` × ${i.taskId} (exit ${String(i.exitCode??-1)}, ${l}ms)`)}e.info("")}const r=[...s.tasks].filter(o=>typeof o.duration=="number").sort((o,i)=>(i.duration??0)-(o.duration??0)).slice(0,5);if(r.length>0){e.info("Slowest tasks:");for(const o of r)e.info(` ${o.taskId.padEnd(40)} ${String(o.duration??0).padStart(6)}ms [${o.cacheStatus}]`);e.info("")}},pr=t=>{if(!(t===void 0||t==="")){if(t!=="read"&&t!=="write"&&t!=="readwrite")throw new Error(`--cache-mode must be one of: read, write, readwrite (received "${t}")`);return t}},mr=t=>{if(!(t===void 0||t==="")){if(t!=="http"&&t!=="reapi")throw new Error(`--cache-backend must be one of: http, reapi (received "${t}")`);return t}},gr=t=>{if(!(t===void 0||t==="")){if(t!=="declared"&&t!=="trace")throw new Error(`--hash-mode must be one of: declared, trace (received "${t}")`);return t}},wr=({interactive:t,taskPty:e,workspacePty:s})=>e===!0?!0:e===!1?!1:t&&s!==!1,yr=t=>`'${t.replaceAll("'",String.raw`'\''`)}'`,Ye=t=>process.platform==="win32"?t.length>0&&!/[\s"&|<>^()%!]/.test(t)?t:`"${t.replaceAll('"','""')}"`:yr(t),vr=(t,e,s)=>{if(!e||e.length===0||s===!1||s===void 0)return t;if(s==="args"||s==="both"){const n=e.map(r=>Ye(r)).join(" ");return`${t} ${n}`}return t},qt="visForwardedArgs",xr=(t,e)=>{const s=e.overrides[qt];if(!Array.isArray(s)||s.length===0)return t;const n=s.map(r=>Ye(r)).join(" ");return`${t} ${n}`},Ke=(t,e,s)=>{const n=t.overrides.command;if(!n)return;const r=Se(t),o=t.segment!==void 0&&t.segment.index<t.segment.count,i=o?n:xr(n,t),l=o?i:vr(i,e,r?.affectedFiles),d=Ot(r,s),h=r?.shellArgs,u=h&&h.length>0?h.join(" "):"-c";return d?`${d} ${u} ${Ye(l)}`:l},jr=2e3,Ut=async(t,e,s)=>{const{workspaceRoot:n}=e,r=t.map(w=>{const k=Ke(w,e.affectedFiles,Ft());if(!k)return;const O=w.overrides.visOptions,I=Ue(n,w.projectRoot,!!O?.runFromWorkspaceRoot),x=wr({interactive:!!s,taskPty:w.pty,workspacePty:O?.pty}),D=Te(e,w);return{command:k,cwd:I,env:D.env,inheritEnv:D.inheritEnv,name:w.id,...x?{ptySize:{cols:process.stdout.columns??80,rows:process.stdout.rows??24},stdin:"pty"}:{}}}).filter(w=>w!==void 0);if(r.length===0)return;if(!s){await Ce(r,{killOthers:["failure"],onEvent:()=>{}});return}const{abortSignal:o,lifeCycle:i,stdinRegistry:l,store:d}=s,h=r.map(w=>t.find(k=>k.id===w.name)).filter(Boolean),u=w=>r[w]?.stdin==="pty",p=new Map,a=w=>{if(!u(w))return;let k=p.get(w);return k||(k=new He(Re),p.set(w,k)),k};d.unmarkDone(),i.startTasks?.(h);const m=new Map,y=new Map;let g;const S=()=>{for(const w of y.values())try{w("SIGTERM")}catch{}g||(g=setTimeout(()=>{for(const w of y.values())try{w("SIGKILL")}catch{}y.clear()},2e3),g.unref?.())};let v;o&&(v=()=>{S()},o.then(()=>{v?.()}).catch(()=>{v?.()}));try{await Ce(r,{killOthers:["failure"],onEvent:w=>{const k=h[w.index];if(k)switch(w.kind){case"close":{const O=m.get(k.id)??Date.now(),I=w.killed||w.exitCode===0?"success":"failure";i.endTasks?.([{code:w.exitCode??0,endTime:Date.now(),startTime:O,status:I,task:k,terminalOutput:d.getSnapshot().outputs.get(k.id)??""}]),y.delete(w.index),l?.delete(k.id);break}case"error":{if(w.message){const O=a(w.index);O?(O.write(`${w.message}
|
|
3
|
+
`),d.setOutput(k.id,O.toString())):d.addOutput(k.id,`${w.message}
|
|
4
|
+
`)}break}case"started":{m.set(k.id,Date.now()),w.kill&&y.set(w.index,w.kill),w.write&&l&&l.set(k.id,{kill:w.kill,resize:w.resize,write:w.write});break}case"stderr":case"stdout":{if(w.text){const O=a(w.index);O?(O.write(w.text),d.setOutput(k.id,O.toString())):d.addOutput(k.id,`${w.text}
|
|
5
|
+
`)}break}default:}}})}finally{g&&(clearTimeout(g),g=void 0),d.markDone()}},lt=t=>{try{return process.kill(-t,0),!0}catch{try{return process.kill(t,0),!0}catch{return!1}}},kr=t=>{Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,t)},Sr=t=>{const{extraPids:e=[],pidFiles:s,runDir:n}=t,r=[],o=i=>{try{process.kill(-i,"SIGTERM")}catch{try{process.kill(i,"SIGTERM")}catch{}}};for(const i of s){let l;try{const d=en(i),h=Number.parseInt(d.trim(),10);l=Number.isFinite(h)&&h>0?h:void 0}catch{continue}l!==void 0&&(r.push(l),o(l))}for(const i of e)!Number.isFinite(i)||i<=0||(r.push(i),o(i));if(r.length>0){const d=Date.now()+1500;for(;Date.now()<d;){let h=!0;for(const u of r)if(lt(u)){h=!1;break}if(h)break;kr(100)}for(const h of r)if(lt(h))try{process.kill(-h,"SIGKILL")}catch{try{process.kill(h,"SIGKILL")}catch{}}}n&&fn(n)},br=({ephemeralPidFiles:t,registryStartedIds:e,registryStartedPids:s,serviceEventBridge:n,serviceRunDir:r,stopServicesOnExit:o,workspaceRoot:i})=>{let l=!1;const d=()=>{if(l)return;l=!0,n&&n.dispose().catch(()=>{});const p=o?[...s.values()]:void 0;Sr({extraPids:p,pidFiles:t,runDir:r})},h=()=>{d()},u=t.length>0||r!==void 0||o&&e.length>0;return{finish:async()=>{d(),u&&(process.off("SIGINT",h),process.off("SIGTERM",h)),o&&e.length>0&&await Promise.all(e.map(async p=>{try{await qs(i,p)}catch{}}))},install:()=>{u&&(process.on("SIGINT",h),process.on("SIGTERM",h))}}},Tr=({config:t,logger:e,persistentTasks:s,taskGraph:n})=>{const r=Object.keys(n.tasks).length,o=n.roots.length;e.info(`Execution plan (${String(r)} task(s), ${String(o)} root(s)):`),e.info("");const i=new Set,l=(d,h)=>{if(i.has(d))return;i.add(d);for(const g of n.dependencies[d]??[])l(g,h+1);const u=n.tasks[d],p=" ".repeat(h+1),a=u?.segment?` (segment ${String(u.segment.index)}/${String(u.segment.count)}: ${String(u.overrides.command)})`:"",m=u?.hashMode==="trace"||t.taskRunner?.autoFingerprint===!0,y=`${u?.cache===!1?" (no-cache)":""}${m?" (trace)":""}${a}`;e.info(`${p}${d}${y}`)};for(const d of n.roots)l(d,0);for(const d of Object.keys(n.tasks))l(d,0);s.length>0&&(e.info(""),e.info(` + ${String(s.length)} persistent task(s) (run after graph completes)`)),e.info("")},$r=(t,e)=>{if(t===e)return!0;if(!t||!e||t.length!==e.length)return!1;for(const[s,n]of t.entries())if(!Object.is(n,e[s]))return!1;return!0},dt=({children:t,deps:e,onRender:s,style:n,width:r})=>{const o=U.useRef(null),i=U.useRef(!1),l=U.useRef(e),d=U.useRef(t),h=U.useRef(s);h.current=s;let u=!1;e!==void 0?$r(l.current,e)||(u=!0,l.current=e):t!==d.current&&(u=!0,d.current=t),u&&(i.current=!1,o.current&&(o.current.cachedRender=void 0)),U.useLayoutEffect(()=>{const a=o.current;a&&(a.internal_onRendered=()=>{i.current=!0,h.current?.(a)})}),U.useEffect(()=>()=>{const a=o.current;a&&(a.cachedRender=void 0,a.internal_onRendered=void 0)},[]);const p=U.useMemo(()=>({...n,width:r}),[n,r]);return c.jsx("ink-static-render",{ref:o,style:p,children:i.current?null:t()})},Cr=t=>Array.isArray(t)?`[${t.join(",")}]`:typeof t=="object"&&t!==null?JSON.stringify(t):String(t),Ir=(t,e,s)=>e==="_"?`${t}${Array.isArray(s)?s.join(" "):String(s)}`:`${t}--${e}=${Cr(s)}`,Xe=(t,e,s)=>{const n=new Set(new Set(s.map(a=>a.target.target))),r=new Set(new Set(s.map(a=>a.target.project))),o=e.filter(a=>n.has(a)),i=t.filter(a=>r.has(a)),l=s.length-i.length*o.length,d=o.length===1?"target":"targets",h=o.join(", "),u=i.length===1?`project ${i[0]}`:`${i.length} projects`;let p=`${d} ${h} for ${u}`;return l>0&&(p+=` and ${l} ${l===1?"task":"tasks"} ${l===1?"it depends":"they depend"} on`),p},Er={error:"red",info:"white",success:"green"},Ne=({children:t,title:e,variant:s})=>{const n=Er[s];return c.jsxs(j,{flexDirection:"column",children:[c.jsxs(j,{gap:1,children:[c.jsx(f,{bold:!0,inverse:!0,children:" VIS "}),c.jsx(f,{bold:!0,color:n,children:"•"}),c.jsx(f,{children:e})]}),t]})},Vt=({cached:t,failed:e,failedIds:s,projectNames:n,retriedIds:r,skippedIds:o,succeeded:i,targets:l,tasks:d,took:h})=>{const u=Xe(n,l,d),p=r??[];if(e===0&&(!o||o.length===0)){const a=t>0?` (${t} read from cache)`:"";return c.jsx(dt,{children:()=>c.jsx(Ne,{title:`Successfully ran ${u}`,variant:"success",children:c.jsxs(j,{flexDirection:"column",marginTop:1,paddingLeft:3,children:[c.jsxs(f,{children:[c.jsx(f,{color:"green",children:At})," ",i+t," tasks completed",a?c.jsx(f,{dimColor:!0,children:a}):null,c.jsx(f,{dimColor:!0,children:` · Took ${h}`})]}),p.length>0&&c.jsxs(j,{flexDirection:"column",marginTop:1,children:[c.jsxs(f,{children:[c.jsx(f,{color:"yellow",children:"↻"})," ",c.jsx(f,{color:"yellow",children:String(p.length)})," task",p.length===1?"":"s"," succeeded after retry:"]}),p.map(m=>c.jsxs(f,{children:[" ",c.jsx(f,{color:"yellow",children:"↻"})," ",m]},m))]})]})})})}return c.jsx(dt,{children:()=>c.jsx(Ne,{title:`Ran ${u}`,variant:"error",children:c.jsxs(j,{flexDirection:"column",marginTop:1,paddingLeft:3,children:[o&&o.length>0&&c.jsxs(j,{flexDirection:"column",children:[c.jsxs(f,{dimColor:!0,children:[o.length," ","task",o.length===1?"":"s"," ","skipped (dependency failed or --bail)"]}),o.map(a=>c.jsxs(f,{dimColor:!0,children:[" - ",a]},a)),c.jsx(f,{})]}),e>0&&c.jsxs(j,{flexDirection:"column",children:[c.jsxs(f,{children:[c.jsx(f,{color:"red",children:String(e)})," ","task",e===1?"":"s"," ","failed:"]}),s.map(a=>c.jsxs(f,{children:[" ",c.jsx(f,{color:"red",children:Dt})," ",a]},a)),c.jsx(f,{})]}),p.length>0&&c.jsxs(j,{flexDirection:"column",children:[c.jsxs(f,{children:[c.jsx(f,{color:"yellow",children:String(p.length)})," ","task",p.length===1?"":"s"," ","finished after retry:"]}),p.map(a=>c.jsxs(f,{children:[" ",c.jsx(f,{color:"yellow",children:"↻"})," ",a]},a)),c.jsx(f,{})]}),c.jsx(f,{dimColor:!0,children:` Took ${h}`})]})})})};class Pe{#e;#n=new Set;#s=new Map;constructor(e,s){this.#e={autoExitCountdown:null,cached:0,completed:0,done:!1,endTime:null,failed:0,filterActive:!1,filterText:"",focusedPanel:"tasks",interactiveMode:!1,outputs:new Map,pinnedTaskIds:[null,null],rerunRequested:!1,retriedIds:[],retryTaskId:null,rows:e.map(n=>({persistent:!!n.overrides.visOptions?.persistent,status:"pending",taskId:n.id})),running:0,selectedIndex:0,startTime:Date.now(),statusFilter:"all",succeeded:0,totalTasks:s??e.length,viewMode:"list"}}getSnapshot=()=>this.#e;subscribe=e=>(this.#n.add(e),()=>{this.#n.delete(e)});startTasks(e){const s=[...this.#e.rows];for(const n of e){const r=s.findIndex(o=>o.taskId===n.id);r!==-1&&(s[r]={...s[r],elapsed:0,status:"running"},this.#s.set(n.id,process.hrtime()))}this.#t({...this.#e,rows:s,running:this.#e.running+e.length})}endTasks(e){const s=[...this.#e.rows];let{cached:n,completed:r,failed:o,succeeded:i}=this.#e;const l=new Map(this.#e.outputs),d=[...this.#e.retriedIds];for(const p of e){const a=s.findIndex(m=>m.taskId===p.task.id);switch(a!==-1&&(s[a]={...s[a],duration:p.startTime&&p.endTime?p.endTime-p.startTime:void 0,retryAttempts:p.retryAttempts,status:p.status}),p.retryAttempts&&p.retryAttempts>0&&d.push(p.task.id),r++,p.status){case"failure":{o++;break}case"local-cache":case"local-cache-kept-existing":case"remote-cache":{n++;break}case"success":{i++;break}}p.terminalOutput&&!l.has(p.task.id)&&l.set(p.task.id,p.terminalOutput),this.#s.delete(p.task.id)}let{selectedIndex:h}=this.#e;if(o>this.#e.failed){const p=s.findIndex(a=>a.status==="failure");p!==-1&&(h=p)}const u=Math.max(0,this.#e.running-e.length);this.#t({...this.#e,cached:n,completed:r,failed:o,outputs:l,retriedIds:d,rows:s,running:u,selectedIndex:h,succeeded:i})}static#r=256*1024;addOutput(e,s){if(!s.trim())return;let n=(this.#e.outputs.get(e)??"")+s;n.length>Pe.#r&&(n=n.slice(-Pe.#r)),this.#e.outputs.set(e,n),this.#t({...this.#e})}setOutput(e,s){this.#e.outputs.set(e,s),this.#t({...this.#e})}markDone(){this.#t({...this.#e,done:!0,endTime:Date.now()})}unmarkDone(){this.#t({...this.#e,autoExitCountdown:null,done:!1,endTime:null})}tick(){if(this.#s.size===0)return;let e=!1;const s=[...this.#e.rows];for(let n=0;n<s.length;n++){const r=s[n];if(r.status==="running"){const o=this.#s.get(r.taskId);if(o){const i=process.hrtime(o),l=i[0]*1e3+i[1]/1e6;s[n]={...r,elapsed:l},e=!0}}}e&&this.#t({...this.#e,rows:s})}setSelectedIndex(e){e!==this.#e.selectedIndex&&this.#t({...this.#e,selectedIndex:e})}setFocusedPanel(e){e!==this.#e.focusedPanel&&this.#t({...this.#e,focusedPanel:e})}setFilter(e){this.#t({...this.#e,filterText:e,selectedIndex:0})}setFilterActive(e){e!==this.#e.filterActive&&this.#t({...this.#e,filterActive:e,filterText:e?this.#e.filterText:"",selectedIndex:0})}pinTask(e,s){const n=[...this.#e.pinnedTaskIds];n[e]=s,this.#t({...this.#e,pinnedTaskIds:n})}clearPins(){this.#t({...this.#e,pinnedTaskIds:[null,null]})}requestRetry(e){const s=[...this.#e.rows],n=s.findIndex(l=>l.taskId===e);let{completed:r,failed:o,succeeded:i}=this.#e;if(n!==-1){const l=s[n].status;l==="failure"?(o=Math.max(0,o-1),r=Math.max(0,r-1)):l==="success"&&(i=Math.max(0,i-1),r=Math.max(0,r-1)),s[n]={...s[n],elapsed:0,retryAttempts:void 0,status:"running"},this.#s.set(e,process.hrtime())}this.#t({...this.#e,completed:r,done:!1,endTime:null,failed:o,interactiveMode:!1,retriedIds:this.#e.retriedIds.filter(l=>l!==e),retryTaskId:e,rows:s,succeeded:i})}acknowledgeRetry(){const e=this.#e.retryTaskId;return e&&this.#t({...this.#e,retryTaskId:null}),e}setInteractiveMode(e){e!==this.#e.interactiveMode&&this.#t({...this.#e,interactiveMode:e})}setViewMode(e){e!==this.#e.viewMode&&this.#t({...this.#e,viewMode:e})}setStatusFilter(e){this.#t({...this.#e,selectedIndex:0,statusFilter:e})}requestRerun(){this.#s.clear(),this.#t({...this.#e,autoExitCountdown:null,cached:0,completed:0,done:!1,endTime:null,failed:0,interactiveMode:!1,outputs:new Map,rerunRequested:!0,retriedIds:[],rows:this.#e.rows.map(e=>({persistent:e.persistent,status:"pending",taskId:e.taskId})),running:0,startTime:Date.now(),succeeded:0,viewMode:"list"})}acknowledgeRerun(){this.#e.rerunRequested&&this.#t({...this.#e,rerunRequested:!1})}#t(e){this.#e=e;for(const s of this.#n)try{s()}catch{}}}const Rr=t=>nr(t),Pr=/^(?<name>(?:[A-Z][\w$]*)?(?:Error|Exception))(?::[ \t](?<message>.*))?$/,Mr=/^\s*at\s+/,Or=t=>{const e=t.split(`
|
|
6
|
+
`);let s;for(let n=0;n<e.length;n++){const r=Pr.exec(e[n].trim());if(!r)continue;const o=[];for(let i=n+1;i<e.length&&i<=n+200;i++){const l=e[i];if(Mr.test(l))o.push(l.trim());else{if(o.length>0)break;if(l.trim()!=="")break}}if(o.length>0){const i=r.groups?.name??"Error",l=r.groups?.message??"";s={message:l,name:i,stack:`${i}: ${l}
|
|
7
7
|
${o.map(d=>` ${d}`).join(`
|
|
8
|
-
`)}`}}}return s},
|
|
8
|
+
`)}`}}}return s},zt=t=>{if(t.startsWith("file://"))try{return jn(t)}catch{return t}return t},Fr=t=>!t.includes("node_modules")&&!t.startsWith("node:")&&!t.startsWith("internal/"),Ar=t=>{try{return In(t)}catch{return}},Dr=(t,e)=>{if(!t.file||t.line===void 0)return;const s=zt(t.file),n=yn(s)?s:st(e,s);if(!Fr(n)||!ge(n))return;const r=Ar(n);if(r){const o=$n(r,{column:t.column===void 0?0:Math.max(0,t.column-1),line:t.line});if(o.source&&o.line!=null){const i=st(vn(n),o.source),d=Cn(r,o.source)??(ge(i)?ve(i,"utf8"):void 0);if(d!==void 0)return{column:o.column==null?void 0:o.column+1,file:i,line:o.line,source:d}}}return{column:t.column,file:n,line:t.line,source:ve(n,"utf8")}},ut=(t,e)=>{const s=xn(e,t);return s&&!s.startsWith("..")?s:t},Yt=(t,e)=>{if(!t?.trim())return t;try{const s=Or(Rr(t));if(!s)return t;const n=new Error(s.message);n.name=s.name,n.stack=s.stack;const r=bn(n);if(r.length===0)return t;const o=e.color,i={dim:a=>o?nt(a):a,head:a=>o?Sn(De(a)):a,loc:a=>o?kn(a):a};let l,d;for(const a of r){const m=Dr(a,e.cwd);if(m){l=m,d=a;break}}const h=[i.head(`✖ ${s.name}${s.message?`: ${s.message}`:""}`)];if(l){const a=`${ut(l.file,e.cwd)}:${l.line}${l.column?`:${l.column}`:""}`;h.push(` ${i.loc(a)}`,""),h.push(Tn(l.source,{start:{column:l.column,line:l.line}},{color:o?{gutter:nt,marker:De,message:De}:void 0,linesAbove:2,linesBelow:3}))}const u=r.filter(a=>a!==d).slice(0,8).map(a=>{const m=a.methodName??"<anonymous>",y=a.file?`${ut(zt(a.file),e.cwd)}${a.line?`:${a.line}`:""}`:"";return i.dim(` at ${m}${y?` (${y})`:""}`)});u.length>0&&h.push("",...u);const p=i.dim("─".repeat(40));return`${h.join(`
|
|
9
9
|
`)}
|
|
10
10
|
${p}
|
|
11
|
-
${t}`}catch{return t}},
|
|
12
|
-
`,
|
|
13
|
-
`)}catch{}},
|
|
14
|
-
`,i=
|
|
15
|
-
`))
|
|
16
|
-
`)})})}),
|
|
17
|
-
`):J?a.outputs.get(J)??"":"",K=U.useMemo(()=>z?.status==="failure"&&te?Ut(te,{color:!process.env.NO_COLOR,cwd:process.cwd()}):te,[z?.status,te]),N=g??J,H=g?Z?.status==="crashed"||Z?.status==="failed"?"failure":"running":z?.status,V=Ke(r,l,d),re=a.done?`Completed ${V} (${we((a.endTime??Date.now())-a.startTime)})`:`Running ${V}...`,oe=a.done?a.failed>0?"error":"success":"running",fe=U.useCallback(R=>{P.current?.scrollTo(Math.max(0,R-2))},[]);if(U.useEffect(()=>{a.interactiveMode&&z?.status!=="running"&&i.setInteractiveMode(!1)},[a.interactiveMode,z?.status,i]),U.useEffect(()=>{if(!J)return;let R=u;a.viewMode==="split"&&u>=gt?R=u-Math.floor(u*.4)-2:(a.viewMode==="split"||a.viewMode==="fullscreen")&&(R=u-2);const b=Math.max(1,p-4);o.get(J)?.resize?.(R,b)},[u,p,a.viewMode,J]),Qe((R,b)=>{if(b.escape){i.setInteractiveMode(!1);return}if(!J)return;const A=o.get(J);if(!A){i.setInteractiveMode(!1);return}if(b.return)A.write("\r");else if(b.upArrow)A.write("\x1B[A");else if(b.downArrow)A.write("\x1B[B");else if(b.rightArrow)A.write("\x1B[C");else if(b.leftArrow)A.write("\x1B[D");else if(b.backspace)A.write("");else if(b.delete)A.write("\x1B[3~");else if(b.tab)A.write(" ");else if(b.home)A.write("\x1B[H");else if(b.end)A.write("\x1B[F");else if(b.pageUp)A.write("\x1B[5~");else if(b.pageDown)A.write("\x1B[6~");else if(b.ctrl&&R){const Q=R.toUpperCase().codePointAt(0);Q!==void 0&&Q>=65&&Q<=90&&A.write(String.fromCodePoint(Q-64))}else R&&A.write(R)},{isActive:a.interactiveMode}),Qe((R,b)=>{if(R==="c"&&b.ctrl){h();return}if(!M){if(C){b.escape||R==="?"?v(!1):R==="q"?(v(!1),T(!0)):b.downArrow||R==="j"?L.current?.scrollBy(1):b.upArrow||R==="k"?L.current?.scrollBy(-1):b.pageDown?L.current?.scrollBy(5):b.pageUp?L.current?.scrollBy(-5):b.home?L.current?.scrollToTop():b.end&&L.current?.scrollToBottom();return}if(R==="?"){v(!0);return}if(R==="q"){T(!0);return}if(R==="r"&&a.done){i.requestRerun();return}if(R==="R"&&a.done){const A=W[a.selectedIndex];A?.status==="failure"&&i.requestRetry(A.taskId);return}if(R==="F"&&!a.filterActive){const A=["all","failed","running","passed"],Q=A.indexOf(a.statusFilter);i.setStatusFilter(A[(Q+1)%A.length]);return}if(a.filterActive){if(b.escape){i.setFilterActive(!1);return}if(b.return){i.setFilterActive(!1);return}if(b.backspace){i.setFilter(a.filterText.slice(0,-1));return}if(R&&!b.ctrl&&!b.meta){i.setFilter(a.filterText+R);return}return}if(R==="i"&&z?.status==="running"&&(a.viewMode==="fullscreen"||a.viewMode==="split"&&a.focusedPanel==="output")){i.setInteractiveMode(!0);return}if(a.viewMode==="fullscreen"){if(b.escape){i.setViewMode("split"),D("split");return}if(R==="f"){const A=!I;k(A),A&&$.current?.scrollToBottom();return}if(b.downArrow||R==="j"){k(!1),$.current?.scrollBy(1);return}if(b.upArrow||R==="k"){k(!1),$.current?.scrollBy(-1);return}if(b.pageDown||b.ctrl&&R==="d"){k(!1),$.current?.scrollBy(12);return}if(b.pageUp||b.ctrl&&R==="u"){k(!1),$.current?.scrollBy(-12);return}if(b.home){k(!1),$.current?.scrollToTop();return}if(b.end){k(!0),$.current?.scrollToBottom();return}return}if(a.focusedPanel==="dock"&&j&&n){if(b.tab){S(null),i.setFocusedPanel("tasks");return}if(b.escape){i.setFocusedPanel("tasks"),S(null),a.viewMode==="split"&&(i.setViewMode("list"),D("list"));return}if(b.downArrow||R==="j"){y(A=>Math.min(A+1,w.length-1));return}if(b.upArrow||R==="k"){y(A=>Math.max(A-1,0));return}if(b.return){const A=w[E];A&&(S(A),k(!0),B(),O.current.splitList=0,O.current.splitOutput=0,i.setViewMode("split"),i.setFocusedPanel("output"),D("split"));return}if((R==="r"||R==="R")&&e){const A=w[E],Q=A?n.getState(A)?.status:void 0;if(A&&(Q==="crashed"||Q==="failed")){const ae=e(A);ae instanceof Promise&&ae.catch(()=>{})}return}return}if(a.viewMode==="split"){if(b.tab){a.focusedPanel==="tasks"?i.setFocusedPanel("output"):j?i.setFocusedPanel("dock"):(S(null),i.setFocusedPanel("tasks"));return}if(a.focusedPanel==="output"){if(b.escape){if(g&&j){S(null),i.setViewMode("list"),i.setFocusedPanel("dock"),D("list");return}S(null),i.setFocusedPanel("tasks");return}if(b.return){B(),i.setViewMode("fullscreen");return}if(R==="f"){const A=!I;k(A),A&&$.current?.scrollToBottom();return}if(b.downArrow||R==="j"){k(!1),$.current?.scrollBy(1);return}if(b.upArrow||R==="k"){k(!1),$.current?.scrollBy(-1);return}if(b.pageDown||b.ctrl&&R==="d"){k(!1),$.current?.scrollBy(12);return}if(b.pageUp||b.ctrl&&R==="u"){k(!1),$.current?.scrollBy(-12);return}if(b.home){k(!1),$.current?.scrollToTop();return}if(b.end){k(!0),$.current?.scrollToBottom();return}return}if(b.escape){i.setViewMode("list"),D("list");return}if(b.return){i.setFocusedPanel("output");return}}if(a.viewMode==="list"||a.viewMode==="split"&&a.focusedPanel==="tasks"){if(b.tab&&a.viewMode==="list"&&j){i.setFocusedPanel("dock");return}if(b.downArrow||R==="j"){const A=Math.min(a.selectedIndex+1,Math.max(0,W.length-1));i.setSelectedIndex(A),fe(A);return}if(b.upArrow||R==="k"){const A=Math.max(a.selectedIndex-1,0);i.setSelectedIndex(A),fe(A);return}if(b.return&&a.viewMode==="list"){k(!0),B(),O.current.splitList=0,O.current.splitOutput=0,i.setViewMode("split"),i.setFocusedPanel("output"),D("split");return}if(R==="/"){i.setFilterActive(!0);return}if(R==="1"&&G){i.pinTask(0,G);return}if(R==="2"&&G){i.pinTask(1,G);return}if(R==="0"){i.clearPins();return}b.escape&&a.filterText&&i.setFilter("")}}},{isActive:!a.interactiveMode}),u<pt||p<mt)return c.jsx(x,{alignItems:"center",height:p,justifyContent:"center",width:u,children:c.jsxs(f,{color:"yellow",children:["Terminal too small (",u,"x",p,"). Minimum:"," ",pt,"x",mt]})});const de=c.jsxs(x,{gap:1,children:[a.succeeded>0&&c.jsxs(f,{bold:!0,color:"green",children:["✓"," ",a.succeeded]}),a.cached>0&&c.jsxs(f,{dimColor:!0,children:["✓"," ",a.cached]}),a.failed>0&&c.jsxs(f,{bold:!0,color:"red",children:["✗"," ",a.failed]}),a.running>0&&c.jsxs(f,{color:"cyan",children:["◷"," ",a.running]}),c.jsxs(f,{dimColor:!0,children:[a.totalTasks," ","total"]}),a.statusFilter!=="all"&&c.jsxs(f,{color:"yellow",children:["[",a.statusFilter,"]"]})]});let ce;if(a.viewMode==="fullscreen")ce=[c.jsxs(x,{gap:1,children:[c.jsx(f,{bold:!0,color:"white",children:"Esc"}),c.jsx(f,{dimColor:!0,children:"BACK"})]},"esc"),c.jsxs(x,{gap:1,children:[c.jsx(f,{bold:!0,color:"white",children:"↑↓"}),c.jsx(f,{dimColor:!0,children:"SCROLL"})]},"scroll"),c.jsxs(x,{gap:1,children:[c.jsx(f,{bold:!0,color:"white",children:"^u ^d"}),c.jsx(f,{dimColor:!0,children:"PAGE"})]},"page"),...z?.status==="running"?[c.jsxs(x,{gap:1,children:[c.jsx(f,{bold:!0,color:"white",children:"i"}),c.jsx(f,{dimColor:!0,children:"INPUT"})]},"i")]:[],c.jsxs(x,{gap:1,children:[c.jsx(f,{bold:!0,color:"white",children:"q"}),c.jsx(f,{dimColor:!0,children:"QUIT"})]},"q")];else if(a.done){const R=W[a.selectedIndex]?.status==="failure";ce=[c.jsxs(x,{gap:1,children:[c.jsx(f,{bold:!0,color:"white",children:"q"}),c.jsx(f,{dimColor:!0,children:"QUIT"})]},"q"),c.jsxs(x,{gap:1,children:[c.jsx(f,{bold:!0,color:"white",children:"r"}),c.jsx(f,{dimColor:!0,children:"RERUN"})]},"r"),...R?[c.jsxs(x,{gap:1,children:[c.jsx(f,{bold:!0,color:"white",children:"R"}),c.jsx(f,{dimColor:!0,children:"RETRY"})]},"R")]:[],c.jsxs(x,{gap:1,children:[c.jsx(f,{bold:!0,color:"white",children:"?"}),c.jsx(f,{dimColor:!0,children:"HELP"})]},"?"),c.jsxs(x,{gap:1,children:[c.jsx(f,{bold:!0,color:"white",children:"↑↓"}),c.jsx(f,{dimColor:!0,children:"NAV"})]},"nav"),c.jsxs(x,{gap:1,children:[c.jsx(f,{bold:!0,color:"white",children:"F"}),c.jsx(f,{dimColor:!0,children:"FILTER"})]},"F"),c.jsxs(x,{gap:1,children:[c.jsx(f,{bold:!0,color:"white",children:"⏎"}),c.jsx(f,{dimColor:!0,children:a.viewMode==="list"?"OUTPUT":"FULLSCREEN"})]},"enter")]}else a.viewMode==="split"&&a.focusedPanel==="output"?ce=[c.jsxs(x,{gap:1,children:[c.jsx(f,{bold:!0,color:"white",children:"q"}),c.jsx(f,{dimColor:!0,children:"QUIT"})]},"q"),c.jsxs(x,{gap:1,children:[c.jsx(f,{bold:!0,color:"white",children:"Esc"}),c.jsx(f,{dimColor:!0,children:"BACK"})]},"esc"),c.jsxs(x,{gap:1,children:[c.jsx(f,{bold:!0,color:"white",children:"↑↓"}),c.jsx(f,{dimColor:!0,children:"SCROLL"})]},"scroll"),...z?.status==="running"?[c.jsxs(x,{gap:1,children:[c.jsx(f,{bold:!0,color:"white",children:"i"}),c.jsx(f,{dimColor:!0,children:"INPUT"})]},"i")]:[],c.jsxs(x,{gap:1,children:[c.jsx(f,{bold:!0,color:"white",children:"⏎"}),c.jsx(f,{dimColor:!0,children:"FULLSCREEN"})]},"enter"),c.jsxs(x,{gap:1,children:[c.jsx(f,{bold:!0,color:"white",children:"Tab"}),c.jsx(f,{dimColor:!0,children:"PANEL"})]},"tab"),c.jsxs(x,{gap:1,children:[c.jsx(f,{bold:!0,color:"white",children:"?"}),c.jsx(f,{dimColor:!0,children:"HELP"})]},"?")]:ce=[c.jsxs(x,{gap:1,children:[c.jsx(f,{bold:!0,color:"white",children:"q"}),c.jsx(f,{dimColor:!0,children:"QUIT"})]},"q"),c.jsxs(x,{gap:1,children:[c.jsx(f,{bold:!0,color:"white",children:"?"}),c.jsx(f,{dimColor:!0,children:"HELP"})]},"?"),c.jsxs(x,{gap:1,children:[c.jsx(f,{bold:!0,color:"white",children:"↑↓"}),c.jsx(f,{dimColor:!0,children:"NAV"})]},"nav"),c.jsxs(x,{gap:1,children:[c.jsx(f,{bold:!0,color:"white",children:"/"}),c.jsx(f,{dimColor:!0,children:"FILTER"})]},"/"),c.jsxs(x,{gap:1,children:[c.jsx(f,{bold:!0,color:"white",children:"F"}),c.jsx(f,{dimColor:!0,children:"STATUS"})]},"F"),c.jsxs(x,{gap:1,children:[c.jsx(f,{bold:!0,color:"white",children:"⏎"}),c.jsx(f,{dimColor:!0,children:a.viewMode==="list"?"OUTPUT":"FULLSCREEN"})]},"enter"),...a.viewMode==="split"?[c.jsxs(x,{gap:1,children:[c.jsx(f,{bold:!0,color:"white",children:"Tab"}),c.jsx(f,{dimColor:!0,children:"PANEL"})]},"tab")]:[]];const ee=c.jsxs(x,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",flexShrink:0,justifyContent:"space-between",children:[c.jsx(x,{flexGrow:1,flexWrap:"wrap",gap:2,paddingX:1,children:ce}),c.jsx(x,{flexShrink:0,paddingX:1,children:de})]}),ne=c.jsxs(Ts,{backgroundColor:"#1e1e1e",footer:c.jsxs(f,{dimColor:!0,children:[c.jsx(f,{bold:!0,color:"white",children:"↑↓"})," ","scroll"," ",c.jsx(f,{bold:!0,color:"white",children:"?"}),"/",c.jsx(f,{bold:!0,color:"white",children:"Esc"})," ","close"]}),scrollRef:L,title:"KEYBOARD SHORTCUTS",visible:C,width:52,children:[c.jsxs(x,{flexDirection:"column",marginBottom:1,children:[c.jsxs(x,{marginBottom:1,children:[c.jsx(f,{dimColor:!0,children:"── "}),c.jsx(f,{bold:!0,color:"white",children:"NAVIGATION"})]}),c.jsxs(x,{children:[c.jsx(x,{width:24,children:c.jsxs(f,{children:[c.jsxs(f,{bold:!0,color:"white",children:[" ","↑","/k"]}),c.jsx(f,{dimColor:!0,children:" Move up"})]})}),c.jsxs(f,{children:[c.jsxs(f,{bold:!0,color:"white",children:[" ","↓","/j"]}),c.jsx(f,{dimColor:!0,children:" Move down"})]})]}),c.jsxs(f,{children:[c.jsxs(f,{bold:!0,color:"white",children:[" ","Tab"]}),c.jsx(f,{dimColor:!0,children:" Switch panel (split)"})]}),c.jsxs(f,{children:[c.jsxs(f,{bold:!0,color:"white",children:[" ","Esc"]}),c.jsx(f,{dimColor:!0,children:" Back / close"})]}),c.jsxs(f,{children:[c.jsxs(f,{bold:!0,color:"white",children:[" ","Enter"]}),c.jsx(f,{dimColor:!0,children:" Show output / fullscreen"})]})]}),c.jsxs(x,{flexDirection:"column",marginBottom:1,children:[c.jsxs(x,{marginBottom:1,children:[c.jsx(f,{dimColor:!0,children:"── "}),c.jsx(f,{bold:!0,color:"white",children:"VIEWS"})]}),c.jsxs(f,{children:[c.jsxs(f,{bold:!0,color:"white",children:[" ","Enter"]}),c.jsxs(f,{dimColor:!0,children:[" ","List"," ","→"," ","Split"," ","→"," ","Fullscreen"]})]}),c.jsxs(f,{children:[c.jsxs(f,{bold:!0,color:"white",children:[" ","Esc"]}),c.jsxs(f,{dimColor:!0,children:[" ","Fullscreen"," ","→"," ","Split"," ","→"," ","List"]})]})]}),c.jsxs(x,{flexDirection:"column",marginBottom:1,children:[c.jsxs(x,{marginBottom:1,children:[c.jsx(f,{dimColor:!0,children:"── "}),c.jsx(f,{bold:!0,color:"white",children:"ACTIONS"})]}),c.jsxs(x,{children:[c.jsx(x,{width:24,children:c.jsxs(f,{children:[c.jsxs(f,{bold:!0,color:"white",children:[" ","/"]}),c.jsx(f,{dimColor:!0,children:" Filter by text"})]})}),c.jsxs(f,{children:[c.jsxs(f,{bold:!0,color:"white",children:[" ","F"]}),c.jsx(f,{dimColor:!0,children:" Filter by status"})]})]}),c.jsxs(x,{children:[c.jsx(x,{width:24,children:c.jsxs(f,{children:[c.jsxs(f,{bold:!0,color:"white",children:[" ","1"]}),c.jsx(f,{dimColor:!0,children:"/"}),c.jsx(f,{bold:!0,color:"white",children:"2"}),c.jsx(f,{dimColor:!0,children:" Pin to output pane"})]})}),c.jsxs(f,{children:[c.jsxs(f,{bold:!0,color:"white",children:[" ","0"]}),c.jsx(f,{dimColor:!0,children:" Clear pins"})]})]}),c.jsxs(x,{children:[c.jsx(x,{width:24,children:c.jsxs(f,{children:[c.jsxs(f,{bold:!0,color:"white",children:[" ","r"]}),c.jsx(f,{dimColor:!0,children:" Rerun all (done)"})]})}),c.jsxs(f,{children:[c.jsxs(f,{bold:!0,color:"white",children:[" ","R"]}),c.jsx(f,{dimColor:!0,children:" Retry failed task"})]})]}),c.jsxs(f,{children:[c.jsxs(f,{bold:!0,color:"white",children:[" ","i"]}),c.jsx(f,{dimColor:!0,children:" Interactive input (running task)"})]})]}),c.jsxs(x,{flexDirection:"column",marginBottom:1,children:[c.jsxs(x,{marginBottom:1,children:[c.jsx(f,{dimColor:!0,children:"── "}),c.jsx(f,{bold:!0,color:"white",children:"SCROLLING"}),c.jsx(f,{dimColor:!0,children:" (output panel)"})]}),c.jsxs(x,{children:[c.jsx(x,{width:24,children:c.jsxs(f,{children:[c.jsxs(f,{bold:!0,color:"white",children:[" ","↑","/k"]}),c.jsx(f,{dimColor:!0,children:" Scroll up"})]})}),c.jsxs(f,{children:[c.jsxs(f,{bold:!0,color:"white",children:[" ","↓","/j"]}),c.jsx(f,{dimColor:!0,children:" Scroll down"})]})]}),c.jsxs(x,{children:[c.jsx(x,{width:24,children:c.jsxs(f,{children:[c.jsxs(f,{bold:!0,color:"white",children:[" ","^u"]}),c.jsx(f,{dimColor:!0,children:" Page up"})]})}),c.jsxs(f,{children:[c.jsxs(f,{bold:!0,color:"white",children:[" ","^d"]}),c.jsx(f,{dimColor:!0,children:" Page down"})]})]}),c.jsxs(x,{children:[c.jsx(x,{width:24,children:c.jsxs(f,{children:[c.jsxs(f,{bold:!0,color:"white",children:[" ","Home"]}),c.jsx(f,{dimColor:!0,children:" Top"})]})}),c.jsxs(f,{children:[c.jsxs(f,{bold:!0,color:"white",children:[" ","End"]}),c.jsx(f,{dimColor:!0,children:" Bottom (resume follow)"})]})]}),c.jsxs(f,{children:[c.jsxs(f,{bold:!0,color:"white",children:[" ","f"]}),c.jsx(f,{dimColor:!0,children:" Toggle auto-scroll (tail mode)"})]})]}),c.jsxs(x,{flexDirection:"column",children:[c.jsxs(x,{marginBottom:1,children:[c.jsx(f,{dimColor:!0,children:"── "}),c.jsx(f,{bold:!0,color:"white",children:"GENERAL"})]}),c.jsxs(x,{children:[c.jsx(x,{width:24,children:c.jsxs(f,{children:[c.jsxs(f,{bold:!0,color:"white",children:[" ","q"]}),c.jsx(f,{dimColor:!0,children:" Quit"})]})}),c.jsxs(f,{children:[c.jsxs(f,{bold:!0,color:"white",children:[" ","?"]}),c.jsx(f,{dimColor:!0,children:" Toggle help"})]})]})]})]}),Y=c.jsx($s,{autoExitSeconds:t>0?t:3,onCancel:()=>{T(!1)},visible:M}),he=j&&n?c.jsx(Jn,{activeIndex:E,focused:a.focusedPanel==="dock",store:n}):null;if(a.viewMode==="fullscreen")return c.jsxs(x,{flexDirection:"column",height:p,width:u,children:[c.jsx(x,{flexGrow:1,children:c.jsx(dt,{autoScroll:I,duration:z?.duration??z?.elapsed,focused:!0,interactiveMode:a.interactiveMode,output:K,scrollRef:$,status:H,supportsInteractive:!g,taskId:N})}),he,ee,Y,ne]});if(a.viewMode==="split"){const R=u>=gt,b=c.jsx(ht,{compact:!0,filterActive:a.filterActive,filterText:a.filterText,focused:a.focusedPanel==="tasks",headerStatus:oe,parallelSlots:s,pinnedTaskIds:a.pinnedTaskIds,rows:W,scrollRef:P,selectedIndex:a.selectedIndex,title:re}),A=c.jsx(dt,{autoScroll:I,duration:z?.duration??z?.elapsed,focused:a.focusedPanel==="output",interactiveMode:a.interactiveMode,output:K,scrollRef:$,showFullscreenHint:!0,status:H,supportsInteractive:!g,taskId:N});if(R){const ae=Math.floor(u*.4);return c.jsxs(x,{flexDirection:"column",height:p,width:u,children:[c.jsxs(x,{flexDirection:"row",flexGrow:1,children:[c.jsx(x,{width:ae,children:b}),c.jsx(x,{flexGrow:1,children:A})]}),he,ee,Y,ne]})}const Q=Math.floor(p*.45);return c.jsxs(x,{flexDirection:"column",height:p,width:u,children:[c.jsx(x,{height:Q,children:b}),c.jsx(x,{flexGrow:1,children:A}),he,ee,Y,ne]})}return c.jsxs(x,{flexDirection:"column",height:p,width:u,children:[c.jsx(x,{flexGrow:1,children:c.jsx(ht,{filterActive:a.filterActive,filterText:a.filterText,focused:a.focusedPanel!=="dock",headerStatus:oe,parallelSlots:s,pinnedTaskIds:a.pinnedTaskIds,rows:W,scrollRef:P,selectedIndex:a.selectedIndex,title:re})}),he,ee,Y,ne]})},ti=t=>t==="quiet"?"quiet":"normal",si=(t,e)=>typeof t=="string"?ti(t.toLowerCase()):e===!0?"quiet":"normal",We=(t,e)=>{const s=t.overrides.visOptions;return s?.outputStyle==="normal"||s?.outputStyle==="quiet"?s.outputStyle:e},Xt=t=>`${t.id}: tracker saw no workspace access; cached on declared inputs`;class ri{#e;#r;#s;#n=[];#t=[];#i=[];#o=new Map;#c;#a;#d;#u=0;constructor(e){this.#e=e.projectNames,this.#r=e.args.targets,this.#s=e.tasks,this.#c=e.logReporter,this.#a=e.outputStyle??"normal",this.#d=e.ciGrouping??"auto"}startCommand(){this.#u=Date.now();const e=process.stdout.columns||80,s=`Running ${Ke(this.#e,this.#r,this.#s)}`,r=le(X.createElement(Ne,{title:s,variant:"info"}),{columns:e});se(r,"run header");const n=this.#s[0],o=n?.overrides?Object.entries(n.overrides).filter(([i])=>i!=="command"):[];if(o.length>0){se(`
|
|
11
|
+
${t}`}catch{return t}},Lr={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"]},we=t=>dr(t,Lr),Br={chunkCodeUnits:32*1024,now:Date.now,stallDropMs:3e4,stallRerouteMs:3e4,stallWarnMs:1e4},_r=(t,e)=>{if(t.length<=e)return[t];const s=[];let n=0;for(;n<t.length;){let r=Math.min(n+e,t.length);if(r<t.length){const o=t.lastIndexOf(`
|
|
12
|
+
`,r-1);o>=n&&(r=o+1),r>n&&(t.codePointAt(r-1)??0)>65535&&(r-=1)}s.push(t.slice(n,r)),n=r}return s},Nr=(t,e,s={})=>{const n={...Br,...s},r=Math.min(250,Math.max(10,Math.floor(n.stallWarnMs/4))),o=[],i=[],l=new Set;let d="stdout",h=!1,u=!1,p=!1,a=0,m,y;const g=()=>o.length>0||u,S=b=>{try{e.write(`${b}
|
|
13
|
+
`)}catch{}},v=()=>{const b=i.splice(0);for(const F of b)F()},w=()=>{if(d==="dropped"||!g()){m&&(clearTimeout(m),m=void 0);return}m||(m=setTimeout(C,r),m.unref?.())},k=b=>{p=!0,S(`vis: stdout stalled for ${Math.round(b/1e3)}s — dropping the wedged stdout write and rerouting the remaining output to stderr so the run can still finish; at most one ${n.chunkCodeUnits}-unit chunk of stdout output is lost.`);try{t.destroy?.()}catch{}d="stderr",a=n.now(),y?.()},O=()=>{try{e.destroy?.()}catch{}d="dropped",o.length=0,a=n.now(),y?.(),v(),w()},I=(b,F)=>{if(b===t&&d==="stdout"){p=!0;const B=F?.code;S(`vis: stdout writes failed (${B??F?.message??"stream closed or errored"}) — rerouting the remaining output to stderr.`),d="stderr",a=n.now(),y?.();return}b===e&&d==="stderr"&&O()},x=()=>{l.has(t)||(t.on("error",b=>{I(t,b)}),t.on("close",()=>{I(t)}),l.add(t)),l.has(e)||(e.on("error",b=>{I(e,b)}),e.on("close",()=>{I(e)}),l.add(e))},D=b=>new Promise(F=>{const B=G=>{b.off("drain",L),b.off("error",_),b.off("close",W),y===q&&(y=void 0),u=!1,F(G)},L=()=>{B("drain")},_=()=>{B("error")},W=()=>{B("close")},q=()=>{B("abandoned")};u=!0,y=q,b.once("drain",L),b.once("error",_),b.once("close",W)}),P=async()=>{if(!h){h=!0;try{for(;d!=="dropped"&&o.length>0;){const b=d==="stderr"?e:t,F=o[0],B=b.write(F.text);if(o.shift(),B){a=n.now(),p=!1;continue}await D(b)==="drain"&&(a=n.now(),p=!1)}}catch(b){I(d==="stderr"?e:t,b instanceof Error?b:void 0)}finally{h=!1,w(),v()}}},C=()=>{if(m=void 0,d==="dropped"||!g()){v();return}const b=n.now()-a;if(d==="stdout"){if(b>=n.stallRerouteMs)k(b);else if(b>=n.stallWarnMs&&!p){p=!0;const{pendingChunks:F,pendingCodeUnits:B}=M(),L=o.at(0)?.label;S(`vis: stdout writes stalled for ${Math.round(b/1e3)}s (${F} chunk(s), ~${Math.round(B/1024)} KB pending${L?` for "${L}"`:""}); waiting for the log reader to drain.`)}}else b>=n.stallDropMs&&O();w(),o.length>0&&P()},M=()=>({channel:d,pendingChunks:o.length,pendingCodeUnits:o.reduce((b,F)=>b+F.text.length,0)});return{flush:()=>new Promise(b=>{if(d==="dropped"||!g()){b();return}i.push(b),w()}),status:M,write:(b,F)=>{if(!(d==="dropped"||b.length===0)){g()||(a=n.now());for(const B of _r(b,n.chunkCodeUnits))o.push({label:F,text:B});x(),P(),w()}}}};let ft;const Wr=()=>(ft??=Nr(process.stdout,process.stderr),ft),se=(t,e)=>{Wr().write(t,e)},ye=t=>t==="local-cache"||t==="local-cache-kept-existing"||t==="remote-cache",xe=t=>{switch(t){case"failure":return{color:"red",icon:Dt};case"local-cache":case"local-cache-kept-existing":case"remote-cache":case"success":return{color:"green",icon:At};case"skipped":return{color:"gray",icon:Fe};default:return{color:"gray",icon:"?"}}},ke=t=>{const{color:e,icon:s}=xe(t);return le(X.createElement(f,{color:e},s),{columns:10}).trim()},Gr=t=>{const{color:e,icon:s}=xe(t);switch(t){case"local-cache":case"local-cache-kept-existing":case"remote-cache":return le(X.createElement(f,null,X.createElement(f,{color:e},s)," ",X.createElement(f,{color:"cyan"},"[cache]")),{columns:30}).trim();case"skipped":return le(X.createElement(f,null,X.createElement(f,{dimColor:!0},s)," ",X.createElement(f,{dimColor:!0},"[skipped]")),{columns:30}).trim();default:return le(X.createElement(f,{color:e},s),{columns:10}).trim()}},Hr=t=>t==="azure"||t==="buildkite"||t==="github"||t==="gitlab"||t==="off"?t:process.env.GITHUB_ACTIONS==="true"?"github":process.env.GITLAB_CI==="true"?"gitlab":process.env.BUILDKITE==="true"?"buildkite":process.env.TF_BUILD?.toLowerCase()==="true"?"azure":"off",qr=t=>{const e=t.replaceAll(/\W+/g,"_"),s=En("sha256").update(t).digest("hex").slice(0,6);return`${e}_${s}`},Ur=(t,e,s,n="auto")=>{const r=s.trim();if(!r)return;const o=`
|
|
14
|
+
`,i=Hr(n);if(i==="github"){se(`::group::${ke(e)} ${t}${o}`,t),se(r+o,t),se(`::endgroup::${o}`,t);return}if(i==="gitlab"){const p=Math.floor(Date.now()/1e3),a=qr(t),m=e==="failure"?"":"[collapsed=true]",y="\x1B[0K";se(`${y}section_start:${String(p)}:${a}${m}\r${y}${ke(e)} ${t}${o}`,t),se(r+o,t);const g=Math.floor(Date.now()/1e3);se(`${y}section_end:${String(g)}:${a}\r${y}${o}`,t);return}if(i==="buildkite"){se(`${e==="failure"?"+++":"---"} ${ke(e)} ${t}${o}`,t),se(r+o,t);return}if(i==="azure"){se(`##[group]${ke(e)} ${t}${o}`,t),se(r+o,t),se(`##[endgroup]${o}`,t);return}const l=process.stdout.columns||80,d=le(X.createElement(f,{dimColor:!0},Fe.repeat(l)),{columns:l}).trim(),h=Gr(e),u=le(X.createElement(f,{bold:!0},t),{columns:l}).trim();se(`${d}${o}`,t),se(`${h} ${u}${o}`,t),se(r+o,t),se(`${d}${o}`,t)},Vr=t=>t==="running"?{color:"white",icon:"•"}:t==="pending"?{color:"gray",icon:"·"}:xe(t),zr=({autoScroll:t,focused:e,interactiveMode:s,showFullscreenHint:n,statusValue:r,supportsInteractive:o,taskId:i})=>{if(!i)return;if(s)return"Esc cancel | Enter send";const l=t?"":" PAUSED (f resume)",d=o?" i INPUT":"";return e&&r==="running"&&n?`⏎ FULLSCREEN${d} f FOLLOW${l}`:e&&r==="running"?`f FOLLOW${d}${l}`:e&&n?`<enter> full screen${l}`:e?l||void 0:"<tab> or <enter> to focus"},ht=({autoScroll:t=!0,duration:e,focused:s,interactiveMode:n,output:r,scrollRef:o,showFullscreenHint:i,status:l,supportsInteractive:d=!0,taskId:h})=>{const u=l??"pending",{icon:p}=Vr(u),a=s?"bold":"single",m=u==="failure"?"red":u==="success"||ye(u)?s?"green":"gray":u==="running"?s?"white":"cyan":s?"white":"gray",y=h?`${p} ${h}`:void 0,g=e===void 0?void 0:we(e),S=zr({autoScroll:t,focused:s,interactiveMode:n??!1,showFullscreenHint:i??!1,statusValue:u,supportsInteractive:d,taskId:h});if(!h)return c.jsxs(j,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",paddingX:2,paddingY:1,children:[c.jsx(f,{dimColor:!0,children:"Select a task to view output"}),c.jsx(f,{dimColor:!0,children:"Press Enter or 1/2 to pin"})]});const v=[];if(r)for(const w of r.split(`
|
|
15
|
+
`))v.push(w.endsWith("\r")?w.slice(0,-1):w);return!r&&(u==="running"||u==="pending")?c.jsx(j,{borderBottomTitle:S,borderColor:m,borderStyle:a,borderTopRightTitle:g,borderTopTitle:y,flexDirection:"column",flexGrow:1,paddingX:2,paddingY:1,children:c.jsx(j,{alignItems:"center",flexGrow:1,justifyContent:"center",children:c.jsx(f,{dimColor:!0,children:"Waiting for task output…"})})}):c.jsxs(j,{borderBottomTitle:S,borderColor:n?"yellow":m,borderStyle:a,borderTopRightTitle:g,borderTopTitle:y,flexDirection:"column",flexGrow:1,children:[c.jsx(j,{flexGrow:1,flexShrink:1,paddingY:1,children:c.jsx(Rt,{flexGrow:1,followOutput:t,paddingX:2,ref:o,scrollbar:!0,scrollbarColor:"gray",scrollbarStyle:"block",children:c.jsx(f,{children:v.join(`
|
|
16
|
+
`)})})}),n&&c.jsx(j,{flexShrink:0,justifyContent:"center",paddingX:1,children:c.jsx(f,{bold:!0,color:"yellow",children:"INTERACTIVE | keystrokes forwarded to task | Esc to exit"})})]})},Yr={crashed:"✖",failed:"✖",pending:"·",ready:"●",starting:"•"},Kt=t=>t==="ready"?"green":t==="crashed"||t==="failed"?"red":t==="starting"?"cyan":"gray",Kr=({status:t})=>t==="starting"?c.jsx(f,{color:"cyan",children:c.jsx(Bt,{type:"dots"})}):c.jsx(f,{bold:!0,color:Kt(t),children:Yr[t]}),Xr=({active:t,focused:e,state:s})=>{const n=e&&t,r=n?">":" ",o=s.status==="ready"?s.port?`running, port ${String(s.port)}`:"running":s.status==="failed"||s.status==="crashed"?s.errorMessage??"exited":s.lastLine??"booting…";return c.jsxs(j,{flexDirection:"row",flexShrink:0,overflow:"hidden",children:[c.jsx(f,{children:r}),c.jsx(f,{children:" "}),c.jsx(j,{flexShrink:0,width:3,children:c.jsx(Kr,{status:s.status})}),c.jsx(j,{flexGrow:0,flexShrink:0,width:28,children:c.jsx(f,{bold:n,inverse:n,children:s.id})}),c.jsx(j,{flexGrow:1,flexShrink:1,overflow:"hidden",children:c.jsxs(f,{color:Kt(s.status),dimColor:s.status!=="crashed"&&s.status!=="failed",wrap:"truncate-end",children:[" ",o]})})]})},Jr=({states:t})=>{const e=[];for(const n of t)n.status==="ready"&&e.push(n.id);const s=e.join(", ");return c.jsxs(j,{paddingX:1,children:[c.jsxs(f,{bold:!0,color:"green",children:["● ","Services"]}),c.jsxs(f,{children:[" ",String(e.length)," / ",String(t.length)," running"]}),s.length>0&&c.jsxs(f,{dimColor:!0,children:[" ",s]}),c.jsx(f,{dimColor:!0,children:" [Tab ↓]"})]})},Qr=({states:t})=>{const e=t.find(s=>s.status==="crashed"||s.status==="failed");return e?c.jsxs(j,{flexDirection:"column",paddingX:1,children:[c.jsxs(f,{bold:!0,color:"red",children:["✖ ","Service crashed:"," ",e.id]}),e.tailLines.slice(-3).map((s,n)=>c.jsxs(f,{color:"red",dimColor:!0,children:[" ",s]},`crash-${String(n)}`))]}):c.jsx(c.Fragment,{})},Zr=({activeIndex:t,focused:e,store:s})=>{const n=U.useSyncExternalStore(s.subscribe,s.getSnapshot),r=s.getIds();if(r.length===0)return c.jsx(c.Fragment,{});const o=r.map(u=>n.get(u)).filter(u=>u!==void 0),i=s.getDockState(),l=i==="crash"?"red":i==="ready"?"gray":e?"white":"cyan",d=i==="crash"?"Services (crashed)":i==="ready"?"Services":"Services (starting)",h=e?i==="crash"?"↑↓ select Enter logs R retry Esc back":"↑↓ select Enter logs Esc back":"Tab to focus services";return i==="ready"&&!e?c.jsx(j,{borderColor:l,borderStyle:"single",flexDirection:"row",flexShrink:0,children:c.jsx(Jr,{states:o})}):c.jsxs(j,{borderBottomTitle:h,borderColor:l,borderStyle:e?"bold":"single",borderTopTitle:d,flexDirection:"column",flexGrow:2,flexShrink:0,minHeight:6,paddingX:1,children:[i==="crash"&&c.jsx(Qr,{states:o}),o.map((u,p)=>c.jsx(Xr,{active:p===t,focused:e,state:u},u.id))]})},Xt=6,Jt=8,Qt=12,ei=t=>t==="running"||t==="pending"?Lt:t==="local-cache"||t==="local-cache-kept-existing"?"Local":t==="remote-cache"?"Remote":Fe,pt=(t,e)=>e[0]===t?"[1]":e[1]===t?"[2]":"",mt=({compact:t,focused:e,isSelected:s,pinLabel:n,row:r})=>{const{persistent:o,status:i,taskId:l}=r,d=e&&s,h=d?">":" ",u=i==="running"&&o===!0;let p;if(u)p=c.jsx(f,{bold:!0,color:"green",children:" ● "});else if(i==="running")p=c.jsxs(f,{bold:!0,color:"white",children:[" ",c.jsx(Bt,{type:"dots"})," "]});else if(i==="pending")p=c.jsx(f,{bold:!0,color:"gray",children:" · "});else{const{color:m,icon:y}=xe(i);p=c.jsxs(f,{bold:!0,color:m,children:[" ",y," "]})}let a=Lt;return u?a="running":i!=="running"&&i!=="pending"?a=r.duration===void 0?Fe:we(r.duration):i==="running"&&r.elapsed!==void 0&&(a=we(r.elapsed)),c.jsxs(j,{children:[c.jsx(f,{children:h}),c.jsx(j,{width:Xt,children:p}),c.jsxs(j,{flexGrow:1,children:[c.jsx(f,{bold:d,inverse:d,children:l}),n?c.jsx(f,{dimColor:!0,children:` ${n}`}):null]}),!t&&c.jsx(j,{justifyContent:"flex-end",width:Jt,children:c.jsx(f,{dimColor:!ye(i),children:ei(i)})}),!t&&c.jsx(j,{justifyContent:"flex-end",width:Qt,children:c.jsx(f,{color:u?"green":void 0,dimColor:i==="pending"||u,children:a})})]})},gt=({compact:t,filterActive:e,filterText:s,focused:n,headerStatus:r,parallelSlots:o=3,pinnedTaskIds:i,rows:l,scrollRef:d,selectedIndex:h,title:u})=>{const p=r==="error"?"red":r==="success"?"green":n?"white":"gray",a=l[h]?.taskId,m=[];let y=0;for(const w of l)w.status==="running"?m.push(w):w.status==="pending"&&(y+=1);const g=Math.min(o,m.length+y),S=g>1,v=[];if(S)for(let w=0;w<g;w++){const k=m[w];k?v.push(c.jsx(mt,{compact:t,focused:n,isSelected:k.taskId===a,pinLabel:pt(k.taskId,i),row:k},`par-${k.taskId}`)):v.push(c.jsxs(j,{children:[c.jsx(f,{children:" "}),c.jsx(j,{width:Xt,children:c.jsx(f,{bold:!0,color:"gray",children:" · "})}),c.jsx(f,{dimColor:!0,children:"Waiting for task..."})]},`par-empty-${String(w)}`))}return c.jsxs(j,{borderColor:p,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[c.jsxs(j,{flexShrink:0,paddingX:1,children:[c.jsx(f,{bold:!0,inverse:!0,children:" VIS "}),c.jsx(f,{children:` ${u}`}),!t&&c.jsxs(j,{flexGrow:1,gap:0,justifyContent:"flex-end",children:[c.jsx(j,{justifyContent:"flex-end",width:Jt,children:c.jsx(f,{dimColor:!0,children:"Cache"})}),c.jsx(j,{justifyContent:"flex-end",width:Qt,children:c.jsx(f,{dimColor:!0,children:"Duration"})})]})]}),c.jsx(Rt,{flexGrow:1,flexShrink:1,paddingX:1,paddingY:1,ref:d,scrollbar:!0,scrollbarColor:"gray",scrollbarStyle:"block",children:l.map(w=>c.jsx(mt,{compact:t,focused:n,isSelected:w.taskId===a,pinLabel:pt(w.taskId,i),row:w},w.taskId))}),S&&c.jsx(j,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",borderTop:!0,flexDirection:"column",flexShrink:0,paddingX:1,paddingY:1,children:v}),e&&c.jsxs(j,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",borderTop:!0,flexShrink:0,paddingX:1,children:[c.jsx(f,{bold:!0,color:"white",children:"/ "}),c.jsx(f,{children:s}),c.jsx(f,{inverse:!0,children:" "})]})]})},wt=40,yt=10,vt=100,ti=Object.freeze([]),si=({autoExitSeconds:t,onRetryService:e,parallelSlots:s,projectNames:n,serviceDockStore:r,stdinRegistry:o,store:i,targets:l,tasks:d})=>{const{exit:h}=Ts(),{columns:u,rows:p}=$s(),a=U.useSyncExternalStore(i.subscribe,i.getSnapshot),m=U.useCallback(R=>r?r.subscribe(R):()=>{},[r]);U.useSyncExternalStore(m,()=>r?r.getDockState():"ready");const y=r?r.getIds():ti,g=y.length>0,[S,v]=U.useState(0),[w,k]=U.useState(null),O=U.useSyncExternalStore(m,()=>w&&r?r.getState(w):void 0),[I,x]=U.useState(!1),D=U.useRef(null),P=U.useRef(null),C=U.useRef(null),[M,$]=U.useState(!1),[E,b]=U.useState(!0),F=U.useRef({list:0,splitList:0,splitOutput:0}),B=U.useCallback(()=>{a.viewMode==="list"?F.current.list=P.current?.getScrollOffset()??0:a.viewMode==="split"&&(F.current.splitList=P.current?.getScrollOffset()??0,F.current.splitOutput=C.current?.getScrollOffset()??0)},[a.viewMode]),L=U.useCallback(R=>{setTimeout(()=>{if(R==="list"){const T=F.current.list;P.current?.scrollTo(T)}else if(R==="split"){const T=F.current.splitList;T>0?P.current?.scrollTo(T):P.current?.scrollTo(Math.max(0,i.getSnapshot().selectedIndex-2)),C.current?.scrollTo(F.current.splitOutput)}},0)},[i]),_=U.useRef(!1);U.useEffect(()=>{a.done&&!_.current&&(_.current=!0,t>0&&a.failed===0&&$(!0)),!a.done&&_.current&&(_.current=!1,$(!1))},[a.done,a.failed,t]);const W=U.useMemo(()=>{const R=y.length>0?new Set(y):null,T=a.filterText?a.filterText.toLowerCase():null,A=[];for(const Q of a.rows)R?.has(Q.taskId)||a.statusFilter==="failed"&&Q.status!=="failure"||a.statusFilter==="running"&&Q.status!=="running"&&Q.status!=="pending"||a.statusFilter==="passed"&&Q.status!=="success"&&!ye(Q.status)||T&&!Q.taskId.toLowerCase().includes(T)||A.push(Q);return A},[a.rows,a.filterText,a.statusFilter,y]),G=(W[a.selectedIndex]??null)?.taskId??null,J=w?null:a.pinnedTaskIds[0]??G,z=J?a.rows.find(R=>R.taskId===J):null,Z=O??null,te=w?(Z?.tailLines??[]).join(`
|
|
17
|
+
`):J?a.outputs.get(J)??"":"",K=U.useMemo(()=>z?.status==="failure"&&te?Yt(te,{color:!process.env.NO_COLOR,cwd:process.cwd()}):te,[z?.status,te]),N=w??J,H=w?Z?.status==="crashed"||Z?.status==="failed"?"failure":"running":z?.status,V=Xe(n,l,d),ne=a.done?`Completed ${V} (${we((a.endTime??Date.now())-a.startTime)})`:`Running ${V}...`,oe=a.done?a.failed>0?"error":"success":"running",he=U.useCallback(R=>{P.current?.scrollTo(Math.max(0,R-2))},[]);if(U.useEffect(()=>{a.interactiveMode&&z?.status!=="running"&&i.setInteractiveMode(!1)},[a.interactiveMode,z?.status,i]),U.useEffect(()=>{if(!J)return;let R=u;a.viewMode==="split"&&u>=vt?R=u-Math.floor(u*.4)-2:(a.viewMode==="split"||a.viewMode==="fullscreen")&&(R=u-2);const T=Math.max(1,p-4);o.get(J)?.resize?.(R,T)},[u,p,a.viewMode,J]),et((R,T)=>{if(T.escape){i.setInteractiveMode(!1);return}if(!J)return;const A=o.get(J);if(!A){i.setInteractiveMode(!1);return}if(T.return)A.write("\r");else if(T.upArrow)A.write("\x1B[A");else if(T.downArrow)A.write("\x1B[B");else if(T.rightArrow)A.write("\x1B[C");else if(T.leftArrow)A.write("\x1B[D");else if(T.backspace)A.write("");else if(T.delete)A.write("\x1B[3~");else if(T.tab)A.write(" ");else if(T.home)A.write("\x1B[H");else if(T.end)A.write("\x1B[F");else if(T.pageUp)A.write("\x1B[5~");else if(T.pageDown)A.write("\x1B[6~");else if(T.ctrl&&R){const Q=R.toUpperCase().codePointAt(0);Q!==void 0&&Q>=65&&Q<=90&&A.write(String.fromCodePoint(Q-64))}else R&&A.write(R)},{isActive:a.interactiveMode}),et((R,T)=>{if(R==="c"&&T.ctrl){h();return}if(!M){if(I){T.escape||R==="?"?x(!1):R==="q"?(x(!1),$(!0)):T.downArrow||R==="j"?D.current?.scrollBy(1):T.upArrow||R==="k"?D.current?.scrollBy(-1):T.pageDown?D.current?.scrollBy(5):T.pageUp?D.current?.scrollBy(-5):T.home?D.current?.scrollToTop():T.end&&D.current?.scrollToBottom();return}if(R==="?"){x(!0);return}if(R==="q"){$(!0);return}if(R==="r"&&a.done){i.requestRerun();return}if(R==="R"&&a.done){const A=W[a.selectedIndex];A?.status==="failure"&&i.requestRetry(A.taskId);return}if(R==="F"&&!a.filterActive){const A=["all","failed","running","passed"],Q=A.indexOf(a.statusFilter);i.setStatusFilter(A[(Q+1)%A.length]);return}if(a.filterActive){if(T.escape){i.setFilterActive(!1);return}if(T.return){i.setFilterActive(!1);return}if(T.backspace){i.setFilter(a.filterText.slice(0,-1));return}if(R&&!T.ctrl&&!T.meta){i.setFilter(a.filterText+R);return}return}if(R==="i"&&z?.status==="running"&&(a.viewMode==="fullscreen"||a.viewMode==="split"&&a.focusedPanel==="output")){i.setInteractiveMode(!0);return}if(a.viewMode==="fullscreen"){if(T.escape){i.setViewMode("split"),L("split");return}if(R==="f"){const A=!E;b(A),A&&C.current?.scrollToBottom();return}if(T.downArrow||R==="j"){b(!1),C.current?.scrollBy(1);return}if(T.upArrow||R==="k"){b(!1),C.current?.scrollBy(-1);return}if(T.pageDown||T.ctrl&&R==="d"){b(!1),C.current?.scrollBy(12);return}if(T.pageUp||T.ctrl&&R==="u"){b(!1),C.current?.scrollBy(-12);return}if(T.home){b(!1),C.current?.scrollToTop();return}if(T.end){b(!0),C.current?.scrollToBottom();return}return}if(a.focusedPanel==="dock"&&g&&r){if(T.tab){k(null),i.setFocusedPanel("tasks");return}if(T.escape){i.setFocusedPanel("tasks"),k(null),a.viewMode==="split"&&(i.setViewMode("list"),L("list"));return}if(T.downArrow||R==="j"){v(A=>Math.min(A+1,y.length-1));return}if(T.upArrow||R==="k"){v(A=>Math.max(A-1,0));return}if(T.return){const A=y[S];A&&(k(A),b(!0),B(),F.current.splitList=0,F.current.splitOutput=0,i.setViewMode("split"),i.setFocusedPanel("output"),L("split"));return}if((R==="r"||R==="R")&&e){const A=y[S],Q=A?r.getState(A)?.status:void 0;if(A&&(Q==="crashed"||Q==="failed")){const ae=e(A);ae instanceof Promise&&ae.catch(()=>{})}return}return}if(a.viewMode==="split"){if(T.tab){a.focusedPanel==="tasks"?i.setFocusedPanel("output"):g?i.setFocusedPanel("dock"):(k(null),i.setFocusedPanel("tasks"));return}if(a.focusedPanel==="output"){if(T.escape){if(w&&g){k(null),i.setViewMode("list"),i.setFocusedPanel("dock"),L("list");return}k(null),i.setFocusedPanel("tasks");return}if(T.return){B(),i.setViewMode("fullscreen");return}if(R==="f"){const A=!E;b(A),A&&C.current?.scrollToBottom();return}if(T.downArrow||R==="j"){b(!1),C.current?.scrollBy(1);return}if(T.upArrow||R==="k"){b(!1),C.current?.scrollBy(-1);return}if(T.pageDown||T.ctrl&&R==="d"){b(!1),C.current?.scrollBy(12);return}if(T.pageUp||T.ctrl&&R==="u"){b(!1),C.current?.scrollBy(-12);return}if(T.home){b(!1),C.current?.scrollToTop();return}if(T.end){b(!0),C.current?.scrollToBottom();return}return}if(T.escape){i.setViewMode("list"),L("list");return}if(T.return){i.setFocusedPanel("output");return}}if(a.viewMode==="list"||a.viewMode==="split"&&a.focusedPanel==="tasks"){if(T.tab&&a.viewMode==="list"&&g){i.setFocusedPanel("dock");return}if(T.downArrow||R==="j"){const A=Math.min(a.selectedIndex+1,Math.max(0,W.length-1));i.setSelectedIndex(A),he(A);return}if(T.upArrow||R==="k"){const A=Math.max(a.selectedIndex-1,0);i.setSelectedIndex(A),he(A);return}if(T.return&&a.viewMode==="list"){b(!0),B(),F.current.splitList=0,F.current.splitOutput=0,i.setViewMode("split"),i.setFocusedPanel("output"),L("split");return}if(R==="/"){i.setFilterActive(!0);return}if(R==="1"&&G){i.pinTask(0,G);return}if(R==="2"&&G){i.pinTask(1,G);return}if(R==="0"){i.clearPins();return}T.escape&&a.filterText&&i.setFilter("")}}},{isActive:!a.interactiveMode}),u<wt||p<yt)return c.jsx(j,{alignItems:"center",height:p,justifyContent:"center",width:u,children:c.jsxs(f,{color:"yellow",children:["Terminal too small (",u,"x",p,"). Minimum:"," ",wt,"x",yt]})});const de=c.jsxs(j,{gap:1,children:[a.succeeded>0&&c.jsxs(f,{bold:!0,color:"green",children:["✓"," ",a.succeeded]}),a.cached>0&&c.jsxs(f,{dimColor:!0,children:["✓"," ",a.cached]}),a.failed>0&&c.jsxs(f,{bold:!0,color:"red",children:["✗"," ",a.failed]}),a.running>0&&c.jsxs(f,{color:"cyan",children:["◷"," ",a.running]}),c.jsxs(f,{dimColor:!0,children:[a.totalTasks," ","total"]}),a.statusFilter!=="all"&&c.jsxs(f,{color:"yellow",children:["[",a.statusFilter,"]"]})]});let ce;if(a.viewMode==="fullscreen")ce=[c.jsxs(j,{gap:1,children:[c.jsx(f,{bold:!0,color:"white",children:"Esc"}),c.jsx(f,{dimColor:!0,children:"BACK"})]},"esc"),c.jsxs(j,{gap:1,children:[c.jsx(f,{bold:!0,color:"white",children:"↑↓"}),c.jsx(f,{dimColor:!0,children:"SCROLL"})]},"scroll"),c.jsxs(j,{gap:1,children:[c.jsx(f,{bold:!0,color:"white",children:"^u ^d"}),c.jsx(f,{dimColor:!0,children:"PAGE"})]},"page"),...z?.status==="running"?[c.jsxs(j,{gap:1,children:[c.jsx(f,{bold:!0,color:"white",children:"i"}),c.jsx(f,{dimColor:!0,children:"INPUT"})]},"i")]:[],c.jsxs(j,{gap:1,children:[c.jsx(f,{bold:!0,color:"white",children:"q"}),c.jsx(f,{dimColor:!0,children:"QUIT"})]},"q")];else if(a.done){const R=W[a.selectedIndex]?.status==="failure";ce=[c.jsxs(j,{gap:1,children:[c.jsx(f,{bold:!0,color:"white",children:"q"}),c.jsx(f,{dimColor:!0,children:"QUIT"})]},"q"),c.jsxs(j,{gap:1,children:[c.jsx(f,{bold:!0,color:"white",children:"r"}),c.jsx(f,{dimColor:!0,children:"RERUN"})]},"r"),...R?[c.jsxs(j,{gap:1,children:[c.jsx(f,{bold:!0,color:"white",children:"R"}),c.jsx(f,{dimColor:!0,children:"RETRY"})]},"R")]:[],c.jsxs(j,{gap:1,children:[c.jsx(f,{bold:!0,color:"white",children:"?"}),c.jsx(f,{dimColor:!0,children:"HELP"})]},"?"),c.jsxs(j,{gap:1,children:[c.jsx(f,{bold:!0,color:"white",children:"↑↓"}),c.jsx(f,{dimColor:!0,children:"NAV"})]},"nav"),c.jsxs(j,{gap:1,children:[c.jsx(f,{bold:!0,color:"white",children:"F"}),c.jsx(f,{dimColor:!0,children:"FILTER"})]},"F"),c.jsxs(j,{gap:1,children:[c.jsx(f,{bold:!0,color:"white",children:"⏎"}),c.jsx(f,{dimColor:!0,children:a.viewMode==="list"?"OUTPUT":"FULLSCREEN"})]},"enter")]}else a.viewMode==="split"&&a.focusedPanel==="output"?ce=[c.jsxs(j,{gap:1,children:[c.jsx(f,{bold:!0,color:"white",children:"q"}),c.jsx(f,{dimColor:!0,children:"QUIT"})]},"q"),c.jsxs(j,{gap:1,children:[c.jsx(f,{bold:!0,color:"white",children:"Esc"}),c.jsx(f,{dimColor:!0,children:"BACK"})]},"esc"),c.jsxs(j,{gap:1,children:[c.jsx(f,{bold:!0,color:"white",children:"↑↓"}),c.jsx(f,{dimColor:!0,children:"SCROLL"})]},"scroll"),...z?.status==="running"?[c.jsxs(j,{gap:1,children:[c.jsx(f,{bold:!0,color:"white",children:"i"}),c.jsx(f,{dimColor:!0,children:"INPUT"})]},"i")]:[],c.jsxs(j,{gap:1,children:[c.jsx(f,{bold:!0,color:"white",children:"⏎"}),c.jsx(f,{dimColor:!0,children:"FULLSCREEN"})]},"enter"),c.jsxs(j,{gap:1,children:[c.jsx(f,{bold:!0,color:"white",children:"Tab"}),c.jsx(f,{dimColor:!0,children:"PANEL"})]},"tab"),c.jsxs(j,{gap:1,children:[c.jsx(f,{bold:!0,color:"white",children:"?"}),c.jsx(f,{dimColor:!0,children:"HELP"})]},"?")]:ce=[c.jsxs(j,{gap:1,children:[c.jsx(f,{bold:!0,color:"white",children:"q"}),c.jsx(f,{dimColor:!0,children:"QUIT"})]},"q"),c.jsxs(j,{gap:1,children:[c.jsx(f,{bold:!0,color:"white",children:"?"}),c.jsx(f,{dimColor:!0,children:"HELP"})]},"?"),c.jsxs(j,{gap:1,children:[c.jsx(f,{bold:!0,color:"white",children:"↑↓"}),c.jsx(f,{dimColor:!0,children:"NAV"})]},"nav"),c.jsxs(j,{gap:1,children:[c.jsx(f,{bold:!0,color:"white",children:"/"}),c.jsx(f,{dimColor:!0,children:"FILTER"})]},"/"),c.jsxs(j,{gap:1,children:[c.jsx(f,{bold:!0,color:"white",children:"F"}),c.jsx(f,{dimColor:!0,children:"STATUS"})]},"F"),c.jsxs(j,{gap:1,children:[c.jsx(f,{bold:!0,color:"white",children:"⏎"}),c.jsx(f,{dimColor:!0,children:a.viewMode==="list"?"OUTPUT":"FULLSCREEN"})]},"enter"),...a.viewMode==="split"?[c.jsxs(j,{gap:1,children:[c.jsx(f,{bold:!0,color:"white",children:"Tab"}),c.jsx(f,{dimColor:!0,children:"PANEL"})]},"tab")]:[]];const ee=c.jsxs(j,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",flexShrink:0,justifyContent:"space-between",children:[c.jsx(j,{flexGrow:1,flexWrap:"wrap",gap:2,paddingX:1,children:ce}),c.jsx(j,{flexShrink:0,paddingX:1,children:de})]}),re=c.jsxs(Cs,{backgroundColor:"#1e1e1e",footer:c.jsxs(f,{dimColor:!0,children:[c.jsx(f,{bold:!0,color:"white",children:"↑↓"})," ","scroll"," ",c.jsx(f,{bold:!0,color:"white",children:"?"}),"/",c.jsx(f,{bold:!0,color:"white",children:"Esc"})," ","close"]}),scrollRef:D,title:"KEYBOARD SHORTCUTS",visible:I,width:52,children:[c.jsxs(j,{flexDirection:"column",marginBottom:1,children:[c.jsxs(j,{marginBottom:1,children:[c.jsx(f,{dimColor:!0,children:"── "}),c.jsx(f,{bold:!0,color:"white",children:"NAVIGATION"})]}),c.jsxs(j,{children:[c.jsx(j,{width:24,children:c.jsxs(f,{children:[c.jsxs(f,{bold:!0,color:"white",children:[" ","↑","/k"]}),c.jsx(f,{dimColor:!0,children:" Move up"})]})}),c.jsxs(f,{children:[c.jsxs(f,{bold:!0,color:"white",children:[" ","↓","/j"]}),c.jsx(f,{dimColor:!0,children:" Move down"})]})]}),c.jsxs(f,{children:[c.jsxs(f,{bold:!0,color:"white",children:[" ","Tab"]}),c.jsx(f,{dimColor:!0,children:" Switch panel (split)"})]}),c.jsxs(f,{children:[c.jsxs(f,{bold:!0,color:"white",children:[" ","Esc"]}),c.jsx(f,{dimColor:!0,children:" Back / close"})]}),c.jsxs(f,{children:[c.jsxs(f,{bold:!0,color:"white",children:[" ","Enter"]}),c.jsx(f,{dimColor:!0,children:" Show output / fullscreen"})]})]}),c.jsxs(j,{flexDirection:"column",marginBottom:1,children:[c.jsxs(j,{marginBottom:1,children:[c.jsx(f,{dimColor:!0,children:"── "}),c.jsx(f,{bold:!0,color:"white",children:"VIEWS"})]}),c.jsxs(f,{children:[c.jsxs(f,{bold:!0,color:"white",children:[" ","Enter"]}),c.jsxs(f,{dimColor:!0,children:[" ","List"," ","→"," ","Split"," ","→"," ","Fullscreen"]})]}),c.jsxs(f,{children:[c.jsxs(f,{bold:!0,color:"white",children:[" ","Esc"]}),c.jsxs(f,{dimColor:!0,children:[" ","Fullscreen"," ","→"," ","Split"," ","→"," ","List"]})]})]}),c.jsxs(j,{flexDirection:"column",marginBottom:1,children:[c.jsxs(j,{marginBottom:1,children:[c.jsx(f,{dimColor:!0,children:"── "}),c.jsx(f,{bold:!0,color:"white",children:"ACTIONS"})]}),c.jsxs(j,{children:[c.jsx(j,{width:24,children:c.jsxs(f,{children:[c.jsxs(f,{bold:!0,color:"white",children:[" ","/"]}),c.jsx(f,{dimColor:!0,children:" Filter by text"})]})}),c.jsxs(f,{children:[c.jsxs(f,{bold:!0,color:"white",children:[" ","F"]}),c.jsx(f,{dimColor:!0,children:" Filter by status"})]})]}),c.jsxs(j,{children:[c.jsx(j,{width:24,children:c.jsxs(f,{children:[c.jsxs(f,{bold:!0,color:"white",children:[" ","1"]}),c.jsx(f,{dimColor:!0,children:"/"}),c.jsx(f,{bold:!0,color:"white",children:"2"}),c.jsx(f,{dimColor:!0,children:" Pin to output pane"})]})}),c.jsxs(f,{children:[c.jsxs(f,{bold:!0,color:"white",children:[" ","0"]}),c.jsx(f,{dimColor:!0,children:" Clear pins"})]})]}),c.jsxs(j,{children:[c.jsx(j,{width:24,children:c.jsxs(f,{children:[c.jsxs(f,{bold:!0,color:"white",children:[" ","r"]}),c.jsx(f,{dimColor:!0,children:" Rerun all (done)"})]})}),c.jsxs(f,{children:[c.jsxs(f,{bold:!0,color:"white",children:[" ","R"]}),c.jsx(f,{dimColor:!0,children:" Retry failed task"})]})]}),c.jsxs(f,{children:[c.jsxs(f,{bold:!0,color:"white",children:[" ","i"]}),c.jsx(f,{dimColor:!0,children:" Interactive input (running task)"})]})]}),c.jsxs(j,{flexDirection:"column",marginBottom:1,children:[c.jsxs(j,{marginBottom:1,children:[c.jsx(f,{dimColor:!0,children:"── "}),c.jsx(f,{bold:!0,color:"white",children:"SCROLLING"}),c.jsx(f,{dimColor:!0,children:" (output panel)"})]}),c.jsxs(j,{children:[c.jsx(j,{width:24,children:c.jsxs(f,{children:[c.jsxs(f,{bold:!0,color:"white",children:[" ","↑","/k"]}),c.jsx(f,{dimColor:!0,children:" Scroll up"})]})}),c.jsxs(f,{children:[c.jsxs(f,{bold:!0,color:"white",children:[" ","↓","/j"]}),c.jsx(f,{dimColor:!0,children:" Scroll down"})]})]}),c.jsxs(j,{children:[c.jsx(j,{width:24,children:c.jsxs(f,{children:[c.jsxs(f,{bold:!0,color:"white",children:[" ","^u"]}),c.jsx(f,{dimColor:!0,children:" Page up"})]})}),c.jsxs(f,{children:[c.jsxs(f,{bold:!0,color:"white",children:[" ","^d"]}),c.jsx(f,{dimColor:!0,children:" Page down"})]})]}),c.jsxs(j,{children:[c.jsx(j,{width:24,children:c.jsxs(f,{children:[c.jsxs(f,{bold:!0,color:"white",children:[" ","Home"]}),c.jsx(f,{dimColor:!0,children:" Top"})]})}),c.jsxs(f,{children:[c.jsxs(f,{bold:!0,color:"white",children:[" ","End"]}),c.jsx(f,{dimColor:!0,children:" Bottom (resume follow)"})]})]}),c.jsxs(f,{children:[c.jsxs(f,{bold:!0,color:"white",children:[" ","f"]}),c.jsx(f,{dimColor:!0,children:" Toggle auto-scroll (tail mode)"})]})]}),c.jsxs(j,{flexDirection:"column",children:[c.jsxs(j,{marginBottom:1,children:[c.jsx(f,{dimColor:!0,children:"── "}),c.jsx(f,{bold:!0,color:"white",children:"GENERAL"})]}),c.jsxs(j,{children:[c.jsx(j,{width:24,children:c.jsxs(f,{children:[c.jsxs(f,{bold:!0,color:"white",children:[" ","q"]}),c.jsx(f,{dimColor:!0,children:" Quit"})]})}),c.jsxs(f,{children:[c.jsxs(f,{bold:!0,color:"white",children:[" ","?"]}),c.jsx(f,{dimColor:!0,children:" Toggle help"})]})]})]})]}),Y=c.jsx(Is,{autoExitSeconds:t>0?t:3,onCancel:()=>{$(!1)},visible:M}),pe=g&&r?c.jsx(Zr,{activeIndex:S,focused:a.focusedPanel==="dock",store:r}):null;if(a.viewMode==="fullscreen")return c.jsxs(j,{flexDirection:"column",height:p,width:u,children:[c.jsx(j,{flexGrow:1,children:c.jsx(ht,{autoScroll:E,duration:z?.duration??z?.elapsed,focused:!0,interactiveMode:a.interactiveMode,output:K,scrollRef:C,status:H,supportsInteractive:!w,taskId:N})}),pe,ee,Y,re]});if(a.viewMode==="split"){const R=u>=vt,T=c.jsx(gt,{compact:!0,filterActive:a.filterActive,filterText:a.filterText,focused:a.focusedPanel==="tasks",headerStatus:oe,parallelSlots:s,pinnedTaskIds:a.pinnedTaskIds,rows:W,scrollRef:P,selectedIndex:a.selectedIndex,title:ne}),A=c.jsx(ht,{autoScroll:E,duration:z?.duration??z?.elapsed,focused:a.focusedPanel==="output",interactiveMode:a.interactiveMode,output:K,scrollRef:C,showFullscreenHint:!0,status:H,supportsInteractive:!w,taskId:N});if(R){const ae=Math.floor(u*.4);return c.jsxs(j,{flexDirection:"column",height:p,width:u,children:[c.jsxs(j,{flexDirection:"row",flexGrow:1,children:[c.jsx(j,{width:ae,children:T}),c.jsx(j,{flexGrow:1,children:A})]}),pe,ee,Y,re]})}const Q=Math.floor(p*.45);return c.jsxs(j,{flexDirection:"column",height:p,width:u,children:[c.jsx(j,{height:Q,children:T}),c.jsx(j,{flexGrow:1,children:A}),pe,ee,Y,re]})}return c.jsxs(j,{flexDirection:"column",height:p,width:u,children:[c.jsx(j,{flexGrow:1,children:c.jsx(gt,{filterActive:a.filterActive,filterText:a.filterText,focused:a.focusedPanel!=="dock",headerStatus:oe,parallelSlots:s,pinnedTaskIds:a.pinnedTaskIds,rows:W,scrollRef:P,selectedIndex:a.selectedIndex,title:ne})}),pe,ee,Y,re]})},ni=t=>t==="quiet"?"quiet":"normal",ri=(t,e)=>typeof t=="string"?ni(t.toLowerCase()):e===!0?"quiet":"normal",We=(t,e)=>{const s=t.overrides.visOptions;return s?.outputStyle==="normal"||s?.outputStyle==="quiet"?s.outputStyle:e},Zt=t=>`${t.id}: tracker saw no workspace access; cached on declared inputs`;class ii{#e;#n;#s;#r=[];#t=[];#i=[];#o=new Map;#c;#a;#d;#u=0;constructor(e){this.#e=e.projectNames,this.#n=e.args.targets,this.#s=e.tasks,this.#c=e.logReporter,this.#a=e.outputStyle??"normal",this.#d=e.ciGrouping??"auto"}startCommand(){this.#u=Date.now();const e=process.stdout.columns||80,s=`Running ${Xe(this.#e,this.#n,this.#s)}`,n=le(X.createElement(Ne,{title:s,variant:"info"}),{columns:e});se(n,"run header");const r=this.#s[0],o=r?.overrides?Object.entries(r.overrides).filter(([i])=>i!=="command"):[];if(o.length>0){se(`
|
|
18
18
|
With additional flags:
|
|
19
|
-
`,"run header");for(const[i,l]of o)se(`${
|
|
19
|
+
`,"run header");for(const[i,l]of o)se(`${Ir(" ",i,l)}
|
|
20
20
|
`,"run header")}se(`
|
|
21
|
-
`,"run header")}startTasks(e){const s=process.stdout.columns||80;for(const
|
|
22
|
-
`,
|
|
23
|
-
`,
|
|
24
|
-
`,"cache notice")}printCacheDisabledByTask(e){this.#l(`${e.id}: caching disabled by task via disableCache()`)}printSelfModifyingSkip(e,s){this.#l(`${e.id}: caching skipped — task modified its own input${s.length===1?"":"s"} (${s.join(", ")})`)}printDeclaredFallback(e){We(e,this.#a)!=="quiet"&&this.#l(
|
|
25
|
-
`,"run summary");const
|
|
26
|
-
`,"run summary")}}const
|
|
27
|
-
`);for(const
|
|
21
|
+
`,"run header")}startTasks(e){const s=process.stdout.columns||80;for(const n of e){const r=le(X.createElement(f,null,X.createElement(f,{dimColor:!0},">"),` ${n.id}`),{columns:s});se(`${r}
|
|
22
|
+
`,n.id)}}endTasks(e){const s=process.stdout.columns||80;for(const n of e){this.#o.set(n.task.id,n),n.status==="failure"?this.#r.push(n):ye(n.status)&&this.#t.push(n),n.retryAttempts&&n.retryAttempts>0&&this.#i.push(n);const r=ke(n.status),o=n.startTime&&n.endTime?` (${we(n.endTime-n.startTime)})`:"",i=ye(n.status)?" [cache]":"",l=n.retryAttempts&&n.retryAttempts>0?` [retried ${n.retryAttempts}x]`:"",d=le(X.createElement(f,null,r,` ${n.task.id}`,i?X.createElement(f,{color:"cyan"},i):null,l?X.createElement(f,{color:"yellow"},l):null,o?X.createElement(f,{dimColor:!0},o):null),{columns:s});se(`${d}
|
|
23
|
+
`,n.task.id)}}#l(e){const s=process.stdout.columns||80,n=le(X.createElement(f,{dimColor:!0},` ⓘ ${e}`),{columns:s});se(`${n}
|
|
24
|
+
`,"cache notice")}printCacheDisabledByTask(e){this.#l(`${e.id}: caching disabled by task via disableCache()`)}printSelfModifyingSkip(e,s){this.#l(`${e.id}: caching skipped — task modified its own input${s.length===1?"":"s"} (${s.join(", ")})`)}printDeclaredFallback(e){We(e,this.#a)!=="quiet"&&this.#l(Zt(e))}printEmptyFingerprintWarning(e,s){this.#l(`${e.id}: caching skipped — ${s}`)}printTaskTerminalOutput(e,s,n){if(We(e,this.#a)==="quiet"&&(s==="success"||ye(s)))return;const r=s==="failure"?Yt(n,{color:!process.env.NO_COLOR,cwd:process.cwd()}):n;if(this.#c){this.#c.printTaskTerminalOutput(e,s,r);return}Ur(e.id,s,r,this.#d)}endCommand(){const e=we(Date.now()-this.#u),s=this.#s.filter(o=>!this.#o.has(o.id)).map(o=>o.id);se(`
|
|
25
|
+
`,"run summary");const n=process.stdout.columns||80,r=le(X.createElement(Vt,{cached:this.#t.length,failed:this.#r.length,failedIds:this.#r.map(o=>o.task.id),projectNames:this.#e,retriedIds:this.#i.length>0?this.#i.map(o=>o.task.id):void 0,skippedIds:s.length>0?s:void 0,succeeded:this.#o.size-this.#r.length-this.#t.length,targets:this.#n,tasks:this.#s,took:e}),{columns:n});se(`${r}
|
|
26
|
+
`,"run summary")}}const oi=t=>{const{args:e,autoExit:s=!1,onRetryService:n,outputStyle:r="normal",projectNames:o,serviceDockStore:i,stdinRegistry:l,tasks:d,totalTaskCount:h}=t,u=new Pe(d,h),p=typeof e.parallel=="number"?e.parallel:3,a=s===!0?3:typeof s=="number"?s:0,m=new Map,y=($,E)=>{const b=m.get($);b?b.push(E):m.set($,[E])};let g,S;const v=new Promise($=>{S=$});let w;const k=()=>{w&&(clearInterval(w),w=void 0)},O=()=>{if(process.stdin.isTTY&&typeof process.stdin.setRawMode=="function")try{process.stdin.setRawMode(!1)}catch{}process.stdin.pause(),process.stdin.unref()},I=()=>{if(l){for(const $ of l.values())$.kill?.();l.clear()}},x=()=>{k(),C(),I(),O(),process.stdout.write("\x1B[?1049l\x1B[?25h"),g?.cleanup(),process.exit(1)},D=()=>{const $=u.getSnapshot(),E=we(Date.now()-$.startTime),b=$.rows.filter(L=>L.status==="failure").map(L=>L.taskId),F=process.stdout.columns||80;process.stdout.write(`
|
|
27
|
+
`);for(const L of $.rows){const{persistent:_,status:W,taskId:q}=L,G=W==="running"||W==="pending",J=xe(W),z=G&&_?"■":J.icon,Z=G&&_?"gray":J.color;let te="";switch(W){case"local-cache":case"local-cache-kept-existing":{te=" [local cache]";break}case"remote-cache":{te=" [remote cache]";break}case"skipped":{te=" [skipped]";break}default:{G&&_?te=" [stopped]":G&&(te=" [skipped]");break}}const K=L.retryAttempts&&L.retryAttempts>0?` [retried ${L.retryAttempts}x]`:"",N=le(X.createElement(f,null," ",X.createElement(f,{color:Z},z),` vis run ${q}`,te?X.createElement(f,{dimColor:!0},` ${te}`):null,K?X.createElement(f,{color:"yellow"},K):null),{columns:F});process.stdout.write(`${N}
|
|
28
28
|
`)}process.stdout.write(`
|
|
29
|
-
`);const B=le(X.createElement(
|
|
30
|
-
`),
|
|
31
|
-
`,X.createElement(f,{bold:!0,color:q},` ${G} vis run ${_.taskId}`)),{columns:
|
|
29
|
+
`);const B=le(X.createElement(Vt,{cached:$.cached,failed:$.failed,failedIds:b,projectNames:o,retriedIds:$.retriedIds.length>0?$.retriedIds:void 0,succeeded:$.succeeded,targets:e.targets,tasks:d,took:E}),{columns:F});if(process.stdout.write(`${B}
|
|
30
|
+
`),r!=="quiet"){const L=[...$.rows.filter(_=>_.status!=="failure"),...$.rows.filter(_=>_.status==="failure")];for(const _ of L){if(_.status==="running"||_.status==="pending")continue;const W=$.outputs.get(_.taskId);if(!W?.trim())continue;const{color:q,icon:G}=xe(_.status),J=le(X.createElement(f,null,`
|
|
31
|
+
`,X.createElement(f,{bold:!0,color:q},` ${G} vis run ${_.taskId}`)),{columns:F});process.stdout.write(`${J}
|
|
32
32
|
|
|
33
33
|
`);const z=W.trim().split(`
|
|
34
34
|
`).map(Z=>` ${Z}`).join(`
|
|
35
35
|
`);process.stdout.write(`${z}
|
|
36
|
-
`)}}};let P;const
|
|
37
|
-
`)},printDeclaredFallback(
|
|
38
|
-
`)},printEmptyFingerprintWarning(
|
|
39
|
-
`)},printSelfModifyingSkip(
|
|
40
|
-
`)},printTaskTerminalOutput(
|
|
41
|
-
`;
|
|
36
|
+
`)}}};let P;const C=()=>{P&&(clearInterval(P),P=void 0)};return{lifeCycle:{endCommand(){k(),u.markDone(),P||(P=setInterval(()=>{},1e3))},endTasks($){u.endTasks($);for(const E of $){const b=m.get(E.task.id);if(b){m.delete(E.task.id);for(const F of b)u.addOutput(E.task.id,F)}}},printCacheDisabledByTask($){y($.id,`ⓘ caching disabled by task via disableCache()
|
|
37
|
+
`)},printDeclaredFallback($){We($,r)!=="quiet"&&y($.id,`ⓘ ${Zt($)}
|
|
38
|
+
`)},printEmptyFingerprintWarning($,E){y($.id,`ⓘ caching skipped — ${E}
|
|
39
|
+
`)},printSelfModifyingSkip($,E){y($.id,`ⓘ caching skipped — task modified its own input${E.length===1?"":"s"} (${E.join(", ")})
|
|
40
|
+
`)},printTaskTerminalOutput($,E,b){u.getSnapshot().outputs.has($.id)||u.addOutput($.id,b)},startCommand(){process.on("SIGINT",x),process.on("SIGTERM",x),P||(P=setInterval(()=>{},1e3)),g=Es(X.createElement(si,{autoExitSeconds:a,onRetryService:n,parallelSlots:p,projectNames:o,serviceDockStore:i,stdinRegistry:l??new Map,store:u,targets:e.targets,tasks:d}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}),g.waitUntilExit().then(()=>{C(),I(),O(),process.removeListener("SIGINT",x),process.removeListener("SIGTERM",x),D(),S()}).catch(()=>{C(),I(),O(),process.removeListener("SIGINT",x),process.removeListener("SIGTERM",x),S()})},startTasks($){u.startTasks($),w||(w=setInterval(()=>{u.tick()},100))}},renderIsDone:v,store:u}},ci=t=>{const{killGracePeriodMs:e=5e3,onTimeout:s,sendSignal:n,timeoutMs:r}=t;if(r<=0)return{cancel:()=>{}};const o=Math.max(e,0);let i;const l=setTimeout(()=>{s?.(),n("SIGTERM"),o>0&&(i=setTimeout(()=>{n("SIGKILL")},o))},r);return{cancel:()=>{clearTimeout(l),i&&clearTimeout(i)}}},ai=async(t,e,s)=>{if(!e)return s();const n=t.get(e)??Promise.resolve();let r;const o=new Promise(l=>{r=l}),i=n.then(()=>o);t.set(e,i),await n;try{return await s()}finally{r(),t.get(e)===i&&t.delete(e)}},li=t=>{let e=Math.max(0,Math.floor(t));return{claim(s){const n=Math.max(0,Math.min(s,e));return e-=n,n},get remaining(){return e}}},es=t=>async(e,s)=>{const{hooks:n,lifeCycle:r,mutexPool:o,onOutput:i,onOutputReplace:l,resolveCommand:d,retryBudget:h,serviceEventBridge:u,spawnContext:p,stdinRegistry:a,strictEnvFailure:m,workspaceRoot:y}=t,g=Se(e),S=Ue(y,s.cwd??e.projectRoot,g?.runFromWorkspaceRoot===!0),v=d(e);if(!v)return{code:0,terminalOutput:`No command configured for ${e.target.project}:${e.target.target}`};const w=Te(p,e,s),k=m(e,v,s);if(k!==void 0)return r?.onTaskStderr?.(e,k),{code:1,terminalOutput:k};const O=g?.pty===!0,I=!!a,x=e.pty===!0?!0:e.pty===!1?!1:I||O;x&&(e.cache=!1);const D=x?void 0:new ur(Re),P=x?new He(Re):void 0;let C;const M=E=>{if(E.kind==="started"&&(C=E.kill,E.write&&a&&a.set(e.id,{kill:E.kill,resize:E.resize,write:E.write}),u?.onRegistryTaskStarted(e.id)),(E.kind==="stdout"||E.kind==="stderr")&&E.text!==void 0)if(E.kind==="stdout"?r?.onTaskStdout?.(e,E.text):r?.onTaskStderr?.(e,E.text),P)P.write(E.text),I&&l?.(e.id,P.toString()),u&&u.onTaskOutput(e.id,E.text);else{const b=`${E.text}
|
|
41
|
+
`;D.append(b),i?.(e.id,b)}E.kind==="close"&&(a&&a.delete(e.id),u&&u.onRegistryTaskClosed(e.id,E.exitCode??0,!!E.killed).catch(()=>{}))},$=async()=>{const E=g?.retryCount??0,b=g?.retryDelay,F=h?h.claim(E):E,B=typeof g?.timeout=="number"&&g.timeout>0?g.timeout:0,L=typeof g?.killGracePeriodMs=="number"&&g.killGracePeriodMs>=0?g.killGracePeriodMs:5e3;let _=!1,W=0;const q=ci({killGracePeriodMs:L,onTimeout:()=>{_=!0},sendSignal:Z=>{C?.(Z)},timeoutMs:B});let G;try{G=await Ce([{command:v,cwd:S,env:w.env,inheritEnv:w.inheritEnv,name:e.id,...x?{ptySize:{cols:process.stdout.columns??80,rows:process.stdout.rows??24},stdin:"pty"}:{}}],{killOthers:["failure"],onEvent:M,...F>0?{restart:{delay:b??"exponential",onRetry:async(Z,te,K)=>{W=Z,n&&await n.callHook("task:retry",e,Z,K)},tries:F}}:{}})}finally{q.cancel()}const J=G.closeEvents[0],z=P?P.toString():D.toString();return _?{code:124,retryAttempts:W,terminalOutput:`${z}
|
|
42
42
|
[timeout] Task "${e.id}" exceeded ${B}ms budget.
|
|
43
|
-
`}:{code:J?.exitCode??1,retryAttempts:W,terminalOutput:z}};return o?
|
|
43
|
+
`}:{code:J?.exitCode??1,retryAttempts:W,terminalOutput:z}};return o?ai(o,g?.mutex,$):$()},di=({injectedServiceIdSet:t,runtime:e,serviceDockStore:s,serviceEventBridge:n,workspaceRoot:r})=>{const{failureLogLifeCycle:o,hookLifeCycle:i,hooks:l,lifecycleOptions:d,outputStyle:h,resolveCommand:u,sharedRetryBudget:p,spawnContext:a,strictEnvFailure:m}=e,y=new Map,g=oi({...d,onRetryService:n?I=>n.retry(I):void 0,outputStyle:h,serviceDockStore:s,stdinRegistry:y}),{lifeCycle:S,store:v}=g,w=new $t([S,i,o]),O=es({hooks:l,lifeCycle:w,mutexPool:new Map,onOutput:(I,x)=>{n&&t.has(I)?n.onTaskOutput(I,x):v.addOutput(I,x)},onOutputReplace:(I,x)=>{v.setOutput(I,x)},resolveCommand:u,retryBudget:p,serviceEventBridge:n??void 0,spawnContext:a,stdinRegistry:y,strictEnvFailure:m,workspaceRoot:r});return{dynamic:g,lifeCycle:w,stdinRegistry:y,store:v,taskExecutor:O}},ui=async({dynamic:t,initialTasks:e,lifeCycle:s,options:n,persistentTasks:r,projectGraph:o,runtime:i,stdinRegistry:l,store:d,taskExecutor:h,taskGraph:u,workspaceRoot:p})=>{const{childEnvPolicyFor:a,preTraceCheck:m,resolveCommand:y,runnerOptions:g,spawnContext:S}=i,v=await Ct(e,g,{childEnvPolicy:a,lifeCycle:s,preTraceCheck:m,projectGraph:o,resolveChildEnv:(w,k)=>Te(S,w,k),resolveCommand:y,taskExecutor:h,taskGraph:u,workspaceRoot:p});if(r.length>0&&!n.failFast){const w=new Promise(k=>{const O=d.subscribe(()=>{const I=d.getSnapshot();(I.rerunRequested||I.retryTaskId)&&(O(),k())});t.renderIsDone.then(()=>{O(),k()}).catch(()=>{O(),k()})});await Ut(r,S,{abortSignal:w,lifeCycle:s,stdinRegistry:l,store:d})}return v},fi=async({dynamic:t,store:e})=>{let s=null;return{action:await new Promise(r=>{const o=e.subscribe(()=>{const i=e.getSnapshot();i.rerunRequested&&(e.acknowledgeRerun(),o(),r("rerun")),i.retryTaskId&&(s=e.acknowledgeRetry(),o(),r("retry"))});t.renderIsDone.then(()=>{o(),r("quit")}).catch(()=>{o(),r("quit")})}),retryTaskId:s}},ue="@voidzero-dev/vite-task-client",Je="@visulima/task-runner-client",Me=`npm:${Je}@^1`,ts=ie(".vis",".vite-client-override-declined"),Oe="pnpm-workspace.yaml",hi=["dependencies","devDependencies","optionalDependencies","peerDependencies"],ss=t=>{try{return JSON.parse(ve(t,"utf8"))}catch{return}},pi=t=>{const e=ie(t,Oe);if(ge(e))try{return _t(ve(e,"utf8")).toJS()?.overrides}catch{return}},mi=t=>t==="pnpm"||t==="aube"?"pnpm.overrides":t==="yarn"?"resolutions":"overrides",gi=t=>{const e=ie(t,Oe);try{const s=_t(ve(e,"utf8"));return s.setIn(["overrides",ue],Me),Ve(e,s.toString()),!0}catch{return!1}},xt=t=>t!==void 0&&hi.some(e=>t[e]?.[ue]!==void 0),wi=(t,e)=>t!==void 0&&(t.pnpm?.overrides?.[ue]!==void 0||t.overrides?.[ue]!==void 0||t.resolutions?.[ue]!==void 0)||e?.[ue]!==void 0,yi=(t,e=[])=>{const s=ss(ie(t,"package.json")),n=ge(ie(t,"node_modules","@voidzero-dev","vite-task-client"));return{alreadyOverridden:wi(s,pi(t)),declined:ge(ie(t,ts)),manager:Rn(t)?.manager,present:xt(s)||n||e.some(r=>xt(r))}},vi=t=>{try{const e=ie(t,ts);hn(Mt(e),{recursive:!0}),Ve(e,`Declined adding the ${ue} → ${Je} override.
|
|
44
44
|
Delete this file to be asked again.
|
|
45
|
-
`)}catch{}},
|
|
46
|
-
`)}catch{return}return{file:"package.json",installCommand:s}},
|
|
47
|
-
${a(
|
|
48
|
-
`;await Ae(e,s)},
|
|
49
|
-
`)},
|
|
50
|
-
`)},
|
|
45
|
+
`)}catch{}},xi=(t,e="npm")=>{const s=`${e} install`;if((e==="pnpm"||e==="aube")&&ge(ie(t,Oe))&&gi(t))return{file:Oe,installCommand:s};const n=ie(t,"package.json"),r=ss(n);if(!r)return;const o=mi(e);o==="pnpm.overrides"?(r.pnpm??={},r.pnpm.overrides??={},r.pnpm.overrides[ue]=Me):(r[o]??={},r[o][ue]=Me);try{Ve(n,`${JSON.stringify(r,void 0,4)}
|
|
46
|
+
`)}catch{return}return{file:"package.json",installCommand:s}},ji=async(t,e)=>{const s=yi(t,e.projectManifests);if(!s.present||s.alreadyOverridden||s.declined)return!1;const n=Mn({input:process.stdin,output:process.stdout});try{e.logger.info(`Detected ${ue}. Its cache hints no-op under @visulima/task-runner unless aliased to ${Je} (a drop-in replacement).`);const r=await new Promise(i=>{n.question("Add the override now? [y/N] ",i)});if(!/^y(?:es)?$/i.test(r.trim()))return vi(t),e.logger.info("Skipped. Delete .vis/.vite-client-override-declined to be asked again."),!1;const o=xi(t,s.manager);return o===void 0?(e.logger.warn("Could not write the override automatically — add it manually (see @visulima/task-runner-client README)."),!1):(e.logger.info(`Added "${ue}": "${Me}" to ${o.file}. Run \`${o.installCommand}\` to apply it.`),!0)}finally{n.close()}},ki=async({config:t,logger:e,options:s,packageJsons:n,workspaceRoot:r})=>{await Fn(r,t.toolchain,{error:l=>{e.error(l)},info:l=>{e.info(l)},warn:l=>{e.warn(l)}},!!s.skipToolchain);const o=s.preflight!==!1&&t.preflight?.lockfile!==!1,i=Pn(r,be,{warn:l=>{e.warn(l)}},{skip:!o});if(!i.shouldContinue)throw new Error(`${i.formattedMessage??"preflight: lockfile drift detected"} (pass --no-preflight to bypass)`);o&&!be&&process.stdin.isTTY&&process.stdout.isTTY&&await ji(r,{interactive:!0,logger:{info:l=>{e.info(l)},warn:l=>{e.warn(l)}},projectManifests:[...n.values()]})},Si=/\$(?:\{([A-Z_]\w*)(:-[^}]*)?\}|([A-Z_]\w*))/gi,bi=new Set(["0","!","#","$","*","-","?","@","_"]),Ti=t=>{const e=new Map;for(const s of t.matchAll(Si)){const n=s[1],r=s[3],o=s[2],i=n??r;if(i===void 0||bi.has(i))continue;const l=o!==void 0,d=e.get(i);d===void 0?e.set(i,l):d&&!l&&e.set(i,!1)}return[...e.entries()].map(([s,n])=>({hasDefault:n,name:s}))},$i=t=>{const{command:e,processEnv:s,taskEnv:n,taskId:r}=t,o=Ti(e);if(o.length===0)return;const i=[];for(const{hasDefault:l,name:d}of o){if(l)continue;const h=n[d],u=s[d];h===void 0&&u===void 0&&i.push(d)}if(i.length!==0)return{missing:i.toSorted(),taskId:r}},Ci=t=>{const e=t.missing.map(s=>`$${s}`).join(", ");return`Strict env: ${t.taskId} references unset variable${t.missing.length===1?"":"s"} ${e}. Set ${t.missing.length===1?"it":"them"} in the task env, an envFile, or the parent shell — or opt out with options.strictEnv: false.`},Ii=async({configTaskRunner:t,logger:e,options:s,runnerOptions:n,workspaceRoot:r})=>{const o=fs(t.remoteCache);if(o){const i=pr(s.cacheMode),l=mr(s.cacheBackend);n.remoteCache={...o,...i?{mode:i}:{},...l?{backend:l}:{}};const d=n.remoteCache.onUploadError;if(n.remoteCache.onUploadError=(h,u)=>{d?.(h,u),e.debug?.(`[vis run] remote cache error (${h}): ${u instanceof Error?u.message:String(u)}`)},n.remoteCache.attestation){const{expectedIdentity:h,requireOnDownload:u}=n.remoteCache.attestation;if(!(h!==void 0&&("github"in h&&typeof h.github?.ref=="string"&&typeof h.github.repo=="string"&&typeof h.github.workflow=="string"||"oidcIssuer"in h&&typeof h.oidcIssuer=="string"&&(typeof h.san=="string"||typeof h.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 h&&(!h.sanRegex.startsWith("^")||!h.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:a,isSigstoreInstalled:m}=await import("./loader.js");m()||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:
|
|
47
|
+
${a(r)}`);const{buildCacheAttestationHooks:y}=await import("./cache-attestation.js");n.remoteCache.attestation=y({expectedIdentity:h,onReject:(g,S)=>{e.warn(`[vis run] remote cache entry ${g.slice(0,12)} rejected: attestation ${S}. Treating as a cache miss.`)},onVerifyFailure:g=>{e.warn(`[vis run] attestation verification failed: ${g}`)},requireOnDownload:u,workspaceRoot:r})}}else(s.cacheMode||s.cacheBackend)&&e.warn("[vis run] --cache-mode and --cache-backend require a `remoteCache` block in vis.config.ts (or TURBO_API env); ignoring.")},Ei=async({affectedFiles:t,config:e,currentOs:s,initialTasks:n,invocationCwd:r,logger:o,options:i,persistentTasks:l,projectsWithTarget:d,runCacheDirectory:h,serviceEnvByTaskId:u,serviceResult:p,target:a,taskGraph:m,visConfig:y,workspaceRoot:g})=>{const S=Date.now(),v=Us(),w=(N,H)=>{const V=H instanceof Error?H.message:String(H);o.warn(`Plugin error in ${N}: ${V}`)};await Vs(v,e.plugins);const k=typeof i.profile=="string"?i.profile:void 0,O=async N=>{if(!k)return;const H=It(N,m,S),V=k.startsWith("/")?k:`${g}/${k}`;await ps(H,V),o.info(`Profile written to ${k}`)},I=e.taskRunner??{},x=fr(process.env.VIS_RUN_CONCURRENCY_LIMIT);x&&"invalid"in x&&o.warn(`VIS_RUN_CONCURRENCY_LIMIT=${x.invalid} is not a positive number; falling back to default concurrency.`);const D=x&&"value"in x?x.value:void 0,P=i.parallel??D??3,C=i.strictEnv??e.strictEnv??!1,M=new Set,$={dryRun:i.dryRun??!1,parallel:P,skipNxCache:!i.cache,summarize:i.summarize??!1,...I,cacheDirectory:h,dataDirectory:I.dataDirectory??Ie(g),namedInputs:e.namedInputs,onDiagnostic:(N,H)=>{M.has(N)||(M.add(N),o.warn(H))},onFingerprint:async(N,H)=>{await v.callHook("task:fingerprint",N,H)}},E=N=>an($.env,Se(N)?.env),b=cn({affectedFiles:t,childEnvPolicy:E,initCwd:r,serviceEnvByTaskId:u,taskSlots:P,workspaceRoot:g}),F=N=>Ke(N,t,s),B=(N,H,V)=>{if(!(Se(N)?.strictEnv??C))return;const oe=Te(b,N,V),he=b.childEnvPolicy(N),de=$i({command:H,processEnv:he.mode==="clean"?hs(process.env,he):process.env,taskEnv:oe.env,taskId:N.id});return de?Ci(de):void 0},L=(N,H)=>{const V=F(N);return V===void 0?void 0:B(N,V,H)};await Ii({configTaskRunner:I,logger:o,options:i,runnerOptions:$,workspaceRoot:g});const _=process.stdout.isTTY&&!be,W=y?.run?.quietOnSuccess===!0,q=e.tui?.autoExit??(W?3:!1),G={args:{parallel:$.parallel,targets:[a]},autoExit:q,projectNames:d,tasks:[...n,...l].flatMap(N=>{const H=Object.values(m.tasks).filter(V=>V.segment!==void 0&&V.id.startsWith(`${N.id}#`));return H.length>0?H:[N]}),totalTaskCount:Object.keys(m.tasks).length+l.length},J=typeof i.retryBudget=="number"?i.retryBudget:void 0,z=J===void 0?void 0:li(J),Z=new zs(v,w),te=new An(g),K=ri(i.outputStyle,y?.run?.quietOnSuccess);if(p.satisfiedServices.length>0)for(const N of p.satisfiedServices){const H=p.serviceDependentsByServiceId.get(N.id)??[];try{await v.callHook("service:attach",N,H)}catch(V){w("service:attach",V)}}return{childEnvPolicyFor:E,failureLogLifeCycle:te,hookLifeCycle:Z,hooks:v,isTTY:_,lifecycleOptions:G,maybeWriteProfile:O,outputStyle:K,preTraceCheck:L,resolveCommand:F,runnerOptions:$,sharedRetryBudget:z,spawnContext:b,startTime:S,strictEnvFailure:B}},Ri=async t=>{if(process.env.VIS_NO_SHELL_HISTORY)return;if(zn()==="win32"){try{await Oi(t)}catch{}return}const e=process.env.SHELL;if(!e)return;const s=tn(e);try{if(s==="zsh"){await Pi(t);return}if(s==="bash"){await Mi(t);return}s==="fish"&&await Fi(t)}catch{}},Qe=t=>t.replaceAll(/[\u0000-\u001F\u007F]/gu," ").trimEnd(),Pi=async t=>{const e=process.env.HISTFILE??ie(process.env.ZDOTDIR??ze(),".zsh_history"),s=`: ${Math.floor(Date.now()/1e3)}:0;${Qe(t)}
|
|
48
|
+
`;await Ae(e,s)},Mi=async t=>{const e=process.env.HISTFILE??ie(ze(),".bash_history");await Ae(e,`${Qe(t)}
|
|
49
|
+
`)},Oi=async t=>{const e=process.env.VIS_PSREADLINE_HISTORY,s=process.env.APPDATA;if(e===void 0&&(s===void 0||s===""))return;const n=e??ie(s,"Microsoft","Windows","PowerShell","PSReadLine","ConsoleHost_history.txt");await Vn(Mt(n),{recursive:!0}),await Ae(n,`${Qe(t)}\r
|
|
50
|
+
`)},Fi=async t=>{const e=ie(ze(),".local","share","fish","fish_history"),n=`- cmd: ${t.replaceAll("\\","\\\\").replaceAll(`
|
|
51
51
|
`,String.raw`\n`).replaceAll("\r",String.raw`\r`)}
|
|
52
52
|
when: ${Math.floor(Date.now()/1e3)}
|
|
53
|
-
`;await Ae(e,
|
|
54
|
-
`))}return{projectsWithTarget:d,projectTargetIndex:h}},
|
|
55
|
-
Did you mean: vis run ${e} --affected ${
|
|
56
|
-
Or use the dedicated command: vis affected ${e} …`)}},
|
|
57
|
-
|
|
58
|
-
Pass --if-present to skip quietly when nothing matches.`)};if(e.filter&&e.filter.length>0){const
|
|
59
|
-
`).filter(Boolean):void 0),P=
|
|
60
|
-
`).map(
|
|
61
|
-
`),i=o.pop()??"";this.#t.set(e,i);for(const l of o)this.#d(e,l)}notifyRegistryStarting(e){this.#s.starting(e)}notifyRegistryStarted(e,s){this.#s.started(e,s)}onRegistryTaskStarted(e){this.#
|
|
62
|
-
`)}#u(e,s){let
|
|
63
|
-
`);return}switch(
|
|
64
|
-
`)}}#l(e){const s=this.#
|
|
65
|
-
`))l.length!==0&&this.#w(e,l);this.#s.log(e,i)}}catch{}}#w(e,s){const
|
|
66
|
-
`),i=o.pop()??"";this.#t.set(e,i);for(const l of o)this.#d(e,l)}async#
|
|
53
|
+
`;await Ae(e,n)},Ai=t=>t.startsWith("./")||t.startsWith("../")||t.startsWith("/")||t.startsWith("**"),Di=t=>{let e=t.trim();if(e==="")return;let s=!1,n=!1,r=!1;e.startsWith("...")&&(s=!0,e=e.slice(3),e.startsWith("^")&&(r=!0,e=e.slice(1))),e.endsWith("...")&&(n=!0,e=e.slice(0,-3),e.endsWith("^")&&(r=!0,e=e.slice(0,-1)));let o;const i=/\[([^\]]*)\]$/.exec(e);i&&(o=i[1]??"",e=e.slice(0,i.index));let l=e.trim(),d=!1;return l.startsWith("{")&&l.endsWith("}")&&l.length>=2?(l=l.slice(1,-1),d=!0):Ai(l)&&(d=!0),{changedSince:o,excludeSelf:r,includeDependencies:n,includeDependents:s,isPath:d,pattern:l}},Ge=t=>{let e=t.replaceAll("\\","/");return e.startsWith("./")&&(e=e.slice(2)),e.length>1&&e.endsWith("/")&&(e=e.slice(0,-1)),e},Li=(t,e,s)=>t===""?!1:_e(t,e)?!0:s!==void 0&&_e(t,s),Bi=(t,e)=>{if(e===void 0||e==="")return!1;const s=Ge(t),n=Ge(e);return _e(s,n)},_i=(t,e,s)=>{const{affected:n,downstream:r,upstream:o}=ms(t,s,{downstream:e.includeDependents?"deep":"none",upstream:e.includeDependencies?"deep":"none"});if(!e.excludeSelf)return n;const i=new Set([...r,...o]);for(const l of t)i.delete(l);return i},Ni=async(t,e)=>{const{packageNameByProject:s,projectGraph:n}=e,r=Object.keys(n.nodes);let o=new Set;if(t.pattern!=="")for(const i of r)t.isPath?Bi(t.pattern,n.nodes[i]?.data.root)&&o.add(i):Li(t.pattern,i,s?.get(i))&&o.add(i);if(t.changedSince!==void 0){const i=t.changedSince===""?e.defaultBase??"main":t.changedSince,l=e.changedProjectsForRef??Wi(e),d=new Set(await l(i));o=t.pattern===""?d:new Set([...o].filter(h=>d.has(h)))}return!t.includeDependents&&!t.includeDependencies?o:_i(o,t,n)},Wi=t=>async e=>{const{projectGraph:s,workspaceRoot:n}=t;if(!n)return[];let r;try{r=await gs(n,e,"HEAD")}catch(i){const l=i instanceof Error?i.message:String(i);throw new Error(`vis run --filter: invalid changed-since ref "${e}" (${l})`,{cause:i})}const o=new Set;for(const[i,l]of Object.entries(s.nodes)){const d=Ge(l.data.root??i);if(!(d===""||d==="."))for(const h of r){const u=sn(n,h).replaceAll("\\","/");if(u===d||u.startsWith(`${d}/`)){o.add(i);break}}}return[...o]},Gi=async(t,e)=>{const s=new Set;for(const n of t)for(const r of await Ni(n,e))s.add(r);return[...s]},Hi=async(t,e)=>{const s=[];for(const n of t){const r=Di(n);r&&s.push(r)}return Gi(s,e)},qi=({logger:t,options:e,projectNames:s,projectOptions:n,target:r,workspace:o})=>{const i=(typeof e.runnerTags=="string"?e.runnerTags:process.env.VIS_RUNNER_TAGS)??void 0,l=i?new Set(i.split(",").map(u=>u.trim()).filter(Boolean)):void 0,d=[],h=new Map;for(const u of s){const a=n.get(u)?.[r];if(!a)continue;const m=a.options;if(!m?.internal){if(!nn(m,!!be)){t.debug?.(`Skipping ${u}:${r} — runInCI filter`);continue}if(!rn(m,l)){t.debug?.(`Skipping ${u}:${r} — runner-tags filter`);continue}d.push(u),h.set(u,a)}}if(d.length===0){if(e.ifPresent){t.info(`No projects have the "${r}" target; skipping (--if-present).`);return}const u=Nt(o),p=Object.entries(o.projects).filter(([,m])=>m.targets?.[r]!==void 0).map(([m])=>m),a=[`No projects have the "${r}" target.`];if(p.length>0)a.push("",`Target "${r}" exists in these projects but was filtered out:`,...p.slice(0,5).map(m=>` - ${m}`)),p.length>5&&a.push(` …and ${p.length-5} more`);else{const m=Dn(r,u,3);m.length>0&&a.push("",m.length===1?`Did you mean "${m[0]}"?`:`Did you mean one of: ${m.map(y=>`"${y}"`).join(", ")}?`),a.push("","Run `vis run` without arguments to see all available targets, or pass --if-present to skip when no project has the target.")}throw new fe(a.join(`
|
|
54
|
+
`))}return{projectsWithTarget:d,projectTargetIndex:h}},Ui=async({argument:t,logger:e,workspace:s})=>{let n=t[0];if(!n){const r=Nt(s);if(process.stdout.isTTY&&process.stdin.isTTY){const o=await Ln(r);if(!o){e.info("No target selected.");return}n=o,await Ri(`vis run ${o}`)}else throw e.info("Available targets:"),e.info(""),e.info(Bn(r)),e.info(""),new fe("Missing target. Usage: vis run <target>")}return n},Vi=({config:t,logger:e,options:s,projectGraph:n})=>{if(t.constraints&&!s.skipConstraints){const r=ws(n,t.constraints);if(r.length>0){for(const o of r)e.error(`[${o.rule}] ${o.message}`);throw new Error(`${r.length} project constraint violation(s) found. Use --skip-constraints to bypass.`)}}},zi=({options:t,rawSelector:e})=>{if(!t.affected){const s=t.uncommitted?"--uncommitted":"--no-uncommitted",n=[["--base",t.base],["--head",t.head],["--downstream",t.downstream],["--upstream",t.upstream],[s,t.uncommitted]].filter(([,r])=>r!==void 0).map(([r])=>r);if(n.length>0)throw new fe(`${n.join(", ")} ${n.length===1?"requires":"require"} --affected.
|
|
55
|
+
Did you mean: vis run ${e} --affected ${n.map(r=>r.includes("uncommitted")?r:`${r}=…`).join(" ")}
|
|
56
|
+
Or use the dedicated command: vis affected ${e} …`)}},Yi=async({logger:t,options:e,packageJsons:s,projectGraph:n,projectOptions:r,rawSelector:o,visConfig:i,workspace:l,workspaceRoot:d})=>{const h=await Gn(o,l,process.cwd(),d),u=_n(r),p=Nn(h.target,u);p!==h.target&&t.debug?.(`Resolved alias "${h.target}" → "${p}"`);let a=h.projects;e.projects!==void 0&&(a=Wn(a,String(e.projects),Object.keys(l.projects)));const m=y=>{if(e.ifPresent){t.info(`${y}; skipping (--if-present).`);return}throw new fe(`${y}.
|
|
57
|
+
|
|
58
|
+
Pass --if-present to skip quietly when nothing matches.`)};if(e.filter&&e.filter.length>0){const y=new Map;for(const[v,w]of s)y.set(v,w.name);const g=await Hi(e.filter,{defaultBase:i?.defaultBase,packageNameByProject:y,projectGraph:n,workspaceRoot:d}),S=new Set(g);if(a=a.filter(v=>S.has(v)),a.length===0){m(`Filter ${e.filter.map(v=>`"${v}"`).join(", ")} matched no projects`);return}}if(e.query&&(a=Hn(a,l,e.query),a.length===0)){m(`Query "${String(e.query)}" matched no projects`);return}if(e.tag&&e.tag.length>0&&(a=qn(a,l,e.tag),a.length===0)){m(`Tag filter ${e.tag.map(y=>`"${y}"`).join(", ")} matched no projects`);return}return{projectNames:a,target:p}},Ki=async({cacheDirectory:t,fileOwners:e,logger:s,options:n,projectGraph:r,projectNames:o,visConfig:i,workspace:l,workspaceRoot:d})=>{let h=o,u,p,a;if(n.affected){const m=await Ns({base:n.base,downstream:n.downstream,head:n.head,uncommitted:n.uncommitted,upstream:n.upstream},{fileOwners:e,namedInputs:i?.namedInputs,projectGraph:r,projects:l.projects,workspaceRoot:d},{affectedIgnore:i?.affectedIgnore,defaultBase:i?.defaultBase,externalInputStatePath:t?ie(t,"external-inputs.json"):void 0,persistExternalInputState:!1});for(const S of m.notes)s.info(`▸ ${S}`);if(u=m.externalInputHashes,p=m.externalInputStatePath,m.changedFiles.length===0&&(m.changedExternalInputs?.length??0)===0){s.info("No files changed. Nothing to run.");return}const y=new Set(m.affectedProjects);if(h=h.filter(S=>y.has(S)),h.length===0){s.info("No projects affected by the changes.");return}const g=new Set(m.ignoredFiles);a=m.changedFiles.filter(S=>!g.has(S)),s.info(`Affected projects: ${h.join(", ")}`)}return{affectedChangedFiles:a,externalInputHashes:u,externalInputStatePath:p,projectNames:h}},Xi=async({argument:t,cacheDirectory:e,config:s,fileOwners:n,logger:r,options:o,packageJsons:i,projectGraph:l,projectOptions:d,visConfig:h,workspace:u,workspaceRoot:p})=>{const a=await Ui({argument:t,logger:r,workspace:u});if(a===void 0)return;Vi({config:s,logger:r,options:o,projectGraph:l}),zi({options:o,rawSelector:a});const m=await Yi({logger:r,options:o,packageJsons:i,projectGraph:l,projectOptions:d,rawSelector:a,visConfig:h,workspace:u,workspaceRoot:p});if(!m)return;const{target:y}=m,g=t.slice(1).map(String),S=await Ki({cacheDirectory:e,fileOwners:n,logger:r,options:o,projectGraph:l,projectNames:m.projectNames,visConfig:h,workspace:u,workspaceRoot:p});if(!S)return;const{affectedChangedFiles:v,externalInputHashes:w,externalInputStatePath:k,projectNames:O}=S,I=Ft(),x=process.env[ln],D=v??(x?x.split(`
|
|
59
|
+
`).filter(Boolean):void 0),P=qi({logger:r,options:o,projectNames:O,projectOptions:d,target:y,workspace:u});if(!P)return;const{projectsWithTarget:C,projectTargetIndex:M}=P;return{affectedExternalInputState:k&&w?{hashes:w,path:k}:void 0,affectedFiles:D,currentOs:I,forwardedArgs:g,projectsWithTarget:C,projectTargetIndex:M,target:y}},Ji=64*1024,jt=256,Qi=new RegExp("[\x1B]\\[[0-?]*[ -/]*[@-~]","g"),Le=t=>t.replaceAll(Qi,"").replaceAll("\r","");class kt{#e=[];#n=new Set;#s=new Map;#r=new Map;constructor(e=[]){for(const s of e)this.#r.set(s,{id:s,status:"pending",tailLines:[]});this.#e=[...e],this.#i()}getSnapshot=()=>this.#s;subscribe=e=>(this.#n.add(e),()=>{this.#n.delete(e)});getIds(){return this.#e}getState(e){return this.#r.get(e)}getDockState(){let e=!1,s=!1;for(const n of this.#r.values())n.status==="crashed"||n.status==="failed"?e=!0:(n.status==="pending"||n.status==="starting")&&(s=!0);return e?"crash":s?"boot":"ready"}registerService(e){this.#r.has(e)||(this.#r.set(e,{id:e,status:"pending",tailLines:[]}),this.#e=[...this.#e,e],this.#o())}markStarting(e){this.#t(e,s=>({...s,errorMessage:void 0,startedAt:s.startedAt??Date.now(),status:"starting"}))}markStarted(e,s){this.#t(e,n=>({...n,startedAt:n.startedAt??Date.now(),status:n.status==="ready"?"ready":"starting"}))}markReady(e,s){this.#t(e,n=>({...n,errorMessage:void 0,port:s.port,readyAt:Date.now(),status:"ready"}))}markFailed(e,s,n){const r=n?.message;this.#t(e,o=>({...o,errorMessage:Le(r??s),status:"failed"}))}markCrashed(e,s){const n=s.slice(-jt).map(r=>Le(r));this.#t(e,r=>({...r,errorMessage:n.length>0?n[n.length-1]:"process exited",status:"crashed",tailLines:n}))}appendLog(e,s){const n=s.split(`
|
|
60
|
+
`).map(r=>Le(r)).filter(r=>r.length>0);n.length!==0&&this.#t(e,r=>{const o=[...r.tailLines,...n];for(;o.length>jt;)o.shift();let i=0;for(let l=o.length-1;l>=0;l--)if(i+=o[l].length+1,i>Ji){o.splice(0,l+1);break}return{...r,lastLine:n[n.length-1],tailLines:o}})}abortBoot(e){let s=!1;const n=new Map(this.#r);for(const[r,o]of n)(o.status==="pending"||o.status==="starting")&&(n.set(r,{...o,errorMessage:e,status:"failed"}),s=!0);s&&(this.#r=n,this.#i(),this.#o())}#t(e,s){const n=this.#r.get(e);n&&(this.#r.set(e,s(n)),this.#i(),this.#o())}#i(){this.#s=new Map(this.#r)}#o(){for(const e of this.#n)try{e()}catch{}}}const Ze=t=>{const e=t.overrides.visOptions;return e&&typeof e=="object"?e:void 0},Zi=async t=>{const{initialTasks:e,probe:s,registeredEntries:n,taskGraph:r,visVersion:o}=t,i=new Map,l=new Map,d=new Map;for(const x of n)if(Ys(x.pid)){if(x.visVersion!==o){l.set(x.id,x);continue}i.set(x.id,x)}if(s){const x=[...i.values()],D=await Promise.all(x.map(async P=>{try{return[P.id,await s(P)]}catch{return[P.id,!1]}}));for(const[P,C]of D)if(!C){const M=i.get(P);i.delete(P),M&&d.set(P,M)}}const h=new Set(e.map(x=>x.id)),u=new Set,p=[],a=[],m=new Set;for(const x of Object.values(r.dependencies))for(const D of x)m.add(D);for(const[x,D]of Object.entries(r.tasks)){if(!Ze(D)?.service)continue;if(i.has(x)){u.add(x),a.push(i.get(x));continue}if(h.has(x)||!m.has(x))continue;const M=l.get(x),$=d.get(x);let E;M?E=`Service ${x} is registered with vis ${M.visVersion}, but this invocation is vis ${o}. Restart with \`vis service restart ${x}\` to pick up the new version.`:$?E=`Service ${x} is registered (PID ${String($.pid)}) but failed its readiness probe — the wrapper process is alive but the underlying server is not responding. Run \`vis service restart ${x}\` to recover.`:E=`Target depends on the service ${x}, which is not running. Run \`vis service start ${x}\` first, or invoke \`${x}\` directly.`,p.push({message:E,targetId:x})}if(u.size===0)return{diagnostics:p,initialTasks:e,satisfiedServices:a,serviceDependentsByServiceId:new Map,serviceEnvByTaskId:new Map,taskGraph:r};const y=new Map,g=x=>{const D=new Set,P=[...r.dependencies[x]??[]],C=new Set;for(;P.length>0;){const M=P.pop();if(!C.has(M)){C.add(M),u.has(M)&&D.add(M);for(const $ of r.dependencies[M]??[])C.has($)||P.push($)}}return[...D].sort()},S=new Map;for(const x of Object.keys(r.dependencies)){if(u.has(x))continue;const D=g(x);if(D.length===0)continue;const P={};for(const C of D){const M=i.get(C);if(!M)continue;Object.assign(P,M.env);const $=S.get(C);$?$.push(x):S.set(C,[x])}Object.keys(P).length>0&&y.set(x,P)}for(const x of S.values())x.sort();const v={};for(const[x,D]of Object.entries(r.tasks))u.has(x)||(v[x]=D);const w={};for(const[x,D]of Object.entries(r.dependencies))u.has(x)||(w[x]=D.filter(P=>!u.has(P)));const k=new Map;for(const x of Object.keys(v))k.set(x,0);for(const x of Object.values(w))for(const D of x)k.has(D)&&k.set(D,(k.get(D)??0)+1);const O=[];for(const x of r.roots)!u.has(x)&&v[x]&&O.push(x);for(const[x,D]of k)D===0&&!O.includes(x)&&v[x]&&O.push(x);const I=e.filter(x=>!u.has(x.id));return{diagnostics:p,initialTasks:I,satisfiedServices:a,serviceDependentsByServiceId:S,serviceEnvByTaskId:y,taskGraph:{dependencies:w,roots:O,tasks:v}}},$e="[[VIS_BOOT]]",eo=250,to=1e3,St=3,so=t=>{try{return process.kill(t,0),!0}catch{return!1}},bt=t=>{try{const e=ve(t,"utf8").trim(),s=Number.parseInt(e,10);return Number.isFinite(s)&&s>0?s:null}catch{return null}};class no{#e;#n;#s;#r;#t=new Map;#i=new Map;#o=new Map;#c=new Map;#a=new Set;constructor(e){this.#e=e.indexToId,this.#n=new Map(e.services),this.#s=e.sink,this.#r=e.workspaceRoot}onProcessEvent=e=>{if(e.kind!=="stdout"&&e.kind!=="stderr")return;const s=this.#e.get(e.index);s===void 0||e.text===void 0||this.onTaskOutput(s,e.text)};onTaskOutput(e,s){if(!this.#n.has(e))return;const o=((this.#t.get(e)??"")+s).split(`
|
|
61
|
+
`),i=o.pop()??"";this.#t.set(e,i);for(const l of o)this.#d(e,l)}notifyRegistryStarting(e){this.#s.starting(e)}notifyRegistryStarted(e,s){this.#s.started(e,s)}onRegistryTaskStarted(e){this.#n.get(e)?.mode==="registry"&&this.notifyRegistryStarting(e)}async onRegistryTaskClosed(e,s,n){if(this.#n.get(e)?.mode!=="registry")return;if(n||s!==0){this.notifyRegistryFailed(e,"exit-code",{exitCode:s,killed:n});return}const o=await Ks(this.#r,e);if(!o){this.notifyRegistryFailed(e,"missing-registry-entry");return}const{config:i}=o,l=i.readiness?.tcp?.port??i.port??0,d=i.readiness?.tcp?.host??"127.0.0.1";this.notifyRegistryReady(e,{host:d,logFile:o.logFile,pid:o.pid,port:l})}notifyRegistryReady(e,s){this.#s.ready(e,{host:s.host,port:s.port}),this.#h(e,s.logFile),s.pid!==null&&this.#p(e,s.pid)}notifyRegistryFailed(e,s,n){this.#s.failed(e,s,n)}async retry(e){const s=this.#n.get(e);if(s){if(this.#f(e),this.#t.delete(e),this.#i.delete(e),this.#s.starting(e),s.mode==="registry"){await this.#v(e,s.registry);return}s.mode==="ephemeral"&&this.#y(e,s.ephemeral)}}async dispose(){for(const e of[...this.#o.keys(),...this.#c.keys()])this.#f(e);this.#a.size>0&&(await Promise.race([Promise.all(this.#a),new Promise(e=>{setTimeout(e,2e3)})]),this.#a.clear()),this.#t.clear(),this.#i.clear()}#d(e,s){if(s.startsWith($e)){this.#u(e,s.slice($e.length));return}const n=this.#i.get(e)??[];n.push(s),n.length>St&&n.shift(),this.#i.set(e,n),this.#s.log(e,`${s}
|
|
62
|
+
`)}#u(e,s){let n;try{n=JSON.parse(s)}catch{this.#s.log(e,`${$e+s}
|
|
63
|
+
`);return}switch(n.event){case"failed":{const r=typeof n.reason=="string"?n.reason:"unknown",o={};for(const[i,l]of Object.entries(n))i!=="event"&&i!=="id"&&i!=="reason"&&(o[i]=l);this.#s.failed(e,r,o);break}case"ready":{const r=typeof n.host=="string"?n.host:"127.0.0.1",o=typeof n.port=="number"?n.port:0;this.#s.ready(e,{host:r,port:o}),this.#l(e);break}case"started":{const r=typeof n.pid=="number"?n.pid:null;this.#s.started(e,r);break}default:this.#s.log(e,`${$e+s}
|
|
64
|
+
`)}}#l(e){const s=this.#n.get(e);if(s?.ephemeral===void 0)return;this.#h(e,s.ephemeral.logFile);const n=bt(s.ephemeral.pidFile);n!==null&&this.#p(e,n)}#h(e,s){if(this.#o.has(e)||!ge(s))return;const n=pn(s,"r"),r=(()=>{try{return tt(s).size}catch{return 0}})(),o={fd:n,logFile:s,pollTimer:setInterval(()=>{this.#g(e)},eo),position:r};this.#o.set(e,o)}#g(e){const s=this.#o.get(e);if(s)try{const n=tt(s.logFile);if(n.size<=s.position)return;const r=Buffer.alloc(n.size-s.position),o=mn(s.fd,r,0,r.length,s.position);if(o>0){s.position+=o;const i=r.subarray(0,o).toString("utf8");for(const l of i.split(`
|
|
65
|
+
`))l.length!==0&&this.#w(e,l);this.#s.log(e,i)}}catch{}}#w(e,s){const n=this.#i.get(e)??[];for(n.push(s);n.length>St;)n.shift();this.#i.set(e,n)}#p(e,s){if(this.#c.has(e))return;const n={pid:s,timer:setInterval(()=>{if(!so(s)){const r=[...this.#i.get(e)??[]];this.#f(e),this.#s.crashed(e,r)}},to)};this.#c.set(e,n)}#f(e){const s=this.#o.get(e);if(s){clearInterval(s.pollTimer);try{gn(s.fd)}catch{}this.#o.delete(e)}const n=this.#c.get(e);n&&(clearInterval(n.timer),this.#c.delete(e))}#y(e,s){if(s===void 0)return;const n=bt(s.pidFile);if(n!==null)try{process.kill(-n,"SIGTERM")}catch{}const r=Kn("node",[s.scriptPath,s.configFile],{cwd:s.cwd,stdio:["ignore","pipe","pipe"]});r.stdout.on("data",i=>{this.#m(e,i)}),r.stderr.on("data",i=>{this.#m(e,i)}),r.on("error",i=>{this.#s.failed(e,"respawn-error",{message:i.message})});const o=new Promise(i=>{const l=()=>{this.#a.delete(o),i()};r.once("exit",l),r.once("error",l)});this.#a.add(o)}#m(e,s){const o=((this.#t.get(e)??"")+s.toString("utf8")).split(`
|
|
66
|
+
`),i=o.pop()??"";this.#t.set(e,i);for(const l of o)this.#d(e,l)}async#v(e,s){if(s!==void 0){try{await Xs({id:e,workspaceRoot:this.#r})}catch{}try{const n=await Js({command:s.command,config:s.config,cwd:s.cwd,env:s.env,id:e,workspaceRoot:this.#r}),r=s.config.readiness?.tcp?.port??s.config.port??0,o=s.config.readiness?.tcp?.host??"127.0.0.1";this.#s.started(e,n.entry.pid),this.notifyRegistryReady(e,{host:o,logFile:n.entry.logFile,pid:n.entry.pid,port:r})}catch(n){const r=n instanceof Error?n.message:String(n);this.#s.failed(e,"retry-failed",{message:r})}}}}const ns=(t,e,s)=>{const n=[],r=[];for(const o of e){const i=s.tasks[o];if(!i){r.push({id:o,reason:"task not in graph"});continue}const l=i.overrides.command;if(!l){r.push({id:o,reason:"no command resolved"});continue}const d=Ze(i);if(!d?.service){r.push({id:o,reason:"no service config"});continue}const h=Ue(t,i.projectRoot,!!d.runFromWorkspaceRoot),{envFile:u}=d,p=u===void 0||u===!1?{}:on(h,u),a=d.service.env??{};n.push({command:l,config:d.service,cwd:h,env:{...p,...a},id:o})}return{services:n,skipped:r}},ro=(t,e)=>{const s=new Set(t),n=new Map;for(const i of t){const l=(e.dependencies[i]??[]).filter(d=>s.has(d));n.set(i,new Set(l))}const r=[],o=new Set;for(;n.size>0;){const i=[];for(const[l,d]of n){for(const h of d)o.has(h)&&d.delete(h);d.size===0&&i.push(l)}i.length===0&&i.push(...n.keys());for(const l of i)o.add(l),n.delete(l);i.sort(),r.push({ids:i})}return r},io=(t,e)=>{const s=[];for(const n of ro(t,e))s.push(...n.ids);return s},oo=String.raw`import { spawn } from "node:child_process";
|
|
67
67
|
import { closeSync, openSync, readFileSync, readSync, statSync, writeFileSync } from "node:fs";
|
|
68
68
|
import { createConnection } from "node:net";
|
|
69
69
|
|
|
@@ -177,17 +177,17 @@ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
|
177
177
|
try { process.kill(-child.pid, "SIGTERM"); } catch {}
|
|
178
178
|
process.exit(1);
|
|
179
179
|
})();
|
|
180
|
-
`,co=()=>{const t=
|
|
181
|
-
`))}const
|
|
182
|
-
`),
|
|
183
|
-
`)},xo=async(t,e)=>{e.write("filter projects (empty to cancel) > ");const s=t,
|
|
184
|
-
`);if(d===-1)return;const h=o.slice(0,d).replace(/\r$/,"").trim();if(t.off("data",i),
|
|
185
|
-
`):await e.onFilter(p)}finally{i=!1}break}case"q":{await e.onQuit();break}case"r":{await e.onRerun();break}case"return":{await e.onRerun();break}}},d=(u,p)=>{l(p).catch(a=>{
|
|
186
|
-
`)})},h=s;return h.on("keypress",d),{close:()=>{if(h.off("keypress",d),!o)try{s.setRawMode?.(!1)}catch{}const u=s;if(typeof u.pause=="function")try{u.pause()}catch{}}}},
|
|
180
|
+
`,co=()=>{const t=wn(ie(Yn(),"vis-services-")),e=ie(t,"bootstrap.mjs");return Pt(e,oo),{runDir:t,scriptPath:e}},rs=(t,e,s)=>{const n=s.replaceAll(/[^\w-]/g,"_");return{configFile:ie(t,`${n}.json`),logFile:ie(t,`${n}.log`),pidFile:ie(t,`${n}.pid`),scriptPath:e}},ao=t=>{const{paths:e,service:s}=t,n=s.config.readiness?.tcp?.port??s.config.port;if(typeof n!="number")throw new TypeError(`Service ${s.id} has no TCP readiness port — declare \`service.port\` or \`service.readiness.tcp.port\`.`);const r={...s.env,PATH:ys(s.cwd,s.env)};return{command:s.command,cwd:s.cwd,env:r,host:s.config.readiness?.tcp?.host??"127.0.0.1",id:s.id,logFile:e.logFile,pidFile:e.pidFile,port:n,timeoutMs:s.config.readiness?.tcp?.timeoutMs??3e4}},lo=t=>`node ${JSON.stringify(t.scriptPath)} ${JSON.stringify(t.configFile)}`,uo=t=>{const{id:e,visBin:s,workspaceRoot:n}=t;return`node ${JSON.stringify(s)} service start ${JSON.stringify(e)} --cwd ${JSON.stringify(n)}`},fo=t=>{const{missingServiceIds:e,mode:s,taskGraph:n,visBin:r,workspaceRoot:o}=t,{services:i,skipped:l}=ns(o,e,n);if(i.length===0)return{chain:[],ephemeralPidFiles:[],runDir:void 0,serviceEnvByTaskId:new Map,skipped:l};const d=io(i.map(v=>v.id),n),h=new Map(i.map(v=>[v.id,v])),u=[],p=[];if(s==="ephemeral")for(const v of d){const w=h.get(v);w&&p.push({id:v,payload:ao({paths:{logFile:"",pidFile:""},service:w})})}let a;s==="ephemeral"&&(a=co());let m;for(const v of d){const w=h.get(v),k=n.tasks[v];if(!w||!k)continue;let O;if(s==="ephemeral"){const I=rs(a.runDir,a.scriptPath,v),D={...p.find(P=>P.id===v).payload,logFile:I.logFile,pidFile:I.pidFile};Pt(I.configFile,JSON.stringify(D)),O=lo(I),u.push(I.pidFile)}else O=uo({id:v,visBin:r,workspaceRoot:o});if(k.overrides={...k.overrides,command:O},k.cache=!1,n.tasks[v]=k,m!==void 0){const I=n.dependencies[v]??[];I.includes(m)||(n.dependencies[v]=[...I,m])}m=v}const y=new Set(d),g=new Map,S=v=>{const w=new Set,k=[...n.dependencies[v]??[]],O=new Set;for(;k.length>0;){const I=k.pop();if(!O.has(I)){O.add(I),y.has(I)&&w.add(I);for(const x of n.dependencies[I]??[])O.has(x)||k.push(x)}}return[...w].sort()};for(const v of Object.keys(n.dependencies)){if(y.has(v))continue;const w=S(v);if(w.length===0)continue;const k={};for(const O of w){const I=h.get(O);I?.config.env&&Object.assign(k,I.config.env)}Object.keys(k).length>0&&g.set(v,k)}return{chain:d,ephemeralPidFiles:u,runDir:a?.runDir,serviceEnvByTaskId:g,skipped:l}},ho=new Set(["auto","ephemeral","off","persistent"]),po=t=>t.cli!==void 0?"cli":t.config===void 0?"default":"config",mo=t=>{const{cli:e,config:s,isCi:n,isPersistentTarget:r,isTty:o,target:i}=t;if(e!==void 0&&!ho.has(e))throw new Error(`--services: expected one of auto|ephemeral|persistent|off, got "${e}"`);const l=e??s??(o&&!n?"auto":"off");return l==="off"?"off":l==="ephemeral"?"ephemeral":l==="persistent"?"registry":r||i==="dev"?"ephemeral":"registry"},go=async({config:t,initialTasks:e,logger:s,options:n,persistentTasks:r,target:o,taskGraph:i,workspaceRoot:l})=>{let d=e,h=i;const u=process.env.VIS_VERSION??"0.0.0",p=n.dryRun?void 0:async C=>{try{return await Qs(C.config,{timeoutMs:jr}),!0}catch{return!1}},a=await Zs(l),m=await Zi({initialTasks:[...d,...r],probe:p,registeredEntries:a,taskGraph:h,visVersion:u}),y=[];let g,S=0;const v=[],w=new Map;let k=[];const O=new Set;let I=null,x=null;if(m.diagnostics.length>0){const C=!!(process.stdout.isTTY&&process.stdin.isTTY),M=n.dryRun?"off":mo({cli:n.services,config:t.run?.services,isCi:!!be,isPersistentTarget:r.length>0,isTty:C,target:o});if(M==="off"){for(const W of m.diagnostics)s.error(W.message);const L=po({cli:n.services,config:t.run?.services}),_=[];throw n.dryRun?_.push("`--dry-run` never starts services; drop it to let vis boot them."):L==="default"?_.push("vis only auto-starts service deps in an interactive terminal by default (this run is CI or non-TTY).","Pass `--services=ephemeral` to boot them for this run, or set `run.services` in vis.config.ts."):L==="cli"?_.push("`--services=off` was passed; use `--services=ephemeral` to boot them for this run."):_.push('`run.services: "off"` is set in vis.config.ts; override it with `--services=ephemeral`.'),new fe([`${m.diagnostics.length} service dependency error(s) — start the missing services or invoke them directly.`,..._].join(`
|
|
181
|
+
`))}const $=m.diagnostics.map(L=>L.targetId),E=M,b=E==="registry"?ns(l,$,h):void 0,F=process.argv[1]??"vis",B=fo({missingServiceIds:$,mode:E,taskGraph:h,visBin:F,workspaceRoot:l});if(B.skipped.length>0){for(const{id:L,reason:_}of B.skipped)s.error(`Cannot auto-start ${L}: ${_}`);throw new fe(`${B.skipped.length} service(s) cannot be auto-started — invoke them directly or add a service config.`)}y.push(...B.ephemeralPidFiles),g=B.runDir,k=B.chain;for(const L of B.chain)O.add(L);if(E==="registry"&&(S=B.chain.length,v.push(...B.chain)),B.chain.length>0){const L=new kt(B.chain),_=new Map;if(E==="ephemeral"&&B.runDir)for(const W of B.chain){const q=rs(B.runDir,`${B.runDir}/bootstrap.mjs`,W);_.set(W,{ephemeral:{configFile:q.configFile,cwd:l,logFile:q.logFile,pidFile:q.pidFile,scriptPath:q.scriptPath},mode:"ephemeral"})}else if(E==="registry"&&b)for(const W of b.services)_.set(W.id,{mode:"registry",registry:{command:W.command,config:W.config,cwd:W.cwd,env:W.env}});if(_.size>0){const W=new no({indexToId:new Map,services:_,sink:{crashed:(q,G)=>{L.markCrashed(q,G)},failed:(q,G,J)=>{L.markFailed(q,G,J)},log:(q,G)=>{L.appendLog(q,G)},ready:(q,G)=>{L.markReady(q,G)},started:(q,G)=>{L.markStarted(q,G),E==="registry"&&G!==null&&w.set(q,G)},starting:q=>{L.markStarting(q)}},workspaceRoot:l});I=L,x=W}}for(const[L,_]of B.serviceEnvByTaskId){const W=m.serviceEnvByTaskId.get(L)??{};m.serviceEnvByTaskId.set(L,{...W,..._})}}const D=new Set(r.map(C=>C.id));if(d=m.initialTasks.filter(C=>!D.has(C.id)),h=m.taskGraph,k.length>0&&(d=[...k.map(M=>h.tasks[M]).filter(M=>M!==void 0),...d]),r.length>0){const C=new Set(r.map(F=>F.id)),M={};for(const[F,B]of Object.entries(h.tasks))C.has(F)||(M[F]=B);const $={};for(const[F,B]of Object.entries(h.dependencies))C.has(F)||($[F]=B.filter(L=>!C.has(L)));const E=new Set;for(const F of Object.values($))for(const B of F)E.add(B);const b=Object.keys(M).filter(F=>!E.has(F));h={dependencies:$,roots:b,tasks:M}}const{serviceEnvByTaskId:P}=m;if(m.satisfiedServices.length>0){const C=m.satisfiedServices.map(M=>M.id).join(", ");if(s.debug?.(`Auto-attached to running services: ${C}`),I)for(const M of m.satisfiedServices)I.registerService(M.id);else I=new kt(m.satisfiedServices.map(M=>M.id));for(const M of m.satisfiedServices){const $=M.config.readiness?.tcp?.port??M.config.port??0,E=M.config.readiness?.tcp?.host??"127.0.0.1";I.markReady(M.id,{host:E,port:$})}}return{ephemeralPidFiles:y,initialTasks:d,injectedServiceIdSet:O,registryStartedCount:S,registryStartedIds:v,registryStartedPids:w,serviceDockStore:I,serviceEnvByTaskId:P,serviceEventBridge:x,serviceResult:m,serviceRunDir:g,taskGraph:h}},wo=(t,e)=>{const s=e?.trim();if(!s)return{filter:void 0,tasks:[...t]};const n=s.toLowerCase();return{filter:s,tasks:t.filter(r=>r.target.project.toLowerCase().includes(n))}},yo=[""," Watch keybinds:"," r, Enter rerun"," a rerun all (clear filter)"," p filter by project name"," q, Ctrl+C quit"," h, ? show this help",""].join(`
|
|
182
|
+
`),vo=t=>{t.write(`${yo}
|
|
183
|
+
`)},xo=async(t,e)=>{e.write("filter projects (empty to cancel) > ");const s=t,n=s.isRaw===!0;if(n)try{s.setRawMode?.(!1)}catch{}return await new Promise(r=>{let o="";const i=l=>{o+=typeof l=="string"?l:l.toString("utf8");const d=o.indexOf(`
|
|
184
|
+
`);if(d===-1)return;const h=o.slice(0,d).replace(/\r$/,"").trim();if(t.off("data",i),n)try{s.setRawMode?.(!0)}catch{}r(h.length>0?h:void 0)};t.on("data",i)})},jo=t=>{const{handlers:e}=t,s=t.input??process.stdin,n=t.output??process.stdout,r=t.promptFilter??xo;if(!s||s.isTTY===!1)return{close:()=>{}};On(s);const o=s.isRaw===!0;try{s.setRawMode?.(!0)}catch{return{close:()=>{}}}typeof s.resume=="function"&&s.resume();let i=!1;const l=async u=>{if(u.ctrl===!0&&u.name==="c"){await e.onQuit();return}if(!i)switch(u.name){case"?":case"h":{await e.onHelp();break}case"a":{await e.onClearFilter();break}case"p":{i=!0;try{const p=await r(s,n);p===void 0?n.write(`filter cancelled.
|
|
185
|
+
`):await e.onFilter(p)}finally{i=!1}break}case"q":{await e.onQuit();break}case"r":{await e.onRerun();break}case"return":{await e.onRerun();break}}},d=(u,p)=>{l(p).catch(a=>{n.write(`[vis watch] keybind handler failed: ${a.message}
|
|
186
|
+
`)})},h=s;return h.on("keypress",d),{close:()=>{if(h.off("keypress",d),!o)try{s.setRawMode?.(!1)}catch{}const u=s;if(typeof u.pause=="function")try{u.pause()}catch{}}}},ko=({firstRun:t,hasFailure:e,logger:s,options:n,workspaceRoot:r})=>{if(n.flaky){const l=Rs(r,{minRuns:2},t.runHistory);if(l.length>0){s.info(""),s.info("Flaky tasks (based on historical runs):"),s.info("");for(const d of Ps(l))s.info(` ${d}`);s.info("")}}const o=[];for(const[l,d]of t.results)d.retryAttempts&&d.retryAttempts>0&&o.push(l);const i=n.failOnRetry&&o.length>0;if(i){const d=o.slice(0,5),h=o.length-d.length,u=h>0?`${d.join(", ")}, and ${String(h)} more`:d.join(", ");s.warn(""),s.warn(`--fail-on-retry: ${String(o.length)} task(s) succeeded only after retry: ${u}`)}if(e||i){const l=i&&!e?"Some tasks succeeded only after retry (--fail-on-retry).":"Some tasks failed.",d=2e3,h=[];for(const[u,p]of t.results){if(p.status!=="failure")continue;const a=p.terminalOutput??"",m=a.length>d?`…${a.slice(-d)}`:a,y=p.code??"?";h.push(` ${u} (exit ${String(y)}):
|
|
187
187
|
${m.split(`
|
|
188
|
-
`).map(
|
|
189
|
-
`)}`)}throw new
|
|
188
|
+
`).map(g=>` ${g}`).join(`
|
|
189
|
+
`)}`)}throw new fe(h.length>0?`${l}
|
|
190
190
|
${h.join(`
|
|
191
|
-
`)}`:l)}},
|
|
192
|
-
`);
|
|
193
|
-
`)},Ao=(t,e,s,r)=>{if(!s||s.length===0)return{env:{},kind:"ok"};const n=Po(s);if(n.length>0)return{errors:n.map(i=>`invalid \`arguments\` schema for "${t}": ${i}`),help:Be(t,e,s),kind:"invalid"};if(r.includes("--help")||r.includes("-h"))return{kind:"help",text:Be(t,e,s)};const o=Mo(s,r);return o.errors.length>0?{errors:o.errors,help:Be(t,e,s),kind:"invalid"}:{env:Oo(o.values),kind:"ok"}},Lo=({forwardedArgs:t,logger:e,projectsWithTarget:s,projectTargetIndex:r,target:n})=>{const o=s.map(u=>({project:u,schema:r.get(u)?.arguments})).filter(u=>Array.isArray(u.schema)&&u.schema.length>0),i=new Map;for(const{project:u,schema:p}of o){const a=JSON.stringify(p),m=i.get(a)??[];m.push(u),i.set(a,m)}if(i.size>1){const u=[...i.values()].map(p=>p.join(", ")).join(" | ");throw new Error(`Target "${n}" declares conflicting \`arguments\` schemas across projects (${u}). Run a single project (e.g. \`vis run ${o[0]?.project}:${n}\` or --projects=<name>) so the argument contract is unambiguous.`)}const l=o[0]?.schema,d=r.get(o[0]?.project??s[0])?.description,h=Ao(n,d,l,t);if(h.kind==="help"){e.info(h.text);return}if(h.kind==="invalid"){e.info(`Invalid arguments for "${n}":`);for(const u of h.errors)e.info(` ✖ ${u}`);throw e.info(""),e.info(h.help),new Error(`Invalid arguments for target "${n}"`)}return{env:h.env}},Do=new Set(["cache","command","dependsOn","fingerprintEnv","hashMode","inputs","outputs","parallelism","splitCompound","untrackedEnv"]),Bo=t=>t?Object.keys(t).filter(e=>Do.has(e)).toSorted():[],_o=(t,e)=>`${t}: ${e.map(s=>`"${s}"`).join(", ")} ${e.length===1?"is a target property, not an option":"are target properties, not options"}, so ${e.length===1?"it is":"they are"} ignored under "options". Move ${e.length===1?"it":"them"} next to "command".`,No=({affectedFiles:t,forwardedArgs:e,logger:s,options:r,projectsWithTarget:n,projectTargetIndex:o,target:i,taskArgumentEnvVars:l,workspace:d})=>{const h=r.pty,u=pn(r.hashMode);let p=n.map(j=>{const E=d.projects[j],y=o.get(j),g={project:j,target:i},S=`${j}:${i}`,F=h?{...y.options,pty:y.options?.pty??!0}:y.options,C=y.command?$t(y.command,{affectedFiles:t,projectRoot:E?.root}):y.command,v=E?.root&&E.root.length>0?E.root:".",L=(y.outputs??[]).map($=>typeof $!="string"?$:$.replaceAll("{projectRoot}",v).replaceAll("{projectName}",j)),P=Bo(y.options);return P.length>0&&s.warn(_o(S,P)),{cache:y.cache,declaresInputs:y.inputs!==void 0,fingerprintEnv:y.fingerprintEnv,hashMode:u??y.hashMode,id:S,outputs:L,overrides:{command:C,...e.length>0?{[Wt]:e}:{},...Object.keys(l).length>0?{[cr]:l}:{},...F?{visOptions:F}:{}},parallelism:y.parallelism,projectRoot:E?.root,splitCompound:y.splitCompound,target:g,untrackedEnv:y.untrackedEnv}});const a=[],m=[];for(const j of p)ke(j)?.persistent?(j.cache=!1,a.push(j)):m.push(j);p=m;const w=js(r.partition);if(w&&(p=Ss.partitionTasks(p,w),s.info(`Partition ${w.index}/${w.total}: running ${p.length} task(s)`),p.length===0)){s.info("No tasks assigned to this partition.");return}return{initialTasks:p,persistentTasks:a}},Wo=({affectedFiles:t,config:e,forwardedArgs:s,logger:r,options:n,projectGraph:o,projectOptions:i,projectsWithTarget:l,projectTargetIndex:d,target:h,workspace:u})=>{const p=Lo({forwardedArgs:s,logger:r,projectsWithTarget:l,projectTargetIndex:d,target:h});if(!p)return;const a=No({affectedFiles:t,forwardedArgs:s,logger:r,options:n,projectsWithTarget:l,projectTargetIndex:d,target:h,taskArgumentEnvVars:p.env,workspace:u});if(!a)return;const{persistentTasks:m}=a,{initialTasks:w}=a,j=$o({affectedFiles:t,config:e,initialTasks:w,logger:r,options:n,persistentTasks:m,projectGraph:o,projectOptions:i,workspace:u});return{initialTasks:w,persistentTasks:m,taskGraph:j}},gc=async({argument:t,logger:e,options:s,visConfig:r,workspaceRoot:n})=>{if(!n)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const o=n;if(Ds({options:s,visConfig:r},o),Ws(o),s.lastDetails){await un(o,e);return}const i=process.cwd(),l=await Os(o,r),{config:d,fileOwners:h,packageJsons:u,projectOptions:p,workspace:a}=As(o,r,l),m=Ls(o,a,u),w=d.taskRunner??{},j=Fs({branchScopedCache:d.branchScopedCache,configCacheDir:w.cacheDirectory,optionsCacheDir:s.cacheDir,sharedWorktreeCache:d.sharedWorktreeCache,workspaceRoot:o}),E=await Yi({argument:t,cacheDirectory:j,config:d,fileOwners:h,logger:e,options:s,packageJsons:u,projectGraph:m,projectOptions:p,visConfig:r,workspace:a,workspaceRoot:o});if(!E)return;const{affectedExternalInputState:y,affectedFiles:g,currentOs:S,forwardedArgs:F,projectsWithTarget:C,projectTargetIndex:v,target:L}=E,P=Wo({affectedFiles:g,config:d,forwardedArgs:F,logger:e,options:s,projectGraph:m,projectOptions:p,projectsWithTarget:C,projectTargetIndex:v,target:L,workspace:a});if(!P)return;const{persistentTasks:$}=P;let{initialTasks:M,taskGraph:T}=P;await xi({config:d,logger:e,options:s,packageJsons:u,workspaceRoot:o});const I=await go({config:d,initialTasks:M,logger:e,options:s,persistentTasks:$,target:L,taskGraph:T,workspaceRoot:o});M=I.initialTasks,T=I.taskGraph;const{ephemeralPidFiles:k,injectedServiceIdSet:O,registryStartedCount:B,registryStartedIds:D,registryStartedPids:_,serviceDockStore:W,serviceEnvByTaskId:q,serviceEventBridge:G,serviceResult:J,serviceRunDir:z}=I,Z=s.stopServices,te=Sn({ephemeralPidFiles:k,registryStartedIds:D,registryStartedPids:_,serviceEventBridge:G,serviceRunDir:z,stopServicesOnExit:Z,workspaceRoot:o});te.install();try{if(T=Co({logger:e,options:s,projectOptions:p,taskGraph:T}),s.dryRun){kn({config:d,logger:e,persistentTasks:$,taskGraph:T});return}const K=await Ci({affectedFiles:g,config:d,currentOs:S,initialTasks:M,invocationCwd:i,logger:e,options:s,persistentTasks:$,projectsWithTarget:C,runCacheDirectory:j,serviceEnvByTaskId:q,serviceResult:J,target:L,taskGraph:T,visConfig:r,workspaceRoot:o});if(y){K.hooks.hook("run:after",async H=>{[...H.values()].some(re=>re.code!==0)||await _s(y.path,y.hashes)});const N=new Set($.map(H=>H.id));K.hooks.hook("task:failure",async H=>{N.has(H.id)&&await Ns(y.path)})}if(await K.hooks.callHook("run:before",{tasks:M,workspaceRoot:o}),K.isTTY){const{spawnContext:N}=K,{dynamic:H,lifeCycle:V,stdinRegistry:re,store:oe,taskExecutor:fe}=ai({injectedServiceIdSet:O,runtime:K,serviceDockStore:W,serviceEventBridge:G,workspaceRoot:o});let de="rerun",ce=null,ee=new Map;for(;de!=="quit";){if(de==="rerun")ee=await li({dynamic:H,initialTasks:M,lifeCycle:V,options:s,persistentTasks:$,projectGraph:m,runtime:K,stdinRegistry:re,store:oe,taskExecutor:fe,taskGraph:T,workspaceRoot:o});else if(de==="retry"&&ce){const Y=T.tasks[ce]??M.find(R=>R.id===ce),he=Y?Ye(Y,N.affectedFiles,S):void 0;if(Y&&he){V.startTasks?.([Y]);const R=new He(Re),b=ar(N,Y),Q=(await Ce([{command:he,cwd:b.cwd,env:b.env,inheritEnv:b.inheritEnv,name:Y.id,ptySize:{cols:process.stdout.columns??80,rows:process.stdout.rows??24},stdin:"pty"}],{onEvent:ae=>{ae.kind==="started"&&ae.write&&re.set(Y.id,{kill:ae.kill,resize:ae.resize,write:ae.write}),(ae.kind==="stdout"||ae.kind==="stderr")&&ae.text&&(R.write(ae.text),oe.setOutput(Y.id,R.toString())),ae.kind==="close"&&re.delete(Y.id)}})).closeEvents[0];V.endTasks?.([{code:Q?.exitCode??1,status:Q?.exitCode===0?"success":"failure",task:Y,terminalOutput:oe.getSnapshot().outputs.get(Y.id)}])}else Y&&V.endTasks?.([{code:1,status:"failure",task:Y,terminalOutput:`No command configured for ${Y.id}`}]);ce=null,oe.markDone()}const ne=await di({dynamic:H,store:oe});de=ne.action,ce=ne.retryTaskId}await H.renderIsDone,await K.hooks.callHook("run:after",ee),await K.maybeWriteProfile(ee),ss({logger:e,registryStartedCount:B,stopServicesOnExit:Z})}else await ko({initialTasks:M,logger:e,options:s,persistentTasks:$,projectGraph:m,projectsWithTarget:C,registryStartedCount:B,runtime:K,serviceEventBridge:G,stopServicesOnExit:Z,taskGraph:T,visConfig:r,workspace:a,workspaceRoot:o})}finally{await te.finish()}};export{gc as default};
|
|
191
|
+
`)}`:l)}},is=({logger:t,registryStartedCount:e,stopServicesOnExit:s})=>{e>0&&(t.info(""),s?t.info(`${String(e)} service(s) stopped (--stop-services).`):t.info(`${String(e)} service(s) started in the background. Run \`vis service stop --all\` to clean up.`))},So=async({initialTasks:t,logger:e,options:s,persistentTasks:n,projectGraph:r,projectsWithTarget:o,registryStartedCount:i,runtime:l,serviceEventBridge:d,stopServicesOnExit:h,taskGraph:u,visConfig:p,workspace:a,workspaceRoot:m})=>{const{childEnvPolicyFor:y,failureLogLifeCycle:g,hookLifeCycle:S,hooks:v,lifecycleOptions:w,maybeWriteProfile:k,outputStyle:O,preTraceCheck:I,resolveCommand:x,runnerOptions:D,sharedRetryBudget:P,spawnContext:C,startTime:M,strictEnvFailure:$}=l;let E=t;const b=new Map,F=typeof s.log=="string"?s.log.toLowerCase():"",B=F==="labeled"||F==="grouped"||F==="interleaved"?F:void 0,L=B?vs(B):void 0,_=new $t([new ii({...w,ciGrouping:p?.run?.ciGrouping??"auto",logReporter:L,outputStyle:O}),S,g]),W=es({hooks:v,lifeCycle:_,mutexPool:b,resolveCommand:x,retryBudget:P,serviceEventBridge:d??void 0,spawnContext:C,strictEnvFailure:$,workspaceRoot:m}),q=async()=>{const z=Date.now(),Z=await Ct(E,D,{childEnvPolicy:y,lifeCycle:_,preTraceCheck:I,projectGraph:r,resolveChildEnv:(ne,oe)=>Te(C,ne,oe),resolveCommand:x,taskExecutor:W,taskGraph:u,workspaceRoot:m}),te=Date.now()-z;if(s.summarize){const ne=It(Z,u,M);await xs(ne,m,{dataDirectory:Ie(m)})}let K=!1;for(const[,ne]of Z)ne.status==="failure"&&(K=!0);const N=Ms(Z,te),H=Os(m),V=Fs(m,te,H);return e.info(""),e.info(` ${N}${V?` ${V}`:""}`),{hasFailure:K,results:Z,runHistory:H}},G=await q();await v.callHook("run:after",G.results),await k(G.results);const{hasFailure:J}=G;if(s.watch){const z=o.map(ee=>{const Y=a.projects[ee]?.root;if(Y)return Y.startsWith("/")?Y:`${m}/${Y}`}).filter(ee=>ee!==void 0),Z=E;let te;const K=ee=>{const re=wo(Z,ee);return te=re.filter,E=re.tasks,re.tasks.length};let N=!1,H=G.results;const V=()=>{const ee=rt(H,m);if(ee.directories.length>0&&ee.files.size>0){const re=Xn(ee.files,m,ee.directories);return{handle:it({filter:re,onChange:oe,paths:ee.directories}),mode:"tracked"}}return{handle:it({onChange:oe,paths:z}),mode:"roots"}};let ne;const oe=async ee=>{if(!N){N=!0;try{e.info(`Change detected in ${ee.length} file(s), rerunning…`),H=(await q()).results,ne?.close(),ne=V().handle}finally{N=!1}}},he=V();ne=he.handle;const de=he.mode==="tracked"?`Watching ${String(rt(H,m).files.size)} tracked file(s)`:`Watching ${String(z.length)} project root(s)`;e.info(`${de} — edit a file to rerun, press h for keybinds, q to quit.`);const ce=async()=>{if(!N){N=!0;try{if(E.length===0){e.info("No tasks match the active filter — press a to clear it.");return}H=(await q()).results,ne?.close(),ne=V().handle}finally{N=!1}}};await new Promise(ee=>{let re=!1,Y;const pe=()=>{R()},R=()=>{re||(re=!0,Y?.close(),process.off("SIGINT",pe),ne?.close(),ee())};process.on("SIGINT",pe),Y=jo({handlers:{onClearFilter:async()=>{const T=K(void 0);e.info(`Filter cleared — running ${String(T)} task(s).`),await ce()},onFilter:async T=>{const A=te,Q=K(T);if(Q===0){e.info(`Filter "${T}" matched no projects — keeping previous filter.`),K(A);return}e.info(`Filter "${T}" matched ${String(Q)} task(s).`),await ce()},onHelp:()=>{vo(process.stdout)},onQuit:()=>{R()},onRerun:ce}})});return}ko({firstRun:G,hasFailure:J,logger:e,options:s,workspaceRoot:m}),n.length>0&&!s.failFast&&await Ut(n,C,void 0),is({logger:e,registryStartedCount:i,stopServicesOnExit:h})},bo=t=>t.split(",").map(e=>e.trim()).filter(e=>e!==""),To=(t,e,s)=>{const n=new Set,r=[];if(t===void 0||t.trim()==="")return{skipTaskIds:n,unmatchedPatterns:r};const o=[...s],i=new Set(o),l=new Map;for(const d of o){const h=d.lastIndexOf(":");if(h===-1)continue;const u=d.slice(h+1),p=l.get(u);p===void 0?l.set(u,[d]):p.push(d)}for(const d of bo(t)){if(d.startsWith("~:"))throw new Error(`--skip-cache does not support the closest-project selector "~:" (received "${d}"). Use \`pkg:target\`, \`:target\`, or \`#tag:target\`.`);if(i.has(d)){n.add(d);continue}const h=Un(d);if(!h){r.push(d);continue}let u=!1;switch(h.kind){case"all":{const p=l.get(h.target)??[];for(const a of p)n.add(a),u=!0;break}case"project":{const p=h.projects?.[0];if(p!==void 0){const a=`${p}:${h.target}`;i.has(a)&&(n.add(a),u=!0)}break}case"tag":{const{tag:p}=h;if(p!==void 0){const a=l.get(h.target)??[];for(const m of a){const y=m.slice(0,m.lastIndexOf(":"));e.projects[y]?.tags?.includes(p)===!0&&(n.add(m),u=!0)}}break}}u||r.push(d)}return{skipTaskIds:n,unmatchedPatterns:r}},$o=({affectedFiles:t,config:e,initialTasks:s,logger:n,options:r,persistentTasks:o,projectGraph:i,projectOptions:l,workspace:d})=>{const h=new Set([...s,...o].map(p=>p.id)),u=Ss([...s,...o],{onCycleBroken:p=>{n.warn(`Ignoring dev-only dependency cycle (build order is ambiguous): ${p.join(" → ")}`)},onUnmatchedProjectSelector:p=>{n.warn(`dependsOn.projects entry "${p}" matched no project — that dependency edge was not created.`)},projectGraph:i,targetDefaults:e.tasks,workspace:d});for(const[p,a]of Object.entries(u.tasks)){const m=a.target.project,y=a.target.target,g=l.get(m)?.[y];if(!g){h.has(p)||n.warn(`${y} required via dependsOn but no command is configured for ${m} — skipping (no-op).`);continue}const S=d.projects[m];let v=!1;const w={...a.overrides};w.visOptions===void 0&&g.options&&(w.visOptions=g.options,v=!0),w.command===void 0&&g.command&&(w.command=Et(g.command,{affectedFiles:t,projectRoot:S?.root}),v=!0),v&&(a.overrides=w,u.tasks[p]=a)}if(typeof r.skipCache=="string"&&r.skipCache.trim()!=="")if(r.cache){const p=To(r.skipCache,d,Object.keys(u.tasks));for(const a of p.skipTaskIds){const m=u.tasks[a];m!==void 0&&(m.cache=!1)}p.unmatchedPatterns.length>0&&n.warn(`--skip-cache: no tasks matched ${p.unmatchedPatterns.map(a=>`"${a}"`).join(", ")}`),p.skipTaskIds.size>0&&n.debug?.(`--skip-cache: bypassing cache for ${String(p.skipTaskIds.size)} task(s)`)}else n.debug?.("--skip-cache ignored: --no-cache already disables caching for the whole run");return u},Co=({logger:t,options:e,projectOptions:s,taskGraph:n})=>{let r=n;e.reverse&&(r=js(r),t.debug?.(`Reversed task graph: ${String(r.roots.length)} new root(s) (originally leaves)`));for(const o of Object.values(r.tasks)){const i=s.get(o.target.project)?.[o.target.target]?.options;o.splitCompound&&Ot(i)!==void 0&&(t.warn(`splitCompound ignored for ${o.id}: it uses a custom shell. Running the command as one unit.`),o.splitCompound=void 0)}return r=ks(r,{commandOf:o=>o.overrides.command,onDiagnostic:(o,i)=>{t.warn(i)}}),r},os=t=>t.replace(/^--?/u,""),Io=new Set(["0","1","false","no","true","yes"]),Eo=t=>!t.startsWith("-")||/^-(?:\d|\.\d)/u.test(t),Tt=(t,e,s,n,r,o)=>{if(n!==void 0)return t.set(e,n),0;const i=r[o+1];return(s?.type??"string")==="boolean"?i!==void 0&&Io.has(i.toLowerCase())?(t.set(e,i.toLowerCase()),1):(t.set(e,"true"),0):i!==void 0&&Eo(i)?(t.set(e,i),1):(t.set(e,"true"),0)},Ro=(t,e)=>{const s=t.type??"string";if(s==="number"){const n=e.trim(),r=Number(n);return n===""||!Number.isFinite(r)?{error:`--${t.name} expects a number, got "${e}"`}:{value:r}}if(s==="boolean")return["1","true","yes"].includes(e.toLowerCase())?{value:!0}:["0","false","no"].includes(e.toLowerCase())?{value:!1}:{error:`--${t.name} expects a boolean, got "${e}"`};if(s==="enum"){const n=t.choices??[];return n.includes(e)?{value:e}:{error:`--${t.name} must be one of [${n.join(", ")}], got "${e}"`}}return{value:e}},Po=t=>{const e=[],s=new Set;for(const n of t){const r=n.name||"<unnamed>";(!n.name||!/^[a-zA-Z][\w-]*$/u.test(n.name))&&e.push(`argument name "${r}" is empty or invalid (start with a letter; use letters, digits, '-', '_')`),s.has(n.name)&&e.push(`duplicate argument name "${r}"`),s.add(n.name),n.alias!==void 0&&n.alias.length!==1&&e.push(`argument "${r}" alias "${n.alias}" must be a single character`);const o=n.type??"string";if(o==="enum"&&(n.choices===void 0||n.choices.length===0)&&e.push(`argument "${r}" has type "enum" but declares no choices`),n.default!==void 0){const i=typeof n.default;o==="number"&&i==="number"||o==="boolean"&&i==="boolean"||(o==="string"||o==="enum")&&i==="string"?o==="enum"&&n.choices&&!n.choices.includes(n.default)&&e.push(`argument "${r}" default "${String(n.default)}" is not one of its choices`):e.push(`argument "${r}" default ${JSON.stringify(n.default)} does not match type "${o}"`)}}return e},Mo=(t,e)=>{const s=new Map,n=new Map;for(const h of t)s.set(h.name,h),h.alias&&n.set(h.alias,h);const r=new Map,o=[];for(let h=0;h<e.length;h+=1){const u=e[h];if(u==="--"){o.push(...e.slice(h+1));break}if(u.startsWith("--no-")){r.set(os(u.slice(5)),"false");continue}const p=/^--([^=]+)(?:=(.*))?$/su.exec(u);if(p){const y=p[1];h+=Tt(r,y,s.get(y),p[2],e,h);continue}const a=/^-([^=-])(?:=(.*))?$/su.exec(u),m=a?.[1];if(a&&m!==void 0){const y=n.get(m);h+=Tt(r,y?.name??m,y,a[2],e,h);continue}o.push(u)}const i={},l=[];let d=0;for(const h of t){let u=r.get(h.name);if(u===void 0&&h.positional&&d<o.length&&(u=o[d],d+=1),u===void 0){h.default!==void 0?i[h.name]=h.default:h.required&&l.push(`missing required argument --${h.name}`);continue}const{error:p,value:a}=Ro(h,u);p?l.push(p):a!==void 0&&(i[h.name]=a)}return{errors:l,values:i}},Oo=t=>`VIS_ARG_${os(t).replaceAll(/[^a-zA-Z0-9]+/gu,"_").toUpperCase()}`,Fo=t=>{const e={};for(const[s,n]of Object.entries(t))e[Oo(s)]=String(n);return e},Be=(t,e,s)=>{const n=[`Usage: vis run ${t} [-- <args>]`];if(e&&n.push("",e),s.length===0)return n.join(`
|
|
192
|
+
`);n.push("","Arguments:");const r=s.map(i=>{const l=i.positional?`<${i.name}>`:`--${i.name}`,d=i.alias?`, -${i.alias}`:"";return{left:`${l}${d}`,right:i}}),o=Math.max(...r.map(i=>i.left.length));for(const{left:i,right:l}of r){const d=[],h=l.type??"string";d.push(h==="enum"?`enum(${(l.choices??[]).join("|")})`:h),l.required&&d.push("required"),l.default!==void 0&&d.push(`default: ${String(l.default)}`);const u=`${l.description??""}${l.description?" ":""}[${d.join(", ")}]`;n.push(` ${i.padEnd(o)} ${u}`)}return n.join(`
|
|
193
|
+
`)},Ao=(t,e,s,n)=>{if(!s||s.length===0)return{env:{},kind:"ok"};const r=Po(s);if(r.length>0)return{errors:r.map(i=>`invalid \`arguments\` schema for "${t}": ${i}`),help:Be(t,e,s),kind:"invalid"};if(n.includes("--help")||n.includes("-h"))return{kind:"help",text:Be(t,e,s)};const o=Mo(s,n);return o.errors.length>0?{errors:o.errors,help:Be(t,e,s),kind:"invalid"}:{env:Fo(o.values),kind:"ok"}},Do=({forwardedArgs:t,logger:e,projectsWithTarget:s,projectTargetIndex:n,target:r})=>{const o=s.map(u=>({project:u,schema:n.get(u)?.arguments})).filter(u=>Array.isArray(u.schema)&&u.schema.length>0),i=new Map;for(const{project:u,schema:p}of o){const a=JSON.stringify(p),m=i.get(a)??[];m.push(u),i.set(a,m)}if(i.size>1){const u=[...i.values()].map(p=>p.join(", ")).join(" | ");throw new Error(`Target "${r}" declares conflicting \`arguments\` schemas across projects (${u}). Run a single project (e.g. \`vis run ${o[0]?.project}:${r}\` or --projects=<name>) so the argument contract is unambiguous.`)}const l=o[0]?.schema,d=n.get(o[0]?.project??s[0])?.description,h=Ao(r,d,l,t);if(h.kind==="help"){e.info(h.text);return}if(h.kind==="invalid"){e.info(`Invalid arguments for "${r}":`);for(const u of h.errors)e.info(` ✖ ${u}`);throw e.info(""),e.info(h.help),new Error(`Invalid arguments for target "${r}"`)}return{env:h.env}},Lo=new Set(["cache","command","dependsOn","fingerprintEnv","hashMode","inputs","outputs","parallelism","splitCompound","untrackedEnv"]),Bo=t=>t?Object.keys(t).filter(e=>Lo.has(e)).toSorted():[],_o=(t,e)=>`${t}: ${e.map(s=>`"${s}"`).join(", ")} ${e.length===1?"is a target property, not an option":"are target properties, not options"}, so ${e.length===1?"it is":"they are"} ignored under "options". Move ${e.length===1?"it":"them"} next to "command".`,No=({affectedFiles:t,forwardedArgs:e,logger:s,options:n,projectsWithTarget:r,projectTargetIndex:o,target:i,taskArgumentEnvVars:l,workspace:d})=>{const h=n.pty,u=gr(n.hashMode);let p=r.map(g=>{const S=d.projects[g],v=o.get(g),w={project:g,target:i},k=`${g}:${i}`,O=h?{...v.options,pty:v.options?.pty??!0}:v.options,I=v.command?Et(v.command,{affectedFiles:t,projectRoot:S?.root}):v.command,x=S?.root&&S.root.length>0?S.root:".",D=(v.outputs??[]).map(C=>typeof C!="string"?C:C.replaceAll("{projectRoot}",x).replaceAll("{projectName}",g)),P=Bo(v.options);return P.length>0&&s.warn(_o(k,P)),{cache:v.cache,declaresInputs:v.inputs!==void 0,fingerprintEnv:v.fingerprintEnv,hashMode:u??v.hashMode,id:k,outputs:D,overrides:{command:I,...e.length>0?{[qt]:e}:{},...Object.keys(l).length>0?{[dn]:l}:{},...O?{visOptions:O}:{}},parallelism:v.parallelism,projectRoot:S?.root,splitCompound:v.splitCompound,target:w,untrackedEnv:v.untrackedEnv}});const a=[],m=[];for(const g of p)Se(g)?.persistent?(g.cache=!1,a.push(g)):m.push(g);p=m;const y=qe(n.partition);if(y&&(p=bs.partitionTasks(p,y),s.info(`Partition ${y.index}/${y.total}: running ${p.length} task(s)`),p.length===0)){s.info("No tasks assigned to this partition.");return}return{initialTasks:p,persistentTasks:a}},Wo=(t,e,s)=>t.target.target===e&&s.has(t.target.project),Go=(t,e,s,n,r)=>{const o=new Set(e.map(g=>g.target.project)),i=new Set(Object.entries(t.tasks).flatMap(([g,S])=>Wo(S,s,o)?[g]:[])),l=ot(i,g=>t.dependencies[g]),d={},h=(g,S)=>l.has(g)&&!i.has(g)&&S.always!==!0&&!r(S),u=ot(Object.entries(t.tasks).flatMap(([g,S])=>h(g,S)?[g]:[]),g=>t.dependencies[g]),p=g=>{const S=t.dependencies[g]??[];return S.length>0&&S.every(v=>l.has(v)&&!i.has(v))};for(const[g,S]of Object.entries(t.tasks)){const v=l.has(g)&&!i.has(g);S.always===!0?n===(!i.has(g)&&p(g)?"deps-only":"skip-deps")&&(d[g]=S):n==="deps-only"?v&&(!r(S)||u.has(g))&&(d[g]=S):v?d[g]=r(S)?S:{...S,satisfied:!0}:i.has(g)&&(d[g]=S)}const a={},m=new Set;for(const g of Object.keys(d)){const S=(t.dependencies[g]??[]).filter(v=>v in d);a[g]=S;for(const v of S)m.add(v)}const y=Object.values(d).filter(g=>!m.has(g.id));return{initialTasks:n==="skip-deps"?e.filter(g=>g.id in d):y,taskGraph:{dependencies:a,roots:y.map(g=>g.id),tasks:d}}},Ho=t=>{if(t.depsOnly&&t.skipDeps)throw new fe("--deps-only and --skip-deps are opposites; pass one of them.");if(t.depsOnly&&qe(t.partition)!==void 0)throw new fe("--deps-only cannot be combined with --partition (or VIS_PARTITION): run the dependencies once unpartitioned, then partition the --skip-deps runs.");return t.depsOnly?"deps-only":t.skipDeps?"skip-deps":void 0},qo=(t,{logger:e,partitioned:s,scope:n,target:r})=>{if(t.persistentTasks.length>0)throw new fe(`--deps-only / --skip-deps split a finite run across CI steps; ${r} is a persistent (long-running) target, so run it without them.`);const o=Go(t.taskGraph,t.initialTasks,r,n,l=>!!Ze(l)?.service),i=s?Object.values(o.taskGraph.tasks).find(l=>l.satisfied===!0&&l.target.target===r):void 0;if(i)throw new fe(`--skip-deps cannot partition ${r}: ${i.id} is a ${r} task another shard runs, and this shard's tasks depend on it. Run ${r} unpartitioned.`);if(Object.keys(o.taskGraph.tasks).length===0){e.info(n==="deps-only"?`▸ No dependencies to run for ${r}.`:`▸ No ${r} tasks to run.`);return}return{...o,persistentTasks:t.persistentTasks}},Uo=({affectedFiles:t,config:e,forwardedArgs:s,logger:n,options:r,projectGraph:o,projectOptions:i,projectsWithTarget:l,projectTargetIndex:d,target:h,workspace:u})=>{const p=Do({forwardedArgs:s,logger:n,projectsWithTarget:l,projectTargetIndex:d,target:h});if(!p)return;const a=Ho(r),m=No({affectedFiles:t,forwardedArgs:s,logger:n,options:r,projectsWithTarget:l,projectTargetIndex:d,target:h,taskArgumentEnvVars:p.env,workspace:u});if(!m)return;const{persistentTasks:y}=m,{initialTasks:g}=m,S=$o({affectedFiles:t,config:e,initialTasks:g,logger:n,options:r,persistentTasks:y,projectGraph:o,projectOptions:i,workspace:u}),v={initialTasks:g,persistentTasks:y,taskGraph:S};return a?qo(v,{logger:n,partitioned:qe(r.partition)!==void 0,scope:a,target:h}):v},jc=async({argument:t,logger:e,options:s,visConfig:n,workspaceRoot:r})=>{if(!r)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const o=r;if(_s({options:s,visConfig:n},o),Hs(o),s.lastDetails){await hr(o,e);return}const i=process.cwd(),l=await Ds(o,n),{config:d,fileOwners:h,packageJsons:u,projectOptions:p,workspace:a}=Ls(o,n,l),m=Bs(o,a,u),y=d.taskRunner??{},g=As({branchScopedCache:d.branchScopedCache,configCacheDir:y.cacheDirectory,optionsCacheDir:s.cacheDir,sharedWorktreeCache:d.sharedWorktreeCache,workspaceRoot:o}),S=await Xi({argument:t,cacheDirectory:g,config:d,fileOwners:h,logger:e,options:s,packageJsons:u,projectGraph:m,projectOptions:p,visConfig:n,workspace:a,workspaceRoot:o});if(!S)return;const{affectedExternalInputState:v,affectedFiles:w,currentOs:k,forwardedArgs:O,projectsWithTarget:I,projectTargetIndex:x,target:D}=S,P=Uo({affectedFiles:w,config:d,forwardedArgs:O,logger:e,options:s,projectGraph:m,projectOptions:p,projectsWithTarget:I,projectTargetIndex:x,target:D,workspace:a});if(!P)return;const{persistentTasks:C}=P;let{initialTasks:M,taskGraph:$}=P;await ki({config:d,logger:e,options:s,packageJsons:u,workspaceRoot:o});const E=await go({config:d,initialTasks:M,logger:e,options:s,persistentTasks:C,target:D,taskGraph:$,workspaceRoot:o});M=E.initialTasks,$=E.taskGraph;const{ephemeralPidFiles:b,injectedServiceIdSet:F,registryStartedCount:B,registryStartedIds:L,registryStartedPids:_,serviceDockStore:W,serviceEnvByTaskId:q,serviceEventBridge:G,serviceResult:J,serviceRunDir:z}=E,Z=s.stopServices,te=br({ephemeralPidFiles:b,registryStartedIds:L,registryStartedPids:_,serviceEventBridge:G,serviceRunDir:z,stopServicesOnExit:Z,workspaceRoot:o});te.install();try{if($=Co({logger:e,options:s,projectOptions:p,taskGraph:$}),s.dryRun){Tr({config:d,logger:e,persistentTasks:C,taskGraph:$});return}const K=await Ei({affectedFiles:w,config:d,currentOs:k,initialTasks:M,invocationCwd:i,logger:e,options:s,persistentTasks:C,projectsWithTarget:I,runCacheDirectory:g,serviceEnvByTaskId:q,serviceResult:J,target:D,taskGraph:$,visConfig:n,workspaceRoot:o});if(v&&!s.depsOnly&&!s.skipDeps){K.hooks.hook("run:after",async H=>{[...H.values()].some(ne=>ne.code!==0)||await Ws(v.path,v.hashes)});const N=new Set(C.map(H=>H.id));K.hooks.hook("task:failure",async H=>{N.has(H.id)&&await Gs(v.path)})}if(await K.hooks.callHook("run:before",{tasks:M,workspaceRoot:o}),K.isTTY){const{spawnContext:N}=K,{dynamic:H,lifeCycle:V,stdinRegistry:ne,store:oe,taskExecutor:he}=di({injectedServiceIdSet:F,runtime:K,serviceDockStore:W,serviceEventBridge:G,workspaceRoot:o});let de="rerun",ce=null,ee=new Map;for(;de!=="quit";){if(de==="rerun")ee=await ui({dynamic:H,initialTasks:M,lifeCycle:V,options:s,persistentTasks:C,projectGraph:m,runtime:K,stdinRegistry:ne,store:oe,taskExecutor:he,taskGraph:$,workspaceRoot:o});else if(de==="retry"&&ce){const Y=$.tasks[ce]??M.find(R=>R.id===ce),pe=Y?Ke(Y,N.affectedFiles,k):void 0;if(Y&&pe){V.startTasks?.([Y]);const R=new He(Re),T=un(N,Y),Q=(await Ce([{command:pe,cwd:T.cwd,env:T.env,inheritEnv:T.inheritEnv,name:Y.id,ptySize:{cols:process.stdout.columns??80,rows:process.stdout.rows??24},stdin:"pty"}],{onEvent:ae=>{ae.kind==="started"&&ae.write&&ne.set(Y.id,{kill:ae.kill,resize:ae.resize,write:ae.write}),(ae.kind==="stdout"||ae.kind==="stderr")&&ae.text&&(R.write(ae.text),oe.setOutput(Y.id,R.toString())),ae.kind==="close"&&ne.delete(Y.id)}})).closeEvents[0];V.endTasks?.([{code:Q?.exitCode??1,status:Q?.exitCode===0?"success":"failure",task:Y,terminalOutput:oe.getSnapshot().outputs.get(Y.id)}])}else Y&&V.endTasks?.([{code:1,status:"failure",task:Y,terminalOutput:`No command configured for ${Y.id}`}]);ce=null,oe.markDone()}const re=await fi({dynamic:H,store:oe});de=re.action,ce=re.retryTaskId}await H.renderIsDone,await K.hooks.callHook("run:after",ee),await K.maybeWriteProfile(ee),is({logger:e,registryStartedCount:B,stopServicesOnExit:Z})}else await So({initialTasks:M,logger:e,options:s,persistentTasks:C,projectGraph:m,projectsWithTarget:I,registryStartedCount:B,runtime:K,serviceEventBridge:G,stopServicesOnExit:Z,taskGraph:$,visConfig:n,workspace:a,workspaceRoot:o})}finally{await te.finish()}};export{jc as default};
|