@visulima/vis 6.1.0 → 6.1.1
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 +43 -0
- package/dist/bin.js +1 -1
- package/dist/binx.js +1 -1
- package/dist/config/index.d.ts +1226 -1216
- package/dist/packem_chunks/bloom-sync.js +1 -1
- package/dist/packem_chunks/cargo-lock.js +5 -0
- package/dist/packem_chunks/cargo-plan.js +3 -3
- package/dist/packem_chunks/catalog-detector.js +1 -1
- package/dist/packem_chunks/catalog.js +1 -94
- package/dist/packem_chunks/catalog2.js +11 -0
- package/dist/packem_chunks/cli-exec.js +1 -1
- package/dist/packem_chunks/cli-main.js +156 -174
- package/dist/packem_chunks/context.js +8 -0
- package/dist/packem_chunks/fix.js +1 -1
- package/dist/packem_chunks/handler10.js +1 -1
- package/dist/packem_chunks/handler12.js +1 -1
- package/dist/packem_chunks/handler13.js +1 -1
- package/dist/packem_chunks/handler14.js +1 -1
- package/dist/packem_chunks/handler15.js +1 -1
- package/dist/packem_chunks/handler19.js +5 -5
- package/dist/packem_chunks/handler2.js +1 -1
- package/dist/packem_chunks/handler20.js +1 -1
- package/dist/packem_chunks/handler21.js +1 -1
- package/dist/packem_chunks/handler23.js +1 -1
- package/dist/packem_chunks/handler24.js +1 -1
- package/dist/packem_chunks/handler25.js +1 -1
- package/dist/packem_chunks/handler28.js +1 -1
- package/dist/packem_chunks/handler3.js +1 -1
- package/dist/packem_chunks/handler31.js +1 -1
- package/dist/packem_chunks/handler32.js +1 -1
- package/dist/packem_chunks/handler33.js +1 -1
- package/dist/packem_chunks/handler34.js +3 -3
- package/dist/packem_chunks/handler35.js +1 -1
- package/dist/packem_chunks/handler36.js +1 -1
- package/dist/packem_chunks/handler38.js +2 -2
- package/dist/packem_chunks/handler39.js +5 -5
- package/dist/packem_chunks/handler4.js +4 -4
- package/dist/packem_chunks/handler40.js +1 -1
- package/dist/packem_chunks/handler41.js +1 -1
- package/dist/packem_chunks/handler42.js +1 -1
- package/dist/packem_chunks/handler43.js +1 -1
- package/dist/packem_chunks/handler44.js +1 -1
- package/dist/packem_chunks/handler45.js +1 -1
- package/dist/packem_chunks/handler46.js +1 -1
- package/dist/packem_chunks/handler47.js +1 -1
- package/dist/packem_chunks/handler48.js +1 -1
- package/dist/packem_chunks/handler49.js +1 -1
- package/dist/packem_chunks/handler5.js +4 -4
- package/dist/packem_chunks/handler50.js +5 -5
- package/dist/packem_chunks/handler52.js +1 -1
- package/dist/packem_chunks/handler54.js +2 -2
- package/dist/packem_chunks/handler55.js +1 -1
- package/dist/packem_chunks/handler56.js +3 -3
- package/dist/packem_chunks/handler57.js +4 -4
- package/dist/packem_chunks/handler58.js +4 -4
- package/dist/packem_chunks/handler59.js +2 -2
- package/dist/packem_chunks/handler6.js +7 -7
- package/dist/packem_chunks/handler60.js +1 -1
- package/dist/packem_chunks/handler61.js +2 -2
- package/dist/packem_chunks/handler62.js +1 -1
- package/dist/packem_chunks/handler63.js +3 -3
- package/dist/packem_chunks/handler64.js +3 -3
- package/dist/packem_chunks/handler65.js +2 -2
- package/dist/packem_chunks/handler66.js +2 -2
- package/dist/packem_chunks/handler67.js +5 -5
- package/dist/packem_chunks/handler68.js +12 -25
- package/dist/packem_chunks/handler69.js +25 -22
- package/dist/packem_chunks/handler70.js +22 -10
- package/dist/packem_chunks/handler71.js +10 -133
- package/dist/packem_chunks/handler72.js +133 -23
- package/dist/packem_chunks/handler73.js +23 -323
- package/dist/packem_chunks/handler74.js +274 -659
- package/dist/packem_chunks/handler75.js +708 -48
- package/dist/packem_chunks/handler76.js +48 -27
- package/dist/packem_chunks/handler77.js +27 -3
- package/dist/packem_chunks/handler78.js +3 -191
- package/dist/packem_chunks/handler79.js +191 -0
- package/dist/packem_chunks/handler8.js +1 -1
- package/dist/packem_chunks/heal.js +2 -2
- package/dist/packem_chunks/help-command.js +1 -1
- package/dist/packem_chunks/index2.js +3 -58
- package/dist/packem_chunks/index3.js +40 -3
- package/dist/packem_chunks/index6.js +135 -7
- package/dist/packem_chunks/index7.js +7 -135
- package/dist/packem_chunks/keys-refresh.js +1 -1
- package/dist/packem_chunks/list.js +2 -2
- package/dist/packem_chunks/prune.js +1 -1
- package/dist/packem_chunks/python-plan.js +3 -3
- package/dist/packem_chunks/python-projects.js +1 -1
- package/dist/packem_chunks/python.js +1 -0
- package/dist/packem_chunks/run.js +1 -1
- package/dist/packem_chunks/snapshot.js +2 -2
- package/dist/packem_chunks/state.js +2 -2
- package/dist/packem_chunks/status.js +1 -1
- package/dist/packem_chunks/sync.js +1 -1
- package/dist/packem_chunks/verify-lockfile.js +1 -1
- package/dist/packem_chunks/version-resolver.js +1 -1
- package/dist/packem_chunks/workspace.js +2 -2
- package/dist/packem_shared/ReleaseClient-CWD9BC5w.js +1 -0
- package/dist/packem_shared/advisories-BodWQ5DQ.js +1 -0
- package/dist/packem_shared/{affected-selection-DGb6Xu5K.js → affected-selection-QaMUnFqe.js} +1 -1
- package/dist/packem_shared/{ai-analysis-pldoS_N4.js → ai-analysis-D7jlbJky.js} +3 -3
- package/dist/packem_shared/ai-cache-iSIyY3So.js +1 -0
- package/dist/packem_shared/{ai-fix-D9MxigBQ.js → ai-fix-CgCyO65Q.js} +6 -6
- package/dist/packem_shared/apply-DoeQAAGm.js +6 -0
- package/dist/packem_shared/apply-release-plan-BalHtK-g.js +15 -0
- package/dist/packem_shared/{bin-AZQv95jh.js → bin-LyW9KY0i.js} +1 -1
- package/dist/packem_shared/clean-package-json-rutwkKl-.js +1 -0
- package/dist/packem_shared/createAdapter-DMK4bBET.js +1 -0
- package/dist/packem_shared/createVersionActions-DXo4z8VN.js +1 -0
- package/dist/packem_shared/dependency-scan-DFnt1mni.js +1 -0
- package/dist/packem_shared/{ecosystem-gate-DiqQj0LJ.js → ecosystem-gate-Bdz-gK_Y.js} +1 -1
- package/dist/packem_shared/env-BSXG3QKH.js +4 -0
- package/dist/packem_shared/failure-log-DIsKBKaI.js +2 -0
- package/dist/packem_shared/formatBytes-_HvjOy8a-iHCer6uX.js +1 -0
- package/dist/packem_shared/glob-Cyk1H9ZL-DRlUeuow.js +1 -0
- package/dist/packem_shared/{index-JRb5wabN.js → index-B1ZsG3oa.js} +1 -1
- package/dist/packem_shared/index-CgNfNk12.js +1 -0
- package/dist/packem_shared/lifecycle-CQjeMPY0.js +2 -0
- package/dist/packem_shared/missing-package-json-dtwl6w-S.js +1 -0
- package/dist/packem_shared/multi-eco-lockfiles-CyIfYw4u.js +1 -0
- package/dist/packem_shared/npmrc-CHsOyMvA.js +2 -0
- package/dist/packem_shared/osv-C53WUoSW.js +1 -0
- package/dist/packem_shared/{package-version-KLwH0Ivy.js → package-version-DqYSd_ia.js} +1 -1
- package/dist/packem_shared/packument-CbTmbHU4.js +1 -0
- package/dist/packem_shared/{project-name-filter-B1ZCsbOW.js → project-name-filter-mwTJC1IK.js} +1 -1
- package/dist/packem_shared/{provenance-L1M2FPy_.js → provenance-SX1MxPUZ.js} +1 -1
- package/dist/packem_shared/publish-Dc0XGH3K.js +34 -0
- package/dist/packem_shared/registry-CkoaWkjP.js +81 -0
- package/dist/packem_shared/registry-keys-z038Ecb4.js +1 -0
- package/dist/packem_shared/removeSync-g1D5kONg-LbjATA8v.js +1 -0
- package/dist/packem_shared/renderToString-DR0zDUjh-C7p-L6AO.js +3 -0
- package/dist/packem_shared/{resolve-explicit-CQa37JSq.js → resolve-explicit-D9kdTNvl.js} +1 -1
- package/dist/packem_shared/{run-D-uVGHQ4.js → run-DLvd3RIZ.js} +1 -1
- package/dist/packem_shared/run-summary-utils-CMeURYtS.js +1 -0
- package/dist/packem_shared/s1ngularity-BuU9Cxpy.js +1 -0
- package/dist/packem_shared/{scaffold-files-DVyfB0yz.js → scaffold-files-Bje3_Ixv.js} +1 -1
- package/dist/packem_shared/scan-progress-D8ojNcKt.js +2 -0
- package/dist/packem_shared/{signatures-DIqFUOfs.js → signatures-CeL0bOEo.js} +1 -1
- package/dist/packem_shared/spinner-Bqjpz3i4.js +1 -0
- package/dist/packem_shared/table-DDAJalPF.js +1 -0
- package/dist/packem_shared/tabs-CC0GJLww.js +1 -0
- package/dist/packem_shared/{task-env-DzR4RkOj.js → task-env-C2lmxvzA.js} +1 -1
- package/dist/packem_shared/typosquats-BFKus_aM.js +1 -0
- package/dist/packem_shared/use-measured-height-_nYuZ-Au.js +1 -0
- package/dist/packem_shared/vis-update-app-Ba5ce8Jd.js +1 -0
- package/dist/packem_shared/{vis-user-error-CRmrBaD1.js → vis-user-error-D_ekz9rF.js} +1 -1
- package/dist/packem_shared/{watch-loop-D1_e-qIl.js → watch-loop-DWr41vHM.js} +1 -1
- package/dist/packem_shared/xxh3-BLHlvhgT.js +1 -0
- package/dist/release/core/package-managers/index.js +1 -1
- package/dist/release/core/version-actions/index.js +1 -1
- package/dist/release/index.js +1 -1
- package/index.js +26 -26
- package/package.json +9 -9
- package/dist/packem_chunks/orchestrator.js +0 -46
- package/dist/packem_shared/ReleaseClient-DAvbxCdo.js +0 -1
- package/dist/packem_shared/createAdapter-F7GidOzU.js +0 -1
- package/dist/packem_shared/createVersionActions-ByaJ1Nbv.js +0 -1
- package/dist/packem_shared/dependency-scan-CawAKoU_.js +0 -1
- package/dist/packem_shared/failure-log-BP-gCUb5.js +0 -2
- package/dist/packem_shared/formatBytes-_HvjOy8a-B_qQr4Hw.js +0 -4
- package/dist/packem_shared/glob-Cyk1H9ZL-Dxlf9Swz.js +0 -1
- package/dist/packem_shared/index-CDHP1kby.js +0 -1
- package/dist/packem_shared/lifecycle-DvmDIRbb.js +0 -2
- package/dist/packem_shared/missing-package-json-Cu5YVAot.js +0 -1
- package/dist/packem_shared/multi-eco-lockfiles-B2X3yhyo.js +0 -1
- package/dist/packem_shared/packument-zb18Jnlw.js +0 -1
- package/dist/packem_shared/registry-keys-DxdqMzyp.js +0 -1
- package/dist/packem_shared/s1ngularity-CO5GkkqX.js +0 -1
- package/dist/packem_shared/scan-progress-RwCRxJdX.js +0 -2
- package/dist/packem_shared/spinner-BJjbNl1F.js +0 -1
- package/dist/packem_shared/tabs--uxJGL8N.js +0 -1
- package/dist/packem_shared/typosquats-D4DEHhFy.js +0 -1
- package/dist/packem_shared/use-measured-height-DUZyyias.js +0 -1
- package/dist/packem_shared/vis-update-app-9b2kSk9f.js +0 -1
|
@@ -1,191 +1,3 @@
|
|
|
1
|
-
import{createRequire as
|
|
2
|
-
Delete this file to be asked again.
|
|
3
|
-
`)}catch{}},wi=(s,e="npm")=>{const t=`${e} install`;if((e==="pnpm"||e==="aube")&&Oe(le(s,at))&&hi(s))return{file:at,installCommand:t};const r=le(s,"package.json"),c=Hs(r);if(!c)return;const o=fi(e);o==="pnpm.overrides"?(c.pnpm??={},c.pnpm.overrides??={},c.pnpm.overrides[xe]=ct):(c[o]??={},c[o][xe]=ct);try{$t(r,`${JSON.stringify(c,void 0,4)}
|
|
4
|
-
`)}catch{return}return{file:"package.json",installCommand:t}},vi=async(s,e)=>{const t=mi(s,e.projectManifests);if(!t.present||t.alreadyOverridden||t.declined)return!1;const r=nn({input:process.stdin,output:process.stdout});try{e.logger.info(`Detected ${xe}. Its cache hints no-op under @visulima/task-runner unless aliased to ${Et} (a drop-in replacement).`);const c=await new Promise(i=>{r.question("Add the override now? [y/N] ",i)});if(!/^y(?:es)?$/i.test(c.trim()))return gi(s),e.logger.info("Skipped. Delete .vis/.vite-client-override-declined to be asked again."),!1;const o=wi(s,t.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 "${xe}": "${ct}" to ${o.file}. Run \`${o.installCommand}\` to apply it.`),!0)}finally{r.close()}},yi=new Set(["cache","command","dependsOn","fingerprintEnv","hashMode","inputs","outputs","parallelism","splitCompound","untrackedEnv"]),xi=s=>s?Object.keys(s).filter(e=>yi.has(e)).toSorted():[],ji=(s,e)=>`${s}: ${e.map(t=>`"${t}"`).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".`,ki=({interactive:s,taskPty:e,workspacePty:t})=>e===!0?!0:e===!1?!1:s&&t!==!1,bi=s=>s.split(",").map(e=>e.trim()).filter(e=>e!==""),Si=(s,e,t)=>{const r=new Set,c=[];if(s===void 0||s.trim()==="")return{skipTaskIds:r,unmatchedPatterns:c};const o=[...t],i=new Set(o),d=new Map;for(const u of o){const p=u.lastIndexOf(":");if(p===-1)continue;const f=u.slice(p+1),m=d.get(f);m===void 0?d.set(f,[u]):m.push(u)}for(const u of bi(s)){if(u.startsWith("~:"))throw new Error(`--skip-cache does not support the closest-project selector "~:" (received "${u}"). Use \`pkg:target\`, \`:target\`, or \`#tag:target\`.`);if(i.has(u)){r.add(u);continue}const p=Cn(u);if(!p){c.push(u);continue}let f=!1;switch(p.kind){case"all":{const m=d.get(p.target)??[];for(const a of m)r.add(a),f=!0;break}case"project":{const m=p.projects?.[0];if(m!==void 0){const a=`${m}:${p.target}`;i.has(a)&&(r.add(a),f=!0)}break}case"tag":{const{tag:m}=p;if(m!==void 0){const a=d.get(p.target)??[];for(const k of a){const S=k.slice(0,k.lastIndexOf(":"));e.projects[S]?.tags?.includes(m)===!0&&(r.add(k),f=!0)}}break}}f||c.push(u)}return{skipTaskIds:r,unmatchedPatterns:c}},Ti=/\$(?:\{([A-Z_]\w*)(:-[^}]*)?\}|([A-Z_]\w*))/gi,$i=new Set(["0","!","#","$","*","-","?","@","_"]),Ci=s=>{const e=new Map;for(const t of s.matchAll(Ti)){const r=t[1],c=t[3],o=t[2],i=r??c;if(i===void 0||$i.has(i))continue;const d=o!==void 0,u=e.get(i);u===void 0?e.set(i,d):u&&!d&&e.set(i,!1)}return[...e.entries()].map(([t,r])=>({hasDefault:r,name:t}))},Ii=s=>{const{command:e,processEnv:t,taskEnv:r,taskId:c}=s,o=Ci(e);if(o.length===0)return;const i=[];for(const{hasDefault:d,name:u}of o){if(d)continue;const p=r[u],f=t[u];p===void 0&&f===void 0&&i.push(u)}if(i.length!==0)return{missing:i.toSorted(),taskId:c}},Ei=s=>{const e=s.missing.map(t=>`$${t}`).join(", ");return`Strict env: ${s.taskId} references unset variable${s.missing.length===1?"":"s"} ${e}. Set ${s.missing.length===1?"it":"them"} in the task env, an envFile, or the parent shell — or opt out with options.strictEnv: false.`},Ri=64*1024,hs=256,Pi=new RegExp("[\x1B]\\[[0-?]*[ -/]*[@-~]","g"),vt=s=>s.replaceAll(Pi,"").replaceAll("\r","");class ps{#e=[];#r=new Set;#s=new Map;#n=new Map;constructor(e=[]){for(const t of e)this.#n.set(t,{id:t,status:"pending",tailLines:[]});this.#e=[...e],this.#i()}getSnapshot=()=>this.#s;subscribe=e=>(this.#r.add(e),()=>{this.#r.delete(e)});getIds(){return this.#e}getState(e){return this.#n.get(e)}getDockState(){let e=!1,t=!1;for(const r of this.#n.values())r.status==="crashed"||r.status==="failed"?e=!0:(r.status==="pending"||r.status==="starting")&&(t=!0);return e?"crash":t?"boot":"ready"}registerService(e){this.#n.has(e)||(this.#n.set(e,{id:e,status:"pending",tailLines:[]}),this.#e=[...this.#e,e],this.#o())}markStarting(e){this.#t(e,t=>({...t,errorMessage:void 0,startedAt:t.startedAt??Date.now(),status:"starting"}))}markStarted(e,t){this.#t(e,r=>({...r,startedAt:r.startedAt??Date.now(),status:r.status==="ready"?"ready":"starting"}))}markReady(e,t){this.#t(e,r=>({...r,errorMessage:void 0,port:t.port,readyAt:Date.now(),status:"ready"}))}markFailed(e,t,r){const c=r?.message;this.#t(e,o=>({...o,errorMessage:vt(c??t),status:"failed"}))}markCrashed(e,t){const r=t.slice(-hs).map(c=>vt(c));this.#t(e,c=>({...c,errorMessage:r.length>0?r[r.length-1]:"process exited",status:"crashed",tailLines:r}))}appendLog(e,t){const r=t.split(`
|
|
5
|
-
`).map(c=>vt(c)).filter(c=>c.length>0);r.length!==0&&this.#t(e,c=>{const o=[...c.tailLines,...r];for(;o.length>hs;)o.shift();let i=0;for(let d=o.length-1;d>=0;d--)if(i+=o[d].length+1,i>Ri){o.splice(0,d+1);break}return{...c,lastLine:r[r.length-1],tailLines:o}})}abortBoot(e){let t=!1;const r=new Map(this.#n);for(const[c,o]of r)(o.status==="pending"||o.status==="starting")&&(r.set(c,{...o,errorMessage:e,status:"failed"}),t=!0);t&&(this.#n=r,this.#i(),this.#o())}#t(e,t){const r=this.#n.get(e);r&&(this.#n.set(e,t(r)),this.#i(),this.#o())}#i(){this.#s=new Map(this.#n)}#o(){for(const e of this.#r)try{e()}catch{}}}const Mi=(s,e)=>{if(s===e)return!0;if(!s||!e||s.length!==e.length)return!1;for(const[t,r]of s.entries())if(!Object.is(r,e[t]))return!1;return!0},ms=({children:s,deps:e,onRender:t,style:r,width:c})=>{const o=K.useRef(null),i=K.useRef(!1),d=K.useRef(e),u=K.useRef(s),p=K.useRef(t);p.current=t;let f=!1;e!==void 0?Mi(d.current,e)||(f=!0,d.current=e):s!==u.current&&(f=!0,u.current=s),f&&(i.current=!1,o.current&&(o.current.cachedRender=void 0)),K.useLayoutEffect(()=>{const a=o.current;a&&(a.internal_onRendered=()=>{i.current=!0,p.current?.(a)})}),K.useEffect(()=>()=>{const a=o.current;a&&(a.cachedRender=void 0,a.internal_onRendered=void 0)},[]);const m=K.useMemo(()=>({...r,width:c}),[r,c]);return n.jsx("ink-static-render",{ref:o,style:m,children:i.current?null:s()})},Fi=s=>Array.isArray(s)?`[${s.join(",")}]`:typeof s=="object"&&s!==null?JSON.stringify(s):String(s),Oi=(s,e,t)=>e==="_"?`${s}${Array.isArray(t)?t.join(" "):String(t)}`:`${s}--${e}=${Fi(t)}`,Rt=(s,e,t)=>{const r=new Set(new Set(t.map(a=>a.target.target))),c=new Set(new Set(t.map(a=>a.target.project))),o=e.filter(a=>r.has(a)),i=s.filter(a=>c.has(a)),d=t.length-i.length*o.length,u=o.length===1?"target":"targets",p=o.join(", "),f=i.length===1?`project ${i[0]}`:`${i.length} projects`;let m=`${u} ${p} for ${f}`;return d>0&&(m+=` and ${d} ${d===1?"task":"tasks"} ${d===1?"it depends":"they depend"} on`),m},Ai={error:"red",info:"white",success:"green"},jt=({children:s,title:e,variant:t})=>{const r=Ai[t];return n.jsxs(w,{flexDirection:"column",children:[n.jsxs(w,{gap:1,children:[n.jsx(l,{bold:!0,inverse:!0,children:" VIS "}),n.jsx(l,{bold:!0,color:r,children:"•"}),n.jsx(l,{children:e})]}),s]})},Ws=({cached:s,failed:e,failedIds:t,projectNames:r,retriedIds:c,skippedIds:o,succeeded:i,targets:d,tasks:u,took:p})=>{const f=Rt(r,d,u),m=c??[];if(e===0&&(!o||o.length===0)){const a=s>0?` (${s} read from cache)`:"";return n.jsx(ms,{children:()=>n.jsx(jt,{title:`Successfully ran ${f}`,variant:"success",children:n.jsxs(w,{flexDirection:"column",marginTop:1,paddingLeft:3,children:[n.jsxs(l,{children:[n.jsx(l,{color:"green",children:As})," ",i+s," tasks completed",a?n.jsx(l,{dimColor:!0,children:a}):null,n.jsx(l,{dimColor:!0,children:` · Took ${p}`})]}),m.length>0&&n.jsxs(w,{flexDirection:"column",marginTop:1,children:[n.jsxs(l,{children:[n.jsx(l,{color:"yellow",children:"↻"})," ",n.jsx(l,{color:"yellow",children:String(m.length)})," task",m.length===1?"":"s"," succeeded after retry:"]}),m.map(k=>n.jsxs(l,{children:[" ",n.jsx(l,{color:"yellow",children:"↻"})," ",k]},k))]})]})})})}return n.jsx(ms,{children:()=>n.jsx(jt,{title:`Ran ${f}`,variant:"error",children:n.jsxs(w,{flexDirection:"column",marginTop:1,paddingLeft:3,children:[o&&o.length>0&&n.jsxs(w,{flexDirection:"column",children:[n.jsxs(l,{dimColor:!0,children:[o.length," ","task",o.length===1?"":"s"," ","skipped (dependency failed or --bail)"]}),o.map(a=>n.jsxs(l,{dimColor:!0,children:[" - ",a]},a)),n.jsx(l,{})]}),e>0&&n.jsxs(w,{flexDirection:"column",children:[n.jsxs(l,{children:[n.jsx(l,{color:"red",children:String(e)})," ","task",e===1?"":"s"," ","failed:"]}),t.map(a=>n.jsxs(l,{children:[" ",n.jsx(l,{color:"red",children:Ls})," ",a]},a)),n.jsx(l,{})]}),m.length>0&&n.jsxs(w,{flexDirection:"column",children:[n.jsxs(l,{children:[n.jsx(l,{color:"yellow",children:String(m.length)})," ","task",m.length===1?"":"s"," ","finished after retry:"]}),m.map(a=>n.jsxs(l,{children:[" ",n.jsx(l,{color:"yellow",children:"↻"})," ",a]},a)),n.jsx(l,{})]}),n.jsx(l,{dimColor:!0,children:` Took ${p}`})]})})})};class lt{#e;#r=new Set;#s=new Map;constructor(e,t){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:t??e.length,viewMode:"list"}}getSnapshot=()=>this.#e;subscribe=e=>(this.#r.add(e),()=>{this.#r.delete(e)});startTasks(e){const t=[...this.#e.rows];for(const r of e){const c=t.findIndex(o=>o.taskId===r.id);c!==-1&&(t[c]={...t[c],elapsed:0,status:"running"},this.#s.set(r.id,process.hrtime()))}this.#t({...this.#e,rows:t,running:this.#e.running+e.length})}endTasks(e){const t=[...this.#e.rows];let{cached:r,completed:c,failed:o,succeeded:i}=this.#e;const d=new Map(this.#e.outputs),u=[...this.#e.retriedIds];for(const m of e){const a=t.findIndex(k=>k.taskId===m.task.id);switch(a!==-1&&(t[a]={...t[a],duration:m.startTime&&m.endTime?m.endTime-m.startTime:void 0,retryAttempts:m.retryAttempts,status:m.status}),m.retryAttempts&&m.retryAttempts>0&&u.push(m.task.id),c++,m.status){case"failure":{o++;break}case"local-cache":case"local-cache-kept-existing":case"remote-cache":{r++;break}case"success":{i++;break}}m.terminalOutput&&!d.has(m.task.id)&&d.set(m.task.id,m.terminalOutput),this.#s.delete(m.task.id)}let{selectedIndex:p}=this.#e;if(o>this.#e.failed){const m=t.findIndex(a=>a.status==="failure");m!==-1&&(p=m)}const f=Math.max(0,this.#e.running-e.length);this.#t({...this.#e,cached:r,completed:c,failed:o,outputs:d,retriedIds:u,rows:t,running:f,selectedIndex:p,succeeded:i})}static#n=256*1024;addOutput(e,t){if(!t.trim())return;let r=(this.#e.outputs.get(e)??"")+t;r.length>lt.#n&&(r=r.slice(-lt.#n)),this.#e.outputs.set(e,r),this.#t({...this.#e})}setOutput(e,t){this.#e.outputs.set(e,t),this.#t({...this.#e})}markDone(){this.#t({...this.#e,done:!0,endTime:Date.now()})}unmarkDone(){this.#t({...this.#e,autoExitCountdown:null,done:!1,endTime:null})}tick(){if(this.#s.size===0)return;let e=!1;const t=[...this.#e.rows];for(let r=0;r<t.length;r++){const c=t[r];if(c.status==="running"){const o=this.#s.get(c.taskId);if(o){const i=process.hrtime(o),d=i[0]*1e3+i[1]/1e6;t[r]={...c,elapsed:d},e=!0}}}e&&this.#t({...this.#e,rows:t})}setSelectedIndex(e){e!==this.#e.selectedIndex&&this.#t({...this.#e,selectedIndex:e})}setFocusedPanel(e){e!==this.#e.focusedPanel&&this.#t({...this.#e,focusedPanel:e})}setFilter(e){this.#t({...this.#e,filterText:e,selectedIndex:0})}setFilterActive(e){e!==this.#e.filterActive&&this.#t({...this.#e,filterActive:e,filterText:e?this.#e.filterText:"",selectedIndex:0})}pinTask(e,t){const r=[...this.#e.pinnedTaskIds];r[e]=t,this.#t({...this.#e,pinnedTaskIds:r})}clearPins(){this.#t({...this.#e,pinnedTaskIds:[null,null]})}requestRetry(e){const t=[...this.#e.rows],r=t.findIndex(d=>d.taskId===e);let{completed:c,failed:o,succeeded:i}=this.#e;if(r!==-1){const d=t[r].status;d==="failure"?(o=Math.max(0,o-1),c=Math.max(0,c-1)):d==="success"&&(i=Math.max(0,i-1),c=Math.max(0,c-1)),t[r]={...t[r],elapsed:0,retryAttempts:void 0,status:"running"},this.#s.set(e,process.hrtime())}this.#t({...this.#e,completed:c,done:!1,endTime:null,failed:o,interactiveMode:!1,retriedIds:this.#e.retriedIds.filter(d=>d!==e),retryTaskId:e,rows:t,succeeded:i})}acknowledgeRetry(){const e=this.#e.retryTaskId;return e&&this.#t({...this.#e,retryTaskId:null}),e}setInteractiveMode(e){e!==this.#e.interactiveMode&&this.#t({...this.#e,interactiveMode:e})}setViewMode(e){e!==this.#e.viewMode&&this.#t({...this.#e,viewMode:e})}setStatusFilter(e){this.#t({...this.#e,selectedIndex:0,statusFilter:e})}requestRerun(){this.#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 t of this.#r)try{t()}catch{}}}const Li=27,Di={95:"apc",80:"dcs",94:"pm",88:"sos"},Bi={159:"apc",144:"dcs",158:"pm",152:"sos"},qs=s=>s===155||s===157||s===144||s===152||s===158||s===159,Vs=(s,e)=>{for(let t=e;t<s.length;t+=1){const r=s.codePointAt(t);if(r>=64&&r<=126)return t}return-1},dt=(s,e,t)=>{for(let r=e;r<s.length;r+=1){const c=s.codePointAt(r);if(c===156||t&&c===7)return r;if(c===27&&s.codePointAt(r+1)===92)return r+1}return-1},_i=(s,e)=>{const t=s.codePointAt(e+1);if(t===91){const r=Vs(s,e+2);return r===-1?void 0:{end:r,kind:"csi"}}if(t===93){const r=dt(s,e+2,!0);return r===-1?void 0:{end:r,kind:"osc"}}if(t===80||t===88||t===94||t===95){const r=dt(s,e+2,!1),c=Di[t];return r===-1?void 0:{end:r,kind:c}}return t===void 0?void 0:{end:e+1,kind:"escape"}},Ni=(s,e)=>{const t=s.codePointAt(e);if(t===155){const r=Vs(s,e+1);return r===-1?void 0:{end:r,kind:"csi"}}if(t===157){const r=dt(s,e+1,!0);return r===-1?void 0:{end:r,kind:"osc"}}if(t===144||t===152||t===158||t===159){const r=dt(s,e+1,!1),c=Bi[t];return r===-1?void 0:{end:r,kind:c}}},Gi=s=>{if(s.includes(String.fromCodePoint(27)))return!0;for(let e=0;e<s.length;e+=1)if(qs(s.codePointAt(e)))return!0;return!1},Hi=s=>{if(!Gi(s))return s;let e="",t=0,r=0;const{length:c}=s;for(;r<c;){const o=s.codePointAt(r);let i;if(o===Li)i=_i(s,r);else if(qs(o))i=Ni(s,r);else{r+=1;continue}const d=i===void 0?c-1:i.end;e+=s.slice(t,r),t=d+1,r=d+1}return e+=s.slice(t),e},Wi=s=>Hi(s),qi=/^(?<name>(?:[A-Z][\w$]*)?(?:Error|Exception))(?::[ \t](?<message>.*))?$/,Vi=/^\s*at\s+/,Ui=s=>{const e=s.split(`
|
|
6
|
-
`);let t;for(let r=0;r<e.length;r++){const c=qi.exec(e[r].trim());if(!c)continue;const o=[];for(let i=r+1;i<e.length&&i<=r+200;i++){const d=e[i];if(Vi.test(d))o.push(d.trim());else{if(o.length>0)break;if(d.trim()!=="")break}}if(o.length>0){const i=c.groups?.name??"Error",d=c.groups?.message??"";t={message:d,name:i,stack:`${i}: ${d}
|
|
7
|
-
${o.map(u=>` ${u}`).join(`
|
|
8
|
-
`)}`}}}return t},Us=s=>{if(s.startsWith("file://"))try{return Dn(s)}catch{return s}return s},zi=s=>!s.includes("node_modules")&&!s.startsWith("node:")&&!s.startsWith("internal/"),Yi=s=>{try{return qn(s)}catch{return}},Ki=(s,e)=>{if(!s.file||s.line===void 0)return;const t=Us(s.file),r=On(t)?t:os(e,t);if(!zi(r)||!Oe(r))return;const c=Yi(r);if(c){const o=Hn(c,{column:s.column===void 0?0:Math.max(0,s.column-1),line:s.line});if(o.source&&o.line!=null){const i=os(An(r),o.source),u=Wn(c,o.source)??(Oe(i)?Ne(i,"utf8"):void 0);if(u!==void 0)return{column:o.column==null?void 0:o.column+1,file:i,line:o.line,source:u}}}return{column:s.column,file:r,line:s.line,source:Ne(r,"utf8")}},gs=(s,e)=>{const t=Ln(e,s);return t&&!t.startsWith("..")?t:s},zs=(s,e)=>{if(!s?.trim())return s;try{const t=Ui(Wi(s));if(!t)return s;const r=new Error(t.message);r.name=t.name,r.stack=t.stack;const c=Nn(r);if(c.length===0)return s;const o=e.color,i={dim:a=>o?cs(a):a,head:a=>o?_n(wt(a)):a,loc:a=>o?Bn(a):a};let d,u;for(const a of c){const k=Ki(a,e.cwd);if(k){d=k,u=a;break}}const p=[i.head(`✖ ${t.name}${t.message?`: ${t.message}`:""}`)];if(d){const a=`${gs(d.file,e.cwd)}:${d.line}${d.column?`:${d.column}`:""}`;p.push(` ${i.loc(a)}`,""),p.push(Gn(d.source,{start:{column:d.column,line:d.line}},{color:o?{gutter:cs,marker:wt,message:wt}:void 0,linesAbove:2,linesBelow:3}))}const f=c.filter(a=>a!==u).slice(0,8).map(a=>{const k=a.methodName??"<anonymous>",S=a.file?`${gs(Us(a.file),e.cwd)}${a.line?`:${a.line}`:""}`:"";return i.dim(` at ${k}${S?` (${S})`:""}`)});f.length>0&&p.push("",...f);const m=i.dim("─".repeat(40));return`${p.join(`
|
|
9
|
-
`)}
|
|
10
|
-
${m}
|
|
11
|
-
${s}`}catch{return s}},Xi={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"]},Ae=s=>li(s,Xi),_e=s=>s==="local-cache"||s==="local-cache-kept-existing"||s==="remote-cache",Ge=s=>{switch(s){case"failure":return{color:"red",icon:Ls};case"local-cache":case"local-cache-kept-existing":case"remote-cache":case"success":return{color:"green",icon:As};case"skipped":return{color:"gray",icon:ft};default:return{color:"gray",icon:"?"}}},Xe=s=>{const{color:e,icon:t}=Ge(s);return me(Q.createElement(l,{color:e},t),{columns:10}).trim()},Ji=s=>{const{color:e,icon:t}=Ge(s);switch(s){case"local-cache":case"local-cache-kept-existing":case"remote-cache":return me(Q.createElement(l,null,Q.createElement(l,{color:e},t)," ",Q.createElement(l,{color:"cyan"},"[cache]")),{columns:30}).trim();case"skipped":return me(Q.createElement(l,null,Q.createElement(l,{dimColor:!0},t)," ",Q.createElement(l,{dimColor:!0},"[skipped]")),{columns:30}).trim();default:return me(Q.createElement(l,{color:e},t),{columns:10}).trim()}},Qi=s=>s==="azure"||s==="buildkite"||s==="github"||s==="gitlab"||s==="off"?s:process.env.GITHUB_ACTIONS==="true"?"github":process.env.GITLAB_CI==="true"?"gitlab":process.env.BUILDKITE==="true"?"buildkite":process.env.TF_BUILD?.toLowerCase()==="true"?"azure":"off",Zi=s=>{const e=s.replaceAll(/\W+/g,"_"),t=Vn("sha256").update(s).digest("hex").slice(0,6);return`${e}_${t}`},eo=(s,e,t,r="auto")=>{const c=t.trim();if(!c)return;const o=`
|
|
12
|
-
`,i=Qi(r);if(i==="github"){process.stdout.write(`::group::${Xe(e)} ${s}${o}`),process.stdout.write(c+o),process.stdout.write(`::endgroup::${o}`);return}if(i==="gitlab"){const m=Math.floor(Date.now()/1e3),a=Zi(s),k=e==="failure"?"":"[collapsed=true]",S="\x1B[0K";process.stdout.write(`${S}section_start:${String(m)}:${a}${k}\r${S}${Xe(e)} ${s}${o}`),process.stdout.write(c+o);const M=Math.floor(Date.now()/1e3);process.stdout.write(`${S}section_end:${String(M)}:${a}\r${S}${o}`);return}if(i==="buildkite"){const m=e==="failure"?"+++":"---";process.stdout.write(`${m} ${Xe(e)} ${s}${o}`),process.stdout.write(c+o);return}if(i==="azure"){process.stdout.write(`##[group]${Xe(e)} ${s}${o}`),process.stdout.write(c+o),process.stdout.write(`##[endgroup]${o}`);return}const d=process.stdout.columns||80,u=me(Q.createElement(l,{dimColor:!0},ft.repeat(d)),{columns:d}).trim(),p=Ji(e),f=me(Q.createElement(l,{bold:!0},s),{columns:d}).trim();process.stdout.write(`${u}${o}`),process.stdout.write(`${p} ${f}${o}`),process.stdout.write(c+o),process.stdout.write(`${u}${o}`)},to=s=>s==="running"?{color:"white",icon:"•"}:s==="pending"?{color:"gray",icon:"·"}:Ge(s),so=({autoScroll:s,focused:e,interactiveMode:t,showFullscreenHint:r,statusValue:c,supportsInteractive:o,taskId:i})=>{if(!i)return;if(t)return"Esc cancel | Enter send";const d=s?"":" PAUSED (f resume)",u=o?" i INPUT":"";return e&&c==="running"&&r?`⏎ FULLSCREEN${u} f FOLLOW${d}`:e&&c==="running"?`f FOLLOW${u}${d}`:e&&r?`<enter> full screen${d}`:e?d||void 0:"<tab> or <enter> to focus"},ws=({autoScroll:s=!0,duration:e,focused:t,interactiveMode:r,output:c,scrollRef:o,showFullscreenHint:i,status:d,supportsInteractive:u=!0,taskId:p})=>{const f=d??"pending",{icon:m}=to(f),a=t?"bold":"single",k=f==="failure"?"red":f==="success"||_e(f)?t?"green":"gray":f==="running"?t?"white":"cyan":t?"white":"gray",S=p?`${m} ${p}`:void 0,M=e===void 0?void 0:Ae(e),Z=so({autoScroll:s,focused:t,interactiveMode:r??!1,showFullscreenHint:i??!1,statusValue:f,supportsInteractive:u,taskId:p});if(!p)return n.jsxs(w,{alignItems:"center",borderColor:"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,justifyContent:"center",paddingX:2,paddingY:1,children:[n.jsx(l,{dimColor:!0,children:"Select a task to view output"}),n.jsx(l,{dimColor:!0,children:"Press Enter or 1/2 to pin"})]});const b=[];if(c)for(const g of c.split(`
|
|
13
|
-
`))b.push(g.endsWith("\r")?g.slice(0,-1):g);return!c&&(f==="running"||f==="pending")?n.jsx(w,{borderBottomTitle:Z,borderColor:k,borderStyle:a,borderTopRightTitle:M,borderTopTitle:S,flexDirection:"column",flexGrow:1,paddingX:2,paddingY:1,children:n.jsx(w,{alignItems:"center",flexGrow:1,justifyContent:"center",children:n.jsx(l,{dimColor:!0,children:"Waiting for task output…"})})}):n.jsxs(w,{borderBottomTitle:Z,borderColor:r?"yellow":k,borderStyle:a,borderTopRightTitle:M,borderTopTitle:S,flexDirection:"column",flexGrow:1,children:[n.jsx(w,{flexGrow:1,flexShrink:1,paddingY:1,children:n.jsx(Ps,{flexGrow:1,followOutput:s,paddingX:2,ref:o,scrollbar:!0,scrollbarColor:"gray",scrollbarStyle:"block",children:n.jsx(l,{children:b.join(`
|
|
14
|
-
`)})})}),r&&n.jsx(w,{flexShrink:0,justifyContent:"center",paddingX:1,children:n.jsx(l,{bold:!0,color:"yellow",children:"INTERACTIVE | keystrokes forwarded to task | Esc to exit"})})]})},ro={crashed:"✖",failed:"✖",pending:"·",ready:"●",starting:"•"},Ys=s=>s==="ready"?"green":s==="crashed"||s==="failed"?"red":s==="starting"?"cyan":"gray",no=({status:s})=>s==="starting"?n.jsx(l,{color:"cyan",children:n.jsx(Bs,{type:"dots"})}):n.jsx(l,{bold:!0,color:Ys(s),children:ro[s]}),io=({active:s,focused:e,state:t})=>{const r=e&&s,c=r?">":" ",o=t.status==="ready"?t.port?`running, port ${String(t.port)}`:"running":t.status==="failed"||t.status==="crashed"?t.errorMessage??"exited":t.lastLine??"booting…";return n.jsxs(w,{flexDirection:"row",flexShrink:0,overflow:"hidden",children:[n.jsx(l,{children:c}),n.jsx(l,{children:" "}),n.jsx(w,{flexShrink:0,width:3,children:n.jsx(no,{status:t.status})}),n.jsx(w,{flexGrow:0,flexShrink:0,width:28,children:n.jsx(l,{bold:r,inverse:r,children:t.id})}),n.jsx(w,{flexGrow:1,flexShrink:1,overflow:"hidden",children:n.jsxs(l,{color:Ys(t.status),dimColor:t.status!=="crashed"&&t.status!=="failed",wrap:"truncate-end",children:[" ",o]})})]})},oo=({states:s})=>{const e=[];for(const r of s)r.status==="ready"&&e.push(r.id);const t=e.join(", ");return n.jsxs(w,{paddingX:1,children:[n.jsxs(l,{bold:!0,color:"green",children:["● ","Services"]}),n.jsxs(l,{children:[" ",String(e.length)," / ",String(s.length)," running"]}),t.length>0&&n.jsxs(l,{dimColor:!0,children:[" ",t]}),n.jsx(l,{dimColor:!0,children:" [Tab ↓]"})]})},co=({states:s})=>{const e=s.find(t=>t.status==="crashed"||t.status==="failed");return e?n.jsxs(w,{flexDirection:"column",paddingX:1,children:[n.jsxs(l,{bold:!0,color:"red",children:["✖ ","Service crashed:"," ",e.id]}),e.tailLines.slice(-3).map((t,r)=>n.jsxs(l,{color:"red",dimColor:!0,children:[" ",t]},`crash-${String(r)}`))]}):n.jsx(n.Fragment,{})},ao=({activeIndex:s,focused:e,store:t})=>{const r=K.useSyncExternalStore(t.subscribe,t.getSnapshot),c=t.getIds();if(c.length===0)return n.jsx(n.Fragment,{});const o=c.map(f=>r.get(f)).filter(f=>f!==void 0),i=t.getDockState(),d=i==="crash"?"red":i==="ready"?"gray":e?"white":"cyan",u=i==="crash"?"Services (crashed)":i==="ready"?"Services":"Services (starting)",p=e?i==="crash"?"↑↓ select Enter logs R retry Esc back":"↑↓ select Enter logs Esc back":"Tab to focus services";return i==="ready"&&!e?n.jsx(w,{borderColor:d,borderStyle:"single",flexDirection:"row",flexShrink:0,children:n.jsx(oo,{states:o})}):n.jsxs(w,{borderBottomTitle:p,borderColor:d,borderStyle:e?"bold":"single",borderTopTitle:u,flexDirection:"column",flexGrow:2,flexShrink:0,minHeight:6,paddingX:1,children:[i==="crash"&&n.jsx(co,{states:o}),o.map((f,m)=>n.jsx(io,{active:m===s,focused:e,state:f},f.id))]})},Ks=6,Xs=8,Js=12,lo=s=>s==="running"||s==="pending"?Ds:s==="local-cache"||s==="local-cache-kept-existing"?"Local":s==="remote-cache"?"Remote":ft,vs=(s,e)=>e[0]===s?"[1]":e[1]===s?"[2]":"",ys=({compact:s,focused:e,isSelected:t,pinLabel:r,row:c})=>{const{persistent:o,status:i,taskId:d}=c,u=e&&t,p=u?">":" ",f=i==="running"&&o===!0;let m;if(f)m=n.jsx(l,{bold:!0,color:"green",children:" ● "});else if(i==="running")m=n.jsxs(l,{bold:!0,color:"white",children:[" ",n.jsx(Bs,{type:"dots"})," "]});else if(i==="pending")m=n.jsx(l,{bold:!0,color:"gray",children:" · "});else{const{color:k,icon:S}=Ge(i);m=n.jsxs(l,{bold:!0,color:k,children:[" ",S," "]})}let a=Ds;return f?a="running":i!=="running"&&i!=="pending"?a=c.duration===void 0?ft:Ae(c.duration):i==="running"&&c.elapsed!==void 0&&(a=Ae(c.elapsed)),n.jsxs(w,{children:[n.jsx(l,{children:p}),n.jsx(w,{width:Ks,children:m}),n.jsxs(w,{flexGrow:1,children:[n.jsx(l,{bold:u,inverse:u,children:d}),r?n.jsx(l,{dimColor:!0,children:` ${r}`}):null]}),!s&&n.jsx(w,{justifyContent:"flex-end",width:Xs,children:n.jsx(l,{dimColor:!_e(i),children:lo(i)})}),!s&&n.jsx(w,{justifyContent:"flex-end",width:Js,children:n.jsx(l,{color:f?"green":void 0,dimColor:i==="pending"||f,children:a})})]})},xs=({compact:s,filterActive:e,filterText:t,focused:r,headerStatus:c,parallelSlots:o=3,pinnedTaskIds:i,rows:d,scrollRef:u,selectedIndex:p,title:f})=>{const m=c==="error"?"red":c==="success"?"green":r?"white":"gray",a=d[p]?.taskId,k=[];let S=0;for(const g of d)g.status==="running"?k.push(g):g.status==="pending"&&(S+=1);const M=Math.min(o,k.length+S),Z=M>1,b=[];if(Z)for(let g=0;g<M;g++){const $=k[g];$?b.push(n.jsx(ys,{compact:s,focused:r,isSelected:$.taskId===a,pinLabel:vs($.taskId,i),row:$},`par-${$.taskId}`)):b.push(n.jsxs(w,{children:[n.jsx(l,{children:" "}),n.jsx(w,{width:Ks,children:n.jsx(l,{bold:!0,color:"gray",children:" · "})}),n.jsx(l,{dimColor:!0,children:"Waiting for task..."})]},`par-empty-${String(g)}`))}return n.jsxs(w,{borderColor:m,borderStyle:"single",flexDirection:"column",flexGrow:1,children:[n.jsxs(w,{flexShrink:0,paddingX:1,children:[n.jsx(l,{bold:!0,inverse:!0,children:" VIS "}),n.jsx(l,{children:` ${f}`}),!s&&n.jsxs(w,{flexGrow:1,gap:0,justifyContent:"flex-end",children:[n.jsx(w,{justifyContent:"flex-end",width:Xs,children:n.jsx(l,{dimColor:!0,children:"Cache"})}),n.jsx(w,{justifyContent:"flex-end",width:Js,children:n.jsx(l,{dimColor:!0,children:"Duration"})})]})]}),n.jsx(Ps,{flexGrow:1,flexShrink:1,paddingX:1,paddingY:1,ref:u,scrollbar:!0,scrollbarColor:"gray",scrollbarStyle:"block",children:d.map(g=>n.jsx(ys,{compact:s,focused:r,isSelected:g.taskId===a,pinLabel:vs(g.taskId,i),row:g},g.taskId))}),Z&&n.jsx(w,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",borderTop:!0,flexDirection:"column",flexShrink:0,paddingX:1,paddingY:1,children:b}),e&&n.jsxs(w,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",borderTop:!0,flexShrink:0,paddingX:1,children:[n.jsx(l,{bold:!0,color:"white",children:"/ "}),n.jsx(l,{children:t}),n.jsx(l,{inverse:!0,children:" "})]})]})},js=40,ks=10,bs=100,uo=Object.freeze([]),fo=({autoExitSeconds:s,onRetryService:e,parallelSlots:t,projectNames:r,serviceDockStore:c,stdinRegistry:o,store:i,targets:d,tasks:u})=>{const{exit:p}=Ar(),{columns:f,rows:m}=Lr(),a=K.useSyncExternalStore(i.subscribe,i.getSnapshot),k=K.useCallback(I=>c?c.subscribe(I):()=>{},[c]);K.useSyncExternalStore(k,()=>c?c.getDockState():"ready");const S=c?c.getIds():uo,M=S.length>0,[Z,b]=K.useState(0),[g,$]=K.useState(null),_=K.useSyncExternalStore(k,()=>g&&c?c.getState(g):void 0),[H,x]=K.useState(!1),D=K.useRef(null),F=K.useRef(null),N=K.useRef(null),[re,C]=K.useState(!1),[P,V]=K.useState(!0),te=K.useRef({list:0,splitList:0,splitOutput:0}),ge=K.useCallback(()=>{a.viewMode==="list"?te.current.list=F.current?.getScrollOffset()??0:a.viewMode==="split"&&(te.current.splitList=F.current?.getScrollOffset()??0,te.current.splitOutput=N.current?.getScrollOffset()??0)},[a.viewMode]),ie=K.useCallback(I=>{setTimeout(()=>{if(I==="list"){const j=te.current.list;F.current?.scrollTo(j)}else if(I==="split"){const j=te.current.splitList;j>0?F.current?.scrollTo(j):F.current?.scrollTo(Math.max(0,i.getSnapshot().selectedIndex-2)),N.current?.scrollTo(te.current.splitOutput)}},0)},[i]),se=K.useRef(!1);K.useEffect(()=>{a.done&&!se.current&&(se.current=!0,s>0&&a.failed===0&&C(!0)),!a.done&&se.current&&(se.current=!1,C(!1))},[a.done,a.failed,s]);const ee=K.useMemo(()=>{const I=S.length>0?new Set(S):null,j=a.filterText?a.filterText.toLowerCase():null,E=[];for(const X of a.rows)I?.has(X.taskId)||a.statusFilter==="failed"&&X.status!=="failure"||a.statusFilter==="running"&&X.status!=="running"&&X.status!=="pending"||a.statusFilter==="passed"&&X.status!=="success"&&!_e(X.status)||j&&!X.taskId.toLowerCase().includes(j)||E.push(X);return E},[a.rows,a.filterText,a.statusFilter,S]),de=(ee[a.selectedIndex]??null)?.taskId??null,G=g?null:a.pinnedTaskIds[0]??de,W=G?a.rows.find(I=>I.taskId===G):null,fe=_??null,ae=g?(fe?.tailLines??[]).join(`
|
|
15
|
-
`):G?a.outputs.get(G)??"":"",be=K.useMemo(()=>W?.status==="failure"&&ae?zs(ae,{color:!process.env.NO_COLOR,cwd:process.cwd()}):ae,[W?.status,ae]),q=g??G,He=g?fe?.status==="crashed"||fe?.status==="failed"?"failure":"running":W?.status,We=Rt(r,d,u),Ze=a.done?`Completed ${We} (${Ae((a.endTime??Date.now())-a.startTime)})`:`Running ${We}...`,et=a.done?a.failed>0?"error":"success":"running",tt=K.useCallback(I=>{F.current?.scrollTo(Math.max(0,I-2))},[]);if(K.useEffect(()=>{a.interactiveMode&&W?.status!=="running"&&i.setInteractiveMode(!1)},[a.interactiveMode,W?.status,i]),K.useEffect(()=>{if(!G)return;let I=f;a.viewMode==="split"&&f>=bs?I=f-Math.floor(f*.4)-2:(a.viewMode==="split"||a.viewMode==="fullscreen")&&(I=f-2);const j=Math.max(1,m-4);o.get(G)?.resize?.(I,j)},[f,m,a.viewMode,G]),rs((I,j)=>{if(j.escape){i.setInteractiveMode(!1);return}if(!G)return;const E=o.get(G);if(!E){i.setInteractiveMode(!1);return}if(j.return)E.write("\r");else if(j.upArrow)E.write("\x1B[A");else if(j.downArrow)E.write("\x1B[B");else if(j.rightArrow)E.write("\x1B[C");else if(j.leftArrow)E.write("\x1B[D");else if(j.backspace)E.write("");else if(j.delete)E.write("\x1B[3~");else if(j.tab)E.write(" ");else if(j.home)E.write("\x1B[H");else if(j.end)E.write("\x1B[F");else if(j.pageUp)E.write("\x1B[5~");else if(j.pageDown)E.write("\x1B[6~");else if(j.ctrl&&I){const X=I.toUpperCase().codePointAt(0);X!==void 0&&X>=65&&X<=90&&E.write(String.fromCodePoint(X-64))}else I&&E.write(I)},{isActive:a.interactiveMode}),rs((I,j)=>{if(I==="c"&&j.ctrl){p();return}if(!re){if(H){j.escape||I==="?"?x(!1):I==="q"?(x(!1),C(!0)):j.downArrow||I==="j"?D.current?.scrollBy(1):j.upArrow||I==="k"?D.current?.scrollBy(-1):j.pageDown?D.current?.scrollBy(5):j.pageUp?D.current?.scrollBy(-5):j.home?D.current?.scrollToTop():j.end&&D.current?.scrollToBottom();return}if(I==="?"){x(!0);return}if(I==="q"){C(!0);return}if(I==="r"&&a.done){i.requestRerun();return}if(I==="R"&&a.done){const E=ee[a.selectedIndex];E?.status==="failure"&&i.requestRetry(E.taskId);return}if(I==="F"&&!a.filterActive){const E=["all","failed","running","passed"],X=E.indexOf(a.statusFilter);i.setStatusFilter(E[(X+1)%E.length]);return}if(a.filterActive){if(j.escape){i.setFilterActive(!1);return}if(j.return){i.setFilterActive(!1);return}if(j.backspace){i.setFilter(a.filterText.slice(0,-1));return}if(I&&!j.ctrl&&!j.meta){i.setFilter(a.filterText+I);return}return}if(I==="i"&&W?.status==="running"&&(a.viewMode==="fullscreen"||a.viewMode==="split"&&a.focusedPanel==="output")){i.setInteractiveMode(!0);return}if(a.viewMode==="fullscreen"){if(j.escape){i.setViewMode("split"),ie("split");return}if(I==="f"){const E=!P;V(E),E&&N.current?.scrollToBottom();return}if(j.downArrow||I==="j"){V(!1),N.current?.scrollBy(1);return}if(j.upArrow||I==="k"){V(!1),N.current?.scrollBy(-1);return}if(j.pageDown||j.ctrl&&I==="d"){V(!1),N.current?.scrollBy(12);return}if(j.pageUp||j.ctrl&&I==="u"){V(!1),N.current?.scrollBy(-12);return}if(j.home){V(!1),N.current?.scrollToTop();return}if(j.end){V(!0),N.current?.scrollToBottom();return}return}if(a.focusedPanel==="dock"&&M&&c){if(j.tab){$(null),i.setFocusedPanel("tasks");return}if(j.escape){i.setFocusedPanel("tasks"),$(null),a.viewMode==="split"&&(i.setViewMode("list"),ie("list"));return}if(j.downArrow||I==="j"){b(E=>Math.min(E+1,S.length-1));return}if(j.upArrow||I==="k"){b(E=>Math.max(E-1,0));return}if(j.return){const E=S[Z];E&&($(E),V(!0),ge(),te.current.splitList=0,te.current.splitOutput=0,i.setViewMode("split"),i.setFocusedPanel("output"),ie("split"));return}if((I==="r"||I==="R")&&e){const E=S[Z],X=E?c.getState(E)?.status:void 0;if(E&&(X==="crashed"||X==="failed")){const Le=e(E);Le instanceof Promise&&Le.catch(()=>{})}return}return}if(a.viewMode==="split"){if(j.tab){a.focusedPanel==="tasks"?i.setFocusedPanel("output"):M?i.setFocusedPanel("dock"):($(null),i.setFocusedPanel("tasks"));return}if(a.focusedPanel==="output"){if(j.escape){if(g&&M){$(null),i.setViewMode("list"),i.setFocusedPanel("dock"),ie("list");return}$(null),i.setFocusedPanel("tasks");return}if(j.return){ge(),i.setViewMode("fullscreen");return}if(I==="f"){const E=!P;V(E),E&&N.current?.scrollToBottom();return}if(j.downArrow||I==="j"){V(!1),N.current?.scrollBy(1);return}if(j.upArrow||I==="k"){V(!1),N.current?.scrollBy(-1);return}if(j.pageDown||j.ctrl&&I==="d"){V(!1),N.current?.scrollBy(12);return}if(j.pageUp||j.ctrl&&I==="u"){V(!1),N.current?.scrollBy(-12);return}if(j.home){V(!1),N.current?.scrollToTop();return}if(j.end){V(!0),N.current?.scrollToBottom();return}return}if(j.escape){i.setViewMode("list"),ie("list");return}if(j.return){i.setFocusedPanel("output");return}}if(a.viewMode==="list"||a.viewMode==="split"&&a.focusedPanel==="tasks"){if(j.tab&&a.viewMode==="list"&&M){i.setFocusedPanel("dock");return}if(j.downArrow||I==="j"){const E=Math.min(a.selectedIndex+1,Math.max(0,ee.length-1));i.setSelectedIndex(E),tt(E);return}if(j.upArrow||I==="k"){const E=Math.max(a.selectedIndex-1,0);i.setSelectedIndex(E),tt(E);return}if(j.return&&a.viewMode==="list"){V(!0),ge(),te.current.splitList=0,te.current.splitOutput=0,i.setViewMode("split"),i.setFocusedPanel("output"),ie("split");return}if(I==="/"){i.setFilterActive(!0);return}if(I==="1"&&de){i.pinTask(0,de);return}if(I==="2"&&de){i.pinTask(1,de);return}if(I==="0"){i.clearPins();return}j.escape&&a.filterText&&i.setFilter("")}}},{isActive:!a.interactiveMode}),f<js||m<ks)return n.jsx(w,{alignItems:"center",height:m,justifyContent:"center",width:f,children:n.jsxs(l,{color:"yellow",children:["Terminal too small (",f,"x",m,"). Minimum:"," ",js,"x",ks]})});const oe=n.jsxs(w,{gap:1,children:[a.succeeded>0&&n.jsxs(l,{bold:!0,color:"green",children:["✓"," ",a.succeeded]}),a.cached>0&&n.jsxs(l,{dimColor:!0,children:["✓"," ",a.cached]}),a.failed>0&&n.jsxs(l,{bold:!0,color:"red",children:["✗"," ",a.failed]}),a.running>0&&n.jsxs(l,{color:"cyan",children:["◷"," ",a.running]}),n.jsxs(l,{dimColor:!0,children:[a.totalTasks," ","total"]}),a.statusFilter!=="all"&&n.jsxs(l,{color:"yellow",children:["[",a.statusFilter,"]"]})]});let Se;if(a.viewMode==="fullscreen")Se=[n.jsxs(w,{gap:1,children:[n.jsx(l,{bold:!0,color:"white",children:"Esc"}),n.jsx(l,{dimColor:!0,children:"BACK"})]},"esc"),n.jsxs(w,{gap:1,children:[n.jsx(l,{bold:!0,color:"white",children:"↑↓"}),n.jsx(l,{dimColor:!0,children:"SCROLL"})]},"scroll"),n.jsxs(w,{gap:1,children:[n.jsx(l,{bold:!0,color:"white",children:"^u ^d"}),n.jsx(l,{dimColor:!0,children:"PAGE"})]},"page"),...W?.status==="running"?[n.jsxs(w,{gap:1,children:[n.jsx(l,{bold:!0,color:"white",children:"i"}),n.jsx(l,{dimColor:!0,children:"INPUT"})]},"i")]:[],n.jsxs(w,{gap:1,children:[n.jsx(l,{bold:!0,color:"white",children:"q"}),n.jsx(l,{dimColor:!0,children:"QUIT"})]},"q")];else if(a.done){const I=ee[a.selectedIndex]?.status==="failure";Se=[n.jsxs(w,{gap:1,children:[n.jsx(l,{bold:!0,color:"white",children:"q"}),n.jsx(l,{dimColor:!0,children:"QUIT"})]},"q"),n.jsxs(w,{gap:1,children:[n.jsx(l,{bold:!0,color:"white",children:"r"}),n.jsx(l,{dimColor:!0,children:"RERUN"})]},"r"),...I?[n.jsxs(w,{gap:1,children:[n.jsx(l,{bold:!0,color:"white",children:"R"}),n.jsx(l,{dimColor:!0,children:"RETRY"})]},"R")]:[],n.jsxs(w,{gap:1,children:[n.jsx(l,{bold:!0,color:"white",children:"?"}),n.jsx(l,{dimColor:!0,children:"HELP"})]},"?"),n.jsxs(w,{gap:1,children:[n.jsx(l,{bold:!0,color:"white",children:"↑↓"}),n.jsx(l,{dimColor:!0,children:"NAV"})]},"nav"),n.jsxs(w,{gap:1,children:[n.jsx(l,{bold:!0,color:"white",children:"F"}),n.jsx(l,{dimColor:!0,children:"FILTER"})]},"F"),n.jsxs(w,{gap:1,children:[n.jsx(l,{bold:!0,color:"white",children:"⏎"}),n.jsx(l,{dimColor:!0,children:a.viewMode==="list"?"OUTPUT":"FULLSCREEN"})]},"enter")]}else a.viewMode==="split"&&a.focusedPanel==="output"?Se=[n.jsxs(w,{gap:1,children:[n.jsx(l,{bold:!0,color:"white",children:"q"}),n.jsx(l,{dimColor:!0,children:"QUIT"})]},"q"),n.jsxs(w,{gap:1,children:[n.jsx(l,{bold:!0,color:"white",children:"Esc"}),n.jsx(l,{dimColor:!0,children:"BACK"})]},"esc"),n.jsxs(w,{gap:1,children:[n.jsx(l,{bold:!0,color:"white",children:"↑↓"}),n.jsx(l,{dimColor:!0,children:"SCROLL"})]},"scroll"),...W?.status==="running"?[n.jsxs(w,{gap:1,children:[n.jsx(l,{bold:!0,color:"white",children:"i"}),n.jsx(l,{dimColor:!0,children:"INPUT"})]},"i")]:[],n.jsxs(w,{gap:1,children:[n.jsx(l,{bold:!0,color:"white",children:"⏎"}),n.jsx(l,{dimColor:!0,children:"FULLSCREEN"})]},"enter"),n.jsxs(w,{gap:1,children:[n.jsx(l,{bold:!0,color:"white",children:"Tab"}),n.jsx(l,{dimColor:!0,children:"PANEL"})]},"tab"),n.jsxs(w,{gap:1,children:[n.jsx(l,{bold:!0,color:"white",children:"?"}),n.jsx(l,{dimColor:!0,children:"HELP"})]},"?")]:Se=[n.jsxs(w,{gap:1,children:[n.jsx(l,{bold:!0,color:"white",children:"q"}),n.jsx(l,{dimColor:!0,children:"QUIT"})]},"q"),n.jsxs(w,{gap:1,children:[n.jsx(l,{bold:!0,color:"white",children:"?"}),n.jsx(l,{dimColor:!0,children:"HELP"})]},"?"),n.jsxs(w,{gap:1,children:[n.jsx(l,{bold:!0,color:"white",children:"↑↓"}),n.jsx(l,{dimColor:!0,children:"NAV"})]},"nav"),n.jsxs(w,{gap:1,children:[n.jsx(l,{bold:!0,color:"white",children:"/"}),n.jsx(l,{dimColor:!0,children:"FILTER"})]},"/"),n.jsxs(w,{gap:1,children:[n.jsx(l,{bold:!0,color:"white",children:"F"}),n.jsx(l,{dimColor:!0,children:"STATUS"})]},"F"),n.jsxs(w,{gap:1,children:[n.jsx(l,{bold:!0,color:"white",children:"⏎"}),n.jsx(l,{dimColor:!0,children:a.viewMode==="list"?"OUTPUT":"FULLSCREEN"})]},"enter"),...a.viewMode==="split"?[n.jsxs(w,{gap:1,children:[n.jsx(l,{bold:!0,color:"white",children:"Tab"}),n.jsx(l,{dimColor:!0,children:"PANEL"})]},"tab")]:[]];const Ce=n.jsxs(w,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",flexShrink:0,justifyContent:"space-between",children:[n.jsx(w,{flexGrow:1,flexWrap:"wrap",gap:2,paddingX:1,children:Se}),n.jsx(w,{flexShrink:0,paddingX:1,children:oe})]}),we=n.jsxs(Dr,{backgroundColor:"#1e1e1e",footer:n.jsxs(l,{dimColor:!0,children:[n.jsx(l,{bold:!0,color:"white",children:"↑↓"})," ","scroll"," ",n.jsx(l,{bold:!0,color:"white",children:"?"}),"/",n.jsx(l,{bold:!0,color:"white",children:"Esc"})," ","close"]}),scrollRef:D,title:"KEYBOARD SHORTCUTS",visible:H,width:52,children:[n.jsxs(w,{flexDirection:"column",marginBottom:1,children:[n.jsxs(w,{marginBottom:1,children:[n.jsx(l,{dimColor:!0,children:"── "}),n.jsx(l,{bold:!0,color:"white",children:"NAVIGATION"})]}),n.jsxs(w,{children:[n.jsx(w,{width:24,children:n.jsxs(l,{children:[n.jsxs(l,{bold:!0,color:"white",children:[" ","↑","/k"]}),n.jsx(l,{dimColor:!0,children:" Move up"})]})}),n.jsxs(l,{children:[n.jsxs(l,{bold:!0,color:"white",children:[" ","↓","/j"]}),n.jsx(l,{dimColor:!0,children:" Move down"})]})]}),n.jsxs(l,{children:[n.jsxs(l,{bold:!0,color:"white",children:[" ","Tab"]}),n.jsx(l,{dimColor:!0,children:" Switch panel (split)"})]}),n.jsxs(l,{children:[n.jsxs(l,{bold:!0,color:"white",children:[" ","Esc"]}),n.jsx(l,{dimColor:!0,children:" Back / close"})]}),n.jsxs(l,{children:[n.jsxs(l,{bold:!0,color:"white",children:[" ","Enter"]}),n.jsx(l,{dimColor:!0,children:" Show output / fullscreen"})]})]}),n.jsxs(w,{flexDirection:"column",marginBottom:1,children:[n.jsxs(w,{marginBottom:1,children:[n.jsx(l,{dimColor:!0,children:"── "}),n.jsx(l,{bold:!0,color:"white",children:"VIEWS"})]}),n.jsxs(l,{children:[n.jsxs(l,{bold:!0,color:"white",children:[" ","Enter"]}),n.jsxs(l,{dimColor:!0,children:[" ","List"," ","→"," ","Split"," ","→"," ","Fullscreen"]})]}),n.jsxs(l,{children:[n.jsxs(l,{bold:!0,color:"white",children:[" ","Esc"]}),n.jsxs(l,{dimColor:!0,children:[" ","Fullscreen"," ","→"," ","Split"," ","→"," ","List"]})]})]}),n.jsxs(w,{flexDirection:"column",marginBottom:1,children:[n.jsxs(w,{marginBottom:1,children:[n.jsx(l,{dimColor:!0,children:"── "}),n.jsx(l,{bold:!0,color:"white",children:"ACTIONS"})]}),n.jsxs(w,{children:[n.jsx(w,{width:24,children:n.jsxs(l,{children:[n.jsxs(l,{bold:!0,color:"white",children:[" ","/"]}),n.jsx(l,{dimColor:!0,children:" Filter by text"})]})}),n.jsxs(l,{children:[n.jsxs(l,{bold:!0,color:"white",children:[" ","F"]}),n.jsx(l,{dimColor:!0,children:" Filter by status"})]})]}),n.jsxs(w,{children:[n.jsx(w,{width:24,children:n.jsxs(l,{children:[n.jsxs(l,{bold:!0,color:"white",children:[" ","1"]}),n.jsx(l,{dimColor:!0,children:"/"}),n.jsx(l,{bold:!0,color:"white",children:"2"}),n.jsx(l,{dimColor:!0,children:" Pin to output pane"})]})}),n.jsxs(l,{children:[n.jsxs(l,{bold:!0,color:"white",children:[" ","0"]}),n.jsx(l,{dimColor:!0,children:" Clear pins"})]})]}),n.jsxs(w,{children:[n.jsx(w,{width:24,children:n.jsxs(l,{children:[n.jsxs(l,{bold:!0,color:"white",children:[" ","r"]}),n.jsx(l,{dimColor:!0,children:" Rerun all (done)"})]})}),n.jsxs(l,{children:[n.jsxs(l,{bold:!0,color:"white",children:[" ","R"]}),n.jsx(l,{dimColor:!0,children:" Retry failed task"})]})]}),n.jsxs(l,{children:[n.jsxs(l,{bold:!0,color:"white",children:[" ","i"]}),n.jsx(l,{dimColor:!0,children:" Interactive input (running task)"})]})]}),n.jsxs(w,{flexDirection:"column",marginBottom:1,children:[n.jsxs(w,{marginBottom:1,children:[n.jsx(l,{dimColor:!0,children:"── "}),n.jsx(l,{bold:!0,color:"white",children:"SCROLLING"}),n.jsx(l,{dimColor:!0,children:" (output panel)"})]}),n.jsxs(w,{children:[n.jsx(w,{width:24,children:n.jsxs(l,{children:[n.jsxs(l,{bold:!0,color:"white",children:[" ","↑","/k"]}),n.jsx(l,{dimColor:!0,children:" Scroll up"})]})}),n.jsxs(l,{children:[n.jsxs(l,{bold:!0,color:"white",children:[" ","↓","/j"]}),n.jsx(l,{dimColor:!0,children:" Scroll down"})]})]}),n.jsxs(w,{children:[n.jsx(w,{width:24,children:n.jsxs(l,{children:[n.jsxs(l,{bold:!0,color:"white",children:[" ","^u"]}),n.jsx(l,{dimColor:!0,children:" Page up"})]})}),n.jsxs(l,{children:[n.jsxs(l,{bold:!0,color:"white",children:[" ","^d"]}),n.jsx(l,{dimColor:!0,children:" Page down"})]})]}),n.jsxs(w,{children:[n.jsx(w,{width:24,children:n.jsxs(l,{children:[n.jsxs(l,{bold:!0,color:"white",children:[" ","Home"]}),n.jsx(l,{dimColor:!0,children:" Top"})]})}),n.jsxs(l,{children:[n.jsxs(l,{bold:!0,color:"white",children:[" ","End"]}),n.jsx(l,{dimColor:!0,children:" Bottom (resume follow)"})]})]}),n.jsxs(l,{children:[n.jsxs(l,{bold:!0,color:"white",children:[" ","f"]}),n.jsx(l,{dimColor:!0,children:" Toggle auto-scroll (tail mode)"})]})]}),n.jsxs(w,{flexDirection:"column",children:[n.jsxs(w,{marginBottom:1,children:[n.jsx(l,{dimColor:!0,children:"── "}),n.jsx(l,{bold:!0,color:"white",children:"GENERAL"})]}),n.jsxs(w,{children:[n.jsx(w,{width:24,children:n.jsxs(l,{children:[n.jsxs(l,{bold:!0,color:"white",children:[" ","q"]}),n.jsx(l,{dimColor:!0,children:" Quit"})]})}),n.jsxs(l,{children:[n.jsxs(l,{bold:!0,color:"white",children:[" ","?"]}),n.jsx(l,{dimColor:!0,children:" Toggle help"})]})]})]})]}),Te=n.jsx(Br,{autoExitSeconds:s>0?s:3,onCancel:()=>{C(!1)},visible:re}),Me=M&&c?n.jsx(ao,{activeIndex:Z,focused:a.focusedPanel==="dock",store:c}):null;if(a.viewMode==="fullscreen")return n.jsxs(w,{flexDirection:"column",height:m,width:f,children:[n.jsx(w,{flexGrow:1,children:n.jsx(ws,{autoScroll:P,duration:W?.duration??W?.elapsed,focused:!0,interactiveMode:a.interactiveMode,output:be,scrollRef:N,status:He,supportsInteractive:!g,taskId:q})}),Me,Ce,Te,we]});if(a.viewMode==="split"){const I=f>=bs,j=n.jsx(xs,{compact:!0,filterActive:a.filterActive,filterText:a.filterText,focused:a.focusedPanel==="tasks",headerStatus:et,parallelSlots:t,pinnedTaskIds:a.pinnedTaskIds,rows:ee,scrollRef:F,selectedIndex:a.selectedIndex,title:Ze}),E=n.jsx(ws,{autoScroll:P,duration:W?.duration??W?.elapsed,focused:a.focusedPanel==="output",interactiveMode:a.interactiveMode,output:be,scrollRef:N,showFullscreenHint:!0,status:He,supportsInteractive:!g,taskId:q});if(I){const Le=Math.floor(f*.4);return n.jsxs(w,{flexDirection:"column",height:m,width:f,children:[n.jsxs(w,{flexDirection:"row",flexGrow:1,children:[n.jsx(w,{width:Le,children:j}),n.jsx(w,{flexGrow:1,children:E})]}),Me,Ce,Te,we]})}const X=Math.floor(m*.45);return n.jsxs(w,{flexDirection:"column",height:m,width:f,children:[n.jsx(w,{height:X,children:j}),n.jsx(w,{flexGrow:1,children:E}),Me,Ce,Te,we]})}return n.jsxs(w,{flexDirection:"column",height:m,width:f,children:[n.jsx(w,{flexGrow:1,children:n.jsx(xs,{filterActive:a.filterActive,filterText:a.filterText,focused:a.focusedPanel!=="dock",headerStatus:et,parallelSlots:t,pinnedTaskIds:a.pinnedTaskIds,rows:ee,scrollRef:F,selectedIndex:a.selectedIndex,title:Ze})}),Me,Ce,Te,we]})},ho=s=>s==="quiet"?"quiet":"normal",po=(s,e)=>typeof s=="string"?ho(s.toLowerCase()):e===!0?"quiet":"normal",kt=(s,e)=>{const t=s.overrides.visOptions;return t?.outputStyle==="normal"||t?.outputStyle==="quiet"?t.outputStyle:e},Qs=s=>`${s.id}: tracker saw no workspace access; cached on declared inputs`;class mo{#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,t=`Running ${Rt(this.#e,this.#r,this.#s)}`,r=me(Q.createElement(jt,{title:t,variant:"info"}),{columns:e});process.stdout.write(r);const c=this.#s[0],o=c?.overrides?Object.entries(c.overrides).filter(([i])=>i!=="command"):[];if(o.length>0){process.stdout.write(`
|
|
16
|
-
With additional flags:
|
|
17
|
-
`);for(const[i,d]of o)process.stdout.write(`${Oi(" ",i,d)}
|
|
18
|
-
`)}process.stdout.write(`
|
|
19
|
-
`)}startTasks(e){const t=process.stdout.columns||80;for(const r of e){const c=me(Q.createElement(l,null,Q.createElement(l,{dimColor:!0},">"),` ${r.id}`),{columns:t});process.stdout.write(`${c}
|
|
20
|
-
`)}}endTasks(e){const t=process.stdout.columns||80;for(const r of e){this.#o.set(r.task.id,r),r.status==="failure"?this.#n.push(r):_e(r.status)&&this.#t.push(r),r.retryAttempts&&r.retryAttempts>0&&this.#i.push(r);const c=Xe(r.status),o=r.startTime&&r.endTime?` (${Ae(r.endTime-r.startTime)})`:"",i=_e(r.status)?" [cache]":"",d=r.retryAttempts&&r.retryAttempts>0?` [retried ${r.retryAttempts}x]`:"",u=me(Q.createElement(l,null,c,` ${r.task.id}`,i?Q.createElement(l,{color:"cyan"},i):null,d?Q.createElement(l,{color:"yellow"},d):null,o?Q.createElement(l,{dimColor:!0},o):null),{columns:t});process.stdout.write(`${u}
|
|
21
|
-
`)}}#l(e){const t=process.stdout.columns||80,r=me(Q.createElement(l,{dimColor:!0},` ⓘ ${e}`),{columns:t});process.stdout.write(`${r}
|
|
22
|
-
`)}printCacheDisabledByTask(e){this.#l(`${e.id}: caching disabled by task via disableCache()`)}printSelfModifyingSkip(e,t){this.#l(`${e.id}: caching skipped — task modified its own input${t.length===1?"":"s"} (${t.join(", ")})`)}printDeclaredFallback(e){kt(e,this.#a)!=="quiet"&&this.#l(Qs(e))}printEmptyFingerprintWarning(e,t){this.#l(`${e.id}: caching skipped — ${t}`)}printTaskTerminalOutput(e,t,r){if(kt(e,this.#a)==="quiet"&&(t==="success"||_e(t)))return;const c=t==="failure"?zs(r,{color:!process.env.NO_COLOR,cwd:process.cwd()}):r;if(this.#c){this.#c.printTaskTerminalOutput(e,t,c);return}eo(e.id,t,c,this.#d)}endCommand(){const e=Ae(Date.now()-this.#u),t=this.#s.filter(o=>!this.#o.has(o.id)).map(o=>o.id);process.stdout.write(`
|
|
23
|
-
`);const r=process.stdout.columns||80,c=me(Q.createElement(Ws,{cached:this.#t.length,failed:this.#n.length,failedIds:this.#n.map(o=>o.task.id),projectNames:this.#e,retriedIds:this.#i.length>0?this.#i.map(o=>o.task.id):void 0,skippedIds:t.length>0?t:void 0,succeeded:this.#o.size-this.#n.length-this.#t.length,targets:this.#r,tasks:this.#s,took:e}),{columns:r});process.stdout.write(`${c}
|
|
24
|
-
`)}}const go=s=>{const{args:e,autoExit:t=!1,onRetryService:r,outputStyle:c="normal",projectNames:o,serviceDockStore:i,stdinRegistry:d,tasks:u,totalTaskCount:p}=s,f=new lt(u,p),m=typeof e.parallel=="number"?e.parallel:3,a=t===!0?3:typeof t=="number"?t:0,k=new Map,S=(C,P)=>{const V=k.get(C);V?V.push(P):k.set(C,[P])};let M,Z;const b=new Promise(C=>{Z=C});let g;const $=()=>{g&&(clearInterval(g),g=void 0)},_=()=>{if(process.stdin.isTTY&&typeof process.stdin.setRawMode=="function")try{process.stdin.setRawMode(!1)}catch{}process.stdin.pause(),process.stdin.unref()},H=()=>{if(d){for(const C of d.values())C.kill?.();d.clear()}},x=()=>{$(),N(),H(),_(),process.stdout.write("\x1B[?1049l\x1B[?25h"),M?.cleanup(),process.exit(1)},D=()=>{const C=f.getSnapshot(),P=Ae(Date.now()-C.startTime),V=C.rows.filter(ie=>ie.status==="failure").map(ie=>ie.taskId),te=process.stdout.columns||80;process.stdout.write(`
|
|
25
|
-
`);for(const ie of C.rows){const{persistent:se,status:ee,taskId:ke}=ie,de=ee==="running"||ee==="pending",G=Ge(ee),W=de&&se?"■":G.icon,fe=de&&se?"gray":G.color;let ae="";switch(ee){case"local-cache":case"local-cache-kept-existing":{ae=" [local cache]";break}case"remote-cache":{ae=" [remote cache]";break}case"skipped":{ae=" [skipped]";break}default:{de&&se?ae=" [stopped]":de&&(ae=" [skipped]");break}}const be=ie.retryAttempts&&ie.retryAttempts>0?` [retried ${ie.retryAttempts}x]`:"",q=me(Q.createElement(l,null," ",Q.createElement(l,{color:fe},W),` vis run ${ke}`,ae?Q.createElement(l,{dimColor:!0},` ${ae}`):null,be?Q.createElement(l,{color:"yellow"},be):null),{columns:te});process.stdout.write(`${q}
|
|
26
|
-
`)}process.stdout.write(`
|
|
27
|
-
`);const ge=me(Q.createElement(Ws,{cached:C.cached,failed:C.failed,failedIds:V,projectNames:o,retriedIds:C.retriedIds.length>0?C.retriedIds:void 0,succeeded:C.succeeded,targets:e.targets,tasks:u,took:P}),{columns:te});if(process.stdout.write(`${ge}
|
|
28
|
-
`),c!=="quiet"){const ie=[...C.rows.filter(se=>se.status!=="failure"),...C.rows.filter(se=>se.status==="failure")];for(const se of ie){if(se.status==="running"||se.status==="pending")continue;const ee=C.outputs.get(se.taskId);if(!ee?.trim())continue;const{color:ke,icon:de}=Ge(se.status),G=me(Q.createElement(l,null,`
|
|
29
|
-
`,Q.createElement(l,{bold:!0,color:ke},` ${de} vis run ${se.taskId}`)),{columns:te});process.stdout.write(`${G}
|
|
30
|
-
|
|
31
|
-
`);const W=ee.trim().split(`
|
|
32
|
-
`).map(fe=>` ${fe}`).join(`
|
|
33
|
-
`);process.stdout.write(`${W}
|
|
34
|
-
`)}}};let F;const N=()=>{F&&(clearInterval(F),F=void 0)};return{lifeCycle:{endCommand(){$(),f.markDone(),F||(F=setInterval(()=>{},1e3))},endTasks(C){f.endTasks(C);for(const P of C){const V=k.get(P.task.id);if(V){k.delete(P.task.id);for(const te of V)f.addOutput(P.task.id,te)}}},printCacheDisabledByTask(C){S(C.id,`ⓘ caching disabled by task via disableCache()
|
|
35
|
-
`)},printDeclaredFallback(C){kt(C,c)!=="quiet"&&S(C.id,`ⓘ ${Qs(C)}
|
|
36
|
-
`)},printEmptyFingerprintWarning(C,P){S(C.id,`ⓘ caching skipped — ${P}
|
|
37
|
-
`)},printSelfModifyingSkip(C,P){S(C.id,`ⓘ caching skipped — task modified its own input${P.length===1?"":"s"} (${P.join(", ")})
|
|
38
|
-
`)},printTaskTerminalOutput(C,P,V){f.getSnapshot().outputs.has(C.id)||f.addOutput(C.id,V)},startCommand(){process.on("SIGINT",x),process.on("SIGTERM",x),F||(F=setInterval(()=>{},1e3)),M=_r(Q.createElement(fo,{autoExitSeconds:a,onRetryService:r,parallelSlots:m,projectNames:o,serviceDockStore:i,stdinRegistry:d??new Map,store:f,targets:e.targets,tasks:u}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}),M.waitUntilExit().then(()=>{N(),H(),_(),process.removeListener("SIGINT",x),process.removeListener("SIGTERM",x),D(),Z()}).catch(()=>{N(),H(),_(),process.removeListener("SIGINT",x),process.removeListener("SIGTERM",x),Z()})},startTasks(C){f.startTasks(C),g||(g=setInterval(()=>{f.tick()},100))}},renderIsDone:b,store:f}},wo=async s=>{if(process.env.VIS_NO_SHELL_HISTORY)return;if(zn()==="win32"){try{await xo(s)}catch{}return}const e=process.env.SHELL;if(!e)return;const t=gr(e);try{if(t==="zsh"){await vo(s);return}if(t==="bash"){await yo(s);return}t==="fish"&&await jo(s)}catch{}},Pt=s=>s.replaceAll(/[\u0000-\u001F\u007F]/gu," ").trimEnd(),vo=async s=>{const e=process.env.HISTFILE??le(process.env.ZDOTDIR??It(),".zsh_history"),t=`: ${Math.floor(Date.now()/1e3)}:0;${Pt(s)}
|
|
39
|
-
`;await ht(e,t)},yo=async s=>{const e=process.env.HISTFILE??le(It(),".bash_history");await ht(e,`${Pt(s)}
|
|
40
|
-
`)},xo=async s=>{const e=process.env.VIS_PSREADLINE_HISTORY,t=process.env.APPDATA;if(e===void 0&&(t===void 0||t===""))return;const r=e??le(t,"Microsoft","Windows","PowerShell","PSReadLine","ConsoleHost_history.txt");await Un(Rs(r),{recursive:!0}),await ht(r,`${Pt(s)}\r
|
|
41
|
-
`)},jo=async s=>{const e=le(It(),".local","share","fish","fish_history"),r=`- cmd: ${s.replaceAll("\\","\\\\").replaceAll(`
|
|
42
|
-
`,String.raw`\n`).replaceAll("\r",String.raw`\r`)}
|
|
43
|
-
when: ${Math.floor(Date.now()/1e3)}
|
|
44
|
-
`;await ht(e,r)},ko=s=>{const{killGracePeriodMs:e=5e3,onTimeout:t,sendSignal:r,timeoutMs:c}=s;if(c<=0)return{cancel:()=>{}};const o=Math.max(e,0);let i;const d=setTimeout(()=>{t?.(),r("SIGTERM"),o>0&&(i=setTimeout(()=>{r("SIGKILL")},o))},c);return{cancel:()=>{clearTimeout(d),i&&clearTimeout(i)}}},bo=(s,e)=>{const t=e?.trim();if(!t)return{filter:void 0,tasks:[...s]};const r=t.toLowerCase();return{filter:t,tasks:s.filter(c=>c.target.project.toLowerCase().includes(r))}},So=[""," Watch keybinds:"," r, Enter rerun"," a rerun all (clear filter)"," p filter by project name"," q, Ctrl+C quit"," h, ? show this help",""].join(`
|
|
45
|
-
`),To=s=>{s.write(`${So}
|
|
46
|
-
`)},$o=async(s,e)=>{e.write("filter projects (empty to cancel) > ");const t=s,r=t.isRaw===!0;if(r)try{t.setRawMode?.(!1)}catch{}return await new Promise(c=>{let o="";const i=d=>{o+=typeof d=="string"?d:d.toString("utf8");const u=o.indexOf(`
|
|
47
|
-
`);if(u===-1)return;const p=o.slice(0,u).replace(/\r$/,"").trim();if(s.off("data",i),r)try{t.setRawMode?.(!0)}catch{}c(p.length>0?p:void 0)};s.on("data",i)})},Co=s=>{const{handlers:e}=s,t=s.input??process.stdin,r=s.output??process.stdout,c=s.promptFilter??$o;if(!t||t.isTTY===!1)return{close:()=>{}};on(t);const o=t.isRaw===!0;try{t.setRawMode?.(!0)}catch{return{close:()=>{}}}typeof t.resume=="function"&&t.resume();let i=!1;const d=async f=>{if(f.ctrl===!0&&f.name==="c"){await e.onQuit();return}if(!i)switch(f.name){case"?":case"h":{await e.onHelp();break}case"a":{await e.onClearFilter();break}case"p":{i=!0;try{const m=await c(t,r);m===void 0?r.write(`filter cancelled.
|
|
48
|
-
`):await e.onFilter(m)}finally{i=!1}break}case"q":{await e.onQuit();break}case"r":{await e.onRerun();break}case"return":{await e.onRerun();break}}},u=(f,m)=>{d(m).catch(a=>{r.write(`[vis watch] keybind handler failed: ${a.message}
|
|
49
|
-
`)})},p=t;return p.on("keypress",u),{close:()=>{if(p.off("keypress",u),!o)try{t.setRawMode?.(!1)}catch{}const f=t;if(typeof f.pause=="function")try{f.pause()}catch{}}}},Io=s=>{const e=s.overrides.visOptions;return e&&typeof e=="object"?e:void 0},Eo=async s=>{const{initialTasks:e,probe:t,registeredEntries:r,taskGraph:c,visVersion:o}=s,i=new Map,d=new Map,u=new Map;for(const x of r)if(dn(x.pid)){if(x.visVersion!==o){d.set(x.id,x);continue}i.set(x.id,x)}if(t){const x=[...i.values()],D=await Promise.all(x.map(async F=>{try{return[F.id,await t(F)]}catch{return[F.id,!1]}}));for(const[F,N]of D)if(!N){const re=i.get(F);i.delete(F),re&&u.set(F,re)}}const p=new Set(e.map(x=>x.id)),f=new Set,m=[],a=[],k=new Set;for(const x of Object.values(c.dependencies))for(const D of x)k.add(D);for(const[x,D]of Object.entries(c.tasks)){if(!Io(D)?.service)continue;if(i.has(x)){f.add(x),a.push(i.get(x));continue}if(p.has(x)||!k.has(x))continue;const re=d.get(x),C=u.get(x);let P;re?P=`Service ${x} is registered with vis ${re.visVersion}, but this invocation is vis ${o}. Restart with \`vis service restart ${x}\` to pick up the new version.`:C?P=`Service ${x} is registered (PID ${String(C.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.`:P=`Target depends on the service ${x}, which is not running. Run \`vis service start ${x}\` first, or invoke \`${x}\` directly.`,m.push({message:P,targetId:x})}if(f.size===0)return{diagnostics:m,initialTasks:e,satisfiedServices:a,serviceDependentsByServiceId:new Map,serviceEnvByTaskId:new Map,taskGraph:c};const S=new Map,M=x=>{const D=new Set,F=[...c.dependencies[x]??[]],N=new Set;for(;F.length>0;){const re=F.pop();if(!N.has(re)){N.add(re),f.has(re)&&D.add(re);for(const C of c.dependencies[re]??[])N.has(C)||F.push(C)}}return[...D].sort()},Z=new Map;for(const x of Object.keys(c.dependencies)){if(f.has(x))continue;const D=M(x);if(D.length===0)continue;const F={};for(const N of D){const re=i.get(N);if(!re)continue;Object.assign(F,re.env);const C=Z.get(N);C?C.push(x):Z.set(N,[x])}Object.keys(F).length>0&&S.set(x,F)}for(const x of Z.values())x.sort();const b={};for(const[x,D]of Object.entries(c.tasks))f.has(x)||(b[x]=D);const g={};for(const[x,D]of Object.entries(c.dependencies))f.has(x)||(g[x]=D.filter(F=>!f.has(F)));const $=new Map;for(const x of Object.keys(b))$.set(x,0);for(const x of Object.values(g))for(const D of x)$.has(D)&&$.set(D,($.get(D)??0)+1);const _=[];for(const x of c.roots)!f.has(x)&&b[x]&&_.push(x);for(const[x,D]of $)D===0&&!_.includes(x)&&b[x]&&_.push(x);const H=e.filter(x=>!f.has(x.id));return{diagnostics:m,initialTasks:H,satisfiedServices:a,serviceDependentsByServiceId:Z,serviceEnvByTaskId:S,taskGraph:{dependencies:g,roots:_,tasks:b}}},Ro=s=>s.startsWith("./")||s.startsWith("../")||s.startsWith("/")||s.startsWith("**"),Po=s=>{let e=s.trim();if(e==="")return;let t=!1,r=!1,c=!1;e.startsWith("...")&&(t=!0,e=e.slice(3),e.startsWith("^")&&(c=!0,e=e.slice(1))),e.endsWith("...")&&(r=!0,e=e.slice(0,-3),e.endsWith("^")&&(c=!0,e=e.slice(0,-1)));let o;const i=/\[([^\]]*)\]$/.exec(e);i&&(o=i[1]??"",e=e.slice(0,i.index));let d=e.trim(),u=!1;return d.startsWith("{")&&d.endsWith("}")&&d.length>=2?(d=d.slice(1,-1),u=!0):Ro(d)&&(u=!0),{changedSince:o,excludeSelf:c,includeDependencies:r,includeDependents:t,isPath:u,pattern:d}},bt=s=>{let e=s.replaceAll("\\","/");return e.startsWith("./")&&(e=e.slice(2)),e.length>1&&e.endsWith("/")&&(e=e.slice(0,-1)),e},Mo=(s,e,t)=>s===""?!1:xt(s,e)?!0:t!==void 0&&xt(s,t),Fo=(s,e)=>{if(e===void 0||e==="")return!1;const t=bt(s),r=bt(e);return xt(t,r)},Oo=(s,e,t)=>{const{affected:r,downstream:c,upstream:o}=yr(s,t,{downstream:e.includeDependents?"deep":"none",upstream:e.includeDependencies?"deep":"none"});if(!e.excludeSelf)return r;const i=new Set([...c,...o]);for(const d of s)i.delete(d);return i},Ao=async(s,e)=>{const{packageNameByProject:t,projectGraph:r}=e,c=Object.keys(r.nodes);let o=new Set;if(s.pattern!=="")for(const i of c)s.isPath?Fo(s.pattern,r.nodes[i]?.data.root)&&o.add(i):Mo(s.pattern,i,t?.get(i))&&o.add(i);if(s.changedSince!==void 0){const i=s.changedSince===""?e.defaultBase??"main":s.changedSince,d=e.changedProjectsForRef??Lo(e),u=new Set(await d(i));o=s.pattern===""?u:new Set([...o].filter(p=>u.has(p)))}return!s.includeDependents&&!s.includeDependencies?o:Oo(o,s,r)},Lo=s=>async e=>{const{projectGraph:t,workspaceRoot:r}=s;if(!r)return[];let c;try{c=await xr(r,e,"HEAD")}catch(i){const d=i instanceof Error?i.message:String(i);throw new Error(`vis run --filter: invalid changed-since ref "${e}" (${d})`,{cause:i})}const o=new Set;for(const[i,d]of Object.entries(t.nodes)){const u=bt(d.data.root??i);if(!(u===""||u==="."))for(const p of c){const f=wr(r,p).replaceAll("\\","/");if(f===u||f.startsWith(`${u}/`)){o.add(i);break}}}return[...o]},Do=async(s,e)=>{const t=new Set;for(const r of s)for(const c of await Ao(r,e))t.add(c);return[...t]},Bo=async(s,e)=>{const t=[];for(const r of s){const c=Po(r);c&&t.push(c)}return Do(t,e)},nt="[[VIS_BOOT]]",_o=250,No=1e3,Ss=3,Go=s=>{try{return process.kill(s,0),!0}catch{return!1}},Ts=s=>{try{const e=Ne(s,"utf8").trim(),t=Number.parseInt(e,10);return Number.isFinite(t)&&t>0?t:null}catch{return null}};class Ho{#e;#r;#s;#n;#t=new Map;#i=new Map;#o=new Map;#c=new Map;#a=new Set;constructor(e){this.#e=e.indexToId,this.#r=new Map(e.services),this.#s=e.sink,this.#n=e.workspaceRoot}onProcessEvent=e=>{if(e.kind!=="stdout"&&e.kind!=="stderr")return;const t=this.#e.get(e.index);t===void 0||e.text===void 0||this.onTaskOutput(t,e.text)};onTaskOutput(e,t){if(!this.#r.has(e))return;const o=((this.#t.get(e)??"")+t).split(`
|
|
50
|
-
`),i=o.pop()??"";this.#t.set(e,i);for(const d of o)this.#d(e,d)}notifyRegistryStarting(e){this.#s.starting(e)}notifyRegistryStarted(e,t){this.#s.started(e,t)}onRegistryTaskStarted(e){this.#r.get(e)?.mode==="registry"&&this.notifyRegistryStarting(e)}async onRegistryTaskClosed(e,t,r){if(this.#r.get(e)?.mode!=="registry")return;if(r||t!==0){this.notifyRegistryFailed(e,"exit-code",{exitCode:t,killed:r});return}const o=await un(this.#n,e);if(!o){this.notifyRegistryFailed(e,"missing-registry-entry");return}const{config:i}=o,d=i.readiness?.tcp?.port??i.port??0,u=i.readiness?.tcp?.host??"127.0.0.1";this.notifyRegistryReady(e,{host:u,logFile:o.logFile,pid:o.pid,port:d})}notifyRegistryReady(e,t){this.#s.ready(e,{host:t.host,port:t.port}),this.#h(e,t.logFile),t.pid!==null&&this.#p(e,t.pid)}notifyRegistryFailed(e,t,r){this.#s.failed(e,t,r)}async retry(e){const t=this.#r.get(e);if(t){if(this.#f(e),this.#t.delete(e),this.#i.delete(e),this.#s.starting(e),t.mode==="registry"){await this.#y(e,t.registry);return}t.mode==="ephemeral"&&this.#v(e,t.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,t){if(t.startsWith(nt)){this.#u(e,t.slice(nt.length));return}const r=this.#i.get(e)??[];r.push(t),r.length>Ss&&r.shift(),this.#i.set(e,r),this.#s.log(e,`${t}
|
|
51
|
-
`)}#u(e,t){let r;try{r=JSON.parse(t)}catch{this.#s.log(e,`${nt+t}
|
|
52
|
-
`);return}switch(r.event){case"failed":{const c=typeof r.reason=="string"?r.reason:"unknown",o={};for(const[i,d]of Object.entries(r))i!=="event"&&i!=="id"&&i!=="reason"&&(o[i]=d);this.#s.failed(e,c,o);break}case"ready":{const c=typeof r.host=="string"?r.host:"127.0.0.1",o=typeof r.port=="number"?r.port:0;this.#s.ready(e,{host:c,port:o}),this.#l(e);break}case"started":{const c=typeof r.pid=="number"?r.pid:null;this.#s.started(e,c);break}default:this.#s.log(e,`${nt+t}
|
|
53
|
-
`)}}#l(e){const t=this.#r.get(e);if(t?.ephemeral===void 0)return;this.#h(e,t.ephemeral.logFile);const r=Ts(t.ephemeral.pidFile);r!==null&&this.#p(e,r)}#h(e,t){if(this.#o.has(e)||!Oe(t))return;const r=en(t,"r"),c=(()=>{try{return ns(t).size}catch{return 0}})(),o={fd:r,logFile:t,pollTimer:setInterval(()=>{this.#g(e)},_o),position:c};this.#o.set(e,o)}#g(e){const t=this.#o.get(e);if(t)try{const r=ns(t.logFile);if(r.size<=t.position)return;const c=Buffer.alloc(r.size-t.position),o=tn(t.fd,c,0,c.length,t.position);if(o>0){t.position+=o;const i=c.subarray(0,o).toString("utf8");for(const d of i.split(`
|
|
54
|
-
`))d.length!==0&&this.#w(e,d);this.#s.log(e,i)}}catch{}}#w(e,t){const r=this.#i.get(e)??[];for(r.push(t);r.length>Ss;)r.shift();this.#i.set(e,r)}#p(e,t){if(this.#c.has(e))return;const r={pid:t,timer:setInterval(()=>{if(!Go(t)){const c=[...this.#i.get(e)??[]];this.#f(e),this.#s.crashed(e,c)}},No)};this.#c.set(e,r)}#f(e){const t=this.#o.get(e);if(t){clearInterval(t.pollTimer);try{sn(t.fd)}catch{}this.#o.delete(e)}const r=this.#c.get(e);r&&(clearInterval(r.timer),this.#c.delete(e))}#v(e,t){if(t===void 0)return;const r=Ts(t.pidFile);if(r!==null)try{process.kill(-r,"SIGTERM")}catch{}const c=Jn("node",[t.scriptPath,t.configFile],{cwd:t.cwd,stdio:["ignore","pipe","pipe"]});c.stdout.on("data",i=>{this.#m(e,i)}),c.stderr.on("data",i=>{this.#m(e,i)}),c.on("error",i=>{this.#s.failed(e,"respawn-error",{message:i.message})});const o=new Promise(i=>{const d=()=>{this.#a.delete(o),i()};c.once("exit",d),c.once("error",d)});this.#a.add(o)}#m(e,t){const o=((this.#t.get(e)??"")+t.toString("utf8")).split(`
|
|
55
|
-
`),i=o.pop()??"";this.#t.set(e,i);for(const d of o)this.#d(e,d)}async#y(e,t){if(t!==void 0){try{await fn({id:e,workspaceRoot:this.#n})}catch{}try{const r=await hn({command:t.command,config:t.config,cwd:t.cwd,env:t.env,id:e,workspaceRoot:this.#n}),c=t.config.readiness?.tcp?.port??t.config.port??0,o=t.config.readiness?.tcp?.host??"127.0.0.1";this.#s.started(e,r.entry.pid),this.notifyRegistryReady(e,{host:o,logFile:r.entry.logFile,pid:r.entry.pid,port:c})}catch(r){const c=r instanceof Error?r.message:String(r);this.#s.failed(e,"retry-failed",{message:c})}}}}const Wo=s=>{const e=s.overrides.visOptions;return e&&typeof e=="object"?e:void 0},Zs=(s,e,t)=>{const r=[],c=[];for(const o of e){const i=t.tasks[o];if(!i){c.push({id:o,reason:"task not in graph"});continue}const d=i.overrides.command;if(!d){c.push({id:o,reason:"no command resolved"});continue}const u=Wo(i);if(!u?.service){c.push({id:o,reason:"no service config"});continue}const p=Ct(s,i.projectRoot,!!u.runFromWorkspaceRoot),{envFile:f}=u,m=f===void 0||f===!1?{}:Pn(p,f),a=u.service.env??{};r.push({command:d,config:u.service,cwd:p,env:{...m,...a},id:o})}return{services:r,skipped:c}},qo=(s,e)=>{const t=new Set(s),r=new Map;for(const i of s){const d=(e.dependencies[i]??[]).filter(u=>t.has(u));r.set(i,new Set(d))}const c=[],o=new Set;for(;r.size>0;){const i=[];for(const[d,u]of r){for(const p of u)o.has(p)&&u.delete(p);u.size===0&&i.push(d)}i.length===0&&i.push(...r.keys());for(const d of i)o.add(d),r.delete(d);i.sort(),c.push({ids:i})}return c},Vo=(s,e)=>{const t=[];for(const r of qo(s,e))t.push(...r.ids);return t},Uo=String.raw`import { spawn } from "node:child_process";
|
|
56
|
-
import { closeSync, openSync, readFileSync, readSync, statSync, writeFileSync } from "node:fs";
|
|
57
|
-
import { createConnection } from "node:net";
|
|
58
|
-
|
|
59
|
-
const cfgPath = process.argv[2];
|
|
60
|
-
|
|
61
|
-
if (!cfgPath) {
|
|
62
|
-
console.error("[vis-service-bootstrap] missing config path");
|
|
63
|
-
process.exit(2);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const cfg = JSON.parse(readFileSync(cfgPath, "utf8"));
|
|
67
|
-
|
|
68
|
-
// Structured marker for service-event-bridge.ts to consume. Plain
|
|
69
|
-
// process.stdout.write keeps the line atomic and on the same stream
|
|
70
|
-
// as the tailed child log, so the parser sees one stream.
|
|
71
|
-
const emit = (event) => {
|
|
72
|
-
process.stdout.write("[[VIS_BOOT]]" + JSON.stringify({ ...event, id: cfg.id }) + "\n");
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
// Spawn the child with its stdio bound to a real file descriptor on
|
|
76
|
-
// disk — NOT inherited from the bootstrap. If the child inherited
|
|
77
|
-
// our stdio, it would inherit vis run's task pipes, and vis run would
|
|
78
|
-
// block waiting for those pipes to close even after this bootstrap
|
|
79
|
-
// exits. The logfile gives the grandchild a stable target it can keep
|
|
80
|
-
// writing to long after this bootstrap is gone.
|
|
81
|
-
const childLogFd = openSync(cfg.logFile, "a");
|
|
82
|
-
|
|
83
|
-
const child = spawn(cfg.command, {
|
|
84
|
-
cwd: cfg.cwd,
|
|
85
|
-
detached: true,
|
|
86
|
-
env: { ...process.env, ...cfg.env },
|
|
87
|
-
shell: true,
|
|
88
|
-
stdio: ["ignore", childLogFd, childLogFd],
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
// Close the bootstrap's copy of the fd; the child kept its own.
|
|
92
|
-
closeSync(childLogFd);
|
|
93
|
-
|
|
94
|
-
if (child.pid !== undefined) {
|
|
95
|
-
try {
|
|
96
|
-
writeFileSync(cfg.pidFile, String(child.pid));
|
|
97
|
-
} catch (error) {
|
|
98
|
-
console.error("[vis] failed to write pid file: " + (error?.message ?? String(error)));
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
emit({ event: "started", pid: child.pid ?? null });
|
|
103
|
-
|
|
104
|
-
let exitedEarly = false;
|
|
105
|
-
|
|
106
|
-
child.once("exit", (code, signal) => {
|
|
107
|
-
exitedEarly = true;
|
|
108
|
-
emit({ code, event: "failed", reason: "exited-before-ready", signal });
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
// Forward new bytes from the logfile to our stdout while we're alive.
|
|
112
|
-
// Polling-based tail; preflight is short, ~200ms per cycle is fine.
|
|
113
|
-
let tailPos = 0;
|
|
114
|
-
const tailFd = openSync(cfg.logFile, "r");
|
|
115
|
-
|
|
116
|
-
const flushTail = () => {
|
|
117
|
-
try {
|
|
118
|
-
const stat = statSync(cfg.logFile);
|
|
119
|
-
if (stat.size <= tailPos) return;
|
|
120
|
-
const remaining = stat.size - tailPos;
|
|
121
|
-
const buf = Buffer.alloc(remaining);
|
|
122
|
-
const n = readSync(tailFd, buf, 0, remaining, tailPos);
|
|
123
|
-
if (n > 0) {
|
|
124
|
-
process.stdout.write(buf.subarray(0, n));
|
|
125
|
-
tailPos += n;
|
|
126
|
-
}
|
|
127
|
-
} catch {}
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
const probeOnce = () => new Promise((resolve) => {
|
|
131
|
-
const socket = createConnection({ host: cfg.host || "127.0.0.1", port: cfg.port });
|
|
132
|
-
let settled = false;
|
|
133
|
-
const finish = (ok) => {
|
|
134
|
-
if (settled) return;
|
|
135
|
-
settled = true;
|
|
136
|
-
try { socket.destroy(); } catch {}
|
|
137
|
-
resolve(ok);
|
|
138
|
-
};
|
|
139
|
-
socket.once("connect", () => finish(true));
|
|
140
|
-
socket.once("error", () => finish(false));
|
|
141
|
-
socket.setTimeout(1000, () => finish(false));
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
145
|
-
|
|
146
|
-
(async () => {
|
|
147
|
-
const deadline = Date.now() + (cfg.timeoutMs ?? 30000);
|
|
148
|
-
while (Date.now() < deadline) {
|
|
149
|
-
flushTail();
|
|
150
|
-
if (exitedEarly) {
|
|
151
|
-
try { closeSync(tailFd); } catch {}
|
|
152
|
-
process.exit(1);
|
|
153
|
-
}
|
|
154
|
-
if (await probeOnce()) {
|
|
155
|
-
flushTail();
|
|
156
|
-
emit({ event: "ready", host: cfg.host || "127.0.0.1", port: cfg.port });
|
|
157
|
-
try { closeSync(tailFd); } catch {}
|
|
158
|
-
child.unref();
|
|
159
|
-
process.exit(0);
|
|
160
|
-
}
|
|
161
|
-
await sleep(200);
|
|
162
|
-
}
|
|
163
|
-
flushTail();
|
|
164
|
-
emit({ event: "failed", reason: "timeout", timeoutMs: cfg.timeoutMs ?? 30000 });
|
|
165
|
-
try { closeSync(tailFd); } catch {}
|
|
166
|
-
try { process.kill(-child.pid, "SIGTERM"); } catch {}
|
|
167
|
-
process.exit(1);
|
|
168
|
-
})();
|
|
169
|
-
`,zo=()=>{const s=rn(le(Yn(),"vis-services-")),e=le(s,"bootstrap.mjs");return _s(e,Uo),{runDir:s,scriptPath:e}},er=(s,e,t)=>{const r=t.replaceAll(/[^\w-]/g,"_");return{configFile:le(s,`${r}.json`),logFile:le(s,`${r}.log`),pidFile:le(s,`${r}.pid`),scriptPath:e}},Yo=s=>{const{paths:e,service:t}=s,r=t.config.readiness?.tcp?.port??t.config.port;if(typeof r!="number")throw new TypeError(`Service ${t.id} has no TCP readiness port — declare \`service.port\` or \`service.readiness.tcp.port\`.`);const c={...t.env,PATH:jr(t.cwd,t.env)};return{command:t.command,cwd:t.cwd,env:c,host:t.config.readiness?.tcp?.host??"127.0.0.1",id:t.id,logFile:e.logFile,pidFile:e.pidFile,port:r,timeoutMs:t.config.readiness?.tcp?.timeoutMs??3e4}},Ko=s=>`node ${JSON.stringify(s.scriptPath)} ${JSON.stringify(s.configFile)}`,Xo=s=>{const{id:e,visBin:t,workspaceRoot:r}=s;return`node ${JSON.stringify(t)} service start ${JSON.stringify(e)} --cwd ${JSON.stringify(r)}`},Jo=s=>{const{missingServiceIds:e,mode:t,taskGraph:r,visBin:c,workspaceRoot:o}=s,{services:i,skipped:d}=Zs(o,e,r);if(i.length===0)return{chain:[],ephemeralPidFiles:[],runDir:void 0,serviceEnvByTaskId:new Map,skipped:d};const u=Vo(i.map(b=>b.id),r),p=new Map(i.map(b=>[b.id,b])),f=[],m=[];if(t==="ephemeral")for(const b of u){const g=p.get(b);g&&m.push({id:b,payload:Yo({paths:{logFile:"",pidFile:""},service:g})})}let a;t==="ephemeral"&&(a=zo());let k;for(const b of u){const g=p.get(b),$=r.tasks[b];if(!g||!$)continue;let _;if(t==="ephemeral"){const H=er(a.runDir,a.scriptPath,b),D={...m.find(F=>F.id===b).payload,logFile:H.logFile,pidFile:H.pidFile};_s(H.configFile,JSON.stringify(D)),_=Ko(H),f.push(H.pidFile)}else _=Xo({id:b,visBin:c,workspaceRoot:o});if($.overrides={...$.overrides,command:_},$.cache=!1,r.tasks[b]=$,k!==void 0){const H=r.dependencies[b]??[];H.includes(k)||(r.dependencies[b]=[...H,k])}k=b}const S=new Set(u),M=new Map,Z=b=>{const g=new Set,$=[...r.dependencies[b]??[]],_=new Set;for(;$.length>0;){const H=$.pop();if(!_.has(H)){_.add(H),S.has(H)&&g.add(H);for(const x of r.dependencies[H]??[])_.has(x)||$.push(x)}}return[...g].sort()};for(const b of Object.keys(r.dependencies)){if(S.has(b))continue;const g=Z(b);if(g.length===0)continue;const $={};for(const _ of g){const H=p.get(_);H?.config.env&&Object.assign($,H.config.env)}Object.keys($).length>0&&M.set(b,$)}return{chain:u,ephemeralPidFiles:f,runDir:a?.runDir,serviceEnvByTaskId:M,skipped:d}},Qo=new Set(["auto","ephemeral","off","persistent"]),Zo=s=>s.cli!==void 0?"cli":s.config===void 0?"default":"config",ec=s=>{const{cli:e,config:t,isCi:r,isPersistentTarget:c,isTty:o,target:i}=s;if(e!==void 0&&!Qo.has(e))throw new Error(`--services: expected one of auto|ephemeral|persistent|off, got "${e}"`);const d=e??t??(o&&!r?"auto":"off");return d==="off"?"off":d==="ephemeral"?"ephemeral":d==="persistent"?"registry":c||i==="dev"?"ephemeral":"registry"},tr=s=>s.replace(/^--?/u,""),tc=new Set(["0","1","false","no","true","yes"]),sc=s=>!s.startsWith("-")||/^-(?:\d|\.\d)/u.test(s),$s=(s,e,t,r,c,o)=>{if(r!==void 0)return s.set(e,r),0;const i=c[o+1];return(t?.type??"string")==="boolean"?i!==void 0&&tc.has(i.toLowerCase())?(s.set(e,i.toLowerCase()),1):(s.set(e,"true"),0):i!==void 0&&sc(i)?(s.set(e,i),1):(s.set(e,"true"),0)},rc=(s,e)=>{const t=s.type??"string";if(t==="number"){const r=e.trim(),c=Number(r);return r===""||!Number.isFinite(c)?{error:`--${s.name} expects a number, got "${e}"`}:{value:c}}if(t==="boolean")return["1","true","yes"].includes(e.toLowerCase())?{value:!0}:["0","false","no"].includes(e.toLowerCase())?{value:!1}:{error:`--${s.name} expects a boolean, got "${e}"`};if(t==="enum"){const r=s.choices??[];return r.includes(e)?{value:e}:{error:`--${s.name} must be one of [${r.join(", ")}], got "${e}"`}}return{value:e}},nc=s=>{const e=[],t=new Set;for(const r of s){const c=r.name||"<unnamed>";(!r.name||!/^[a-zA-Z][\w-]*$/u.test(r.name))&&e.push(`argument name "${c}" is empty or invalid (start with a letter; use letters, digits, '-', '_')`),t.has(r.name)&&e.push(`duplicate argument name "${c}"`),t.add(r.name),r.alias!==void 0&&r.alias.length!==1&&e.push(`argument "${c}" alias "${r.alias}" must be a single character`);const o=r.type??"string";if(o==="enum"&&(r.choices===void 0||r.choices.length===0)&&e.push(`argument "${c}" has type "enum" but declares no choices`),r.default!==void 0){const i=typeof r.default;o==="number"&&i==="number"||o==="boolean"&&i==="boolean"||(o==="string"||o==="enum")&&i==="string"?o==="enum"&&r.choices&&!r.choices.includes(r.default)&&e.push(`argument "${c}" default "${String(r.default)}" is not one of its choices`):e.push(`argument "${c}" default ${JSON.stringify(r.default)} does not match type "${o}"`)}}return e},ic=(s,e)=>{const t=new Map,r=new Map;for(const p of s)t.set(p.name,p),p.alias&&r.set(p.alias,p);const c=new Map,o=[];for(let p=0;p<e.length;p+=1){const f=e[p];if(f==="--"){o.push(...e.slice(p+1));break}if(f.startsWith("--no-")){c.set(tr(f.slice(5)),"false");continue}const m=/^--([^=]+)(?:=(.*))?$/su.exec(f);if(m){const S=m[1];p+=$s(c,S,t.get(S),m[2],e,p);continue}const a=/^-([^=-])(?:=(.*))?$/su.exec(f),k=a?.[1];if(a&&k!==void 0){const S=r.get(k);p+=$s(c,S?.name??k,S,a[2],e,p);continue}o.push(f)}const i={},d=[];let u=0;for(const p of s){let f=c.get(p.name);if(f===void 0&&p.positional&&u<o.length&&(f=o[u],u+=1),f===void 0){p.default!==void 0?i[p.name]=p.default:p.required&&d.push(`missing required argument --${p.name}`);continue}const{error:m,value:a}=rc(p,f);m?d.push(m):a!==void 0&&(i[p.name]=a)}return{errors:d,values:i}},oc=s=>`VIS_ARG_${tr(s).replaceAll(/[^a-zA-Z0-9]+/gu,"_").toUpperCase()}`,cc=s=>{const e={};for(const[t,r]of Object.entries(s))e[oc(t)]=String(r);return e},yt=(s,e,t)=>{const r=[`Usage: vis run ${s} [-- <args>]`];if(e&&r.push("",e),t.length===0)return r.join(`
|
|
170
|
-
`);r.push("","Arguments:");const c=t.map(i=>{const d=i.positional?`<${i.name}>`:`--${i.name}`,u=i.alias?`, -${i.alias}`:"";return{left:`${d}${u}`,right:i}}),o=Math.max(...c.map(i=>i.left.length));for(const{left:i,right:d}of c){const u=[],p=d.type??"string";u.push(p==="enum"?`enum(${(d.choices??[]).join("|")})`:p),d.required&&u.push("required"),d.default!==void 0&&u.push(`default: ${String(d.default)}`);const f=`${d.description??""}${d.description?" ":""}[${u.join(", ")}]`;r.push(` ${i.padEnd(o)} ${f}`)}return r.join(`
|
|
171
|
-
`)},ac=(s,e,t,r)=>{if(!t||t.length===0)return{env:{},kind:"ok"};const c=nc(t);if(c.length>0)return{errors:c.map(i=>`invalid \`arguments\` schema for "${s}": ${i}`),help:yt(s,e,t),kind:"invalid"};if(r.includes("--help")||r.includes("-h"))return{kind:"help",text:yt(s,e,t)};const o=ic(t,r);return o.errors.length>0?{errors:o.errors,help:yt(s,e,t),kind:"invalid"}:{env:cc(o.values),kind:"ok"}},lc=2e3,Cs=async(s,e,t)=>{const{workspaceRoot:r}=e,c=s.map(g=>{const $=St(g,e.affectedFiles,Fs());if(!$)return;const _=g.overrides.visOptions,H=Ct(r,g.projectRoot,!!_?.runFromWorkspaceRoot),x=ki({interactive:!!t,taskPty:g.pty,workspacePty:_?.pty}),D=Qe(e,g);return{command:$,cwd:H,env:D.env,inheritEnv:D.inheritEnv,name:g.id,...x?{ptySize:{cols:process.stdout.columns??80,rows:process.stdout.rows??24},stdin:"pty"}:{}}}).filter(g=>g!==void 0);if(c.length===0)return;if(!t){await it(c,{killOthers:["failure"],onEvent:()=>{}});return}const{abortSignal:o,lifeCycle:i,stdinRegistry:d,store:u}=t,p=c.map(g=>s.find($=>$.id===g.name)).filter(Boolean),f=g=>c[g]?.stdin==="pty",m=new Map,a=g=>{if(!f(g))return;let $=m.get(g);return $||($=new Tt(ut),m.set(g,$)),$};u.unmarkDone(),i.startTasks?.(p);const k=new Map,S=new Map;let M;const Z=()=>{for(const g of S.values())try{g("SIGTERM")}catch{}M||(M=setTimeout(()=>{for(const g of S.values())try{g("SIGKILL")}catch{}S.clear()},2e3),M.unref?.())};let b;o&&(b=()=>{Z()},o.then(()=>{b?.()}).catch(()=>{b?.()}));try{await it(c,{killOthers:["failure"],onEvent:g=>{const $=p[g.index];if($)switch(g.kind){case"close":{const _=k.get($.id)??Date.now(),H=g.killed||g.exitCode===0?"success":"failure";i.endTasks?.([{code:g.exitCode??0,endTime:Date.now(),startTime:_,status:H,task:$,terminalOutput:u.getSnapshot().outputs.get($.id)??""}]),S.delete(g.index),d?.delete($.id);break}case"error":{if(g.message){const _=a(g.index);_?(_.write(`${g.message}
|
|
172
|
-
`),u.setOutput($.id,_.toString())):u.addOutput($.id,`${g.message}
|
|
173
|
-
`)}break}case"started":{k.set($.id,Date.now()),g.kill&&S.set(g.index,g.kill),g.write&&d&&d.set($.id,{kill:g.kill,resize:g.resize,write:g.write});break}case"stderr":case"stdout":{if(g.text){const _=a(g.index);_?(_.write(g.text),u.setOutput($.id,_.toString())):u.addOutput($.id,`${g.text}
|
|
174
|
-
`)}break}default:}}})}finally{M&&(clearTimeout(M),M=void 0),u.markDone()}},Is=s=>{try{return process.kill(-s,0),!0}catch{try{return process.kill(s,0),!0}catch{return!1}}},dc=s=>{Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,s)},uc=s=>{const{extraPids:e=[],pidFiles:t,runDir:r}=s,c=[],o=i=>{try{process.kill(-i,"SIGTERM")}catch{try{process.kill(i,"SIGTERM")}catch{}}};for(const i of t){let d;try{const u=vr(i),p=Number.parseInt(u.trim(),10);d=Number.isFinite(p)&&p>0?p:void 0}catch{continue}d!==void 0&&(c.push(d),o(d))}for(const i of e)!Number.isFinite(i)||i<=0||(c.push(i),o(i));if(c.length>0){const u=Date.now()+1500;for(;Date.now()<u;){let p=!0;for(const f of c)if(Is(f)){p=!1;break}if(p)break;dc(100)}for(const p of c)if(Is(p))try{process.kill(-p,"SIGKILL")}catch{try{process.kill(p,"SIGKILL")}catch{}}}r&&Xr(r)},ut=256*1024;class fc{#e;#r="";#s=!1;constructor(e){this.#e=e}append(e){this.#r+=e,this.#r.length>this.#e&&(this.#r=this.#r.slice(-this.#e),this.#s=!0)}toString(){return this.#s?`[...output truncated, showing last ${Math.round(this.#e/1024)}KB...]
|
|
175
|
-
${this.#r}`:this.#r}}const hc=s=>`'${s.replaceAll("'",String.raw`'\''`)}'`,Mt=s=>process.platform==="win32"?s.length>0&&!/[\s"&|<>^()%!]/.test(s)?s:`"${s.replaceAll('"','""')}"`:hc(s),pc=(s,e,t)=>{if(!e||e.length===0||t===!1||t===void 0)return s;if(t==="args"||t==="both"){const r=e.map(c=>Mt(c)).join(" ");return`${s} ${r}`}return s},sr="visForwardedArgs",mc=(s,e)=>{const t=e.overrides[sr];if(!Array.isArray(t)||t.length===0)return s;const r=t.map(c=>Mt(c)).join(" ");return`${s} ${r}`},St=(s,e,t)=>{const r=s.overrides.command;if(!r)return;const c=Je(s),o=s.segment!==void 0&&s.segment.index<s.segment.count,i=o?r:mc(r,s),d=o?i:pc(i,e,c?.affectedFiles),u=Os(c,t),p=c?.shellArgs,f=p&&p.length>0?p.join(" "):"-c";return u?`${u} ${f} ${Mt(d)}`:d},gc=async(s,e,t)=>{if(!e)return t();const r=s.get(e)??Promise.resolve();let c;const o=new Promise(d=>{c=d}),i=r.then(()=>o);s.set(e,i),await r;try{return await t()}finally{c(),s.get(e)===i&&s.delete(e)}},wc=s=>{let e=Math.max(0,Math.floor(s));return{claim(t){const r=Math.max(0,Math.min(t,e));return e-=r,r},get remaining(){return e}}},Es=s=>async(e,t)=>{const{hooks:r,lifeCycle:c,mutexPool:o,onOutput:i,onOutputReplace:d,resolveCommand:u,retryBudget:p,serviceEventBridge:f,spawnContext:m,stdinRegistry:a,strictEnvFailure:k,workspaceRoot:S}=s,M=Je(e),Z=Ct(S,t.cwd??e.projectRoot,M?.runFromWorkspaceRoot===!0),b=u(e);if(!b)return{code:0,terminalOutput:`No command configured for ${e.target.project}:${e.target.target}`};const g=Qe(m,e,t),$=k(e,b,t);if($!==void 0)return c?.onTaskStderr?.(e,$),{code:1,terminalOutput:$};const _=M?.pty===!0,H=!!a,x=e.pty===!0?!0:e.pty===!1?!1:H||_;x&&(e.cache=!1);const D=x?void 0:new fc(ut),F=x?new Tt(ut):void 0;let N;const re=P=>{if(P.kind==="started"&&(N=P.kill,P.write&&a&&a.set(e.id,{kill:P.kill,resize:P.resize,write:P.write}),f?.onRegistryTaskStarted(e.id)),(P.kind==="stdout"||P.kind==="stderr")&&P.text!==void 0)if(P.kind==="stdout"?c?.onTaskStdout?.(e,P.text):c?.onTaskStderr?.(e,P.text),F)F.write(P.text),H&&d?.(e.id,F.toString()),f&&f.onTaskOutput(e.id,P.text);else{const V=`${P.text}
|
|
176
|
-
`;D.append(V),i?.(e.id,V)}P.kind==="close"&&(a&&a.delete(e.id),f&&f.onRegistryTaskClosed(e.id,P.exitCode??0,!!P.killed).catch(()=>{}))},C=async()=>{const P=M?.retryCount??0,V=M?.retryDelay,te=p?p.claim(P):P,ge=typeof M?.timeout=="number"&&M.timeout>0?M.timeout:0,ie=typeof M?.killGracePeriodMs=="number"&&M.killGracePeriodMs>=0?M.killGracePeriodMs:5e3;let se=!1,ee=0;const ke=ko({killGracePeriodMs:ie,onTimeout:()=>{se=!0},sendSignal:fe=>{N?.(fe)},timeoutMs:ge});let de;try{de=await it([{command:b,cwd:Z,env:g.env,inheritEnv:g.inheritEnv,name:e.id,...x?{ptySize:{cols:process.stdout.columns??80,rows:process.stdout.rows??24},stdin:"pty"}:{}}],{killOthers:["failure"],onEvent:re,...te>0?{restart:{delay:V??"exponential",onRetry:async(fe,ae,be)=>{ee=fe,r&&await r.callHook("task:retry",e,fe,be)},tries:te}}:{}})}finally{ke.cancel()}const G=de.closeEvents[0],W=F?F.toString():D.toString();return se?{code:124,retryAttempts:ee,terminalOutput:`${W}
|
|
177
|
-
[timeout] Task "${e.id}" exceeded ${ge}ms budget.
|
|
178
|
-
`}:{code:G?.exitCode??1,retryAttempts:ee,terminalOutput:W}};return o?gc(o,M?.mutex,C):C()},vc=s=>{if(!s||s.trim().length===0)return;const e=Number.parseFloat(s);return!Number.isFinite(e)||e<=0?{invalid:s}:{value:Math.floor(e)}},yc=async(s,e)=>{const t=await Pr(s,{dataDirectory:ot(s)});if(!t){e.warn(`No previous run recorded yet. Run a task at least once to populate ${Mr(s,{dataDirectory:ot(s)})}.`);return}const r=(t.duration/1e3).toFixed(2);if(e.info(""),e.info(`Last run — ${t.startTime} (${r}s)`),e.info(""),e.info(` Total: ${String(t.stats.total)}`),e.info(` Succeeded: ${String(t.stats.succeeded)}`),e.info(` Cached: ${String(t.stats.cached)}`),e.info(` Failed: ${String(t.stats.failed)}`),e.info(` Skipped: ${String(t.stats.skipped)}`),e.info(""),t.stats.failed>0){const o=t.tasks.filter(i=>i.exitCode!==void 0&&i.exitCode!==0);e.info("Failed tasks:");for(const i of o){const d=i.duration??0;e.info(` × ${i.taskId} (exit ${String(i.exitCode??-1)}, ${d}ms)`)}e.info("")}const c=[...t.tasks].filter(o=>typeof o.duration=="number").sort((o,i)=>(i.duration??0)-(o.duration??0)).slice(0,5);if(c.length>0){e.info("Slowest tasks:");for(const o of c)e.info(` ${o.taskId.padEnd(40)} ${String(o.duration??0).padStart(6)}ms [${o.cacheStatus}]`);e.info("")}},xc=s=>{if(!(s===void 0||s==="")){if(s!=="read"&&s!=="write"&&s!=="readwrite")throw new Error(`--cache-mode must be one of: read, write, readwrite (received "${s}")`);return s}},jc=s=>{if(!(s===void 0||s==="")){if(s!=="http"&&s!=="reapi")throw new Error(`--cache-backend must be one of: http, reapi (received "${s}")`);return s}},kc=s=>{if(!(s===void 0||s==="")){if(s!=="declared"&&s!=="trace")throw new Error(`--hash-mode must be one of: declared, trace (received "${s}")`);return s}},Xc=async({argument:s,logger:e,options:t,visConfig:r,workspaceRoot:c})=>{if(!c)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const o=c;if(an({options:t,visConfig:r},o),Kn(o),t.lastDetails){await yc(o,e);return}const i=process.cwd(),d=await zr(o,r),{config:u,fileOwners:p,packageJsons:f,projectOptions:m,workspace:a}=Yr(o,r,d),k=Kr(o,a,f);let S=s[0];if(!S){const h=is(a);if(process.stdout.isTTY&&process.stdin.isTTY){const v=await jn(h);if(!v){e.info("No target selected.");return}S=v,await wo(`vis run ${v}`)}else throw e.info("Available targets:"),e.info(""),e.info(kn(h)),e.info(""),new Fe("Missing target. Usage: vis run <target>")}if(u.constraints&&!t.skipConstraints){const h=kr(k,u.constraints);if(h.length>0){for(const v of h)e.error(`[${v.rule}] ${v.message}`);throw new Error(`${h.length} project constraint violation(s) found. Use --skip-constraints to bypass.`)}}if(!t.affected){const h=t.uncommitted?"--uncommitted":"--no-uncommitted",v=[["--base",t.base],["--head",t.head],["--downstream",t.downstream],["--upstream",t.upstream],[h,t.uncommitted]].filter(([,y])=>y!==void 0).map(([y])=>y);if(v.length>0)throw new Fe(`${v.join(", ")} ${v.length===1?"requires":"require"} --affected.
|
|
179
|
-
Did you mean: vis run ${S} --affected ${v.map(y=>y.includes("uncommitted")?y:`${y}=…`).join(" ")}
|
|
180
|
-
Or use the dedicated command: vis affected ${S} …`)}const M=await In(S,a,process.cwd(),o),Z=bn(m),b=Sn(M.target,Z);b!==M.target&&e.debug?.(`Resolved alias "${M.target}" → "${b}"`);let g=M.projects;const $=s.slice(1).map(String);t.projects!==void 0&&(g=Tn(g,String(t.projects),Object.keys(a.projects)));const _=h=>{if(t.ifPresent){e.info(`${h}; skipping (--if-present).`);return}throw new Fe(`${h}.
|
|
181
|
-
|
|
182
|
-
Pass --if-present to skip quietly when nothing matches.`)};if(t.filter&&t.filter.length>0){const h=new Map;for(const[T,B]of f)h.set(T,B.name);const v=await Bo(t.filter,{defaultBase:r?.defaultBase,packageNameByProject:h,projectGraph:k,workspaceRoot:o}),y=new Set(v);if(g=g.filter(T=>y.has(T)),g.length===0){_(`Filter ${t.filter.map(T=>`"${T}"`).join(", ")} matched no projects`);return}}if(t.query&&(g=En(g,a,t.query),g.length===0)){_(`Query "${String(t.query)}" matched no projects`);return}if(t.tag&&t.tag.length>0&&(g=Rn(g,a,t.tag),g.length===0)){_(`Tag filter ${t.tag.map(h=>`"${h}"`).join(", ")} matched no projects`);return}let H;if(t.affected){const h=await xn({base:t.base,downstream:t.downstream,head:t.head,uncommitted:t.uncommitted,upstream:t.upstream},{fileOwners:p,projectGraph:k,projects:a.projects,workspaceRoot:o},{affectedIgnore:r?.affectedIgnore,defaultBase:r?.defaultBase});for(const T of h.notes)e.info(`▸ ${T}`);if(h.changedFiles.length===0){e.info("No files changed. Nothing to run.");return}const v=new Set(h.affectedProjects);if(g=g.filter(T=>v.has(T)),g.length===0){e.info("No projects affected by the changes.");return}const y=new Set(h.ignoredFiles);H=h.changedFiles.filter(T=>!y.has(T)),e.info(`Affected projects: ${g.join(", ")}`)}const x=Fs(),D=process.env[Qn],F=H??(D?D.split(`
|
|
183
|
-
`).filter(Boolean):void 0),N=(typeof t.runnerTags=="string"?t.runnerTags:process.env.VIS_RUNNER_TAGS)??void 0,re=N?new Set(N.split(",").map(h=>h.trim()).filter(Boolean)):void 0,C=[],P=new Map;for(const h of g){const y=m.get(h)?.[b];if(!y)continue;const T=y.options;if(!T?.internal){if(!Mn(T,!!Ke)){e.debug?.(`Skipping ${h}:${b} — runInCI filter`);continue}if(!Fn(T,re)){e.debug?.(`Skipping ${h}:${b} — runner-tags filter`);continue}C.push(h),P.set(h,y)}}if(C.length===0){if(t.ifPresent){e.info(`No projects have the "${b}" target; skipping (--if-present).`);return}const h=is(a),v=Object.entries(a.projects).filter(([,T])=>T.targets?.[b]!==void 0).map(([T])=>T),y=[`No projects have the "${b}" target.`];if(v.length>0)y.push("",`Target "${b}" exists in these projects but was filtered out:`,...v.slice(0,5).map(T=>` - ${T}`)),v.length>5&&y.push(` …and ${v.length-5} more`);else{const T=$n(b,h,3);T.length>0&&y.push("",T.length===1?`Did you mean "${T[0]}"?`:`Did you mean one of: ${T.map(B=>`"${B}"`).join(", ")}?`),y.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(y.join(`
|
|
184
|
-
`))}const V=t.pty,te=C.map(h=>({project:h,schema:P.get(h)?.arguments})).filter(h=>Array.isArray(h.schema)&&h.schema.length>0),ge=new Map;for(const{project:h,schema:v}of te){const y=JSON.stringify(v),T=ge.get(y)??[];T.push(h),ge.set(y,T)}if(ge.size>1){const h=[...ge.values()].map(v=>v.join(", ")).join(" | ");throw new Error(`Target "${b}" declares conflicting \`arguments\` schemas across projects (${h}). Run a single project (e.g. \`vis run ${te[0]?.project}:${b}\` or --projects=<name>) so the argument contract is unambiguous.`)}const ie=te[0]?.schema,se=P.get(te[0]?.project??C[0])?.description,ee=ac(b,se,ie,$);if(ee.kind==="help"){e.info(ee.text);return}if(ee.kind==="invalid"){e.info(`Invalid arguments for "${b}":`);for(const h of ee.errors)e.info(` ✖ ${h}`);throw e.info(""),e.info(ee.help),new Error(`Invalid arguments for target "${b}"`)}const ke=ee.env,de=kc(t.hashMode);let G=C.map(h=>{const v=a.projects[h],y=P.get(h),T={project:h,target:b},B=`${h}:${b}`,J=V?{...y.options,pty:y.options?.pty??!0}:y.options,O=y.command?Zt(y.command,{affectedFiles:F,projectRoot:v?.root}):y.command,A=v?.root&&v.root.length>0?v.root:".",z=(y.outputs??[]).map(R=>typeof R!="string"?R:R.replaceAll("{projectRoot}",A).replaceAll("{projectName}",h)),Y=xi(y.options);return Y.length>0&&e.warn(ji(B,Y)),{cache:y.cache,declaresInputs:y.inputs!==void 0,fingerprintEnv:y.fingerprintEnv,hashMode:de??y.hashMode,id:B,outputs:z,overrides:{command:O,...$.length>0?{[sr]:$}:{},...Object.keys(ke).length>0?{[Zn]:ke}:{},...J?{visOptions:J}:{}},parallelism:y.parallelism,projectRoot:v?.root,splitCompound:y.splitCompound,target:T,untrackedEnv:y.untrackedEnv}});const W=[],fe=[];for(const h of G)Je(h)?.persistent?(h.cache=!1,W.push(h)):fe.push(h);G=fe;const ae=br(t.partition);if(ae&&(G=Sr.partitionTasks(G,ae),e.info(`Partition ${ae.index}/${ae.total}: running ${G.length} task(s)`),G.length===0)){e.info("No tasks assigned to this partition.");return}const be=new Set([...G,...W].map(h=>h.id));let q=Tr([...G,...W],{onCycleBroken:h=>{e.warn(`Ignoring dev-only dependency cycle (build order is ambiguous): ${h.join(" → ")}`)},onUnmatchedProjectSelector:h=>{e.warn(`dependsOn.projects entry "${h}" matched no project — that dependency edge was not created.`)},projectGraph:k,targetDefaults:u.tasks,workspace:a});for(const[h,v]of Object.entries(q.tasks)){const y=v.target.project,T=v.target.target,B=m.get(y)?.[T];if(!B){be.has(h)||e.warn(`${T} required via dependsOn but no command is configured for ${y} — skipping (no-op).`);continue}const J=a.projects[y];let O=!1;const A={...v.overrides};A.visOptions===void 0&&B.options&&(A.visOptions=B.options,O=!0),A.command===void 0&&B.command&&(A.command=Zt(B.command,{affectedFiles:F,projectRoot:J?.root}),O=!0),O&&(v.overrides=A,q.tasks[h]=v)}if(typeof t.skipCache=="string"&&t.skipCache.trim()!=="")if(t.cache){const h=Si(t.skipCache,a,Object.keys(q.tasks));for(const v of h.skipTaskIds){const y=q.tasks[v];y!==void 0&&(y.cache=!1)}h.unmatchedPatterns.length>0&&e.warn(`--skip-cache: no tasks matched ${h.unmatchedPatterns.map(v=>`"${v}"`).join(", ")}`),h.skipTaskIds.size>0&&e.debug?.(`--skip-cache: bypassing cache for ${String(h.skipTaskIds.size)} task(s)`)}else e.debug?.("--skip-cache ignored: --no-cache already disables caching for the whole run");await ln(o,u.toolchain,{error:h=>{e.error(h)},info:h=>{e.info(h)},warn:h=>{e.warn(h)}},!!t.skipToolchain);const He=t.preflight!==!1&&u.preflight?.lockfile!==!1,We=Qr(o,Ke,{warn:h=>{e.warn(h)}},{skip:!He});if(!We.shouldContinue)throw new Error(`${We.formattedMessage??"preflight: lockfile drift detected"} (pass --no-preflight to bypass)`);He&&!Ke&&process.stdin.isTTY&&process.stdout.isTTY&&await vi(o,{interactive:!0,logger:{info:h=>{e.info(h)},warn:h=>{e.warn(h)}},projectManifests:[...f.values()]});const Ze=process.env.VIS_VERSION??"0.0.0",et=t.dryRun?void 0:async h=>{try{return await pn(h.config,{timeoutMs:lc}),!0}catch{return!1}},tt=await mn(o),oe=await Eo({initialTasks:[...G,...W],probe:et,registeredEntries:tt,taskGraph:q,visVersion:Ze}),Se=[];let Ce,we=0;const Te=[],Me=new Map;let I=[];const j=new Set;let E=null,X=null;if(oe.diagnostics.length>0){const h=!!(process.stdout.isTTY&&process.stdin.isTTY),v=t.dryRun?"off":ec({cli:t.services,config:u.run?.services,isCi:!!Ke,isPersistentTarget:W.length>0,isTty:h,target:b});if(v==="off"){for(const Y of oe.diagnostics)e.error(Y.message);const A=Zo({cli:t.services,config:u.run?.services}),z=[];throw t.dryRun?z.push("`--dry-run` never starts services; drop it to let vis boot them."):A==="default"?z.push("vis only auto-starts service deps in an interactive terminal by default (this run is CI or non-TTY).","Pass `--services=ephemeral` to boot them for this run, or set `run.services` in vis.config.ts."):A==="cli"?z.push("`--services=off` was passed; use `--services=ephemeral` to boot them for this run."):z.push('`run.services: "off"` is set in vis.config.ts; override it with `--services=ephemeral`.'),new Fe([`${oe.diagnostics.length} service dependency error(s) — start the missing services or invoke them directly.`,...z].join(`
|
|
185
|
-
`))}const y=oe.diagnostics.map(A=>A.targetId),T=v,B=T==="registry"?Zs(o,y,q):void 0,J=process.argv[1]??"vis",O=Jo({missingServiceIds:y,mode:T,taskGraph:q,visBin:J,workspaceRoot:o});if(O.skipped.length>0){for(const{id:A,reason:z}of O.skipped)e.error(`Cannot auto-start ${A}: ${z}`);throw new Fe(`${O.skipped.length} service(s) cannot be auto-started — invoke them directly or add a service config.`)}Se.push(...O.ephemeralPidFiles),Ce=O.runDir,I=O.chain;for(const A of O.chain)j.add(A);if(T==="registry"&&(we=O.chain.length,Te.push(...O.chain)),O.chain.length>0){const A=new ps(O.chain),z=new Map;if(T==="ephemeral"&&O.runDir)for(const Y of O.chain){const R=er(O.runDir,`${O.runDir}/bootstrap.mjs`,Y);z.set(Y,{ephemeral:{configFile:R.configFile,cwd:o,logFile:R.logFile,pidFile:R.pidFile,scriptPath:R.scriptPath},mode:"ephemeral"})}else if(T==="registry"&&B)for(const Y of B.services)z.set(Y.id,{mode:"registry",registry:{command:Y.command,config:Y.config,cwd:Y.cwd,env:Y.env}});if(z.size>0){const Y=new Ho({indexToId:new Map,services:z,sink:{crashed:(R,L)=>{A.markCrashed(R,L)},failed:(R,L,U)=>{A.markFailed(R,L,U)},log:(R,L)=>{A.appendLog(R,L)},ready:(R,L)=>{A.markReady(R,L)},started:(R,L)=>{A.markStarted(R,L),T==="registry"&&L!==null&&Me.set(R,L)},starting:R=>{A.markStarting(R)}},workspaceRoot:o});E=A,X=Y}}for(const[A,z]of O.serviceEnvByTaskId){const Y=oe.serviceEnvByTaskId.get(A)??{};oe.serviceEnvByTaskId.set(A,{...Y,...z})}}const Le=new Set(W.map(h=>h.id));if(G=oe.initialTasks.filter(h=>!Le.has(h.id)),q=oe.taskGraph,I.length>0&&(G=[...I.map(v=>q.tasks[v]).filter(v=>v!==void 0),...G]),W.length>0){const h=new Set(W.map(J=>J.id)),v={};for(const[J,O]of Object.entries(q.tasks))h.has(J)||(v[J]=O);const y={};for(const[J,O]of Object.entries(q.dependencies))h.has(J)||(y[J]=O.filter(A=>!h.has(A)));const T=new Set;for(const J of Object.values(y))for(const O of J)T.add(O);const B=Object.keys(v).filter(J=>!T.has(J));q={dependencies:y,roots:B,tasks:v}}const{serviceEnvByTaskId:rr}=oe;if(oe.satisfiedServices.length>0){const h=oe.satisfiedServices.map(v=>v.id).join(", ");if(e.debug?.(`Auto-attached to running services: ${h}`),E)for(const v of oe.satisfiedServices)E.registerService(v.id);else E=new ps(oe.satisfiedServices.map(v=>v.id));for(const v of oe.satisfiedServices){const y=v.config.readiness?.tcp?.port??v.config.port??0,T=v.config.readiness?.tcp?.host??"127.0.0.1";E.markReady(v.id,{host:T,port:y})}}t.reverse&&(q=$r(q),e.debug?.(`Reversed task graph: ${String(q.roots.length)} new root(s) (originally leaves)`));for(const h of Object.values(q.tasks)){const v=m.get(h.target.project)?.[h.target.target]?.options;h.splitCompound&&Os(v)!==void 0&&(e.warn(`splitCompound ignored for ${h.id}: it uses a custom shell. Running the command as one unit.`),h.splitCompound=void 0)}if(q=Cr(q,{commandOf:h=>h.overrides.command,onDiagnostic:(h,v)=>{e.warn(v)}}),t.dryRun){const h=Object.keys(q.tasks).length,v=q.roots.length;e.info(`Execution plan (${String(h)} task(s), ${String(v)} root(s)):`),e.info("");const y=new Set,T=(B,J)=>{if(y.has(B))return;y.add(B);for(const L of q.dependencies[B]??[])T(L,J+1);const O=q.tasks[B],A=" ".repeat(J+1),z=O?.segment?` (segment ${String(O.segment.index)}/${String(O.segment.count)}: ${String(O.overrides.command)})`:"",Y=O?.hashMode==="trace"||u.taskRunner?.autoFingerprint===!0,R=`${O?.cache===!1?" (no-cache)":""}${Y?" (trace)":""}${z}`;e.info(`${A}${B}${R}`)};for(const B of q.roots)T(B,0);for(const B of Object.keys(q.tasks))T(B,0);W.length>0&&(e.info(""),e.info(` + ${String(W.length)} persistent task(s) (run after graph completes)`)),e.info("");return}const Ft=Date.now(),$e=gn(),Ot=(h,v)=>{const y=v instanceof Error?v.message:String(v);e.warn(`Plugin error in ${h}: ${y}`)};await wn($e,u.plugins);const qe=typeof t.profile=="string"?t.profile:void 0,At=async h=>{if(!qe)return;const v=ss(h,q,Ft),y=qe.startsWith("/")?qe:`${o}/${qe}`;await Or(v,y),e.info(`Profile written to ${qe}`)},st=u.taskRunner??{},nr=Nr(o,t.cacheDir,st.cacheDirectory,u.sharedWorktreeCache),ir=Gr(nr,o,u.branchScopedCache),De=vc(process.env.VIS_RUN_CONCURRENCY_LIMIT);De&&"invalid"in De&&e.warn(`VIS_RUN_CONCURRENCY_LIMIT=${De.invalid} is not a positive number; falling back to default concurrency.`);const or=De&&"value"in De?De.value:void 0,Lt=t.parallel??or??3,cr=t.strictEnv??u.strictEnv??!1,Dt=new Set,Ie={dryRun:t.dryRun??!1,parallel:Lt,skipNxCache:!t.cache,summarize:t.summarize??!1,...st,cacheDirectory:ir,dataDirectory:st.dataDirectory??ot(o),namedInputs:u.namedInputs,onDiagnostic:(h,v)=>{Dt.has(h)||(Dt.add(h),e.warn(v))},onFingerprint:async(h,v)=>{await $e.callHook("task:fingerprint",h,v)}},pt=h=>si(Ie.env,Je(h)?.env),je=ei({affectedFiles:F,childEnvPolicy:pt,initCwd:i,serviceEnvByTaskId:rr,taskSlots:Lt,workspaceRoot:o}),Ve=h=>St(h,F,x),mt=(h,v,y)=>{if(!(Je(h)?.strictEnv??cr))return;const B=Qe(je,h,y),J=je.childEnvPolicy(h),O=Ii({command:v,processEnv:J.mode==="clean"?Fr(process.env,J):process.env,taskEnv:B.env,taskId:h.id});return O?Ei(O):void 0},Bt=(h,v)=>{const y=Ve(h);return y===void 0?void 0:mt(h,y,v)},_t=Ir(st.remoteCache);if(_t){const h=xc(t.cacheMode),v=jc(t.cacheBackend);if(Ie.remoteCache={..._t,...h?{mode:h}:{},...v?{backend:v}:{}},Ie.remoteCache.attestation){const{expectedIdentity:y,requireOnDownload:T}=Ie.remoteCache.attestation;if(!(y!==void 0&&("github"in y&&typeof y.github?.ref=="string"&&typeof y.github.repo=="string"&&typeof y.github.workflow=="string"||"oidcIssuer"in y&&typeof y.oidcIssuer=="string"&&(typeof y.san=="string"||typeof y.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 y&&(!y.sanRegex.startsWith("^")||!y.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:J,isSigstoreInstalled:O}=await import("./loader.js");O()||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:
|
|
186
|
-
${J(o)}`);const{buildCacheAttestationHooks:A}=await import("./cache-attestation.js");Ie.remoteCache.attestation=A({expectedIdentity:y,onReject:(z,Y)=>{e.warn(`[vis run] remote cache entry ${z.slice(0,12)} rejected: attestation ${Y}. Treating as a cache miss.`)},onVerifyFailure:z=>{e.warn(`[vis run] attestation verification failed: ${z}`)},requireOnDownload:T,workspaceRoot:o})}}else(t.cacheMode||t.cacheBackend)&&e.warn("[vis run] --cache-mode and --cache-backend require a `remoteCache` block in vis.config.ts (or TURBO_API env); ignoring.");const ar=process.stdout.isTTY&&!Ke,lr=r?.run?.quietOnSuccess===!0,dr=u.tui?.autoExit??(lr?3:!1),Nt={args:{parallel:Ie.parallel,targets:[b]},autoExit:dr,projectNames:C,tasks:[...G,...W].flatMap(h=>{const v=Object.values(q.tasks).filter(y=>y.segment!==void 0&&y.id.startsWith(`${h.id}#`));return v.length>0?v:[h]}),totalTaskCount:Object.keys(q.tasks).length+W.length},Gt=typeof t.retryBudget=="number"?t.retryBudget:void 0,Ht=Gt===void 0?void 0:wc(Gt),Wt=new vn($e,Ot),qt=new cn(o),Vt=po(t.outputStyle,r?.run?.quietOnSuccess);if(oe.satisfiedServices.length>0)for(const h of oe.satisfiedServices){const v=oe.serviceDependentsByServiceId.get(h.id)??[];try{await $e.callHook("service:attach",h,v)}catch(y){Ot("service:attach",y)}}await $e.callHook("run:before",{tasks:G,workspaceRoot:o});const Ue=t.stopServices;let Ut=!1;const zt=()=>{if(Ut)return;Ut=!0,X&&X.dispose().catch(()=>{});const h=Ue?[...Me.values()]:void 0;uc({extraPids:h,pidFiles:Se,runDir:Ce})},rt=()=>{zt()},Yt=Se.length>0||Ce!==void 0||Ue&&Te.length>0;Yt&&(process.on("SIGINT",rt),process.on("SIGTERM",rt));try{if(ar){const h=new Map,v=go({...Nt,onRetryService:X?R=>X.retry(R):void 0,outputStyle:Vt,serviceDockStore:E,stdinRegistry:h}),{lifeCycle:y,store:T}=v,B=new es([y,Wt,qt]),O=Es({hooks:$e,lifeCycle:B,mutexPool:new Map,onOutput:(R,L)=>{X&&j.has(R)?X.onTaskOutput(R,L):T.addOutput(R,L)},onOutputReplace:(R,L)=>{T.setOutput(R,L)},resolveCommand:Ve,retryBudget:Ht,serviceEventBridge:X??void 0,spawnContext:je,stdinRegistry:h,strictEnvFailure:mt,workspaceRoot:o});let A="rerun",z=null,Y=new Map;for(;A!=="quit";){if(A==="rerun"){if(Y=await ts(G,Ie,{childEnvPolicy:pt,lifeCycle:B,preTraceCheck:Bt,projectGraph:k,resolveChildEnv:(R,L)=>Qe(je,R,L),resolveCommand:Ve,taskExecutor:O,taskGraph:q,workspaceRoot:o}),W.length>0&&!t.failFast){const R=new Promise(L=>{const U=T.subscribe(()=>{const ce=T.getSnapshot();(ce.rerunRequested||ce.retryTaskId)&&(U(),L())});v.renderIsDone.then(()=>{U(),L()}).catch(()=>{U(),L()})});await Cs(W,je,{abortSignal:R,lifeCycle:B,stdinRegistry:h,store:T})}}else if(A==="retry"&&z){const R=q.tasks[z]??G.find(U=>U.id===z),L=R?St(R,je.affectedFiles,x):void 0;if(R&&L){B.startTasks?.([R]);const U=new Tt(ut),ce=ti(je,R),he=(await it([{command:L,cwd:ce.cwd,env:ce.env,inheritEnv:ce.inheritEnv,name:R.id,ptySize:{cols:process.stdout.columns??80,rows:process.stdout.rows??24},stdin:"pty"}],{onEvent:ne=>{ne.kind==="started"&&ne.write&&h.set(R.id,{kill:ne.kill,resize:ne.resize,write:ne.write}),(ne.kind==="stdout"||ne.kind==="stderr")&&ne.text&&(U.write(ne.text),T.setOutput(R.id,U.toString())),ne.kind==="close"&&h.delete(R.id)}})).closeEvents[0];B.endTasks?.([{code:he?.exitCode??1,status:he?.exitCode===0?"success":"failure",task:R,terminalOutput:T.getSnapshot().outputs.get(R.id)}])}else R&&B.endTasks?.([{code:1,status:"failure",task:R,terminalOutput:`No command configured for ${R.id}`}]);z=null,T.markDone()}A=await new Promise(R=>{const L=T.subscribe(()=>{const U=T.getSnapshot();U.rerunRequested&&(T.acknowledgeRerun(),L(),R("rerun")),U.retryTaskId&&(z=T.acknowledgeRetry(),L(),R("retry"))});v.renderIsDone.then(()=>{L(),R("quit")}).catch(()=>{L(),R("quit")})})}await v.renderIsDone,await $e.callHook("run:after",Y),await At(Y),we>0&&(e.info(""),Ue?e.info(`${String(we)} service(s) stopped (--stop-services).`):e.info(`${String(we)} service(s) started in the background. Run \`vis service stop --all\` to clean up.`))}else{const h=new Map,v=typeof t.log=="string"?t.log.toLowerCase():"",y=v==="labeled"||v==="grouped"||v==="interleaved"?v:void 0,T=y?Er(y):void 0,B=new es([new mo({...Nt,ciGrouping:r?.run?.ciGrouping??"auto",logReporter:T,outputStyle:Vt}),Wt,qt]),J=Es({hooks:$e,lifeCycle:B,mutexPool:h,resolveCommand:Ve,retryBudget:Ht,serviceEventBridge:X??void 0,spawnContext:je,strictEnvFailure:mt,workspaceRoot:o}),O=async()=>{const L=Date.now(),U=await ts(G,Ie,{childEnvPolicy:pt,lifeCycle:B,preTraceCheck:Bt,projectGraph:k,resolveChildEnv:(pe,Be)=>Qe(je,pe,Be),resolveCommand:Ve,taskExecutor:J,taskGraph:q,workspaceRoot:o}),ce=Date.now()-L;if(t.summarize){const pe=ss(U,q,Ft);await Rr(pe,o,{dataDirectory:ot(o)})}let ve=!1;for(const[,pe]of U)pe.status==="failure"&&(ve=!0);const he=Hr(U,ce),ne=Wr(o),Ee=qr(o,ce,ne);return e.info(""),e.info(` ${he}${Ee?` ${Ee}`:""}`),{hasFailure:ve,results:U,runHistory:ne}},A=await O();await $e.callHook("run:after",A.results),await At(A.results);const{hasFailure:z}=A;if(t.watch){const L=C.map(ue=>{const Re=a.projects[ue]?.root;if(Re)return Re.startsWith("/")?Re:`${o}/${Re}`}).filter(ue=>ue!==void 0),U=G;let ce;const ve=ue=>{const ye=bo(U,ue);return ce=ye.filter,G=ye.tasks,ye.tasks.length};let he=!1,ne=A.results;const Ee=()=>{const ue=as(ne,o);if(ue.directories.length>0&&ue.files.size>0){const ye=Xn(ue.files,o,ue.directories);return{handle:ls({filter:ye,onChange:Be,paths:ue.directories}),mode:"tracked"}}return{handle:ls({onChange:Be,paths:L}),mode:"roots"}};let pe;const Be=async ue=>{if(!he){he=!0;try{e.info(`Change detected in ${ue.length} file(s), rerunning…`),ne=(await O()).results,pe?.close(),pe=Ee().handle}finally{he=!1}}},Kt=Ee();pe=Kt.handle;const ur=Kt.mode==="tracked"?`Watching ${String(as(ne,o).files.size)} tracked file(s)`:`Watching ${String(L.length)} project root(s)`;e.info(`${ur} — edit a file to rerun, press h for keybinds, q to quit.`);const gt=async()=>{if(!he){he=!0;try{if(G.length===0){e.info("No tasks match the active filter — press a to clear it.");return}ne=(await O()).results,pe?.close(),pe=Ee().handle}finally{he=!1}}};await new Promise(ue=>{let ye=!1,Re;const Xt=()=>{Jt()},Jt=()=>{ye||(ye=!0,Re?.close(),process.off("SIGINT",Xt),pe?.close(),ue())};process.on("SIGINT",Xt),Re=Co({handlers:{onClearFilter:async()=>{const ze=ve(void 0);e.info(`Filter cleared — running ${String(ze)} task(s).`),await gt()},onFilter:async ze=>{const fr=ce,Qt=ve(ze);if(Qt===0){e.info(`Filter "${ze}" matched no projects — keeping previous filter.`),ve(fr);return}e.info(`Filter "${ze}" matched ${String(Qt)} task(s).`),await gt()},onHelp:()=>{To(process.stdout)},onQuit:()=>{Jt()},onRerun:gt}})});return}if(t.flaky){const L=Vr(o,{minRuns:2},A.runHistory);if(L.length>0){e.info(""),e.info("Flaky tasks (based on historical runs):"),e.info("");for(const U of Ur(L))e.info(` ${U}`);e.info("")}}const Y=[];for(const[L,U]of A.results)U.retryAttempts&&U.retryAttempts>0&&Y.push(L);const R=t.failOnRetry&&Y.length>0;if(R){const U=Y.slice(0,5),ce=Y.length-U.length,ve=ce>0?`${U.join(", ")}, and ${String(ce)} more`:U.join(", ");e.warn(""),e.warn(`--fail-on-retry: ${String(Y.length)} task(s) succeeded only after retry: ${ve}`)}if(z||R){const L=R&&!z?"Some tasks succeeded only after retry (--fail-on-retry).":"Some tasks failed.",U=2e3,ce=[];for(const[ve,he]of A.results){if(he.status!=="failure")continue;const ne=he.terminalOutput??"",Ee=ne.length>U?`…${ne.slice(-U)}`:ne,pe=he.code??"?";ce.push(` ${ve} (exit ${String(pe)}):
|
|
187
|
-
${Ee.split(`
|
|
188
|
-
`).map(Be=>` ${Be}`).join(`
|
|
189
|
-
`)}`)}throw new Fe(ce.length>0?`${L}
|
|
190
|
-
${ce.join(`
|
|
191
|
-
`)}`:L)}W.length>0&&!t.failFast&&await Cs(W,je,void 0),we>0&&(e.info(""),Ue?e.info(`${String(we)} service(s) stopped (--stop-services).`):e.info(`${String(we)} service(s) started in the background. Run \`vis service stop --all\` to clean up.`))}}finally{zt(),Yt&&(process.off("SIGINT",rt),process.off("SIGTERM",rt)),Ue&&Te.length>0&&await Promise.all(Te.map(async h=>{try{await yn(o,h)}catch{}}))}};export{wc as createRetryBudget,Xc as default};
|
|
1
|
+
import{createRequire as Ne}from"node:module";import{C as W,L as Ce,K as ze,M as Ge,J as $e,N as We,Q as Ve,q as Ue}from"./cli-main.js";import{i as Xe}from"../packem_shared/index-BjdW45xX.js";import{r as p,j as e,X as s,O as o,R as He}from"../packem_shared/registry-CkoaWkjP.js";import{d as Ke}from"../packem_shared/pm-runner-RM72mDZg.js";import{h as Je,e as le,z as Ye,m as Qe}from"../packem_shared/index-BzhrR_iC.js";import{y as Ze}from"../packem_shared/isAccessibleSync-DYKTrrvc-C-_5cgwu.js";import{h as et}from"../packem_shared/writeFileSync-DJoHk3Ks-BPRoepNw.js";import{n as tt,a as ot}from"../packem_shared/tabs-CC0GJLww.js";let Re;const _e=i=>(Re??=Ne(import.meta.url))(i),J=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Be=i=>{if(typeof J<"u"&&J.versions&&J.versions.node){const[t,n]=J.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return J.getBuiltinModule(i)}return _e(i)},{writeFileSync:qe}=Be("node:fs"),rt=(i,{whitespace:t=!0}={})=>i.replace(Je,n=>n.startsWith('"')||n[1]==="*"&&!n.endsWith("*/")?n:t?n.replaceAll(/\S/g," "):""),V=[{config:{customizations:{vscode:{extensions:["dbaeumer.vscode-eslint","esbenp.prettier-vscode"]}},features:{"ghcr.io/devcontainers/features/git:1":{},"ghcr.io/devcontainers/features/github-cli:1":{}},forwardPorts:[3e3],image:"mcr.microsoft.com/devcontainers/javascript-node:22",name:"Node.js",postCreateCommand:"npm install"},description:"Node.js 22 with Git and GitHub CLI",id:"node",name:"Node.js"},{config:{customizations:{vscode:{extensions:["dbaeumer.vscode-eslint","esbenp.prettier-vscode"]}},features:{"ghcr.io/devcontainers/features/git:1":{},"ghcr.io/devcontainers/features/github-cli:1":{}},forwardPorts:[3e3],image:"mcr.microsoft.com/devcontainers/javascript-node:22",mounts:[{source:"${localWorkspaceFolderBasename}-node_modules",target:"${containerWorkspaceFolder}/node_modules",type:"volume"},{source:"${localWorkspaceFolderBasename}-pnpm-store",target:"/home/node/.local/share/pnpm/store",type:"volume"}],name:"Node.js + pnpm Monorepo",postCreateCommand:"corepack enable && pnpm install",remoteUser:"node",workspaceFolder:"/workspaces/${localWorkspaceFolderBasename}"},description:"Node.js 22 with pnpm, corepack, and optimized volume mounts",id:"node-pnpm",name:"Node.js + pnpm"},{config:{customizations:{vscode:{extensions:["dbaeumer.vscode-eslint","esbenp.prettier-vscode","ms-azuretools.vscode-docker"]}},dockerComposeFile:"docker-compose.yml",forwardPorts:[3e3,5432],name:"Node.js + PostgreSQL",postCreateCommand:"npm install",service:"app",workspaceFolder:"/workspaces/${localWorkspaceFolderBasename}"},description:"Node.js with PostgreSQL via Docker Compose",id:"node-postgres",name:"Node.js + PostgreSQL"},{config:{customizations:{vscode:{extensions:["dbaeumer.vscode-eslint","esbenp.prettier-vscode","ms-azuretools.vscode-docker"]}},features:{"ghcr.io/devcontainers/features/docker-in-docker:2":{},"ghcr.io/devcontainers/features/git:1":{},"ghcr.io/devcontainers/features/github-cli:1":{}},forwardPorts:[3e3],image:"mcr.microsoft.com/devcontainers/javascript-node:22",name:"Node.js + Docker",postCreateCommand:"npm install"},description:"Node.js 22 with Docker-in-Docker for container workflows",id:"node-dind",name:"Node.js + Docker-in-Docker"},{config:{customizations:{vscode:{extensions:["dbaeumer.vscode-eslint","esbenp.prettier-vscode","ms-azuretools.vscode-docker"]}},dockerComposeFile:"docker-compose.yml",features:{"ghcr.io/devcontainers/features/docker-in-docker:2":{}},forwardPorts:[3e3,5432,6379],name:"Full Stack",postCreateCommand:"npm install",service:"app",workspaceFolder:"/workspaces/${localWorkspaceFolderBasename}"},description:"Node.js + PostgreSQL + Redis + Docker via Compose",id:"fullstack",name:"Full Stack"},{config:{customizations:{vscode:{extensions:["ms-python.python","ms-python.vscode-pylance"],settings:{"editor.formatOnSave":!0,"python.defaultInterpreterPath":"/usr/local/bin/python"}}},features:{"ghcr.io/devcontainers/features/git:1":{},"ghcr.io/devcontainers/features/github-cli:1":{},"ghcr.io/devcontainers/features/python:1":{version:"3.12"}},forwardPorts:[8e3],image:"mcr.microsoft.com/devcontainers/python:3.12",name:"Python",postCreateCommand:"pip install -r requirements.txt || true"},description:"Python 3.12 with pip and venv",id:"python",name:"Python"},{config:{customizations:{vscode:{extensions:["golang.go"],settings:{"editor.formatOnSave":!0,"go.toolsManagement.autoUpdate":!0}}},features:{"ghcr.io/devcontainers/features/git:1":{},"ghcr.io/devcontainers/features/go:1":{version:"1.22"}},forwardPorts:[8080],image:"mcr.microsoft.com/devcontainers/go:1.22",name:"Go",postCreateCommand:"go mod download || true"},description:"Go 1.22 development environment",id:"go",name:"Go"},{config:{customizations:{vscode:{extensions:["rust-lang.rust-analyzer","tamasfe.even-better-toml"],settings:{"editor.formatOnSave":!0}}},features:{"ghcr.io/devcontainers/features/git:1":{},"ghcr.io/devcontainers/features/rust:1":{}},image:"mcr.microsoft.com/devcontainers/rust:latest",name:"Rust",postCreateCommand:"cargo build || true"},description:"Rust development with cargo and rust-analyzer",id:"rust",name:"Rust"},{config:{customizations:{vscode:{extensions:["vscjava.vscode-java-pack","vscjava.vscode-maven"]}},features:{"ghcr.io/devcontainers/features/git:1":{},"ghcr.io/devcontainers/features/java:1":{version:"17"}},forwardPorts:[8080],image:"mcr.microsoft.com/devcontainers/java:17",name:"Java",postCreateCommand:"./mvnw install || ./gradlew build || true"},description:"Java 17 with Maven/Gradle support",id:"java",name:"Java"},{config:{customizations:{vscode:{extensions:["ms-azuretools.vscode-docker","ms-kubernetes-tools.vscode-kubernetes-tools","hashicorp.terraform"]}},features:{"ghcr.io/devcontainers/features/aws-cli:1":{},"ghcr.io/devcontainers/features/azure-cli:1":{},"ghcr.io/devcontainers/features/docker-in-docker:2":{},"ghcr.io/devcontainers/features/kubectl-helm-minikube:1":{},"ghcr.io/devcontainers/features/terraform:1":{}},image:"mcr.microsoft.com/devcontainers/base:ubuntu",name:"DevOps"},description:"Docker, Kubernetes, Terraform, AWS & Azure CLIs",id:"devops",name:"DevOps"},{config:{features:{"ghcr.io/devcontainers/features/common-utils:2":{}},image:"mcr.microsoft.com/devcontainers/base:ubuntu",name:"Minimal",remoteUser:"vscode"},description:"Bare Ubuntu with common utilities",id:"minimal",name:"Minimal"},{config:{image:"mcr.microsoft.com/devcontainers/base:ubuntu",name:"Custom"},description:"Minimal Ubuntu base - configure from scratch",id:"custom",name:"Custom (Blank)"}],nt=i=>{const t=le(i,".devcontainer","devcontainer.json");if(!Ze(t))return null;const n=Ye(t),c=rt(n),l=c!==n;let r;try{r=JSON.parse(c)}catch(a){const m=a instanceof Error?a.message:String(a);throw new Error(`Failed to parse ${t}: ${m}`,{cause:a})}return{config:r,hadComments:l}},it=(i,t,n)=>{const c=n?Qe(n):le(i,".devcontainer"),l=n??le(c,"devcontainer.json");et(c),qe(l,`${JSON.stringify(t,null,2)}
|
|
2
|
+
`,"utf8")},st={bun:[{source:"${localWorkspaceFolderBasename}-node_modules",target:"${containerWorkspaceFolder}/node_modules",type:"volume"},{source:"${localWorkspaceFolderBasename}-bun-cache",target:"/home/node/.bun/install/cache",type:"volume"}],npm:[{source:"${localWorkspaceFolderBasename}-node_modules",target:"${containerWorkspaceFolder}/node_modules",type:"volume"},{source:"${localWorkspaceFolderBasename}-npm-cache",target:"/home/node/.npm",type:"volume"}],pnpm:[{source:"${localWorkspaceFolderBasename}-node_modules",target:"${containerWorkspaceFolder}/node_modules",type:"volume"},{source:"${localWorkspaceFolderBasename}-pnpm-store",target:"/home/node/.local/share/pnpm/store",type:"volume"}],yarn:[{source:"${localWorkspaceFolderBasename}-node_modules",target:"${containerWorkspaceFolder}/node_modules",type:"volume"},{source:"${localWorkspaceFolderBasename}-yarn-cache",target:"/home/node/.yarn/cache",type:"volume"}]},ct=[{featureMatch:"docker-in-docker",mounts:[]},{featureMatch:"docker-outside-of-docker",mounts:[{source:"/var/run/docker.sock",target:"/var/run/docker.sock",type:"bind"}]},{featureMatch:"/features/git:",mounts:[{source:"${localWorkspaceFolderBasename}-git-config",target:"/home/node/.gitconfig",type:"volume"}]}],pe=(i,t,n)=>{const c=[],l=new Set(n.map(a=>typeof a=="string"?a:a.target));if(i)for(const a of st[i])l.has(a.target)||c.push(a);const r=Object.keys(t);for(const{featureMatch:a,mounts:m}of ct)if(r.some(g=>g.includes(a)))for(const g of m)l.has(g.target)||c.push(g);return c},_=["general","features","ports","lifecycle","extensions","environment","mounts","compose"],Y=i=>structuredClone(i);class lt{#r=new Set;#e;constructor(t,n,c=null){const l=t===null,r=t??{name:""},a=Y(r);this.#e={config:a,detectedPm:c,extensionSearch:"",featureSearch:"",fieldEditing:!1,fieldIndex:0,hadComments:n,isDirty:!1,mode:l?"create":"edit",originalConfig:l?null:Y(r),section:"general",showTemplateSelector:l,suggestedMounts:pe(c,a.features??{},a.mounts??[]),templateIndex:0}}getSnapshot=()=>this.#e;subscribe=t=>(this.#r.add(t),()=>{this.#r.delete(t)});setSection(t){t!==this.#e.section&&this.#t({...this.#e,fieldEditing:!1,fieldIndex:0,section:t})}nextSection(){const n=(_.indexOf(this.#e.section)+1)%_.length;this.setSection(_[n])}previousSection(){const n=(_.indexOf(this.#e.section)-1+_.length)%_.length;this.setSection(_[n])}setFieldIndex(t){t!==this.#e.fieldIndex&&this.#t({...this.#e,fieldIndex:Math.max(0,t)})}setFieldEditing(t){t!==this.#e.fieldEditing&&this.#t({...this.#e,fieldEditing:t})}setTemplateIndex(t){const n=Math.max(0,Math.min(t,V.length-1));n!==this.#e.templateIndex&&this.#t({...this.#e,templateIndex:n})}applyTemplate(t){const n=V.find(c=>c.id===t);n&&this.#t(this.#o({...this.#e,config:Y(n.config),isDirty:!0,showTemplateSelector:!1}))}dismissTemplateSelector(){this.#t({...this.#e,showTemplateSelector:!1})}updateConfig(t){this.#t({...this.#e,config:{...this.#e.config,...t},isDirty:!0})}toggleFeature(t){const n={...this.#e.config.features};n[t]===void 0?n[t]={}:delete n[t],this.#t(this.#o({...this.#e,config:{...this.#e.config,features:n},isDirty:!0}))}setFeatureSearch(t){this.#t({...this.#e,featureSearch:t,fieldIndex:0})}addPort(t){const n=this.#e.config.forwardPorts??[];if(n.includes(t))return;const c=[...n,t];this.#t({...this.#e,config:{...this.#e.config,forwardPorts:c},isDirty:!0})}removePort(t){const n=[...this.#e.config.forwardPorts??[]];n.splice(t,1),this.#t({...this.#e,config:{...this.#e.config,forwardPorts:n.length>0?n:void 0},isDirty:!0})}toggleExtension(t){const n={...this.#e.config.customizations},c={...n.vscode},l=[...c.extensions??[]],r=l.indexOf(t);r===-1?l.push(t):l.splice(r,1),c.extensions=l.length>0?l:void 0,n.vscode=c.extensions||c.settings?c:void 0,this.#t({...this.#e,config:{...this.#e.config,customizations:n.vscode||n.jetbrains?n:void 0},isDirty:!0})}setExtensionSearch(t){this.#t({...this.#e,extensionSearch:t,fieldIndex:0})}addEnvVar(t,n,c){const l=t==="container"?"containerEnv":"remoteEnv",r={...this.#e.config[l],[n]:c};this.#t({...this.#e,config:{...this.#e.config,[l]:r},isDirty:!0})}removeEnvVar(t,n){const c=t==="container"?"containerEnv":"remoteEnv",l={...this.#e.config[c]};delete l[n],this.#t({...this.#e,config:{...this.#e.config,[c]:Object.keys(l).length>0?l:void 0},isDirty:!0})}addMount(t){const n=[...this.#e.config.mounts??[],t];this.#t(this.#o({...this.#e,config:{...this.#e.config,mounts:n},isDirty:!0}))}removeMount(t){const n=[...this.#e.config.mounts??[]];n.splice(t,1),this.#t(this.#o({...this.#e,config:{...this.#e.config,mounts:n.length>0?n:void 0},isDirty:!0}))}applySuggestedMounts(){if(this.#e.suggestedMounts.length===0)return;const t=[...this.#e.config.mounts??[],...this.#e.suggestedMounts];this.#t(this.#o({...this.#e,config:{...this.#e.config,mounts:t},isDirty:!0}))}setLifecycleCommand(t,n){this.#t({...this.#e,config:{...this.#e.config,[t]:n||void 0},isDirty:!0})}markClean(){this.#t({...this.#e,isDirty:!1,originalConfig:Y(this.#e.config)})}getJsonPreview(){return JSON.stringify(this.#n(),null,2)}cleanConfig(){return this.#n()}#n(){const t=Y(this.#e.config);for(const[n,c]of Object.entries(t))(c===""||c===void 0)&&delete t[n];return t.build&&(t.build.dockerfile===""&&delete t.build.dockerfile,t.build.context===""&&delete t.build.context,t.build.args&&Object.keys(t.build.args).length===0&&delete t.build.args,Object.keys(t.build).length===0&&delete t.build),t.forwardPorts?.length===0&&delete t.forwardPorts,t.mounts?.length===0&&delete t.mounts,t.runServices?.length===0&&delete t.runServices,t.capAdd?.length===0&&delete t.capAdd,t.securityOpt?.length===0&&delete t.securityOpt,t.features&&Object.keys(t.features).length===0&&delete t.features,t.customizations?.vscode?.extensions?.length===0&&delete t.customizations.vscode.extensions,t.customizations?.vscode&&Object.keys(t.customizations.vscode).length===0&&delete t.customizations.vscode,t.customizations&&Object.keys(t.customizations).length===0&&delete t.customizations,t.containerEnv&&Object.keys(t.containerEnv).length===0&&delete t.containerEnv,t.remoteEnv&&Object.keys(t.remoteEnv).length===0&&delete t.remoteEnv,t}#o(t){return{...t,suggestedMounts:pe(t.detectedPm,t.config.features??{},t.config.mounts??[])}}#t(t){this.#e=t;for(const n of this.#r)try{n()}catch{}}}const xe=[{category:"linting",description:"Integrates ESLint into the editor",id:"dbaeumer.vscode-eslint",name:"ESLint"},{category:"linting",description:"Stylelint CSS/SCSS linting",id:"stylelint.vscode-stylelint",name:"Stylelint"},{category:"formatting",description:"Opinionated code formatter",id:"esbenp.prettier-vscode",name:"Prettier"},{category:"formatting",description:"EditorConfig file support",id:"editorconfig.editorconfig",name:"EditorConfig"},{category:"formatting",description:"Fast Rust-based formatter and linter",id:"biomejs.biome",name:"Biome"},{category:"language",description:"Rich TypeScript and JavaScript support",id:"ms-vscode.vscode-typescript-next",name:"TypeScript Nightly"},{category:"language",description:"Tailwind CSS IntelliSense",id:"bradlc.vscode-tailwindcss",name:"Tailwind CSS"},{category:"language",description:"YAML language support with schemas",id:"redhat.vscode-yaml",name:"YAML"},{category:"language",description:"TOML language support",id:"tamasfe.even-better-toml",name:"TOML"},{category:"language",description:"Dockerfile and Docker Compose support",id:"ms-azuretools.vscode-docker",name:"Docker"},{category:"language",description:"Python language support with Pylance",id:"ms-python.python",name:"Python"},{category:"language",description:"Go language support",id:"golang.go",name:"Go"},{category:"language",description:"Rust language support via rust-analyzer",id:"rust-lang.rust-analyzer",name:"rust-analyzer"},{category:"git",description:"Git supercharged: blame, history, stash, etc.",id:"eamodio.gitlens",name:"GitLens"},{category:"git",description:"GitHub Pull Requests and Issues",id:"github.vscode-pull-request-github",name:"GitHub PR"},{category:"testing",description:"Vitest test explorer integration",id:"vitest.explorer",name:"Vitest Explorer"},{category:"testing",description:"Jest test runner and assertions",id:"orta.vscode-jest",name:"Jest"},{category:"debugging",description:"REST client for testing APIs",id:"humao.rest-client",name:"REST Client"},{category:"debugging",description:"Error Lens: inline error highlighting",id:"usernamehw.errorlens",name:"Error Lens"},{category:"other",description:"Intelligent code completion with AI",id:"github.copilot",name:"GitHub Copilot"},{category:"other",description:"Path autocompletion for imports",id:"christian-kohler.path-intellisense",name:"Path Intellisense"},{category:"other",description:"Import cost display in editor",id:"wix.vscode-import-cost",name:"Import Cost"},{category:"other",description:"Todo Tree: highlight and list TODOs",id:"gruntfuggly.todo-tree",name:"Todo Tree"}],je=[{category:"language",description:"Node.js runtime via nvm with optional pnpm/yarn",id:"ghcr.io/devcontainers/features/node:1",name:"Node.js"},{category:"language",description:"Python runtime with pip and optional tools",id:"ghcr.io/devcontainers/features/python:1",name:"Python"},{category:"language",description:"Go compiler and tools",id:"ghcr.io/devcontainers/features/go:1",name:"Go"},{category:"language",description:"Rust toolchain via rustup",id:"ghcr.io/devcontainers/features/rust:1",name:"Rust"},{category:"language",description:"Java runtime and JDK via SDKMAN",id:"ghcr.io/devcontainers/features/java:1",name:"Java"},{category:"language",description:".NET SDK and runtime",id:"ghcr.io/devcontainers/features/dotnet:2",name:".NET"},{category:"tool",description:"Common utilities: zsh, Oh My Zsh, git, curl, etc.",id:"ghcr.io/devcontainers/features/common-utils:2",name:"Common Utilities"},{category:"tool",description:"Git version control",id:"ghcr.io/devcontainers/features/git:1",name:"Git"},{category:"tool",description:"Git Large File Storage support",id:"ghcr.io/devcontainers/features/git-lfs:1",name:"Git LFS"},{category:"tool",description:"GitHub CLI for repository management",id:"ghcr.io/devcontainers/features/github-cli:1",name:"GitHub CLI"},{category:"tool",description:"Run Docker containers inside the dev container",id:"ghcr.io/devcontainers/features/docker-in-docker:2",name:"Docker-in-Docker"},{category:"tool",description:"Access host Docker daemon from inside the container",id:"ghcr.io/devcontainers/features/docker-outside-of-docker:1",name:"Docker-from-Docker"},{category:"tool",description:"kubectl, Helm, and Minikube for Kubernetes",id:"ghcr.io/devcontainers/features/kubectl-helm-minikube:1",name:"Kubernetes Tools"},{category:"tool",description:"Infrastructure as code with Terraform",id:"ghcr.io/devcontainers/features/terraform:1",name:"Terraform"},{category:"tool",description:"Nix package manager",id:"ghcr.io/devcontainers/features/nix:1",name:"Nix"},{category:"tool",description:"SSH server for remote connections to the container",id:"ghcr.io/devcontainers/features/sshd:1",name:"SSH Server"},{category:"cloud",description:"Amazon Web Services CLI v2",id:"ghcr.io/devcontainers/features/aws-cli:1",name:"AWS CLI"},{category:"cloud",description:"Microsoft Azure CLI",id:"ghcr.io/devcontainers/features/azure-cli:1",name:"Azure CLI"},{category:"cloud",description:"Google Cloud Platform CLI",id:"ghcr.io/devcontainers/features/gcloud:1",name:"Google Cloud CLI"},{category:"database",description:"PostgreSQL client tools",id:"ghcr.io/devcontainers-extra/features/postgres-client:1",name:"PostgreSQL Client"},{category:"database",description:"Redis client tools",id:"ghcr.io/devcontainers-extra/features/redis-client:1",name:"Redis Client"}],de=i=>{if(!i)return je;const t=i.toLowerCase();return je.filter(n=>n.name.toLowerCase().includes(t)||n.id.toLowerCase().includes(t)||n.description.toLowerCase().includes(t))},ue=i=>{if(!i)return xe;const t=i.toLowerCase();return xe.filter(n=>n.name.toLowerCase().includes(t)||n.id.toLowerCase().includes(t)||n.description.toLowerCase().includes(t))},at=/^[a-z]$/i,dt=i=>{const t=i.codePointAt(0);return t!==void 0&&(t<32||t===127)},ut=(i,t)=>i.length===0||dt(i)?!1:t.ctrl&&t.meta?!at.test(i):!(t.ctrl||t.meta),ht=/\S+\s*$/,se=(i,t)=>i.length===0||!t?void 0:t.find(n=>n.startsWith(i))?.slice(i.length)??void 0,ke=-1,mt=(i,t,n,c)=>t.leftArrow?Math.max(0,n-1):t.home||t.ctrl&&i==="a"?0:t.end||t.ctrl&&i==="e"?c:ke,gt=(i,t,n,c)=>{if(t.backspace&&c>0)return[n.slice(0,c-1)+n.slice(c),c-1];if(t.delete&&c<n.length)return[n.slice(0,c)+n.slice(c+1),c];if(t.ctrl&&i==="u")return[n.slice(c),0];if(t.ctrl&&i==="k")return[n.slice(0,c),c];if(t.ctrl&&i==="w"){const l=n.slice(0,c).replace(ht,"");return[l+n.slice(c),l.length]}};function he({defaultValue:i="",isDisabled:t=!1,mask:n=!1,onChange:c,onSubmit:l,placeholder:r,suggestions:a}){const[m,f]=p.useState(i),[g,v]=p.useState(i.length),x=p.useRef(m);x.current=m;const b=p.useRef(g);b.current=g;const y=p.useRef(c);y.current=c;const D=p.useRef(l);D.current=l;const k=se(m,a),M=p.useCallback((T,I)=>{const{current:E}=b,S=x.current;if(I.return){const w=se(S,a),C=w?S+w:S;w&&(f(C),v(C.length),y.current?.(C)),D.current?.(C);return}if(I.escape)return;if(I.rightArrow){const w=se(S,a);if(E===S.length&&w){const C=S+w;f(C),v(C.length),y.current?.(C);return}v(Math.min(S.length,E+1));return}const A=mt(T,I,E,S.length);if(A!==ke){v(A);return}const H=gt(T,I,S,E);if(H){const[w,C]=H;f(w),v(C),y.current?.(w);return}if(ut(T,I)){const w=S.slice(0,E)+T+S.slice(E);f(w),v(E+T.length),y.current?.(w)}},[a]);W(M,{isActive:!t});const F=n?"*".repeat(m.length):m,U=F.slice(0,g),X=F[g],Q=F.slice(g+1);return t?e.jsx(s,{children:e.jsx(o,{dimColor:!0,children:F||r||""})}):m.length===0&&r?e.jsxs(s,{children:[e.jsx(o,{dimColor:!0,inverse:!0,children:r[0]}),e.jsx(o,{dimColor:!0,children:r.slice(1)})]}):e.jsxs(s,{children:[e.jsxs(o,{children:[U,e.jsx(o,{inverse:!0,children:X??" "}),Q]}),k?e.jsx(o,{dimColor:!0,children:k}):void 0]})}const Ee=["dockerComposeFile","service"],ft={dockerComposeFile:"Compose File",service:"Service"},ve={dockerComposeFile:"docker-compose.yml",service:"app"},pt={dockerComposeFile:"Path to Docker Compose file (relative to .devcontainer/)",service:"Which service in the compose file to connect the IDE to"},xt=({config:i,fieldEditing:t,fieldIndex:n,onUpdate:c})=>{const l=!!i.dockerComposeFile,r=!!(i.image||i.build);return e.jsxs(s,{flexDirection:"column",paddingX:1,children:[e.jsx(s,{marginBottom:1,children:e.jsx(o,{bold:!0,color:"cyan",children:"Docker Compose Integration"})}),r&&l&&e.jsx(s,{marginBottom:1,children:e.jsx(o,{color:"yellow",children:"Note: When using Docker Compose, the image/build settings in General are ignored."})}),Ee.map((a,m)=>{const f=m===n,g=i[a]??"",v=Array.isArray(i[a])?i[a].join(", "):g;return e.jsxs(s,{flexDirection:"column",marginBottom:1,children:[e.jsxs(s,{children:[e.jsx(s,{width:20,children:e.jsxs(o,{bold:f,color:f?"cyan":"white",children:[f?"❯ ":" ",ft[a],":"]})}),e.jsx(s,{flexGrow:1,children:f&&t?e.jsx(he,{defaultValue:v,onChange:x=>{c({[a]:x||void 0})},placeholder:ve[a]}):e.jsx(o,{color:v?"white":"gray",children:v||ve[a]})})]}),e.jsx(s,{paddingLeft:4,children:e.jsx(o,{dimColor:!0,children:pt[a]})})]},a)}),e.jsx(s,{marginTop:1,children:e.jsxs(o,{dimColor:!0,children:[e.jsx(o,{bold:!0,color:"white",children:"Enter"})," ","edit field"," ",e.jsx(o,{bold:!0,color:"white",children:"↑↓"})," ","navigate"," ",e.jsx(o,{bold:!0,color:"white",children:"Esc"})," ","stop editing"]})})]})},jt=Ee.length,vt=({config:i,fieldIndex:t})=>{const n=i.containerEnv??{},c=i.remoteEnv??{},l=Object.keys(n),r=Object.keys(c),a=l.length,m=l.length+1,f=m+r.length,g=t<=a,v=t>a;return e.jsxs(s,{flexDirection:"column",paddingX:1,children:[e.jsxs(s,{borderColor:g?"cyan":"gray",borderStyle:"single",flexDirection:"column",paddingX:1,paddingY:0,children:[e.jsxs(s,{flexShrink:0,marginBottom:l.length>0?1:0,children:[e.jsx(o,{bold:!0,color:g?"cyan":"white",children:"containerEnv"}),e.jsx(o,{dimColor:!0,children:" — baked into the container image"})]}),l.map((x,b)=>{const y=b===t;return e.jsx(s,{flexShrink:0,children:e.jsxs(o,{color:y?"cyan":void 0,inverse:y,wrap:"truncate",children:[y?" ❯ ":" ",e.jsx(o,{bold:!0,children:x}),e.jsx(o,{dimColor:!0,children:" = "}),e.jsx(o,{children:n[x]})]})},x)}),e.jsx(s,{flexShrink:0,marginTop:l.length>0?1:0,children:e.jsxs(o,{color:t===a?"cyan":"gray",inverse:t===a,children:[" ","+ Add variable..."]})})]}),e.jsxs(s,{borderColor:v?"cyan":"gray",borderStyle:"single",flexDirection:"column",marginTop:1,paddingX:1,paddingY:0,children:[e.jsxs(s,{flexShrink:0,marginBottom:r.length>0?1:0,children:[e.jsx(o,{bold:!0,color:v?"cyan":"white",children:"remoteEnv"}),e.jsx(o,{dimColor:!0,children:" — set at runtime by the IDE"})]}),r.map((x,b)=>{const D=m+b===t;return e.jsx(s,{flexShrink:0,children:e.jsxs(o,{color:D?"cyan":void 0,inverse:D,wrap:"truncate",children:[D?" ❯ ":" ",e.jsx(o,{bold:!0,children:x}),e.jsx(o,{dimColor:!0,children:" = "}),e.jsx(o,{children:c[x]})]})},x)}),e.jsx(s,{flexShrink:0,marginTop:r.length>0?1:0,children:e.jsxs(o,{color:t===f?"cyan":"gray",inverse:t===f,children:[" ","+ Add variable..."]})})]}),e.jsx(s,{flexShrink:0,marginTop:1,children:e.jsxs(o,{dimColor:!0,wrap:"truncate",children:[e.jsx(o,{bold:!0,color:"white",children:"a"}),"/",e.jsx(o,{bold:!0,color:"white",children:"Enter"})," ","add on + row"," ",e.jsx(o,{bold:!0,color:"white",children:"d"})," ","remove"," ",e.jsx(o,{bold:!0,color:"white",children:"↑↓"})," ","navigate"]})})]})},bt=i=>{const t=Object.keys(i.containerEnv??{}).length,n=Object.keys(i.remoteEnv??{}).length;return t+1+n+1},wt=({config:i,fieldIndex:t,scrollOffset:n,searchText:c,viewportHeight:l})=>{const r=p.useMemo(()=>new Set(i.customizations?.vscode?.extensions),[i.customizations?.vscode?.extensions]),a=p.useMemo(()=>ue(c),[c]),m=a.length,f=m>l&&l>0;return e.jsxs(s,{flexDirection:"column",flexGrow:1,children:[e.jsxs(s,{flexShrink:0,gap:1,paddingX:1,children:[e.jsxs(o,{bold:!0,color:"cyan",children:[r.size," ","selected"]}),c&&e.jsxs(o,{dimColor:!0,children:["— filter:"," ",e.jsx(o,{color:"yellow",children:c})," ","(",a.length," ","results)"]})]}),e.jsxs(s,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[e.jsx(s,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:e.jsx(s,{flexDirection:"column",marginTop:-n,children:a.map((g,v)=>{const x=v===t,b=r.has(g.id);return e.jsxs(s,{flexShrink:0,height:1,children:[e.jsx(o,{children:x?">":" "}),e.jsxs(o,{color:b?"white":"gray",children:[" ",b?"☑":"☐"," "]}),e.jsx(s,{flexGrow:1,children:e.jsxs(o,{bold:x,inverse:x,wrap:"truncate",children:[g.name,e.jsxs(o,{dimColor:!0,children:[" ","-",g.id]})]})})]},g.id)})})}),f&&e.jsx(s,{flexShrink:0,marginLeft:1,marginRight:1,children:e.jsx(Ce,{contentHeight:m,placement:"inset",scrollOffset:n,style:"block",viewportHeight:l})})]}),a.length===0&&e.jsx(s,{paddingX:1,children:e.jsx(o,{dimColor:!0,children:"No extensions match the search."})})]})},yt=({config:i,fieldIndex:t,scrollOffset:n,searchText:c,viewportHeight:l})=>{const r=p.useMemo(()=>new Set(Object.keys(i.features??{})),[i.features]),a=p.useMemo(()=>de(c),[c]),m=a.length,f=m>l&&l>0;return e.jsxs(s,{flexDirection:"column",flexGrow:1,children:[e.jsxs(s,{flexShrink:0,gap:1,paddingX:1,children:[e.jsxs(o,{bold:!0,color:"cyan",children:[r.size," ","selected"]}),c&&e.jsxs(o,{dimColor:!0,children:["— filter:"," ",e.jsx(o,{color:"yellow",children:c})," ","(",a.length," ","results)"]})]}),e.jsxs(s,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[e.jsx(s,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:e.jsx(s,{flexDirection:"column",marginTop:-n,children:a.map((g,v)=>{const x=v===t,b=r.has(g.id);return e.jsxs(s,{flexShrink:0,height:1,children:[e.jsx(o,{children:x?">":" "}),e.jsxs(o,{color:b?"white":"gray",children:[" ",b?"☑":"☐"," "]}),e.jsx(s,{flexGrow:1,children:e.jsxs(o,{bold:x,inverse:x,wrap:"truncate",children:[g.name,e.jsxs(o,{dimColor:!0,children:[" ","-",g.description]})]})})]},g.id)})})}),f&&e.jsx(s,{flexShrink:0,marginLeft:1,marginRight:1,children:e.jsx(Ce,{contentHeight:m,placement:"inset",scrollOffset:n,style:"block",viewportHeight:l})})]}),a.length===0&&e.jsx(s,{paddingX:1,children:e.jsx(o,{dimColor:!0,children:"No features match the search."})})]})},ae=["name","image","workspaceFolder","workspaceMount","remoteUser","containerUser","shutdownAction"],St={containerUser:"Container User",image:"Image",name:"Name",remoteUser:"Remote User",shutdownAction:"Shutdown Action",workspaceFolder:"Workspace Folder",workspaceMount:"Workspace Mount"},be={containerUser:"root",image:"mcr.microsoft.com/devcontainers/javascript-node:22",name:"My Dev Container",remoteUser:"node",shutdownAction:"none | stopContainer",workspaceFolder:"/workspaces/${localWorkspaceFolderBasename}",workspaceMount:"source=${localWorkspaceFolder},target=...,type=bind"},te=["privileged","overrideCommand"],Ct={overrideCommand:"Override Command",privileged:"Privileged"},kt=ae.length+te.length,Et=({config:i,fieldEditing:t,fieldIndex:n,onUpdate:c})=>e.jsxs(s,{flexDirection:"column",paddingX:1,children:[e.jsx(s,{marginBottom:1,children:e.jsx(o,{bold:!0,color:"cyan",children:"General Configuration"})}),ae.map((l,r)=>{const a=r===n,m=i[l]??"";return e.jsxs(s,{marginBottom:1,children:[e.jsx(s,{width:20,children:e.jsxs(o,{bold:a,color:a?"cyan":"white",children:[a?"❯ ":" ",St[l],":"]})}),e.jsx(s,{flexGrow:1,children:a&&t?e.jsx(he,{defaultValue:m,onChange:f=>{c({[l]:f})},placeholder:be[l]}):e.jsx(o,{color:m?"white":"gray",children:m||be[l]})})]},l)}),te.map((l,r)=>{const m=ae.length+r===n,f=i[l]??!1;return e.jsxs(s,{marginBottom:r<te.length-1?1:0,children:[e.jsx(s,{width:20,children:e.jsxs(o,{bold:m,color:m?"cyan":"white",children:[m?"❯ ":" ",Ct[l],":"]})}),e.jsx(s,{flexGrow:1,children:e.jsxs(o,{color:f?"green":"gray",children:[f?"yes":"no",m&&e.jsx(o,{dimColor:!0,children:" (Space to toggle)"})]})})]},l)}),e.jsx(s,{marginTop:1,children:e.jsxs(o,{dimColor:!0,children:[e.jsx(o,{bold:!0,color:"white",children:"Enter"})," ","edit field"," ",e.jsx(o,{bold:!0,color:"white",children:"Space"})," ","toggle"," ",e.jsx(o,{bold:!0,color:"white",children:"↑↓"})," ","navigate"," ",e.jsx(o,{bold:!0,color:"white",children:"Esc"})," ","stop editing"]})})]}),Ie=kt,ce=te,De=["postCreateCommand","postStartCommand","postAttachCommand","onCreateCommand"],It={onCreateCommand:"On Create",postAttachCommand:"Post Attach",postCreateCommand:"Post Create",postStartCommand:"Post Start"},Dt={onCreateCommand:"Runs once when the container is first created",postAttachCommand:"Runs each time the IDE attaches",postCreateCommand:"Runs after the container is created and workspace mounted",postStartCommand:"Runs each time the container starts"},Tt=({config:i,fieldEditing:t,fieldIndex:n,onSetCommand:c})=>e.jsxs(s,{flexDirection:"column",paddingX:1,children:[e.jsx(s,{marginBottom:1,children:e.jsx(o,{bold:!0,color:"cyan",children:"Lifecycle Commands"})}),De.map((l,r)=>{const a=r===n,m=i[l],f=Array.isArray(m)?m.join(" && "):m??"";return e.jsxs(s,{flexDirection:"column",marginBottom:1,children:[e.jsx(s,{children:e.jsxs(o,{bold:a,color:a?"cyan":"white",children:[a?"❯ ":" ",It[l]]})}),e.jsx(s,{paddingLeft:4,children:e.jsx(o,{dimColor:!0,children:Dt[l]})}),e.jsx(s,{paddingLeft:4,children:a&&t?e.jsx(he,{defaultValue:f,onChange:g=>{c(l,g)},placeholder:"e.g. npm install"}):e.jsx(o,{color:f?"green":"gray",children:f||"(not set)"})})]},l)}),e.jsx(s,{marginTop:1,children:e.jsxs(o,{dimColor:!0,children:[e.jsx(o,{bold:!0,color:"white",children:"Enter"})," ","edit command"," ",e.jsx(o,{bold:!0,color:"white",children:"↑↓"})," ","navigate"," ",e.jsx(o,{bold:!0,color:"white",children:"Esc"})," ","stop editing"]})})]}),At=De.length,we=i=>typeof i=="string"?i:`[${i.type}] ${i.source} → ${i.target}`,Lt=({addingMount:i,config:t,detectedPm:n,fieldIndex:c,mountPhase:l,mountSource:r,mountTarget:a,mountType:m,suggestedMounts:f})=>{const g=t.mounts??[];return e.jsxs(s,{flexDirection:"column",paddingX:1,children:[e.jsxs(s,{flexShrink:0,gap:1,paddingX:1,children:[e.jsxs(o,{bold:!0,color:"cyan",children:[g.length," ","mounts"]}),n&&e.jsxs(o,{dimColor:!0,children:["— detected:"," ",e.jsx(o,{color:"white",children:n})]})]}),f.length>0&&!i&&e.jsxs(s,{borderColor:"yellow",borderStyle:"single",flexDirection:"column",marginBottom:1,marginTop:1,paddingX:1,children:[e.jsxs(s,{flexShrink:0,children:[e.jsx(o,{bold:!0,color:"yellow",children:"Suggested mounts"}),e.jsxs(o,{dimColor:!0,children:[" ","— press"," ",e.jsx(o,{bold:!0,color:"white",children:"A"})," ","to add all"]})]}),f.map((v,x)=>e.jsx(s,{flexShrink:0,children:e.jsxs(o,{dimColor:!0,wrap:"truncate",children:[" + ",we(v)]})},`suggestion-${String(x)}`))]}),g.length>0&&e.jsx(s,{flexDirection:"column",marginBottom:1,children:g.map((v,x)=>{const b=x===c;return e.jsxs(s,{flexShrink:0,height:1,children:[e.jsx(o,{children:b?">":" "}),e.jsx(s,{flexGrow:1,children:e.jsxs(o,{bold:b,inverse:b,wrap:"truncate",children:[" ",we(v)]})})]},`mount-${String(x)}`)})}),!i&&e.jsx(s,{flexShrink:0,children:e.jsxs(o,{color:c===g.length?"cyan":"gray",inverse:c===g.length,children:[" ","+ Add mount..."]})}),i&&e.jsxs(s,{borderColor:"cyan",borderStyle:"single",flexDirection:"column",marginTop:1,paddingX:1,children:[e.jsx(s,{flexShrink:0,marginBottom:1,children:e.jsx(o,{bold:!0,color:"cyan",children:"New Mount"})}),e.jsxs(s,{flexShrink:0,children:[e.jsx(s,{width:12,children:e.jsxs(o,{bold:l==="source",color:l==="source"?"cyan":"white",children:[l==="source"?"❯ ":" ","Source:"]})}),e.jsx(o,{color:r?"yellow":"gray",children:r||(l==="source"?"_":"(type source, Enter to continue)")})]}),e.jsxs(s,{flexShrink:0,children:[e.jsx(s,{width:12,children:e.jsxs(o,{bold:l==="target",color:l==="target"?"cyan":"white",children:[l==="target"?"❯ ":" ","Target:"]})}),e.jsx(o,{color:a?"yellow":"gray",children:a||(l==="target"?"_":"/container/path")})]}),e.jsxs(s,{flexShrink:0,children:[e.jsx(s,{width:12,children:e.jsxs(o,{bold:l==="type",color:l==="type"?"cyan":"white",children:[l==="type"?"❯ ":" ","Type:"]})}),l==="type"?e.jsxs(o,{children:[e.jsx(o,{bold:m==="volume",color:m==="volume"?"cyan":"gray",children:"[1] volume"})," ",e.jsx(o,{bold:m==="bind",color:m==="bind"?"cyan":"gray",children:"[2] bind"})," ",e.jsx(o,{bold:m==="tmpfs",color:m==="tmpfs"?"cyan":"gray",children:"[3] tmpfs"})]}):e.jsx(o,{color:"gray",children:m})]}),e.jsx(s,{flexShrink:0,marginTop:1,children:e.jsx(o,{dimColor:!0,wrap:"truncate",children:l==="type"?"1/2/3 select type, Enter confirm, Esc cancel":"Type text, Enter next step, Esc cancel"})})]}),g.length===0&&!i&&f.length===0&&e.jsx(s,{marginTop:1,children:e.jsx(o,{dimColor:!0,children:"Tip: Use volume mounts for node_modules and caches to improve performance."})})]})},Ft=({addingPort:i,addPortValue:t,config:n,fieldIndex:c})=>{const l=n.forwardPorts??[],r=c===l.length;return e.jsxs(s,{flexDirection:"column",paddingX:1,children:[e.jsxs(s,{marginBottom:1,children:[e.jsx(o,{bold:!0,color:"cyan",children:"Forwarded Ports"}),e.jsxs(o,{dimColor:!0,children:[" ","(",l.length," ","ports)"]})]}),l.map((a,m)=>{const f=m===c;return e.jsx(s,{children:e.jsxs(o,{color:f?"cyan":void 0,inverse:f,children:[" ",String(a)]})},`port-${String(a)}`)}),e.jsx(s,{marginTop:l.length>0?1:0,children:e.jsxs(o,{color:r?"cyan":"gray",inverse:r,children:[" ",r&&i?e.jsxs(o,{children:["Enter port:"," ",e.jsx(o,{color:"yellow",children:t||"_"})]}):"+ Add port..."]})}),e.jsx(s,{marginTop:1,children:e.jsxs(o,{dimColor:!0,children:[e.jsx(o,{bold:!0,color:"white",children:"Enter"})," ",r?"type port number, Enter to confirm":"select"," ",e.jsx(o,{bold:!0,color:"white",children:"d"})," ","remove selected"," ",e.jsx(o,{bold:!0,color:"white",children:"↑↓"})," ","navigate"]})})]})},Ot=({focused:i,hadComments:t,jsonPreview:n,mode:c,scrollRef:l})=>e.jsxs(s,{borderColor:i?"cyan":"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,children:[e.jsxs(s,{flexShrink:0,paddingX:1,children:[e.jsx(o,{bold:!0,color:i?"cyan":"white",children:"Preview"}),e.jsxs(o,{dimColor:!0,children:[" ","(",c==="create"?"new":"edit",")"]})]}),t&&c==="edit"&&e.jsx(s,{flexShrink:0,paddingX:1,children:e.jsx(o,{color:"yellow",children:"Comments will not be preserved."})}),e.jsx(ze,{flexGrow:1,ref:l,scrollbar:!0,scrollbarColor:"gray",children:n.split(`
|
|
3
|
+
`).map((r,a)=>e.jsx(o,{color:"green",children:r},`line-${String(a)}`))})]}),Pt=i=>{const t=[],n=[],c=[];if(!i.image&&!i.build&&!i.dockerComposeFile&&t.push({field:"image",message:'One of "image", "build", or "dockerComposeFile" is required'}),i.build&&(i.image&&n.push({field:"image",message:'Both "image" and "build" are set; "build" takes precedence'}),i.build.dockerfile||t.push({field:"build.dockerfile",message:'"build" requires a "dockerfile" path'})),i.dockerComposeFile&&!i.service&&t.push({field:"service",message:'"service" is required when using "dockerComposeFile"'}),i.features!==void 0&&(typeof i.features!="object"||Array.isArray(i.features))&&t.push({field:"features",message:'"features" must be an object mapping feature IDs to options'}),i.forwardPorts)if(Array.isArray(i.forwardPorts))for(const[l,r]of i.forwardPorts.entries())typeof r=="number"&&(r<1||r>65535)&&t.push({field:"forwardPorts",message:`Invalid port ${String(r)} at index ${String(l)}`});else t.push({field:"forwardPorts",message:'"forwardPorts" must be an array'});return i.customizations?.vscode?.extensions&&!Array.isArray(i.customizations.vscode.extensions)&&t.push({field:"customizations.vscode.extensions",message:"Extensions must be an array"}),i.customizations?.vscode?.settings&&typeof i.customizations.vscode.settings!="object"&&t.push({field:"customizations.vscode.settings",message:"Settings must be an object"}),i.name||c.push({field:"name",message:"Consider adding a name for better identification"}),(!i.features||Object.keys(i.features).length===0)&&c.push({field:"features",message:"Consider adding features for common tools"}),(!i.customizations?.vscode?.extensions||i.customizations.vscode.extensions.length===0)&&c.push({field:"extensions",message:"Consider adding VS Code extensions for your stack"}),i.privileged&&n.push({field:"privileged",message:"Running in privileged mode is a security risk"}),{errors:t,suggestions:c,valid:t.length===0,warnings:n}},ye=80,Se=15,Mt=120,Te=[{description:"Container name, base image, workspace folder, and user",id:"general",label:"General"},{description:"Installable tools and runtimes (Node, Python, Docker, etc.)",id:"features",label:"Features"},{description:"Ports to forward from the container to your host",id:"ports",label:"Ports"},{description:"Commands to run at different stages of the container lifecycle",id:"lifecycle",label:"Lifecycle"},{description:"VS Code extensions to auto-install in the container",id:"extensions",label:"Extensions"},{description:"Environment variables for the container and IDE",id:"environment",label:"Env"},{description:"Volume and bind mounts for persistent data and caches",id:"mounts",label:"Mounts"},{description:"Docker Compose integration for multi-container setups",id:"compose",label:"Compose"}],Nt=new Map(Te.map(i=>[i.id,i.description])),Rt=(i,t,n,c)=>{switch(i){case"compose":return jt;case"environment":return bt(t);case"extensions":return ue(c).length;case"features":return de(n).length;case"general":return Ie;case"lifecycle":return At;case"mounts":return(t.mounts?.length??0)+1;case"ports":return(t.forwardPorts?.length??0)+1;default:return 0}},_t=({onSave:i,store:t})=>{const{exit:n}=Ge(),{columns:c,rows:l}=$e(),r=p.useSyncExternalStore(t.subscribe,t.getSnapshot),[a,m]=p.useState(!1),[f,g]=p.useState(!1),[v,x]=p.useState(!1),[b,y]=p.useState(null),[D,k]=p.useState("editor"),[M,F]=p.useState(0),[U,X]=p.useState(!1),[Q,T]=p.useState(""),[I,E]=p.useState(null),[S,A]=p.useState(""),[H,w]=p.useState(""),[C,B]=p.useState("key"),[oe,Z]=p.useState(!1),[re,z]=p.useState(""),[ne,G]=p.useState(""),[me,K]=p.useState("volume"),[O,$]=p.useState("source"),ie=p.useRef(null),R=p.useRef(null),N=p.useRef(null),ee=p.useRef(!0);p.useEffect(()=>(ee.current=!0,()=>{ee.current=!1,N.current&&clearTimeout(N.current)}),[]);const ge=Rt(r.section,r.config,r.featureSearch,r.extensionSearch),q=Math.max(1,l-9);p.useEffect(()=>{r.section!=="features"&&r.section!=="extensions"||F(u=>r.fieldIndex>=u+q?r.fieldIndex-q+1:r.fieldIndex<u?r.fieldIndex:u)},[r.fieldIndex,r.section,q]),p.useEffect(()=>{F(0)},[r.section,r.featureSearch,r.extensionSearch]);const Ae=p.useCallback(()=>{const u=t.cleanConfig(),h=Pt(u);if(!h.valid){const j=h.errors[0];y(j?`Error: ${j.message}`:"Validation failed"),N.current&&clearTimeout(N.current),N.current=setTimeout(()=>{ee.current&&y(null)},3e3);return}i(u),t.markClean();const d=h.warnings.length;y(d>0?`Saved! (${String(d)} warning${d>1?"s":""})`:"Saved!"),N.current&&clearTimeout(N.current),N.current=setTimeout(()=>{ee.current&&y(null)},2e3)},[i,t]);W((u,h)=>{if(h.downArrow||u==="j")t.setTemplateIndex(r.templateIndex+1);else if(h.upArrow||u==="k")t.setTemplateIndex(r.templateIndex-1);else if(h.return){const d=V[r.templateIndex];d&&t.applyTemplate(d.id)}else h.escape&&t.dismissTemplateSelector()},{isActive:r.showTemplateSelector}),W((u,h)=>{if(h.escape){X(!1),T("");return}if(h.return){const d=Number.parseInt(Q,10);!Number.isNaN(d)&&d>0&&d<=65535&&t.addPort(d),X(!1),T("");return}if(h.backspace){T(d=>d.slice(0,-1));return}u&&/^\d$/u.test(u)&&T(d=>d+u)},{isActive:U}),W((u,h)=>{if(h.escape){E(null),A(""),w(""),B("key");return}if(h.return){if(C==="key"&&S){B("value");return}if(C==="value"&&S){t.addEnvVar(I,S,H),E(null),A(""),w(""),B("key");return}}if(h.backspace){C==="key"?A(d=>d.slice(0,-1)):w(d=>d.slice(0,-1));return}u&&!h.ctrl&&!h.meta&&(C==="key"?A(d=>d+u):w(d=>d+u))},{isActive:I!==null}),W((u,h)=>{if(h.escape){Z(!1),z(""),G(""),$("source");return}if(h.return){if(O==="source"&&re){$("target");return}if(O==="target"&&ne){$("type");return}if(O==="type"){t.addMount({source:re,target:ne,type:me}),Z(!1),z(""),G(""),$("source");return}}if(O==="type"){switch(u){case"1":{K("volume");break}case"2":{K("bind");break}case"3":{K("tmpfs");break}}return}if(h.backspace){O==="source"?z(d=>d.slice(0,-1)):O==="target"&&G(d=>d.slice(0,-1));return}u&&!h.ctrl&&!h.meta&&(O==="source"?z(d=>d+u):O==="target"&&G(d=>d+u))},{isActive:oe}),W((u,h)=>{if(u==="c"&&h.ctrl){n();return}if(!f){if(a){h.escape||u==="?"?m(!1):h.downArrow||u==="j"?ie.current?.scrollBy(1):h.upArrow||u==="k"?ie.current?.scrollBy(-1):u==="q"&&(m(!1),g(!0));return}if(v){if(h.escape){x(!1),r.section==="features"?t.setFeatureSearch(""):t.setExtensionSearch("");return}if(h.return){x(!1);return}if(h.backspace){r.section==="features"?t.setFeatureSearch(r.featureSearch.slice(0,-1)):t.setExtensionSearch(r.extensionSearch.slice(0,-1));return}if(u&&!h.ctrl&&!h.meta){r.section==="features"?t.setFeatureSearch(r.featureSearch+u):t.setExtensionSearch(r.extensionSearch+u);return}return}if(r.fieldEditing){if(h.escape){t.setFieldEditing(!1);return}if(h.return){t.setFieldEditing(!1);return}return}if(u==="?"){m(!0);return}if(u==="q"){r.isDirty?g(!0):n();return}if(u==="s"){Ae();return}if(h.tab){k(d=>d==="editor"?"preview":"editor");return}if(D==="preview"){if(h.downArrow||u==="j"){R.current?.scrollBy(1);return}if(h.upArrow||u==="k"){R.current?.scrollBy(-1);return}if(h.pageDown){R.current?.scrollBy(10);return}if(h.pageUp){R.current?.scrollBy(-10);return}if(h.home){R.current?.scrollToTop();return}if(h.end){R.current?.scrollToBottom();return}h.escape&&k("editor");return}if(h.downArrow||u==="j"){ge>0&&t.setFieldIndex(Math.min(r.fieldIndex+1,ge-1));return}if(h.upArrow||u==="k"){t.setFieldIndex(Math.max(r.fieldIndex-1,0));return}if(h.return){switch(r.section){case"compose":case"general":case"lifecycle":{t.setFieldEditing(!0);break}case"environment":{const d=Object.keys(r.config.containerEnv??{}).length,j=d,P=d+1+Object.keys(r.config.remoteEnv??{}).length;r.fieldIndex===j?(E("container"),A(""),w(""),B("key")):r.fieldIndex===P&&(E("remote"),A(""),w(""),B("key"));break}case"mounts":{const d=r.config.mounts??[];r.fieldIndex===d.length&&(Z(!0),z(""),G(""),K("volume"),$("source"));break}case"ports":{const d=r.config.forwardPorts??[];r.fieldIndex===d.length&&(X(!0),T(""));break}}return}if(u===" "){switch(r.section){case"extensions":{const j=ue(r.extensionSearch)[r.fieldIndex];j&&t.toggleExtension(j.id);break}case"features":{const j=de(r.featureSearch)[r.fieldIndex];j&&t.toggleFeature(j.id);break}case"general":{const d=Ie-ce.length,j=r.fieldIndex-d;if(j>=0&&j<ce.length){const P=ce[j];t.updateConfig({[P]:!r.config[P]})}break}}return}if(u==="/"){(r.section==="features"||r.section==="extensions")&&x(!0);return}if(u==="A"&&r.section==="mounts"){t.applySuggestedMounts();return}if(u==="a"){if(r.section==="environment"){const d=Object.keys(r.config.containerEnv??{}).length,j=r.fieldIndex<=d?"container":"remote";E(j),A(""),w(""),B("key")}else r.section==="mounts"&&(Z(!0),z(""),G(""),K("volume"),$("source"));return}if(u==="d")switch(r.section){case"environment":{const d=Object.keys(r.config.containerEnv??{}),j=Object.keys(r.config.remoteEnv??{});if(r.fieldIndex<d.length)t.removeEnvVar("container",d[r.fieldIndex]),d.length===1||r.fieldIndex>=d.length-1&&t.setFieldIndex(d.length-2);else{const P=r.fieldIndex-d.length-1;P>=0&&P<j.length&&(t.removeEnvVar("remote",j[P]),j.length===1||P>=j.length-1&&t.setFieldIndex(r.fieldIndex-1))}break}case"mounts":{const d=r.config.mounts??[];if(r.fieldIndex<d.length){t.removeMount(r.fieldIndex);const j=d.length-1;r.fieldIndex>=j&&j>0&&t.setFieldIndex(j-1)}break}case"ports":{const d=r.config.forwardPorts??[];if(r.fieldIndex<d.length){t.removePort(r.fieldIndex);const j=d.length-1;r.fieldIndex>=j&&j>0&&t.setFieldIndex(j-1)}break}}}},{isActive:!r.showTemplateSelector&&!U&&I===null&&!oe});const Le=p.useMemo(()=>t.getJsonPreview(),[r.config]);if(c<ye||l<Se)return e.jsx(s,{alignItems:"center",height:l,justifyContent:"center",width:c,children:e.jsxs(o,{color:"yellow",children:["Terminal too small (",c,"x",l,"), need"," ",ye,"x",Se]})});if(r.showTemplateSelector)return e.jsx(s,{alignItems:"center",flexDirection:"column",height:l,justifyContent:"center",width:c,children:e.jsxs(s,{borderColor:"cyan",borderStyle:"round",flexDirection:"column",paddingX:2,paddingY:1,width:60,children:[e.jsx(s,{justifyContent:"center",marginBottom:1,children:e.jsx(o,{bold:!0,color:"cyan",children:"Select a Template"})}),V.map((u,h)=>{const d=h===r.templateIndex;return e.jsx(s,{children:e.jsxs(o,{color:d?"cyan":void 0,inverse:d,children:[d?" ❯ ":" ",e.jsx(o,{bold:d,children:u.name}),e.jsxs(o,{dimColor:!0,children:[" ","-",u.description]})]})},u.id)}),e.jsx(s,{justifyContent:"center",marginTop:1,children:e.jsxs(o,{dimColor:!0,children:[e.jsx(o,{bold:!0,color:"white",children:"↑↓"})," ","navigate"," ",e.jsx(o,{bold:!0,color:"white",children:"Enter"})," ","select"," ",e.jsx(o,{bold:!0,color:"white",children:"Esc"})," ","blank"]})})]})});let L;switch(r.section){case"compose":{L=e.jsx(xt,{config:r.config,fieldEditing:r.fieldEditing,fieldIndex:r.fieldIndex,onUpdate:u=>{t.updateConfig(u)}});break}case"environment":{L=e.jsxs(s,{flexDirection:"column",children:[e.jsx(vt,{config:r.config,fieldIndex:r.fieldIndex}),I!==null&&e.jsx(s,{marginTop:1,paddingX:1,children:e.jsxs(o,{color:"cyan",children:["Add"," ",I," ","env:"," ",C==="key"?e.jsxs(o,{children:["key=",e.jsx(o,{color:"yellow",children:S||"_"})," ","(Enter to set value)"]}):e.jsxs(o,{children:[S,"=",e.jsx(o,{color:"yellow",children:H||"_"})," ","(Enter to confirm, Esc to cancel)"]})]})})]});break}case"extensions":{L=e.jsx(wt,{config:r.config,fieldIndex:r.fieldIndex,scrollOffset:M,searchText:r.extensionSearch,viewportHeight:q});break}case"features":{L=e.jsx(yt,{config:r.config,fieldIndex:r.fieldIndex,scrollOffset:M,searchText:r.featureSearch,viewportHeight:q});break}case"general":{L=e.jsx(Et,{config:r.config,fieldEditing:r.fieldEditing,fieldIndex:r.fieldIndex,onUpdate:u=>{t.updateConfig(u)}});break}case"lifecycle":{L=e.jsx(Tt,{config:r.config,fieldEditing:r.fieldEditing,fieldIndex:r.fieldIndex,onSetCommand:(u,h)=>{t.setLifecycleCommand(u,h)}});break}case"mounts":{L=e.jsx(Lt,{addingMount:oe,config:r.config,detectedPm:r.detectedPm,fieldIndex:r.fieldIndex,mountPhase:O,mountSource:re,mountTarget:ne,mountType:me,suggestedMounts:r.suggestedMounts});break}case"ports":{L=e.jsx(Ft,{addingPort:U,addPortValue:Q,config:r.config,fieldIndex:r.fieldIndex});break}default:L=e.jsx(o,{children:"Unknown section"})}const Fe=e.jsxs(s,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",flexShrink:0,children:[e.jsxs(s,{flexGrow:1,flexWrap:"wrap",gap:2,paddingX:1,children:[e.jsxs(s,{gap:1,children:[e.jsx(o,{bold:!0,color:"white",children:"q"}),e.jsx(o,{dimColor:!0,children:"QUIT"})]}),e.jsxs(s,{gap:1,children:[e.jsx(o,{bold:!0,color:"white",children:"?"}),e.jsx(o,{dimColor:!0,children:"HELP"})]}),e.jsxs(s,{gap:1,children:[e.jsx(o,{bold:!0,color:"white",children:"↑↓"}),e.jsx(o,{dimColor:!0,children:"NAV"})]}),(r.section==="features"||r.section==="extensions")&&e.jsxs(s,{gap:1,children:[e.jsx(o,{bold:!0,color:"white",children:"Space"}),e.jsx(o,{dimColor:!0,children:"CHECK"})]}),e.jsxs(s,{gap:1,children:[e.jsx(o,{bold:!0,color:"white",children:"←→"}),e.jsx(o,{dimColor:!0,children:"TABS"})]}),e.jsxs(s,{gap:1,children:[e.jsx(o,{bold:!0,color:"white",children:"Tab"}),e.jsx(o,{dimColor:!0,children:"PANEL"})]}),(r.section==="features"||r.section==="extensions")&&e.jsxs(s,{gap:1,children:[e.jsx(o,{bold:!0,color:"white",children:"/"}),e.jsx(o,{dimColor:!0,children:"FILTER"})]}),e.jsxs(s,{gap:1,children:[e.jsx(o,{bold:!0,color:"white",children:"s"}),e.jsx(o,{dimColor:!0,children:"SAVE"})]})]}),e.jsxs(s,{paddingX:1,children:[b&&e.jsxs(o,{color:b.startsWith("Error")?"red":"green",children:[b," "]}),r.isDirty&&e.jsx(o,{color:"yellow",children:"[modified]"}),!r.isDirty&&!b&&e.jsx(o,{dimColor:!0,children:"[saved]"})]})]}),Oe=e.jsxs(We,{footer:e.jsxs(o,{dimColor:!0,children:[e.jsx(o,{bold:!0,color:"white",children:"↑↓"})," ","scroll"," ",e.jsx(o,{bold:!0,color:"white",children:"?"}),"/",e.jsx(o,{bold:!0,color:"white",children:"Esc"})," ","close"]}),scrollRef:ie,title:"KEYBOARD SHORTCUTS",visible:a,width:56,children:[e.jsxs(s,{flexDirection:"column",marginBottom:1,children:[e.jsxs(s,{marginBottom:1,children:[e.jsx(o,{dimColor:!0,children:"── "}),e.jsx(o,{bold:!0,color:"white",children:"NAVIGATION"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"←→"}),e.jsx(o,{dimColor:!0,children:" Switch tabs"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"↑↓"}),"/",e.jsx(o,{bold:!0,color:"white",children:"j/k"}),e.jsx(o,{dimColor:!0,children:" Navigate within section"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"Tab"}),e.jsx(o,{dimColor:!0,children:" Switch editor/preview panel"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"Enter"}),e.jsx(o,{dimColor:!0,children:" Edit selected field"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"Esc"}),e.jsx(o,{dimColor:!0,children:" Stop editing / cancel"})]})]}),e.jsxs(s,{flexDirection:"column",marginBottom:1,children:[e.jsxs(s,{marginBottom:1,children:[e.jsx(o,{dimColor:!0,children:"── "}),e.jsx(o,{bold:!0,color:"white",children:"FEATURES / EXTENSIONS"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"Space"}),e.jsx(o,{dimColor:!0,children:" Toggle selection"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"/"}),e.jsx(o,{dimColor:!0,children:" Search / filter"})]})]}),e.jsxs(s,{flexDirection:"column",marginBottom:1,children:[e.jsxs(s,{marginBottom:1,children:[e.jsx(o,{dimColor:!0,children:"── "}),e.jsx(o,{bold:!0,color:"white",children:"LISTS (Ports, Mounts, Env)"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"a"}),e.jsx(o,{dimColor:!0,children:" Add new entry"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"d"}),e.jsx(o,{dimColor:!0,children:" Delete selected entry"})]})]}),e.jsxs(s,{flexDirection:"column",children:[e.jsxs(s,{marginBottom:1,children:[e.jsx(o,{dimColor:!0,children:"── "}),e.jsx(o,{bold:!0,color:"white",children:"ACTIONS"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"s"}),e.jsx(o,{dimColor:!0,children:" Save configuration"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"q"}),e.jsx(o,{dimColor:!0,children:" Quit"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"?"}),e.jsx(o,{dimColor:!0,children:" Toggle help"})]})]})]}),Pe=e.jsx(Ot,{focused:D==="preview",hadComments:r.hadComments,jsonPreview:Le,mode:r.mode,scrollRef:R}),fe=c>=Mt,Me=fe?Math.floor(c*.38):0;return e.jsxs(s,{flexDirection:"column",height:l,width:c,children:[e.jsxs(s,{flexShrink:0,gap:1,paddingX:1,children:[e.jsx(o,{bold:!0,inverse:!0,children:" VIS "}),e.jsxs(o,{wrap:"truncate",children:[r.mode==="create"?"Create":"Edit"," ","devcontainer"]})]}),e.jsx(s,{flexShrink:0,paddingX:1,paddingY:1,children:e.jsx(tt,{defaultValue:r.section,keyMap:{useNumbers:!1,useTab:!1},onChange:u=>{t.setSection(u),k("editor")},showIndex:!1,children:Te.map(({id:u,label:h})=>e.jsx(ot,{name:u,children:h},u))})}),e.jsx(s,{flexShrink:0,paddingRight:2,children:e.jsx(o,{dimColor:!0,wrap:"truncate",children:Nt.get(r.section)??""})}),e.jsxs(s,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[e.jsx(s,{borderColor:D==="editor"?"white":"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,overflow:"hidden",children:L}),fe&&e.jsx(s,{flexShrink:0,width:Me,children:Pe})]}),Fe,e.jsx(Ve,{autoExitSeconds:3,onCancel:()=>{g(!1)},visible:f}),Oe]})},Kt=async({logger:i,options:t,workspaceRoot:n})=>{if(!n)throw new Error("Could not determine workspace root. Run this command inside a monorepo or project directory.");const c=n,l=t.template,r=t.output,a=!!process.stdout.isTTY&&!Xe;let m=null;try{m=Ke(c).name}catch{}const f=nt(c);let g=f?.config??null;const v=f?.hadComments??!1;if(l&&!f){const k=V.find(M=>M.id===l);if(!k){const M=V.map(F=>F.id).join(", ");throw new Error(`Unknown template "${l}". Valid templates: ${M}`)}g=k.config}if(!a){g?i.info(JSON.stringify(g,null,2)):(i.error("No existing devcontainer.json found. Use --template to generate one in non-TTY mode."),process.exitCode=1);return}process.stdin.isTTY&&typeof process.stdin.setRawMode=="function"&&(process.stdin.setRawMode(!0),process.stdin.ref(),process.stdin.resume());const x=setInterval(()=>{},1e3),b=new lt(g,v,m);l&&!f&&b.dismissTemplateSelector();let y=null;if(await Ue(He.createElement(_t,{onSave:k=>{it(c,k,r),y=k},store:b}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit(),clearInterval(x),y){const k=r??".devcontainer/devcontainer.json";i.info(`DevContainer config saved to ${k}`)}};export{Kt as default};
|